os_dependent_stuff.asm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ; syscalls
  2. %ifidn __OUTPUT_FORMAT__,elf64
  3. ; http://lxr.linux.no/linux+v3.13.5/arch/x86/syscalls/syscall_64.tbl
  4. %define SYSCALL_OPEN 2
  5. %define SYSCALL_WRITE 1
  6. %define SYSCALL_MMAP 9
  7. %define SYSCALL_MUNMAP 11
  8. %define SYSCALL_PWRITE 18
  9. %define SYSCALL_FORK 57
  10. %define SYSCALL_WAITID 247
  11. %define SYSCALL_EXIT 60
  12. %elifidn __OUTPUT_FORMAT__,macho64
  13. ; http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/kern/syscalls.master
  14. %define SYSCALL_OPEN 0x2000005
  15. %define SYSCALL_WRITE 0x2000004
  16. %define SYSCALL_MMAP 0x20000C5
  17. %define SYSCALL_MUNMAP 0x2000049
  18. %define SYSCALL_PWRITE 0x200009A
  19. %define SYSCALL_FORK 0x2000002
  20. %define SYSCALL_WAITID 0x20000AD
  21. %define SYSCALL_EXIT 0x2000001
  22. %endif
  23. ; fcntls
  24. %ifidn __OUTPUT_FORMAT__,elf64
  25. ; http://lxr.linux.no/linux+v3.13.5/include/uapi/asm-generic/fcntl.h
  26. %define O_RDONLY 0o0000000
  27. %define O_WRONLY 0o0000001
  28. %define O_RDWR 0o0000002
  29. %define O_CREAT 0o0000100
  30. %define O_EXCL 0o0000200
  31. %define O_NOCTTY 0o0000400
  32. %define O_TRUNC 0o0001000
  33. %define O_APPEND 0o0002000
  34. %define O_NONBLOCK 0o0004000
  35. %define O_DSYNC 0o0010000
  36. %define FASYNC 0o0020000
  37. %define O_DIRECT 0o0040000
  38. %define O_LARGEFILE 0o0100000
  39. %define O_DIRECTORY 0o0200000
  40. %define O_NOFOLLOW 0o0400000
  41. %define O_NOATIME 0o1000000
  42. %define O_CLOEXEC 0o2000000
  43. %define O_SYNC 0o4000000
  44. %define O_PATH 0o10000000
  45. %elifidn __OUTPUT_FORMAT__,macho64
  46. ; http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/fcntl.h
  47. %define O_RDONLY 0x0000
  48. %define O_WRONLY 0x0001
  49. %define O_RDWR 0x0002
  50. %define O_NONBLOCK 0x0004
  51. %define O_APPEND 0x0008
  52. %define O_SHLOCK 0x0010
  53. %define O_EXLOCK 0x0020
  54. %define O_ASYNC 0x0040
  55. %define O_SYNC 0x0080
  56. %define O_NOFOLOW 0x0100
  57. %define O_CREAT 0x0200
  58. %define O_TRUNC 0x0400
  59. %define O_EXCL 0x0800
  60. %define O_NOCTTY 0x20000
  61. %define O_DIRECTORY 0x100000
  62. %define O_SYMLINK 0x200000
  63. %define O_DSYNC 0x400000
  64. %endif
  65. ; mmap() and mprotect() flags
  66. %ifidn __OUTPUT_FORMAT__,elf64
  67. ; http://lxr.linux.no/linux+v3.13.5/include/uapi/asm-generic/mman-common.h
  68. %define MAP_SHARED 0x01
  69. %define MAP_PRIVATE 0x02
  70. %define MAP_FIXED 0x10
  71. %define MAP_ANON 0x20
  72. %define PROT_NONE 0b0000
  73. %define PROT_READ 0b0001
  74. %define PROT_WRITE 0b0010
  75. %define PROT_EXEC 0b0100
  76. %define PROT_SEM 0b1000
  77. %define PROT_GROWSDOWN 0x01000000
  78. %define PROT_GROWSUP 0x02000000
  79. %elifidn __OUTPUT_FORMAT__,macho64
  80. ; http://www.opensource.apple.com/source/xnu/xnu-2050.18.24/bsd/sys/mman.h
  81. %define MAP_SHARED 0b000000000001
  82. %define MAP_PRIVATE 0b000000000010
  83. %define MAP_FIXED 0b000000010000
  84. %define MAP_RENAME 0b000000100000
  85. %define MAP_NORESERVE 0b000001000000
  86. %define MAP_INHERIT 0b000010000000
  87. %define MAP_NOEXTEND 0b000100000000
  88. %define MAP_SEMAPHORE 0b001000000000
  89. %define MAP_NOCACHE 0b010000000000
  90. %define MAP_JIT 0b100000000000
  91. %define MAP_FILE 0x0000
  92. %define MAP_ANON 0x1000
  93. %define PROT_NONE 0b000
  94. %define PROT_READ 0b001
  95. %define PROT_WRITE 0b010
  96. %define PROT_EXEC 0b100
  97. %endif
  98. ; wait() flags are shared
  99. ; http://lxr.linux.no/linux+v3.13.5/include/uapi/linux/wait.h
  100. %define WEXITED 0x04
  101. %define P_ALL 0
  102. %define P_PID 1
  103. %define P_PGID 2
  104. %define ECHILD 10
  105. default rel
  106. section .text