# Library dir
COMMON = ../common
-CFLAGS = -g -O2 -Wall -W -I$(COMMON)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON)
CC = gcc
EBIND = emxbind
LDFLAGS =
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
Write32 (Obj, H->StrPoolOffs);
Write32 (Obj, H->StrPoolSize);
Write32 (Obj, H->AssertOffs);
- Write32 (Obj, H->AssertSize);
+ Write32 (Obj, H->AssertSize);
Write32 (Obj, H->ScopeOffs);
Write32 (Obj, H->ScopeSize);
}
Error ("Could not open `%s': %s", Name, strerror (errno));
}
- /* Get the modification time of the object file */
- if (fstat (fileno (Obj), &StatBuf) != 0) {
+ /* Get the modification time of the object file. There a race condition
+ * here, since we cannot use fileno() (non standard identifier in standard
+ * header file), and therefore not fstat. When using stat with the
+ * file name, there's a risk that the file was deleted and recreated
+ * while it was open. Since mtime and size are only used to check
+ * if a file has changed in the debugger, we will ignore this problem
+ * here.
+ */
+ if (stat (Name, &StatBuf) != 0) {
Error ("Cannot stat object file `%s': %s", Name, strerror (errno));
}
# Library dir
COMMON = ../common
-CFLAGS = -g -O2 -Wall -W -I$(COMMON)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON)
CC = gcc
EBIND = emxbind
LDFLAGS =
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM -MG $^ > .depend
+ $(CC) $(CFLAGS) -MM -MG $^ > .depend
# -----------------------------------------------------------------------------
# Rules to make config includes
void NewInputFile (const char* Name)
/* Open a new input file */
{
- InputFile* I;
- FILE* F;
+ char* PathName = 0;
/* First try to open the file */
- F = fopen (Name, "r");
+ FILE* F = fopen (Name, "r");
if (F == 0) {
- char* PathName;
-
/* Error (fatal error if this is the main file) */
if (ICount == 0) {
Fatal ("Cannot open input file `%s': %s", Name, strerror (errno));
Error ("Cannot open include file `%s': %s", Name, strerror (errno));
}
- /* Free the allocated memory */
- xfree (PathName);
-
+ /* Use the path name from now on */
+ Name = PathName;
}
/* check again if we do now have an open file */
if (F != 0) {
unsigned FileIdx;
-
- /* Stat the file and remember the values */
+ InputFile* IF;
+
+ /* Stat the file and remember the values. There a race condition here,
+ * since we cannot use fileno() (non standard identifier in standard
+ * header file), and therefore not fstat. When using stat with the
+ * file name, there's a risk that the file was deleted and recreated
+ * while it was open. Since mtime and size are only used to check
+ * if a file has changed in the debugger, we will ignore this problem
+ * here.
+ */
struct stat Buf;
- if (fstat (fileno (F), &Buf) != 0) {
+ if (stat (Name, &Buf) != 0) {
Fatal ("Cannot stat input file `%s': %s", Name, strerror (errno));
}
FileIdx = AddFile (Name, Buf.st_size, Buf.st_mtime);
/* Create a new state variable and initialize it */
- I = xmalloc (sizeof (*I));
- I->F = F;
- I->Pos.Line = 0;
- I->Pos.Col = 0;
- I->Pos.Name = FileIdx;
- I->Tok = Tok;
- I->C = C;
- I->Line[0] = '\0';
+ IF = xmalloc (sizeof (*IF));
+ IF->F = F;
+ IF->Pos.Line = 0;
+ IF->Pos.Col = 0;
+ IF->Pos.Name = FileIdx;
+ IF->Tok = Tok;
+ IF->C = C;
+ IF->Line[0] = '\0';
/* Use the new file */
- I->Next = IFile;
- IFile = I;
+ IF->Next = IFile;
+ IFile = IF;
++ICount;
/* Read the first character from the new file */
Tok = TOK_SEP;
}
+
+ /* Free an allocated name buffer */
+ xfree (PathName);
}
*/
if (IF->Usage++ == 0) {
- /* Get file size and modification time */
+ /* Get file size and modification time. There a race condition here,
+ * since we cannot use fileno() (non standard identifier in standard
+ * header file), and therefore not fstat. When using stat with the
+ * file name, there's a risk that the file was deleted and recreated
+ * while it was open. Since mtime and size are only used to check
+ * if a file has changed in the debugger, we will ignore this problem
+ * here.
+ */
struct stat Buf;
- if (fstat (fileno (F), &Buf) != 0) {
+ if (stat (IF->Name, &Buf) != 0) {
/* Error */
Fatal ("Cannot stat `%s': %s", IF->Name, strerror (errno));
}
CC65_INC = \"/usr/lib/cc65/include/\"
#
-CFLAGS = -O2 -g -Wall -W -I$(COMMON) -DCC65_INC=$(CC65_INC)
+CFLAGS = -O2 -g -Wall -W -std=c89 -I$(COMMON) -DCC65_INC=$(CC65_INC)
CC=gcc
EBIND=emxbind
LDFLAGS=-lm
static void ExpandMacro (StrBuf* Target, Macro* M)
/* Expand a macro into Target */
{
+ /* ### printf ("Expanding %s(%u)\n", M->Name, ++V); */
+
/* Check if this is a function like macro */
- //printf ("Expanding %s(%u)\n", M->Name, ++V);
if (M->ArgCount >= 0) {
int Whitespace = IsSpace (CurC);
DoneMacroExp (&E);
}
- //printf ("Done with %s(%u)\n", M->Name, V--);
+ /* ### printf ("Done with %s(%u)\n", M->Name, V--); */
}
NextChar ();
NextChar ();
- /* Remember that the macro is variadic and use __VA_ARGS__ as
+ /* Remember that the macro is variadic and use __VA_ARGS__ as
* the argument name.
*/
AddMacroArg (M, "__VA_ARGS__");
SB_Drop (&M->Replacement, 1);
}
- //printf ("%s: <%.*s>\n", M->Name, SB_GetLen (&M->Replacement), SB_GetConstBuf (&M->Replacement));
+ /* ### printf ("%s: <%.*s>\n", M->Name, SB_GetLen (&M->Replacement), SB_GetConstBuf (&M->Replacement)); */
/* If we have an existing macro, check if the redefinition is identical.
* Print a diagnostic if not.
CC=gcc
-CFLAGS = -O2 -g -Wall -W -I$(COMMON) -D$(SPAWN)
+CFLAGS = -O2 -g -Wall -W -std=c89 -I$(COMMON) -D$(SPAWN)
EBIND = emxbind
LDFLAGS=
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -D$(SPAWN) -MM $^ > .depend
+ $(CC) $(CFLAGS) -D$(SPAWN) -MM $^ > .depend
# Library dir
COMMON = ../common
-CFLAGS = -g -O2 -Wall -W -I$(COMMON)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON)
CC = gcc
EBIND = emxbind
LDFLAGS =
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
# gcc Makefile for the binutils common stuff
#
-CFLAGS = -g -O2 -Wall -W
+CFLAGS = -g -O2 -Wall -W -std=c89
CC = gcc
LDFLAGS =
LIB = common.a
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
+/* No action if we're using a C99 compiler */
+#if (__STDC_VERSION__ < 199901)
+
+
+
/* The watcom compiler doesn't have va_copy and a problematic va_list definition */
#if defined(__WATCOMC__)
#define va_copy(dest,src) memcpy((dest), (src), sizeof (va_list))
#endif
-/* GNU C before version 3 has its own name */
-#if defined(__GNUC__) && (__GNUC__ == 2)
+/* GNU C has a builtin function */
+#if defined(__GNUC__)
#define va_copy(dest,src) __va_copy(dest, src)
#endif
+#endif /* #if (__STDC_VERSION__ < 199901) */
+
+
+
/* End of va_copy.h */
#endif
# Library dir
COMMON = ../common
-CFLAGS = -g -O2 -Wall -W -I$(COMMON)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON)
CC=gcc
EBIND=emxbind
LDFLAGS=
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
#include "grc.h"
/* common stuff */
-//#include "cmdline.h"
#include "fname.h"
#include "abend.h"
#include "chartype.h"
}
}
-//char *bintos(unsigned char a, char *out) {
char *bintos(unsigned char a, char out[7]) {
int i=0;
for (;i<8;i++) {
128, 0, 1, 128, 0, 1, 128, 0, 1, 128, 0, 1, 128, 0, 1,
128, 0, 1, 128, 0, 1, 128, 0, 1, 128, 0, 1, 255, 255, 255 };
-char *ProgName; // for AbEnd, later remove and use common/cmdline.h
+char *ProgName; /* for AbEnd, later remove and use common/cmdline.h */
char *outputCName=NULL, *outputSName=NULL, *outputVName=NULL;
FILE *outputCFile, *outputSFile, *outputVFile;
COMMON = ../common
-CFLAGS = -g -O2 -Wall -W -I$(COMMON)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON)
CC = gcc
LDFLAGS =
EBIND = emxbind
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
CC65_LIB = \"/usr/lib/cc65/lib/\"
#
-CFLAGS = -g -O2 -Wall -W -I$(COMMON) -DCC65_LIB=$(CC65_LIB)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON) -DCC65_LIB=$(CC65_LIB)
CC=gcc
EBIND=emxbind
LDFLAGS=
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM -MG $^ > .depend
+ $(CC) $(CFLAGS) -MM -MG $^ > .depend
# -----------------------------------------------------------------------------
# Rules to make config includes
# gcc Makefile for the program sources
#
-CFLAGS = -g -O2 -Wall
+CFLAGS = -g -O2 -Wall -std=c89
CC = gcc
LDFLAGS =
# Library dir
COMMON = ../common
-CFLAGS = -O2 -g -Wall -W -I$(COMMON)
+CFLAGS = -O2 -g -Wall -W -std=c89 -I$(COMMON)
CC=gcc
EBIND=emxbind
LDFLAGS=
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
COMMON = ../../common
SIM65 = ..
-CFLAGS = -g -O2 -Wall -W -I$(COMMON) -I$(SIM65) -fpic
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON) -I$(SIM65) -fpic
CC = gcc
EBIND = emxbind
LDFLAGS =
.PHONY: depend dep
depend dep: $(CHIPS:.so=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -I$(SIM65) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend
# Library dir
COMMON = ../common
-CFLAGS = -g -O2 -Wall -W -I$(COMMON)
+CFLAGS = -g -O2 -Wall -W -std=c89 -I$(COMMON)
CC = gcc
EBIND = emxbind
LDFLAGS =
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
- $(CC) -I$(COMMON) -MM $^ > .depend
+ $(CC) $(CFLAGS) -MM $^ > .depend