types.h revision 894f8cb1395d3409bb995d18abc1b3409c557d01
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/* __kernel_gid_t and __kernel_uid_t are 16 bit for legacy reasons. 39 * Android uses __kernel_uid32_t and __kernel_gid32_t instead. 40 */ 41typedef __kernel_gid32_t gid_t; 42typedef __kernel_uid32_t uid_t; 43 44typedef unsigned long blkcnt_t; 45typedef unsigned long blksize_t; 46typedef __kernel_caddr_t caddr_t; 47typedef __kernel_clock_t clock_t; 48typedef __kernel_clockid_t clockid_t; 49typedef __kernel_daddr_t daddr_t; 50typedef unsigned long fsblkcnt_t; 51typedef unsigned long fsfilcnt_t; 52typedef __kernel_ino_t ino_t; 53typedef __kernel_key_t key_t; 54typedef __kernel_mode_t mode_t; 55typedef __nlink_t nlink_t; 56typedef __kernel_pid_t pid_t; 57typedef __kernel_suseconds_t suseconds_t; 58typedef __kernel_timer_t timer_t; 59typedef unsigned int useconds_t; 60 61#if !defined(__LP64__) 62/* This historical accident means that we had a 32-bit dev_t on 32-bit architectures. */ 63typedef uint32_t dev_t; 64#else 65typedef uint64_t dev_t; 66#endif 67 68/* This historical accident means that we had a 32-bit time_t on 32-bit architectures. */ 69typedef __kernel_time_t time_t; 70 71/* This historical accident means that we had a 32-bit off_t on 32-bit architectures. */ 72#ifndef _OFF_T_DEFINED_ 73#define _OFF_T_DEFINED_ 74typedef __kernel_off_t off_t; 75#endif 76typedef __kernel_loff_t loff_t; 77typedef loff_t off64_t; 78 79/* This one really is meant to be just 32 bits! */ 80typedef uint32_t id_t; 81 82/* while POSIX wants these in <sys/types.h>, we 83 * declare then in <pthread.h> instead */ 84#if 0 85typedef .... pthread_attr_t; 86typedef .... pthread_cond_t; 87typedef .... pthread_condattr_t; 88typedef .... pthread_key_t; 89typedef .... pthread_mutex_t; 90typedef .... pthread_once_t; 91typedef .... pthread_rwlock_t; 92typedef .... pthread_rwlock_attr_t; 93typedef .... pthread_t; 94#endif 95 96#ifndef _SSIZE_T_DEFINED_ 97#define _SSIZE_T_DEFINED_ 98/* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you 99 * pass a ssize_t to a printf-style function. The correct type is __kernel_ssize_t, which is 100 * "int", which isn't an ABI change for C code (because they're the same size) but is an ABI 101 * change for C++ because "int" and "long int" mangle to "i" and "l" respectively. So until 102 * we can fix the ABI, this change should not be propagated to the NDK. http://b/8253769. */ 103typedef __kernel_ssize_t ssize_t; 104#endif 105 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