Mstdlib-1.24.0
m_types.h
1/* The MIT License (MIT)
2 *
3 * Copyright (c) 2015 Monetra Technologies, LLC.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23
24#ifndef __M_TYPES_H__
25#define __M_TYPES_H__
26
27#include <mstdlib/base/m_defs.h>
28
29/* C89 */
30#include <limits.h> /* U?LONG_MAX */
31#include <stddef.h> /* NULL */
32#include <sys/types.h> /* size_t */
33
34/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
35
36#if defined(__GNUC__)
37# pragma GCC system_header
38#endif
39
40/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
41
42#ifdef _WIN32
43 typedef unsigned __int64 M_uint64;
44 typedef __int64 M_int64;
45# ifdef _WIN64
46 typedef unsigned __int64 M_uintptr;
47 typedef __int64 M_intptr;
48# else
49 typedef unsigned long M_uintptr;
50 typedef long M_intptr;
51# endif
52#else /* ! _WIN32 */
53 typedef unsigned long M_uintptr;
54 typedef long M_intptr;
55 typedef unsigned long long M_uint64;
56 typedef long long M_int64;
57#endif
58
59typedef unsigned int M_uint32;
60typedef signed int M_int32;
61typedef unsigned short M_uint16;
62typedef signed short M_int16;
63typedef unsigned char M_uint8;
64typedef signed char M_int8;
65
66#ifdef _MSC_VER
67 typedef M_intptr ssize_t;
68#endif
69
70#define M_INT8_MAX 127
71#define M_INT16_MAX 32767
72#define M_INT32_MAX 2147483647L
73#define M_INT64_MAX 9223372036854775807LL
74
75#define M_INT8_MIN (-M_INT8_MAX - 1)
76#define M_INT16_MIN (-M_INT16_MAX - 1)
77#define M_INT32_MIN (-M_INT32_MAX - 1L)
78#define M_INT64_MIN (-M_INT64_MAX - 1LL)
79
80#define M_UINT8_MAX (M_INT8_MAX *2 + 1)
81#define M_UINT16_MAX (M_INT16_MAX*2U + 1)
82#define M_UINT32_MAX (M_INT32_MAX*2UL + 1)
83#define M_UINT64_MAX (M_INT64_MAX*2ULL + 1)
84
85#ifdef _WIN64
86# define M_UINTPTR_MAX M_UINT64_MAX
87# define M_INTPTR_MAX M_INT64_MAX
88# define M_INTPTR_MIN M_INT64_MIN
89#else
90# define M_UINTPTR_MAX ULONG_MAX
91# define M_INTPTR_MAX LONG_MAX
92# define M_INTPTR_MIN LONG_MIN
93#endif
94
95#ifndef SSIZE_MAX
96# define SSIZE_MAX M_INTPTR_MAX
97#endif
98#ifndef SSIZE_MIN
99# define SSIZE_MIN M_INTPTR_MIN
100#endif
101#ifndef SIZE_MAX
102# define SIZE_MAX ((size_t)M_UINTPTR_MAX)
103#endif
104
105/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
106
107typedef enum { M_false = 0, M_true = 1, M_FALSE = 0, M_TRUE = 1 } M_bool;
108
109/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
110
111#define M_TIMEOUT_INF M_UINT64_MAX
112
113/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
114
115#endif /* __M_TYPES_H__ */