* Minor code cleanups

* Fix for PR/1811, from Paul Eggert.
This commit is contained in:
Paul Smith 2000-07-07 17:34:56 +00:00
parent 88187d9f4b
commit 3c132f10f3
8 changed files with 138 additions and 54 deletions

View File

@ -1,3 +1,43 @@
2000-07-07 Paul D. Smith <psmith@gnu.org>
* remake.c (f_mtime): If NO_FLOAT is defined, don't bother with
the offset calculation.
(name_mtime): Replace EINTR test with EINTR_SET macro.
2000-07-07 Paul Eggert <eggert@twinsun.com>
Fix for PR/1811:
* remake.c (update_file_1):
Avoid spurious rebuilds of archive members due to their
timestamp resolution being only one second.
(f_mtime): Avoid spurious warnings of timestamps in the future due to
the clock's resolution being lower than file timestamps'.
When warning about future timestamps, report only the discrepancy,
not the absolute value of the timestamp and the current time.
* file.c (file_timestamp_now): New arg RESOLUTION.
* filedef.h (file_timestamp_now): Likewise.
(FILE_TIMESTAMP_NS): Now returns int. All uses changed.
2000-07-05 Paul D. Smith <psmith@gnu.org>
* variable.c (lookup_variable) [VMS]: Remove vestigial references
to listp. Fixes PR/1793.
2000-06-26 Paul Eggert <eggert@twinsun.com>
* Makefile.am (MAINTAINERCLEANFILES): New macro, with stamp-pot in it.
* dir.c (vms_hash): Ensure ctype macro args are nonnegative.
* remake.c (f_mtime): Remove unused var memtime.
2000-06-25 Martin Buchholz <martin@xemacs.org>
* make.texinfo, NEWS, TODO.private: Minor spelling corrections.
Ran spell-check on make.texinfo.
2000-06-23 Paul D. Smith <psmith@gnu.org> 2000-06-23 Paul D. Smith <psmith@gnu.org>
* main.c (main): Replace EXIT_SUCCESS, EXIT_FAILURE, and * main.c (main): Replace EXIT_SUCCESS, EXIT_FAILURE, and

View File

@ -57,6 +57,8 @@ all-local: $(srcdir)/stamp-pot
$(srcdir)/stamp-pot: $(POTFILES) $(srcdir)/stamp-pot: $(POTFILES)
@echo "$(POTFILES)" > $@ @echo "$(POTFILES)" > $@
MAINTAINERCLEANFILES = $(srcdir)/stamp-pot
# --------------- Local INSTALL Section # --------------- Local INSTALL Section

2
NEWS
View File

@ -44,7 +44,7 @@ Version 3.79
explicitly within a make rule you may need to re-examine your use for explicitly within a make rule you may need to re-examine your use for
correctness given this change. correctness given this change.
* A new psuedo-target .NOTPARALLEL is available. If defined, the * A new pseudo-target .NOTPARALLEL is available. If defined, the
current makefile is run serially regardless of the value of -j. current makefile is run serially regardless of the value of -j.
However, submakes are still eligible for parallel execution. However, submakes are still eligible for parallel execution.

View File

