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