mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
Update attribute bound_no_checking
tcctok.h: - Add CONFIG_TCC_BCHECK arround TOK_NO_BOUND_CHECK1/TOK_NO_BOUND_CHECK2 tccgen.c: - Add CONFIG_TCC_BCHECK arround TOK_NO_BOUND_CHECK1/TOK_NO_BOUND_CHECK2 - Undo alias definition in tccpp.c when function bound checking if off tests/tests2/114_bound_signal.c: - Test alias undo - fix sleep problem
This commit is contained in:
parent
c740fa2795
commit
4c9e3a5988
25
tccgen.c
25
tccgen.c
@ -4124,10 +4124,12 @@ redo:
|
||||
case TOK_ALWAYS_INLINE2:
|
||||
ad->f.func_alwinl = 1;
|
||||
break;
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
case TOK_NO_BOUND_CHECK1:
|
||||
case TOK_NO_BOUND_CHECK2:
|
||||
ad->f.no_bcheck = 1;
|
||||
break;
|
||||
#endif
|
||||
case TOK_SECTION1:
|
||||
case TOK_SECTION2:
|
||||
skip('(');
|
||||
@ -5960,6 +5962,26 @@ special_math_val:
|
||||
if (t < TOK_UIDENT)
|
||||
expect("identifier");
|
||||
s = sym_find(t);
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
/* HACK to undo alias definition in tccpp.c
|
||||
if function has no bound checking */
|
||||
if (tcc_state->do_bounds_check == 0 && s &&
|
||||
(s->type.t & VT_BTYPE) == VT_FUNC && (s->asm_label & SYM_FIELD)) {
|
||||
const char *name = get_tok_str(s->asm_label & ~SYM_FIELD, NULL);
|
||||
|
||||
if (name && strncmp (name, "__bound_", strlen("__bound_")) == 0) {
|
||||
char str[100];
|
||||
int v = s->v;
|
||||
|
||||
sprintf (str, "!%s", name); /* illegal name */
|
||||
t = tok_alloc(str, strlen(str))->tok;
|
||||
s = sym_find(t);
|
||||
if (s == NULL)
|
||||
s = external_global_sym(t, &func_old_type);
|
||||
s->asm_label = v | SYM_FIELD; /* use old name as alias */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!s || IS_ASM_SYM(s)) {
|
||||
const char *name = get_tok_str(t, NULL);
|
||||
if (tok != '(')
|
||||
@ -8087,14 +8109,13 @@ static void gen_function(Sym *sym)
|
||||
{
|
||||
/* Initialize VLA state */
|
||||
struct scope f = { 0 };
|
||||
cur_scope = root_scope = &f;
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
unsigned char save_bcheck = tcc_state->do_bounds_check;
|
||||
|
||||
if (sym->type.ref->f.no_bcheck)
|
||||
tcc_state->do_bounds_check = 0;
|
||||
#endif
|
||||
|
||||
cur_scope = root_scope = &f;
|
||||
nocode_wanted = 0;
|
||||
ind = cur_text_section->data_offset;
|
||||
if (sym->a.aligned) {
|
||||
|
2
tcctok.h
2
tcctok.h
@ -134,8 +134,10 @@
|
||||
DEF(TOK_DESTRUCTOR2, "__destructor__")
|
||||
DEF(TOK_ALWAYS_INLINE1, "always_inline")
|
||||
DEF(TOK_ALWAYS_INLINE2, "__always_inline__")
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
DEF(TOK_NO_BOUND_CHECK1, "bound_no_checking")
|
||||
DEF(TOK_NO_BOUND_CHECK2, "__bound_no_checking__")
|
||||
#endif
|
||||
|
||||
DEF(TOK_MODE, "__mode__")
|
||||
DEF(TOK_MODE_QI, "__QI__")
|
||||
|
@ -33,6 +33,8 @@ add (void) BOUNDS_NO_CHECKING
|
||||
for (i = 0; i < (sizeof(dummy)/sizeof(dummy[0])); i++) {
|
||||
dummy[i]++;
|
||||
}
|
||||
/* Should not be translated into __bound_memset */
|
||||
memset (&dummy[0], 0, sizeof(dummy));
|
||||
}
|
||||
|
||||
static void *
|
||||
@ -68,6 +70,7 @@ main (void)
|
||||
struct sigaction act;
|
||||
sigjmp_buf sj;
|
||||
sigset_t m;
|
||||
time_t end;
|
||||
|
||||
memset (&act, 0, sizeof (act));
|
||||
act.sa_handler = signal_handler;
|
||||
@ -80,7 +83,9 @@ main (void)
|
||||
pthread_create(&id2, NULL, do_signal, NULL);
|
||||
|
||||
printf ("start\n");
|
||||
sleep(1);
|
||||
/* sleep does not work !!! */
|
||||
end = time(NULL) + 2;
|
||||
while (time(NULL) < end) ;
|
||||
run = 0;
|
||||
printf ("end\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user