mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-22 04:30:19 +02:00
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'.
This commit is contained in:
parent
9157d90102
commit
abca59fea4
2 changed files with 26 additions and 9 deletions
|
@ -62,6 +62,8 @@
|
||||||
#define R_OK 4
|
#define R_OK 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stat-time.h>
|
||||||
|
|
||||||
|
|
||||||
/* Loading a file, given an absolute filename. */
|
/* 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
|
#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
|
static int
|
||||||
compiled_is_fresh (SCM full_filename, SCM compiled_filename)
|
compiled_is_fresh (SCM full_filename, SCM compiled_filename)
|
||||||
{
|
{
|
||||||
char *source, *compiled;
|
char *source, *compiled;
|
||||||
struct stat stat_source, stat_compiled;
|
struct stat stat_source, stat_compiled;
|
||||||
int res;
|
int compiled_is_newer = 0;
|
||||||
|
|
||||||
source = scm_to_locale_string (full_filename);
|
source = scm_to_locale_string (full_filename);
|
||||||
compiled = scm_to_locale_string (compiled_filename);
|
compiled = scm_to_locale_string (compiled_filename);
|
||||||
|
|
||||||
if (stat (source, &stat_source) == 0
|
if (stat (source, &stat_source) == 0
|
||||||
&& stat (compiled, &stat_compiled) == 0
|
&& stat (compiled, &stat_compiled) == 0)
|
||||||
&& stat_source.st_mtime <= stat_compiled.st_mtime)
|
|
||||||
{
|
{
|
||||||
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 (";;; note: source file ", scm_current_error_port ());
|
||||||
scm_puts (source, scm_current_error_port ());
|
scm_puts (source, scm_current_error_port ());
|
||||||
scm_puts ("\n;;; newer than compiled ", scm_current_error_port ());
|
scm_puts ("\n;;; newer than compiled ", scm_current_error_port ());
|
||||||
scm_puts (compiled, scm_current_error_port ());
|
scm_puts (compiled, scm_current_error_port ());
|
||||||
scm_puts ("\n", scm_current_error_port ());
|
scm_puts ("\n", scm_current_error_port ());
|
||||||
res = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free (source);
|
free (source);
|
||||||
free (compiled);
|
free (compiled);
|
||||||
return res;
|
|
||||||
|
return compiled_is_newer;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_KEYWORD (kw_env, "env");
|
SCM_KEYWORD (kw_env, "env");
|
||||||
|
|
|
@ -1116,7 +1116,11 @@ If there is no handler at all, Guile prints an error and then exits."
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let* ((scmstat (stat name))
|
(let* ((scmstat (stat name))
|
||||||
(gostat (stat go-path #f)))
|
(gostat (stat go-path #f)))
|
||||||
(if (and gostat (>= (stat:mtime gostat) (stat:mtime scmstat)))
|
(if (and gostat
|
||||||
|
(or (> (stat:mtime gostat) (stat:mtime scmstat))
|
||||||
|
(and (= (stat:mtime gostat) (stat:mtime scmstat))
|
||||||
|
(>= (stat:mtimensec gostat)
|
||||||
|
(stat:mtimensec scmstat)))))
|
||||||
go-path
|
go-path
|
||||||
(begin
|
(begin
|
||||||
(if gostat
|
(if gostat
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue