[hackers] [scc] Deal size_t like any other type || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 20 Jul 2015 22:09:59 +0200 (CEST)

commit da8e1d6c8cd2711d7a8566bf658399fbe3531b39
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jul 20 22:07:23 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jul 20 22:07:23 2015 +0200

    Deal size_t like any other type
    
    The important point in the types in the current
    implementation is the value of the fields, so two
    types can be represented by different pointers,
    with different values that if they have the same
    values then they will be the same type. For this
    reason is better keep size_t like a common type.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index 328343f..8ec77f7 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -343,7 +343,7 @@ extern int lexmode;
 
 extern Type *voidtype, *pvoidtype, *booltype,
             *uchartype, *chartype,
- *uinttype, *inttype, *sizetp,
+ *uinttype, *inttype, *sizettype,
             *ushortype, *shortype,
             *longtype, *ulongtype,
             *ullongtype, *llongtype,
diff --git a/cc1/code.c b/cc1/code.c
index e22908e..937a625 100644
--- a/cc1/code.c
+++ b/cc1/code.c
_AT_@ -345,7 +345,7 @@ sizeofnode(Type *tp)
         Symbol *sym;
 
         sym = newsym(NS_IDEN);
- sym->type = sizetp;
+ sym->type = sizettype;
         sym->u.i = tp->size;
         return constnode(sym);
 }
diff --git a/cc1/types.c b/cc1/types.c
index 5e2011c..0a20ffd 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -147,6 +147,14 @@ static Type types[] = {
                 .size = 16,
                 .align = 1,
                 .n.rank = RANK_LDOUBLE
+ },
+ { /* 17 = sizettype */
+ .op = INT,
+ .letter = L_UINT,
+ .defined = 1,
+ .size = 2,
+ .align = 1,
+ .n.rank = RANK_UINT
         }
 };
 
_AT_@ -158,9 +166,7 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
         *longtype = &types[10], *ulongtype = &types[11],
         *ullongtype = &types[12], *llongtype = &types[13],
         *floattype = &types[14], *doubletype = &types[15],
- *ldoubletype = &types[16];
-
-Type *sizetp = &types[8]; /* TODO: This depend of the target */
+ *ldoubletype = &types[16], *sizettype = &types[17];
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
Received on Mon Jul 20 2015 - 22:09:59 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 20 2015 - 22:12:11 CEST