MySQL  8.0.17
Source Code Documentation
my_inttypes.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2016, 2019, 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  @deprecated Use <stdint.h> instead. Prefer int to sized types.
32 */
33 
34 #include "my_config.h"
35 
36 #ifndef MYSQL_ABI_CHECK
37 #include <stddef.h>
38 #include <stdint.h>
39 #include <sys/types.h>
40 #endif
41 
42 #ifdef _WIN32
43 #include <BaseTsd.h>
44 typedef unsigned int uint;
45 typedef unsigned short ushort;
46 #endif
47 #if !defined(HAVE_ULONG)
48 typedef unsigned long ulong; /* Short for unsigned long */
49 #endif
50 
51 typedef unsigned char uchar; /* Short for unsigned char */
52 
53 // Legacy typedefs. Prefer the standard intXX_t (or std::intXX_t) to these.
54 // Note that the Google C++ style guide says you should generally not use
55 // unsigned types unless you need defined wraparound semantics or store
56 // things like bitfields. Your default choice of type should be simply int.
57 typedef int8_t int8;
58 typedef uint8_t uint8;
59 typedef int16_t int16;
60 typedef uint16_t uint16;
61 typedef int32_t int32;
62 typedef uint32_t uint32;
63 typedef intptr_t intptr;
64 
65 // These are not defined as [u]int64_t, since we have code that assumes that
66 // [u]int64 == [unsigned] long long. This is also legacy behavior; use
67 // [u]int64_t when possible.
68 typedef long long int64;
69 typedef unsigned long long uint64;
70 
71 // We have both ulonglong and my_ulonglong, which can be different. Don't use
72 // any of them in new code; use [u]int64_t.
73 typedef long long int longlong;
74 typedef unsigned long long int ulonglong;
75 #if defined(_WIN32)
76 typedef unsigned __int64 my_ulonglong;
77 #else
78 typedef unsigned long long my_ulonglong;
79 #endif
80 
81 #if defined(_WIN32)
82 typedef unsigned long long my_off_t;
83 #else
84 #if SIZEOF_OFF_T > 4
85 typedef ulonglong my_off_t;
86 #else
87 typedef unsigned long my_off_t;
88 #endif
89 #endif /*_WIN32*/
90 #define MY_FILEPOS_ERROR (~(my_off_t)0)
91 
92 #if defined(_WIN32)
93 /*
94  off_t is 32 bit long. We do not use C runtime functions
95  with off_t but native Win32 file IO APIs, that work with
96  64 bit offsets.
97 */
98 #undef SIZEOF_OFF_T
99 #define SIZEOF_OFF_T 8
100 #endif
101 
102 #define INT_MIN64 (~0x7FFFFFFFFFFFFFFFLL)
103 #define INT_MAX64 0x7FFFFFFFFFFFFFFFLL
104 #define INT_MIN32 (~0x7FFFFFFFL)
105 #define INT_MAX32 0x7FFFFFFFL
106 #define UINT_MAX32 0xFFFFFFFFL
107 #define INT_MIN24 (~0x007FFFFF)
108 #define INT_MAX24 0x007FFFFF
109 #define UINT_MAX24 0x00FFFFFF
110 #define INT_MIN16 (~0x7FFF)
111 #define INT_MAX16 0x7FFF
112 #define UINT_MAX16 0xFFFF
113 #define INT_MIN8 (~0x7F)
114 #define INT_MAX8 0x7F
115 #define UINT_MAX8 0xFF
116 
117 #ifndef SIZE_T_MAX
118 #define SIZE_T_MAX (~((size_t)0))
119 #endif
120 
121 typedef int myf; /* Type of MyFlags in my_funcs */
122 
123 /* Macros for converting *constants* to the right type */
124 #define MYF(v) (myf)(v)
125 
126 /* Length of decimal number represented by INT32. */
127 #define MY_INT32_NUM_DECIMAL_DIGITS 11U
128 
129 /* Length of decimal number represented by INT64. */
130 #define MY_INT64_NUM_DECIMAL_DIGITS 21U
131 
132 #ifdef _WIN32
133 typedef SSIZE_T ssize_t;
134 #endif
135 
136 /*
137  This doesn't really belong here, but it was the only reasonable place
138  at the time.
139 */
140 #ifdef _WIN32
141 typedef int sigset_t;
142 #endif
143 
144 #endif // MY_INTTYPES_INCLUDED
unsigned long long int ulonglong
Definition: my_inttypes.h:74
unsigned char uchar
Definition: my_inttypes.h:51
unsigned long long uint64
Definition: my_inttypes.h:69
unsigned long long my_ulonglong
Definition: my_inttypes.h:78
uint16_t uint16
Definition: my_inttypes.h:60
unsigned int uint
Definition: uca-dump.cc:29
long long int longlong
Definition: my_inttypes.h:73
uint32_t uint32
Definition: my_inttypes.h:62
uint8_t uint8
Definition: my_inttypes.h:58
unsigned long my_off_t
Definition: my_inttypes.h:87
int myf
Definition: my_inttypes.h:121
int32_t int32
Definition: my_inttypes.h:61
intptr_t intptr
Definition: my_inttypes.h:63
long long int64
Definition: my_inttypes.h:68
int8_t int8
Definition: my_inttypes.h:57
unsigned long ulong
Definition: my_inttypes.h:48
int16_t int16
Definition: my_inttypes.h:59