1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #undef _GNU_SOURCE
18 #include <string.h>
19 
20 // At the time of writing, libcxx -- which is dragged in by gtest -- assumes
21 // declarations from glibc of things that aren't available without _GNU_SOURCE.
22 // This means we can't even build a test that directly calls the posix
23 // strerror_r.  Add a wrapper in a separate file that doesn't use any gtest.
24 // For glibc 2.15, the symbols in question are:
25 //   at_quick_exit, quick_exit, vasprintf, strtoll_l, strtoull_l, and strtold_l.
26 
posix_strerror_r(int errnum,char * buf,size_t buflen)27 int posix_strerror_r(int errnum, char* buf, size_t buflen) {
28   return strerror_r(errnum, buf, buflen);
29 }
30