XrdSysPlatform.hh

Go to the documentation of this file.
00001 #ifndef __XRDSYS_PLATFORM_H__
00002 #define __XRDSYS_PLATFORM_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                     X r d S y s P l a t f o r m . h h                      */
00006 /*                                                                            */
00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012   
00013 //        $Id: XrdSysPlatform.hh 38011 2011-02-08 18:35:57Z ganis $
00014 
00015 // Include stdlib so that ENDIAN macros are defined properly
00016 //
00017 #include <stdlib.h>
00018 #ifdef __linux__
00019 #include <memory.h>
00020 #include <string.h>
00021 #include <sys/types.h>
00022 #include <asm/param.h>
00023 #include <byteswap.h>
00024 #define MAXNAMELEN NAME_MAX
00025 #endif
00026 #ifdef __macos__
00027 #include <AvailabilityMacros.h>
00028 #include <sys/types.h>
00029 #define fdatasync(x) fsync(x)
00030 #define MAXNAMELEN NAME_MAX
00031 #ifndef dirent64
00032 #  define dirent64 dirent
00033 #endif
00034 #ifndef off64_t
00035 #define off64_t int64_t
00036 #endif
00037 #if (!defined(MAC_OS_X_VERSION_10_5) || \
00038      MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
00039 #ifndef stat64
00040 #  define stat64 stat
00041 #endif
00042 #endif
00043 #endif
00044 #ifdef __FreeBSD__
00045 #include <sys/types.h>
00046 #endif
00047 
00048 #ifdef __solaris__
00049 #define posix_memalign(memp, algn, sz) \
00050         ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
00051 #endif
00052 
00053 #if defined(__linux__) || defined(__macos__) || defined(__FreeBSD__)
00054 
00055 #define S_IAMB      0x1FF   /* access mode bits */
00056 
00057 #define F_DUP2FD F_DUPFD
00058 
00059 #define STATFS      statfs
00060 #define STATFS_BUFF struct statfs
00061 
00062 #define FS_BLKFACT  4
00063 
00064 #define FLOCK_t struct flock
00065 
00066 typedef off_t offset_t;
00067 
00068 #define GTZ_NULL (struct timezone *)0
00069 
00070 #else
00071 
00072 #define STATFS      statvfs
00073 #define STATFS_BUFF struct statvfs
00074 
00075 #define FS_BLKFACT  1
00076 
00077 #define SHMDT_t char *
00078 
00079 #define FLOCK_t flock_t
00080 
00081 #define GTZ_NULL (void *)0
00082 
00083 #endif
00084 
00085 #ifdef __linux__
00086 
00087 #define SHMDT_t const void *
00088 #endif
00089 
00090 // For alternative platforms
00091 //
00092 #ifdef __macos__
00093 #include <AvailabilityMacros.h>
00094 extern char *cuserid(char *s);
00095 #ifndef POLLRDNORM
00096 #define POLLRDNORM  0
00097 #endif
00098 #ifndef POLLRDBAND
00099 #define POLLRDBAND  0
00100 #endif
00101 #ifndef POLLWRNORM
00102 #define POLLWRNORM  0
00103 #endif
00104 #define O_LARGEFILE 0
00105 #define memalign(pgsz,amt) valloc(amt)
00106 #define posix_memalign(memp, algn, sz) \
00107         ((*memp = memalign(algn, sz)) ? 0 : ENOMEM)
00108 #define SHMDT_t void *
00109 #ifndef EDEADLOCK
00110 #define EDEADLOCK EDEADLK
00111 #endif
00112 #endif
00113 
00114 #ifdef __FreeBSD__
00115 #define O_LARGEFILE 0
00116 typedef off_t off64_t;
00117 #define memalign(pgsz,amt) valloc(amt)
00118 #endif
00119 
00120 // Only sparc platforms have structure alignment problems w/ optimization
00121 // so the h2xxx() variants are used when converting network streams.
00122 
00123 #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \
00124    defined(__IEEE_BIG_ENDIAN) || \
00125    (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN)
00126 #define Xrd_Big_Endian
00127 #ifndef htonll
00128 #define htonll(_x_)  _x_
00129 #endif
00130 #ifndef h2nll
00131 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
00132 #endif
00133 #ifndef ntohll
00134 #define ntohll(_x_)  _x_
00135 #endif
00136 #ifndef n2hll
00137 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long))
00138 #endif
00139 
00140 #elif defined(_LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || \
00141      defined(__IEEE_LITTLE_ENDIAN) || \
00142      (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)
00143 #if !defined(__GNUC__) || defined(__macos__)
00144 
00145 #if !defined(__sun) || (defined(__sun) && (!defined(htonll) || !defined(ntohll)))
00146 extern "C" unsigned long long Swap_n2hll(unsigned long long x);
00147 #ifndef htonll
00148 #define htonll(_x_) Swap_n2hll(_x_)
00149 #endif
00150 #ifndef ntohll
00151 #define ntohll(_x_) Swap_n2hll(_x_)
00152 #endif
00153 #endif
00154 
00155 #else
00156 
00157 #ifndef htonll
00158 #define htonll(_x_) __bswap_64(_x_)
00159 #endif
00160 #ifndef ntohll
00161 #define ntohll(_x_) __bswap_64(_x_)
00162 #endif
00163 
00164 #endif
00165 
00166 #ifndef h2nll
00167 #define h2nll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
00168                         _y_ = htonll(_y_)
00169 #endif
00170 #ifndef n2hll
00171 #define n2hll(_x_, _y_) memcpy((void *)&_y_,(const void *)&_x_,sizeof(long long));\
00172                         _y_ = ntohll(_y_)
00173 #endif
00174 
00175 #else
00176 #ifndef WIN32
00177 #error Unable to determine target architecture endianness!
00178 #endif
00179 #endif
00180 
00181 #ifndef HAVE_STRLCPY
00182 extern "C"
00183 {extern size_t strlcpy(char *dst, const char *src, size_t size);}
00184 #endif
00185 
00186 //
00187 // To make socklen_t portable use SOCKLEN_t
00188 //
00189 #if defined(__solaris__) && !defined(__linux__)
00190 #   if __GNUC__ >= 3 || __GNUC_MINOR__ >= 90
00191 #      define XR__SUNGCC3
00192 #   endif
00193 #endif
00194 #if defined(__linux__)
00195 #   include <features.h>
00196 #   if __GNU_LIBRARY__ == 6
00197 #      ifndef XR__GLIBC
00198 #         define XR__GLIBC
00199 #      endif
00200 #   endif
00201 #endif
00202 #if defined(__MACH__) && defined(__i386__)
00203 #   define R__GLIBC
00204 #endif
00205 #if defined(_AIX) || \
00206    (defined(XR__SUNGCC3) && !defined(__arch64__))
00207 #   define SOCKLEN_t size_t
00208 #elif defined(XR__GLIBC) || \
00209    defined(__FreeBSD__) || \
00210    (defined(XR__SUNGCC3) && defined(__arch64__)) || defined(__macos__)
00211 #   ifndef SOCKLEN_t
00212 #      define SOCKLEN_t socklen_t
00213 #   endif
00214 #elif !defined(SOCKLEN_t)
00215 #   define SOCKLEN_t int
00216 #endif
00217 
00218 #ifdef _LP64
00219 #define PTR2INT(x) static_cast<int>((long long)x)
00220 #else
00221 #define PTR2INT(x) int(x)
00222 #endif
00223 
00224 #ifdef WIN32
00225 #include "XrdSys/XrdWin32.hh"
00226 #define Netdata_t void *
00227 #define Sokdata_t char *
00228 #define IOV_INIT(data,dlen) dlen,data
00229 #define MAKEDIR(path,mode) mkdir(path)
00230 #define net_errno WSAGetLastError()
00231 #else
00232 #define O_BINARY 0
00233 #define Netdata_t char *
00234 #define Sokdata_t void *
00235 #define IOV_INIT(data,dlen) data,dlen
00236 #define MAKEDIR(path,mode) mkdir(path,mode)
00237 #define net_errno errno
00238 #endif
00239 
00240 #ifdef WIN32
00241 #define MAXNAMELEN 256
00242 #define MAXPATHLEN 1024
00243 #else
00244 #include <sys/param.h>
00245 #endif
00246 // The following gets arround a relative new gcc compiler bug
00247 //
00248 #define XRDABS(x) (x < 0 ? -x : x)
00249 
00250 #endif  // __XRDSYS_PLATFORM_H__

Generated on Tue Jul 5 14:47:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1