summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen LaHaise <bcrl@kvack.org>2002-08-27 19:03:05 +0000
committerBen LaHaise <bcrl@kvack.org>2002-08-27 19:03:05 +0000
commitdeff45de0910a038e65f0dc5981486cfd0cae80b (patch)
treeb07e85c7b79208f1f4ca71b9df81076199b57d55
parenta2898b5d9815e462d8ef9fbbfb0c56a294d72e8b (diff)
downloadlibaio-deff45de0910a038e65f0dc5981486cfd0cae80b.tar.gz
we have real syscall numbers for x86!libaio.0-3-13.3
-rw-r--r--src/lib/src/Makefile13
-rw-r--r--src/lib/src/aio_syscalls.c79
-rw-r--r--src/lib/src/kso_init.c23
-rw-r--r--src/lib/src/stub.S32
-rw-r--r--src/lib/src/syscall-i386.h36
-rw-r--r--src/lib/src/vsysaddr.S24
6 files changed, 117 insertions, 90 deletions
diff --git a/src/lib/src/Makefile b/src/lib/src/Makefile
index 2fd462a..01e4089 100644
--- a/src/lib/src/Makefile
+++ b/src/lib/src/Makefile
@@ -2,21 +2,12 @@ root=/
all: libredhat-kernel.so
ASFLAGS=-D__KERNEL__ -D__ASSEMBLY__ -I../include -nostdlib -nostartfiles
-CFLAGS=-D__KERNEL__ -I../include -nostdlib -nostartfiles
+CFLAGS=-Wall -D__KERNEL__ -I../include -nostdlib -nostartfiles -O2 -fomit-frame-pointer
soname=libredhat-kernel.so.1
dummyver=.0.0
extraver=.0.1
-so_objs=vsysaddr.o kso_init.o
-
-# We can't autogenerate or we'll depend on running a kernel with this
-# already installed
-make_stub_vsysaddr.S:
- rm -f vsysaddr.S
- echo '#include "stub.S"' >vsysaddr.S
- awk -- "/^bfff.* vsys_/ { print \"dynamic_syscall(\"\$$3 \",0x\" \$$1 \")\"; }" <System.map >>vsysaddr.S
-
-vsysaddr.o: vsysaddr.S
+so_objs=aio_syscalls.o
$(soname): $(so_objs) libredhat-kernel.map
gcc -nostdlib -nostartfiles -shared -Wl,--version-script=libredhat-kernel.map -Wl,-soname=$(soname) -o $@ $(so_objs)
diff --git a/src/lib/src/aio_syscalls.c b/src/lib/src/aio_syscalls.c
new file mode 100644
index 0000000..5d8ef1b
--- /dev/null
+++ b/src/lib/src/aio_syscalls.c
@@ -0,0 +1,79 @@
+/* libaio Linux async I/O interface
+ Copyright 2002 Red Hat, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <stdlib.h>
+
+#include "../../libaio.h"
+#include "../../vsys_def.h"
+
+#include "syscall-i386.h"
+
+#include <asm/errno.h>
+
+
+int vsys_io_setup(unsigned nr_reqs, io_context_t *ctxp)
+{
+ return syscall2(__NR_io_setup, nr_reqs, ctxp);
+}
+
+int vsys_io_destroy(io_context_t ctx)
+{
+ return syscall1(__NR_io_destroy, ctx);
+}
+
+int vsys_io_submit(io_context_t ctx, long nr, struct iocb *iocbs[])
+{
+ return syscall3(__NR_io_submit, ctx, nr, iocbs);
+}
+
+static inline int real_sys_io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *event)
+{
+ return syscall3(__NR_io_cancel, ctx, iocb, event);
+}
+
+/* ABI change. Provide partial compatibility on this one for now. */
+int vsys_io_cancel(io_context_t ctx, struct iocb *iocb)
+{
+ struct io_event event;
+
+ /* FIXME: the old ABI would return the event on the completion queue */
+ return real_sys_io_cancel(ctx, iocb, &event);
+}
+
+int vsys_io_wait(io_context_t ctx, struct iocb *iocb, const struct timespec *when)
+{
+ return -ENOSYS;
+}
+
+
+/* ABI change. Provide backwards compatibility for this one. */
+static inline long real_sys_io_getevents(io_context_t ctx_id, long min_nr,
+ long nr, struct io_event *events, struct timespec *timeout)
+{
+ return syscall5(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout);
+}
+
+int vsys_io_getevents(io_context_t ctx_id, long nr, struct io_event *events,
+ const struct timespec *const_timeout)
+{
+ struct timespec timeout;
+ if (const_timeout)
+ timeout = *const_timeout;
+ return real_sys_io_getevents(ctx_id, 1, nr, events,
+ const_timeout ? &timeout : NULL);
+}
+
diff --git a/src/lib/src/kso_init.c b/src/lib/src/kso_init.c
deleted file mode 100644
index fb605ce..0000000
--- a/src/lib/src/kso_init.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* libaio Linux async I/O interface
- Copyright 2002 Red Hat, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-long _init(void)
-{
- return 0;
-}
-
diff --git a/src/lib/src/stub.S b/src/lib/src/stub.S
deleted file mode 100644
index 5702358..0000000
--- a/src/lib/src/stub.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* stub.S
- libaio Linux async I/O interface
- Copyright 2002 Red Hat, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <asm/segment.h>
-#include <asm/errno.h>
-
- .text
-
-#define dynamic_syscall(x,a) \
- .globl x ;\
- .type x, @function ;\
- .align 16 ;\
- x: ;\
- movl $-ENOSYS,%eax ;\
- ret ;\
- .size x,.-x
-
diff --git a/src/lib/src/syscall-i386.h b/src/lib/src/syscall-i386.h
new file mode 100644
index 0000000..fc67ce8
--- /dev/null
+++ b/src/lib/src/syscall-i386.h
@@ -0,0 +1,36 @@
+#define __NR_io_setup 245
+#define __NR_io_destroy 246
+#define __NR_io_getevents 247
+#define __NR_io_submit 248
+#define __NR_io_cancel 249
+
+#define syscall1(nr, a) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a)); \
+ __ret; })
+
+#define syscall2(nr, a, b) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b)); \
+ __ret; })
+
+#define syscall3(nr, a, b, c) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b), "d" (c)); \
+ __ret; })
+
+#define syscall4(nr, a, b, c, d) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b), "d" (c), "S" (d)); \
+ __ret; })
+
+#define syscall5(nr, a, b, c, d, e) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b), "d" (c), "S" (d), "D" (e)); \
+ __ret; })
+
diff --git a/src/lib/src/vsysaddr.S b/src/lib/src/vsysaddr.S
deleted file mode 100644
index 28513a7..0000000
--- a/src/lib/src/vsysaddr.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/* libaio Linux async I/O interface
- Copyright 2002 Red Hat, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include "stub.S"
-dynamic_syscall(vsys_io_setup,0xbfff0010)
-dynamic_syscall(vsys_io_destroy,0xbfff0025)
-dynamic_syscall(vsys_io_submit,0xbfff003a)
-dynamic_syscall(vsys_io_cancel,0xbfff004f)
-dynamic_syscall(vsys_io_wait,0xbfff0064)
-dynamic_syscall(vsys_io_getevents,0xbfff0079)