History

win64: fix va_arg

fixes 5c35ba66c5ade4713bbd9c005e66889f6d7db293 Implementation was consistent within tcc but incompatible with the ABI (for example library functions vprintf etc) Also: - tccpp.c/get_tok_str() : avoid "unknown format "%llu" warning - x86_64_gen.c/gen_vla_alloc() : fix vstack leak

grischka committed 10 years ago

Commit 41349941 parent 03609055 files · +12 −5Browse files

Unified · Split

5 files
  1. include/stdarg.h +2 −1
  2. tccgen.c +1 −0
  3. tccpp.c +0 −3
  4. tests/tcctest.c +9 −0
  5. x86_64-gen.c +0 −1
include/stdarg.h+2−1
@@ -30,7 +30,8 @@ void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align); · 29 unmodified lines
30#else /* _WIN64 */30#else /* _WIN64 */
31typedef char *va_list;31typedef char *va_list;
32#define va_start(ap,last) __builtin_va_start(ap,last)32#define va_start(ap,last) __builtin_va_start(ap,last)
33#define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap)33#define va_arg(ap, t) ((sizeof(t) > 8 || (sizeof(t) & (sizeof(t) - 1))) \
34 ? **(t **)((ap += 8) - 8) : *(t *)((ap += 8) - 8))
34#define va_copy(dest, src) ((dest) = (src))35#define va_copy(dest, src) ((dest) = (src))
35#define va_end(ap)36#define va_end(ap)
36#endif37#endif
tccgen.c+1−0
@@ -4033,6 +4033,7 @@ ST_FUNC void unary(void) · 4032 unmodified lines
4033 tcc_error("__builtin_va_start expects a local variable");4033 tcc_error("__builtin_va_start expects a local variable");
4034 vtop->r &= ~(VT_LVAL | VT_REF);4034 vtop->r &= ~(VT_LVAL | VT_REF);
4035 vtop->type = char_pointer_type;4035 vtop->type = char_pointer_type;
4036 vtop->c.i += 8;
4036 vstore();4037 vstore();
4037 }4038 }
4038 break;4039 break;
tccpp.c+0−3
@@ -464,9 +464,6 @@ ST_FUNC const char *get_tok_str(int v, CValue *cv) · 463 unmodified lines
464 switch(v) {464 switch(v) {
465 case TOK_CINT:465 case TOK_CINT:
466 case TOK_CUINT:466 case TOK_CUINT:
467 /* XXX: not quite exact, but only useful for testing */
468 sprintf(p, "%llu", (unsigned long long)cv->i);
469 break;
470 case TOK_CLLONG:467 case TOK_CLLONG:
471 case TOK_CULLONG:468 case TOK_CULLONG:
472 /* XXX: not quite exact, but only useful for testing */469 /* XXX: not quite exact, but only useful for testing */
tests/tcctest.c+9−0
@@ -2116,6 +2116,14 @@ void stdarg_for_struct(struct myspace bob, ...) · 2115 unmodified lines
2116 va_end(ap);2116 va_end(ap);
2117}2117}
2118 2118
2119void stdarg_for_libc(const char *fmt, ...)
2120{
2121 va_list args;
2122 va_start(args, fmt);
2123 vprintf(fmt, args);
2124 va_end(args);
2125}
2126
2119void stdarg_test(void)2127void stdarg_test(void)
2120{2128{
2121 LONG_DOUBLE ld = 1234567891234LL;2129 LONG_DOUBLE ld = 1234567891234LL;
@@ -2162,6 +2170,7 @@ void stdarg_test(void) · 40 unmodified lines
2162 2170
2163 bob.profile = 42;2171 bob.profile = 42;
2164 stdarg_for_struct(bob, bob, bob, bob.profile);2172 stdarg_for_struct(bob, bob, bob, bob.profile);
2173 stdarg_for_libc("stdarg_for_libc: %s %.2f %d\n", "string", 1.23, 456);
2165}2174}
2166 2175
2167void whitespace_test(void)2176void whitespace_test(void)
x86_64-gen.c+0−1
@@ -2228,7 +2228,6 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) { · 2227 unmodified lines
2228 vpush_global_sym(&func_old_type, TOK_alloca);2228 vpush_global_sym(&func_old_type, TOK_alloca);
2229 vswap(); /* Move alloca ref past allocation size */2229 vswap(); /* Move alloca ref past allocation size */
2230 gfunc_call(1);2230 gfunc_call(1);
2231 vset(type, REG_IRET, 0);
2232#else2231#else
2233 int r;2232 int r;
2234 r = gv(RC_INT); /* allocation size */2233 r = gv(RC_INT); /* allocation size */

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