posix_io.h
Go to the documentation of this file.00001 #ifndef _GPXE_POSIX_IO_H
00002 #define _GPXE_POSIX_IO_H
00003
00004
00005
00006
00007
00008
00009
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011
00012 #include <stdint.h>
00013 #include <gpxe/uaccess.h>
00014
00015
00016 #define POSIX_FD_MIN ( 1 )
00017
00018
00019 #define POSIX_FD_MAX ( 31 )
00020
00021
00022 typedef uint32_t fd_set;
00023
00024 extern int open ( const char *uri_string );
00025 extern ssize_t read_user ( int fd, userptr_t buffer,
00026 off_t offset, size_t len );
00027 extern int select ( fd_set *readfds, int wait );
00028 extern ssize_t fsize ( int fd );
00029 extern int close ( int fd );
00030
00031
00032
00033
00034
00035
00036 static inline __attribute__ (( always_inline )) void
00037 FD_ZERO ( fd_set *set ) {
00038 *set = 0;
00039 }
00040
00041
00042
00043
00044
00045
00046
00047 static inline __attribute__ (( always_inline )) void
00048 FD_SET ( int fd, fd_set *set ) {
00049 *set |= ( 1 << fd );
00050 }
00051
00052
00053
00054
00055
00056
00057
00058 static inline __attribute__ (( always_inline )) void
00059 FD_CLR ( int fd, fd_set *set ) {
00060 *set &= ~( 1 << fd );
00061 }
00062
00063
00064
00065
00066
00067
00068
00069
00070 static inline __attribute__ (( always_inline )) int
00071 FD_ISSET ( int fd, fd_set *set ) {
00072 return ( *set & ( 1 << fd ) );
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 static inline ssize_t read ( int fd, void *buf, size_t len ) {
00084 return read_user ( fd, virt_to_user ( buf ), 0, len );
00085 }
00086
00087 #endif