161611Sbostic.\" Copyright (c) 1980, 1991, 1993 261611Sbostic.\" The Regents of the University of California. All rights reserved. 320767Smckusick.\" 448832Scael.\" %sccs.include.redist.roff% 520767Smckusick.\" 6*69089Smckusick.\" @(#)types.5 8.2 (Berkeley) 04/28/95 748832Scael.\" 848832Scael.Dd 948832Scael.Dt TYPES 5 1048832Scael.Os BSD 4 1148832Scael.Sh NAME 1248832Scael.Nm types 1348832Scael.Nd system data types 1448832Scael.Sh SYNOPSIS 1548832Scael.Fd #include <sys/types.h> 1648832Scael.Sh DESCRIPTION 1748832ScaelThe file 1848832Scael.Pa sys/types.h 1948832Scaelcontains the defined data types used in the kernel (most are 2048832Scaelused through out the system). 2148832Scael.Bd -literal 22*69089Smckusick#ifndef _SYS_TYPES_H_ 23*69089Smckusick#define _SYS_TYPES_H_ 2448832Scael 25*69089Smckusick/* Machine type dependent parameters. */ 26*69089Smckusick#include <machine/ansi.h> 27*69089Smckusick#include <machine/types.h> 28*69089Smckusick 2948832Scael#ifndef _POSIX_SOURCE 3048832Scaeltypedef unsigned char u_char; 3148832Scaeltypedef unsigned short u_short; 3248832Scaeltypedef unsigned int u_int; 3348832Scaeltypedef unsigned long u_long; 3448832Scaeltypedef unsigned short ushort; /* Sys V compatibility */ 35*69089Smckusicktypedef unsigned int uint; /* Sys V compatibility */ 36*69089Smckusick#endif 3748832Scael 38*69089Smckusicktypedef u_int64_t u_quad_t; /* quads */ 39*69089Smckusicktypedef int64_t quad_t; 40*69089Smckusicktypedef quad_t * qaddr_t; 41*69089Smckusick 42*69089Smckusicktypedef char * caddr_t; /* core address */ 43*69089Smckusicktypedef int32_t daddr_t; /* disk address */ 44*69089Smckusicktypedef u_int32_t dev_t; /* device number */ 45*69089Smckusicktypedef u_int32_t fixpt_t; /* fixed point number */ 46*69089Smckusicktypedef u_int32_t gid_t; /* group id */ 47*69089Smckusicktypedef u_int32_t ino_t; /* inode number */ 48*69089Smckusicktypedef long key_t; /* IPC key (for Sys V IPC) */ 49*69089Smckusicktypedef u_int16_t mode_t; /* permissions */ 50*69089Smckusicktypedef u_int16_t nlink_t; /* link count */ 51*69089Smckusicktypedef quad_t off_t; /* file offset */ 52*69089Smckusicktypedef int32_t pid_t; /* process id */ 53*69089Smckusicktypedef int32_t segsz_t; /* segment size */ 54*69089Smckusicktypedef int32_t swblk_t; /* swap offset */ 55*69089Smckusicktypedef u_int32_t uid_t; /* user id */ 56*69089Smckusick 57*69089Smckusick/* 58*69089Smckusick * This belongs in unistd.h, but is placed here to ensure that programs 59*69089Smckusick * casting the second parameter of lseek to off_t will get the correct 60*69089Smckusick * version of lseek. 61*69089Smckusick */ 62*69089Smckusick#ifndef KERNEL 63*69089Smckusick#include <sys/cdefs.h> 64*69089Smckusick__BEGIN_DECLS 65*69089Smckusickoff_t lseek __P((int, off_t, int)); 66*69089Smckusick__END_DECLS 6748832Scael#endif 6848832Scael 69*69089Smckusick#ifndef _POSIX_SOURCE 70*69089Smckusick /* major number */ 71*69089Smckusick#define major(x) ((int32_t)(((u_int32_t)(x) >> 8) & 0xff)) 72*69089Smckusick#define minor(x) ((int32_t)((x) & 0xff)) /* minor number */ 73*69089Smckusick#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ 7448832Scael#endif 7548832Scael 76*69089Smckusick#include <machine/endian.h> 77*69089Smckusick 78*69089Smckusick#ifdef _BSD_CLOCK_T_ 79*69089Smckusicktypedef _BSD_CLOCK_T_ clock_t; 80*69089Smckusick#undef _BSD_CLOCK_T_ 8148832Scael#endif 8248832Scael 83*69089Smckusick#ifdef _BSD_SIZE_T_ 84*69089Smckusicktypedef _BSD_SIZE_T_ size_t; 85*69089Smckusick#undef _BSD_SIZE_T_ 8648832Scael#endif 8748832Scael 88*69089Smckusick#ifdef _BSD_SSIZE_T_ 89*69089Smckusicktypedef _BSD_SSIZE_T_ ssize_t; 90*69089Smckusick#undef _BSD_SSIZE_T_ 9148832Scael#endif 9248832Scael 93*69089Smckusick#ifdef _BSD_TIME_T_ 94*69089Smckusicktypedef _BSD_TIME_T_ time_t; 95*69089Smckusick#undef _BSD_TIME_T_ 96*69089Smckusick#endif 9748832Scael 9848832Scael#ifndef _POSIX_SOURCE 9948832Scael#define NBBY 8 /* number of bits in a byte */ 10048832Scael 10148832Scael/* 10248832Scael * Select uses bit masks of file descriptors in longs. These macros 10348832Scael * manipulate such bit fields (the filesystem macros use chars). 10448832Scael * FD_SETSIZE may be defined by the user, but the default here should 105*69089Smckusick * be enough for most uses. 10648832Scael */ 10748832Scael#ifndef FD_SETSIZE 10848832Scael#define FD_SETSIZE 256 10948832Scael#endif 11048832Scael 111*69089Smckusicktypedef int32_t fd_mask; 11248832Scael#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 11348832Scael 11448832Scael#ifndef howmany 115*69089Smckusick#define howmany(x, y) (((x) + ((y) - 1)) / (y)) 11648832Scael#endif 11748832Scael 11848832Scaeltypedef struct fd_set { 11948832Scael fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 12048832Scael} fd_set; 12148832Scael 12248832Scael#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) 12348832Scael#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) 12448832Scael#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) 125*69089Smckusick#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) 126*69089Smckusick#define FD_ZERO(p) bzero(p, sizeof(*(p))) 12748832Scael 128*69089Smckusick#if defined(__STDC__) && defined(KERNEL) 129*69089Smckusick/* 130*69089Smckusick * Forward structure declarations for function prototypes. We include the 131*69089Smckusick * common structures that cross subsystem boundaries here; others are mostly 132*69089Smckusick * used in the same place that the structure is defined. 133*69089Smckusick */ 134*69089Smckusickstruct proc; 135*69089Smckusickstruct pgrp; 136*69089Smckusickstruct ucred; 137*69089Smckusickstruct rusage; 138*69089Smckusickstruct file; 139*69089Smckusickstruct buf; 140*69089Smckusickstruct tty; 141*69089Smckusickstruct uio; 142*69089Smckusick#endif 143*69089Smckusick 14448832Scael#endif /* !_POSIX_SOURCE */ 145*69089Smckusick#endif /* !_SYS_TYPES_H_ */ 14648832Scael.Ed 14748832Scael.Sh SEE ALSO 14848832Scael.Xr fs 5 , 14948832Scael.Xr time 3 , 15048832Scael.Xr lseek 2 , 15148832Scael.Sh HISTORY 15248832ScaelA 15348832Scael.Nm 15448832Scaelfile appeared in 15548832Scael.At v7 . 156