tcc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +35 -0
  3. data/README.md +196 -0
  4. data/ext/tcc/extconf.rb +25 -0
  5. data/ext/tcc/tcc-0.9.26.patch +30 -0
  6. data/ext/tcc/tcc-0.9.26/COPYING +504 -0
  7. data/ext/tcc/tcc-0.9.26/Changelog +396 -0
  8. data/ext/tcc/tcc-0.9.26/Makefile +349 -0
  9. data/ext/tcc/tcc-0.9.26/README +101 -0
  10. data/ext/tcc/tcc-0.9.26/TODO +93 -0
  11. data/ext/tcc/tcc-0.9.26/VERSION +1 -0
  12. data/ext/tcc/tcc-0.9.26/arm-gen.c +2005 -0
  13. data/ext/tcc/tcc-0.9.26/c67-gen.c +2560 -0
  14. data/ext/tcc/tcc-0.9.26/coff.h +446 -0
  15. data/ext/tcc/tcc-0.9.26/config.h +8 -0
  16. data/ext/tcc/tcc-0.9.26/config.mak +28 -0
  17. data/ext/tcc/tcc-0.9.26/config.texi +1 -0
  18. data/ext/tcc/tcc-0.9.26/configure +540 -0
  19. data/ext/tcc/tcc-0.9.26/conftest.c +71 -0
  20. data/ext/tcc/tcc-0.9.26/elf.h +1731 -0
  21. data/ext/tcc/tcc-0.9.26/examples/ex1.c +8 -0
  22. data/ext/tcc/tcc-0.9.26/examples/ex2.c +98 -0
  23. data/ext/tcc/tcc-0.9.26/examples/ex3.c +24 -0
  24. data/ext/tcc/tcc-0.9.26/examples/ex4.c +26 -0
  25. data/ext/tcc/tcc-0.9.26/examples/ex5.c +8 -0
  26. data/ext/tcc/tcc-0.9.26/i386-asm.c +1498 -0
  27. data/ext/tcc/tcc-0.9.26/i386-asm.h +473 -0
  28. data/ext/tcc/tcc-0.9.26/i386-gen.c +1096 -0
  29. data/ext/tcc/tcc-0.9.26/i386-tok.h +243 -0
  30. data/ext/tcc/tcc-0.9.26/il-gen.c +667 -0
  31. data/ext/tcc/tcc-0.9.26/il-opcodes.h +251 -0
  32. data/ext/tcc/tcc-0.9.26/include/float.h +57 -0
  33. data/ext/tcc/tcc-0.9.26/include/stdarg.h +41 -0
  34. data/ext/tcc/tcc-0.9.26/include/stdbool.h +10 -0
  35. data/ext/tcc/tcc-0.9.26/include/stddef.h +28 -0
  36. data/ext/tcc/tcc-0.9.26/include/tcclib.h +78 -0
  37. data/ext/tcc/tcc-0.9.26/include/varargs.h +12 -0
  38. data/ext/tcc/tcc-0.9.26/lib/Makefile +102 -0
  39. data/ext/tcc/tcc-0.9.26/lib/alloca86-bt.S +47 -0
  40. data/ext/tcc/tcc-0.9.26/lib/alloca86.S +35 -0
  41. data/ext/tcc/tcc-0.9.26/lib/alloca86_64.S +42 -0
  42. data/ext/tcc/tcc-0.9.26/lib/bcheck.c +875 -0
  43. data/ext/tcc/tcc-0.9.26/lib/libtcc1.c +691 -0
  44. data/ext/tcc/tcc-0.9.26/libtcc.c +1941 -0
  45. data/ext/tcc/tcc-0.9.26/libtcc.h +103 -0
  46. data/ext/tcc/tcc-0.9.26/stab.def +234 -0
  47. data/ext/tcc/tcc-0.9.26/stab.h +17 -0
  48. data/ext/tcc/tcc-0.9.26/tcc-doc.html +2332 -0
  49. data/ext/tcc/tcc-0.9.26/tcc-doc.info +1151 -0
  50. data/ext/tcc/tcc-0.9.26/tcc-doc.texi +1268 -0
  51. data/ext/tcc/tcc-0.9.26/tcc.1 +415 -0
  52. data/ext/tcc/tcc-0.9.26/tcc.c +352 -0
  53. data/ext/tcc/tcc-0.9.26/tcc.h +1379 -0
  54. data/ext/tcc/tcc-0.9.26/tccasm.c +1118 -0
  55. data/ext/tcc/tcc-0.9.26/tcccoff.c +948 -0
  56. data/ext/tcc/tcc-0.9.26/tccelf.c +3129 -0
  57. data/ext/tcc/tcc-0.9.26/tccgen.c +5841 -0
  58. data/ext/tcc/tcc-0.9.26/tccpe.c +1887 -0
  59. data/ext/tcc/tcc-0.9.26/tccpp.c +3128 -0
  60. data/ext/tcc/tcc-0.9.26/tccrun.c +737 -0
  61. data/ext/tcc/tcc-0.9.26/tcctok.h +278 -0
  62. data/ext/tcc/tcc-0.9.26/tests/Makefile +199 -0
  63. data/ext/tcc/tcc-0.9.26/tests/asmtest.S +609 -0
  64. data/ext/tcc/tcc-0.9.26/tests/boundtest.c +233 -0
  65. data/ext/tcc/tcc-0.9.26/tests/gcctestsuite.sh +33 -0
  66. data/ext/tcc/tcc-0.9.26/tests/libtcc_test.c +76 -0
  67. data/ext/tcc/tcc-0.9.26/tests/tcctest.c +2713 -0
  68. data/ext/tcc/tcc-0.9.26/tests/tests2/00_assignment.c +18 -0
  69. data/ext/tcc/tcc-0.9.26/tests/tests2/00_assignment.expect +3 -0
  70. data/ext/tcc/tcc-0.9.26/tests/tests2/01_comment.c +14 -0
  71. data/ext/tcc/tcc-0.9.26/tests/tests2/01_comment.expect +5 -0
  72. data/ext/tcc/tcc-0.9.26/tests/tests2/02_printf.c +18 -0
  73. data/ext/tcc/tcc-0.9.26/tests/tests2/02_printf.expect +15 -0
  74. data/ext/tcc/tcc-0.9.26/tests/tests2/03_struct.c +31 -0
  75. data/ext/tcc/tcc-0.9.26/tests/tests2/03_struct.expect +6 -0
  76. data/ext/tcc/tcc-0.9.26/tests/tests2/04_for.c +15 -0
  77. data/ext/tcc/tcc-0.9.26/tests/tests2/04_for.expect +10 -0
  78. data/ext/tcc/tcc-0.9.26/tests/tests2/05_array.c +21 -0
  79. data/ext/tcc/tcc-0.9.26/tests/tests2/05_array.expect +10 -0
  80. data/ext/tcc/tcc-0.9.26/tests/tests2/06_case.c +29 -0
  81. data/ext/tcc/tcc-0.9.26/tests/tests2/06_case.expect +8 -0
  82. data/ext/tcc/tcc-0.9.26/tests/tests2/07_function.c +30 -0
  83. data/ext/tcc/tcc-0.9.26/tests/tests2/07_function.expect +4 -0
  84. data/ext/tcc/tcc-0.9.26/tests/tests2/08_while.c +24 -0
  85. data/ext/tcc/tcc-0.9.26/tests/tests2/08_while.expect +11 -0
  86. data/ext/tcc/tcc-0.9.26/tests/tests2/09_do_while.c +24 -0
  87. data/ext/tcc/tcc-0.9.26/tests/tests2/09_do_while.expect +11 -0
  88. data/ext/tcc/tcc-0.9.26/tests/tests2/10_pointer.c +40 -0
  89. data/ext/tcc/tcc-0.9.26/tests/tests2/10_pointer.expect +8 -0
  90. data/ext/tcc/tcc-0.9.26/tests/tests2/11_precedence.c +40 -0
  91. data/ext/tcc/tcc-0.9.26/tests/tests2/11_precedence.expect +15 -0
  92. data/ext/tcc/tcc-0.9.26/tests/tests2/12_hashdefine.c +14 -0
  93. data/ext/tcc/tcc-0.9.26/tests/tests2/12_hashdefine.expect +2 -0
  94. data/ext/tcc/tcc-0.9.26/tests/tests2/13_integer_literals.c +20 -0
  95. data/ext/tcc/tcc-0.9.26/tests/tests2/13_integer_literals.expect +5 -0
  96. data/ext/tcc/tcc-0.9.26/tests/tests2/14_if.c +21 -0
  97. data/ext/tcc/tcc-0.9.26/tests/tests2/14_if.expect +2 -0
  98. data/ext/tcc/tcc-0.9.26/tests/tests2/15_recursion.c +21 -0
  99. data/ext/tcc/tcc-0.9.26/tests/tests2/15_recursion.expect +10 -0
  100. data/ext/tcc/tcc-0.9.26/tests/tests2/16_nesting.c +21 -0
  101. data/ext/tcc/tcc-0.9.26/tests/tests2/16_nesting.expect +18 -0
  102. data/ext/tcc/tcc-0.9.26/tests/tests2/17_enum.c +29 -0
  103. data/ext/tcc/tcc-0.9.26/tests/tests2/17_enum.expect +3 -0
  104. data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.c +12 -0
  105. data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.expect +3 -0
  106. data/ext/tcc/tcc-0.9.26/tests/tests2/18_include.h +1 -0
  107. data/ext/tcc/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.c +28 -0
  108. data/ext/tcc/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.expect +3 -0
  109. data/ext/tcc/tcc-0.9.26/tests/tests2/20_pointer_comparison.c +24 -0
  110. data/ext/tcc/tcc-0.9.26/tests/tests2/20_pointer_comparison.expect +6 -0
  111. data/ext/tcc/tcc-0.9.26/tests/tests2/21_char_array.c +33 -0
  112. data/ext/tcc/tcc-0.9.26/tests/tests2/21_char_array.expect +7 -0
  113. data/ext/tcc/tcc-0.9.26/tests/tests2/22_floating_point.c +50 -0
  114. data/ext/tcc/tcc-0.9.26/tests/tests2/22_floating_point.expect +16 -0
  115. data/ext/tcc/tcc-0.9.26/tests/tests2/23_type_coercion.c +54 -0
  116. data/ext/tcc/tcc-0.9.26/tests/tests2/23_type_coercion.expect +12 -0
  117. data/ext/tcc/tcc-0.9.26/tests/tests2/24_math_library.c +28 -0
  118. data/ext/tcc/tcc-0.9.26/tests/tests2/24_math_library.expect +18 -0
  119. data/ext/tcc/tcc-0.9.26/tests/tests2/25_quicksort.c +83 -0
  120. data/ext/tcc/tcc-0.9.26/tests/tests2/25_quicksort.expect +2 -0
  121. data/ext/tcc/tcc-0.9.26/tests/tests2/26_character_constants.c +17 -0
  122. data/ext/tcc/tcc-0.9.26/tests/tests2/26_character_constants.expect +8 -0
  123. data/ext/tcc/tcc-0.9.26/tests/tests2/27_sizeof.c +16 -0
  124. data/ext/tcc/tcc-0.9.26/tests/tests2/27_sizeof.expect +3 -0
  125. data/ext/tcc/tcc-0.9.26/tests/tests2/28_strings.c +46 -0
  126. data/ext/tcc/tcc-0.9.26/tests/tests2/28_strings.expect +19 -0
  127. data/ext/tcc/tcc-0.9.26/tests/tests2/29_array_address.c +13 -0
  128. data/ext/tcc/tcc-0.9.26/tests/tests2/29_array_address.expect +1 -0
  129. data/ext/tcc/tcc-0.9.26/tests/tests2/30_hanoi.c +122 -0
  130. data/ext/tcc/tcc-0.9.26/tests/tests2/30_hanoi.expect +71 -0
  131. data/ext/tcc/tcc-0.9.26/tests/tests2/31_args.c +14 -0
  132. data/ext/tcc/tcc-0.9.26/tests/tests2/31_args.expect +7 -0
  133. data/ext/tcc/tcc-0.9.26/tests/tests2/32_led.c +266 -0
  134. data/ext/tcc/tcc-0.9.26/tests/tests2/32_led.expect +4 -0
  135. data/ext/tcc/tcc-0.9.26/tests/tests2/33_ternary_op.c +15 -0
  136. data/ext/tcc/tcc-0.9.26/tests/tests2/33_ternary_op.expect +10 -0
  137. data/ext/tcc/tcc-0.9.26/tests/tests2/34_array_assignment.c +23 -0
  138. data/ext/tcc/tcc-0.9.26/tests/tests2/34_array_assignment.expect +2 -0
  139. data/ext/tcc/tcc-0.9.26/tests/tests2/35_sizeof.c +14 -0
  140. data/ext/tcc/tcc-0.9.26/tests/tests2/35_sizeof.expect +2 -0
  141. data/ext/tcc/tcc-0.9.26/tests/tests2/36_array_initialisers.c +21 -0
  142. data/ext/tcc/tcc-0.9.26/tests/tests2/36_array_initialisers.expect +20 -0
  143. data/ext/tcc/tcc-0.9.26/tests/tests2/37_sprintf.c +17 -0
  144. data/ext/tcc/tcc-0.9.26/tests/tests2/37_sprintf.expect +20 -0
  145. data/ext/tcc/tcc-0.9.26/tests/tests2/38_multiple_array_index.c +32 -0
  146. data/ext/tcc/tcc-0.9.26/tests/tests2/38_multiple_array_index.expect +4 -0
  147. data/ext/tcc/tcc-0.9.26/tests/tests2/39_typedef.c +31 -0
  148. data/ext/tcc/tcc-0.9.26/tests/tests2/39_typedef.expect +3 -0
  149. data/ext/tcc/tcc-0.9.26/tests/tests2/40_stdio.c +52 -0
  150. data/ext/tcc/tcc-0.9.26/tests/tests2/40_stdio.expect +27 -0
  151. data/ext/tcc/tcc-0.9.26/tests/tests2/41_hashif.c +85 -0
  152. data/ext/tcc/tcc-0.9.26/tests/tests2/41_hashif.expect +6 -0
  153. data/ext/tcc/tcc-0.9.26/tests/tests2/42_function_pointer.c +18 -0
  154. data/ext/tcc/tcc-0.9.26/tests/tests2/42_function_pointer.expect +2 -0
  155. data/ext/tcc/tcc-0.9.26/tests/tests2/43_void_param.c +15 -0
  156. data/ext/tcc/tcc-0.9.26/tests/tests2/43_void_param.expect +1 -0
  157. data/ext/tcc/tcc-0.9.26/tests/tests2/44_scoped_declarations.c +17 -0
  158. data/ext/tcc/tcc-0.9.26/tests/tests2/44_scoped_declarations.expect +1 -0
  159. data/ext/tcc/tcc-0.9.26/tests/tests2/45_empty_for.c +18 -0
  160. data/ext/tcc/tcc-0.9.26/tests/tests2/45_empty_for.expect +10 -0
  161. data/ext/tcc/tcc-0.9.26/tests/tests2/46_grep.c +564 -0
  162. data/ext/tcc/tcc-0.9.26/tests/tests2/47_switch_return.c +24 -0
  163. data/ext/tcc/tcc-0.9.26/tests/tests2/47_switch_return.expect +4 -0
  164. data/ext/tcc/tcc-0.9.26/tests/tests2/48_nested_break.c +26 -0
  165. data/ext/tcc/tcc-0.9.26/tests/tests2/48_nested_break.expect +1 -0
  166. data/ext/tcc/tcc-0.9.26/tests/tests2/49_bracket_evaluation.c +23 -0
  167. data/ext/tcc/tcc-0.9.26/tests/tests2/49_bracket_evaluation.expect +1 -0
  168. data/ext/tcc/tcc-0.9.26/tests/tests2/50_logical_second_arg.c +29 -0
  169. data/ext/tcc/tcc-0.9.26/tests/tests2/50_logical_second_arg.expect +20 -0
  170. data/ext/tcc/tcc-0.9.26/tests/tests2/51_static.c +30 -0
  171. data/ext/tcc/tcc-0.9.26/tests/tests2/51_static.expect +8 -0
  172. data/ext/tcc/tcc-0.9.26/tests/tests2/52_unnamed_enum.c +27 -0
  173. data/ext/tcc/tcc-0.9.26/tests/tests2/52_unnamed_enum.expect +9 -0
  174. data/ext/tcc/tcc-0.9.26/tests/tests2/54_goto.c +56 -0
  175. data/ext/tcc/tcc-0.9.26/tests/tests2/54_goto.expect +8 -0
  176. data/ext/tcc/tcc-0.9.26/tests/tests2/55_lshift_type.c +52 -0
  177. data/ext/tcc/tcc-0.9.26/tests/tests2/55_lshift_type.expect +1 -0
  178. data/ext/tcc/tcc-0.9.26/tests/tests2/LICENSE +37 -0
  179. data/ext/tcc/tcc-0.9.26/tests/tests2/Makefile +98 -0
  180. data/ext/tcc/tcc-0.9.26/texi2pod.pl +427 -0
  181. data/ext/tcc/tcc-0.9.26/win32/build-tcc.bat +60 -0
  182. data/ext/tcc/tcc-0.9.26/win32/examples/dll.c +12 -0
  183. data/ext/tcc/tcc-0.9.26/win32/examples/fib.c +23 -0
  184. data/ext/tcc/tcc-0.9.26/win32/examples/hello_dll.c +19 -0
  185. data/ext/tcc/tcc-0.9.26/win32/examples/hello_win.c +163 -0
  186. data/ext/tcc/tcc-0.9.26/win32/include/_mingw.h +139 -0
  187. data/ext/tcc/tcc-0.9.26/win32/include/assert.h +54 -0
  188. data/ext/tcc/tcc-0.9.26/win32/include/conio.h +409 -0
  189. data/ext/tcc/tcc-0.9.26/win32/include/ctype.h +281 -0
  190. data/ext/tcc/tcc-0.9.26/win32/include/dir.h +31 -0
  191. data/ext/tcc/tcc-0.9.26/win32/include/direct.h +68 -0
  192. data/ext/tcc/tcc-0.9.26/win32/include/dirent.h +135 -0
  193. data/ext/tcc/tcc-0.9.26/win32/include/dos.h +55 -0
  194. data/ext/tcc/tcc-0.9.26/win32/include/errno.h +75 -0
  195. data/ext/tcc/tcc-0.9.26/win32/include/excpt.h +123 -0
  196. data/ext/tcc/tcc-0.9.26/win32/include/fcntl.h +52 -0
  197. data/ext/tcc/tcc-0.9.26/win32/include/fenv.h +108 -0
  198. data/ext/tcc/tcc-0.9.26/win32/include/inttypes.h +297 -0
  199. data/ext/tcc/tcc-0.9.26/win32/include/io.h +418 -0
  200. data/ext/tcc/tcc-0.9.26/win32/include/limits.h +111 -0
  201. data/ext/tcc/tcc-0.9.26/win32/include/locale.h +91 -0
  202. data/ext/tcc/tcc-0.9.26/win32/include/malloc.h +175 -0
  203. data/ext/tcc/tcc-0.9.26/win32/include/math.h +777 -0
  204. data/ext/tcc/tcc-0.9.26/win32/include/mem.h +13 -0
  205. data/ext/tcc/tcc-0.9.26/win32/include/memory.h +40 -0
  206. data/ext/tcc/tcc-0.9.26/win32/include/process.h +176 -0
  207. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/conio_s.h +42 -0
  208. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/crtdbg_s.h +19 -0
  209. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/io_s.h +33 -0
  210. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/mbstring_s.h +52 -0
  211. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/search_s.h +25 -0
  212. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stdio_s.h +145 -0
  213. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stdlib_s.h +67 -0
  214. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/stralign_s.h +30 -0
  215. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/string_s.h +41 -0
  216. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/sys/timeb_s.h +34 -0
  217. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/tchar_s.h +266 -0
  218. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/time_s.h +61 -0
  219. data/ext/tcc/tcc-0.9.26/win32/include/sec_api/wchar_s.h +128 -0
  220. data/ext/tcc/tcc-0.9.26/win32/include/setjmp.h +160 -0
  221. data/ext/tcc/tcc-0.9.26/win32/include/share.h +28 -0
  222. data/ext/tcc/tcc-0.9.26/win32/include/signal.h +63 -0
  223. data/ext/tcc/tcc-0.9.26/win32/include/stdint.h +209 -0
  224. data/ext/tcc/tcc-0.9.26/win32/include/stdio.h +429 -0
  225. data/ext/tcc/tcc-0.9.26/win32/include/stdlib.h +580 -0
  226. data/ext/tcc/tcc-0.9.26/win32/include/string.h +164 -0
  227. data/ext/tcc/tcc-0.9.26/win32/include/sys/fcntl.h +13 -0
  228. data/ext/tcc/tcc-0.9.26/win32/include/sys/file.h +14 -0
  229. data/ext/tcc/tcc-0.9.26/win32/include/sys/locking.h +30 -0
  230. data/ext/tcc/tcc-0.9.26/win32/include/sys/stat.h +290 -0
  231. data/ext/tcc/tcc-0.9.26/win32/include/sys/time.h +69 -0
  232. data/ext/tcc/tcc-0.9.26/win32/include/sys/timeb.h +133 -0
  233. data/ext/tcc/tcc-0.9.26/win32/include/sys/types.h +118 -0
  234. data/ext/tcc/tcc-0.9.26/win32/include/sys/unistd.h +14 -0
  235. data/ext/tcc/tcc-0.9.26/win32/include/sys/utime.h +146 -0
  236. data/ext/tcc/tcc-0.9.26/win32/include/tchar.h +1102 -0
  237. data/ext/tcc/tcc-0.9.26/win32/include/time.h +287 -0
  238. data/ext/tcc/tcc-0.9.26/win32/include/vadefs.h +11 -0
  239. data/ext/tcc/tcc-0.9.26/win32/include/values.h +4 -0
  240. data/ext/tcc/tcc-0.9.26/win32/include/wchar.h +871 -0
  241. data/ext/tcc/tcc-0.9.26/win32/include/wctype.h +172 -0
  242. data/ext/tcc/tcc-0.9.26/win32/include/winapi/basetsd.h +149 -0
  243. data/ext/tcc/tcc-0.9.26/win32/include/winapi/basetyps.h +85 -0
  244. data/ext/tcc/tcc-0.9.26/win32/include/winapi/guiddef.h +151 -0
  245. data/ext/tcc/tcc-0.9.26/win32/include/winapi/intrin.h +11 -0
  246. data/ext/tcc/tcc-0.9.26/win32/include/winapi/poppack.h +8 -0
  247. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack1.h +8 -0
  248. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack2.h +8 -0
  249. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack4.h +8 -0
  250. data/ext/tcc/tcc-0.9.26/win32/include/winapi/pshpack8.h +8 -0
  251. data/ext/tcc/tcc-0.9.26/win32/include/winapi/reason.h +80 -0
  252. data/ext/tcc/tcc-0.9.26/win32/include/winapi/specstrings.h +7 -0
  253. data/ext/tcc/tcc-0.9.26/win32/include/winapi/stralign.h +154 -0
  254. data/ext/tcc/tcc-0.9.26/win32/include/winapi/tvout.h +79 -0
  255. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winbase.h +2951 -0
  256. data/ext/tcc/tcc-0.9.26/win32/include/winapi/wincon.h +301 -0
  257. data/ext/tcc/tcc-0.9.26/win32/include/winapi/windef.h +293 -0
  258. data/ext/tcc/tcc-0.9.26/win32/include/winapi/windows.h +123 -0
  259. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winerror.h +3166 -0
  260. data/ext/tcc/tcc-0.9.26/win32/include/winapi/wingdi.h +4080 -0
  261. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnetwk.h +476 -0
  262. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnls.h +765 -0
  263. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winnt.h +5770 -0
  264. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winreg.h +272 -0
  265. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winuser.h +5651 -0
  266. data/ext/tcc/tcc-0.9.26/win32/include/winapi/winver.h +160 -0
  267. data/ext/tcc/tcc-0.9.26/win32/lib/chkstk.S +191 -0
  268. data/ext/tcc/tcc-0.9.26/win32/lib/crt1.c +34 -0
  269. data/ext/tcc/tcc-0.9.26/win32/lib/dllcrt1.c +13 -0
  270. data/ext/tcc/tcc-0.9.26/win32/lib/dllmain.c +9 -0
  271. data/ext/tcc/tcc-0.9.26/win32/lib/gdi32.def +337 -0
  272. data/ext/tcc/tcc-0.9.26/win32/lib/kernel32.def +765 -0
  273. data/ext/tcc/tcc-0.9.26/win32/lib/msvcrt.def +1399 -0
  274. data/ext/tcc/tcc-0.9.26/win32/lib/user32.def +654 -0
  275. data/ext/tcc/tcc-0.9.26/win32/lib/wincrt1.c +64 -0
  276. data/ext/tcc/tcc-0.9.26/win32/tcc-win32.txt +156 -0
  277. data/ext/tcc/tcc-0.9.26/win32/tools/tiny_impdef.c +243 -0
  278. data/ext/tcc/tcc-0.9.26/win32/tools/tiny_libmaker.c +258 -0
  279. data/ext/tcc/tcc-0.9.26/x86_64-asm.h +448 -0
  280. data/ext/tcc/tcc-0.9.26/x86_64-gen.c +1701 -0
  281. data/lib/tcc.rb +291 -0
  282. data/tcc.gemspec +15 -0
  283. metadata +343 -0
