From bc95f59574c8d2535fa028e8a6af09f826725801 Mon Sep 17 00:00:00 2001 From: Ken Foskey Date: Fri, 11 Oct 2002 12:42:49 +0000 Subject: dmake: Implement fix for Lost child problem. Correct some checks for functions (assumed present) and also fix up all gcc warnings using -Wall. --- dmake/Makefile.in | 4 +- dmake/config.h.in | 9 ++++ dmake/configure | 2 +- dmake/configure.in | 2 +- dmake/dag.c | 8 ++-- dmake/dmake.c | 10 +++-- dmake/expand.c | 5 ++- dmake/extern.h | 26 ++++++++++- dmake/function.c | 20 +-------- dmake/getinp.c | 12 ++--- dmake/infer.c | 15 ++++--- dmake/make.c | 22 +++++---- dmake/parse.c | 4 +- dmake/quit.c | 7 ++- dmake/rulparse.c | 15 ++++--- dmake/sysintf.c | 11 +++-- dmake/unix/arlib.c | 3 +- dmake/unix/dcache.c | 4 +- dmake/unix/linux/gnu/public.h | 8 +++- dmake/unix/rmprq.c | 4 +- dmake/unix/runargv.c | 102 ++++++++++++++++++++++++++++-------------- 21 files changed, 188 insertions(+), 105 deletions(-) diff --git a/dmake/Makefile.in b/dmake/Makefile.in index 08047e08b106..9e8c0235fa10 100755 --- a/dmake/Makefile.in +++ b/dmake/Makefile.in @@ -17,9 +17,9 @@ # # $RCSfile: Makefile.in,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: waratah $ $Date: 2002-10-04 13:31:33 $ +# last change: $Author: waratah $ $Date: 2002-10-11 13:42:40 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses diff --git a/dmake/config.h.in b/dmake/config.h.in index a0bf18d8e734..31f9c1b312a4 100644 --- a/dmake/config.h.in +++ b/dmake/config.h.in @@ -36,6 +36,12 @@ /* Define if you have the putenv function. */ #undef HAVE_PUTENV +/* Define if you have the settz function. */ +#undef HAVE_SETTZ + +/* Define if you have the setvbuf function. */ +#undef HAVE_SETVBUF + /* Define if you have the strcspn function. */ #undef HAVE_STRCSPN @@ -48,6 +54,9 @@ /* Define if you have the strstr function. */ #undef HAVE_STRSTR +/* Define if you have the tzset function. */ +#undef HAVE_TZSET + /* Define if you have the header file. */ #undef HAVE_DIRENT_H diff --git a/dmake/configure b/dmake/configure index 827fa36582f5..12ed0930e1f1 100755 --- a/dmake/configure +++ b/dmake/configure @@ -2120,7 +2120,7 @@ fi fi -for ac_func in getcwd getwd putenv strcspn strerror strspn strstr +for ac_func in getcwd getwd putenv strcspn strerror strspn strstr setvbuf tzset settz do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:2127: checking for $ac_func" >&5 diff --git a/dmake/configure.in b/dmake/configure.in index 85c9184015f9..2d64a5ecfbbf 100755 --- a/dmake/configure.in +++ b/dmake/configure.in @@ -44,7 +44,7 @@ AC_FUNC_MEMCMP AC_TYPE_SIGNAL AC_FUNC_UTIME_NULL AC_FUNC_VPRINTF -AC_CHECK_FUNCS(getcwd getwd putenv strcspn strerror strspn strstr) +AC_CHECK_FUNCS(getcwd getwd putenv strcspn strerror strspn strstr setvbuf tzset settz) dnl Checks for OS AC_MSG_CHECKING([the operating system]) diff --git a/dmake/dag.c b/dmake/dag.c index 09efcb510c99..6fc0bcc6ce6d 100644 --- a/dmake/dag.c +++ b/dmake/dag.c @@ -1,4 +1,4 @@ -/* RCS $Id: dag.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: dag.c,v 1.2 2002-10-11 13:42:42 waratah Exp $ -- -- SYNOPSIS -- Routines to construct the internal dag. @@ -321,11 +321,12 @@ int flags; /* initial ht_flags */ /* Check for macro variables and make the necessary adjustment in the * corresponding global variables */ - if( hp->ht_flag & M_VAR_MASK ) + if( hp->ht_flag & M_VAR_MASK ) { if( !(flags & M_EXPANDED) ) Error( "Macro variable '%s' must be assigned with :=", name ); else set_macro_value(hp); + } DB_RETURN( hp ); } @@ -496,11 +497,12 @@ int fail; DB_ENTER( "Test_circle" ); DB_PRINT( "tc", ("checking [%s]", cp->CE_NAME) ); - if( cp->ce_flag & F_MARK ) + if( cp->ce_flag & F_MARK ) { if( fail ) Fatal("Detected circular dependency in graph at [%s]", cp->CE_NAME); else DB_RETURN( 1 ); + } cp->ce_flag |= F_MARK; for( lp = cp->ce_prq; !res && lp != NIL(LINK); lp = lp->cl_next ) diff --git a/dmake/dmake.c b/dmake/dmake.c index 941c8a203c23..a3376da5b99c 100644 --- a/dmake/dmake.c +++ b/dmake/dmake.c @@ -1,4 +1,4 @@ -/* RCS $Id: dmake.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: dmake.c,v 1.2 2002-10-11 13:42:42 waratah Exp $ -- -- SYNOPSIS -- The main program. @@ -116,7 +116,7 @@ static void _do_f_flag ANSI((char, char *, char **)); static void _do_f_flag ANSI((int, char *, char **)); #endif -PUBLIC void +PUBLIC int main(argc, argv) int argc; char **argv; @@ -393,6 +393,7 @@ char **argv; Clear_signals(); Epilog(ex_val); /* Does not return -- EVER */ + return 0; } @@ -484,11 +485,12 @@ int err; DB_ENTER("Openfile"); - if( name == NIL(char) || !*name ) + if( name == NIL(char) || !*name ) { if( !err ) DB_RETURN(NIL(FILE)); else Fatal( "Openfile: NIL filename" ); + } if( next_file_slot == MAX_INC_DEPTH ) Fatal( "Too many open files. Max nesting level is %d.", MAX_INC_DEPTH); @@ -566,7 +568,7 @@ char **rname; { HASHPTR hp; FILE *fil = NIL(FILE); - char *fname; + char *fname = NIL(char); char *ename = NIL(char); /* order of precedence is: diff --git a/dmake/expand.c b/dmake/expand.c index 664aa03ddc09..b6321845800f 100644 --- a/dmake/expand.c +++ b/dmake/expand.c @@ -1,4 +1,4 @@ -/* RCS $Id: expand.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: expand.c,v 1.2 2002-10-11 13:42:42 waratah Exp $ -- -- SYNOPSIS -- Macro expansion code. @@ -321,7 +321,7 @@ char *src; * DIRECTORY_FLAG is set, then we want to keep the directory portion * othewise throw it away and blank out to the end of the token */ - if( (e = Basename(s)) != s) + if( (e = Basename(s)) != s) { if( !(mod & DIRECTORY_FLAG) ) { strcpy(s, e); e = s+(str.tk_str-e); @@ -330,6 +330,7 @@ char *src; } else s = e; + } /* search for the suffix, if there is none, treat it as a NULL suffix. * if no file name treat it as a NULL file name. same copy op as diff --git a/dmake/extern.h b/dmake/extern.h index c41c143a1aef..fdf5c2446ce7 100644 --- a/dmake/extern.h +++ b/dmake/extern.h @@ -1,4 +1,4 @@ -/* RCS $Id: extern.h,v 1.5 2002-10-07 13:36:01 waratah Exp $ +/* RCS $Id: extern.h,v 1.6 2002-10-11 13:42:42 waratah Exp $ -- -- SYNOPSIS -- External declarations for dmake functions. @@ -90,4 +90,28 @@ * the extern declarations however. */ #include "posix.h" +/* Work around some of the functions that may or may not exist */ +#if ! HAVE_TZSET +#if HAVE_SETTZ +# define tzset() settz() +#else +# warn "tzset is not supported, null out" +# define tzset() +#endif +#endif + +/* Get the working directory fall back code */ +#if ! HAVE_GETCWD +#if HAVE_GETWD +# define getcwd(buf,len) getwd(buf) +#else +# error "You have no supported way of getting working directory" +#endif +#endif + +/* If setvbuf is not available set output to unbuffered */ +#if ! HAVE_SETVBUF +# define setvbuf(fp,bp,type,len) setbuf(fp,NULL) +#endif + #endif diff --git a/dmake/function.c b/dmake/function.c index 20e83b7f9695..baa48346c08b 100644 --- a/dmake/function.c +++ b/dmake/function.c @@ -1,10 +1,10 @@ -/* RCS $Id: function.c,v 1.2 2002-10-04 13:31:34 waratah Exp $ +/* RCS $Id: function.c,v 1.3 2002-10-11 13:42:42 waratah Exp $ -- -- SYNOPSIS -- GNU style functions for dmake. -- -- DESCRIPTION --- All GNU stule functions understood by dmake are implemented in this +-- All GNU style functions understood by dmake are implemented in this -- file. Currently the only such function is $(mktmp ...) which is -- not part of GNU-make is an extension provided by dmake. -- @@ -568,22 +568,6 @@ char *mod1; } -static int -not (arg) -int arg; -{ - return(!arg); -} - - -static int -nop (arg) -int arg; -{ - return(arg); -} - - static char * _exec_andor( args, doand ) char *args; diff --git a/dmake/getinp.c b/dmake/getinp.c index 9218e61a7d22..c2d0302bd096 100644 --- a/dmake/getinp.c +++ b/dmake/getinp.c @@ -1,4 +1,4 @@ -/* RCS $Id: getinp.c,v 1.2 2000-10-20 11:12:55 hjs Exp $ +/* RCS $Id: getinp.c,v 1.3 2002-10-11 13:42:43 waratah Exp $ -- -- SYNOPSIS -- Handle reading of input. @@ -44,6 +44,8 @@ static int _handle_conditional ANSI((int, TKSTRPTR)); static int rule_ind = 0; /* index of rule when reading Rule_tab */ static int skip = FALSE; /* if true the skip input */ +int partcomp( char* lhs, int opcode ); + PUBLIC int Get_line( buf, fil )/* @@ -61,7 +63,7 @@ FILE *fil; static int ignore = FALSE; int cont = FALSE; int pos = 0; - int res; + int res = 0; register char *tmp = NIL(char); DB_ENTER( "Get_line" ); @@ -324,7 +326,7 @@ char *brk; int anchor; { register char *s; - register char *curp; + register char *curp = 0; register char *t; int done = FALSE; char space[100]; @@ -476,7 +478,7 @@ TKSTRPTR tg; { static short action[MAX_COND_DEPTH]; static char ifcntl[MAX_COND_DEPTH]; - char *tok, *lhs, *rhs, *op, *expr; + char *lhs, *expr; char *lop, *partstr; int result, n, m; @@ -584,7 +586,7 @@ TKSTRPTR tg; int partcomp( char* lhs, int opcode ) { - char *tok, *rhs, *op; + char *tok, *rhs, *op = 0; int result, opsind; const int localopscount=4; char* localops[]={"==","!=","<=",">="}; diff --git a/dmake/infer.c b/dmake/infer.c index 478db5867f9a..a9db27c674d6 100644 --- a/dmake/infer.c +++ b/dmake/infer.c @@ -1,4 +1,4 @@ -/* RCS $Id: infer.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: infer.c,v 1.2 2002-10-11 13:42:43 waratah Exp $ -- -- SYNOPSIS -- Infer how to make a target. @@ -145,14 +145,14 @@ CELLPTR setdirroot; int dump = (match->ic_next->ic_next != NIL(ICELL)); /* Check for definite ambiguity */ - if( !dump ) + if( !dump ) { if( (match->ic_meta->ce_prq && match->ic_next->ic_meta->ce_prq) || (!match->ic_meta->ce_prq && !match->ic_next->ic_meta->ce_prq) ) dump = TRUE; else if(!match->ic_meta->ce_prq && match->ic_next->ic_meta->ce_prq ) match = match->ic_next; - - if( dump ) { + } + else { int count = 1; Continue = TRUE; @@ -236,7 +236,7 @@ CELLPTR setdirroot; /* If infcell already had a directory set then modify it based on * whether it was the original cell or some intermediary. */ - if( imeta->ce_dir ) + if( imeta->ce_dir ) { if( infcell->ce_dir && infcell == cp ) { /* cp->ce_dir was set and we have pushed the directory prior * to calling this routine. We should therefore pop it and @@ -247,6 +247,7 @@ CELLPTR setdirroot; } else infcell->ce_dir = imeta->ce_dir; + } for( lp=imeta->ce_indprq; lp != NIL(LINK); lp=lp->cl_next ) { char *name = lp->cl_prq->CE_NAME; @@ -350,12 +351,12 @@ ICELLPTR *nnmp; /* Now run through the list of prerequisite edge's for the %-meta. */ for( ; edge != NIL(LINK); edge = edge->cl_next ) { - HASHPTR thp; /* temporary hash table pointer */ + HASHPTR thp = 0; /* temporary hash table pointer */ HASH iprqh; /* hash cell for new prerequisite */ CELL iprq; /* inferred prerequisite to look for */ CELLPTR idirroot; /* Inferred prerequisite root */ CELLPTR nidirroot; /* Inferred prerequisite root */ - STRINGPTR ircp; /* Inferred prerequisites recipe */ + STRINGPTR ircp = 0; /* Inferred prerequisites recipe */ char *idir; /* directory to CD to. */ int ipush = 0; /* flag for push on inferred prereq */ char *name = NIL(char); /* prerequisite name */ diff --git a/dmake/make.c b/dmake/make.c index 2586e58c28ba..4ba659d8a451 100644 --- a/dmake/make.c +++ b/dmake/make.c @@ -1,4 +1,4 @@ -/* RCS $Id: make.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: make.c,v 1.2 2002-10-11 13:42:43 waratah Exp $ -- -- SYNOPSIS -- Perform the update of all outdated targets. @@ -59,6 +59,8 @@ static LINKPTR _dup_prq ANSI((LINKPTR)); static LINKPTR _expand_dynamic_prq ANSI(( LINKPTR, LINKPTR, char * )); static char* _prefix ANSI((char *, char *)); static char* _pool_lookup ANSI((char *)); +static int _explode_graph ANSI((CELLPTR, LINKPTR, CELLPTR)); + #define RP_GPPROLOG 0 #define RP_RECIPE 1 @@ -340,7 +342,7 @@ CELLPTR setdirroot; DB_PRINT( "make", ("(%s, %ld, 0x%08x, 0x%04x)", cp->CE_NAME, cp->ce_time, cp->ce_attr, cp->ce_flag) ); - if( !(cp->ce_flag & F_TARGET) && (cp->ce_time == (time_t) 0L) ) + if( !(cp->ce_flag & F_TARGET) && (cp->ce_time == (time_t) 0L) ) { if( Makemkf ) { rval = -1; goto stop_making_it; @@ -353,6 +355,7 @@ CELLPTR setdirroot; cp->ce_flag |= F_RULES; else Fatal( "`%s' not found, and can't be made", cp->CE_NAME ); + } DB_PRINT( "mem", ("%s:-A mem %ld", cp->CE_NAME, (long) coreleft()) ); @@ -417,7 +420,7 @@ CELLPTR setdirroot; tcp = dp->cl_prq; seq = (((cp->ce_attr | Glob_attr) & A_SEQ) != 0); - if( tcp->ce_flag & F_VISITED ) + if( tcp->ce_flag & F_VISITED ) { if( _explode_graph(tcp, dp, setdirroot) == 0 ) { /* didn't blow it up so see if we need to wait for it. */ if( tcp->ce_flag & F_MADE ) { @@ -429,6 +432,7 @@ CELLPTR setdirroot; } else tcp = dp->cl_prq; + } if( seq && !made ) goto stop_making_it; @@ -590,13 +594,14 @@ CELLPTR setdirroot; name = cp->ce_fname; lib = cp->ce_lib; - if( (!(Glob_attr & A_SILENT) || !Trace) && !(cp->ce_attr & A_PHONY) ) + if( (!(Glob_attr & A_SILENT) || !Trace) && !(cp->ce_attr & A_PHONY) ) { if( lib == NIL(char) ) printf("touch(%s)", name ); else if( cp->ce_attr & A_SYMBOL ) printf("touch(%s((%s)))", lib, name ); else printf("touch(%s(%s))", lib, name ); + } if( !Trace && !(cp->ce_attr & A_PHONY) ) if( Do_touch( name, lib, @@ -854,7 +859,7 @@ HASHPTR hp; -int +static int _explode_graph( cp, parent, setdirroot )/* ========================================== Check to see if we have made the node already. If so then don't do @@ -945,7 +950,7 @@ CELLPTR cp; STRINGPTR orp; char *cmnd; char *groupfile; - FILE *tmpfile; + FILE *tmpfile = 0; int do_it; t_attr attr; int group; @@ -1221,12 +1226,13 @@ int ignore; DB_ENTER( "Pop_dir" ); - if( dir_stack == NIL(STRING) ) + if( dir_stack == NIL(STRING) ) { if( ignore ) { DB_VOID_RETURN; } else Error( "Directory stack empty for return from .SETDIR" ); + } if( Set_dir(dir = dir_stack->st_string) ) Fatal( "Could not change to directory `%s'", dir ); @@ -1272,7 +1278,7 @@ _set_tmd()/* p = Get_token( &pd, DirBrkStr, FALSE ); if( !is_sep && strcmp(m, p) ) { /* they differ */ - char *tmp; + char *tmp = 0; if( first ) { /* They differ in the first component */ tmd = Makedir; /* In this case use the full path */ break; diff --git a/dmake/parse.c b/dmake/parse.c index c7bf8bf76880..834ca1dbb635 100644 --- a/dmake/parse.c +++ b/dmake/parse.c @@ -1,4 +1,4 @@ -/* RCS $Id: parse.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: parse.c,v 1.2 2002-10-11 13:42:43 waratah Exp $ -- -- SYNOPSIS -- Parse the input, and perform semantic analysis @@ -105,7 +105,7 @@ FILE *fil; } else if( *p == ']' ) Fatal( "Found unmatched ']'" ); - else if( *pTmpBuf && *p || (Notabs && !*pTmpBuf && !*p)) + else if( (*pTmpBuf && *p) || (Notabs && !*pTmpBuf && !*p)) State = NORMAL_SCAN; } diff --git a/dmake/quit.c b/dmake/quit.c index ffb4eda74d4c..ce383b394dc8 100644 --- a/dmake/quit.c +++ b/dmake/quit.c @@ -1,4 +1,4 @@ -/* RCS $Id: quit.c,v 1.1.1.1 2000-09-22 15:33:25 hr Exp $ +/* RCS $Id: quit.c,v 1.2 2002-10-11 13:42:43 waratah Exp $ -- -- SYNOPSIS -- End the dmake session. @@ -48,6 +48,11 @@ Quit()/* } +const int in_quit( void ) +{ + return _dont_quit; +} + static void _handle_quit( err_target )/* ============================ diff --git a/dmake/rulparse.c b/dmake/rulparse.c index 430c60901aef..17bbd2cb9afc 100644 --- a/dmake/rulparse.c +++ b/dmake/rulparse.c @@ -1,4 +1,4 @@ -/* RCS $Id: rulparse.c,v 1.3 2002-07-11 08:53:30 mh Exp $ +/* RCS $Id: rulparse.c,v 1.4 2002-10-11 13:42:44 waratah Exp $ -- -- SYNOPSIS -- Perform semantic analysis on input @@ -144,11 +144,12 @@ int *state; /* Logically OR the attributes specified into one main * ATTRIBUTE mask. */ - if( at == A_SETDIR ) + if( at == A_SETDIR ) { if( set_dir != NIL( char ) ) Warning( "Multiple .SETDIR attribute ignored" ); else set_dir = DmStrDup( tok ); + } attr |= at; } @@ -832,12 +833,13 @@ CELLPTR prereq; * apply all of the attributes to the complete list of prerequisites. */ - if( (targets == NIL(CELL)) && attr ) + if( (targets == NIL(CELL)) && attr ) { if( prereq != NIL(CELL) ) for( tp1=prereq; tp1 != NIL(CELL); tp1 = tp1->ce_link ) _set_attributes( attr, set_dir, tp1 ); else _set_global_attr( attr ); + } /* Now that we have built the lists of targets, the parser must parse the * rules if there are any. However we must start the rule list with the @@ -964,7 +966,7 @@ CELLPTR target; CELLPTR prereq; { LINKPTR edl; - CELLPTR edge; + CELLPTR edge = 0; CELLPTR tpq,cur; int match; @@ -1188,7 +1190,7 @@ t_attr attr; char *set_dir; CELLPTR cp; { - char *dir; + char *dir = 0; DB_ENTER( "_set_attributes" ); @@ -1225,7 +1227,7 @@ t_attr attr; /* Some compilers can't handle a switch on a long, and t_attr is now a long * integer on some systems. foey! */ for( flag = MAX_ATTR; flag; flag >>= 1 ) - if( flag & attr ) + if( flag & attr ) { if( flag == A_PRECIOUS) Def_macro(".PRECIOUS", "y", M_EXPANDED); else if( flag == A_SILENT) Def_macro(".SILENT", "y", M_EXPANDED); else if( flag == A_IGNORE ) Def_macro(".IGNORE", "y", M_EXPANDED); @@ -1236,6 +1238,7 @@ t_attr attr; else if( flag == A_SHELL ) Def_macro(".USESHELL", "y", M_EXPANDED); else if( flag == A_MKSARGS ) Def_macro(".MKSARGS", "y", M_EXPANDED); else if( flag == A_SWAP ) Def_macro(".SWAP", "y", M_EXPANDED); + } attr &= ~A_GLOB; if( attr ) Warning( "Non global attribute(s) ignored" ); diff --git a/dmake/sysintf.c b/dmake/sysintf.c index c2fbe7cf05fa..ce966e2c2ceb 100644 --- a/dmake/sysintf.c +++ b/dmake/sysintf.c @@ -1,4 +1,4 @@ -/* RCS $Id: sysintf.c,v 1.3 2001-02-19 16:08:04 hjs Exp $ +/* RCS $Id: sysintf.c,v 1.4 2002-10-11 13:42:44 waratah Exp $ -- -- SYNOPSIS -- System independent interface @@ -125,7 +125,11 @@ char **member; else if( strlen(Basename(name)) > NameMax ) return(-1); else - return( utime(name, NIL(time_t)) ); +#ifdef HAVE_UTIME_NULL + return( utime(name, NULL) ); +#else +# error "Utime NULL not supported" +#endif } @@ -598,7 +602,7 @@ CELLPTR target; : (status & 0xff)==SIGTERM ? -1 : (status & 0x7f)+128); - if( status ) + if( status ) { if( !abort_flg ) { char buf[512]; @@ -636,6 +640,7 @@ CELLPTR target; } else if(!(target->ce_attr & A_PRECIOUS)||(target->ce_attr & A_ERRREMOVE)) Remove_file( target->ce_fname ); + } } diff --git a/dmake/unix/arlib.c b/dmake/unix/arlib.c index 22a2168cfed1..63ecfa8c2a20 100644 --- a/dmake/unix/arlib.c +++ b/dmake/unix/arlib.c @@ -1,4 +1,4 @@ -/* RCS $Id: arlib.c,v 1.1.1.1 2000-09-22 15:33:33 hr Exp $ +/* RCS $Id: arlib.c,v 1.2 2002-10-11 13:42:47 waratah Exp $ -- -- SYNOPSIS -- Unix archive manipulation code. @@ -415,7 +415,6 @@ ar_touch( f, now )/* FILE *f; time_t now; { - struct ar_hdr arhdr; /* external archive header */ fseek(f, arhdroffset + (unsigned long)(((struct ar_hdr *)0)->ar_date), 0); diff --git a/dmake/unix/dcache.c b/dmake/unix/dcache.c index d9ab5d987584..4b1457bf8fb9 100644 --- a/dmake/unix/dcache.c +++ b/dmake/unix/dcache.c @@ -1,4 +1,4 @@ -/* RCS $Id: dcache.c,v 1.1.1.1 2000-09-22 15:33:33 hr Exp $ +/* RCS $Id: dcache.c,v 1.2 2002-10-11 13:42:47 waratah Exp $ -- -- SYNOPSIS -- Directory cache management routines. @@ -189,7 +189,7 @@ int force; } if( Verbose & V_DIR_CACHE ) - printf("%s: Updating dir cache entry for [%s], new time is %d\n", + printf("%s: Updating dir cache entry for [%s], new time is %ld\n", Pname, spath, ep ? ep->mtime : 0L); } diff --git a/dmake/unix/linux/gnu/public.h b/dmake/unix/linux/gnu/public.h index 01e80862fbbd..3d930348b930 100644 --- a/dmake/unix/linux/gnu/public.h +++ b/dmake/unix/linux/gnu/public.h @@ -1,4 +1,4 @@ -/* RCS $Id: public.h,v 1.1.1.1 2000-09-22 15:33:35 hr Exp $ +/* RCS $Id: public.h,v 1.2 2002-10-11 13:42:49 waratah Exp $ -- WARNING -- This file is AUTOMATICALLY GENERATED DO NOT EDIT IT -- -- @@ -88,7 +88,7 @@ void Clear_prerequisites ANSI((CELLPTR)); int Test_circle ANSI((CELLPTR, int)); STRINGPTR Def_recipe ANSI((char *, STRINGPTR, int, int)); t_attr Rcp_attribute ANSI((char *)); -void main ANSI((int, char **)); +int main ANSI((int, char **)); FILE *Openfile ANSI((char *, int, int)); FILE *Closefile ANSI(()); FILE *Search_file ANSI((char *, char **)); @@ -137,6 +137,7 @@ int Get_line ANSI((char *, FILE *)); char *Do_comment ANSI((char *, char **, int)); char *Get_token ANSI((TKSTRPTR, char *, int)); void Quit ANSI(()); +const int in_quit ANSI((void)); void Read_state ANSI(()); void Write_state ANSI(()); int Check_state ANSI((CELLPTR, STRINGPTR *, int)); @@ -160,5 +161,8 @@ int runargv ANSI((CELLPTR, int, int, int, int, char *)); int Wait_for_child ANSI((int, int)); void Clean_up_processes ANSI(()); time_t CacheStat ANSI((char *, int)); +int touch_arch ANSI(( char *, char *)); +void void_lcache ANSI(( char *, char *)); + #endif diff --git a/dmake/unix/rmprq.c b/dmake/unix/rmprq.c index 3b95f237b7b8..17a951ae1fbd 100644 --- a/dmake/unix/rmprq.c +++ b/dmake/unix/rmprq.c @@ -1,4 +1,4 @@ -/* RCS $Id: rmprq.c,v 1.1.1.1 2000-09-22 15:33:33 hr Exp $ +/* RCS $Id: rmprq.c,v 1.2 2002-10-11 13:42:47 waratah Exp $ -- -- SYNOPSIS -- Remove prerequisites code. @@ -32,7 +32,7 @@ Remove_prq( tcp ) CELLPTR tcp; { static LINKPTR rlp = NIL(LINK); - static flag = 0; + static int flag = 0; static HASHPTR m_at, m_q, m_b, m_g, m_l, m_bb, m_up; char *m_at_s, *m_g_s, *m_q_s, *m_b_s, *m_l_s, *m_bb_s, *m_up_s; LINKPTR tlp; diff --git a/dmake/unix/runargv.c b/dmake/unix/runargv.c index f2111aff4aa2..0418a4db6015 100644 --- a/dmake/unix/runargv.c +++ b/dmake/unix/runargv.c @@ -1,4 +1,4 @@ -/* RCS $Id: runargv.c,v 1.4 2001-05-29 22:43:32 pluby Exp $ +/* RCS $Id: runargv.c,v 1.5 2002-10-11 13:42:48 waratah Exp $ -- -- SYNOPSIS -- Invoke a sub process. @@ -24,10 +24,20 @@ */ #include +#include + #include "extern.h" + +/* temporarily comment out spwan code as it does not actually work yet */ +#undef HAVE_SPAWN_H +#if HAVE_SPAWN_H +# include +#endif #include "sysintf.h" -#if defined(__CYGWIN__) -#include +#if HAVE_ERRNO_H +# include +#else + extern int errno; #endif typedef struct prp { @@ -54,13 +64,37 @@ static PR *_procs = NIL(PR); static int _proc_cnt = 0; static int _abort_flg= FALSE; static int _use_i = -1; -static int _do_upd = 0; static void _add_child ANSI((int, CELLPTR, int, int)); static void _attach_cmd ANSI((char *, int, int, CELLPTR, int, int)); static void _finished_child ANSI((int, int)); static int _running ANSI((CELLPTR)); +#if ! HAVE_STRERROR +static char * +private_strerror (errnum) + int errnum; +{ +#ifndef __APPLE__ +#ifdef arm32 + extern const char * const sys_errlist[]; +#else +#if defined(linux) || defined(__FreeBSD__) + extern const char * const sys_errlist[]; +#else + extern char *sys_errlist[]; +#endif + #endif +#endif + extern int sys_nerr; + + if (errnum > 0 && errnum <= sys_nerr) + return sys_errlist[errnum]; + return "Unknown system error"; +} +#define strerror private_strerror +#endif /* HAVE_STRERROR */ + PUBLIC int runargv(target, ignore, group, last, shell, cmd) CELLPTR target; @@ -70,22 +104,7 @@ int last; int shell; char *cmd; { -#if !defined(__CYGWIN__) - extern int errno; -#ifndef __APPLE__ -#ifdef arm32 - extern const char * const sys_errlist[]; -#else -#if defined(linux) || defined(__FreeBSD__) - extern const char * const sys_errlist[]; -#else - extern char *sys_errlist[]; -#endif -#endif -#endif -#else /* __CYGWIN__ */ -#define sys_errlist _sys_errlist -#endif + int pid; char **argv; @@ -96,30 +115,44 @@ char *cmd; return(1); } - while( _proc_cnt == Max_proc ) - if( Wait_for_child(FALSE, -1) == -1 ) - { - Fatal( "Lost a child %d", errno ); - /* If we make it here, something has gone wrong and we need to - * forcefully exit */ - Epilog( ERROR_EXIT_VALUE ); + /* Any Fatal call can potentially loop by recursion because we + * are called from the Quit routine that Fatal indirectly calls + * since Fatal should not happen I have left this bug in here */ + while( _proc_cnt == Max_proc ) { + if( Wait_for_child(FALSE, -1) == -1 ) { + if( ! in_quit() || errno != ECHILD ) + Fatal( "Lost a child %d: %s", errno, strerror( errno ) ); + else {/* we are quitting and the _proc_cnt was stuffed up by ^C */ + fprintf(stderr,"_proc_cnt %d, Max_proc %d\n",_proc_cnt,Max_proc); + _proc_cnt = 0; + } } + } argv = Pack_argv( group, shell, cmd ); +#if HAVE_SPAWN_H + if (posix_spawn (&pid, argv[0], NULL, NULL, argv, (char *)NULL)) + { /* posix_spawn failed */ + Error("%s: %s", argv[0], strerror(errno)); + Handle_result(-1, ignore, _abort_flg, target); + return(-1); + } else { + _add_child(pid, target, ignore, last); + } +#else /* HAVE_SPAWN_H */ + switch( pid=fork() ){ - int wid; - int status; case -1: /* fork failed */ - Error("%s: %s", argv[0], sys_errlist[errno]); + Error("%s: %s", argv[0], strerror( errno )); Handle_result(-1, ignore, _abort_flg, target); return(-1); case 0: /* child */ execvp(argv[0], argv); Continue = TRUE; /* survive error message */ - Error("%s: %s", argv[0], sys_errlist[errno]); + Error("%s: %s", argv[0], strerror( errno )); kill(getpid(), SIGTERM); /*NOTREACHED*/ @@ -127,6 +160,8 @@ char *cmd; _add_child(pid, target, ignore, last); } +#endif /* HAVE_SPAWN_H */ + return(1); } @@ -143,7 +178,9 @@ int pid; waitchild = (pid == -1)? FALSE : Wait_for_completion; do { - if( (wid = wait(&status)) == -1 ) return(-1); + wid = wait(&status); + if( wid == -1 ) + return(-1); _abort_flg = abort_flg; _finished_child(wid, status); @@ -212,7 +249,6 @@ int pid; int status; { register int i; - register PR *pp; char *dir; for( i=0; i