]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/create_module.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / create_module.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * create_module syscall for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 #include <features.h>
11 #define __need_size_t
12 #include <stddef.h>
13 #include <errno.h>
14 #include <sys/syscall.h>
15
16 #ifdef __NR_create_module
17
18 unsigned long create_module(const char *name, size_t size);
19
20 #if defined(__UCLIBC_BROKEN_CREATE_MODULE__)
21 # define __NR___create_module  __NR_create_module
22 static __inline__ _syscall2(long, __create_module, const char *, name, size_t, size)
23 /* By checking the value of errno, we know if we have been fooled
24  * by the syscall2 macro making a very high address look like a
25  * negative, so we fix it up here.  */
26 unsigned long create_module(const char *name, size_t size)
27 {
28         long ret = __create_module(name, size);
29
30         /* Jump through hoops to fixup error return codes */
31         if (ret == -1 && errno > 125) {
32                 ret = -errno;
33                 __set_errno(0);
34         }
35         return ret;
36 }
37 #elif defined(__UCLIBC_SLIGHTLY_BROKEN_CREATE_MODULE__)
38 # define __NR___create_module  __NR_create_module
39 /* Alpha doesn't have the same problem, exactly, but a bug in older
40    kernels fails to clear the error flag.  Clear it here explicitly.  */
41 static __inline__ _syscall4(unsigned long, __create_module, const char *, name,
42                         size_t, size, size_t, dummy, size_t, err)
43 unsigned long create_module(const char *name, size_t size)
44 {
45         return __create_module(name, size, 0, 0);
46 }
47 #else
48 /* Sparc, MIPS, etc don't mistake return values for errors. */
49 _syscall2(unsigned long, create_module, const char *, name, size_t, size)
50 #endif
51
52 #endif