@ -28,13 +28,14 @@ priority on my list of things I don't have time to do right now is
fixing up the GNU make test suite. Most importantly it needs to be made fixing up the GNU make test suite. Most importantly it needs to be made
"parallelizable", so more than one regression can run at the same time "parallelizable", so more than one regression can run at the same time
(essentially, make the "work" directory local). Also, the CWD during (essentially, make the "work" directory local). Also, the CWD during
the test should be in the work directory; right now sometimes tests leak the test should be in the work directory or, better, a test-specific
files into the main directory which causes subsequent tests to fail temporary directory so each test gets a new directory; right now
(some tests may need to be tweaked). Beyond that, any cleanup done to sometimes tests leak files into the main directory which causes
make writing, reading, or handling tests simpler would be great! Please subsequent tests to fail (some tests may need to be tweaked). Beyond
feel free to make whatever changes you like to the current tests, given that, any cleanup done to make writing, reading, or handling tests
some high-level goals, and that you'll port the current tests to simpler would be great! Please feel free to make whatever changes you
whatever you do :). like to the current tests, given some high-level goals, and that you'll
port the current tests to whatever you do :).
The Rest of the List The Rest of the List
@ -46,9 +47,9 @@ The Rest of the List
2) Option to check more than timestamps to determine if targets have 2) Option to check more than timestamps to determine if targets have
changed. This is also a very big one. It's _close_ to my plate :), changed. This is also a very big one. It's _close_ to my plate :),
and I have very definite ideas about how I want it done. Please and I have very definite ideas about how I would like it done.
pick something else unless you must have this feature. If you try Please pick something else unless you must have this feature. If
it, please work _extremely_ closely with me on it. you try it, please work _extremely_ closely with me on it.
2a) Possibly a special case of this is the .KEEP_STATE feature of Sun's 2a) Possibly a special case of this is the .KEEP_STATE feature of Sun's
make. Some great folks at W U. in Canada did an implementation of make. Some great folks at W U. in Canada did an implementation of
@ -95,7 +96,7 @@ The Rest of the List
doing until #1 is done. doing until #1 is done.
9) Right now the .PRECIOUS, .INTERMEDIATE, and .SECONDARY 9) Right now the .PRECIOUS, .INTERMEDIATE, and .SECONDARY
psuedo-targets have different capabilities. For example, .PRECIOUS pseudo-targets have different capabilities. For example, .PRECIOUS
can take a "%", the others can't. Etc. These should all work the can take a "%", the others can't. Etc. These should all work the
same, insofar as that makes sense. same, insofar as that makes sense.
@ -105,15 +106,35 @@ The Rest of the List
very important for parallel builds: sometimes you need some stuff very important for parallel builds: sometimes you need some stuff
done first but you don't want to rebuild everything because of it. done first but you don't want to rebuild everything because of it.
11) Improved debugging/logging/etc. capabilities. This area is in 11) Improved debugging/logging/etc. capabilities. Part of this is done:
desparate need of work; the current -d, -s, etc. options are simply I introduced a number of debugging enhancements. Tim Magill is (I
insufficient. We need different levels of output: some that are think) looking into options to control output more selectively.
much less verbose. E.g., maybe just print one line about why make One thing I want to do in debugging is add a flag to allow debugging
decides to rebuild each target. Also, we could use something like of variables as they're expanded (!). This would be incredibly
the -E option for preprocessors; this would print out makefiles verbose, but could be invaluable when nothing else seems to work and
after resolving all includes, immediate variable reverences, etc. you just can't figure it out. The way variables are expanded now
Also, a way to turn on and off obeying the "@" token for scripts means this isn't 100% trivial, but it probably won't be hard.
that's independent of -n (so we could have them in effect for -n,
and have them not in effect without -n).
Maybe other things. Contact me about the user interface. 12) Integration of Guile as an embedded scripting language. This means:
allowing Guile functions to be declared in makefiles somehow, then
providing a syntax for invoking them. At least one formulation of
that would have the function resolve to a string which would be
substituted in the makefile, kind of like $(shell ...) does now, but
using the embedded interpreter so there's no process forked of
course. Obviously this is an optional add-on feature.
It could be more advanced than that, even, who knows? Maybe make
could provide Guile functions that allow Guile scripts more direct
access to internal make structures, somehow. This kind of thing
needs a lot of thought.
Also there's always the flip side: in some very fundamental ways
make isn't the best choice right now for a complex build tool. It's
great for simple-to-medium tasks, but there are already other tools
available for the really tough situations. Ask yourself,
realistically, how much work is worthwhile to add to make, given the
fundamentals you can't really overcome without significantly
affecting backward compatibility--and then why not use another tool
in the first place?
Something to think about.

15
file.c
View File

