1 #ifndef __XRDSYS_PLATFORM_H__
2 #define __XRDSYS_PLATFORM_H__
38 #include <sys/types.h>
39 #include <asm/param.h>
41 #define MAXNAMELEN NAME_MAX
44 #include <AvailabilityMacros.h>
45 #include <sys/types.h>
46 #define fdatasync(x) fsync(x)
47 #define MAXNAMELEN NAME_MAX
49 # define dirent64 dirent
52 #define off64_t int64_t
54 #if (!defined(MAC_OS_X_VERSION_10_5) || \
55 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
62 #include <sys/types.h>
66 #define posix_memalign(memp, algn, sz) \
67 ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
68 #define __USE_LEGACY_PROTOTYPES__ 1
71 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
75 #if !defined(__FreeBSD__)
76 #define F_DUP2FD F_DUPFD
80 #define STATFS_BUFF struct statfs
84 #define FLOCK_t struct flock
86 typedef off_t offset_t;
88 #define GTZ_NULL (struct timezone *)0
92 #define STATFS statvfs
93 #define STATFS_BUFF struct statvfs
97 #define SHMDT_t char *
99 #define FLOCK_t flock_t
101 #define GTZ_NULL (void *)0
107 #define SHMDT_t const void *
113 #include <AvailabilityMacros.h>
123 #define O_LARGEFILE 0
124 #define memalign(pgsz,amt) valloc(amt)
125 #define posix_memalign(memp, algn, sz) \
126 ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
127 #define SHMDT_t void *
129 #define EDEADLOCK EDEADLK
134 #define O_LARGEFILE 0
135 typedef off_t off64_t;
136 #define memalign(pgsz,amt) valloc(amt)
142 #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \
143 defined(__IEEE_BIG_ENDIAN) || \
144 (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN)
145 #define Xrd_Big_Endian
147 #define htonll(_x_) _x_
150 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
153 #define ntohll(_x_) _x_
156 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
159 #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || \
160 defined(__IEEE_LITTLE_ENDIAN) || \
161 (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)
162 #if !defined(__GNUC__) || defined(__APPLE__)
164 #if !defined(__sun) || (defined(__sun) && (!defined(_LP64) || defined(__SunOS_5_10)))
165 extern "C" unsigned long long Swap_n2hll(
unsigned long long x);
167 #define htonll(_x_) Swap_n2hll(_x_)
170 #define ntohll(_x_) Swap_n2hll(_x_)
177 #define htonll(_x_) __bswap_64(_x_)
180 #define ntohll(_x_) __bswap_64(_x_)
186 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
190 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
196 #error Unable to determine target architecture endianness!
202 {
extern size_t strlcpy(
char *dst,
const char *src,
size_t size);}
208 #if defined(__solaris__) && !defined(__linux__)
209 # if __GNUC__ >= 3 || __GNUC_MINOR__ >= 90
213 #if defined(__linux__)
214 # include <features.h>
215 # if __GNU_LIBRARY__ == 6
221 #if defined(__MACH__) && defined(__i386__)
224 #if defined(_AIX) || \
225 (defined(XR__SUNGCC3) && !defined(__arch64__))
226 # define SOCKLEN_t size_t
227 #elif defined(XR__GLIBC) || \
228 defined(__FreeBSD__) || \
229 (defined(XR__SUNGCC3) && defined(__arch64__)) || defined(__APPLE__) || \
230 (defined(__sun) && defined(_SOCKLEN_T))
232 # define SOCKLEN_t socklen_t
234 #elif !defined(SOCKLEN_t)
235 # define SOCKLEN_t int
239 #define PTR2INT(x) static_cast<int>((long long)x)
241 #define PTR2INT(x) int(x)
245 #include "XrdSys/XrdWin32.hh"
246 #define Netdata_t void *
247 #define Sokdata_t char *
248 #define IOV_INIT(data,dlen) dlen,data
249 #define MAKEDIR(path,mode) mkdir(path)
250 #define net_errno WSAGetLastError()
253 #define Netdata_t char *
254 #define Sokdata_t void *
255 #define IOV_INIT(data,dlen) data,dlen
256 #define MAKEDIR(path,mode) mkdir(path,mode)
257 #define net_errno errno
261 #define MAXNAMELEN 256
262 #define MAXPATHLEN 1024
264 #include <sys/param.h>
265 #if defined(__FreeBSD__)
266 #define MAXNAMELEN 256
271 #define XRDABS(x) (x < 0 ? -x : x)
273 #ifndef LT_MODULE_EXT
274 #define LT_MODULE_EXT ".so"
277 #endif // __XRDSYS_PLATFORM_H__