mmap64.S 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Copyright (C) 1995,96,97,98,99,2000,2002 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, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <_lfs_64.h>
  15. #define _ERRNO_H 1
  16. #include <bits/errno.h>
  17. #include <sys/syscall.h>
  18. #ifdef __NR_mmap2
  19. #define LINKAGE 4
  20. #define PTR_SIZE 4
  21. #define SVRSP 16 /* saved register space */
  22. #define PARMS LINKAGE+SVRSP /* space for 4 saved regs */
  23. #define ADDR PARMS
  24. #define LEN ADDR+PTR_SIZE
  25. #define PROT LEN+4
  26. #define FLAGS PROT+4
  27. #define FD FLAGS+4
  28. #define OFFLO FD+4
  29. #define OFFHI OFFLO+4
  30. .text
  31. .global mmap64
  32. .type mmap64,%function
  33. mmap64:
  34. /* Save registers. */
  35. pushl %ebp
  36. pushl %ebx
  37. pushl %esi
  38. pushl %edi
  39. movl OFFLO(%esp), %edx
  40. movl OFFHI(%esp), %ecx
  41. testl $0xfff, %edx
  42. jne L_einval
  43. shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */
  44. shrl $12, %ecx
  45. jne L_einval
  46. movl %edx, %ebp
  47. movl ADDR(%esp), %ebx
  48. movl LEN(%esp), %ecx
  49. movl PROT(%esp), %edx
  50. movl FLAGS(%esp), %esi
  51. movl FD(%esp), %edi
  52. movl $__NR_mmap2, %eax /* System call number in %eax. */
  53. /* Do the system call trap. */
  54. int $0x80
  55. /* Restore registers. */
  56. popl %edi
  57. popl %esi
  58. popl %ebx
  59. popl %ebp
  60. /* If 0 > %eax > -4096 there was an error. */
  61. cmpl $-4095,%eax
  62. ja __syscall_error
  63. /* Successful; return the syscall's value. */
  64. ret
  65. /* This means the offset value is too large. */
  66. L_einval:
  67. popl %edi
  68. popl %esi
  69. popl %ebx
  70. popl %ebp
  71. movl $-EINVAL, %eax
  72. jmp __syscall_error
  73. .size mmap64,.-mmap64
  74. #endif