summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-01-02 05:32:53 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-01-02 05:32:53 +0000
commit3984dde12bd1be44d28ce9358d0be17ea7965828 (patch)
treebb8a7e96ead4c07a3eafac66aa59a406a7ca65ab
parent0984b7e48fbd310e0b7e81940f3ac052563aaaab (diff)
make mmap() return void *, add MAP_FAILED
-rw-r--r--lib/libc/gen/nlist.c8
-rw-r--r--lib/libc/stdlib/malloc.c8
-rw-r--r--lib/libc/sys/mmap.22
-rw-r--r--lib/libc/sys/mmap.c6
-rw-r--r--sys/kern/syscalls.master4
-rw-r--r--sys/sys/mman.h9
6 files changed, 21 insertions, 16 deletions
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index a67901ddb04..dcdb67ab243 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: nlist.c,v 1.22 1997/12/15 10:19:17 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: nlist.c,v 1.23 1998/01/02 05:32:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -65,7 +65,7 @@ __aout_fdnlist(fd, list)
register struct nlist *list;
{
register struct nlist *p, *s;
- register caddr_t strtab;
+ register void * strtab;
register off_t stroff, symoff;
register u_long symsize;
register int nent, cc;
@@ -97,7 +97,7 @@ __aout_fdnlist(fd, list)
strsize = st.st_size - stroff;
strtab = mmap(NULL, (size_t)strsize, PROT_READ, MAP_COPY|MAP_FILE,
fd, stroff);
- if (strtab == (char *)-1)
+ if (strtab == MAP_FAILED)
return (-1);
/*
* clean out any left-over information for all valid entries.
@@ -179,7 +179,7 @@ __ecoff_fdnlist(fd, list)
mappedsize = st.st_size;
mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_COPY|MAP_FILE,
fd, 0);
- if (mappedfile == (char *)-1)
+ if (mappedfile == MAP_FAILED)
BAD;
if (check(0, sizeof *exechdrp))
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 66d1a2a9daf..9aadc494f90 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: malloc.c,v 1.29 1997/08/23 10:43:25 pefo Exp $";
+static char rcsid[] = "$OpenBSD: malloc.c,v 1.30 1998/01/02 05:32:49 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -268,7 +268,7 @@ static char *malloc_func;
/* Macro for mmap */
#define MMAP(size) \
- mmap((caddr_t)0, (size), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, \
+ mmap((void *)0, (size), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, \
MMAP_FD, (off_t)0);
/*
@@ -391,7 +391,7 @@ malloc_exit()
/*
* Allocate a number of pages from the OS
*/
-static caddr_t
+static void *
map_pages(pages)
int pages;
{
@@ -466,7 +466,7 @@ extend_pgdir(index)
page_dir = new;
/* Now free the old stuff */
- munmap((caddr_t)old, oldlen);
+ munmap(old, oldlen);
return 1;
}
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
index aa14d81f49a..e629999c8d1 100644
--- a/lib/libc/sys/mmap.2
+++ b/lib/libc/sys/mmap.2
@@ -42,7 +42,7 @@
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <sys/mman.h>
-.Ft caddr_t
+.Ft void *
.Fn mmap "void *addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
.Sh DESCRIPTION
The
diff --git a/lib/libc/sys/mmap.c b/lib/libc/sys/mmap.c
index f0b41ee9ea6..2debc8d2186 100644
--- a/lib/libc/sys/mmap.c
+++ b/lib/libc/sys/mmap.c
@@ -32,7 +32,7 @@
*/
#if defined(SYSLIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: mmap.c,v 1.7 1997/11/14 21:24:39 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mmap.c,v 1.8 1998/01/02 05:32:50 deraadt Exp $";
#endif /* SYSLIBC_SCCS and not lint */
#include <sys/types.h>
@@ -47,7 +47,7 @@ quad_t __syscall(quad_t, ...);
* This function provides 64-bit offset padding that
* is not supplied by GCC 1.X but is supplied by GCC 2.X.
*/
-caddr_t
+void *
mmap(addr, len, prot, flags, fd, offset)
void *addr;
size_t len;
@@ -57,6 +57,6 @@ mmap(addr, len, prot, flags, fd, offset)
off_t offset;
{
- return((caddr_t)(long)__syscall((quad_t)SYS_mmap, addr, len, prot,
+ return((void *)(long)__syscall((quad_t)SYS_mmap, addr, len, prot,
flags, fd, 0, offset));
}
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 711fc4c20ad..b595cdd0650 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.19 1997/11/14 20:56:03 deraadt Exp $
+ $OpenBSD: syscalls.master,v 1.20 1998/01/02 05:32:51 deraadt Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -349,7 +349,7 @@
195 STD { int sys_setrlimit(u_int which, struct rlimit *rlp); }
196 STD { int sys_getdirentries(int fd, char *buf, \
u_int count, long *basep); }
-197 STD { caddr_t sys_mmap(void *addr, size_t len, \
+197 STD { void *sys_mmap(void *addr, size_t len, \
int prot, int flags, int fd, long pad, \
off_t pos); }
198 STD { int sys_nosys(void); } __syscall
diff --git a/sys/sys/mman.h b/sys/sys/mman.h
index b3d1affc65d..fd807844b60 100644
--- a/sys/sys/mman.h
+++ b/sys/sys/mman.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mman.h,v 1.5 1997/11/14 20:56:06 deraadt Exp $ */
+/* $OpenBSD: mman.h,v 1.6 1998/01/02 05:32:52 deraadt Exp $ */
/* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */
/*-
@@ -63,6 +63,11 @@
#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */
/*
+ * Error return from mmap()
+ */
+#define MAP_FAILED ((void *)-1)
+
+/*
* Mapping type
*/
#define MAP_FILE 0x0000 /* map from file (default) */
@@ -90,7 +95,7 @@
__BEGIN_DECLS
/* Some of these int's should probably be size_t's */
-caddr_t mmap __P((void *, size_t, int, int, int, off_t));
+void * mmap __P((void *, size_t, int, int, int, off_t));
int mprotect __P((void *, size_t, int));
int munmap __P((void *, size_t));
int msync __P((void *, size_t, int));