Back to index

glibc  2.9
types.h
Go to the documentation of this file.
00001 /* bits/types.h -- definitions of __*_t types underlying *_t types.
00002    Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /*
00021  * Never include this file directly; use <sys/types.h> instead.
00022  */
00023 
00024 #ifndef       _BITS_TYPES_H
00025 #define       _BITS_TYPES_H 1
00026 
00027 #include <features.h>
00028 #include <bits/wordsize.h>
00029 
00030 /* Convenience types.  */
00031 typedef unsigned char __u_char;
00032 typedef unsigned short int __u_short;
00033 typedef unsigned int __u_int;
00034 typedef unsigned long int __u_long;
00035 
00036 /* Fixed-size types, underlying types depend on word size and compiler.  */
00037 typedef signed char __int8_t;
00038 typedef unsigned char __uint8_t;
00039 typedef signed short int __int16_t;
00040 typedef unsigned short int __uint16_t;
00041 typedef signed int __int32_t;
00042 typedef unsigned int __uint32_t;
00043 #if __WORDSIZE == 64
00044 typedef signed long int __int64_t;
00045 typedef unsigned long int __uint64_t;
00046 #elif defined __GLIBC_HAVE_LONG_LONG
00047 __extension__ typedef signed long long int __int64_t;
00048 __extension__ typedef unsigned long long int __uint64_t;
00049 #endif
00050 
00051 /* quad_t is also 64 bits.  */
00052 #if __WORDSIZE == 64
00053 typedef long int __quad_t;
00054 typedef unsigned long int __u_quad_t;
00055 #elif defined __GLIBC_HAVE_LONG_LONG
00056 __extension__ typedef long long int __quad_t;
00057 __extension__ typedef unsigned long long int __u_quad_t;
00058 #else
00059 typedef struct
00060 {
00061   long __val[2];
00062 } __quad_t;
00063 typedef struct
00064 {
00065   __u_long __val[2];
00066 } __u_quad_t;
00067 #endif
00068 
00069 
00070 /* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
00071    macros for each of the OS types we define below.  The definitions
00072    of those macros must use the following macros for underlying types.
00073    We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
00074    variants of each of the following integer types on this machine.
00075 
00076        16            -- "natural" 16-bit type (always short)
00077        32            -- "natural" 32-bit type (always int)
00078        64            -- "natural" 64-bit type (long or long long)
00079        LONG32        -- 32-bit type, traditionally long
00080        QUAD          -- 64-bit type, always long long
00081        WORD          -- natural type of __WORDSIZE bits (int or long)
00082        LONGWORD      -- type of __WORDSIZE bits, traditionally long
00083 
00084    We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
00085    conventional uses of `long' or `long long' type modifiers match the
00086    types we define, even when a less-adorned type would be the same size.
00087    This matters for (somewhat) portably writing printf/scanf formats for
00088    these types, where using the appropriate l or ll format modifiers can
00089    make the typedefs and the formats match up across all GNU platforms.  If
00090    we used `long' when it's 64 bits where `long long' is expected, then the
00091    compiler would warn about the formats not matching the argument types,
00092    and the programmer changing them to shut up the compiler would break the
00093    program's portability.
00094 
00095    Here we assume what is presently the case in all the GCC configurations
00096    we support: long long is always 64 bits, long is always word/address size,
00097    and int is always 32 bits.  */
00098 
00099 #define       __S16_TYPE           short int
00100 #define __U16_TYPE          unsigned short int
00101 #define       __S32_TYPE           int
00102 #define __U32_TYPE          unsigned int
00103 #define __SLONGWORD_TYPE    long int
00104 #define __ULONGWORD_TYPE    unsigned long int
00105 #if __WORDSIZE == 32
00106 # define __SQUAD_TYPE              __quad_t
00107 # define __UQUAD_TYPE              __u_quad_t
00108 # define __SWORD_TYPE              int
00109 # define __UWORD_TYPE              unsigned int
00110 # define __SLONG32_TYPE            long int
00111 # define __ULONG32_TYPE            unsigned long int
00112 # define __S64_TYPE         __quad_t
00113 # define __U64_TYPE         __u_quad_t
00114 /* We want __extension__ before typedef's that use nonstandard base types
00115    such as `long long' in C89 mode.  */
00116 # define __STD_TYPE         __extension__ typedef
00117 #elif __WORDSIZE == 64
00118 # define __SQUAD_TYPE              long int
00119 # define __UQUAD_TYPE              unsigned long int
00120 # define __SWORD_TYPE              long int
00121 # define __UWORD_TYPE              unsigned long int
00122 # define __SLONG32_TYPE            int
00123 # define __ULONG32_TYPE            unsigned int
00124 # define __S64_TYPE         long int
00125 # define __U64_TYPE         unsigned long int
00126 /* No need to mark the typedef with __extension__.   */
00127 # define __STD_TYPE         typedef
00128 #else
00129 # error
00130 #endif
00131 #include <bits/typesizes.h> /* Defines __*_T_TYPE macros.  */
00132 
00133 
00134 __STD_TYPE __DEV_T_TYPE __dev_t;   /* Type of device numbers.  */
00135 __STD_TYPE __UID_T_TYPE __uid_t;   /* Type of user identifications.  */
00136 __STD_TYPE __GID_T_TYPE __gid_t;   /* Type of group identifications.  */
00137 __STD_TYPE __INO_T_TYPE __ino_t;   /* Type of file serial numbers.  */
00138 __STD_TYPE __INO64_T_TYPE __ino64_t;      /* Type of file serial numbers (LFS).*/
00139 __STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks.  */
00140 __STD_TYPE __NLINK_T_TYPE __nlink_t;      /* Type of file link counts.  */
00141 __STD_TYPE __OFF_T_TYPE __off_t;   /* Type of file sizes and offsets.  */
00142 __STD_TYPE __OFF64_T_TYPE __off64_t;      /* Type of file sizes and offsets (LFS).  */
00143 __STD_TYPE __PID_T_TYPE __pid_t;   /* Type of process identifications.  */
00144 __STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs.  */
00145 __STD_TYPE __CLOCK_T_TYPE __clock_t;      /* Type of CPU usage counts.  */
00146 __STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement.  */
00147 __STD_TYPE __RLIM64_T_TYPE __rlim64_t;    /* Type for resource measurement (LFS).  */
00148 __STD_TYPE __ID_T_TYPE __id_t;            /* General type for IDs.  */
00149 __STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch.  */
00150 __STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds.  */
00151 __STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds.  */
00152 
00153 __STD_TYPE __DADDR_T_TYPE __daddr_t;      /* The type of a disk address.  */
00154 __STD_TYPE __SWBLK_T_TYPE __swblk_t;      /* Type of a swap block maybe?  */
00155 __STD_TYPE __KEY_T_TYPE __key_t;   /* Type of an IPC key.  */
00156 
00157 /* Clock ID used in clock and timer functions.  */
00158 __STD_TYPE __CLOCKID_T_TYPE __clockid_t;
00159 
00160 /* Timer ID returned by `timer_create'.  */
00161 __STD_TYPE __TIMER_T_TYPE __timer_t;
00162 
00163 /* Type to represent block size.  */
00164 __STD_TYPE __BLKSIZE_T_TYPE __blksize_t;
00165 
00166 /* Types from the Large File Support interface.  */
00167 
00168 /* Type to count number of disk blocks.  */
00169 __STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;
00170 __STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;
00171 
00172 /* Type to count file system blocks.  */
00173 __STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;
00174 __STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;
00175 
00176 /* Type to count file system nodes.  */
00177 __STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
00178 __STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
00179 
00180 __STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error.  */
00181 
00182 /* These few don't really vary by system, they always correspond
00183    to one of the other defined types.  */
00184 typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS).  */
00185 typedef __quad_t *__qaddr_t;
00186 typedef char *__caddr_t;
00187 
00188 /* Duplicates info from stdint.h but this is used in unistd.h.  */
00189 __STD_TYPE __SWORD_TYPE __intptr_t;
00190 
00191 /* Duplicate info from sys/socket.h.  */
00192 __STD_TYPE __U32_TYPE __socklen_t;
00193 
00194 
00195 #undef __STD_TYPE
00196 
00197 #endif /* bits/types.h */