C Standard Library Extensions 1.1

cxtypes.h

00001 /* $Id: cxtypes.h,v 1.3 2011/02/21 14:15:31 rpalsa Exp $
00002  *
00003  * This file is part of the ESO C Extension Library
00004  * Copyright (C) 2001-2011 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 #include <cxconfig.h>
00025 #include <cxmacros.h>
00026 
00027 
00028 CX_BEGIN_DECLS
00029 
00030 /*
00031  * Some mathematical constants. Some strict ISO C implementations
00032  * don't provide them as symbols. The constants provide enough
00033  * digits for the 128 bit IEEE quad
00034  */
00035 
00036 #define CX_E     2.7182818284590452353602874713526625L
00037 #define CX_LN2   0.6931471805599453094172321214581766L
00038 #define CX_LN10  2.3025850929940456840179914546843642L
00039 #define CX_PI    3.1415926535897932384626433832795029L
00040 #define CX_PI_2  1.5707963267948966192313216916397514L
00041 #define CX_PI_4  0.7853981633974483096156608458198757L
00042 #define CX_SQRT2 1.4142135623730950488016887242096981L
00043 
00044 
00045 /*
00046  * Minimum and maximum constants for fixed size integer types
00047  */
00048 
00049 #define CX_MININT8    ((cxint8)   0x80)
00050 #define CX_MAXINT8    ((cxint8)   0x7f)
00051 #define CX_MAXUINT8   ((cxuint8)  0xff)
00052 
00053 #define CX_MININT16   ((cxint16)   0x8000)
00054 #define CX_MAXINT16   ((cxint16)   0x7fff)
00055 #define CX_MAXUINT16  ((cxuint16)  0xffff)
00056 
00057 #define CX_MININT32   ((cxint32)   0x80000000)
00058 #define CX_MAXINT32   ((cxint32)   0x7fffffff)
00059 #define CX_MAXUINT32  ((cxuint32)  0xffffffff)
00060 
00061 #define CX_MININT64   ((cxint64)   CX_INT64_CONSTANT(0x8000000000000000))
00062 #define CX_MAXINT64   CX_INT64_CONSTANT(0x7fffffffffffffff)
00063 #define CX_MAXUINT64  CX_INT64_CONSTANT(0xffffffffffffffffU)
00064 
00065 
00066 /*
00067  * For completeness: Definitions for standard types
00068  */
00069 
00070 typedef char  cxchar;
00071 typedef short cxshort;
00072 typedef int   cxint;
00073 typedef long  cxlong;
00074 typedef cxint cxbool;
00075 
00076 typedef unsigned char  cxuchar;
00077 typedef unsigned short cxushort;
00078 typedef unsigned int   cxuint;
00079 typedef unsigned long  cxulong;
00080 typedef cxuchar        cxbyte;
00081 
00082 typedef float  cxfloat;
00083 typedef double cxdouble;
00084 
00085 typedef void * cxptr;
00086 typedef const void * cxcptr;
00087 
00088 
00089 /*
00090  * Generic, frequently used types.
00091  */
00092 
00093 typedef cxint  (*cx_compare_func) (cxcptr a, cxcptr b);
00094 typedef cxint  (*cx_compare_data_func) (cxcptr a, cxcptr b, cxptr data);
00095 typedef cxbool (*cx_equal_func) (cxcptr a, cxcptr b);
00096 typedef void   (*cx_free_func) (cxptr data);
00097 
00098 CX_END_DECLS
00099 
00100 #endif /* _CX_TYPES_H */