commit 7903bbf3ea842fe18ed2ca0606d859058d3eff47
Author:     FRIGN <[email protected]>
AuthorDate: Wed May 25 07:58:42 2016 +0200
Commit:     FRIGN <[email protected]>
CommitDate: Wed May 25 08:02:15 2016 +0200

    [cc1] Unboolify
    
    Bools artificially limit what you can do on a logical basis with normal
    ints. So let's drop them.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index 58962f1..0dda636 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -347,7 +347,7 @@ extern void errorp(char *fmt, ...);
 extern void cpperror(char *fmt, ...);
 
 /* types.c */
-extern bool eqtype(Type *tp1, Type *tp2);
+extern int eqtype(Type *tp1, Type *tp2);
 extern Type *ctype(unsigned type, unsigned sign, unsigned size);
 extern Type *mktype(Type *tp, int op, TINT nelem, Type *data[]);
 extern Type *duptype(Type *base);
@@ -376,10 +376,10 @@ extern void decl(void);
 /* lex.c */
 extern char ahead(void);
 extern unsigned next(void);
-extern bool moreinput(void);
+extern int moreinput(void);
 extern void expect(unsigned tok);
 extern void discard(void);
-extern bool addinput(char *fname);
+extern int addinput(char *fname);
 extern void setsafe(int type);
 extern void ilex(char *fname);
 #define accept(t) ((yytoken == (t)) ? next() : 0)
@@ -402,9 +402,9 @@ extern TUINT ones(int nbytes);
 extern Node *decay(Node *), *negate(Node *np), *assign(void);
 extern Node *convert(Node *np, Type *tp1, char iscast);
 extern Node *iconstexpr(void), *condexpr(void), *expr(void);
-extern bool isnodecmp(int op);
+extern int isnodecmp(int op);
 extern int negop(int op);
-extern bool cmpnode(Node *np, TUINT val);
+extern int cmpnode(Node *np, TUINT val);
 
 /* init.c */
 extern void initializer(Symbol *sym, Type *tp);
@@ -412,8 +412,8 @@ extern Node *initlist(Type *tp);
 
 /* cpp.c */
 extern void icpp(void);
-extern bool cpp(void);
-extern bool expand(char *begin, Symbol *sym);
+extern int cpp(void);
+extern int expand(char *begin, Symbol *sym);
 extern void incdir(char *dir);
 extern void outcpp(void);
 extern Symbol *defmacro(char *s);
diff --git a/cc1/cpp.c b/cc1/cpp.c
index d18b925..82c6e48 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -226,7 +226,7 @@ expansion_too_long:
 }
 
 #define BUFSIZE ((INPUTSIZ > FILENAME_MAX+2) ? INPUTSIZ : FILENAME_MAX+2)
-bool
+int
 expand(char *begin, Symbol *sym)
 {
        size_t total, elen, rlen, llen, ilen;
@@ -324,7 +324,7 @@ getpars(Symbol *args[NR_MACROARG])
        return n;
 }
 
-static bool
+static int
 getdefs(Symbol *args[NR_MACROARG], int nargs, char *bp, size_t bufsiz)
 {
        Symbol **argp;
@@ -425,7 +425,7 @@ incdir(char *dir)
        dirinclude[ninclude-1] = dir;
 }
 
-static bool
+static int
 includefile(char *dir, char *file, size_t filelen)
 {
        size_t dirlen;
@@ -684,7 +684,7 @@ undef(void)
        next();
 }
 
