diff options
| author | Holger Lubitz | 2007-08-08 01:01:09 +0200 |
|---|---|---|
| committer | Holger Lubitz | 2007-08-08 01:01:09 +0200 |
| commit | b79d438080845337d797c7b0dcf3372000fe80e2 (patch) | |
| tree | 24f42fa8779441dcf73d75801bcb27419dfe8d99 /src/include/gpxe | |
| parent | Revert "malloc attribute changes" (diff) | |
| parent | Set current working URI to be that of the executable image when (diff) | |
| download | ipxe-b79d438080845337d797c7b0dcf3372000fe80e2.tar.gz ipxe-b79d438080845337d797c7b0dcf3372000fe80e2.tar.xz ipxe-b79d438080845337d797c7b0dcf3372000fe80e2.zip | |
Merge branch 'master' of git://git.etherboot.org/scm/gpxe
Diffstat (limited to 'src/include/gpxe')
| -rw-r--r-- | src/include/gpxe/posix_io.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/include/gpxe/posix_io.h b/src/include/gpxe/posix_io.h index a5cf0c753..9984db005 100644 --- a/src/include/gpxe/posix_io.h +++ b/src/include/gpxe/posix_io.h @@ -10,13 +10,67 @@ #include <stdint.h> #include <gpxe/uaccess.h> +/** Minimum file descriptor that will ever be allocated */ +#define POSIX_FD_MIN ( 1 ) + +/** Maximum file descriptor that will ever be allocated */ +#define POSIX_FD_MAX ( 31 ) + +/** File descriptor set as used for select() */ +typedef uint32_t fd_set; + extern int open ( const char *uri_string ); extern ssize_t read_user ( int fd, userptr_t buffer, off_t offset, size_t len ); +extern int select ( fd_set *readfds, int wait ); extern ssize_t fsize ( int fd ); extern int close ( int fd ); /** + * Zero a file descriptor set + * + * @v set File descriptor set + */ +static inline __attribute__ (( always_inline )) void +FD_ZERO ( fd_set *set ) { + *set = 0; +} + +/** + * Set a bit within a file descriptor set + * + * @v fd File descriptor + * @v set File descriptor set + */ +static inline __attribute__ (( always_inline )) void +FD_SET ( int fd, fd_set *set ) { + *set |= ( 1 << fd ); +} + +/** + * Clear a bit within a file descriptor set + * + * @v fd File descriptor + * @v set File descriptor set + */ +static inline __attribute__ (( always_inline )) void +FD_CLR ( int fd, fd_set *set ) { + *set &= ~( 1 << fd ); +} + +/** + * Test a bit within a file descriptor set + * + * @v fd File descriptor + * @v set File descriptor set + * @ret is_set Corresponding bit is set + */ +static inline __attribute__ (( always_inline )) int +FD_ISSET ( int fd, fd_set *set ) { + return ( *set & ( 1 << fd ) ); +} + +/** * Read data from file * * @v fd File descriptor |
