mariadb/newbrt/portability.h
Yoni Fogel 5d7a5dfaa3 Addresses #1185
Modified makefile to be more modular with icc and gcc options.
Modified portability.h with some stubs and some real portability code

Removed named variadic macros for unnamed variadic macros (c99 only supports unnamed)
Removed ', ## __VAR_ARGS__' in favor of ', __VAR_ARGS__' due to apparent bug in the intel compiler (on windows at least)
__ICC means the linux intel compiler, __ICL means the windows intel compiler
__INTEL_COMPILER is set by both
Removed some include files (for windows) that don't exist.

git-svn-id: file:///svn/tokudb.1131b+1080a+1185+nostatementexprs@6473 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:21 -04:00

81 lines
1.8 KiB
C

#ifndef PORTABILITY_H
#define PORTABILITY_H
// Portability layer
#if defined(__INTEL_COMPILER)
#if !defined(__ICL) && !defined(__ICC)
#error Which intel compiler?
#endif
#if defined(__ICL) && defined(__ICC)
#error Cannot distinguish between windows and linux intel compiler
#endif
#if defined(__ICL)
//Windows Intel Compiler
#define TOKU_WINDOWS
//Define standard integer types.
typedef __int8 int8_t;
typedef unsigned __int8 u_int8_t;
typedef __int16 int16_t;
typedef unsigned __int16 u_int16_t;
typedef __int32 int32_t;
typedef unsigned __int32 u_int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 u_int64_t;
//Define chmod
/*
static inline
int
chmod(const char *path, mode_t mode) {
//TODO: Write API to support what we really need.
//Linux version supports WRITE/EXECUTE/READ bits separately for user/group/world
//windows _chmod supports WRITE/READ bits separately for ?? one type (user? world?)
//See _chmod in sys/stat.h
//Supports setting read/write mode (not separately for user/group/world)
return 0;
}
*/
#define chmod(a,b) (void)0 /* Remove temporarily till compatibility layer exists */
#define FAKE_WINDOWS_STUBS
#ifdef FAKE_WINDOWS_STUBS
typedef size_t ssize_t;
#define PRId64 "lld"
#endif //FAKE_WINDOWS_STUBS
#endif //Windows Intel Compiler
// Intel compiler.
// Define ntohl using bswap.
// Define __attribute__ to be null
#include <sys/types.h>
static inline
u_int32_t
ntohl(u_int32_t x) {
return _bswap(x);
}
static inline
u_int32_t
htonl(u_int32_t x) {
return _bswap(x);
}
#define __attribute__(x)
#elif defined __GNUC__
// Gcc:
// Define ntohl using arpa/inet.h
#include <arpa/inet.h>
#else
#error Not ICC and not GNUC. What compiler?
#endif
#endif