[Glibc-bsd-commits] r4413 - trunk/glibc-ports/kfreebsd

Petr Salinger ps-guest at alioth.debian.org
Wed May 8 08:19:29 UTC 2013


Author: ps-guest
Date: 2013-05-08 08:19:28 +0000 (Wed, 08 May 2013)
New Revision: 4413

Modified:
   trunk/glibc-ports/kfreebsd/Makefile
   trunk/glibc-ports/kfreebsd/getcwd.c
Log:
1st getcwd changes


Modified: trunk/glibc-ports/kfreebsd/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/Makefile	2013-05-07 23:22:08 UTC (rev 4412)
+++ trunk/glibc-ports/kfreebsd/Makefile	2013-05-08 08:19:28 UTC (rev 4413)
@@ -126,7 +126,7 @@
 
 # Special ELF hacks.
 ifeq ($(subdir),elf)
-sysdep-rtld-routines += dl-brk dl-sbrk
+sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd
 sysdep_routines += sys_umtx
 endif
 

Modified: trunk/glibc-ports/kfreebsd/getcwd.c
===================================================================
--- trunk/glibc-ports/kfreebsd/getcwd.c	2013-05-07 23:22:08 UTC (rev 4412)
+++ trunk/glibc-ports/kfreebsd/getcwd.c	2013-05-08 08:19:28 UTC (rev 4413)
@@ -27,6 +27,12 @@
 #include <sysdep.h>
 #include <bp-checks.h>
 
+/* If we compile the file for use in ld.so we don't need the feature
+   that getcwd() allocates the buffers itself.  */
+#ifdef IS_IN_rtld
+# define NO_ALLOCATION  1
+#endif
+
 /* The system calls only makes a lookup in the VFS cache, which can easily
    fail.  Therefore we use the generic version as a fallback.  */
 extern int __syscall_getcwd (char *__unbounded buf, unsigned int size);
@@ -50,8 +56,11 @@
 	      __set_errno (EINVAL);
 	      return NULL;
 	    }
-
+#ifdef NO_ALLOCATION
+          buf = NULL;
+#else
 	  buf = (char *) malloc (len);
+#endif
 	  if (__builtin_expect (buf == NULL, 0))
 	    {
 	      __set_errno (ENOMEM);
@@ -68,7 +77,11 @@
 
 	  if (buf == NULL)
 	    {
+#ifdef NO_ALLOCATION
+              buf = NULL;
+#else
 	      buf = (char *) malloc (size);
+#endif
 	      if (__builtin_expect (buf == NULL, 0))
 		{
 		  __set_errno (ENOMEM);
@@ -80,12 +93,18 @@
       memcpy (buf, tmpbuf, len);
       return buf;
     }
+#ifdef IS_IN_rtld
+  return NULL;
+#else
   return generic_getcwd (buf, size);
+#endif
 }
 
 weak_alias (__getcwd, getcwd)
 
+#ifndef IS_IN_rtld
 /* Get the code for the generic version.  */
 #define GETCWD_RETURN_TYPE	static char * internal_function
 #define __getcwd		generic_getcwd
 #include <sysdeps/posix/getcwd.c>
+#endif




More information about the Glibc-bsd-commits mailing list