phunix/include/sys/select.h
Tomas Hruby 0b8e20c89e Changes to the include files in order to make cross-compilation possible.
- The primary reason is that mkfs and installboot need to run natively during
  the cross compilation (host and target versions are compiled). There is a
  collision of include files though. E.g. a.out.h is very minix-specific.
  Therefore some files we moved and replaced by stubs that include the original
  file if compiling on or for Minix :
  
  include/a.out.h -> include/minix/a.out.h
  include/sys/dir.h -> include/minix/dir.h
  include/dirent.h -> include/minix/dirent.h
  include/sys/types.h -> include/minix/types.h

- This does not break any native compilation on Minix. Other headers that were
  including the original files are changed according to include directly the
  new, minix specific location not to pick up the host system includes while
  cross-compiling.

- role of this patch is to make rebasing of the build branch simpler until the
  new build system is merged
2009-11-06 08:46:22 +00:00

51 lines
1.5 KiB
C
Executable File

#ifndef _SYS_SELECT_H
#define _SYS_SELECT_H 1
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#endif
#include <sys/time.h>
#include <minix/types.h>
#include <limits.h>
#include <string.h>
/* Use this datatype as basic storage unit in fd_set */
typedef u32_t fd_mask;
/* This many bits fit in an fd_set word. */
#define _FDSETBITSPERWORD (sizeof(fd_mask)*8)
/* Bit manipulation macros */
#define _FD_BITMASK(b) (1L << ((b) % _FDSETBITSPERWORD))
#define _FD_BITWORD(b) ((b)/_FDSETBITSPERWORD)
/* Default FD_SETSIZE is OPEN_MAX. */
#ifndef FD_SETSIZE
#define FD_SETSIZE OPEN_MAX
#endif
/* We want to store FD_SETSIZE bits. */
#define _FDSETWORDS(b) (((b)+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
typedef struct {
fd_mask fds_bits[_FDSETWORDS(FD_SETSIZE)];
} fd_set;
_PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) );
#define FD_ZERO(s) do { int _i; for(_i = 0; _i < _FDSETWORDS(FD_SETSIZE); _i++) { (s)->fds_bits[_i] = 0; } } while(0)
#define FD_SET(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] |= _FD_BITMASK(f); } while(0)
#define FD_CLR(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] &= ~(_FD_BITMASK(f)); } while(0)
#define FD_ISSET(f, s) ((s)->fds_bits[_FD_BITWORD(f)] & _FD_BITMASK(f))
/* possible select() operation types; read, write, errors */
/* (FS/driver internal use only) */
#define SEL_RD (1 << 0)
#define SEL_WR (1 << 1)
#define SEL_ERR (1 << 2)
#define SEL_NOTIFY (1 << 3) /* not a real select operation */
#endif /* _SYS_SELECT_H */