aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-05-26 18:48:56 +0000
committerEric Andersen <andersen@codepoet.org>2003-05-26 18:48:56 +0000
commit82ab3d7c3e65998e0b033347072ee32cf5d61b42 (patch)
tree23318f32d86a7f4c591bd9a8ef895f4e32929243
parentb0cfca75442293b4b670584d83c39f9cea9f5a8b (diff)
downloadbusybox-w32-82ab3d7c3e65998e0b033347072ee32cf5d61b42.tar.gz
busybox-w32-82ab3d7c3e65998e0b033347072ee32cf5d61b42.tar.bz2
busybox-w32-82ab3d7c3e65998e0b033347072ee32cf5d61b42.zip
Make all syscall declarations use the syscall() function
-rw-r--r--include/libbb.h13
-rw-r--r--libbb/module_syscalls.c47
-rw-r--r--libbb/syscalls.c80
3 files changed, 77 insertions, 63 deletions
diff --git a/include/libbb.h b/include/libbb.h
index a54ab4d5c..2828456bc 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -66,6 +66,19 @@ extern int daemon (int nochdir, int noclose);
66char *strtok_r(char *s, const char *delim, char **ptrptr); 66char *strtok_r(char *s, const char *delim, char **ptrptr);
67#endif 67#endif
68 68
69/* Convenience macros to test the version of gcc. */
70#if defined __GNUC__ && defined __GNUC_MINOR__
71# define __GNUC_PREREQ(maj, min) \
72 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
73#else
74# define __GNUC_PREREQ(maj, min) 0
75#endif
76
77/* __restrict is known in EGCS 1.2 and above. */
78#if !__GNUC_PREREQ (2,92)
79# define __restrict /* Ignore */
80#endif
81
69/* Some useful definitions */ 82/* Some useful definitions */
70#define FALSE ((int) 0) 83#define FALSE ((int) 0)
71#define TRUE ((int) 1) 84#define TRUE ((int) 1)
diff --git a/libbb/module_syscalls.c b/libbb/module_syscalls.c
index 8fe9e525c..b0ace74ea 100644
--- a/libbb/module_syscalls.c
+++ b/libbb/module_syscalls.c
@@ -37,42 +37,47 @@
37 37
38#if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) 38#if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
39/* These syscalls are not included as part of libc5 */ 39/* These syscalls are not included as part of libc5 */
40_syscall1(int, delete_module, const char *, name); 40int delete_module(const char *name)
41_syscall1(int, get_kernel_syms, __ptr_t, ks); 41{
42 return(syscall(__NR_delete_module, name));
43}
44int get_kernel_syms(__ptr_t ks)
45{
46 return(syscall(__NR_get_kernel_syms, ks));
47}
42 48
43/* This may have 5 arguments (for old 2.0 kernels) or 2 arguments 49/* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
44 * (for 2.2 and 2.4 kernels). Use the greatest common denominator, 50 * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
45 * and let the kernel cope with whatever it gets. Its good at that. */ 51 * and let the kernel cope with whatever it gets. Its good at that. */
46_syscall5(int, init_module, void *, first, void *, second, void *, third, 52int init_module(void *first, void *second, void *third, void *fourth, void *fifth)
47 void *, fourth, void *, fifth); 53{
54 return(syscall(__NR_init_module, first, second, third, fourth, fifth));
55}
48 56
57int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
58{
49#ifndef __NR_query_module 59#ifndef __NR_query_module
50#warning This kernel does not support the query_module syscall 60#warning This kernel does not support the query_module syscall
51#warning -> The query_module system call is being stubbed out... 61#warning -> The query_module system call is being stubbed out...
52int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret) 62 bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
53{ 63 "BusyBox with a kernel supporting the query_module system call.\n");
54 bb_error_msg("\n\nTo make this application work, you will need to recompile\n" 64 errno=ENOSYS;
55 "with a kernel supporting the query_module system call. -Erik\n"); 65 return -1;
56 errno=ENOSYS;
57 return -1;
58}
59#else 66#else
60_syscall5(int, query_module, const char *, name, int, which, 67 return(syscall(__NR_query_module, name, which, buf, bufsize, ret));
61 void *, buf, size_t, bufsize, size_t*, ret);
62#endif 68#endif
69}
63 70
64/* Jump through hoops to fixup error return codes */ 71/* Jump through hoops to fixup error return codes */
65#define __NR___create_module __NR_create_module
66static inline _syscall2(long, __create_module, const char *, name, size_t, size)
67unsigned long create_module(const char *name, size_t size) 72unsigned long create_module(const char *name, size_t size)
68{ 73{
69 long ret = __create_module(name, size); 74 long ret = syscall(__NR_create_module, name, size);
70 75
71 if (ret == -1 && errno > 125) { 76 if (ret == -1 && errno > 125) {
72 ret = -errno; 77 ret = -errno;
73 errno = 0; 78 errno = 0;
74 } 79 }
75 return ret; 80 return ret;
76} 81}
77 82
78#endif /* __GNU_LIBRARY__ < 5 */ 83#endif /* __GNU_LIBRARY__ < 5 */
diff --git a/libbb/syscalls.c b/libbb/syscalls.c
index 8d8c689f1..2434cb453 100644
--- a/libbb/syscalls.c
+++ b/libbb/syscalls.c
@@ -34,71 +34,67 @@
34#endif 34#endif
35#include "libbb.h" 35#include "libbb.h"
36 36
37#if defined(__ia64__)
38int sysfs( int option, unsigned int fs_index, char * buf) 37int sysfs( int option, unsigned int fs_index, char * buf)
39{ 38{
40 return(syscall(__NR_sysfs, option, fs_index, buf)); 39 return(syscall(__NR_sysfs, option, fs_index, buf));
41} 40}
42#else
43_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
44#endif
45 41
42int pivot_root(const char * new_root,const char * put_old)
43{
46#ifndef __NR_pivot_root 44#ifndef __NR_pivot_root
47#warning This kernel does not support the pivot_root syscall 45#warning This kernel does not support the pivot_root syscall
48#warning -> The pivot_root system call is being stubbed out... 46#warning -> The pivot_root system call is being stubbed out...
49int pivot_root(const char * new_root,const char * put_old) 47 /* BusyBox was compiled against a kernel that did not support
50{ 48 * the pivot_root system call. To make this application work,
51 /* BusyBox was compiled against a kernel that did not support 49 * you will need to recompile with a kernel supporting the
52 * the pivot_root system call. To make this application work, 50 * pivot_root system call.
53 * you will need to recompile with a kernel supporting the 51 */
54 * pivot_root system call. 52 bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
55 */ 53 "BusyBox with a kernel supporting the pivot_root system call.\n");
56 bb_error_msg("\n\nTo make this application work, you will need to recompile\n" 54 errno=ENOSYS;
57 "with a kernel supporting the pivot_root system call. -Erik\n"); 55 return -1;
58 errno=ENOSYS;
59 return -1;
60}
61#else 56#else
62# if defined(__ia64__) 57 return(syscall(__NR_pivot_root, new_root, put_old));
63 int pivot_root(const char * new_root,const char * put_old)
64 {
65 return(syscall(__NR_pivot_root, new_root, put_old));
66 }
67# else
68 _syscall2(int,pivot_root,const char *,new_root,const char *,put_old);
69# endif
70#endif 58#endif
71 59}
72 60
73 61
74 62
75#if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) 63#if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
64
76/* These syscalls are not included as part of libc5 */ 65/* These syscalls are not included as part of libc5 */
77_syscall2(int, bdflush, int, func, int, data); 66int bdflush(int func, int data)
67{
68 return(syscall(__NR_bdflush, func, data));
69}
78 70
79#ifndef __alpha__ 71#ifndef __alpha__
80# define __NR_klogctl __NR_syslog 72# define __NR_klogctl __NR_syslog
81 _syscall3(int, klogctl, int, type, char *, b, int, len); 73int klogctl(int type, char *b, int len)
74{
75 return(syscall(__NR_klogctl, type, b, len));
76}
82#endif 77#endif
83 78
84#ifndef __NR_umount2 79
85# warning This kernel does not support the umount2 syscall
86# warning -> The umount2 system call is being stubbed out...
87int umount2(const char * special_file, int flags) 80int umount2(const char * special_file, int flags)
88{ 81{
89 /* BusyBox was compiled against a kernel that did not support 82#ifndef __NR_pivot_root
90 * the umount2 system call. To make this application work, 83#warning This kernel does not support the umount2 syscall
91 * you will need to recompile with a kernel supporting the 84#warning -> The umount2 system call is being stubbed out...
92 * umount2 system call. 85 /* BusyBox was compiled against a kernel that did not support
93 */ 86 * the umount2 system call. To make this application work,
94 bb_error_msg("\n\nTo make this application work, you will need to recompile\n" 87 * you will need to recompile with a kernel supporting the
95 "with a kernel supporting the umount2 system call. -Erik\n"); 88 * umount2 system call.
96 errno=ENOSYS; 89 */
97 return -1; 90 bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
98} 91 "BusyBox with a kernel supporting the umount2 system call.\n");
99# else 92 errno=ENOSYS;
100_syscall2(int, umount2, const char *, special_file, int, flags); 93 return -1;
94#else
95 return(syscall(__NR_umount2, special_file, flags));
101#endif 96#endif
97}
102 98
103 99
104#endif /* __GNU_LIBRARY__ < 5 */ 100#endif /* __GNU_LIBRARY__ < 5 */