-bool
+int
 cpp(void)
 {
        static struct {
diff --git a/cc1/decl.c b/cc1/decl.c
index 582f4a7..c77238e 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -65,7 +65,7 @@ push(struct declarators *dp, int op, ...)
        va_end(va);
 }
 
-static bool
+static int
 pop(struct declarators *dp, struct decl *dcl)
 {
        struct declarator *p;
diff --git a/cc1/expr.c b/cc1/expr.c
index 85902b8..5c86075 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -12,7 +12,7 @@
 
 Node *expr(void);
 
-bool
+int
 cmpnode(Node *np, TUINT val)
 {
        Symbol *sym;
@@ -36,7 +36,7 @@ cmpnode(Node *np, TUINT val)
        return 0;
 }
 
-bool
+int
 isnodecmp(int op)
 {
        switch (op) {
diff --git a/cc1/fold.c b/cc1/fold.c
index 637e5ba..e75e1eb 100644
--- a/cc1/fold.c
+++ b/cc1/fold.c
@@ -17,7 +17,7 @@ ones(int nbytes)
        return v;
 }
 
-static bool
+static int
 addi(TINT l, TINT r, Type *tp)
 {
        struct limits *lim = getlimits(tp);
@@ -35,7 +35,7 @@ addi(TINT l, TINT r, Type *tp)
        return 0;
 }
 
-static bool
+static int
 addf(TFLOAT l, TFLOAT r, Type *tp)
 {
        struct limits *lim = getlimits(tp);
@@ -53,19 +53,19 @@ addf(TFLOAT l, TFLOAT r, Type *tp)
        return 0;
 }
 
-static bool
+static int
 subi(TINT l, TINT r, Type *tp)
 {
        return addi(l, -r, tp);
 }
 
-static bool
+static int
 subf(TFLOAT l, TFLOAT r, Type *tp)
 {
        return addf(l, -r, tp);
 }
 
-static bool
+static int
 muli(TINT l, TINT r, Type *tp)
 {
        struct limits *lim = getlimits(tp);
@@ -83,7 +83,7 @@ muli(TINT l, TINT r, Type *tp)
        return 0;
 }
 
-static bool
+static int
 mulf(TFLOAT l, TFLOAT r, Type *tp)
 {
        struct limits *lim = getlimits(tp);
@@ -101,7 +101,7 @@ mulf(TFLOAT l, TFLOAT r, Type *tp)
        return 0;
 }
 
-static bool
+static int
 divi(TINT l, TINT r,  Type *tp)
 {
        struct limits *lim = getlimits(tp);
@@ -113,7 +113,7 @@ divi(TINT l, TINT r,  Type *tp)
        return 1;
 }
 
-static bool
+static int
 divf(TFLOAT l, TFLOAT r,  Type *tp)
 {
        struct limits *lim = getlimits(tp);
@@ -128,7 +128,7 @@ divf(TFLOAT l, TFLOAT r,  Type *tp)
        return 1;
 }
 
-static bool
+static int
 lshi(TINT l, TINT r, Type *tp)
 {
        if (r < 0 || r >= tp->size * 8) {
@@ -138,7 +138,7 @@ lshi(TINT l, TINT r, Type *tp)
        return muli(l, 1 << r, tp);
 }
 
-static bool
+static int
 rshi(TINT l, TINT r, Type *tp)
 {
        if (r < 0 || r >= tp->size * 8) {
@@ -148,12 +148,12 @@ rshi(TINT l, TINT r, Type *tp)
        return 1;
 }
 
-static bool
+static int
 foldint(int op, Symbol *res, TINT l, TINT r)
 {
        TINT i;
        Type *tp = res->type;
-       bool (*validate)(TINT, TINT, Type *tp);
+       int (*validate)(TINT, TINT, Type *tp);
 
        switch (op) {
        case OADD: validate = addi; break;
@@ -196,7 +196,7 @@ foldint(int op, Symbol *res, TINT l, TINT r)
        return 1;
 }
 
-static bool
+static int
 folduint(int op, Symbol *res, TUINT l, TUINT r)
 {
        TINT i;
@@ -234,12 +234,12 @@ sign:
        return 1;
 }
 
-static bool
+static int
 foldfloat(int op, Symbol *res, TFLOAT l, TFLOAT r)
 {
        TFLOAT f;
        TINT i;
-       bool (*validate)(TFLOAT, TFLOAT, Type *tp);
+       int (*validate)(TFLOAT, TFLOAT, Type *tp);
 
        switch (op) {
        case OADD: validate = addf; break;
diff --git a/cc1/lex.c b/cc1/lex.c
index a2f5d18..84b691e 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -93,7 +93,7 @@ ilex(char *fname)
        keywords(keys, NS_KEYWORD);
 }
 
-bool
+int
 addinput(char *fname)
 {
        FILE *fp;
@@ -174,7 +174,7 @@ comment(char type)
                error("unterminated comment");
 }
 
-static bool
+static int
 readline(void)
 {
        char *bp, *lim;
@@ -212,7 +212,7 @@ repeat:
        return 1;
 }
 
-bool
+int
 moreinput(void)
 {
        static char file[FILENAME_MAX];
diff --git a/cc1/types.c b/cc1/types.c
index c21cc6b..68990c6 100644
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -308,7 +308,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
        return *tbl = bp;
 }
 
-bool
+int
 eqtype(Type *tp1, Type *tp2)
 {
        TINT n;
diff --git a/inc/cc.h b/inc/cc.h
index bbc6389..e801a3f 100644
--- a/inc/cc.h
+++ b/inc/cc.h
@@ -1,12 +1,4 @@
 /* See LICENSE file for copyright and license details. */
-#ifndef __bool_true_and_false_defined
-#ifdef NBOOL
-typedef unsigned bool;
-#else
-#include <stdbool.h>
-#endif
-#endif
-
 #ifndef NDEBUG
 extern int debug;
 #define DBG(fmt, ...) dbg(fmt, __VA_ARGS__)

Reply via email to