├── lib └── tinycc │ ├── VERSION │ ├── tests │ ├── pp │ │ ├── 04.expect │ │ ├── 06.expect │ │ ├── 07.expect │ │ ├── 09.expect │ │ ├── 08.expect │ │ ├── 13.expect │ │ ├── 01.expect │ │ ├── 16.expect │ │ ├── 22.expect │ │ ├── 07.c │ │ ├── 06.c │ │ ├── 16.c │ │ ├── 10.expect │ │ ├── 18.expect │ │ ├── 04.c │ │ ├── 09.c │ │ ├── 12.expect │ │ ├── 14.expect │ │ ├── 05.expect │ │ ├── 15.expect │ │ ├── 17.expect │ │ ├── 08.c │ │ ├── 20.expect │ │ ├── 21.expect │ │ ├── 13.S │ │ ├── 03.expect │ │ ├── 19.expect │ │ ├── 01.c │ │ ├── 10.c │ │ ├── 11.expect │ │ ├── 22.c │ │ ├── 14.c │ │ ├── 12.S │ │ ├── 05.c │ │ ├── 02.expect │ │ ├── pp-counter.expect │ │ ├── 17.c │ │ ├── 03.c │ │ ├── 15.c │ │ ├── 20.c │ │ ├── 21.c │ │ ├── pp-counter.c │ │ ├── 02.c │ │ ├── 11.c │ │ ├── 18.c │ │ └── Makefile │ ├── tests2 │ │ ├── 129_scopes.expect │ │ ├── 80_flexarray.expect │ │ ├── 81_types.expect │ │ ├── 106_versym.expect │ │ ├── 115_bound_setjmp.expect │ │ ├── 116_bound_setjmp2.expect │ │ ├── 92_enum_bitfield.expect │ │ ├── 100_c99array-decls.expect │ │ ├── 103_implicit_memmove.expect │ │ ├── 107_stack_safe.expect │ │ ├── 110_average.expect │ │ ├── 111_conversion.expect │ │ ├── 122_vla_reuse.expect │ │ ├── 43_void_param.expect │ │ ├── 48_nested_break.expect │ │ ├── 86_memory-model.expect │ │ ├── 132_bound_test.expect │ │ ├── 29_array_address.expect │ │ ├── 35_sizeof.expect │ │ ├── 64_macro_nesting.expect │ │ ├── 71_macro_empty_arg.expect │ │ ├── 84_hex-float.expect │ │ ├── 99_fastcall.expect │ │ ├── 105_local_extern.expect │ │ ├── 133_exec_section_in_c.expect │ │ ├── 85_asm-outside-function.expect │ │ ├── 109_float_struct_calling.expect │ │ ├── 114_bound_signal.expect │ │ ├── 12_hashdefine.expect │ │ ├── 14_if.expect │ │ ├── 27_sizeof.expect │ │ ├── 39_typedef.expect │ │ ├── 42_function_pointer.expect │ │ ├── 55_lshift_type.expect │ │ ├── 82_attribs_position.expect │ │ ├── 00_assignment.expect │ │ ├── 121_struct_return.expect │ │ ├── 44_scoped_declarations.expect │ │ ├── 47_switch_return.expect │ │ ├── 07_function.expect │ │ ├── 49_bracket_evaluation.expect │ │ ├── 88_codeopt.expect │ │ ├── 91_ptr_longlong_arith32.expect │ │ ├── 34_array_assignment.expect │ │ ├── 67_macro_concat.expect │ │ ├── 79_vla_continue.expect │ │ ├── 83_utf8_in_identifiers.expect │ │ ├── 06_case.expect │ │ ├── 108_constructor.expect │ │ ├── 124_atomic_counter.expect │ │ ├── 41_hashif.expect │ │ ├── 72_long_long_constant.expect │ │ ├── 01_comment.expect │ │ ├── 19_pointer_arithmetic.expect │ │ ├── 20_pointer_comparison.expect │ │ ├── 78_vla_label.expect │ │ ├── 17_enum.expect │ │ ├── 18_include2.h │ │ ├── 95_bitfields_ms.c │ │ ├── 130_large_argument.expect │ │ ├── 102_alignas.expect │ │ ├── 13_integer_literals.expect │ │ ├── 04_for.expect │ │ ├── 26_character_constants.expect │ │ ├── 51_static.expect │ │ ├── 05_array.expect │ │ ├── 45_empty_for.expect │ │ ├── 46_grep.expect │ │ ├── 08_while.expect │ │ ├── 09_do_while.expect │ │ ├── 52_unnamed_enum.expect │ │ ├── 77_push_pop_macro.expect │ │ ├── 38_multiple_array_index.expect │ │ ├── 15_recursion.expect │ │ ├── 21_char_array.expect │ │ ├── 31_args.expect │ │ ├── 54_goto.expect │ │ ├── 32_led.expect │ │ ├── 123_vla_bug.expect │ │ ├── 25_quicksort.expect │ │ ├── 97_utf8_string_literal.expect │ │ ├── 03_struct.expect │ │ ├── 18_include.h │ │ ├── 94_generic.expect │ │ ├── 11_precedence.expect │ │ ├── 18_include.expect │ │ ├── 127_asm_goto.expect │ │ ├── 10_pointer.expect │ │ ├── 119_random_stuff.expect │ │ ├── 126_bound_global.expect │ │ ├── 28_strings.expect │ │ ├── 117_builtins.expect │ │ ├── 50_logical_second_arg.expect │ │ ├── 71_macro_empty_arg.c │ │ ├── 33_ternary_op.expect │ │ ├── 98_al_ax_extend.expect │ │ ├── 16_nesting.expect │ │ ├── 23_type_coercion.expect │ │ ├── 89_nocode_wanted.expect │ │ ├── 76_dollars_in_identifiers.expect │ │ ├── 83_utf8_in_identifiers.c │ │ ├── 120_alias.expect │ │ ├── 43_void_param.c │ │ ├── 37_sprintf.expect │ │ ├── 64_macro_nesting.c │ │ ├── 29_array_address.c │ │ ├── 126_bound_global.c │ │ ├── 04_for.c │ │ ├── 128_run_atexit.expect │ │ ├── 24_math_library.expect │ │ ├── 105_local_extern.c │ │ ├── 113_btdll.expect │ │ ├── 35_sizeof.c │ │ ├── 44_scoped_declarations.c │ │ ├── 02_printf.expect │ │ ├── 87_dead_code.expect │ │ ├── 12_hashdefine.c │ │ ├── 85_asm-outside-function.c │ │ ├── 45_empty_for.c │ │ ├── 84_hex-float.c │ │ ├── 00_assignment.c │ │ ├── 67_macro_concat.c │ │ ├── 31_args.c │ │ ├── 37_sprintf.c │ │ ├── 01_comment.c │ │ ├── 107_stack_safe.c │ │ ├── 27_sizeof.c │ │ ├── 36_array_initialisers.expect │ │ ├── 91_ptr_longlong_arith32.c │ │ ├── 111_conversion.c │ │ ├── 08_while.c │ │ ├── 09_do_while.c │ │ ├── 14_if.c │ │ ├── 131_return_struct_in_reg.expect │ │ ├── 108_constructor.c │ │ ├── 15_recursion.c │ │ ├── 16_nesting.c │ │ ├── 05_array.c │ │ ├── 26_character_constants.c │ │ ├── 13_integer_literals.c │ │ ├── 34_array_assignment.c │ │ ├── 47_switch_return.c │ │ ├── 40_stdio.expect │ │ ├── 72_long_long_constant.c │ │ ├── 48_nested_break.c │ │ ├── 02_printf.c │ │ ├── 49_bracket_evaluation.c │ │ ├── 20_pointer_comparison.c │ │ ├── 103_implicit_memmove.c │ │ ├── 106_versym.c │ │ ├── 120+_alias.c │ │ ├── 19_pointer_arithmetic.c │ │ ├── 07_function.c │ │ ├── 110_average.c │ │ ├── 109_float_struct_calling.c │ │ ├── 42_function_pointer.c │ │ ├── 132_bound_test.c │ │ ├── 51_static.c │ │ ├── 52_unnamed_enum.c │ │ ├── 06_case.c │ │ ├── 133_exec_section_in_c.c │ │ ├── 38_multiple_array_index.c │ │ ├── 21_char_array.c │ │ ├── 122_vla_reuse.c │ │ ├── 50_logical_second_arg.c │ │ ├── 80_flexarray.c │ │ ├── 97_utf8_string_literal.c │ │ ├── 113_btdll.c │ │ ├── 36_array_initialisers.c │ │ ├── 77_push_pop_macro.c │ │ ├── 121_struct_return.c │ │ ├── 100_c99array-decls.c │ │ ├── 70_floating_point_literals.expect │ │ ├── 118_switch.expect │ │ ├── 10_pointer.c │ │ ├── 03_struct.c │ │ ├── 24_math_library.c │ │ ├── 96_nodata_wanted.expect │ │ ├── 54_goto.c │ │ ├── 101_cleanup.expect │ │ ├── 123_vla_bug.c │ │ ├── 86_memory-model.c │ │ ├── 11_precedence.c │ │ ├── 78_vla_label.c │ │ ├── 76_dollars_in_identifiers.c │ │ ├── 22_floating_point.expect │ │ ├── 23_type_coercion.c │ │ ├── 130_large_argument.c │ │ ├── 93_integer_promotion.expect │ │ ├── 102_alignas.c │ │ ├── 120_alias.c │ │ ├── 61_integers.expect │ │ ├── 18_include.c │ │ ├── 98_al_ax_extend.c │ │ ├── 129_scopes.c │ │ ├── 28_strings.c │ │ ├── 128_run_atexit.c │ │ ├── 40_stdio.c │ │ ├── 41_hashif.c │ │ ├── 104_inline.expect │ │ ├── 81_types.c │ │ ├── 39_typedef.c │ │ ├── 125_atomic_misc.expect │ │ ├── 75_array_in_struct_init.expect │ │ ├── 131_return_struct_in_reg.c │ │ ├── 17_enum.c │ │ ├── 92_enum_bitfield.c │ │ ├── 127_asm_goto.c │ │ ├── 93_integer_promotion.c │ │ ├── 25_quicksort.c │ │ ├── 55_lshift_type.c │ │ └── 104+_inline.c │ ├── tcctest.h │ ├── 42test.h │ ├── bug.c │ ├── exec_section_in_asm.c │ ├── asm-c-connect-2.c │ └── asm-c-connect-1.c │ ├── win32 │ ├── lib │ │ ├── crt1w.c │ │ ├── wincrt1w.c │ │ ├── dllmain.c │ │ ├── dllcrt1.c │ │ └── crtinit.c │ ├── include │ │ ├── values.h │ │ ├── winapi │ │ │ ├── poppack.h │ │ │ ├── pshpack1.h │ │ │ ├── pshpack2.h │ │ │ ├── pshpack4.h │ │ │ ├── pshpack8.h │ │ │ └── ws2ipdef.h │ │ ├── vadefs.h │ │ ├── mem.h │ │ ├── sys │ │ │ ├── fcntl.h │ │ │ ├── file.h │ │ │ └── locking.h │ │ ├── sec_api │ │ │ ├── crtdbg_s.h │ │ │ ├── sys │ │ │ │ └── timeb_s.h │ │ │ ├── search_s.h │ │ │ ├── stralign_s.h │ │ │ ├── io_s.h │ │ │ └── conio_s.h │ │ ├── iso646.h │ │ ├── share.h │ │ ├── dir.h │ │ ├── uchar.h │ │ ├── dos.h │ │ ├── memory.h │ │ ├── fcntl.h │ │ ├── errno.h │ │ └── signal.h │ └── examples │ │ ├── dll.c │ │ ├── fib.c │ │ └── hello_dll.c │ ├── lib │ ├── dsohandle.c │ ├── armflush.c │ ├── bt-log.c │ └── alloca.S │ ├── examples │ ├── ex5.c │ ├── ex1.c │ ├── ex3.c │ └── ex4.c │ ├── include │ ├── stdnoreturn.h │ ├── stdbool.h │ ├── stdarg.h │ ├── varargs.h │ ├── stdalign.h │ └── stddef.h │ ├── stab.h │ └── .gitignore ├── src ├── GNUmakefile ├── elflinker.h └── io.c ├── docs ├── cjit-logotype.png ├── cjit-mascotte.png ├── cjit-mascotte-card.png ├── demo └── demo.sh ├── test ├── multifile │ ├── myfunc.h │ ├── myfunc.c │ ├── myfunc2.c │ ├── myfunc3.c │ └── main.c ├── hello-bom-utf16-be.c ├── hello-bom-utf16-le.c ├── win_timeb.c ├── bats │ ├── libexec │ │ └── bats-core │ │ │ ├── bats-format-cat │ │ │ └── bats-format-tap │ └── lib │ │ └── bats-core │ │ ├── preprocessing.bash │ │ └── validator.bash ├── test_helper │ ├── bats_file │ │ └── load.bash │ ├── bats_support │ │ ├── load.bash │ │ └── src │ │ │ └── error.bash │ └── bats_assert │ │ ├── src │ │ ├── assert_equal.bash │ │ ├── assert_success.bash │ │ ├── assert_not_equal.bash │ │ ├── assert.bash │ │ └── refute.bash │ │ └── load.bash ├── hello.c ├── hello-bom-utf8.c ├── cargs.c ├── cflags.c ├── bats_setup ├── dmon.bats ├── windows.bats └── dmon.c ├── examples ├── resources │ ├── cubicmap.png │ └── cubicmap_atlas.png ├── tinyc.games │ ├── flappy │ │ ├── bird-0.png │ │ ├── bird-1.png │ │ ├── bird-2.png │ │ ├── bird-3.png │ │ ├── pillar.png │ │ └── background.png │ ├── PixelatedEleganceRegular.ttf │ └── shaders │ │ ├── font.frag │ │ └── font.vert ├── tetris │ └── shaders │ │ ├── main.frag │ │ └── main.vert ├── donut.c └── dmon.c ├── .gitignore ├── .releaserc ├── .editorconfig └── LICENSES ├── MIT-0.txt ├── LLVM-exception.txt ├── MIT.txt └── BSD-2-Clause.txt /lib/tinycc/VERSION: -------------------------------------------------------------------------------- 1 | 0.9.28rc -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/04.expect: -------------------------------------------------------------------------------- 1 | (1) 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/06.expect: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/07.expect: -------------------------------------------------------------------------------- 1 | a 2 | YES 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/09.expect: -------------------------------------------------------------------------------- 1 | aaaaoooo 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/129_scopes.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/80_flexarray.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/81_types.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/106_versym.expect: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/115_bound_setjmp.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/116_bound_setjmp2.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/92_enum_bitfield.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/08.expect: -------------------------------------------------------------------------------- 1 | (hej.s_s.s_pos) 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/13.expect: -------------------------------------------------------------------------------- 1 | .text 2 | endtext: 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/100_c99array-decls.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/103_implicit_memmove.expect: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/107_stack_safe.expect: -------------------------------------------------------------------------------- 1 | 1 2 3 4 -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/110_average.expect: -------------------------------------------------------------------------------- 1 | 15 2 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/111_conversion.expect: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/122_vla_reuse.expect: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/43_void_param.expect: -------------------------------------------------------------------------------- 1 | yo 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/48_nested_break.expect: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/86_memory-model.expect: -------------------------------------------------------------------------------- 1 | Ok 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/01.expect: -------------------------------------------------------------------------------- 1 | char p[] = "x ## y"; 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/132_bound_test.expect: -------------------------------------------------------------------------------- 1 | 42000 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/29_array_address.expect: -------------------------------------------------------------------------------- 1 | bcdef 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/35_sizeof.expect: -------------------------------------------------------------------------------- 1 | 1 1 2 | 2 2 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/64_macro_nesting.expect: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/71_macro_empty_arg.expect: -------------------------------------------------------------------------------- 1 | 17 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/84_hex-float.expect: -------------------------------------------------------------------------------- 1 | n+1 = 15 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/99_fastcall.expect: -------------------------------------------------------------------------------- 1 | TEST OK 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/105_local_extern.expect: -------------------------------------------------------------------------------- 1 | f 2 | f 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/133_exec_section_in_c.expect: -------------------------------------------------------------------------------- 1 | hi 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/85_asm-outside-function.expect: -------------------------------------------------------------------------------- 1 | okay 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/16.expect: -------------------------------------------------------------------------------- 1 | 2 | 16.c:3: warning: A redefined 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/109_float_struct_calling.expect: -------------------------------------------------------------------------------- 1 | 5.000000 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/114_bound_signal.expect: -------------------------------------------------------------------------------- 1 | start 2 | end 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/12_hashdefine.expect: -------------------------------------------------------------------------------- 1 | 12 2 | 12, 24, 36 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/14_if.expect: -------------------------------------------------------------------------------- 1 | a is true 2 | b is false 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/27_sizeof.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 8 4 | 4 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/39_typedef.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 12,34 3 | 12,34 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/42_function_pointer.expect: -------------------------------------------------------------------------------- 1 | yo 24 2 | 42 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/55_lshift_type.expect: -------------------------------------------------------------------------------- 1 | 0 test(s) failed 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/82_attribs_position.expect: -------------------------------------------------------------------------------- 1 | 42 2 | 42 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/22.expect: -------------------------------------------------------------------------------- 1 | A 1 B 2 | X ARG_1 X ARG_2 X ARG_3 X; 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/00_assignment.expect: -------------------------------------------------------------------------------- 1 | 42 2 | 64 3 | 12, 34 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/121_struct_return.expect: -------------------------------------------------------------------------------- 1 | 0 1 2 3 1234 2345 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/44_scoped_declarations.expect: -------------------------------------------------------------------------------- 1 | it's all good 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/47_switch_return.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | out 4 | 3 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/07_function.expect: -------------------------------------------------------------------------------- 1 | 9 2 | 16 3 | a=1234 4 | qfunc() 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/49_bracket_evaluation.expect: -------------------------------------------------------------------------------- 1 | 12.340000, 56.780000 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/88_codeopt.expect: -------------------------------------------------------------------------------- 1 | okay 2 | okay 3 | okay: 42 1 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/91_ptr_longlong_arith32.expect: -------------------------------------------------------------------------------- 1 | data = "0123-5678" 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/07.c: -------------------------------------------------------------------------------- 1 | #define a() YES 2 | #define b() a 3 | b() 4 | b()() 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/34_array_assignment.expect: -------------------------------------------------------------------------------- 1 | 12 23 34 45 2 | 12 23 34 45 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/67_macro_concat.expect: -------------------------------------------------------------------------------- 1 | jim: 21, bob: 42 2 | jim: 63 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/79_vla_continue.expect: -------------------------------------------------------------------------------- 1 | OK 2 | OK 3 | OK 4 | OK 5 | OK 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/83_utf8_in_identifiers.expect: -------------------------------------------------------------------------------- 1 | привет=0.1 2 | Lefèvre=2 3 | -------------------------------------------------------------------------------- /src/GNUmakefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm -f *.o 3 | rm -f embed* 4 | rm -f assets.* 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/06.c: -------------------------------------------------------------------------------- 1 | #define X(a,b, \ 2 | c,d) \ 3 | foo 4 | 5 | X(1,2,3,4) 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/06_case.expect: -------------------------------------------------------------------------------- 1 | 0 2 | 0 3 | 1 4 | 1 5 | 2 6 | 2 7 | 3 8 | 0 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/108_constructor.expect: -------------------------------------------------------------------------------- 1 | constructor 2 | main 3 | destructor 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/124_atomic_counter.expect: -------------------------------------------------------------------------------- 1 | SUCCESS 2 | SUCCESS 3 | SUCCESS 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/41_hashif.expect: -------------------------------------------------------------------------------- 1 | #include test 2 | b 3 | g 4 | i 5 | p 6 | r 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/72_long_long_constant.expect: -------------------------------------------------------------------------------- 1 | long long constant test ok. 2 | -------------------------------------------------------------------------------- /docs/cjit-logotype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/docs/cjit-logotype.png -------------------------------------------------------------------------------- /docs/cjit-mascotte.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/docs/cjit-mascotte.png -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/01_comment.expect: -------------------------------------------------------------------------------- 1 | Hello 2 | Hello 3 | Hello 4 | Hello 5 | Hello 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/19_pointer_arithmetic.expect: -------------------------------------------------------------------------------- 1 | 42 2 | b is not NULL 3 | c is NULL 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/20_pointer_comparison.expect: -------------------------------------------------------------------------------- 1 | 12 2 | 34 3 | 0 4 | 1 5 | 1 6 | 0 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/78_vla_label.expect: -------------------------------------------------------------------------------- 1 | boom! 2 | boom! 3 | 11 4 | 12 5 | 0 6 | 1 7 | -------------------------------------------------------------------------------- /test/multifile/myfunc.h: -------------------------------------------------------------------------------- 1 | int myfunc(void); 2 | int myfunc2(void); 3 | int myfunc3(void); 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/16.c: -------------------------------------------------------------------------------- 1 | /* The following should warn */ 2 | #define A ... 3 | #define A <<= 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/17_enum.expect: -------------------------------------------------------------------------------- 1 | 0 1 2 3 54 73 74 75 2 | 12 3 | 54 4 | enum to int: 1 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/18_include2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | printf ("counter %d\n", __COUNTER__); 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/95_bitfields_ms.c: -------------------------------------------------------------------------------- 1 | #define MS_BITFIELDS 1 2 | #include "95_bitfields.c" 3 | -------------------------------------------------------------------------------- /lib/tinycc/win32/lib/crt1w.c: -------------------------------------------------------------------------------- 1 | #define _UNICODE 1 2 | #define UNICODE 1 3 | #include "crt1.c" 4 | -------------------------------------------------------------------------------- /test/hello-bom-utf16-be.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/test/hello-bom-utf16-be.c -------------------------------------------------------------------------------- /test/hello-bom-utf16-le.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/test/hello-bom-utf16-le.c -------------------------------------------------------------------------------- /docs/cjit-mascotte-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/docs/cjit-mascotte-card.png -------------------------------------------------------------------------------- /lib/tinycc/lib/dsohandle.c: -------------------------------------------------------------------------------- 1 | void * __dso_handle __attribute((visibility("hidden"))) = &__dso_handle; 2 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/10.expect: -------------------------------------------------------------------------------- 1 | x 2 | x x 3 | x x x x 4 | x x x x x x x x 5 | x x x x x x x x)))) 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/18.expect: -------------------------------------------------------------------------------- 1 | X181 1 2 | X182 0 3 | X183 yeah 4 | ABC : a b c 5 | TEST : t e s t 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/130_large_argument.expect: -------------------------------------------------------------------------------- 1 | 1 2 2 | 3 4 5 3 | 13 12 11 10 9 8 7 6 5 4 3 2 1 4 | -------------------------------------------------------------------------------- /lib/tinycc/win32/lib/wincrt1w.c: -------------------------------------------------------------------------------- 1 | #define _UNICODE 1 2 | #define UNICODE 1 3 | #include "wincrt1.c" 4 | -------------------------------------------------------------------------------- /examples/resources/cubicmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/resources/cubicmap.png -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/04.c: -------------------------------------------------------------------------------- 1 | #define foobar 1 2 | #define C(x,y) x##y 3 | #define D(x) (C(x,bar)) 4 | D(foo) 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/102_alignas.expect: -------------------------------------------------------------------------------- 1 | 102_alignas.c:4: warning: type defaults to int 2 | 1 1 1 1 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/13_integer_literals.expect: -------------------------------------------------------------------------------- 1 | 24680 2 | 342391 3 | 2386092 4 | 2386092 5 | 1365 6 | -------------------------------------------------------------------------------- /test/win_timeb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int a; 5 | a=clock(); 6 | } 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/04_for.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/26_character_constants.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 8 3 | 64 4 | 1 5 | 14 6 | 16 7 | 64 8 | test @ 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/51_static.expect: -------------------------------------------------------------------------------- 1 | 1234 2 | 4567 3 | 4568 4 | 4569 5 | 4570 6 | 1234 7 | 8901 8 | 2345 9 | -------------------------------------------------------------------------------- /test/bats/libexec/bats-core/bats-format-cat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | trap '' INT 5 | 6 | cat 7 | -------------------------------------------------------------------------------- /test/multifile/myfunc.c: -------------------------------------------------------------------------------- 1 | int myfunc(void) 2 | { 3 | printf("hello from myfunc\n"); 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/09.c: -------------------------------------------------------------------------------- 1 | #define C(a,b,c) a##b##c 2 | #define N(x,y) C(x,_,y) 3 | #define A_O aaaaoooo 4 | N(A,O) 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/05_array.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 9 4 | 16 5 | 25 6 | 36 7 | 49 8 | 64 9 | 81 10 | 100 11 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/45_empty_for.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/46_grep.expect: -------------------------------------------------------------------------------- 1 | File 46_grep.c: 2 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 3 | 4 | -------------------------------------------------------------------------------- /examples/resources/cubicmap_atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/resources/cubicmap_atlas.png -------------------------------------------------------------------------------- /examples/tinyc.games/flappy/bird-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/flappy/bird-0.png -------------------------------------------------------------------------------- /examples/tinyc.games/flappy/bird-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/flappy/bird-1.png -------------------------------------------------------------------------------- /examples/tinyc.games/flappy/bird-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/flappy/bird-2.png -------------------------------------------------------------------------------- /examples/tinyc.games/flappy/bird-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/flappy/bird-3.png -------------------------------------------------------------------------------- /examples/tinyc.games/flappy/pillar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/flappy/pillar.png -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/12.expect: -------------------------------------------------------------------------------- 1 | 9999: 1: movw (%esi), %bx; .section __ex_table, "a"; .long 9999b, 6001f ; 2 | 6001: 3 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/08_while.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 2 4 | 3 5 | 5 6 | 8 7 | 13 8 | 21 9 | 34 10 | 55 11 | 89 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/14.expect: -------------------------------------------------------------------------------- 1 | return Z(Z(1,2),2); 2 | return Q(1,2); 3 | return ((A + A) * (A + A)) + ((B * B) + (B * B)); 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/09_do_while.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 2 4 | 3 5 | 5 6 | 8 7 | 13 8 | 21 9 | 34 10 | 55 11 | 89 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/52_unnamed_enum.expect: -------------------------------------------------------------------------------- 1 | a=0 2 | b=1 3 | c=2 4 | e=0 5 | f=1 6 | g=2 7 | i=0 8 | j=1 9 | k=2 10 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/77_push_pop_macro.expect: -------------------------------------------------------------------------------- 1 | abort = 111 2 | abort = 222 3 | abort = 333 4 | abort = 222 5 | abort = 111 6 | -------------------------------------------------------------------------------- /examples/tinyc.games/flappy/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/flappy/background.png -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/05.expect: -------------------------------------------------------------------------------- 1 | int j[] = { 123, 45, 67, 89, 2 | 10, 11, 12, }; 3 | int j[] = { 123, 45, 67, 89, 10, 11, 12, }; 4 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/15.expect: -------------------------------------------------------------------------------- 1 | return (long double)d; 2 | return A+++B; 3 | return A+ ++B; 4 | return A+++ +B; 5 | return 0x1E -1; 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/38_multiple_array_index.expect: -------------------------------------------------------------------------------- 1 | x=0: 1 2 3 4 2 | x=1: 5 6 7 8 3 | x=2: 9 10 11 12 4 | x=3: 13 14 15 16 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/15_recursion.expect: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 6 4 | 24 5 | 120 6 | 720 7 | 5040 8 | 40320 9 | 362880 10 | 3628800 11 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/21_char_array.expect: -------------------------------------------------------------------------------- 1 | hello 2 | h: 104 3 | e: 101 4 | l: 108 5 | l: 108 6 | o: 111 7 | copied string is hello 8 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/31_args.expect: -------------------------------------------------------------------------------- 1 | hello world 6 2 | arg 1: arg1 3 | arg 2: arg2 4 | arg 3: arg3 5 | arg 4: arg4 6 | arg 5: arg5 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/54_goto.expect: -------------------------------------------------------------------------------- 1 | In fred() 2 | At end 3 | In joe() 4 | c = 1234 5 | done 6 | In henry() 7 | b = 1234 8 | done 9 | -------------------------------------------------------------------------------- /examples/tinyc.games/PixelatedEleganceRegular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dyne/cjit/HEAD/examples/tinyc.games/PixelatedEleganceRegular.ttf -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/17.expect: -------------------------------------------------------------------------------- 1 | X162 "onetok" 2 | X161 "onetok" 3 | X163 "one##tok" 4 | X170 x ## y 5 | X171 x ## y 6 | X180 return Z(Z(1)); 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/32_led.expect: -------------------------------------------------------------------------------- 1 | _ _ _ _ 2 | | _| _| |_| |_ |_ | 3 | | |_ _| | _| |_| | 4 | 5 | -------------------------------------------------------------------------------- /test/multifile/myfunc2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int myfunc2(void) 3 | { 4 | printf("hello from myfunc2\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/08.c: -------------------------------------------------------------------------------- 1 | // test macro expansion in arguments 2 | #define s_pos s_s.s_pos 3 | #define foo(x) (x) 4 | foo(hej.s_pos) 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/123_vla_bug.expect: -------------------------------------------------------------------------------- 1 | default: i = 0 2 | reached 3 3 | after do_cmddefault: i = 2 4 | default: i = 3 5 | default: i = 4 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/25_quicksort.expect: -------------------------------------------------------------------------------- 1 | 62 83 4 89 36 21 74 37 65 33 96 38 53 16 74 55 2 | 4 16 21 33 36 37 38 53 55 62 65 74 74 83 89 96 3 | -------------------------------------------------------------------------------- /test/multifile/myfunc3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int myfunc3(void) 4 | { 5 | printf("hello from myfunc3\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/test_helper/bats_file/load.bash: -------------------------------------------------------------------------------- 1 | source "$(dirname "${BASH_SOURCE[0]}")/src/file.bash" 2 | source "$(dirname "${BASH_SOURCE[0]}")/src/temp.bash" 3 | -------------------------------------------------------------------------------- /lib/tinycc/examples/ex5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | printf("Hello World\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/97_utf8_string_literal.expect: -------------------------------------------------------------------------------- 1 | 0068 0065 006C 006C 006F 0024 0024 4F60 597D 00A2 00A2 4E16 754C 20AC 20AC 0077 006F 0072 006C 0064 2 | -------------------------------------------------------------------------------- /lib/tinycc/examples/ex1.c: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/tcc -run 2 | #include 3 | 4 | int main() 5 | { 6 | printf("Hello World\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/03_struct.expect: -------------------------------------------------------------------------------- 1 | 03_struct.c:14: warning: attribute '__cleanup__' ignored on type 2 | 12 3 | 34 4 | 12 5 | 34 6 | 56 7 | 78 8 | ~fred() 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/18_include.h: -------------------------------------------------------------------------------- 1 | printf("included\n"); 2 | /* test file with missing newline */ 3 | #ifndef INCLUDE 4 | #define INCLUDE 5 | #endif /* INCLUDE */ -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/94_generic.expect: -------------------------------------------------------------------------------- 1 | 20 2 | 10 3 | 20 4 | 123 5 | 2 6 | 0 7 | 5 8 | 1 9 | 2 10 | 3 11 | 4 12 | long 13 | 1 14 | 3 15 | 5 16 | 1 17 | -------------------------------------------------------------------------------- /test/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char **argv) { 5 | fprintf(stdout,"Hello World!"); 6 | return(0); 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cjit 2 | *.o 3 | src/assets.* 4 | src/embed_* 5 | .build_done* 6 | dl 7 | cjit.res 8 | cjit.rc 9 | cjit_source 10 | pristine 11 | cjit-demo* 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/20.expect: -------------------------------------------------------------------------------- 1 | X1 printk(KERN_WARNING "pipapo",bla); 2 | X2 printk(KERN_WARNING "bla",foo); 3 | X2 twoopq 4 | X3 otwopq 5 | X4 optwoq 6 | X5 opqtwo 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/11_precedence.expect: -------------------------------------------------------------------------------- 1 | 134 2 | 134 3 | 0 4 | 1 5 | 1 6 | 1 7 | 1 8 | 46 9 | 1, 0 10 | 0, 1 11 | 1 12 | 1916 13 | 1916 14 | 64 15 | 4 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/18_include.expect: -------------------------------------------------------------------------------- 1 | including 2 | included 3 | done 4 | has_include 5 | has_include 6 | has_include_next 7 | has_include_next 8 | counter 0 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/127_asm_goto.expect: -------------------------------------------------------------------------------- 1 | simple_jump: okay 2 | another_jump: okay 3 | three_way_jump(0): okay 4 | three_way_jump(1): okay 5 | three_way_jump(-1): okay 6 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/values.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TODO: Nothing here yet. Should provide UNIX compatibility constants 3 | * comparable to those in limits.h and float.h. 4 | */ 5 | -------------------------------------------------------------------------------- /test/hello-bom-utf8.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char **argv) { 5 | fprintf(stderr,"Hello World!\n"); 6 | return(0); 7 | } 8 | -------------------------------------------------------------------------------- /examples/tetris/shaders/main.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec3 color2; 3 | 4 | out vec4 color; 5 | 6 | void main() 7 | { 8 | color = vec4(color2.xyz, 1.0); 9 | } 10 | -------------------------------------------------------------------------------- /lib/tinycc/include/stdnoreturn.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDNORETURN_H 2 | #define _STDNORETURN_H 3 | 4 | /* ISOC11 noreturn */ 5 | #define noreturn _Noreturn 6 | 7 | #endif /* _STDNORETURN_H */ 8 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/21.expect: -------------------------------------------------------------------------------- 1 | ----- 1 ------ 2 | OK 3 | ----- 2 ------ 4 | OK 5 | ----- 3 ------ 6 | OK 7 | ----- 4 ------ 8 | OK 9 | ----- 5 ------ 10 | line 39 11 | line ## 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/10_pointer.expect: -------------------------------------------------------------------------------- 1 | a = 42 2 | bolshevic.a = 12 3 | bolshevic.b = 34 4 | bolshevic.c = 56 5 | tsar->a = 12 6 | tsar->b = 34 7 | tsar->c = 56 8 | bolshevic.b = 34 9 | -------------------------------------------------------------------------------- /test/cargs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main (int n, char** args) { 4 | for(int i=0; i 2 | #include "myfunc.h" 3 | 4 | 5 | 6 | int main(void) 7 | { 8 | myfunc(); 9 | myfunc2(); 10 | myfunc3(); 11 | return 0; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/19.expect: -------------------------------------------------------------------------------- 1 | X92 M_IFI_1 2 | X93 KO 3 | X94 KO 4 | X95 a 5 | X96 M_IFI_1 6 | X97 ok 7 | X98 (1)(ok, nok) 8 | X99 ok 9 | X1 ok 10 | X2 1 11 | X3 ok 12 | X4 1 13 | X5 nok 14 | X6 ok 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/01.c: -------------------------------------------------------------------------------- 1 | #define hash_hash # ## # 2 | #define mkstr(a) # a 3 | #define in_between(a) mkstr(a) 4 | #define join(c, d) in_between(c hash_hash d) 5 | char p[] = join(x, y); 6 | // char p[] = "x ## y"; 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/117_builtins.expect: -------------------------------------------------------------------------------- 1 | BOUNDS OFF: 2 | 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:1 10:1 11:1 12:1 13:1 14:1 15:1 3 | BOUNDS ON: 4 | 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:1 10:1 11:1 12:1 13:1 14:1 15:1 5 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/10.c: -------------------------------------------------------------------------------- 1 | #define f(x) x 2 | #define g(x) f(x) f(x 3 | #define i(x) g(x)) g(x 4 | #define h(x) i(x))) i(x 5 | #define k(x) i(x))) i(x)))) 6 | f(x) 7 | g(x)) 8 | i(x))) 9 | h(x)))) 10 | k(x)))) 11 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/50_logical_second_arg.expect: -------------------------------------------------------------------------------- 1 | fred 2 | 0 3 | fred 4 | joe 5 | 1 6 | joe 7 | fred 8 | 0 9 | joe 10 | 1 11 | fred 12 | 0 13 | fred 14 | joe 15 | 1 16 | joe 17 | fred 18 | 0 19 | joe 20 | 1 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/71_macro_empty_arg.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define T(a,b,c) a b c 4 | 5 | int main(void) 6 | { 7 | printf("%d", T(1,+,2) T(+,,) T(,2,*) T(,7,) T(,,)); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/33_ternary_op.expect: -------------------------------------------------------------------------------- 1 | 33_ternary_op.c:26: warning: pointer/integer mismatch in conditional expression 2 | 0 3 | 1 4 | 4 5 | 9 6 | 16 7 | 15 8 | 18 9 | 21 10 | 24 11 | 27 12 | 152 13 | okay 14 | 1 15 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | { 2 | "repositoryUrl": "git@github.com:dyne/cjit.git", 3 | "plugins": [ 4 | "@semantic-release/commit-analyzer", 5 | "@semantic-release/release-notes-generator", 6 | "@semantic-release/changelog" 7 | ] 8 | } -------------------------------------------------------------------------------- /lib/tinycc/tests/tcctest.h: -------------------------------------------------------------------------------- 1 | static inline const char *get_basefile_from_header(void) 2 | { 3 | return __BASE_FILE__; 4 | } 5 | 6 | static inline const char *get_file_from_header(void) 7 | { 8 | return __FILE__; 9 | } 10 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/98_al_ax_extend.expect: -------------------------------------------------------------------------------- 1 | 0000ABCE 0000ABCE 2 | FFFFABCE FFFFABCE 3 | 000000CE 000000CE 4 | FFFFFFCE FFFFFFCE 5 | 6 | 0000ABCE 0000ABCE 7 | FFFFABCE FFFFABCE 8 | 000000CE 000000CE 9 | FFFFFFCE FFFFFFCE 10 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/11.expect: -------------------------------------------------------------------------------- 1 | a 2 | a b 3 | a b c 4 | a b c d 5 | x a b c d y 6 | x a b c y 7 | x a b y 8 | x a y 9 | x y 10 | x A,B,C y 11 | x A,B y 12 | x A y 13 | x y 14 | __attribute__((__noreturn__)) 15 | 1 2 16 | D_B_D_A 17 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/16_nesting.expect: -------------------------------------------------------------------------------- 1 | 0 0 0 2 | 0 0 1 3 | 0 0 2 4 | 0 1 0 5 | 0 1 1 6 | 0 1 2 7 | 0 2 0 8 | 0 2 1 9 | 0 2 2 10 | 1 0 0 11 | 1 0 1 12 | 1 0 2 13 | 1 1 0 14 | 1 1 1 15 | 1 1 2 16 | 1 2 0 17 | 1 2 1 18 | 1 2 2 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/23_type_coercion.expect: -------------------------------------------------------------------------------- 1 | char: a 2 | char: b 3 | char: c 4 | int: 97 5 | int: 98 6 | int: 99 7 | float: 97.000000 8 | float: 98.000000 9 | float: 99.000000 10 | 97 97 11 | 97 97 12 | 97.000000 97.000000 13 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/89_nocode_wanted.expect: -------------------------------------------------------------------------------- 1 | begin 2 | timeout=2 3 | timeout=1 4 | timeout=2 5 | timeout=1 6 | timeout=2 7 | timeout=1 8 | timeout=2 9 | timeout=1 10 | timeout=2 11 | timeout=1 12 | timeout=2 13 | timeout=1 14 | end 15 | -------------------------------------------------------------------------------- /examples/tinyc.games/shaders/font.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec2 uv; 3 | out vec4 color; 4 | 5 | uniform vec3 incolor; 6 | uniform sampler2D tex; 7 | 8 | void main() 9 | { 10 | color = vec4(incolor, texture(tex, uv).r); 11 | } 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/22.c: -------------------------------------------------------------------------------- 1 | #define TRACE(a,b,c) X a X b X c X 2 | #define rettrue(x) 1 3 | A rettrue(bla) B 4 | TRACE( 5 | ARG_1, 6 | #if rettrue(bla) 7 | ARG_2, 8 | #else 9 | ARG_2_wrong, 10 | #endif 11 | ARG_3 12 | ); 13 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/76_dollars_in_identifiers.expect: -------------------------------------------------------------------------------- 1 | fred=10 2 | joe=20 3 | henry=30 4 | fred2=10 5 | joe2=20 6 | henry2=30 7 | fred10=100 8 | joe_10=2 9 | local=10 10 | a100$=100 11 | a$$=1000 12 | a$c$b=2121 13 | $100=10000 14 | $$$=money 15 | -------------------------------------------------------------------------------- /examples/tinyc.games/shaders/font.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec4 pos; 3 | out vec2 uv; 4 | 5 | uniform mat4 proj; 6 | 7 | void main() 8 | { 9 | gl_Position = proj * vec4(pos.xy, 0.0, 1.0); 10 | uv = pos.zw; 11 | } 12 | -------------------------------------------------------------------------------- /lib/tinycc/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDBOOL_H 2 | #define _STDBOOL_H 3 | 4 | /* ISOC99 boolean */ 5 | 6 | #define bool _Bool 7 | #define true 1 8 | #define false 0 9 | #define __bool_true_false_are_defined 1 10 | 11 | #endif /* _STDBOOL_H */ 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/83_utf8_in_identifiers.c: -------------------------------------------------------------------------------- 1 | #include 2 | double привет=0.1; 3 | int Lefèvre=2; 4 | int main(){ 5 | printf("привет=%g\n",привет); 6 | printf("Lefèvre=%d\n",Lefèvre); 7 | return 0; 8 | } 9 | // pcc & tcc only 10 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/14.c: -------------------------------------------------------------------------------- 1 | #define W Z 2 | #define Z(X) W(X,2) 3 | #define Y(X) Z(X) 4 | #define X Y 5 | return X(X(1)); 6 | 7 | #define P Q 8 | #define Q(n) P(n,2) 9 | return P(1); 10 | 11 | #define A (B * B) 12 | #define B (A + A) 13 | return A + B; 14 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/120_alias.expect: -------------------------------------------------------------------------------- 1 | in target function 2 | in target function 3 | in target function 4 | g_int = 34 5 | alias_int = 34 6 | asm_int = 34 7 | in unit2: 8 | in target function 9 | in target function 10 | g_int = 34 11 | alias_int = 34 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/43_void_param.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void fred(void) 4 | { 5 | printf("yo\n"); 6 | } 7 | 8 | int main() 9 | { 10 | fred(); 11 | 12 | return 0; 13 | } 14 | 15 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 16 | -------------------------------------------------------------------------------- /lib/tinycc/win32/lib/dllmain.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | 3 | #include 4 | 5 | BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) 6 | { 7 | return TRUE; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/12.S: -------------------------------------------------------------------------------- 1 | #define SRC(y...) \ 2 | 9999: y; \ 3 | .section __ex_table, "a"; \ 4 | .long 9999b, 6001f ; \ 5 | // .previous 6 | 7 | SRC(1: movw (%esi), %bx) 8 | 6001: 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/37_sprintf.expect: -------------------------------------------------------------------------------- 1 | ->01<- 2 | ->02<- 3 | ->03<- 4 | ->04<- 5 | ->05<- 6 | ->06<- 7 | ->07<- 8 | ->08<- 9 | ->09<- 10 | ->10<- 11 | ->11<- 12 | ->12<- 13 | ->13<- 14 | ->14<- 15 | ->15<- 16 | ->16<- 17 | ->17<- 18 | ->18<- 19 | ->19<- 20 | ->20<- 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/05.c: -------------------------------------------------------------------------------- 1 | #define t(x,y,z) x ## y ## z 2 | #define xxx(s) int s[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), \ 3 | t(10,,), t(,11,), t(,,12), t(,,) }; 4 | 5 | int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), 6 | t(10,,), t(,11,), t(,,12), t(,,) }; 7 | xxx(j) 8 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/64_macro_nesting.c: -------------------------------------------------------------------------------- 1 | #include // printf() 2 | 3 | #define CAT2(a,b) a##b 4 | #define CAT(a,b) CAT2(a,b) 5 | #define AB(x) CAT(x,y) 6 | 7 | int main(void) 8 | { 9 | int xy = 42; 10 | printf("%d\n", CAT(A,B)(x)); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/29_array_address.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char a[10]; 7 | strcpy(a, "abcdef"); 8 | printf("%s\n", &a[1]); 9 | 10 | return 0; 11 | } 12 | 13 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 14 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/126_bound_global.c: -------------------------------------------------------------------------------- 1 | /* test bound checking code without -run */ 2 | 3 | int arr[10]; 4 | 5 | int 6 | main(int argc, char **argv) 7 | { 8 | int i; 9 | 10 | for (i = 0; i <= sizeof(arr)/sizeof(arr[0]); i++) 11 | arr[i] = 0; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/04_for.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int Count; 6 | 7 | for (Count = 1; Count <= 10; Count++) 8 | { 9 | printf("%d\n", Count); 10 | } 11 | 12 | return 0; 13 | } 14 | 15 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/128_run_atexit.expect: -------------------------------------------------------------------------------- 1 | [test_128_return] 2 | startup5 3 | cleanup5 4 | 1 cleanup4 5 | 1 cleanup3 6 | cleanup2 7 | cleanup1 8 | [returns 1] 9 | 10 | [test_128_exit] 11 | startup5 12 | cleanup5 13 | 2 cleanup4 14 | 2 cleanup3 15 | cleanup2 16 | cleanup1 17 | [returns 2] 18 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/24_math_library.expect: -------------------------------------------------------------------------------- 1 | 0.119712 2 | 0.992809 3 | 0.120579 4 | 0.120290 5 | 1.450506 6 | 0.119429 7 | 0.120288 8 | 1.007209 9 | 0.119427 10 | 1.127497 11 | 0.120000 12 | -2.120264 13 | -0.920819 14 | 0.775357 15 | 0.346410 16 | 12.000000 17 | 13.000000 18 | 12.000000 19 | -------------------------------------------------------------------------------- /examples/tetris/shaders/main.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec2 pos; 3 | layout (location = 1) in vec3 color; 4 | 5 | out vec3 color2; 6 | 7 | uniform mat4 proj; 8 | 9 | void main() 10 | { 11 | gl_Position = proj * vec4(pos.xy, 0.0, 1.0); 12 | color2 = color; 13 | } 14 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/105_local_extern.c: -------------------------------------------------------------------------------- 1 | extern int printf(const char *, ...); 2 | void f(void); 3 | void bar(void) { void f(void); f(); } 4 | void foo(void) { extern void f(void); f(); } 5 | void f(void) { printf("f\n"); } 6 | 7 | int main() 8 | { 9 | bar(); 10 | foo(); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/113_btdll.expect: -------------------------------------------------------------------------------- 1 | 113_btdll.c:12: at f_1: hello from f_1() / 113_btdll.c:12 2 | 113_btdll.c:37: by main 3 | 113_btdll.c:20: at f_2: hello from f_2() / 113_btdll.c:20 4 | 113_btdll.c:38: by main 5 | 113_btdll.c:31: at f_main: hello from f_main() / 113_btdll.c:31 6 | 113_btdll.c:39: by main 7 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/02.expect: -------------------------------------------------------------------------------- 1 | f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); 2 | f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); 3 | char c[2][6] = { "hello", "" }; 4 | f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); 5 | f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); 6 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/35_sizeof.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char a; 6 | short b; 7 | 8 | printf("%d %d\n", sizeof(char), sizeof(a)); 9 | printf("%d %d\n", sizeof(short), sizeof(b)); 10 | 11 | return 0; 12 | } 13 | 14 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/44_scoped_declarations.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | 7 | for (a = 0; a < 2; a++) 8 | { 9 | int b = a; 10 | } 11 | 12 | printf("it's all good\n"); 13 | 14 | return 0; 15 | } 16 | 17 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 18 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/02_printf.expect: -------------------------------------------------------------------------------- 1 | Hello world 2 | Count = -5 3 | Count = -4 4 | Count = -3 5 | Count = -2 6 | Count = -1 7 | Count = 0 8 | Count = 1 9 | Count = 2 10 | Count = 3 11 | Count = 4 12 | Count = 5 13 | String 'hello', 'there' is 'hello', 'there' 14 | Character 'A' is 'A' 15 | Character 'a' is 'a' 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/87_dead_code.expect: -------------------------------------------------------------------------------- 1 | timeout=2 2 | timeout=1 3 | boo 4 | yeah 5 | twice 6 | once 7 | twice 8 | SEtwice 9 | SEonce 10 | SEtwice 11 | twice2 12 | once2 13 | twice2 14 | twice3 15 | once3 16 | twice3 17 | caseok 18 | caseok2 19 | g=1 20 | check 1 21 | g=2 22 | check 2 23 | g=3 24 | nondead works 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/12_hashdefine.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define FRED 12 4 | #define BLOGGS(x) (12*(x)) 5 | 6 | int main() 7 | { 8 | printf("%d\n", FRED); 9 | printf("%d, %d, %d\n", BLOGGS(1), BLOGGS(2), BLOGGS(3)); 10 | 11 | return 0; 12 | } 13 | 14 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/85_asm-outside-function.c: -------------------------------------------------------------------------------- 1 | #ifdef __leading_underscore 2 | # define _ "_" 3 | #else 4 | # define _ 5 | #endif 6 | 7 | extern int printf (const char *, ...); 8 | extern void vide(void); 9 | __asm__(_"vide: ret"); 10 | 11 | int main() { 12 | vide(); 13 | printf ("okay\n"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/45_empty_for.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int Count = 0; 6 | 7 | for (;;) 8 | { 9 | Count++; 10 | printf("%d\n", Count); 11 | if (Count >= 10) 12 | break; 13 | } 14 | 15 | return 0; 16 | } 17 | 18 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/pp-counter.expect: -------------------------------------------------------------------------------- 1 | X1 0 2 | X2 1 3 | X3 3 4 | X4 x 4 y 5 | X5 x 5 y 6 6 | X6 b 7 7 | X7 8 9 8 | X8 x 10 y x 10 y 11 x2 x 10 y 12 y2 13 9 | X9 x 14 y 15 x 14 y 15 16 x2 x 14 y 15 17 y2 18 10 | X10 19 19 20 x2 19 21 y2 22 11 | X11 23 23 24 x2 23 25 y2 26 12 | X12 "__COUNTER__" 13 | X13 x27 14 | X14 x__COUNTER__ 15 | X15 x2828 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/84_hex-float.c: -------------------------------------------------------------------------------- 1 | extern int printf(const char *format, ...); 2 | 3 | #define ACPI_TYPE_INVALID 0x1E 4 | #define NUM_NS_TYPES ACPI_TYPE_INVALID+1 5 | int array[NUM_NS_TYPES]; 6 | 7 | #define n 0xe 8 | int main() 9 | { 10 | printf("n+1 = %d\n", n+1); 11 | // printf("n+1 = %d\n", 0xe+1); 12 | } 13 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/winapi/poppack.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(pop) 8 | #endif 9 | -------------------------------------------------------------------------------- /lib/tinycc/stab.h: -------------------------------------------------------------------------------- 1 | #ifndef __GNU_STAB__ 2 | 3 | /* Indicate the GNU stab.h is in use. */ 4 | 5 | #define __GNU_STAB__ 6 | 7 | #define __define_stab(NAME, CODE, STRING) NAME=CODE, 8 | 9 | enum __stab_debug_code 10 | { 11 | #include "stab.def" 12 | LAST_UNUSED_STAB_CODE 13 | }; 14 | 15 | #undef __define_stab 16 | 17 | #endif /* __GNU_STAB_ */ 18 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/00_assignment.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | a = 42; 7 | printf("%d\n", a); 8 | 9 | int b = 64; 10 | printf("%d\n", b); 11 | 12 | int c = 12, d = 34; 13 | printf("%d, %d\n", c, d); 14 | 15 | return 0; 16 | } 17 | 18 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/67_macro_concat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define P(A,B) A ## B ; bob 4 | #define Q(A,B) A ## B+ 5 | 6 | int main(void) 7 | { 8 | int bob, jim = 21; 9 | bob = P(jim,) *= 2; 10 | printf("jim: %d, bob: %d\n", jim, bob); 11 | jim = 60 Q(+,)3; 12 | printf("jim: %d\n", jim); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/winapi/pshpack1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(push,1) 8 | #endif 9 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/winapi/pshpack2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(push,2) 8 | #endif 9 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/winapi/pshpack4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(push,4) 8 | #endif 9 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/winapi/pshpack8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(push,8) 8 | #endif 9 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/31_args.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | int Count; 6 | 7 | printf("hello world %d\n", argc); 8 | for (Count = 1; Count < argc; Count++) 9 | printf("arg %d: %s\n", Count, argv[Count]); 10 | 11 | return 0; 12 | } 13 | 14 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/37_sprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char Buf[100]; 6 | int Count; 7 | 8 | for (Count = 1; Count <= 20; Count++) 9 | { 10 | sprintf(Buf, "->%02d<-\n", Count); 11 | printf("%s", Buf); 12 | } 13 | 14 | return 0; 15 | } 16 | 17 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 18 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/01_comment.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("Hello\n"); 6 | printf("Hello\n"); /* this is a comment */ printf("Hello\n"); 7 | printf("Hello\n"); 8 | // this is also a comment sayhello(); 9 | printf("Hello\n"); 10 | 11 | return 0; 12 | } 13 | 14 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/107_stack_safe.c: -------------------------------------------------------------------------------- 1 | extern int printf(const char *, ...); 2 | 3 | static void func_ull_ull(unsigned long long l1,unsigned long long l2){ 4 | } 5 | 6 | int main() 7 | { 8 | int a,b,c,d; 9 | a=1;b=2;c=3;d=4; 10 | func_ull_ull((unsigned long long)a/1.0,(unsigned long long)b/1.0); 11 | printf("%d %d %d %d",a,b,c,d); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/27_sizeof.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char a; 6 | int b; 7 | double c; 8 | 9 | printf("%d\n", sizeof(a)); 10 | printf("%d\n", sizeof(b)); 11 | printf("%d\n", sizeof(c)); 12 | 13 | printf("%d\n", sizeof(!a)); 14 | 15 | return 0; 16 | } 17 | 18 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/17.c: -------------------------------------------------------------------------------- 1 | #define STR1(u) # u 2 | #define pass(a) a 3 | #define __ASM_REG(reg) STR1(one##reg) 4 | #define _ASM_DX __ASM_REG(tok) 5 | X162 pass(__ASM_REG(tok)) 6 | X161 pass(_ASM_DX) 7 | X163 pass(STR1(one##tok)) 8 | 9 | X170 pass(x ## y) 10 | X171 pass(x pass(##) y) 11 | 12 | #define Y(x) Z(x) 13 | #define X Y 14 | X180 return X(X(1)); 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/36_array_initialisers.expect: -------------------------------------------------------------------------------- 1 | 0: 12 2 | 1: 34 3 | 2: 56 4 | 3: 78 5 | 4: 90 6 | 5: 123 7 | 6: 456 8 | 7: 789 9 | 8: 8642 10 | 9: 9753 11 | 0: 12 12 | 1: 34 13 | 2: 56 14 | 3: 78 15 | 4: 90 16 | 5: 123 17 | 6: 456 18 | 7: 789 19 | 8: 8642 20 | 9: 9753 21 | 0: 12 22 | 1: 34 23 | 2: 0 24 | 3: 0 25 | 4: 0 26 | 5: 0 27 | 6: 0 28 | 7: 0 29 | 8: 0 30 | 9: 0 31 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/91_ptr_longlong_arith32.c: -------------------------------------------------------------------------------- 1 | int printf(const char *, ...); 2 | char t[] = "012345678"; 3 | 4 | int main(void) 5 | { 6 | char *data = t; 7 | unsigned long long r = 4; 8 | unsigned a = 5; 9 | unsigned long long b = 12; 10 | 11 | *(unsigned*)(data + r) += a - b; 12 | 13 | printf("data = \"%s\"\n", data); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/vadefs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_VADEFS 7 | #define _INC_VADEFS 8 | 9 | //!__TINYC__: GNUC specific stuff removed 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/111_conversion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | union u { 4 | unsigned long ul; 5 | long double ld; 6 | }; 7 | 8 | void 9 | conv (union u *p) 10 | { 11 | p->ul = (unsigned int) p->ld; 12 | } 13 | 14 | int main (void) 15 | { 16 | union u v; 17 | 18 | v.ld = 42; 19 | conv (&v); 20 | printf ("%lu\n", v.ul); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/08_while.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | int p; 7 | int t; 8 | 9 | a = 1; 10 | p = 0; 11 | t = 0; 12 | 13 | while (a < 100) 14 | { 15 | printf("%d\n", a); 16 | t = a; 17 | a = t + p; 18 | p = t; 19 | } 20 | 21 | return 0; 22 | } 23 | 24 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/09_do_while.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | int p; 7 | int t; 8 | 9 | a = 1; 10 | p = 0; 11 | t = 0; 12 | 13 | do 14 | { 15 | printf("%d\n", a); 16 | t = a; 17 | a = t + p; 18 | p = t; 19 | } while (a < 100); 20 | 21 | return 0; 22 | } 23 | 24 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/14_if.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a = 1; 6 | 7 | if (a) 8 | printf("a is true\n"); 9 | else 10 | printf("a is false\n"); 11 | 12 | int b = 0; 13 | if (b) 14 | printf("b is true\n"); 15 | else 16 | printf("b is false\n"); 17 | 18 | return 0; 19 | } 20 | 21 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 22 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/131_return_struct_in_reg.expect: -------------------------------------------------------------------------------- 1 | 05 0a 2 | 12 34 3 | 1245 5678 4 | 12345678 9abcdef0 5 | 123456789abcdef0 fedcba9876543210 6 | 1.0 2.0 3.0 4.0 7 | 8 | 05 0a 9 | 12 34 10 | 1245 5678 11 | 12345678 9abcdef0 12 | 123456789abcdef0 fedcba9876543210 13 | 1.0 2.0 3.0 4.0 14 | 15 | 05 0a 16 | 12 34 17 | 1245 5678 18 | 12345678 9abcdef0 19 | 123456789abcdef0 fedcba9876543210 20 | 1.0 2.0 3.0 4.0 21 | -------------------------------------------------------------------------------- /lib/tinycc/include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDARG_H 2 | #define _STDARG_H 3 | 4 | typedef __builtin_va_list va_list; 5 | #define va_start __builtin_va_start 6 | #define va_arg __builtin_va_arg 7 | #define va_copy __builtin_va_copy 8 | #define va_end __builtin_va_end 9 | 10 | /* fix a buggy dependency on GCC in libio.h */ 11 | typedef va_list __gnuc_va_list; 12 | #define _VA_LIST_DEFINED 13 | 14 | #endif /* _STDARG_H */ 15 | -------------------------------------------------------------------------------- /test/cflags.c: -------------------------------------------------------------------------------- 1 | /* Test CFLAGS env parsing 2 | * run me successfully only with: 3 | * CFLAGS="-DALLOWED=1" cjit test/cflags.c 4 | */ 5 | 6 | #if !defined(ALLOWED) || (ALLOWED != 1) 7 | 8 | #error Running this program is not allowed. Please compile with -DALLOWED=1 9 | 10 | #else 11 | 12 | #include 13 | 14 | int main(void) 15 | { 16 | printf("Success."); 17 | return 0; 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/108_constructor.c: -------------------------------------------------------------------------------- 1 | extern int write (int fd, void *buf, int len); 2 | 3 | static void __attribute__ ((constructor)) 4 | testc (void) 5 | { 6 | write (1, "constructor\n", 12); 7 | } 8 | 9 | static void __attribute__ ((destructor)) 10 | testd (void) 11 | { 12 | write (1, "destructor\n", 11); 13 | } 14 | 15 | int 16 | main (void) 17 | { 18 | write (1, "main\n", 5); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/15_recursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int factorial(int i) 4 | { 5 | if (i < 2) 6 | return i; 7 | else 8 | return i * factorial(i - 1); 9 | } 10 | 11 | int main() 12 | { 13 | int Count; 14 | 15 | for (Count = 1; Count <= 10; Count++) 16 | printf("%d\n", factorial(Count)); 17 | 18 | return 0; 19 | } 20 | 21 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 22 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/16_nesting.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int x, y, z; 6 | 7 | for (x = 0; x < 2; x++) 8 | { 9 | for (y = 0; y < 3; y++) 10 | { 11 | for (z = 0; z < 3; z++) 12 | { 13 | printf("%d %d %d\n", x, y, z); 14 | } 15 | } 16 | } 17 | 18 | return 0; 19 | } 20 | 21 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 22 | -------------------------------------------------------------------------------- /lib/tinycc/win32/examples/dll.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | // 3 | // dll.c - Windows DLL example - dynamically linked part 4 | // 5 | 6 | #include 7 | 8 | __declspec(dllexport) const char *hello_data = "(not set)"; 9 | 10 | __declspec(dllexport) void hello_func (void) 11 | { 12 | MessageBox (0, hello_data, "From DLL", MB_ICONINFORMATION); 13 | } 14 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | /* 7 | * This file is part of the Mingw32 package. 8 | * 9 | * mem.h maps to string.h 10 | */ 11 | #ifndef __STRICT_ANSI__ 12 | #include 13 | #endif 14 | -------------------------------------------------------------------------------- /lib/tinycc/include/varargs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _VARARGS_H 7 | #define _VARARGS_H 8 | 9 | #error "TinyCC no longer implements ." 10 | #error "Revise your code to use ." 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/05_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int Count; 6 | int Array[10]; 7 | 8 | for (Count = 1; Count <= 10; Count++) 9 | { 10 | Array[Count-1] = Count * Count; 11 | } 12 | 13 | for (Count = 0; Count < 10; Count++) 14 | { 15 | printf("%d\n", Array[Count]); 16 | } 17 | 18 | return 0; 19 | } 20 | 21 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 22 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/26_character_constants.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("%d\n", '\1'); 6 | printf("%d\n", '\10'); 7 | printf("%d\n", '\100'); 8 | printf("%d\n", '\x01'); 9 | printf("%d\n", '\x0e'); 10 | printf("%d\n", '\x10'); 11 | printf("%d\n", '\x40'); 12 | printf("test \x40\n"); 13 | 14 | return 0; 15 | } 16 | 17 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 18 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/13_integer_literals.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a = 24680; 6 | int b = 01234567; 7 | int c = 0x2468ac; 8 | int d = 0x2468AC; 9 | int e = 0b010101010101; 10 | 11 | printf("%d\n", a); 12 | printf("%d\n", b); 13 | printf("%d\n", c); 14 | printf("%d\n", d); 15 | printf("%d\n", e); 16 | 17 | return 0; 18 | } 19 | 20 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/34_array_assignment.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a[4]; 6 | 7 | a[0] = 12; 8 | a[1] = 23; 9 | a[2] = 34; 10 | a[3] = 45; 11 | 12 | printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]); 13 | 14 | int b[4]; 15 | 16 | b = a; 17 | 18 | printf("%d %d %d %d\n", b[0], b[1], b[2], b[3]); 19 | 20 | return 0; 21 | } 22 | 23 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 24 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | /* 7 | * This file is part of the Mingw32 package. 8 | * 9 | * This fcntl.h maps to the root fcntl.h 10 | */ 11 | #ifndef __STRICT_ANSI__ 12 | #include 13 | #endif 14 | -------------------------------------------------------------------------------- /lib/tinycc/include/stdalign.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDALIGN_H 2 | #define _STDALIGN_H 3 | 4 | #if __STDC_VERSION__ < 201112L && (defined(__GNUC__) || defined(__TINYC__)) 5 | # define _Alignas(t) __attribute__((__aligned__(t))) 6 | # define _Alignof(t) __alignof__(t) 7 | #endif 8 | 9 | #define alignas _Alignas 10 | #define alignof _Alignof 11 | 12 | #define __alignas_is_defined 1 13 | #define __alignof_is_defined 1 14 | 15 | #endif /* _STDALIGN_H */ 16 | 17 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sys/file.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | /* 7 | * This file is part of the Mingw32 package. 8 | * 9 | * This file.h maps to the root fcntl.h 10 | * TODO? 11 | */ 12 | #ifndef __STRICT_ANSI__ 13 | #include 14 | #endif 15 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/47_switch_return.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void fred(int x) 4 | { 5 | switch (x) 6 | { 7 | case 1: printf("1\n"); return; 8 | case 2: printf("2\n"); break; 9 | case 3: printf("3\n"); return; 10 | } 11 | 12 | printf("out\n"); 13 | } 14 | 15 | int main() 16 | { 17 | fred(1); 18 | fred(2); 19 | fred(3); 20 | 21 | return 0; 22 | } 23 | 24 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/40_stdio.expect: -------------------------------------------------------------------------------- 1 | hello 2 | ch: 104 'h' 3 | ch: 101 'e' 4 | ch: 108 'l' 5 | ch: 108 'l' 6 | ch: 111 'o' 7 | ch: 10 '.' 8 | ch: 104 'h' 9 | ch: 101 'e' 10 | ch: 108 'l' 11 | ch: 108 'l' 12 | ch: 111 'o' 13 | ch: 10 '.' 14 | ch: 104 'h' 15 | ch: 101 'e' 16 | ch: 108 'l' 17 | ch: 108 'l' 18 | ch: 111 'o' 19 | ch: 10 '.' 20 | ch: 104 'h' 21 | ch: 101 'e' 22 | ch: 108 'l' 23 | ch: 108 'l' 24 | ch: 111 'o' 25 | ch: 10 '.' 26 | x: hello 27 | x: hello 28 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/72_long_long_constant.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | long long int res = 0; 6 | 7 | if (res < -2147483648LL) { 8 | printf("Error: 0 < -2147483648\n"); 9 | return 1; 10 | } 11 | else 12 | if (2147483647LL < res) { 13 | printf("Error: 2147483647 < 0\n"); 14 | return 2; 15 | } 16 | else 17 | printf("long long constant test ok.\n"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/winapi/ws2ipdef.h: -------------------------------------------------------------------------------- 1 | #ifndef _WS2IPDEF_H 2 | #define _WS2IPDEF_H 3 | 4 | #if __GNUC__ >=3 5 | #pragma GCC system_header 6 | #endif 7 | 8 | #include 9 | 10 | struct ip_mreq { 11 | struct in_addr imr_multiaddr; 12 | struct in_addr imr_interface; 13 | }; 14 | 15 | struct ip_mreq_source { 16 | struct in_addr imr_multiaddr; 17 | struct in_addr imr_sourceaddr; 18 | struct in_addr imr_interface; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/48_nested_break.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | char b; 7 | 8 | a = 0; 9 | while (a < 2) 10 | { 11 | printf("%d", a++); 12 | break; 13 | 14 | b = 'A'; 15 | while (b < 'C') 16 | { 17 | printf("%c", b++); 18 | } 19 | printf("e"); 20 | } 21 | printf("\n"); 22 | 23 | return 0; 24 | } 25 | 26 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 27 | -------------------------------------------------------------------------------- /src/elflinker.h: -------------------------------------------------------------------------------- 1 | #ifndef __ELFLINKER_H__ 2 | #define __ELFLINKER_H__ 3 | 4 | #include 5 | 6 | struct LDState { 7 | int cc; 8 | int fd; 9 | int new_undef_sym; 10 | int static_link; 11 | xarray_t *libs; 12 | xarray_t *libpaths; 13 | }; 14 | typedef struct LDState LDState; 15 | 16 | bool read_ldsoconf(xarray_t *dest, char *path); 17 | bool read_ldsoconf_dir(xarray_t *dest, const char *directory); 18 | int resolve_libs(CJITState *cjit); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/42test.h: -------------------------------------------------------------------------------- 1 | /* This file is to test compute #include directives. It's named so 2 | that it starts with a pre-processing number which isn't a valid 3 | number (42test.h). Including this must work. */ 4 | #ifndef INC42_FIRST 5 | int have_included_42test_h; 6 | #define INC42_FIRST 7 | #elif !defined INC42_SECOND 8 | #define INC42_SECOND 9 | int have_included_42test_h_second; 10 | #else 11 | #define INC42_THIRD 12 | int have_included_42test_h_third; 13 | #endif 14 | -------------------------------------------------------------------------------- /lib/tinycc/win32/examples/fib.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include // atoi() 3 | 4 | int fib(n) 5 | { 6 | if (n <= 2) 7 | return 1; 8 | else 9 | return fib(n-1) + fib(n-2); 10 | } 11 | 12 | int main(int argc, char **argv) 13 | { 14 | int n; 15 | if (argc < 2) { 16 | printf("usage: fib n\n" 17 | "Compute nth Fibonacci number\n"); 18 | return 1; 19 | } 20 | 21 | n = atoi(argv[1]); 22 | printf("fib(%d) = %d\n", n, fib(n)); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/02_printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("Hello world\n"); 6 | 7 | int Count; 8 | for (Count = -5; Count <= 5; Count++) 9 | printf("Count = %d\n", Count); 10 | 11 | printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there"); 12 | printf("Character 'A' is '%c'\n", 65); 13 | printf("Character 'a' is '%c'\n", 'a'); 14 | 15 | return 0; 16 | } 17 | 18 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/49_bracket_evaluation.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct point 4 | { 5 | double x; 6 | double y; 7 | }; 8 | 9 | struct point point_array[100]; 10 | 11 | int main() 12 | { 13 | int my_point = 10; 14 | 15 | point_array[my_point].x = 12.34; 16 | point_array[my_point].y = 56.78; 17 | 18 | printf("%f, %f\n", point_array[my_point].x, point_array[my_point].y); 19 | 20 | return 0; 21 | } 22 | 23 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 24 | -------------------------------------------------------------------------------- /lib/tinycc/examples/ex3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fib(n) 4 | { 5 | if (n <= 2) 6 | return 1; 7 | else 8 | return fib(n-1) + fib(n-2); 9 | } 10 | 11 | int main(int argc, char **argv) 12 | { 13 | int n; 14 | if (argc < 2) { 15 | printf("usage: fib n\n" 16 | "Compute nth Fibonacci number\n"); 17 | return 1; 18 | } 19 | 20 | n = atoi(argv[1]); 21 | printf("fib(%d) = %d\n", n, fib(n, 2)); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/03.c: -------------------------------------------------------------------------------- 1 | #define str(s) # s 2 | #define xstr(s) str(s) 3 | #define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ 4 | x ## s, x ## t) 5 | #define INCFILE(n) vers ## n 6 | #define glue(a, b) a ## b 7 | #define xglue(a, b) glue(a, b) 8 | #define HIGHLOW "hello" 9 | #define LOW LOW ", world" 10 | debug(1, 2); 11 | fputs(str(strncmp("abc\0d", "abc", '\4') // this goes away 12 | == 0) str(: @\n), s); 13 | \#include xstr(INCFILE(2).h) 14 | glue(HIGH, LOW); 15 | xglue(HIGH, LOW) 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/20_pointer_comparison.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | int b; 7 | int *d; 8 | int *e; 9 | d = &a; 10 | e = &b; 11 | a = 12; 12 | b = 34; 13 | printf("%d\n", *d); 14 | printf("%d\n", *e); 15 | printf("%d\n", d == e); 16 | printf("%d\n", d != e); 17 | d = e; 18 | printf("%d\n", d == e); 19 | printf("%d\n", d != e); 20 | 21 | return 0; 22 | } 23 | 24 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/15.c: -------------------------------------------------------------------------------- 1 | // insert a space between two tokens if otherwise they 2 | // would form a single token when read back 3 | 4 | #define n(x) x 5 | 6 | return (n(long)n(double))d; 7 | return n(A)n(++)n(+)n(B); 8 | return n(A)n(+)n(++)n(B); 9 | return n(A)n(++)n(+)n(+)n(B); 10 | 11 | // not a hex float 12 | return n(0x1E)n(-1); 13 | 14 | // unlike gcc but correct 15 | // XXX: return n(x)+n(x)-n(1)+n(1)-2; 16 | 17 | // unlike gcc, but cannot appear in valid C 18 | // XXX: return n(x)n(x)n(1)n(2)n(x); 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/103_implicit_memmove.c: -------------------------------------------------------------------------------- 1 | /* Test that the memmove TCC is emitting for the struct copy 2 | and hence implicitely declares can be declared properly also 3 | later. */ 4 | struct S { int a,b,c,d, e[1024];}; 5 | int foo (struct S *a, struct S *b) 6 | { 7 | *a = *b; 8 | return 0; 9 | } 10 | 11 | void *memmove(void*,const void*,__SIZE_TYPE__); 12 | void foo2 (struct S *a, struct S *b) 13 | { 14 | memmove(a, b, sizeof *a); 15 | } 16 | 17 | int main() 18 | { 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/106_versym.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | main(void) 7 | { 8 | int ret; 9 | pthread_condattr_t attr; 10 | pthread_cond_t condition; 11 | 12 | /* This test fails if symbol versioning does not work */ 13 | pthread_condattr_init (&attr); 14 | pthread_condattr_setpshared (&attr, PTHREAD_PROCESS_SHARED); 15 | printf ("%s\n", pthread_cond_init (&condition, &attr) ? "fail":"ok"); 16 | pthread_condattr_destroy (&attr); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/120+_alias.c: -------------------------------------------------------------------------------- 1 | extern int printf (const char *, ...); 2 | extern void target(void); 3 | extern void alias_for_target(void); 4 | extern void asm_for_target(void); 5 | extern int g_int, alias_int; 6 | 7 | void inunit2(void); 8 | 9 | void inunit2(void) 10 | { 11 | printf("in unit2:\n"); 12 | target(); 13 | alias_for_target(); 14 | /* This symbol is not supposed to be available in this unit: 15 | asm_for_target(); 16 | */ 17 | printf("g_int = %d\nalias_int = %d\n", g_int, alias_int); 18 | } 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/19_pointer_arithmetic.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a; 6 | int *b; 7 | int *c; 8 | 9 | a = 42; 10 | b = &a; 11 | c = NULL; 12 | 13 | printf("%d\n", *b); 14 | 15 | if (b == NULL) 16 | printf("b is NULL\n"); 17 | else 18 | printf("b is not NULL\n"); 19 | 20 | if (c == NULL) 21 | printf("c is NULL\n"); 22 | else 23 | printf("c is not NULL\n"); 24 | 25 | return 0; 26 | } 27 | 28 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 29 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Dyne.org foundation 2 | # SPDX-FileCopyrightText: 2023-2024 Dyne.org foundation 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | # stop search for .editorconfig in parent directories 7 | root = true 8 | 9 | [*] 10 | end_of_line = lf 11 | insert_final_newline = true 12 | charset = utf-8 13 | 14 | [**/*.[ch]] 15 | indent_style = tab 16 | indent_size = 4 17 | 18 | [GNUMakefile] 19 | indent_style = tab 20 | indent_size = 4 21 | 22 | [test/*.bats] 23 | indent_style = space 24 | indent_size = 4 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/07_function.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int myfunc(int x) 4 | { 5 | return x * x; 6 | } 7 | 8 | void vfunc(int a) 9 | { 10 | printf("a=%d\n", a); 11 | } 12 | 13 | void qfunc() 14 | { 15 | printf("qfunc()\n"); 16 | } 17 | 18 | void zfunc() 19 | { 20 | ((void (*)(void))0) (); 21 | } 22 | 23 | int main() 24 | { 25 | printf("%d\n", myfunc(3)); 26 | printf("%d\n", myfunc(4)); 27 | 28 | vfunc(1234); 29 | 30 | qfunc(); 31 | 32 | return 0; 33 | } 34 | 35 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 36 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/110_average.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct 4 | { 5 | double average; 6 | int count; 7 | } 8 | stats_type; 9 | 10 | static void 11 | testc (stats_type *s, long long data) 12 | { 13 | s->average = (s->average * s->count + data) / (s->count + 1); 14 | s->count++; 15 | } 16 | 17 | int main (void) 18 | { 19 | stats_type s; 20 | 21 | s.average = 0; 22 | s.count = 0; 23 | testc (&s, 10); 24 | testc (&s, 20); 25 | printf ("%g %d\n", s.average, s.count); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /test/test_helper/bats_support/load.bash: -------------------------------------------------------------------------------- 1 | # Preserve path at the time this file was sourced 2 | # This prevents using of user-defined mocks/stubs that modify the PATH 3 | 4 | # BATS_SAVED_PATH was introduced in bats-core v1.10.0 5 | # if it is already set, we can use its more robust value 6 | # else we try to recreate it here 7 | BATS_SAVED_PATH="${BATS_SAVED_PATH-$PATH}" 8 | 9 | source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" 10 | source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" 11 | source "$(dirname "${BASH_SOURCE[0]}")/src/lang.bash" 12 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/109_float_struct_calling.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* This test used to fail on x86_64 on linux with sse registers */ 4 | 5 | struct Point { 6 | float x; 7 | float y; 8 | }; 9 | 10 | struct Rect { 11 | struct Point top_left; 12 | struct Point size; 13 | }; 14 | 15 | float foo(struct Point p, struct Rect r) { 16 | return r.size.x; 17 | } 18 | 19 | int main(int argc, char **argv) { 20 | struct Point p = {1, 2}; 21 | struct Rect r = {{3, 4}, {5, 6}}; 22 | printf("%f\n", foo(p, r)); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/42_function_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fred(int p) 4 | { 5 | printf("yo %d\n", p); 6 | return 42; 7 | } 8 | 9 | int (*f)(int) = &fred; 10 | 11 | /* To test what this is supposed to test the destination function 12 | (fprint here) must not be called directly anywhere in the test. */ 13 | int (*fprintfptr)(FILE *, const char *, ...) = &fprintf; 14 | 15 | int main() 16 | { 17 | fprintfptr(stdout, "%d\n", (*f)(24)); 18 | 19 | return 0; 20 | } 21 | 22 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 23 | -------------------------------------------------------------------------------- /lib/tinycc/win32/examples/hello_dll.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | // 3 | // HELLO_DLL.C - Windows DLL example - main application part 4 | // 5 | 6 | #include 7 | 8 | void hello_func (void); 9 | __declspec(dllimport) extern const char *hello_data; 10 | 11 | int WINAPI WinMain( 12 | HINSTANCE hInstance, 13 | HINSTANCE hPrevInstance, 14 | LPSTR lpCmdLine, 15 | int nCmdShow) 16 | { 17 | hello_data = "Hello World!"; 18 | hello_func(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/132_bound_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | union ieee_double_extract 5 | { 6 | struct { 7 | unsigned int manl:32; 8 | unsigned int manh:20; 9 | unsigned int exp:11; 10 | unsigned int sig:1; 11 | } s; 12 | double d; 13 | }; 14 | 15 | double scale(double d) 16 | { 17 | union ieee_double_extract x; 18 | 19 | x.d = d; 20 | x.d *= 1000; 21 | return x.d; 22 | } 23 | 24 | int 25 | main(void) 26 | { 27 | printf("%g\n", scale(42)); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/51_static.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static int fred = 1234; 4 | static int joe; 5 | 6 | void henry() 7 | { 8 | static int fred = 4567; 9 | 10 | printf("%d\n", fred); 11 | fred++; 12 | } 13 | 14 | int main() 15 | { 16 | printf("%d\n", fred); 17 | henry(); 18 | henry(); 19 | henry(); 20 | henry(); 21 | printf("%d\n", fred); 22 | fred = 8901; 23 | joe = 2345; 24 | printf("%d\n", fred); 25 | printf("%d\n", joe); 26 | 27 | return 0; 28 | } 29 | 30 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 31 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/52_unnamed_enum.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | enum fred { a, b, c }; 4 | 5 | int main() 6 | { 7 | printf("a=%d\n", a); 8 | printf("b=%d\n", b); 9 | printf("c=%d\n", c); 10 | 11 | enum fred d; 12 | 13 | typedef enum { e, f, g } h; 14 | typedef enum { i, j, k } m; 15 | 16 | printf("e=%d\n", e); 17 | printf("f=%d\n", f); 18 | printf("g=%d\n", g); 19 | 20 | printf("i=%d\n", i); 21 | printf("j=%d\n", j); 22 | printf("k=%d\n", k); 23 | 24 | return 0; 25 | } 26 | 27 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 28 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/20.c: -------------------------------------------------------------------------------- 1 | /* Various things I encountered while hacking the pre processor */ 2 | #define wrap(x) x 3 | #define pr_warning(fmt, ...) printk(KERN_WARNING fmt, ##__VA_ARGS__) 4 | #define pr_warn(x,y) pr_warning(x,y) 5 | #define net_ratelimited_function(function, ...) function(__VA_ARGS__) 6 | X1 net_ratelimited_function(pr_warn, "pipapo", bla); 7 | X2 net_ratelimited_function(wrap(pr_warn), "bla", foo); 8 | #define two m n 9 | #define chain4(a,b,c,d) a ## b ## c ## d 10 | X2 chain4(two,o,p,q) 11 | X3 chain4(o,two,p,q) 12 | X4 chain4(o,p,two,q) 13 | X5 chain4(o,p,q,two) 14 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sec_api/crtdbg_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | 7 | #ifndef _INC_CRTDBG_S 8 | #define _INC_CRTDBG_S 9 | 10 | #include 11 | 12 | #if defined(MINGW_HAS_SECURE_API) 13 | 14 | #define _dupenv_s_dbg(ps1,size,s2,t,f,l) _dupenv_s(ps1,size,s2) 15 | #define _wdupenv_s_dbg(ps1,size,s2,t,f,l) _wdupenv_s(ps1,size,s2) 16 | 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/06_case.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int Count; 6 | 7 | for (Count = 0; Count < 4; Count++) 8 | { 9 | printf("%d\n", Count); 10 | switch (Count) 11 | { 12 | case 1: 13 | printf("%d\n", 1); 14 | break; 15 | 16 | case 2: 17 | printf("%d\n", 2); 18 | break; 19 | 20 | default: 21 | printf("%d\n", 0); 22 | break; 23 | } 24 | } 25 | 26 | return 0; 27 | } 28 | 29 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 30 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/133_exec_section_in_c.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Previously in TinyCC, ELF sections defined in attributes would always have 4 | the execute bit not set, so you would get segmentation faults when code in these 5 | sections was exectuted. This file is a minimal example of a file that will put 6 | the resulting code in a non-executable section (and invoke it) prior to the fix. 7 | */ 8 | __attribute__((section(".text.wumbo"))) 9 | int wumbo (int arg) { 10 | return arg * 2; 11 | } 12 | 13 | int main () { 14 | wumbo(2); 15 | puts("hi"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/38_multiple_array_index.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a[4][4]; 6 | int b = 0; 7 | int x; 8 | int y; 9 | 10 | for (x = 0; x < 4; x++) 11 | { 12 | for (y = 0; y < 4; y++) 13 | { 14 | b++; 15 | a[x][y] = b; 16 | } 17 | } 18 | 19 | for (x = 0; x < 4; x++) 20 | { 21 | printf("x=%d: ", x); 22 | for (y = 0; y < 4; y++) 23 | { 24 | printf("%d ", a[x][y]); 25 | } 26 | printf("\n"); 27 | } 28 | 29 | return 0; 30 | } 31 | 32 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 33 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/21_char_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int x = 'a'; 6 | char y = x; 7 | 8 | char *a = "hello"; 9 | 10 | printf("%s\n", a); 11 | 12 | int c; 13 | c = *a; 14 | 15 | char *b; 16 | for (b = a; *b != 0; b++) 17 | printf("%c: %d\n", *b, *b); 18 | 19 | char destarray[10]; 20 | char *dest = &destarray[0]; 21 | char *src = a; 22 | 23 | while (*src != 0) 24 | *dest++ = *src++; 25 | 26 | *dest = 0; 27 | 28 | printf("copied string is %s\n", destarray); 29 | 30 | return 0; 31 | } 32 | 33 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 34 | -------------------------------------------------------------------------------- /docs/demo: -------------------------------------------------------------------------------- 1 | Write-Host "" 2 | Write-Host "Welcome to CJIT!" 3 | Write-Host "We'll be downloading our quick demo setup, please wait a bit," 4 | Write-Host "then all will be found inside the 'cjit-demo' folder right here." 5 | Invoke-WebRequest -OutFile "cjit.exe" -Uri "https://github.com/dyne/cjit/releases/latest/download/cjit.exe" 6 | Invoke-WebRequest -OutFile "cjit-demo.tar.gz" -Uri "https://github.com/dyne/cjit/releases/latest/download/cjit-demo.tar.gz" 7 | .\cjit.exe --xtgz cjit-demo.tar.gz 8 | cp .\cjit.exe cjit-demo 9 | cd cjit-demo 10 | Write-Host "Ready to start! Follow the tutorial:" 11 | Write-Host " --> https://dyne.org/docs/cjit <--" 12 | Write-Host "" 13 | -------------------------------------------------------------------------------- /lib/tinycc/win32/lib/dllcrt1.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | 3 | #include 4 | #include 5 | #include "crtinit.c" 6 | 7 | BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved); 8 | 9 | BOOL WINAPI _dllstart(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) 10 | { 11 | BOOL bRet; 12 | if (dwReason == DLL_PROCESS_ATTACH) /* ignore DLL_THREAD_ATTACH */ 13 | run_ctors(0, 0, 0); 14 | bRet = DllMain (hDll, dwReason, lpReserved); 15 | if (dwReason == DLL_PROCESS_DETACH) /* ignore DLL_THREAD_DETACH */ 16 | run_dtors(); 17 | return bRet; 18 | } 19 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/122_vla_reuse.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int 4 | main (void) 5 | { 6 | int n = 0; 7 | int first=1; 8 | int *p[101]; 9 | if (0) { 10 | lab:; 11 | } 12 | int x[n % 100 + 1]; 13 | if (first == 0) { 14 | if (&x[0] != p[n % 100 + 1]) { 15 | printf ("ERROR: %p %p\n", &x[0], p[n % 100 + 1]); 16 | return(1); 17 | } 18 | } 19 | else { 20 | p[n % 100 + 1] = &x[0]; 21 | first = n < 100; 22 | } 23 | x[0] = 1; 24 | x[n % 100] = 2; 25 | n++; 26 | if (n < 100000) 27 | goto lab; 28 | printf ("OK\n"); 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/50_logical_second_arg.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fred() 4 | { 5 | printf("fred\n"); 6 | return 0; 7 | } 8 | 9 | int joe() 10 | { 11 | printf("joe\n"); 12 | return 1; 13 | } 14 | 15 | int main() 16 | { 17 | printf("%d\n", fred() && joe()); 18 | printf("%d\n", fred() || joe()); 19 | printf("%d\n", joe() && fred()); 20 | printf("%d\n", joe() || fred()); 21 | printf("%d\n", fred() && (1 + joe())); 22 | printf("%d\n", fred() || (0 + joe())); 23 | printf("%d\n", joe() && (0 + fred())); 24 | printf("%d\n", joe() || (1 + fred())); 25 | 26 | return 0; 27 | } 28 | 29 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 30 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/80_flexarray.c: -------------------------------------------------------------------------------- 1 | #include 2 | struct wchar { 3 | char *data; char mem[]; 4 | }; 5 | struct wint { 6 | char *data; int mem[]; 7 | }; 8 | int f1char (void) { 9 | char s[9]="nonono"; 10 | struct wchar q = {"bugs"}; 11 | return !s[0]; 12 | } 13 | int f1int (void) { 14 | char s[9]="nonono"; 15 | struct wint q = {"bugs"}; 16 | return !s[0]; 17 | } 18 | int empty[] = {}; // GNU extension 19 | int main (void) { 20 | char s[9]="nonono"; 21 | static struct wchar q = {"bugs", {'c'}}; 22 | //printf ("tcc has %s %s\n", s, q.data); 23 | if (f1char() || f1int()) 24 | printf ("bla\n"); 25 | return !s[0]; 26 | } 27 | -------------------------------------------------------------------------------- /lib/tinycc/tests/bug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int compile_errors(void) 5 | { 6 | #if TEST == 1 7 | { 8 | /* Not constant */ 9 | static int i = (&"Foobar"[1] - &"Foobar"[0]); 10 | } 11 | #endif 12 | #if TEST == 2 13 | { 14 | /* Not constant */ 15 | struct{int c;}v; 16 | static long i=((char*)&(v.c)-(char*)&v); 17 | } 18 | #endif 19 | #if TEST == 3 20 | { 21 | /* Not constant */ 22 | static const short ar[] = { &&l1 - &&l1, &&l2 - &&l1 }; 23 | void *p = &&l1 + ar[0]; 24 | goto *p; 25 | l1: return 1; 26 | l2: return 2; 27 | } 28 | #endif 29 | return 0; 30 | } 31 | 32 | int 33 | main(void) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/97_utf8_string_literal.c: -------------------------------------------------------------------------------- 1 | // this file contains BMP chars encoded in UTF-8 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main() 8 | { 9 | char hello_world_in_czech[] = "čau, světe"; 10 | char hello_world_in_czech_ucn[] = "\u010dau, sv\u011bte"; 11 | if (sizeof(hello_world_in_czech) != sizeof(hello_world_in_czech_ucn) 12 | || strcmp(hello_world_in_czech, hello_world_in_czech_ucn)) 13 | abort(); 14 | 15 | wchar_t s[] = L"hello$$你好¢¢世界€€world"; 16 | wchar_t *p; 17 | for (p = s; *p; p++) printf("%04X ", (unsigned) *p); 18 | printf("\n"); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/21.c: -------------------------------------------------------------------------------- 1 | /* accept 'defined' as result of substitution */ 2 | 3 | ----- 1 ------ 4 | #define AAA 2 5 | #define BBB 6 | #define CCC (defined ( AAA ) && AAA > 1 && !defined BBB) 7 | #if !CCC 8 | OK 9 | #else 10 | NOT OK 11 | #endif 12 | 13 | ----- 2 ------ 14 | #undef BBB 15 | #if CCC 16 | OK 17 | #else 18 | NOT OK 19 | #endif 20 | 21 | ----- 3 ------ 22 | #define DEFINED defined 23 | #define DDD (DEFINED ( AAA ) && AAA > 1 && !DEFINED BBB) 24 | #if (DDD) 25 | OK 26 | #else 27 | NOT OK 28 | #endif 29 | 30 | ----- 4 ------ 31 | #undef AAA 32 | #if !(DDD) 33 | OK 34 | #else 35 | NOT OK 36 | #endif 37 | 38 | ----- 5 ------ 39 | line __LINE__ 40 | #define __LINE__ # ## # 41 | line __LINE__ 42 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/113_btdll.c: -------------------------------------------------------------------------------- 1 | int tcc_backtrace(const char*, ...); 2 | #define hello() \ 3 | tcc_backtrace("hello from %s() / %s:%d",__FUNCTION__,__FILE__,__LINE__) 4 | 5 | #ifndef _WIN32 6 | # define __declspec(n) 7 | #endif 8 | 9 | #if DLL==1 10 | __declspec(dllexport) int f_1() 11 | { 12 | hello(); 13 | return 0; 14 | } 15 | 16 | 17 | #elif DLL==2 18 | __declspec(dllexport) int f_2() 19 | { 20 | hello(); 21 | return 0; 22 | } 23 | 24 | 25 | #else 26 | 27 | int f_1(); 28 | int f_2(); 29 | int f_main() 30 | { 31 | hello(); 32 | return 0; 33 | } 34 | 35 | int main () 36 | { 37 | f_1(); 38 | f_2(); 39 | f_main(); 40 | return 0; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/36_array_initialisers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int Array3[10]; 4 | int Array3[] = { 12, 34, }; 5 | int main() 6 | { 7 | int Count; 8 | 9 | int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 }; 10 | 11 | for (Count = 0; Count < 10; Count++) 12 | printf("%d: %d\n", Count, Array[Count]); 13 | 14 | int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, }; 15 | 16 | for (Count = 0; Count < 10; Count++) 17 | printf("%d: %d\n", Count, Array2[Count]); 18 | 19 | for (Count = 0; Count < 10; Count++) 20 | printf("%d: %d\n", Count, Array3[Count]); 21 | 22 | return 0; 23 | } 24 | 25 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 26 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/pp-counter.c: -------------------------------------------------------------------------------- 1 | X1 __COUNTER__ 2 | X2 __COUNTER__ 3 | #if __COUNTER__ 4 | X3 __COUNTER__ 5 | #endif 6 | #define pass(x) x 7 | #define a x __COUNTER__ y 8 | #define a2 pass(__COUNTER__) 9 | #define f(c) c __COUNTER__ 10 | #define apply(d) d d __COUNTER__ x2 f(d) y2 __COUNTER__ 11 | #define _paste(a,b) a ## b 12 | #define paste(a,b) _paste(a,b) 13 | #define _paste3(a,b,c) a ## b ## c 14 | #define doublepaste(a,b) _paste3(a,b,b) 15 | #define str(x) #x 16 | X4 a 17 | X5 f(a) 18 | X6 f(b) 19 | X7 f(__COUNTER__) 20 | X8 apply(a) 21 | X9 apply(f(a)) 22 | X10 apply(__COUNTER__) 23 | X11 apply(a2) 24 | X12 str(__COUNTER__) 25 | X13 paste(x,__COUNTER__) 26 | X14 _paste(x,__COUNTER__) 27 | X15 doublepaste(x,__COUNTER__) 28 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/02.c: -------------------------------------------------------------------------------- 1 | #define x 3 2 | #define f(a) f(x * (a)) 3 | #undef x 4 | #define x 2 5 | #define g f 6 | #define z z[0] 7 | #define h g(~ 8 | #define m(a) a(w) 9 | #define w 0,1 10 | #define t(a) a 11 | #define p() int 12 | #define q(x) x 13 | #define r(x,y) x ## y 14 | #define str(x) # x 15 | f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); 16 | g(x+(3,4)-w) | h 5) & m 17 | (f)^m(m); 18 | char c[2][6] = { str(hello), str() }; 19 | /* 20 | * f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); 21 | * f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); 22 | * char c[2][6] = { "hello", "" }; 23 | */ 24 | #define L21 f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); 25 | #define L22 g(x+(3,4)-w) | h 5) & m\ 26 | (f)^m(m); 27 | L21 28 | L22 29 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/iso646.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the TinyCC package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | 7 | /* 8 | * ISO C Standard: 7.9 Alternative spellings 9 | */ 10 | 11 | #ifndef _ISO646_H_ 12 | #define _ISO646_H_ 13 | 14 | #define and && 15 | #define and_eq &= 16 | #define bitand & 17 | #define bitor | 18 | #define compl ~ 19 | #define not ! 20 | #define not_eq != 21 | #define or || 22 | #define or_eq |= 23 | #define xor ^ 24 | #define xor_eq ^= 25 | 26 | #endif /* _ISO646_H_ */ 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/tinycc/examples/ex4.c: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 2 | #include 3 | #include 4 | #include 5 | 6 | /* Yes, TCC can use X11 too ! */ 7 | 8 | int main(int argc, char **argv) 9 | { 10 | Display *display; 11 | Screen *screen; 12 | 13 | display = XOpenDisplay(""); 14 | if (!display) { 15 | fprintf(stderr, "Could not open X11 display\n"); 16 | exit(1); 17 | } 18 | printf("X11 display opened.\n"); 19 | screen = XScreenOfDisplay(display, 0); 20 | printf("width = %d\nheight = %d\ndepth = %d\n", 21 | screen->width, 22 | screen->height, 23 | screen->root_depth); 24 | XCloseDisplay(display); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /test/bats_setup: -------------------------------------------------------------------------------- 1 | # setup paths for BATS test units 2 | setup() { 3 | bats_require_minimum_version 1.5.0 4 | T="$BATS_TEST_DIRNAME" 5 | TMP="$BATS_TEST_TMPDIR" 6 | # R=`cd "$T"/.. && pwd` 7 | R=`pwd` 8 | load "$T"/test_helper/bats_support/load 9 | load "$T"/test_helper/bats_assert/load 10 | CJIT="${R}/cjit" 11 | [ -r "$CJIT" ] || CJIT="${R}/cjit.exe" 12 | [ -r "$CJIT" ] || CJIT="${R}/cjit.command" 13 | [ -r "$CJIT" ] || { 14 | >&2 echo "CJIT is not built, cannot run test suite" 15 | exit 1 16 | } 17 | ${CJIT} -v 2>&1| grep 'System libtcc' >/dev/null && SYSTCC=1 18 | if [ -z $SYSTCC ]; then 19 | rm -rf `${CJIT} --xass` 20 | fi 21 | TCC="${R}/lib/tinycc/tcc" 22 | [ -r "$TCC" ] || TCC="${R}/lib/tinycc/tcc.exe" 23 | unset CFLAGS 24 | } 25 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/share.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_SHARE 7 | #define _INC_SHARE 8 | 9 | #ifndef _WIN32 10 | #error Only Win32 target is supported! 11 | #endif 12 | 13 | #define _SH_COMPAT 0x00 14 | #define _SH_DENYRW 0x10 15 | #define _SH_DENYWR 0x20 16 | #define _SH_DENYRD 0x30 17 | #define _SH_DENYNO 0x40 18 | #define _SH_SECURE 0x80 19 | 20 | #ifndef NO_OLDNAMES 21 | #define SH_COMPAT _SH_COMPAT 22 | #define SH_DENYRW _SH_DENYRW 23 | #define SH_DENYWR _SH_DENYWR 24 | #define SH_DENYRD _SH_DENYRD 25 | #define SH_DENYNO _SH_DENYNO 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/77_push_pop_macro.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | /* must not affect how #pragma ppop_macro works */ 6 | #define pop_macro foobar1 7 | 8 | /* must not affect how #pragma push_macro works */ 9 | #define push_macro foobar2 10 | 11 | #undef abort 12 | #define abort "111" 13 | printf("abort = %s\n", abort); 14 | 15 | #pragma push_macro("abort") 16 | #undef abort 17 | #define abort "222" 18 | printf("abort = %s\n", abort); 19 | 20 | #pragma push_macro("abort") 21 | #undef abort 22 | #define abort "333" 23 | printf("abort = %s\n", abort); 24 | 25 | #pragma pop_macro("abort") 26 | printf("abort = %s\n", abort); 27 | 28 | #pragma pop_macro("abort") 29 | printf("abort = %s\n", abort); 30 | } 31 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sys/locking.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_LOCKING 7 | #define _INC_LOCKING 8 | 9 | #ifndef _WIN32 10 | #error Only Win32 target is supported! 11 | #endif 12 | 13 | /* All the headers include this file. */ 14 | #include <_mingw.h> 15 | 16 | #define _LK_UNLCK 0 17 | #define _LK_LOCK 1 18 | #define _LK_NBLCK 2 19 | #define _LK_RLCK 3 20 | #define _LK_NBRLCK 4 21 | 22 | #ifndef NO_OLDNAMES 23 | #define LK_UNLCK _LK_UNLCK 24 | #define LK_LOCK _LK_LOCK 25 | #define LK_NBLCK _LK_NBLCK 26 | #define LK_RLCK _LK_RLCK 27 | #define LK_NBRLCK _LK_NBRLCK 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/121_struct_return.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct { 4 | int data[4]; 5 | double d1; 6 | double d2; 7 | } Node; 8 | 9 | Node init(Node self) { 10 | self.data[0] = 0; 11 | self.data[1] = 1; 12 | self.data[2] = 2; 13 | self.data[3] = 3; 14 | self.d1 = 1234; 15 | self.d2 = 2345; 16 | return self; 17 | } 18 | 19 | void dummy(Node self) { 20 | } 21 | 22 | void print_data(Node data) { 23 | printf ("%d %d %d %d %g %g\n", 24 | data.data[0], data.data[1], data.data[2], data.data[3], 25 | data.d1, data.d2); 26 | } 27 | 28 | int main(void) { 29 | /* This code resulted in a bounds checking error */ 30 | Node data; 31 | dummy (data); 32 | char val; 33 | data = init (data); 34 | print_data(data); 35 | } 36 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/100_c99array-decls.c: -------------------------------------------------------------------------------- 1 | void foo(int [5]); 2 | void fooc(int x[const 5]); 3 | void foos(int x[static 5]); 4 | void foov(int x[volatile 5]); 5 | void foor(int x[restrict 5]); 6 | void fooc(int [const 5]); 7 | void foos(int [static 5]); 8 | void foov(int [volatile 5]); 9 | void foor(int [restrict 5]); 10 | void fooc(int (* const x)); 11 | void foos(int *x); 12 | void foov(int * volatile x); 13 | void foor(int * restrict x); 14 | void fooc(int x[volatile 5]) 15 | { 16 | x[3] = 42; 17 | #ifdef INVALID 18 | x = 0; 19 | #endif 20 | } 21 | void foovm(int x[const *]); 22 | void foovm(int * const x); 23 | #ifdef INVALID 24 | void wrongc(int x[3][const 4]); 25 | void wrongvm(int x[static *]); 26 | void foovm(int x[const *]) 27 | { 28 | x[2] = 1; 29 | } 30 | #endif 31 | int main() 32 | { 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /docs/demo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | echo 4 | echo "Welcome to CJIT!" 5 | echo "We'll be downloading our quick demo setup, please wait a bit," 6 | echo "then all will be found inside the 'cjit-demo' folder right here." 7 | source /etc/os-release 8 | distro="${NAME,,}-${VERSION_ID}" 9 | arch=`uname -m` 10 | echo "Host system detected: ${distro}" 11 | echo "Architecture detected: ${arch}" 12 | [ -x ./cjit ] || { 13 | curl -sLo cjit https://github.com/dyne/cjit/releases/latest/download/cjit-${arch}-${distro} 14 | chmod +x cjit 15 | } 16 | curl -sLo cjit-demo.tar.gz https://github.com/dyne/cjit/releases/latest/download/cjit-demo.tar.gz 17 | ./cjit --xtgz cjit-demo.tar.gz 18 | cp ./cjit cjit-demo/ 19 | cd cjit-demo 20 | echo "Ready to start! Follow the tutorial:" 21 | echo " --> https://dyne.org/docs/cjit <--" 22 | echo 23 | exit 0 24 | -------------------------------------------------------------------------------- /examples/donut.c: -------------------------------------------------------------------------------- 1 | i,j,k,x,y,o,N; 2 | main(){float z[1760],a 3 | #define R(t,x,y) f=x;x-=t*y\ 4 | ;y+=t*f;f=(3-x*x-y*y)/2;x*=f;y*=f; 5 | =0,e=1,c=1,d=0,f,g,h,G,H,A,t,D;char 6 | b[1760];for(;;){memset(b,32,1760);g=0, 7 | h=1;memset(z,0,7040);for(j=0;j<90;j++){ 8 | G=0,H=1;for(i=0;i<314;i++){A=h+2,D=1/(G* 9 | A*a+g*e+5);t=G*A *e-g*a;x=40+30*D 10 | *(H*A*d-t*c);y= 12+15*D*(H*A*c+ 11 | t*d);o=x+80*y;N =8*((g*a-G*h*e) 12 | *d-G*h*a-g*e-H*h *c);if(22>y&&y> 13 | 0&&x>0&&80>x&&D>z[o]){z[o]=D;b[o]=(N>0 14 | ?N:0)[".,-~:;=!*#$@"];}R(.02,H,G);}R( 15 | .07,h,g);}for(k=0;1761>k;k++)putchar 16 | (k%80?b[k]:10);R(.04,e,a);R(.02,d, 17 | c);usleep(15000);printf('\n'+( 18 | " donut.c! \x1b[23A"));}} 19 | /*no math lib needed 20 | .@a1k0n 2021.*/ 21 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sec_api/sys/timeb_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | 7 | #ifndef _TIMEB_H_S 8 | #define _TIMEB_H_S 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #if defined(MINGW_HAS_SECURE_API) 17 | 18 | #ifdef _USE_32BIT_TIME_T 19 | #define _ftime_s _ftime32_s 20 | #else 21 | #define _ftime_s _ftime64_s 22 | #endif 23 | 24 | _CRTIMP errno_t __cdecl _ftime32_s(struct __timeb32 *_Time); 25 | #if _INTEGRAL_MAX_BITS >= 64 26 | _CRTIMP errno_t __cdecl _ftime64_s(struct __timeb64 *_Time); 27 | #endif 28 | #endif 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/70_floating_point_literals.expect: -------------------------------------------------------------------------------- 1 | 0.123000 2 | 122999996416.000000 3 | 0.000000 4 | 122999996416.000000 5 | 6 | 123.123001 7 | 123122997002240.000000 8 | 0.000000 9 | 123122997002240.000000 10 | 11 | 123.000000 12 | 123000003231744.000000 13 | 0.000000 14 | 123000003231744.000000 15 | 16 | 123000003231744.000000 17 | 0.000000 18 | 123000003231744.000000 19 | 20 | 21 | 428.000000 22 | 0.000026 23 | 428.000000 24 | 25 | 1756112.000000 26 | 0.104672 27 | 1756592.000000 28 | 29 | 1753088.000000 30 | 0.104492 31 | 1753088.000000 32 | 33 | 1753088.000000 34 | 0.104492 35 | 1753088.000000 36 | 37 | 38 | 3424.000000 39 | 0.000204 40 | 3424.000000 41 | 42 | 1756112.000000 43 | 0.104672 44 | 1756112.000000 45 | 46 | 1753088.000000 47 | 0.104492 48 | 1753088.000000 49 | 50 | 1753088.000000 51 | 0.104492 52 | 1753088.000000 53 | 54 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/118_switch.expect: -------------------------------------------------------------------------------- 1 | 1 : 1 2 | 10 : 2 3 | 100 : 3 4 | 1000 : 4 5 | 10000 : 5 6 | 100000 : 6 7 | 1000000 : 7 8 | 10000000 : 8 9 | 100000000 : 9 10 | 1000000000 : 10 11 | 10000000000 : 11 12 | 100000000000 : 12 13 | 1000000000000 : 13 14 | 10000000000000 : 14 15 | 100000000000000 : 15 16 | 1000000000000000 : 16 17 | 10000000000000000 : 17 18 | 100000000000000000 : 18 19 | 1000000000000000000 : 19 20 | -8446744073709551616 : 20 21 | 1 : 1 22 | 10 : 2 23 | 100 : 3 24 | 1000 : 4 25 | 10000 : 5 26 | 100000 : 6 27 | 1000000 : 7 28 | 10000000 : 8 29 | 100000000 : 9 30 | 1000000000 : 10 31 | 10000000000 : 11 32 | 100000000000 : 12 33 | 1000000000000 : 13 34 | 10000000000000 : 14 35 | 100000000000000 : 15 36 | 1000000000000000 : 16 37 | 10000000000000000 : 17 38 | 100000000000000000 : 18 39 | 1000000000000000000 : 19 40 | 10000000000000000000 : 20 41 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/10_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct ziggy 4 | { 5 | int a; 6 | int b; 7 | int c; 8 | } bolshevic; 9 | 10 | int main() 11 | { 12 | int a; 13 | int *b; 14 | int c; 15 | 16 | a = 42; 17 | b = &a; 18 | printf("a = %d\n", *b); 19 | 20 | bolshevic.a = 12; 21 | bolshevic.b = 34; 22 | bolshevic.c = 56; 23 | 24 | printf("bolshevic.a = %d\n", bolshevic.a); 25 | printf("bolshevic.b = %d\n", bolshevic.b); 26 | printf("bolshevic.c = %d\n", bolshevic.c); 27 | 28 | struct ziggy *tsar = &bolshevic; 29 | 30 | printf("tsar->a = %d\n", tsar->a); 31 | printf("tsar->b = %d\n", tsar->b); 32 | printf("tsar->c = %d\n", tsar->c); 33 | 34 | b = &(bolshevic.b); 35 | printf("bolshevic.b = %d\n", *b); 36 | 37 | return 0; 38 | } 39 | 40 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 41 | -------------------------------------------------------------------------------- /lib/tinycc/tests/exec_section_in_asm.c: -------------------------------------------------------------------------------- 1 | /* This test only works on x86-64. */ 2 | /* Previously in TinyCC, ELF sections defined in assembly would always have the 3 | execute bit not set, so you would get segmentation faults when code in these 4 | sections was exectuted. This file is a minimal example of a file that will put 5 | the resulting code in a non-executable section (and invoke it) prior to the fix. 6 | */ 7 | #include 8 | 9 | void *memset(void *dst, int c, int len); 10 | 11 | __asm__ ( 12 | ".section .text.nolibc_memset\n" 13 | ".weak memset\n" 14 | "memset:\n" 15 | "xchgl %eax, %esi\n\t" 16 | "movq %rdx, %rcx\n\t" 17 | "pushq %rdi\n\t" 18 | "rep stosb\n\t" 19 | "popq %rax\n\t" 20 | "retq\n" 21 | ); 22 | 23 | int main () { 24 | char buf[10]; 25 | memset(&buf[0], 'A', 9); 26 | buf[9] = 0; 27 | puts(buf); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/03_struct.c: -------------------------------------------------------------------------------- 1 | extern int printf(const char*, ...); 2 | 3 | struct fred; 4 | 5 | void fred$(struct fred* this) 6 | { 7 | printf("~fred()\n"); 8 | } 9 | 10 | struct __attribute__((__cleanup__(fred$))) fred 11 | { 12 | int boris; 13 | int natasha; 14 | }; 15 | 16 | int main() 17 | { 18 | struct fred __attribute__((__cleanup__(fred$))) bloggs; 19 | 20 | bloggs.boris = 12; 21 | bloggs.natasha = 34; 22 | 23 | printf("%d\n", bloggs.boris); 24 | printf("%d\n", bloggs.natasha); 25 | 26 | struct fred jones[2]; 27 | jones[0].boris = 12; 28 | jones[0].natasha = 34; 29 | jones[1].boris = 56; 30 | jones[1].natasha = 78; 31 | 32 | printf("%d\n", jones[0].boris); 33 | printf("%d\n", jones[0].natasha); 34 | printf("%d\n", jones[1].boris); 35 | printf("%d\n", jones[1].natasha); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/24_math_library.c: -------------------------------------------------------------------------------- 1 | #define _ISOC99_SOURCE 1 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | printf("%f\n", sin(0.12)); 9 | printf("%f\n", cos(0.12)); 10 | printf("%f\n", tan(0.12)); 11 | printf("%f\n", asin(0.12)); 12 | printf("%f\n", acos(0.12)); 13 | printf("%f\n", atan(0.12)); 14 | printf("%f\n", sinh(0.12)); 15 | printf("%f\n", cosh(0.12)); 16 | printf("%f\n", tanh(0.12)); 17 | printf("%f\n", exp(0.12)); 18 | printf("%f\n", fabs(-0.12)); 19 | printf("%f\n", log(0.12)); 20 | printf("%f\n", log10(0.12)); 21 | printf("%f\n", pow(0.12, 0.12)); 22 | printf("%f\n", sqrt(0.12)); 23 | printf("%f\n", round(12.34)); 24 | printf("%f\n", ceil(12.34)); 25 | printf("%f\n", floor(12.34)); 26 | 27 | return 0; 28 | } 29 | 30 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 31 | -------------------------------------------------------------------------------- /lib/tinycc/win32/lib/crtinit.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | 3 | #ifdef __leading_underscore 4 | # define _(s) s 5 | #else 6 | # define _(s) _##s 7 | #endif 8 | 9 | extern void (*_(_init_array_start)[]) (int argc, _TCHAR **argv, _TCHAR **envp); 10 | extern void (*_(_init_array_end)[]) (int argc, _TCHAR **argv, _TCHAR **envp); 11 | extern void (*_(_fini_array_start)[]) (void); 12 | extern void (*_(_fini_array_end)[]) (void); 13 | 14 | static void run_ctors(int argc, _TCHAR **argv, _TCHAR **env) 15 | { 16 | int i = 0; 17 | while (&_(_init_array_start)[i] != _(_init_array_end)) 18 | (*_(_init_array_start)[i++])(argc, argv, env); 19 | } 20 | 21 | static void run_dtors(void) 22 | { 23 | int i = 0; 24 | while (&_(_fini_array_end)[i] != _(_fini_array_start)) 25 | (*_(_fini_array_end)[--i])(); 26 | } 27 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/96_nodata_wanted.expect: -------------------------------------------------------------------------------- 1 | [test_static_data_error] 2 | 96_nodata_wanted.c:7: error: initializer element is not computable at load time 3 | 4 | [test_static_nodata_error] 5 | 96_nodata_wanted.c:14: error: initializer element is not computable at load time 6 | 7 | [test_global_data_error] 8 | 96_nodata_wanted.c:20: error: initializer element is not computable at load time 9 | 10 | [test_local_data_noerror] 11 | 96_nodata_wanted.c:25: warning: assignment makes integer from pointer without a cast 12 | 96_nodata_wanted.c:25: warning: cast between pointer and integer of different size 13 | 14 | [test_data_suppression_off] 15 | data: 16 | 8 - 8.0 - 8.0 - main - static string 17 | 333 44 555555 6 7 18 | size of data/text: 19 | non-zero/non-zero 20 | 21 | [test_data_suppression_on] 22 | size of data/text: 23 | zero/zero 24 | 25 | [test_static_data] 26 | a = 1 27 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/54_goto.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void fred() 4 | { 5 | printf("In fred()\n"); 6 | goto done; 7 | printf("In middle\n"); 8 | done: 9 | printf("At end\n"); 10 | } 11 | 12 | void joe() 13 | { 14 | int b = 5678; 15 | 16 | printf("In joe()\n"); 17 | 18 | { 19 | int c = 1234; 20 | printf("c = %d\n", c); 21 | goto outer; 22 | printf("uh-oh\n"); 23 | } 24 | 25 | outer: 26 | 27 | printf("done\n"); 28 | } 29 | 30 | void henry() 31 | { 32 | int a; 33 | 34 | printf("In henry()\n"); 35 | goto inner; 36 | 37 | { 38 | int b; 39 | inner: 40 | b = 1234; 41 | printf("b = %d\n", b); 42 | } 43 | 44 | printf("done\n"); 45 | } 46 | 47 | int main() 48 | { 49 | fred(); 50 | joe(); 51 | henry(); 52 | 53 | return 0; 54 | } 55 | 56 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 57 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/11.c: -------------------------------------------------------------------------------- 1 | #define D1(s, ...) s 2 | #define D2(s, ...) s D1(__VA_ARGS__) 3 | #define D3(s, ...) s D2(__VA_ARGS__) 4 | #define D4(s, ...) s D3(__VA_ARGS__) 5 | 6 | D1(a) 7 | D2(a, b) 8 | D3(a, b, c) 9 | D4(a, b, c, d) 10 | 11 | x D4(a, b, c, d) y 12 | x D4(a, b, c) y 13 | x D4(a, b) y 14 | x D4(a) y 15 | x D4() y 16 | 17 | #define GNU_COMMA(X,Y...) X,##Y 18 | 19 | x GNU_COMMA(A,B,C) y 20 | x GNU_COMMA(A,B) y 21 | x GNU_COMMA(A) y 22 | x GNU_COMMA() y 23 | 24 | #define __sun_attr___noreturn__ __attribute__((__noreturn__)) 25 | #define ___sun_attr_inner(__a) __sun_attr_##__a 26 | #define __sun_attr__(__a) ___sun_attr_inner __a 27 | #define __NORETURN __sun_attr__((__noreturn__)) 28 | __NORETURN 29 | #define X(...) 30 | #define Y(...) 1 __VA_ARGS__ 2 31 | Y(X X() ()) 32 | 33 | #define DDD(A, B) D_ ## B ## _D_ ## A 34 | #define CCC(X, ...) DDD(X,## __VA_ARGS__) 35 | /* must be D_B_D_A (not D_B _D_A) */ 36 | CCC(A,B) 37 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/101_cleanup.expect: -------------------------------------------------------------------------------- 1 | c: a 2 | c: o 3 | glob_i: 65536 4 | oo: 2.600000 5 | c: f 6 | str: I don't think this should be print(but gcc got it wrong too) 7 | because what if free was call inside cleanup function I don't think this should be print(but gcc got it wrong too) 8 | should be print before 9 | str: that 10 | str: this should appear only once 11 | str: -that2 12 | str: -that 13 | str: test2 14 | str: one 15 | ---- 1 16 | str: two 17 | str: three 18 | -- loop 0 -- 19 | 100 20 | 100 21 | 100 22 | 100 23 | 100 24 | 100 25 | 100 26 | 100 27 | 100 28 | 100 29 | 10 30 | -- loop 1 -- 31 | 200 32 | 200 33 | 200 34 | 200 35 | 200 36 | 200 37 | 200 38 | 200 39 | 200 40 | 200 41 | 10 42 | -- loop 2 -- 43 | 300 44 | 0 45 | -- loop 3 -- 46 | 400 47 | 500 48 | 400 49 | after break 50 | 1000 51 | ---- 0 52 | ---- 1 53 | str: plop 54 | str: tata ! 55 | str: 3 56 | str: 2 57 | str: 1 58 | str: last goto out 59 | str: wololo 60 | -------------------------------------------------------------------------------- /src/io.c: -------------------------------------------------------------------------------- 1 | /* CJIT https://dyne.org/cjit 2 | * 3 | * Copyright (C) 2024 Dyne.org foundation 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sec_api/search_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_SEARCH_S 7 | #define _INC_SEARCH_S 8 | 9 | #include 10 | 11 | #if defined(MINGW_HAS_SECURE_API) 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | _CRTIMP void *__cdecl _lfind_s(const void *_Key,const void *_Base,unsigned int *_NumOfElements,size_t _SizeOfElements,int (__cdecl *_PtFuncCompare)(void *,const void *,const void *),void *_Context); 18 | _CRTIMP void *__cdecl _lsearch_s(const void *_Key,void *_Base,unsigned int *_NumOfElements,size_t _SizeOfElements,int (__cdecl *_PtFuncCompare)(void *,const void *,const void *),void *_Context); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/123_vla_bug.c: -------------------------------------------------------------------------------- 1 | typedef __SIZE_TYPE__ size_t; 2 | extern int printf(const char*, ...); 3 | extern size_t strlen(const char*); 4 | char str[] = "blabla"; 5 | int g; 6 | int main() 7 | { 8 | //char helpme[strlen(str) + 1]; 9 | int i = 0; 10 | #if 0 11 | if (g) { 12 | char buf[strlen(str) + 10]; 13 | buf[0] = 0; 14 | } 15 | alabel: 16 | printf("default: i = %d\n", i); 17 | #else 18 | for (i = 0; i < 5; i++) { 19 | switch (i) { 20 | case 10: 21 | if (g) { 22 | char buf[strlen(str) + 10]; 23 | buf[0] = 0; 24 | goto do_cmd; 25 | } 26 | break; 27 | case 1: 28 | printf("reached 3\n"); 29 | do_cmd: 30 | printf("after do_cmd"); 31 | break; 32 | default: 33 | g++; 34 | printf("default: i = %d\n", i); 35 | break; 36 | } 37 | } 38 | #endif 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /test/bats/lib/bats-core/preprocessing.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BATS_TMPNAME="$BATS_RUN_TMPDIR/bats.$$" 4 | BATS_PARENT_TMPNAME="$BATS_RUN_TMPDIR/bats.$PPID" 5 | # shellcheck disable=SC2034 6 | BATS_OUT="${BATS_TMPNAME}.out" # used in bats-exec-file 7 | 8 | bats_preprocess_source() { 9 | # export to make it visible to bats_evaluate_preprocessed_source 10 | # since the latter runs in bats-exec-test's bash while this runs in bats-exec-file's 11 | export BATS_TEST_SOURCE="${BATS_TMPNAME}.src" 12 | # shellcheck disable=SC2153 13 | CHECK_BATS_COMMENT_COMMANDS=1 "$BATS_ROOT/libexec/bats-core/bats-preprocess" "$BATS_TEST_FILENAME" >"$BATS_TEST_SOURCE" 14 | } 15 | 16 | bats_evaluate_preprocessed_source() { 17 | if [[ -z "${BATS_TEST_SOURCE:-}" ]]; then 18 | BATS_TEST_SOURCE="${BATS_PARENT_TMPNAME}.src" 19 | fi 20 | # Dynamically loaded user files provided outside of Bats. 21 | # shellcheck disable=SC1090 22 | source "$BATS_TEST_SOURCE" 23 | } 24 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/86_memory-model.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int 4 | main() 5 | { 6 | #if defined(__LLP64__) 7 | if (sizeof(short) == 2 8 | && sizeof(int) == 4 9 | && sizeof(long int) == 4 10 | && sizeof(long long int) == 8 11 | && sizeof(void*) == 8) { 12 | (void)printf("Ok\n"); 13 | } else { 14 | (void)printf("KO __LLP64__\n"); 15 | } 16 | #elif defined(__LP64__) 17 | if (sizeof(short) == 2 18 | && sizeof(int) == 4 19 | && sizeof(long int) == 8 20 | && sizeof(long long int) == 8 21 | && sizeof(void*) == 8) { 22 | (void)printf("Ok\n"); 23 | } else { 24 | (void)printf("KO __LP64__\n"); 25 | } 26 | #elif defined(__ILP32__) 27 | if (sizeof(short) == 2 28 | && sizeof(int) == 4 29 | && sizeof(long int) == 4 30 | && sizeof(void*) == 4) { 31 | (void)printf("Ok\n"); 32 | } else { 33 | (void)printf("KO __ILP32__\n"); 34 | } 35 | #else 36 | (void)printf("KO no __*LP*__ defined.\n"); 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /LICENSES/MIT-0.txt: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 6 | software and associated documentation files (the "Software"), to deal in the Software 7 | without restriction, including without limitation the rights to use, copy, modify, 8 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 12 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 13 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 14 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 15 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 16 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | -------------------------------------------------------------------------------- /LICENSES/LLVM-exception.txt: -------------------------------------------------------------------------------- 1 | ---- LLVM Exceptions to the Apache 2.0 License ---- 2 | 3 | As an exception, if, as a result of your compiling your source code, portions 4 | of this Software are embedded into an Object form of such source code, you 5 | may redistribute such embedded portions in such Object form without complying 6 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 7 | 8 | In addition, if you combine or link compiled forms of this Software with 9 | software that is licensed under the GPLv2 ("Combined Software") and if a 10 | court of competent jurisdiction determines that the patent provision (Section 11 | 3), the indemnity provision (Section 9) or other Section of the License 12 | conflicts with the conditions of the GPLv2, you may retroactively and 13 | prospectively choose to deem waived or otherwise exclude such Section(s) of 14 | the License, but only in their entirety and only with respect to the Combined 15 | Software. 16 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/11_precedence.c: -------------------------------------------------------------------------------- 1 | //#include 2 | extern int printf(const char *, ...); 3 | 4 | int main() 5 | { 6 | int a; 7 | int b; 8 | int c; 9 | int d; 10 | int e; 11 | int f; 12 | int x; 13 | int y; 14 | 15 | a = 12; 16 | b = 34; 17 | c = 56; 18 | d = 78; 19 | e = 0; 20 | f = 1; 21 | 22 | printf("%d\n", c + d); 23 | printf("%d\n", (y = c + d)); 24 | printf("%d\n", e || e && f); 25 | printf("%d\n", e || f && f); 26 | printf("%d\n", e && e || f); 27 | printf("%d\n", e && f || f); 28 | printf("%d\n", a && f | f); 29 | printf("%d\n", a | b ^ c & d); 30 | printf("%d, %d\n", a == a, a == b); 31 | printf("%d, %d\n", a != a, a != b); 32 | printf("%d\n", a != b && c != d); 33 | printf("%d\n", a + b * c / f); 34 | printf("%d\n", a + b * c / f); 35 | printf("%d\n", (4 << 4)); 36 | printf("%d\n", (64 >> 4)); 37 | 38 | return 0; 39 | } 40 | 41 | // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : 42 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sec_api/stralign_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef __STRALIGN_H_S_ 7 | #define __STRALIGN_H_S_ 8 | 9 | #include 10 | 11 | #if defined(MINGW_HAS_SECURE_API) 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #if !defined(I_X86_) && defined(_WSTRING_S_DEFINED) 18 | #if defined(__cplusplus) && defined(_WConst_Return) 19 | static __inline PUWSTR ua_wcscpy_s(PUWSTR Destination,size_t DestinationSize,PCUWSTR Source) { 20 | if(WSTR_ALIGNED(Source) && WSTR_ALIGNED(Destination)) return (wcscpy_s((PWSTR)Destination,DestinationSize,(PCWSTR)Source)==0 ? Destination : NULL); 21 | return uaw_wcscpy((PCUWSTR)String,Character); 22 | } 23 | #endif 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/78_vla_label.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* This test segfaults as of April 27, 2015. */ 4 | void f1(int argc) 5 | { 6 | char test[argc]; 7 | if(0) 8 | label: 9 | printf("boom!\n"); 10 | if(argc-- == 0) 11 | return; 12 | goto label; 13 | } 14 | 15 | /* This segfaulted on 2015-11-19. */ 16 | void f2(void) 17 | { 18 | goto start; 19 | { 20 | int a[1 && 1]; /* not a variable-length array */ 21 | int b[1 || 1]; /* not a variable-length array */ 22 | int c[1 ? 1 : 1]; /* not a variable-length array */ 23 | start: 24 | a[0] = 0; 25 | b[0] = 0; 26 | c[0] = 0; 27 | } 28 | } 29 | 30 | void f3(void) 31 | { 32 | printf("%d\n", 0 ? printf("x1\n") : 11); 33 | printf("%d\n", 1 ? 12 : printf("x2\n")); 34 | printf("%d\n", 0 && printf("x3\n")); 35 | printf("%d\n", 1 || printf("x4\n")); 36 | } 37 | 38 | int main() 39 | { 40 | f1(2); 41 | f2(); 42 | f3(); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /test/dmon.bats: -------------------------------------------------------------------------------- 1 | load bats_setup 2 | 3 | @test "DMON monitoring of filesystem" { 4 | 5 | # Check if the script is being run by PowerShell 6 | [ -r ${R}/.build_done_win ] && { 7 | >&3 echo ">> Skipping DMON test on Windows PowerShell" 8 | >&3 echo ">> TODO: run in background, test monitor and quit in PS" 9 | return 0 10 | } 11 | ${CJIT} -v 2>&1| grep '^Build: MUSL' && { 12 | >&3 echo ">> Skipping DMON test on MUSL libc build" 13 | return 0 14 | } 15 | 16 | (sleep 1; 17 | rm -f ${TMP}/dmon_test_create.txt; 18 | touch ${TMP}/dmon_test_create.txt; 19 | rm -f ${TMP}/dmon_test_create.txt; 20 | sleep 2; 21 | kill -HUP `cat ${TMP}/test_dmon.pid`) & 22 | 23 | run ${CJIT} -p ${TMP}/test_dmon.pid -I${T} ${T}/dmon.c -- ${TMP} 24 | # assert_failure # TODO: cleaner way than kill -HUP 25 | assert_line --regexp '^CREATE:.*dmon_test_create.txt$' 26 | assert_line --regexp '^DELETE:.*dmon_test_create.txt$' 27 | } 28 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/76_dollars_in_identifiers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define $(x) x 4 | #define $fred 10 5 | #define joe$ 20 6 | #define hen$y 30 7 | 8 | #define $10(x) x*10 9 | #define _$10(x) x/10 10 | 11 | int main() 12 | { 13 | printf("fred=%d\n", $fred); 14 | printf("joe=%d\n", joe$); 15 | printf("henry=%d\n", hen$y); 16 | 17 | printf("fred2=%d\n", $($fred)); 18 | printf("joe2=%d\n", $(joe$)); 19 | printf("henry2=%d\n", $(hen$y)); 20 | 21 | printf("fred10=%d\n", $10($fred)); 22 | printf("joe_10=%d\n", _$10(joe$)); 23 | 24 | int $ = 10; 25 | int a100$ = 100; 26 | int a$$ = 1000; 27 | int a$c$b = 2121; 28 | int $100 = 10000; 29 | const char *$$$ = "money"; 30 | 31 | printf("local=%d\n", $); 32 | printf("a100$=%d\n", a100$); 33 | printf("a$$=%d\n", a$$); 34 | printf("a$c$b=%d\n", a$c$b); 35 | printf("$100=%d\n", $100); 36 | printf("$$$=%s", $$$); 37 | 38 | return 0; 39 | } 40 | 41 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 42 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/22_floating_point.expect: -------------------------------------------------------------------------------- 1 | 69.119995 -631.327881 2 | 69.12 -631.328 3 | 69.120000 -631.327870 4 | 69.119995 -44.439999 700.665222 0.217330 5 | 69.12 -44.44 700.665 0.21733 6 | 69.120000 -44.440000 700.665200 0.217330 7 | 69.119995 -44.439999 700.665222 0.217330 8 | 69.12 -44.44 700.665 0.21733 9 | 69.120000 -44.440000 700.665200 0.217330 10 | 1 1 0 0 0 1 11 | 0 1 1 1 0 0 12 | 0 0 0 1 1 1 13 | 1 1 0 0 0 1 14 | 0 1 1 1 0 0 15 | 0 0 0 1 1 1 16 | 1 1 0 0 0 1 17 | 0 1 1 1 0 0 18 | 0 0 0 1 1 1 19 | 1 1 0 0 0 1 20 | 0 1 1 1 0 0 21 | 0 0 0 1 1 1 22 | 1 1 0 0 0 1 23 | 0 1 1 1 0 0 24 | 0 0 0 1 1 1 25 | 1 1 0 0 0 1 26 | 0 1 1 1 0 0 27 | 0 0 0 1 1 1 28 | 0 1 1 0 1 0 29 | 69.119995 69.12 69.120000 30 | 69.119995 69.12 69.120000 31 | -44.439999 -44.44 -44.440000 32 | -44.439999 -44.44 -44.440000 33 | 700.665222 700.665 700.665200 34 | 700.665222 700.665 700.665200 35 | 0.217330 0.21733 0.217330 36 | 0.217330 0.21733 0.217330 37 | 12.340000 12.34 12.340000 38 | -12.340000 -12.34 -12.340000 39 | 2.000000 40 | 0.909297 41 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/23_type_coercion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void charfunc(char a) 4 | { 5 | printf("char: %c\n", a); 6 | } 7 | 8 | void intfunc(int a) 9 | { 10 | printf("int: %d\n", a); 11 | } 12 | 13 | void floatfunc(float a) 14 | { 15 | printf("float: %f\n", a); 16 | } 17 | 18 | int main() 19 | { 20 | charfunc('a'); 21 | charfunc(98); 22 | charfunc(99.0); 23 | 24 | intfunc('a'); 25 | intfunc(98); 26 | intfunc(99.0); 27 | 28 | floatfunc('a'); 29 | floatfunc(98); 30 | floatfunc(99.0); 31 | 32 | /* printf("%c %d %f\n", 'a', 'b', 'c'); */ 33 | /* printf("%c %d %f\n", 97, 98, 99); */ 34 | /* printf("%c %d %f\n", 97.0, 98.0, 99.0); */ 35 | 36 | char b = 97; 37 | char c = 97.0; 38 | 39 | printf("%d %d\n", b, c); 40 | 41 | int d = 'a'; 42 | int e = 97.0; 43 | 44 | printf("%d %d\n", d, e); 45 | 46 | float f = 'a'; 47 | float g = 97; 48 | 49 | printf("%f %f\n", f, g); 50 | 51 | return 0; 52 | } 53 | 54 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 55 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/18.c: -------------------------------------------------------------------------------- 1 | #define M_RETI_ARG27(x,y,z,aa, ...) aa 2 | #define M_RET_ARG27(...) M_RETI_ARG27(__VA_ARGS__) 3 | #define M_COMMA_P(...) M_RET_ARG27(__VA_ARGS__, 1, 1, 0, useless) 4 | #define M_EMPTYI_DETECT(...) 0, 1, 5 | #define M_EMPTYI_P_C1(...) M_COMMA_P(M_EMPTYI_DETECT __VA_ARGS__ () ) 6 | #define EX 7 | #define empty(x) 8 | #define fnlike(x) yeah x 9 | /* If the following macro is called with empty arg (X183), the use 10 | of 'x' between fnlike and '(' doesn't hinder the recognition of this 11 | being a further fnlike macro invocation. */ 12 | #define usefnlike(x) fnlike x (x) 13 | X181 M_EMPTYI_P_C1() 14 | X182 M_EMPTYI_P_C1(x) 15 | X183 usefnlike() 16 | 17 | #define ABC(x) ABC : x 18 | #define A(a,b,c) a ## b ## c 19 | #define B(a,b,c) A(a,b,c) 20 | #define C(a,b,c) a b c 21 | B( 22 | C(A,C(,,),), 23 | C(B(,,),B,B(,,)), 24 | C(B(,,),B(,,),C) 25 | )/* */(a b c) 26 | 27 | #define TEST(x) TEST : x 28 | #define K(a,b) a ## b 29 | #define L(a,b) K( TE a , b ST ) 30 | L(,)(t e s t) 31 | -------------------------------------------------------------------------------- /test/test_helper/bats_assert/src/assert_equal.bash: -------------------------------------------------------------------------------- 1 | # assert_equal 2 | # ============ 3 | # 4 | # Summary: Fail if the actual and expected values are not equal. 5 | # 6 | # Usage: assert_equal 7 | # 8 | # Options: 9 | # The value being compared. 10 | # The value to compare against. 11 | # 12 | # ```bash 13 | # @test 'assert_equal()' { 14 | # assert_equal 'have' 'want' 15 | # } 16 | # ``` 17 | # 18 | # IO: 19 | # STDERR - expected and actual values, on failure 20 | # Globals: 21 | # none 22 | # Returns: 23 | # 0 - if values equal 24 | # 1 - otherwise 25 | # 26 | # On failure, the expected and actual values are displayed. 27 | # 28 | # ``` 29 | # -- values do not equal -- 30 | # expected : want 31 | # actual : have 32 | # -- 33 | # ``` 34 | assert_equal() { 35 | if [[ $1 != "$2" ]]; then 36 | batslib_print_kv_single_or_multi 8 \ 37 | 'expected' "$2" \ 38 | 'actual' "$1" \ 39 | | batslib_decorate 'values do not equal' \ 40 | | fail 41 | fi 42 | } 43 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sec_api/io_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_IO_S 7 | #define _INC_IO_S 8 | 9 | #include 10 | 11 | #if defined(MINGW_HAS_SECURE_API) 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | _CRTIMP errno_t __cdecl _access_s(const char *_Filename,int _AccessMode); 18 | _CRTIMP errno_t __cdecl _chsize_s(int _FileHandle,__int64 _Size); 19 | _CRTIMP errno_t __cdecl _mktemp_s(char *_TemplateName,size_t _Size); 20 | _CRTIMP errno_t __cdecl _umask_s(int _NewMode,int *_OldMode); 21 | 22 | #ifndef _WIO_S_DEFINED 23 | #define _WIO_S_DEFINED 24 | _CRTIMP errno_t __cdecl _waccess_s(const wchar_t *_Filename,int _AccessMode); 25 | _CRTIMP errno_t __cdecl _wmktemp_s(wchar_t *_TemplateName,size_t _SizeInWords); 26 | #endif 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /test/test_helper/bats_assert/src/assert_success.bash: -------------------------------------------------------------------------------- 1 | # assert_success 2 | # ============== 3 | # 4 | # Summary: Fail if `$status` is not 0. 5 | # 6 | # Usage: assert_success 7 | # 8 | # IO: 9 | # STDERR - `$status` and `$output`, on failure 10 | # Globals: 11 | # status 12 | # output 13 | # Returns: 14 | # 0 - if `$status' is 0 15 | # 1 - otherwise 16 | # 17 | # ```bash 18 | # @test 'assert_success() status only' { 19 | # run bash -c "echo 'Error!'; exit 1" 20 | # assert_success 21 | # } 22 | # ``` 23 | # 24 | # On failure, `$status` and `$output` are displayed. 25 | # 26 | # ``` 27 | # -- command failed -- 28 | # status : 1 29 | # output : Error! 30 | # -- 31 | # ``` 32 | assert_success() { 33 | : "${output?}" 34 | : "${status?}" 35 | 36 | if (( status != 0 )); then 37 | { local -ir width=6 38 | batslib_print_kv_single "$width" 'status' "$status" 39 | batslib_print_kv_single_or_multi "$width" 'output' "$output" 40 | } \ 41 | | batslib_decorate 'command failed' \ 42 | | fail 43 | fi 44 | } 45 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/130_large_argument.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct large1 { 4 | int a[768]; 5 | }; 6 | 7 | struct large2 { 8 | int a[1920]; 9 | }; 10 | 11 | void pass_large_struct1(struct large1 in) 12 | { 13 | printf("%d %d\n", in.a[200], in.a[767]); 14 | return; 15 | } 16 | 17 | void pass_large_struct2(struct large2 in) 18 | { 19 | printf("%d %d %d\n", in.a[200], in.a[1023], in.a[1919]); 20 | return; 21 | } 22 | 23 | void pass_many_args(int a, int b, int c, int d, int e, int f, int g, int h, int i, 24 | int j, int k, int l, int m) 25 | { 26 | printf("%d %d %d %d %d %d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h, i, 27 | j, k, l, m); 28 | return; 29 | } 30 | 31 | struct large1 l1 = { .a = { [200] = 1, [767] = 2 } }; 32 | struct large2 l2 = { .a = { [200] = 3, [1023] = 4, [1919] = 5} }; 33 | 34 | int main(void) 35 | { 36 | pass_large_struct1(l1); 37 | pass_large_struct2(l2); 38 | pass_many_args(13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/93_integer_promotion.expect: -------------------------------------------------------------------------------- 1 | signed : s.ub 2 | unsigned : s.u 3 | signed : s.ullb 4 | unsigned : s.ull 5 | signed : s.c 6 | 7 | signed : (1 ? s.ub : 1) 8 | unsigned : (1 ? s.u : 1) 9 | signed : (1 ? s.ullb : 1) 10 | unsigned : (1 ? s.ull : 1) 11 | signed : (1 ? s.c : 1) 12 | 13 | signed : s.ub << 1 14 | unsigned : s.u << 1 15 | signed : s.ullb << 1 16 | unsigned : s.ull << 1 17 | signed : s.c << 1 18 | 19 | signed : +s.ub 20 | unsigned : +s.u 21 | signed : +s.ullb 22 | unsigned : +s.ull 23 | signed : +s.c 24 | 25 | signed : -s.ub 26 | unsigned : -s.u 27 | signed : -s.ullb 28 | unsigned : -s.ull 29 | signed : -s.c 30 | 31 | signed : ~s.ub 32 | unsigned : ~s.u 33 | signed : ~s.ullb 34 | unsigned : ~s.ull 35 | signed : ~s.c 36 | 37 | signed : !s.ub 38 | signed : !s.u 39 | signed : !s.ullb 40 | signed : !s.ull 41 | signed : !s.c 42 | 43 | unsigned : +(unsigned)s.ub 44 | unsigned : -(unsigned)s.ub 45 | unsigned : ~(unsigned)s.ub 46 | signed : !(unsigned)s.ub 47 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/102_alignas.c: -------------------------------------------------------------------------------- 1 | _Alignas(16) int i1; 2 | int _Alignas(16) i2; 3 | void _Alignas(16) *p2; 4 | _Alignas(16) i3; 5 | int _Alignas(double) i4; 6 | int _Alignas(int) i5; 7 | #if 0 8 | /* The following are currently wrongly accepted by TCC but really shouldn't. */ 9 | int _Alignas(int _Alignas(16)) i6; //wrong, 'int _Alignas(16)' is no type-name 10 | typedef int _Alignas(16) int16aligned_t; //wrong, _Alignas invalid on typedef 11 | int16aligned_t i7; 12 | #endif 13 | /* i8 should get an alignment of 16, because unlike _Alignas the 14 | corresponding attribute _does_ apply to type-name, though not in 15 | some clang versions. */ 16 | int _Alignas(int __attribute__((aligned(16)))) i8; 17 | extern int printf(const char*, ...); 18 | #ifdef _MSC_VER 19 | #define alignof(x) (int)__alignof(x) 20 | #else 21 | #define alignof(x) (int)__alignof__(x) 22 | #endif 23 | int main() 24 | { 25 | printf("%d %d %d %d\n", 26 | alignof(i1) == 16, alignof(i4) == alignof(double), 27 | alignof(i5) == alignof(int) , alignof(i8) == 16); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/120_alias.c: -------------------------------------------------------------------------------- 1 | /* Check semantics of various constructs to generate renamed symbols. */ 2 | 3 | extern int printf (const char *, ...); 4 | void target(void); 5 | void target(void) { 6 | printf("in target function\n"); 7 | } 8 | void alias_for_target(void) __attribute__((alias("target"))); 9 | 10 | int g_int = 34; 11 | int alias_int __attribute__((alias("g_int"))); 12 | 13 | #ifdef __leading_underscore 14 | # define _ "_" 15 | #else 16 | # define _ 17 | #endif 18 | 19 | void asm_for_target(void) __asm__(_"target"); 20 | int asm_int __asm__(_"g_int"); 21 | 22 | /* This is not supposed to compile, alias targets must be defined in the 23 | same unit. In TCC they even must be defined before the reference 24 | void alias_for_undef(void) __attribute__((alias("undefined"))); 25 | */ 26 | 27 | extern void inunit2(void); 28 | 29 | int main(void) 30 | { 31 | target(); 32 | alias_for_target(); 33 | asm_for_target(); 34 | printf("g_int = %d\nalias_int = %d\nasm_int = %d\n", g_int, alias_int, asm_int); 35 | inunit2(); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /lib/tinycc/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | \#* 3 | .#* 4 | *.o 5 | *.a 6 | *.exe 7 | *.dll 8 | *.obj 9 | *.pdb 10 | *.lib 11 | *.exp 12 | *.log 13 | *.bz2 14 | *.zip 15 | .gdb_history 16 | a.out 17 | tcc_g 18 | tcc 19 | tcc_c 20 | tcc_p 21 | *-tcc 22 | libtcc*.def 23 | 24 | config*.h 25 | *_.h 26 | config*.mak 27 | config.texi 28 | c2str 29 | tags 30 | TAGS 31 | tcc.1 32 | *.pod 33 | *.tcov 34 | tcc-doc.html 35 | tcc-doc.info 36 | 37 | win32/doc 38 | win32/examples/libtcc_test.c 39 | win32/libtcc 40 | win32/lib/32 41 | win32/lib/64 42 | win32/include/float.h 43 | win32/include/stdalign.h 44 | win32/include/stdarg.h 45 | win32/include/stdbool.h 46 | win32/include/stddef.h 47 | win32/include/stdnoreturn.h 48 | win32/include/varargs.h 49 | win32/include/tcclib.h 50 | 51 | tests/tcctest[1234] 52 | tests/tcctest.gcc 53 | tests/*.out* 54 | tests/*.ref 55 | tests/*.txt 56 | tests/*.gcc 57 | tests/*-cc* 58 | tests/*-tcc* 59 | tests/libtcc_test 60 | tests/libtcc_test_mt 61 | tests/asm-c-connect 62 | tests/asm-c-connect-sep 63 | tests/vla_test 64 | tests/hello 65 | tests/tests2/fred.txt 66 | libtcc.dylib 67 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/61_integers.expect: -------------------------------------------------------------------------------- 1 | 18/21=0 2 | 18%21=18 3 | 41/21=1 4 | 41%21=20 5 | 42/21=2 6 | 42%21=0 7 | 43/21=2 8 | 43%21=1 9 | 126/21=6 10 | 126%21=0 11 | 131/21=6 12 | 131%21=5 13 | (UINT_MAX/2+3)/2=1073741825 14 | (UINT_MAX/2+3)%2=0 15 | 18/-21=0 16 | 18%-21=18 17 | 41/-21=4294967295 18 | 41%-21=20 19 | 42/-21=4294967294 20 | 42%-21=0 21 | 43/-21=4294967294 22 | 43%-21=1 23 | 126/-21=4294967290 24 | 126%-21=0 25 | 131/-21=4294967290 26 | 131%-21=5 27 | (UINT_MAX/2+3)/-2=0 28 | (UINT_MAX/2+3)%-2=2147483650 29 | -18/21=0 30 | -18%21=4294967278 31 | -41/21=4294967295 32 | -41%21=4294967276 33 | -42/21=4294967294 34 | -42%21=0 35 | -43/21=4294967294 36 | -43%21=4294967295 37 | -126/21=4294967290 38 | -126%21=0 39 | -131/21=4294967290 40 | -131%21=4294967291 41 | -(UINT_MAX/2+3)/2=1073741823 42 | -(UINT_MAX/2+3)%2=0 43 | -18/-21=0 44 | -18%-21=4294967278 45 | -41/-21=1 46 | -41%-21=4294967276 47 | -42/-21=2 48 | -42%-21=0 49 | -43/-21=2 50 | -43%-21=4294967295 51 | -126/-21=6 52 | -126%-21=0 53 | -131/-21=6 54 | -131%-21=4294967291 55 | -(UINT_MAX/2+3)/-2=0 56 | -(UINT_MAX/2+3)%-2=2147483646 57 | -------------------------------------------------------------------------------- /lib/tinycc/tests/asm-c-connect-2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore) 4 | # define _ "_" 5 | #else 6 | # define _ 7 | #endif 8 | 9 | #ifdef __clang__ 10 | /* clang needs some help tp not throw functions away even at -O0 */ 11 | #define __USED __attribute__((__used__)) 12 | #else 13 | #define __USED 14 | #endif 15 | 16 | int x3(void) 17 | { 18 | printf(" x3"); 19 | return 3; 20 | } 21 | 22 | /* That callx4 is defined globally (as if ".globl callx4") 23 | is a TCC extension. GCC doesn't behave like this. */ 24 | void callx4(void); 25 | #if __i386__ 26 | __asm__(_"callx4: call "_"x4; ret;" 27 | #else 28 | /* Keep stack aligned */ 29 | __asm__(_"callx4: sub $8,%rsp; call "_"x4; add $8,%rsp; ret;" 30 | #endif 31 | #ifndef __TINYC__ 32 | " .global "_"callx4" 33 | #endif 34 | ); 35 | 36 | extern void x5(void); 37 | 38 | void callx5_again(void); 39 | void callx5_again(void) 40 | { 41 | x5(); 42 | asm("call "_"x6"); 43 | } 44 | 45 | static void __USED x6() 46 | { 47 | printf(" x6-2"); 48 | } 49 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/dir.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | /* 7 | * dir.h 8 | * 9 | * This file OBSOLESCENT and only provided for backward compatibility. 10 | * Please use io.h instead. 11 | * 12 | * This file is part of the Mingw32 package. 13 | * 14 | * Contributors: 15 | * Created by Colin Peters 16 | * Mumit Khan 17 | * 18 | * THIS SOFTWARE IS NOT COPYRIGHTED 19 | * 20 | * This source code is offered for use in the public domain. You may 21 | * use, modify or distribute it freely. 22 | * 23 | * This code is distributed in the hope that it will be useful but 24 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 25 | * DISCLAIMED. This includes but is not limited to warranties of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | * 28 | */ 29 | 30 | #include 31 | 32 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/uchar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the TinyCC package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | 7 | #ifndef _INC_UCHAR 8 | #define _INC_UCHAR 9 | 10 | /* 11 | * The following defines are only valid when C11 (-std=c11) is used. 12 | * 13 | * ... a wide character constant prefixed by the letter u or U has type char16_t 14 | * or char32_t, respectively, unsigned integer types defined in the 15 | * header. 16 | */ 17 | 18 | #if __STDC_VERSION__ >= 201112L 19 | /** 20 | * __STDC_UTF_16__ The integer constant 1, intended to indicate that 21 | * values of type char16_t are UTF-16 encoded. 22 | */ 23 | #define __STDC_UTF_16__ 1 24 | /** 25 | * __STDC_UTF_32__ The integer constant 1, intended to indicate that 26 | * values of type char32_t are UTF-32 encoded. 27 | */ 28 | #define __STDC_UTF_32__ 1 29 | 30 | typedef unsigned short char16_t; 31 | typedef unsigned int char32_t; 32 | #endif /* __STDC_VERSION__ >= 201112L */ 33 | #endif /* _INC_UCHAR */ 34 | -------------------------------------------------------------------------------- /test/test_helper/bats_assert/src/assert_not_equal.bash: -------------------------------------------------------------------------------- 1 | # assert_not_equal 2 | # ============ 3 | # 4 | # Summary: Fail if the actual and unexpected values are equal. 5 | # 6 | # Usage: assert_not_equal 7 | # 8 | # Options: 9 | # The value being compared. 10 | # The value to compare against. 11 | # 12 | # ```bash 13 | # @test 'assert_not_equal()' { 14 | # assert_not_equal 'foo' 'foo' 15 | # } 16 | # ``` 17 | # 18 | # IO: 19 | # STDERR - expected and actual values, on failure 20 | # Globals: 21 | # none 22 | # Returns: 23 | # 0 - if actual does not equal unexpected 24 | # 1 - otherwise 25 | # 26 | # On failure, the unexpected and actual values are displayed. 27 | # 28 | # ``` 29 | # -- values should not be equal -- 30 | # unexpected : foo 31 | # actual : foo 32 | # -- 33 | # ``` 34 | assert_not_equal() { 35 | if [[ "$1" == "$2" ]]; then 36 | batslib_print_kv_single_or_multi 10 \ 37 | 'unexpected' "$2" \ 38 | 'actual' "$1" \ 39 | | batslib_decorate 'values should not be equal' \ 40 | | fail 41 | fi 42 | } 43 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/18_include.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("including\n"); 6 | #include "18_include.h" 7 | #define test_missing_nl 8 | printf("done\n"); 9 | 10 | #define INC "18_include.h" 11 | 12 | #ifdef __has_include 13 | #if defined __has_include 14 | #if __has_include("18_include.h") 15 | printf("has_include\n"); 16 | #endif 17 | #if __has_include(INC) 18 | printf("has_include\n"); 19 | #endif 20 | #if __has_include("not_found_18_include.h") 21 | printf("has_include not found\n"); 22 | #endif 23 | #endif 24 | #endif 25 | 26 | #ifdef __has_include_next 27 | #if defined __has_include_next 28 | #if __has_include_next("18_include.h") 29 | printf("has_include_next\n"); 30 | #endif 31 | #if __has_include_next(INC) 32 | printf("has_include_next\n"); 33 | #endif 34 | #if __has_include_next("not_found_18_include.h") 35 | printf("has_include_next not found\n"); 36 | #endif 37 | #endif 38 | #endif 39 | 40 | #include "18_include2.h" 41 | #include "./18_include2.h" 42 | #include "../tests2/18_include2.h" 43 | 44 | return 0; 45 | } 46 | 47 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 48 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/98_al_ax_extend.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | asm ( 4 | ".text;" 5 | ".globl _us;.globl _ss;.globl _uc;.globl _sc;" 6 | "_us:;_ss:;_uc:;_sc:;" 7 | "movl $0x1234ABCD, %eax;" 8 | "ret;" 9 | ); 10 | 11 | #ifndef __leading_underscore 12 | #define us _us 13 | #define ss _ss 14 | #define uc _uc 15 | #define sc _sc 16 | #endif 17 | 18 | int main() 19 | { 20 | unsigned short us(void); 21 | short ss(void); 22 | unsigned char uc(void); 23 | signed char sc(void); 24 | 25 | unsigned short (*fpus)(void) = us; 26 | short (*fpss)(void) = ss; 27 | unsigned char (*fpuc)(void) = uc; 28 | signed char (*fpsc)(void) = sc; 29 | 30 | printf("%08X %08X\n", us() + 1, fpus() + 1); 31 | printf("%08X %08X\n", ss() + 1, fpss() + 1); 32 | printf("%08X %08X\n", uc() + 1, fpuc() + 1); 33 | printf("%08X %08X\n", sc() + 1, fpsc() + 1); 34 | printf("\n"); 35 | printf("%08X %08X\n", fpus() + 1, us() + 1); 36 | printf("%08X %08X\n", fpss() + 1, ss() + 1); 37 | printf("%08X %08X\n", fpuc() + 1, uc() + 1); 38 | printf("%08X %08X\n", fpsc() + 1, sc() + 1); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /test/windows.bats: -------------------------------------------------------------------------------- 1 | load bats_setup 2 | 3 | @test "Timeb.h inclusion for clock() in Windows" { 4 | # see https://www.reddit.com/r/C_Programming/comments/1h1g4gc/comment/lzc9fta/ 5 | # /sys/timeb.h:132: error: include file 'sec_api/sys/timeb_s.h' not found 6 | run ${CJIT} test/win_timeb.c 7 | assert_success 8 | } 9 | 10 | @test "BOM source file UTF8" { 11 | run ${CJIT} -q test/hello-bom-utf8.c 12 | assert_failure 13 | assert_line --partial 'UTF BOM detected in file: test/hello-bom-utf8.c' 14 | assert_line --partial 'Encoding is not yet supported, execution aborted.' 15 | } 16 | 17 | @test "BOM source file UTF16 big endian" { 18 | run ${CJIT} -q test/hello-bom-utf16-be.c 19 | assert_failure 20 | assert_line --partial 'UTF BOM detected in file: test/hello-bom-utf16-be.c' 21 | assert_line --partial 'Encoding is not yet supported, execution aborted.' 22 | } 23 | 24 | @test "BOM source file UTF16 little endian" { 25 | run ${CJIT} -q test/hello-bom-utf16-le.c 26 | assert_failure 27 | assert_line --partial 'UTF BOM detected in file: test/hello-bom-utf16-le.c' 28 | assert_line --partial 'Encoding is not yet supported, execution aborted.' 29 | } 30 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/129_scopes.c: -------------------------------------------------------------------------------- 1 | #include 2 | enum{ in = 0}; 3 | #define myassert(X) do{ if(!X) printf("%d: assertion failed\n", __LINE__); }while(0) 4 | int main(){ 5 | { 6 | myassert(!in); 7 | if(sizeof(enum{in=1})) myassert(in); 8 | myassert(!in); //OOPS 9 | } 10 | { 11 | myassert(!in); 12 | switch(sizeof(enum{in=1})) { default: myassert(in); } 13 | myassert(!in); //OOPS 14 | } 15 | { 16 | myassert(!in); 17 | while(sizeof(enum{in=1})) { myassert(in); break; } 18 | myassert(!in); //OOPS 19 | } 20 | { 21 | myassert(!in); 22 | do{ myassert(!in);}while(0*sizeof(enum{in=1})); 23 | myassert(!in); //OOPS 24 | } 25 | 26 | { 27 | myassert(!in); 28 | for(sizeof(enum{in=1});;){ myassert(in); break; } 29 | myassert(!in); //OK 30 | } 31 | { 32 | myassert(!in); 33 | for(;;sizeof(enum{in=1})){ myassert(in); break; } 34 | myassert(!in); //OK 35 | } 36 | { 37 | myassert(!in); 38 | for(;sizeof(enum{in=1});){ myassert(in); break; } 39 | myassert(!in); //OK 40 | } 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/28_strings.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char a[10]; 7 | 8 | strcpy(a, "hello"); 9 | printf("%s\n", a); 10 | 11 | strncpy(a, "gosh", 2); 12 | printf("%s\n", a); 13 | 14 | printf("%d\n", strcmp(a, "apple") > 0); 15 | printf("%d\n", strcmp(a, "goere") > 0); 16 | printf("%d\n", strcmp(a, "zebra") < 0); 17 | 18 | printf("%d\n", strlen(a)); 19 | 20 | strcat(a, "!"); 21 | printf("%s\n", a); 22 | 23 | printf("%d\n", strncmp(a, "apple", 2) > 0); 24 | printf("%d\n", strncmp(a, "goere", 2) == 0); 25 | printf("%d\n", strncmp(a, "goerg", 2) == 0); 26 | printf("%d\n", strncmp(a, "zebra", 2) < 0); 27 | 28 | printf("%s\n", strchr(a, 'o')); 29 | printf("%s\n", strrchr(a, 'l')); 30 | printf("%d\n", strrchr(a, 'x') == NULL); 31 | 32 | memset(&a[1], 'r', 4); 33 | printf("%s\n", a); 34 | 35 | memcpy(&a[2], a, 2); 36 | printf("%s\n", a); 37 | 38 | printf("%d\n", memcmp(a, "apple", 4) > 0); 39 | printf("%d\n", memcmp(a, "grgr", 4) == 0); 40 | printf("%d\n", memcmp(a, "zebra", 4) < 0); 41 | 42 | return 0; 43 | } 44 | 45 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 46 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/128_run_atexit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int atexit(void (*function)(void)); 4 | int on_exit(void (*function)(int, void *), void *arg); 5 | void exit(int status); 6 | 7 | void __attribute((constructor)) startup5(void) 8 | { 9 | printf ("startup5\n"); 10 | } 11 | 12 | void cleanup1(void) 13 | { 14 | printf ("cleanup1\n"); 15 | fflush(stdout); 16 | } 17 | 18 | void cleanup2(void) 19 | { 20 | printf ("cleanup2\n"); 21 | } 22 | 23 | void cleanup3(int ret, void *arg) 24 | { 25 | printf ("%d %s\n", ret, (char *) arg); 26 | } 27 | 28 | void cleanup4(int ret, void *arg) 29 | { 30 | printf ("%d %s\n", ret, (char *) arg); 31 | } 32 | 33 | void __attribute((destructor)) cleanup5(void) 34 | { 35 | printf ("cleanup5\n"); 36 | } 37 | 38 | void test(void) 39 | { 40 | atexit(cleanup1); 41 | atexit(cleanup2); 42 | on_exit(cleanup3, "cleanup3"); 43 | on_exit(cleanup4, "cleanup4"); 44 | } 45 | 46 | #if defined test_128_return 47 | int main(int argc, char **argv) 48 | { 49 | test(); 50 | return 1; 51 | } 52 | 53 | #elif defined test_128_exit 54 | int main(int argc, char **argv) 55 | { 56 | test(); 57 | exit(2); 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /test/bats/lib/bats-core/validator.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bats_test_count_validator() { 4 | trap '' INT # continue forwarding 5 | header_pattern='[0-9]+\.\.[0-9]+' 6 | IFS= read -r header 7 | # repeat the header 8 | printf "%s\n" "$header" 9 | 10 | # if we detect a TAP plan 11 | if [[ "$header" =~ $header_pattern ]]; then 12 | # extract the number of tests ... 13 | local expected_number_of_tests="${header:3}" 14 | # ... count the actual number of [not ] oks... 15 | local actual_number_of_tests=0 16 | while IFS= read -r line; do 17 | # forward line 18 | printf "%s\n" "$line" 19 | case "$line" in 20 | 'ok '*) 21 | ((++actual_number_of_tests)) 22 | ;; 23 | 'not ok'*) 24 | ((++actual_number_of_tests)) 25 | ;; 26 | esac 27 | done 28 | # ... and error if they are not the same 29 | if [[ "${actual_number_of_tests}" != "${expected_number_of_tests}" ]]; then 30 | printf '# bats warning: Executed %s instead of expected %s tests\n' "$actual_number_of_tests" "$expected_number_of_tests" 31 | return 1 32 | fi 33 | else 34 | # forward output unchanged 35 | cat 36 | fi 37 | } 38 | -------------------------------------------------------------------------------- /test/test_helper/bats_assert/src/assert.bash: -------------------------------------------------------------------------------- 1 | # assert 2 | # ====== 3 | # 4 | # Summary: Fail if the given expression evaluates to false. 5 | # 6 | # Usage: assert 7 | 8 | # Options: 9 | # The expression to evaluate for truthiness. 10 | # *__Note:__ The expression must be a simple command. 11 | # [Compound commands](https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands), 12 | # such as `[[`, can be used only when executed with `bash -c`.* 13 | # 14 | # IO: 15 | # STDERR - the failed expression, on failure 16 | # Globals: 17 | # none 18 | # Returns: 19 | # 0 - if expression evaluates to true 20 | # 1 - otherwise 21 | # 22 | # ```bash 23 | # @test 'assert()' { 24 | # touch '/var/log/test.log' 25 | # assert [ -e '/var/log/test.log' ] 26 | # } 27 | # ``` 28 | # 29 | # On failure, the failed expression is displayed. 30 | # 31 | # ``` 32 | # -- assertion failed -- 33 | # expression : [ -e /var/log/test.log ] 34 | # -- 35 | # ``` 36 | assert() { 37 | if ! "$@"; then 38 | batslib_print_kv_single 10 'expression' "$*" \ 39 | | batslib_decorate 'assertion failed' \ 40 | | fail 41 | fi 42 | } 43 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/40_stdio.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | FILE *f = fopen("fred.txt", "w"); 6 | fwrite("hello\nhello\n", 1, 12, f); 7 | fclose(f); 8 | 9 | char freddy[7]; 10 | f = fopen("fred.txt", "r"); 11 | if (fread(freddy, 1, 6, f) != 6) 12 | printf("couldn't read fred.txt\n"); 13 | 14 | freddy[6] = '\0'; 15 | fclose(f); 16 | 17 | printf("%s", freddy); 18 | 19 | int InChar; 20 | char ShowChar; 21 | f = fopen("fred.txt", "r"); 22 | while ( (InChar = fgetc(f)) != EOF) 23 | { 24 | ShowChar = InChar; 25 | if (ShowChar < ' ') 26 | ShowChar = '.'; 27 | 28 | printf("ch: %d '%c'\n", InChar, ShowChar); 29 | } 30 | fclose(f); 31 | 32 | f = fopen("fred.txt", "r"); 33 | while ( (InChar = getc(f)) != EOF) 34 | { 35 | ShowChar = InChar; 36 | if (ShowChar < ' ') 37 | ShowChar = '.'; 38 | 39 | printf("ch: %d '%c'\n", InChar, ShowChar); 40 | } 41 | fclose(f); 42 | 43 | f = fopen("fred.txt", "r"); 44 | while (fgets(freddy, sizeof(freddy), f) != NULL) 45 | printf("x: %s", freddy); 46 | 47 | fclose(f); 48 | 49 | return 0; 50 | } 51 | 52 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 53 | -------------------------------------------------------------------------------- /test/dmon.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define DMON_IMPL 3 | #include 4 | 5 | 6 | static void watch_callback(dmon_watch_id watch_id, dmon_action action, const char* rootdir, 7 | const char* filepath, const char* oldfilepath, void* user) 8 | { 9 | (void)(user); 10 | (void)(watch_id); 11 | 12 | switch (action) { 13 | case DMON_ACTION_CREATE: 14 | fprintf(stderr,"CREATE: [%s]%s\n", rootdir, filepath); 15 | break; 16 | case DMON_ACTION_DELETE: 17 | fprintf(stderr,"DELETE: [%s]%s\n", rootdir, filepath); 18 | break; 19 | case DMON_ACTION_MODIFY: 20 | fprintf(stderr,"MODIFY: [%s]%s\n", rootdir, filepath); 21 | break; 22 | case DMON_ACTION_MOVE: 23 | fprintf(stderr,"MOVE: [%s]%s -> [%s]%s\n", rootdir, oldfilepath, rootdir, filepath); 24 | break; 25 | } 26 | } 27 | 28 | int main(int argc, char* argv[]) 29 | { 30 | if (argc > 1) { 31 | dmon_init(); 32 | puts("waiting for changes .."); 33 | dmon_watch(argv[1], watch_callback, DMON_WATCHFLAGS_RECURSIVE, NULL); 34 | getchar(); 35 | dmon_deinit(); 36 | } else { 37 | puts("usage: test dirname"); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /test/test_helper/bats_support/src/error.bash: -------------------------------------------------------------------------------- 1 | # 2 | # bats-support - Supporting library for Bats test helpers 3 | # 4 | # Written in 2016 by Zoltan Tombol 5 | # 6 | # To the extent possible under law, the author(s) have dedicated all 7 | # copyright and related and neighboring rights to this software to the 8 | # public domain worldwide. This software is distributed without any 9 | # warranty. 10 | # 11 | # You should have received a copy of the CC0 Public Domain Dedication 12 | # along with this software. If not, see 13 | # . 14 | # 15 | 16 | # 17 | # error.bash 18 | # ---------- 19 | # 20 | # Functions implementing error reporting. Used by public helper 21 | # functions or test suits directly. 22 | # 23 | 24 | # Fail and display a message. When no parameters are specified, the 25 | # message is read from the standard input. Other functions use this to 26 | # report failure. 27 | # 28 | # Globals: 29 | # none 30 | # Arguments: 31 | # $@ - [=STDIN] message 32 | # Returns: 33 | # 1 - always 34 | # Inputs: 35 | # STDIN - [=$@] message 36 | # Outputs: 37 | # STDERR - message 38 | fail() { 39 | (( $# == 0 )) && batslib_err || batslib_err "$@" 40 | return 1 41 | } 42 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/41_hashif.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | printf("#include test\n"); 6 | 7 | #if 1 8 | #if 0 9 | printf("a\n"); 10 | #else 11 | printf("b\n"); 12 | #endif 13 | #else 14 | #if 0 15 | printf("c\n"); 16 | #else 17 | printf("d\n"); 18 | #endif 19 | #endif 20 | 21 | #if 0 22 | #if 1 23 | printf("e\n"); 24 | #else 25 | printf("f\n"); 26 | #endif 27 | #else 28 | #if 1 29 | printf("g\n"); 30 | #else 31 | printf("h\n"); 32 | #endif 33 | #endif 34 | 35 | #define DEF 36 | 37 | #ifdef DEF 38 | #ifdef DEF 39 | printf("i\n"); 40 | #else 41 | printf("j\n"); 42 | #endif 43 | #else 44 | #ifdef DEF 45 | printf("k\n"); 46 | #else 47 | printf("l\n"); 48 | #endif 49 | #endif 50 | 51 | #ifndef DEF 52 | #ifndef DEF 53 | printf("m\n"); 54 | #else 55 | printf("n\n"); 56 | #endif 57 | #else 58 | #ifndef DEF 59 | printf("o\n"); 60 | #else 61 | printf("p\n"); 62 | #endif 63 | #endif 64 | 65 | #define ONE 1 66 | #define ZERO 0 67 | 68 | #if ONE 69 | #if ZERO 70 | printf("q\n"); 71 | #else 72 | printf("r\n"); 73 | #endif 74 | #else 75 | #if ZERO 76 | printf("s\n"); 77 | #else 78 | printf("t\n"); 79 | #endif 80 | #endif 81 | 82 | return 0; 83 | } 84 | 85 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 86 | -------------------------------------------------------------------------------- /test/test_helper/bats_assert/src/refute.bash: -------------------------------------------------------------------------------- 1 | # refute 2 | # ====== 3 | # 4 | # Summary: Fail if the given expression evaluates to true. 5 | # 6 | # Usage: refute 7 | # 8 | # Options: 9 | # The expression to evaluate for falsiness. 10 | # *__Note:__ The expression must be a simple command. 11 | # [Compound commands](https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands), 12 | # such as `[[`, can be used only when executed with `bash -c`.* 13 | # 14 | # IO: 15 | # STDERR - the successful expression, on failure 16 | # Globals: 17 | # none 18 | # Returns: 19 | # 0 - if expression evaluates to false 20 | # 1 - otherwise 21 | # 22 | # ```bash 23 | # @test 'refute()' { 24 | # rm -f '/var/log/test.log' 25 | # refute [ -e '/var/log/test.log' ] 26 | # } 27 | # ``` 28 | # 29 | # On failure, the successful expression is displayed. 30 | # 31 | # ``` 32 | # -- assertion succeeded, but it was expected to fail -- 33 | # expression : [ -e /var/log/test.log ] 34 | # -- 35 | # ``` 36 | refute() { 37 | if "$@"; then 38 | batslib_print_kv_single 10 'expression' "$*" \ 39 | | batslib_decorate 'assertion succeeded, but it was expected to fail' \ 40 | | fail 41 | fi 42 | } 43 | -------------------------------------------------------------------------------- /LICENSES/BSD-2-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /lib/tinycc/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | typedef __SIZE_TYPE__ size_t; 5 | typedef __PTRDIFF_TYPE__ ssize_t; 6 | typedef __WCHAR_TYPE__ wchar_t; 7 | typedef __PTRDIFF_TYPE__ ptrdiff_t; 8 | typedef __PTRDIFF_TYPE__ intptr_t; 9 | typedef __SIZE_TYPE__ uintptr_t; 10 | 11 | #if __STDC_VERSION__ >= 201112L 12 | typedef union { long long __ll; long double __ld; } max_align_t; 13 | #endif 14 | 15 | #ifndef NULL 16 | #define NULL ((void*)0) 17 | #endif 18 | 19 | #undef offsetof 20 | #define offsetof(type, field) ((size_t)&((type *)0)->field) 21 | 22 | #if defined __i386__ || defined __x86_64__ 23 | void *alloca(size_t size); 24 | #endif 25 | 26 | #endif 27 | 28 | /* Older glibc require a wint_t from (when requested 29 | by __need_wint_t, as otherwise stddef.h isn't allowed to 30 | define this type). Note that this must be outside the normal 31 | _STDDEF_H guard, so that it works even when we've included the file 32 | already (without requiring wint_t). Some other libs define _WINT_T 33 | if they've already provided that type, so we can use that as guard. 34 | TCC defines __WINT_TYPE__ for us. */ 35 | #if defined (__need_wint_t) 36 | #ifndef _WINT_T 37 | #define _WINT_T 38 | typedef __WINT_TYPE__ wint_t; 39 | #endif 40 | #undef __need_wint_t 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/104_inline.expect: -------------------------------------------------------------------------------- 1 | 0 inline_inline_2decl_only 2 | 0 inline_inline_undeclared 3 | 0 inline_inline_predeclared 4 | 0 inline_inline_postdeclared 5 | 0 inline_inline_prepostdeclared 6 | 0 inline_inline_undeclared2 7 | 0 inline_inline_predeclared2 8 | 0 inline_inline_postdeclared2 9 | 0 inline_inline_prepostdeclared2 10 | 1 extern_extern_postdeclared 11 | 1 extern_extern_postdeclared2 12 | 1 extern_extern_predeclared 13 | 1 extern_extern_predeclared2 14 | 1 extern_extern_prepostdeclared 15 | 1 extern_extern_prepostdeclared2 16 | 1 extern_extern_undeclared 17 | 1 extern_extern_undeclared2 18 | 1 extern_postdeclared 19 | 1 extern_postdeclared2 20 | 1 extern_predeclared 21 | 1 extern_predeclared2 22 | 1 extern_prepostdeclared 23 | 1 extern_undeclared 24 | 1 extern_undeclared2 25 | 1 inst2_extern_inline_postdeclared 26 | 1 inst2_extern_inline_predeclared 27 | 1 inst3_extern_inline_predeclared 28 | 1 inst_extern_inline_postdeclared 29 | 1 inst_extern_inline_predeclared 30 | 1 main 31 | 1 noinst_extern_inline_func 32 | 1 noinst_extern_inline_postdeclared 33 | 1 noinst_extern_inline_postdeclared2 34 | 1 noinst_extern_inline_undeclared 35 | 0 noinst_static_inline_postdeclared 36 | 0 noinst2_static_inline_postdeclared 37 | 0 noinst_static_inline_predeclared 38 | 0 noinst2_static_inline_predeclared 39 | 0 static_func 40 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/81_types.c: -------------------------------------------------------------------------------- 1 | /* The following are all valid decls, even though some subtypes 2 | are incomplete. */ 3 | enum E *e; 4 | const enum E *e1; 5 | enum E const *e2; 6 | struct S *s; 7 | const struct S *s1; 8 | struct S const *s2; 9 | 10 | /* Various strangely looking declarators, which are all valid 11 | and have to map to the same numbered typedefs. */ 12 | typedef int (*fptr1)(); 13 | int f1 (int (), int); 14 | typedef int (*fptr2)(int x); 15 | int f2 (int (int x), int); 16 | typedef int (*fptr3)(int); 17 | int f3 (int (int), int); 18 | typedef int (*fptr4[4])(int); 19 | int f4 (int (*[4])(int), int); 20 | typedef int (*fptr5)(fptr1); 21 | int f5 (int (int()), fptr1); 22 | int f1 (fptr1 fp, int i) 23 | { 24 | return (*fp)(i); 25 | } 26 | int f2 (fptr2 fp, int i) 27 | { 28 | return (*fp)(i); 29 | } 30 | int f3 (fptr3 fp, int i) 31 | { 32 | return (*fp)(i); 33 | } 34 | int f4 (fptr4 fp, int i) 35 | { 36 | return (*fp[i])(i); 37 | } 38 | int f5 (fptr5 fp, fptr1 i) 39 | { 40 | return fp(i); 41 | } 42 | typedef int intx4[4]; 43 | int f8 (intx4, int); 44 | int f8 (int ([4]), int); 45 | int f8 (int y[4], int i) 46 | { 47 | return y[i]; 48 | } 49 | int f9 (int (*)(int), int); 50 | int f9 (int ((int)), int); 51 | int f9 (int f(int), int i) 52 | { 53 | return f(i); 54 | } 55 | int main () { return 0; } 56 | -------------------------------------------------------------------------------- /examples/dmon.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void watch_callback(dmon_watch_id watch_id, 5 | dmon_action action, 6 | const char* rootdir, 7 | const char* filepath, 8 | const char* oldfilepath, 9 | void* user) { 10 | (void)(user); 11 | (void)(watch_id); 12 | switch (action) { 13 | case DMON_ACTION_CREATE: 14 | fprintf(stderr,"CREATE: [%s]%s\n", rootdir, filepath); 15 | break; 16 | case DMON_ACTION_DELETE: 17 | fprintf(stderr,"DELETE: [%s]%s\n", rootdir, filepath); 18 | break; 19 | case DMON_ACTION_MODIFY: 20 | fprintf(stderr,"MODIFY: [%s]%s\n", rootdir, filepath); 21 | break; 22 | case DMON_ACTION_MOVE: 23 | fprintf(stderr,"MOVE: [%s]%s -> [%s]%s\n", rootdir, oldfilepath, rootdir, filepath); 24 | break; 25 | } 26 | } 27 | 28 | int main(int argc, char* argv[]) { 29 | if (argc > 1) { 30 | dmon_init(); 31 | puts("waiting for changes .."); 32 | dmon_watch(argv[1], watch_callback, DMON_WATCHFLAGS_RECURSIVE, NULL); 33 | getchar(); 34 | dmon_deinit(); 35 | } else { 36 | puts("usage: test dirname"); 37 | } 38 | return 0; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/dos.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_DOS 7 | #define _INC_DOS 8 | 9 | #include <_mingw.h> 10 | #include 11 | 12 | #pragma pack(push,_CRT_PACKING) 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #ifndef _DISKFREE_T_DEFINED 19 | #define _DISKFREE_T_DEFINED 20 | 21 | struct _diskfree_t { 22 | unsigned total_clusters; 23 | unsigned avail_clusters; 24 | unsigned sectors_per_cluster; 25 | unsigned bytes_per_sector; 26 | }; 27 | #endif 28 | 29 | #define _A_NORMAL 0x00 30 | #define _A_RDONLY 0x01 31 | #define _A_HIDDEN 0x02 32 | #define _A_SYSTEM 0x04 33 | #define _A_SUBDIR 0x10 34 | #define _A_ARCH 0x20 35 | 36 | #ifndef _GETDISKFREE_DEFINED 37 | #define _GETDISKFREE_DEFINED 38 | _CRTIMP unsigned __cdecl _getdiskfree(unsigned _Drive,struct _diskfree_t *_DiskFree); 39 | #endif 40 | 41 | #if (defined(_X86_) && !defined(__x86_64)) 42 | void __cdecl _disable(void); 43 | void __cdecl _enable(void); 44 | #endif 45 | 46 | #ifndef NO_OLDNAMES 47 | #define diskfree_t _diskfree_t 48 | #endif 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #pragma pack(pop) 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/tinycc/tests/asm-c-connect-1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore) 4 | # define _ "_" 5 | #else 6 | # define _ 7 | #endif 8 | 9 | #ifdef __clang__ 10 | /* clang needs some help tp not throw functions away even at -O0 */ 11 | #define __USED __attribute__((__used__)) 12 | #else 13 | #define __USED 14 | #endif 15 | 16 | static int __USED x1_c (void) 17 | { 18 | printf(" x1"); 19 | return 1; 20 | } 21 | 22 | #if __i386__ 23 | asm(".text;"_"x1: call "_"x1_c; ret"); 24 | #else 25 | /* Keep stack aligned */ 26 | asm(".text;"_"x1: sub $8,%rsp; call "_"x1_c; add $8,%rsp; ret"); 27 | #endif 28 | 29 | void callx4(void); 30 | void callx5_again(void); 31 | 32 | void x6() 33 | { 34 | printf(" x6-1"); 35 | } 36 | 37 | int main(int argc, char *argv[]) 38 | { 39 | printf("*"); 40 | asm("call "_"x1"); 41 | asm("call "_"x2"); 42 | asm("call "_"x3"); 43 | callx4(); 44 | asm("call "_"x5"); 45 | callx5_again(); 46 | x6(); 47 | printf(" *\n"); 48 | return 0; 49 | } 50 | 51 | static 52 | int __USED x2(void) 53 | { 54 | printf(" x2"); 55 | return 2; 56 | } 57 | 58 | extern int x3(void); 59 | 60 | void x4(void) 61 | { 62 | printf(" x4"); 63 | } 64 | 65 | void x5(void); 66 | void x5(void) 67 | { 68 | printf(" x5"); 69 | } 70 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/memory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_MEMORY 7 | #define _INC_MEMORY 8 | 9 | #include <_mingw.h> 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifndef _CONST_RETURN 16 | #define _CONST_RETURN 17 | #endif 18 | 19 | #define _WConst_return _CONST_RETURN 20 | 21 | #ifndef _CRT_MEMORY_DEFINED 22 | #define _CRT_MEMORY_DEFINED 23 | _CRTIMP void *__cdecl _memccpy(void *_Dst,const void *_Src,int _Val,size_t _MaxCount); 24 | _CONST_RETURN void *__cdecl memchr(const void *_Buf ,int _Val,size_t _MaxCount); 25 | _CRTIMP int __cdecl _memicmp(const void *_Buf1,const void *_Buf2,size_t _Size); 26 | _CRTIMP int __cdecl _memicmp_l(const void *_Buf1,const void *_Buf2,size_t _Size,_locale_t _Locale); 27 | int __cdecl memcmp(const void *_Buf1,const void *_Buf2,size_t _Size); 28 | void *__cdecl memcpy(void *_Dst,const void *_Src,size_t _Size); 29 | void *__cdecl memset(void *_Dst,int _Val,size_t _Size); 30 | 31 | #ifndef NO_OLDNAMES 32 | void *__cdecl memccpy(void *_Dst,const void *_Src,int _Val,size_t _Size); 33 | int __cdecl memicmp(const void *_Buf1,const void *_Buf2,size_t _Size); 34 | #endif 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif 41 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/39_typedef.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef int MyInt; 4 | 5 | struct FunStruct 6 | { 7 | int i; 8 | int j; 9 | }; 10 | 11 | typedef struct FunStruct MyFunStruct; 12 | 13 | typedef MyFunStruct *MoreFunThanEver; 14 | 15 | int main() 16 | { 17 | MyInt a = 1; 18 | printf("%d\n", a); 19 | 20 | MyFunStruct b; 21 | b.i = 12; 22 | b.j = 34; 23 | printf("%d,%d\n", b.i, b.j); 24 | 25 | MoreFunThanEver c = &b; 26 | printf("%d,%d\n", c->i, c->j); 27 | 28 | return 0; 29 | } 30 | 31 | /* "If the specification of an array type includes any type qualifiers, 32 | the element type is so-qualified, not the array type." */ 33 | 34 | typedef int A[3]; 35 | extern A const ca; 36 | extern const A ca; 37 | extern const int ca[3]; 38 | 39 | typedef A B[1][2]; 40 | extern B const cb; 41 | extern const B cb; 42 | extern const int cb[1][2][3]; 43 | 44 | extern B b; 45 | extern int b[1][2][3]; 46 | 47 | /* Funny but valid function declaration. */ 48 | typedef int functype (int); 49 | extern functype func; 50 | int func(int i) 51 | { 52 | return i + 1; 53 | } 54 | 55 | /* Even funnier function decl and definition using typeof. */ 56 | int set_anon_super(void); 57 | int set_anon_super(void) 58 | { 59 | return 42; 60 | } 61 | typedef int sas_type (void); 62 | extern typeof(set_anon_super) set_anon_super; 63 | extern sas_type set_anon_super; 64 | 65 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 66 | -------------------------------------------------------------------------------- /lib/tinycc/lib/armflush.c: -------------------------------------------------------------------------------- 1 | /* armflush.c - flush the instruction cache 2 | 3 | __clear_cache is used in tccrun.c, It is a built-in 4 | intrinsic with gcc. However tcc in order to compile 5 | itself needs this function */ 6 | 7 | #ifdef __TINYC__ 8 | 9 | /* syscall wrapper */ 10 | unsigned _tccsyscall(unsigned syscall_nr, ...); 11 | 12 | /* arm-tcc supports only fake asm currently */ 13 | __asm__( 14 | ".global _tccsyscall\n" 15 | "_tccsyscall:\n" 16 | "push {r7, lr}\n\t" 17 | "mov r7, r0\n\t" 18 | "mov r0, r1\n\t" 19 | "mov r1, r2\n\t" 20 | "mov r2, r3\n\t" 21 | "svc #0\n\t" 22 | "pop {r7, pc}" 23 | ); 24 | 25 | /* from unistd.h: */ 26 | #if defined(__thumb__) || defined(__ARM_EABI__) 27 | # define __NR_SYSCALL_BASE 0x0 28 | #else 29 | # define __NR_SYSCALL_BASE 0x900000 30 | #endif 31 | #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) 32 | #define __ARM_NR_cacheflush (__ARM_NR_BASE+2) 33 | 34 | #define syscall _tccsyscall 35 | 36 | #else 37 | 38 | #define _GNU_SOURCE 39 | #include 40 | #include 41 | #include 42 | 43 | #endif 44 | 45 | /* Flushing for tccrun */ 46 | void __clear_cache(void *beginning, void *end) 47 | { 48 | /* __ARM_NR_cacheflush is kernel private and should not be used in user space. 49 | * However, there is no ARM asm parser in tcc so we use it for now */ 50 | syscall(__ARM_NR_cacheflush, beginning, end, 0); 51 | } 52 | -------------------------------------------------------------------------------- /lib/tinycc/tests/pp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # credits: 01..13.c from the pcc cpp-tests suite 3 | # 4 | 5 | TOP = ../.. 6 | include $(TOP)/Makefile 7 | SRC = $(TOPSRC)/tests/pp 8 | VPATH = $(SRC) 9 | 10 | files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1))) 11 | TESTS = $(call files,c) $(call files,S) 12 | 13 | all test testspp.all: $(sort $(TESTS)) 14 | 15 | DIFF_OPTS = -Nu -b 16 | 17 | # Filter source directory in warnings/errors (out-of-tree builds) 18 | FILTER = 2>&1 | sed 's,$(SRC)/,,g' 19 | 20 | %.test: %.c %.expect 21 | @echo PPTest $* ... 22 | -@$(TCC) -E -P $< $(FILTER) >$*.output 2>&1 ; \ 23 | diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \ 24 | && rm -f $*.output 25 | 26 | %.test: %.S %.expect 27 | @echo PPTest $* ... 28 | -@$(TCC) -E -P $< $(FILTER) >$*.output 2>&1 ; \ 29 | diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \ 30 | && rm -f $*.output 31 | 32 | testspp.%: %.test ; 33 | 34 | # generate .expect file with tcc, e.g. "make testspp.17+" 35 | testspp.%+: %.c 36 | $(TCC) -E -P $*.[cS] -o $*.expect 37 | 38 | # automatically generate .expect files with gcc: 39 | %.expect: # %.c 40 | gcc -E -P $*.[cS] >$*.expect 2>&1 41 | 42 | # tell make not to delete 43 | .PRECIOUS: %.expect 44 | 45 | clean: 46 | rm -f *.output 47 | 48 | 02.test : DIFF_OPTS += -w 49 | # 15.test : DIFF_OPTS += -I"^XXX:" 50 | 51 | # diff options: 52 | # -b ighore space changes 53 | # -w ighore all whitespace 54 | # -B ignore blank lines 55 | # -I ignore lines matching RE 56 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/fcntl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #include <_mingw.h> 7 | 8 | #include 9 | 10 | #ifndef _INC_FCNTL 11 | #define _INC_FCNTL 12 | 13 | #define _O_RDONLY 0x0000 14 | #define _O_WRONLY 0x0001 15 | #define _O_RDWR 0x0002 16 | #define _O_APPEND 0x0008 17 | #define _O_CREAT 0x0100 18 | #define _O_TRUNC 0x0200 19 | #define _O_EXCL 0x0400 20 | #define _O_TEXT 0x4000 21 | #define _O_BINARY 0x8000 22 | #define _O_WTEXT 0x10000 23 | #define _O_U16TEXT 0x20000 24 | #define _O_U8TEXT 0x40000 25 | #define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR) 26 | 27 | #define _O_RAW _O_BINARY 28 | #define _O_NOINHERIT 0x0080 29 | #define _O_TEMPORARY 0x0040 30 | #define _O_SHORT_LIVED 0x1000 31 | 32 | #define _O_SEQUENTIAL 0x0020 33 | #define _O_RANDOM 0x0010 34 | 35 | #if !defined(NO_OLDNAMES) || defined(_POSIX) 36 | #define O_RDONLY _O_RDONLY 37 | #define O_WRONLY _O_WRONLY 38 | #define O_RDWR _O_RDWR 39 | #define O_APPEND _O_APPEND 40 | #define O_CREAT _O_CREAT 41 | #define O_TRUNC _O_TRUNC 42 | #define O_EXCL _O_EXCL 43 | #define O_TEXT _O_TEXT 44 | #define O_BINARY _O_BINARY 45 | #define O_RAW _O_BINARY 46 | #define O_TEMPORARY _O_TEMPORARY 47 | #define O_NOINHERIT _O_NOINHERIT 48 | #define O_SEQUENTIAL _O_SEQUENTIAL 49 | #define O_RANDOM _O_RANDOM 50 | #define O_ACCMODE _O_ACCMODE 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/125_atomic_misc.expect: -------------------------------------------------------------------------------- 1 | [test_atomic_compare_exchange] 2 | 1 99 77 3 | 0 80 80 4 | 85 33 80 5 | 90 66 80 6 | 7 | [test_atomic_store] 8 | r = 12, i = 24 9 | 10 | [test_atomic_store_pointer] 11 | *p = 2 12 | 13 | [test_atomic_store_struct] 14 | 1 2 3 4 15 | 16 | [test_atomic_op] 17 | fetch_add: SUCCESS 18 | fetch_sub: SUCCESS 19 | fetch_or: SUCCESS 20 | fetch_xor: SUCCESS 21 | fetch_and: SUCCESS 22 | 23 | [test_atomic_op2] 24 | fetch_add: SUCCESS 25 | fetch_sub: SUCCESS 26 | fetch_or: SUCCESS 27 | fetch_xor: SUCCESS 28 | fetch_and: SUCCESS 29 | fetch_nand: SUCCESS 30 | add_fetch: SUCCESS 31 | sub_fetch: SUCCESS 32 | or_fetch: SUCCESS 33 | xor_fetch: SUCCESS 34 | and_fetch: SUCCESS 35 | nand_fetch: SUCCESS 36 | 37 | [test_atomic_thread_signal] 38 | 1 39 | 40 | [test_atomic_error_1] 41 | 125_atomic_misc.c:176: error: pointer expected 42 | 43 | [test_atomic_error_2] 44 | 125_atomic_misc.c:183: error: integral or integer-sized pointer target type expected 45 | 46 | [test_atomic_error_3] 47 | 125_atomic_misc.c:190: error: integral or integer-sized pointer target type expected 48 | 49 | [test_atomic_error_4] 50 | 125_atomic_misc.c:198: error: pointer target type mismatch in argument 2 51 | 52 | [test_atomic_warn_1] 53 | 125_atomic_misc.c:206: warning: assignment makes integer from pointer without a cast 54 | 55 | [test_atomic_warn_2] 56 | 125_atomic_misc.c:216: warning: assignment from incompatible pointer type 57 | 58 | [test_atomic_warn_3] 59 | 125_atomic_misc.c:224: warning: assignment of read-only location 60 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/75_array_in_struct_init.expect: -------------------------------------------------------------------------------- 1 | cases[0].c[0]=73400320 2 | cases[0].c[1]=262144 3 | cases[0].c[2]=805567999 4 | cases[0].c[3]=-1 5 | cases[0].b=1 6 | cases[0].e=2 7 | cases[0].k=1 8 | 9 | cases[1].c[0]=879754751 10 | cases[1].c[1]=262144 11 | cases[1].c[2]=262144 12 | cases[1].c[3]=805567999 13 | cases[1].b=2 14 | cases[1].e=3 15 | cases[1].k=2 16 | 17 | cases[2].c[0]=879754751 18 | cases[2].c[1]=805567999 19 | cases[2].c[2]=262144 20 | cases[2].c[3]=805567999 21 | cases[2].b=1 22 | cases[2].e=3 23 | cases[2].k=2 24 | 25 | cases[3].c[0]=879754751 26 | cases[3].c[1]=805830143 27 | cases[3].c[2]=524288 28 | cases[3].c[3]=-1 29 | cases[3].b=1 30 | cases[3].e=2 31 | cases[3].k=1 32 | 33 | cases[4].c[0]=879754751 34 | cases[4].c[1]=805830143 35 | cases[4].c[2]=1048576 36 | cases[4].c[3]=805830143 37 | cases[4].b=1 38 | cases[4].e=3 39 | cases[4].k=1 40 | 41 | cases[5].c[0]=879754751 42 | cases[5].c[1]=805830143 43 | cases[5].c[2]=262144 44 | cases[5].c[3]=262144 45 | cases[5].b=1 46 | cases[5].e=3 47 | cases[5].k=1 48 | 49 | cases[6].c[0]=73400320 50 | cases[6].c[1]=807403007 51 | cases[6].c[2]=807403007 52 | cases[6].c[3]=-1 53 | cases[6].b=1 54 | cases[6].e=2 55 | cases[6].k=1 56 | 57 | cases[7].c[0]=839122431 58 | cases[7].c[1]=2097152 59 | cases[7].c[2]=807403007 60 | cases[7].c[3]=-1 61 | cases[7].b=0 62 | cases[7].e=2 63 | cases[7].k=1 64 | 65 | cases[8].c[0]=67108864 66 | cases[8].c[1]=807403007 67 | cases[8].c[2]=134217728 68 | cases[8].c[3]=-1 69 | cases[8].b=0 70 | cases[8].e=2 71 | cases[8].k=0 72 | 73 | -------------------------------------------------------------------------------- /test/bats/libexec/bats-core/bats-format-tap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | trap '' INT 4 | 5 | # shellcheck source=lib/bats-core/formatter.bash 6 | source "$BATS_ROOT/$BATS_LIBDIR/bats-core/formatter.bash" 7 | 8 | bats_tap_stream_plan() { 9 | printf "1..%d\n" "$1" 10 | } 11 | 12 | bats_tap_stream_begin() { # 13 | : 14 | } 15 | 16 | bats_tap_stream_ok() { # [ 17 | printf "ok %d %s" "$1" "$2" 18 | if [[ "${BATS_FORMATTER_TEST_DURATION-x}" != x ]]; then 19 | printf " # in %d ms" "$BATS_FORMATTER_TEST_DURATION" 20 | fi 21 | printf "\n" 22 | } 23 | 24 | bats_tap_stream_not_ok() { # 25 | printf "not ok %d %s" "$1" "$2" 26 | if [[ "${BATS_FORMATTER_TEST_DURATION-x}" != x ]]; then 27 | printf " # in %d ms" "$BATS_FORMATTER_TEST_DURATION" 28 | fi 29 | if [[ "${BATS_FORMATTER_TEST_TIMEOUT-x}" != x ]]; then 30 | printf " # timeout after %d s" "${BATS_FORMATTER_TEST_TIMEOUT}" 31 | fi 32 | printf "\n" 33 | } 34 | 35 | bats_tap_stream_skipped() { # 36 | if [[ $# -eq 3 ]]; then 37 | printf "ok %d %s # skip %s\n" "$1" "$2" "$3" 38 | else 39 | printf "ok %d %s # skip\n" "$1" "$2" 40 | fi 41 | } 42 | 43 | bats_tap_stream_comment() { # 44 | printf "# %s\n" "$1" 45 | } 46 | 47 | bats_tap_stream_suite() { # 48 | : 49 | } 50 | 51 | bats_tap_stream_unknown() { # 52 | printf "%s\n" "$1" 53 | } 54 | 55 | bats_parse_internal_extended_tap 56 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/131_return_struct_in_reg.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct s1 { 4 | unsigned char a:4, b:4; 5 | } g1 = { 0x05, 0x0a }; 6 | 7 | struct s2 { 8 | unsigned char a, b; 9 | } g2 = { 0x12, 0x34 }; 10 | 11 | struct s4 { 12 | unsigned short a, b; 13 | } g4 = { 0x1245, 0x5678 }; 14 | 15 | struct s8 { 16 | unsigned a, b; 17 | } g8 = { 0x12345678, 0x9abcdef0 }; 18 | 19 | /* returned in 2 registers on riscv64 */ 20 | struct s16 { 21 | unsigned long long a, b; 22 | } g16 = { 0x123456789abcdef0ULL, 0xfedcba9876543210ULL }; 23 | 24 | /* Homogeneous float aggregate on ARM hard-float */ 25 | struct s_f4 { 26 | double a, b, c, d; 27 | } g_f4 = { 1,2,3,4 }; 28 | 29 | #define def(S) \ 30 | struct s##S f##S(int x) \ 31 | { \ 32 | struct s##S l##S = g##S, *p##S = &l##S; \ 33 | if (x == 0) \ 34 | return g##S; \ 35 | else if (x == 1) \ 36 | return l##S; \ 37 | else \ 38 | return *p##S; \ 39 | } 40 | 41 | def(1) 42 | def(2) 43 | def(4) 44 | def(8) 45 | def(16) 46 | def(_f4) 47 | 48 | #define chk(S,x) \ 49 | struct s##S l##S = f##S(x); \ 50 | printf("%02llx %02llx\n", \ 51 | (unsigned long long)l##S.a, \ 52 | (unsigned long long)l##S.b \ 53 | ); 54 | 55 | int main() 56 | { 57 | for (int x = 0;;) { 58 | chk(1,x); 59 | chk(2,x); 60 | chk(4,x); 61 | chk(8,x); 62 | chk(16,x); 63 | struct s_f4 l_f4 = f_f4(x); 64 | printf("%.1f %.1f %.1f %.1f\n", l_f4.a, l_f4.b, l_f4.c, l_f4.d); 65 | if (++x > 2) 66 | break; 67 | printf("\n"); 68 | } 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/17_enum.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | enum fred 4 | { 5 | a, 6 | b, 7 | c, 8 | d, 9 | e = 54, 10 | f = 73, 11 | g, 12 | h 13 | }; 14 | 15 | /* All following uses of enum efoo should compile 16 | without warning. While forward enums aren't ISO C, 17 | it's accepted by GCC also in strict mode, and only warned 18 | about with -pedantic. This happens in the real world. */ 19 | /* Strict ISO C doesn't allow this kind of forward declaration of 20 | enums, but GCC accepts it (and gives only pedantic warning), and 21 | it occurs in the wild. */ 22 | enum efoo; 23 | struct Sforward_use { 24 | int (*fmember) (enum efoo x); 25 | }; 26 | 27 | extern enum efoo it_real_fn(void); 28 | enum efoo { 29 | ONE, 30 | TWO, 31 | }; 32 | struct S2 { 33 | enum efoo (*f2) (void); 34 | }; 35 | void should_compile(struct S2 *s) 36 | { 37 | s->f2 = it_real_fn; 38 | } 39 | 40 | enum efoo it_real_fn(void) 41 | { 42 | return TWO; 43 | } 44 | 45 | static unsigned int deref_uintptr(unsigned int *p) 46 | { 47 | return *p; 48 | } 49 | 50 | enum Epositive { 51 | epos_one, epos_two 52 | }; 53 | 54 | int main() 55 | { 56 | enum fred frod; 57 | enum Epositive epos = epos_two; 58 | 59 | printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h); 60 | /* printf("%d\n", frod); */ 61 | frod = 12; 62 | printf("%d\n", frod); 63 | frod = e; 64 | printf("%d\n", frod); 65 | 66 | /* Following should compile without warning. */ 67 | printf ("enum to int: %u\n", deref_uintptr(&epos)); 68 | 69 | return 0; 70 | } 71 | 72 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 73 | -------------------------------------------------------------------------------- /lib/tinycc/lib/bt-log.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------- */ 2 | /* function to get a stack backtrace on demand with a message */ 3 | 4 | #include 5 | #include 6 | #include 7 | #undef __attribute__ 8 | 9 | #ifdef _WIN32 10 | # define DLL_EXPORT __declspec(dllexport) 11 | #else 12 | # define DLL_EXPORT 13 | #endif 14 | 15 | /* Needed when using ...libtcc1-usegcc=yes in lib/Makefile */ 16 | #if (defined(__GNUC__) && (__GNUC__ >= 6)) || defined(__clang__) 17 | #pragma GCC diagnostic push 18 | #pragma GCC diagnostic ignored "-Wframe-address" 19 | #endif 20 | 21 | typedef struct rt_frame { 22 | void *ip, *fp, *sp; 23 | } rt_frame; 24 | 25 | __attribute__((weak)) 26 | int _tcc_backtrace(rt_frame *f, const char *fmt, va_list ap); 27 | 28 | DLL_EXPORT int tcc_backtrace(const char *fmt, ...) 29 | { 30 | va_list ap; 31 | int ret; 32 | 33 | if (_tcc_backtrace) { 34 | rt_frame f; 35 | f.fp = __builtin_frame_address(1); 36 | f.ip = __builtin_return_address(0); 37 | va_start(ap, fmt); 38 | ret = _tcc_backtrace(&f, fmt, ap); 39 | va_end(ap); 40 | } else { 41 | const char *p, *nl = "\n"; 42 | if (fmt[0] == '^' && (p = strchr(fmt + 1, fmt[0]))) 43 | fmt = p + 1; 44 | if (fmt[0] == '\001') 45 | ++fmt, nl = ""; 46 | va_start(ap, fmt); 47 | ret = vfprintf(stderr, fmt, ap); 48 | va_end(ap); 49 | fprintf(stderr, "%s", nl), fflush(stderr); 50 | } 51 | return ret; 52 | } 53 | 54 | #if (defined(__GNUC__) && (__GNUC__ >= 6)) || defined(__clang__) 55 | #pragma GCC diagnostic pop 56 | #endif 57 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/92_enum_bitfield.c: -------------------------------------------------------------------------------- 1 | /* This checks if enums needing 8 bit but only having positive 2 | values are correctly zero extended (instead of sign extended) 3 | when stored into/loaded from a 8 bit bit-field of enum type (which 4 | itself is implementation defined, so isn't necessarily supported by all 5 | other compilers). */ 6 | enum tree_code { 7 | SOME_CODE = 148, /* has bit 7 set, and hence all further enum values as well */ 8 | LAST_AND_UNUSED_TREE_CODE 9 | }; 10 | typedef union tree_node *tree; 11 | struct tree_common 12 | { 13 | union tree_node *chain; 14 | union tree_node *type; 15 | enum tree_code code : 8; 16 | unsigned side_effects_flag : 1; 17 | }; 18 | union tree_node 19 | { 20 | struct tree_common common; 21 | }; 22 | enum c_tree_code { 23 | C_DUMMY_TREE_CODE = LAST_AND_UNUSED_TREE_CODE, 24 | STMT_EXPR, 25 | LAST_C_TREE_CODE 26 | }; 27 | enum cplus_tree_code { 28 | CP_DUMMY_TREE_CODE = LAST_C_TREE_CODE, 29 | AMBIG_CONV, 30 | LAST_CPLUS_TREE_CODE 31 | }; 32 | 33 | extern int printf(const char *, ...); 34 | int blah(){return 0;} 35 | 36 | int convert_like_real (tree convs) 37 | { 38 | switch (((enum tree_code) (convs)->common.code)) 39 | { 40 | case AMBIG_CONV: /* This has bit 7 set, which must not be the sign 41 | bit in tree_common.code, i.e. the bitfield must 42 | be somehow marked unsigned. */ 43 | return blah(); 44 | default: 45 | break; 46 | }; 47 | printf("unsigned enum bit-fields broken\n"); 48 | return 0; 49 | } 50 | 51 | int main() 52 | { 53 | union tree_node convs; 54 | 55 | convs.common.code = AMBIG_CONV; 56 | convert_like_real (&convs); 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /test/test_helper/bats_assert/load.bash: -------------------------------------------------------------------------------- 1 | # bats-assert - Common assertions for Bats 2 | # 3 | # Written in 2016 by Zoltan Tombol 4 | # 5 | # To the extent possible under law, the author(s) have dedicated all 6 | # copyright and related and neighboring rights to this software to the 7 | # public domain worldwide. This software is distributed without any 8 | # warranty. 9 | # 10 | # You should have received a copy of the CC0 Public Domain Dedication 11 | # along with this software. If not, see 12 | # . 13 | # 14 | # Assertions are functions that perform a test and output relevant 15 | # information on failure to help debugging. They return 1 on failure 16 | # and 0 otherwise. 17 | # 18 | # All output is formatted for readability using the functions of 19 | # `output.bash' and sent to the standard error. 20 | 21 | # shellcheck disable=1090 22 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash" 23 | source "$(dirname "${BASH_SOURCE[0]}")/src/refute.bash" 24 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_equal.bash" 25 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_not_equal.bash" 26 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_success.bash" 27 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_failure.bash" 28 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_output.bash" 29 | source "$(dirname "${BASH_SOURCE[0]}")/src/refute_output.bash" 30 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_line.bash" 31 | source "$(dirname "${BASH_SOURCE[0]}")/src/refute_line.bash" 32 | source "$(dirname "${BASH_SOURCE[0]}")/src/assert_regex.bash" 33 | source "$(dirname "${BASH_SOURCE[0]}")/src/refute_regex.bash" 34 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/127_asm_goto.c: -------------------------------------------------------------------------------- 1 | static int simple_jump(void) 2 | { 3 | asm goto ("jmp %l[label]" : : : : label); 4 | return 0; 5 | label: 6 | return 1; 7 | } 8 | 9 | static int three_way_jump(int val, int *addr) 10 | { 11 | *addr = 42; 12 | asm goto ("cmp $0, %1\n\t" 13 | "jg %l[larger]\n\t" 14 | "jl %l[smaller]\n\t" 15 | "incl %0\n\t" 16 | : "=m" (*addr) 17 | : "r" (val) 18 | : 19 | : smaller, larger); 20 | return 1; 21 | smaller: 22 | return 2; 23 | larger: 24 | return 3; 25 | } 26 | 27 | static int another_jump(void) 28 | { 29 | asm goto ("jmp %l[label]" : : : : label); 30 | return 70; 31 | /* Use the same label name as in simple_jump to check that 32 | that doesn't confuse our C/ASM symbol tables */ 33 | label: 34 | return 71; 35 | } 36 | 37 | extern int printf (const char *, ...); 38 | int main(void) 39 | { 40 | int i; 41 | if (simple_jump () == 1) 42 | printf ("simple_jump: okay\n"); 43 | else 44 | printf ("simple_jump: wrong\n"); 45 | if (another_jump () == 71) 46 | printf ("another_jump: okay\n"); 47 | else 48 | printf ("another_jump: wrong\n"); 49 | if (three_way_jump(0, &i) == 1 && i == 43) 50 | printf ("three_way_jump(0): okay\n"); 51 | else 52 | printf ("three_way_jump(0): wrong (i=%d)\n", i); 53 | if (three_way_jump(1, &i) == 3 && i == 42) 54 | printf ("three_way_jump(1): okay\n"); 55 | else 56 | printf ("three_way_jump(1): wrong (i=%d)\n", i); 57 | if (three_way_jump(-1, &i) == 2 && i == 42) 58 | printf ("three_way_jump(-1): okay\n"); 59 | else 60 | printf ("three_way_jump(-1): wrong (i=%d)\n", i); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/93_integer_promotion.c: -------------------------------------------------------------------------------- 1 | /* integer promotion */ 2 | 3 | int printf(const char*, ...); 4 | #define promote(s) printf(" %ssigned : %s\n", (s) - 100 < 0 ? " " : "un", #s); 5 | 6 | int main (void) 7 | { 8 | struct { 9 | unsigned ub:3; 10 | unsigned u:32; 11 | unsigned long long ullb:35; 12 | unsigned long long ull:64; 13 | unsigned char c; 14 | } s = { 1, 1, 1 }; 15 | 16 | promote(s.ub); 17 | promote(s.u); 18 | promote(s.ullb); 19 | promote(s.ull); 20 | promote(s.c); 21 | printf("\n"); 22 | 23 | promote((1 ? s.ub : 1)); 24 | promote((1 ? s.u : 1)); 25 | promote((1 ? s.ullb : 1)); 26 | promote((1 ? s.ull : 1)); 27 | promote((1 ? s.c : 1)); 28 | printf("\n"); 29 | 30 | promote(s.ub << 1); 31 | promote(s.u << 1); 32 | promote(s.ullb << 1); 33 | promote(s.ull << 1); 34 | promote(s.c << 1); 35 | printf("\n"); 36 | 37 | promote(+s.ub); 38 | promote(+s.u); 39 | promote(+s.ullb); 40 | promote(+s.ull); 41 | promote(+s.c); 42 | printf("\n"); 43 | 44 | promote(-s.ub); 45 | promote(-s.u); 46 | promote(-s.ullb); 47 | promote(-s.ull); 48 | promote(-s.c); 49 | printf("\n"); 50 | 51 | promote(~s.ub); 52 | promote(~s.u); 53 | promote(~s.ullb); 54 | promote(~s.ull); 55 | promote(~s.c); 56 | printf("\n"); 57 | 58 | promote(!s.ub); 59 | promote(!s.u); 60 | promote(!s.ullb); 61 | promote(!s.ull); 62 | promote(!s.c); 63 | printf("\n"); 64 | 65 | promote(+(unsigned)s.ub); 66 | promote(-(unsigned)s.ub); 67 | promote(~(unsigned)s.ub); 68 | promote(!(unsigned)s.ub); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/sec_api/conio_s.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | 7 | #ifndef _INC_CONIO_S 8 | #define _INC_CONIO_S 9 | 10 | #include 11 | 12 | #if defined(MINGW_HAS_SECURE_API) 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | _CRTIMP errno_t __cdecl _cgets_s(char *_Buffer,size_t _Size,size_t *_SizeRead); 19 | _CRTIMP int __cdecl _cprintf_s(const char *_Format,...); 20 | _CRTIMP int __cdecl _cscanf_s(const char *_Format,...); 21 | _CRTIMP int __cdecl _cscanf_s_l(const char *_Format,_locale_t _Locale,...); 22 | _CRTIMP int __cdecl _vcprintf_s(const char *_Format,va_list _ArgList); 23 | _CRTIMP int __cdecl _cprintf_s_l(const char *_Format,_locale_t _Locale,...); 24 | _CRTIMP int __cdecl _vcprintf_s_l(const char *_Format,_locale_t _Locale,va_list _ArgList); 25 | 26 | #ifndef _WCONIO_DEFINED_S 27 | #define _WCONIO_DEFINED_S 28 | _CRTIMP errno_t __cdecl _cgetws_s(wchar_t *_Buffer,size_t _SizeInWords,size_t *_SizeRead); 29 | _CRTIMP int __cdecl _cwprintf_s(const wchar_t *_Format,...); 30 | _CRTIMP int __cdecl _cwscanf_s(const wchar_t *_Format,...); 31 | _CRTIMP int __cdecl _cwscanf_s_l(const wchar_t *_Format,_locale_t _Locale,...); 32 | _CRTIMP int __cdecl _vcwprintf_s(const wchar_t *_Format,va_list _ArgList); 33 | _CRTIMP int __cdecl _cwprintf_s_l(const wchar_t *_Format,_locale_t _Locale,...); 34 | _CRTIMP int __cdecl _vcwprintf_s_l(const wchar_t *_Format,_locale_t _Locale,va_list _ArgList); 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_ERRNO 7 | #define _INC_ERRNO 8 | 9 | #include <_mingw.h> 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifndef _CRT_ERRNO_DEFINED 16 | #define _CRT_ERRNO_DEFINED 17 | _CRTIMP int *__cdecl _errno(void); 18 | #define errno (*_errno()) 19 | 20 | errno_t __cdecl _set_errno(int _Value); 21 | errno_t __cdecl _get_errno(int *_Value); 22 | #endif 23 | 24 | #define EPERM 1 25 | #define ENOENT 2 26 | #define ESRCH 3 27 | #define EINTR 4 28 | #define EIO 5 29 | #define ENXIO 6 30 | #define E2BIG 7 31 | #define ENOEXEC 8 32 | #define EBADF 9 33 | #define ECHILD 10 34 | #define EAGAIN 11 35 | #define ENOMEM 12 36 | #define EACCES 13 37 | #define EFAULT 14 38 | #define EBUSY 16 39 | #define EEXIST 17 40 | #define EXDEV 18 41 | #define ENODEV 19 42 | #define ENOTDIR 20 43 | #define EISDIR 21 44 | #define ENFILE 23 45 | #define EMFILE 24 46 | #define ENOTTY 25 47 | #define EFBIG 27 48 | #define ENOSPC 28 49 | #define ESPIPE 29 50 | #define EROFS 30 51 | #define EMLINK 31 52 | #define EPIPE 32 53 | #define EDOM 33 54 | #define EDEADLK 36 55 | #define ENAMETOOLONG 38 56 | #define ENOLCK 39 57 | #define ENOSYS 40 58 | #define ENOTEMPTY 41 59 | 60 | #ifndef RC_INVOKED 61 | #if !defined(_SECURECRT_ERRCODE_VALUES_DEFINED) 62 | #define _SECURECRT_ERRCODE_VALUES_DEFINED 63 | #define EINVAL 22 64 | #define ERANGE 34 65 | #define EILSEQ 42 66 | #define STRUNCATE 80 67 | #endif 68 | #endif 69 | 70 | #define EDEADLOCK EDEADLK 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | #endif 76 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/25_quicksort.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int array[16]; 4 | 5 | //Swap integer values by array indexes 6 | void swap(int a, int b) 7 | { 8 | int tmp = array[a]; 9 | array[a] = array[b]; 10 | array[b] = tmp; 11 | } 12 | 13 | //Partition the array into two halves and return the 14 | //index about which the array is partitioned 15 | int partition(int left, int right) 16 | { 17 | int pivotIndex = left; 18 | int pivotValue = array[pivotIndex]; 19 | int index = left; 20 | int i; 21 | 22 | swap(pivotIndex, right); 23 | for(i = left; i < right; i++) 24 | { 25 | if(array[i] < pivotValue) 26 | { 27 | swap(i, index); 28 | index += 1; 29 | } 30 | } 31 | swap(right, index); 32 | 33 | return index; 34 | } 35 | 36 | //Quicksort the array 37 | void quicksort(int left, int right) 38 | { 39 | if(left >= right) 40 | return; 41 | 42 | int index = partition(left, right); 43 | quicksort(left, index - 1); 44 | quicksort(index + 1, right); 45 | } 46 | 47 | int main() 48 | { 49 | int i; 50 | 51 | array[0] = 62; 52 | array[1] = 83; 53 | array[2] = 4; 54 | array[3] = 89; 55 | array[4] = 36; 56 | array[5] = 21; 57 | array[6] = 74; 58 | array[7] = 37; 59 | array[8] = 65; 60 | array[9] = 33; 61 | array[10] = 96; 62 | array[11] = 38; 63 | array[12] = 53; 64 | array[13] = 16; 65 | array[14] = 74; 66 | array[15] = 55; 67 | 68 | for (i = 0; i < 16; i++) 69 | printf("%d ", array[i]); 70 | 71 | printf("\n"); 72 | 73 | quicksort(0, 15); 74 | 75 | for (i = 0; i < 16; i++) 76 | printf("%d ", array[i]); 77 | 78 | printf("\n"); 79 | 80 | return 0; 81 | } 82 | 83 | /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ 84 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/55_lshift_type.c: -------------------------------------------------------------------------------- 1 | /* $Id: lshift-type.c 53089 2012-07-06 11:18:26Z vinc17/ypig $ 2 | 3 | Tests on left-shift type, written by Vincent Lefevre . 4 | 5 | ISO C99 TC3 says: [6.5.7#3] "The integer promotions are performed on 6 | each of the operands. The type of the result is that of the promoted 7 | left operand." 8 | */ 9 | 10 | #include 11 | 12 | #define PTYPE(M) ((M) < 0 || -(M) < 0 ? -1 : 1) * (int) sizeof((M)+0) 13 | #define CHECK(X,T) check(#X, PTYPE(X), PTYPE((X) << (T) 1)) 14 | #define TEST1(X,T) do { CHECK(X,T); CHECK(X,unsigned T); } while (0) 15 | #define TEST2(X) \ 16 | do \ 17 | { \ 18 | TEST1((X),short); \ 19 | TEST1((X),int); \ 20 | TEST1((X),long); \ 21 | TEST1((X),long long); \ 22 | } \ 23 | while (0) 24 | #define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0) 25 | #define TEST4(X) \ 26 | do \ 27 | { \ 28 | TEST3((X),short); \ 29 | TEST3((X),int); \ 30 | TEST3((X),long); \ 31 | TEST3((X),long long); \ 32 | } \ 33 | while (0) 34 | 35 | static int debug, nfailed = 0; 36 | 37 | static void check (const char *s, int arg1, int shift) 38 | { 39 | int failed = arg1 != shift; 40 | if (debug || failed) 41 | printf ("%s %d %d\n", s, arg1, shift); 42 | nfailed += failed; 43 | } 44 | 45 | int main (int argc, char **argv) 46 | { 47 | debug = argc > 1; 48 | TEST4(1); 49 | TEST4(-1); 50 | printf ("%d test(s) failed\n", nfailed); 51 | return nfailed != 0; 52 | } 53 | -------------------------------------------------------------------------------- /lib/tinycc/lib/alloca.S: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------- */ 2 | /* alloca.S */ 3 | 4 | #ifdef __leading_underscore 5 | # define _(s) _##s 6 | #else 7 | # define _(s) s 8 | #endif 9 | 10 | /* ---------------------------------------------- */ 11 | #if defined __i386__ 12 | 13 | .globl _(alloca), _(__alloca) 14 | _(alloca): 15 | _(__alloca): 16 | push %ebp 17 | mov %esp,%ebp 18 | mov 8(%ebp),%eax 19 | add $3,%eax 20 | and $-4,%eax 21 | #ifdef _WIN32 22 | jmp .+16 #p2 23 | p1: 24 | sub $4096,%esp 25 | sub $4096,%eax 26 | test %eax,(%esp) 27 | p2: 28 | cmp $4096,%eax 29 | jae p1 30 | #endif 31 | sub %eax,%esp 32 | mov 4(%ebp),%eax 33 | mov 0(%ebp),%ebp 34 | add $8,%esp 35 | push %eax 36 | lea 8(%esp),%eax 37 | ret 38 | 39 | /* ---------------------------------------------- */ 40 | #elif defined __x86_64__ 41 | 42 | .globl _(alloca) 43 | _(alloca): 44 | pop %rdx 45 | #ifdef _WIN32 46 | mov %rcx,%rax 47 | #else 48 | mov %rdi,%rax 49 | #endif 50 | add $15,%rax 51 | and $-16,%rax 52 | jz p3 53 | 54 | #ifdef _WIN32 55 | p1: 56 | cmp $4096,%rax 57 | jbe p2 58 | test %rax,-4096(%rsp) 59 | sub $4096,%rsp 60 | sub $4096,%rax 61 | jmp p1 62 | p2: 63 | #endif 64 | sub %rax,%rsp 65 | mov %rsp,%rax 66 | p3: 67 | push %rdx 68 | ret 69 | 70 | /* ---------------------------------------------- */ 71 | #elif defined __arm__ 72 | 73 | .text 74 | .align 2 75 | .global alloca 76 | .type alloca, %function 77 | alloca: 78 | rsb sp, r0, sp 79 | bic sp, sp, #7 80 | mov r0, sp 81 | mov pc, lr 82 | .size alloca, .-alloca 83 | 84 | /* ---------------------------------------------- */ 85 | #endif 86 | -------------------------------------------------------------------------------- /lib/tinycc/tests/tests2/104+_inline.c: -------------------------------------------------------------------------------- 1 | 2 | #define GOT(f) \ 3 | __attribute__((weak)) void f(void); \ 4 | printf("%d %s\n", !!((__SIZE_TYPE__)f & ~0u), #f); 5 | 6 | int printf(const char*, ...); 7 | 8 | void check_exports() 9 | { 10 | // 0 11 | GOT(inline_inline_2decl_only) 12 | GOT(inline_inline_undeclared) 13 | GOT(inline_inline_predeclared) 14 | GOT(inline_inline_postdeclared) 15 | GOT(inline_inline_prepostdeclared) 16 | GOT(inline_inline_undeclared2) 17 | GOT(inline_inline_predeclared2) 18 | GOT(inline_inline_postdeclared2) 19 | GOT(inline_inline_prepostdeclared2) 20 | 21 | // 1 22 | GOT(extern_extern_postdeclared) 23 | GOT(extern_extern_postdeclared2) 24 | GOT(extern_extern_predeclared) 25 | GOT(extern_extern_predeclared2) 26 | GOT(extern_extern_prepostdeclared) 27 | GOT(extern_extern_prepostdeclared2) 28 | GOT(extern_extern_undeclared) 29 | GOT(extern_extern_undeclared2) 30 | GOT(extern_postdeclared) 31 | GOT(extern_postdeclared2) 32 | GOT(extern_predeclared) 33 | GOT(extern_predeclared2) 34 | GOT(extern_prepostdeclared) 35 | GOT(extern_undeclared) 36 | GOT(extern_undeclared2) 37 | GOT(inst2_extern_inline_postdeclared) 38 | GOT(inst2_extern_inline_predeclared) 39 | GOT(inst3_extern_inline_predeclared) 40 | GOT(inst_extern_inline_postdeclared) 41 | GOT(inst_extern_inline_predeclared) 42 | GOT(main) 43 | GOT(noinst_extern_inline_func) 44 | GOT(noinst_extern_inline_postdeclared) 45 | GOT(noinst_extern_inline_postdeclared2) 46 | GOT(noinst_extern_inline_undeclared) 47 | 48 | // 0 49 | GOT(noinst_static_inline_postdeclared) 50 | GOT(noinst2_static_inline_postdeclared) 51 | GOT(noinst_static_inline_predeclared) 52 | GOT(noinst2_static_inline_predeclared) 53 | GOT(static_func) 54 | } 55 | -------------------------------------------------------------------------------- /lib/tinycc/win32/include/signal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER within this package. 5 | */ 6 | #ifndef _INC_SIGNAL 7 | #define _INC_SIGNAL 8 | 9 | #include <_mingw.h> 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifndef _SIG_ATOMIC_T_DEFINED 16 | #define _SIG_ATOMIC_T_DEFINED 17 | typedef int sig_atomic_t; 18 | #endif 19 | 20 | #define NSIG 23 21 | 22 | #define SIGHUP 1 /* hangup */ 23 | #define SIGINT 2 24 | #define SIGQUIT 3 /* quit */ 25 | #define SIGILL 4 26 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ 27 | #define SIGIOT 6 /* IOT instruction */ 28 | #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ 29 | #define SIGEMT 7 /* EMT instruction */ 30 | #define SIGFPE 8 31 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 32 | #define SIGBUS 10 /* bus error */ 33 | #define SIGSEGV 11 34 | #define SIGSYS 12 /* bad argument to system call */ 35 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ 36 | #ifdef __USE_MINGW_ALARM 37 | #define SIGALRM 14 /* alarm clock */ 38 | #endif 39 | #define SIGTERM 15 40 | #define SIGBREAK 21 41 | #define SIGABRT2 22 42 | 43 | #define SIGABRT_COMPAT 6 44 | 45 | typedef void (*__p_sig_fn_t)(int); 46 | 47 | #define SIG_DFL (__p_sig_fn_t)0 48 | #define SIG_IGN (__p_sig_fn_t)1 49 | #define SIG_GET (__p_sig_fn_t)2 50 | #define SIG_SGE (__p_sig_fn_t)3 51 | #define SIG_ACK (__p_sig_fn_t)4 52 | #define SIG_ERR (__p_sig_fn_t)-1 53 | 54 | extern void **__cdecl __pxcptinfoptrs(void); 55 | #define _pxcptinfoptrs (*__pxcptinfoptrs()) 56 | 57 | __p_sig_fn_t __cdecl signal(int _SigNum,__p_sig_fn_t _Func); 58 | int __cdecl raise(int _SigNum); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif 64 | --------------------------------------------------------------------------------