mmap64.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #define _ERRNO_H 1
  16. #include <features.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 __syscall_error (PLT)
  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 (PLT)
  50. .Linval:
  51. mov r0, $-EINVAL
  52. ldmfd sp!, {r4, r5, lr}
  53. b __syscall_error (PLT)
  54. __syscall_error:
  55. /* Looks like the syscall choked -- set errno */
  56. ldr r3, .L4
  57. /* Calculate the - of the syscall result, in case we need it */
  58. rsb r2, r0, $0
  59. /* errno = -result */
  60. str r2, [r9,r3]
  61. /* return -1 */
  62. mvn r0, $0
  63. mov pc, lr
  64. .size mmap64,.-mmap64;
  65. .L4: .word errno
  66. #endif