Commit Graph

24 Commits

Author SHA1 Message Date
rillig e0fa644c43 make(1): move Job.xtraced to ShellWriter
This flag was placed wrong in the Job since it is only necessary as long
as the shell commands are written to the shell file.

Resetting it in JobStart and JobExec was completely misguided since that
is far away from writing the shell commands; this should have been done
in JobPrintCommands instead.

The status of this flag doesn't need to be printed in debugging mode
since it is controlled by a single command line option (-dx) and does
not interact with all the other switches.
2020-12-12 10:21:50 +00:00
rillig a6d2ec5914 make(1): unpack struct JobFlags
The job flags are only used individually.
2020-12-10 21:33:25 +00:00
rillig c2147f488d make(1): split JobFlags into separate fields
Having all these flags in a single bitmask makes it harder to see where
exactly they can possibly be used since their state could also be
modified using the unsuspicious job->flags = 0.  Using individual names
just leaves the single memset, and that is only used during
initialization.
2020-12-10 20:49:11 +00:00
rillig 625b0ad57d make(1): document possible undefined behavior in trace.c with .CURDIR 2020-10-31 22:05:56 +00:00
rillig e8b104bf6c make(1): change char * to void * in Var_Value
The only purpose of the parameter freeIt is to free the memory
associated with the return value.  To do this, no pointer arithmetic is
needed.  Therefore, change to a void pointer, to catch accidental use of
that pointer.
2020-10-30 20:30:44 +00:00
rillig f336e55bc4 make(1): revert previous commit
It had accidentally reverted all the work from the past few days.
2020-10-05 19:27:47 +00:00
rillig b6c0384ff9 make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)
The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25.  In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath.  Dir_ClearPath takes full ownership of the given list and
empties it.  This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table.  This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes.  This by itself
was not a problem since the hash table would be freed afterwards.  But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again.  Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
2020-10-05 19:24:29 +00:00
rillig 052e64b5e1 make(1): clean up #include sections 2020-10-03 21:52:50 +00:00
rillig 6de75a95f8 make(1): clean up RCSID blocks
These blocks mostly consisted of redundant structure, following the same
#ifndef pattern over and over, with only minimal variation.

It's easier to maintain if the common structure is only written once and
encapsulated in a macro.

To avoid "defined but unused" warnings from GCC in the case where
MAKE_NATIVE is not defined, I had to add volatile.  Adding
MAKE_ATTR_UNUSED alone would not preserve the rcsid variable in the
resulting binary.
2020-09-13 15:15:51 +00:00
rillig 86abf69ed1 make(1): no declaration-after-statement anymore
NetBSD make is intended to be maximally portable, therefore it uses only
C89.  This was not declared in the Makefile before.

There are still a few places in parse.c and metachar.c that use
end-of-line comments.  These will be fixed in a follow-up commit.
2020-08-03 20:26:09 +00:00
rillig ad6695e0a6 make(1): avoid calls to free(3) in the common case of a NULL pointer 2020-08-01 09:55:00 +00:00
rillig ab2bfed61f make(1): let Var_Value return a const char *
The return value must not be modified anyway, so let the compiler check
this for free.
2020-08-01 09:25:36 +00:00
rillig 820b5caede make(1): remove trailing whitespace 2020-07-03 08:13:23 +00:00
christos 266b18d880 prepare for time_t 64 2008-12-28 18:31:51 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
christos a686e4e754 back all changes out until I fix it properly. 2008-02-15 21:29:50 +00:00
christos 2b28370627 - use pid_t/size_t as appropriate instead of int.
- use %ld to print pids.
- fix a bit of lint.
- WARNS=4
2008-02-14 22:11:20 +00:00
dsl 913c34c213 Expunge last references to jobTokensFree 2006-01-04 21:35:44 +00:00
ross 42dbdbd46a Simplify build, no functional changes.
Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when
you want things simple, instead add MAKE_NATIVE to get those hugely
important features like __RCSID().

It's now possible to build make on some hosts with: cc *.c */*.c
2004-05-07 00:04:38 +00:00
wiz 86ebbc3a0e Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register. 2002-06-15 18:24:55 +00:00
reinoud a233fbd53e Fix major bug in make(1) ... due to shadowing of the dotLast path used for
the .DOTLAST primitive by a boolean variable with the same name, this whole
mechanism was broken ... it doesn't save much stat calls but it was wrong.

Thanks to Jason Thorpe for the other shadow-variable fixing patches he
made.
2002-01-27 01:50:54 +00:00
cgd 2f928e31d3 <sys/time.h>, rather than <time.h>. The former is actually the documented
way to get gettimeofday(), etc.  On some systems on which you might want
to host make (e.g. solaris), <time.h> won't get you a struct timeval
definition.
2001-01-23 02:48:05 +00:00
sommerfeld 1ef47ae656 Include token counts in trace output.
Don't let tokensFree go negative.
2000-12-30 16:38:22 +00:00
sommerfeld 694b899b9c Quick and dirty trace mechanism to make it easier to look at how different
parallel make job distribution algorithms work in practice.
2000-12-29 23:11:08 +00:00