C Standard Library Extensions 1.3.1
cxtypes.h
1/*
2 * This file is part of the ESO C Extension Library
3 * Copyright (C) 2001-2026 European Southern Observatory
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef _CX_TYPES_H
20#define _CX_TYPES_H
21
22#include "cxconfig.h"
23#include "cxmacros.h"
24
25
26CX_BEGIN_DECLS
27
28/*
29 * Some mathematical constants. Some strict ISO C implementations
30 * don't provide them as symbols. The constants provide enough
31 * digits for the 128 bit IEEE quad
32 */
33
34#define CX_E 2.7182818284590452353602874713526625L
35#define CX_LN2 0.6931471805599453094172321214581766L
36#define CX_LN10 2.3025850929940456840179914546843642L
37#define CX_PI 3.1415926535897932384626433832795029L
38#define CX_PI_2 1.5707963267948966192313216916397514L
39#define CX_PI_4 0.7853981633974483096156608458198757L
40#define CX_SQRT2 1.4142135623730950488016887242096981L
41
42
43/*
44 * Minimum and maximum constants for fixed size integer types
45 */
46
47#define CX_MININT8 ((cxint8)0x80)
48#define CX_MAXINT8 ((cxint8)0x7f)
49#define CX_MAXUINT8 ((cxuint8)0xff)
50
51#define CX_MININT16 ((cxint16)0x8000)
52#define CX_MAXINT16 ((cxint16)0x7fff)
53#define CX_MAXUINT16 ((cxuint16)0xffff)
54
55#define CX_MININT32 ((cxint32)0x80000000)
56#define CX_MAXINT32 ((cxint32)0x7fffffff)
57#define CX_MAXUINT32 ((cxuint32)0xffffffff)
58
59#define CX_MININT64 ((cxint64)CX_INT64_CONSTANT(0x8000000000000000))
60#define CX_MAXINT64 CX_INT64_CONSTANT(0x7fffffffffffffff)
61#define CX_MAXUINT64 CX_INT64_CONSTANT(0xffffffffffffffffU)
62
63
64/*
65 * For completeness: Definitions for standard types
66 */
67
68typedef char cxchar;
69typedef short cxshort;
70typedef int cxint;
71typedef long cxlong;
72typedef long long cxllong;
73typedef cxint cxbool;
74
75typedef unsigned char cxuchar;
76typedef unsigned short cxushort;
77typedef unsigned int cxuint;
78typedef unsigned long cxulong;
79typedef unsigned long long cxullong;
80typedef cxuchar cxbyte;
81
82typedef float cxfloat;
83typedef double cxdouble;
84
85typedef void *cxptr;
86typedef const void *cxcptr;
87
88
89/*
90 * Generic, frequently used types.
91 */
92
93typedef cxint (*cx_compare_func)(cxcptr a, cxcptr b);
94typedef cxint (*cx_compare_data_func)(cxcptr a, cxcptr b, cxptr data);
95typedef cxbool (*cx_equal_func)(cxcptr a, cxcptr b);
96typedef void (*cx_free_func)(cxptr data);
97
98CX_END_DECLS
99
100#endif /* _CX_TYPES_H */