diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-04-14 23:42:28 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-04-15 00:09:16 +0200 |
commit | 073167ef7b803067bcc8be19925fac1a48577bd8 (patch) | |
tree | c54db78672d35a9dd1c542cefc705bbd65aeb87a /libguile/i18n.c | |
parent | 22072f2155f657ff229bf8aaaa00318b60e8d6e5 (diff) | |
download | guile-073167ef7b803067bcc8be19925fac1a48577bd8.tar.gz |
Allow compilation with `--disable-posix'.
Reported by Dmitry Dzhus <dima@dzhus.org>.
* configure.ac: Remove `AC_LIBOBJ([filesys])'. Document
`--disable-posix' as omitting non-essential POSIX interfaces.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
Add `filesys.c'.
(DOT_DOC_FILES): Add `filesys.doc'.
(EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Remove
`filesys.c'.
* libguile/posix.c (scm_mkstemp, scm_access): Move to `filesys.c'.
(scm_init_posix): Move `R_OK' etc. to `filesys.c'.
* libguile/filesys.c (scm_chown, scm_chmod, scm_umask, scm_open_fdes,
scm_open, scm_close, scm_close_fdes, scm_link, scm_tc16_dir,
scm_directory_stream_p, scm_opendir, scm_readdir, scm_rewinddir,
scm_closedir, scm_dir_print, scm_dir_free, scm_chdir, scm_getcwd,
set_element, fill_select_type, get_element, retrieve_select_type,
scm_select, scm_fcntl, scm_fsync, scm_symlink, scm_readlink,
scm_lstat, scm_copy_file): Conditionalize on HAVE_POSIX.
(scm_mkstemp, scm_access): New functions.
(scm_init_filesys): Conditionalize `scm_tc16_dir', `O_RDONLY', etc. on
HAVE_POSIX. Define `R_OK', `W_OK', etc.
* libguile/fports.c (fport_print): Use `scm_ttyname' only when
HAVE_POSIX.
* libguile/i18n.c (lock_locale_mutex, unlock_locale_mutex): New
functions. Update users of `scm_i_locale_mutex' to use them.
* libguile/init.c (scm_i_init_guile): Always call `scm_init_filesys'.
* meta/guile-tools.in (main): Use `setlocale' only when it is defined.
* module/ice-9/boot-9.scm: Always load `ice-9/posix'.
Diffstat (limited to 'libguile/i18n.c')
-rw-r--r-- | libguile/i18n.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/libguile/i18n.c b/libguile/i18n.c index fc651fd7e..6ee159b73 100644 --- a/libguile/i18n.c +++ b/libguile/i18n.c @@ -82,6 +82,25 @@ setlocale (int category, const char *name) /* Helper stringification macro. */ #define SCM_I18N_STRINGIFY(_name) # _name +/* Acquiring and releasing the locale lock. */ + +static inline void +lock_locale_mutex (void) +{ +#ifdef HAVE_POSIX + scm_i_pthread_mutex_lock (&scm_i_locale_mutex); +#else +#endif +} + +static inline void +unlock_locale_mutex (void) +{ +#ifdef HAVE_POSIX + scm_i_pthread_mutex_unlock (&scm_i_locale_mutex); +#else +#endif +} /* Locale objects, string and character collation, and other locale-dependent @@ -421,7 +440,7 @@ leave_locale_section (const scm_t_locale_settings *settings) /* Restore the previous locale settings. */ (void)restore_locale_settings (settings); - scm_i_pthread_mutex_unlock (&scm_i_locale_mutex); + unlock_locale_mutex (); } /* Enter a locked locale section. */ @@ -431,12 +450,12 @@ enter_locale_section (scm_t_locale locale, { int err; - scm_i_pthread_mutex_lock (&scm_i_locale_mutex); + lock_locale_mutex (); err = get_current_locale_settings (prev_locale); if (err) { - scm_i_pthread_mutex_unlock (&scm_i_locale_mutex); + unlock_locale_mutex (); return err; } @@ -483,7 +502,7 @@ get_current_locale (SCM *result) c_locale = scm_gc_malloc (sizeof (* c_locale), "locale"); - scm_i_pthread_mutex_lock (&scm_i_locale_mutex); + lock_locale_mutex (); c_locale->category_mask = LC_ALL_MASK; c_locale->base_locale = SCM_UNDEFINED; @@ -498,7 +517,7 @@ get_current_locale (SCM *result) else err = EINVAL; - scm_i_pthread_mutex_unlock (&scm_i_locale_mutex); + unlock_locale_mutex (); if (err) scm_gc_free (c_locale, sizeof (* c_locale), "locale"); @@ -1490,7 +1509,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0, http://opengroup.org/onlinepubs/007908799/xsh/nl_langinfo.html for details. */ - scm_i_pthread_mutex_lock (&scm_i_locale_mutex); + lock_locale_mutex (); if (c_locale != NULL) { #ifdef USE_GNU_LOCALE_API @@ -1506,7 +1525,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0, lsec_err = get_current_locale_settings (&lsec_prev_locale); if (lsec_err) - scm_i_pthread_mutex_unlock (&scm_i_locale_mutex); + unlock_locale_mutex (); else { lsec_err = install_locale (c_locale); @@ -1540,7 +1559,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0, } c_result = strdup (c_result); - scm_i_pthread_mutex_unlock (&scm_i_locale_mutex); + unlock_locale_mutex (); if (c_result == NULL) result = SCM_BOOL_F; |