Debian Codegraph @

crt/aws-c-common/include/aws/common/stdint.h

raw symbols SCIP
1 #ifndef AWS_COMMON_STDINT_H
2 #define AWS_COMMON_STDINT_H
3 /**
4 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: Apache-2.0.
6 */
7
8 #include <aws/common/assert.h>
9 #include <stddef.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 #ifndef NO_STDINT
14 # include <stdint.h> /* NOLINT(fuchsia-restrict-system-includes) */
15 /* Android defines SIZE_MAX in limits.h, not stdint.h */
16 # ifdef ANDROID
17 # include <limits.h>
18 # endif
19 #else
20 # if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__ia64__) || defined(__powerpc64__)
21 # define PTR_SIZE 8
22 # else
23 # define PTR_SIZE 4
24 # endif
25
26 typedef signed char int8_t;
27 typedef short int int16_t;
28 typedef int int32_t;
29 # if (PTR_SIZE == 8)
30 typedef long int int64_t;
31 # else
32 typedef long long int int64_t;
33 # endif /* (PTR_SIZE == 8) */
34
35 typedef unsigned char uint8_t;
36 typedef unsigned short int uint16_t;
37
38 typedef unsigned int uint32_t;
39
40 # if (PTR_SIZE == 8)
41 typedef unsigned long int uint64_t;
42 # else
43 typedef unsigned long long int uint64_t;
44 # endif /* (PTR_SIZE == 8) */
45
46 # if (PTR_SIZE == 8)
47 typedef long int intptr_t;
48 typedef unsigned long int uintptr_t;
49 # else
50 typedef int intptr_t;
51 typedef unsigned int uintptr_t;
52 # endif
53
54 # if (PTR_SIZE == 8)
55 # define __INT64_C(c) c##L
56 # define __UINT64_C(c) c##UL
57 # else
58 # define __INT64_C(c) c##LL
59 # define __UINT64_C(c) c##ULL
60 # endif
61
62 # define INT8_MIN (-128)
63 # define INT16_MIN (-32767 - 1)
64 # define INT32_MIN (-2147483647 - 1)
65 # define INT64_MIN (-__INT64_C(9223372036854775807) - 1)
66 # define INT8_MAX (127)
67 # define INT16_MAX (32767)
68 # define INT32_MAX (2147483647)
69 # define INT64_MAX (__INT64_C(9223372036854775807))
70 # define UINT8_MAX (255)
71 # define UINT16_MAX (65535)
72 # define UINT32_MAX (4294967295U)
73 # define UINT64_MAX (__UINT64_C(18446744073709551615))
74
75 AWS_STATIC_ASSERT(sizeof(uint64_t) == 8);
76 AWS_STATIC_ASSERT(sizeof(uint32_t) == 4);
77 AWS_STATIC_ASSERT(sizeof(uint16_t) == 2);
78 AWS_STATIC_ASSERT(sizeof(uint8_t) == 1);
79 AWS_STATIC_ASSERT(sizeof(int64_t) == 8);
80 AWS_STATIC_ASSERT(sizeof(int32_t) == 4);
81 AWS_STATIC_ASSERT(sizeof(int16_t) == 2);
82 AWS_STATIC_ASSERT(sizeof(int8_t) == 1);
83 AWS_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(void *));
84 AWS_STATIC_ASSERT(sizeof(intptr_t) == sizeof(void *));
85 AWS_STATIC_ASSERT(sizeof(char) == 1);
86 #endif /* NO_STDINT */
87
88 /**
89 * @deprecated Use int64_t instead for offsets in public APIs.
90 */
91 typedef int64_t aws_off_t;
92
93 #endif /* AWS_COMMON_STDINT_H */