aboutsummaryrefslogtreecommitdiff
path: root/gcc/cobol/util.cc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2025-03-15 09:43:36 +0000
committerIain Sandoe <iain@sandoe.co.uk>2025-03-18 20:04:47 +0000
commit544a9d9e49a1ff1d031cf9c85518f7c95179834a (patch)
treed87fe0870a14ec0e85aa5727b1f32a1e6654b05b /gcc/cobol/util.cc
parent1ad1bcc991b32d72d4de4758c0dcac611f20cda8 (diff)
downloadgcc-544a9d9e49a1ff1d031cf9c85518f7c95179834a.zip
gcc-544a9d9e49a1ff1d031cf9c85518f7c95179834a.tar.gz
gcc-544a9d9e49a1ff1d031cf9c85518f7c95179834a.tar.bz2
gcc, cobol: Check for get_current_dir_name [PR119301]
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>
Diffstat (limited to 'gcc/cobol/util.cc')
-rw-r--r--gcc/cobol/util.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index 62ecd98..101a0a0 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -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 )
{