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 #if !defined(__FreeBSD__)
00076 #define F_DUP2FD F_DUPFD
00077 #endif
00078
00079 #define STATFS statfs
00080 #define STATFS_BUFF struct statfs
00081
00082 #define FS_BLKFACT 4
00083
00084 #define FLOCK_t struct flock
00085
00086 typedef off_t offset_t;
00087
00088 #define GTZ_NULL (struct timezone *)0
00089
00090 #else
00091
00092 #define STATFS statvfs
00093 #define STATFS_BUFF struct statvfs
00094
00095 #define FS_BLKFACT 1
00096
00097 #define SHMDT_t char *
00098
00099 #define FLOCK_t flock_t
00100
00101 #define GTZ_NULL (void *)0
00102
00103 #endif
00104
00105 #ifdef __linux__
00106
00107 #define SHMDT_t const void *
00108 #endif
00109
00110
00111
00112 #ifdef __APPLE__
00113 #include <AvailabilityMacros.h>
00114 #ifndef POLLRDNORM
00115 #define POLLRDNORM 0
00116 #endif
00117 #ifndef POLLRDBAND
00118 #define POLLRDBAND 0
00119 #endif
00120 #ifndef POLLWRNORM
00121 #define POLLWRNORM 0
00122 #endif
00123 #define O_LARGEFILE 0
00124 #define memalign(pgsz,amt) valloc(amt)
00125 #define posix_memalign(memp, algn, sz) \
00126 ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
00127 #define SHMDT_t void *
00128 #ifndef EDEADLOCK
00129 #define EDEADLOCK EDEADLK
00130 #endif
00131 #endif
00132
00133 #ifdef __FreeBSD__
00134 #define O_LARGEFILE 0
00135 typedef off_t off64_t;
00136 #define memalign(pgsz,amt) valloc(amt)
00137 #endif
00138
00139
00140
00141
00142 #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \
00143 defined(__IEEE_BIG_ENDIAN) || \
00144 (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN)
00145 #define Xrd_Big_Endian
00146 #ifndef htonll
00147 #define htonll(_x_) _x_
00148 #endif
00149 #ifndef h2nll
00150 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
00151 #endif
00152 #ifndef ntohll
00153 #define ntohll(_x_) _x_
00154 #endif
00155 #ifndef n2hll
00156 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
00157 #endif
00158
00159 #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || \
00160 defined(__IEEE_LITTLE_ENDIAN) || \
00161 (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)
00162 #if !defined(__GNUC__) || defined(__APPLE__)
00163
00164 #if !defined(__sun) || (defined(__sun) && (!defined(_LP64) || defined(__SunOS_5_10)))
00165 extern "C" unsigned long long Swap_n2hll(unsigned long long x);
00166 #ifndef htonll
00167 #define htonll(_x_) Swap_n2hll(_x_)
00168 #endif
00169 #ifndef ntohll
00170 #define ntohll(_x_) Swap_n2hll(_x_)
00171 #endif
00172 #endif
00173
00174 #else
00175
00176 #ifndef htonll
00177 #define htonll(_x_) __bswap_64(_x_)
00178 #endif
00179 #ifndef ntohll
00180 #define ntohll(_x_) __bswap_64(_x_)
00181 #endif
00182
00183 #endif
00184
00185 #ifndef h2nll
00186 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
00187 _y_ = htonll(_y_)
00188 #endif
00189 #ifndef n2hll
00190 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
00191 _y_ = ntohll(_y_)
00192 #endif
00193
00194 #else
00195 #ifndef WIN32
00196 #error Unable to determine target architecture endianness!
00197 #endif
00198 #endif
00199
00200 #ifndef HAVE_STRLCPY
00201 extern "C"
00202 {extern size_t strlcpy(char *dst, const char *src, size_t size);}
00203 #endif
00204
00205
00206
00207
00208 #if defined(__solaris__) && !defined(__linux__)
00209 # if __GNUC__ >= 3 || __GNUC_MINOR__ >= 90
00210 # define XR__SUNGCC3
00211 # endif
00212 #endif
00213 #if defined(__linux__)
00214 # include <features.h>
00215 # if __GNU_LIBRARY__ == 6
00216 # ifndef XR__GLIBC
00217 # define XR__GLIBC
00218 # endif
00219 # endif
00220 #endif
00221 #if defined(__MACH__) && defined(__i386__)
00222 # define R__GLIBC
00223 #endif
00224 #if defined(_AIX) || \
00225 (defined(XR__SUNGCC3) && !defined(__arch64__))
00226 # define SOCKLEN_t size_t
00227 #elif defined(XR__GLIBC) || \
00228 defined(__FreeBSD__) || \
00229 (defined(XR__SUNGCC3) && defined(__arch64__)) || defined(__APPLE__) || \
00230 (defined(__sun) && defined(_SOCKLEN_T))
00231 # ifndef SOCKLEN_t
00232 # define SOCKLEN_t socklen_t
00233 # endif
00234 #elif !defined(SOCKLEN_t)
00235 # define SOCKLEN_t int
00236 #endif
00237
00238 #ifdef _LP64
00239 #define PTR2INT(x) static_cast<int>((long long)x)
00240 #else
00241 #define PTR2INT(x) int(x)
00242 #endif
00243
00244 #ifdef WIN32
00245 #include "XrdSys/XrdWin32.hh"
00246 #define Netdata_t void *
00247 #define Sokdata_t char *
00248 #define IOV_INIT(data,dlen) dlen,data
00249 #define MAKEDIR(path,mode) mkdir(path)
00250 #define CHMOD(path, mode) {}
00251 #define net_errno WSAGetLastError()
00252 #else
00253 #define O_BINARY 0
00254 #define Netdata_t char *
00255 #define Sokdata_t void *
00256 #define IOV_INIT(data,dlen) data,dlen
00257 #define MAKEDIR(path,mode) mkdir(path,mode)
00258 #define CHMOD(path, mode) chmod(path,mode)
00259 #define net_errno errno
00260 #endif
00261
00262 #ifdef WIN32
00263 #define MAXNAMELEN 256
00264 #define MAXPATHLEN 1024
00265 #else
00266 #include <sys/param.h>
00267 #if defined(__FreeBSD__)
00268 #define MAXNAMELEN 256
00269 #endif
00270 #endif
00271
00272
00273 #define XRDABS(x) (x < 0 ? -x : x)
00274
00275 #ifndef LT_MODULE_EXT
00276 #define LT_MODULE_EXT ".so"
00277 #endif
00278
00279 #endif // __XRDSYS_PLATFORM_H__