diff options
| author | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2017-09-28 13:25:12 +0200 |
|---|---|---|
| committer | Mark Shinwell <mshinwell@gmail.com> | 2017-09-28 12:25:11 +0100 |
| commit | 46899afd5e16ed51c919909ebf970a8ef9be0ce4 (patch) | |
| tree | 5e2eb351f190949df2e01f0e5218b2b8891bd76a | |
| parent | 24aa2d3cb582d03b5b88e9e0c3c84f985e3937e3 (diff) | |
| download | ocaml-46899afd5e16ed51c919909ebf970a8ef9be0ce4.tar.gz | |
In Sys.getcwd, don't call getwd if HAS_GETWD is not set (follow-up to #1086) (#1335)
| -rw-r--r-- | Changes | 5 | ||||
| -rw-r--r-- | asmrun/spacetime.c | 6 | ||||
| -rw-r--r-- | byterun/sys.c | 2 | ||||
| -rw-r--r-- | config/s-templ.h | 2 | ||||
| -rwxr-xr-x | configure | 5 |
5 files changed, 8 insertions, 12 deletions
@@ -614,6 +614,11 @@ Release branch for 4.06: - GPR#1073: Remove statically allocated compare stack. (Stephen Dolan) +- GPR#1086: in Sys.getcwd, just fail instead of calling getwd() + if HAS_GETCWD is not set. + (Report and first fix by Sebastian Markbåge, final fix by Xavier Leroy, + review by MarK Shinwell) + - GPR#1269: Remove 50ms delay at exit for programs using threads (Valentin Gatien-Baron, review by Stephen Dolan) diff --git a/asmrun/spacetime.c b/asmrun/spacetime.c index bdcdd9f4f8..5d0d0dede2 100644 --- a/asmrun/spacetime.c +++ b/asmrun/spacetime.c @@ -225,14 +225,12 @@ void caml_spacetime_initialize(void) caml_secure_getenv("OCAML_SPACETIME_SNAPSHOT_DIR"); if (user_specified_automatic_snapshot_dir == NULL) { -#ifdef HAS_GETCWD +#if defined(HAS_GETCWD) if (getcwd(cwd, sizeof(cwd)) == NULL) { dir_ok = 0; } #else - if (getwd(cwd) == NULL) { - dir_ok = 0; - } + dir_ok = 0; #endif if (dir_ok) { automatic_snapshot_dir = strdup(cwd); diff --git a/byterun/sys.c b/byterun/sys.c index a7a81d71e9..fa3d5d0781 100644 --- a/byterun/sys.c +++ b/byterun/sys.c @@ -321,7 +321,7 @@ CAMLprim value caml_sys_getcwd(value unit) #ifdef HAS_GETCWD ret = getcwd_os(buff, sizeof(buff)/sizeof(*buff)); #else - ret = getwd(buff); + caml_invalid_argument("Sys.getcwd not implemented"); #endif /* HAS_GETCWD */ if (ret == 0) caml_sys_error(NO_ARG); return caml_copy_string_of_os(buff); diff --git a/config/s-templ.h b/config/s-templ.h index 9ab980b21e..6eb971d2e6 100644 --- a/config/s-templ.h +++ b/config/s-templ.h @@ -92,10 +92,8 @@ /* Define HAS_MKFIFO if the library provides the mkfifo() function. */ #define HAS_GETCWD -#define HAS_GETWD /* Define HAS_GETCWD if the library provides the getcwd() function. */ -/* Define HAS_GETWD if the library provides the getwd() function. */ #define HAS_GETPRIORITY @@ -1305,11 +1305,6 @@ if sh ./hasgot getcwd; then echo "#define HAS_GETCWD" >> s.h fi -if sh ./hasgot getwd; then - inf "getwd() found." - echo "#define HAS_GETWD" >> s.h -fi - if sh ./hasgot getpriority setpriority; then inf "getpriority() found." echo "#define HAS_GETPRIORITY" >> s.h |
