Use libc assert(); fix dependencies; unbreak isduo().
Switch from custom assert() to libc assert() in mach/proto/as. Continue to disable asserts if DEBUG == 0. This change found a problem in the build system; comm2.y was missing depedencies on comm0.h and comm1.h. Add the missing dependencies to the cppfile rule. Allow the dependencies by modifying cppfile in first/build.lua to act like cfile if t.dir is false. Now that comm2.y gets rebuilt, I must fix the wrong prototype of yyparse() in comm1.h. I got unlucky as induo() in comm5.c was reading beyond the end of the array. It found an operator "= " ('=' then space) in the garbage, so it returned a garbage token number, and "VAR = 123" became a syntax error. Unbreak induo() by terminating the array.
This commit is contained in:
parent
805c916ab0
commit
ac4cbd735e
|
@ -92,7 +92,9 @@ definerule("cppfile",
|
|||
|
||||
local hdrpaths = {}
|
||||
for _, t in pairs(e.deps) do
|
||||
hdrpaths[#hdrpaths+1] = "-I"..t.dir
|
||||
if t.dir then
|
||||
hdrpaths[#hdrpaths+1] = "-I"..t.dir
|
||||
end
|
||||
end
|
||||
hdrpaths = uniquify(hdrpaths)
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ definerule("build_as",
|
|||
srcs = { "mach/proto/as/comm2.y" },
|
||||
outleaf = "comm2.y",
|
||||
deps = {
|
||||
"mach/proto/as/comm0.h",
|
||||
"mach/proto/as/comm1.h",
|
||||
"h+emheaders",
|
||||
archlib,
|
||||
},
|
||||
|
|
|
@ -105,16 +105,16 @@ _include "out.h"
|
|||
#include "out.h"
|
||||
#endif
|
||||
|
||||
#if DEBUG == 0
|
||||
#define assert(ex) /* nothing */
|
||||
/*
|
||||
* Define assert(). Disable assertions if DEBUG == 0.
|
||||
*/
|
||||
#if DEBUG == 0 && !defined(NDEBUG)
|
||||
#define NDEBUG
|
||||
#endif
|
||||
|
||||
#if DEBUG == 1
|
||||
#define assert(ex) {if (!(ex)) assert1();}
|
||||
#endif
|
||||
|
||||
#if DEBUG == 2
|
||||
#define assert(ex) {if (!(ex)) assert2(__FILE__, __LINE__);}
|
||||
#ifdef _include
|
||||
_include <assert.h>
|
||||
#else
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#define CTRL(x) ((x) & 037)
|
||||
|
|
|
@ -105,7 +105,7 @@ extern int curr_token;
|
|||
|
||||
/* forward function declarations */
|
||||
/* comm2.y */
|
||||
void yyparse(void);
|
||||
int yyparse(void);
|
||||
/* comm4.c */
|
||||
void stop(void);
|
||||
void newmodule(const char *);
|
||||
|
|
|
@ -283,6 +283,7 @@ induo(int c)
|
|||
('>'<<8) | '>', OP_RR,
|
||||
('|'<<8) | '|', OP_OO,
|
||||
('&'<<8) | '&', OP_AA,
|
||||
0 /* terminates array */
|
||||
};
|
||||
short *p;
|
||||
|
||||
|
|
|
@ -79,10 +79,8 @@ newident(item_t *ip, int typ)
|
|||
void
|
||||
newlabel(item_t *ip)
|
||||
{
|
||||
#if DEBUG != 0
|
||||
#ifdef THREE_PASS
|
||||
#if defined(THREE_PASS) && !defined(NDEBUG)
|
||||
ADDR_T oldval = ip->i_valu;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (DOTSCT == NULL)
|
||||
|
|
|
@ -406,22 +406,6 @@ void fatal(const char* s, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
#if DEBUG == 2
|
||||
assert2(file, line)
|
||||
char *file;
|
||||
{
|
||||
fatal("assertion failed (%s, %d)", file, line);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG == 1
|
||||
assert1()
|
||||
{
|
||||
fatal("assertion failed");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* VARARGS1 */
|
||||
void serror(const char* s, ...)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue