about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/dl-sysdep.c37
-rw-r--r--sysdeps/generic/machine-gmon.h4
-rw-r--r--sysdeps/generic/strsep.c23
3 files changed, 52 insertions, 12 deletions
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index e18f0b89a4..4f97f8547b 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -26,11 +26,14 @@
 #include <link.h>
 #include <unistd.h>
 
+#include <dl-machine.h>
 
 extern int _dl_argc;
 extern char **_dl_argv;
 extern char **_environ;
 extern size_t _dl_pagesize;
+extern const char *_dl_platform;
+extern size_t _dl_platformlen;
 extern void _end;
 extern void ENTRY_POINT (void);
 
@@ -57,6 +60,7 @@ _dl_sysdep_start (void **start_argptr,
   _dl_argc = *(long *) start_argptr;
   _dl_argv = (char **) start_argptr + 1;
   _environ = &_dl_argv[_dl_argc + 1];
+  _dl_platform = NULL; /* Default to nothing known about the platform.  */
   start_argptr = (void **) _environ;
   while (*start_argptr)
     ++start_argptr;
@@ -93,6 +97,12 @@ _dl_sysdep_start (void **start_argptr,
       case AT_EGID:
 	egid = av->a_un.a_val;
 	break;
+      case AT_PLATFORM:
+	_dl_platform = av->a_un.a_ptr;
+	break;
+      case AT_HWCAP:
+	/* Well, what shall we use?  A string or an integer with bits?  */
+	break;
       }
 
   /* Linux doesn't provide us with any of these values on the stack
@@ -107,21 +117,28 @@ _dl_sysdep_start (void **start_argptr,
 
   __libc_enable_secure = uid != euid || gid != egid;
 
+  if (_dl_pagesize == 0)
+    _dl_pagesize = __getpagesize ();
+
 #ifdef DL_SYSDEP_INIT
   DL_SYSDEP_INIT;
 #endif
 
+#ifdef DL_PLATFORM_INIT
+  DL_PLATFORM_INIT;
+#endif
+
+  /* Determine the length of the platform name.  */
+  if (_dl_platform != NULL)
+    _dl_platformlen = strlen (_dl_platform);
+
   if (__sbrk (0) == &_end)
-    {
-      /* The dynamic linker was run as a program, and so the initial break
-	 starts just after our bss, at &_end.  The malloc in dl-minimal.c
-	 will consume the rest of this page, so tell the kernel to move the
-	 break up that far.  When the user program examines its break, it
-	 will see this new value and not clobber our data.  */
-      size_t pg = __getpagesize ();
-
-      __sbrk (pg - ((&_end - (void *) 0) & (pg - 1)));
-    }
+    /* The dynamic linker was run as a program, and so the initial break
+       starts just after our bss, at &_end.  The malloc in dl-minimal.c
+       will consume the rest of this page, so tell the kernel to move the
+       break up that far.  When the user program examines its break, it
+       will see this new value and not clobber our data.  */
+    __sbrk (_dl_pagesize - ((&_end - (void *) 0) & (_dl_pagesize - 1)));
 
   (*dl_main) (phdr, phnum, &user_entry);
   return user_entry;
diff --git a/sysdeps/generic/machine-gmon.h b/sysdeps/generic/machine-gmon.h
index c4a2168322..3b63707eaf 100644
--- a/sysdeps/generic/machine-gmon.h
+++ b/sysdeps/generic/machine-gmon.h
@@ -22,6 +22,10 @@
      void *__builtin_return_address (unsigned int N)
    returns the return address of the frame N frames up.  */
 
+/* Be warned that GCC cannot usefully compile __builtin_return_address(N) 
+   for N != 0 on all machines.  In this case, you may have to write
+   your own version of _mcount().  */
+
 #if __GNUC__ < 2
  #error "This file uses __builtin_return_address, a GCC 2 extension."
 #endif
diff --git a/sysdeps/generic/strsep.c b/sysdeps/generic/strsep.c
index d17e53a772..b2c7e90c39 100644
--- a/sysdeps/generic/strsep.c
+++ b/sysdeps/generic/strsep.c
@@ -27,8 +27,27 @@ __strsep (char **stringp, const char *delim)
   if (! begin || *begin == '\0')
     return NULL;
 
-  /* Find the end of the token.  */
-  end = strpbrk (begin, delim);
+  /* A frequent case is when the delimiter string contains only one
+     character.  Here we don't need to call the expensive `strpbrk'
+     function and instead work using `strchr'.  */
+  if (delim[0] == '\0' || delim[1] == '\0')
+    {
+      char ch = delim[0];
+
+      if (ch == '\0')
+	end = NULL;
+      else
+	{
+	  while (*begin == ch)
+	    ++begin;
+
+	  end = strchr (begin, delim[0]);
+	}
+    }
+  else
+    /* Find the end of the token.  */
+    end = strpbrk (begin, delim);
+
   if (end)
     {
       /* Terminate the token and set *STRINGP past NUL character.  */