aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-01-28 01:21:33 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-01-28 01:21:33 +0000
commit656ea57b2160547c909f7f7b9d63a59100f1c01c (patch)
tree6d82773a096ca412a2dd2642917ba523d7b556d0
parent173d724734f81b3245a41822fc27f7556509d826 (diff)
downloadklibc-656ea57b2160547c909f7f7b9d63a59100f1c01c.tar.gz
Add getpagesize() as a real function -- it's a system call on someklibc-0.100
platforms and not others.
-rw-r--r--include/unistd.h8
-rw-r--r--klibc/Makefile2
-rw-r--r--klibc/getpagesize.c26
-rw-r--r--klibc/include/unistd.h8
-rw-r--r--klibc/syscommon.h2
5 files changed, 32 insertions, 14 deletions
diff --git a/include/unistd.h b/include/unistd.h
index 03e8e99666cf1..3d5c6881d359f 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -10,7 +10,6 @@
#include <stddef.h>
#include <sys/types.h>
#include <sys/select.h>
-#include <asm/page.h>
__extern char **environ;
__extern __noreturn _exit(int);
@@ -106,14 +105,11 @@ __extern int optind, opterr, optopt;
__extern int isatty(int);
+__extern int getpagesize(void);
+
/* Standard file descriptor numbers. */
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
-static inline int getpagesize(void)
-{
- return PAGE_SIZE;
-}
-
#endif /* _UNISTD_H */
diff --git a/klibc/Makefile b/klibc/Makefile
index 057558c7fa3bc..c5d22279ec1cb 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -24,7 +24,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \
__signal.o signal.o bsd_signal.o siglist.o siglongjmp.o \
sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
- brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
+ brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o getpagesize.o \
memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
memmove.o \
strcasecmp.o strncasecmp.o strndup.o strerror.o \
diff --git a/klibc/getpagesize.c b/klibc/getpagesize.c
new file mode 100644
index 0000000000000..2d975b1586c78
--- /dev/null
+++ b/klibc/getpagesize.c
@@ -0,0 +1,26 @@
+/*
+ * getpagesize.c
+ */
+
+#include <sys/syscall.h>
+#include <asm/page.h>
+
+/* Presumably there is a better way to do this... */
+#ifdef __ia64__
+# define __NR_getpagesize 1171
+#endif
+
+#ifdef __NR_getpagesize
+
+_syscall0(int,getpagesize);
+
+#else
+
+int getpagesize(void)
+{
+ return PAGE_SIZE;
+}
+
+#endif
+
+
diff --git a/klibc/include/unistd.h b/klibc/include/unistd.h
index 03e8e99666cf1..3d5c6881d359f 100644
--- a/klibc/include/unistd.h
+++ b/klibc/include/unistd.h
@@ -10,7 +10,6 @@
#include <stddef.h>
#include <sys/types.h>
#include <sys/select.h>
-#include <asm/page.h>
__extern char **environ;
__extern __noreturn _exit(int);
@@ -106,14 +105,11 @@ __extern int optind, opterr, optopt;
__extern int isatty(int);
+__extern int getpagesize(void);
+
/* Standard file descriptor numbers. */
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
-static inline int getpagesize(void)
-{
- return PAGE_SIZE;
-}
-
#endif /* _UNISTD_H */
diff --git a/klibc/syscommon.h b/klibc/syscommon.h
index 3093920739107..429025279eb22 100644
--- a/klibc/syscommon.h
+++ b/klibc/syscommon.h
@@ -28,5 +28,5 @@
#include <unistd.h>
#ifdef __i386__
-#include <sys/vm86.h>
+# include <sys/vm86.h>
#endif