@ -580,11 +580,12 @@ file_timestamp_cons (fname, s, ns)
return ts; return ts;
} }
/* Get and print file timestamps. */ /* Return the current time as a file timestamp, setting *RESOLUTION to
its resolution. */
FILE_TIMESTAMP FILE_TIMESTAMP
file_timestamp_now () file_timestamp_now (int *resolution)
{ {
int r;
time_t s; time_t s;
int ns; int ns;
@ -598,6 +599,7 @@ file_timestamp_now ()
struct timespec timespec; struct timespec timespec;
if (clock_gettime (CLOCK_REALTIME, &timespec) == 0) if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
{ {
r = 1;
s = timespec.tv_sec; s = timespec.tv_sec;
ns = timespec.tv_nsec; ns = timespec.tv_nsec;
goto got_time; goto got_time;
@ -609,6 +611,7 @@ file_timestamp_now ()
struct timeval timeval; struct timeval timeval;
if (gettimeofday (&timeval, 0) == 0) if (gettimeofday (&timeval, 0) == 0)
{ {
r = 1000;
s = timeval.tv_sec; s = timeval.tv_sec;
ns = timeval.tv_usec * 1000; ns = timeval.tv_usec * 1000;
goto got_time; goto got_time;
@ -617,13 +620,17 @@ file_timestamp_now ()
#endif #endif
} }
r = 1000000000;
s = time ((time_t *) 0); s = time ((time_t *) 0);
ns = 0; ns = 0;
got_time: got_time:
*resolution = r;
return file_timestamp_cons (0, s, ns); return file_timestamp_cons (0, s, ns);
} }
/* Place into the buffer P a printable representation of the file
timestamp TS. */
void void
file_timestamp_sprintf (p, ts) file_timestamp_sprintf (p, ts)
char *p; char *p;
@ -647,7 +654,7 @@ file_timestamp_sprintf (p, ts)
applies only to local times, whereas this timestamp might come applies only to local times, whereas this timestamp might come
from a remote filesystem. So removing trailing zeros is the from a remote filesystem. So removing trailing zeros is the
best guess that we can do. */ best guess that we can do. */
sprintf (p, ".%09ld", (long) FILE_TIMESTAMP_NS (ts)); sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts));
p += strlen (p) - 1; p += strlen (p) - 1;
while (*p == '0') while (*p == '0')
p--; p--;

View File

