globus_common  17.9
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_common_include.h
Go to the documentation of this file.
1 
8 #if !defined(GLOBUS_COMMON_INCLUDE_H)
9 #define GLOBUS_COMMON_INCLUDE_H 1
10 
11 #include "globus_config.h"
12 
13 #if defined(_WIN32) && !defined(__CYGWIN__)
14 #include <winsock2.h>
15 #include <ws2tcpip.h>
16 #endif
17 
18 #ifdef __GNUC__
19 #define GlobusFuncName(func) static const char * _globus_func_name \
20  __attribute__((__unused__)) = #func
21 #else
22 #define GlobusFuncName(func) static const char * _globus_func_name = #func
23 #endif
24 
25 extern const char * _globus_func_name;
26 
27 #define _GCSL(s) globus_common_i18n_get_string(GLOBUS_COMMON_MODULE,\
28  s)
29 
31 #ifndef __USE_POSIX
32 #define __USE_POSIX
33 #endif
34 
35 /*
36  * Include system files if we have them
37  */
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #if !defined(_WIN32)
41 #include <unistd.h>
42 #endif
43 #include <sys/param.h>
44 #include <fcntl.h>
45 
46 #if defined(_WIN32)
47 # include <windows.h>
48 # include <winsock2.h>
49 # include <process.h>
50 # include <io.h>
51 # include <sys/timeb.h>
52 # include <signal.h>
53 # include <malloc.h>
54 #else
55 # include <pwd.h>
56 # include <netdb.h>
57 # include <netinet/in.h>
58 # include <sys/socket.h>
59 # include <sys/uio.h>
60 #endif
61 
62 
63 #include <sys/time.h>
64 #include <time.h>
65 
66 #include <stdint.h>
67 #include <errno.h>
68 #include <stdlib.h>
69 #include <stdio.h>
70 #include <limits.h>
71 #include <assert.h>
72 #include <signal.h>
73 #include <string.h>
74 #include <ctype.h>
75 #include <stdarg.h>
76 
77 #include <dirent.h>
78 #include <fcntl.h>
79 
80 /******************************************************************************
81  Define macros
82 ******************************************************************************/
83 
84 /*
85  * Various macro definitions for assertion checking
86  */
87 #if 0
88  void globus_dump_stack();
89  #define GLOBUS_DUMP_STACK() globus_dump_stack()
90 #else
91  #define GLOBUS_DUMP_STACK()
92 #endif
93 
94 #if defined(BUILD_DEBUG)
95 # define globus_assert(assertion) \
96  do { \
97  if (!(assertion)) \
98  { \
99  fprintf(stderr, "Assertion " #assertion \
100  " failed in file %s at line %d\n", \
101  __FILE__, __LINE__); \
102  GLOBUS_DUMP_STACK(); \
103  abort(); \
104  } \
105  } while(0)
106 
107 # define globus_assert_string(assertion, string) \
108  do { \
109  if (!(assertion)) \
110  { \
111  fprintf(stderr, "Assertion " #assertion \
112  " failed in file %s at line %d: %s", \
113  __FILE__, __LINE__, string); \
114  GLOBUS_DUMP_STACK(); \
115  abort(); \
116  } \
117  } while(0)
118 #else /* BUILD_DEBUG */
119 # define globus_assert(assertion)
120 # define globus_assert_string(assertion, string)
121 #endif /* BUILD_DEBUG */
122 
123 #define GLOBUS_MAX(V1,V2) (((V1) > (V2)) ? (V1) : (V2))
124 #define GLOBUS_MIN(V1,V2) (((V1) < (V2)) ? (V1) : (V2))
125 
126 #ifndef EXTERN_C_BEGIN
127 #ifdef __cplusplus
128 #define EXTERN_C_BEGIN extern "C" {
129 #define EXTERN_C_END }
130 #else
131 #define EXTERN_C_BEGIN
132 #define EXTERN_C_END
133 #endif
134 #endif
135 
136 /* POSIX error code remapping */
137 #ifdef _WIN32
138 #ifndef EWOULDBLOCK
139  #define EWOULDBLOCK EAGAIN
140 #endif
141 #ifndef ETIMEDOUT
142  #define ETIMEDOUT WSAETIMEDOUT
143 #endif
144 #ifndef EINPROGRESS
145  #define EINPROGRESS WSAEINPROGRESS
146 #endif
147 #endif
148 
149 #include <inttypes.h>
150 
151 /* vsnprintf is already defined to mingw version */
152 #if defined(_WIN32) && !defined(__USE_MINGW_ANSI_STDIO)
153 # define vsnprintf _vsnprintf
154 #endif
155 
156 #ifndef MAXHOSTNAMELEN
157 #define MAXHOSTNAMELEN 64
158 #endif
159 
160 #include "globus_types.h"
161 #endif /* GLOBUS_COMMON_INCLUDE_H */
162 
Common Primitive Types.
Globus Platform Configuration.