History

Trim trailing spaces everywhere.

gus knight committed 11 years ago

Commit 41031221 parent 5e67f2427 files · +430 −430Browse files

Unified · Split

27 files
  1. CMakeLists.txt +3 −3
  2. c67-gen.c +41 −41
  3. coff.h +6 −6
  4. configure +1 −1
  5. i386-asm.c +1 −1
  6. i386-asm.h +5 −5
  7. i386-gen.c +12 −12
  8. il-gen.c +7 −7
  9. il-opcodes.h +1 −1
  10. lib/bcheck.c +28 −28
  11. lib/libtcc1.c +13 −13
  12. libtcc.c +1 −1
  13. tcc-doc.texi +23 −23
  14. tcc.c +1 −1
  15. tcc.h +4 −4
  16. tccasm.c +25 −25
  17. tcccoff.c +2 −2
  18. tccelf.c +1 −1
  19. tccgen.c +110 −110
  20. tcclib.h +3 −3
  21. tccpe.c +1 −1
  22. tccpp.c +36 −36
  23. tcctok.h +1 −1
  24. tests/abitest.c +15 −15
  25. tests/tcctest.c +58 −58
  26. texi2pod.pl +1 −1
  27. x86_64-gen.c +30 −30
CMakeLists.txt+3−3
@@ -154,7 +154,7 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt · 153 unmodified lines
154 foreach(make_tcc_def ${TCC_NATIVE_DEFINITIONS})154 foreach(make_tcc_def ${TCC_NATIVE_DEFINITIONS})
155 set(TCC_NATIVE_FLAGS ${TCC_NATIVE_FLAGS} -D${make_tcc_def})155 set(TCC_NATIVE_FLAGS ${TCC_NATIVE_FLAGS} -D${make_tcc_def})
156 endforeach()156 endforeach()
157 157
158 if (TCC_BUILD_NATIVE)158 if (TCC_BUILD_NATIVE)
159 add_library(libtcc159 add_library(libtcc
160 libtcc.c160 libtcc.c
@@ -179,7 +179,7 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt · 18 unmodified lines
179 endif()179 endif()
180 install(TARGETS tcc libtcc RUNTIME DESTINATION ${EXE_PATH} LIBRARY DESTINATION ${NATIVE_LIB_PATH} ARCHIVE DESTINATION ${NATIVE_LIB_PATH})180 install(TARGETS tcc libtcc RUNTIME DESTINATION ${EXE_PATH} LIBRARY DESTINATION ${NATIVE_LIB_PATH} ARCHIVE DESTINATION ${NATIVE_LIB_PATH})
181 set_target_properties(tcc libtcc PROPERTIES COMPILE_DEFINITIONS "${TCC_NATIVE_DEFINITIONS}")181 set_target_properties(tcc libtcc PROPERTIES COMPILE_DEFINITIONS "${TCC_NATIVE_DEFINITIONS}")
182 182
183 if("${libtcc_sources}" STRGREATER "")183 if("${libtcc_sources}" STRGREATER "")
184 make_libtcc1("" tcc "${libtcc_ar}" "${TCC_NATIVE_DEFINITIONS}" "${libtcc_includes}" "${libtcc_sources}")184 make_libtcc1("" tcc "${libtcc_ar}" "${TCC_NATIVE_DEFINITIONS}" "${libtcc_includes}" "${libtcc_sources}")
185 endif()185 endif()
@@ -188,7 +188,7 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt · 2 unmodified lines
188 add_executable(${cross_name}-tcc tcc.c)188 add_executable(${cross_name}-tcc tcc.c)
189 set_target_properties(${cross_name}-tcc PROPERTIES COMPILE_DEFINITIONS "ONE_SOURCE;${definitions}")189 set_target_properties(${cross_name}-tcc PROPERTIES COMPILE_DEFINITIONS "ONE_SOURCE;${definitions}")
190 install(TARGETS ${cross_name}-tcc RUNTIME DESTINATION ${EXE_PATH})190 install(TARGETS ${cross_name}-tcc RUNTIME DESTINATION ${EXE_PATH})
191 191
192 if("${libtcc_sources}" STRGREATER "")192 if("${libtcc_sources}" STRGREATER "")
193 make_libtcc1(${cross_name} "${cross_name}-tcc" "${libtcc_ar}" "${definitions}" "${libtcc_includes}" "${libtcc_sources}")193 make_libtcc1(${cross_name} "${cross_name}-tcc" "${libtcc_ar}" "${definitions}" "${libtcc_includes}" "${libtcc_sources}")
194 endif()194 endif()
c67-gen.c+41−41
@@ -1,6 +1,6 @@
1/*1/*
2 * TMS320C67xx code generator for TCC2 * TMS320C67xx code generator for TCC
3 * 3 *
4 * Copyright (c) 2001, 2002 Fabrice Bellard4 * Copyright (c) 2001, 2002 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -130,7 +130,7 @@ enum { · 123 unmodified lines
130#include "tcc.h"130#include "tcc.h"
131 131
132ST_DATA const int reg_classes[NB_REGS] = {132ST_DATA const int reg_classes[NB_REGS] = {
133 /* eax */ RC_INT | RC_FLOAT | RC_EAX, 133 /* eax */ RC_INT | RC_FLOAT | RC_EAX,
134 // only allow even regs for floats (allow for doubles)134 // only allow even regs for floats (allow for doubles)
135 /* ecx */ RC_INT | RC_ECX,135 /* ecx */ RC_INT | RC_ECX,
136 /* edx */ RC_INT | RC_INT_BSIDE | RC_FLOAT | RC_EDX,136 /* edx */ RC_INT | RC_INT_BSIDE | RC_FLOAT | RC_EDX,
@@ -161,7 +161,7 @@ ST_DATA const int reg_classes[NB_REGS] = { · 24 unmodified lines
161// although tcc thinks it is passing parameters on the stack,161// although tcc thinks it is passing parameters on the stack,
162// the C67 really passes up to the first 10 params in special162// the C67 really passes up to the first 10 params in special
163// regs or regs pairs (for 64 bit params). So keep track of163// regs or regs pairs (for 64 bit params). So keep track of
164// the stack offsets so we can translate to the appropriate 164// the stack offsets so we can translate to the appropriate
165// reg (pair)165// reg (pair)
166 166
167#define NoCallArgsPassedOnStack 10167#define NoCallArgsPassedOnStack 10
@@ -246,7 +246,7 @@ void gsym(int t) · 78 unmodified lines
246 gsym_addr(t, ind);246 gsym_addr(t, ind);
247}247}
248 248
249// these are regs that tcc doesn't really know about, 249// these are regs that tcc doesn't really know about,
250// but assign them unique values so the mapping routines250// but assign them unique values so the mapping routines
251// can distinguish them251// can distinguish them
252 252
@@ -298,7 +298,7 @@ int C67_map_regn(int r) · 45 unmodified lines
298 return 0;298 return 0;
299}299}
300 300
301// mapping from tcc reg number to 301// mapping from tcc reg number to
302// C67 register to condition code field302// C67 register to condition code field
303//303//
304// valid condition code regs are:304// valid condition code regs are:
@@ -343,15 +343,15 @@ int C67_map_regs(int r) · 38 unmodified lines
343 else if (r >= TREG_C67_A4 && r <= TREG_C67_B13) // these form a pattern of alt pairs343 else if (r >= TREG_C67_A4 && r <= TREG_C67_B13) // these form a pattern of alt pairs
344 return (r & 2) >> 1;344 return (r & 2) >> 1;
345 else if (r == C67_A0)345 else if (r == C67_A0)
346 return 0; // set to A side 346 return 0; // set to A side
347 else if (r == C67_B2)347 else if (r == C67_B2)
348 return 1; // set to B side 348 return 1; // set to B side
349 else if (r == C67_B3)349 else if (r == C67_B3)
350 return 1; // set to B side350 return 1; // set to B side
351 else if (r == C67_SP)351 else if (r == C67_SP)
352 return 0x1; // set to SP (B15) B side 352 return 0x1; // set to SP (B15) B side
353 else if (r == C67_FP)353 else if (r == C67_FP)
354 return 0x0; // set to FP (A15) A side 354 return 0x0; // set to FP (A15) A side
355 else355 else
356 ALWAYS_ASSERT(FALSE);356 ALWAYS_ASSERT(FALSE);
357 357
@@ -420,7 +420,7 @@ void C67_asm(char *s, int a, int b, int c) · 62 unmodified lines
420 (5 << 9) | //mode 5 = pos offset, base reg + off reg420 (5 << 9) | //mode 5 = pos offset, base reg + off reg
421 (0 << 8) | //r (LDDW bit 0)421 (0 << 8) | //r (LDDW bit 0)
422 (0 << 7) | //y D1/D2 A side422 (0 << 7) | //y D1/D2 A side
423 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 423 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
424 (1 << 2) | //opcode424 (1 << 2) | //opcode
425 (C67_map_regs(a) << 1) | //side of src425 (C67_map_regs(a) << 1) | //side of src
426 (0 << 0)); //parallel426 (0 << 0)); //parallel
@@ -442,7 +442,7 @@ void C67_asm(char *s, int a, int b, int c) · 15 unmodified lines
442 (5 << 9) | //mode 5 = pos offset, base reg + off reg442 (5 << 9) | //mode 5 = pos offset, base reg + off reg
443 (0 << 8) | //r (LDDW bit 0)443 (0 << 8) | //r (LDDW bit 0)
444 (0 << 7) | //y D1/D2 A side444 (0 << 7) | //y D1/D2 A side
445 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 445 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
446 (1 << 2) | //opcode446 (1 << 2) | //opcode
447 (C67_map_regs(a) << 1) | //side of src447 (C67_map_regs(a) << 1) | //side of src
448 (0 << 0)); //parallel448 (0 << 0)); //parallel
@@ -464,7 +464,7 @@ void C67_asm(char *s, int a, int b, int c) · 15 unmodified lines
464 (5 << 9) | //mode 5 = pos offset, base reg + off reg464 (5 << 9) | //mode 5 = pos offset, base reg + off reg
465 (0 << 8) | //r (LDDW bit 0)465 (0 << 8) | //r (LDDW bit 0)
466 (0 << 7) | //y D1/D2 A side466 (0 << 7) | //y D1/D2 A side
467 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 467 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
468 (1 << 2) | //opcode468 (1 << 2) | //opcode
469 (C67_map_regs(a) << 1) | //side of src469 (C67_map_regs(a) << 1) | //side of src
470 (0 << 0)); //parallel470 (0 << 0)); //parallel
@@ -475,7 +475,7 @@ void C67_asm(char *s, int a, int b, int c) · 4 unmodified lines
475 (1 << 9) | //mode 1 = pos cst offset475 (1 << 9) | //mode 1 = pos cst offset
476 (0 << 8) | //r (LDDW bit 0)476 (0 << 8) | //r (LDDW bit 0)
477 (C67_map_regs(b) << 7) | //y D1/D2 base reg side477 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
478 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 478 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
479 (1 << 2) | //opcode479 (1 << 2) | //opcode
480 (C67_map_regs(a) << 1) | //side of src480 (C67_map_regs(a) << 1) | //side of src
481 (0 << 0)); //parallel481 (0 << 0)); //parallel
@@ -486,7 +486,7 @@ void C67_asm(char *s, int a, int b, int c) · 4 unmodified lines
486 (1 << 9) | //mode 1 = pos cst offset486 (1 << 9) | //mode 1 = pos cst offset
487 (0 << 8) | //r (LDDW bit 0)487 (0 << 8) | //r (LDDW bit 0)
488 (C67_map_regs(b) << 7) | //y D1/D2 base reg side488 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
489 (5 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 489 (5 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
490 (1 << 2) | //opcode490 (1 << 2) | //opcode
491 (C67_map_regs(a) << 1) | //side of src491 (C67_map_regs(a) << 1) | //side of src
492 (0 << 0)); //parallel492 (0 << 0)); //parallel
@@ -497,7 +497,7 @@ void C67_asm(char *s, int a, int b, int c) · 4 unmodified lines
497 (1 << 9) | //mode 1 = pos cst offset497 (1 << 9) | //mode 1 = pos cst offset
498 (0 << 8) | //r (LDDW bit 0)498 (0 << 8) | //r (LDDW bit 0)
499 (C67_map_regs(b) << 7) | //y D1/D2 base reg side499 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
500 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 500 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
501 (1 << 2) | //opcode501 (1 << 2) | //opcode
502 (C67_map_regs(a) << 1) | //side of src502 (C67_map_regs(a) << 1) | //side of src
503 (0 << 0)); //parallel503 (0 << 0)); //parallel
@@ -509,7 +509,7 @@ void C67_asm(char *s, int a, int b, int c) · 5 unmodified lines
509 (1 << 9) | //mode 1 = pos cst offset509 (1 << 9) | //mode 1 = pos cst offset
510 (0 << 8) | //r (LDDW bit 0)510 (0 << 8) | //r (LDDW bit 0)
511 (C67_map_regs(b) << 7) | //y D1/D2 base reg side511 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
512 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 512 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
513 (1 << 2) | //opcode513 (1 << 2) | //opcode
514 (C67_map_regs(a) << 1) | //side of src514 (C67_map_regs(a) << 1) | //side of src
515 (0 << 0)); //parallel515 (0 << 0)); //parallel
@@ -641,7 +641,7 @@ void C67_asm(char *s, int a, int b, int c) · 125 unmodified lines
641 (1 << 9) | //mode 1 = pos cst offset641 (1 << 9) | //mode 1 = pos cst offset
642 (0 << 8) | //r (LDDW bit 0)642 (0 << 8) | //r (LDDW bit 0)
643 (C67_map_regs(a) << 7) | //y D1/D2 src side643 (C67_map_regs(a) << 7) | //y D1/D2 src side
644 (2 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 644 (2 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
645 (1 << 2) | //opcode645 (1 << 2) | //opcode
646 (C67_map_regs(b) << 1) | //side of dst646 (C67_map_regs(b) << 1) | //side of dst
647 (0 << 0)); //parallel647 (0 << 0)); //parallel
@@ -652,7 +652,7 @@ void C67_asm(char *s, int a, int b, int c) · 4 unmodified lines
652 (1 << 9) | //mode 1 = pos cst offset652 (1 << 9) | //mode 1 = pos cst offset
653 (0 << 8) | //r (LDDW bit 0)653 (0 << 8) | //r (LDDW bit 0)
654 (C67_map_regs(a) << 7) | //y D1/D2 src side654 (C67_map_regs(a) << 7) | //y D1/D2 src side
655 (0 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 655 (0 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
656 (1 << 2) | //opcode656 (1 << 2) | //opcode
657 (C67_map_regs(b) << 1) | //side of dst657 (C67_map_regs(b) << 1) | //side of dst
658 (0 << 0)); //parallel658 (0 << 0)); //parallel
@@ -674,7 +674,7 @@ void C67_asm(char *s, int a, int b, int c) · 15 unmodified lines
674 (1 << 9) | //mode 1 = pos cst offset674 (1 << 9) | //mode 1 = pos cst offset
675 (0 << 8) | //r (LDDW bit 0)675 (0 << 8) | //r (LDDW bit 0)
676 (C67_map_regs(a) << 7) | //y D1/D2 src side676 (C67_map_regs(a) << 7) | //y D1/D2 src side
677 (6 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 677 (6 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
678 (1 << 2) | //opcode678 (1 << 2) | //opcode
679 (C67_map_regs(b) << 1) | //side of dst679 (C67_map_regs(b) << 1) | //side of dst
680 (0 << 0)); //parallel680 (0 << 0)); //parallel
@@ -877,7 +877,7 @@ void C67_asm(char *s, int a, int b, int c) · 196 unmodified lines
877 C67_g((0 << 29) | //creg877 C67_g((0 << 29) | //creg
878 (0 << 28) | //inv878 (0 << 28) | //inv
879 (C67_map_regn(c) << 23) | //dst879 (C67_map_regn(c) << 23) | //dst
880 (C67_map_regn(b) << 18) | //src2 880 (C67_map_regn(b) << 18) | //src2
881 (0 << 13) | //src1 NA881 (0 << 13) | //src1 NA
882 (xpath << 12) | //x cross path if opposite sides882 (xpath << 12) | //x cross path if opposite sides
883 (0x4a << 5) | //opcode883 (0x4a << 5) | //opcode
@@ -890,7 +890,7 @@ void C67_asm(char *s, int a, int b, int c) · 6 unmodified lines
890 C67_g((0 << 29) | //creg890 C67_g((0 << 29) | //creg
891 (0 << 28) | //inv891 (0 << 28) | //inv
892 (C67_map_regn(c) << 23) | //dst892 (C67_map_regn(c) << 23) | //dst
893 (C67_map_regn(b) << 18) | //src2 893 (C67_map_regn(b) << 18) | //src2
894 (0 << 13) | //src1 NA894 (0 << 13) | //src1 NA
895 (xpath << 12) | //x cross path if opposite sides895 (xpath << 12) | //x cross path if opposite sides
896 (0x49 << 5) | //opcode896 (0x49 << 5) | //opcode
@@ -903,7 +903,7 @@ void C67_asm(char *s, int a, int b, int c) · 6 unmodified lines
903 C67_g((0 << 29) | //creg903 C67_g((0 << 29) | //creg
904 (0 << 28) | //inv904 (0 << 28) | //inv
905 (C67_map_regn(c) << 23) | //dst905 (C67_map_regn(c) << 23) | //dst
906 (C67_map_regn(b) << 18) | //src2 906 (C67_map_regn(b) << 18) | //src2
907 (0 << 13) | //src1 NA907 (0 << 13) | //src1 NA
908 (xpath << 12) | //x cross path if opposite sides908 (xpath << 12) | //x cross path if opposite sides
909 (0x39 << 5) | //opcode909 (0x39 << 5) | //opcode
@@ -958,7 +958,7 @@ void C67_asm(char *s, int a, int b, int c) · 48 unmodified lines
958 (0 << 28) | //inv958 (0 << 28) | //inv
959 (C67_map_regn(c) << 23) | //dst959 (C67_map_regn(c) << 23) | //dst
960 (C67_map_regn(b) << 18) | //src2 (possible x path)960 (C67_map_regn(b) << 18) | //src2 (possible x path)
961 (C67_map_regn(a) << 13) | //src1 961 (C67_map_regn(a) << 13) | //src1
962 (xpath << 12) | //x cross path if opposite sides962 (xpath << 12) | //x cross path if opposite sides
963 (0x3 << 5) | //opcode963 (0x3 << 5) | //opcode
964 (0x6 << 2) | //opcode fixed964 (0x6 << 2) | //opcode fixed
@@ -973,7 +973,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
973 (0 << 28) | //inv973 (0 << 28) | //inv
974 (C67_map_regn(c) << 23) | //dst974 (C67_map_regn(c) << 23) | //dst
975 (C67_map_regn(b) << 18) | //src2 (possible x path)975 (C67_map_regn(b) << 18) | //src2 (possible x path)
976 (C67_map_regn(a) << 13) | //src1 976 (C67_map_regn(a) << 13) | //src1
977 (xpath << 12) | //x cross path if opposite sides977 (xpath << 12) | //x cross path if opposite sides
978 (0x7 << 5) | //opcode978 (0x7 << 5) | //opcode
979 (0x6 << 2) | //opcode fixed979 (0x6 << 2) | //opcode fixed
@@ -988,7 +988,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
988 (0 << 28) | //inv988 (0 << 28) | //inv
989 (C67_map_regn(c) << 23) | //dst989 (C67_map_regn(c) << 23) | //dst
990 (C67_map_regn(b) << 18) | //src2 (possible x path)990 (C67_map_regn(b) << 18) | //src2 (possible x path)
991 (C67_map_regn(a) << 13) | //src1 991 (C67_map_regn(a) << 13) | //src1
992 (xpath << 12) | //x cross path if opposite sides992 (xpath << 12) | //x cross path if opposite sides
993 (0x7f << 5) | //opcode993 (0x7f << 5) | //opcode
994 (0x6 << 2) | //opcode fixed994 (0x6 << 2) | //opcode fixed
@@ -1003,7 +1003,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1003 (0 << 28) | //inv1003 (0 << 28) | //inv
1004 (C67_map_regn(c) << 23) | //dst1004 (C67_map_regn(c) << 23) | //dst
1005 (C67_map_regn(b) << 18) | //src2 (possible x path)1005 (C67_map_regn(b) << 18) | //src2 (possible x path)
1006 (C67_map_regn(a) << 13) | //src1 1006 (C67_map_regn(a) << 13) | //src1
1007 (xpath << 12) | //x cross path if opposite sides1007 (xpath << 12) | //x cross path if opposite sides
1008 (0x7b << 5) | //opcode1008 (0x7b << 5) | //opcode
1009 (0x6 << 2) | //opcode fixed1009 (0x6 << 2) | //opcode fixed
@@ -1018,7 +1018,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1018 (0 << 28) | //inv1018 (0 << 28) | //inv
1019 (C67_map_regn(c) << 23) | //dst1019 (C67_map_regn(c) << 23) | //dst
1020 (C67_map_regn(b) << 18) | //src2 (possible x path)1020 (C67_map_regn(b) << 18) | //src2 (possible x path)
1021 (C67_map_regn(a) << 13) | //src1 1021 (C67_map_regn(a) << 13) | //src1
1022 (xpath << 12) | //x cross path if opposite sides1022 (xpath << 12) | //x cross path if opposite sides
1023 (0x6f << 5) | //opcode1023 (0x6f << 5) | //opcode
1024 (0x6 << 2) | //opcode fixed1024 (0x6 << 2) | //opcode fixed
@@ -1033,7 +1033,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1033 (0 << 28) | //inv1033 (0 << 28) | //inv
1034 (C67_map_regn(c) << 23) | //dst1034 (C67_map_regn(c) << 23) | //dst
1035 (C67_map_regn(b) << 18) | //src2 (possible x path)1035 (C67_map_regn(b) << 18) | //src2 (possible x path)
1036 (C67_map_regn(a) << 13) | //src1 1036 (C67_map_regn(a) << 13) | //src1
1037 (xpath << 12) | //x cross path if opposite sides1037 (xpath << 12) | //x cross path if opposite sides
1038 (0x10 << 5) | //opcode1038 (0x10 << 5) | //opcode
1039 (0x6 << 2) | //opcode fixed1039 (0x6 << 2) | //opcode fixed
@@ -1048,7 +1048,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1048 (0 << 28) | //inv1048 (0 << 28) | //inv
1049 (C67_map_regn(c) << 23) | //dst1049 (C67_map_regn(c) << 23) | //dst
1050 (C67_map_regn(b) << 18) | //src2 (possible x path)1050 (C67_map_regn(b) << 18) | //src2 (possible x path)
1051 (C67_map_regn(a) << 13) | //src1 1051 (C67_map_regn(a) << 13) | //src1
1052 (xpath << 12) | //x cross path if opposite sides1052 (xpath << 12) | //x cross path if opposite sides
1053 (0x18 << 5) | //opcode1053 (0x18 << 5) | //opcode
1054 (0x6 << 2) | //opcode fixed1054 (0x6 << 2) | //opcode fixed
@@ -1063,7 +1063,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1063 (0 << 28) | //inv1063 (0 << 28) | //inv
1064 (C67_map_regn(c) << 23) | //dst1064 (C67_map_regn(c) << 23) | //dst
1065 (C67_map_regn(b) << 18) | //src2 (possible x path)1065 (C67_map_regn(b) << 18) | //src2 (possible x path)
1066 (C67_map_regn(a) << 13) | //src1 1066 (C67_map_regn(a) << 13) | //src1
1067 (xpath << 12) | //x cross path if opposite sides1067 (xpath << 12) | //x cross path if opposite sides
1068 (0x11 << 5) | //opcode1068 (0x11 << 5) | //opcode
1069 (0x6 << 2) | //opcode fixed1069 (0x6 << 2) | //opcode fixed
@@ -1078,7 +1078,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1078 (0 << 28) | //inv1078 (0 << 28) | //inv
1079 (C67_map_regn(c) << 23) | //dst1079 (C67_map_regn(c) << 23) | //dst
1080 (C67_map_regn(b) << 18) | //src2 (possible x path)1080 (C67_map_regn(b) << 18) | //src2 (possible x path)
1081 (C67_map_regn(a) << 13) | //src1 1081 (C67_map_regn(a) << 13) | //src1
1082 (xpath << 12) | //x cross path if opposite sides1082 (xpath << 12) | //x cross path if opposite sides
1083 (0x19 << 5) | //opcode1083 (0x19 << 5) | //opcode
1084 (0x6 << 2) | //opcode fixed1084 (0x6 << 2) | //opcode fixed
@@ -1093,7 +1093,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1093 (0 << 28) | //inv1093 (0 << 28) | //inv
1094 (C67_map_regn(c) << 23) | //dst1094 (C67_map_regn(c) << 23) | //dst
1095 (C67_map_regn(b) << 18) | //src2 (possible x path)1095 (C67_map_regn(b) << 18) | //src2 (possible x path)
1096 (C67_map_regn(a) << 13) | //src1 1096 (C67_map_regn(a) << 13) | //src1
1097 (xpath << 12) | //x cross path if opposite sides1097 (xpath << 12) | //x cross path if opposite sides
1098 (0x1c << 7) | //opcode1098 (0x1c << 7) | //opcode
1099 (0x0 << 2) | //opcode fixed1099 (0x0 << 2) | //opcode fixed
@@ -1108,7 +1108,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1108 (0 << 28) | //inv1108 (0 << 28) | //inv
1109 (C67_map_regn(c) << 23) | //dst1109 (C67_map_regn(c) << 23) | //dst
1110 (C67_map_regn(b) << 18) | //src2 (possible x path)1110 (C67_map_regn(b) << 18) | //src2 (possible x path)
1111 (C67_map_regn(a) << 13) | //src1 1111 (C67_map_regn(a) << 13) | //src1
1112 (xpath << 12) | //x cross path if opposite sides1112 (xpath << 12) | //x cross path if opposite sides
1113 (0x0e << 7) | //opcode1113 (0x0e << 7) | //opcode
1114 (0x0 << 2) | //opcode fixed1114 (0x0 << 2) | //opcode fixed
@@ -1138,7 +1138,7 @@ void C67_asm(char *s, int a, int b, int c) · 23 unmodified lines
1138 (0 << 28) | //inv1138 (0 << 28) | //inv
1139 (C67_map_regn(c) << 23) | //dst1139 (C67_map_regn(c) << 23) | //dst
1140 (C67_map_regn(b) << 18) | //src21140 (C67_map_regn(b) << 18) | //src2
1141 (C67_map_regn(a) << 13) | //src1 1141 (C67_map_regn(a) << 13) | //src1
1142 (xpath << 12) | //x cross path if opposite sides1142 (xpath << 12) | //x cross path if opposite sides
1143 (0x37 << 6) | //opcode1143 (0x37 << 6) | //opcode
1144 (0x8 << 2) | //opcode fixed1144 (0x8 << 2) | //opcode fixed
@@ -1153,7 +1153,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1153 (0 << 28) | //inv1153 (0 << 28) | //inv
1154 (C67_map_regn(c) << 23) | //dst1154 (C67_map_regn(c) << 23) | //dst
1155 (C67_map_regn(b) << 18) | //src21155 (C67_map_regn(b) << 18) | //src2
1156 (C67_map_regn(a) << 13) | //src1 1156 (C67_map_regn(a) << 13) | //src1
1157 (xpath << 12) | //x cross path if opposite sides1157 (xpath << 12) | //x cross path if opposite sides
1158 (0x27 << 6) | //opcode1158 (0x27 << 6) | //opcode
1159 (0x8 << 2) | //opcode fixed1159 (0x8 << 2) | //opcode fixed
@@ -1168,7 +1168,7 @@ void C67_asm(char *s, int a, int b, int c) · 8 unmodified lines
1168 (0 << 28) | //inv1168 (0 << 28) | //inv
1169 (C67_map_regn(c) << 23) | //dst1169 (C67_map_regn(c) << 23) | //dst
1170 (C67_map_regn(b) << 18) | //src21170 (C67_map_regn(b) << 18) | //src2
1171 (C67_map_regn(a) << 13) | //src1 1171 (C67_map_regn(a) << 13) | //src1
1172 (xpath << 12) | //x cross path if opposite sides1172 (xpath << 12) | //x cross path if opposite sides
1173 (0x33 << 6) | //opcode1173 (0x33 << 6) | //opcode
1174 (0x8 << 2) | //opcode fixed1174 (0x8 << 2) | //opcode fixed
@@ -1597,7 +1597,7 @@ void load(int r, SValue * sv) · 422 unmodified lines
1597 size = 4;1597 size = 4;
1598 }1598 }
1599 1599
1600 // check if fc is a positive reference on the stack, 1600 // check if fc is a positive reference on the stack,
1601 // if it is tcc is referencing what it thinks is a parameter1601 // if it is tcc is referencing what it thinks is a parameter
1602 // on the stack, so check if it is really in a register.1602 // on the stack, so check if it is really in a register.
1603 1603
@@ -1962,7 +1962,7 @@ void gfunc_call(int nb_args) · 358 unmodified lines
1962// ending with B12:B13.1962// ending with B12:B13.
1963//1963//
1964// When a call is made, if the caller has its parameters1964// When a call is made, if the caller has its parameters
1965// in regs A4-B13 these must be saved before/as the call 1965// in regs A4-B13 these must be saved before/as the call
1966// parameters are loaded and restored upon return (or if/when needed).1966// parameters are loaded and restored upon return (or if/when needed).
1967 1967
1968/* generate function prolog of type 't' */1968/* generate function prolog of type 't' */
@@ -2033,7 +2033,7 @@ void gfunc_prolog(CType * func_type) · 64 unmodified lines
2033 2033
2034 TotalBytesPushedOnStack = -loc;2034 TotalBytesPushedOnStack = -loc;
2035 2035
2036 func_sub_sp_offset = ind; // remember where we put the stack instruction 2036 func_sub_sp_offset = ind; // remember where we put the stack instruction
2037 C67_ADDK(0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily)2037 C67_ADDK(0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily)
2038 2038
2039 C67_PUSH(C67_A0);2039 C67_PUSH(C67_A0);
@@ -2049,11 +2049,11 @@ void gfunc_epilog(void) · 9 unmodified lines
2049 C67_NOP(4); // NOP wait for load2049 C67_NOP(4); // NOP wait for load
2050 C67_IREG_B_REG(0, C67_CREG_ZERO, C67_B3); // B.S2 B32050 C67_IREG_B_REG(0, C67_CREG_ZERO, C67_B3); // B.S2 B3
2051 C67_POP(C67_FP);2051 C67_POP(C67_FP);
2052 C67_ADDK(local, C67_SP); // ADDK.L2 loc,SP 2052 C67_ADDK(local, C67_SP); // ADDK.L2 loc,SP
2053 C67_Adjust_ADDK((int *) (cur_text_section->data +2053 C67_Adjust_ADDK((int *) (cur_text_section->data +
2054 func_sub_sp_offset),2054 func_sub_sp_offset),
2055 -local + TotalBytesPushedOnStack);2055 -local + TotalBytesPushedOnStack);
2056 C67_NOP(3); // NOP 2056 C67_NOP(3); // NOP
2057 }2057 }
2058}2058}
2059 2059
coff.h+6−6
@@ -31,9 +31,9 @@ struct filehdr { · 30 unmodified lines
31#define F_LITTLE 0x100 /* byte ordering of an AR32WR (vax) */31#define F_LITTLE 0x100 /* byte ordering of an AR32WR (vax) */
32#define F_BIG 0x200 /* byte ordering of an AR32W (3B, maxi) */32#define F_BIG 0x200 /* byte ordering of an AR32W (3B, maxi) */
33#define F_PATCH 0x400 /* contains "patch" list in optional header */33#define F_PATCH 0x400 /* contains "patch" list in optional header */
34#define F_NODF 0x400 34#define F_NODF 0x400
35 35
36#define F_VERSION (F_GSP10 | F_GSP20) 36#define F_VERSION (F_GSP10 | F_GSP20)
37#define F_BYTE_ORDER (F_LITTLE | F_BIG)37#define F_BYTE_ORDER (F_LITTLE | F_BIG)
38#define FILHDR struct filehdr38#define FILHDR struct filehdr
39 39
@@ -68,7 +68,7 @@ typedef struct aouthdr { · 28 unmodified lines
68 68
69/*----------------------------------------------------------------------*/69/*----------------------------------------------------------------------*/
70/* When a UNIX aout header is to be built in the optional header, */70/* When a UNIX aout header is to be built in the optional header, */
71/* the following magic numbers can appear in that header: */ 71/* the following magic numbers can appear in that header: */
72/* */72/* */
73/* AOUT1MAGIC : default : readonly sharable text segment */73/* AOUT1MAGIC : default : readonly sharable text segment */
74/* AOUT2MAGIC: : writable text segment */74/* AOUT2MAGIC: : writable text segment */
@@ -164,7 +164,7 @@ struct scnhdr { · 89 unmodified lines
164#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, not loaded */164#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, not loaded */
165#define STYP_GROUP 0x04 /* "grouped" : formed of input sections */165#define STYP_GROUP 0x04 /* "grouped" : formed of input sections */
166#define STYP_PAD 0x08 /* "padding" : not allocated, not relocated, loaded */166#define STYP_PAD 0x08 /* "padding" : not allocated, not relocated, loaded */
167#define STYP_COPY 0x10 /* "copy" : used for C init tables - 167#define STYP_COPY 0x10 /* "copy" : used for C init tables -
168 not allocated, relocated,168 not allocated, relocated,
169 loaded; reloc & lineno169 loaded; reloc & lineno
170 entries processed normally */170 entries processed normally */
@@ -358,11 +358,11 @@ struct syment · 187 unmodified lines
358#define N_BTSHFT_COFF 4358#define N_BTSHFT_COFF 4
359#define N_TSHIFT_COFF 2359#define N_TSHIFT_COFF 2
360 360
361#define BTYPE_COFF(x) ((x) & N_BTMASK_COFF) 361#define BTYPE_COFF(x) ((x) & N_BTMASK_COFF)
362#define ISINT(x) (((x) >= T_CHAR && (x) <= T_LONG) || \362#define ISINT(x) (((x) >= T_CHAR && (x) <= T_LONG) || \
363 ((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)363 ((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)
364#define ISFLT_COFF(x) ((x) == T_DOUBLE || (x) == T_FLOAT)364#define ISFLT_COFF(x) ((x) == T_DOUBLE || (x) == T_FLOAT)
365#define ISPTR_COFF(x) (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF)) 365#define ISPTR_COFF(x) (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF))
366#define ISFCN_COFF(x) (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))366#define ISFCN_COFF(x) (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))
367#define ISARY_COFF(x) (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))367#define ISARY_COFF(x) (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))
368#define ISTAG_COFF(x) ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)368#define ISTAG_COFF(x) ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)
configure+1−1
@@ -66,7 +66,7 @@ case $targetos in · 65 unmodified lines
66esac66esac
67 67
68# find source path68# find source path
69# XXX: we assume an absolute path is given when launching configure, 69# XXX: we assume an absolute path is given when launching configure,
70# except in './configure' case.70# except in './configure' case.
71source_path=${0%configure}71source_path=${0%configure}
72source_path=${source_path%/}72source_path=${source_path%/}
i386-asm.c+1−1
@@ -712,7 +712,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) · 711 unmodified lines
712 a32 = addr32 = 1;712 a32 = addr32 = 1;
713 }713 }
714#endif714#endif
715 if (b & 0xff00) 715 if (b & 0xff00)
716 g(b >> 8);716 g(b >> 8);
717 g(b);717 g(b);
718 return;718 return;
i386-asm.h+5−5
@@ -57,7 +57,7 @@ ALT(DEF_ASM_OP0L(stosb, 0xaa, 0, OPC_BWL)) · 56 unmodified lines
57ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWL))57ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWL))
58 58
59 /* bits */59 /* bits */
60 60
61ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))61ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))
62ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))62ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA, OPT_REGW))
63 63
@@ -91,7 +91,7 @@ ALT(DEF_ASM_OP2(btcw, 0x0fba, 7, OPC_MODRM | OPC_WL, OPT_IM8, OPT_REGW | OPT_EA) · 27 unmodified lines
91 DEF_ASM_OP0(repz, 0xf3)91 DEF_ASM_OP0(repz, 0xf3)
92 DEF_ASM_OP0(repne, 0xf2)92 DEF_ASM_OP0(repne, 0xf2)
93 DEF_ASM_OP0(repnz, 0xf2)93 DEF_ASM_OP0(repnz, 0xf2)
94 94
95 DEF_ASM_OP0(invd, 0x0f08)95 DEF_ASM_OP0(invd, 0x0f08)
96 DEF_ASM_OP0(wbinvd, 0x0f09)96 DEF_ASM_OP0(wbinvd, 0x0f09)
97 DEF_ASM_OP0(cpuid, 0x0fa2)97 DEF_ASM_OP0(cpuid, 0x0fa2)
@@ -236,7 +236,7 @@ ALT(DEF_ASM_OP1(jo, 0x70, 0, OPC_SHORTJMP | OPC_JMP | OPC_TEST, OPT_ADDR)) · 138 unmodified lines
236 DEF_ASM_OP1(loopz, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)236 DEF_ASM_OP1(loopz, 0xe1, 0, OPC_SHORTJMP, OPT_ADDR)
237 DEF_ASM_OP1(loop, 0xe2, 0, OPC_SHORTJMP, OPT_ADDR)237 DEF_ASM_OP1(loop, 0xe2, 0, OPC_SHORTJMP, OPT_ADDR)
238 DEF_ASM_OP1(jecxz, 0xe3, 0, OPC_SHORTJMP, OPT_ADDR)238 DEF_ASM_OP1(jecxz, 0xe3, 0, OPC_SHORTJMP, OPT_ADDR)
239 239
240 /* float */240 /* float */
241 /* specific fcomp handling */241 /* specific fcomp handling */
242ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))242ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))
@@ -298,7 +298,7 @@ ALT(DEF_ASM_OP1(fldl, 0xdd, 0, OPC_MODRM, OPT_EA)) · 55 unmodified lines
298 DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)298 DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)
299 DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)299 DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)
300 DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)300 DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)
301 301
302 /* fp store */302 /* fp store */
303 DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)303 DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)
304 DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)304 DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)
@@ -380,7 +380,7 @@ ALT(DEF_ASM_OP2(cmpxchgb, 0x0fb0, 0, OPC_MODRM | OPC_BWL, OPT_REG, OPT_REG | OPT · 75 unmodified lines
380 380
381 /* pentium */381 /* pentium */
382 DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )382 DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )
383 383
384 /* pentium pro */384 /* pentium pro */
385 ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))385 ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST, OPT_REG32 | OPT_EA, OPT_REG32))
386#ifdef I386_ASM_16386#ifdef I386_ASM_16
i386-gen.c+12−12
@@ -1,6 +1,6 @@
1/*1/*
2 * X86 code generator for TCC2 * X86 code generator for TCC
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -32,7 +32,7 @@ typedef int RegArgs; · 25 unmodified lines
32#define RC_INT 0x0001 /* generic integer register */32#define RC_INT 0x0001 /* generic integer register */
33#define RC_FLOAT 0x0002 /* generic float register */33#define RC_FLOAT 0x0002 /* generic float register */
34#define RC_EAX 0x000434#define RC_EAX 0x0004
35#define RC_ST0 0x0008 35#define RC_ST0 0x0008
36#define RC_ECX 0x001036#define RC_ECX 0x0010
37#define RC_EDX 0x002037#define RC_EDX 0x0020
38#define RC_IRET RC_EAX /* function return: integer register */38#define RC_IRET RC_EAX /* function return: integer register */
@@ -357,11 +357,11 @@ static void gcall_or_jmp(int is_jmp) · 318 unmodified lines
357 /* constant case */357 /* constant case */
358 if (vtop->r & VT_SYM) {358 if (vtop->r & VT_SYM) {
359 /* relocation case */359 /* relocation case */
360 greloc(cur_text_section, vtop->sym, 360 greloc(cur_text_section, vtop->sym,
361 ind + 1, R_386_PC32);361 ind + 1, R_386_PC32);
362 } else {362 } else {
363 /* put an empty PC32 relocation */363 /* put an empty PC32 relocation */
364 put_elf_reloc(symtab_section, cur_text_section, 364 put_elf_reloc(symtab_section, cur_text_section,
365 ind + 1, R_386_PC32, 0);365 ind + 1, R_386_PC32, 0);
366 }366 }
367 oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */367 oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */
@@ -417,7 +417,7 @@ ST_FUNC void gfunc_call(int nb_args) · 49 unmodified lines
417{417{
418 int size, align, r, args_size, i, func_call;418 int size, align, r, args_size, i, func_call;
419 Sym *func_sym;419 Sym *func_sym;
420 420
421 args_size = 0;421 args_size = 0;
422 for(i = 0;i < nb_args; i++) {422 for(i = 0;i < nb_args; i++) {
423 if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {423 if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
@@ -610,7 +610,7 @@ ST_FUNC void gfunc_epilog(void) · 186 unmodified lines
610 /* generate bound local allocation */610 /* generate bound local allocation */
611 saved_ind = ind;611 saved_ind = ind;
612 ind = func_sub_sp_offset;612 ind = func_sub_sp_offset;
613 sym_data = get_sym_ref(&char_pointer_type, lbounds_section, 613 sym_data = get_sym_ref(&char_pointer_type, lbounds_section,
614 func_bound_offset, lbounds_section->data_offset);614 func_bound_offset, lbounds_section->data_offset);
615 greloc(cur_text_section, sym_data,615 greloc(cur_text_section, sym_data,
616 ind + 1, R_386_32);616 ind + 1, R_386_32);
@@ -637,8 +637,8 @@ ST_FUNC void gfunc_epilog(void) · 20 unmodified lines
637 g(func_ret_sub >> 8);637 g(func_ret_sub >> 8);
638 }638 }
639 /* align local size to word & save local variables */639 /* align local size to word & save local variables */
640 640
641 v = (-loc + 3) & -4; 641 v = (-loc + 3) & -4;
642 saved_ind = ind;642 saved_ind = ind;
643 ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;643 ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
644#ifdef TCC_TARGET_PE644#ifdef TCC_TARGET_PE
@@ -741,7 +741,7 @@ ST_FUNC void gen_opi(int op) · 96 unmodified lines
741 r = vtop[-1].r;741 r = vtop[-1].r;
742 fr = vtop[0].r;742 fr = vtop[0].r;
743 o((opc << 3) | 0x01);743 o((opc << 3) | 0x01);
744 o(0xc0 + r + fr * 8); 744 o(0xc0 + r + fr * 8);
745 }745 }
746 vtop--;746 vtop--;
747 if (op >= TOK_ULT && op <= TOK_GT) {747 if (op >= TOK_ULT && op <= TOK_GT) {
@@ -911,7 +911,7 @@ ST_FUNC void gen_opf(int op) · 163 unmodified lines
911 load(TREG_ST0, vtop);911 load(TREG_ST0, vtop);
912 swapped = !swapped;912 swapped = !swapped;
913 }913 }
914 914
915 switch(op) {915 switch(op) {
916 default:916 default:
917 case '+':917 case '+':
@@ -972,7 +972,7 @@ ST_FUNC void gen_cvt_itof(int t) · 54 unmodified lines
972 o(0x50 + (vtop->r & VT_VALMASK)); /* push r */972 o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
973 o(0x242cdf); /* fildll (%esp) */973 o(0x242cdf); /* fildll (%esp) */
974 o(0x08c483); /* add $8, %esp */974 o(0x08c483); /* add $8, %esp */
975 } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 975 } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
976 (VT_INT | VT_UNSIGNED)) {976 (VT_INT | VT_UNSIGNED)) {
977 /* unsigned int to float/double/long double */977 /* unsigned int to float/double/long double */
978 o(0x6a); /* push $0 */978 o(0x6a); /* push $0 */
@@ -1060,7 +1060,7 @@ ST_FUNC void gen_bounded_ptr_add(void) · 81 unmodified lines
1060 vtop++;1060 vtop++;
1061 vtop->r = TREG_EAX | VT_BOUNDED;1061 vtop->r = TREG_EAX | VT_BOUNDED;
1062 /* address of bounding function call point */1062 /* address of bounding function call point */
1063 vtop->c.ul = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel)); 1063 vtop->c.ul = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel));
1064}1064}
1065 1065
1066/* patch pointer addition in vtop so that pointer dereferencing is1066/* patch pointer addition in vtop so that pointer dereferencing is
il-gen.c+7−7
@@ -1,6 +1,6 @@
1/*1/*
2 * CIL code generator for TCC2 * CIL code generator for TCC
3 * 3 *
4 * Copyright (c) 2002 Fabrice Bellard4 * Copyright (c) 2002 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -112,7 +112,7 @@ static void init_outfile(void) · 105 unmodified lines
112{112{
113 if (!il_outfile) {113 if (!il_outfile) {
114 il_outfile = stdout;114 il_outfile = stdout;
115 fprintf(il_outfile, 115 fprintf(il_outfile,
116 ".assembly extern mscorlib\n"116 ".assembly extern mscorlib\n"
117 "{\n"117 "{\n"
118 ".ver 1:0:2411:0\n"118 ".ver 1:0:2411:0\n"
@@ -149,7 +149,7 @@ static void out_opi(int op, int c) · 30 unmodified lines
149}149}
150 150
151/* XXX: not complete */151/* XXX: not complete */
152static void il_type_to_str(char *buf, int buf_size, 152static void il_type_to_str(char *buf, int buf_size,
153 int t, const char *varstr)153 int t, const char *varstr)
154{154{
155 int bt;155 int bt;
@@ -301,12 +301,12 @@ void load(int r, SValue *sv) · 145 unmodified lines
301 out_op(IL_OP_LDIND_U2);301 out_op(IL_OP_LDIND_U2);
302 else302 else
303 out_op(IL_OP_LDIND_I4);303 out_op(IL_OP_LDIND_I4);
304 } 304 }
305 } else {305 } else {
306 if (v == VT_CONST) {306 if (v == VT_CONST) {
307 /* XXX: handle globals */307 /* XXX: handle globals */
308 if (fc >= -1 && fc <= 8) {308 if (fc >= -1 && fc <= 8) {
309 out_op(IL_OP_LDC_I4_M1 + fc + 1); 309 out_op(IL_OP_LDC_I4_M1 + fc + 1);
310 } else {310 } else {
311 out_opi(IL_OP_LDC_I4, fc);311 out_opi(IL_OP_LDC_I4, fc);
312 }312 }
@@ -430,10 +430,10 @@ void gfunc_prolog(int t) · 117 unmodified lines
430 /* XXX: cannot do better now */430 /* XXX: cannot do better now */
431 fprintf(il_outfile, " .maxstack %d\n", NB_REGS);431 fprintf(il_outfile, " .maxstack %d\n", NB_REGS);
432 fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");432 fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");
433 433
434 if (!strcmp(funcname, "main"))434 if (!strcmp(funcname, "main"))
435 fprintf(il_outfile, " .entrypoint\n");435 fprintf(il_outfile, " .entrypoint\n");
436 436
437 sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);437 sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
438 func_call = sym->r;438 func_call = sym->r;
439 439
il-opcodes.h+1−1
@@ -1,6 +1,6 @@
1/*1/*
2 * CIL opcode definition2 * CIL opcode definition
3 * 3 *
4 * Copyright (c) 2002 Fabrice Bellard4 * Copyright (c) 2002 Fabrice Bellard
5 *5 *
6 * This program is free software; you can redistribute it and/or modify6 * This program is free software; you can redistribute it and/or modify
lib/bcheck.c+28−28
@@ -1,6 +1,6 @@
1/*1/*
2 * Tiny C Memory and bounds checker2 * Tiny C Memory and bounds checker
3 * 3 *
4 * Copyright (c) 2002 Fabrice Bellard4 * Copyright (c) 2002 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -88,7 +88,7 @@ int __bound_delete_region(void *p); · 81 unmodified lines
88 88
89#ifdef __attribute__89#ifdef __attribute__
90 /* an __attribute__ macro is defined in the system headers */90 /* an __attribute__ macro is defined in the system headers */
91 #undef __attribute__ 91 #undef __attribute__
92#endif92#endif
93#define FASTCALL __attribute__((regparm(3)))93#define FASTCALL __attribute__((regparm(3)))
94 94
@@ -177,8 +177,8 @@ void * FASTCALL __bound_ptr_add(void *p, size_t offset) · 82 unmodified lines
177 dprintf(stderr, "%s %s: %p %p\n", __FILE__, __FUNCTION__, p, offset);177 dprintf(stderr, "%s %s: %p %p\n", __FILE__, __FUNCTION__, p, offset);
178 178
179 e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];179 e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];
180 e = (BoundEntry *)((char *)e + 180 e = (BoundEntry *)((char *)e +
181 ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) & 181 ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) &
182 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));182 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));
183 addr -= e->start;183 addr -= e->start;
184 if (addr > e->size) {184 if (addr > e->size) {
@@ -236,7 +236,7 @@ BOUND_PTR_INDIR(16) · 51 unmodified lines
236}236}
237 237
238/* called when entering a function to add all the local regions */238/* called when entering a function to add all the local regions */
239void FASTCALL __bound_local_new(void *p1) 239void FASTCALL __bound_local_new(void *p1)
240{240{
241 size_t addr, size, fp, *p = p1;241 size_t addr, size, fp, *p = p1;
242 242
@@ -255,7 +255,7 @@ void FASTCALL __bound_local_new(void *p1) · 12 unmodified lines
255}255}
256 256
257/* called when leaving a function to delete all the local regions */257/* called when leaving a function to delete all the local regions */
258void FASTCALL __bound_local_delete(void *p1) 258void FASTCALL __bound_local_delete(void *p1)
259{259{
260 size_t addr, fp, *p = p1;260 size_t addr, fp, *p = p1;
261 GET_CALLER_FP(fp);261 GET_CALLER_FP(fp);
@@ -331,14 +331,14 @@ static void mark_invalid(size_t addr, size_t size) · 69 unmodified lines
331#if 0331#if 0
332 dprintf(stderr, "mark_invalid: start = %x %x\n", t2_start, t2_end);332 dprintf(stderr, "mark_invalid: start = %x %x\n", t2_start, t2_end);
333#endif333#endif
334 334
335 /* first we handle full pages */335 /* first we handle full pages */
336 t1_start = (t2_start + BOUND_T2_SIZE - 1) >> BOUND_T2_BITS;336 t1_start = (t2_start + BOUND_T2_SIZE - 1) >> BOUND_T2_BITS;
337 t1_end = t2_end >> BOUND_T2_BITS;337 t1_end = t2_end >> BOUND_T2_BITS;
338 338
339 i = t2_start & (BOUND_T2_SIZE - 1);339 i = t2_start & (BOUND_T2_SIZE - 1);
340 j = t2_end & (BOUND_T2_SIZE - 1);340 j = t2_end & (BOUND_T2_SIZE - 1);
341 341
342 if (t1_start == t1_end) {342 if (t1_start == t1_end) {
343 page = get_page(t2_start >> BOUND_T2_BITS);343 page = get_page(t2_start >> BOUND_T2_BITS);
344 for(; i < j; i++) {344 for(; i < j; i++) {
@@ -456,7 +456,7 @@ void __bound_main_arg(void **p) · 111 unmodified lines
456 void *start = p;456 void *start = p;
457 while (*p++);457 while (*p++);
458 458
459 dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n", 459 dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n",
460 __FILE__, __FUNCTION__, (void *) p - start);460 __FILE__, __FUNCTION__, (void *) p - start);
461 461
462 __bound_new_region(start, (void *) p - start);462 __bound_new_region(start, (void *) p - start);
@@ -467,7 +467,7 @@ void __bound_exit(void) · 4 unmodified lines
467 restore_malloc_hooks();467 restore_malloc_hooks();
468}468}
469 469
470static inline void add_region(BoundEntry *e, 470static inline void add_region(BoundEntry *e,
471 size_t start, size_t size)471 size_t start, size_t size)
472{472{
473 BoundEntry *e1;473 BoundEntry *e1;
@@ -496,7 +496,7 @@ void __bound_new_region(void *p, size_t size) · 22 unmodified lines
496 496
497 __bound_init();497 __bound_init();
498 498
499 dprintf(stderr, "%s, %s(%p, %p) start\n", 499 dprintf(stderr, "%s, %s(%p, %p) start\n",
500 __FILE__, __FUNCTION__, p, size);500 __FILE__, __FUNCTION__, p, size);
501 501
502 start = (size_t)p;502 start = (size_t)p;
@@ -506,9 +506,9 @@ void __bound_new_region(void *p, size_t size) · 3 unmodified lines
506 506
507 /* start */507 /* start */
508 page = get_page(t1_start);508 page = get_page(t1_start);
509 t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) & 509 t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) &
510 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);510 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
511 t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) & 511 t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) &
512 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);512 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
513 513
514 514
@@ -557,7 +557,7 @@ void __bound_new_region(void *p, size_t size) · 42 unmodified lines
557}557}
558 558
559/* delete a region */559/* delete a region */
560static inline void delete_region(BoundEntry *e, 560static inline void delete_region(BoundEntry *e,
561 void *p, size_t empty_size)561 void *p, size_t empty_size)
562{562{
563 size_t addr;563 size_t addr;
@@ -612,9 +612,9 @@ int __bound_delete_region(void *p) · 48 unmodified lines
612 612
613 start = (size_t)p;613 start = (size_t)p;
614 t1_start = start >> (BOUND_T2_BITS + BOUND_T3_BITS);614 t1_start = start >> (BOUND_T2_BITS + BOUND_T3_BITS);
615 t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) & 615 t2_start = (start >> (BOUND_T3_BITS - BOUND_E_BITS)) &
616 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);616 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
617 617
618 /* find region size */618 /* find region size */
619 page = __bound_t1[t1_start];619 page = __bound_t1[t1_start];
620 e = (BoundEntry *)((char *)page + t2_start);620 e = (BoundEntry *)((char *)page + t2_start);
@@ -622,7 +622,7 @@ int __bound_delete_region(void *p) · 1 unmodified line
622 if (addr > e->size)622 if (addr > e->size)
623 e = __bound_find_region(e, p);623 e = __bound_find_region(e, p);
624 /* test if invalid region */624 /* test if invalid region */
625 if (e->size == EMPTY_SIZE || (size_t)p != e->start) 625 if (e->size == EMPTY_SIZE || (size_t)p != e->start)
626 return -1;626 return -1;
627 /* compute the size we put in invalid regions */627 /* compute the size we put in invalid regions */
628 if (e->is_invalid)628 if (e->is_invalid)
@@ -634,7 +634,7 @@ int __bound_delete_region(void *p) · 5 unmodified lines
634 634
635 /* now we can free each entry */635 /* now we can free each entry */
636 t1_end = end >> (BOUND_T2_BITS + BOUND_T3_BITS);636 t1_end = end >> (BOUND_T2_BITS + BOUND_T3_BITS);
637 t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) & 637 t2_end = (end >> (BOUND_T3_BITS - BOUND_E_BITS)) &
638 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);638 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS);
639 639
640 delete_region(e, p, empty_size);640 delete_region(e, p, empty_size);
@@ -690,8 +690,8 @@ static size_t get_region_size(void *p) · 49 unmodified lines
690 BoundEntry *e;690 BoundEntry *e;
691 691
692 e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];692 e = __bound_t1[addr >> (BOUND_T2_BITS + BOUND_T3_BITS)];
693 e = (BoundEntry *)((char *)e + 693 e = (BoundEntry *)((char *)e +
694 ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) & 694 ((addr >> (BOUND_T3_BITS - BOUND_E_BITS)) &
695 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));695 ((BOUND_T2_SIZE - 1) << BOUND_E_BITS)));
696 addr -= e->start;696 addr -= e->start;
697 if (addr > e->size)697 if (addr > e->size)
@@ -756,16 +756,16 @@ static void libc_free(void *ptr) · 58 unmodified lines
756void *__bound_malloc(size_t size, const void *caller)756void *__bound_malloc(size_t size, const void *caller)
757{757{
758 void *ptr;758 void *ptr;
759 759
760 /* we allocate one more byte to ensure the regions will be760 /* we allocate one more byte to ensure the regions will be
761 separated by at least one byte. With the glibc malloc, it may761 separated by at least one byte. With the glibc malloc, it may
762 be in fact not necessary */762 be in fact not necessary */
763 ptr = libc_malloc(size + 1);763 ptr = libc_malloc(size + 1);
764 764
765 if (!ptr)765 if (!ptr)
766 return NULL;766 return NULL;
767 767
768 dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n", 768 dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n",
769 __FILE__, __FUNCTION__, ptr, size);769 __FILE__, __FUNCTION__, ptr, size);
770 770
771 __bound_new_region(ptr, size);771 __bound_new_region(ptr, size);
@@ -792,13 +792,13 @@ void *__bound_memalign(size_t size, size_t align, const void *caller) · 20 unmodified lines
792 be in fact not necessary */792 be in fact not necessary */
793 ptr = memalign(size + 1, align);793 ptr = memalign(size + 1, align);
794#endif794#endif
795 795
796 install_malloc_hooks();796 install_malloc_hooks();
797 797
798 if (!ptr)798 if (!ptr)
799 return NULL;799 return NULL;
800 800
801 dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n", 801 dprintf(stderr, "%s, %s calling __bound_new_region(%p, %p)\n",
802 __FILE__, __FUNCTION__, ptr, size);802 __FILE__, __FUNCTION__, ptr, size);
803 803
804 __bound_new_region(ptr, size);804 __bound_new_region(ptr, size);
@@ -862,8 +862,8 @@ static void bound_dump(void) · 57 unmodified lines
862 e = page + j;862 e = page + j;
863 /* do not print invalid or empty entries */863 /* do not print invalid or empty entries */
864 if (e->size != EMPTY_SIZE && e->start != 0) {864 if (e->size != EMPTY_SIZE && e->start != 0) {
865 fprintf(stderr, "%08x:", 865 fprintf(stderr, "%08x:",
866 (i << (BOUND_T2_BITS + BOUND_T3_BITS)) + 866 (i << (BOUND_T2_BITS + BOUND_T3_BITS)) +
867 (j << BOUND_T3_BITS));867 (j << BOUND_T3_BITS));
868 do {868 do {
869 fprintf(stderr, " %08lx:%08lx", e->start, e->start + e->size);869 fprintf(stderr, " %08lx:%08lx", e->start, e->start + e->size);
lib/libtcc1.c+13−13
@@ -1,5 +1,5 @@
1/* TCC runtime library. 1/* TCC runtime library.
2 Parts of this code are (c) 2002 Fabrice Bellard 2 Parts of this code are (c) 2002 Fabrice Bellard
3 3
4 Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.4 Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.
5 5
@@ -25,7 +25,7 @@ General Public License for more details. · 19 unmodified lines
25You should have received a copy of the GNU General Public License25You should have received a copy of the GNU General Public License
26along with this program; see the file COPYING. If not, write to26along with this program; see the file COPYING. If not, write to
27the Free Software Foundation, 59 Temple Place - Suite 330,27the Free Software Foundation, 59 Temple Place - Suite 330,
28Boston, MA 02111-1307, USA. 28Boston, MA 02111-1307, USA.
29*/29*/
30 30
31#include <stdint.h>31#include <stdint.h>
@@ -370,10 +370,10 @@ long long __divdi3(long long u, long long v) · 338 unmodified lines
370 int c = 0;370 int c = 0;
371 DWunion uu, vv;371 DWunion uu, vv;
372 DWtype w;372 DWtype w;
373 373
374 uu.ll = u;374 uu.ll = u;
375 vv.ll = v;375 vv.ll = v;
376 376
377 if (uu.s.high < 0) {377 if (uu.s.high < 0) {
378 c = ~c;378 c = ~c;
379 uu.ll = __negdi2 (uu.ll);379 uu.ll = __negdi2 (uu.ll);
@@ -393,17 +393,17 @@ long long __moddi3(long long u, long long v) · 13 unmodified lines
393 int c = 0;393 int c = 0;
394 DWunion uu, vv;394 DWunion uu, vv;
395 DWtype w;395 DWtype w;
396 396
397 uu.ll = u;397 uu.ll = u;
398 vv.ll = v;398 vv.ll = v;
399 399
400 if (uu.s.high < 0) {400 if (uu.s.high < 0) {
401 c = ~c;401 c = ~c;
402 uu.ll = __negdi2 (uu.ll);402 uu.ll = __negdi2 (uu.ll);
403 }403 }
404 if (vv.s.high < 0)404 if (vv.s.high < 0)
405 vv.ll = __negdi2 (vv.ll);405 vv.ll = __negdi2 (vv.ll);
406 406
407 __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);407 __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
408 if (c)408 if (c)
409 w = __negdi2 (w);409 w = __negdi2 (w);
@@ -418,7 +418,7 @@ unsigned long long __udivdi3(unsigned long long u, unsigned long long v) · 8 unmodified lines
418unsigned long long __umoddi3(unsigned long long u, unsigned long long v)418unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
419{419{
420 UDWtype w;420 UDWtype w;
421 421
422 __udivmoddi4 (u, v, &w);422 __udivmoddi4 (u, v, &w);
423 return w;423 return w;
424}424}
@@ -499,7 +499,7 @@ long long __tcc_cvt_ftol(long double x) · 74 unmodified lines
499/* XXX: fix tcc's code generator to do this instead */499/* XXX: fix tcc's code generator to do this instead */
500float __floatundisf(unsigned long long a)500float __floatundisf(unsigned long long a)
501{501{
502 DWunion uu; 502 DWunion uu;
503 XFtype r;503 XFtype r;
504 504
505 uu.ll = a;505 uu.ll = a;
@@ -514,7 +514,7 @@ float __floatundisf(unsigned long long a) · 8 unmodified lines
514 514
515double __floatundidf(unsigned long long a)515double __floatundidf(unsigned long long a)
516{516{
517 DWunion uu; 517 DWunion uu;
518 XFtype r;518 XFtype r;
519 519
520 uu.ll = a;520 uu.ll = a;
@@ -529,7 +529,7 @@ double __floatundidf(unsigned long long a) · 8 unmodified lines
529 529
530long double __floatundixf(unsigned long long a)530long double __floatundixf(unsigned long long a)
531{531{
532 DWunion uu; 532 DWunion uu;
533 XFtype r;533 XFtype r;
534 534
535 uu.ll = a;535 uu.ll = a;
@@ -608,7 +608,7 @@ unsigned long long __fixunsxfdi (long double a1) · 72 unmodified lines
608 608
609 if (exp > 0)609 if (exp > 0)
610 return (unsigned long long)-1;610 return (unsigned long long)-1;
611 else if (exp >= -63) 611 else if (exp >= -63)
612 return l >> -exp;612 return l >> -exp;
613 else613 else
614 return 0;614 return 0;
libtcc.c+1−1
@@ -318,7 +318,7 @@ PUB_FUNC void tcc_free_debug(void *ptr) · 317 unmodified lines
318 318
319 mem_cur_size -= header->size;319 mem_cur_size -= header->size;
320 header->size = (size_t)-1;320 header->size = (size_t)-1;
321 321
322 if (header->next)322 if (header->next)
323 header->next->prev = header->prev;323 header->next->prev = header->prev;
324 324
tcc-doc.texi+23−23
@@ -99,9 +99,9 @@ the @code{main()} of a.c. · 98 unmodified lines
99 99
100@item @samp{tcc a.c -run b.c arg1}100@item @samp{tcc a.c -run b.c arg1}
101Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given101Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given
102as first argument to the @code{main()} of the resulting program. 102as first argument to the @code{main()} of the resulting program.
103@ignore 103@ignore
104Because multiple C files are specified, @option{--} are necessary to clearly 104Because multiple C files are specified, @option{--} are necessary to clearly
105separate the program arguments from the TCC options.105separate the program arguments from the TCC options.
106@end ignore106@end ignore
107 107
@@ -136,14 +136,14 @@ need to add @code{#!/usr/local/bin/tcc -run} at the start of your C source: · 28 unmodified lines
136#!/usr/local/bin/tcc -run136#!/usr/local/bin/tcc -run
137#include <stdio.h>137#include <stdio.h>
138 138
139int main() 139int main()
140@{140@{
141 printf("Hello World\n");141 printf("Hello World\n");
142 return 0;142 return 0;
143@}143@}
144@end example144@end example
145 145
146TCC can read C source code from @emph{standard input} when @option{-} is used in 146TCC can read C source code from @emph{standard input} when @option{-} is used in
147place of @option{infile}. Example:147place of @option{infile}. Example:
148 148
149@example149@example
@@ -271,7 +271,7 @@ Make string constants be of type @code{const char *} instead of @code{char · 121 unmodified lines
271@item -Werror271@item -Werror
272Abort compilation if warnings are issued.272Abort compilation if warnings are issued.
273 273
274@item -Wall 274@item -Wall
275Activate all warnings, except @option{-Werror}, @option{-Wunusupported} and275Activate all warnings, except @option{-Werror}, @option{-Wunusupported} and
276@option{-Wwrite-strings}.276@option{-Wwrite-strings}.
277 277
@@ -451,7 +451,7 @@ function name. · 173 unmodified lines
451 451
452 int tab[10] = @{ 1, 2, [5] = 5, [9] = 9@};452 int tab[10] = @{ 1, 2, [5] = 5, [9] = 9@};
453@end example453@end example
454 454
455@item Compound initializers are supported:455@item Compound initializers are supported:
456@example456@example
457 int *p = (int [])@{ 1, 2, 3 @};457 int *p = (int [])@{ 1, 2, 3 @};
@@ -465,7 +465,7 @@ works for structures and strings. · 7 unmodified lines
465@end example465@end example
466 466
467@noindent467@noindent
468is the same as writing 468is the same as writing
469@example469@example
470 double d = 4771840.0;470 double d = 4771840.0;
471@end example471@end example
@@ -481,12 +481,12 @@ TCC implements some GNU C extensions: · 9 unmodified lines
481 481
482@itemize482@itemize
483 483
484@item array designators can be used without '=': 484@item array designators can be used without '=':
485@example485@example
486 int a[10] = @{ [0] 1, [5] 2, 3, 4 @};486 int a[10] = @{ [0] 1, [5] 2, 3, 4 @};
487@end example487@end example
488 488
489@item Structure field designators can be a label: 489@item Structure field designators can be a label:
490@example490@example
491 struct @{ int x, y; @} st = @{ x: 1, y: 1@};491 struct @{ int x, y; @} st = @{ x: 1, y: 1@};
492@end example492@end example
@@ -555,7 +555,7 @@ Here are some examples: · 62 unmodified lines
555align variable @code{a} to 8 bytes and put it in section @code{.mysection}.555align variable @code{a} to 8 bytes and put it in section @code{.mysection}.
556 556
557@example557@example
558 int my_add(int a, int b) __attribute__ ((section(".mycodesection"))) 558 int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
559 @{559 @{
560 return a + b;560 return a + b;
561 @}561 @}
@@ -572,17 +572,17 @@ generate function @code{my_add} in section @code{.mycodesection}. · 10 unmodified lines
572 dprintf("one arg %d\n", 1);572 dprintf("one arg %d\n", 1);
573@end example573@end example
574 574
575@item @code{__FUNCTION__} is interpreted as C99 @code{__func__} 575@item @code{__FUNCTION__} is interpreted as C99 @code{__func__}
576(so it has not exactly the same semantics as string literal GNUC576(so it has not exactly the same semantics as string literal GNUC
577where it is a string literal).577where it is a string literal).
578 578
579@item The @code{__alignof__} keyword can be used as @code{sizeof} 579@item The @code{__alignof__} keyword can be used as @code{sizeof}
580to get the alignment of a type or an expression.580to get the alignment of a type or an expression.
581 581
582@item The @code{typeof(x)} returns the type of @code{x}. 582@item The @code{typeof(x)} returns the type of @code{x}.
583@code{x} is an expression or a type.583@code{x} is an expression or a type.
584 584
585@item Computed gotos: @code{&&label} returns a pointer of type 585@item Computed gotos: @code{&&label} returns a pointer of type
586@code{void *} on the goto label @code{label}. @code{goto *expr} can be586@code{void *} on the goto label @code{label}. @code{goto *expr} can be
587used to jump on the pointer resulting from @code{expr}.587used to jump on the pointer resulting from @code{expr}.
588 588
@@ -616,7 +616,7 @@ TCC includes its own x86 inline assembler with a @code{gas}-like (GNU · 27 unmodified lines
616assembler) syntax. No intermediate files are generated. GCC 3.x named616assembler) syntax. No intermediate files are generated. GCC 3.x named
617operands are supported.617operands are supported.
618 618
619@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()} 619@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()}
620are supported.620are supported.
621 621
622@item @code{#pragma pack} is supported for win32 compatibility.622@item @code{#pragma pack} is supported for win32 compatibility.
@@ -681,7 +681,7 @@ same as C. · 58 unmodified lines
681@item +, -681@item +, -
682@end enumerate682@end enumerate
683 683
684@item A value is either an absolute number or a label plus an offset. 684@item A value is either an absolute number or a label plus an offset.
685All operators accept absolute values except '+' and '-'. '+' or '-' can be685All operators accept absolute values except '+' and '-'. '+' or '-' can be
686used to add an offset to a label. '-' supports two labels only if they686used to add an offset to a label. '-' supports two labels only if they
687are the same or if they are both defined and in the same section.687are the same or if they are both defined and in the same section.
@@ -694,7 +694,7 @@ are the same or if they are both defined and in the same section. · 6 unmodified lines
694 694
695@item All labels are considered as local, except undefined ones.695@item All labels are considered as local, except undefined ones.
696 696
697@item Numeric labels can be used as local @code{gas}-like labels. 697@item Numeric labels can be used as local @code{gas}-like labels.
698They can be defined several times in the same source. Use 'b'698They can be defined several times in the same source. Use 'b'
699(backward) or 'f' (forward) as suffix to reference them:699(backward) or 'f' (forward) as suffix to reference them:
700 700
@@ -901,7 +901,7 @@ Here are some examples of caught errors: · 200 unmodified lines
901@chapter The @code{libtcc} library901@chapter The @code{libtcc} library
902 902
903The @code{libtcc} library enables you to use TCC as a backend for903The @code{libtcc} library enables you to use TCC as a backend for
904dynamic code generation. 904dynamic code generation.
905 905
906Read the @file{libtcc.h} to have an overview of the API. Read906Read the @file{libtcc.h} to have an overview of the API. Read
907@file{libtcc_test.c} to have a very simple example.907@file{libtcc_test.c} to have a very simple example.
@@ -941,10 +941,10 @@ except: · 33 unmodified lines
941 941
942@itemize942@itemize
943 943
944@item For initialized arrays with unknown size, a first pass 944@item For initialized arrays with unknown size, a first pass
945is done to count the number of elements.945is done to count the number of elements.
946 946
947@item For architectures where arguments are evaluated in 947@item For architectures where arguments are evaluated in
948reverse order, a first pass is done to reverse the argument order.948reverse order, a first pass is done to reverse the argument order.
949 949
950@end itemize950@end itemize
@@ -1156,7 +1156,7 @@ stack. · 205 unmodified lines
1156@item VT_CMP1156@item VT_CMP
1157indicates that the value is actually stored in the CPU flags (i.e. the1157indicates that the value is actually stored in the CPU flags (i.e. the
1158value is the consequence of a test). The value is either 0 or 1. The1158value is the consequence of a test). The value is either 0 or 1. The
1159actual CPU flags used is indicated in @code{SValue.c.i}. 1159actual CPU flags used is indicated in @code{SValue.c.i}.
1160 1160
1161If any code is generated which destroys the CPU flags, this value MUST be1161If any code is generated which destroys the CPU flags, this value MUST be
1162put in a normal register.1162put in a normal register.
@@ -1176,7 +1176,7 @@ taken. · 13 unmodified lines
1176@item VT_LVAL1176@item VT_LVAL
1177is a flag indicating that the value is actually an lvalue (left value of1177is a flag indicating that the value is actually an lvalue (left value of
1178an assignment). It means that the value stored is actually a pointer to1178an assignment). It means that the value stored is actually a pointer to
1179the wanted value. 1179the wanted value.
1180 1180
1181Understanding the use @code{VT_LVAL} is very important if you want to1181Understanding the use @code{VT_LVAL} is very important if you want to
1182understand how TCC works.1182understand how TCC works.
tcc.c+1−1
@@ -1,6 +1,6 @@
1/*1/*
2 * TCC - Tiny C Compiler2 * TCC - Tiny C Compiler
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
tcc.h+4−4
@@ -1,6 +1,6 @@
1/*1/*
2 * TCC - Tiny C Compiler2 * TCC - Tiny C Compiler
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -605,7 +605,7 @@ struct TCCState { · 598 unmodified lines
605 int old_struct_init_code; /* use old algorithm to init array in struct when there is no '{' used.605 int old_struct_init_code; /* use old algorithm to init array in struct when there is no '{' used.
606 Liuux 2.4.26 can't find initrd when compiled with a new algorithm */606 Liuux 2.4.26 can't find initrd when compiled with a new algorithm */
607 int dollars_in_identifiers; /* allows '$' char in indentifiers */607 int dollars_in_identifiers; /* allows '$' char in indentifiers */
608 608
609 /* warning switches */609 /* warning switches */
610 int warn_write_strings;610 int warn_write_strings;
611 int warn_unsupported;611 int warn_unsupported;
@@ -631,7 +631,7 @@ struct TCCState { · 19 unmodified lines
631 631
632 char *init_symbol; /* symbols to call at load-time (not used currently) */632 char *init_symbol; /* symbols to call at load-time (not used currently) */
633 char *fini_symbol; /* symbols to call at unload-time (not used currently) */633 char *fini_symbol; /* symbols to call at unload-time (not used currently) */
634 634
635#ifdef TCC_TARGET_I386635#ifdef TCC_TARGET_I386
636 int seg_size; /* 32. Can be 16 with i386 assembler (.code16) */636 int seg_size; /* 32. Can be 16 with i386 assembler (.code16) */
637#endif637#endif
@@ -885,7 +885,7 @@ struct TCCState { · 247 unmodified lines
885 885
886#define TOK_SHL 0x01 /* shift left */886#define TOK_SHL 0x01 /* shift left */
887#define TOK_SAR 0x02 /* signed shift right */887#define TOK_SAR 0x02 /* signed shift right */
888 888
889/* assignement operators : normal operator or 0x80 */889/* assignement operators : normal operator or 0x80 */
890#define TOK_A_MOD 0xa5890#define TOK_A_MOD 0xa5
891#define TOK_A_AND 0xa6891#define TOK_A_AND 0xa6
tccasm.c+25−25
@@ -1,6 +1,6 @@
1/*1/*
2 * GAS like assembler for TCC2 * GAS like assembler for TCC
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -125,7 +125,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe) · 118 unmodified lines
125 break;125 break;
126 }126 }
127}127}
128 128
129static void asm_expr_prod(TCCState *s1, ExprValue *pe)129static void asm_expr_prod(TCCState *s1, ExprValue *pe)
130{130{
131 int op;131 int op;
@@ -134,7 +134,7 @@ static void asm_expr_prod(TCCState *s1, ExprValue *pe) · 2 unmodified lines
134 asm_expr_unary(s1, pe);134 asm_expr_unary(s1, pe);
135 for(;;) {135 for(;;) {
136 op = tok;136 op = tok;
137 if (op != '*' && op != '/' && op != '%' && 137 if (op != '*' && op != '/' && op != '%' &&
138 op != TOK_SHL && op != TOK_SAR)138 op != TOK_SHL && op != TOK_SAR)
139 break;139 break;
140 next();140 next();
@@ -145,14 +145,14 @@ static void asm_expr_prod(TCCState *s1, ExprValue *pe) · 4 unmodified lines
145 case '*':145 case '*':
146 pe->v *= e2.v;146 pe->v *= e2.v;
147 break;147 break;
148 case '/': 148 case '/':
149 if (e2.v == 0) {149 if (e2.v == 0) {
150 div_error:150 div_error:
151 tcc_error("division by zero");151 tcc_error("division by zero");
152 }152 }
153 pe->v /= e2.v;153 pe->v /= e2.v;
154 break;154 break;
155 case '%': 155 case '%':
156 if (e2.v == 0)156 if (e2.v == 0)
157 goto div_error;157 goto div_error;
158 pe->v %= e2.v;158 pe->v %= e2.v;
@@ -186,7 +186,7 @@ static void asm_expr_logic(TCCState *s1, ExprValue *pe) · 27 unmodified lines
186 case '&':186 case '&':
187 pe->v &= e2.v;187 pe->v &= e2.v;
188 break;188 break;
189 case '|': 189 case '|':
190 pe->v |= e2.v;190 pe->v |= e2.v;
191 break;191 break;
192 default:192 default:
@@ -224,7 +224,7 @@ static inline void asm_expr_sum(TCCState *s1, ExprValue *pe) · 31 unmodified lines
224 } else if (pe->sym && !e2.sym) {224 } else if (pe->sym && !e2.sym) {
225 /* OK */225 /* OK */
226 } else if (pe->sym && e2.sym) {226 } else if (pe->sym && e2.sym) {
227 if (pe->sym == e2.sym) { 227 if (pe->sym == e2.sym) {
228 /* OK */228 /* OK */
229 } else if (pe->sym->r == e2.sym->r && pe->sym->r != 0) {229 } else if (pe->sym->r == e2.sym->r && pe->sym->r != 0) {
230 /* we also accept defined symbols in the same section */230 /* we also accept defined symbols in the same section */
@@ -267,7 +267,7 @@ static void asm_new_label1(TCCState *s1, int label, int is_local, · 36 unmodified lines
267 if (sym->r) {267 if (sym->r) {
268 /* the label is already defined */268 /* the label is already defined */
269 if (!is_local) {269 if (!is_local) {
270 tcc_error("assembler label '%s' already defined", 270 tcc_error("assembler label '%s' already defined",
271 get_tok_str(label, NULL));271 get_tok_str(label, NULL));
272 } else {272 } else {
273 /* redefinition of local labels is possible */273 /* redefinition of local labels is possible */
@@ -493,7 +493,7 @@ static void asm_parse_directive(TCCState *s1) · 219 unmodified lines
493 case TOK_ASM_weak:493 case TOK_ASM_weak:
494 case TOK_ASM_hidden:494 case TOK_ASM_hidden:
495 tok1 = tok;495 tok1 = tok;
496 do { 496 do {
497 Sym *sym;497 Sym *sym;
498 498
499 next();499 next();
@@ -541,7 +541,7 @@ static void asm_parse_directive(TCCState *s1) · 41 unmodified lines
541 case TOK_ASM_text:541 case TOK_ASM_text:
542 case TOK_ASM_data:542 case TOK_ASM_data:
543 case TOK_ASM_bss:543 case TOK_ASM_bss:
544 { 544 {
545 char sname[64];545 char sname[64];
546 tok1 = tok;546 tok1 = tok;
547 n = 0;547 n = 0;
@@ -591,7 +591,7 @@ static void asm_parse_directive(TCCState *s1) · 43 unmodified lines
591 }591 }
592 break;592 break;
593 case TOK_ASM_size:593 case TOK_ASM_size:
594 { 594 {
595 Sym *sym;595 Sym *sym;
596 596
597 next();597 next();
@@ -612,7 +612,7 @@ static void asm_parse_directive(TCCState *s1) · 14 unmodified lines
612 }612 }
613 break;613 break;
614 case TOK_ASM_type:614 case TOK_ASM_type:
615 { 615 {
616 Sym *sym;616 Sym *sym;
617 const char *newtype;617 const char *newtype;
618 618
@@ -637,7 +637,7 @@ static void asm_parse_directive(TCCState *s1) · 18 unmodified lines
637 sym->type.t = (sym->type.t & ~VT_BTYPE) | VT_FUNC;637 sym->type.t = (sym->type.t & ~VT_BTYPE) | VT_FUNC;
638 }638 }
639 else if (s1->warn_unsupported)639 else if (s1->warn_unsupported)
640 tcc_warning("change type of '%s' from 0x%x to '%s' ignored", 640 tcc_warning("change type of '%s' from 0x%x to '%s' ignored",
641 get_tok_str(sym->v, NULL), sym->type.t, newtype);641 get_tok_str(sym->v, NULL), sym->type.t, newtype);
642 642
643 next();643 next();
@@ -669,7 +669,7 @@ static void asm_parse_directive(TCCState *s1) · 25 unmodified lines
669 }669 }
670 break;670 break;
671 case TOK_ASM_previous:671 case TOK_ASM_previous:
672 { 672 {
673 Section *sec;673 Section *sec;
674 next();674 next();
675 if (!last_text_section)675 if (!last_text_section)
@@ -830,7 +830,7 @@ ST_FUNC int tcc_assemble(TCCState *s1, int do_preprocess) · 154 unmodified lines
830 830
831 cur_text_section->data_offset = ind;831 cur_text_section->data_offset = ind;
832 832
833 free_defines(define_start); 833 free_defines(define_start);
834 834
835 return ret;835 return ret;
836}836}
@@ -863,7 +863,7 @@ static void tcc_assemble_inline(TCCState *s1, char *str, int len) · 26 unmodified lines
863/* find a constraint by its number or id (gcc 3 extended863/* find a constraint by its number or id (gcc 3 extended
864 syntax). return -1 if not found. Return in *pp in char after the864 syntax). return -1 if not found. Return in *pp in char after the
865 constraint */865 constraint */
866ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, 866ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands,
867 const char *name, const char **pp)867 const char *name, const char **pp)
868{868{
869 int index;869 int index;
@@ -901,7 +901,7 @@ ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, · 31 unmodified lines
901 return index;901 return index;
902}902}
903 903
904static void subst_asm_operands(ASMOperand *operands, int nb_operands, 904static void subst_asm_operands(ASMOperand *operands, int nb_operands,
905 int nb_outputs,905 int nb_outputs,
906 CString *out_str, CString *in_str)906 CString *out_str, CString *in_str)
907{907{
@@ -1052,12 +1052,12 @@ ST_FUNC void asm_instr(void) · 144 unmodified lines
1052 token after the assembler parsing */1052 token after the assembler parsing */
1053 if (tok != ';')1053 if (tok != ';')
1054 expect("';'");1054 expect("';'");
1055 1055
1056 /* save all values in the memory */1056 /* save all values in the memory */
1057 save_regs(0);1057 save_regs(0);
1058 1058
1059 /* compute constraints */1059 /* compute constraints */
1060 asm_compute_constraints(operands, nb_operands, nb_outputs, 1060 asm_compute_constraints(operands, nb_operands, nb_outputs,
1061 clobber_regs, &out_reg);1061 clobber_regs, &out_reg);
1062 1062
1063 /* substitute the operands in the asm string. No substitution is1063 /* substitute the operands in the asm string. No substitution is
@@ -1076,8 +1076,8 @@ ST_FUNC void asm_instr(void) · 12 unmodified lines
1076#endif1076#endif
1077 1077
1078 /* generate loads */1078 /* generate loads */
1079 asm_gen_code(operands, nb_operands, nb_outputs, 0, 1079 asm_gen_code(operands, nb_operands, nb_outputs, 0,
1080 clobber_regs, out_reg); 1080 clobber_regs, out_reg);
1081 1081
1082 /* assemble the string with tcc internal assembler */1082 /* assemble the string with tcc internal assembler */
1083 tcc_assemble_inline(tcc_state, astr1.data, astr1.size - 1);1083 tcc_assemble_inline(tcc_state, astr1.data, astr1.size - 1);
@@ -1086,9 +1086,9 @@ ST_FUNC void asm_instr(void) · 2 unmodified lines
1086 next();1086 next();
1087 1087
1088 /* store the output values if needed */1088 /* store the output values if needed */
1089 asm_gen_code(operands, nb_operands, nb_outputs, 1, 1089 asm_gen_code(operands, nb_operands, nb_outputs, 1,
1090 clobber_regs, out_reg);1090 clobber_regs, out_reg);
1091 1091
1092 /* free everything */1092 /* free everything */
1093 for(i=0;i<nb_operands;i++) {1093 for(i=0;i<nb_operands;i++) {
1094 ASMOperand *op;1094 ASMOperand *op;
@@ -1110,7 +1110,7 @@ ST_FUNC void asm_global_instr(void) · 15 unmodified lines
1110 token after the assembler parsing */1110 token after the assembler parsing */
1111 if (tok != ';')1111 if (tok != ';')
1112 expect("';'");1112 expect("';'");
1113 1113
1114#ifdef ASM_DEBUG1114#ifdef ASM_DEBUG
1115 printf("asm_global: \"%s\"\n", (char *)astr.data);1115 printf("asm_global: \"%s\"\n", (char *)astr.data);
1116#endif1116#endif
@@ -1119,7 +1119,7 @@ ST_FUNC void asm_global_instr(void) · 2 unmodified lines
1119 1119
1120 /* assemble the string with tcc internal assembler */1120 /* assemble the string with tcc internal assembler */
1121 tcc_assemble_inline(tcc_state, astr.data, astr.size - 1);1121 tcc_assemble_inline(tcc_state, astr.data, astr.size - 1);
1122 1122
1123 cur_text_section->data_offset = ind;1123 cur_text_section->data_offset = ind;
1124 1124
1125 /* restore the current C token */1125 /* restore the current C token */
tcccoff.c+2−2
@@ -1,6 +1,6 @@
1/*1/*
2 * COFF file handling for TCC2 * COFF file handling for TCC
3 * 3 *
4 * Copyright (c) 2003, 2004 TK4 * Copyright (c) 2003, 2004 TK
5 * Copyright (c) 2004 Fabrice Bellard5 * Copyright (c) 2004 Fabrice Bellard
6 *6 *
@@ -606,7 +606,7 @@ ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f) · 599 unmodified lines
606 // put a .ef606 // put a .ef
607 607
608 strcpy(csym._n._n_name, ".ef");608 strcpy(csym._n._n_name, ".ef");
609 csym.n_value = EndAddress[k]; // physical address 609 csym.n_value = EndAddress[k]; // physical address
610 csym.n_scnum = CoffTextSectionNo;610 csym.n_scnum = CoffTextSectionNo;
611 csym.n_type = 0;611 csym.n_type = 0;
612 csym.n_sclass = C_FCN;612 csym.n_sclass = C_FCN;
tccelf.c+1−1
@@ -1179,7 +1179,7 @@ static unsigned long put_got_entry(TCCState *s1, · 1178 unmodified lines
1179 p[11] = 0xe9; /* jmp plt_start */1179 p[11] = 0xe9; /* jmp plt_start */
1180 put32(p + 12, -(plt->data_offset));1180 put32(p + 12, -(plt->data_offset));
1181 1181
1182 /* If this was an UNDEF symbol set the offset in the 1182 /* If this was an UNDEF symbol set the offset in the
1183 dynsymtab to the PLT slot, so that PC32 relocs to it1183 dynsymtab to the PLT slot, so that PC32 relocs to it
1184 can be resolved. */1184 can be resolved. */
1185 if (sym->st_shndx == SHN_UNDEF)1185 if (sym->st_shndx == SHN_UNDEF)
tccgen.c+110−110
@@ -1,6 +1,6 @@
1/*1/*
2 * TCC - Tiny C Compiler2 * TCC - Tiny C Compiler
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -299,7 +299,7 @@ static void weaken_symbol(Sym *sym) · 292 unmodified lines
299 if (sym->c > 0) {299 if (sym->c > 0) {
300 int esym_type;300 int esym_type;
301 ElfW(Sym) *esym;301 ElfW(Sym) *esym;
302 302
303 esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];303 esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
304 esym_type = ELFW(ST_TYPE)(esym->st_info);304 esym_type = ELFW(ST_TYPE)(esym->st_info);
305 esym->st_info = ELFW(ST_INFO)(STB_WEAK, esym_type);305 esym->st_info = ELFW(ST_INFO)(STB_WEAK, esym_type);
@@ -321,7 +321,7 @@ static void apply_visibility(Sym *sym, CType *type) · 15 unmodified lines
321 321
322 if (sym->c > 0) {322 if (sym->c > 0) {
323 ElfW(Sym) *esym;323 ElfW(Sym) *esym;
324 324
325 esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];325 esym = &((ElfW(Sym) *)symtab_section->data)[sym->c];
326 vis >>= VT_VIS_SHIFT;326 vis >>= VT_VIS_SHIFT;
327 esym->st_other = (esym->st_other & ~ELFW(ST_VISIBILITY)(-1)) | vis;327 esym->st_other = (esym->st_other & ~ELFW(ST_VISIBILITY)(-1)) | vis;
@@ -425,7 +425,7 @@ ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsign · 97 unmodified lines
425/* push a reference to a section offset by adding a dummy symbol */425/* push a reference to a section offset by adding a dummy symbol */
426static void vpush_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)426static void vpush_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
427{427{
428 vpushsym(type, get_sym_ref(type, sec, offset, size)); 428 vpushsym(type, get_sym_ref(type, sec, offset, size));
429}429}
430 430
431/* define a new external reference to a symbol 'v' of type 'u' */431/* define a new external reference to a symbol 'v' of type 'u' */
@@ -461,7 +461,7 @@ static Sym *external_sym(int v, CType *type, int r, char *asm_label) · 29 unmodified lines
461 s->r = r | VT_CONST | VT_SYM;461 s->r = r | VT_CONST | VT_SYM;
462 s->type.t |= VT_EXTERN;462 s->type.t |= VT_EXTERN;
463 } else if (!is_compatible_types(&s->type, type)) {463 } else if (!is_compatible_types(&s->type, type)) {
464 tcc_error("incompatible types for redefinition of '%s'", 464 tcc_error("incompatible types for redefinition of '%s'",
465 get_tok_str(v, NULL));465 get_tok_str(v, NULL));
466 }466 }
467 /* Merge some storage attributes. */467 /* Merge some storage attributes. */
@@ -600,7 +600,7 @@ ST_FUNC int get_reg_ex(int rc, int rc2) · 132 unmodified lines
600{600{
601 int r;601 int r;
602 SValue *p;602 SValue *p;
603 603
604 for(r=0;r<NB_REGS;r++) {604 for(r=0;r<NB_REGS;r++) {
605 if (reg_classes[r] & rc2) {605 if (reg_classes[r] & rc2) {
606 int n;606 int n;
@@ -636,7 +636,7 @@ ST_FUNC int get_reg(int rc) · 29 unmodified lines
636 }636 }
637 notfound: ;637 notfound: ;
638 }638 }
639 639
640 /* no register left : free the first one on the stack (VERY640 /* no register left : free the first one on the stack (VERY
641 IMPORTANT to start from the bottom to ensure that we don't641 IMPORTANT to start from the bottom to ensure that we don't
642 spill registers used in gen_opi()) */642 spill registers used in gen_opi()) */
@@ -761,7 +761,7 @@ ST_FUNC int gv(int rc) · 118 unmodified lines
761 gen_op(TOK_SAR);761 gen_op(TOK_SAR);
762 r = gv(rc);762 r = gv(rc);
763 } else {763 } else {
764 if (is_float(vtop->type.t) && 764 if (is_float(vtop->type.t) &&
765 (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {765 (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
766 Sym *sym;766 Sym *sym;
767 int *ptr;767 int *ptr;
@@ -769,7 +769,7 @@ ST_FUNC int gv(int rc) · 1 unmodified line
769#if defined(TCC_TARGET_ARM) && !defined(TCC_ARM_VFP)769#if defined(TCC_TARGET_ARM) && !defined(TCC_ARM_VFP)
770 CValue check;770 CValue check;
771#endif771#endif
772 772
773 /* XXX: unify with initializers handling ? */773 /* XXX: unify with initializers handling ? */
774 /* CPUs usually cannot use float constants, so we store them774 /* CPUs usually cannot use float constants, so we store them
775 generically in data segment */775 generically in data segment */
@@ -803,7 +803,7 @@ ST_FUNC int gv(int rc) · 27 unmodified lines
803 vtop->c.ptr_offset = 0;803 vtop->c.ptr_offset = 0;
804 }804 }
805#ifdef CONFIG_TCC_BCHECK805#ifdef CONFIG_TCC_BCHECK
806 if (vtop->r & VT_MUSTBOUND) 806 if (vtop->r & VT_MUSTBOUND)
807 gbound();807 gbound();
808#endif808#endif
809 809
@@ -921,7 +921,7 @@ ST_FUNC int gv(int rc) · 111 unmodified lines
921 vtop->r = r;921 vtop->r = r;
922#ifdef TCC_TARGET_C67922#ifdef TCC_TARGET_C67
923 /* uses register pairs for doubles */923 /* uses register pairs for doubles */
924 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) 924 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
925 vtop->r2 = r+1;925 vtop->r2 = r+1;
926#endif926#endif
927 }927 }
@@ -1036,7 +1036,7 @@ static void lbuild(int t) · 108 unmodified lines
1036 vpop();1036 vpop();
1037}1037}
1038 1038
1039/* rotate n first stack elements to the bottom 1039/* rotate n first stack elements to the bottom
1040 I1 ... In -> I2 ... In I1 [top is right]1040 I1 ... In -> I2 ... In I1 [top is right]
1041*/1041*/
1042ST_FUNC void vrotb(int n)1042ST_FUNC void vrotb(int n)
@@ -1476,7 +1476,7 @@ static void gen_opic(int op) · 433 unmodified lines
1476 vtop--;1476 vtop--;
1477 } else {1477 } else {
1478 /* if commutative ops, put c2 as constant */1478 /* if commutative ops, put c2 as constant */
1479 if (c1 && (op == '+' || op == '&' || op == '^' || 1479 if (c1 && (op == '+' || op == '&' || op == '^' ||
1480 op == '|' || op == '*')) {1480 op == '|' || op == '*')) {
1481 vswap();1481 vswap();
1482 c2 = c1; //c = c1, c1 = c2, c2 = c;1482 c2 = c1; //c = c1, c1 = c2, c2 = c;
@@ -1582,13 +1582,13 @@ static void gen_opif(int op) · 99 unmodified lines
1582 case '+': f1 += f2; break;1582 case '+': f1 += f2; break;
1583 case '-': f1 -= f2; break;1583 case '-': f1 -= f2; break;
1584 case '*': f1 *= f2; break;1584 case '*': f1 *= f2; break;
1585 case '/': 1585 case '/':
1586 if (f2 == 0.0) {1586 if (f2 == 0.0) {
1587 if (const_wanted)1587 if (const_wanted)
1588 tcc_error("division by zero in constant");1588 tcc_error("division by zero in constant");
1589 goto general_case;1589 goto general_case;
1590 }1590 }
1591 f1 /= f2; 1591 f1 /= f2;
1592 break;1592 break;
1593 /* XXX: also handles tests ? */1593 /* XXX: also handles tests ? */
1594 default:1594 default:
@@ -1636,7 +1636,7 @@ static inline int is_null_pointer(SValue *p) · 41 unmodified lines
1636 1636
1637static inline int is_integer_btype(int bt)1637static inline int is_integer_btype(int bt)
1638{1638{
1639 return (bt == VT_BYTE || bt == VT_SHORT || 1639 return (bt == VT_BYTE || bt == VT_SHORT ||
1640 bt == VT_INT || bt == VT_LLONG);1640 bt == VT_INT || bt == VT_LLONG);
1641}1641}
1642 1642
@@ -1645,7 +1645,7 @@ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op) · 2 unmodified lines
1645{1645{
1646 CType *type1, *type2, tmp_type1, tmp_type2;1646 CType *type1, *type2, tmp_type1, tmp_type2;
1647 int bt1, bt2;1647 int bt1, bt2;
1648 1648
1649 /* null pointers are accepted for all comparisons as gcc */1649 /* null pointers are accepted for all comparisons as gcc */
1650 if (is_null_pointer(p1) || is_null_pointer(p2))1650 if (is_null_pointer(p1) || is_null_pointer(p2))
1651 return;1651 return;
@@ -1663,16 +1663,16 @@ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op) · 11 unmodified lines
1663 /* both must be pointers or implicit function pointers */1663 /* both must be pointers or implicit function pointers */
1664 if (bt1 == VT_PTR) {1664 if (bt1 == VT_PTR) {
1665 type1 = pointed_type(type1);1665 type1 = pointed_type(type1);
1666 } else if (bt1 != VT_FUNC) 1666 } else if (bt1 != VT_FUNC)
1667 goto invalid_operands;1667 goto invalid_operands;
1668 1668
1669 if (bt2 == VT_PTR) {1669 if (bt2 == VT_PTR) {
1670 type2 = pointed_type(type2);1670 type2 = pointed_type(type2);
1671 } else if (bt2 != VT_FUNC) { 1671 } else if (bt2 != VT_FUNC) {
1672 invalid_operands:1672 invalid_operands:
1673 tcc_error("invalid operands to binary %s", get_tok_str(op, NULL));1673 tcc_error("invalid operands to binary %s", get_tok_str(op, NULL));
1674 }1674 }
1675 if ((type1->t & VT_BTYPE) == VT_VOID || 1675 if ((type1->t & VT_BTYPE) == VT_VOID ||
1676 (type2->t & VT_BTYPE) == VT_VOID)1676 (type2->t & VT_BTYPE) == VT_VOID)
1677 return;1677 return;
1678 tmp_type1 = *type1;1678 tmp_type1 = *type1;
@@ -1698,7 +1698,7 @@ ST_FUNC void gen_op(int op) · 19 unmodified lines
1698 t2 = vtop[0].type.t;1698 t2 = vtop[0].type.t;
1699 bt1 = t1 & VT_BTYPE;1699 bt1 = t1 & VT_BTYPE;
1700 bt2 = t2 & VT_BTYPE;1700 bt2 = t2 & VT_BTYPE;
1701 1701
1702 if (bt1 == VT_PTR || bt2 == VT_PTR) {1702 if (bt1 == VT_PTR || bt2 == VT_PTR) {
1703 /* at least one operand is a pointer */1703 /* at least one operand is a pointer */
1704 /* relationnal op: must be both pointers */1704 /* relationnal op: must be both pointers */
@@ -1729,7 +1729,7 @@ ST_FUNC void gen_op(int op) · 24 unmodified lines
1729#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)1729#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
1730 vtop->type.t = VT_LLONG;1730 vtop->type.t = VT_LLONG;
1731#else1731#else
1732 vtop->type.t = VT_INT; 1732 vtop->type.t = VT_INT;
1733#endif1733#endif
1734 vswap();1734 vswap();
1735 gen_op(TOK_PDIV);1735 gen_op(TOK_PDIV);
@@ -1770,7 +1770,7 @@ ST_FUNC void gen_op(int op) · 34 unmodified lines
1770 fprintf(stderr, "v+i-j = %p\n", v+i-j);1770 fprintf(stderr, "v+i-j = %p\n", v+i-j);
1771 fprintf(stderr, "v+(i-j) = %p\n", v+(i-j));1771 fprintf(stderr, "v+(i-j) = %p\n", v+(i-j));
1772 }1772 }
1773 When this code is on. then the output looks like 1773 When this code is on. then the output looks like
1774 v+i-j = 0xfffffffe1774 v+i-j = 0xfffffffe
1775 v+(i-j) = 0xbff840001775 v+(i-j) = 0xbff84000
1776 */1776 */
@@ -1880,7 +1880,7 @@ static void gen_cvt_itof1(int t) · 103 unmodified lines
1880#ifdef TCC_TARGET_ARM641880#ifdef TCC_TARGET_ARM64
1881 gen_cvt_itof(t);1881 gen_cvt_itof(t);
1882#else1882#else
1883 if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 1883 if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
1884 (VT_LLONG | VT_UNSIGNED)) {1884 (VT_LLONG | VT_UNSIGNED)) {
1885 1885
1886 if (t == VT_FLOAT)1886 if (t == VT_FLOAT)
@@ -2127,7 +2127,7 @@ static void gen_cast(CType *type) · 240 unmodified lines
2127 /* scalar to bool */2127 /* scalar to bool */
2128 vpushi(0);2128 vpushi(0);
2129 gen_op(TOK_NE);2129 gen_op(TOK_NE);
2130 } else if ((dbt & VT_BTYPE) == VT_BYTE || 2130 } else if ((dbt & VT_BTYPE) == VT_BYTE ||
2131 (dbt & VT_BTYPE) == VT_SHORT) {2131 (dbt & VT_BTYPE) == VT_SHORT) {
2132 if (sbt == VT_PTR) {2132 if (sbt == VT_PTR) {
2133 vtop->type.t = VT_INT;2133 vtop->type.t = VT_INT;
@@ -2140,7 +2140,7 @@ static void gen_cast(CType *type) · 6 unmodified lines
2140 /* from long long: just take low order word */2140 /* from long long: just take low order word */
2141 lexpand();2141 lexpand();
2142 vpop();2142 vpop();
2143 } 2143 }
2144 /* if lvalue and single word type, nothing to do because2144 /* if lvalue and single word type, nothing to do because
2145 the lvalue already contains the real type size (see2145 the lvalue already contains the real type size (see
2146 VT_LVAL_xxx constants) */2146 VT_LVAL_xxx constants) */
@@ -2194,7 +2194,7 @@ ST_FUNC int type_size(CType *type, int *a) · 47 unmodified lines
2194#endif2194#endif
2195#elif defined(TCC_TARGET_ARM)2195#elif defined(TCC_TARGET_ARM)
2196#ifdef TCC_ARM_EABI2196#ifdef TCC_ARM_EABI
2197 *a = 8; 2197 *a = 8;
2198#else2198#else
2199 *a = 4;2199 *a = 4;
2200#endif2200#endif
@@ -2289,7 +2289,7 @@ static int is_compatible_func(CType *type1, CType *type2) · 88 unmodified lines
2289/* return true if type1 and type2 are the same. If unqualified is2289/* return true if type1 and type2 are the same. If unqualified is
2290 true, qualifiers on the types are ignored.2290 true, qualifiers on the types are ignored.
2291 2291
2292 - enums are not checked as gcc __builtin_types_compatible_p () 2292 - enums are not checked as gcc __builtin_types_compatible_p ()
2293 */2293 */
2294static int compare_types(CType *type1, CType *type2, int unqualified)2294static int compare_types(CType *type1, CType *type2, int unqualified)
2295{2295{
@@ -2326,7 +2326,7 @@ static int compare_types(CType *type1, CType *type2, int unqualified) · 30 unmodified lines
2326}2326}
2327 2327
2328/* return true if type1 and type2 are exactly the same (including2328/* return true if type1 and type2 are exactly the same (including
2329 qualifiers). 2329 qualifiers).
2330*/2330*/
2331static int is_compatible_types(CType *type1, CType *type2)2331static int is_compatible_types(CType *type1, CType *type2)
2332{2332{
@@ -2344,7 +2344,7 @@ static int is_compatible_parameter_types(CType *type1, CType *type2) · 11 unmodified lines
2344 printed in the type */2344 printed in the type */
2345/* XXX: union */2345/* XXX: union */
2346/* XXX: add array and function pointers */2346/* XXX: add array and function pointers */
2347static void type_to_str(char *buf, int buf_size, 2347static void type_to_str(char *buf, int buf_size,
2348 CType *type, const char *varstr)2348 CType *type, const char *varstr)
2349{2349{
2350 int bt, v, t;2350 int bt, v, t;
@@ -2487,7 +2487,7 @@ static void gen_assign_cast(CType *dt) · 136 unmodified lines
2487 if (sbt != VT_PTR)2487 if (sbt != VT_PTR)
2488 goto error;2488 goto error;
2489 type2 = pointed_type(st);2489 type2 = pointed_type(st);
2490 if ((type1->t & VT_BTYPE) == VT_VOID || 2490 if ((type1->t & VT_BTYPE) == VT_VOID ||
2491 (type2->t & VT_BTYPE) == VT_VOID) {2491 (type2->t & VT_BTYPE) == VT_VOID) {
2492 /* void * can match anything */2492 /* void * can match anything */
2493 } else {2493 } else {
@@ -2716,7 +2716,7 @@ ST_FUNC void inc(int post, int c) · 222 unmodified lines
2716 vrotb(3);2716 vrotb(3);
2717 }2717 }
2718 /* add constant */2718 /* add constant */
2719 vpushi(c - TOK_MID); 2719 vpushi(c - TOK_MID);
2720 gen_op('+');2720 gen_op('+');
2721 vstore(); /* store value */2721 vstore(); /* store value */
2722 if (post)2722 if (post)
@@ -2734,7 +2734,7 @@ ST_FUNC void inc(int post, int c) · 11 unmodified lines
2734static void parse_attribute(AttributeDef *ad)2734static void parse_attribute(AttributeDef *ad)
2735{2735{
2736 int t, n;2736 int t, n;
2737 2737
2738 while (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2) {2738 while (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2) {
2739 next();2739 next();
2740 skip('(');2740 skip('(');
@@ -2787,7 +2787,7 @@ static void parse_attribute(AttributeDef *ad) · 46 unmodified lines
2787 if (tok == '(') {2787 if (tok == '(') {
2788 next();2788 next();
2789 n = expr_const();2789 n = expr_const();
2790 if (n <= 0 || (n & (n - 1)) != 0) 2790 if (n <= 0 || (n & (n - 1)) != 0)
2791 tcc_error("alignment must be a positive power of two");2791 tcc_error("alignment must be a positive power of two");
2792 skip(')');2792 skip(')');
2793 } else {2793 } else {
@@ -2828,7 +2828,7 @@ static void parse_attribute(AttributeDef *ad) · 34 unmodified lines
2828 case TOK_REGPARM2:2828 case TOK_REGPARM2:
2829 skip('(');2829 skip('(');
2830 n = expr_const();2830 n = expr_const();
2831 if (n > 3) 2831 if (n > 3)
2832 n = 3;2832 n = 3;
2833 else if (n < 0)2833 else if (n < 0)
2834 n = 0;2834 n = 0;
@@ -2840,7 +2840,7 @@ static void parse_attribute(AttributeDef *ad) · 5 unmodified lines
2840 case TOK_FASTCALL2:2840 case TOK_FASTCALL2:
2841 case TOK_FASTCALL3:2841 case TOK_FASTCALL3:
2842 ad->a.func_call = FUNC_FASTCALLW;2842 ad->a.func_call = FUNC_FASTCALLW;
2843 break; 2843 break;
2844#endif2844#endif
2845 case TOK_MODE:2845 case TOK_MODE:
2846 skip('(');2846 skip('(');
@@ -2874,9 +2874,9 @@ static void parse_attribute(AttributeDef *ad) · 27 unmodified lines
2874 if (tok == '(') {2874 if (tok == '(') {
2875 int parenthesis = 0;2875 int parenthesis = 0;
2876 do {2876 do {
2877 if (tok == '(') 2877 if (tok == '(')
2878 parenthesis++;2878 parenthesis++;
2879 else if (tok == ')') 2879 else if (tok == ')')
2880 parenthesis--;2880 parenthesis--;
2881 next();2881 next();
2882 } while (parenthesis && tok != -1);2882 } while (parenthesis && tok != -1);
@@ -2928,7 +2928,7 @@ static void struct_decl(CType *type, int u, int tdef) · 45 unmodified lines
2928 do_decl:2928 do_decl:
2929 type->t = u;2929 type->t = u;
2930 type->ref = s;2930 type->ref = s;
2931 2931
2932 if (tok == '{') {2932 if (tok == '{') {
2933 next();2933 next();
2934 if (s->c != -1)2934 if (s->c != -1)
@@ -3001,7 +3001,7 @@ static void struct_decl(CType *type, int u, int tdef) · 66 unmodified lines
3001 }3001 }
3002 if ((type1.t & VT_BTYPE) == VT_FUNC ||3002 if ((type1.t & VT_BTYPE) == VT_FUNC ||
3003 (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))3003 (type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))
3004 tcc_error("invalid type for '%s'", 3004 tcc_error("invalid type for '%s'",
3005 get_tok_str(v, NULL));3005 get_tok_str(v, NULL));
3006 }3006 }
3007 if (tok == ':') {3007 if (tok == ':') {
@@ -3009,10 +3009,10 @@ static void struct_decl(CType *type, int u, int tdef) · 1 unmodified line
3009 bit_size = expr_const();3009 bit_size = expr_const();
3010 /* XXX: handle v = 0 case for messages */3010 /* XXX: handle v = 0 case for messages */
3011 if (bit_size < 0)3011 if (bit_size < 0)
3012 tcc_error("negative width in bit-field '%s'", 3012 tcc_error("negative width in bit-field '%s'",
3013 get_tok_str(v, NULL));3013 get_tok_str(v, NULL));
3014 if (v && bit_size == 0)3014 if (v && bit_size == 0)
3015 tcc_error("zero width for bit-field '%s'", 3015 tcc_error("zero width for bit-field '%s'",
3016 get_tok_str(v, NULL));3016 get_tok_str(v, NULL));
3017 }3017 }
3018 size = type_size(&type1, &align);3018 size = type_size(&type1, &align);
@@ -3028,8 +3028,8 @@ static void struct_decl(CType *type, int u, int tdef) · 9 unmodified lines
3028 lbit_pos = 0;3028 lbit_pos = 0;
3029 if (bit_size >= 0) {3029 if (bit_size >= 0) {
3030 bt = type1.t & VT_BTYPE;3030 bt = type1.t & VT_BTYPE;
3031 if (bt != VT_INT && 3031 if (bt != VT_INT &&
3032 bt != VT_BYTE && 3032 bt != VT_BYTE &&
3033 bt != VT_SHORT &&3033 bt != VT_SHORT &&
3034 bt != VT_BOOL &&3034 bt != VT_BOOL &&
3035 bt != VT_ENUM &&3035 bt != VT_ENUM &&
@@ -3056,7 +3056,7 @@ static void struct_decl(CType *type, int u, int tdef) · 20 unmodified lines
3056 bit_pos = 0;3056 bit_pos = 0;
3057 lbit_pos = bit_pos;3057 lbit_pos = bit_pos;
3058 /* XXX: handle LSB first */3058 /* XXX: handle LSB first */
3059 type1.t |= VT_BITFIELD | 3059 type1.t |= VT_BITFIELD |
3060 (bit_pos << VT_STRUCT_SHIFT) |3060 (bit_pos << VT_STRUCT_SHIFT) |
3061 (bit_size << (VT_STRUCT_SHIFT + 6));3061 (bit_size << (VT_STRUCT_SHIFT + 6));
3062 bit_pos += bit_size;3062 bit_pos += bit_size;
@@ -3083,10 +3083,10 @@ static void struct_decl(CType *type, int u, int tdef) · 20 unmodified lines
3083 maxalign = align;3083 maxalign = align;
3084 }3084 }
3085#if 03085#if 0
3086 printf("add field %s offset=%d", 3086 printf("add field %s offset=%d",
3087 get_tok_str(v, NULL), offset);3087 get_tok_str(v, NULL), offset);
3088 if (type1.t & VT_BITFIELD) {3088 if (type1.t & VT_BITFIELD) {
3089 printf(" pos=%d size=%d", 3089 printf(" pos=%d size=%d",
3090 (type1.t >> VT_STRUCT_SHIFT) & 0x3f,3090 (type1.t >> VT_STRUCT_SHIFT) & 0x3f,
3091 (type1.t >> (VT_STRUCT_SHIFT + 6)) & 0x3f);3091 (type1.t >> (VT_STRUCT_SHIFT + 6)) & 0x3f);
3092 }3092 }
@@ -3113,7 +3113,7 @@ static void struct_decl(CType *type, int u, int tdef) · 20 unmodified lines
3113 }3113 }
3114 skip('}');3114 skip('}');
3115 /* store size and alignment */3115 /* store size and alignment */
3116 s->c = (c + maxalign - 1) & -maxalign; 3116 s->c = (c + maxalign - 1) & -maxalign;
3117 s->r = maxalign;3117 s->r = maxalign;
3118 }3118 }
3119 }3119 }
@@ -3126,7 +3126,7 @@ ST_FUNC int is_btype_size(int bt) · 6 unmodified lines
3126}3126}
3127 3127
3128/* return 0 if no type declaration. otherwise, return the basic type3128/* return 0 if no type declaration. otherwise, return the basic type
3129 and skip it. 3129 and skip it.
3130 */3130 */
3131static int parse_btype(CType *type, AttributeDef *ad)3131static int parse_btype(CType *type, AttributeDef *ad)
3132{3132{
@@ -3436,9 +3436,9 @@ static void post_type(CType *type, AttributeDef *ad) · 303 unmodified lines
3436 skip(')');3436 skip(')');
3437 /* NOTE: const is ignored in returned type as it has a special3437 /* NOTE: const is ignored in returned type as it has a special
3438 meaning in gcc / C++ */3438 meaning in gcc / C++ */
3439 type->t &= ~VT_CONSTANT; 3439 type->t &= ~VT_CONSTANT;
3440 /* some ancient pre-K&R C allows a function to return an array3440 /* some ancient pre-K&R C allows a function to return an array
3441 and the array brackets to be put after the arguments, such 3441 and the array brackets to be put after the arguments, such
3442 that "int c()[]" means something like "int[] c()" */3442 that "int c()[]" means something like "int[] c()" */
3443 if (tok == '[') {3443 if (tok == '[') {
3444 next();3444 next();
@@ -3479,7 +3479,7 @@ static void post_type(CType *type, AttributeDef *ad) · 34 unmodified lines
3479 if (type->t == VT_FUNC)3479 if (type->t == VT_FUNC)
3480 tcc_error("declaration of an array of functions");3480 tcc_error("declaration of an array of functions");
3481 t1 |= type->t & VT_VLA;3481 t1 |= type->t & VT_VLA;
3482 3482
3483 if (t1 & VT_VLA) {3483 if (t1 & VT_VLA) {
3484 loc -= type_size(&int_type, &align);3484 loc -= type_size(&int_type, &align);
3485 loc &= -align;3485 loc &= -align;
@@ -3493,7 +3493,7 @@ static void post_type(CType *type, AttributeDef *ad) · 7 unmodified lines
3493 }3493 }
3494 if (n != -1)3494 if (n != -1)
3495 vpop();3495 vpop();
3496 3496
3497 /* we push an anonymous symbol which will contain the array3497 /* we push an anonymous symbol which will contain the array
3498 element type */3498 element type */
3499 s = sym_push(SYM_FIELD, type, 0, n);3499 s = sym_push(SYM_FIELD, type, 0, n);
@@ -3506,7 +3506,7 @@ static void post_type(CType *type, AttributeDef *ad) · 6 unmodified lines
3506 in 'type'. 'td' is a bitmask indicating which kind of type decl is3506 in 'type'. 'td' is a bitmask indicating which kind of type decl is
3507 expected. 'type' should contain the basic type. 'ad' is the3507 expected. 'type' should contain the basic type. 'ad' is the
3508 attribute definition of the basic type. It can be modified by3508 attribute definition of the basic type. It can be modified by
3509 type_decl(). 3509 type_decl().
3510 */3510 */
3511static void type_decl(CType *type, AttributeDef *ad, int *v, int td)3511static void type_decl(CType *type, AttributeDef *ad, int *v, int td)
3512{3512{
@@ -3537,7 +3537,7 @@ static void type_decl(CType *type, AttributeDef *ad, int *v, int td) · 24 unmodified lines
3537 mk_pointer(type);3537 mk_pointer(type);
3538 type->t |= qualifiers;3538 type->t |= qualifiers;
3539 }3539 }
3540 3540
3541 /* XXX: clarify attribute handling */3541 /* XXX: clarify attribute handling */
3542 if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)3542 if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
3543 parse_attribute(ad);3543 parse_attribute(ad);
@@ -3576,7 +3576,7 @@ static void type_decl(CType *type, AttributeDef *ad, int *v, int td) · 32 unmodified lines
3576 type->t |= storage;3576 type->t |= storage;
3577 if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)3577 if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
3578 parse_attribute(ad);3578 parse_attribute(ad);
3579 3579
3580 if (!type1.t)3580 if (!type1.t)
3581 return;3581 return;
3582 /* append type at the end of type1 */3582 /* append type at the end of type1 */
@@ -3711,7 +3711,7 @@ ST_FUNC void unary(void) · 128 unmodified lines
3711 next();3711 next();
3712 goto tok_next;3712 goto tok_next;
3713 case TOK_CINT:3713 case TOK_CINT:
3714 case TOK_CCHAR: 3714 case TOK_CCHAR:
3715 case TOK_LCHAR:3715 case TOK_LCHAR:
3716 vpushi(tokc.i);3716 vpushi(tokc.i);
3717 next();3717 next();
@@ -3814,7 +3814,7 @@ ST_FUNC void unary(void) · 96 unmodified lines
3814 linux/include/net/tcp.h:945: error: statement expression in global scope */3814 linux/include/net/tcp.h:945: error: statement expression in global scope */
3815 3815
3816 /* save all registers */3816 /* save all registers */
3817 save_regs(0); 3817 save_regs(0);
3818 /* statement expression : we do not accept break/continue3818 /* statement expression : we do not accept break/continue
3819 inside as GCC does */3819 inside as GCC does */
3820 block(NULL, NULL, NULL, NULL, 0, 1);3820 block(NULL, NULL, NULL, NULL, 0, 1);
@@ -4087,7 +4087,7 @@ ST_FUNC void unary(void) · 266 unmodified lines
4087 vpushsym(&s->type, s);4087 vpushsym(&s->type, s);
4088 next();4088 next();
4089 break;4089 break;
4090 4090
4091 // special qnan , snan and infinity values4091 // special qnan , snan and infinity values
4092 case TOK___NAN__:4092 case TOK___NAN__:
4093 vpush64(VT_DOUBLE, 0x7ff8000000000000ULL);4093 vpush64(VT_DOUBLE, 0x7ff8000000000000ULL);
@@ -4123,7 +4123,7 @@ ST_FUNC void unary(void) · 29 unmodified lines
4123#endif4123#endif
4124 )4124 )
4125 tcc_warning("implicit declaration of function '%s'", name);4125 tcc_warning("implicit declaration of function '%s'", name);
4126 s = external_global_sym(t, &func_old_type, 0); 4126 s = external_global_sym(t, &func_old_type, 0);
4127 }4127 }
4128 if ((s->type.t & (VT_STATIC | VT_INLINE | VT_BTYPE)) ==4128 if ((s->type.t & (VT_STATIC | VT_INLINE | VT_BTYPE)) ==
4129 (VT_STATIC | VT_INLINE | VT_FUNC)) {4129 (VT_STATIC | VT_INLINE | VT_FUNC)) {
@@ -4146,7 +4146,7 @@ ST_FUNC void unary(void) · 16 unmodified lines
4146 }4146 }
4147 break;4147 break;
4148 }4148 }
4149 4149
4150 /* post operations */4150 /* post operations */
4151 while (1) {4151 while (1) {
4152 if (tok == TOK_INC || tok == TOK_DEC) {4152 if (tok == TOK_INC || tok == TOK_DEC) {
@@ -4154,8 +4154,8 @@ ST_FUNC void unary(void) · 1 unmodified line
4154 next();4154 next();
4155 } else if (tok == '.' || tok == TOK_ARROW) {4155 } else if (tok == '.' || tok == TOK_ARROW) {
4156 int qualifiers;4156 int qualifiers;
4157 /* field */ 4157 /* field */
4158 if (tok == TOK_ARROW) 4158 if (tok == TOK_ARROW)
4159 indir();4159 indir();
4160 qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);4160 qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
4161 test_lvalue();4161 test_lvalue();
@@ -4637,7 +4637,7 @@ static void expr_cond(void) · 475 unmodified lines
4637 (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED))4637 (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED))
4638 type.t |= VT_UNSIGNED;4638 type.t |= VT_UNSIGNED;
4639 }4639 }
4640 4640
4641 /* now we convert second operand */4641 /* now we convert second operand */
4642 gen_cast(&type);4642 gen_cast(&type);
4643 if (VT_STRUCT == (vtop->type.t & VT_BTYPE))4643 if (VT_STRUCT == (vtop->type.t & VT_BTYPE))
@@ -4653,9 +4653,9 @@ static void expr_cond(void) · 9 unmodified lines
4653 } else if ((type.t & VT_BTYPE) == VT_LLONG) {4653 } else if ((type.t & VT_BTYPE) == VT_LLONG) {
4654 /* for long longs, we use fixed registers to avoid having4654 /* for long longs, we use fixed registers to avoid having
4655 to handle a complicated move */4655 to handle a complicated move */
4656 rc = RC_IRET; 4656 rc = RC_IRET;
4657 }4657 }
4658 4658
4659 r2 = gv(rc);4659 r2 = gv(rc);
4660 /* this is horrible, but we must also convert first4660 /* this is horrible, but we must also convert first
4661 operand */4661 operand */
@@ -4677,7 +4677,7 @@ static void expr_cond(void) · 15 unmodified lines
4677static void expr_eq(void)4677static void expr_eq(void)
4678{4678{
4679 int t;4679 int t;
4680 4680
4681 expr_cond();4681 expr_cond();
4682 if (tok == '=' ||4682 if (tok == '=' ||
4683 (tok >= TOK_A_MOD && tok <= TOK_A_DIV) ||4683 (tok >= TOK_A_MOD && tok <= TOK_A_DIV) ||
@@ -4797,7 +4797,7 @@ static void label_or_decl(int l) · 113 unmodified lines
4797 decl(l);4797 decl(l);
4798}4798}
4799 4799
4800static void block(int *bsym, int *csym, int *case_sym, int *def_sym, 4800static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
4801 int case_reg, int is_expr)4801 int case_reg, int is_expr)
4802{4802{
4803 int a, b, c, d;4803 int a, b, c, d;
@@ -4858,7 +4858,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 54 unmodified lines
4858 frame_bottom->next = scope_stack_bottom;4858 frame_bottom->next = scope_stack_bottom;
4859 scope_stack_bottom = frame_bottom;4859 scope_stack_bottom = frame_bottom;
4860 llabel = local_label_stack;4860 llabel = local_label_stack;
4861 4861
4862 /* handle local labels declarations */4862 /* handle local labels declarations */
4863 if (tok == TOK_LABEL) {4863 if (tok == TOK_LABEL) {
4864 next();4864 next();
@@ -4906,14 +4906,14 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 41 unmodified lines
4906 /* pop locally defined symbols */4906 /* pop locally defined symbols */
4907 scope_stack_bottom = scope_stack_bottom->next;4907 scope_stack_bottom = scope_stack_bottom->next;
4908 sym_pop(&local_stack, s);4908 sym_pop(&local_stack, s);
4909 4909
4910 /* Pop VLA frames and restore stack pointer if required */4910 /* Pop VLA frames and restore stack pointer if required */
4911 if (vlas_in_scope > saved_vlas_in_scope) {4911 if (vlas_in_scope > saved_vlas_in_scope) {
4912 vla_sp_loc = saved_vlas_in_scope ? block_vla_sp_loc : vla_sp_root_loc;4912 vla_sp_loc = saved_vlas_in_scope ? block_vla_sp_loc : vla_sp_root_loc;
4913 vla_sp_restore();4913 vla_sp_restore();
4914 }4914 }
4915 vlas_in_scope = saved_vlas_in_scope;4915 vlas_in_scope = saved_vlas_in_scope;
4916 4916
4917 next();4917 next();
4918 } else if (tok == TOK_RETURN) {4918 } else if (tok == TOK_RETURN) {
4919 next();4919 next();
@@ -5080,7 +5080,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 160 unmodified lines
5080 gsym_addr(b, c);5080 gsym_addr(b, c);
5081 scope_stack_bottom = scope_stack_bottom->next;5081 scope_stack_bottom = scope_stack_bottom->next;
5082 sym_pop(&local_stack, s);5082 sym_pop(&local_stack, s);
5083 } else 5083 } else
5084 if (tok == TOK_DO) {5084 if (tok == TOK_DO) {
5085 next();5085 next();
5086 a = 0;5086 a = 0;
@@ -5154,7 +5154,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 67 unmodified lines
5154 skip(':');5154 skip(':');
5155 is_expr = 0;5155 is_expr = 0;
5156 goto block_after_label;5156 goto block_after_label;
5157 } else 5157 } else
5158 if (tok == TOK_DEFAULT) {5158 if (tok == TOK_DEFAULT) {
5159 next();5159 next();
5160 skip(':');5160 skip(':');
@@ -5185,7 +5185,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 24 unmodified lines
5185 s->r = LABEL_FORWARD;5185 s->r = LABEL_FORWARD;
5186 }5186 }
5187 vla_sp_restore_root();5187 vla_sp_restore_root();
5188 if (s->r & LABEL_FORWARD) 5188 if (s->r & LABEL_FORWARD)
5189 s->jnext = gjmp(s->jnext);5189 s->jnext = gjmp(s->jnext);
5190 else5190 else
5191 gjmp_addr(s->jnext);5191 gjmp_addr(s->jnext);
@@ -5240,8 +5240,8 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 48 unmodified lines
5240 address. cur_index/cur_field is the pointer to the current5240 address. cur_index/cur_field is the pointer to the current
5241 value. 'size_only' is true if only size info is needed (only used5241 value. 'size_only' is true if only size info is needed (only used
5242 in arrays) */5242 in arrays) */
5243static void decl_designator(CType *type, Section *sec, unsigned long c, 5243static void decl_designator(CType *type, Section *sec, unsigned long c,
5244 int *cur_index, Sym **cur_field, 5244 int *cur_index, Sym **cur_field,
5245 int size_only)5245 int size_only)
5246{5246{
5247 Sym *s, *f;5247 Sym *s, *f;
@@ -5265,7 +5265,7 @@ static void decl_designator(CType *type, Section *sec, unsigned long c, · 17 unmodified lines
5265 if (tok == TOK_DOTS && gnu_ext) {5265 if (tok == TOK_DOTS && gnu_ext) {
5266 next();5266 next();
5267 index_last = expr_const();5267 index_last = expr_const();
5268 if (index_last < 0 || 5268 if (index_last < 0 ||
5269 (s->c >= 0 && index_last >= s->c) ||5269 (s->c >= 0 && index_last >= s->c) ||
5270 index_last < index)5270 index_last < index)
5271 expect("invalid index");5271 expect("invalid index");
@@ -5361,7 +5361,7 @@ static void decl_designator(CType *type, Section *sec, unsigned long c, · 89 unmodified lines
5361#define EXPR_ANY 25361#define EXPR_ANY 2
5362 5362
5363/* store a value or an expression directly in global data or in local array */5363/* store a value or an expression directly in global data or in local array */
5364static void init_putv(CType *type, Section *sec, unsigned long c, 5364static void init_putv(CType *type, Section *sec, unsigned long c,
5365 int v, int expr_type)5365 int v, int expr_type)
5366{5366{
5367 int saved_global_expr, bt, bit_pos, bit_size;5367 int saved_global_expr, bt, bit_pos, bit_size;
@@ -5387,7 +5387,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c, · 19 unmodified lines
5387 expr_eq();5387 expr_eq();
5388 break;5388 break;
5389 }5389 }
5390 5390
5391 dtype = *type;5391 dtype = *type;
5392 dtype.t &= ~VT_CONSTANT; /* need to do that to avoid false warning */5392 dtype.t &= ~VT_CONSTANT; /* need to do that to avoid false warning */
5393 5393
@@ -5502,7 +5502,7 @@ static void init_putz(CType *t, Section *sec, unsigned long c, int size) · 108 unmodified lines
5502 allocation. 'first' is true if array '{' must be read (multi5502 allocation. 'first' is true if array '{' must be read (multi
5503 dimension implicit array init handling). 'size_only' is true if5503 dimension implicit array init handling). 'size_only' is true if
5504 size only evaluation is wanted (only for arrays). */5504 size only evaluation is wanted (only for arrays). */
5505static void decl_initializer(CType *type, Section *sec, unsigned long c, 5505static void decl_initializer(CType *type, Section *sec, unsigned long c,
5506 int first, int size_only)5506 int first, int size_only)
5507{5507{
5508 int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i;5508 int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i;
@@ -5512,14 +5512,14 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 3 unmodified lines
5512 5512
5513 if (type->t & VT_VLA) {5513 if (type->t & VT_VLA) {
5514 int a;5514 int a;
5515 5515
5516 /* save current stack pointer */5516 /* save current stack pointer */
5517 if (vlas_in_scope == 0) {5517 if (vlas_in_scope == 0) {
5518 if (vla_sp_root_loc == -1)5518 if (vla_sp_root_loc == -1)
5519 vla_sp_root_loc = (loc -= PTR_SIZE);5519 vla_sp_root_loc = (loc -= PTR_SIZE);
5520 gen_vla_sp_save(vla_sp_root_loc);5520 gen_vla_sp_save(vla_sp_root_loc);
5521 }5521 }
5522 5522
5523 vla_runtime_type_size(type, &a);5523 vla_runtime_type_size(type, &a);
5524 gen_vla_alloc(type, a);5524 gen_vla_alloc(type, a);
5525 gen_vla_sp_save(c);5525 gen_vla_sp_save(c);
@@ -5533,7 +5533,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 7 unmodified lines
5533 size1 = type_size(t1, &align1);5533 size1 = type_size(t1, &align1);
5534 5534
5535 no_oblock = 1;5535 no_oblock = 1;
5536 if ((first && tok != TOK_LSTR && tok != TOK_STR) || 5536 if ((first && tok != TOK_LSTR && tok != TOK_STR) ||
5537 tok == '{') {5537 tok == '{') {
5538 if (tok != '{')5538 if (tok != '{')
5539 tcc_error("character array initializer must be a literal,"5539 tcc_error("character array initializer must be a literal,"
@@ -5544,7 +5544,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 4 unmodified lines
5544 5544
5545 /* only parse strings here if correct type (otherwise: handle5545 /* only parse strings here if correct type (otherwise: handle
5546 them as ((w)char *) expressions */5546 them as ((w)char *) expressions */
5547 if ((tok == TOK_LSTR && 5547 if ((tok == TOK_LSTR &&
5548#ifdef TCC_TARGET_PE5548#ifdef TCC_TARGET_PE
5549 (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)5549 (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)
5550#else5550#else
@@ -5604,7 +5604,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 53 unmodified lines
5604 /* must put zero in holes (note that doing it that way5604 /* must put zero in holes (note that doing it that way
5605 ensures that it even works with designators) */5605 ensures that it even works with designators) */
5606 if (!size_only && array_length < index) {5606 if (!size_only && array_length < index) {
5607 init_putz(t1, sec, c + array_length * size1, 5607 init_putz(t1, sec, c + array_length * size1,
5608 (index - array_length) * size1);5608 (index - array_length) * size1);
5609 }5609 }
5610 index++;5610 index++;
@@ -5624,7 +5624,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 13 unmodified lines
5624 skip('}');5624 skip('}');
5625 /* put zeros at the end */5625 /* put zeros at the end */
5626 if (!size_only && n >= 0 && array_length < n) {5626 if (!size_only && n >= 0 && array_length < n) {
5627 init_putz(t1, sec, c + array_length * size1, 5627 init_putz(t1, sec, c + array_length * size1,
5628 (n - array_length) * size1);5628 (n - array_length) * size1);
5629 }5629 }
5630 /* patch type size if needed */5630 /* patch type size if needed */
@@ -5690,7 +5690,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 59 unmodified lines
5690 decl_designator(type, sec, c, NULL, &f, size_only);5690 decl_designator(type, sec, c, NULL, &f, size_only);
5691 index = f->c;5691 index = f->c;
5692 if (!size_only && array_length < index) {5692 if (!size_only && array_length < index) {
5693 init_putz(type, sec, c + array_length, 5693 init_putz(type, sec, c + array_length,
5694 index - array_length);5694 index - array_length);
5695 }5695 }
5696 index = index + type_size(&f->type, &align1);5696 index = index + type_size(&f->type, &align1);
@@ -5743,7 +5743,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 46 unmodified lines
5743 }5743 }
5744 /* put zeros at the end */5744 /* put zeros at the end */
5745 if (!size_only && array_length < n) {5745 if (!size_only && array_length < n) {
5746 init_putz(type, sec, c + array_length, 5746 init_putz(type, sec, c + array_length,
5747 n - array_length);5747 n - array_length);
5748 }5748 }
5749 if (!no_oblock)5749 if (!no_oblock)
@@ -5795,7 +5795,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, · 45 unmodified lines
5795 zero, then a reference to the new object is put in the value stack.5795 zero, then a reference to the new object is put in the value stack.
5796 If 'has_init' is 2, a special parsing is done to handle string5796 If 'has_init' is 2, a special parsing is done to handle string
5797 constants. */5797 constants. */
5798static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, 5798static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
5799 int has_init, int v, char *asm_label,5799 int has_init, int v, char *asm_label,
5800 int scope)5800 int scope)
5801{5801{
@@ -5826,7 +5826,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 24 unmodified lines
5826 initializers handling */5826 initializers handling */
5827 tok_str_new(&init_str);5827 tok_str_new(&init_str);
5828 if (size < 0 || (flexible_array && has_init)) {5828 if (size < 0 || (flexible_array && has_init)) {
5829 if (!has_init) 5829 if (!has_init)
5830 tcc_error("unknown type size");5830 tcc_error("unknown type size");
5831 /* get all init string */5831 /* get all init string */
5832 if (has_init == 2) {5832 if (has_init == 2) {
@@ -5855,7 +5855,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 22 unmodified lines
5855 }5855 }
5856 tok_str_add(&init_str, -1);5856 tok_str_add(&init_str, -1);
5857 tok_str_add(&init_str, 0);5857 tok_str_add(&init_str, 0);
5858 5858
5859 /* compute size */5859 /* compute size */
5860 save_parse_state(&saved_parse_state);5860 save_parse_state(&saved_parse_state);
5861 5861
@@ -5865,10 +5865,10 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 3 unmodified lines
5865 /* prepare second initializer parsing */5865 /* prepare second initializer parsing */
5866 macro_ptr = init_str.str;5866 macro_ptr = init_str.str;
5867 next();5867 next();
5868 5868
5869 /* if still unknown size, error */5869 /* if still unknown size, error */
5870 size = type_size(type, &align);5870 size = type_size(type, &align);
5871 if (size < 0) 5871 if (size < 0)
5872 tcc_error("unknown type size");5872 tcc_error("unknown type size");
5873 }5873 }
5874 if (flexible_array)5874 if (flexible_array)
@@ -5919,14 +5919,14 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 44 unmodified lines
5919 sym = sym_find(v);5919 sym = sym_find(v);
5920 if (sym) {5920 if (sym) {
5921 if (!is_compatible_types(&sym->type, type))5921 if (!is_compatible_types(&sym->type, type))
5922 tcc_error("incompatible types for redefinition of '%s'", 5922 tcc_error("incompatible types for redefinition of '%s'",
5923 get_tok_str(v, NULL));5923 get_tok_str(v, NULL));
5924 if (sym->type.t & VT_EXTERN) {5924 if (sym->type.t & VT_EXTERN) {
5925 /* if the variable is extern, it was not allocated */5925 /* if the variable is extern, it was not allocated */
5926 sym->type.t &= ~VT_EXTERN;5926 sym->type.t &= ~VT_EXTERN;
5927 /* set array size if it was omitted in extern5927 /* set array size if it was omitted in extern
5928 declaration */5928 declaration */
5929 if ((sym->type.t & VT_ARRAY) && 5929 if ((sym->type.t & VT_ARRAY) &&
5930 sym->type.ref->c < 0 &&5930 sym->type.ref->c < 0 &&
5931 type->ref->c >= 0)5931 type->ref->c >= 0)
5932 sym->type.ref->c = type->ref->c;5932 sym->type.ref->c = type->ref->c;
@@ -5966,7 +5966,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 33 unmodified lines
5966#endif5966#endif
5967 sec->data_offset = data_offset;5967 sec->data_offset = data_offset;
5968 /* allocate section space to put the data */5968 /* allocate section space to put the data */
5969 if (sec->sh_type != SHT_NOBITS && 5969 if (sec->sh_type != SHT_NOBITS &&
5970 data_offset > sec->data_allocated)5970 data_offset > sec->data_allocated)
5971 section_realloc(sec, data_offset);5971 section_realloc(sec, data_offset);
5972 /* align section if needed */5972 /* align section if needed */
@@ -6036,12 +6036,12 @@ static void put_func_debug(Sym *sym) · 63 unmodified lines
6036 6036
6037 /* stabs info */6037 /* stabs info */
6038 /* XXX: we put here a dummy type */6038 /* XXX: we put here a dummy type */
6039 snprintf(buf, sizeof(buf), "%s:%c1", 6039 snprintf(buf, sizeof(buf), "%s:%c1",
6040 funcname, sym->type.t & VT_STATIC ? 'f' : 'F');6040 funcname, sym->type.t & VT_STATIC ? 'f' : 'F');
6041 put_stabs_r(buf, N_FUN, 0, file->line_num, 0,6041 put_stabs_r(buf, N_FUN, 0, file->line_num, 0,
6042 cur_text_section, sym->c);6042 cur_text_section, sym->c);
6043 /* //gr gdb wants a line at the function */6043 /* //gr gdb wants a line at the function */
6044 put_stabn(N_SLINE, 0, file->line_num, 0); 6044 put_stabn(N_SLINE, 0, file->line_num, 0);
6045 last_ind = 0;6045 last_ind = 0;
6046 last_line_num = 0;6046 last_line_num = 0;
6047}6047}
@@ -6058,10 +6058,10 @@ static void func_decl_list(Sym *func_sym) · 10 unmodified lines
6058 /* parse each declaration */6058 /* parse each declaration */
6059 while (tok != '{' && tok != ';' && tok != ',' && tok != TOK_EOF &&6059 while (tok != '{' && tok != ';' && tok != ',' && tok != TOK_EOF &&
6060 tok != TOK_ASM1 && tok != TOK_ASM2 && tok != TOK_ASM3) {6060 tok != TOK_ASM1 && tok != TOK_ASM2 && tok != TOK_ASM3) {
6061 if (!parse_btype(&btype, &ad)) 6061 if (!parse_btype(&btype, &ad))
6062 expect("declaration list");6062 expect("declaration list");
6063 if (((btype.t & VT_BTYPE) == VT_ENUM ||6063 if (((btype.t & VT_BTYPE) == VT_ENUM ||
6064 (btype.t & VT_BTYPE) == VT_STRUCT) && 6064 (btype.t & VT_BTYPE) == VT_STRUCT) &&
6065 tok == ';') {6065 tok == ';') {
6066 /* we accept no variable after */6066 /* we accept no variable after */
6067 } else {6067 } else {
@@ -6080,7 +6080,7 @@ static void func_decl_list(Sym *func_sym) · 12 unmodified lines
6080 found:6080 found:
6081 /* check that no storage specifier except 'register' was given */6081 /* check that no storage specifier except 'register' was given */
6082 if (type.t & VT_STORAGE)6082 if (type.t & VT_STORAGE)
6083 tcc_error("storage class specified for '%s'", get_tok_str(v, NULL)); 6083 tcc_error("storage class specified for '%s'", get_tok_str(v, NULL));
6084 convert_parameter_type(&type);6084 convert_parameter_type(&type);
6085 /* we can add the type (NOTE: it could be local to the function) */6085 /* we can add the type (NOTE: it could be local to the function) */
6086 s->type = type;6086 s->type = type;
@@ -6140,7 +6140,7 @@ static void gen_function(Sym *sym) · 53 unmodified lines
6140 sym_pop(&local_stack, NULL);6140 sym_pop(&local_stack, NULL);
6141 /* end of function */6141 /* end of function */
6142 /* patch symbol size */6142 /* patch symbol size */
6143 ((ElfW(Sym) *)symtab_section->data)[sym->c].st_size = 6143 ((ElfW(Sym) *)symtab_section->data)[sym->c].st_size =
6144 ind - func_ind;6144 ind - func_ind;
6145 /* patch symbol weakness (this definition overrules any prototype) */6145 /* patch symbol weakness (this definition overrules any prototype) */
6146 if (sym->type.t & VT_WEAK)6146 if (sym->type.t & VT_WEAK)
@@ -6234,7 +6234,7 @@ static int decl0(int l, int is_for_loop_init) · 87 unmodified lines
6234 btype.t = VT_INT;6234 btype.t = VT_INT;
6235 }6235 }
6236 if (((btype.t & VT_BTYPE) == VT_ENUM ||6236 if (((btype.t & VT_BTYPE) == VT_ENUM ||
6237 (btype.t & VT_BTYPE) == VT_STRUCT) && 6237 (btype.t & VT_BTYPE) == VT_STRUCT) &&
6238 tok == ';') {6238 tok == ';') {
6239 if ((btype.t & VT_BTYPE) == VT_STRUCT) {6239 if ((btype.t & VT_BTYPE) == VT_STRUCT) {
6240 int v = btype.ref->v;6240 int v = btype.ref->v;
@@ -6273,7 +6273,7 @@ static int decl0(int l, int is_for_loop_init) · 32 unmodified lines
6273 asm_label_instr(&astr);6273 asm_label_instr(&astr);
6274 asm_label = tcc_strdup(astr.data);6274 asm_label = tcc_strdup(astr.data);
6275 cstr_free(&astr);6275 cstr_free(&astr);
6276 6276
6277 /* parse one last attribute list, after asm label */6277 /* parse one last attribute list, after asm label */
6278 parse_attribute(&ad);6278 parse_attribute(&ad);
6279 }6279 }
@@ -6299,11 +6299,11 @@ static int decl0(int l, int is_for_loop_init) · 19 unmodified lines
6299 while ((sym = sym->next) != NULL)6299 while ((sym = sym->next) != NULL)
6300 if (!(sym->v & ~SYM_FIELD))6300 if (!(sym->v & ~SYM_FIELD))
6301 expect("identifier");6301 expect("identifier");
6302 6302
6303 /* XXX: cannot do better now: convert extern line to static inline */6303 /* XXX: cannot do better now: convert extern line to static inline */
6304 if ((type.t & (VT_EXTERN | VT_INLINE)) == (VT_EXTERN | VT_INLINE))6304 if ((type.t & (VT_EXTERN | VT_INLINE)) == (VT_EXTERN | VT_INLINE))
6305 type.t = (type.t & ~VT_EXTERN) | VT_STATIC;6305 type.t = (type.t & ~VT_EXTERN) | VT_STATIC;
6306 6306
6307 sym = sym_find(v);6307 sym = sym_find(v);
6308 if (sym) {6308 if (sym) {
6309 Sym *ref;6309 Sym *ref;
@@ -6334,7 +6334,7 @@ static int decl0(int l, int is_for_loop_init) · 24 unmodified lines
6334 6334
6335 if (!is_compatible_types(&sym->type, &type)) {6335 if (!is_compatible_types(&sym->type, &type)) {
6336 func_error1:6336 func_error1:
6337 tcc_error("incompatible types for redefinition of '%s'", 6337 tcc_error("incompatible types for redefinition of '%s'",
6338 get_tok_str(v, NULL));6338 get_tok_str(v, NULL));
6339 }6339 }
6340 type.ref->a.func_proto = 0;6340 type.ref->a.func_proto = 0;
@@ -6349,18 +6349,18 @@ static int decl0(int l, int is_for_loop_init) · 8 unmodified lines
6349 /* static inline functions are just recorded as a kind6349 /* static inline functions are just recorded as a kind
6350 of macro. Their code will be emitted at the end of6350 of macro. Their code will be emitted at the end of
6351 the compilation unit only if they are used */6351 the compilation unit only if they are used */
6352 if ((type.t & (VT_INLINE | VT_STATIC)) == 6352 if ((type.t & (VT_INLINE | VT_STATIC)) ==
6353 (VT_INLINE | VT_STATIC)) {6353 (VT_INLINE | VT_STATIC)) {
6354 int block_level;6354 int block_level;
6355 struct InlineFunc *fn;6355 struct InlineFunc *fn;
6356 const char *filename;6356 const char *filename;
6357 6357
6358 filename = file ? file->filename : "";6358 filename = file ? file->filename : "";
6359 fn = tcc_malloc(sizeof *fn + strlen(filename));6359 fn = tcc_malloc(sizeof *fn + strlen(filename));
6360 strcpy(fn->filename, filename);6360 strcpy(fn->filename, filename);
6361 fn->sym = sym;6361 fn->sym = sym;
6362 tok_str_new(&fn->func_str);6362 tok_str_new(&fn->func_str);
6363 6363
6364 block_level = 0;6364 block_level = 0;
6365 for(;;) {6365 for(;;) {
6366 int t;6366 int t;
tcclib.h+3−3
@@ -1,8 +1,8 @@
1/* Simple libc header for TCC 1/* Simple libc header for TCC
2 * 2 *
3 * Add any function you want from the libc there. This file is here3 * Add any function you want from the libc there. This file is here
4 * only for your convenience so that you do not need to put the whole4 * only for your convenience so that you do not need to put the whole
5 * glibc include files on your floppy disk 5 * glibc include files on your floppy disk
6 */6 */
7#ifndef _TCCLIB_H7#ifndef _TCCLIB_H
8#define _TCCLIB_H8#define _TCCLIB_H
tccpe.c+1−1
@@ -1266,7 +1266,7 @@ static int pe_check_symbols(struct pe_info *pe) · 1265 unmodified lines
1266 put_elf_reloc(symtab_section, text_section,1266 put_elf_reloc(symtab_section, text_section,
1267 offset + 8, R_XXX_THUNKFIX, is->iat_index); // offset to IAT position1267 offset + 8, R_XXX_THUNKFIX, is->iat_index); // offset to IAT position
1268#else1268#else
1269 put_elf_reloc(symtab_section, text_section, 1269 put_elf_reloc(symtab_section, text_section,
1270 offset + 2, R_XXX_THUNKFIX, is->iat_index);1270 offset + 2, R_XXX_THUNKFIX, is->iat_index);
1271#endif1271#endif
1272 is->thk_offset = offset;1272 is->thk_offset = offset;
tccpp.c+36−36
@@ -1,6 +1,6 @@
1/*1/*
2 * TCC - Tiny C Compiler2 * TCC - Tiny C Compiler
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -50,7 +50,7 @@ static unsigned char isidnum_table[256 - CH_EOF]; · 43 unmodified lines
50 50
51static TokenString *macro_stack;51static TokenString *macro_stack;
52 52
53static const char tcc_keywords[] = 53static const char tcc_keywords[] =
54#define DEF(id, str) str "\0"54#define DEF(id, str) str "\0"
55#include "tcctok.h"55#include "tcctok.h"
56#undef DEF56#undef DEF
@@ -221,7 +221,7 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len) · 164 unmodified lines
221 TokenSym *ts, **ptable;221 TokenSym *ts, **ptable;
222 int i;222 int i;
223 223
224 if (tok_ident >= SYM_FIRST_ANOM) 224 if (tok_ident >= SYM_FIRST_ANOM)
225 tcc_error("memory full (symbols)");225 tcc_error("memory full (symbols)");
226 226
227 /* expand token table if needed */227 /* expand token table if needed */
@@ -255,7 +255,7 @@ ST_FUNC TokenSym *tok_alloc(const char *str, int len) · 27 unmodified lines
255 TokenSym *ts, **pts;255 TokenSym *ts, **pts;
256 int i;256 int i;
257 unsigned int h;257 unsigned int h;
258 258
259 h = TOK_HASH_INIT;259 h = TOK_HASH_INIT;
260 for(i=0;i<len;i++)260 for(i=0;i<len;i++)
261 h = TOK_HASH_FUNC(h, ((unsigned char *)str)[i]);261 h = TOK_HASH_FUNC(h, ((unsigned char *)str)[i]);
@@ -511,7 +511,7 @@ static int handle_stray1(uint8_t *p) · 249 unmodified lines
511ST_FUNC void minp(void)511ST_FUNC void minp(void)
512{512{
513 inp();513 inp();
514 if (ch == '\\') 514 if (ch == '\\')
515 handle_stray();515 handle_stray();
516}516}
517 517
@@ -557,7 +557,7 @@ static uint8_t *parse_line_comment(uint8_t *p) · 39 unmodified lines
557ST_FUNC uint8_t *parse_comment(uint8_t *p)557ST_FUNC uint8_t *parse_comment(uint8_t *p)
558{558{
559 int c;559 int c;
560 560
561 p++;561 p++;
562 for(;;) {562 for(;;) {
563 /* fast skip loop */563 /* fast skip loop */
@@ -635,13 +635,13 @@ static inline void skip_spaces(void) · 71 unmodified lines
635 cinp();635 cinp();
636}636}
637 637
638static inline int check_space(int t, int *spc) 638static inline int check_space(int t, int *spc)
639{639{
640 if (t < 256 && (isidnum_table[t - CH_EOF] & IS_SPC)) {640 if (t < 256 && (isidnum_table[t - CH_EOF] & IS_SPC)) {
641 if (*spc) 641 if (*spc)
642 return 1;642 return 1;
643 *spc = 1;643 *spc = 1;
644 } else 644 } else
645 *spc = 0;645 *spc = 0;
646 return 0;646 return 0;
647}647}
@@ -774,7 +774,7 @@ redo_start: · 126 unmodified lines
774 file->buf_ptr = p;774 file->buf_ptr = p;
775 next_nomacro();775 next_nomacro();
776 p = file->buf_ptr;776 p = file->buf_ptr;
777 if (a == 0 && 777 if (a == 0 &&
778 (tok == TOK_ELSE || tok == TOK_ELIF || tok == TOK_ENDIF))778 (tok == TOK_ELSE || tok == TOK_ELIF || tok == TOK_ENDIF))
779 goto the_end;779 goto the_end;
780 if (tok == TOK_IF || tok == TOK_IFDEF || tok == TOK_IFNDEF)780 if (tok == TOK_IF || tok == TOK_IFDEF || tok == TOK_IFNDEF)
@@ -930,7 +930,7 @@ static void tok_str_add2(TokenString *s, int t, CValue *cv) · 149 unmodified lines
930 cstr->size = cv->cstr->size;930 cstr->size = cv->cstr->size;
931 cstr->data_allocated = NULL;931 cstr->data_allocated = NULL;
932 cstr->size_allocated = cstr->size;932 cstr->size_allocated = cstr->size;
933 memcpy((char *)cstr + sizeof(CString), 933 memcpy((char *)cstr + sizeof(CString),
934 cv->cstr->data, cstr->size);934 cv->cstr->data, cstr->size);
935 len += nb_words;935 len += nb_words;
936 }936 }
@@ -1253,14 +1253,14 @@ static int expr_preprocess(void) · 316 unmodified lines
1253{1253{
1254 int c, t;1254 int c, t;
1255 TokenString str;1255 TokenString str;
1256 1256
1257 tok_str_new(&str);1257 tok_str_new(&str);
1258 while (tok != TOK_LINEFEED && tok != TOK_EOF) {1258 while (tok != TOK_LINEFEED && tok != TOK_EOF) {
1259 next(); /* do macro subst */1259 next(); /* do macro subst */
1260 if (tok == TOK_DEFINED) {1260 if (tok == TOK_DEFINED) {
1261 next_nomacro();1261 next_nomacro();
1262 t = tok;1262 t = tok;
1263 if (t == '(') 1263 if (t == '(')
1264 next_nomacro();1264 next_nomacro();
1265 c = define_find(tok) != 0;1265 c = define_find(tok) != 0;
1266 if (t == '(')1266 if (t == '(')
@@ -1914,7 +1914,7 @@ static void parse_escape_string(CString *outstr, const uint8_t *buf, int is_long · 647 unmodified lines
1914 break;1914 break;
1915 case '\'':1915 case '\'':
1916 case '\"':1916 case '\"':
1917 case '\\': 1917 case '\\':
1918 case '?':1918 case '?':
1919 break;1919 break;
1920 default:1920 default:
@@ -2070,7 +2070,7 @@ static void parse_number(const char *p) · 149 unmodified lines
2070 *q = '\0';2070 *q = '\0';
2071 if (b == 16)2071 if (b == 16)
2072 shift = 4;2072 shift = 4;
2073 else 2073 else
2074 shift = 1;2074 shift = 1;
2075 bn_zero(bn);2075 bn_zero(bn);
2076 q = token_buf;2076 q = token_buf;
@@ -2126,7 +2126,7 @@ static void parse_number(const char *p) · 49 unmodified lines
2126 ch = *p++;2126 ch = *p++;
2127 }2127 }
2128 exp_val = exp_val * s;2128 exp_val = exp_val * s;
2129 2129
2130 /* now we can generate the number */2130 /* now we can generate the number */
2131 /* XXX: should patch directly float number */2131 /* XXX: should patch directly float number */
2132 d = (double)bn[1] * 4294967296.0 + (double)bn[0];2132 d = (double)bn[1] * 4294967296.0 + (double)bn[0];
@@ -2363,7 +2363,7 @@ static inline void next_nomacro1(void) · 230 unmodified lines
2363 } else {2363 } else {
2364 tok_flags &= ~TOK_FLAG_EOF;2364 tok_flags &= ~TOK_FLAG_EOF;
2365 /* pop include file */2365 /* pop include file */
2366 2366
2367 /* test if previous '#endif' was after a #ifdef at2367 /* test if previous '#endif' was after a #ifdef at
2368 start of file */2368 start of file */
2369 if (tok_flags & TOK_FLAG_ENDIF) {2369 if (tok_flags & TOK_FLAG_ENDIF) {
@@ -2400,7 +2400,7 @@ maybe_newline: · 30 unmodified lines
2400 case '#':2400 case '#':
2401 /* XXX: simplify */2401 /* XXX: simplify */
2402 PEEKC(c, p);2402 PEEKC(c, p);
2403 if ((tok_flags & TOK_FLAG_BOL) && 2403 if ((tok_flags & TOK_FLAG_BOL) &&
2404 (parse_flags & PARSE_FLAG_PREPROCESS)) {2404 (parse_flags & PARSE_FLAG_PREPROCESS)) {
2405 file->buf_ptr = p;2405 file->buf_ptr = p;
2406 preprocess(tok_flags & TOK_FLAG_BOF);2406 preprocess(tok_flags & TOK_FLAG_BOF);
@@ -2420,7 +2420,7 @@ maybe_newline: · 13 unmodified lines
2420 }2420 }
2421 }2421 }
2422 break;2422 break;
2423 2423
2424 /* dollar is allowed to start identifiers when not parsing asm */2424 /* dollar is allowed to start identifiers when not parsing asm */
2425 case '$':2425 case '$':
2426 if (!(isidnum_table[c - CH_EOF] & IS_ID)2426 if (!(isidnum_table[c - CH_EOF] & IS_ID)
@@ -2433,14 +2433,14 @@ maybe_newline: · 6 unmodified lines
2433 case 'm': case 'n': case 'o': case 'p':2433 case 'm': case 'n': case 'o': case 'p':
2434 case 'q': case 'r': case 's': case 't':2434 case 'q': case 'r': case 's': case 't':
2435 case 'u': case 'v': case 'w': case 'x':2435 case 'u': case 'v': case 'w': case 'x':
2436 case 'y': case 'z': 2436 case 'y': case 'z':
2437 case 'A': case 'B': case 'C': case 'D':2437 case 'A': case 'B': case 'C': case 'D':
2438 case 'E': case 'F': case 'G': case 'H':2438 case 'E': case 'F': case 'G': case 'H':
2439 case 'I': case 'J': case 'K': 2439 case 'I': case 'J': case 'K':
2440 case 'M': case 'N': case 'O': case 'P':2440 case 'M': case 'N': case 'O': case 'P':
2441 case 'Q': case 'R': case 'S': case 'T':2441 case 'Q': case 'R': case 'S': case 'T':
2442 case 'U': case 'V': case 'W': case 'X':2442 case 'U': case 'V': case 'W': case 'X':
2443 case 'Y': case 'Z': 2443 case 'Y': case 'Z':
2444 case '_':2444 case '_':
2445 parse_ident_fast:2445 parse_ident_fast:
2446 p1 = p;2446 p1 = p;
@@ -2594,7 +2594,7 @@ maybe_newline: · 147 unmodified lines
2594 tok = TOK_GT;2594 tok = TOK_GT;
2595 }2595 }
2596 break;2596 break;
2597 2597
2598 case '&':2598 case '&':
2599 PEEKC(c, p);2599 PEEKC(c, p);
2600 if (c == '&') {2600 if (c == '&') {
@@ -2607,7 +2607,7 @@ maybe_newline: · 6 unmodified lines
2607 tok = '&';2607 tok = '&';
2608 }2608 }
2609 break;2609 break;
2610 2610
2611 case '|':2611 case '|':
2612 PEEKC(c, p);2612 PEEKC(c, p);
2613 if (c == '|') {2613 if (c == '|') {
@@ -2633,7 +2633,7 @@ maybe_newline: · 19 unmodified lines
2633 tok = '+';2633 tok = '+';
2634 }2634 }
2635 break;2635 break;
2636 2636
2637 case '-':2637 case '-':
2638 PEEKC(c, p);2638 PEEKC(c, p);
2639 if (c == '-') {2639 if (c == '-') {
@@ -2655,7 +2655,7 @@ maybe_newline: · 15 unmodified lines
2655 PARSE2('*', '*', '=', TOK_A_MUL)2655 PARSE2('*', '*', '=', TOK_A_MUL)
2656 PARSE2('%', '%', '=', TOK_A_MOD)2656 PARSE2('%', '%', '=', TOK_A_MOD)
2657 PARSE2('^', '^', '=', TOK_A_XOR)2657 PARSE2('^', '^', '=', TOK_A_XOR)
2658 2658
2659 /* comments or operator */2659 /* comments or operator */
2660 case '/':2660 case '/':
2661 PEEKC(c, p);2661 PEEKC(c, p);
@@ -2675,7 +2675,7 @@ maybe_newline: · 13 unmodified lines
2675 tok = '/';2675 tok = '/';
2676 }2676 }
2677 break;2677 break;
2678 2678
2679 /* simple tokens */2679 /* simple tokens */
2680 case '(':2680 case '(':
2681 case ')':2681 case ')':
@@ -2730,7 +2730,7 @@ ST_FUNC void next_nomacro(void) · 48 unmodified lines
2730 next_nomacro_spc();2730 next_nomacro_spc();
2731 } while (tok < 256 && (isidnum_table[tok - CH_EOF] & IS_SPC));2731 } while (tok < 256 && (isidnum_table[tok - CH_EOF] & IS_SPC));
2732}2732}
2733 2733
2734 2734
2735static void macro_subst(2735static void macro_subst(
2736 TokenString *tok_str,2736 TokenString *tok_str,
@@ -2924,7 +2924,7 @@ static int macro_subst_tok( · 187 unmodified lines
2924 CValue cval;2924 CValue cval;
2925 CString cstr;2925 CString cstr;
2926 char buf[32];2926 char buf[32];
2927 2927
2928 /* if symbol is a macro, prepare substitution */2928 /* if symbol is a macro, prepare substitution */
2929 /* special macros */2929 /* special macros */
2930 if (tok == TOK___LINE__) {2930 if (tok == TOK___LINE__) {
@@ -2942,10 +2942,10 @@ static int macro_subst_tok( · 11 unmodified lines
2942 time(&ti);2942 time(&ti);
2943 tm = localtime(&ti);2943 tm = localtime(&ti);
2944 if (tok == TOK___DATE__) {2944 if (tok == TOK___DATE__) {
2945 snprintf(buf, sizeof(buf), "%s %2d %d", 2945 snprintf(buf, sizeof(buf), "%s %2d %d",
2946 ab_month_name[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900);2946 ab_month_name[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900);
2947 } else {2947 } else {
2948 snprintf(buf, sizeof(buf), "%02d:%02d:%02d", 2948 snprintf(buf, sizeof(buf), "%02d:%02d:%02d",
2949 tm->tm_hour, tm->tm_min, tm->tm_sec);2949 tm->tm_hour, tm->tm_min, tm->tm_sec);
2950 }2950 }
2951 cstrval = buf;2951 cstrval = buf;
@@ -3010,8 +3010,8 @@ static int macro_subst_tok( · 58 unmodified lines
3010 tok_str_new(&str);3010 tok_str_new(&str);
3011 parlevel = spc = 0;3011 parlevel = spc = 0;
3012 /* NOTE: non zero sa->t indicates VA_ARGS */3012 /* NOTE: non zero sa->t indicates VA_ARGS */
3013 while ((parlevel > 0 || 3013 while ((parlevel > 0 ||
3014 (tok != ')' && 3014 (tok != ')' &&
3015 (tok != ',' || sa->type.t)))) {3015 (tok != ',' || sa->type.t)))) {
3016 if (tok == TOK_EOF || tok == 0)3016 if (tok == TOK_EOF || tok == 0)
3017 break;3017 break;
@@ -3143,7 +3143,7 @@ static inline int *macro_twosharps(const int *ptr0) · 125 unmodified lines
3143 /* given 'a##b', remove nosubsts preceding 'b' */3143 /* given 'a##b', remove nosubsts preceding 'b' */
3144 while ((t1 = *++ptr) == TOK_NOSUBST)3144 while ((t1 = *++ptr) == TOK_NOSUBST)
3145 ;3145 ;
3146 if (t1 && t1 != TOK_TWOSHARPS 3146 if (t1 && t1 != TOK_TWOSHARPS
3147 && t1 != ':') /* 'a##:' don't build a new token */3147 && t1 != ':') /* 'a##:' don't build a new token */
3148 {3148 {
3149 TOK_GET(&t1, &ptr, &cv1);3149 TOK_GET(&t1, &ptr, &cv1);
@@ -3181,7 +3181,7 @@ static void macro_subst( · 31 unmodified lines
3181 int t, spc, nosubst;3181 int t, spc, nosubst;
3182 CValue cval;3182 CValue cval;
3183 int *macro_str1 = NULL;3183 int *macro_str1 = NULL;
3184 3184
3185 /* first scan for '##' operator handling */3185 /* first scan for '##' operator handling */
3186 ptr = macro_str;3186 ptr = macro_str;
3187 spc = nosubst = 0;3187 spc = nosubst = 0;
@@ -3334,7 +3334,7 @@ ST_FUNC void preprocess_new(void) · 146 unmodified lines
3334 : 0;3334 : 0;
3335 3335
3336 memset(hash_ident, 0, TOK_HASH_SIZE * sizeof(TokenSym *));3336 memset(hash_ident, 0, TOK_HASH_SIZE * sizeof(TokenSym *));
3337 3337
3338 tok_ident = TOK_IDENT;3338 tok_ident = TOK_IDENT;
3339 p = tcc_keywords;3339 p = tcc_keywords;
3340 while (*p) {3340 while (*p) {
tcctok.h+1−1
@@ -36,7 +36,7 @@ · 35 unmodified lines
36 DEF(TOK_RESTRICT2, "__restrict")36 DEF(TOK_RESTRICT2, "__restrict")
37 DEF(TOK_RESTRICT3, "__restrict__")37 DEF(TOK_RESTRICT3, "__restrict__")
38 DEF(TOK_EXTENSION, "__extension__") /* gcc keyword */38 DEF(TOK_EXTENSION, "__extension__") /* gcc keyword */
39 39
40 DEF(TOK_FLOAT, "float")40 DEF(TOK_FLOAT, "float")
41 DEF(TOK_DOUBLE, "double")41 DEF(TOK_DOUBLE, "double")
42 DEF(TOK_BOOL, "_Bool")42 DEF(TOK_BOOL, "_Bool")
tests/abitest.c+15−15
@@ -41,7 +41,7 @@ static int run_callback(const char *src, callback_type callback) { · 40 unmodified lines
41 TCCState *s;41 TCCState *s;
42 int result;42 int result;
43 void *ptr;43 void *ptr;
44 44
45 s = tcc_new();45 s = tcc_new();
46 if (!s)46 if (!s)
47 return -1;47 return -1;
@@ -54,14 +54,14 @@ static int run_callback(const char *src, callback_type callback) { · 6 unmodified lines
54 return -1;54 return -1;
55 if (tcc_relocate(s, TCC_RELOCATE_AUTO) == -1)55 if (tcc_relocate(s, TCC_RELOCATE_AUTO) == -1)
56 return -1;56 return -1;
57 57
58 ptr = tcc_get_symbol(s, "f");58 ptr = tcc_get_symbol(s, "f");
59 if (!ptr)59 if (!ptr)
60 return -1;60 return -1;
61 result = callback(ptr);61 result = callback(ptr);
62 62
63 tcc_delete(s);63 tcc_delete(s);
64 64
65 return result;65 return result;
66}66}
67 67
@@ -89,7 +89,7 @@ RET_PRIMITIVE_TEST(longdouble, LONG_DOUBLE, LONG_DOUBLE_LITERAL(378943892.0)) · 21 unmodified lines
89 89
90/*90/*
91 * ret_2float_test:91 * ret_2float_test:
92 * 92 *
93 * On x86-64, a struct with 2 floats should be packed into a single93 * On x86-64, a struct with 2 floats should be packed into a single
94 * SSE register (VT_DOUBLE is used for this purpose).94 * SSE register (VT_DOUBLE is used for this purpose).
95 */95 */
@@ -117,7 +117,7 @@ static int ret_2float_test(void) { · 21 unmodified lines
117 117
118/*118/*
119 * ret_2double_test:119 * ret_2double_test:
120 * 120 *
121 * On x86-64, a struct with 2 doubles should be passed in two SSE121 * On x86-64, a struct with 2 doubles should be passed in two SSE
122 * registers.122 * registers.
123 */123 */
@@ -281,7 +281,7 @@ static int reg_pack_test(void) { · 157 unmodified lines
281 " reg_pack_test_type r = {a.x*5, a.y*3};\n"281 " reg_pack_test_type r = {a.x*5, a.y*3};\n"
282 " return r;\n"282 " return r;\n"
283 "}\n";283 "}\n";
284 284
285 return run_callback(src, reg_pack_test_callback);285 return run_callback(src, reg_pack_test_callback);
286}286}
287 287
@@ -307,7 +307,7 @@ static int reg_pack_longlong_test(void) { · 19 unmodified lines
307 " reg_pack_longlong_test_type r = {a.x*5, a.y*3};\n"307 " reg_pack_longlong_test_type r = {a.x*5, a.y*3};\n"
308 " return r;\n"308 " return r;\n"
309 "}\n";309 "}\n";
310 310
311 return run_callback(src, reg_pack_longlong_test_callback);311 return run_callback(src, reg_pack_longlong_test_callback);
312}312}
313 313
@@ -365,13 +365,13 @@ static int sret_test(void) { · 51 unmodified lines
365 " sret_test_type r = {x.a*35, x.b*19, x.c*21};\n"365 " sret_test_type r = {x.a*35, x.b*19, x.c*21};\n"
366 " return r;\n"366 " return r;\n"
367 "}\n";367 "}\n";
368 368
369 return run_callback(src, sret_test_callback);369 return run_callback(src, sret_test_callback);
370}370}
371 371
372/*372/*
373 * one_member_union_test:373 * one_member_union_test:
374 * 374 *
375 * In the x86-64 ABI a union should always be passed on the stack. However375 * In the x86-64 ABI a union should always be passed on the stack. However
376 * it appears that a single member union is treated by GCC as its member.376 * it appears that a single member union is treated by GCC as its member.
377 */377 */
@@ -399,7 +399,7 @@ static int one_member_union_test(void) { · 21 unmodified lines
399 399
400/*400/*
401 * two_member_union_test:401 * two_member_union_test:
402 * 402 *
403 * In the x86-64 ABI a union should always be passed on the stack.403 * In the x86-64 ABI a union should always be passed on the stack.
404 */404 */
405typedef union two_member_union_test_type_u {int x; long y;} two_member_union_test_type;405typedef union two_member_union_test_type_u {int x; long y;} two_member_union_test_type;
@@ -430,7 +430,7 @@ static int two_member_union_test(void) { · 24 unmodified lines
430 430
431typedef struct many_struct_test_type_s {long long a, b, c;} many_struct_test_type;431typedef struct many_struct_test_type_s {long long a, b, c;} many_struct_test_type;
432typedef many_struct_test_type (*many_struct_test_function_type) (many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type);432typedef many_struct_test_type (*many_struct_test_function_type) (many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type);
433 433
434static int many_struct_test_callback(void *ptr) {434static int many_struct_test_callback(void *ptr) {
435 many_struct_test_function_type f = (many_struct_test_function_type)ptr;435 many_struct_test_function_type f = (many_struct_test_function_type)ptr;
436 many_struct_test_type v = {1, 2, 3};436 many_struct_test_type v = {1, 2, 3};
@@ -457,7 +457,7 @@ static int many_struct_test(void) { · 20 unmodified lines
457 457
458typedef struct many_struct_test_2_type_s {int a, b;} many_struct_test_2_type;458typedef struct many_struct_test_2_type_s {int a, b;} many_struct_test_2_type;
459typedef many_struct_test_2_type (*many_struct_test_2_function_type) (many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type);459typedef many_struct_test_2_type (*many_struct_test_2_function_type) (many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type);
460 460
461static int many_struct_test_2_callback(void *ptr) {461static int many_struct_test_2_callback(void *ptr) {
462 many_struct_test_2_function_type f = (many_struct_test_2_function_type)ptr;462 many_struct_test_2_function_type f = (many_struct_test_2_function_type)ptr;
463 many_struct_test_2_type v = {1,2};463 many_struct_test_2_type v = {1,2};
@@ -598,7 +598,7 @@ static int arg_align_test_callback(void *ptr) { · 134 unmodified lines
598}598}
599 599
600static int arg_align_test(void) {600static int arg_align_test(void) {
601 const char *src = 601 const char *src =
602 "long double f(long double a, int b, long double c, int d, long double e) {\n"602 "long double f(long double a, int b, long double c, int d, long double e) {\n"
603 " return a + c + e;\n"603 " return a + c + e;\n"
604 "}\n";604 "}\n";
@@ -621,7 +621,7 @@ int main(int argc, char **argv) { · 16 unmodified lines
621 int i;621 int i;
622 const char *testname = NULL;622 const char *testname = NULL;
623 int retval = EXIT_SUCCESS;623 int retval = EXIT_SUCCESS;
624 624
625 /* if tcclib.h and libtcc1.a are not installed, where can we find them */625 /* if tcclib.h and libtcc1.a are not installed, where can we find them */
626 for (i = 1; i < argc; ++i) {626 for (i = 1; i < argc; ++i) {
627 if (!memcmp(argv[i], "run_test=", 9))627 if (!memcmp(argv[i], "run_test=", 9))
tests/tcctest.c+58−58
@@ -320,7 +320,7 @@ void macro_test(void) · 319 unmodified lines
320#line 200320#line 200
321 printf("__LINE__=%d __FILE__=%s\n",321 printf("__LINE__=%d __FILE__=%s\n",
322 __LINE__, __FILE__);322 __LINE__, __FILE__);
323#line 203 "test" 323#line 203 "test"
324 printf("__LINE__=%d __FILE__=%s\n",324 printf("__LINE__=%d __FILE__=%s\n",
325 __LINE__, __FILE__);325 __LINE__, __FILE__);
326#line 227 "tcctest.c"326#line 227 "tcctest.c"
@@ -348,7 +348,7 @@ void macro_test(void) · 21 unmodified lines
348 glue(a <, <= 2);348 glue(a <, <= 2);
349 printf("a=%d\n", a);349 printf("a=%d\n", a);
350 }350 }
351 351
352 /* macro function with argument outside the macro string */352 /* macro function with argument outside the macro string */
353#define MF_s MF_hello353#define MF_s MF_hello
354#define MF_hello(msg) printf("%s\n",msg)354#define MF_hello(msg) printf("%s\n",msg)
@@ -357,7 +357,7 @@ void macro_test(void) · 2 unmodified lines
357 357
358 MF_s("hi");358 MF_s("hi");
359 MF_t("hi");359 MF_t("hi");
360 360
361 /* test macro substituion inside args (should not eat stream) */361 /* test macro substituion inside args (should not eat stream) */
362 printf("qq=%d\n", qq(qq)(2));362 printf("qq=%d\n", qq(qq)(2));
363 363
@@ -398,7 +398,7 @@ void recursive_macro_test(void) · 34 unmodified lines
398 printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));398 printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));
399 399
400#define WRAP(x) x400#define WRAP(x) x
401 401
402#define print_num(x) print_num(__FILE__,__LINE__,x)402#define print_num(x) print_num(__FILE__,__LINE__,x)
403 print_num(123);403 print_num(123);
404 WRAP(print_num(123));404 WRAP(print_num(123));
@@ -537,7 +537,7 @@ void goto_test() · 132 unmodified lines
537 /* This needs to parse as label, not as start of decl. */537 /* This needs to parse as label, not as start of decl. */
538 typedef_and_label:538 typedef_and_label:
539 s_loop:539 s_loop:
540 if (i >= 10) 540 if (i >= 10)
541 goto s_end;541 goto s_end;
542 printf("%d", i);542 printf("%d", i);
543 i++;543 i++;
@@ -688,7 +688,7 @@ int main(int argc, char **argv) · 144 unmodified lines
688 callsave_test();688 callsave_test();
689 builtin_frame_address_test();689 builtin_frame_address_test();
690 intdiv_test();690 intdiv_test();
691 return 0; 691 return 0;
692}692}
693 693
694int tab[3];694int tab[3];
@@ -797,10 +797,10 @@ void expr_test() · 102 unmodified lines
797 printf("%d\n", ~12);797 printf("%d\n", ~12);
798 printf("%d\n", -12);798 printf("%d\n", -12);
799 printf("%d\n", +12);799 printf("%d\n", +12);
800 printf("%d %d %d %d\n", 800 printf("%d %d %d %d\n",
801 isid('a'), 801 isid('a'),
802 isid('g'), 802 isid('g'),
803 isid('T'), 803 isid('T'),
804 isid('('));804 isid('('));
805}805}
806 806
@@ -984,7 +984,7 @@ void struct_test() · 177 unmodified lines
984 sizeof(struct aligntest3), __alignof__(struct aligntest3));984 sizeof(struct aligntest3), __alignof__(struct aligntest3));
985 printf("aligntest4 sizeof=%d alignof=%d\n",985 printf("aligntest4 sizeof=%d alignof=%d\n",
986 sizeof(struct aligntest4), __alignof__(struct aligntest4));986 sizeof(struct aligntest4), __alignof__(struct aligntest4));
987 987
988 /* empty structures (GCC extension) */988 /* empty structures (GCC extension) */
989 printf("sizeof(struct empty) = %d\n", sizeof(struct empty));989 printf("sizeof(struct empty) = %d\n", sizeof(struct empty));
990 printf("alignof(struct empty) = %d\n", __alignof__(struct empty));990 printf("alignof(struct empty) = %d\n", __alignof__(struct empty));
@@ -999,17 +999,17 @@ void char_short_test() · 8 unmodified lines
999 999
1000 var1 = 0x01020304;1000 var1 = 0x01020304;
1001 var2 = 0xfffefdfc;1001 var2 = 0xfffefdfc;
1002 printf("s8=%d %d\n", 1002 printf("s8=%d %d\n",
1003 *(char *)&var1, *(char *)&var2);1003 *(char *)&var1, *(char *)&var2);
1004 printf("u8=%d %d\n", 1004 printf("u8=%d %d\n",
1005 *(unsigned char *)&var1, *(unsigned char *)&var2);1005 *(unsigned char *)&var1, *(unsigned char *)&var2);
1006 printf("s16=%d %d\n", 1006 printf("s16=%d %d\n",
1007 *(short *)&var1, *(short *)&var2);1007 *(short *)&var1, *(short *)&var2);
1008 printf("u16=%d %d\n", 1008 printf("u16=%d %d\n",
1009 *(unsigned short *)&var1, *(unsigned short *)&var2);1009 *(unsigned short *)&var1, *(unsigned short *)&var2);
1010 printf("s32=%d %d\n", 1010 printf("s32=%d %d\n",
1011 *(int *)&var1, *(int *)&var2);1011 *(int *)&var1, *(int *)&var2);
1012 printf("u32=%d %d\n", 1012 printf("u32=%d %d\n",
1013 *(unsigned int *)&var1, *(unsigned int *)&var2);1013 *(unsigned int *)&var1, *(unsigned int *)&var2);
1014 *(char *)&var1 = 0x08;1014 *(char *)&var1 = 0x08;
1015 printf("var1=%x\n", var1);1015 printf("var1=%x\n", var1);
@@ -1099,7 +1099,7 @@ void bool_test() · 83 unmodified lines
1099 static int v1 = 34 ? : -1; /* constant case */1099 static int v1 = 34 ? : -1; /* constant case */
1100 static int v2 = 0 ? : -1; /* constant case */1100 static int v2 = 0 ? : -1; /* constant case */
1101 int a = 30;1101 int a = 30;
1102 1102
1103 printf("%d %d\n", v1, v2);1103 printf("%d %d\n", v1, v2);
1104 printf("%d %d\n", a - 30 ? : a * 2, a + 1 ? : a * 2);1104 printf("%d %d\n", a - 30 ? : a * 2, a + 1 ? : a * 2);
1105 }1105 }
@@ -1116,8 +1116,8 @@ static int tab_reinit[]; · 10 unmodified lines
1116static int tab_reinit[10];1116static int tab_reinit[10];
1117 1117
1118//int cinit1; /* a global variable can be defined several times without error ! */1118//int cinit1; /* a global variable can be defined several times without error ! */
1119int cinit1; 1119int cinit1;
1120int cinit1; 1120int cinit1;
1121int cinit1 = 0;1121int cinit1 = 0;
1122int *cinit2 = (int []){3, 2, 1};1122int *cinit2 = (int []){3, 2, 1};
1123 1123
@@ -1157,7 +1157,7 @@ void compound_literal_test(void) · 33 unmodified lines
1157 1157
1158 for(i=0;i<3;i++) {1158 for(i=0;i<3;i++) {
1159 p = (int []){1, 2, 4 + i};1159 p = (int []){1, 2, 4 + i};
1160 printf("%d %d %d\n", 1160 printf("%d %d %d\n",
1161 p[0],1161 p[0],
1162 p[1],1162 p[1],
1163 p[2]);1163 p[2]);
@@ -1188,7 +1188,7 @@ kr_test() · 24 unmodified lines
1188void num(int n)1188void num(int n)
1189{1189{
1190 char *tab, *p;1190 char *tab, *p;
1191 tab = (char*)malloc(20); 1191 tab = (char*)malloc(20);
1192 p = tab;1192 p = tab;
1193 while (1) {1193 while (1) {
1194 *p = 48 + (n % 10);1194 *p = 48 + (n % 10);
@@ -1231,7 +1231,7 @@ void struct_assign_test(void) · 36 unmodified lines
1231 struct structa1 lsta1, lsta2;1231 struct structa1 lsta1, lsta2;
1232 int i;1232 int i;
1233 } s, *ps;1233 } s, *ps;
1234 1234
1235 ps = &s;1235 ps = &s;
1236 ps->i = 4;1236 ps->i = 4;
1237#if 01237#if 0
@@ -1247,7 +1247,7 @@ void struct_assign_test(void) · 9 unmodified lines
1247 s.lsta2.f2 = 2;1247 s.lsta2.f2 = 2;
1248#endif1248#endif
1249 struct_assign_test1(ps->lsta2, 3, 4.5);1249 struct_assign_test1(ps->lsta2, 3, 4.5);
1250 1250
1251 printf("before call: %d %d\n", s.lsta2.f1, s.lsta2.f2);1251 printf("before call: %d %d\n", s.lsta2.f1, s.lsta2.f2);
1252 ps->lsta2 = struct_assign_test2(ps->lsta2, ps->i);1252 ps->lsta2 = struct_assign_test2(ps->lsta2, ps->i);
1253 printf("after call: %d %d\n", ps->lsta2.f1, ps->lsta2.f2);1253 printf("after call: %d %d\n", ps->lsta2.f1, ps->lsta2.f2);
@@ -1300,9 +1300,9 @@ void cast_test() · 46 unmodified lines
1300 printf("%d\n", a);1300 printf("%d\n", a);
1301 a = (scast = 65536) + 1;1301 a = (scast = 65536) + 1;
1302 printf("%d\n", a);1302 printf("%d\n", a);
1303 1303
1304 printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));1304 printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));
1305 1305
1306 /* test cast from unsigned to signed short to int */1306 /* test cast from unsigned to signed short to int */
1307 b = 0xf000;1307 b = 0xf000;
1308 d = (short)b;1308 d = (short)b;
@@ -1310,7 +1310,7 @@ void cast_test() · 1 unmodified line
1310 b = 0xf0f0;1310 b = 0xf0f0;
1311 d = (char)b;1311 d = (char)b;
1312 printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d);1312 printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d);
1313 1313
1314 /* test implicit int casting for array accesses */1314 /* test implicit int casting for array accesses */
1315 c = 0;1315 c = 0;
1316 tab[1] = 2;1316 tab[1] = 2;
@@ -1352,7 +1352,7 @@ char sinit8[] = "hello" "trala"; · 35 unmodified lines
1352 1352
1353struct structinit1 sinit9 = { 1, 2, 3 };1353struct structinit1 sinit9 = { 1, 2, 3 };
1354struct structinit1 sinit10 = { .f2 = 2, 3, .f1 = 1 };1354struct structinit1 sinit10 = { .f2 = 2, 3, .f1 = 1 };
1355struct structinit1 sinit11 = { .f2 = 2, 3, .f1 = 1, 1355struct structinit1 sinit11 = { .f2 = 2, 3, .f1 = 1,
1356#ifdef ALL_ISOC991356#ifdef ALL_ISOC99
1357 .farray[0] = 10,1357 .farray[0] = 10,
1358 .farray[1] = 11,1358 .farray[1] = 11,
@@ -1437,36 +1437,36 @@ void init_test(void) · 78 unmodified lines
1437 int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, };1437 int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, };
1438 struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 };1438 struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 };
1439 int linit17 = sizeof(linit17);1439 int linit17 = sizeof(linit17);
1440 1440
1441 printf("init_test:\n");1441 printf("init_test:\n");
1442 1442
1443 printf("sinit1=%d\n", sinit1);1443 printf("sinit1=%d\n", sinit1);
1444 printf("sinit2=%d\n", sinit2);1444 printf("sinit2=%d\n", sinit2);
1445 printf("sinit3=%d %d %d %d\n", 1445 printf("sinit3=%d %d %d %d\n",
1446 sizeof(sinit3),1446 sizeof(sinit3),
1447 sinit3[0],1447 sinit3[0],
1448 sinit3[1],1448 sinit3[1],
1449 sinit3[2]1449 sinit3[2]
1450 );1450 );
1451 printf("sinit6=%d\n", sizeof(sinit6));1451 printf("sinit6=%d\n", sizeof(sinit6));
1452 printf("sinit7=%d %d %d %d\n", 1452 printf("sinit7=%d %d %d %d\n",
1453 sizeof(sinit7),1453 sizeof(sinit7),
1454 sinit7[0],1454 sinit7[0],
1455 sinit7[1],1455 sinit7[1],
1456 sinit7[2]1456 sinit7[2]
1457 );1457 );
1458 printf("sinit8=%s\n", sinit8);1458 printf("sinit8=%s\n", sinit8);
1459 printf("sinit9=%d %d %d\n", 1459 printf("sinit9=%d %d %d\n",
1460 sinit9.f1,1460 sinit9.f1,
1461 sinit9.f2,1461 sinit9.f2,
1462 sinit9.f31462 sinit9.f3
1463 );1463 );
1464 printf("sinit10=%d %d %d\n", 1464 printf("sinit10=%d %d %d\n",
1465 sinit10.f1,1465 sinit10.f1,
1466 sinit10.f2,1466 sinit10.f2,
1467 sinit10.f31467 sinit10.f3
1468 );1468 );
1469 printf("sinit11=%d %d %d %d %d %d\n", 1469 printf("sinit11=%d %d %d %d %d %d\n",
1470 sinit11.f1,1470 sinit11.f1,
1471 sinit11.f2,1471 sinit11.f2,
1472 sinit11.f3,1472 sinit11.f3,
@@ -1477,7 +1477,7 @@ void init_test(void) · 4 unmodified lines
1477 1477
1478 for(i=0;i<3;i++)1478 for(i=0;i<3;i++)
1479 for(j=0;j<2;j++)1479 for(j=0;j<2;j++)
1480 printf("[%d][%d] = %d %d %d\n", 1480 printf("[%d][%d] = %d %d %d\n",
1481 i, j, sinit4[i][j], sinit5[i][j], linit4[i][j]);1481 i, j, sinit4[i][j], sinit5[i][j], linit4[i][j]);
1482 printf("linit1=%d\n", linit1);1482 printf("linit1=%d\n", linit1);
1483 printf("linit2=%d\n", linit2);1483 printf("linit2=%d\n", linit2);
@@ -1486,7 +1486,7 @@ void init_test(void) · 2 unmodified lines
1486 1486
1487 printf("sinit12=%s\n", sinit12);1487 printf("sinit12=%s\n", sinit12);
1488 printf("sinit13=%d %s %s %s\n",1488 printf("sinit13=%d %s %s %s\n",
1489 sizeof(sinit13), 1489 sizeof(sinit13),
1490 sinit13[0],1490 sinit13[0],
1491 sinit13[1],1491 sinit13[1],
1492 sinit13[2]);1492 sinit13[2]);
@@ -1500,7 +1500,7 @@ void init_test(void) · 7 unmodified lines
1500 printf("\n");1500 printf("\n");
1501 for(i=0;i<10;i++) printf(" %d", linit15[i]);1501 for(i=0;i<10;i++) printf(" %d", linit15[i]);
1502 printf("\n");1502 printf("\n");
1503 printf("%d %d %d %d\n", 1503 printf("%d %d %d %d\n",
1504 linit16.a1,1504 linit16.a1,
1505 linit16.a2,1505 linit16.a2,
1506 linit16.a3,1506 linit16.a3,
@@ -1599,13 +1599,13 @@ void bitfield_test(void) · 92 unmodified lines
1599 printf("%d %d\n", sa, ca);1599 printf("%d %d\n", sa, ca);
1600 1600
1601 st1.f1 = 7;1601 st1.f1 = 7;
1602 if (st1.f1 == -1) 1602 if (st1.f1 == -1)
1603 printf("st1.f1 == -1\n");1603 printf("st1.f1 == -1\n");
1604 else 1604 else
1605 printf("st1.f1 != -1\n");1605 printf("st1.f1 != -1\n");
1606 if (st1.f2 == -1) 1606 if (st1.f2 == -1)
1607 printf("st1.f2 == -1\n");1607 printf("st1.f2 == -1\n");
1608 else 1608 else
1609 printf("st1.f2 != -1\n");1609 printf("st1.f2 != -1\n");
1610 1610
1611 /* bit sizes below must be bigger than 32 since GCC doesn't allow1611 /* bit sizes below must be bigger than 32 since GCC doesn't allow
@@ -1835,7 +1835,7 @@ void lloptest(long long a, long long b) · 223 unmodified lines
1835 a + b,1835 a + b,
1836 a - b,1836 a - b,
1837 a * b);1837 a * b);
1838 1838
1839 if (b != 0) {1839 if (b != 0) {
1840 printf("arith1: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",1840 printf("arith1: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
1841 a / b,1841 a / b,
@@ -1856,7 +1856,7 @@ void lloptest(long long a, long long b) · 14 unmodified lines
1856 a > b,1856 a > b,
1857 a >= b,1857 a >= b,
1858 a <= b);1858 a <= b);
1859 1859
1860 printf("utest: %d %d %d %d %d %d\n",1860 printf("utest: %d %d %d %d %d %d\n",
1861 ua == ub,1861 ua == ub,
1862 ua != ub,1862 ua != ub,
@@ -1932,7 +1932,7 @@ long long llfunc1(int a) · 69 unmodified lines
1932}1932}
1933 1933
1934struct S {1934struct S {
1935 int id; 1935 int id;
1936 char item;1936 char item;
1937};1937};
1938 1938
@@ -1953,8 +1953,8 @@ void longlong_test(void) · 14 unmodified lines
1953 a = ia;1953 a = ia;
1954 b = ua;1954 b = ua;
1955 printf(LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", a, b);1955 printf(LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", a, b);
1956 printf(LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " %Lx\n", 1956 printf(LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " %Lx\n",
1957 (long long)1, 1957 (long long)1,
1958 (long long)-2,1958 (long long)-2,
1959 1LL,1959 1LL,
1960 0x1234567812345679);1960 0x1234567812345679);
@@ -2049,7 +2049,7 @@ void vprintf1(const char *fmt, ...) · 88 unmodified lines
2049 2049
2050 va_start(aq, fmt);2050 va_start(aq, fmt);
2051 va_copy(ap, aq);2051 va_copy(ap, aq);
2052 2052
2053 p = fmt;2053 p = fmt;
2054 for(;;) {2054 for(;;) {
2055 c = *p;2055 c = *p;
@@ -2250,10 +2250,10 @@ void c99_vla_test(int size1, int size2) · 194 unmodified lines
2250 int tab1[size][2], tab2[10][2];2250 int tab1[size][2], tab2[10][2];
2251 void *tab1_ptr, *tab2_ptr, *bad_ptr;2251 void *tab1_ptr, *tab2_ptr, *bad_ptr;
2252 2252
2253 /* "size" should have been 'captured' at tab1 declaration, 2253 /* "size" should have been 'captured' at tab1 declaration,
2254 so modifying it should have no effect on VLA behaviour. */2254 so modifying it should have no effect on VLA behaviour. */
2255 size = size-1;2255 size = size-1;
2256 2256
2257 printf("Test C99 VLA 1 (sizeof): ");2257 printf("Test C99 VLA 1 (sizeof): ");
2258 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");2258 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");
2259 tab1_ptr = tab1;2259 tab1_ptr = tab1;
@@ -2325,7 +2325,7 @@ void sizeof_test(void) · 65 unmodified lines
2325 t <<= 16;2325 t <<= 16;
2326 t <<= 16;2326 t <<= 16;
2327 t++;2327 t++;
2328 /* This checks that sizeof really can be used to manipulate 2328 /* This checks that sizeof really can be used to manipulate
2329 uintptr_t objects, without truncation. */2329 uintptr_t objects, without truncation. */
2330 t2 = t & -sizeof(uintptr_t);2330 t2 = t & -sizeof(uintptr_t);
2331 printf ("%lu %lu\n", t, t2);2331 printf ("%lu %lu\n", t, t2);
@@ -2358,15 +2358,15 @@ void statement_expr_test(void) · 26 unmodified lines
2358 2358
2359 a = 0;2359 a = 0;
2360 for(i=0;i<10;i++) {2360 for(i=0;i<10;i++) {
2361 a += 1 + 2361 a += 1 +
2362 ( { int b, j; 2362 ( { int b, j;
2363 b = 0; 2363 b = 0;
2364 for(j=0;j<5;j++) 2364 for(j=0;j<5;j++)
2365 b += j; b; 2365 b += j; b;
2366 } );2366 } );
2367 }2367 }
2368 printf("a=%d\n", a);2368 printf("a=%d\n", a);
2369 2369
2370}2370}
2371 2371
2372void local_label_test(void)2372void local_label_test(void)
@@ -2589,7 +2589,7 @@ void builtin_test(void) · 216 unmodified lines
2589 COMPAT_TYPE(char *, signed char *);2589 COMPAT_TYPE(char *, signed char *);
2590 COMPAT_TYPE(char *, char *);2590 COMPAT_TYPE(char *, char *);
2591/* space is needed because tcc preprocessor introduces a space between each token */2591/* space is needed because tcc preprocessor introduces a space between each token */
2592 COMPAT_TYPE(char * *, void *); 2592 COMPAT_TYPE(char * *, void *);
2593#endif2593#endif
2594 printf("res = %d\n", __builtin_constant_p(1));2594 printf("res = %d\n", __builtin_constant_p(1));
2595 printf("res = %d\n", __builtin_constant_p(1 + 2));2595 printf("res = %d\n", __builtin_constant_p(1 + 2));
@@ -2640,7 +2640,7 @@ void __attribute__((weak)) weak_test(void) · 44 unmodified lines
2640 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);2640 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);
2641 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);2641 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);
2642 printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);2642 printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);
2643 2643
2644 printf("weak_asm_f1=%d\n", weak_asm_f1 != NULL);2644 printf("weak_asm_f1=%d\n", weak_asm_f1 != NULL);
2645 printf("weak_asm_f2=%d\n", weak_asm_f2 != NULL);2645 printf("weak_asm_f2=%d\n", weak_asm_f2 != NULL);
2646 printf("weak_asm_f3=%d\n", weak_asm_f3 != NULL);2646 printf("weak_asm_f3=%d\n", weak_asm_f3 != NULL);
texi2pod.pl+1−1
@@ -229,7 +229,7 @@ while(<$inf>) { · 228 unmodified lines
229 $inf = gensym();229 $inf = gensym();
230 230
231 # Try cwd and $ibase.231 # Try cwd and $ibase.
232 open($inf, "<" . $1) 232 open($inf, "<" . $1)
233 or open($inf, "<" . $ibase . "/" . $1)233 or open($inf, "<" . $ibase . "/" . $1)
234 or die "cannot open $1 or $ibase/$1: $!\n";234 or die "cannot open $1 or $ibase/$1: $!\n";
235 next;235 next;
x86_64-gen.c+30−30
@@ -681,7 +681,7 @@ ST_FUNC void gen_bounded_ptr_add(void) · 680 unmodified lines
681 681
682 682
683 /* relocation offset of the bounding function call point */683 /* relocation offset of the bounding function call point */
684 vtop->c.ull = (cur_text_section->reloc->data_offset - sizeof(ElfW(Rela))); 684 vtop->c.ull = (cur_text_section->reloc->data_offset - sizeof(ElfW(Rela)));
685}685}
686 686
687/* patch pointer addition in vtop so that pointer dereferencing is687/* patch pointer addition in vtop so that pointer dereferencing is
@@ -823,7 +823,7 @@ void gfunc_call(int nb_args) · 135 unmodified lines
823 struct_size = args_size;823 struct_size = args_size;
824 for(i = 0; i < nb_args; i++) {824 for(i = 0; i < nb_args; i++) {
825 SValue *sv;825 SValue *sv;
826 826
827 --arg;827 --arg;
828 sv = &vtop[-i];828 sv = &vtop[-i];
829 bt = (sv->type.t & VT_BTYPE);829 bt = (sv->type.t & VT_BTYPE);
@@ -897,7 +897,7 @@ void gfunc_call(int nb_args) · 67 unmodified lines
897 vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT897 vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT
898 : size > 1 ? VT_SHORT : VT_BYTE;898 : size > 1 ? VT_SHORT : VT_BYTE;
899 }899 }
900 900
901 r = gv(RC_INT);901 r = gv(RC_INT);
902 if (arg >= REGN) {902 if (arg >= REGN) {
903 gen_offs_sp(0x89, r, arg*8);903 gen_offs_sp(0x89, r, arg*8);
@@ -911,7 +911,7 @@ void gfunc_call(int nb_args) · 7 unmodified lines
911 vtop--;911 vtop--;
912 }912 }
913 save_regs(0);913 save_regs(0);
914 914
915 /* Copy R10 and R11 into RCX and RDX, respectively */915 /* Copy R10 and R11 into RCX and RDX, respectively */
916 if (nb_args > 0) {916 if (nb_args > 0) {
917 o(0xd1894c); /* mov %r10, %rcx */917 o(0xd1894c); /* mov %r10, %rcx */
@@ -919,7 +919,7 @@ void gfunc_call(int nb_args) · 1 unmodified line
919 o(0xda894c); /* mov %r11, %rdx */919 o(0xda894c); /* mov %r11, %rdx */
920 }920 }
921 }921 }
922 922
923 gcall_or_jmp(0);923 gcall_or_jmp(0);
924 vtop--;924 vtop--;
925}925}
@@ -1072,10 +1072,10 @@ static X86_64_Mode classify_x86_64_inner(CType *ty, int offset, int start, int e · 146 unmodified lines
1072{1072{
1073 X86_64_Mode mode;1073 X86_64_Mode mode;
1074 Sym *f;1074 Sym *f;
1075 1075
1076 switch (ty->t & VT_BTYPE) {1076 switch (ty->t & VT_BTYPE) {
1077 case VT_VOID: return x86_64_mode_none;1077 case VT_VOID: return x86_64_mode_none;
1078 1078
1079 case VT_INT:1079 case VT_INT:
1080 case VT_BYTE:1080 case VT_BYTE:
1081 case VT_SHORT:1081 case VT_SHORT:
@@ -1084,12 +1084,12 @@ static X86_64_Mode classify_x86_64_inner(CType *ty, int offset, int start, int e · 2 unmodified lines
1084 case VT_PTR:1084 case VT_PTR:
1085 case VT_FUNC:1085 case VT_FUNC:
1086 case VT_ENUM: return x86_64_mode_integer;1086 case VT_ENUM: return x86_64_mode_integer;
1087 1087
1088 case VT_FLOAT:1088 case VT_FLOAT:
1089 case VT_DOUBLE: return x86_64_mode_sse;1089 case VT_DOUBLE: return x86_64_mode_sse;
1090 1090
1091 case VT_LDOUBLE: return x86_64_mode_x87;1091 case VT_LDOUBLE: return x86_64_mode_x87;
1092 1092
1093 case VT_STRUCT:1093 case VT_STRUCT:
1094 f = ty->ref;1094 f = ty->ref;
1095 1095
@@ -1098,10 +1098,10 @@ static X86_64_Mode classify_x86_64_inner(CType *ty, int offset, int start, int e · 2 unmodified lines
1098 if (f->c + offset >= start && f->c + offset < end)1098 if (f->c + offset >= start && f->c + offset < end)
1099 mode = classify_x86_64_merge(mode, classify_x86_64_inner(&f->type, f->c + offset, start, end));1099 mode = classify_x86_64_merge(mode, classify_x86_64_inner(&f->type, f->c + offset, start, end));
1100 }1100 }
1101 1101
1102 return mode;1102 return mode;
1103 }1103 }
1104 1104
1105 assert(0);1105 assert(0);
1106}1106}
1107 1107
@@ -1305,7 +1305,7 @@ void gfunc_call(int nb_args) · 197 unmodified lines
1305 args_size = 0;1305 args_size = 0;
1306 while (run_start != nb_args) {1306 while (run_start != nb_args) {
1307 int run_gen_reg = gen_reg, run_sse_reg = sse_reg;1307 int run_gen_reg = gen_reg, run_sse_reg = sse_reg;
1308 1308
1309 run_end = nb_args;1309 run_end = nb_args;
1310 stack_adjust = 0;1310 stack_adjust = 0;
1311 for(i = run_start; (i < nb_args) && (run_end == nb_args); i++) {1311 for(i = run_start; (i < nb_args) && (run_end == nb_args); i++) {
@@ -1319,10 +1319,10 @@ void gfunc_call(int nb_args) · 7 unmodified lines
1319 stack_adjust += size;1319 stack_adjust += size;
1320 }1320 }
1321 }1321 }
1322 1322
1323 gen_reg = run_gen_reg;1323 gen_reg = run_gen_reg;
1324 sse_reg = run_sse_reg;1324 sse_reg = run_sse_reg;
1325 1325
1326 /* adjust stack to align SSE boundary */1326 /* adjust stack to align SSE boundary */
1327 if (stack_adjust &= 15) {1327 if (stack_adjust &= 15) {
1328 /* fetch cpu flag before the following sub will change the value */1328 /* fetch cpu flag before the following sub will change the value */
@@ -1334,7 +1334,7 @@ void gfunc_call(int nb_args) · 5 unmodified lines
1334 oad(0xec81, stack_adjust); /* sub $xxx, %rsp */1334 oad(0xec81, stack_adjust); /* sub $xxx, %rsp */
1335 args_size += stack_adjust;1335 args_size += stack_adjust;
1336 }1336 }
1337 1337
1338 for(i = run_start; i < run_end;) {1338 for(i = run_start; i < run_end;) {
1339 int arg_stored = regargs_nregs(&reg_args[i]) == 0;1339 int arg_stored = regargs_nregs(&reg_args[i]) == 0;
1340 SValue tmp;1340 SValue tmp;
@@ -1344,7 +1344,7 @@ void gfunc_call(int nb_args) · 3 unmodified lines
1344 ++i;1344 ++i;
1345 continue;1345 continue;
1346 }1346 }
1347 1347
1348 /* Swap argument to top, it will possibly be changed here,1348 /* Swap argument to top, it will possibly be changed here,
1349 and might use more temps. At the end of the loop we keep1349 and might use more temps. At the end of the loop we keep
1350 in on the stack and swap it back to its original position1350 in on the stack and swap it back to its original position
@@ -1352,7 +1352,7 @@ void gfunc_call(int nb_args) · 1 unmodified line
1352 tmp = vtop[0];1352 tmp = vtop[0];
1353 vtop[0] = vtop[-i];1353 vtop[0] = vtop[-i];
1354 vtop[-i] = tmp;1354 vtop[-i] = tmp;
1355 1355
1356 classify_x86_64_arg(&vtop->type, NULL, &size, &align, &args);1356 classify_x86_64_arg(&vtop->type, NULL, &size, &align, &args);
1357 1357
1358 switch (vtop->type.t & VT_BTYPE) {1358 switch (vtop->type.t & VT_BTYPE) {
@@ -1369,11 +1369,11 @@ void gfunc_call(int nb_args) · 10 unmodified lines
1369 vstore();1369 vstore();
1370 args_size += size;1370 args_size += size;
1371 break;1371 break;
1372 1372
1373 case VT_LDOUBLE:1373 case VT_LDOUBLE:
1374 assert(0);1374 assert(0);
1375 break;1375 break;
1376 1376
1377 case VT_FLOAT:1377 case VT_FLOAT:
1378 case VT_DOUBLE:1378 case VT_DOUBLE:
1379 r = gv(RC_FLOAT);1379 r = gv(RC_FLOAT);
@@ -1384,7 +1384,7 @@ void gfunc_call(int nb_args) · 4 unmodified lines
1384 o(0x24);1384 o(0x24);
1385 args_size += size;1385 args_size += size;
1386 break;1386 break;
1387 1387
1388 default:1388 default:
1389 /* simple type */1389 /* simple type */
1390 /* XXX: implicit cast ? */1390 /* XXX: implicit cast ? */
@@ -1417,7 +1417,7 @@ void gfunc_call(int nb_args) · 26 unmodified lines
1417 break;1417 break;
1418 1418
1419 vrotb(i+1);1419 vrotb(i+1);
1420 1420
1421 if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {1421 if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
1422 gv(RC_ST0);1422 gv(RC_ST0);
1423 oad(0xec8148, size); /* sub $xxx, %rsp */1423 oad(0xec8148, size); /* sub $xxx, %rsp */
@@ -1440,7 +1440,7 @@ void gfunc_call(int nb_args) · 16 unmodified lines
1440 vstore();1440 vstore();
1441 args_size += size;1441 args_size += size;
1442 }1442 }
1443 1443
1444 vpop();1444 vpop();
1445 memmove(reg_args + i, reg_args + i + 1, (nb_args - i - 1) * sizeof *reg_args);1445 memmove(reg_args + i, reg_args + i + 1, (nb_args - i - 1) * sizeof *reg_args);
1446 --nb_args;1446 --nb_args;
@@ -1698,7 +1698,7 @@ void gfunc_prolog(CType *func_type) · 251 unmodified lines
1698 addr += size;1698 addr += size;
1699 }1699 }
1700 break;1700 break;
1701 1701
1702 case x86_64_mode_memory:1702 case x86_64_mode_memory:
1703 case x86_64_mode_x87:1703 case x86_64_mode_x87:
1704 addr = (addr + align - 1) & -align;1704 addr = (addr + align - 1) & -align;
@@ -2104,7 +2104,7 @@ void gen_opf(int op) · 399 unmodified lines
2104 vswap();2104 vswap();
2105 }2105 }
2106 assert(!(vtop[-1].r & VT_LVAL));2106 assert(!(vtop[-1].r & VT_LVAL));
2107 2107
2108 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)2108 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
2109 o(0x66);2109 o(0x66);
2110 if (op == TOK_EQ || op == TOK_NE)2110 if (op == TOK_EQ || op == TOK_NE)
@@ -2141,7 +2141,7 @@ void gen_opf(int op) · 30 unmodified lines
2141 ft = vtop->type.t;2141 ft = vtop->type.t;
2142 fc = vtop->c.ul;2142 fc = vtop->c.ul;
2143 assert((ft & VT_BTYPE) != VT_LDOUBLE);2143 assert((ft & VT_BTYPE) != VT_LDOUBLE);
2144 2144
2145 r = vtop->r;2145 r = vtop->r;
2146 /* if saved lvalue, then we must reload it */2146 /* if saved lvalue, then we must reload it */
2147 if ((vtop->r & VT_VALMASK) == VT_LLOCAL) {2147 if ((vtop->r & VT_VALMASK) == VT_LLOCAL) {
@@ -2153,14 +2153,14 @@ void gen_opf(int op) · 5 unmodified lines
2153 load(r, &v1);2153 load(r, &v1);
2154 fc = 0;2154 fc = 0;
2155 }2155 }
2156 2156
2157 assert(!(vtop[-1].r & VT_LVAL));2157 assert(!(vtop[-1].r & VT_LVAL));
2158 if (swapped) {2158 if (swapped) {
2159 assert(vtop->r & VT_LVAL);2159 assert(vtop->r & VT_LVAL);
2160 gv(RC_FLOAT);2160 gv(RC_FLOAT);
2161 vswap();2161 vswap();
2162 }2162 }
2163 2163
2164 if ((ft & VT_BTYPE) == VT_DOUBLE) {2164 if ((ft & VT_BTYPE) == VT_DOUBLE) {
2165 o(0xf2);2165 o(0xf2);
2166 } else {2166 } else {
@@ -2168,7 +2168,7 @@ void gen_opf(int op) · 1 unmodified line
2168 }2168 }
2169 o(0x0f);2169 o(0x0f);
2170 o(0x58 + a);2170 o(0x58 + a);
2171 2171
2172 if (vtop->r & VT_LVAL) {2172 if (vtop->r & VT_LVAL) {
2173 gen_modrm(vtop[-1].r, r, vtop->sym, fc);2173 gen_modrm(vtop[-1].r, r, vtop->sym, fc);
2174 } else {2174 } else {
@@ -2231,7 +2231,7 @@ void gen_cvt_ftof(int t) · 56 unmodified lines
2231 ft = vtop->type.t;2231 ft = vtop->type.t;
2232 bt = ft & VT_BTYPE;2232 bt = ft & VT_BTYPE;
2233 tbt = t & VT_BTYPE;2233 tbt = t & VT_BTYPE;
2234 2234
2235 if (bt == VT_FLOAT) {2235 if (bt == VT_FLOAT) {
2236 gv(RC_FLOAT);2236 gv(RC_FLOAT);
2237 if (tbt == VT_DOUBLE) {2237 if (tbt == VT_DOUBLE) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t