@ -131,8 +131,8 @@ extern void notice_finished_file PARAMS ((struct file *file));
#define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \ #define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \
>> FILE_TIMESTAMP_LO_BITS) >> FILE_TIMESTAMP_LO_BITS)
#define FILE_TIMESTAMP_NS(ts) (((ts) - ORDINARY_MTIME_MIN) \ #define FILE_TIMESTAMP_NS(ts) ((int) (((ts) - ORDINARY_MTIME_MIN) \
& ((1 << FILE_TIMESTAMP_LO_BITS) - 1)) & ((1 << FILE_TIMESTAMP_LO_BITS) - 1)))
/* Upper bound on length of string "YYYY-MM-DD HH:MM:SS.NNNNNNNNN" /* Upper bound on length of string "YYYY-MM-DD HH:MM:SS.NNNNNNNNN"
representing a file timestamp. The upper bound is not necessarily 19, representing a file timestamp. The upper bound is not necessarily 19,
@ -154,7 +154,7 @@ extern void notice_finished_file PARAMS ((struct file *file));
extern FILE_TIMESTAMP file_timestamp_cons PARAMS ((char const *, extern FILE_TIMESTAMP file_timestamp_cons PARAMS ((char const *,
time_t, int)); time_t, int));
extern FILE_TIMESTAMP file_timestamp_now PARAMS ((void)); extern FILE_TIMESTAMP file_timestamp_now PARAMS ((int *));
extern void file_timestamp_sprintf PARAMS ((char *p, FILE_TIMESTAMP ts)); extern void file_timestamp_sprintf PARAMS ((char *p, FILE_TIMESTAMP ts));
/* Return the mtime of file F (a struct file *), caching it. /* Return the mtime of file F (a struct file *), caching it.

View File

@ -396,6 +396,15 @@ update_file_1 (file, depth)
noexist = this_mtime == NONEXISTENT_MTIME; noexist = this_mtime == NONEXISTENT_MTIME;
if (noexist) if (noexist)
DBF (DB_BASIC, _("File `%s' does not exist.\n")); DBF (DB_BASIC, _("File `%s' does not exist.\n"));
else
{
#ifndef NO_ARCHIVES
/* Avoid spurious rebuilds of archive members due to their
timestamp resolution being only one second. */
if (1 < FILE_TIMESTAMPS_PER_S && ar_name (file->name))
this_mtime += FILE_TIMESTAMPS_PER_S - 1;
#endif
}
must_make = noexist; must_make = noexist;
@ -1041,7 +1050,6 @@ f_mtime (file, search)
char *arname, *memname; char *arname, *memname;
struct file *arfile; struct file *arfile;
time_t memtime;
int arname_used = 0; int arname_used = 0;
time_t member_date; time_t member_date;
@ -1154,7 +1162,7 @@ f_mtime (file, search)
&& mtime != NONEXISTENT_MTIME && mtime != NONEXISTENT_MTIME
&& !file->updated) && !file->updated)
{ {
static FILE_TIMESTAMP now; static FILE_TIMESTAMP adjusted_now;
FILE_TIMESTAMP adjusted_mtime = mtime; FILE_TIMESTAMP adjusted_mtime = mtime;
@ -1178,19 +1186,28 @@ f_mtime (file, search)
adjusted_mtime -= adjustment; adjusted_mtime -= adjustment;
#endif #endif
/* If the file's time appears to be in the future, udpate our /* If the file's time appears to be in the future, update our
concept of the present and try once more. */ concept of the present and try once more. */
if (now < adjusted_mtime if (adjusted_now < adjusted_mtime)
&& (now = file_timestamp_now ()) < adjusted_mtime) {
{ int resolution;
char mtimebuf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1]; FILE_TIMESTAMP now = file_timestamp_now (&resolution);
char nowbuf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1]; adjusted_now = now + (resolution - 1);
if (adjusted_now < adjusted_mtime)
file_timestamp_sprintf (mtimebuf, mtime); {
file_timestamp_sprintf (nowbuf, now); #ifdef NO_FLOAT
error (NILF, _("*** Warning: File `%s' has modification time in the future (%s > %s)"), error (NILF, _("*** Warning: File `%s' has modification time in the future"),
file->name, mtimebuf, nowbuf); file->name);
clock_skew_detected = 1; #else
double from_now =
(FILE_TIMESTAMP_S (mtime) - FILE_TIMESTAMP_S (now)
+ ((FILE_TIMESTAMP_NS (mtime) - FILE_TIMESTAMP_NS (now))
/ 1e9));
error (NILF, _("*** Warning: File `%s' has modification time %.2g s in the future"),
file->name, from_now);
#endif
clock_skew_detected = 1;
}
} }
} }
} }
@ -1228,13 +1245,13 @@ name_mtime (name)
{ {
struct stat st; struct stat st;
while (stat (name, &st) != 0) while (stat (name, &st) != 0)
if (errno != EINTR) if (!EINTR_SET)
{ {
if (errno != ENOENT && errno != ENOTDIR) if (errno != ENOENT && errno != ENOTDIR)
perror_with_name ("stat:", name); perror_with_name ("stat:", name);
return NONEXISTENT_MTIME; return NONEXISTENT_MTIME;
} }
return FILE_TIMESTAMP_STAT_MODTIME (name, st); return FILE_TIMESTAMP_STAT_MODTIME (name, st);
} }

View File

@ -201,9 +201,6 @@ lookup_variable (name, length)
sptr = value; sptr = value;
scnt = 0; scnt = 0;
if (listp)
*listp = current_variable_set_list;
while ((sptr = strchr (sptr, '$'))) while ((sptr = strchr (sptr, '$')))
{ {
scnt++; scnt++;