Bladeren bron

[linux] Fix building on RHEL5 and similar platforms

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 jaren geleden
bovenliggende
commit
c0e3a774b2
2 gewijzigde bestanden met toevoegingen van 68 en 75 verwijderingen
  1. 40
    48
      src/arch/x86/core/linux/linux_api.c
  2. 28
    27
      src/include/linux_api.h

+ 40
- 48
src/arch/x86/core/linux/linux_api.c Bestand weergeven

@@ -16,7 +16,7 @@
16 16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 17
  */
18 18
 
19
-FILE_LICENCE(GPL2_OR_LATER);
19
+FILE_LICENCE ( GPL2_OR_LATER );
20 20
 
21 21
 /** @file
22 22
  *
@@ -29,86 +29,78 @@ FILE_LICENCE(GPL2_OR_LATER);
29 29
 #include <asm/unistd.h>
30 30
 #include <string.h>
31 31
 
32
-int linux_open(const char *pathname, int flags)
33
-{
34
-	return linux_syscall(__NR_open, pathname, flags);
32
+int linux_open ( const char *pathname, int flags ) {
33
+	return linux_syscall ( __NR_open, pathname, flags );
35 34
 }
36 35
 
37
-int linux_close(int fd)
38
-{
39
-	return linux_syscall(__NR_close, fd);
36
+int linux_close ( int fd ) {
37
+	return linux_syscall ( __NR_close, fd );
40 38
 }
41 39
 
42
-ssize_t linux_read(int fd, void *buf, size_t count)
43
-{
44
-	return linux_syscall(__NR_read, fd, buf, count);
40
+__kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count ) {
41
+	return linux_syscall ( __NR_read, fd, buf, count );
45 42
 }
46 43
 
47
-ssize_t linux_write(int fd, const void *buf, size_t count)
48
-{
49
-	return linux_syscall(__NR_write, fd, buf, count);
44
+__kernel_ssize_t linux_write ( int fd, const void *buf,
45
+			       __kernel_size_t count ) {
46
+	return linux_syscall  (  __NR_write, fd, buf, count );
50 47
 }
51 48
 
52
-int linux_fcntl(int fd, int cmd, ...)
53
-{
49
+int linux_fcntl ( int fd, int cmd, ... ) {
54 50
 	long arg;
55 51
 	va_list list;
56 52
 
57
-	va_start(list, cmd);
58
-	arg = va_arg(list, long);
59
-	va_end(list);
53
+	va_start ( list, cmd );
54
+	arg = va_arg ( list, long );
55
+	va_end ( list );
60 56
 
61
-	return linux_syscall(__NR_fcntl, fd, cmd, arg);
57
+	return linux_syscall ( __NR_fcntl, fd, cmd, arg );
62 58
 }
63 59
 
64
-int linux_ioctl(int fd, int request, ...)
65
-{
60
+int linux_ioctl ( int fd, int request, ... ) {
66 61
 	void *arg;
67 62
 	va_list list;
68 63
 
69
-	va_start(list, request);
70
-	arg = va_arg(list, void *);
71
-	va_end(list);
64
+	va_start ( list, request );
65
+	arg = va_arg ( list, void * );
66
+	va_end ( list );
72 67
 
73
-	return linux_syscall(__NR_ioctl, fd, request, arg);
68
+	return linux_syscall ( __NR_ioctl, fd, request, arg );
74 69
 }
75 70
 
76
-int linux_poll(struct pollfd *fds, nfds_t nfds, int timeout)
77
-{
78
-	return linux_syscall(__NR_poll, fds, nfds, timeout);
71
+int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout ) {
72
+	return linux_syscall ( __NR_poll, fds, nfds, timeout );
79 73
 }
80 74
 
81
-int linux_nanosleep(const struct timespec *req, struct timespec *rem)
82
-{
83
-	return linux_syscall(__NR_nanosleep, req, rem);
75
+int linux_nanosleep ( const struct timespec *req, struct timespec *rem ) {
76
+	return linux_syscall ( __NR_nanosleep, req, rem );
84 77
 }
85 78
 
86
-int linux_usleep(useconds_t usec)
87
-{
79
+int linux_usleep ( useconds_t usec ) {
88 80
 	struct timespec ts = {
89
-		.tv_sec = (long) (usec / 1000000),
90
-		.tv_nsec = (long) (usec % 1000000) * 1000ul
81
+		.tv_sec = ( ( long ) ( usec / 1000000 ) ),
82
+		.tv_nsec = ( ( long ) ( usec % 1000000 ) * 1000UL ),
91 83
 	};
92 84
 
93
-	return linux_nanosleep(&ts, NULL);
85
+	return linux_nanosleep ( &ts, NULL );
94 86
 }
95 87
 
96
-int linux_gettimeofday(struct timeval *tv, struct timezone *tz)
97
-{
98
-	return linux_syscall(__NR_gettimeofday, tv, tz);
88
+int linux_gettimeofday ( struct timeval *tv, struct timezone *tz ) {
89
+	return linux_syscall ( __NR_gettimeofday, tv, tz );
99 90
 }
100 91
 
101
-void *linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
102
-{
103
-	return (void *)linux_syscall(__SYSCALL_mmap, addr, length, prot, flags, fd, offset);
92
+void * linux_mmap ( void *addr, __kernel_size_t length, int prot, int flags,
93
+		    int fd, __kernel_off_t offset ) {
94
+	return ( void * ) linux_syscall ( __SYSCALL_mmap, addr, length, prot,
95
+					  flags, fd, offset );
104 96
 }
105 97
 
106
-void *linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags)
107
-{
108
-	return (void *)linux_syscall(__NR_mremap, old_address, old_size, new_size, flags);
98
+void * linux_mremap ( void *old_address, __kernel_size_t old_size,
99
+		      __kernel_size_t new_size, int flags ) {
100
+	return ( void * ) linux_syscall ( __NR_mremap, old_address, old_size,
101
+					  new_size, flags );
109 102
 }
110 103
 
111
-int linux_munmap(void *addr, size_t length)
112
-{
113
-	return linux_syscall(__NR_munmap, addr, length);
104
+int linux_munmap ( void *addr, __kernel_size_t length ) {
105
+	return linux_syscall ( __NR_munmap, addr, length );
114 106
 }

+ 28
- 27
src/include/linux_api.h Bestand weergeven

@@ -33,40 +33,41 @@ FILE_LICENCE(GPL2_OR_LATER);
33 33
 
34 34
 #include <stdint.h>
35 35
 
36
-typedef int pid_t;
37
-
36
+#define __KERNEL_STRICT_NAMES
38 37
 #include <linux/types.h>
39 38
 #include <linux/posix_types.h>
39
+typedef __kernel_pid_t pid_t;
40
+typedef __kernel_time_t time_t;
41
+typedef __kernel_suseconds_t suseconds_t;
42
+typedef __kernel_loff_t loff_t;
40 43
 #include <linux/time.h>
41 44
 #include <linux/mman.h>
42 45
 #include <linux/fcntl.h>
43 46
 #include <linux/ioctl.h>
44 47
 #include <linux/poll.h>
45
-
46
-typedef uint32_t useconds_t;
47
-
48
-extern long linux_syscall(int number, ...);
49
-
50
-extern int linux_open(const char *pathname, int flags);
51
-extern int linux_close(int fd);
52
-extern ssize_t linux_read(int fd, void *buf, size_t count);
53
-extern ssize_t linux_write(int fd, const void *buf, size_t count);
54
-extern int linux_fcntl(int fd, int cmd, ...);
55
-extern int linux_ioctl(int fd, int request, ...);
56
-
57 48
 typedef unsigned long nfds_t;
58
-extern int linux_poll(struct pollfd *fds, nfds_t nfds, int timeout);
59
-
60
-extern int linux_nanosleep(const struct timespec *req, struct timespec *rem);
61
-extern int linux_usleep(useconds_t usec);
62
-extern int linux_gettimeofday(struct timeval *tv, struct timezone *tz);
63
-
64
-#define MAP_FAILED ((void *)-1)
65
-
66
-extern void *linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
67
-extern void *linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags);
68
-extern int linux_munmap(void *addr, size_t length);
69
-
70
-extern const char *linux_strerror(int errnum);
49
+typedef uint32_t useconds_t;
50
+#define MAP_FAILED ( ( void * ) -1 )
51
+
52
+extern long linux_syscall ( int number, ... );
53
+
54
+extern int linux_open ( const char *pathname, int flags );
55
+extern int linux_close ( int fd );
56
+extern __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count );
57
+extern __kernel_ssize_t linux_write ( int fd, const void *buf,
58
+				      __kernel_size_t count );
59
+extern int linux_fcntl ( int fd, int cmd, ... );
60
+extern int linux_ioctl ( int fd, int request, ... );
61
+extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout );
62
+extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem );
63
+extern int linux_usleep ( useconds_t usec );
64
+extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz );
65
+extern void * linux_mmap ( void *addr, __kernel_size_t length, int prot,
66
+			   int flags, int fd, off_t offset );
67
+extern void * linux_mremap ( void *old_address, __kernel_size_t old_size,
68
+			     __kernel_size_t new_size, int flags );
69
+extern int linux_munmap ( void *addr, __kernel_size_t length );
70
+
71
+extern const char * linux_strerror ( int errnum );
71 72
 
72 73
 #endif /* _LINUX_API_H */

Laden…
Annuleren
Opslaan