david/ipxe
Archived
1
0

[linux] Fix building on RHEL5 and similar platforms

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2010-10-11 02:24:39 +01:00
parent 6d11229e83
commit c0e3a774b2
2 changed files with 65 additions and 72 deletions

View File

@ -29,28 +29,24 @@ FILE_LICENCE(GPL2_OR_LATER);
#include <asm/unistd.h> #include <asm/unistd.h>
#include <string.h> #include <string.h>
int linux_open(const char *pathname, int flags) int linux_open ( const char *pathname, int flags ) {
{
return linux_syscall ( __NR_open, pathname, flags ); return linux_syscall ( __NR_open, pathname, flags );
} }
int linux_close(int fd) int linux_close ( int fd ) {
{
return linux_syscall ( __NR_close, fd ); return linux_syscall ( __NR_close, fd );
} }
ssize_t linux_read(int fd, void *buf, size_t count) __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count ) {
{
return linux_syscall ( __NR_read, fd, buf, count ); return linux_syscall ( __NR_read, fd, buf, count );
} }
ssize_t linux_write(int fd, const void *buf, size_t count) __kernel_ssize_t linux_write ( int fd, const void *buf,
{ __kernel_size_t count ) {
return linux_syscall ( __NR_write, fd, buf, count ); return linux_syscall ( __NR_write, fd, buf, count );
} }
int linux_fcntl(int fd, int cmd, ...) int linux_fcntl ( int fd, int cmd, ... ) {
{
long arg; long arg;
va_list list; va_list list;
@ -61,8 +57,7 @@ int linux_fcntl(int fd, int cmd, ...)
return linux_syscall ( __NR_fcntl, fd, cmd, arg ); return linux_syscall ( __NR_fcntl, fd, cmd, arg );
} }
int linux_ioctl(int fd, int request, ...) int linux_ioctl ( int fd, int request, ... ) {
{
void *arg; void *arg;
va_list list; va_list list;
@ -73,42 +68,39 @@ int linux_ioctl(int fd, int request, ...)
return linux_syscall ( __NR_ioctl, fd, request, arg ); return linux_syscall ( __NR_ioctl, fd, request, arg );
} }
int linux_poll(struct pollfd *fds, nfds_t nfds, int timeout) int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout ) {
{
return linux_syscall ( __NR_poll, fds, nfds, timeout ); return linux_syscall ( __NR_poll, fds, nfds, timeout );
} }
int linux_nanosleep(const struct timespec *req, struct timespec *rem) int linux_nanosleep ( const struct timespec *req, struct timespec *rem ) {
{
return linux_syscall ( __NR_nanosleep, req, rem ); return linux_syscall ( __NR_nanosleep, req, rem );
} }
int linux_usleep(useconds_t usec) int linux_usleep ( useconds_t usec ) {
{
struct timespec ts = { struct timespec ts = {
.tv_sec = (long) (usec / 1000000), .tv_sec = ( ( long ) ( usec / 1000000 ) ),
.tv_nsec = (long) (usec % 1000000) * 1000ul .tv_nsec = ( ( long ) ( usec % 1000000 ) * 1000UL ),
}; };
return linux_nanosleep ( &ts, NULL ); return linux_nanosleep ( &ts, NULL );
} }
int linux_gettimeofday(struct timeval *tv, struct timezone *tz) int linux_gettimeofday ( struct timeval *tv, struct timezone *tz ) {
{
return linux_syscall ( __NR_gettimeofday, tv, tz ); return linux_syscall ( __NR_gettimeofday, tv, tz );
} }
void *linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) void * linux_mmap ( void *addr, __kernel_size_t length, int prot, int flags,
{ int fd, __kernel_off_t offset ) {
return (void *)linux_syscall(__SYSCALL_mmap, addr, length, prot, flags, fd, offset); return ( void * ) linux_syscall ( __SYSCALL_mmap, addr, length, prot,
flags, fd, offset );
} }
void *linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags) void * linux_mremap ( void *old_address, __kernel_size_t old_size,
{ __kernel_size_t new_size, int flags ) {
return (void *)linux_syscall(__NR_mremap, old_address, old_size, new_size, flags); return ( void * ) linux_syscall ( __NR_mremap, old_address, old_size,
new_size, flags );
} }
int linux_munmap(void *addr, size_t length) int linux_munmap ( void *addr, __kernel_size_t length ) {
{
return linux_syscall ( __NR_munmap, addr, length ); return linux_syscall ( __NR_munmap, addr, length );
} }

View File

@ -33,39 +33,40 @@ FILE_LICENCE(GPL2_OR_LATER);
#include <stdint.h> #include <stdint.h>
typedef int pid_t; #define __KERNEL_STRICT_NAMES
#include <linux/types.h> #include <linux/types.h>
#include <linux/posix_types.h> #include <linux/posix_types.h>
typedef __kernel_pid_t pid_t;
typedef __kernel_time_t time_t;
typedef __kernel_suseconds_t suseconds_t;
typedef __kernel_loff_t loff_t;
#include <linux/time.h> #include <linux/time.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/poll.h> #include <linux/poll.h>
typedef unsigned long nfds_t;
typedef uint32_t useconds_t; typedef uint32_t useconds_t;
#define MAP_FAILED ( ( void * ) -1 )
extern long linux_syscall ( int number, ... ); extern long linux_syscall ( int number, ... );
extern int linux_open ( const char *pathname, int flags ); extern int linux_open ( const char *pathname, int flags );
extern int linux_close ( int fd ); extern int linux_close ( int fd );
extern ssize_t linux_read(int fd, void *buf, size_t count); extern __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count );
extern ssize_t linux_write(int fd, const void *buf, size_t count); extern __kernel_ssize_t linux_write ( int fd, const void *buf,
__kernel_size_t count );
extern int linux_fcntl ( int fd, int cmd, ... ); extern int linux_fcntl ( int fd, int cmd, ... );
extern int linux_ioctl ( int fd, int request, ... ); extern int linux_ioctl ( int fd, int request, ... );
typedef unsigned long nfds_t;
extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout ); extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout );
extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem ); extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem );
extern int linux_usleep ( useconds_t usec ); extern int linux_usleep ( useconds_t usec );
extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz ); extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz );
extern void * linux_mmap ( void *addr, __kernel_size_t length, int prot,
#define MAP_FAILED ((void *)-1) int flags, int fd, off_t offset );
extern void * linux_mremap ( void *old_address, __kernel_size_t old_size,
extern void *linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); __kernel_size_t new_size, int flags );
extern void *linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags); extern int linux_munmap ( void *addr, __kernel_size_t length );
extern int linux_munmap(void *addr, size_t length);
extern const char * linux_strerror ( int errnum ); extern const char * linux_strerror ( int errnum );