eg_config.h

Go to the documentation of this file.
00001 /* EGlib "Efficient General Library" provides some basic structures and
00002  * algorithms commons in many optimization algorithms.
00003  *
00004  * Copyright (C) 2005 Daniel Espinoza and Marcos Goycoolea.
00005  * 
00006  * This library is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by the
00008  * Free Software Foundation; either version 2.1 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful, but 
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
00013  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
00014  * License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this library; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
00019  * */
00020 /* ========================================================================= */
00021 /** Main Configuration for the library, as debug levels and so on
00022  * 
00023  * @par History:
00024  * - 2010-08-13
00025  *            - Add suport for autoconf and configure for header and feature
00026  *            selection
00027  * - 2006-01-27
00028  *          - Handle some problems with stdint.h in SUN
00029  * - 2005-08-17
00030  *          - Set memory aligment to 8 bits
00031  * - 2003-06-02
00032  *          - First Implementation
00033  * @version 0.0.1 
00034  * */
00035 /* ========================================================================= */
00036 #ifndef __EG_CONFIG_H__
00037 #define __EG_CONFIG_H__
00038 #include "config.h"
00039 #ifdef HAVE_STDIO_H
00040 # include <stdio.h>
00041 #endif
00042 #ifdef HAVE_SYS_SOCKET_H
00043 # include <sys/socket.h>
00044 #endif
00045 #ifdef HAVE_SYS_TYPES_H
00046 # include <sys/types.h>
00047 #endif
00048 #ifdef HAVE_SYS_STAT_H
00049 # include <sys/stat.h>
00050 #endif
00051 #ifdef STDC_HEADERS
00052 # include <stdlib.h>
00053 # include <stddef.h>
00054 #else
00055 # ifdef HAVE_STDLIB_H
00056 # include <stdlib.h>
00057 # endif
00058 #endif
00059 #ifdef HAVE_STRING_H
00060 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
00061 # include <memory.h>
00062 # endif
00063 # include <string.h>
00064 #endif
00065 #ifdef HAVE_STRINGS_H
00066 # include <strings.h>
00067 #endif
00068 #ifdef HAVE_INTTYPES_H
00069 # include <inttypes.h>
00070 #endif
00071 #ifdef HAVE_STDINT_H
00072 # include <stdint.h>
00073 #endif
00074 #ifdef HAVE_UNISTD_H
00075 # include <unistd.h>
00076 #endif
00077 #ifdef HAVE_ERRNO_H
00078 # include <errno.h>
00079 #endif
00080 #ifdef HAVE_LIMITS_H
00081 # include <limits.h>
00082 #endif
00083 #ifdef HAVE_MATH_H
00084 # include <math.h>
00085 #endif
00086 #ifdef HAVE_FLOAT_H
00087 # include <float.h>
00088 #endif
00089 #ifdef HAVE_GETOPT_H
00090 # include <getopt.h>
00091 #endif
00092 #ifdef HAVE_NETINET_IN_H
00093 # include <netinet/in.h>
00094 #endif
00095 #ifdef HAVE_NETINET_TCP_H
00096 # include <netinet/tcp.h>
00097 #endif
00098 #ifdef HAVE_NETDB_H
00099 # include <netdb.h>
00100 #endif
00101 #ifdef HAVE_FCNTL_H
00102 # include <fcntl.h>
00103 #endif
00104 #ifdef HAVE_SYS_RESOURCE_H
00105 # include <sys/resource.h>
00106 #endif
00107 #ifdef HAVE_SYS_PARAM_H
00108 # include <sys/param.h>
00109 #endif
00110 #ifdef TIME_WITH_SYS_TIME
00111 # include <sys/time.h>
00112 # include <time.h>
00113 #else
00114 # ifdef HAVE_SYS_TIME_H
00115 # include <sys/time.h>
00116 # else
00117 # include <time.h>
00118 # endif
00119 #endif
00120 #ifdef HAVE_SYS_TIMES_H
00121 # include <sys/times.h>
00122 #endif
00123 #ifdef HAVE_STDARG_H
00124 # include <stdarg.h>
00125 #endif
00126 #ifdef HAVE_SYS_UTSNAME_H
00127 # include <sys/utsname.h>
00128 #endif
00129 #ifdef HAVE_SIGNAL_H
00130 # include <signal.h>
00131 #endif
00132 #ifdef HAVE_SETJMP_H
00133 # include <setjmp.h>
00134 #endif
00135 #ifdef HAVE_PTHREAD_H
00136 # include <pthread.h>
00137 #endif
00138 #ifdef HAVE_SOFTFLOAT
00139 #include "softfloat.h"
00140 #endif
00141 
00142 /* ========================================================================= */
00143 /** @brief We check for the GNU C extension typeof if necesary. */
00144 #ifndef HAVE_TYPEOF
00145 # if !HAVE_TYPEOF
00146 #  error Can not compile EGlib without ``typeof'' support
00147 # endif
00148 #endif
00149 
00150 /* ========================================================================= */
00151 /** @brief if libbz2 define (if not available) the required function prototypes
00152  */
00153 #ifdef HAVE_LIBBZ2
00154 # if HAVE_LIBBZ2
00155 #  ifdef HAVE_BZLIB_H
00156 #   include <bzlib.h>
00157 #  else 
00158 /* define BZFILE */
00159 #   ifndef HAVE_BZFILEP
00160 typedef void BZFILE;
00161 #   endif
00162 /* define functions */
00163 #   ifndef HAVE_DECL_BZ2_BZCLOSE
00164 extern void BZ2_bzclose(BZFILE* b);
00165 #   endif
00166 #   ifndef HAVE_DECL_BZ2_BZERROR
00167 extern const char* BZ2_bzerror(BZFILE*b,int*errnum);
00168 #   endif
00169 #   ifndef HAVE_DECL_BZ2_BZOPEN
00170 extern BZFILE* BZ2_open(const char*path,const char*mode);
00171 #   endif
00172 #   ifndef HAVE_DECL_BZ2_BZREAD
00173 extern int BZ2_bzread(BZFILE*b,void*buf,int len);
00174 #   endif
00175 #   ifndef HAVE_DECL_BZ2_BZWRITE
00176 extern int BZ2_bzwrite(BZFILE*b,void*bug,int len);
00177 #   endif
00178 #  endif
00179 # endif
00180 #endif
00181 /* ========================================================================= */
00182 /** @brief ig libz define (if not available) the required prototypes */
00183 #ifdef HAVE_LIBZ
00184 # if HAVE_LIBZ
00185 #  ifdef HAVE_ZLIB_H
00186 #   include <zlib.h>
00187 #  else 
00188 /* define gzFile */
00189 #   ifndef HAVE_GZFILE
00190 typedef void* gzFIle;
00191 #   endif
00192 /* define functions */
00193 #   ifndef HAVE_DECL_GZCLOSE
00194 extern int gzclose(gzFile b);
00195 #   endif
00196 #   ifndef HAVE_DECL_GZEOF
00197 extern int gzeof(gzFile b);
00198 #   endif
00199 #   ifndef HAVE_DECL_GZERROR
00200 extern const char* gzerror(gzFile b,int*errnum);
00201 #   endif
00202 #   ifndef HAVE_DECL_GZOPEN
00203 extern gzFile gzopen(const char*path,const char*mode);
00204 #   endif
00205 #   ifndef HAVE_DECL_GZREAD
00206 extern int gzread(gzFile b,void*buf,unsigned len);
00207 #   endif
00208 #   ifndef HAVE_DECL_GZWRITE
00209 extern int gzwrite(gzFile b,void*const bug,unsigned len);
00210 #   endif
00211 #  endif
00212 # endif
00213 #endif
00214 /* ========================================================================= */
00215 /** @brief see if we have both pthread library and header file available, if
00216  * so, define HAVE_EG_THREAD */
00217 #if defined HAVE_PTHREAD_H && HAVE_PTHREAD_H && defined HAVE_LIBPTHREAD && HAVE_LIBPTHREAD
00218 #define HAVE_EG_THREAD 1
00219 #else
00220 #define HAVE_EG_THREAD 0
00221 #endif
00222 /* ========================================================================= */
00223 /** @brief if no gmp support, we do not include gmp.h, if on the otherhand, we
00224  * have libgmp, we MUST have gmp.h */
00225 #ifdef HAVE_LIBGMP
00226 # if HAVE_LIBGMP
00227 #  ifdef HAVE_GMP_H
00228 #   include <gmp.h>
00229 #  else
00230 #   error Must have gmp.h if comiling gmp-support, change configure options accordingly or instal gmp-dev in your system 
00231 #  endif
00232 # endif
00233 #endif
00234 /* ========================================================================= */
00235 /** @brief assert Debug options definitions, by defoult set on */
00236 #ifndef DEBUG
00237 #warning you should define DEBUG, assuming it to be 1
00238 #define DEBUG 1
00239 #endif
00240 
00241 /* ========================================================================= */
00242 /** @brief assert Verbose options definition, by default set on */
00243 #ifndef VERBOSE_LEVEL
00244 #warning you should define VERBOSE_LEVEL, assuming it to be 1
00245 #define VERBOSE_LEVEL 1
00246 #endif
00247 
00248 /* ========================================================================= */
00249 /** @brief if no posix_memalign function is present, we must turn off memslab
00250  * support by reducing it to malloc */
00251 #ifndef HAVE_POSIX_MEMALIGN
00252 #define EG_SLAB_REDUCE_TO_MALLOC 1
00253 #endif
00254 /* ========================================================================= */
00255 /** @brief internal newline string */
00256 #define EG_NEWLINE "\n"
00257 /* end eg_config.h */
00258 #endif