mmap64.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (C) 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #include <features.h>
  16. #define _ERRNO_H
  17. #include <bits/errno.h>
  18. #include <sys/syscall.h>
  19. #if defined __UCLIBC_HAS_LFS__ && defined __NR_mmap2
  20. /* The mmap2 system call takes six arguments, all in registers. */
  21. .text
  22. .global mmap64
  23. .type mmap64,%function
  24. .align 4
  25. mmap64:
  26. stmfd sp!, {r4, r5, lr}
  27. ldr r5, [sp, $16]
  28. ldr r4, [sp, $12]
  29. movs ip, r5, lsl $20 @ check that offset is page-aligned
  30. bne .Linval
  31. ldr ip, [sp, $20]
  32. mov r5, r5, lsr $12
  33. orr r5, r5, ip, lsl $20 @ compose page offset
  34. movs ip, ip, lsr $12
  35. bne .Linval @ check for overflow
  36. mov ip, r0
  37. swi __NR_mmap2
  38. cmn r0, $4096
  39. ldmccfd sp!, {r4, r5, pc}
  40. cmn r0, $ENOSYS
  41. ldmnefd sp!, {r4, r5, lr}
  42. bne __error
  43. /* The current kernel does not support mmap2. Fall back to plain
  44. mmap if the offset is small enough. */
  45. ldr r5, [sp, $20]
  46. mov r0, ip @ first arg was clobbered
  47. teq r5, $0
  48. ldmeqfd sp!, {r4, r5, lr}
  49. beq __mmap
  50. .Linval:
  51. mov r0, $-EINVAL
  52. ldmfd sp!, {r4, r5, lr}
  53. b __error
  54. __error:
  55. b __syscall_error
  56. .size mmap64,.-mmap64
  57. #endif