FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
tds_sysdep_public.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-2011 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tds_sysdep_public_h_
21 #define _tds_sysdep_public_h_
22 
23 /*
24  * This file is publicly installed.
25  * MUST not include config.h
26  */
27 
28 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
29 # include <stdint.h>
30 #else
31 typedef signed char int8_t; /* 8-bit int */
32 typedef unsigned char uint8_t; /* 8-bit int */
33 /*
34  * This is where platform-specific changes need to be made.
35  */
36 # if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
37 # include <winsock2.h>
38 # include <ws2tcpip.h>
39 # include <windows.h>
40  typedef signed short int16_t; /* 16-bit int */
41  typedef unsigned short uint16_t; /* 16-bit int */
42  typedef signed int int32_t; /* 32-bit int */
43  typedef unsigned int uint32_t; /* 32-bit int */
44  typedef signed __int64 int64_t; /* 64-bit int */
45  typedef unsigned __int64 uint64_t; /* 64-bit int */
46 # if !defined(WIN64) && !defined(_WIN64)
47  typedef signed int intptr_t; /* 32-bit int */
48  typedef unsigned int uintptr_t; /* 32-bit int */
49 # else
50  typedef signed __int64 intptr_t; /* 64-bit int */
51  typedef unsigned __int64 uintptr_t; /* 64-bit int */
52 # endif
53 # else /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */
54  typedef signed short int16_t; /* 16-bit int */
55  typedef unsigned short uint16_t; /* 16-bit int */
56  typedef signed int int32_t; /* 32-bit int */
57  typedef unsigned int uint32_t; /* 32-bit int */
58  typedef signed long int64_t; /* 64-bit int */
59  typedef unsigned long uint64_t; /* 64-bit int */
60  typedef signed long intptr_t;
61  typedef unsigned long uintptr_t;
62 # endif
63 #endif
64 
65 #include <float.h>
66 
67 /* try to understand float sizes using float.h constants */
68 #if FLT_RADIX == 2
69 # if FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128
70 # define tds_sysdep_real32_type float /* 32-bit real */
71 # elif DBL_MANT_DIG == 24 && DBL_MAX_EXP == 128
72 # define tds_sysdep_real32_type double /* 32-bit real */
73 # elif LDBL_MANT_DIG == 24 && LDBL_MAX_EXP == 128
74 # define tds_sysdep_real32_type long double /* 32-bit real */
75 # endif
76 # if FLT_MANT_DIG == 53 && FLT_MAX_EXP == 1024
77 # define tds_sysdep_real64_type float /* 64-bit real */
78 # elif DBL_MANT_DIG == 53 && DBL_MAX_EXP == 1024
79 # define tds_sysdep_real64_type double /* 64-bit real */
80 # elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
81 # define tds_sysdep_real64_type long double /* 64-bit real */
82 # endif
83 # if !defined(tds_sysdep_real32_type) || !defined(tds_sysdep_real64_type)
84 # error Some float type was not found!
85 # endif
86 #else
87 # if FLT_DIG == 6 && FLT_MAX_10_EXP == 38
88 # define tds_sysdep_real32_type float /* 32-bit real */
89 # elif DBL_DIG == 6 && DBL_MAX_10_EXP == 38
90 # define tds_sysdep_real32_type double /* 32-bit real */
91 # elif LDBL_DIG == 6 && LDBL_MAX_10_EXP == 38
92 # define tds_sysdep_real32_type long double /* 32-bit real */
93 # endif
94 # if FLT_DIG == 15 && FLT_MAX_10_EXP == 308
95 # define tds_sysdep_real64_type float /* 64-bit real */
96 # elif DBL_DIG == 15 && DBL_MAX_10_EXP == 308
97 # define tds_sysdep_real64_type double /* 64-bit real */
98 # elif LDBL_DIG == 15 && LDBL_MAX_10_EXP == 308
99 # define tds_sysdep_real64_type long double /* 64-bit real */
100 # endif
101 #endif
102 
103 /* fall back to configure.ac types */
104 #ifndef tds_sysdep_real32_type
105 #define tds_sysdep_real32_type float /* 32-bit real */
106 #endif /* !tds_sysdep_real32_type */
107 
108 #ifndef tds_sysdep_real64_type
109 #define tds_sysdep_real64_type double /* 64-bit real */
110 #endif /* !tds_sysdep_real64_type */
111 
112 #if !defined(MSDBLIB) && !defined(SYBDBLIB)
113 #define SYBDBLIB 1
114 #endif
115 #if defined(MSDBLIB) && defined(SYBDBLIB)
116 #error MSDBLIB and SYBDBLIB cannot both be defined
117 #endif
118 
119 #endif /* _tds_sysdep_public_h_ */