~ chicken-core (chicken-5) 80a34c6e281943576ef1d91dc60a6329fe249a5f
commit 80a34c6e281943576ef1d91dc60a6329fe249a5f Author: Peter Bex <peter@more-magic.net> AuthorDate: Sun Jan 29 19:12:51 2017 +0100 Commit: Kooda <kooda@upyum.com> CommitDate: Sat Feb 25 22:18:58 2017 +0100 Move SEARCH_EXE_PATH macro magic to platform Makefiles The macro #ifdef.. etc stuff got way too complex for no good reason. Get rid of the detection logic and place #define SEARCH_EXE_PATH 1 in the platform-specific Makefiles for platforms that don't have any more specific search logic in C_resolve_executable_pathname(). Signed-off-by: Kooda <kooda@upyum.com> diff --git a/Makefile.aix b/Makefile.aix index 2b0c521e..3e66dda1 100644 --- a/Makefile.aix +++ b/Makefile.aix @@ -93,6 +93,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_ALLOCA_H 1" >>$@ echo "#define HAVE_ERRNO_H 1" >>$@ echo "#define HAVE_SYSEXITS_H 1" >>$@ + echo "#define SEARCH_EXE_PATH 1" >>$@ echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ diff --git a/Makefile.android b/Makefile.android index b738f080..63bc3b34 100644 --- a/Makefile.android +++ b/Makefile.android @@ -88,6 +88,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_ALLOCA_H 1" >>$@ echo "#define HAVE_ERRNO_H 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ + echo "#define SEARCH_EXE_PATH 1" >>$@ echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ diff --git a/Makefile.bsd b/Makefile.bsd index 6dd40f2e..cb069447 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -93,6 +93,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_ALLOCA 1" >>$@ echo "#define HAVE_ERRNO_H 1" >>$@ echo "#define HAVE_SYSEXITS_H 1" >>$@ + echo "#define SEARCH_EXE_PATH 1" >>$@ echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ diff --git a/Makefile.cygwin b/Makefile.cygwin index 9867f8e8..906fa1aa 100644 --- a/Makefile.cygwin +++ b/Makefile.cygwin @@ -107,6 +107,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_ERRNO_H 1" >>$@ echo "#define HAVE_SYSEXITS_H 1" >>$@ echo "#define HAVE_DLFCN_H 1" >>$@ + echo "#define SEARCH_EXE_PATH 1" >>$@ echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ diff --git a/Makefile.hurd b/Makefile.hurd index bd955292..83402f58 100644 --- a/Makefile.hurd +++ b/Makefile.hurd @@ -88,6 +88,7 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_ERRNO_H 1" >>$@ echo "#define HAVE_SYSEXITS_H 1" >>$@ echo "#define HAVE_MEMMOVE 1" >>$@ + echo "#define SEARCH_EXE_PATH 1" >>$@ echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ diff --git a/Makefile.ios b/Makefile.ios index 9f460646..20084486 100644 --- a/Makefile.ios +++ b/Makefile.ios @@ -91,6 +91,8 @@ chicken-config.h: chicken-defaults.h echo "#define HAVE_ALLOCA_H 1" >>$@ echo "#define HAVE_ERRNO_H 1" >>$@ echo "#define HAVE_SYSEXITS_H 1" >>$@ +# TODO: Use MacOS exe path mechanism? + echo "#define SEARCH_EXE_PATH 1" >>$@ echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@ ifdef GCHOOKS echo "#define C_GC_HOOKS" >>$@ diff --git a/chicken.h b/chicken.h index 32cb03ef..b53fe44c 100644 --- a/chicken.h +++ b/chicken.h @@ -312,22 +312,6 @@ void *alloca (); # endif #endif -/** - * HAVE_EXE_PATH is defined on platforms on which there's a simple way - * to retrieve a path to the current executable (such as reading - * "/proc/<pid>/exe" or some similar trick). - * - * SEARCH_EXE_PATH is defined on platforms on which we must search for - * the current executable. Because this search is sensitive to things - * like CWD, PATH, and so on, it's done once at startup and saved in - * `C_main_exe`. - */ -#if defined(__linux__) || defined(__sun) || defined(C_MACOSX) || defined(__HAIKU__) || (defined(_WIN32) && !defined(__CYGWIN__)) -# define HAVE_EXE_PATH -#elif defined(__unix__) || defined(C_XXXBSD) || defined(_AIX) -# define SEARCH_EXE_PATH -#endif - /* Needed for pre-emptive threading */ #define C_TIMER_INTERRUPTS @@ -1632,6 +1616,16 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; # define C_set_gui_mode #endif +/** + * SEARCH_EXE_PATH is defined on platforms on which we must search for + * the current executable. Because this search is sensitive to things + * like CWD, PATH, and so on, it's done once at startup and saved in + * `C_main_exe`. + * + * On platforms where it's not defined, there's a simple way to + * retrieve a path to the current executable (such as reading + * "/proc/<pid>/exe" or some similar trick). + */ #ifdef SEARCH_EXE_PATH # define C_set_main_exe(fname) C_main_exe = C_resolve_executable_pathname(fname) #else diff --git a/runtime.c b/runtime.c index 5e0cc104..9ccce654 100644 --- a/runtime.c +++ b/runtime.c @@ -12903,6 +12903,8 @@ C_resolve_executable_pathname(C_char *fname) /* seek next entry, skip colon */ } while (path += len, *path++); +#else +# error "Please either define SEARCH_EXE_PATH in Makefile.<platform> or implement C_resolve_executable_pathname for your platform!" #endif error:Trap