Grid Community Toolkit  6.2.1653033972 (tag: v6.2.20220524)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_common_include.h
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
23 #if !defined(GLOBUS_COMMON_INCLUDE_H)
24 #define GLOBUS_COMMON_INCLUDE_H 1
25 
26 #include "globus_config.h"
27 
28 #if defined(_WIN32) && !defined(__CYGWIN__)
29 #include <winsock2.h>
30 #include <ws2tcpip.h>
31 #endif
32 
33 #ifdef __GNUC__
34 #define GlobusFuncName(func) static const char * _globus_func_name \
35  __attribute__((__unused__)) = #func
36 #else
37 #define GlobusFuncName(func) static const char * _globus_func_name = #func
38 #endif
39 
40 extern const char * _globus_func_name;
41 
42 #define _GCSL(s) globus_common_i18n_get_string(GLOBUS_COMMON_MODULE,\
43  s)
44 
46 #ifndef __USE_POSIX
47 #define __USE_POSIX
48 #endif
49 
50 /*
51  * Include system files if we have them
52  */
53 #include <sys/types.h>
54 #include <sys/stat.h>
55 #if !defined(_WIN32)
56 #include <unistd.h>
57 #endif
58 #include <sys/param.h>
59 #include <fcntl.h>
60 
61 #if defined(_WIN32)
62 # include <windows.h>
63 # include <winsock2.h>
64 # include <process.h>
65 # include <io.h>
66 # include <sys/timeb.h>
67 # include <signal.h>
68 # include <malloc.h>
69 #else
70 # include <pwd.h>
71 # include <netdb.h>
72 # include <netinet/in.h>
73 # include <sys/socket.h>
74 # include <sys/uio.h>
75 #endif
76 
77 
78 #include <sys/time.h>
79 #include <time.h>
80 
81 #include <stdint.h>
82 #include <errno.h>
83 #include <stdlib.h>
84 #include <stdio.h>
85 #include <limits.h>
86 #include <assert.h>
87 #include <signal.h>
88 #include <string.h>
89 #include <ctype.h>
90 #include <stdarg.h>
91 
92 #include <dirent.h>
93 #include <fcntl.h>
94 
95 #ifdef _WIN32
96 extern int inet_pton(int af, const char *src, void *dst);
97 #endif /* _WIN32 */
98 
99 /******************************************************************************
100  Define macros
101 ******************************************************************************/
102 
103 /*
104  * Various macro definitions for assertion checking
105  */
106 #if 0
107  void globus_dump_stack();
108  #define GLOBUS_DUMP_STACK() globus_dump_stack()
109 #else
110  #define GLOBUS_DUMP_STACK()
111 #endif
112 
113 #if defined(BUILD_DEBUG)
114 # define globus_assert(assertion) \
115  do { \
116  if (!(assertion)) \
117  { \
118  fprintf(stderr, "Assertion " #assertion \
119  " failed in file %s at line %d\n", \
120  __FILE__, __LINE__); \
121  GLOBUS_DUMP_STACK(); \
122  abort(); \
123  } \
124  } while(0)
125 
126 # define globus_assert_string(assertion, string) \
127  do { \
128  if (!(assertion)) \
129  { \
130  fprintf(stderr, "Assertion " #assertion \
131  " failed in file %s at line %d: %s", \
132  __FILE__, __LINE__, string); \
133  GLOBUS_DUMP_STACK(); \
134  abort(); \
135  } \
136  } while(0)
137 #else /* BUILD_DEBUG */
138 # define globus_assert(assertion)
139 # define globus_assert_string(assertion, string)
140 #endif /* BUILD_DEBUG */
141 
142 #define GLOBUS_MAX(V1,V2) (((V1) > (V2)) ? (V1) : (V2))
143 #define GLOBUS_MIN(V1,V2) (((V1) < (V2)) ? (V1) : (V2))
144 
145 #ifndef EXTERN_C_BEGIN
146 #ifdef __cplusplus
147 #define EXTERN_C_BEGIN extern "C" {
148 #define EXTERN_C_END }
149 #else
150 #define EXTERN_C_BEGIN
151 #define EXTERN_C_END
152 #endif
153 #endif
154 
155 /* POSIX error code remapping */
156 #ifdef _WIN32
157 #ifndef EWOULDBLOCK
158  #define EWOULDBLOCK EAGAIN
159 #endif
160 #ifndef ETIMEDOUT
161  #define ETIMEDOUT WSAETIMEDOUT
162 #endif
163 #ifndef EINPROGRESS
164  #define EINPROGRESS WSAEINPROGRESS
165 #endif
166 #endif
167 
168 #include <inttypes.h>
169 
170 /* vsnprintf is already defined to mingw version */
171 #if defined(_WIN32) && !defined(__USE_MINGW_ANSI_STDIO)
172 # define vsnprintf _vsnprintf
173 #endif
174 
175 #ifndef MAXHOSTNAMELEN
176 #define MAXHOSTNAMELEN 64
177 #endif
178 
179 #include "globus_types.h"
180 #endif /* GLOBUS_COMMON_INCLUDE_H */
181 
Common Primitive Types.
Globus Platform Configuration.