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 = {}
|
local hdrpaths = {}
|
||||||
for _, t in pairs(e.deps) do
|
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
|
end
|
||||||
hdrpaths = uniquify(hdrpaths)
|
hdrpaths = uniquify(hdrpaths)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ definerule("build_as",
|
||||||
srcs = { "mach/proto/as/comm2.y" },
|
srcs = { "mach/proto/as/comm2.y" },
|
||||||
outleaf = "comm2.y",
|
outleaf = "comm2.y",
|
||||||
deps = {
|
deps = {
|
||||||
|
"mach/proto/as/comm0.h",
|
||||||
|
"mach/proto/as/comm1.h",
|
||||||
"h+emheaders",
|
"h+emheaders",
|
||||||
archlib,
|
archlib,
|
||||||
},
|
},
|
||||||
|
|
|
@ -105,16 +105,16 @@ _include "out.h"
|
||||||
#include "out.h"
|
#include "out.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUG == 0
|
/*
|
||||||
#define assert(ex) /* nothing */
|
* Define assert(). Disable assertions if DEBUG == 0.
|
||||||
|
*/
|
||||||
|
#if DEBUG == 0 && !defined(NDEBUG)
|
||||||
|
#define NDEBUG
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _include
|
||||||
#if DEBUG == 1
|
_include <assert.h>
|
||||||
#define assert(ex) {if (!(ex)) assert1();}
|
#else
|
||||||
#endif
|
#include <assert.h>
|
||||||
|
|
||||||
#if DEBUG == 2
|
|
||||||
#define assert(ex) {if (!(ex)) assert2(__FILE__, __LINE__);}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CTRL(x) ((x) & 037)
|
#define CTRL(x) ((x) & 037)
|
||||||
|
|
|
@ -105,7 +105,7 @@ extern int curr_token;
|
||||||
|
|
||||||
/* forward function declarations */
|
/* forward function declarations */
|
||||||
/* comm2.y */
|
/* comm2.y */
|
||||||
void yyparse(void);
|
int yyparse(void);
|
||||||
/* comm4.c */
|
/* comm4.c */
|
||||||
void stop(void);
|
void stop(void);
|
||||||
void newmodule(const char *);
|
void newmodule(const char *);
|
||||||
|
|
|
@ -283,6 +283,7 @@ induo(int c)
|
||||||
('>'<<8) | '>', OP_RR,
|
('>'<<8) | '>', OP_RR,
|
||||||
('|'<<8) | '|', OP_OO,
|
('|'<<8) | '|', OP_OO,
|
||||||
('&'<<8) | '&', OP_AA,
|
('&'<<8) | '&', OP_AA,
|
||||||
|
0 /* terminates array */
|
||||||
};
|
};
|
||||||
short *p;
|
short *p;
|
||||||
|
|
||||||
|
|
|
@ -79,10 +79,8 @@ newident(item_t *ip, int typ)
|
||||||
void
|
void
|
||||||
newlabel(item_t *ip)
|
newlabel(item_t *ip)
|
||||||
{
|
{
|
||||||
#if DEBUG != 0
|
#if defined(THREE_PASS) && !defined(NDEBUG)
|
||||||
#ifdef THREE_PASS
|
|
||||||
ADDR_T oldval = ip->i_valu;
|
ADDR_T oldval = ip->i_valu;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (DOTSCT == NULL)
|
if (DOTSCT == NULL)
|
||||||
|
|
|
@ -406,22 +406,6 @@ void fatal(const char* s, ...)
|
||||||
va_end(ap);
|
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 */
|
/* VARARGS1 */
|
||||||
void serror(const char* s, ...)
|
void serror(const char* s, ...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue