mmap64.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #ifdef __PIC__
  50. beq mmap(PLT)
  51. #else
  52. beq mmap
  53. #endif
  54. .Linval:
  55. mov r0, $-EINVAL
  56. ldmfd sp!, {r4, r5, lr}
  57. b __error
  58. __error:
  59. b __syscall_error
  60. .size mmap64,.-mmap64
  61. #endif