summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2000-06-13 05:22:52 +0000
committerPaul Smith <psmith@gnu.org>2000-06-13 05:22:52 +0000
commit4972b017b63f3ce324bfa65a1b46a2a173baf463 (patch)
treed4bac994ae10ea2290d195dfe12978a8bfcda2ea
parent4a5550c8225d762f684d4047e20cc45274b6a785 (diff)
downloadgunmake-4972b017b63f3ce324bfa65a1b46a2a173baf463.tar.gz
* Some timestamp fixes from Paul Eggert.
* Fix compilation on Linux; use libintl.h and not gettext.h when using the system gettext.
-rw-r--r--ChangeLog56
-rw-r--r--NEWS2
-rw-r--r--acconfig.h9
-rw-r--r--acinclude.m410
-rw-r--r--commands.c7
-rw-r--r--file.c60
-rw-r--r--filedef.h75
-rw-r--r--function.c2
-rw-r--r--gettext.h28
-rw-r--r--main.c6
-rw-r--r--make.h10
-rw-r--r--remake.c95
-rw-r--r--vpath.c6
13 files changed, 235 insertions, 131 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f050ec..df101bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,59 @@
+2000-06-13 Paul D. Smith <psmith@gnu.org>
+
+ * gettext.h: If we have libintl.h, use that instead of any of the
+ contents of gettext.h. We won't check for libintl.h unless we're
+ using the system gettext.
+
+ * function.c (func_word): Clarify error message.
+
+2000-06-10 Paul Eggert <eggert@twinsun.com>
+
+ Support nanosecond resolution on hosts with 64-bit time_t and
+ uintmax_t (e.g. 64-bit Sparc Solaris), by splitting
+ FILE_TIMESTAMP into a 30-bit part for nanoseconds, with the
+ rest for seconds, if FILE_TIMESTAMP is at least 64 bits wide.
+
+ * make.h: Always define FILE_TIMESTAMP to be uintmax_t, for
+ simplicity.
+
+ * filedef.h (FILE_TIMESTAMP_HI_RES, FILE_TIMESTAMP_LO_BITS)
+ (UNKNOWN_MTIME, NONEXISTENT_MTIME, OLD_MTIME)
+ (ORDINARY_MTIME_MIN, ORDINARY_MTIME_MAX): New macros.
+ (FILE_TIMESTAMP_STAT_MODTIME): Now takes fname arg. All uses changed.
+ (FILE_TIMESTAMP_DIV, FILE_TIMESTAMP_MOD)
+ (FILE_TIMESTAMP_FROM_S_AND_NS): Remove.
+ (FILE_TIMESTAMP_S, FILE_TIMESTAMP_NS): Use shifts instead of
+ multiplication and division. Offset the timestamps by
+ ORDINARY_MTIME_MIN.
+ (file_timestamp_cons): New decl.
+ (NEW_MTIME): Now just the maximal timestamp value, as we no longer use
+ -1 to refer to nonexistent files.
+
+ * file.c (snap_deps, print_file): Use NONEXISTENT_MTIME,
+ UNKNOWN_MTIME, and OLD_MTIME instead of magic constants.
+ * filedef.h (file_mtime_1): Likewise.
+ * main.c (main): Likewise.
+ * remake.c (update_file_1, notice_finished_file, check_dep)
+ (f_mtime, name_mtime, library_search): Likewise.
+ * vpath.c (selective_vpath_search): Likewise.
+
+ * remake.c (f_mtime): Do not assume that (time_t) -1 equals
+ NONEXISTENT_MTIME. When futzing with time stamps, adjust by
+ multiples of 2**30, not 10**9. Do not calculate timestamp
+ adjustments on DOS unless they are needed.
+
+ * commands.c (delete_target): Do not assume that
+ FILE_TIMESTAMP_S yields -1 for a nonexistent file, as that is
+ no longer true with the new representation.
+
+ * file.c (file_timestamp_cons): New function, replacing
+ FILE_TIMESTAMP_FROM_S_AND_NS. All uses changed.
+ (file_timestamp_now): Use FILE_TIMESTAMP_HI_RES instead of 1 <
+ FILE_TIMESTAMPS_PER_S to determine whether we're using hi-res
+ timestamps.
+ (print_file): Print OLD_MTIME values as "very old" instead of
+ as a timestamp.
+
2000-05-31 Paul Eggert <eggert@twinsun.com>
* remake.c (name_mtime): Check for stat failures. Retry if EINTR.
diff --git a/NEWS b/NEWS
index 8a29d5c..ef11308 100644
--- a/NEWS
+++ b/NEWS
@@ -46,7 +46,7 @@ Version 3.79
all debugging information is generated.
* The `-p' (print database) output now includes filename and linenumber
- information for variable definitions, to help debugging.
+ information for variable definitions, to aid debugging.
* The wordlist function no longer reverses its arguments if the "start"
value is greater than the "end" value. If that's true, nothing is
diff --git a/acconfig.h b/acconfig.h
index ae47fdd..5ac77ff 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -7,21 +7,12 @@
/* Define to 1 if NLS is requested. */
#undef ENABLE_NLS
-/* Define as 1 if you have dcgettext. */
-#undef HAVE_DCGETTEXT
-
-/* Define as 1 if you have gettext and don't want to use GNU gettext. */
-#undef HAVE_GETTEXT
-
/* Define if your locale.h file contains LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to the installation directory for locales. */
#undef LOCALEDIR
-/* Define as 1 if you have the stpcpy function. */
-#undef HAVE_STPCPY
-
/* Define to the name of the SCCS `get' command. */
#undef SCCS_GET
diff --git a/acinclude.m4 b/acinclude.m4
index 63e84c6..e267b70 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -486,6 +486,8 @@ esac
dnl ---------------------------------------------------------------------------
dnl Enable internationalization support for GNU make.
dnl Obtained from the libit 0.7 distribution
+dnl Modified to check for a system version of GNU gettext by
+dnl Paul D. Smith <psmith@gnu.org>
dnl
AC_DEFUN(fp_WITH_GETTEXT, [
@@ -509,7 +511,7 @@ AC_DEFUN(fp_WITH_GETTEXT, [
# Look around for gettext() on the system
AC_SEARCH_LIBS(gettext, intl)
- if test $ac_cv_search_gettext = no; then
+ if test "$ac_cv_search_gettext" = no; then
with_included_gettext=yes
else
# We only want to deal with GNU's gettext; if we don't have that
@@ -523,10 +525,10 @@ AC_DEFUN(fp_WITH_GETTEXT, [
esac
fi
- if test $with_included_gettext = yes; then
+ if test "$with_included_gettext" = yes; then
LIBOBJS="$LIBOBJS gettext.o"
- AC_DEFINE(HAVE_GETTEXT)
- AC_DEFINE(HAVE_DCGETTEXT)
+ AC_DEFINE(HAVE_GETTEXT, 1, [Define if you have the gettext function.])
+ AC_DEFINE(HAVE_DCGETTEXT, 1, [Define if you have the dcgettext function.])
else
AC_CHECK_HEADERS(libintl.h)
AC_CHECK_FUNCS(dcgettext gettext)
diff --git a/commands.c b/commands.c
index df4a447..156fe06 100644
--- a/commands.c
+++ b/commands.c
@@ -477,7 +477,10 @@ delete_target (file, on_behalf_of)
#ifndef NO_ARCHIVES
if (ar_name (file->name))
{
- if (ar_member_date (file->name) != FILE_TIMESTAMP_S (file->last_mtime))
+ time_t file_date = (file->last_mtime == NONEXISTENT_MTIME
+ ? (time_t) -1
+ : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
+ if (ar_member_date (file->name) != file_date)
{
if (on_behalf_of)
error (NILF, _("*** [%s] Archive member `%s' may be bogus; not deleted"),
@@ -492,7 +495,7 @@ delete_target (file, on_behalf_of)
if (stat (file->name, &st) == 0
&& S_ISREG (st.st_mode)
- && FILE_TIMESTAMP_STAT_MODTIME (st) != file->last_mtime)
+ && FILE_TIMESTAMP_STAT_MODTIME (file->name, st) != file->last_mtime)
{
if (on_behalf_of)
error (NILF, _("*** [%s] Deleting file `%s'"), on_behalf_of, file->name);
diff --git a/file.c b/file.c
index daaea69..b583db9 100644
--- a/file.c
+++ b/file.c
@@ -475,8 +475,8 @@ snap_deps ()
{
/* Mark this file as phony and nonexistent. */
f2->phony = 1;
- f2->last_mtime = (FILE_TIMESTAMP) -1;
- f2->mtime_before_update = (FILE_TIMESTAMP) -1;
+ f2->last_mtime = NONEXISTENT_MTIME;
+ f2->mtime_before_update = NONEXISTENT_MTIME;
}
for (f = lookup_file (".INTERMEDIATE"); f != 0; f = f->prev)
@@ -564,35 +564,73 @@ set_command_state (file, state)
d->file->command_state = state;
}
+/* Convert an external file timestamp to internal form. */
+
+FILE_TIMESTAMP
+file_timestamp_cons (fname, s, ns)
+ char const *fname;
+ time_t s;
+ int ns;
+{
+ int offset = ORDINARY_MTIME_MIN + (FILE_TIMESTAMP_HI_RES ? ns : 0);
+ FILE_TIMESTAMP product = (FILE_TIMESTAMP) s << FILE_TIMESTAMP_LO_BITS;
+ FILE_TIMESTAMP ts = product + offset;
+
+ if (! (s <= FILE_TIMESTAMP_S (ORDINARY_MTIME_MAX)
+ && product <= ts && ts <= ORDINARY_MTIME_MAX))
+ {
+ char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
+ ts = s <= OLD_MTIME ? ORDINARY_MTIME_MIN : ORDINARY_MTIME_MAX;
+ file_timestamp_sprintf (buf, ts);
+ error (NILF, _("%s: Timestamp out of range; substituting %s"),
+ fname ? fname : _("Current time"), buf);
+ }
+
+ return ts;
+}
+
/* Get and print file timestamps. */
FILE_TIMESTAMP
file_timestamp_now ()
{
+ time_t s;
+ int ns;
+
/* Don't bother with high-resolution clocks if file timestamps have
only one-second resolution. The code below should work, but it's
not worth the hassle of debugging it on hosts where it fails. */
- if (1 < FILE_TIMESTAMPS_PER_S)
+ if (FILE_TIMESTAMP_HI_RES)
{
#if HAVE_CLOCK_GETTIME && defined CLOCK_REALTIME
{
struct timespec timespec;
if (clock_gettime (CLOCK_REALTIME, &timespec) == 0)
- return FILE_TIMESTAMP_FROM_S_AND_NS (timespec.tv_sec,
- timespec.tv_nsec);
+ {
+ s = timespec.tv_sec;
+ ns = timespec.tv_nsec;
+ goto got_time;
+ }
}
#endif
#if HAVE_GETTIMEOFDAY
{
struct timeval timeval;
if (gettimeofday (&timeval, 0) == 0)
- return FILE_TIMESTAMP_FROM_S_AND_NS (timeval.tv_sec,
- timeval.tv_usec * 1000);
+ {
+ s = timeval.tv_sec;
+ ns = timeval.tv_usec * 1000;
+ goto got_time;
+ }
}
#endif
}
- return FILE_TIMESTAMP_FROM_S_AND_NS (time ((time_t *) 0), 0);
+ s = time ((time_t *) 0);
+ ns = 0;
+
+ got_time:
+ return file_timestamp_cons (0, s, ns);
}
void
@@ -666,10 +704,12 @@ print_file (f)
printf (" %s", dep_name (d));
putchar ('\n');
}
- if (f->last_mtime == 0)
+ if (f->last_mtime == UNKNOWN_MTIME)
puts (_("# Modification time never checked."));
- else if (f->last_mtime == (FILE_TIMESTAMP) -1)
+ else if (f->last_mtime == NONEXISTENT_MTIME)
puts (_("# File does not exist."));
+ else if (f->last_mtime == OLD_MTIME)
+ puts (_("# File is very old."));
else
{
char buf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
diff --git a/filedef.h b/filedef.h
index 9391818..5743d6a 100644
--- a/filedef.h
+++ b/filedef.h
@@ -118,28 +118,28 @@ extern void notice_finished_file PARAMS ((struct file *file));
#ifdef ST_MTIM_NSEC
-# define FILE_TIMESTAMP_STAT_MODTIME(st) \
- FILE_TIMESTAMP_FROM_S_AND_NS ((st).st_mtime, \
- (st).st_mtim.ST_MTIM_NSEC)
-# define FILE_TIMESTAMPS_PER_S \
- MIN ((FILE_TIMESTAMP) 1000000000, \
- (INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP) \
- / INTEGER_TYPE_MAXIMUM (time_t)))
+# define FILE_TIMESTAMP_HI_RES \
+ (2147483647 < INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP) >> 31)
+# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
+ file_timestamp_cons (fname, (st).st_mtime, (st).st_mtim.ST_MTIM_NSEC)
#else
-# define FILE_TIMESTAMP_STAT_MODTIME(st) ((st).st_mtime)
-# define FILE_TIMESTAMPS_PER_S 1
+# define FILE_TIMESTAMP_HI_RES 0
+# define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
+ file_timestamp_cons (fname, (st).st_mtime, 0)
#endif
-#define FILE_TIMESTAMP_FROM_S_AND_NS(s, ns) \
- ((s) * FILE_TIMESTAMPS_PER_S \
- + (ns) * FILE_TIMESTAMPS_PER_S / 1000000000)
-#define FILE_TIMESTAMP_DIV(a, b) ((a)/(b) - ((a)%(b) < 0))
-#define FILE_TIMESTAMP_MOD(a, b) ((a)%(b) + ((a)%(b) < 0) * (b))
-#define FILE_TIMESTAMP_S(ts) FILE_TIMESTAMP_DIV ((ts), FILE_TIMESTAMPS_PER_S)
-#define FILE_TIMESTAMP_NS(ts) \
- (((FILE_TIMESTAMP_MOD ((ts), FILE_TIMESTAMPS_PER_S) * 1000000000) \
- + (FILE_TIMESTAMPS_PER_S - 1)) \
- / FILE_TIMESTAMPS_PER_S)
+/* If FILE_TIMESTAMP is 64 bits (or more), use nanosecond resolution.
+ (Multiply by 2**30 instead of by 10**9 to save time at the cost of
+ slightly decreasing the number of available timestamps.) With
+ 64-bit FILE_TIMESTAMP, this stops working on 2514-05-30 01:53:04
+ UTC, but by then uintmax_t should be larger than 64 bits. */
+#define FILE_TIMESTAMPS_PER_S (FILE_TIMESTAMP_HI_RES ? 1000000000 : 1)
+#define FILE_TIMESTAMP_LO_BITS (FILE_TIMESTAMP_HI_RES ? 30 : 0)
+
+#define FILE_TIMESTAMP_S(ts) (((ts) - ORDINARY_MTIME_MIN) \
+ >> FILE_TIMESTAMP_LO_BITS)
+#define FILE_TIMESTAMP_NS(ts) (((ts) - ORDINARY_MTIME_MIN) \
+ & ((1 << FILE_TIMESTAMP_LO_BITS) - 1))
/* Upper bound on length of string "YYYY-MM-DD HH:MM:SS.NNNNNNNNN"
representing a file timestamp. The upper bound is not necessarily 19,
@@ -159,35 +159,48 @@ extern void notice_finished_file PARAMS ((struct file *file));
* 302 / 1000) \
+ 1 + 1 + 4 + 25)
+extern FILE_TIMESTAMP file_timestamp_cons PARAMS ((char const *,
+ time_t, int));
extern FILE_TIMESTAMP file_timestamp_now PARAMS ((void));
extern void file_timestamp_sprintf PARAMS ((char *p, FILE_TIMESTAMP ts));
/* Return the mtime of file F (a struct file *), caching it.
- The value is -1 if the file does not exist. */
+ The value is NONEXISTENT_MTIME if the file does not exist. */
#define file_mtime(f) file_mtime_1 ((f), 1)
/* Return the mtime of file F (a struct file *), caching it.
Don't search using vpath for the file--if it doesn't actually exist,
we don't find it.
- The value is -1 if the file does not exist. */
+ The value is NONEXISTENT_MTIME if the file does not exist. */
#define file_mtime_no_search(f) file_mtime_1 ((f), 0)
extern FILE_TIMESTAMP f_mtime PARAMS ((struct file *file, int search));
#define file_mtime_1(f, v) \
- ((f)->last_mtime ? (f)->last_mtime : f_mtime ((f), v))
+ ((f)->last_mtime == UNKNOWN_MTIME ? f_mtime ((f), v) : (f)->last_mtime)
+
+/* Special timestamp values. */
+
+/* The file's timestamp is not yet known. */
+#define UNKNOWN_MTIME 0
+
+/* The file does not exist. */
+#define NONEXISTENT_MTIME 1
+
+/* The file does not exist, and we assume that it is older than any
+ actual file. */
+#define OLD_MTIME 2
+
+/* The smallest and largest ordinary timestamps. */
+#define ORDINARY_MTIME_MIN (OLD_MTIME + 1)
+#define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \
+ << FILE_TIMESTAMP_LO_BITS) \
+ + ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S - 1)
/* Modtime value to use for `infinitely new'. We used to get the current time
from the system and use that whenever we wanted `new'. But that causes
trouble when the machine running make and the machine holding a file have
different ideas about what time it is; and can also lose for `force'
targets, which need to be considered newer than anything that depends on
- them, even if said dependents' modtimes are in the future.
-
- If FILE_TIMESTAMP is unsigned, its maximum value is the same as
- ((FILE_TIMESTAMP) -1), so use one less than that, because -1 is
- used for non-existing files. */
-#define NEW_MTIME \
- (INTEGER_TYPE_SIGNED (FILE_TIMESTAMP) \
- ? INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP) \
- : (INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP) - 1))
+ them, even if said dependents' modtimes are in the future. */
+#define NEW_MTIME INTEGER_TYPE_MAXIMUM (FILE_TIMESTAMP)
#define check_renamed(file) \
while ((file)->renamed != 0) (file) = (file)->renamed /* No ; here. */
diff --git a/function.c b/function.c
index d4fd11e..9b5fc66 100644
--- a/function.c
+++ b/function.c
@@ -738,7 +738,7 @@ func_word (o, argv, funcname)
i = atoi (argv[0]);
if (i == 0)
- fatal (reading_file, _("the `word' function takes a positive index argument"));
+ fatal (reading_file, _("first argument to `word' function must be greater than 0"));
end_p = argv[1];
diff --git a/gettext.h b/gettext.h
index 205c4e8..6a33cc1 100644
--- a/gettext.h
+++ b/gettext.h
@@ -17,16 +17,14 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* Because on some systems (e.g. Solaris) we sometimes have to include
- the systems libintl.h as well as this file we have more complex
- include protection above. But the systems header might perhaps also
- define _LIBINTL_H and therefore we have to protect the definition here. */
-
-#if !defined _LIBINTL_H || !defined _LIBGETTEXT_H
-#ifndef _LIBINTL_H
-# define _LIBINTL_H 1
-#endif
-#define _LIBGETTEXT_H 1
+/* Include libintl.h, if it was found: we don't even look for it unless we
+ want to use the system's gettext(). If not, the rest of the file contains
+ the headers necessary for our own gettext.c. */
+
+#ifdef HAVE_LIBINTL_H
+# include <libintl.h>
+
+#else
/* We define an additional symbol to signal that we use the GNU
implementation of gettext. */
@@ -80,10 +78,6 @@ extern const struct _msg_ent _msg_tbl[];
extern int _msg_tbl_length;
#endif
-/* For automatical extraction of messages sometimes no real
- translation is needed. Instead the string itself is the result. */
-#define gettext_noop(Str) (Str)
-
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
@@ -172,6 +166,12 @@ extern int _nl_msg_cat_cntr;
}
#endif
+#endif /* !HAVE_LIBINTL_H */
+
+#ifndef gettext_noop
+/* For automatical extraction of messages sometimes no real
+ translation is needed. Instead the string itself is the result. */
+# define gettext_noop(Str) (Str)
#endif
/* End of libgettext.h */
diff --git a/main.c b/main.c
index dccee19..af40349 100644
--- a/main.c
+++ b/main.c
@@ -1575,7 +1575,7 @@ int main (int argc, char ** argv)
build_vpath_lists ();
- /* Mark files given with -o flags as very old (00:00:01.00 Jan 1, 1970)
+ /* Mark files given with -o flags as very old
and as having been updated already, and files given with -W flags as
brand new (time-stamp as far as possible into the future). */
@@ -1583,7 +1583,7 @@ int main (int argc, char ** argv)
for (p = old_files->list; *p != 0; ++p)
{
f = enter_command_line_file (*p);
- f->last_mtime = f->mtime_before_update = (FILE_TIMESTAMP) 1;
+ f->last_mtime = f->mtime_before_update = OLD_MTIME;
f->updated = 1;
f->update_status = 0;
f->command_state = cs_finished;
@@ -1716,7 +1716,7 @@ int main (int argc, char ** argv)
error (NILF, _("Failed to remake makefile `%s'."),
d->file->name);
mtime = file_mtime_no_search (d->file);
- any_remade |= (mtime != (FILE_TIMESTAMP) -1
+ any_remade |= (mtime != NONEXISTENT_MTIME
&& mtime != makefile_mtimes[i]);
}
}
diff --git a/make.h b/make.h
index 16fcac7..f128618 100644
--- a/make.h
+++ b/make.h
@@ -286,14 +286,10 @@ extern char *alloca ();
# endif /* HAVE_ALLOCA_H. */
#endif /* GCC. */
-#ifdef ST_MTIM_NSEC
-# if HAVE_INTTYPES_H
-# include <inttypes.h>
-# endif
-# define FILE_TIMESTAMP uintmax_t
-#else
-# define FILE_TIMESTAMP time_t
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
#endif
+#define FILE_TIMESTAMP uintmax_t
/* ISDIGIT offers the following features:
- Its arg may be any int or unsigned int; it need not be an unsigned char.
diff --git a/remake.c b/remake.c
index eb45d12..343a05e 100644
--- a/remake.c
+++ b/remake.c
@@ -390,7 +390,7 @@ update_file_1 (file, depth)
this_mtime = file_mtime (file);
check_renamed (file);
- noexist = this_mtime == (FILE_TIMESTAMP) -1;
+ noexist = this_mtime == NONEXISTENT_MTIME;
if (noexist)
DBF (DB_BASIC, _("File `%s' does not exist.\n"));
@@ -560,7 +560,7 @@ update_file_1 (file, depth)
#if 1 /* %%% In version 4, remove this code completely to
implement not remaking deps if their deps are newer
than their parents. */
- if (d_mtime == (FILE_TIMESTAMP) -1 && !d->file->intermediate)
+ if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate)
/* We must remake if this dep does not
exist and is not intermediate. */
must_make = 1;
@@ -577,7 +577,7 @@ update_file_1 (file, depth)
{
const char *fmt = 0;
- if (d_mtime == (FILE_TIMESTAMP) -1)
+ if (d_mtime == NONEXISTENT_MTIME)
{
if (ISDB (DB_BASIC))
fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");
@@ -726,7 +726,7 @@ notice_finished_file (file)
}
}
- if (file->mtime_before_update == 0)
+ if (file->mtime_before_update == UNKNOWN_MTIME)
file->mtime_before_update = file->last_mtime;
if (ran && !file->phony)
@@ -750,7 +750,7 @@ notice_finished_file (file)
else if (file->is_target && file->cmds == 0)
i = 1;
- file->last_mtime = i == 0 ? 0 : NEW_MTIME;
+ file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;
/* Propagate the change of modification time to all the double-colon
entries for this file. */
@@ -811,7 +811,7 @@ check_dep (file, depth, this_mtime, must_make_ptr)
check_renamed (file);
mtime = file_mtime (file);
check_renamed (file);
- if (mtime == (FILE_TIMESTAMP) -1 || mtime > this_mtime)
+ if (mtime == NONEXISTENT_MTIME || mtime > this_mtime)
*must_make_ptr = 1;
}
else
@@ -839,7 +839,7 @@ check_dep (file, depth, this_mtime, must_make_ptr)
check_renamed (file);
mtime = file_mtime (file);
check_renamed (file);
- if (mtime != (FILE_TIMESTAMP) -1 && mtime > this_mtime)
+ if (mtime != NONEXISTENT_MTIME && mtime > this_mtime)
*must_make_ptr = 1;
/* Otherwise, update all non-intermediate files we depend on,
if necessary, and see whether any of them is more
@@ -1040,6 +1040,7 @@ f_mtime (file, search)
struct file *arfile;
time_t memtime;
int arname_used = 0;
+ time_t member_date;
/* Find the archive's name. */
ar_parse_name (file->name, &arname, &memname);
@@ -1094,23 +1095,21 @@ f_mtime (file, search)
free (arname);
free (memname);
- if (mtime == (FILE_TIMESTAMP) -1)
+ if (mtime == NONEXISTENT_MTIME)
/* The archive doesn't exist, so its members don't exist either. */
- return (FILE_TIMESTAMP) -1;
+ return NONEXISTENT_MTIME;
- memtime = ar_member_date (file->hname);
- if (memtime == (time_t) -1)
- /* The archive member doesn't exist. */
- return (FILE_TIMESTAMP) -1;
-
- mtime = FILE_TIMESTAMP_FROM_S_AND_NS (memtime, 0);
+ member_date = ar_member_date (file->hname);
+ mtime = (member_date == (time_t) -1
+ ? NONEXISTENT_MTIME
+ : file_timestamp_cons (file->hname, member_date, 0));
}
else
#endif
{
mtime = name_mtime (file->name);
- if (mtime == (FILE_TIMESTAMP) -1 && search && !file->ignore_vpath)
+ if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath)
{
/* If name_mtime failed, search VPATH. */
char *name = file->name;
@@ -1119,8 +1118,8 @@ f_mtime (file, search)
|| (name[0] == '-' && name[1] == 'l'
&& library_search (&name, &mtime)))
{
- if (mtime != 0)
- /* vpath_search and library_search store zero in MTIME
+ if (mtime != UNKNOWN_MTIME)
+ /* vpath_search and library_search store UNKNOWN_MTIME
if they didn't need to do a stat call for their work. */
file->last_mtime = mtime;
@@ -1148,35 +1147,38 @@ f_mtime (file, search)
We only need to do this once, for now. */
- static FILE_TIMESTAMP now;
+ if (!clock_skew_detected
+ && mtime != NONEXISTENT_MTIME
+ && !file->updated)
+ {
+ static FILE_TIMESTAMP now;
+
+ FILE_TIMESTAMP adjusted_mtime = mtime;
- FILE_TIMESTAMP adjusted_mtime = mtime;
+#if defined WINDOWS32 || defined _MSDOS__
+ FILE_TIMESTAMP adjustment;
#ifdef WINDOWS32
- /* FAT filesystems round time to the nearest even second!
- Allow for any file (NTFS or FAT) to perhaps suffer from this
- brain damage. */
- if ((FILE_TIMESTAMP_S (adjusted_mtime) & 1) == 0
- && FILE_TIMESTAMP_NS (adjusted_mtime) == 0)
- adjusted_mtime -= FILE_TIMESTAMPS_PER_S;
+ /* FAT filesystems round time to the nearest even second!
+ Allow for any file (NTFS or FAT) to perhaps suffer from this
+ brain damage. */
+ adjustment = (((FILE_TIMESTAMP_S (adjusted_mtime) & 1) == 0
+ && FILE_TIMESTAMP_NS (adjusted_mtime) == 0)
+ ? (FILE_TIMESTAMP) 1 << FILE_TIMESTAMP_LO_BITS
+ : 0);
#else
-#ifdef __MSDOS__
- /* On DJGPP under Windows 98 and Windows NT, FAT filesystems can
- set file times up to 3 seconds into the future! The bug doesn't
- occur in plain DOS or in Windows 95, but we play it safe. */
- adjusted_mtime -= 3 * FILE_TIMESTAMPS_PER_S;
+ /* On DJGPP under Windows 98 and Windows NT, FAT filesystems can
+ set file times up to 3 seconds into the future! The bug doesn't
+ occur in plain DOS or in Windows 95, but we play it safe. */
+ adjustment = (FILE_TIMESTAMP) 3 << FILE_TIMESTAMP_LO_BITS;
#endif
+ if (ORDINARY_MTIME_MIN + adjustment <= adjusted_mtime)
+ adjusted_mtime -= adjustment;
#endif
- if (!clock_skew_detected
- && mtime != (FILE_TIMESTAMP)-1 && now < adjusted_mtime
- && !file->updated)
- {
- /* This file's time appears to be in the future.
- Update our concept of the present, and compare again. */
-
- now = file_timestamp_now ();
-
- if (now < adjusted_mtime)
+ /* If the file's time appears to be in the future, udpate our
+ concept of the present and try once more. */
+ if (now < adjusted_mtime
+ && (now = file_timestamp_now ()) < adjusted_mtime)
{
char mtimebuf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
char nowbuf[FILE_TIMESTAMP_PRINT_LEN_BOUND + 1];
@@ -1201,7 +1203,8 @@ f_mtime (file, search)
been built by us but was found now, it existed before make
started. So, turn off the intermediate bit so make doesn't
delete it, since it didn't create it. */
- if (mtime != (FILE_TIMESTAMP)-1 && file->command_state == cs_not_started
+ if (mtime != NONEXISTENT_MTIME && file->command_state == cs_not_started
+ && file->command_state == cs_not_started
&& !file->tried_implicit && file->intermediate)
file->intermediate = 0;
@@ -1227,10 +1230,10 @@ name_mtime (name)
{
if (errno != ENOENT && errno != ENOTDIR)
perror_with_name ("stat:", name);
- return (FILE_TIMESTAMP) -1;
+ return NONEXISTENT_MTIME;
}
- return FILE_TIMESTAMP_STAT_MODTIME (st);
+ return FILE_TIMESTAMP_STAT_MODTIME (name, st);
}
@@ -1316,7 +1319,7 @@ library_search (lib, mtime_ptr)
/* Look first for `libNAME.a' in the current directory. */
mtime = name_mtime (libbuf);
- if (mtime != (FILE_TIMESTAMP) -1)
+ if (mtime != NONEXISTENT_MTIME)
{
*lib = xstrdup (libbuf);
if (mtime_ptr != 0)
@@ -1356,7 +1359,7 @@ library_search (lib, mtime_ptr)
{
sprintf (buf, "%s/%s", *dp, libbuf);
mtime = name_mtime (buf);
- if (mtime != (FILE_TIMESTAMP) -1)
+ if (mtime != NONEXISTENT_MTIME)
{
*lib = xstrdup (buf);
if (mtime_ptr != 0)
diff --git a/vpath.c b/vpath.c
index 2288f9a..000db97 100644
--- a/vpath.c
+++ b/vpath.c
@@ -525,10 +525,10 @@ selective_vpath_search (path, file, mtime_ptr)
if (mtime_ptr != 0)
/* Store the modtime into *MTIME_PTR for the caller.
If we have had no need to stat the file here,
- we record a zero modtime to indicate this. */
+ we record UNKNOWN_MTIME to indicate this. */
*mtime_ptr = (exists_in_cache
- ? FILE_TIMESTAMP_STAT_MODTIME (st)
- : (FILE_TIMESTAMP) 0);
+ ? FILE_TIMESTAMP_STAT_MODTIME (name, st)
+ : UNKNOWN_MTIME);
free (name);
return 1;