Completed sys/select.h, renamed the howmany() macro to _howmany() - now
also contains the pselect() prototype. Added new header file sys/time.h. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1736 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
493130b326
commit
d068515fcb
@ -4,7 +4,9 @@
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
/* If FD_SET is already defined, only the select() prototype is
|
||||
@ -19,24 +21,16 @@
|
||||
# define FD_SETSIZE 1024
|
||||
#endif
|
||||
|
||||
/* Compatibily only: use FD_SETSIZE instead */
|
||||
#ifndef FDSETSIZE
|
||||
# define FDSETSIZE FD_SETSIZE
|
||||
#endif
|
||||
|
||||
/* compatibility with BSD */
|
||||
#define NBBY 8 /* number of bits in a byte */
|
||||
|
||||
typedef unsigned long fd_mask;
|
||||
|
||||
#ifndef howmany
|
||||
# define howmany(x, y) (((x) + ((y) - 1)) / (y))
|
||||
#ifndef _howmany
|
||||
# define _howmany(x, y) (((x) + ((y) - 1)) / (y))
|
||||
#endif
|
||||
|
||||
#define NFDBITS (sizeof(fd_mask) * NBBY)
|
||||
#define NFDBITS (sizeof(fd_mask) * 8) /* bits per mask */
|
||||
|
||||
typedef struct fd_set {
|
||||
fd_mask bits[howmany(FD_SETSIZE, NFDBITS)];
|
||||
fd_mask bits[_howmany(FD_SETSIZE, NFDBITS)];
|
||||
} fd_set;
|
||||
|
||||
#define _FD_BITSINDEX(fd) ((fd) / NFDBITS)
|
||||
@ -49,11 +43,17 @@ typedef struct fd_set {
|
||||
|
||||
#endif /* FD_SET */
|
||||
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int pselect(int nbits, struct fd_set *rbits, struct fd_set *wbits, struct fd_set *ebits,
|
||||
const struct timespec *timeout, const sigset_t *sigMask);
|
||||
extern int select(int nbits, struct fd_set *rbits, struct fd_set *wbits,
|
||||
struct fd_set *ebits, struct timeval *timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
int select(int nbits, struct fd_set *rbits, struct fd_set *wbits,
|
||||
struct fd_set *ebits, struct timeval *timeout);
|
||||
|
||||
#endif /* _SYS_SELECT_H */
|
||||
|
52
headers/posix/sys/time.h
Normal file
52
headers/posix/sys/time.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef _SYS_TIME_H
|
||||
#define _SYS_TIME_H
|
||||
/*
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
|
||||
#include <sys/select.h>
|
||||
/* circular dependency: fd_set needs to be defined and the
|
||||
* select prototype exported by this file, but <sys/select.h>
|
||||
* needs struct timeval.
|
||||
*/
|
||||
|
||||
struct timezone {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval;
|
||||
struct timeval it_value;
|
||||
};
|
||||
|
||||
#define ITIMER_REAL 1 /* real time */
|
||||
#define ITIMER_VIRTUAL 2 /* process virtual time */
|
||||
#define ITIMER_PROF 3 /* both */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int getitimer(int which, struct itimerval *value);
|
||||
extern int setitimer(int which, const struct itimerval *value, struct itimerval *oldValue);
|
||||
extern int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||
|
||||
extern int utimes(const char *name, const struct timeval times[2]);
|
||||
/* legacy */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_TIME_H */
|
Loading…
Reference in New Issue
Block a user