diff options
author | marcus <marcus> | 2003-09-24 22:13:56 +0000 |
---|---|---|
committer | marcus <marcus> | 2003-09-24 22:13:56 +0000 |
commit | 90aa62ee1de3c45182d9bfd87acf9c03ede9cdfc (patch) | |
tree | f5fd8566bfacbc1d92dc979ceb5e44767e23517a /physmem/mmap.c | |
parent | e7d323d1f64c14e25f2aa673bc0d00495c785287 (diff) |
2003-09-24 Marcus Brinkmann <marcus@gnu.org>
* mmap.c: New file.
* Makefile.am (physmem_SOURCES): Add mmap.c.
* malloc-wrap.c (LACKS_SYS_MMAN_H, mmap, munmap, PROT_READ,
PROT_WRITE, MAP_PRIVATE, MAP_ANONYMOUS, MUNMAP_FAILURE): Remove
macros.
* zalloc.c (panic): Remove macro.
Diffstat (limited to 'physmem/mmap.c')
-rw-r--r-- | physmem/mmap.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/physmem/mmap.c b/physmem/mmap.c new file mode 100644 index 0000000..c54a7d2 --- /dev/null +++ b/physmem/mmap.c @@ -0,0 +1,53 @@ +/* mmap.c - A simple mmap for anonymous memory allocations in physmem. + Copyright (C) 2003 Free Software Foundation, Inc. + Written by Marcus Brinkmann. + + This file is part of the GNU Hurd. + + The GNU Hurd 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.1 of the License, or (at your option) any later version. + + The GNU Hurd 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 the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <sys/mman.h> + +#include "output.h" +#include "zalloc.h" + + +void * +mmap (void *address, size_t length, int protect, int flags, + int filedes, off_t offset) +{ + if (address) + panic ("mmap called with non-zero ADDRESS"); + if (flags != (MAP_PRIVATE | MAP_ANONYMOUS)) + panic ("mmap called with invalid flags"); + if (protect != (PROT_READ | PROT_WRITE)) + panic ("mmap called with invalid protection"); + + /* At this point, we can safely ignore FILEDES and OFFSET. */ + return (((void *) zalloc (length)) ?: (void *) -1); +} + + +int +munmap (void *addr, size_t length) +{ + zfree ((l4_word_t) addr, length); + return 0; +} |