1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
|
/*
* Dktypes.c
*
* $Id$
*
* Global types
*
* This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
* project.
*
* Copyright (C) 1998-2018 OpenLink Software
*
* This project is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; only version 2 of the License, dated June 1991.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef _DKTYPES_H
#define _DKTYPES_H
#include <math.h>
#ifdef HAVE_STDINT_H
#include <stdint.h> /* for INT64_MAX etc */
#endif
#ifdef _MSC_VER
#include <limits.h>
#endif
#ifndef _ITYPES_H
# if SIZEOF_LONG == 4
# define int32 long
# define uint32 unsigned long
# elif SIZEOF_INT == 4
# define int32 int
# define uint32 unsigned int
# elif defined (ULONG_MAX) && ULONG_MAX == 4294967295U /* (4 bytes) */
# define int32 long
# define uint32 unsigned long
# elif defined (UINT_MAX) && UINT_MAX == 4294967295U /* (4 bytes) */
# define int32 int
# define uint32 unsigned int
# elif defined (MAXLONG) && MAXLONG == 2147483647U /* (4 bytes) */
# define int32 long
# define uint32 unsigned long
# else
# error Unable to guess the int32/uint32 types. Try including the <limits.h>
# endif
#endif
#ifndef INT16_MAX
# define INT16_MAX (32767)
#endif
#ifndef INT16_MIN
# define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef INT64_MIN
#define INT64_MIN (-9223372036854775807LL-1)
#endif
#ifndef INT64_MAX
# define INT64_MAX (9223372036854775807LL)
#endif
/* true for most compilers, subject to change */
#if 1
# if SIZEOF_SHORT == 2
#define uint16 unsigned short
# endif
# if SIZEOF_CHAR == 1
#define uint8 unsigned char
# endif /* SIZEOF_CHAR */
#endif /* 1 */
#ifndef uint16
# error Unable to guess uint16 type
#endif
#ifndef uint8
# error Unable to guess uint8 type
#endif
#if defined (WIN32) && !defined (_PHP) && !defined(BIF_SAMPLES)
#define int64 __int64
#elif SIZEOF_LONG_LONG == 8
#define int64 long long
#endif
#if defined (_WIN64)
#define ptrlong int64 /* integer type with size of pointer */
#define uptrlong unsigned int64 /* integer type with size of pointer */
#else
#define ptrlong long /* integer type with size of pointer */
#define uptrlong unsigned long /* integer type with size of pointer */
#endif
#define ptr_long ptrlong
#define ptr_ulong uptrlong
#define uint64 unsigned int64
#if defined (OS2) || defined (WIN32)
# define ssize_t signed int
# ifndef _ITYPES_H
typedef char * caddr_t;
# endif
#endif
typedef const char * ccaddr_t;
typedef unsigned char dtp_t;
/* Interface to a certain communication device */
typedef struct device_s device_t;
/* Interface to a certain session */
typedef struct session_s session_t;
#if 0
typedef struct du_thread_s du_thread_t;
typedef struct du_semaphore_s du_semaphore_t;
typedef struct du_semaphore_s semaphore_t;
typedef struct dk_mutex_s dk_mutex_t;
#endif
/* General type for specifying timeout values for select, read and write */
typedef struct
{
int32 to_sec; /* seconds */
int32 to_usec; /* microseconds */
} timeout_t;
#ifdef FILE64
#define OFF_T off64_t
#define LSEEK(x,y,z) lseek64((x),(y),(z))
#define FTRUNCATE(x,y) ftruncate64((x),(y))
#define V_STAT(x,y) stat64((x), (y))
#define V_FSTAT(x,y) fstat64((x), (y))
typedef struct stat64 STAT_T;
#else /* FILE64 */
#ifdef WIN32
#define OFF_T __int64
#define LSEEK(x,y,z) _lseeki64((x),(y),(z))
#define FTRUNCATE(x,y) ftruncate64((x),(y))
#define V_STAT(x,y) _stati64((x), (y))
#define V_FSTAT(x,y) _fstati64((x), (y))
typedef struct _stati64 STAT_T;
#else /* WIN32 */
#define OFF_T off_t
#define LSEEK(x,y,z) lseek((x),(y),(z))
#define FTRUNCATE(x,y) ftruncate((x),(y))
#define V_STAT(x,y) stat((x), (y))
#define V_FSTAT(x,y) fstat((x), (y))
typedef struct stat STAT_T;
#endif
#endif /* FILE64 */
#if defined (WIN32)
#define OFF_T_PRINTF_FMT "%I64d"
#define OFF_T_PRINTF_DTP unsigned __int64
#elif defined (ULLONG_MAX)
#define OFF_T_PRINTF_FMT "%llu"
#define OFF_T_PRINTF_DTP unsigned long long
#else
#define OFF_T_PRINTF_FMT "%lu"
#define OFF_T_PRINTF_DTP unsigned long
#endif
#ifndef int64
#ifdef WIN32
typedef __int64 int64;
#else
typedef long long int64;
#endif
#endif
#ifdef _WIN32
/* VC10 */
//#include <float.h>
//#define DBL_POS_INF ((float)1e300)
//#define DBL_NEG_INF (-DBL_POS_INF)
//#define DBL_NAN ((float)1e300 * 0.0f)
//#define isfinite(d) _finite(d)
//#define isnan(d) _isnan(d)
//#define IS_DOUBLE_OVERFLOW(d) (!isfinite(d))
//#define IS_FLOAT_OVERFLOW(f) (!isfinite(d))
__inline double
round (double x)
{
return x < 0 ? floor (x) : ceil (x);
}
/* VC12 */
#include <math.h>
#define DBL_POS_INF INFINITY
#define DBL_NEG_INF (-INFINITY)
#define DBL_NAN NAN
#define IS_DOUBLE_OVERFLOW(d) (!isfinite(d))
#define IS_FLOAT_OVERFLOW(f) (!isfinite(d))
#else
#ifndef isfinite
#ifdef _finite
#define isfinite(val) _finite (val)
#else
#error "Neither isfinite() nor _finite() is defined in standard headers"
#endif
#endif
#ifndef DBL_POS_INF
#if defined(INFINITY)
#define DBL_POS_INF (INFINITY)
#elif defined(DBL_MAX)
#define DBL_POS_INF (DBL_MAX + DBL_MAX)
#elif defined (HUGE)
#define DBL_POS_INF (HUGE + HUGE)
#else
#define DBL_POS_INF ((double)(1e1000000))
#endif
#endif
#ifndef DBL_NEG_INF
#define DBL_NEG_INF (-DBL_POS_INF)
#endif
#ifndef DBL_NAN
#if defined(NAN)
#define DBL_NAN (NAN)
#else
#define DBL_NAN (DBL_POS_INF - DBL_POS_INF)
#endif
#endif
#endif
struct mem_pool_s;
typedef struct mem_pool_s mem_pool_t;
#endif
|