about summary refs log tree commit diff
path: root/catgets
diff options
context:
space:
mode:
Diffstat (limited to 'catgets')
-rw-r--r--catgets/catgets.c19
-rw-r--r--catgets/open_catalog.c28
2 files changed, 28 insertions, 19 deletions
diff --git a/catgets/catgets.c b/catgets/catgets.c
index ebfb2c54cc..b5de2fbb50 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
 
@@ -166,15 +166,18 @@ catclose (nl_catd catalog_desc)
 
   catalog = (__nl_catd) catalog_desc;
 
+#ifdef _POSIX_MAPPED_FILES
   if (catalog->status == mmapped)
     __munmap ((void *) catalog->file_ptr, catalog->file_size);
-  else if (catalog->status == malloced)
-    free ((void *) catalog->file_ptr);
-  else if (catalog->status != closed && catalog->status != nonexisting)
-    {
-      __set_errno (EBADF);
-      return -1;
-    }
+  else
+#endif	/* _POSIX_MAPPED_FILES */
+    if (catalog->status == malloced)
+      free ((void *) catalog->file_ptr);
+    else if (catalog->status != closed && catalog->status != nonexisting)
+      {
+	__set_errno (EBADF);
+	return -1;
+      }
 
   if (catalog->nlspath)
     free ((void *) catalog->nlspath);
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index deaa8718dd..e4b61d779a 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -24,7 +24,9 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <sys/mman.h>
+#ifdef _POSIX_MAPPED_FILES
+# include <sys/mman.h>
+#endif
 #include <sys/stat.h>
 
 #include "catgetsinfo.h"
@@ -194,19 +196,20 @@ __open_catalog (__nl_catd catalog)
       goto unlock_return;
     }
 
-#ifndef MAP_COPY
+  catalog->file_size = st.st_size;
+#ifdef _POSIX_MAPPED_FILES
+# ifndef MAP_COPY
     /* Linux seems to lack read-only copy-on-write.  */
-# define MAP_COPY MAP_PRIVATE
-#endif
-#ifndef MAP_FILE
+#  define MAP_COPY MAP_PRIVATE
+# endif
+# ifndef MAP_FILE
     /* Some systems do not have this flag; it is superfluous.  */
-# define MAP_FILE 0
-#endif
-#ifndef MAP_INHERIT
+#  define MAP_FILE 0
+# endif
+# ifndef MAP_INHERIT
     /* Some systems might lack this; they lose.  */
-# define MAP_INHERIT 0
-#endif
-  catalog->file_size = st.st_size;
+#  define MAP_INHERIT 0
+# endif
   catalog->file_ptr =
     (struct catalog_obj *) __mmap (NULL, st.st_size, PROT_READ,
 				   MAP_FILE|MAP_COPY|MAP_INHERIT, fd, 0);
@@ -214,6 +217,7 @@ __open_catalog (__nl_catd catalog)
     /* Tell the world we managed to mmap the file.  */
     catalog->status = mmapped;
   else
+#endif /* _POSIX_MAPPED_FILES */
     {
       /* mmap failed perhaps because the system call is not
 	 implemented.  Try to load the file.  */
@@ -258,9 +262,11 @@ __open_catalog (__nl_catd catalog)
     invalid_file:
       /* Invalid file.  Free the resources and mark catalog as not
 	 usable.  */
+#ifdef _POSIX_MAPPED_FILES
       if (catalog->status == mmapped)
 	__munmap ((void *) catalog->file_ptr, catalog->file_size);
       else
+#endif	/* _POSIX_MAPPED_FILES */
 	free (catalog->file_ptr);
       catalog->status = nonexisting;
       goto unlock_return;