source: SVN/cambria/redboot/packages/isoinfra/current/include/sys/select.h @ 1

Last change on this file since 1 was 1, checked in by Tim Harvey, 2 years ago

restored latest version of files from server backup

Signed-off-by: Tim Harvey <tharvey@…>

File size: 5.3 KB
Line 
1/*========================================================================
2//
3//      sys/select.h
4//
5//      POSIX definitions for select()
6//
7//========================================================================
8//####ECOSGPLCOPYRIGHTBEGIN####
9// -------------------------------------------
10// This file is part of eCos, the Embedded Configurable Operating System.
11// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12// Copyright (C) 2002 Nick Garnett
13//
14// eCos is free software; you can redistribute it and/or modify it under
15// the terms of the GNU General Public License as published by the Free
16// Software Foundation; either version 2 or (at your option) any later version.
17//
18// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19// WARRANTY; without even the implied warranty of MERCHANTABILITY or
20// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21// for more details.
22//
23// You should have received a copy of the GNU General Public License along
24// with eCos; if not, write to the Free Software Foundation, Inc.,
25// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26//
27// As a special exception, if other files instantiate templates or use macros
28// or inline functions from this file, or you compile this file and link it
29// with other works to produce a work based on this file, this file does not
30// by itself cause the resulting work to be covered by the GNU General Public
31// License. However the source code for this file must still be made available
32// in accordance with section (3) of the GNU General Public License.
33//
34// This exception does not invalidate any other reasons why a work based on
35// this file might be covered by the GNU General Public License.
36//
37// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38// at http://sources.redhat.com/ecos/ecos-license/
39// -------------------------------------------
40//####ECOSGPLCOPYRIGHTEND####
41//========================================================================
42//#####DESCRIPTIONBEGIN####
43//
44// Author(s):     jlarmour
45// Contributors: 
46// Date:          2001-07-26
47// Purpose:       This file provides the macros, types and functions
48//                required by POSIX 1003.1.
49// Description:   Much of the real contents of this file get set from the
50//                configuration (set by the implementation)
51// Usage:         #include <sys/select.h>
52//
53//####DESCRIPTIONEND####
54//
55//======================================================================
56*/
57
58/* CONFIGURATION */
59
60#include <pkgconf/isoinfra.h>          /* Configuration header */
61
62/* ------------------------------------------------------------------- */
63
64#if !defined(_POSIX_SOURCE)
65
66#ifdef CYGINT_ISO_SELECT
67# ifdef CYGBLD_ISO_SELECT_HEADER
68#  include CYGBLD_ISO_SELECT_HEADER
69# else
70
71#   ifndef CYGONCE_ISO_SYS_SELECT_FD_SETS
72#   define CYGONCE_ISO_SYS_SELECT_FD_SETS
73
74#define NBBY    8               /* number of bits in a byte */
75
76/*
77 * Select uses bit masks of file descriptors in longs.  These macros
78 * manipulate such bit fields (the filesystem macros use chars).
79 * FD_SETSIZE may be defined by the user, but the default here should
80 * be enough for most uses.
81 */
82#ifndef FD_SETSIZE
83#define FD_SETSIZE      256
84#endif
85
86typedef unsigned int    fd_mask;
87#define __NFDBITS       (sizeof(fd_mask) * NBBY)        /* bits per mask */
88
89#ifndef __howmany
90#define __howmany(__x, __y)     (((__x) + ((__y) - 1)) / (__y))
91#endif
92
93typedef struct fd_set {
94        fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)];
95} fd_set;
96
97#define FD_SET(__n, __p)   ((__p)->fds_bits[(__n)/__NFDBITS] |= (1 << ((__n) % __NFDBITS)))
98#define FD_CLR(__n, __p)   ((__p)->fds_bits[(__n)/__NFDBITS] &= ~(1 << ((__n) % __NFDBITS)))
99#define FD_ISSET(__n, __p) ((__p)->fds_bits[(__n)/__NFDBITS] & (1 << ((__n) % __NFDBITS)))
100
101#define FD_COPY(__f, __t)                                       \
102{                                                               \
103    unsigned int _i;                                            \
104    for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \
105        (__t)->fds_bits[_i] = (__f)->fds_bits[_i];              \
106}
107
108#define FD_ZERO(__p)                                            \
109{                                                               \
110    unsigned int _i;                                            \
111    for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \
112        (__p)->fds_bits[_i] = 0;                                \
113}
114
115#   endif /* CYGONCE_ISO_SYS_SELECT_FD_SETS */
116
117#  ifndef __NEED_FD_SETS_ONLY
118
119#   ifndef CYGONCE_ISO_SYS_SELECT_H
120#   define CYGONCE_ISO_SYS_SELECT_H
121
122#   ifdef __cplusplus
123extern "C" {
124#   endif
125
126struct timeval;
127extern int
128select( int /* nfd */, fd_set * /* in */, fd_set * /* out */,
129        fd_set * /* ex */, struct timeval * /* tv */ );
130
131#ifdef CYGPKG_POSIX
132# include <pkgconf/posix.h>
133# ifdef CYGPKG_POSIX_SIGNALS
134#  include <signal.h>
135struct timespec;
136extern int
137pselect( int /* nfd */, fd_set * /* in */, fd_set * /* out */,
138        fd_set * /* ex */, const struct timespec * /* ts */,
139        const sigset_t * /* mask */);
140# endif
141#endif
142   
143#   ifdef __cplusplus
144}   /* extern "C" */
145#   endif
146
147#   endif /* CYGONCE_ISO_SYS_SELECT_H multiple inclusion protection */
148
149#  endif /* __NEED_FD_SETS_ONLY */
150
151# endif
152#endif
153
154
155#endif /* if !defined(_POSIX_SOURCE) */
156/* ------------------------------------------------------------------- */
157
158/* EOF sys/select.h */
Note: See TracBrowser for help on using the repository browser.