globus_common_include.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00023 #if !defined(GLOBUS_COMMON_INCLUDE_H)
00024 #define GLOBUS_COMMON_INCLUDE_H 1
00025 
00026 #include "globus_config.h"
00027 
00028 #if defined(_WIN32) && !defined(__CYGWIN__)
00029 #include <winsock2.h>
00030 #include <ws2tcpip.h>
00031 #endif
00032 
00033 #ifdef __GNUC__
00034 #define GlobusFuncName(func) static const char * _globus_func_name \
00035     __attribute__((__unused__)) = #func
00036 #else
00037 #define GlobusFuncName(func) static const char * _globus_func_name = #func
00038 #endif
00039 
00040 extern const char * _globus_func_name;
00041 
00042 #define _GCSL(s) globus_common_i18n_get_string(GLOBUS_COMMON_MODULE,\
00043                                s)
00044 
00046 #ifndef __USE_POSIX
00047 #define __USE_POSIX
00048 #endif
00049 
00050 /*
00051  * Include system files if we have them
00052  */
00053 #include <sys/types.h>
00054 #include <sys/stat.h>
00055 #if !defined(_WIN32)
00056 #include <unistd.h>
00057 #endif
00058 #include <sys/param.h>
00059 #include <fcntl.h>
00060 
00061 #if defined(_WIN32)
00062 #   include <windows.h>
00063 #   include <winsock2.h>
00064 #   include <process.h>
00065 #   include <io.h>
00066 #   include <sys/timeb.h>
00067 #   include <signal.h>
00068 #   include <malloc.h>
00069 #else
00070 #   include <pwd.h>
00071 #   include <netdb.h>
00072 #   include <netinet/in.h>
00073 #   include <sys/socket.h>
00074 #   include <sys/uio.h>
00075 #endif
00076 
00077 
00078 #include <sys/time.h>
00079 #include <time.h>
00080 
00081 #include <stdint.h>
00082 #include <errno.h>
00083 #include <stdlib.h>
00084 #include <stdio.h>
00085 #include <limits.h>
00086 #include <assert.h>
00087 #include <signal.h>
00088 #include <string.h>
00089 #include <ctype.h>
00090 #include <stdarg.h>
00091 
00092 #include <dirent.h>
00093 #include <fcntl.h>
00094 
00095 #ifdef _WIN32
00096 extern int inet_pton(int af, const char *src, void *dst);
00097 #endif /* _WIN32 */
00098 
00099 /******************************************************************************
00100                                  Define macros
00101 ******************************************************************************/
00102 
00103 /*
00104  * Various macro definitions for assertion checking
00105  */
00106 #if 0
00107         void globus_dump_stack();
00108         #define GLOBUS_DUMP_STACK() globus_dump_stack() 
00109 #else
00110         #define GLOBUS_DUMP_STACK()
00111 #endif
00112 
00113 #if defined(BUILD_DEBUG)
00114 #   define globus_assert(assertion)                                         \
00115     do {                                                                            \
00116         if (!(assertion))                                                       \
00117         {                                                                               \
00118             fprintf(stderr, "Assertion " #assertion     \
00119                     " failed in file %s at line %d\n",                  \
00120                     __FILE__, __LINE__);                                        \
00121             GLOBUS_DUMP_STACK();                                                    \
00122             abort();                                        \
00123          }                                                                              \
00124     } while(0)
00125 
00126 #   define globus_assert_string(assertion, string)      \
00127     do {                                                                                \
00128         if (!(assertion))                                                   \
00129         {                                                                               \
00130             fprintf(stderr, "Assertion " #assertion             \
00131                     " failed in file %s at line %d: %s",        \
00132                     __FILE__, __LINE__, string);                            \
00133             GLOBUS_DUMP_STACK();                                                    \
00134             abort();                                        \
00135         }                                                                               \
00136     } while(0)
00137 #else /* BUILD_DEBUG */
00138 #   define globus_assert(assertion)
00139 #   define globus_assert_string(assertion, string)
00140 #endif /* BUILD_DEBUG */
00141 
00142 #define GLOBUS_MAX(V1,V2) (((V1) > (V2)) ? (V1) : (V2))
00143 #define GLOBUS_MIN(V1,V2) (((V1) < (V2)) ? (V1) : (V2))
00144 
00145 #ifndef EXTERN_C_BEGIN
00146 #ifdef __cplusplus
00147 #define EXTERN_C_BEGIN extern "C" {
00148 #define EXTERN_C_END }
00149 #else
00150 #define EXTERN_C_BEGIN
00151 #define EXTERN_C_END
00152 #endif
00153 #endif
00154 
00155 /* POSIX error code remapping */
00156 #ifdef _WIN32
00157 #ifndef EWOULDBLOCK 
00158         #define EWOULDBLOCK EAGAIN
00159 #endif
00160 #ifndef ETIMEDOUT 
00161         #define ETIMEDOUT WSAETIMEDOUT
00162 #endif
00163 #ifndef EINPROGRESS 
00164         #define EINPROGRESS WSAEINPROGRESS
00165 #endif
00166 #endif
00167 
00168 #include <inttypes.h>
00169 
00170 #if defined(_WIN32)
00171 #    define vsnprintf _vsnprintf
00172 #endif
00173 
00174 #ifndef MAXHOSTNAMELEN
00175 #define MAXHOSTNAMELEN 64
00176 #endif
00177 
00178 #include "globus_types.h"
00179 #endif  /* GLOBUS_COMMON_INCLUDE_H */
00180 

Generated on 20 Jun 2015 for globus_common by  doxygen 1.4.7