types.h revision 94363
11541Srgrimes/*- 214500Shsu * Copyright (c) 1982, 1986, 1991, 1993, 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * (c) UNIX System Laboratories, Inc. 51541Srgrimes * All or some portions of this file are derived from material licensed 61541Srgrimes * to the University of California by American Telephone and Telegraph 71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81541Srgrimes * the permission of UNIX System Laboratories, Inc. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. All advertising materials mentioning features or use of this software 191541Srgrimes * must display the following acknowledgement: 201541Srgrimes * This product includes software developed by the University of 211541Srgrimes * California, Berkeley and its contributors. 221541Srgrimes * 4. Neither the name of the University nor the names of its contributors 231541Srgrimes * may be used to endorse or promote products derived from this software 241541Srgrimes * without specific prior written permission. 251541Srgrimes * 261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361541Srgrimes * SUCH DAMAGE. 371541Srgrimes * 3814500Shsu * @(#)types.h 8.6 (Berkeley) 2/19/95 3950477Speter * $FreeBSD: head/sys/sys/types.h 94363 2002-04-10 15:58:13Z mike $ 401541Srgrimes */ 411541Srgrimes 421541Srgrimes#ifndef _SYS_TYPES_H_ 431541Srgrimes#define _SYS_TYPES_H_ 441541Srgrimes 4533778Sbde#include <sys/cdefs.h> 4633778Sbde 471541Srgrimes/* Machine type dependent parameters. */ 4893514Smike#include <machine/ansi.h> 4990868Smike#include <machine/endian.h> 5014500Shsu#include <machine/types.h> 5193514Smike#include <sys/_types.h> 521541Srgrimes 531541Srgrimes#ifndef _POSIX_SOURCE 541541Srgrimestypedef unsigned char u_char; 551541Srgrimestypedef unsigned short u_short; 561541Srgrimestypedef unsigned int u_int; 571541Srgrimestypedef unsigned long u_long; 581541Srgrimestypedef unsigned short ushort; /* Sys V compatibility */ 591541Srgrimestypedef unsigned int uint; /* Sys V compatibility */ 601541Srgrimes#endif 611541Srgrimes 6293514Smike/* 6393514Smike * XXX POSIX sized integrals that should appear only in <sys/stdint.h>. 6493514Smike */ 6593514Smike#ifndef _INT8_T_DECLARED 6693514Smiketypedef __int8_t int8_t; 6793514Smike#define _INT8_T_DECLARED 6893514Smike#endif 6993514Smike 7093514Smike#ifndef _INT16_T_DECLARED 7193514Smiketypedef __int16_t int16_t; 7293514Smike#define _INT16_T_DECLARED 7393514Smike#endif 7493514Smike 7593514Smike#ifndef _INT32_T_DECLARED 7693514Smiketypedef __int32_t int32_t; 7793514Smike#define _INT32_T_DECLARED 7893514Smike#endif 7993514Smike 8093514Smike#ifndef _INT64_T_DECLARED 8193514Smiketypedef __int64_t int64_t; 8293514Smike#define _INT64_T_DECLARED 8393514Smike#endif 8493514Smike 8593514Smike#ifndef _UINT8_T_DECLARED 8693514Smiketypedef __uint8_t uint8_t; 8793514Smike#define _UINT8_T_DECLARED 8893514Smike#endif 8993514Smike 9093514Smike#ifndef _UINT16_T_DECLARED 9193514Smiketypedef __uint16_t uint16_t; 9293514Smike#define _UINT16_T_DECLARED 9393514Smike#endif 9493514Smike 9593514Smike#ifndef _UINT32_T_DECLARED 9693514Smiketypedef __uint32_t uint32_t; 9793514Smike#define _UINT32_T_DECLARED 9893514Smike#endif 9993514Smike 10093514Smike#ifndef _UINT64_T_DECLARED 10193514Smiketypedef __uint64_t uint64_t; 10293514Smike#define _UINT64_T_DECLARED 10393514Smike#endif 10493514Smike 10593514Smike#ifndef _INTPTR_T_DECLARED 10693514Smiketypedef __intptr_t intptr_t; 10793514Smiketypedef __uintptr_t uintptr_t; 10893514Smike#define _INTPTR_T_DECLARED 10993514Smike#endif 11093514Smike 11193514Smike/* 11293514Smike * Deprecated BSD unsigned integrals. 11393514Smike */ 11441927Sdttypedef __uint8_t u_int8_t; 11541927Sdttypedef __uint16_t u_int16_t; 11641927Sdttypedef __uint32_t u_int32_t; 11741927Sdttypedef __uint64_t u_int64_t; 11841927Sdt 11993514Smike/* 12093514Smike * Deprecated BSD 64-bit integrals. 12193514Smike */ 12214500Shsutypedef u_int64_t u_quad_t; /* quads */ 12314500Shsutypedef int64_t quad_t; 1241541Srgrimestypedef quad_t * qaddr_t; 1251541Srgrimes 1261541Srgrimestypedef char * caddr_t; /* core address */ 12751901Smarceltypedef __const char * c_caddr_t; /* core address, pointer to const */ 12851901Smarceltypedef __volatile char *v_caddr_t; /* core address, pointer to volatile */ 12914500Shsutypedef int32_t daddr_t; /* disk address */ 13092363Smckusicktypedef int64_t daddr64_t; /* 64-bit disk address */ 13142957Sdillontypedef u_int32_t u_daddr_t; /* unsigned disk address */ 13224895Sbdetypedef u_int32_t fixpt_t; /* fixed point number */ 13391325Smike 13493521Smike#ifdef _BSD_GID_T_ 13593514Smiketypedef _BSD_GID_T_ gid_t; /* group id */ 13693521Smike#undef _BSD_GID_T_ 13791325Smike#endif 13891325Smike 13914500Shsutypedef u_int32_t ino_t; /* inode number */ 14014500Shsutypedef long key_t; /* IPC key (for Sys V IPC) */ 14114500Shsutypedef u_int16_t mode_t; /* permissions */ 14214500Shsutypedef u_int16_t nlink_t; /* link count */ 1439342Sbdetypedef _BSD_OFF_T_ off_t; /* file offset */ 1449342Sbdetypedef _BSD_PID_T_ pid_t; /* process id */ 14524895Sbdetypedef quad_t rlim_t; /* resource limit */ 14694363Smike 14794363Smike#ifdef _BSD_SEGSZ_T_ 14894363Smiketypedef _BSD_SEGSZ_T_ segsz_t; /* segment size (in pages) */ 14994363Smike#undef _BSD_SEGSZ_T_ 15036735Sdfr#endif 15194363Smike 15214500Shsutypedef int32_t swblk_t; /* swap offset */ 15341927Sdttypedef int32_t ufs_daddr_t; 15479769Spetertypedef int32_t ufs_time_t; 1551541Srgrimes 15693521Smike#ifdef _BSD_UID_T_ 15793514Smiketypedef _BSD_UID_T_ uid_t; /* user id */ 15893521Smike#undef _BSD_UID_T_ 15993514Smike#endif 16093514Smike 16155205Speter#ifdef _KERNEL 16215481Sbdetypedef int boolean_t; 16341927Sdttypedef u_int64_t uoff_t; 16415481Sbdetypedef struct vm_page *vm_page_t; 16512642Sbde 16648936Sphkstruct specinfo; 16748936Sphk 16847028Sphktypedef u_int32_t udev_t; /* device number */ 16948936Sphktypedef struct specinfo *dev_t; 17047028Sphk 17167708Sphk#define offsetof(type, field) __offsetof(type, field) 17267708Sphk 17355205Speter#else /* !_KERNEL */ 17447028Sphk 17547028Sphktypedef u_int32_t dev_t; /* device number */ 17647049Sphk#define udev_t dev_t 17747028Sphk 1781541Srgrimes#ifndef _POSIX_SOURCE 17947028Sphk 1803093Sdg/* 1813093Sdg * minor() gives a cookie instead of an index since we don't want to 1823093Sdg * change the meanings of bits 0-15 or waste time and space shifting 1833093Sdg * bits 16-31 for devices that don't use them. 1843093Sdg */ 18547028Sphk#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ 18647028Sphk#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ 18747028Sphk#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ 18846818Sphk 18947028Sphk#endif /* _POSIX_SOURCE */ 19046818Sphk 19155205Speter#endif /* !_KERNEL */ 19246818Sphk 19393521Smike#ifdef _BSD_CLOCK_T_ 1941541Srgrimestypedef _BSD_CLOCK_T_ clock_t; 19593521Smike#undef _BSD_CLOCK_T_ 1961541Srgrimes#endif 1971541Srgrimes 19893521Smike#ifdef _BSD_CLOCKID_T_ 19933778Sbdetypedef _BSD_CLOCKID_T_ clockid_t; 20093521Smike#undef _BSD_CLOCKID_T_ 20133778Sbde#endif 20233778Sbde 20390711Swollman#ifdef _BSD_FFLAGS_T_ 20493521Smiketypedef _BSD_FFLAGS_T_ fflags_t; /* file flags */ 20590711Swollman#undef _BSD_FFLAGS_T_ 20690711Swollman#endif 20790711Swollman 20893521Smike#ifdef _BSD_SIZE_T_ 2091541Srgrimestypedef _BSD_SIZE_T_ size_t; 21093521Smike#undef _BSD_SIZE_T_ 2111541Srgrimes#endif 2121541Srgrimes 21393521Smike#ifdef _BSD_SSIZE_T_ 2141541Srgrimestypedef _BSD_SSIZE_T_ ssize_t; 21593521Smike#undef _BSD_SSIZE_T_ 2161541Srgrimes#endif 2171541Srgrimes 21893521Smike#ifdef _BSD_TIME_T_ 2191541Srgrimestypedef _BSD_TIME_T_ time_t; 22093521Smike#undef _BSD_TIME_T_ 2211541Srgrimes#endif 2221541Srgrimes 22393521Smike#ifdef _BSD_TIMER_T_ 22425579Spetertypedef _BSD_TIMER_T_ timer_t; 22593521Smike#undef _BSD_TIMER_T_ 22625579Speter#endif 22725579Speter 2281541Srgrimes#ifndef _POSIX_SOURCE 22990193Smarkm#define NBBY 8 /* number of bits in a byte */ 2301541Srgrimes 2311541Srgrimes/* 2321541Srgrimes * Select uses bit masks of file descriptors in longs. These macros 2331541Srgrimes * manipulate such bit fields (the filesystem macros use chars). 2341541Srgrimes * FD_SETSIZE may be defined by the user, but the default here should 2351541Srgrimes * be enough for most uses. 2361541Srgrimes */ 2371541Srgrimes#ifndef FD_SETSIZE 23890135Smarkm#define FD_SETSIZE 1024U 2391541Srgrimes#endif 2401541Srgrimes 24157361Spetertypedef unsigned long fd_mask; 24224895Sbde#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 2431541Srgrimes 2441541Srgrimes#ifndef howmany 24590135Smarkm#define howmany(x, y) (((x) + ((y) - 1U)) / (y)) 2461541Srgrimes#endif 2471541Srgrimes 2481541Srgrimestypedef struct fd_set { 2491541Srgrimes fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 2501541Srgrimes} fd_set; 2511541Srgrimes 25257357Speter#define _fdset_mask(n) ((fd_mask)1 << ((n) % NFDBITS)) 25357357Speter#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= _fdset_mask(n)) 25457357Speter#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~_fdset_mask(n)) 25557357Speter#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & _fdset_mask(n)) 2561541Srgrimes#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) 2571541Srgrimes#define FD_ZERO(p) bzero(p, sizeof(*(p))) 2581541Srgrimes 25924896Sbde/* 26024896Sbde * These declarations belong elsewhere, but are repeated here and in 26124896Sbde * <stdio.h> to give broken programs a better chance of working with 26224896Sbde * 64-bit off_t's. 26324896Sbde */ 26455205Speter#ifndef _KERNEL 26524896Sbde__BEGIN_DECLS 26624896Sbde#ifndef _FTRUNCATE_DECLARED 26724896Sbde#define _FTRUNCATE_DECLARED 26892719Salfredint ftruncate(int, off_t); 26924896Sbde#endif 27024896Sbde#ifndef _LSEEK_DECLARED 27124896Sbde#define _LSEEK_DECLARED 27292719Salfredoff_t lseek(int, off_t, int); 27324896Sbde#endif 27424896Sbde#ifndef _MMAP_DECLARED 27524896Sbde#define _MMAP_DECLARED 27692719Salfredvoid * mmap(void *, size_t, int, int, int, off_t); 27724896Sbde#endif 27824896Sbde#ifndef _TRUNCATE_DECLARED 27924896Sbde#define _TRUNCATE_DECLARED 28092719Salfredint truncate(const char *, off_t); 28124896Sbde#endif 28224896Sbde__END_DECLS 28355205Speter#endif /* !_KERNEL */ 28424896Sbde 28533778Sbde#endif /* !_POSIX_SOURCE */ 2861541Srgrimes 2871541Srgrimes#endif /* !_SYS_TYPES_H_ */ 288