first pass at function prototypes with cdefs.h
[unix-history] / usr / src / sys / sys / types.h
CommitLineData
da7c5cc6 1/*
54357075 2 * Copyright (c) 1982 Regents of the University of California.
da7c5cc6
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
91befe9c 6 * @(#)types.h 7.13 (Berkeley) %G%
da7c5cc6 7 */
10cbd931 8
91befe9c
KB
9#ifndef _TYPES_H_
10#define _TYPES_H_
10cbd931 11
f5f5858f 12typedef short dev_t;
4677ac5e
KB
13#ifndef _POSIX_SOURCE
14 /* major part of a device */
10cbd931 15#define major(x) ((int)(((unsigned)(x)>>8)&0377))
4677ac5e 16 /* minor part of a device */
10cbd931 17#define minor(x) ((int)((x)&0377))
4677ac5e 18 /* make a device number */
10cbd931 19#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
4677ac5e 20#endif
10cbd931
BJ
21
22typedef unsigned char u_char;
23typedef unsigned short u_short;
24typedef unsigned int u_int;
25typedef unsigned long u_long;
4677ac5e 26typedef unsigned short ushort; /* Sys V compatibility */
10cbd931 27
b28b3a13 28#include <machine/types.h>
4677ac5e
KB
29
30#ifdef _CLOCK_T_
31typedef _CLOCK_T_ clock_t;
32#undef _CLOCK_T_
33#endif
34
35#ifdef _TIME_T_
36typedef _TIME_T_ time_t;
37#undef _TIME_T_
38#endif
39
f5f5858f
KB
40#ifdef _SIZE_T_
41typedef _SIZE_T_ size_t;
42#undef _SIZE_T_
0f5da3e7 43#endif
f5f5858f 44
4677ac5e 45#ifndef _POSIX_SOURCE
0f5da3e7 46typedef struct _uquad { unsigned long val[2]; } u_quad;
af0b24db 47typedef struct _quad { long val[2]; } quad;
4677ac5e 48#endif
f5f5858f
KB
49typedef long * qaddr_t; /* should be typedef quad * qaddr_t; */
50
46304247 51typedef long daddr_t;
10cbd931 52typedef char * caddr_t;
ad30fb67 53typedef u_long ino_t;
6e7edb25 54typedef long swblk_t;
e5b27ef1 55typedef long segsz_t;
bec4c3f0 56typedef long off_t;
2597eb51
MK
57typedef u_short uid_t;
58typedef u_short gid_t;
8355a99b 59typedef short pid_t;
1f03542e 60typedef u_short nlink_t;
491b04fb 61typedef u_short mode_t;
80b6b780 62typedef u_long fixpt_t;
0e118a41 63
4677ac5e 64#ifndef _POSIX_SOURCE
6c906a20 65#define NBBY 8 /* number of bits in a byte */
f5f5858f 66
24437d47 67/*
f5f5858f
KB
68 * Select uses bit masks of file descriptors in longs. These macros
69 * manipulate such bit fields (the filesystem macros use chars).
70 * FD_SETSIZE may be defined by the user, but the default here should
71 * be >= NOFILE (param.h).
24437d47 72 */
24437d47 73#ifndef FD_SETSIZE
6c906a20 74#define FD_SETSIZE 256
24437d47
MK
75#endif
76
77typedef long fd_mask;
78#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
f5f5858f 79
6c906a20
MK
80#ifndef howmany
81#define howmany(x, y) (((x)+((y)-1))/(y))
82#endif
24437d47
MK
83
84typedef struct fd_set {
85 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
86} fd_set;
87
88#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
89#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
90#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
4677ac5e 91#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
24437d47 92
4677ac5e 93#endif /* !_POSIX_SOURCE */
91befe9c 94#endif /* !_TYPES_H_ */