summaryrefslogtreecommitdiff
path: root/intl/loadmsgcat.c
diff options
context:
space:
mode:
Diffstat (limited to 'intl/loadmsgcat.c')
-rw-r--r--intl/loadmsgcat.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index f6214e1428..480e6bc384 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -35,8 +35,13 @@
# include <unistd.h>
#endif
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP) || defined _LIBC
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
+ || (defined _LIBC && defined _POSIX_MAPPED_FILES)
# include <sys/mman.h>
+# undef HAVE_MMAP
+# define HAVE_MMAP 1
+#else
+# undef HAVE_MMAP
#endif
#include "gettext.h"
@@ -72,10 +77,7 @@ _nl_load_domain (domain_file)
size_t size;
struct stat st;
struct mo_file_header *data = (struct mo_file_header *) -1;
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
int use_mmap = 0;
-#endif
struct loaded_domain *domain;
domain_file->decided = 1;
@@ -103,8 +105,7 @@ _nl_load_domain (domain_file)
return;
}
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
+#ifdef HAVE_MMAP
/* Now we are ready to load the file. If mmap() is available we try
this first. If not available or it failed we try to load it. */
data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
@@ -153,8 +154,7 @@ _nl_load_domain (domain_file)
if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED)
{
/* The magic number is wrong: not a message catalog file. */
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
+#ifdef HAVE_MMAP
if (use_mmap)
munmap ((caddr_t) data, size);
else
@@ -188,9 +188,8 @@ _nl_load_domain (domain_file)
((char *) data + W (domain->must_swap, data->hash_tab_offset));
break;
default:
- /* This is an illegal revision. */
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
+ /* This is an invalid revision. */
+#ifdef HAVE_MMAP
if (use_mmap)
munmap ((caddr_t) data, size);
else
@@ -213,9 +212,11 @@ internal_function
_nl_unload_domain (domain)
struct loaded_domain *domain;
{
+#ifdef _POSIX_MAPPED_FILES
if (domain->use_mmap)
munmap ((caddr_t) domain->data, domain->mmap_size);
else
+#endif /* _POSIX_MAPPED_FILES */
free ((void *) domain->data);
free (domain);