1 |
199 |
simons |
/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
2 |
|
|
This file is part of the GNU C Library.
|
3 |
|
|
|
4 |
|
|
The GNU C Library is free software; you can redistribute it and/or
|
5 |
|
|
modify it under the terms of the GNU Library General Public License as
|
6 |
|
|
published by the Free Software Foundation; either version 2 of the
|
7 |
|
|
License, or (at your option) any later version.
|
8 |
|
|
|
9 |
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
|
|
Library General Public License for more details.
|
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU Library General Public
|
15 |
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
16 |
|
|
not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
|
17 |
|
|
Cambridge, MA 02139, USA. */
|
18 |
|
|
|
19 |
|
|
#ifndef _GNU_TYPES_H
|
20 |
|
|
|
21 |
|
|
#define _GNU_TYPES_H 1
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Convenience types. */
|
25 |
|
|
typedef unsigned char __u_char;
|
26 |
|
|
typedef unsigned short __u_short;
|
27 |
|
|
typedef unsigned int __u_int;
|
28 |
|
|
typedef unsigned long __u_long;
|
29 |
|
|
typedef struct
|
30 |
|
|
{
|
31 |
|
|
long val[2];
|
32 |
|
|
} __quad;
|
33 |
|
|
typedef struct
|
34 |
|
|
{
|
35 |
|
|
__u_long val[2];
|
36 |
|
|
} __u_quad;
|
37 |
|
|
|
38 |
|
|
#ifdef __linux__
|
39 |
|
|
typedef unsigned short __dev_t; /* Type of device numbers. */
|
40 |
|
|
typedef unsigned short __gid_t; /* Type of group identifications. */
|
41 |
|
|
typedef unsigned short __uid_t; /* Type of user identifications. */
|
42 |
|
|
typedef unsigned short __mode_t;/* Type of file attribute bitmasks. */
|
43 |
|
|
typedef long __daddr_t; /* The type of a disk address. */
|
44 |
|
|
typedef long __off_t; /* Type of file sizes and offsets. */
|
45 |
|
|
#ifndef __STRICT_ANSI__
|
46 |
|
|
typedef long long __loff_t; /* Type of long file sizes and offsets. */
|
47 |
|
|
#endif
|
48 |
|
|
typedef unsigned long __ino_t; /* Type of file serial numbers. */
|
49 |
|
|
typedef unsigned short __nlink_t; /* Type of file link counts. */
|
50 |
|
|
typedef long __time_t;
|
51 |
|
|
#else
|
52 |
|
|
typedef int __dev_t; /* Type of device numbers. */
|
53 |
|
|
typedef unsigned int __gid_t; /* Type of group identifications. */
|
54 |
|
|
typedef unsigned int __uid_t; /* Type of user identifications. */
|
55 |
|
|
typedef unsigned int __mode_t; /* Type of file attribute bitmasks. */
|
56 |
|
|
typedef long int __daddr_t; /* The type of a disk address. */
|
57 |
|
|
typedef long int __off_t; /* Type of file sizes and offsets. */
|
58 |
|
|
typedef unsigned long int __ino_t; /* Type of file serial numbers. */
|
59 |
|
|
typedef unsigned short int __nlink_t; /* Type of file link counts. */
|
60 |
|
|
typedef long int __time_t;
|
61 |
|
|
#endif
|
62 |
|
|
|
63 |
|
|
typedef int __pid_t; /* Type of process identifications. */
|
64 |
|
|
typedef int __ssize_t; /* Type of a byte count, or error. */
|
65 |
|
|
typedef __quad __fsid_t; /* Type of file system IDs. */
|
66 |
|
|
|
67 |
|
|
/* Everythin' else. */
|
68 |
|
|
typedef char *__caddr_t;
|
69 |
|
|
typedef long int __swblk_t; /* Type of a swap block maybe? */
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
/* fd_set for select. */
|
73 |
|
|
|
74 |
|
|
#ifdef __linux__
|
75 |
|
|
|
76 |
|
|
#if 1
|
77 |
|
|
|
78 |
|
|
#include <linux/posix_types.h>
|
79 |
|
|
|
80 |
|
|
#ifndef __FDSET_LONGS
|
81 |
|
|
#define __FDSET_LONGS __FDSET_INTS
|
82 |
|
|
#endif
|
83 |
|
|
|
84 |
|
|
typedef struct __fd_set {
|
85 |
|
|
unsigned long fds_bits [__FDSET_LONGS];
|
86 |
|
|
} __fd_set;
|
87 |
|
|
|
88 |
|
|
#else
|
89 |
|
|
|
90 |
|
|
#ifndef __FDSET_LONGS
|
91 |
|
|
#define __FDSET_LONGS 8
|
92 |
|
|
#endif
|
93 |
|
|
|
94 |
|
|
typedef struct __fd_set {
|
95 |
|
|
unsigned long fds_bits [__FDSET_LONGS];
|
96 |
|
|
} __fd_set;
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
#ifndef __NFDBITS
|
100 |
|
|
|
101 |
|
|
#define __NFDBITS (sizeof(unsigned long int) * 8)
|
102 |
|
|
|
103 |
|
|
#define __FD_SETSIZE (__FDSET_LONGS*__NFDBITS)
|
104 |
|
|
|
105 |
|
|
#define __FD_SET(fd,fdsetp) \
|
106 |
|
|
__asm__ __volatile__ ("btsl %1,%0": \
|
107 |
|
|
"=m" (*(__fd_set *) (fdsetp)):"r" ((int) (fd)))
|
108 |
|
|
|
109 |
|
|
#define __FD_CLR(fd,fdsetp) \
|
110 |
|
|
__asm__ __volatile__("btrl %1,%0": \
|
111 |
|
|
"=m" (*(__fd_set *) (fdsetp)):"r" ((int) (fd)))
|
112 |
|
|
|
113 |
|
|
#define __FD_ISSET(fd,fdsetp) __extension__ ({ \
|
114 |
|
|
unsigned char __result; \
|
115 |
|
|
__asm__ __volatile__("btl %1,%2 ; setb %0" \
|
116 |
|
|
:"=q" (__result) :"r" ((int) (fd)), \
|
117 |
|
|
"m" (*(__fd_set *) (fdsetp))); \
|
118 |
|
|
__result; })
|
119 |
|
|
|
120 |
|
|
#define __FD_ZERO(fdsetp) \
|
121 |
|
|
__asm__ __volatile__("cld ; rep ; stosl" \
|
122 |
|
|
:"=m" (*(__fd_set *) (fdsetp)) \
|
123 |
|
|
:"a" (0), "c" (__FDSET_LONGS), \
|
124 |
|
|
"D" ((__fd_set *) (fdsetp)) :"cx","di")
|
125 |
|
|
|
126 |
|
|
#endif /* __NFDBITS */
|
127 |
|
|
|
128 |
|
|
#endif
|
129 |
|
|
|
130 |
|
|
#else /* __linux__ */
|
131 |
|
|
|
132 |
|
|
/* Number of descriptors that can fit in an `fd_set'. */
|
133 |
|
|
#define __FD_SETSIZE 256
|
134 |
|
|
|
135 |
|
|
/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
|
136 |
|
|
#define __NFDBITS (sizeof(unsigned long int) * 8)
|
137 |
|
|
#define __FDELT(d) ((d) / __NFDBITS)
|
138 |
|
|
#define __FDMASK(d) (1 << ((d) % __NFDBITS))
|
139 |
|
|
|
140 |
|
|
typedef struct
|
141 |
|
|
{
|
142 |
|
|
unsigned long int fds_bits [(__FD_SETSIZE + (__NFDBITS - 1)) / __NFDBITS];
|
143 |
|
|
} __fd_set;
|
144 |
|
|
|
145 |
|
|
/* This line MUST be split! Otherwise m4 will not change it. */
|
146 |
|
|
#define __FD_ZERO(set) \
|
147 |
|
|
((void) memset((__ptr_t) (set), 0, sizeof(fd_set)))
|
148 |
|
|
#define __FD_SET(d, set) ((set)->__bits[__FDELT(d)] |= __FDMASK(d))
|
149 |
|
|
#define __FD_CLR(d, set) ((set)->__bits[__FDELT(d)] &= ~__FDMASK(d))
|
150 |
|
|
#define __FD_ISSET(d, set) ((set)->__bits[__FDELT(d)] & __FDMASK(d))
|
151 |
|
|
|
152 |
|
|
#endif /* __linux__ */
|
153 |
|
|
|
154 |
|
|
#endif /* gnu/types.h */
|