mirror of
git://repo.or.cz/tinycc.git
synced 2026-07-10 21:38:47 +08:00
Some more TLS changes
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-arm64-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
build and test / test-i386-linux (push) Has been cancelled
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-arm64-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
build and test / test-i386-linux (push) Has been cancelled
tccgen.c: remove VT_TLS in gen_cast libtcc.c: remove warning for gcc 16 i386-gen.c: fix gen_modrm for VT_LDOUBLE riscv64-gen.c: add fc to TLS address x86_64-gen.c: add TLS prefix in gen_opf tests2/144_tls.c/tests2/144_tls.expect: updated test case tests/tests2/Makefile skip TLS test for BSD
This commit is contained in:
parent
b895aa7e68
commit
04206d2903
@ -242,6 +242,8 @@ static void gen_modrm(int opc, int op_r2, int r, Sym *sym, int c)
|
||||
int op_reg = REG_VALUE(op_r2) << 3;
|
||||
|
||||
if ((r & VT_SYM) && (sym->type.t & VT_TLS)) {
|
||||
if (opc == 0xdbc0d9) // VT_LDOUBLE
|
||||
o(0xc0d9), opc = 0xdb;
|
||||
o(0x65); /* gs segment prefix */
|
||||
o(opc);
|
||||
oad(0x05 | op_reg, c);
|
||||
|
||||
2
libtcc.c
2
libtcc.c
@ -194,7 +194,7 @@ ST_FUNC char *pstrncpy(char *out, size_t buf_size, const char *s, size_t num)
|
||||
/* extract the basename of a file */
|
||||
PUB_FUNC char *tcc_basename(const char *name)
|
||||
{
|
||||
char *p = strchr(name, 0);
|
||||
char *p = (char *)strchr(name, 0);
|
||||
while (p > name && !IS_DIRSEP(p[-1]))
|
||||
--p;
|
||||
return p;
|
||||
|
||||
@ -188,6 +188,8 @@ static int load_symofs(int r, SValue *sv, int forstore, int *new_fc)
|
||||
greloca(cur_text_section, sv->sym, ind,
|
||||
R_RISCV_TPREL_LO12_I, 0);
|
||||
EI(0x13, 0, rr, rr, 0); // addi RR, RR, 0 %tprel_lo(sym)
|
||||
if (fc)
|
||||
EI(0x13, 0, rr, rr, fc); // addi RR, RR, fc
|
||||
ER(0x33, 0, rr, rr, 4, 0); // add RR, RR, tp
|
||||
*new_fc = 0;
|
||||
return rr;
|
||||
|
||||
2
tccgen.c
2
tccgen.c
@ -3487,7 +3487,7 @@ error:
|
||||
}
|
||||
done:
|
||||
vtop->type = *type;
|
||||
vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY );
|
||||
vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY | VT_TLS );
|
||||
}
|
||||
|
||||
/* return type size as known at compile time. Put alignment at 'a' */
|
||||
|
||||
@ -1,50 +1,87 @@
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
__thread int tls_init = 42;
|
||||
#define CHECK(var,fmt,val) printf(fmt "\n",var); if (var != val) errors = 1
|
||||
|
||||
typedef enum { tls_a, tls_b, tls_c } tls_enum_type;
|
||||
typedef struct { int tls_d, tls_e, tls_f; } tls_struct_type;
|
||||
|
||||
__thread char tls_char = 42;
|
||||
__thread short tls_short = 43;
|
||||
__thread int tls_init = 44;
|
||||
__thread long long tls_long_long = 45;
|
||||
__thread int tls_zero;
|
||||
__thread float tls_float = 46.0;
|
||||
__thread double tls_double = 47.0;
|
||||
__thread long double tls_long_double = 48.0;
|
||||
__thread int *tls_ptr = (int *)49;
|
||||
__thread tls_enum_type tls_enum = tls_b;
|
||||
__thread tls_struct_type tls_struct = { 50, 51, 52 };
|
||||
|
||||
static int check(void)
|
||||
{
|
||||
int errors = 0;
|
||||
|
||||
CHECK(tls_char, "%d", 42);
|
||||
CHECK(tls_short, "%d", 43);
|
||||
CHECK(tls_init, "%d", 44);
|
||||
CHECK(tls_long_long, "%lld", 45);
|
||||
CHECK(tls_zero, "%d", 0);
|
||||
CHECK(tls_float, "%g", 46.0);
|
||||
CHECK(tls_double, "%g", 47.0);
|
||||
CHECK(tls_long_double, "%Lg", 48.0);
|
||||
CHECK(tls_ptr, "%p", (int *)49);
|
||||
CHECK(tls_enum, "%d", tls_b);
|
||||
CHECK(tls_struct.tls_d, "%d", 50);
|
||||
CHECK(tls_struct.tls_e, "%d", 51);
|
||||
CHECK(tls_struct.tls_f, "%d", 52);
|
||||
return errors;
|
||||
}
|
||||
|
||||
static void *thread_func(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
long errors = check();
|
||||
|
||||
printf("%d\n", tls_init);
|
||||
if (tls_init != 42) return (void *)1;
|
||||
tls_char = 10;
|
||||
tls_short = 20;
|
||||
tls_init = 30;
|
||||
tls_long_long = 40;
|
||||
tls_zero = 50;
|
||||
tls_float = 60.0;
|
||||
tls_double = 70.0;
|
||||
tls_long_double = 80.0;
|
||||
tls_ptr = (int *)90;
|
||||
tls_enum = tls_c;
|
||||
tls_struct.tls_d = 100;
|
||||
tls_struct.tls_e = 110;
|
||||
tls_struct.tls_f = 120;
|
||||
|
||||
printf("%d\n", tls_zero);
|
||||
if (tls_zero != 0) return (void *)1;
|
||||
CHECK(tls_char, "%d", 10);
|
||||
CHECK(tls_short, "%d", 20);
|
||||
CHECK(tls_init, "%d", 30);
|
||||
CHECK(tls_long_long, "%lld", 40);
|
||||
CHECK(tls_zero, "%d", 50);
|
||||
CHECK(tls_float, "%g", 60.0);
|
||||
CHECK(tls_double, "%g", 70.0);
|
||||
CHECK(tls_long_double, "%Lg", 80.0);
|
||||
CHECK(tls_enum, "%d", tls_c);
|
||||
CHECK(tls_ptr, "%p", (int *)90);
|
||||
CHECK(tls_struct.tls_d, "%d", 100);
|
||||
CHECK(tls_struct.tls_e, "%d", 110);
|
||||
CHECK(tls_struct.tls_f, "%d", 120);
|
||||
|
||||
tls_init = 100;
|
||||
tls_zero = 200;
|
||||
|
||||
printf("%d\n", tls_init);
|
||||
printf("%d\n", tls_zero);
|
||||
|
||||
return (void *)0;
|
||||
return (void *)errors;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
pthread_t t;
|
||||
void *ret;
|
||||
int errors = 0;
|
||||
|
||||
printf("%d\n", tls_init);
|
||||
if (tls_init != 42) errors = 1;
|
||||
|
||||
printf("%d\n", tls_zero);
|
||||
if (tls_zero != 0) errors = 1;
|
||||
int errors = check();
|
||||
|
||||
pthread_create(&t, NULL, thread_func, NULL);
|
||||
pthread_join(t, &ret);
|
||||
|
||||
if (ret) errors = 1;
|
||||
|
||||
printf("%d\n", tls_init);
|
||||
if (tls_init != 42) errors = 1;
|
||||
|
||||
printf("%d\n", tls_zero);
|
||||
if (tls_zero != 0) errors = 1;
|
||||
|
||||
return errors;
|
||||
return (ret ? 1 : 0) | errors | check();
|
||||
}
|
||||
|
||||
@ -1,8 +1,52 @@
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
0
|
||||
46
|
||||
47
|
||||
48
|
||||
0x31
|
||||
1
|
||||
50
|
||||
51
|
||||
52
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
0
|
||||
46
|
||||
47
|
||||
48
|
||||
0x31
|
||||
1
|
||||
50
|
||||
51
|
||||
52
|
||||
10
|
||||
20
|
||||
30
|
||||
40
|
||||
50
|
||||
60
|
||||
70
|
||||
80
|
||||
2
|
||||
0x5a
|
||||
100
|
||||
200
|
||||
110
|
||||
120
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
0
|
||||
46
|
||||
47
|
||||
48
|
||||
0x31
|
||||
1
|
||||
50
|
||||
51
|
||||
52
|
||||
|
||||
@ -53,6 +53,7 @@ ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS)))
|
||||
SKIP += 106_versym.test # no pthread_condattr_setpshared
|
||||
SKIP += 114_bound_signal.test # libc problem signal/fork
|
||||
SKIP += 116_bound_setjmp2.test # No TLS_FUNC/TLS_VAR in bcheck.c
|
||||
SKIP += 144_tls.test # No tls support
|
||||
endif
|
||||
ifeq ($(CONFIG_OSX),yes)
|
||||
SKIP += 144_tls.test # TLS runtime not supported on Mach-O
|
||||
|
||||
@ -1932,6 +1932,9 @@ void gen_opf(int op)
|
||||
}
|
||||
assert(!(vtop[-1].r & VT_LVAL));
|
||||
|
||||
if ((vtop->r & VT_SYM) && (vtop->sym->type.t & VT_TLS))
|
||||
o(0x64); /* fs segment prefix */
|
||||
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
|
||||
o(0x66);
|
||||
if (op == TOK_EQ || op == TOK_NE)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user