C Standard Library Extensions  1.0.5
cxtypes.h
00001 /* $Id: cxtypes.h,v 1.2 2009/02/11 12:27:50 llundin Exp $
00002  *
00003  * This file is part of the ESO C Extension Library
00004  * Copyright (C) 2001-2006 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #ifndef _CX_TYPES_H
00022 #define _CX_TYPES_H
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 #include <limits.h>
00029 #include <float.h>
00030 
00031 #include <cxmacros.h>
00032 
00033 CX_BEGIN_DECLS
00034 
00035 /*
00036  * Some mathematical constants. Some strict ISO C implementations
00037  * don't provide them as symbols.
00038  */
00039 
00040 /* Deprecated, use constants from cpl_math_const.h instead. */
00041 
00042 #define CX_PI    3.14159265358979323846e0
00043 
00044 /*
00045  * Limits for numerical data types
00046  */
00047 
00048 #define CX_MINSHORT  SHRT_MIN
00049 #define CX_MAXSHORT  SHRT_MAX
00050 #define CX_MAXUSHORT USHRT_MAX
00051 #define CX_MININT    INT_MIN
00052 #define CX_MAXINT    INT_MAX
00053 #define CX_MAXUINT   UINT_MAX
00054 #define CX_MINLONG   LONG_MIN
00055 #define CX_MAXLONG   LONG_MAX
00056 #define CX_MAXULONG  ULONG_MAX
00057 
00058 #define CX_MINFLOAT  FLT_MIN
00059 #define CX_MAXFLOAT  FLT_MAX
00060 #define CX_MINDOUBLE DBL_MIN
00061 #define CX_MAXDOUBLE DBL_MAX
00062 
00063 
00064 #define CX_MININT64  ((cxint64)  0x8000000000000000)
00065 #define CX_MAXINT64  ((cxint64)  0x7fffffffffffffff)
00066 #define CX_MAXUINT64 ((cxuint64) 0xffffffffffffffff)
00067 
00068 
00069 /*
00070  * Sized types
00071  */
00072 
00073 typedef signed char cxint8;
00074 typedef unsigned char cxuint8;
00075 typedef signed short cxint16;
00076 typedef unsigned short cxuint16;
00077 typedef signed int cxint32;
00078 typedef unsigned int cxuint32;
00079 
00080 
00081 #if defined SIZEOF_LONG && SIZEOF_LONG == 8
00082 CX_GNUC_EXTENSION typedef signed long cxint64;
00083 CX_GNUC_EXTENSION typedef unsigned long cxuint64;
00084 #else
00085 CX_GNUC_EXTENSION typedef signed long long cxint64;
00086 CX_GNUC_EXTENSION typedef unsigned long long cxuint64;
00087 #endif
00088 
00089 #if defined SIZEOF_SIZE_T && SIZEOF_SIZE_T == 8
00090 typedef cxint64 cxssize;
00091 typedef cxuint64 cxsize;
00092 #else
00093 typedef cxint32 cxssize;
00094 typedef cxuint32 cxsize;
00095 #endif
00096 
00097 /*
00098  * For completeness: Definitions for standard types
00099  */
00100 
00101 typedef char cxchar;
00102 typedef short cxshort;
00103 typedef int cxint;
00104 typedef long cxlong;
00105 
00106 typedef unsigned char cxbyte;
00107 
00108 typedef unsigned char cxuchar;
00109 typedef unsigned short cxushort;
00110 typedef unsigned int cxuint;
00111 typedef unsigned long cxulong;
00112 
00113 typedef float cxfloat;
00114 typedef double cxdouble;
00115 
00116 typedef void * cxptr;
00117 typedef const void * cxcptr;
00118 
00119 typedef int cxbool;
00120 
00121 
00122 /*
00123  * Generic, frequently used types.
00124  */
00125 
00126 typedef cxint (*cx_compare_func) (cxcptr a, cxcptr b);
00127 typedef cxint (*cx_compare_data_func) (cxcptr a, cxcptr b, cxptr data);
00128 
00129 typedef cxbool (*cx_equal_func) (cxcptr a, cxcptr b);
00130 
00131 typedef void (*cx_free_func) (cxptr data);
00132 
00133 CX_END_DECLS
00134 
00135 #endif /* _CX_TYPES_H */