types.h revision 41927
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 3941927Sdt * $Id: types.h,v 1.25 1998/06/07 17:13:05 dfr Exp $ 401541Srgrimes */ 411541Srgrimes 421541Srgrimes#ifndef _SYS_TYPES_H_ 431541Srgrimes#define _SYS_TYPES_H_ 441541Srgrimes 4533778Sbde#include <sys/cdefs.h> 4633778Sbde 471541Srgrimes/* Machine type dependent parameters. */ 4841927Sdt#include <sys/inttypes.h> /* includes <machine/ansi.h> */ 4914500Shsu#include <machine/types.h> 501541Srgrimes 511541Srgrimes#ifndef _POSIX_SOURCE 521541Srgrimestypedef unsigned char u_char; 531541Srgrimestypedef unsigned short u_short; 541541Srgrimestypedef unsigned int u_int; 551541Srgrimestypedef unsigned long u_long; 561541Srgrimestypedef unsigned short ushort; /* Sys V compatibility */ 571541Srgrimestypedef unsigned int uint; /* Sys V compatibility */ 581541Srgrimes#endif 591541Srgrimes 6041927Sdttypedef __uint8_t u_int8_t; 6141927Sdttypedef __uint16_t u_int16_t; 6241927Sdttypedef __uint32_t u_int32_t; 6341927Sdttypedef __uint64_t u_int64_t; 6441927Sdt 6514500Shsutypedef u_int64_t u_quad_t; /* quads */ 6614500Shsutypedef int64_t quad_t; 671541Srgrimestypedef quad_t * qaddr_t; 681541Srgrimes 691541Srgrimestypedef char * caddr_t; /* core address */ 7014500Shsutypedef int32_t daddr_t; /* disk address */ 7114500Shsutypedef u_int32_t dev_t; /* device number */ 7224895Sbdetypedef u_int32_t fixpt_t; /* fixed point number */ 7314500Shsutypedef u_int32_t gid_t; /* group id */ 7414500Shsutypedef u_int32_t ino_t; /* inode number */ 7514500Shsutypedef long key_t; /* IPC key (for Sys V IPC) */ 7614500Shsutypedef u_int16_t mode_t; /* permissions */ 7714500Shsutypedef u_int16_t nlink_t; /* link count */ 789342Sbdetypedef _BSD_OFF_T_ off_t; /* file offset */ 799342Sbdetypedef _BSD_PID_T_ pid_t; /* process id */ 8024895Sbdetypedef quad_t rlim_t; /* resource limit */ 8136735Sdfr#ifdef __alpha__ /* XXX should be in <machine/types.h> */ 8236735Sdfrtypedef int64_t segsz_t; /* segment size */ 8336735Sdfr#else 8414500Shsutypedef int32_t segsz_t; /* segment size */ 8536735Sdfr#endif 8614500Shsutypedef int32_t swblk_t; /* swap offset */ 8741927Sdttypedef int32_t ufs_daddr_t; 8814500Shsutypedef u_int32_t uid_t; /* user id */ 891541Srgrimes 9012642Sbde#ifdef KERNEL 9115481Sbdetypedef int boolean_t; 9241927Sdttypedef u_int64_t uoff_t; 9315481Sbdetypedef struct vm_page *vm_page_t; 9412642Sbde#endif 9512642Sbde 961541Srgrimes#ifndef _POSIX_SOURCE 973093Sdg/* 983093Sdg * minor() gives a cookie instead of an index since we don't want to 993093Sdg * change the meanings of bits 0-15 or waste time and space shifting 1003093Sdg * bits 16-31 for devices that don't use them. 1013093Sdg */ 1021541Srgrimes#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ 1033093Sdg#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ 10414500Shsu#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ 1051541Srgrimes#endif 1061541Srgrimes 10714500Shsu#include <machine/endian.h> 1081541Srgrimes 1091541Srgrimes#ifdef _BSD_CLOCK_T_ 1101541Srgrimestypedef _BSD_CLOCK_T_ clock_t; 1111541Srgrimes#undef _BSD_CLOCK_T_ 1121541Srgrimes#endif 1131541Srgrimes 11433778Sbde#ifdef _BSD_CLOCKID_T_ 11533778Sbdetypedef _BSD_CLOCKID_T_ clockid_t; 11633778Sbde#undef _BSD_CLOCKID_T_ 11733778Sbde#endif 11833778Sbde 1191541Srgrimes#ifdef _BSD_SIZE_T_ 1201541Srgrimestypedef _BSD_SIZE_T_ size_t; 1211541Srgrimes#undef _BSD_SIZE_T_ 1221541Srgrimes#endif 1231541Srgrimes 1241541Srgrimes#ifdef _BSD_SSIZE_T_ 1251541Srgrimestypedef _BSD_SSIZE_T_ ssize_t; 1261541Srgrimes#undef _BSD_SSIZE_T_ 1271541Srgrimes#endif 1281541Srgrimes 1291541Srgrimes#ifdef _BSD_TIME_T_ 1301541Srgrimestypedef _BSD_TIME_T_ time_t; 1311541Srgrimes#undef _BSD_TIME_T_ 1321541Srgrimes#endif 1331541Srgrimes 13425579Speter#ifdef _BSD_TIMER_T_ 13525579Spetertypedef _BSD_TIMER_T_ timer_t; 13625579Speter#undef _BSD_TIMER_T_ 13725579Speter#endif 13825579Speter 1391541Srgrimes#ifndef _POSIX_SOURCE 1401541Srgrimes#define NBBY 8 /* number of bits in a byte */ 1411541Srgrimes 1421541Srgrimes/* 1431541Srgrimes * Select uses bit masks of file descriptors in longs. These macros 1441541Srgrimes * manipulate such bit fields (the filesystem macros use chars). 1451541Srgrimes * FD_SETSIZE may be defined by the user, but the default here should 1461541Srgrimes * be enough for most uses. 1471541Srgrimes */ 1481541Srgrimes#ifndef FD_SETSIZE 14922968Sache#define FD_SETSIZE 1024 1501541Srgrimes#endif 1511541Srgrimes 15224895Sbdetypedef long fd_mask; 15324895Sbde#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 1541541Srgrimes 1551541Srgrimes#ifndef howmany 15614500Shsu#define howmany(x, y) (((x) + ((y) - 1)) / (y)) 1571541Srgrimes#endif 1581541Srgrimes 1591541Srgrimestypedef struct fd_set { 1601541Srgrimes fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 1611541Srgrimes} fd_set; 1621541Srgrimes 1631541Srgrimes#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 1641541Srgrimes#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 1651541Srgrimes#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 1661541Srgrimes#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) 1671541Srgrimes#define FD_ZERO(p) bzero(p, sizeof(*(p))) 1681541Srgrimes 16924896Sbde/* 17024896Sbde * These declarations belong elsewhere, but are repeated here and in 17124896Sbde * <stdio.h> to give broken programs a better chance of working with 17224896Sbde * 64-bit off_t's. 17324896Sbde */ 17424896Sbde#ifndef KERNEL 17524896Sbde__BEGIN_DECLS 17624896Sbde#ifndef _FTRUNCATE_DECLARED 17724896Sbde#define _FTRUNCATE_DECLARED 17824896Sbdeint ftruncate __P((int, off_t)); 17924896Sbde#endif 18024896Sbde#ifndef _LSEEK_DECLARED 18124896Sbde#define _LSEEK_DECLARED 18224896Sbdeoff_t lseek __P((int, off_t, int)); 18324896Sbde#endif 18424896Sbde#ifndef _MMAP_DECLARED 18524896Sbde#define _MMAP_DECLARED 18632131Salexvoid * mmap __P((void *, size_t, int, int, int, off_t)); 18724896Sbde#endif 18824896Sbde#ifndef _TRUNCATE_DECLARED 18924896Sbde#define _TRUNCATE_DECLARED 19024896Sbdeint truncate __P((const char *, off_t)); 19124896Sbde#endif 19224896Sbde__END_DECLS 19324896Sbde#endif /* !KERNEL */ 19424896Sbde 19533778Sbde#endif /* !_POSIX_SOURCE */ 1961541Srgrimes 1971541Srgrimes#endif /* !_SYS_TYPES_H_ */ 198