MySQL  8.0.16
Source Code Documentation
my_inttypes.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License, version 2.0,
6  as published by the Free Software Foundation.
7 
8  This program is also distributed with certain software (including
9  but not limited to OpenSSL) that is licensed under separate terms,
10  as designated in a particular file or component or in included license
11  documentation. The authors of MySQL hereby grant you an additional
12  permission to link the program and your derivative works with the
13  separately licensed software that they have included with MySQL.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License, version 2.0, for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23 
24 #ifndef MY_INTTYPES_INCLUDED
25 #define MY_INTTYPES_INCLUDED
26 
27 /**
28  @file include/my_inttypes.h
29  Some integer typedefs for easier portability.
30 */
31 
32 #include "my_config.h"
33 
34 #ifndef MYSQL_ABI_CHECK
35 #include <stddef.h>
36 #include <stdint.h>
37 #include <sys/types.h>
38 #endif
39 
40 #ifdef _WIN32
41 #include <BaseTsd.h>
42 typedef unsigned int uint;
43 typedef unsigned short ushort;
44 #endif
45 #if !defined(HAVE_ULONG)
46 typedef unsigned long ulong; /* Short for unsigned long */
47 #endif
48 
49 typedef unsigned char uchar; /* Short for unsigned char */
50 typedef signed char int8; /* Signed integer >= 8 bits */
51 typedef unsigned char uint8; /* Unsigned integer >= 8 bits */
52 typedef short int16;
53 typedef unsigned short uint16;
54 #if SIZEOF_INT == 4
55 typedef int int32;
56 typedef unsigned int uint32;
57 #elif SIZEOF_LONG == 4
58 typedef long int32;
59 typedef unsigned long uint32;
60 #else
61 #error Neither int or long is of 4 bytes width
62 #endif
63 
64 /*
65  Using [unsigned] long long is preferable as [u]longlong because we use
66  [unsigned] long long unconditionally in many places,
67  for example in constants with [U]LL suffix.
68 */
69 typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
70 typedef long long int longlong;
71 typedef longlong int64;
72 typedef ulonglong uint64;
73 
74 #if defined(_WIN32)
75 typedef unsigned __int64 my_ulonglong;
76 #else
77 typedef unsigned long long my_ulonglong;
78 #endif
79 
80 typedef intptr_t intptr;
81 
82 #if defined(_WIN32)
83 typedef unsigned long long my_off_t;
84 #else
85 #if SIZEOF_OFF_T > 4
86 typedef ulonglong my_off_t;
87 #else
88 typedef unsigned long my_off_t;
89 #endif
90 #endif /*_WIN32*/
91 #define MY_FILEPOS_ERROR (~(my_off_t)0)
92 
93 #if defined(_WIN32)
94 /*
95  off_t is 32 bit long. We do not use C runtime functions
96  with off_t but native Win32 file IO APIs, that work with
97  64 bit offsets.
98 */
99 #undef SIZEOF_OFF_T
100 #define SIZEOF_OFF_T 8
101 #endif
102 
103 #define INT_MIN64 (~0x7FFFFFFFFFFFFFFFLL)
104 #define INT_MAX64 0x7FFFFFFFFFFFFFFFLL
105 #define INT_MIN32 (~0x7FFFFFFFL)
106 #define INT_MAX32 0x7FFFFFFFL
107 #define UINT_MAX32 0xFFFFFFFFL
108 #define INT_MIN24 (~0x007FFFFF)
109 #define INT_MAX24 0x007FFFFF
110 #define UINT_MAX24 0x00FFFFFF
111 #define INT_MIN16 (~0x7FFF)
112 #define INT_MAX16 0x7FFF
113 #define UINT_MAX16 0xFFFF
114 #define INT_MIN8 (~0x7F)
115 #define INT_MAX8 0x7F
116 #define UINT_MAX8 0xFF
117 
118 #ifndef SIZE_T_MAX
119 #define SIZE_T_MAX (~((size_t)0))
120 #endif
121 
122 /*
123  Max size that must be added to a so that we know Size to make
124  adressable obj.
125 */
126 typedef ptrdiff_t my_ptrdiff_t;
127 
128 typedef int myf; /* Type of MyFlags in my_funcs */
129 
130 /* Macros for converting *constants* to the right type */
131 #define MYF(v) (myf)(v)
132 
133 /* Length of decimal number represented by INT32. */
134 #define MY_INT32_NUM_DECIMAL_DIGITS 11U
135 
136 /* Length of decimal number represented by INT64. */
137 #define MY_INT64_NUM_DECIMAL_DIGITS 21U
138 
139 #ifdef _WIN32
140 typedef SSIZE_T ssize_t;
141 #endif
142 
143 /*
144  This doesn't really belong here, but it was the only reasonable place
145  at the time.
146 */
147 #ifdef _WIN32
148 typedef int sigset_t;
149 #endif
150 
151 #endif // MY_INTTYPES_INCLUDED
ulonglong uint64
Definition: my_inttypes.h:72
unsigned long long int ulonglong
Definition: my_inttypes.h:69
unsigned char uchar
Definition: my_inttypes.h:49
longlong int64
Definition: my_inttypes.h:71
unsigned char uint8
Definition: my_inttypes.h:51
signed char int8
Definition: my_inttypes.h:50
short int16
Definition: my_inttypes.h:52
unsigned long long my_ulonglong
Definition: my_inttypes.h:77
unsigned int uint
Definition: uca-dump.cc:29
long long int longlong
Definition: my_inttypes.h:70
unsigned long my_off_t
Definition: my_inttypes.h:88
int myf
Definition: my_inttypes.h:128
intptr_t intptr
Definition: my_inttypes.h:80
ptrdiff_t my_ptrdiff_t
Definition: my_inttypes.h:126
unsigned short uint16
Definition: my_inttypes.h:53
unsigned long ulong
Definition: my_inttypes.h:46