[Glibc-bsd-commits] r4708 - trunk/glibc-ports/fbtl

Petr Salinger ps-guest at alioth.debian.org
Tue Jul 9 19:35:25 UTC 2013


Author: ps-guest
Date: 2013-07-09 19:35:24 +0000 (Tue, 09 Jul 2013)
New Revision: 4708

Modified:
   trunk/glibc-ports/fbtl/sem_open.c
Log:
support sem_open()


Modified: trunk/glibc-ports/fbtl/sem_open.c
===================================================================
--- trunk/glibc-ports/fbtl/sem_open.c	2013-07-09 19:32:01 UTC (rev 4707)
+++ trunk/glibc-ports/fbtl/sem_open.c	2013-07-09 19:35:24 UTC (rev 4708)
@@ -49,13 +49,52 @@
 /* Protect the `mountpoint' variable above.  */
 pthread_once_t __namedsem_once attribute_hidden = PTHREAD_ONCE_INIT;
 
+#if 1
+
+/* This is the alternate debian mount point.  */
+static const char alternatemount[] = "/run/shm";
+/* This is the alternate debian directory.  */
+static const char alternatedir[] = "/run/shm/sem.";
+
 /* Determine where the shmfs is mounted (if at all).  */
 void
 attribute_hidden
 __where_is_shmfs (void)
 {
-#warning TODO - or ENOSYS
-#if 0
+  struct statfs f;
+
+  /* The canonical place is /dev/shm.  This is at least what the
+     documentation tells everybody to do.  */
+  if (statfs (defaultmount, &f) == 0)
+    {
+      /* It is in the normal place.  */
+      mountpoint.dir = (char *) defaultdir;
+      mountpoint.dirlen = sizeof (defaultdir) - 1;
+
+      return;
+    }
+
+  /* The alternate place is /run/shm.  */
+  if (statfs (alternatemount, &f) == 0)
+    {
+      /* It is in the normal place.  */
+      mountpoint.dir = (char *) alternatedir;
+      mountpoint.dirlen = sizeof (alternatedir) - 1;
+
+      return;
+    }
+    
+  /* Not configured => not supported */  
+}
+
+#else
+
+
+/* Determine where the shmfs is mounted (if at all).  */
+void
+attribute_hidden
+__where_is_shmfs (void)
+{
   char buf[512];
   struct statfs f;
   struct mntent resmem;
@@ -122,9 +161,9 @@
 
   /* Close the stream.  */
   __endmntent (fp);
-#endif
 }
 
+#endif
 
 /* Comparison function for search of existing mapping.  */
 int
@@ -152,7 +191,7 @@
 /* Lock to protect the search tree.  */
 int __sem_mappings_lock attribute_hidden = LLL_LOCK_INITIALIZER;
 
-#if 0
+
 /* Search for existing mapping and if possible add the one provided.  */
 static sem_t *
 check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
@@ -219,22 +258,23 @@
   if (result != existing && existing != SEM_FAILED && existing != MAP_FAILED)
     {
       /* Do not disturb errno.  */
+#if 1
+      int saved_errno = errno;
+      munmap(existing, sizeof (sem_t));
+      errno = saved_errno; 
+#else    
       INTERNAL_SYSCALL_DECL (err);
       INTERNAL_SYSCALL (munmap, err, 2, existing, sizeof (sem_t));
+#endif
     }
 
   return result;
 }
 
-#endif
 
 sem_t *
 sem_open (const char *name, int oflag, ...)
 {
-#if 1
-      __set_errno (ENOSYS);
-      return SEM_FAILED;
-#else      
   char *finalname;
   sem_t *result = SEM_FAILED;
   int fd;
@@ -298,7 +338,11 @@
     try_create:
       va_start (ap, oflag);
 
+#if 0
       mode = va_arg (ap, mode_t);
+#else
+      mode = va_arg (ap, int);
+#endif
       value = va_arg (ap, unsigned int);
 
       va_end (ap);
@@ -338,6 +382,10 @@
 	     since the file must be opened with a specific mode.  The
 	     mode cannot later be set since then we cannot apply the
 	     file create mask.  */
+#if 1
+#warning drop it after 2.18 sync
+#define __mktemp mktemp
+#endif
 	  if (__mktemp (tmpfname) == NULL)
 	    return SEM_FAILED;
 
@@ -414,5 +462,4 @@
     }
 
   return result;
-#endif  
 }




More information about the Glibc-bsd-commits mailing list