diff options
| author | bellard <bellard> | 2004-10-29 23:55:13 +0000 |
|---|---|---|
| committer | bellard <bellard> | 2004-10-29 23:55:13 +0000 |
| commit | 1e1d3ff68775f62d2b212ec1de7469695ed1ef12 (patch) | |
| tree | 01bb8e5068df5710948b493d694f98c281ab2728 /tcc.c | |
| parent | 736b5657661072acf97e1df85432184048ad2063 (diff) | |
| download | tinycc-1e1d3ff68775f62d2b212ec1de7469695ed1ef12.tar.gz tinycc-1e1d3ff68775f62d2b212ec1de7469695ed1ef12.tar.bz2 | |
packed attribute support
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -215,6 +215,7 @@ typedef struct DLLReference { /* GNUC attribute definition */ typedef struct AttributeDef { int aligned; + int packed; Section *section; unsigned char func_call; /* FUNC_CDECL, FUNC_STDCALL, FUNC_FASTCALLx */ } AttributeDef; @@ -3875,7 +3876,7 @@ static int macro_subst_tok(TokenString *tok_str, CValue cval; CString cstr; char buf[32]; - + /* if symbol is a macro, prepare substitution */ /* special macros */ if (tok == TOK___LINE__) { @@ -4149,7 +4150,7 @@ static void macro_subst(TokenString *tok_str, Sym **nested_list, const int *ptr; int t, ret; CValue cval; - + /* first scan for '##' operator handling */ ptr = macro_str; macro_str1 = macro_twosharps(ptr); @@ -6175,8 +6176,10 @@ void inc(int post, int c) /* Parse GNUC __attribute__ extension. Currently, the following extensions are recognized: - aligned(n) : set data/function alignment. + - packed : force data alignment to 1 - section(x) : generate data/code in this section. - unused : currently ignored, but may be used someday. + - regparm(n) : pass function parameters in registers (i386 only) */ static void parse_attribute(AttributeDef *ad) { @@ -6214,6 +6217,10 @@ static void parse_attribute(AttributeDef *ad) } ad->aligned = n; break; + case TOK_PACKED1: + case TOK_PACKED2: + ad->packed = 1; + break; case TOK_UNUSED1: case TOK_UNUSED2: /* currently, no need to handle it because tcc does not @@ -6364,8 +6371,12 @@ static void struct_decl(CType *type, int u) get_tok_str(v, NULL)); } size = type_size(&type1, &align); - if (align < ad.aligned) - align = ad.aligned; + if (ad.aligned) { + if (align < ad.aligned) + align = ad.aligned; + } else if (ad.packed) { + align = 1; + } lbit_pos = 0; if (bit_size >= 0) { bt = type1.t & VT_BTYPE; @@ -8480,8 +8491,12 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, error("unknown type size"); } /* take into account specified alignment if bigger */ - if (ad->aligned > align) - align = ad->aligned; + if (ad->aligned) { + if (ad->aligned > align) + align = ad->aligned; + } else if (ad->packed) { + align = 1; + } if ((r & VT_VALMASK) == VT_LOCAL) { sec = NULL; if (do_bounds_check && (type->t & VT_ARRAY)) |
