diff options
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/io.h | 10 | ||||
-rw-r--r-- | libgfortran/io/transfer.c | 4 | ||||
-rw-r--r-- | libgfortran/io/unit.c | 6 |
3 files changed, 12 insertions, 8 deletions
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index ab4a103..b4a8113 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -52,8 +52,12 @@ struct format_data; typedef struct fnode fnode; struct gfc_unit; -#ifdef HAVE_NEWLOCALE -/* We have POSIX 2008 extended locale stuff. */ +#if defined (HAVE_FREELOCALE) && defined (HAVE_NEWLOCALE) \ + && defined (HAVE_USELOCALE) +/* We have POSIX 2008 extended locale stuff. We only choose to use it + if all the functions required are present as some systems, e.g. NetBSD + do not have `uselocale'. */ +#define HAVE_POSIX_2008_LOCALE extern locale_t c_locale; internal_proto(c_locale); #else @@ -562,7 +566,7 @@ typedef struct st_parameter_dt char *line_buffer; struct format_data *fmt; namelist_info *ionml; -#ifdef HAVE_NEWLOCALE +#ifdef HAVE_POSIX_2008_LOCALE locale_t old_locale; #endif /* Current position within the look-ahead line buffer. */ diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index dc18bc3..c36d8bc 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3410,7 +3410,7 @@ data_transfer_init_worker (st_parameter_dt *dtp, int read_flag) if (dtp->u.p.current_unit->flags.form == FORM_FORMATTED) { -#ifdef HAVE_USELOCALE +#ifdef HAVE_POSIX_2008_LOCALE dtp->u.p.old_locale = uselocale (c_locale); #else __gthread_mutex_lock (&old_locale_lock); @@ -4243,7 +4243,7 @@ finalize_transfer (st_parameter_dt *dtp) } } -#ifdef HAVE_USELOCALE +#ifdef HAVE_POSIX_2008_LOCALE if (dtp->u.p.old_locale != (locale_t) 0) { uselocale (dtp->u.p.old_locale); diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index a3b0656..faf6299 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -114,7 +114,7 @@ static char stdout_name[] = "stdout"; static char stderr_name[] = "stderr"; -#ifdef HAVE_NEWLOCALE +#ifdef HAVE_POSIX_2008_LOCALE locale_t c_locale; #else /* If we don't have POSIX 2008 per-thread locales, we need to use the @@ -586,7 +586,7 @@ init_units (void) { gfc_unit *u; -#ifdef HAVE_NEWLOCALE +#ifdef HAVE_POSIX_2008_LOCALE c_locale = newlocale (0, "C", 0); #else #ifndef __GTHREAD_MUTEX_INIT @@ -803,7 +803,7 @@ close_units (void) free (newunits); -#ifdef HAVE_FREELOCALE +#ifdef HAVE_POSIX_2008_LOCALE freelocale (c_locale); #endif } |