summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-04-05 07:34:20 +0000
committerEric Andersen <andersen@codepoet.org>2001-04-05 07:34:20 +0000
commitd4d02ff6bdd4003ca80294f31d9ddd5e5585c199 (patch)
tree9e172c26fc3aabfefd9440649fe2994f7151d628 /libc/sysdeps/linux/common
parentba9470b70995e0676313706d394f46807cb6fa88 (diff)
Get the full set of module creating syscalls in place.
-Erik
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/Makefile2
-rw-r--r--libc/sysdeps/linux/common/create_module.c64
-rw-r--r--libc/sysdeps/linux/common/syscalls.c10
3 files changed, 74 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile
index 8dae9d1d3..8617c0b71 100644
--- a/libc/sysdeps/linux/common/Makefile
+++ b/libc/sysdeps/linux/common/Makefile
@@ -27,7 +27,7 @@ LIBC=$(TOPDIR)libc.a
CSRC= waitpid.c getdents.c kernel_version.c statfix.c getdnnm.c tell.c gethstnm.c \
mkfifo.c setegid.c wait.c errno.c getpagesize.c seteuid.c wait3.c setpgrp.c \
- getdtablesize.c
+ getdtablesize.c create_module.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
MSRC=syscalls.c
diff --git a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c
new file mode 100644
index 000000000..1cacaefaf
--- /dev/null
+++ b/libc/sysdeps/linux/common/create_module.c
@@ -0,0 +1,64 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Syscalls for uClibc
+ *
+ * Copyright (C) 2000 by Lineo, inc. Written by Erik Andersen
+ * <andersen@lineo.com>, <andersee@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <errno.h>
+#include <features.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+
+//#define __NR_create_module 127
+
+#if defined(__i386__) || defined(__m68k__) || defined(__arm__)
+#define __NR___create_module __NR_create_module
+_syscall2(long, __create_module, const char *, name, size_t, size);
+/* By checking the value of errno, we know if we have been fooled
+ * by the syscall2 macro making a very high address look like a
+ * negaitive, so we we fix it up here. */
+unsigned long create_module(const char *name, size_t size)
+{
+ long ret = __create_module(name, size);
+
+ /* Jump through hoops to fixup error return codes */
+ if (ret == -1 && errno > 125) {
+ ret = -errno;
+ errno = 0;
+ }
+ return ret;
+}
+#elif defined(__alpha__)
+#define __NR___create_module __NR_create_module
+/* Alpha doesn't have the same problem, exactly, but a bug in older
+ kernels fails to clear the error flag. Clear it here explicitly. */
+_syscall4(unsigned long, __create_module, const char *, name,
+ size_t, size, size_t, dummy, size_t, err);
+unsigned long create_module(const char *name, size_t size)
+{
+ return __create_module(name, size, 0, 0);
+}
+#else
+/* Sparc, MIPS, etc don't mistake return values for errors. */
+_syscall2(unsigned long, create_module, const char *, name, size_t, size)
+#endif
+
+
diff --git a/libc/sysdeps/linux/common/syscalls.c b/libc/sysdeps/linux/common/syscalls.c
index 7051c56ef..ca0b3a317 100644
--- a/libc/sysdeps/linux/common/syscalls.c
+++ b/libc/sysdeps/linux/common/syscalls.c
@@ -891,13 +891,21 @@ _syscall3(int, sigprocmask, int, how, const sigset_t *, set, sigset_t *,
#endif
//#define __NR_create_module 127
+//See sysdeps/linux/commom/create_module.c
//#define __NR_init_module 128
+#ifdef L_init_module
+/* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
+ * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
+ * and let the kernel cope with whatever it gets. It's good at that. */
+_syscall5(int, init_module, void *, first, void *, second, void *, third,
+ void *, fourth, void *, fifth);
+#endif
//#define __NR_delete_module 129
#ifdef L_delete_module
# ifdef __NR_delete_module
- _syscall1(int, delete_module, const char *, name)
+ _syscall1(int, delete_module, const char *, name);
# endif
#endif