2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid[] = "@(#)os_map.c 10.7 (Sleepycat) 10/25/97";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
25 * Map in some shared memory backed by a file descriptor.
27 * PUBLIC: int __os_map __P((int, size_t, int, int, void **));
30 __os_map(fd, len, is_private, is_rdonly, addr)
31 int fd, is_private, is_rdonly;
38 flags = is_private ? MAP_PRIVATE : MAP_SHARED;
39 #ifdef MAP_HASSEMAPHORE
40 flags |= MAP_HASSEMAPHORE;
42 prot = PROT_READ | (is_rdonly ? 0 : PROT_WRITE);
44 #ifndef MAP_FAILED /* XXX: Mmap(2) failure return. */
48 mmap(NULL, len, prot, flags, fd, (off_t)0)) == (void *)MAP_FAILED)
57 * Release the specified shared memory.
59 * PUBLIC: int __os_unmap __P((void *, size_t));
68 * The argument len is always the same length as was mapped.
70 return (munmap(addr, len) ? errno : 0);