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#ifndef _SYS_TYPES_H_
29#define _SYS_TYPES_H_
30
31#include <stddef.h>
32#include <stdint.h>
33#include <sys/cdefs.h>
34
35#include <linux/posix_types.h>
36#include <asm/types.h>
37#include <linux/types.h>
38#include <machine/kernel.h>
39
40typedef __u32    __kernel_dev_t;
41
42/* be careful with __kernel_gid_t and __kernel_uid_t
43 * these are defined as 16-bit for legacy reason, but
44 * the kernel uses 32-bits instead.
45 *
46 * 32-bit values are required for Android, so use
47 * __kernel_uid32_t and __kernel_gid32_t
48 */
49
50typedef __kernel_blkcnt_t    blkcnt_t;
51typedef __kernel_blksize_t   blksize_t;
52typedef __kernel_clock_t     clock_t;
53typedef __kernel_clockid_t   clockid_t;
54typedef __kernel_dev_t       dev_t;
55typedef __kernel_fsblkcnt_t  fsblkcnt_t;
56typedef __kernel_fsfilcnt_t  fsfilcnt_t;
57typedef __kernel_gid32_t     gid_t;
58typedef __kernel_id_t        id_t;
59typedef __kernel_ino_t       ino_t;
60typedef __kernel_key_t       key_t;
61typedef __kernel_mode_t      mode_t;
62typedef __kernel_nlink_t	 nlink_t;
63#ifndef _OFF_T_DEFINED_
64#define _OFF_T_DEFINED_
65typedef __kernel_off_t       off_t;
66#endif
67typedef __kernel_loff_t      loff_t;
68typedef loff_t               off64_t;  /* GLibc-specific */
69
70typedef __kernel_pid_t		 pid_t;
71
72/* while POSIX wants these in <sys/types.h>, we
73 * declare then in <pthread.h> instead */
74#if 0
75typedef  .... pthread_attr_t;
76typedef  .... pthread_cond_t;
77typedef  .... pthread_condattr_t;
78typedef  .... pthread_key_t;
79typedef  .... pthread_mutex_t;
80typedef  .... pthread_once_t;
81typedef  .... pthread_rwlock_t;
82typedef  .... pthread_rwlock_attr_t;
83typedef  .... pthread_t;
84#endif
85
86#ifndef _SSIZE_T_DEFINED_
87#define _SSIZE_T_DEFINED_
88/* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you
89 * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is
90 * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI
91 * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until
92 * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */
93typedef __kernel_ssize_t ssize_t;
94#endif
95
96typedef __kernel_suseconds_t  suseconds_t;
97typedef __kernel_time_t       time_t;
98typedef __kernel_uid32_t        uid_t;
99typedef signed long           useconds_t;
100
101typedef __kernel_daddr_t	daddr_t;
102typedef __kernel_timer_t	timer_t;
103typedef __kernel_mqd_t		mqd_t;
104
105typedef __kernel_caddr_t    caddr_t;
106typedef unsigned int        uint_t;
107typedef unsigned int        uint;
108
109/* for some applications */
110#include <sys/sysmacros.h>
111
112#ifdef __BSD_VISIBLE
113typedef	unsigned char	u_char;
114typedef	unsigned short	u_short;
115typedef	unsigned int	u_int;
116typedef	unsigned long	u_long;
117
118typedef uint32_t       u_int32_t;
119typedef uint16_t       u_int16_t;
120typedef uint8_t        u_int8_t;
121typedef uint64_t       u_int64_t;
122#endif
123
124#endif
125