• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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 #ifndef PORTABILITY_H_included
18 #define PORTABILITY_H_included
19 
20 #include <byteswap.h>
21 #include <sys/sendfile.h>
22 #include <sys/statvfs.h>
23 
24 #include <netdb.h>
25 #if defined(__BIONIC__)
26 extern "C" int android_getaddrinfofornet(const char*, const char*, const struct addrinfo*, unsigned, unsigned, struct addrinfo**);
27 #else
android_getaddrinfofornet(const char * hostname,const char * servname,const struct addrinfo * hints,unsigned,unsigned,struct addrinfo ** res)28 static inline int android_getaddrinfofornet(const char* hostname, const char* servname,
29     const struct addrinfo* hints, unsigned /*netid*/, unsigned /*mark*/, struct addrinfo** res) {
30   return getaddrinfo(hostname, servname, hints, res);
31 }
32 #endif
33 
34 #if defined(__GLIBC__) && !defined(__LP64__)
35 
36 #include <unistd.h>
37 
38 // 32 bit GLIBC hardcodes a "long int" as the return type for
39 // TEMP_FAILURE_RETRY so the return value here gets truncated for
40 // functions that return 64 bit types.
41 #undef TEMP_FAILURE_RETRY
42 #define TEMP_FAILURE_RETRY(exp) ({         \
43     __typeof__(exp) _rc;                   \
44     do {                                   \
45         _rc = (exp);                       \
46     } while (_rc == -1 && errno == EINTR); \
47     _rc; })
48 
49 #endif  // __GLIBC__ && !__LP64__
50 
51 #endif  // PORTABILITY_H_included
52