diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-09-11 13:26:21 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-09-11 13:26:21 +0000 |
commit | c7b05d22d4364f15fbb4613057614c7c4141d5ea (patch) | |
tree | 7c815ee3719e2ece8d7d053e42f8d842c9b50142 /lib | |
parent | 97d2e2140973d0f19150fb246a3e179a62c785cb (diff) |
Use PROTO_NORMAL() on __syscall to go direct, adjusting the declaration
to eliminate some casts.
Retire some uses of old-style STUB* macros where superseded by namespace.h bits
tweaks and ok deraadt@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/hidden/sys/mman.h | 40 | ||||
-rw-r--r-- | lib/libc/hidden/unistd.h | 27 | ||||
-rw-r--r-- | lib/libc/sys/ftruncate.c | 17 | ||||
-rw-r--r-- | lib/libc/sys/lseek.c | 17 | ||||
-rw-r--r-- | lib/libc/sys/mmap.c | 18 | ||||
-rw-r--r-- | lib/libc/sys/mquery.c | 17 | ||||
-rw-r--r-- | lib/libc/sys/posix_madvise.c | 6 | ||||
-rw-r--r-- | lib/libc/sys/pread.c | 12 | ||||
-rw-r--r-- | lib/libc/sys/preadv.c | 10 | ||||
-rw-r--r-- | lib/libc/sys/pwrite.c | 10 | ||||
-rw-r--r-- | lib/libc/sys/pwritev.c | 9 | ||||
-rw-r--r-- | lib/libc/sys/truncate.c | 16 |
12 files changed, 122 insertions, 77 deletions
diff --git a/lib/libc/hidden/sys/mman.h b/lib/libc/hidden/sys/mman.h new file mode 100644 index 00000000000..cf447a41d75 --- /dev/null +++ b/lib/libc/hidden/sys/mman.h @@ -0,0 +1,40 @@ +/* $OpenBSD: mman.h,v 1.1 2015/09/11 13:26:20 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_SYS_MMAN_H_ +#define _LIBC_SYS_MMAN_H_ + +#include_next <sys/mman.h> + +PROTO_NORMAL(madvise); +PROTO_NORMAL(mincore); +PROTO_NORMAL(minherit); +PROTO_NORMAL(mlock); +PROTO_NORMAL(mlockall); +PROTO_NORMAL(mmap); +PROTO_NORMAL(mprotect); +PROTO_NORMAL(mquery); +/*PROTO_CANCEL(msync);*/ +PROTO_NORMAL(munlock); +PROTO_NORMAL(munlockall); +PROTO_NORMAL(munmap); +PROTO_DEPRECATED(posix_madvise); +/*PROTO_NORMAL(shm_mkstemp); */ +/*PROTO_NORMAL(shm_open); */ +/*PROTO_NORMAL(shm_unlink); */ + +#endif /* _LIBC_SYS_MMAN_H_ */ diff --git a/lib/libc/hidden/unistd.h b/lib/libc/hidden/unistd.h new file mode 100644 index 00000000000..e68f2619f94 --- /dev/null +++ b/lib/libc/hidden/unistd.h @@ -0,0 +1,27 @@ +/* $OpenBSD: unistd.h,v 1.1 2015/09/11 13:26:20 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_UNISTD_H_ +#define _LIBC_UNISTD_H_ + +#include_next <unistd.h> + +PROTO_NORMAL(ftruncate); +PROTO_NORMAL(lseek); +PROTO_NORMAL(truncate); + +#endif /* !_LIBC_UNISTD_H_ */ diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c index 38a5a5079e4..b7d63b701da 100644 --- a/lib/libc/sys/ftruncate.c +++ b/lib/libc/sys/ftruncate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftruncate.c,v 1.16 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: ftruncate.c,v 1.17 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,22 +30,19 @@ #include <sys/syscall.h> #include <unistd.h> -#include "thread_private.h" -register_t __syscall(quad_t, ...); +int __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -/* ftruncate is weak to support libpthread locking */ - -STUB_PROTOTYPE(ftruncate); - -STUB_ALIAS(ftruncate); +DEF_SYS(ftruncate); /* * This function provides 64-bit offset padding that * is not supplied by GCC 1.X but is supplied by GCC 2.X. */ int -STUB_NAME(ftruncate)(int fd, off_t length) +ftruncate(int fd, off_t length) { - return (__syscall((quad_t)SYS_ftruncate, fd, 0, length)); + return (__syscall(SYS_ftruncate, fd, 0, length)); } +DEF_WEAK(ftruncate); diff --git a/lib/libc/sys/lseek.c b/lib/libc/sys/lseek.c index 51d0676356a..5d6d7048b32 100644 --- a/lib/libc/sys/lseek.c +++ b/lib/libc/sys/lseek.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lseek.c,v 1.15 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: lseek.c,v 1.16 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -30,22 +30,19 @@ #include <sys/syscall.h> #include <unistd.h> -#include "thread_private.h" -off_t __syscall(quad_t, ...); +off_t __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -/* lseek is weak to support libpthread locking */ - -STUB_PROTOTYPE(lseek); - -STUB_ALIAS(lseek); +DEF_SYS(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 -STUB_NAME(lseek)(int fd, off_t offset, int whence) +lseek(int fd, off_t offset, int whence) { - return (__syscall((quad_t)SYS_lseek, fd, 0, offset, whence)); + return (__syscall(SYS_lseek, fd, 0, offset, whence)); } +DEF_WEAK(lseek); diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c index 2ef5baa5413..30255677413 100644 --- a/lib/libc/sys/mmap.c +++ b/lib/libc/sys/mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mmap.c,v 1.15 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: mmap.c,v 1.16 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -31,23 +31,19 @@ #include <sys/types.h> #include <sys/mman.h> #include <sys/syscall.h> -#include "thread_private.h" -register_t __syscall(quad_t, ...); +void *__syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -STUB_PROTOTYPE(mmap); - -STUB_ALIAS(mmap); +DEF_SYS(mmap); /* * This function provides 64-bit offset padding that * is not supplied by GCC 1.X but is supplied by GCC 2.X. */ void * -STUB_NAME(mmap)(void *addr, size_t len, int prot, int flags, int fd, - off_t offset) +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, - flags, fd, 0, offset)); + return (__syscall(SYS_mmap, addr, len, prot, flags, fd, 0, offset)); } +DEF_WEAK(mmap); diff --git a/lib/libc/sys/mquery.c b/lib/libc/sys/mquery.c index 53b27f971de..10d3d31a35e 100644 --- a/lib/libc/sys/mquery.c +++ b/lib/libc/sys/mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mquery.c,v 1.7 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: mquery.c,v 1.8 2015/09/11 13:26:20 guenther Exp $ */ /* * Written by Artur Grabowski <art@openbsd.org> Public Domain */ @@ -6,21 +6,18 @@ #include <sys/types.h> #include <sys/mman.h> #include <sys/syscall.h> -#include "thread_private.h" -register_t __syscall(quad_t, ...); +void *__syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -STUB_PROTOTYPE(mquery); - -STUB_ALIAS(mquery); +DEF_SYS(mquery); /* * This function provides 64-bit offset padding. */ void * -STUB_NAME(mquery)(void *addr, size_t len, int prot, int flags, int fd, - off_t offset) +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)); + return (__syscall(SYS_mquery, addr, len, prot, flags, fd, 0, offset)); } +DEF_WEAK(mquery); diff --git a/lib/libc/sys/posix_madvise.c b/lib/libc/sys/posix_madvise.c index 153c28223d1..993ff4cc078 100644 --- a/lib/libc/sys/posix_madvise.c +++ b/lib/libc/sys/posix_madvise.c @@ -1,14 +1,12 @@ -/* $OpenBSD: posix_madvise.c,v 1.3 2014/07/10 13:42:53 guenther Exp $ */ +/* $OpenBSD: posix_madvise.c,v 1.4 2015/09/11 13:26:20 guenther Exp $ */ /* * Ted Unangst wrote this file and placed it into the public domain. */ #include <sys/mman.h> #include <errno.h> -int _thread_sys_madvise(void *addr, size_t len, int behav); - int posix_madvise(void *addr, size_t len, int behav) { - return (_thread_sys_madvise(addr, len, behav) ? errno : 0); + return (madvise(addr, len, behav) ? errno : 0); } diff --git a/lib/libc/sys/pread.c b/lib/libc/sys/pread.c index 6338e14dba9..4c522399217 100644 --- a/lib/libc/sys/pread.c +++ b/lib/libc/sys/pread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pread.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: pread.c,v 1.10 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 @@ -29,14 +29,15 @@ * SUCH DAMAGE. */ -#include <sys/types.h> #include <sys/syscall.h> #include <unistd.h> #include "thread_private.h" -register_t __syscall(quad_t, ...); +ssize_t __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); + +DEF_SYS(ftruncate); -/* pread is weak to support libpthread cancellation */ STUB_PROTOTYPE(pread); @@ -49,6 +50,5 @@ STUB_ALIAS(pread); ssize_t STUB_NAME(pread)(int fd, void *buf, size_t nbyte, off_t offset) { - - return (__syscall((quad_t)SYS_pread, fd, buf, nbyte, 0, offset)); + return (__syscall(SYS_pread, fd, buf, nbyte, 0, offset)); } diff --git a/lib/libc/sys/preadv.c b/lib/libc/sys/preadv.c index 238364ddd75..5e008f47ce1 100644 --- a/lib/libc/sys/preadv.c +++ b/lib/libc/sys/preadv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: preadv.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: preadv.c,v 1.10 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 @@ -29,15 +29,14 @@ * SUCH DAMAGE. */ -#include <sys/types.h> #include <sys/syscall.h> #include <sys/uio.h> #include <unistd.h> #include "thread_private.h" -register_t __syscall(quad_t, ...); +ssize_t __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -/* preadv is weak to support libpthread cancellation */ STUB_PROTOTYPE(preadv); @@ -50,6 +49,5 @@ STUB_ALIAS(preadv); ssize_t 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)); + return (__syscall(SYS_preadv, fd, iovp, iovcnt, 0, offset)); } diff --git a/lib/libc/sys/pwrite.c b/lib/libc/sys/pwrite.c index 8757bf9a272..445b12ab430 100644 --- a/lib/libc/sys/pwrite.c +++ b/lib/libc/sys/pwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pwrite.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: pwrite.c,v 1.10 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 @@ -29,14 +29,13 @@ * SUCH DAMAGE. */ -#include <sys/types.h> #include <sys/syscall.h> #include <unistd.h> #include "thread_private.h" -register_t __syscall(quad_t, ...); +ssize_t __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -/* pread is weak to support libpthread cancellation */ STUB_PROTOTYPE(pwrite); @@ -49,6 +48,5 @@ STUB_ALIAS(pwrite); ssize_t 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)); + return (__syscall(SYS_pwrite, fd, buf, nbyte, 0, offset)); } diff --git a/lib/libc/sys/pwritev.c b/lib/libc/sys/pwritev.c index 345d3831965..a6008ef2c19 100644 --- a/lib/libc/sys/pwritev.c +++ b/lib/libc/sys/pwritev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pwritev.c,v 1.9 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: pwritev.c,v 1.10 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 @@ -29,15 +29,14 @@ * SUCH DAMAGE. */ -#include <sys/types.h> #include <sys/syscall.h> #include <sys/uio.h> #include <unistd.h> #include "thread_private.h" -register_t __syscall(quad_t, ...); +ssize_t __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -/* pwritev is weak to support libpthread cancellation */ STUB_PROTOTYPE(pwritev); @@ -51,5 +50,5 @@ ssize_t 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)); + return (__syscall(SYS_pwritev, fd, iovp, iovcnt, 0, offset)); } diff --git a/lib/libc/sys/truncate.c b/lib/libc/sys/truncate.c index 6516136672f..3b0adf685d2 100644 --- a/lib/libc/sys/truncate.c +++ b/lib/libc/sys/truncate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: truncate.c,v 1.13 2011/10/16 06:29:56 guenther Exp $ */ +/* $OpenBSD: truncate.c,v 1.14 2015/09/11 13:26:20 guenther Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -28,24 +28,22 @@ * SUCH DAMAGE. */ -#include <sys/types.h> #include <sys/syscall.h> #include <unistd.h> -#include "thread_private.h" -register_t __syscall(quad_t, ...); +int __syscall(quad_t, ...); +PROTO_NORMAL(__syscall); -STUB_PROTOTYPE(truncate); +DEF_SYS(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 -STUB_NAME(truncate)(const char *path, off_t length) +truncate(const char *path, off_t length) { - - return(__syscall((quad_t)SYS_truncate, path, 0, length)); + return (__syscall(SYS_truncate, path, 0, length)); } +DEF_WEAK(truncate); |