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/types.h> 36#include <linux/posix_types.h> 37 38/* gids, uids, and pids are all 32-bit. */ 39typedef __kernel_gid32_t __gid_t; 40typedef __gid_t gid_t; 41typedef __kernel_uid32_t __uid_t; 42typedef __uid_t uid_t; 43typedef __kernel_pid_t __pid_t; 44typedef __pid_t pid_t; 45typedef uint32_t __id_t; 46typedef __id_t id_t; 47 48typedef unsigned long blkcnt_t; 49typedef unsigned long blksize_t; 50typedef __kernel_caddr_t caddr_t; 51typedef __kernel_clock_t clock_t; 52 53typedef __kernel_clockid_t __clockid_t; 54typedef __clockid_t clockid_t; 55 56typedef __kernel_daddr_t daddr_t; 57typedef unsigned long fsblkcnt_t; 58typedef unsigned long fsfilcnt_t; 59 60typedef __kernel_mode_t __mode_t; 61typedef __mode_t mode_t; 62 63typedef __kernel_key_t __key_t; 64typedef __key_t key_t; 65 66typedef __kernel_ino_t __ino_t; 67typedef __ino_t ino_t; 68 69typedef uint32_t __nlink_t; 70typedef __nlink_t nlink_t; 71 72typedef void* __timer_t; 73typedef __timer_t timer_t; 74 75typedef __kernel_suseconds_t __suseconds_t; 76typedef __suseconds_t suseconds_t; 77 78/* useconds_t is 32-bit on both LP32 and LP64. */ 79typedef uint32_t __useconds_t; 80typedef __useconds_t useconds_t; 81 82#if !defined(__LP64__) 83/* This historical accident means that we had a 32-bit dev_t on 32-bit architectures. */ 84typedef uint32_t dev_t; 85#else 86typedef uint64_t dev_t; 87#endif 88 89/* This historical accident means that we had a 32-bit time_t on 32-bit architectures. */ 90typedef __kernel_time_t __time_t; 91typedef __time_t time_t; 92 93/* This historical accident means that we had a 32-bit off_t on 32-bit architectures. */ 94#if !defined(__LP64__) 95typedef __kernel_off_t off_t; 96typedef __kernel_loff_t loff_t; 97typedef loff_t off64_t; 98#else 99/* We could re-use the LP32 definitions, but that would mean that although off_t and loff_t/off64_t 100 * would be the same size, they wouldn't actually be the same type, which can lead to warnings. */ 101typedef __kernel_off_t off_t; 102typedef off_t loff_t; 103typedef loff_t off64_t; 104#endif 105 106/* while POSIX wants these in <sys/types.h>, we 107 * declare then in <pthread.h> instead */ 108#if 0 109typedef .... pthread_attr_t; 110typedef .... pthread_cond_t; 111typedef .... pthread_condattr_t; 112typedef .... pthread_key_t; 113typedef .... pthread_mutex_t; 114typedef .... pthread_once_t; 115typedef .... pthread_rwlock_t; 116typedef .... pthread_rwlock_attr_t; 117typedef .... pthread_t; 118#endif 119 120#if !defined(__LP64__) 121/* This historical accident means that we had a signed socklen_t on 32-bit architectures. */ 122typedef int32_t __socklen_t; 123#else 124/* LP64 still has a 32-bit socklen_t. */ 125typedef uint32_t __socklen_t; 126#endif 127typedef __socklen_t socklen_t; 128 129typedef __builtin_va_list __va_list; 130 131#ifndef _SSIZE_T_DEFINED_ 132#define _SSIZE_T_DEFINED_ 133/* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you 134 * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is 135 * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI 136 * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until 137 * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */ 138typedef __kernel_ssize_t ssize_t; 139#endif 140 141typedef unsigned int uint_t; 142typedef unsigned int uint; 143 144/* for some applications */ 145#include <sys/sysmacros.h> 146 147#ifdef __BSD_VISIBLE 148typedef unsigned char u_char; 149typedef unsigned short u_short; 150typedef unsigned int u_int; 151typedef unsigned long u_long; 152 153typedef uint32_t u_int32_t; 154typedef uint16_t u_int16_t; 155typedef uint8_t u_int8_t; 156typedef uint64_t u_int64_t; 157#endif 158 159#endif 160