]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc, cobol: Check for get_current_dir_name [PR119301]
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 15 Mar 2025 09:43:36 +0000 (09:43 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 18 Mar 2025 20:04:47 +0000 (20:04 +0000)
This adds a configure check for get_current_dir_name and falls back
to getcwd() if it is not available on the host.

PR cobol/119301

gcc/cobol/ChangeLog:

* util.cc: Check for the availability of get_current_dir_name
snf fall back to getcwd() if it is not present on the host.

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add check for get_current_dir_name.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cobol/util.cc
gcc/config.in
gcc/configure
gcc/configure.ac

index 62ecd98e9ef86eb3d2197c2caa68812685088985..101a0a0d803018af23968f6742bf8eacad16a446 100644 (file)
@@ -72,6 +72,25 @@ extern int yyparse(void);
 
 extern int demonstration_administrator(int N);
 
+#if !defined (HAVE_GET_CURRENT_DIR_NAME)
+/* Posix platforms might not have get_current_dir_name but should have
+   getcwd() and PATH_MAX.  */
+#if __has_include (<limits.h>)
+# include <limits.h>
+#endif
+/* The Hurd doesn't define PATH_MAX.  */
+#if !defined (PATH_MAX) && defined(__GNU__)
+# define PATH_MAX 4096
+#endif
+static inline char *
+get_current_dir_name ()
+{
+  /* Use libiberty's allocator here.  */
+  char *buf = (char *) xmalloc (PATH_MAX);
+  return getcwd (buf, PATH_MAX);
+}
+#endif
+
 const char *
 symbol_type_str( enum symbol_type_t type )
 {
index 0b46faa1e512123ab65f848d8dac9bde971ca123..bc60d36a6352286aa6e8b53f42ec7aa4124facc5 100644 (file)
 #endif
 
 
+/* Define to 1 if you have the `get_current_dir_name' function. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GET_CURRENT_DIR_NAME
+#endif
+
+
 /* Define to 1 if using GNU as. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_GNU_AS
index 0ef47a937603bdfa2a6c7ae17b695b55db89f220..ae1d34971e4277378be7795a741b33402c046a17 100755 (executable)
@@ -10640,7 +10640,7 @@ for ac_func in times clock kill getrlimit setrlimit atoq \
        popen sysconf strsignal getrusage nl_langinfo \
        gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
        clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked   putchar_unlocked putc_unlocked madvise mallinfo mallinfo2 fstatat getauxval \
-       clock_gettime munmap msync
+       clock_gettime munmap msync get_current_dir_name
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
index 4ac419a8a94e94d3e3faf3a9538d2d1f79c300f7..8ef11e36210bf5ab748c400a8a9fe01e18bc70a8 100644 (file)
@@ -1574,7 +1574,7 @@ AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
        popen sysconf strsignal getrusage nl_langinfo \
        gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
        gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval \
-       clock_gettime munmap msync)
+       clock_gettime munmap msync get_current_dir_name)
 
 # At least for glibc, clock_gettime is in librt.  But don't pull that
 # in if it still doesn't give us the function we want.