util/basicDefs.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 Name:      basicDefs.h
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
00006 Note:      The gcc and icc (>=8) both define __GNUC__
00007 Note:      cl.exe (Windows) always defines _WIN32
00008            __cplusplus    Defined for C++ programs only.
00009            _CHAR_UNSIGNED Defined when /J is specified.
00010            _CPPRTTI  Defined for code compiled with the /GR (Enable Run-Time Type Information) option.
00011            _CPPUNWIND  Defined for code compiled with the /GX (Enable Exception Handling) option.
00012            _DLL      Defined when /MD or /MDd - Multithread DLL is specified.
00013            _M_IX86   (x86 specific) Defined as 500 for Blend (/GB), 300 for 80386 (/G3), 400 for 80486 (/G4), 500 for Pentium (/G5), and 600 for Pentium Pro (/G6).
00014            _MSC_VER  Defines the compiler version. Always defined.
00015                      1200: VC++ 6.0 Microsoft Visual C++ version 6.0 or later
00016                      1310: VC++ 7.1 2003 Microsoft (R) 32-bit C/C++ 13.10.3077 for 80x86 1984-2002
00017                      1400: VC++ 8.0 2005 14.00.50727.42
00018            _WIN32    (x86 specific) Defined for applications for WIN32. Always defined.
00019            _MT       Defined when /MD or /MT is specified.
00020            http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_.2f.u.2c_2f.u.asp
00021 -----------------------------------------------------------------------------*/
00022 #ifndef XMLBLASTER_basicDefs_H
00023 #define XMLBLASTER_basicDefs_H
00024 
00025 #if defined(_WIN32)
00026 #  if !defined(_WINDOWS)
00027 #     define _WINDOWS /* We work with _WINDOWS and _MSC_VER in our code */
00028 #  endif
00029 #endif
00030 
00031 #if defined(_WINDOWS)
00032 # define Blaster_Export_Flag __declspec (dllexport)
00033 # define Blaster_Import_Flag __declspec (dllimport)
00034 # if defined(_WINDLL)
00035 #   define Dll_Export Blaster_Export_Flag
00036 # elif defined(DLL_IGNORE)
00037 #   define Dll_Export
00038 # else
00039 #   define Dll_Export Blaster_Import_Flag
00040 #endif
00041 #else
00042 # define Dll_Export
00043 #endif
00044 
00045 #ifndef __cplusplus
00046 #  if !defined(__sun) && !defined(_WINDOWS)  /* __GNUC_MINOR__=85 : gcc 2.85 does not like it either: how to define? */
00047 #    include <stdbool.h>
00048 #  endif
00049 #  ifndef __bool_true_false_are_defined
00050 #    define bool int
00051 #    define true 1
00052 #    define false 0
00053 #  endif
00054 #       define XMLBLASTER_C_bool bool
00055 #else
00056 #if defined(_WINDOWS)
00057 #define XMLBLASTER_C_bool int
00058 #else
00059 #define XMLBLASTER_C_bool bool
00060 #endif
00061 #endif
00062 
00063 #if defined(_WINDOWS)
00064 #  if _MSC_VER >= 1400  /* _WINDOWS: 1200->VC++6.0, 1310->VC++7.1 (2003), 1400->VC++8.0 (2005) */
00065 #    define SNPRINTF snprintf0
00066      /* sscanf_s( tokenstring, "%s", s, sizeof(s) );   !! for %s: two args, the second with size !! */
00067 #    define VSNPRINTF _vsnprintf
00068 #  else
00069 #    define SNPRINTF _snprintf
00070 #    define VSNPRINTF _vsnprintf
00071 #  endif
00072 #else
00073 #  define SNPRINTF snprintf
00074 #  define VSNPRINTF vsnprintf    /* stdarg.h */
00075 #endif
00076 
00077 #if defined(_WINDOWS)
00078   typedef unsigned __int64 uint64_t;
00079   typedef __int64 int64_t;
00080 # define PRINTF_PREFIX_INT64_T "%I64d"
00081 # define PRINTF_PREFIX_UINT64_T "%I64u"
00082   /*typedef long long int64_t;*/
00083   typedef unsigned __int32 uint32_t;
00084   typedef __int32 int32_t;
00085   typedef unsigned __int16 uint16_t;
00086   typedef __int16 int16_t;
00087 #else
00088 
00089 /* FreeBSD uses inttypes.h, not stdint.h.  Boost's lib suggests
00090    this should read  defined(__FreeBSD__) || defined(__IBMCPP__)
00091 */
00092 # if defined(__FreeBSD__) 
00093 #   include <inttypes.h>
00094 # elif defined(__sun)
00095     /*#   include <int_types.h>*/ /* /usr/include/sys/int_types.h */
00096 # elif defined(__hpux)
00097   /*typedef long long int64_t;*/
00098   /*#   include <int_types.h>*/ /* /usr/include/sys/int_types.h */
00099 # else
00100 #   include <stdint.h>  /*-> C99:  uint64_t etc. */
00101 # endif
00102 
00103   /* __unix __WIN64 __WIN32 */
00104 # if __LP64__
00105    /* For example a Xeon processor with UNIX */
00106 #  define PRINTF_PREFIX_INT64_T "%ld"
00107 #  define PRINTF_PREFIX_UINT64_T "%lu"
00108    /*#elif __ILP64__ __LLP64__ */
00109 # else
00110 #  define PRINTF_PREFIX_INT64_T "%lld"
00111 #  define PRINTF_PREFIX_UINT64_T "%llu"
00112 # endif
00113 
00114 #endif
00115 /*#define INT64_DIGITLEN_MAX 19  Size of a max int64_t dumped to a string: LLONG_MAX from limits.h 9223372036854775807 */
00116 #define INT64_STRLEN_MAX 22 
00119 #ifdef GCC_ANSI  
00120 #ifndef __USE_BSD 
00121    typedef unsigned short u_short;
00122 #endif
00123 #endif
00124 
00125 #ifdef _WINDOWS
00126 #  define _INLINE_FUNC        /* C99 allows to declare functions as 'inline', not supported on WIN cl */
00127 #else
00128 #  ifdef __cplusplus
00129 #    define _INLINE_FUNC      /* 'inline' does not compile with g++ */
00130 #  elif __GNUC__
00131 #    define _INLINE_FUNC __inline__ /* http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html */
00132 #  else
00133 #    define _INLINE_FUNC inline /* C99 allows to declare functions as 'inline', it has internal linkage -> code to be in same file as call */
00134 #  endif
00135 #endif
00136 
00137 #if defined(_WINDOWS)
00138 #  define socklen_t int
00139 #  define ssize_t signed int
00140 #elif defined(__alpha)
00141 #  define socklen_t int
00142 #else
00143 #  include <unistd.h>
00144 #endif
00145 
00146 #ifndef XB_NO_PTHREADS
00147 #  define XB_USE_PTHREADS 1 
00148 #endif
00149 
00156 typedef void ( * XmlBlasterNumReadFunc)(void *xb, const size_t currBytesRead, const size_t nbytes);
00157 
00158 #endif /* XMLBLASTER_basicDefs_H */
00159