From 7435c06ff424913d9669c6172e03a1a6d7ab22b6 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 24 Nov 2016 20:48:51 +0100 Subject: [PATCH 01/20] Non-standard stdlib prototypes are not our friend (and not OSX's friend, which implements strcpy() &co as macros). --- util/LLgen/src/machdep.c | 1 - 1 file changed, 1 deletion(-) diff --git a/util/LLgen/src/machdep.c b/util/LLgen/src/machdep.c index 780951495..7fddf8eb2 100644 --- a/util/LLgen/src/machdep.c +++ b/util/LLgen/src/machdep.c @@ -57,7 +57,6 @@ libpath(s) string s; { register string p; register length; p_mem alloc(); - string strcpy(), strcat(); char* libdir = getenv("LLGEN_LIB_DIR"); if (!libdir) From b5980af06f7d907b01c95ea4a99f2a801828e5e8 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 24 Nov 2016 21:03:27 +0100 Subject: [PATCH 02/20] Linker groups don't work on OSX; go back to the hacky way of simply specifying the inputs multiple times, which seems to work. --- first/build.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/first/build.lua b/first/build.lua index 85df519a8..20eab73c8 100644 --- a/first/build.lua +++ b/first/build.lua @@ -220,7 +220,7 @@ definerule("cprogram", commands = { type="strings", default={ - "$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group" + "$(CC) -o %{outs[1]} %{ins} %{ins}" }, } }, From b8a2935f2bc6a3f9b06fbdfa21a56cc665b80d91 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 24 Nov 2016 21:26:05 +0100 Subject: [PATCH 03/20] Fix more invalid prototypes of stdlib functions; build dependency fix. --- lang/basic/src/bem.h | 9 +-------- lang/basic/src/build.lua | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lang/basic/src/bem.h b/lang/basic/src/bem.h index deb6eb435..eb1435802 100644 --- a/lang/basic/src/bem.h +++ b/lang/basic/src/bem.h @@ -3,6 +3,7 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ +#include #include #include #include @@ -73,11 +74,3 @@ extern Linerecord *currline; extern char *itoa(); extern char *salloc(); - -extern char *strcpy(); -extern char *strcat(); -#if __STDC__ -#include -#else -extern char *malloc(); -#endif diff --git a/lang/basic/src/build.lua b/lang/basic/src/build.lua index f4d6b94a8..eff53d6e9 100644 --- a/lang/basic/src/build.lua +++ b/lang/basic/src/build.lua @@ -24,6 +24,7 @@ cprogram { matching(filenamesof("+llgen"), "%.c$"), }, deps = { + "./*.h", "+llgen", "+tokentab_h", "h+emheaders", From 3e69d1185a81872d42542cc5453f38e2edff24ba Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 24 Nov 2016 21:47:40 +0100 Subject: [PATCH 04/20] Fix a whole lot more stray prototypes. --- lang/cem/cemcom.ansi/l_outdef.c | 1 - lang/cem/cemcom.ansi/replace.c | 1 - lang/cem/cpp.ansi/LLlex.c | 1 - lang/cem/cpp.ansi/replace.c | 2 -- lang/m2/m2mm/main.c | 3 +-- modules/src/em_code/insert.c | 3 +-- util/ego/em_ego/em_ego.c | 4 ---- util/ego/ic/ic_lookup.c | 2 -- util/led/main.c | 4 ++-- 9 files changed, 4 insertions(+), 17 deletions(-) diff --git a/lang/cem/cemcom.ansi/l_outdef.c b/lang/cem/cemcom.ansi/l_outdef.c index 32e2172b8..aab98a5b2 100644 --- a/lang/cem/cemcom.ansi/l_outdef.c +++ b/lang/cem/cemcom.ansi/l_outdef.c @@ -37,7 +37,6 @@ extern char *bts2str(); extern char *symbol2str(); -extern char *strchr(); int stat_number = 9999; /* static scope number */ struct outdef OutDef; diff --git a/lang/cem/cemcom.ansi/replace.c b/lang/cem/cemcom.ansi/replace.c index 50978be3c..11908e51b 100644 --- a/lang/cem/cemcom.ansi/replace.c +++ b/lang/cem/cemcom.ansi/replace.c @@ -24,7 +24,6 @@ extern struct idf *GetIdentifier(); extern int InputLevel; struct repl *ReplaceList; /* list of currently active macros */ -extern char *strcat(), *strcpy(); void macro2buffer(); void getactuals(); diff --git a/lang/cem/cpp.ansi/LLlex.c b/lang/cem/cpp.ansi/LLlex.c index dbf8d9ea1..7aa0a1eed 100644 --- a/lang/cem/cpp.ansi/LLlex.c +++ b/lang/cem/cpp.ansi/LLlex.c @@ -30,7 +30,6 @@ int LexSave = 0; /* last character read by GetChar */ extern int InputLevel; /* # of current macro expansions */ extern char *string_token(); -extern char *strcpy(); extern arith char_constant(); #define FLG_ESEEN 0x01 /* possibly a floating point number */ #define FLG_DOTSEEN 0x02 /* certainly a floating point number */ diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index cd7d60696..284b49524 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -21,8 +21,6 @@ #include "replace.h" extern char *GetIdentifier(); -extern char *strcpy(); -extern char *strcat(); extern int InputLevel; struct repl *ReplaceList; /* list of currently active macros */ diff --git a/lang/m2/m2mm/main.c b/lang/m2/m2mm/main.c index 8b951a8b8..2a8269736 100644 --- a/lang/m2/m2mm/main.c +++ b/lang/m2/m2mm/main.c @@ -11,6 +11,7 @@ /* $Id$ */ +#include #include #include "input.h" @@ -27,8 +28,6 @@ int nDEF, mDEF; struct file_list *CurrentArg; extern int err_occurred; extern int Roption; -extern char *strrchr(); -extern char *strcpy(), *strcat(); char * basename(s) diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index f7526b8e4..fd88cd4ec 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include "insert.h" @@ -134,8 +135,6 @@ C_findpart(part) return p; } -extern char *strcpy(), *strcat(), *mktemp(); - static swttmp() { diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 60a99ea5d..d29be7385 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -58,10 +58,6 @@ static const struct #define MAXARGS 1024 /* mar # of args */ #define NTEMPS 4 /* # of temporary files; not tunable */ -extern char* mktemp(); -extern char* strcpy(), *strcat(); -extern char* strrchr(); - static char ddump[128] = TMP_DIR; /* data label dump file */ static char pdump[128] = TMP_DIR; /* procedure name dump file */ static char tmpbufs[NTEMPS * 2][128] = { diff --git a/util/ego/ic/ic_lookup.c b/util/ego/ic/ic_lookup.c index 8a7afa233..34c2391fa 100644 --- a/util/ego/ic/ic_lookup.c +++ b/util/ego/ic/ic_lookup.c @@ -26,8 +26,6 @@ prc_p prochash[NPROCHASH]; num_p numhash[NNUMHASH]; char *lastname; -extern char *strcpy(); - #define newsym() (sym_p) newstruct(sym) #define newprc() (prc_p) newstruct(prc) #define newnum() (num_p) newstruct(num) diff --git a/util/led/main.c b/util/led/main.c index 2ec6ca2f8..b176514cb 100644 --- a/util/led/main.c +++ b/util/led/main.c @@ -10,7 +10,9 @@ static char rcsid[] = "$Id$"; * led - linkage editor for ACK assemblers output format */ +#include #include +#include #include #include "const.h" #include "debug.h" @@ -124,8 +126,6 @@ first_pass(argv) register char *argp; int sectno; int h; - extern int atoi(); - extern char *strchr(); extern int hash(); extern struct outname *searchname(); From f2e3d7b38ce2db0901278960c65b9de9267472c0 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 23 Jul 2017 21:19:07 +0200 Subject: [PATCH 05/20] Don't define functions called itoa(), because this causes problems on platforms that define itoa() in their libcs. --- lang/basic/src/basic.lex | 2 +- lang/basic/src/bem.h | 2 +- lang/basic/src/gencode.c | 2 +- lang/basic/src/util.c | 2 +- lang/occam/comp/em.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index 4eb9e1659..3ee185e3f 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -522,7 +522,7 @@ scanstring() yylval.integer= genemlabel(); C_rom_dlb((label)i,(arith)0); C_rom_icon("9999",(arith)BEMINTSIZE); - C_rom_icon(itoa(length),(arith)BEMINTSIZE); + C_rom_icon(myitoa(length),(arith)BEMINTSIZE); } #ifdef YYDEBUG if (yydebug) print("STRVALUE found\n"); diff --git a/lang/basic/src/bem.h b/lang/basic/src/bem.h index deb6eb435..d49523cd4 100644 --- a/lang/basic/src/bem.h +++ b/lang/basic/src/bem.h @@ -71,7 +71,7 @@ extern int dataused; extern Linerecord *currline; -extern char *itoa(); +extern char *myitoa(); extern char *salloc(); extern char *strcpy(); diff --git a/lang/basic/src/gencode.c b/lang/basic/src/gencode.c index 8fb611dc0..710de169d 100644 --- a/lang/basic/src/gencode.c +++ b/lang/basic/src/gencode.c @@ -670,7 +670,7 @@ gendata() C_df_dnam("datfdes"); C_rom_dnam("datfname",(arith)0); C_rom_cst((arith)1); - C_rom_cst((arith)(itoa(strlen(datfname)))); + C_rom_cst((arith)(myitoa(strlen(datfname)))); C_df_dnam("dattdes"); C_rom_dnam("dattyp",(arith)0); C_rom_cst((arith)1); diff --git a/lang/basic/src/util.c b/lang/basic/src/util.c index ff98cf82b..a85339bc5 100644 --- a/lang/basic/src/util.c +++ b/lang/basic/src/util.c @@ -69,7 +69,7 @@ illegalcmd() -char *itoa(i) +char *myitoa(i) int i; { static char buf[30]; diff --git a/lang/occam/comp/em.c b/lang/occam/comp/em.c index ecd779824..605817371 100644 --- a/lang/occam/comp/em.c +++ b/lang/occam/comp/em.c @@ -355,7 +355,7 @@ void zgt(lab) int lab; { C_zgt((label) lab); } void zlt(lab) int lab; { C_zlt((label) lab); } void zne(lab) int lab; { C_zne((label) lab); } -char *itoa(i) long i; +char *myitoa(i) long i; { static char a[sizeof(long)*3]; sprint(a, "%ld", i); @@ -364,7 +364,7 @@ char *itoa(i) long i; void rom(size, c) int size; long c; { - C_rom_icon(itoa(c), (arith) size); + C_rom_icon(myitoa(c), (arith) size); } void lin() From 064fd52d52aeaa4d0ca549bfbcac416d3a6b7056 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 2 Aug 2017 00:07:51 +0200 Subject: [PATCH 06/20] Update man page not to mention the filename length restriction removed in 893471a42eb4d189cc0ba1dac1864d6f151bccd7. --- lang/m2/comp/modula-2.1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lang/m2/comp/modula-2.1 b/lang/m2/comp/modula-2.1 index 206d33bb7..ee9bc94bd 100644 --- a/lang/m2/comp/modula-2.1 +++ b/lang/m2/comp/modula-2.1 @@ -19,11 +19,6 @@ Implementation modules and program modules must reside in files having a .PP The name of the file in which a definition module is stored must be the same as the module-name, apart from the extension. -Also, in most Unix systems filenames are only 14 characters long. -So, given an IMPORT declaration for a module called "LongModulName", -the compiler will try to open a file called "LongModulN.def". -The requirement does not hold for implementation or program modules, -but is certainly recommended. .SH CALLING THE COMPILER The easiest way to do this is to let the \fIack\fR(1) program do it. So, to compile a program module "prog.mod", just call From 7ff0b65a0dbc7de4d908a424a5c043194a241826 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 5 Aug 2017 21:46:43 +0200 Subject: [PATCH 07/20] Add missing headers. --- modules/src/object/obj.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/src/object/obj.h b/modules/src/object/obj.h index 8f7fd8d32..9000b32ce 100644 --- a/modules/src/object/obj.h +++ b/modules/src/object/obj.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include From e238227ba3e7433cddbd54b8f3d4287a26cab912 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 10:44:38 +0200 Subject: [PATCH 08/20] Build with linux/clang; try building on osx/clang. --- .travis.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f06e5aca3..c1c9ae5dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,17 @@ matrix: include: - - os: linux + - + os: linux + compiler: gcc + include: + - + os: linux + compiler: clang + include: + - + os: osx + env: HOMEBREW_NO_AUTO_UPDATE=1 + compiler: clang addons: apt: From 6c6222cc660c839ef7cd7aa276aee0fef170c77a Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 10:56:40 +0200 Subject: [PATCH 09/20] Try using trusty and non-sudo build environments. --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1c9ae5dc..37e7ce2bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,17 @@ +language: c + matrix: include: - os: linux + sudo: false + dist: trusty compiler: gcc include: - os: linux + sudo: false + dist: trusty compiler: clang include: - @@ -21,7 +27,6 @@ addons: git: depth: 10 -language: c script: - make PREFIX=/tmp/acki From a1043bc5fed550bd757a5bd9673e53bd01d9be79 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 11:15:53 +0200 Subject: [PATCH 10/20] Attempt to correct file system case sensitivity. --- lang/m2/comp/build.lua | 12 ++++++------ lang/m2/comp/{casestat.C => casestat.xc} | 0 lang/m2/comp/{def.H => def.xh} | 0 lang/m2/comp/{node.H => node.xh} | 0 lang/m2/comp/{real.H => real.xh} | 0 lang/m2/comp/{scope.C => scope.xc} | 0 lang/m2/comp/{tmpvar.C => tmpvar.xc} | 0 lang/m2/comp/{type.H => type.xh} | 0 lang/pc/comp/build.lua | 12 ++++++------ lang/pc/comp/{casestat.C => casestat.xc} | 0 lang/pc/comp/{def.H => def.xh} | 0 lang/pc/comp/{desig.H => desig.xh} | 0 lang/pc/comp/{node.H => node.xh} | 0 lang/pc/comp/{scope.H => scope.xh} | 0 lang/pc/comp/{tmpvar.C => tmpvar.xc} | 0 lang/pc/comp/{type.H => type.xh} | 0 16 files changed, 12 insertions(+), 12 deletions(-) rename lang/m2/comp/{casestat.C => casestat.xc} (100%) rename lang/m2/comp/{def.H => def.xh} (100%) rename lang/m2/comp/{node.H => node.xh} (100%) rename lang/m2/comp/{real.H => real.xh} (100%) rename lang/m2/comp/{scope.C => scope.xc} (100%) rename lang/m2/comp/{tmpvar.C => tmpvar.xc} (100%) rename lang/m2/comp/{type.H => type.xh} (100%) rename lang/pc/comp/{casestat.C => casestat.xc} (100%) rename lang/pc/comp/{def.H => def.xh} (100%) rename lang/pc/comp/{desig.H => desig.xh} (100%) rename lang/pc/comp/{node.H => node.xh} (100%) rename lang/pc/comp/{scope.H => scope.xh} (100%) rename lang/pc/comp/{tmpvar.C => tmpvar.xc} (100%) rename lang/pc/comp/{type.H => type.xh} (100%) diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua index 4e12d24f7..490947508 100644 --- a/lang/m2/comp/build.lua +++ b/lang/m2/comp/build.lua @@ -31,8 +31,8 @@ normalrule { } } -for _, f in ipairs(filenamesof("./*.H")) do - local name = replace(basename(f), "%.H$", "") +for _, f in ipairs(filenamesof("./*.xh")) do + local name = replace(basename(f), "%.xh$", "") normalrule { name = name.."_h", ins = { @@ -46,8 +46,8 @@ for _, f in ipairs(filenamesof("./*.H")) do } end -for _, f in ipairs(filenamesof("./*.C")) do - local name = replace(basename(f), "%.C$", "") +for _, f in ipairs(filenamesof("./*.xc")) do + local name = replace(basename(f), "%.xc$", "") normalrule { name = name.."_c", ins = { @@ -65,8 +65,8 @@ normalrule { name = "next_c", ins = { "./make.next", - "./*.H", - "./*.C", + "./*.xh", + "./*.xc", }, outleaves = { "next.c" }, commands = { diff --git a/lang/m2/comp/casestat.C b/lang/m2/comp/casestat.xc similarity index 100% rename from lang/m2/comp/casestat.C rename to lang/m2/comp/casestat.xc diff --git a/lang/m2/comp/def.H b/lang/m2/comp/def.xh similarity index 100% rename from lang/m2/comp/def.H rename to lang/m2/comp/def.xh diff --git a/lang/m2/comp/node.H b/lang/m2/comp/node.xh similarity index 100% rename from lang/m2/comp/node.H rename to lang/m2/comp/node.xh diff --git a/lang/m2/comp/real.H b/lang/m2/comp/real.xh similarity index 100% rename from lang/m2/comp/real.H rename to lang/m2/comp/real.xh diff --git a/lang/m2/comp/scope.C b/lang/m2/comp/scope.xc similarity index 100% rename from lang/m2/comp/scope.C rename to lang/m2/comp/scope.xc diff --git a/lang/m2/comp/tmpvar.C b/lang/m2/comp/tmpvar.xc similarity index 100% rename from lang/m2/comp/tmpvar.C rename to lang/m2/comp/tmpvar.xc diff --git a/lang/m2/comp/type.H b/lang/m2/comp/type.xh similarity index 100% rename from lang/m2/comp/type.H rename to lang/m2/comp/type.xh diff --git a/lang/pc/comp/build.lua b/lang/pc/comp/build.lua index a2cb9accb..c10c1793f 100644 --- a/lang/pc/comp/build.lua +++ b/lang/pc/comp/build.lua @@ -31,8 +31,8 @@ normalrule { } } -for _, f in ipairs(filenamesof("./*.H")) do - local name = replace(basename(f), "%.H$", "") +for _, f in ipairs(filenamesof("./*.xh")) do + local name = replace(basename(f), "%.xh$", "") normalrule { name = name.."_h", ins = { @@ -46,8 +46,8 @@ for _, f in ipairs(filenamesof("./*.H")) do } end -for _, f in ipairs(filenamesof("./*.C")) do - local name = replace(basename(f), "%.C$", "") +for _, f in ipairs(filenamesof("./*.xc")) do + local name = replace(basename(f), "%.xc$", "") normalrule { name = name.."_c", ins = { @@ -65,8 +65,8 @@ normalrule { name = "next_c", ins = { "./make.next", - "./*.H", - "./*.C", + "./*.xh", + "./*.xc", }, outleaves = { "next.c" }, commands = { diff --git a/lang/pc/comp/casestat.C b/lang/pc/comp/casestat.xc similarity index 100% rename from lang/pc/comp/casestat.C rename to lang/pc/comp/casestat.xc diff --git a/lang/pc/comp/def.H b/lang/pc/comp/def.xh similarity index 100% rename from lang/pc/comp/def.H rename to lang/pc/comp/def.xh diff --git a/lang/pc/comp/desig.H b/lang/pc/comp/desig.xh similarity index 100% rename from lang/pc/comp/desig.H rename to lang/pc/comp/desig.xh diff --git a/lang/pc/comp/node.H b/lang/pc/comp/node.xh similarity index 100% rename from lang/pc/comp/node.H rename to lang/pc/comp/node.xh diff --git a/lang/pc/comp/scope.H b/lang/pc/comp/scope.xh similarity index 100% rename from lang/pc/comp/scope.H rename to lang/pc/comp/scope.xh diff --git a/lang/pc/comp/tmpvar.C b/lang/pc/comp/tmpvar.xc similarity index 100% rename from lang/pc/comp/tmpvar.C rename to lang/pc/comp/tmpvar.xc diff --git a/lang/pc/comp/type.H b/lang/pc/comp/type.xh similarity index 100% rename from lang/pc/comp/type.H rename to lang/pc/comp/type.xh From 60e7d06d82703f3a9d727e4788ba00b791277fd2 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 11:58:36 +0200 Subject: [PATCH 11/20] Ansification and warning fixes. --- lang/m2/comp/input.c | 4 +- modules/src/input/AtEoIF.c | 2 +- modules/src/input/AtEoIT.c | 2 +- modules/src/input/inp_pkg.body | 18 ++++---- modules/src/object/object.h | 2 +- modules/src/object/rd.c | 49 +++++++------------- util/led/memory.c | 8 ++-- util/led/memory.h | 2 + util/led/scan.c | 84 ++++++++++++++-------------------- util/led/scan.h | 9 ++++ 10 files changed, 79 insertions(+), 101 deletions(-) diff --git a/lang/m2/comp/input.c b/lang/m2/comp/input.c index ef8ee2982..ad53b50e8 100644 --- a/lang/m2/comp/input.c +++ b/lang/m2/comp/input.c @@ -19,7 +19,7 @@ struct f_info file_info; #include -AtEoIF() +int AtEoIF(void) { /* Make the unstacking of input streams noticable to the lexical analyzer @@ -28,7 +28,7 @@ AtEoIF() return 1; } -AtEoIT() +int AtEoIT(void) { /* Make the end of the text noticable */ diff --git a/modules/src/input/AtEoIF.c b/modules/src/input/AtEoIF.c index 4fbb4d556..5bf9a6000 100644 --- a/modules/src/input/AtEoIF.c +++ b/modules/src/input/AtEoIF.c @@ -8,7 +8,7 @@ inserted file. */ int -AtEoIF() +AtEoIF(void) { return 0; } diff --git a/modules/src/input/AtEoIT.c b/modules/src/input/AtEoIT.c index 977b0cc10..64b15ba7a 100644 --- a/modules/src/input/AtEoIT.c +++ b/modules/src/input/AtEoIT.c @@ -8,7 +8,7 @@ inserted text. */ int -AtEoIT() +AtEoIT(void) { return 0; } diff --git a/modules/src/input/inp_pkg.body b/modules/src/input/inp_pkg.body index 3cca88a17..6de4a5268 100644 --- a/modules/src/input/inp_pkg.body +++ b/modules/src/input/inp_pkg.body @@ -20,7 +20,7 @@ A default one is provided, which does nothing. AtEoIF() : this routine is called at the end of an inserted file. A default one is provided, which does nothing. - + Imported objects are: INP_NPUSHBACK, INP_READ_IN_ONE, INP_TYPE, INP_VAR, routines from the "alloc" package, routines from the "storage" @@ -110,7 +110,7 @@ INP_rdfile(fd, fn, size, pbuf) int rsize; if ( - (*size = sys_filesize(fn)) < 0 + ((*size = sys_filesize(fn))) < 0 || ((unsigned) (*size + 1) != (*size + 1)) || @@ -140,7 +140,7 @@ _PROTOTYPE(INP_PRIVATE char * INP_pbuf, (void)); INP_PRIVATE char * INP_pbuf() { - register struct INP_i_buf *ib = + register struct INP_i_buf *ib = (struct INP_i_buf *) malloc(sizeof(struct INP_i_buf)); if (!ib) return 0; @@ -164,7 +164,7 @@ INP_push_bh() { register struct INP_buffer_header *bh; - if (bh = INP_head) { + if ((bh = INP_head)) { bh->bh_ipp = _ipp; #ifdef INP_TYPE bh->bh_i = INP_VAR; @@ -247,10 +247,10 @@ INP_mk_filename(dir, file, newname) if (!dst) return 0; *newname = dst; if (*dir) { - while (*dst++ = *dir++) ; + while ((*dst++ = *dir++)) ; *(dst-1) = '/'; } - while (*dst++ = *file++); + while ((*dst++ = *file++)); return 1; } @@ -278,13 +278,13 @@ InsertFile(filnam, table, result) if (!sys_open(filnam, OP_READ, &fd)) return 0; } else { - while (*table) { + while (*table) { /* look in the directory table */ if (!INP_mk_filename(*table++, filnam, &newfn)) { return 0; } if (sys_open(newfn, OP_READ, &fd)) { - /* free filnam ??? NO we don't know + /* free filnam ??? NO we don't know where it comes from! */ filnam = newfn; @@ -378,7 +378,7 @@ loadbuf() *--de = *--so; } #endif - if ( INP_rdblock(bh->bh_fd, bh->bh_text, &(bh->bh_size)) + if ( INP_rdblock(bh->bh_fd, bh->bh_text, &(bh->bh_size)) && bh->bh_size > 0 ) { diff --git a/modules/src/object/object.h b/modules/src/object/object.h index d6c218a2a..54e20e26c 100644 --- a/modules/src/object/object.h +++ b/modules/src/object/object.h @@ -36,7 +36,7 @@ void rd_sect(struct outsect *s, unsigned int c); void rd_outsect(int sectno); void rd_emit(char *b, long c); void rd_relo(struct outrelo *r, unsigned int c); -void rd_rew_relo(struct outhead *head); +void rd_rew_relos(struct outhead *head); void rd_name(struct outname *n, unsigned int c); void rd_string(char *s, long c); int rd_arhdr(int fd, struct ar_hdr *a); diff --git a/modules/src/object/rd.c b/modules/src/object/rd.c index 7790a4720..54610a0dc 100644 --- a/modules/src/object/rd.c +++ b/modules/src/object/rd.c @@ -40,9 +40,7 @@ static long rd_base; static int sectionnr; static void -OUTREAD(p, b, n) - char *b; - long n; +OUTREAD(int p, char* b, long n) { register long l = outseek[p]; @@ -59,8 +57,7 @@ OUTREAD(p, b, n) * Open the output file according to the chosen strategy. */ int -rd_open(f) - char *f; +rd_open(char* f) { if ((outfile = open(f, 0)) < 0) @@ -71,7 +68,7 @@ rd_open(f) static int offcnt; int -rd_fdopen(fd) +rd_fdopen(int fd) { register int i; @@ -89,7 +86,7 @@ rd_fdopen(fd) } void -rd_close() +rd_close(void) { close(outfile); @@ -97,21 +94,20 @@ rd_close() } int -rd_fd() +rd_fd(void) { return outfile; } void -rd_ohead(head) - register struct outhead *head; +rd_ohead(struct outhead* head) { register long off; OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD); { register char *c = (char *) head + (SZ_HEAD-4); - + head->oh_nchar = get4(c); c -= 4; head->oh_nemit = get4(c); c -= 2; head->oh_nname = uget2(c); @@ -134,8 +130,7 @@ rd_ohead(head) } void -rd_rew_relos(head) - register struct outhead *head; +rd_rew_relos(struct outhead* head) { register long off = OFF_RELO(*head) + rd_base; @@ -143,9 +138,7 @@ rd_rew_relos(head) } void -rd_sect(sect, cnt) - register struct outsect *sect; - register unsigned int cnt; +rd_sect(struct outsect* sect, unsigned int cnt) { register char *c = (char *) sect + cnt * SZ_SECT; @@ -166,7 +159,7 @@ rd_sect(sect, cnt) } void -rd_outsect(s) +rd_outsect(int s) { OUTSECT(s); sectionnr = s; @@ -176,18 +169,14 @@ rd_outsect(s) * We don't have to worry about byte order here. */ void -rd_emit(emit, cnt) - char *emit; - long cnt; +rd_emit(char* emit, long cnt) { OUTREAD(PARTEMIT, emit, cnt); offset[sectionnr] += cnt; } void -rd_relo(relo, cnt) - register struct outrelo *relo; - register unsigned int cnt; +rd_relo(struct outrelo* relo, unsigned int cnt) { OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); @@ -206,9 +195,7 @@ rd_relo(relo, cnt) } void -rd_name(name, cnt) - register struct outname *name; - register unsigned int cnt; +rd_name(struct outname* name, unsigned int cnt) { OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME); @@ -227,19 +214,15 @@ rd_name(name, cnt) } void -rd_string(addr, len) - char *addr; - long len; +rd_string(char* addr, long len) { - + OUTREAD(PARTCHAR, addr, len); } #ifdef SYMDBUG void -rd_dbug(buf, size) - char *buf; - long size; +rd_dbug(char* buf, long size) { OUTREAD(PARTDBUG, buf, size); } diff --git a/util/led/memory.c b/util/led/memory.c index df4ee99d9..40db843ba 100644 --- a/util/led/memory.c +++ b/util/led/memory.c @@ -473,8 +473,8 @@ free_saved_moduls() * The piece of memory with index `piece' is no longer needed. * We take care that it can be used by compact() later, if needed. */ -dealloc(piece) - register int piece; +void +dealloc(int piece) { /* * Some pieces need their memory throughout the program. @@ -499,9 +499,7 @@ core_alloc(piece, size) return address(piece, off); } -core_free(piece, p) - int piece; - char *p; +void core_free(int piece, char* p) { char *q = address(piece, mems[piece].mem_full); diff --git a/util/led/memory.h b/util/led/memory.h index 79d4c5266..2d2f33063 100644 --- a/util/led/memory.h +++ b/util/led/memory.h @@ -40,3 +40,5 @@ extern struct memory mems[]; extern ind_t core_position; extern ind_t hard_alloc(); extern ind_t alloc(); +extern void dealloc(int piece); +extern void core_free(int piece, char* p); diff --git a/util/led/scan.c b/util/led/scan.c index 1740a14de..d65a2c3cf 100644 --- a/util/led/scan.c +++ b/util/led/scan.c @@ -10,13 +10,17 @@ static char rcsid[] = "$Id$"; #include #include #include -#ifdef SYMDBUG +#include #include #include +#include +#include +#ifdef SYMDBUG #endif /* SYMDBUG */ #include "arch.h" #include "out.h" #include "ranlib.h" +#include "object.h" #include "const.h" #include "assert.h" #include "memory.h" @@ -42,20 +46,21 @@ char *modulname; /* Name of object module. */ long objectsize; #endif /* SYMDBUG */ -static long align(); +static long align(long size); static char *modulbase; -static long modulsize(); -static scan_modul(); -static bool all_alloc(); -static bool direct_alloc(); -static bool indirect_alloc(); -static bool putemitindex(); -static bool putreloindex(); +static long modulsize(struct outhead* head); +static void can_modul(void); +static bool all_alloc(void); +static bool direct_alloc(struct outhead* head); +static bool indirect_alloc(struct outhead* head); +static bool putemitindex(ind_t sectindex, ind_t emitoff, int allopiece); +static bool putreloindex(ind_t relooff, long nrelobytes); #ifdef SYMDBUG -static bool putdbugindex(); +static bool putdbugindex(ind_t dbugoff, long ndbugbytes); #endif /* SYMDBUG */ -static get_indirect(); -static read_modul(); +static void get_indirect(struct outhead* head, struct outsect* sect); +static void read_modul(void); +static void scan_modul(void); /* * Open the file with name `filename' (if necessary) and examine the first @@ -117,16 +122,13 @@ getfile(filename) /* NOTREACHED */ } -/* ARGSUSED */ -closefile(filename) - char *filename; +void closefile(char* filename) { if (passnumber == FIRST || !incore) close(infile); } -get_archive_header(archive_header) - register struct ar_hdr *archive_header; +void get_archive_header(struct ar_hdr* archive_header) { if (passnumber == FIRST || !incore) { rd_arhdr(infile, archive_header); @@ -141,7 +143,7 @@ get_archive_header(archive_header) #endif /* SYMDBUG */ } -get_modul() +void get_modul(void) { if (passnumber == FIRST) { rd_fdopen(infile); @@ -157,8 +159,8 @@ get_modul() * to keep everything in core is abandoned, but we will always put the header, * the section table, and the name and string table into core. */ -static -scan_modul() +static void +scan_modul(void) { bool space; struct outhead *head; @@ -190,7 +192,7 @@ scan_modul() * this was possible. */ static bool -all_alloc() +all_alloc(void) { struct outhead head; extern ind_t hard_alloc(); @@ -287,10 +289,7 @@ indirect_alloc(head) * `emitoff'. */ static bool -putemitindex(sectindex, emitoff, allopiece) - ind_t sectindex; - ind_t emitoff; - int allopiece; +putemitindex(ind_t sectindex, ind_t emitoff, int allopiece) { long flen; ind_t emitindex; @@ -330,9 +329,7 @@ putemitindex(sectindex, emitoff, allopiece) * offset at `relooff'. */ static bool -putreloindex(relooff, nrelobytes) - ind_t relooff; - long nrelobytes; +putreloindex(ind_t relooff, long nrelobytes) { ind_t reloindex; extern ind_t alloc(); @@ -348,9 +345,7 @@ putreloindex(relooff, nrelobytes) * Allocate space for debugging information and put the offset at `dbugoff'. */ static bool -putdbugindex(dbugoff, ndbugbytes) - ind_t relooff; - long ndbugbytes; +putdbugindex(ind_t dbugoff, long ndbugbytes) { ind_t dbugindex; extern ind_t alloc(); @@ -367,12 +362,8 @@ putdbugindex(dbugoff, ndbugbytes) * Compute addresses and read in. Remember that the contents of the sections * and also the relocation table are accessed indirectly. */ -static -get_indirect(head, sect) - struct outhead *head; /* not register! Won't compile on - SCO Xenix 386 if it is! - */ - register struct outsect *sect; +static void +get_indirect(struct outhead* head, struct outsect* sect) { register ind_t *emitindex; register int nsect; @@ -395,8 +386,7 @@ get_indirect(head, sect) /* * Set the file pointer at `pos'. */ -seek(pos) - long pos; +void seek(long pos) { if (passnumber == FIRST || !incore) lseek(infile, pos, 0); @@ -407,8 +397,7 @@ seek(pos) * is not. That's why we do it here. If we don't keep everything in core, * we give the space allocated for a module back. */ -skip_modul(head) - struct outhead *head; +void skip_modul(struct outhead* head) { register ind_t skip = modulsize(head); @@ -425,8 +414,8 @@ skip_modul(head) /* * Read in what we need in pass 2, because we couldn't keep it in core. */ -static -read_modul() +static void +read_modul(void) { struct outhead *head; register struct outsect *sects; @@ -524,8 +513,7 @@ static unsigned short cnt_relos; static unsigned short relind; #define _RELSIZ 64 -startrelo(head) - register struct outhead *head; +void startrelo(struct outhead* head) { ind_t reloindex; @@ -540,8 +528,7 @@ startrelo(head) } } -struct outrelo * -nextrelo() +struct outrelo* nextrelo(void) { static struct outrelo relobuf[_RELSIZ]; @@ -615,8 +602,7 @@ getblk(totalsz, pblksz, sectindex) return (char *) 0; } -endemit(emit) - char *emit; +void endemit(char* emit) { core_free(ALLOMODL, emit); } diff --git a/util/led/scan.h b/util/led/scan.h index 1ceb054f7..b8e55cfa9 100644 --- a/util/led/scan.h +++ b/util/led/scan.h @@ -15,3 +15,12 @@ #ifdef SYMDBUG #define OFF_DBUG(x) (OFF_CHAR(x) + (x).oh_nchar) #endif /* SYMDBUG */ + +extern void seek(long pos); +extern void closefile(char* filename); +extern void get_archive_header(struct ar_hdr* archive_header); +extern void get_modul(void); +extern void skip_modul(struct outhead* head); +extern void startrelo(struct outhead* head); +extern struct outrelo* nextrelo(void); +extern void endemit(char* emit); From b79d9fd7f48953754b2f3e084490d9c86db69871 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 12:38:38 +0200 Subject: [PATCH 12/20] Turn off OSX Travis builds --- this is going to be hard to make work. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37e7ce2bd..47dc3a685 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,11 +13,11 @@ matrix: sudo: false dist: trusty compiler: clang - include: - - - os: osx - env: HOMEBREW_NO_AUTO_UPDATE=1 - compiler: clang +# include: +# - +# os: osx +# env: HOMEBREW_NO_AUTO_UPDATE=1 +# compiler: clang addons: apt: From 789f79b369358062001a13bc87db8223bd779843 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 12:42:17 +0200 Subject: [PATCH 13/20] Ansification, warning fixes, C89ification. --- modules/h/em_label.h | 4 ++++ util/arch/archiver.c | 16 +++++++--------- util/mcgg/iburg.c | 14 +++++++------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/modules/h/em_label.h b/modules/h/em_label.h index 018b0d345..2ff378274 100644 --- a/modules/h/em_label.h +++ b/modules/h/em_label.h @@ -4,5 +4,9 @@ */ /* $Id$ */ +#ifndef _MODULES_H_EM_LABEL_H +#define _MODULES_H_EM_LABEL_H + typedef unsigned int label; +#endif diff --git a/util/arch/archiver.c b/util/arch/archiver.c index bae09a168..65684232a 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -109,7 +109,7 @@ char *temp_arch = &temp_buf[0]; extern char *mktemp(); extern char *ctime(); -void do_object(); +void do_object(int f, long size); void write_symdef(); void add(); @@ -184,7 +184,7 @@ register int mode; magic = rd_unsigned2(fd); if (magic != AALMAG && magic != ARMAG) error(TRUE, "%s is not in ar format\n", name); - + return fd; } @@ -206,7 +206,7 @@ char *argv[]; if (argc < 3) usage(); - + for (ptr = argv[1]; *ptr; ptr++) { switch (*ptr) { case 't' : @@ -268,7 +268,7 @@ char *argv[]; if (app_fl + ex_fl + del_fl + rep_fl + show_fl + pr_fl != 1) usage(); - + if (u_fl && ! rep_fl) usage(); @@ -289,7 +289,7 @@ char *argv[]; signal(SIGINT, catch); get(argc, argv); - + return 0; } @@ -678,7 +678,7 @@ write_symdef() } /* - * Return whether the bytes in `buf' form a good object header. + * Return whether the bytes in `buf' form a good object header. * The header is put in `headp'. */ int @@ -689,9 +689,7 @@ is_outhead(headp) return !BADMAGIC(*headp) && headp->oh_nname != 0; } -void -do_object(f, size) - long size; +void do_object(int f, long size) { struct outhead headbuf; diff --git a/util/mcgg/iburg.c b/util/mcgg/iburg.c index 23705c7d8..4441b6a4a 100644 --- a/util/mcgg/iburg.c +++ b/util/mcgg/iburg.c @@ -136,7 +136,7 @@ int main(int argc, char* argv[]) exit(1); } } - + emitheader(); registerterminals(); @@ -1074,7 +1074,7 @@ static bool find_child_index(Tree node, const char* name, int* index, Tree* foun return true; return false; } - + static void emit_predicate_expr(Rule r, struct expr* p) { bool first = true; @@ -1254,10 +1254,10 @@ static void emitinsndata(Rule rules) int index = 0; emit_input_regs(r->pattern, &index); } - + emit_output_constraints(r); emit_input_constraints(r); - + while (f) { char* data = strdup(f->data); @@ -1276,10 +1276,10 @@ static void emitinsndata(Rule rules) { Tree node; int index = 0; + Nonterm nt; + if (!find_child_index(r->pattern, label, &index, &node)) label_not_found(r, label); - Nonterm nt = node->op; - if (nt->kind == NONTERM) { if (nt->is_fragment) @@ -1310,7 +1310,7 @@ static void emitinsndata(Rule rules) assert(f->data[1] == 0); print("%1data->emit_eoi();\n"); break; - + default: print("%1data->emit_string(\"%s\");\n", f->data); } From 64f2fa9d4672d4ec5a1ac4894d10dce57c72f805 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 13:22:05 +0200 Subject: [PATCH 14/20] Stop using mktemp() --- on Haiku, it always generates the same filenames, pretty much guaranteeing temporary file overwrites on parallel builds. Use mkstemp() instead which creates the files atomically. --- mach/proto/as/comm7.c | 3 ++- modules/src/em_code/insert.c | 5 +++-- modules/src/system/lock.c | 6 +++--- util/LLgen/src/main.c | 5 ++--- util/amisc/astrip.c | 6 ++---- util/arch/archiver.c | 3 +-- util/byacc/main.c | 11 ++++------- util/ego/em_ego/em_ego.c | 8 ++++---- util/ego/il/il.c | 8 ++++---- util/flex/main.c | 7 ++++--- util/opt/main.c | 3 +-- 11 files changed, 30 insertions(+), 35 deletions(-) diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index 3c7871fbe..e95037305 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -363,7 +363,8 @@ char *path, *tail; if ((dir = getenv("TMPDIR")) == NULL) dir = tmp_dir; sprintf(path, "%s/%s", dir, tail); - return(ffcreat(mktemp(path))); + close(mkstemp(path)); + return(ffcreat(path)); } /* ---------- Error handling ---------- */ diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index fd88cd4ec..36950c3ea 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -145,7 +145,8 @@ swttmp() strcpy(p, C_tmpdir); strcat(p, "/CodeXXXXXX"); - C_tmpfile = mktemp(p); + close(mkstemp(p)); + C_tmpfile = p; if (! sys_open(p, OP_WRITE, &C_old_ofp)) { C_failed(); } @@ -250,7 +251,7 @@ mkpart(part) */ register Part *p = C_findpart(part); register int index = part % TABSIZ; - + if (p != 0) { /* multiple defined part ... */ C_internal_error(); diff --git a/modules/src/system/lock.c b/modules/src/system/lock.c index 0f6be5985..6f00a3a16 100644 --- a/modules/src/system/lock.c +++ b/modules/src/system/lock.c @@ -4,6 +4,8 @@ */ /* $Id$ */ +#include +#include #include "system.h" int @@ -12,7 +14,6 @@ sys_lock(path) { char buf[1024]; char *tmpf = ".lockXXXXXX"; - char *strrchr(), *strcpy(), *mktemp(); char *p; int ok, fd; @@ -23,8 +24,7 @@ sys_lock(path) } else strcpy(buf, tmpf); - mktemp(buf); - if ((fd = creat(buf, 0)) < 0) + if ((fd = mkstemp(buf)) < 0) return 0; close(fd); ok = (link(buf, path) == 0); diff --git a/util/LLgen/src/main.c b/util/LLgen/src/main.c index ca4b05f22..1bd31aa46 100644 --- a/util/LLgen/src/main.c +++ b/util/LLgen/src/main.c @@ -37,7 +37,6 @@ extern fatal(); extern comfatal(); extern copyfile(); extern void install(); -extern char *mktemp(); extern char *sbrk(); main(argc,argv) register string argv[]; { @@ -164,8 +163,8 @@ main(argc,argv) register string argv[]; { nc_rec_file = libpath ("nc_rec"); } #endif - mktemp(f_temp); - mktemp(f_pars); + close(mkstemp(f_temp)); + close(mkstemp(f_pars)); if ((fact = fopen(f_temp,"w")) == NULL) { fputs("Cannot create temporary\n",stderr); exit(1); diff --git a/util/amisc/astrip.c b/util/amisc/astrip.c index e96617abf..e82cb27f1 100644 --- a/util/amisc/astrip.c +++ b/util/amisc/astrip.c @@ -17,8 +17,6 @@ char temp_name[] = "/tmp/sXXXXXX"; char *tname; -char *mktemp(); -FILE *fopen(); FILE *tf; struct outhead buf; int readerror, writeerror; @@ -31,12 +29,12 @@ char **argv; signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); - tname = mktemp(temp_name); + close(mkstemp(temp_name)); while(--argc) { if ((status = strip(argv[argc])) > 1) break; } - unlink(tname); + unlink(temp_name); exit(status); } diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 65684232a..2be5fd3ad 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -106,7 +106,6 @@ char *progname; char temp_buf[32]; char *temp_arch = &temp_buf[0]; -extern char *mktemp(); extern char *ctime(); void do_object(int f, long size); @@ -277,7 +276,7 @@ char *argv[]; || app_fl #endif ) { - mktemp(temp_arch); + close(mkstemp(temp_arch)); } #ifdef AAL tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib)); diff --git a/util/byacc/main.c b/util/byacc/main.c index 32982239c..b7f5e8f0c 100644 --- a/util/byacc/main.c +++ b/util/byacc/main.c @@ -1,3 +1,4 @@ +#include #include #include "defs.h" @@ -56,10 +57,6 @@ char *rassoc; short **derives; char *nullable; -extern char *mktemp(); -extern char *getenv(); - - done(k) int k; { @@ -253,9 +250,9 @@ create_file_names() text_file_name[len + 5] = 't'; union_file_name[len + 5] = 'u'; - mktemp(action_file_name); - mktemp(text_file_name); - mktemp(union_file_name); + close(mkstemp(action_file_name)); + close(mkstemp(text_file_name)); + close(mkstemp(union_file_name)); len = strlen(file_prefix); diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index d29be7385..543f0b50b 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -280,7 +280,7 @@ static void phargs[argc++] = "-M"; phargs[argc++] = descr_file; } - + for (i=0; i= 1; i--) { diff --git a/util/ego/il/il.c b/util/ego/il/il.c index 938dfa3cc..8313cb93e 100644 --- a/util/ego/il/il.c +++ b/util/ego/il/il.c @@ -334,10 +334,10 @@ char* argv[]; strcat(ccname, "/ego.i2.XXXXXX"); strcat(sname, "/ego.i3.XXXXXX"); strcat(cname2, "/ego.i4.XXXXXX"); - mktemp(cname); - mktemp(ccname); - mktemp(sname); - mktemp(cname2); + close(mkstemp(cname)); + close(mkstemp(ccname)); + close(mkstemp(sname)); + close(mkstemp(cname2)); pass1(files->lname_in, files->bname_in, cname); /* grep calls, analyse procedures */ space = total_size * space / 100; pass2(cname, space); /* select calls to be expanded */ diff --git a/util/flex/main.c b/util/flex/main.c index fad1a3fa8..d6f0ec936 100644 --- a/util/flex/main.c +++ b/util/flex/main.c @@ -6,7 +6,7 @@ * * This code is derived from software contributed to Berkeley by * Vern Paxson. - * + * * The United States Government has rights in this work pursuant * to contract no. DE-AC03-76SF00098 between the United States * Department of Energy and the University of California. @@ -38,6 +38,7 @@ static char rcsid[] = #endif +#include #include "flexdef.h" static char flex_version[] = "2.3"; @@ -394,7 +395,7 @@ char **argv; { int i, sawcmpflag; - char *arg, *flex_gettime(), *mktemp(); + char *arg, *flex_gettime(); printstats = syntaxerror = trace = spprdflt = interactive = caseins = false; backtrack_report = performance_report = ddebug = fulltbl = fullspd = false; @@ -611,7 +612,7 @@ get_next_arg: /* used by -C and -S flags in lieu of a "continue 2" control */ #else (void) strcpy( temp_action_file_name, "flexXXXXXX.tmp" ); #endif - (void) mktemp( temp_action_file_name ); + close(mkstemp(temp_action_file_name)); action_file_name = temp_action_file_name; } diff --git a/util/opt/main.c b/util/opt/main.c index 2990b22b2..a3df98a73 100644 --- a/util/opt/main.c +++ b/util/opt/main.c @@ -57,13 +57,12 @@ flags(s) register char *s; { } fileinit() { - char *mktemp(); short readshort(); if (readshort() != (short) sp_magic) error("wrong input file"); if (Lflag) { - outfile = fopen(mktemp(template),"w"); + outfile = fdopen(mkstemp(template),"w"); if (outfile == NULL) error("can't create %s",template); } else { From b55198820af4977c416dd95196ebcbf91670b1ce Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 13:39:21 +0200 Subject: [PATCH 15/20] Fix Travis syntax error... --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 47dc3a685..6e9f2d5cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,11 @@ matrix: sudo: false dist: trusty compiler: gcc - include: - os: linux sudo: false dist: trusty compiler: clang -# include: # - # os: osx # env: HOMEBREW_NO_AUTO_UPDATE=1 From 5f6a773649f5c7c0001bc2482cba278c6cf4cc24 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 13:48:01 +0200 Subject: [PATCH 16/20] Turn of qemuppc for now; it's crashing on Travis builds. --- build.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.lua b/build.lua index f7b0ca1ea..9ac5cc7d9 100644 --- a/build.lua +++ b/build.lua @@ -11,14 +11,14 @@ vars.plats = { "linuxppc", "osx386", "osxppc", - "qemuppc", + --"qemuppc", "pc86", "rpi", } vars.plats_with_tests = { "linux386", "linuxppc", - "qemuppc", + --"qemuppc", "pc86", } From a96c846a29e82bb91bfe44395d1ae49f4a5d69aa Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 13:54:07 +0200 Subject: [PATCH 17/20] Don't build mcg as part of linuxppc; it's not used and crashes Travis. --- plat/linuxppc/build-tools.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plat/linuxppc/build-tools.lua b/plat/linuxppc/build-tools.lua index e48524cc9..ef9afb38e 100644 --- a/plat/linuxppc/build-tools.lua +++ b/plat/linuxppc/build-tools.lua @@ -25,7 +25,7 @@ return installable { map = { ["$(PLATDEP)/linuxppc/as"] = "+as", ["$(PLATDEP)/linuxppc/ncg"] = "+ncg", - ["$(PLATDEP)/linuxppc/mcg"] = "+mcg", + --["$(PLATDEP)/linuxppc/mcg"] = "+mcg", ["$(PLATDEP)/linuxppc/top"] = "+top", ["$(PLATIND)/descr/linuxppc"] = "./descr", "util/amisc+aelflod-pkg", From 1203e8afd2acd947d1701950ce292314738725c5 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 14:25:12 +0200 Subject: [PATCH 18/20] mkstemp() is a bit more complex than it looks; because ego wants to use the same base name and generate multiple files based on it, we can't really use mkstemp() for every temporary file. Instead, use mkstemp() once on a placeholder, then generate temporary names based on this. (And delete the placeholder once we've finished.) --- util/ego/em_ego/em_ego.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 543f0b50b..36d64561f 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -58,6 +58,7 @@ static const struct #define MAXARGS 1024 /* mar # of args */ #define NTEMPS 4 /* # of temporary files; not tunable */ +static char tmpbase[] = TMP_DIR "/ego.XXXXXX"; static char ddump[128] = TMP_DIR; /* data label dump file */ static char pdump[128] = TMP_DIR; /* procedure name dump file */ static char tmpbufs[NTEMPS * 2][128] = { @@ -115,6 +116,8 @@ cleanup() if (pdump[0] != '\0') (void)unlink(pdump); } + + (void)unlink(tmpbase); } /*VARARGS1*/ @@ -200,9 +203,8 @@ new_outfiles() char** dst = &phargs[NTEMPS + 1]; if (!Bindex) - { - Bindex = strrchr(tmpbufs[0], 'B') - tmpbufs[0]; - } + Bindex = strlen(tmpbufs[0]) - 2; + for (i = 1; i <= NTEMPS; i++) { *dst = tmpbufs[tmpindex]; @@ -403,25 +405,25 @@ int main(int argc, char* argv[]) fatal("no correct -P flag given"); } + close(mkstemp(tmpbase)); + strcpy(ddump, tmpbase); + strcpy(pdump, tmpbase); + strcpy(tmpbufs[0], tmpbase); + if (keeptemps) { (void)strcpy(ddump, "."); (void)strcpy(pdump, "."); (void)strcpy(tmpbufs[0], "."); } - (void)strcat(ddump, "/ego.dd.XXXXXX"); - close(mkstemp(ddump)); - (void)strcat(pdump, "/ego.pd.XXXXXX"); - close(mkstemp(pdump)); + (void)strcat(ddump, "dd"); + (void)strcat(pdump, "pd"); - (void)strcat(tmpbufs[0], "/ego.XXXXXX"); - close(mkstemp(tmpbufs[0])); - (void)strcat(tmpbufs[0], ".A.BB"); - for (i = 2 * NTEMPS - 1; i >= 1; i--) - { + (void)strcat(tmpbufs[0], "A.BB"); + for (i=1; i<(2 * NTEMPS); i++) (void)strcpy(tmpbufs[i], tmpbufs[0]); - } - i = strrchr(tmpbufs[0], 'A') - tmpbufs[0]; + + i = strlen(tmpbufs[0]) - 4; tmpbufs[0][i] = 'p'; tmpbufs[NTEMPS + 0][i] = 'p'; tmpbufs[1][i] = 'd'; @@ -430,6 +432,7 @@ int main(int argc, char* argv[]) tmpbufs[NTEMPS + 2][i] = 'l'; tmpbufs[3][i] = 'b'; tmpbufs[NTEMPS + 3][i] = 'b'; + run_phase(IC); run_phase(CF); while (*Ophase) From 68a72f76721de870411fb7f6dc52db387096b877 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 14:27:15 +0200 Subject: [PATCH 19/20] Don't try to run the tests on Travis. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e9f2d5cb..76057fd76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,9 @@ addons: apt: packages: - ed - - qemu-user git: depth: 10 script: - - make PREFIX=/tmp/acki + - make PREFIX=/tmp/acki +ack From b83173734d735355ecc65b74524bda7f15b8f807 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 6 Aug 2017 15:57:49 +0200 Subject: [PATCH 20/20] More ansification. --- util/led/archive.c | 2 -- util/led/memory.c | 49 ++++++++++++++++------------------------------ util/led/memory.h | 7 +++++-- util/led/save.c | 2 -- util/led/scan.c | 7 ------- util/led/sym.c | 1 - 6 files changed, 22 insertions(+), 46 deletions(-) diff --git a/util/led/archive.c b/util/led/archive.c index 7e39e9fb7..a202d042c 100644 --- a/util/led/archive.c +++ b/util/led/archive.c @@ -20,8 +20,6 @@ static char rcsid[] = "$Id$"; #define ENDLIB ((long)0) -extern ind_t hard_alloc(); - static struct ar_hdr arhdr; /* diff --git a/util/led/memory.c b/util/led/memory.c index 40db843ba..c5715821e 100644 --- a/util/led/memory.c +++ b/util/led/memory.c @@ -25,15 +25,17 @@ static char rcsid[] = "$Id$"; #include #include #include +#include #include #include "const.h" #include "assert.h" #include "debug.h" #include "memory.h" +#include "object.h" -static copy_down(); -static copy_up(); -static free_saved_moduls(); +static void copy_down(struct memory* mem, ind_t dist); +static void copy_up(struct memory* mem, ind_t dist); +static void free_saved_moduls(void); struct memory mems[NMEMS]; @@ -45,8 +47,7 @@ ind_t core_position = (ind_t)0; /* Index of current module. */ static char *BASE; static ind_t refused; -sbreak(incr) - ind_t incr; +static int sbreak(ind_t incr) { unsigned int inc; @@ -69,12 +70,11 @@ sbreak(incr) * Initialize some pieces of core. We hope that this will be our last * real allocation, meaning we've made the right choices. */ -init_core() +void init_core(void) { register char *base; register ind_t total_size; register struct memory *mem; - extern char *sbrk(); #include "mach.h" #define ALIGN 8 /* minimum alignment for pieces */ @@ -175,9 +175,7 @@ extern int passnumber; * enough bytes, the first or the second time. */ static bool -compact(piece, incr, flag) - register int piece; - register ind_t incr; +compact(int piece, ind_t incr, int flag) #define NORMAL 0 #define FREEZE 1 #define FORCED 2 @@ -315,10 +313,8 @@ compact(piece, incr, flag) * overlap with the old area, but we do not want to overwrite them before they * are copied. */ -static -copy_down(mem, dist) - register struct memory *mem; - ind_t dist; +static void +copy_down(struct memory* mem, ind_t dist) { register char *old; register char *new; @@ -338,10 +334,7 @@ copy_down(mem, dist) * overlap with the old area, but we do not want to overwrite them before they * are copied. */ -static -copy_up(mem, dist) - register struct memory *mem; - ind_t dist; +static void copy_up(struct memory* mem, ind_t dist) { register char *old; register char *new; @@ -364,10 +357,7 @@ static int alloctype = NORMAL; * how many times the area is moved, because of another allocate, this offset * remains valid. */ -ind_t -alloc(piece, size) - int piece; - register long size; +ind_t alloc(int piece, long size) { register ind_t incr = 0; ind_t left = mems[piece].mem_left; @@ -405,9 +395,7 @@ alloc(piece, size) * attempt fails, release the space occupied by other pieces and try again. */ ind_t -hard_alloc(piece, size) - register int piece; - register long size; +hard_alloc(int piece, long size) { register ind_t ret; register int i; @@ -452,8 +440,8 @@ hard_alloc(piece, size) * at the start of the piece allocated for module contents, thereby * overwriting the saved modules, and release its space. */ -static -free_saved_moduls() +static void +free_saved_moduls(void) { register ind_t size; register char *old, *new; @@ -551,7 +539,7 @@ freeze_core() * To transform the various pieces of the output in core to the file format, * we must order the bytes in the unsigned shorts and longs as ACK prescribes. */ -write_bytes() +void write_bytes(void) { unsigned short nsect; long offchar; @@ -609,10 +597,7 @@ write_bytes() } } -namecpy(name, nname, offchar) - register struct outname *name; - register unsigned nname; - register long offchar; +void namecpy(struct outname* name, unsigned nname, long offchar) { while (nname--) { if (name->on_foff) diff --git a/util/led/memory.h b/util/led/memory.h index 2d2f33063..69bbeebe6 100644 --- a/util/led/memory.h +++ b/util/led/memory.h @@ -38,7 +38,10 @@ extern struct memory mems[]; #define int_align(sz) (((sz)+(sizeof(int)-1))&~(int)(sizeof(int)-1)) extern ind_t core_position; -extern ind_t hard_alloc(); -extern ind_t alloc(); +extern void init_core(void); +extern ind_t hard_alloc(int piece, long size); +extern ind_t alloc(int piece, long size); extern void dealloc(int piece); extern void core_free(int piece, char* p); +extern void write_bytes(void); +extern void namecpy(struct outname* name, unsigned nname, long offchar); diff --git a/util/led/save.c b/util/led/save.c index 952649633..c06e25c78 100644 --- a/util/led/save.c +++ b/util/led/save.c @@ -68,8 +68,6 @@ savechar(piece, off) { register long len; register ind_t newoff; - extern ind_t alloc(); - extern ind_t hard_alloc(); if (off == (ind_t)0) return 0; diff --git a/util/led/scan.c b/util/led/scan.c index d65a2c3cf..610149be8 100644 --- a/util/led/scan.c +++ b/util/led/scan.c @@ -195,7 +195,6 @@ static bool all_alloc(void) { struct outhead head; - extern ind_t hard_alloc(); if (hard_alloc(ALLOMODL, (long)sizeof(struct outhead)) == BADOFF) fatal("no space for module header"); @@ -220,8 +219,6 @@ direct_alloc(head) register struct outsect *sects; unsigned short nsect = head->oh_nsect; long size, rest; - extern ind_t hard_alloc(); - extern ind_t alloc(); #ifdef SYMDBUG rest = nsect * sizeof(ind_t) + sizeof(ind_t) + sizeof(ind_t); @@ -293,7 +290,6 @@ putemitindex(ind_t sectindex, ind_t emitoff, int allopiece) { long flen; ind_t emitindex; - extern ind_t alloc(); static long zeros[MAXSECT]; register long zero = zeros[allopiece - ALLOEMIT]; @@ -332,7 +328,6 @@ static bool putreloindex(ind_t relooff, long nrelobytes) { ind_t reloindex; - extern ind_t alloc(); if ((reloindex = alloc(ALLORELO, nrelobytes)) != BADOFF) { *(ind_t *)modulptr(relooff) = reloindex; @@ -348,7 +343,6 @@ static bool putdbugindex(ind_t dbugoff, long ndbugbytes) { ind_t dbugindex; - extern ind_t alloc(); if ((dbugindex = alloc(ALLODBUG, ndbugbytes)) != BADOFF) { *(ind_t *)modulptr(dbugoff) = dbugindex; @@ -425,7 +419,6 @@ read_modul(void) unsigned short nsect, nname; long size; long nchar; - extern ind_t hard_alloc(); assert(passnumber == SECOND); assert(!incore); diff --git a/util/led/sym.c b/util/led/sym.c index 53f0f3440..2e6def052 100644 --- a/util/led/sym.c +++ b/util/led/sym.c @@ -100,7 +100,6 @@ entername(name, hashval) register struct symbol *sym; struct outname *newname; extern ind_t savechar(); - extern ind_t hard_alloc(); debug("entername %s %d %x %x", modulptr((ind_t)name->on_foff), hashval, name->on_type, name->on_desc); savindex = savechar(ALLOGCHR, (ind_t)name->on_foff);