From c18a82ec40d42f06278461f0fe436dc6f1a540c7 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 18 May 2013 12:15:53 +0100 Subject: [PATCH 1/4] Apply build system fixes for OpenBSD contributed by George Koehler. --- README | 8 ++++++-- lang/cem/cemcom.ansi/LLmessage.c | 1 + lang/cem/cemcom.ansi/options.c | 1 + util/LLgen/build.mk | 4 ++-- util/ack/build.mk | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README b/README index d6a56b050..3b0d877fa 100644 --- a/README +++ b/README @@ -45,6 +45,10 @@ Requirements: - an ANSI C compiler. This defaults to gcc. You can change this by setting the CC make variable. +- flex and yacc. + +- GNU make. + - about 40MB free in /tmp (or some other temporary directory). - about 6MB in the target directory. @@ -57,14 +61,14 @@ Instructions: - Run: - make + make # or gmake ...from the command line. This will do the build. The make system is fully parallelisable. If you have a multicore system, you probably want to do: - make -j8 + make -j8 # or gmake -j8 ...instead (substituting the right number of cores, of course). You can also shave a few seconds of the build time by using the -r flag. diff --git a/lang/cem/cemcom.ansi/LLmessage.c b/lang/cem/cemcom.ansi/LLmessage.c index 9010ce45d..c88c5eb24 100644 --- a/lang/cem/cemcom.ansi/LLmessage.c +++ b/lang/cem/cemcom.ansi/LLmessage.c @@ -6,6 +6,7 @@ /* PARSER ERROR ADMINISTRATION */ #include +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" diff --git a/lang/cem/cemcom.ansi/options.c b/lang/cem/cemcom.ansi/options.c index a8f382302..a23ff3405 100644 --- a/lang/cem/cemcom.ansi/options.c +++ b/lang/cem/cemcom.ansi/options.c @@ -11,6 +11,7 @@ #include #include "class.h" #include "macro.h" +#include "idf.h" #include "arith.h" #include "sizes.h" #include "align.h" diff --git a/util/LLgen/build.mk b/util/LLgen/build.mk index 3c40d1886..28da2d715 100644 --- a/util/LLgen/build.mk +++ b/util/LLgen/build.mk @@ -45,9 +45,9 @@ $(eval CLEANABLES += $o $1/Lpars.h) $o: $1/Lpars.h $1/Lpars.h: $2 $(LLGEN) @echo LLGEN $1/Lpars.c - @mkdir -p $(dir $o) + @mkdir -p $1 $(hide) $(RM) $o $1/Lpars.h - $(hide) cd $(dir $o) && $(LLGEN) $(abspath $2) + $(hide) cd $1 && $(LLGEN) $(abspath $2) $(foreach f,$o,$(call cfile,$f)) diff --git a/util/ack/build.mk b/util/ack/build.mk index 1b4fc146c..36e505c12 100644 --- a/util/ack/build.mk +++ b/util/ack/build.mk @@ -5,8 +5,8 @@ $(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) $(wordlist 2, $(words $g), $g): $(firstword $g) $(firstword $g): $(util-ack-mktables) @echo MKTABLES - @mkdir -p $(dir $g) - $(hide) cd $(dir $g) && $(util-ack-mktables) $(INSDIR)/share + @mkdir -p $(OBJDIR)/$D + $(hide) cd $(OBJDIR)/$D && $(util-ack-mktables) $(INSDIR)/share $(eval CLEANABLES += $g) endef From fc1b3672a36228bc7e0664d98542650984b049c1 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 18 May 2013 13:00:37 +0100 Subject: [PATCH 2/4] Reapply bugfix to sbrk() which got dropped during the move from linx386/libsys to liblinux. Set errno correctly. --- plat/linux/liblinux/brk.c | 6 +++++- plat/linux/liblinux/sbrk.c | 25 ++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plat/linux/liblinux/brk.c b/plat/linux/liblinux/brk.c index 8bb53d31d..7ce5c5fc8 100644 --- a/plat/linux/liblinux/brk.c +++ b/plat/linux/liblinux/brk.c @@ -5,9 +5,13 @@ #include #include +#include #include "libsys.h" int brk(void* end) { - return _syscall(__NR_brk, (quad) end, 0, 0); + int e = _syscall(__NR_brk, (quad) end, 0, 0); + if (e == -1) + errno = ENOMEM; + return e; } diff --git a/plat/linux/liblinux/sbrk.c b/plat/linux/liblinux/sbrk.c index 17b273f42..35810ef89 100644 --- a/plat/linux/liblinux/sbrk.c +++ b/plat/linux/liblinux/sbrk.c @@ -1,32 +1,39 @@ -/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/sbrk.c,v $ - * $State: Exp $ - * $Revision: 1.1 $ +/* $Source$ + * $State$ + * $Revision$ */ #include -#include #include +#include #include "libsys.h" #define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ -extern char _end[1]; - -static char* current = _end; +static char* current = NULL; void* sbrk(intptr_t increment) { char* old; char* new; + char* actual; + + if (!current) + current = (char*) _syscall(__NR_brk, 0, 0, 0); if (increment == 0) return current; old = current; new = old + increment; - if (brk(new) < 0) + + actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0); + if (actual < new) + { + errno = ENOMEM; return OUT_OF_MEMORY; + } - current = new; + current = actual; return old; } From e0c121d6e6d015806df2a95d53f36dd7b1834766 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 14:11:04 +0100 Subject: [PATCH 3/4] Use relocation enumerations rather than hard-coded values for relocation types (these were causing problems due to the enumeration values having changed). --- mach/proto/as/comm3.c | 6 +++--- mach/proto/as/comm7.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mach/proto/as/comm3.c b/mach/proto/as/comm3.c index a5490e249..f35d1818c 100644 --- a/mach/proto/as/comm3.c +++ b/mach/proto/as/comm3.c @@ -26,9 +26,9 @@ item_t keytab[] = { 0, EXTERN, 0, ".define", 0, EXTERN, 0, ".extern", 0, DOT, 0, ".", - 0, DATA, 1, ".data1", - 0, DATA, 2, ".data2", - 0, DATA, 4, ".data4", + 0, DATA, RELO1, ".data1", + 0, DATA, RELO2, ".data2", + 0, DATA, RELO4, ".data4", 0, ASCII, 0, ".ascii", 0, ASCII, 1, ".asciz", 0, ALIGN, 0, ".align", diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index fbbe42392..d0a147bdb 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -293,16 +293,16 @@ valu_t val; int n; { switch (n) { - case 1: + case RELO1: emit1((int)val); break; - case 2: + case RELO2: #ifdef BYTES_REVERSED emit1(((int)val>>8)); emit1((int)val); #else emit1((int)val); emit1(((int)val>>8)); #endif break; - case 4: + case RELO4: #ifdef WORDS_REVERSED emit2((int)(val>>16)); emit2((int)(val)); #else From 6fff2d45fece78dad2389b443cde3e0d24e44fac Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 14:48:51 +0100 Subject: [PATCH 4/4] Attempt to fix 64-bitness error in ashow. Deprecate the structure format macros in h/out.h because they make no sense on 64-bit platforms. --- h/out.h | 8 +++++++- util/amisc/ashow.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/h/out.h b/h/out.h index 122296f8e..0dffd2908 100644 --- a/h/out.h +++ b/h/out.h @@ -100,13 +100,19 @@ struct outname { /* * structure format strings */ +#if 0 +/* The following strings only make sense on 32-bit platforms, so we're going + * to try and deprecate them. */ #define SF_HEAD "22222244" #define SF_SECT "44444" #define SF_RELO "1124" #define SF_NAME "4224" +#endif /* - * structure sizes (bytes in file; add digits in SF_*) + * structure sizes on disk (bytes in file; add digits in SF_*) + * Note! These are NOT the sizes in memory (64-bit architectures will have + * a different layout). */ #define SZ_HEAD 20 #define SZ_SECT 20 diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index 5f22827ee..809937d71 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -70,7 +70,7 @@ show(headp) /* * We get all struct outname's and the strings in core first. */ - name = (struct outname *) myalloc(headp->oh_nname * SZ_NAME); + name = (struct outname *) myalloc(headp->oh_nname * sizeof(struct outname)); string = myalloc((unsigned) headp->oh_nchar); rd_name(name, headp->oh_nname); for (np = &name[0]; np < &name[headp->oh_nname]; np++) {