• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _SYS_TYPES_H_
30 #define _SYS_TYPES_H_
31 
32 #include <sys/cdefs.h>
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 
37 #include <linux/types.h>
38 #include <linux/posix_types.h>
39 
40 #include <bits/pthread_types.h>
41 
42 /* gids, uids, and pids are all 32-bit. */
43 typedef __kernel_gid32_t __gid_t;
44 typedef __gid_t gid_t;
45 typedef __kernel_uid32_t __uid_t;
46 typedef __uid_t uid_t;
47 typedef __kernel_pid_t __pid_t;
48 typedef __pid_t pid_t;
49 typedef uint32_t __id_t;
50 typedef __id_t id_t;
51 
52 typedef unsigned long blkcnt_t;
53 typedef unsigned long blksize_t;
54 typedef __kernel_caddr_t caddr_t;
55 typedef __kernel_clock_t clock_t;
56 
57 typedef __kernel_clockid_t __clockid_t;
58 typedef __clockid_t clockid_t;
59 
60 typedef __kernel_daddr_t daddr_t;
61 typedef unsigned long fsblkcnt_t;
62 typedef unsigned long fsfilcnt_t;
63 
64 typedef __kernel_mode_t __mode_t;
65 typedef __mode_t mode_t;
66 
67 typedef __kernel_key_t __key_t;
68 typedef __key_t key_t;
69 
70 typedef __kernel_ino_t __ino_t;
71 typedef __ino_t ino_t;
72 
73 typedef uint64_t ino64_t;
74 
75 typedef uint32_t __nlink_t;
76 typedef __nlink_t nlink_t;
77 
78 typedef void* __timer_t;
79 typedef __timer_t timer_t;
80 
81 typedef __kernel_suseconds_t __suseconds_t;
82 typedef __suseconds_t suseconds_t;
83 
84 /* useconds_t is 32-bit on both LP32 and LP64. */
85 typedef uint32_t __useconds_t;
86 typedef __useconds_t useconds_t;
87 
88 #if !defined(__LP64__)
89 /* This historical accident means that we had a 32-bit dev_t on 32-bit architectures. */
90 typedef uint32_t dev_t;
91 #else
92 typedef uint64_t dev_t;
93 #endif
94 
95 /* This historical accident means that we had a 32-bit time_t on 32-bit architectures. */
96 typedef __kernel_time_t __time_t;
97 typedef __time_t time_t;
98 
99 /* This historical accident means that we had a 32-bit off_t on 32-bit architectures. */
100 /* See https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md */
101 #if defined(__USE_FILE_OFFSET64) || defined(__LP64__)
102 typedef int64_t off_t;
103 typedef off_t loff_t;
104 typedef loff_t off64_t;
105 #else
106 typedef __kernel_off_t off_t;
107 typedef __kernel_loff_t loff_t;
108 typedef loff_t off64_t;
109 #endif
110 
111 #if !defined(__LP64__)
112 /* This historical accident means that we had a signed socklen_t on 32-bit architectures. */
113 typedef int32_t __socklen_t;
114 #else
115 /* LP64 still has a 32-bit socklen_t. */
116 typedef uint32_t __socklen_t;
117 #endif
118 typedef __socklen_t socklen_t;
119 
120 typedef __builtin_va_list __va_list;
121 
122 #ifndef _SSIZE_T_DEFINED_
123 #define _SSIZE_T_DEFINED_
124 /* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you
125  * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is
126  * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI
127  * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until
128  * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */
129 typedef __kernel_ssize_t ssize_t;
130 #endif
131 
132 typedef unsigned int        uint_t;
133 typedef unsigned int        uint;
134 
135 #if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
136 typedef unsigned char  u_char;
137 typedef unsigned short u_short;
138 typedef unsigned int   u_int;
139 typedef unsigned long  u_long;
140 
141 typedef uint32_t u_int32_t;
142 typedef uint16_t u_int16_t;
143 typedef uint8_t  u_int8_t;
144 typedef uint64_t u_int64_t;
145 #endif
146 
147 #endif
148