mirror of
https://github.com/frida/tinycc
synced 2024-12-24 05:56:49 +03:00
Add support for the __mode__ attribute
-- By by ... Detlef
This commit is contained in:
parent
2650584ac4
commit
a975008ae7
4
tcc.h
4
tcc.h
@ -267,7 +267,8 @@ typedef struct AttributeDef {
|
||||
func_export : 1,
|
||||
func_import : 1,
|
||||
func_args : 5,
|
||||
fill : 16;
|
||||
mode : 4,
|
||||
fill : 12;
|
||||
struct Section *section;
|
||||
} AttributeDef;
|
||||
|
||||
@ -278,6 +279,7 @@ typedef struct AttributeDef {
|
||||
#define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)
|
||||
#define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)
|
||||
#define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)
|
||||
#define ATTR_MODE(r) (((AttributeDef*)&(r))->mode)
|
||||
#define INT_ATTR(ad) (*(int*)(ad))
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
23
tccgen.c
23
tccgen.c
@ -2501,6 +2501,25 @@ static void parse_attribute(AttributeDef *ad)
|
||||
ad->func_call = FUNC_FASTCALLW;
|
||||
break;
|
||||
#endif
|
||||
case TOK_MODE:
|
||||
skip('(');
|
||||
switch(tok) {
|
||||
case TOK_MODE_DI:
|
||||
ad->mode = VT_LLONG + 1;
|
||||
break;
|
||||
case TOK_MODE_HI:
|
||||
ad->mode = VT_SHORT + 1;
|
||||
break;
|
||||
case TOK_MODE_SI:
|
||||
ad->mode = VT_INT + 1;
|
||||
break;
|
||||
default:
|
||||
warning("__mode__(%s) not supported\n", get_tok_str(tok, NULL));
|
||||
break;
|
||||
}
|
||||
next();
|
||||
skip(')');
|
||||
break;
|
||||
case TOK_DLLEXPORT:
|
||||
ad->func_export = 1;
|
||||
break;
|
||||
@ -2874,6 +2893,10 @@ static int parse_btype(CType *type, AttributeDef *ad)
|
||||
case TOK_ATTRIBUTE1:
|
||||
case TOK_ATTRIBUTE2:
|
||||
parse_attribute(ad);
|
||||
if (ATTR_MODE(ad)) {
|
||||
u = ATTR_MODE(ad) -1;
|
||||
t = (t & ~VT_BTYPE) | u;
|
||||
}
|
||||
break;
|
||||
/* GNUC typeof */
|
||||
case TOK_TYPEOF1:
|
||||
|
4
tcctok.h
4
tcctok.h
@ -104,6 +104,10 @@
|
||||
DEF(TOK_FASTCALL1, "fastcall")
|
||||
DEF(TOK_FASTCALL2, "__fastcall")
|
||||
DEF(TOK_FASTCALL3, "__fastcall__")
|
||||
DEF(TOK_MODE, "__mode__")
|
||||
DEF(TOK_MODE_DI, "__DI__")
|
||||
DEF(TOK_MODE_HI, "__HI__")
|
||||
DEF(TOK_MODE_SI, "__SI__")
|
||||
DEF(TOK_DLLEXPORT, "dllexport")
|
||||
DEF(TOK_DLLIMPORT, "dllimport")
|
||||
DEF(TOK_NORETURN1, "noreturn")
|
||||
|
Loading…
Reference in New Issue
Block a user