diff options
author | Ludovic Courtès <ludo@gnu.org> | 2010-09-04 16:07:58 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2010-09-04 16:07:58 +0200 |
commit | abca59fea4c3652b1587f982bbf185423967bcfb (patch) | |
tree | 71505a5f999990ac5a96bcae7fde5fa9ded1ce34 /libguile/load.c | |
parent | 9157d901024558ca2cb2a59d21f26b7f897714cd (diff) | |
download | guile-abca59fea4c3652b1587f982bbf185423967bcfb.tar.gz |
Compare source/compiled file timestamps with nano-second resolution.
* libguile/load.c (compiled_is_fresh): Rename `res' to
`compiled_is_newer'. Use `get_stat_mtime' to compare with nano-second
resolution when available.
* module/ice-9/boot-9.scm (load)[fresh-compiled-file-name]: Likewise,
using `stat:mtimensec'.
Diffstat (limited to 'libguile/load.c')
-rw-r--r-- | libguile/load.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/libguile/load.c b/libguile/load.c index 7c06c9b09..fdd2763db 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -62,6 +62,8 @@ #define R_OK 4 #endif +#include <stat-time.h> + /* Loading a file, given an absolute filename. */ @@ -619,35 +621,46 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, #undef FUNC_NAME +/* Return true if COMPILED_FILENAME is newer than source file + FULL_FILENAME, false otherwise. Also return false if one of the + files cannot be stat'd. */ static int compiled_is_fresh (SCM full_filename, SCM compiled_filename) { char *source, *compiled; struct stat stat_source, stat_compiled; - int res; + int compiled_is_newer = 0; source = scm_to_locale_string (full_filename); compiled = scm_to_locale_string (compiled_filename); if (stat (source, &stat_source) == 0 - && stat (compiled, &stat_compiled) == 0 - && stat_source.st_mtime <= stat_compiled.st_mtime) + && stat (compiled, &stat_compiled) == 0) { - res = 1; + struct timespec source_mtime, compiled_mtime; + + source_mtime = get_stat_mtime (&stat_source); + compiled_mtime = get_stat_mtime (&stat_compiled); + + if (source_mtime.tv_sec < compiled_mtime.tv_sec + || (source_mtime.tv_sec == compiled_mtime.tv_sec + && source_mtime.tv_nsec <= compiled_mtime.tv_nsec)) + compiled_is_newer = 1; } - else + + if (!compiled_is_newer) { scm_puts (";;; note: source file ", scm_current_error_port ()); scm_puts (source, scm_current_error_port ()); scm_puts ("\n;;; newer than compiled ", scm_current_error_port ()); scm_puts (compiled, scm_current_error_port ()); scm_puts ("\n", scm_current_error_port ()); - res = 0; } free (source); free (compiled); - return res; + + return compiled_is_newer; } SCM_KEYWORD (kw_env, "env"); |