FreeTDS API: include/tds_sysdep_public.h Source File

FreeTDS API

Loading...
Searching...
No Matches
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(_MSC_VER) && defined(__cplusplus) && __cplusplus >= 201103L) || \
29 (defined(_MSC_VER) && _MSC_VER >= 1600) || \
30 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
31# include <stdint.h>
32#elif (defined(__sun) && defined(__SVR4)) || defined(__hpux)
33# include <inttypes.h>
34#else
35typedef signed char int8_t; /* 8-bit int */
36typedef unsigned char uint8_t; /* 8-bit int */
37/*
38 * This is where platform-specific changes need to be made.
39 */
40# if defined(_WIN32)
41# include <winsock2.h>
42# include <ws2tcpip.h>
43# include <windows.h>
44 typedef signed short int16_t; /* 16-bit int */
45 typedef unsigned short uint16_t; /* 16-bit int */
46 typedef signed int int32_t; /* 32-bit int */
47 typedef unsigned int uint32_t; /* 32-bit int */
48 typedef signed __int64 int64_t; /* 64-bit int */
49 typedef unsigned __int64 uint64_t; /* 64-bit int */
50# else /* defined(_WIN32) */
51 typedef signed short int16_t; /* 16-bit int */
52 typedef unsigned short uint16_t; /* 16-bit int */
53 typedef signed int int32_t; /* 32-bit int */
54 typedef unsigned int uint32_t; /* 32-bit int */
55 typedef signed long int64_t; /* 64-bit int */
56 typedef unsigned long uint64_t; /* 64-bit int */
57# endif
58#endif
59
60#include <float.h>
61
62/* try to understand float sizes using float.h constants */
63#if FLT_RADIX == 2
64# if FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128
65# define tds_sysdep_real32_type float /* 32-bit real */
66# elif DBL_MANT_DIG == 24 && DBL_MAX_EXP == 128
67# define tds_sysdep_real32_type double /* 32-bit real */
68# elif LDBL_MANT_DIG == 24 && LDBL_MAX_EXP == 128
69# define tds_sysdep_real32_type long double /* 32-bit real */
70# endif
71# if FLT_MANT_DIG == 53 && FLT_MAX_EXP == 1024
72# define tds_sysdep_real64_type float /* 64-bit real */
73# elif DBL_MANT_DIG == 53 && DBL_MAX_EXP == 1024
74# define tds_sysdep_real64_type double /* 64-bit real */
75# elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
76# define tds_sysdep_real64_type long double /* 64-bit real */
77# endif
78# if !defined(tds_sysdep_real32_type) || !defined(tds_sysdep_real64_type)
79# error Some float type was not found!
80# endif
81#else
82# if FLT_DIG == 6 && FLT_MAX_10_EXP == 38
83# define tds_sysdep_real32_type float /* 32-bit real */
84# elif DBL_DIG == 6 && DBL_MAX_10_EXP == 38
85# define tds_sysdep_real32_type double /* 32-bit real */
86# elif LDBL_DIG == 6 && LDBL_MAX_10_EXP == 38
87# define tds_sysdep_real32_type long double /* 32-bit real */
88# endif
89# if FLT_DIG == 15 && FLT_MAX_10_EXP == 308
90# define tds_sysdep_real64_type float /* 64-bit real */
91# elif DBL_DIG == 15 && DBL_MAX_10_EXP == 308
92# define tds_sysdep_real64_type double /* 64-bit real */
93# elif LDBL_DIG == 15 && LDBL_MAX_10_EXP == 308
94# define tds_sysdep_real64_type long double /* 64-bit real */
95# endif
96#endif
97
98/* fall back to configure.ac types */
99#ifndef tds_sysdep_real32_type
100#define tds_sysdep_real32_type float /* 32-bit real */
101#endif /* !tds_sysdep_real32_type */
102
103#ifndef tds_sysdep_real64_type
104#define tds_sysdep_real64_type double /* 64-bit real */
105#endif /* !tds_sysdep_real64_type */
106
107#if !defined(MSDBLIB) && !defined(SYBDBLIB)
108#define SYBDBLIB 1
109#endif
110#if defined(MSDBLIB) && defined(SYBDBLIB)
111#error MSDBLIB and SYBDBLIB cannot both be defined
112#endif
113
114#endif /* _tds_sysdep_public_h_ */