mmap.c 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * mmap() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include "syscalls.h"
  10. #include <unistd.h>
  11. #include <sys/mman.h>
  12. #ifdef __NR_mmap
  13. libc_hidden_proto(mmap)
  14. #ifdef __UCLIBC_MMAP_HAS_6_ARGS__
  15. _syscall6(void *, mmap, void *, start, size_t, length,
  16. int, prot, int, flags, int, fd, off_t, offset);
  17. #else
  18. # define __NR__mmap __NR_mmap
  19. static inline _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  20. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  21. int flags, int fd, __off_t offset)
  22. {
  23. unsigned long buffer[6];
  24. buffer[0] = (unsigned long) addr;
  25. buffer[1] = (unsigned long) len;
  26. buffer[2] = (unsigned long) prot;
  27. buffer[3] = (unsigned long) flags;
  28. buffer[4] = (unsigned long) fd;
  29. buffer[5] = (unsigned long) offset;
  30. return (__ptr_t) _mmap(buffer);
  31. }
  32. #endif
  33. libc_hidden_def(mmap)
  34. #endif