1 #ifndef __XRDSYS_PLATFORM_H__
2 #define __XRDSYS_PLATFORM_H__
40 #include <sys/types.h>
41 #include <sys/param.h>
43 #define MAXNAMELEN NAME_MAX
47 #include <AvailabilityMacros.h>
48 #include <sys/types.h>
49 #include <sys/param.h>
50 #include <libkern/OSByteOrder.h>
51 #define fdatasync(x) fsync(x)
52 #define MAXNAMELEN NAME_MAX
54 # define dirent64 dirent
57 #define off64_t int64_t
59 #if (!defined(MAC_OS_X_VERSION_10_5) || \
60 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
67 #if defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
68 #include <sys/types.h>
69 #include <sys/param.h>
70 #define MAXNAMELEN NAME_MAX
74 #include <sys/types.h>
75 #include <sys/param.h>
81 #define MAXNAMELEN 255
82 #define MAXPATHLEN 4096
83 #define MAXHOSTNAMELEN 64
87 #define MAXNAMELEN 256
88 #define MAXPATHLEN 1024
93 #if defined(__solaris__) && defined(__SunOS_5_10)
94 #define posix_memalign(memp, algn, sz) \
95 ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
96 #define __USE_LEGACY_PROTOTYPES__ 1
99 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
103 #define STATFS statfs
104 #define STATFS_BUFF struct statfs
108 #define FLOCK_t struct flock
110 typedef off_t offset_t;
112 #define GTZ_NULL (struct timezone *)0
116 #define STATFS statvfs
117 #define STATFS_BUFF struct statvfs
121 #define SHMDT_t char *
123 #define FLOCK_t flock_t
125 #define GTZ_NULL (void *)0
131 #define SHMDT_t const void *
146 #define O_LARGEFILE 0
147 #define SHMDT_t void *
149 #define EDEADLOCK EDEADLK
154 #define O_LARGEFILE 0
155 typedef off_t off64_t;
158 #if defined(__APPLE__)
159 #define bswap_16 OSSwapInt16
160 #define bswap_32 OSSwapInt32
161 #define bswap_64 OSSwapInt64
164 static inline uint16_t
bswap(uint16_t x) {
return bswap_16(x); }
165 static inline uint32_t
bswap(uint32_t x) {
return bswap_32(x); }
166 static inline uint64_t
bswap(uint64_t x) {
return bswap_64(x); }
171 #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \
172 defined(__IEEE_BIG_ENDIAN) || \
173 (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN)
174 #define Xrd_Big_Endian
176 #define htonll(_x_) _x_
179 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
182 #define ntohll(_x_) _x_
185 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
188 #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || \
189 defined(__IEEE_LITTLE_ENDIAN) || \
190 (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)
191 #if !defined(__GNUC__) || defined(__APPLE__)
193 #if !defined(__sun) || (defined(__sun) && (!defined(_LP64) || defined(__SunOS_5_10)))
194 extern "C" unsigned long long Swap_n2hll(
unsigned long long x);
196 #define htonll(_x_) Swap_n2hll(_x_)
199 #define ntohll(_x_) Swap_n2hll(_x_)
206 #define htonll(_x_) __bswap_64(_x_)
209 #define ntohll(_x_) __bswap_64(_x_)
215 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
219 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
225 #error Unable to determine target architecture endianness!
231 {
extern size_t strlcpy(
char *dst,
const char *src,
size_t size);}
237 #if defined(__solaris__) && !defined(__linux__)
238 # if __GNUC__ >= 3 || __GNUC_MINOR__ >= 90
242 #if defined(__linux__)
243 # include <features.h>
244 # if __GNU_LIBRARY__ == 6
253 #if defined(_AIX) || \
254 (defined(XR__SUNGCC3) && !defined(__arch64__))
255 # define SOCKLEN_t size_t
256 #elif !defined(SOCKLEN_t)
257 # define SOCKLEN_t socklen_t
261 #define PTR2INT(x) static_cast<int>((long long)x)
263 #define PTR2INT(x) int(x)
267 #include "XrdSys/XrdWin32.hh"
268 #define Netdata_t void *
269 #define Sokdata_t char *
270 #define IOV_INIT(data,dlen) dlen,data
271 #define MAKEDIR(path,mode) mkdir(path)
272 #define CHMOD(path, mode) {}
273 #define net_errno WSAGetLastError()
276 #define Netdata_t char *
277 #define Sokdata_t void *
278 #define IOV_INIT(data,dlen) data,dlen
279 #define MAKEDIR(path,mode) mkdir(path,mode)
280 #define CHMOD(path, mode) chmod(path,mode)
281 #define net_errno errno
286 #define XRDABS(x) (x < 0 ? -x : x)
288 #ifndef LT_MODULE_EXT
289 #define LT_MODULE_EXT ".so"