summaryrefslogtreecommitdiffstats
path: root/private/inc/sys/snet/bsd_type.h
blob: 2e4dfb7aeec8c8685c93c7bb8decba46db9ffa8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*++

Copyright (c) 1991  Microsoft Corporation

Module Name:

    bsd_type.h.h

Abstract:

    This module contains definitions for BSD compatibility for
    STREAMS drivers.

Author:

    Eric Chin (ericc)           July 18, 1991

Revision History:

--*/

/*************************************************************************
 *
 *  SpiderTCP/SNMP
 *
 *  Copyright 1990  Spider Systems Limited
 *
 *  BSD_TYPES.H
 *
 *  some #defines for BSD compatibility
 *
 *
 *************************************************************************/

/*
 *	 /usr/projects/spare/PBRAIN/SCCS/pbrainG/dev/src/include/sys/snet/0/s.bsd_types.h
 *	@(#)bsd_types.h	1.3
 *
 *	Last delta created	11:54:01 10/16/90
 *	This file extracted	08:53:46 7/10/91
 *
 *	Modifications:
 *
 *	GSS 01/03/90	put in Pbrain
 */

#ifndef _SYS_SNET_BSD_TYPE_
#define _SYS_SNET_BSD_TYPE_


#ifndef u_char
#define u_char	unsigned char
#define u_short unsigned short
#define u_long 	unsigned long
#define u_int 	unsigned int
#endif


/*
 * Select uses bit masks of file descriptors in integers.
 * These macros manipulate such bit fields (the filesystem macros use chars).
 * FD_SETSIZE may be defined by the user, but the default here
 * should be >= NOFILE (param.h). In the current implementation it should
 * not exceed 32 (sizeof int).
 */
#ifndef	FD_SETSIZE
#define	FD_SETSIZE	32
#endif

/* number of bits in a byte */
#define NBBY 8

typedef int	fd_mask;
#define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
#ifndef howmany
#define	howmany(x, y)	(((x)+((y)-1))/(y))
#endif

typedef	struct fd_set {
 	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} fd_set;


#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p)	bzero((char *)(p), sizeof(*(p)))

#endif /* _SYS_SNET_BSD_TYPE_ */