[hackers] [scc] [cc1] Add fake version of __builtin_va_list || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 19 Dec 2016 13:12:39 +0100 (CET)

commit 481870312e7a7e2389e138a97698811977541970
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Dec 19 13:10:47 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Dec 19 13:10:47 2016 +0100

    [cc1] Add fake version of __builtin_va_list
    
    This is a bultin type that is needed for libc implementations
    because they cannot know the type used by the compilers,
    and making a if-else if for all the compiler is a really
    bad idea.

diff --git a/cc1/arch/amd64-sysv/arch.c b/cc1/arch/amd64-sysv/arch.c
index cdc2749..f0393bb 100644
--- a/cc1/arch/amd64-sysv/arch.c
+++ b/cc1/arch/amd64-sysv/arch.c
_AT_@ -182,6 +182,13 @@ static Type types[] = {
                 .align = 8,
                 .n.rank = RANK_LONG,
         },
+ { /* 20 = va_list_type */
+ .op = PTR,
+ .letter = L_POINTER,
+ .prop = TDEFINED,
+ .size = 8,
+ .align = 8,
+ }
 };
 
 Type *voidtype = &types[0], *pvoidtype = &types[1],
_AT_@ -194,7 +201,8 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
- *ellipsistype = &types[18];
+ *ellipsistype = &types[18],
+ *va_list_type = &types[20];
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
diff --git a/cc1/arch/i386-sysv/arch.c b/cc1/arch/i386-sysv/arch.c
index 873189b..2a8ab3a 100644
--- a/cc1/arch/i386-sysv/arch.c
+++ b/cc1/arch/i386-sysv/arch.c
_AT_@ -181,6 +181,13 @@ static Type types[] = {
                 .align = 4,
                 .n.rank = RANK_INT,
         },
+ { /* 20 = va_list_type */
+ .op = PTR,
+ .letter = L_POINTER,
+ .prop = TDEFINED,
+ .size = 8,
+ .align = 8,
+ }
 };
 
 
_AT_@ -194,7 +201,9 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
- *ellipsistype = &types[18];
+ *ellipsistype = &types[18],
+ *va_list_type = &types[20];
+
 
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
diff --git a/cc1/arch/qbe/arch.c b/cc1/arch/qbe/arch.c
index 5319adc..10011c2 100644
--- a/cc1/arch/qbe/arch.c
+++ b/cc1/arch/qbe/arch.c
_AT_@ -182,6 +182,13 @@ static Type types[] = {
                 .align = 8,
                 .n.rank = RANK_LONG,
         },
+ { /* 20 = va_list_type */
+ .op = PTR,
+ .letter = L_POINTER,
+ .prop = TDEFINED,
+ .size = 8,
+ .align = 8,
+ }
 };
 
 Type *voidtype = &types[0], *pvoidtype = &types[1],
_AT_@ -194,7 +201,8 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
- *ellipsistype = &types[18];
+ *ellipsistype = &types[18],
+ *va_list_type = &types[20];
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
diff --git a/cc1/arch/z80/arch.c b/cc1/arch/z80/arch.c
index d9e2038..55c53dc 100644
--- a/cc1/arch/z80/arch.c
+++ b/cc1/arch/z80/arch.c
_AT_@ -182,6 +182,13 @@ static Type types[] = {
                 .align = 1,
                 .n.rank = RANK_SHORT,
         },
+ { /* 20 = va_list_type */
+ .op = PTR,
+ .letter = L_POINTER,
+ .prop = TDEFINED,
+ .size = 8,
+ .align = 8,
+ }
 };
 
 Type *voidtype = &types[0], *pvoidtype = &types[1],
_AT_@ -194,7 +201,9 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
- *ellipsistype = &types[18];
+ *ellipsistype = &types[18],
+ *va_list_type = &types[20];
+
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
diff --git a/cc1/cc1.h b/cc1/cc1.h
index 120c97e..bb43c73 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -153,6 +153,7 @@ enum tokens {
         FLOAT,
         INT,
         BOOL,
+ VA_LIST,
         STRUCT,
         UNION,
         CHAR,
_AT_@ -451,4 +452,4 @@ extern Type *voidtype, *pvoidtype, *booltype,
             *longtype, *ulongtype,
             *ullongtype, *llongtype,
             *floattype, *doubletype, *ldoubletype,
- *ellipsistype;
+ *ellipsistype, *va_list_type;
diff --git a/cc1/decl.c b/cc1/decl.c
index a9a59ff..b70b442 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -405,6 +405,7 @@ specifier(int *sclass, int *qualifier)
                                 dcl = structdcl;
                                 p = &type;
                                 break;
+ case VA_LIST:
                         case VOID:
                         case BOOL:
                         case CHAR:
diff --git a/cc1/lex.c b/cc1/lex.c
index 9b31721..be9caca 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -46,6 +46,7 @@ ilex(void)
                 {"auto", SCLASS, AUTO},
                 {"break", BREAK, BREAK},
                 {"_Bool", TYPE, BOOL},
+ {"__builtin_va_list", TYPE, VA_LIST},
                 {"case", CASE, CASE},
                 {"char", TYPE, CHAR},
                 {"const", TQUALIFIER, CONST},
diff --git a/cc1/types.c b/cc1/types.c
index 25a6561..0008cd2 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -122,6 +122,10 @@ ctype(unsigned type, unsigned sign, unsigned size)
                         return uchartype;
                 }
                 break;
+ case VA_LIST:
+ if (size || sign)
+ goto invalid_type;
+ return va_list_type;
         case VOID:
                 if (size || sign)
                         goto invalid_type;
Received on Mon Dec 19 2016 - 13:12:39 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 19 2016 - 13:24:22 CET