summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/include/thread_private.h17
-rw-r--r--lib/libc/sys/ftruncate.c8
-rw-r--r--lib/libc/sys/lseek.c8
-rw-r--r--lib/libc/sys/mmap.c10
-rw-r--r--lib/libc/sys/mquery.c10
-rw-r--r--lib/libc/sys/pread.c11
-rw-r--r--lib/libc/sys/preadv.c11
-rw-r--r--lib/libc/sys/pwrite.c11
-rw-r--r--lib/libc/sys/pwritev.c11
-rw-r--r--lib/libc/sys/truncate.c9
10 files changed, 83 insertions, 23 deletions
diff --git a/lib/libc/include/thread_private.h b/lib/libc/include/thread_private.h
index 2d8913e482a..673fb9c6a69 100644
--- a/lib/libc/include/thread_private.h
+++ b/lib/libc/include/thread_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: thread_private.h,v 1.24 2008/06/14 15:43:43 otto Exp $ */
+/* $OpenBSD: thread_private.h,v 1.25 2011/10/16 06:29:56 guenther Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
@@ -34,6 +34,21 @@ extern int __isthreaded;
#endif
/*
+ * Ditto for hand-written syscall stubs:
+ *
+ * Use STUB_NAME(n) to get the strong name of the stub: _thread_sys_n
+ * STUB_ALIAS(n) to generate the weak symbol n pointing to _thread_sys_n,
+ * STUB_PROTOTYPE(n) to generate a prototype for _thread_sys_n (based on n).
+ */
+#define STUB_NAME(name) __CONCAT(_thread_sys_,name)
+#define STUB_ALIAS(name) __weak_alias(name, STUB_NAME(name))
+#ifdef __GNUC__
+#define STUB_PROTOTYPE(name) __typeof__(name) STUB_NAME(name)
+#else
+#define STUB_PROTOTYPE(name) /* typeof() only in gcc */
+#endif
+
+/*
* helper macro to make unique names in the thread namespace
*/
#define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name)
diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c
index d0f5e9837c4..38a5a5079e4 100644
--- a/lib/libc/sys/ftruncate.c
+++ b/lib/libc/sys/ftruncate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftruncate.c,v 1.15 2007/06/05 18:11:48 kurt Exp $ */
+/* $OpenBSD: ftruncate.c,v 1.16 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -36,16 +36,16 @@ register_t __syscall(quad_t, ...);
/* ftruncate is weak to support libpthread locking */
-WEAK_PROTOTYPE(ftruncate);
+STUB_PROTOTYPE(ftruncate);
-WEAK_ALIAS(ftruncate);
+STUB_ALIAS(ftruncate);
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
int
-WEAK_NAME(ftruncate)(int fd, off_t length)
+STUB_NAME(ftruncate)(int fd, off_t length)
{
return (__syscall((quad_t)SYS_ftruncate, fd, 0, length));
}
diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c
index 1abb688a348..51d0676356a 100644
--- a/lib/libc/sys/lseek.c
+++ b/lib/libc/sys/lseek.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lseek.c,v 1.14 2007/06/05 18:11:48 kurt Exp $ */
+/* $OpenBSD: lseek.c,v 1.15 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -36,16 +36,16 @@ off_t __syscall(quad_t, ...);
/* lseek is weak to support libpthread locking */
-WEAK_PROTOTYPE(lseek);
+STUB_PROTOTYPE(lseek);
-WEAK_ALIAS(lseek);
+STUB_ALIAS(lseek);
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
off_t
-WEAK_NAME(lseek)(int fd, off_t offset, int whence)
+STUB_NAME(lseek)(int fd, off_t offset, int whence)
{
return (__syscall((quad_t)SYS_lseek, fd, 0, offset, whence));
}
diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c
index 19ec915d7cc..2ef5baa5413 100644
--- a/lib/libc/sys/mmap.c
+++ b/lib/libc/sys/mmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmap.c,v 1.14 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: mmap.c,v 1.15 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,15 +31,21 @@
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/syscall.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+STUB_PROTOTYPE(mmap);
+
+STUB_ALIAS(mmap);
+
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
void *
-mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
+STUB_NAME(mmap)(void *addr, size_t len, int prot, int flags, int fd,
+ off_t offset)
{
return((void *)__syscall((quad_t)SYS_mmap, addr, len, prot,
diff --git a/lib/libc/sys/mquery.c b/lib/libc/sys/mquery.c
index d22ce89ad26..53b27f971de 100644
--- a/lib/libc/sys/mquery.c
+++ b/lib/libc/sys/mquery.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mquery.c,v 1.6 2005/04/06 16:56:45 millert Exp $ */
+/* $OpenBSD: mquery.c,v 1.7 2011/10/16 06:29:56 guenther Exp $ */
/*
* Written by Artur Grabowski <art@openbsd.org> Public Domain
*/
@@ -6,14 +6,20 @@
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/syscall.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+STUB_PROTOTYPE(mquery);
+
+STUB_ALIAS(mquery);
+
/*
* This function provides 64-bit offset padding.
*/
void *
-mquery(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
+STUB_NAME(mquery)(void *addr, size_t len, int prot, int flags, int fd,
+ off_t offset)
{
return((void *)__syscall((quad_t)SYS_mquery, addr, len, prot,
flags, fd, 0, offset));
diff --git a/lib/libc/sys/pread.c b/lib/libc/sys/pread.c
index 39cedfada10..6338e14dba9 100644
--- a/lib/libc/sys/pread.c
+++ b/lib/libc/sys/pread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pread.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: pread.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -32,15 +32,22 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+/* pread is weak to support libpthread cancellation */
+
+STUB_PROTOTYPE(pread);
+
+STUB_ALIAS(pread);
+
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
ssize_t
-pread(int fd, void *buf, size_t nbyte, off_t offset)
+STUB_NAME(pread)(int fd, void *buf, size_t nbyte, off_t offset)
{
return (__syscall((quad_t)SYS_pread, fd, buf, nbyte, 0, offset));
diff --git a/lib/libc/sys/preadv.c b/lib/libc/sys/preadv.c
index b39e30c3227..238364ddd75 100644
--- a/lib/libc/sys/preadv.c
+++ b/lib/libc/sys/preadv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: preadv.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: preadv.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -33,15 +33,22 @@
#include <sys/syscall.h>
#include <sys/uio.h>
#include <unistd.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+/* preadv is weak to support libpthread cancellation */
+
+STUB_PROTOTYPE(preadv);
+
+STUB_ALIAS(preadv);
+
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
ssize_t
-preadv(int fd, const struct iovec *iovp, int iovcnt, off_t offset)
+STUB_NAME(preadv)(int fd, const struct iovec *iovp, int iovcnt, off_t offset)
{
return (__syscall((quad_t)SYS_preadv, fd, iovp, iovcnt, 0, offset));
diff --git a/lib/libc/sys/pwrite.c b/lib/libc/sys/pwrite.c
index b49d2fdbd55..8757bf9a272 100644
--- a/lib/libc/sys/pwrite.c
+++ b/lib/libc/sys/pwrite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwrite.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: pwrite.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -32,15 +32,22 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+/* pread is weak to support libpthread cancellation */
+
+STUB_PROTOTYPE(pwrite);
+
+STUB_ALIAS(pwrite);
+
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
ssize_t
-pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
+STUB_NAME(pwrite)(int fd, const void *buf, size_t nbyte, off_t offset)
{
return (__syscall((quad_t)SYS_pwrite, fd, buf, nbyte, 0, offset));
diff --git a/lib/libc/sys/pwritev.c b/lib/libc/sys/pwritev.c
index 31192152376..345d3831965 100644
--- a/lib/libc/sys/pwritev.c
+++ b/lib/libc/sys/pwritev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwritev.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: pwritev.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -33,15 +33,22 @@
#include <sys/syscall.h>
#include <sys/uio.h>
#include <unistd.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+/* pwritev is weak to support libpthread cancellation */
+
+STUB_PROTOTYPE(pwritev);
+
+STUB_ALIAS(pwritev);
+
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
ssize_t
-pwritev(int fd, const struct iovec *iovp, int iovcnt, off_t offset)
+STUB_NAME(pwritev)(int fd, const struct iovec *iovp, int iovcnt, off_t offset)
{
return (__syscall((quad_t)SYS_pwritev, fd, iovp, iovcnt, 0, offset));
diff --git a/lib/libc/sys/truncate.c b/lib/libc/sys/truncate.c
index 960deb6f617..6516136672f 100644
--- a/lib/libc/sys/truncate.c
+++ b/lib/libc/sys/truncate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: truncate.c,v 1.12 2005/08/08 08:05:38 espie Exp $ */
+/* $OpenBSD: truncate.c,v 1.13 2011/10/16 06:29:56 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,15 +31,20 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
+#include "thread_private.h"
register_t __syscall(quad_t, ...);
+STUB_PROTOTYPE(truncate);
+
+STUB_ALIAS(truncate);
+
/*
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
int
-truncate(const char *path, off_t length)
+STUB_NAME(truncate)(const char *path, off_t length)
{
return(__syscall((quad_t)SYS_truncate, path, 0, length));