00001 #ifndef __XRDSYS_PLATFORM_H__
00002 #define __XRDSYS_PLATFORM_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <stdlib.h>
00035 #ifdef __linux__
00036 #include <memory.h>
00037 #include <string.h>
00038 #include <sys/types.h>
00039 #include <asm/param.h>
00040 #include <byteswap.h>
00041 #define MAXNAMELEN NAME_MAX
00042 #endif
00043 #ifdef __APPLE__
00044 #include <AvailabilityMacros.h>
00045 #include <sys/types.h>
00046 #define fdatasync(x) fsync(x)
00047 #define MAXNAMELEN NAME_MAX
00048 #ifndef dirent64
00049 # define dirent64 dirent
00050 #endif
00051 #ifndef off64_t
00052 #define off64_t int64_t
00053 #endif
00054 #if (!defined(MAC_OS_X_VERSION_10_5) || \
00055 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
00056 #ifndef stat64
00057 # define stat64 stat
00058 #endif
00059 #endif
00060 #endif
00061 #ifdef __FreeBSD__
00062 #include <sys/types.h>
00063 #endif
00064
00065 #ifdef __solaris__
00066 #define posix_memalign(memp, algn, sz) \
00067 ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
00068 #define __USE_LEGACY_PROTOTYPES__ 1
00069 #endif
00070
00071 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
00072
00073 #define S_IAMB 0x1FF
00074
00075 #define F_DUP2FD F_DUPFD
00076
00077 #define STATFS statfs
00078 #define STATFS_BUFF struct statfs
00079
00080 #define FS_BLKFACT 4
00081
00082 #define FLOCK_t struct flock
00083
00084 typedef off_t offset_t;
00085
00086 #define GTZ_NULL (struct timezone *)0
00087
00088 #else
00089
00090 #define STATFS statvfs
00091 #define STATFS_BUFF struct statvfs
00092
00093 #define FS_BLKFACT 1
00094
00095 #define SHMDT_t char *
00096
00097 #define FLOCK_t flock_t
00098
00099 #define GTZ_NULL (void *)0
00100
00101 #endif
00102
00103 #ifdef __linux__
00104
00105 #define SHMDT_t const void *
00106 #endif
00107
00108
00109
00110 #ifdef __APPLE__
00111 #include <AvailabilityMacros.h>
00112 #ifndef POLLRDNORM
00113 #define POLLRDNORM 0
00114 #endif
00115 #ifndef POLLRDBAND
00116 #define POLLRDBAND 0
00117 #endif
00118 #ifndef POLLWRNORM
00119 #define POLLWRNORM 0
00120 #endif
00121 #define O_LARGEFILE 0
00122 #define memalign(pgsz,amt) valloc(amt)
00123 #define posix_memalign(memp, algn, sz) \
00124 ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
00125 #define SHMDT_t void *
00126 #ifndef EDEADLOCK
00127 #define EDEADLOCK EDEADLK
00128 #endif
00129 #endif
00130
00131 #ifdef __FreeBSD__
00132 #define O_LARGEFILE 0
00133 typedef off_t off64_t;
00134 #define memalign(pgsz,amt) valloc(amt)
00135 #endif
00136
00137
00138
00139
00140 #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \
00141 defined(__IEEE_BIG_ENDIAN) || \
00142 (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN)
00143 #define Xrd_Big_Endian
00144 #ifndef htonll
00145 #define htonll(_x_) _x_
00146 #endif
00147 #ifndef h2nll
00148 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
00149 #endif
00150 #ifndef ntohll
00151 #define ntohll(_x_) _x_
00152 #endif
00153 #ifndef n2hll
00154 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
00155 #endif
00156
00157 #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || \
00158 defined(__IEEE_LITTLE_ENDIAN) || \
00159 (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)
00160 #if !defined(__GNUC__) || defined(__APPLE__)
00161
00162 #if !defined(__sun) || (defined(__sun) && (!defined(_LP64) || defined(__SunOS_5_10)))
00163 extern "C" unsigned long long Swap_n2hll(unsigned long long x);
00164 #ifndef htonll
00165 #define htonll(_x_) Swap_n2hll(_x_)
00166 #endif
00167 #ifndef ntohll
00168 #define ntohll(_x_) Swap_n2hll(_x_)
00169 #endif
00170 #endif
00171
00172 #else
00173
00174 #ifndef htonll
00175 #define htonll(_x_) __bswap_64(_x_)
00176 #endif
00177 #ifndef ntohll
00178 #define ntohll(_x_) __bswap_64(_x_)
00179 #endif
00180
00181 #endif
00182
00183 #ifndef h2nll
00184 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
00185 _y_ = htonll(_y_)
00186 #endif
00187 #ifndef n2hll
00188 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
00189 _y_ = ntohll(_y_)
00190 #endif
00191
00192 #else
00193 #ifndef WIN32
00194 #error Unable to determine target architecture endianness!
00195 #endif
00196 #endif
00197
00198 #ifndef HAVE_STRLCPY
00199 extern "C"
00200 {extern size_t strlcpy(char *dst, const char *src, size_t size);}
00201 #endif
00202
00203
00204
00205
00206 #if defined(__solaris__) && !defined(__linux__)
00207 # if __GNUC__ >= 3 || __GNUC_MINOR__ >= 90
00208 # define XR__SUNGCC3
00209 # endif
00210 #endif
00211 #if defined(__linux__)
00212 # include <features.h>
00213 # if __GNU_LIBRARY__ == 6
00214 # ifndef XR__GLIBC
00215 # define XR__GLIBC
00216 # endif
00217 # endif
00218 #endif
00219 #if defined(__MACH__) && defined(__i386__)
00220 # define R__GLIBC
00221 #endif
00222 #if defined(_AIX) || \
00223 (defined(XR__SUNGCC3) && !defined(__arch64__))
00224 # define SOCKLEN_t size_t
00225 #elif defined(XR__GLIBC) || \
00226 defined(__FreeBSD__) || \
00227 (defined(XR__SUNGCC3) && defined(__arch64__)) || defined(__APPLE__) || \
00228 (defined(__sun) && defined(_SOCKLEN_T))
00229 # ifndef SOCKLEN_t
00230 # define SOCKLEN_t socklen_t
00231 # endif
00232 #elif !defined(SOCKLEN_t)
00233 # define SOCKLEN_t int
00234 #endif
00235
00236 #ifdef _LP64
00237 #define PTR2INT(x) static_cast<int>((long long)x)
00238 #else
00239 #define PTR2INT(x) int(x)
00240 #endif
00241
00242 #ifdef WIN32
00243 #include "XrdSys/XrdWin32.hh"
00244 #define Netdata_t void *
00245 #define Sokdata_t char *
00246 #define IOV_INIT(data,dlen) dlen,data
00247 #define MAKEDIR(path,mode) mkdir(path)
00248 #define net_errno WSAGetLastError()
00249 #else
00250 #define O_BINARY 0
00251 #define Netdata_t char *
00252 #define Sokdata_t void *
00253 #define IOV_INIT(data,dlen) data,dlen
00254 #define MAKEDIR(path,mode) mkdir(path,mode)
00255 #define net_errno errno
00256 #endif
00257
00258 #ifdef WIN32
00259 #define MAXNAMELEN 256
00260 #define MAXPATHLEN 1024
00261 #else
00262 #include <sys/param.h>
00263 #endif
00264
00265
00266 #define XRDABS(x) (x < 0 ? -x : x)
00267
00268 #ifndef LT_MODULE_EXT
00269 #define LT_MODULE_EXT ".so"
00270 #endif
00271
00272 #endif // __XRDSYS_PLATFORM_H__