@@ -0,0 +1,1379 @@
1
+ /*
2
+ * TCC - Tiny C Compiler
3
+ *
4
+ * Copyright (c) 2001-2004 Fabrice Bellard
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #ifndef _TCC_H
22
+ #define _TCC_H
23
+
24
+ #define _GNU_SOURCE
25
+ #include "config.h"
26
+
27
+ #ifdef CONFIG_TCCBOOT
28
+ #include "tccboot.h"
29
+ #define CONFIG_TCC_STATIC
30
+ #else
31
+
32
+ #include <stdlib.h>
33
+ #include <stdio.h>
34
+ #include <stdarg.h>
35
+ #include <string.h>
36
+ #include <errno.h>
37
+ #include <math.h>
38
+ #include <signal.h>
39
+ #include <fcntl.h>
40
+ #include <setjmp.h>
41
+ #include <time.h>
42
+
43
+ #ifndef _WIN32
44
+ # include <unistd.h>
45
+ # include <sys/time.h>
46
+ # include <sys/ucontext.h>
47
+ # include <sys/mman.h>
48
+ # ifndef CONFIG_TCC_STATIC
49
+ # include <dlfcn.h>
50
+ # endif
51
+ #else
52
+ # include <windows.h>
53
+ # include <sys/timeb.h>
54
+ # include <io.h> /* open, close etc. */
55
+ # include <direct.h> /* getcwd */
56
+ # ifdef __GNUC__
57
+ # include <stdint.h>
58
+ # else
59
+ typedef UINT_PTR uintptr_t;
60
+ # endif
61
+ # define inline __inline
62
+ # define inp next_inp
63
+ # ifdef LIBTCC_AS_DLL
64
+ # define LIBTCCAPI __declspec(dllexport)
65
+ # define PUB_FUNC LIBTCCAPI
66
+ # endif
67
+ #endif
68
+
69
+ #endif /* !CONFIG_TCCBOOT */
70
+
71
+ #ifndef O_BINARY
72
+ # define O_BINARY 0
73
+ #endif
74
+
75
+ #include "elf.h"
76
+ #ifdef TCC_TARGET_X86_64
77
+ # define ELFCLASSW ELFCLASS64
78
+ # define ElfW(type) Elf##64##_##type
79
+ # define ELFW(type) ELF##64##_##type
80
+ # define ElfW_Rel ElfW(Rela)
81
+ # define SHT_RELX SHT_RELA
82
+ # define REL_SECTION_FMT ".rela%s"
83
+ /* XXX: DLL with PLT would only work with x86-64 for now */
84
+ # define TCC_OUTPUT_DLL_WITH_PLT
85
+ #else
86
+ # define ELFCLASSW ELFCLASS32
87
+ # define ElfW(type) Elf##32##_##type
88
+ # define ELFW(type) ELF##32##_##type
89
+ # define ElfW_Rel ElfW(Rel)
90
+ # define SHT_RELX SHT_REL
91
+ # define REL_SECTION_FMT ".rel%s"
92
+ #endif
93
+
94
+ /* target address type */
95
+ #define addr_t ElfW(Addr)
96
+
97
+ #include "stab.h"
98
+ #include "libtcc.h"
99
+
100
+ /* parser debug */
101
+ //#define PARSE_DEBUG
102
+ /* preprocessor debug */
103
+ //#define PP_DEBUG
104
+ /* include file debug */
105
+ //#define INC_DEBUG
106
+ /* memory leak debug */
107
+ //#define MEM_DEBUG
108
+ /* assembler debug */
109
+ //#define ASM_DEBUG
110
+
111
+ /* target selection */
112
+ //#define TCC_TARGET_I386 /* i386 code generator */
113
+ //#define TCC_TARGET_ARM /* ARMv4 code generator */
114
+ //#define TCC_TARGET_C67 /* TMS320C67xx code generator */
115
+ //#define TCC_TARGET_X86_64 /* x86-64 code generator */
116
+
117
+ /* default target is I386 */
118
+ #if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
119
+ !defined(TCC_TARGET_C67) && !defined(TCC_TARGET_X86_64)
120
+ #define TCC_TARGET_I386
121
+ #endif
122
+
123
+ #if !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
124
+ !defined(TCC_TARGET_C67) && !defined(TCC_TARGET_X86_64)
125
+ #define CONFIG_TCC_BCHECK /* enable bound checking code */
126
+ #endif
127
+
128
+ /* define it to include assembler support */
129
+ #if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
130
+ #define CONFIG_TCC_ASM
131
+ #endif
132
+
133
+ /* object format selection */
134
+ #if defined(TCC_TARGET_C67)
135
+ #define TCC_TARGET_COFF
136
+ #endif
137
+
138
+ /* only native compiler supports -run */
139
+ #if defined _WIN32 == defined TCC_TARGET_PE
140
+ # if (defined __i386__ || defined _X86_) && defined TCC_TARGET_I386
141
+ # define TCC_IS_NATIVE
142
+ # elif (defined __x86_64__ || defined _AMD64_) && defined TCC_TARGET_X86_64
143
+ # define TCC_IS_NATIVE
144
+ # elif defined __arm__ && defined TCC_TARGET_ARM
145
+ # define TCC_IS_NATIVE
146
+ # endif
147
+ #endif
148
+
149
+ #if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT
150
+ # define CONFIG_TCC_BACKTRACE
151
+ #endif
152
+
153
+ /* ------------ path configuration ------------ */
154
+
155
+ #ifndef CONFIG_SYSROOT
156
+ # define CONFIG_SYSROOT ""
157
+ #endif
158
+ #ifndef CONFIG_TCCDIR
159
+ # define CONFIG_TCCDIR "."
160
+ #endif
161
+ #ifndef CONFIG_LDDIR
162
+ # define CONFIG_LDDIR "lib"
163
+ #endif
164
+
165
+ /* path to find crt1.o, crti.o and crtn.o */
166
+ #ifndef CONFIG_TCC_CRTPREFIX
167
+ # define CONFIG_TCC_CRTPREFIX CONFIG_SYSROOT "/usr/" CONFIG_LDDIR
168
+ #endif
169
+
170
+ /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
171
+
172
+ /* system include paths */
173
+ #ifndef CONFIG_TCC_SYSINCLUDEPATHS
174
+ # ifdef TCC_TARGET_PE
175
+ # define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi"
176
+ # elif defined CONFIG_MULTIARCHDIR
177
+ # define CONFIG_TCC_SYSINCLUDEPATHS \
178
+ CONFIG_SYSROOT "/usr/local/include" \
179
+ ":" CONFIG_SYSROOT "/usr/local/include/" CONFIG_MULTIARCHDIR \
180
+ ":" CONFIG_SYSROOT "/usr/include" \
181
+ ":" CONFIG_SYSROOT "/usr/include/" CONFIG_MULTIARCHDIR \
182
+ ":" "{B}/include"
183
+ # else
184
+ # define CONFIG_TCC_SYSINCLUDEPATHS \
185
+ CONFIG_SYSROOT "/usr/local/include" \
186
+ ":" CONFIG_SYSROOT "/usr/include" \
187
+ ":" "{B}/include"
188
+ # endif
189
+ #endif
190
+
191
+ /* library search paths */
192
+ #ifndef CONFIG_TCC_LIBPATHS
193
+ # ifdef TCC_TARGET_PE
194
+ # define CONFIG_TCC_LIBPATHS "{B}/lib"
195
+ # else
196
+ # define CONFIG_TCC_LIBPATHS \
197
+ CONFIG_SYSROOT "/usr/" CONFIG_LDDIR \
198
+ ":" CONFIG_SYSROOT "/" CONFIG_LDDIR \
199
+ ":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR
200
+ # endif
201
+ #endif
202
+
203
+ /* name of ELF interpreter */
204
+ #ifndef CONFIG_TCC_ELFINTERP
205
+ # if defined __FreeBSD__
206
+ # define CONFIG_TCC_ELFINTERP "/libexec/ld-elf.so.1"
207
+ # elif defined __FreeBSD_kernel__
208
+ # define CONFIG_TCC_ELFINTERP "/lib/ld.so.1"
209
+ # elif defined TCC_ARM_HARDFLOAT
210
+ # define CONFIG_TCC_ELFINTERP "/lib/ld-linux-armhf.so.3"
211
+ # elif defined TCC_ARM_EABI
212
+ # define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.3"
213
+ # elif defined(TCC_TARGET_X86_64)
214
+ # define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
215
+ # elif defined(TCC_UCLIBC)
216
+ # define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0"
217
+ # elif defined(TCC_TARGET_PE)
218
+ # define CONFIG_TCC_ELFINTERP "-"
219
+ # else
220
+ # define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
221
+ # endif
222
+ #endif
223
+
224
+ /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
225
+ #define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/libgcc_s.so.1"
226
+
227
+ /* -------------------------------------------- */
228
+ /* include the target specific definitions */
229
+
230
+ #define TARGET_DEFS_ONLY
231
+ #ifdef TCC_TARGET_I386
232
+ # include "i386-gen.c"
233
+ #endif
234
+ #ifdef TCC_TARGET_X86_64
235
+ # include "x86_64-gen.c"
236
+ #endif
237
+ #ifdef TCC_TARGET_ARM
238
+ # include "arm-gen.c"
239
+ #endif
240
+ #ifdef TCC_TARGET_C67
241
+ # include "coff.h"
242
+ # include "c67-gen.c"
243
+ #endif
244
+ #undef TARGET_DEFS_ONLY
245
+
246
+ /* -------------------------------------------- */
247
+
248
+ #define INCLUDE_STACK_SIZE 32
249
+ #define IFDEF_STACK_SIZE 64
250
+ #define VSTACK_SIZE 256
251
+ #define STRING_MAX_SIZE 1024
252
+ #define PACK_STACK_SIZE 8
253
+
254
+ #define TOK_HASH_SIZE 8192 /* must be a power of two */
255
+ #define TOK_ALLOC_INCR 512 /* must be a power of two */
256
+ #define TOK_MAX_SIZE 4 /* token max size in int unit when stored in string */
257
+
258
+ /* token symbol management */
259
+ typedef struct TokenSym {
260
+ struct TokenSym *hash_next;
261
+ struct Sym *sym_define; /* direct pointer to define */
262
+ struct Sym *sym_label; /* direct pointer to label */
263
+ struct Sym *sym_struct; /* direct pointer to structure */
264
+ struct Sym *sym_identifier; /* direct pointer to identifier */
265
+ int tok; /* token number */
266
+ int len;
267
+ char str[1];
268
+ } TokenSym;
269
+
270
+ #ifdef TCC_TARGET_PE
271
+ typedef unsigned short nwchar_t;
272
+ #else
273
+ typedef int nwchar_t;
274
+ #endif
275
+
276
+ typedef struct CString {
277
+ int size; /* size in bytes */
278
+ void *data; /* either 'char *' or 'nwchar_t *' */
279
+ int size_allocated;
280
+ void *data_allocated; /* if non NULL, data has been malloced */
281
+ } CString;
282
+
283
+ /* type definition */
284
+ typedef struct CType {
285
+ int t;
286
+ struct Sym *ref;
287
+ } CType;
288
+
289
+ /* constant value */
290
+ typedef union CValue {
291
+ long double ld;
292
+ double d;
293
+ float f;
294
+ int i;
295
+ unsigned int ui;
296
+ unsigned int ul; /* address (should be unsigned long on 64 bit cpu) */
297
+ long long ll;
298
+ unsigned long long ull;
299
+ struct CString *cstr;
300
+ void *ptr;
301
+ int tab[LDOUBLE_SIZE/4];
302
+ } CValue;
303
+
304
+ /* value on stack */
305
+ typedef struct SValue {
306
+ CType type; /* type */
307
+ unsigned short r; /* register + flags */
308
+ unsigned short r2; /* second register, used for 'long long'
309
+ type. If not used, set to VT_CONST */
310
+ CValue c; /* constant, if VT_CONST */
311
+ struct Sym *sym; /* symbol, if (VT_SYM | VT_CONST) */
312
+ } SValue;
313
+
314
+ /* symbol management */
315
+ typedef struct Sym {
316
+ int v; /* symbol token */
317
+ char *asm_label; /* associated asm label */
318
+ long r; /* associated register */
319
+ union {
320
+ long c; /* associated number */
321
+ int *d; /* define token stream */
322
+ };
323
+ CType type; /* associated type */
324
+ union {
325
+ struct Sym *next; /* next related symbol */
326
+ long jnext; /* next jump label */
327
+ };
328
+ struct Sym *prev; /* prev symbol in stack */
329
+ struct Sym *prev_tok; /* previous symbol for this token */
330
+ } Sym;
331
+
332
+ /* section definition */
333
+ /* XXX: use directly ELF structure for parameters ? */
334
+ /* special flag to indicate that the section should not be linked to
335
+ the other ones */
336
+ #define SHF_PRIVATE 0x80000000
337
+
338
+ /* special flag, too */
339
+ #define SECTION_ABS ((void *)1)
340
+
341
+ typedef struct Section {
342
+ unsigned long data_offset; /* current data offset */
343
+ unsigned char *data; /* section data */
344
+ unsigned long data_allocated; /* used for realloc() handling */
345
+ int sh_name; /* elf section name (only used during output) */
346
+ int sh_num; /* elf section number */
347
+ int sh_type; /* elf section type */
348
+ int sh_flags; /* elf section flags */
349
+ int sh_info; /* elf section info */
350
+ int sh_addralign; /* elf section alignment */
351
+ int sh_entsize; /* elf entry size */
352
+ unsigned long sh_size; /* section size (only used during output) */
353
+ addr_t sh_addr; /* address at which the section is relocated */
354
+ unsigned long sh_offset; /* file offset */
355
+ int nb_hashed_syms; /* used to resize the hash table */
356
+ struct Section *link; /* link to another section */
357
+ struct Section *reloc; /* corresponding section for relocation, if any */
358
+ struct Section *hash; /* hash table for symbols */
359
+ struct Section *next;
360
+ char name[1]; /* section name */
361
+ } Section;
362
+
363
+ typedef struct DLLReference {
364
+ int level;
365
+ void *handle;
366
+ char name[1];
367
+ } DLLReference;
368
+
369
+ /* GNUC attribute definition */
370
+ typedef struct AttributeDef {
371
+ unsigned
372
+ func_call : 3, /* calling convention (0..5), see below */
373
+ aligned : 5, /* alignement (0..16) */
374
+ packed : 1,
375
+ func_export : 1,
376
+ func_import : 1,
377
+ func_args : 5,
378
+ mode : 4,
379
+ weak : 1,
380
+ fill : 11;
381
+ struct Section *section;
382
+ int alias_target; /* token */
383
+ } AttributeDef;
384
+
385
+ /* gr: wrappers for casting sym->r for other purposes */
386
+ #define FUNC_CALL(r) (((AttributeDef*)&(r))->func_call)
387
+ #define FUNC_EXPORT(r) (((AttributeDef*)&(r))->func_export)
388
+ #define FUNC_IMPORT(r) (((AttributeDef*)&(r))->func_import)
389
+ #define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)
390
+ #define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)
391
+ #define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)
392
+ #define ATTR_MODE(r) (((AttributeDef*)&(r))->mode)
393
+ #define INT_ATTR(ad) (*(int*)(ad))
394
+
395
+ /* -------------------------------------------------- */
396
+
397
+ #define SYM_STRUCT 0x40000000 /* struct/union/enum symbol space */
398
+ #define SYM_FIELD 0x20000000 /* struct/union field symbol space */
399
+ #define SYM_FIRST_ANOM 0x10000000 /* first anonymous sym */
400
+
401
+ /* stored in 'Sym.c' field */
402
+ #define FUNC_NEW 1 /* ansi function prototype */
403
+ #define FUNC_OLD 2 /* old function prototype */
404
+ #define FUNC_ELLIPSIS 3 /* ansi function prototype with ... */
405
+
406
+ /* stored in 'Sym.r' field */
407
+ #define FUNC_CDECL 0 /* standard c call */
408
+ #define FUNC_STDCALL 1 /* pascal c call */
409
+ #define FUNC_FASTCALL1 2 /* first param in %eax */
410
+ #define FUNC_FASTCALL2 3 /* first parameters in %eax, %edx */
411
+ #define FUNC_FASTCALL3 4 /* first parameter in %eax, %edx, %ecx */
412
+ #define FUNC_FASTCALLW 5 /* first parameter in %ecx, %edx */
413
+
414
+ /* field 'Sym.t' for macros */
415
+ #define MACRO_OBJ 0 /* object like macro */
416
+ #define MACRO_FUNC 1 /* function like macro */
417
+
418
+ /* field 'Sym.r' for C labels */
419
+ #define LABEL_DEFINED 0 /* label is defined */
420
+ #define LABEL_FORWARD 1 /* label is forward defined */
421
+ #define LABEL_DECLARED 2 /* label is declared but never used */
422
+
423
+ /* type_decl() types */
424
+ #define TYPE_ABSTRACT 1 /* type without variable */
425
+ #define TYPE_DIRECT 2 /* type with variable */
426
+
427
+ #define IO_BUF_SIZE 8192
428
+
429
+ typedef struct BufferedFile {
430
+ uint8_t *buf_ptr;
431
+ uint8_t *buf_end;
432
+ int fd;
433
+ struct BufferedFile *prev;
434
+ int line_num; /* current line number - here to simplify code */
435
+ int ifndef_macro; /* #ifndef macro / #endif search */
436
+ int ifndef_macro_saved; /* saved ifndef_macro */
437
+ int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
438
+ char filename[1024]; /* filename */
439
+ unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
440
+ } BufferedFile;
441
+
442
+ #define CH_EOB '\\' /* end of buffer or '\0' char in file */
443
+ #define CH_EOF (-1) /* end of file */
444
+
445
+ /* parsing state (used to save parser state to reparse part of the
446
+ source several times) */
447
+ typedef struct ParseState {
448
+ const int *macro_ptr;
449
+ int line_num;
450
+ int tok;
451
+ CValue tokc;
452
+ } ParseState;
453
+
454
+ /* used to record tokens */
455
+ typedef struct TokenString {
456
+ int *str;
457
+ int len;
458
+ int allocated_len;
459
+ int last_line_num;
460
+ } TokenString;
461
+
462
+ /* inline functions */
463
+ typedef struct InlineFunc {
464
+ int *token_str;
465
+ Sym *sym;
466
+ char filename[1];
467
+ } InlineFunc;
468
+
469
+ /* include file cache, used to find files faster and also to eliminate
470
+ inclusion if the include file is protected by #ifndef ... #endif */
471
+ typedef struct CachedInclude {
472
+ int ifndef_macro;
473
+ int hash_next; /* -1 if none */
474
+ char filename[1]; /* path specified in #include */
475
+ } CachedInclude;
476
+
477
+ #define CACHED_INCLUDES_HASH_SIZE 512
478
+
479
+ #ifdef CONFIG_TCC_ASM
480
+ typedef struct ExprValue {
481
+ uint32_t v;
482
+ Sym *sym;
483
+ } ExprValue;
484
+
485
+ #define MAX_ASM_OPERANDS 30
486
+ typedef struct ASMOperand {
487
+ int id; /* GCC 3 optionnal identifier (0 if number only supported */
488
+ char *constraint;
489
+ char asm_str[16]; /* computed asm string for operand */
490
+ SValue *vt; /* C value of the expression */
491
+ int ref_index; /* if >= 0, gives reference to a output constraint */
492
+ int input_index; /* if >= 0, gives reference to an input constraint */
493
+ int priority; /* priority, used to assign registers */
494
+ int reg; /* if >= 0, register number used for this operand */
495
+ int is_llong; /* true if double register value */
496
+ int is_memory; /* true if memory operand */
497
+ int is_rw; /* for '+' modifier */
498
+ } ASMOperand;
499
+ #endif
500
+
501
+ struct sym_attr {
502
+ unsigned long got_offset;
503
+ #ifdef TCC_TARGET_ARM
504
+ unsigned char plt_thumb_stub:1;
505
+ #endif
506
+ };
507
+
508
+ struct TCCState {
509
+
510
+ int verbose; /* if true, display some information during compilation */
511
+ int nostdinc; /* if true, no standard headers are added */
512
+ int nostdlib; /* if true, no standard libraries are added */
513
+ int nocommon; /* if true, do not use common symbols for .bss data */
514
+ int static_link; /* if true, static linking is performed */
515
+ int rdynamic; /* if true, all symbols are exported */
516
+ int symbolic; /* if true, resolve symbols in the current module first */
517
+ int alacarte_link; /* if true, only link in referenced objects from archive */
518
+
519
+ char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
520
+ char *soname; /* as specified on the command line (-soname) */
521
+ char *rpath; /* as specified on the command line (-Wl,-rpath=) */
522
+
523
+ /* output type, see TCC_OUTPUT_XXX */
524
+ int output_type;
525
+ /* output format, see TCC_OUTPUT_FORMAT_xxx */
526
+ int output_format;
527
+
528
+ /* C language options */
529
+ int char_is_unsigned;
530
+ int leading_underscore;
531
+
532
+ /* warning switches */
533
+ int warn_write_strings;
534
+ int warn_unsupported;
535
+ int warn_error;
536
+ int warn_none;
537
+ int warn_implicit_function_declaration;
538
+
539
+ /* compile with debug symbol (and use them if error during execution) */
540
+ int do_debug;
541
+ #ifdef CONFIG_TCC_BCHECK
542
+ /* compile with built-in memory and bounds checker */
543
+ int do_bounds_check;
544
+ #endif
545
+
546
+ addr_t text_addr; /* address of text section */
547
+ int has_text_addr;
548
+
549
+ unsigned long section_align; /* section alignment */
550
+
551
+ char *init_symbol; /* symbols to call at load-time (not used currently) */
552
+ char *fini_symbol; /* symbols to call at unload-time (not used currently) */
553
+
554
+ #ifdef TCC_TARGET_I386
555
+ int seg_size; /* 32. Can be 16 with i386 assembler (.code16) */
556
+ #endif
557
+
558
+ /* array of all loaded dlls (including those referenced by loaded dlls) */
559
+ DLLReference **loaded_dlls;
560
+ int nb_loaded_dlls;
561
+
562
+ /* include paths */
563
+ char **include_paths;
564
+ int nb_include_paths;
565
+
566
+ char **sysinclude_paths;
567
+ int nb_sysinclude_paths;
568
+
569
+ /* library paths */
570
+ char **library_paths;
571
+ int nb_library_paths;
572
+
573
+ /* crt?.o object path */
574
+ char **crt_paths;
575
+ int nb_crt_paths;
576
+
577
+ /* error handling */
578
+ void *error_opaque;
579
+ void (*error_func)(void *opaque, const char *msg);
580
+ int error_set_jmp_enabled;
581
+ jmp_buf error_jmp_buf;
582
+ int nb_errors;
583
+
584
+ /* output file for preprocessing (-E) */
585
+ FILE *ppfp;
586
+
587
+ /* for -MD/-MF: collected dependencies for this compilation */
588
+ char **target_deps;
589
+ int nb_target_deps;
590
+
591
+ /* compilation */
592
+ BufferedFile *include_stack[INCLUDE_STACK_SIZE];
593
+ BufferedFile **include_stack_ptr;
594
+
595
+ int ifdef_stack[IFDEF_STACK_SIZE];
596
+ int *ifdef_stack_ptr;
597
+
598
+ /* included files enclosed with #ifndef MACRO */
599
+ int cached_includes_hash[CACHED_INCLUDES_HASH_SIZE];
600
+ CachedInclude **cached_includes;
601
+ int nb_cached_includes;
602
+
603
+ /* #pragma pack stack */
604
+ int pack_stack[PACK_STACK_SIZE];
605
+ int *pack_stack_ptr;
606
+
607
+ /* inline functions are stored as token lists and compiled last
608
+ only if referenced */
609
+ struct InlineFunc **inline_fns;
610
+ int nb_inline_fns;
611
+
612
+ /* sections */
613
+ Section **sections;
614
+ int nb_sections; /* number of sections, including first dummy section */
615
+
616
+ Section **priv_sections;
617
+ int nb_priv_sections; /* number of private sections */
618
+
619
+ /* got & plt handling */
620
+ Section *got;
621
+ Section *plt;
622
+ struct sym_attr *sym_attrs;
623
+ int nb_sym_attrs;
624
+ /* give the correspondance from symtab indexes to dynsym indexes */
625
+ int *symtab_to_dynsym;
626
+
627
+ /* temporary dynamic symbol sections (for dll loading) */
628
+ Section *dynsymtab_section;
629
+ /* exported dynamic symbol section */
630
+ Section *dynsym;
631
+ /* copy of the gobal symtab_section variable */
632
+ Section *symtab;
633
+ /* tiny assembler state */
634
+ Sym *asm_labels;
635
+
636
+ #ifdef TCC_TARGET_PE
637
+ /* PE info */
638
+ int pe_subsystem;
639
+ unsigned pe_file_align;
640
+ unsigned pe_stack_size;
641
+ # ifdef TCC_TARGET_X86_64
642
+ Section *uw_pdata;
643
+ int uw_sym;
644
+ unsigned uw_offs;
645
+ # endif
646
+ #endif
647
+
648
+ #ifdef TCC_IS_NATIVE
649
+ /* for tcc_relocate */
650
+ void *runtime_mem;
651
+ # ifdef HAVE_SELINUX
652
+ void *write_mem;
653
+ unsigned long mem_size;
654
+ # endif
655
+ # if !defined TCC_TARGET_PE && (defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM)
656
+ /* write PLT and GOT here */
657
+ char *runtime_plt_and_got;
658
+ unsigned runtime_plt_and_got_offset;
659
+ # define TCC_HAS_RUNTIME_PLTGOT
660
+ # endif
661
+ #endif
662
+
663
+ /* used by main and tcc_parse_args only */
664
+ char **files; /* files seen on command line */
665
+ int nb_files; /* number thereof */
666
+ int nb_libraries; /* number of libs thereof */
667
+ char *outfile; /* output filename */
668
+ char *option_m; /* only -m32/-m64 handled */
669
+ int print_search_dirs; /* option */
670
+ int option_r; /* option -r */
671
+ int do_bench; /* option -bench */
672
+ int gen_deps; /* option -MD */
673
+ char *deps_outfile; /* option -MF */
674
+ };
675
+
676
+ /* The current value can be: */
677
+ #define VT_VALMASK 0x003f /* mask for value location, register or: */
678
+ #define VT_CONST 0x0030 /* constant in vc (must be first non register value) */
679
+ #define VT_LLOCAL 0x0031 /* lvalue, offset on stack */
680
+ #define VT_LOCAL 0x0032 /* offset on stack */
681
+ #define VT_CMP 0x0033 /* the value is stored in processor flags (in vc) */
682
+ #define VT_JMP 0x0034 /* value is the consequence of jmp true (even) */
683
+ #define VT_JMPI 0x0035 /* value is the consequence of jmp false (odd) */
684
+ #define VT_REF 0x0040 /* value is pointer to structure rather than address */
685
+ #define VT_LVAL 0x0100 /* var is an lvalue */
686
+ #define VT_SYM 0x0200 /* a symbol value is added */
687
+ #define VT_MUSTCAST 0x0400 /* value must be casted to be correct (used for
688
+ char/short stored in integer registers) */
689
+ #define VT_MUSTBOUND 0x0800 /* bound checking must be done before
690
+ dereferencing value */
691
+ #define VT_BOUNDED 0x8000 /* value is bounded. The address of the
692
+ bounding function call point is in vc */
693
+ #define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */
694
+ #define VT_LVAL_SHORT 0x2000 /* lvalue is a short */
695
+ #define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */
696
+ #define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
697
+
698
+ /* types */
699
+ #define VT_BTYPE 0x000f /* mask for basic type */
700
+ #define VT_INT 0 /* integer type */
701
+ #define VT_BYTE 1 /* signed byte type */
702
+ #define VT_SHORT 2 /* short type */
703
+ #define VT_VOID 3 /* void type */
704
+ #define VT_PTR 4 /* pointer */
705
+ #define VT_ENUM 5 /* enum definition */
706
+ #define VT_FUNC 6 /* function type */
707
+ #define VT_STRUCT 7 /* struct/union definition */
708
+ #define VT_FLOAT 8 /* IEEE float */
709
+ #define VT_DOUBLE 9 /* IEEE double */
710
+ #define VT_LDOUBLE 10 /* IEEE long double */
711
+ #define VT_BOOL 11 /* ISOC99 boolean type */
712
+ #define VT_LLONG 12 /* 64 bit integer */
713
+ #define VT_LONG 13 /* long integer (NEVER USED as type, only
714
+ during parsing) */
715
+ #define VT_UNSIGNED 0x0010 /* unsigned type */
716
+ #define VT_ARRAY 0x0020 /* array type (also has VT_PTR) */
717
+ #define VT_BITFIELD 0x0040 /* bitfield modifier */
718
+ #define VT_CONSTANT 0x0800 /* const modifier */
719
+ #define VT_VOLATILE 0x1000 /* volatile modifier */
720
+ #define VT_SIGNED 0x2000 /* signed type */
721
+ #define VT_VLA 0x00020000 /* VLA type (also has VT_PTR and VT_ARRAY) */
722
+
723
+ /* storage */
724
+ #define VT_EXTERN 0x00000080 /* extern definition */
725
+ #define VT_STATIC 0x00000100 /* static variable */
726
+ #define VT_TYPEDEF 0x00000200 /* typedef definition */
727
+ #define VT_INLINE 0x00000400 /* inline definition */
728
+ #define VT_IMPORT 0x00004000 /* win32: extern data imported from dll */
729
+ #define VT_EXPORT 0x00008000 /* win32: data exported from dll */
730
+ #define VT_WEAK 0x00010000 /* weak symbol */
731
+
732
+ #define VT_STRUCT_SHIFT 18 /* shift for bitfield shift values (max: 32 - 2*6) */
733
+
734
+ /* type mask (except storage) */
735
+ #define VT_STORAGE (VT_EXTERN | VT_STATIC | VT_TYPEDEF | VT_INLINE | VT_IMPORT | VT_EXPORT | VT_WEAK)
736
+ #define VT_TYPE (~(VT_STORAGE))
737
+
738
+ /* token values */
739
+
740
+ /* warning: the following compare tokens depend on i386 asm code */
741
+ #define TOK_ULT 0x92
742
+ #define TOK_UGE 0x93
743
+ #define TOK_EQ 0x94
744
+ #define TOK_NE 0x95
745
+ #define TOK_ULE 0x96
746
+ #define TOK_UGT 0x97
747
+ #define TOK_Nset 0x98
748
+ #define TOK_Nclear 0x99
749
+ #define TOK_LT 0x9c
750
+ #define TOK_GE 0x9d
751
+ #define TOK_LE 0x9e
752
+ #define TOK_GT 0x9f
753
+
754
+ #define TOK_LAND 0xa0
755
+ #define TOK_LOR 0xa1
756
+
757
+ #define TOK_DEC 0xa2
758
+ #define TOK_MID 0xa3 /* inc/dec, to void constant */
759
+ #define TOK_INC 0xa4
760
+ #define TOK_UDIV 0xb0 /* unsigned division */
761
+ #define TOK_UMOD 0xb1 /* unsigned modulo */
762
+ #define TOK_PDIV 0xb2 /* fast division with undefined rounding for pointers */
763
+ #define TOK_CINT 0xb3 /* number in tokc */
764
+ #define TOK_CCHAR 0xb4 /* char constant in tokc */
765
+ #define TOK_STR 0xb5 /* pointer to string in tokc */
766
+ #define TOK_TWOSHARPS 0xb6 /* ## preprocessing token */
767
+ #define TOK_LCHAR 0xb7
768
+ #define TOK_LSTR 0xb8
769
+ #define TOK_CFLOAT 0xb9 /* float constant */
770
+ #define TOK_LINENUM 0xba /* line number info */
771
+ #define TOK_CDOUBLE 0xc0 /* double constant */
772
+ #define TOK_CLDOUBLE 0xc1 /* long double constant */
773
+ #define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */
774
+ #define TOK_ADDC1 0xc3 /* add with carry generation */
775
+ #define TOK_ADDC2 0xc4 /* add with carry use */
776
+ #define TOK_SUBC1 0xc5 /* add with carry generation */
777
+ #define TOK_SUBC2 0xc6 /* add with carry use */
778
+ #define TOK_CUINT 0xc8 /* unsigned int constant */
779
+ #define TOK_CLLONG 0xc9 /* long long constant */
780
+ #define TOK_CULLONG 0xca /* unsigned long long constant */
781
+ #define TOK_ARROW 0xcb
782
+ #define TOK_DOTS 0xcc /* three dots */
783
+ #define TOK_SHR 0xcd /* unsigned shift right */
784
+ #define TOK_PPNUM 0xce /* preprocessor number */
785
+ #define TOK_NOSUBST 0xcf /* means following token has already been pp'd */
786
+
787
+ #define TOK_SHL 0x01 /* shift left */
788
+ #define TOK_SAR 0x02 /* signed shift right */
789
+
790
+ /* assignement operators : normal operator or 0x80 */
791
+ #define TOK_A_MOD 0xa5
792
+ #define TOK_A_AND 0xa6
793
+ #define TOK_A_MUL 0xaa
794
+ #define TOK_A_ADD 0xab
795
+ #define TOK_A_SUB 0xad
796
+ #define TOK_A_DIV 0xaf
797
+ #define TOK_A_XOR 0xde
798
+ #define TOK_A_OR 0xfc
799
+ #define TOK_A_SHL 0x81
800
+ #define TOK_A_SAR 0x82
801
+
802
+ #ifndef offsetof
803
+ #define offsetof(type, field) ((size_t) &((type *)0)->field)
804
+ #endif
805
+
806
+ #ifndef countof
807
+ #define countof(tab) (sizeof(tab) / sizeof((tab)[0]))
808
+ #endif
809
+
810
+ #define TOK_EOF (-1) /* end of file */
811
+ #define TOK_LINEFEED 10 /* line feed */
812
+
813
+ /* all identificators and strings have token above that */
814
+ #define TOK_IDENT 256
815
+
816
+ #define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x)
817
+ #define TOK_ASM_int TOK_INT
818
+ #define TOK_ASM_weak TOK_WEAK1
819
+
820
+ #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
821
+ /* only used for i386 asm opcodes definitions */
822
+ #define DEF_BWL(x) \
823
+ DEF(TOK_ASM_ ## x ## b, #x "b") \
824
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
825
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
826
+ DEF(TOK_ASM_ ## x, #x)
827
+ #define DEF_WL(x) \
828
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
829
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
830
+ DEF(TOK_ASM_ ## x, #x)
831
+ #ifdef TCC_TARGET_X86_64
832
+ # define DEF_BWLQ(x) \
833
+ DEF(TOK_ASM_ ## x ## b, #x "b") \
834
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
835
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
836
+ DEF(TOK_ASM_ ## x ## q, #x "q") \
837
+ DEF(TOK_ASM_ ## x, #x)
838
+ # define DEF_WLQ(x) \
839
+ DEF(TOK_ASM_ ## x ## w, #x "w") \
840
+ DEF(TOK_ASM_ ## x ## l, #x "l") \
841
+ DEF(TOK_ASM_ ## x ## q, #x "q") \
842
+ DEF(TOK_ASM_ ## x, #x)
843
+ # define DEF_BWLX DEF_BWLQ
844
+ # define DEF_WLX DEF_WLQ
845
+ /* number of sizes + 1 */
846
+ # define NBWLX 5
847
+ #else
848
+ # define DEF_BWLX DEF_BWL
849
+ # define DEF_WLX DEF_WL
850
+ /* number of sizes + 1 */
851
+ # define NBWLX 4
852
+ #endif
853
+
854
+ #define DEF_FP1(x) \
855
+ DEF(TOK_ASM_ ## f ## x ## s, "f" #x "s") \
856
+ DEF(TOK_ASM_ ## fi ## x ## l, "fi" #x "l") \
857
+ DEF(TOK_ASM_ ## f ## x ## l, "f" #x "l") \
858
+ DEF(TOK_ASM_ ## fi ## x ## s, "fi" #x "s")
859
+
860
+ #define DEF_FP(x) \
861
+ DEF(TOK_ASM_ ## f ## x, "f" #x ) \
862
+ DEF(TOK_ASM_ ## f ## x ## p, "f" #x "p") \
863
+ DEF_FP1(x)
864
+
865
+ #define DEF_ASMTEST(x) \
866
+ DEF_ASM(x ## o) \
867
+ DEF_ASM(x ## no) \
868
+ DEF_ASM(x ## b) \
869
+ DEF_ASM(x ## c) \
870
+ DEF_ASM(x ## nae) \
871
+ DEF_ASM(x ## nb) \
872
+ DEF_ASM(x ## nc) \
873
+ DEF_ASM(x ## ae) \
874
+ DEF_ASM(x ## e) \
875
+ DEF_ASM(x ## z) \
876
+ DEF_ASM(x ## ne) \
877
+ DEF_ASM(x ## nz) \
878
+ DEF_ASM(x ## be) \
879
+ DEF_ASM(x ## na) \
880
+ DEF_ASM(x ## nbe) \
881
+ DEF_ASM(x ## a) \
882
+ DEF_ASM(x ## s) \
883
+ DEF_ASM(x ## ns) \
884
+ DEF_ASM(x ## p) \
885
+ DEF_ASM(x ## pe) \
886
+ DEF_ASM(x ## np) \
887
+ DEF_ASM(x ## po) \
888
+ DEF_ASM(x ## l) \
889
+ DEF_ASM(x ## nge) \
890
+ DEF_ASM(x ## nl) \
891
+ DEF_ASM(x ## ge) \
892
+ DEF_ASM(x ## le) \
893
+ DEF_ASM(x ## ng) \
894
+ DEF_ASM(x ## nle) \
895
+ DEF_ASM(x ## g)
896
+
897
+ #endif // defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
898
+
899
+ enum tcc_token {
900
+ TOK_LAST = TOK_IDENT - 1,
901
+ #define DEF(id, str) id,
902
+ #include "tcctok.h"
903
+ #undef DEF
904
+ };
905
+
906
+ #define TOK_UIDENT TOK_DEFINE
907
+
908
+ #ifdef _WIN32
909
+ #define snprintf _snprintf
910
+ #define vsnprintf _vsnprintf
911
+ #ifndef __GNUC__
912
+ #define strtold (long double)strtod
913
+ #define strtof (float)strtod
914
+ #define strtoll _strtoi64
915
+ #define strtoull _strtoui64
916
+ #endif
917
+ #else
918
+ /* XXX: need to define this to use them in non ISOC99 context */
919
+ extern float strtof (const char *__nptr, char **__endptr);
920
+ extern long double strtold (const char *__nptr, char **__endptr);
921
+ #endif
922
+
923
+ #ifdef _WIN32
924
+ #define IS_DIRSEP(c) (c == '/' || c == '\\')
925
+ #define IS_ABSPATH(p) (IS_DIRSEP(p[0]) || (p[0] && p[1] == ':' && IS_DIRSEP(p[2])))
926
+ #define PATHCMP stricmp
927
+ #else
928
+ #define IS_DIRSEP(c) (c == '/')
929
+ #define IS_ABSPATH(p) IS_DIRSEP(p[0])
930
+ #define PATHCMP strcmp
931
+ #endif
932
+
933
+ #ifdef TCC_TARGET_PE
934
+ #define PATHSEP ';'
935
+ #else
936
+ #define PATHSEP ':'
937
+ #endif
938
+
939
+ /* space exlcuding newline */
940
+ static inline int is_space(int ch)
941
+ {
942
+ return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r';
943
+ }
944
+
945
+ static inline int isid(int c)
946
+ {
947
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
948
+ }
949
+
950
+ static inline int isnum(int c)
951
+ {
952
+ return c >= '0' && c <= '9';
953
+ }
954
+
955
+ static inline int isoct(int c)
956
+ {
957
+ return c >= '0' && c <= '7';
958
+ }
959
+
960
+ static inline int toup(int c)
961
+ {
962
+ return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c;
963
+ }
964
+
965
+ #ifndef PUB_FUNC
966
+ # define PUB_FUNC
967
+ #endif
968
+
969
+ #ifdef ONE_SOURCE
970
+ #define ST_INLN static inline
971
+ #define ST_FUNC static
972
+ #define ST_DATA static
973
+ #else
974
+ #define ST_INLN
975
+ #define ST_FUNC
976
+ #define ST_DATA extern
977
+ #endif
978
+
979
+ /* ------------ libtcc.c ------------ */
980
+
981
+ /* use GNU C extensions */
982
+ ST_DATA int gnu_ext;
983
+ /* use Tiny C extensions */
984
+ ST_DATA int tcc_ext;
985
+ /* XXX: get rid of this ASAP */
986
+ ST_DATA struct TCCState *tcc_state;
987
+
988
+ #ifdef MEM_DEBUG
989
+ ST_DATA int mem_cur_size;
990
+ ST_DATA int mem_max_size;
991
+ #endif
992
+
993
+ #define AFF_PRINT_ERROR 0x0001 /* print error if file not found */
994
+ #define AFF_REFERENCED_DLL 0x0002 /* load a referenced dll from another dll */
995
+ #define AFF_PREPROCESS 0x0004 /* preprocess file */
996
+
997
+ /* public functions currently used by the tcc main function */
998
+ PUB_FUNC char *pstrcpy(char *buf, int buf_size, const char *s);
999
+ PUB_FUNC char *pstrcat(char *buf, int buf_size, const char *s);
1000
+ PUB_FUNC char *pstrncpy(char *out, const char *in, size_t num);
1001
+ PUB_FUNC char *tcc_basename(const char *name);
1002
+ PUB_FUNC char *tcc_fileextension (const char *name);
1003
+ PUB_FUNC void tcc_free(void *ptr);
1004
+ PUB_FUNC void *tcc_malloc(unsigned long size);
1005
+ PUB_FUNC void *tcc_mallocz(unsigned long size);
1006
+ PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size);
1007
+ PUB_FUNC char *tcc_strdup(const char *str);
1008
+ #define free(p) use_tcc_free(p)
1009
+ #define malloc(s) use_tcc_malloc(s)
1010
+ #define realloc(p, s) use_tcc_realloc(p, s)
1011
+ #undef strdup
1012
+ #define strdup(s) use_tcc_strdup(s)
1013
+ PUB_FUNC void tcc_memstats(void);
1014
+ PUB_FUNC void tcc_error_noabort(const char *fmt, ...);
1015
+ PUB_FUNC void tcc_error(const char *fmt, ...);
1016
+ PUB_FUNC void tcc_warning(const char *fmt, ...);
1017
+
1018
+ /* other utilities */
1019
+ ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data);
1020
+ ST_FUNC void dynarray_reset(void *pp, int *n);
1021
+ ST_FUNC void cstr_ccat(CString *cstr, int ch);
1022
+ ST_FUNC void cstr_cat(CString *cstr, const char *str);
1023
+ ST_FUNC void cstr_wccat(CString *cstr, int ch);
1024
+ ST_FUNC void cstr_new(CString *cstr);
1025
+ ST_FUNC void cstr_free(CString *cstr);
1026
+ ST_FUNC void cstr_reset(CString *cstr);
1027
+
1028
+ ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags);
1029
+ ST_FUNC void section_realloc(Section *sec, unsigned long new_size);
1030
+ ST_FUNC void *section_ptr_add(Section *sec, unsigned long size);
1031
+ ST_FUNC void section_reserve(Section *sec, unsigned long size);
1032
+ ST_FUNC Section *find_section(TCCState *s1, const char *name);
1033
+
1034
+ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, addr_t value, unsigned long size, int can_add_underscore);
1035
+ ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
1036
+ ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
1037
+
1038
+ ST_INLN void sym_free(Sym *sym);
1039
+ ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, long c);
1040
+ ST_FUNC Sym *sym_find2(Sym *s, int v);
1041
+ ST_FUNC Sym *sym_push(int v, CType *type, int r, int c);
1042
+ ST_FUNC void sym_pop(Sym **ptop, Sym *b);
1043
+ ST_INLN Sym *struct_find(int v);
1044
+ ST_INLN Sym *sym_find(int v);
1045
+ ST_FUNC Sym *global_identifier_push(int v, int t, int c);
1046
+
1047
+ ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen);
1048
+ ST_FUNC int tcc_open(TCCState *s1, const char *filename);
1049
+ ST_FUNC void tcc_close(void);
1050
+
1051
+ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags);
1052
+ ST_FUNC int tcc_add_crt(TCCState *s, const char *filename);
1053
+ ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);
1054
+
1055
+ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time);
1056
+ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv);
1057
+
1058
+ /* ------------ tccpp.c ------------ */
1059
+
1060
+ ST_DATA struct BufferedFile *file;
1061
+ ST_DATA int ch, tok;
1062
+ ST_DATA CValue tokc;
1063
+ ST_DATA const int *macro_ptr;
1064
+ ST_DATA int parse_flags;
1065
+ ST_DATA int tok_flags;
1066
+ ST_DATA CString tokcstr; /* current parsed string, if any */
1067
+
1068
+ /* display benchmark infos */
1069
+ ST_DATA int total_lines;
1070
+ ST_DATA int total_bytes;
1071
+ ST_DATA int tok_ident;
1072
+ ST_DATA TokenSym **table_ident;
1073
+
1074
+ #define TOK_FLAG_BOL 0x0001 /* beginning of line before */
1075
+ #define TOK_FLAG_BOF 0x0002 /* beginning of file before */
1076
+ #define TOK_FLAG_ENDIF 0x0004 /* a endif was found matching starting #ifdef */
1077
+ #define TOK_FLAG_EOF 0x0008 /* end of file */
1078
+
1079
+ #define PARSE_FLAG_PREPROCESS 0x0001 /* activate preprocessing */
1080
+ #define PARSE_FLAG_TOK_NUM 0x0002 /* return numbers instead of TOK_PPNUM */
1081
+ #define PARSE_FLAG_LINEFEED 0x0004 /* line feed is returned as a
1082
+ token. line feed is also
1083
+ returned at eof */
1084
+ #define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */
1085
+ #define PARSE_FLAG_SPACES 0x0010 /* next() returns space tokens (for -E) */
1086
+
1087
+ ST_FUNC TokenSym *tok_alloc(const char *str, int len);
1088
+ ST_FUNC char *get_tok_str(int v, CValue *cv);
1089
+ ST_FUNC void save_parse_state(ParseState *s);
1090
+ ST_FUNC void restore_parse_state(ParseState *s);
1091
+ ST_INLN void tok_str_new(TokenString *s);
1092
+ ST_FUNC void tok_str_free(int *str);
1093
+ ST_FUNC void tok_str_add(TokenString *s, int t);
1094
+ ST_FUNC void tok_str_add_tok(TokenString *s);
1095
+ ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg);
1096
+ ST_FUNC void define_undef(Sym *s);
1097
+ ST_INLN Sym *define_find(int v);
1098
+ ST_FUNC void free_defines(Sym *b);
1099
+ ST_FUNC Sym *label_find(int v);
1100
+ ST_FUNC Sym *label_push(Sym **ptop, int v, int flags);
1101
+ ST_FUNC void label_pop(Sym **ptop, Sym *slast);
1102
+ ST_FUNC void parse_define(void);
1103
+ ST_FUNC void preprocess(int is_bof);
1104
+ ST_FUNC void next_nomacro(void);
1105
+ ST_FUNC void next(void);
1106
+ ST_INLN void unget_tok(int last_tok);
1107
+ ST_FUNC void preprocess_init(TCCState *s1);
1108
+ ST_FUNC void preprocess_new(void);
1109
+ ST_FUNC int tcc_preprocess(TCCState *s1);
1110
+ ST_FUNC void skip(int c);
1111
+ ST_FUNC void expect(const char *msg);
1112
+
1113
+ /* ------------ tccgen.c ------------ */
1114
+
1115
+ ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */
1116
+ ST_DATA Section *cur_text_section; /* current section where function code is generated */
1117
+ #ifdef CONFIG_TCC_ASM
1118
+ ST_DATA Section *last_text_section; /* to handle .previous asm directive */
1119
+ #endif
1120
+ #ifdef CONFIG_TCC_BCHECK
1121
+ /* bound check related sections */
1122
+ ST_DATA Section *bounds_section; /* contains global data bound description */
1123
+ ST_DATA Section *lbounds_section; /* contains local data bound description */
1124
+ #endif
1125
+ /* symbol sections */
1126
+ ST_DATA Section *symtab_section, *strtab_section;
1127
+ /* debug sections */
1128
+ ST_DATA Section *stab_section, *stabstr_section;
1129
+
1130
+ #define SYM_POOL_NB (8192 / sizeof(Sym))
1131
+ ST_DATA Sym *sym_free_first;
1132
+ ST_DATA void **sym_pools;
1133
+ ST_DATA int nb_sym_pools;
1134
+
1135
+ ST_DATA Sym *global_stack;
1136
+ ST_DATA Sym *local_stack;
1137
+ ST_DATA Sym *local_label_stack;
1138
+ ST_DATA Sym *global_label_stack;
1139
+ ST_DATA Sym *define_stack;
1140
+ ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
1141
+ ST_DATA SValue __vstack[1+/*to make bcheck happy*/ VSTACK_SIZE], *vtop;
1142
+ #define vstack (__vstack + 1)
1143
+ ST_DATA int rsym, anon_sym, ind, loc;
1144
+
1145
+ ST_DATA int const_wanted; /* true if constant wanted */
1146
+ ST_DATA int nocode_wanted; /* true if no code generation wanted for an expression */
1147
+ ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */
1148
+ ST_DATA CType func_vt; /* current function return type (used by return instruction) */
1149
+ ST_DATA int func_vc;
1150
+ ST_DATA int last_line_num, last_ind, func_ind; /* debug last line number and pc */
1151
+ ST_DATA char *funcname;
1152
+
1153
+ ST_INLN int is_float(int t);
1154
+ ST_FUNC int ieee_finite(double d);
1155
+ ST_FUNC void test_lvalue(void);
1156
+ ST_FUNC void swap(int *p, int *q);
1157
+ ST_FUNC void vpushi(int v);
1158
+ ST_FUNC Sym *external_global_sym(int v, CType *type, int r);
1159
+ ST_FUNC void vset(CType *type, int r, int v);
1160
+ ST_FUNC void vswap(void);
1161
+ ST_FUNC void vpush_global_sym(CType *type, int v);
1162
+ ST_FUNC void vrote(SValue *e, int n);
1163
+ ST_FUNC void vrott(int n);
1164
+ ST_FUNC void vrotb(int n);
1165
+ #ifdef TCC_TARGET_ARM
1166
+ ST_FUNC int get_reg_ex(int rc, int rc2);
1167
+ ST_FUNC void lexpand_nr(void);
1168
+ #endif
1169
+ ST_FUNC void vpushv(SValue *v);
1170
+ ST_FUNC void save_reg(int r);
1171
+ ST_FUNC int get_reg(int rc);
1172
+ ST_FUNC void save_regs(int n);
1173
+ ST_FUNC int gv(int rc);
1174
+ ST_FUNC void gv2(int rc1, int rc2);
1175
+ ST_FUNC void vpop(void);
1176
+ ST_FUNC void gen_op(int op);
1177
+ ST_FUNC int type_size(CType *type, int *a);
1178
+ ST_FUNC void mk_pointer(CType *type);
1179
+ ST_FUNC void vstore(void);
1180
+ ST_FUNC void inc(int post, int c);
1181
+ ST_FUNC void parse_asm_str(CString *astr);
1182
+ ST_FUNC int lvalue_type(int t);
1183
+ ST_FUNC void indir(void);
1184
+ ST_FUNC void unary(void);
1185
+ ST_FUNC void expr_prod(void);
1186
+ ST_FUNC void expr_sum(void);
1187
+ ST_FUNC void gexpr(void);
1188
+ ST_FUNC int expr_const(void);
1189
+ ST_FUNC void gen_inline_functions(void);
1190
+ ST_FUNC void decl(int l);
1191
+ #if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_C67
1192
+ ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size);
1193
+ #endif
1194
+
1195
+ /* ------------ tccelf.c ------------ */
1196
+
1197
+ #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */
1198
+ #define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
1199
+ #define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */
1200
+
1201
+ #define ARMAG "!<arch>\012" /* For COFF and a.out archives */
1202
+
1203
+ typedef struct {
1204
+ unsigned int n_strx; /* index into string table of name */
1205
+ unsigned char n_type; /* type of symbol */
1206
+ unsigned char n_other; /* misc info (usually empty) */
1207
+ unsigned short n_desc; /* description field */
1208
+ unsigned int n_value; /* value of symbol */
1209
+ } Stab_Sym;
1210
+
1211
+ ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags);
1212
+
1213
+ ST_FUNC int put_elf_str(Section *s, const char *sym);
1214
+ ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name);
1215
+ ST_FUNC int add_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int sh_num, const char *name);
1216
+ ST_FUNC int find_elf_sym(Section *s, const char *name);
1217
+ ST_FUNC void put_elf_reloc(Section *symtab, Section *s, unsigned long offset, int type, int symbol);
1218
+
1219
+ ST_FUNC void put_stabs(const char *str, int type, int other, int desc, unsigned long value);
1220
+ ST_FUNC void put_stabs_r(const char *str, int type, int other, int desc, unsigned long value, Section *sec, int sym_index);
1221
+ ST_FUNC void put_stabn(int type, int other, int desc, int value);
1222
+ ST_FUNC void put_stabd(int type, int other, int desc);
1223
+
1224
+ ST_FUNC void relocate_common_syms(void);
1225
+ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve);
1226
+ ST_FUNC void relocate_section(TCCState *s1, Section *s);
1227
+
1228
+ ST_FUNC void tcc_add_linker_symbols(TCCState *s1);
1229
+ ST_FUNC int tcc_load_object_file(TCCState *s1, int fd, unsigned long file_offset);
1230
+ ST_FUNC int tcc_load_archive(TCCState *s1, int fd);
1231
+ ST_FUNC void tcc_add_bcheck(TCCState *s1);
1232
+
1233
+ ST_FUNC void build_got_entries(TCCState *s1);
1234
+ ST_FUNC void tcc_add_runtime(TCCState *s1);
1235
+
1236
+ ST_FUNC addr_t get_elf_sym_addr(TCCState *s, const char *name, int err);
1237
+ #ifdef TCC_IS_NATIVE
1238
+ ST_FUNC void *tcc_get_symbol_err(TCCState *s, const char *name);
1239
+ #endif
1240
+
1241
+ #ifndef TCC_TARGET_PE
1242
+ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level);
1243
+ ST_FUNC int tcc_load_ldscript(TCCState *s1);
1244
+ ST_FUNC uint8_t *parse_comment(uint8_t *p);
1245
+ ST_FUNC void minp(void);
1246
+ ST_INLN void inp(void);
1247
+ ST_FUNC int handle_eob(void);
1248
+ #endif
1249
+
1250
+ /* ------------ xxx-gen.c ------------ */
1251
+
1252
+ #ifdef TCC_TARGET_X86_64
1253
+ ST_DATA const int reg_classes[NB_REGS+7];
1254
+ #else
1255
+ ST_DATA const int reg_classes[NB_REGS];
1256
+ #endif
1257
+
1258
+ ST_FUNC void gsym_addr(int t, int a);
1259
+ ST_FUNC void gsym(int t);
1260
+ ST_FUNC void load(int r, SValue *sv);
1261
+ ST_FUNC void store(int r, SValue *v);
1262
+ ST_FUNC void gfunc_call(int nb_args);
1263
+ ST_FUNC void gfunc_prolog(CType *func_type);
1264
+ ST_FUNC void gfunc_epilog(void);
1265
+ ST_FUNC int gjmp(int t);
1266
+ ST_FUNC void gjmp_addr(int a);
1267
+ ST_FUNC int gtst(int inv, int t);
1268
+ ST_FUNC void gen_opi(int op);
1269
+ ST_FUNC void gen_opf(int op);
1270
+ ST_FUNC void gen_cvt_ftoi(int t);
1271
+ ST_FUNC void gen_cvt_ftof(int t);
1272
+ ST_FUNC void ggoto(void);
1273
+ #ifndef TCC_TARGET_C67
1274
+ ST_FUNC void o(unsigned int c);
1275
+ #endif
1276
+ #ifndef TCC_TARGET_ARM
1277
+ ST_FUNC void gen_cvt_itof(int t);
1278
+ #endif
1279
+
1280
+ /* ------------ i386-gen.c ------------ */
1281
+ #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
1282
+ ST_FUNC void g(int c);
1283
+ ST_FUNC int oad(int c, int s);
1284
+ ST_FUNC void gen_le16(int c);
1285
+ ST_FUNC void gen_le32(int c);
1286
+ ST_FUNC void gen_addr32(int r, Sym *sym, int c);
1287
+ ST_FUNC void gen_addrpc32(int r, Sym *sym, int c);
1288
+ #endif
1289
+
1290
+ #ifdef CONFIG_TCC_BCHECK
1291
+ ST_FUNC void gen_bounded_ptr_add(void);
1292
+ ST_FUNC void gen_bounded_ptr_deref(void);
1293
+ #endif
1294
+
1295
+ /* ------------ x86_64-gen.c ------------ */
1296
+ #ifdef TCC_TARGET_X86_64
1297
+ ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c);
1298
+ ST_FUNC void gen_opl(int op);
1299
+ #endif
1300
+
1301
+ /* ------------ arm-gen.c ------------ */
1302
+ #ifdef TCC_TARGET_ARM
1303
+ ST_FUNC void arm_init_types(void);
1304
+ ST_FUNC uint32_t encbranch(int pos, int addr, int fail);
1305
+ ST_FUNC void gen_cvt_itof1(int t);
1306
+ #endif
1307
+
1308
+ /* ------------ c67-gen.c ------------ */
1309
+ #ifdef TCC_TARGET_C67
1310
+ #endif
1311
+
1312
+ /* ------------ tcccoff.c ------------ */
1313
+
1314
+ #ifdef TCC_TARGET_COFF
1315
+ ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f);
1316
+ ST_FUNC int tcc_load_coff(TCCState * s1, int fd);
1317
+ #endif
1318
+
1319
+ /* ------------ tccasm.c ------------ */
1320
+ ST_FUNC void asm_instr(void);
1321
+ ST_FUNC void asm_global_instr(void);
1322
+ #ifdef CONFIG_TCC_ASM
1323
+ ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, const char *name, const char **pp);
1324
+ ST_FUNC void asm_expr(TCCState *s1, ExprValue *pe);
1325
+ ST_FUNC int asm_int_expr(TCCState *s1);
1326
+ ST_FUNC int tcc_assemble(TCCState *s1, int do_preprocess);
1327
+ /* ------------ i386-asm.c ------------ */
1328
+ ST_FUNC void gen_expr32(ExprValue *pe);
1329
+ ST_FUNC void asm_opcode(TCCState *s1, int opcode);
1330
+ ST_FUNC void asm_compute_constraints(ASMOperand *operands, int nb_operands, int nb_outputs, const uint8_t *clobber_regs, int *pout_reg);
1331
+ ST_FUNC void subst_asm_operand(CString *add_str, SValue *sv, int modifier);
1332
+ ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands, int nb_outputs, int is_output, uint8_t *clobber_regs, int out_reg);
1333
+ ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str);
1334
+ #endif
1335
+
1336
+ /* ------------ tccpe.c -------------- */
1337
+ #ifdef TCC_TARGET_PE
1338
+ ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, int fd);
1339
+ ST_FUNC int pe_output_file(TCCState * s1, const char *filename);
1340
+ ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value);
1341
+ ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2);
1342
+ #ifdef TCC_TARGET_X86_64
1343
+ ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack);
1344
+ #endif
1345
+ #endif
1346
+
1347
+ /* ------------ tccrun.c ----------------- */
1348
+ #ifdef TCC_IS_NATIVE
1349
+ #ifdef CONFIG_TCC_STATIC
1350
+ #define RTLD_LAZY 0x001
1351
+ #define RTLD_NOW 0x002
1352
+ #define RTLD_GLOBAL 0x100
1353
+ #define RTLD_DEFAULT NULL
1354
+ /* dummy function for profiling */
1355
+ ST_FUNC void *dlopen(const char *filename, int flag);
1356
+ ST_FUNC void dlclose(void *p);
1357
+ ST_FUNC const char *dlerror(void);
1358
+ ST_FUNC void *resolve_sym(TCCState *s1, const char *symbol);
1359
+ #elif !defined _WIN32
1360
+ ST_FUNC void *resolve_sym(TCCState *s1, const char *symbol);
1361
+ #endif
1362
+
1363
+ #ifdef CONFIG_TCC_BACKTRACE
1364
+ ST_DATA int rt_num_callers;
1365
+ ST_DATA const char **rt_bound_error_msg;
1366
+ ST_DATA void *rt_prog_main;
1367
+ ST_FUNC void tcc_set_num_callers(int n);
1368
+ #endif
1369
+ #endif
1370
+
1371
+ /********************************************************/
1372
+ #undef ST_DATA
1373
+ #ifdef ONE_SOURCE
1374
+ #define ST_DATA static
1375
+ #else
1376
+ #define ST_DATA
1377
+ #endif
1378
+ /********************************************************/
1379
+ #endif /* _TCC_H */