about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-21 14:34:13 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-21 14:34:13 +0000
commite7c5513dcd240d468812b11fda8eaba404ea082c (patch)
tree9177a17422e50471d537a22bdefee6d4cf48f57e
parentb0fd6165c72f56f0ff6383a5cc89d74ff24820fa (diff)
downloadglibc-e7c5513dcd240d468812b11fda8eaba404ea082c.tar.gz
glibc-e7c5513dcd240d468812b11fda8eaba404ea082c.tar.xz
glibc-e7c5513dcd240d468812b11fda8eaba404ea082c.zip
Update.
1998-09-21 10:00  Ulrich Drepper  <drepper@cygnus.com>

	* string/bits/string2.h: Add mempcpy optimization.
	* sysdeps/generic/mempcpy.c: Undefined __mempcpy.
	* intl/localealias.c: Define mempcpy only if not already defined.

	* sysdeps/i386/i486/bits/string.h: Define ffsl only if not already
	defined.

1998-09-20 10:48 -0400  Zack Weinberg  <zack@rabi.phys.columbia.edu>

	* csu/abi-note.S: Emit the note directly instead of defining
	a preprocessor macro that's only used once.  Don't include sysdep.h.
	* abi-tags: Generalize Solaris entry.

1998-09-18  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/unix/bsd/getpt.c (__libc_ptyname1, __libc_ptyname2):
	Change to array to avoid runtime relocation.
	* sysdeps/unix/sysv/linux/ptsname.c: Update declarations.

1998-09-21 12:22  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* malloc/Makefile ($(objpfx)libmcheck.a): Fix use of $(LN_S).
	* math/Makefile ($(objpfx)libieee.a): Likewise.

1998-09-21  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/generic/getpt.c: Fix order of argument to weak_alias.
	Patch by John Tobey <jtobey@banta-im.com>.
-rw-r--r--ChangeLog31
-rw-r--r--abi-tags8
-rw-r--r--csu/abi-note.S72
-rw-r--r--intl/localealias.c4
-rw-r--r--malloc/Makefile3
-rw-r--r--math/Makefile3
-rw-r--r--string/bits/string2.h147
-rw-r--r--sysdeps/generic/getpt.c2
-rw-r--r--sysdeps/generic/mempcpy.c3
-rw-r--r--sysdeps/i386/i486/bits/string.h4
-rw-r--r--sysdeps/unix/bsd/getpt.c25
-rw-r--r--sysdeps/unix/sysv/linux/ptsname.c12
12 files changed, 249 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index 19f5b14edd..141d7c72bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+1998-09-21 10:00  Ulrich Drepper  <drepper@cygnus.com>
+
+	* string/bits/string2.h: Add mempcpy optimization.
+	* sysdeps/generic/mempcpy.c: Undefined __mempcpy.
+	* intl/localealias.c: Define mempcpy only if not already defined.
+
+	* sysdeps/i386/i486/bits/string.h: Define ffsl only if not already
+	defined.
+
+1998-09-20 10:48 -0400  Zack Weinberg  <zack@rabi.phys.columbia.edu>
+
+	* csu/abi-note.S: Emit the note directly instead of defining
+	a preprocessor macro that's only used once.  Don't include sysdep.h.
+	* abi-tags: Generalize Solaris entry.
+
+1998-09-18  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* sysdeps/unix/bsd/getpt.c (__libc_ptyname1, __libc_ptyname2):
+	Change to array to avoid runtime relocation.
+	* sysdeps/unix/sysv/linux/ptsname.c: Update declarations.
+
+1998-09-21 12:22  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+	* malloc/Makefile ($(objpfx)libmcheck.a): Fix use of $(LN_S).
+	* math/Makefile ($(objpfx)libieee.a): Likewise.
+
+1998-09-21  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/generic/getpt.c: Fix order of argument to weak_alias.
+	Patch by John Tobey <jtobey@banta-im.com>.
+
 1998-09-20  Ulrich Drepper  <drepper@cygnus.com>
 
 	* login/Makefile (distribute): Remove pty-internal.h, add
diff --git a/abi-tags b/abi-tags
index b43f8afb6f..6170a2a13e 100644
--- a/abi-tags
+++ b/abi-tags
@@ -6,9 +6,9 @@
 # earlier entries taking precedence over later entries.  So loose patterns
 # at the end of the list can give defaults.
 
-# The ABI tag values we use are 32-bit quantities stored in machine byte order.
-# Conventionally the high-order byte indicates the OS and the low three
-# bytes form a version number associated with a particular ABI version.
+# The ABI tags we use are four 32-bit integers.  The first of these
+# is the operating-system number, the next three are the revision number
+# of the first compatible kernel.
 
 # After the configuration regexp, four integers in C syntax appear
 # surrounded by any whitespace or punctuation, one for each byte, MSB first.
@@ -20,7 +20,7 @@
 
 .*-.*-gnu-gnu.*		1	0.0.0
 
-sparc-sun-solaris2.*	2	2.0.0	# just an arbitrary value
+.*-sun-solaris2.*	2	2.0.0	# just an arbitrary value
 
 # There is no catch-all default here because every supported OS that uses
 # ELF must have its own unique ABI tag.
diff --git a/csu/abi-note.S b/csu/abi-note.S
index d2051e5b3b..a5014ab5cc 100644
--- a/csu/abi-note.S
+++ b/csu/abi-note.S
@@ -26,44 +26,46 @@
    write to the Free Software Foundation, 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <sysdep.h>
+/* Define an ELF note identifying the operating-system ABI that the
+   executable was created for.  The ELF note information identifies a
+   particular OS or coordinated development effort within which the
+   ELF header's e_machine value plus (for dynamically linked programs)
+   the PT_INTERP dynamic linker name and DT_NEEDED shared library
+   names fully identify the runtime environment required by an
+   executable.
 
-/* The basic layout of note sections is specified by the ELF format.  */
+   The general format of ELF notes is as follows.
+   Offsets and lengths are bytes or (parenthetical references) to the
+   values in other fields.
 
-#define ELF_NOTE_BEGIN(sectname, sectflags, type, name)			      \
-	.section sectname, sectflags;					      \
-	.align 4;		/* Notes are 4-byte aligned.  */	      \
-	.long 1f - 0f;		/* 32-bit word: length of name field */	      \
-	.long 3f - 2f;		/* 32-bit word: length of desc field */	      \
-	.long (type);		/* 32-bit word: vendor-defined type field */  \
-0:	.asciz name;		/* null-terminated string, any length: name */\
-1:	.align 4;		/* Name data padded to 4-byte alignment.  */  \
-2:	/* Here follows the "note descriptor" data, whose format	      \
-	   is not specified by ELF.  The vendor name and type field	      \
-	   indicate what sort of data is found here.  */
+offset	length	contents	
+0	4	length of name
+4	4	length of data
+8	4	note type
+12	(0)	vendor name
+		- null-terminated ASCII string, padded to 4-byte alignment
+12+(0)	(4)	note data, 
 
-#define ELF_NOTE_END							      \
-3:	.align 4		/* Pad to 4-byte align the next note.  */
-
-
-/* The linker (GNU ld 2.8 and later) recognize an allocated section whose
-   name begins with `.note' and creates a PT_NOTE program header entry
-   pointing at it.
-
-   Such a program header is the canonical way (at least in the free OS
-   community) to identify the OS environment ABI that the executable was
-   created for.  The ELF note information identifies a particular OS or
-   coordinated development effort within which the ELF header's e_machine
-   value plus (for dynamically linked programs) the PT_INTERP dynamic
-   linker name and DT_NEEDED shared library names fully identify the
-   runtime environment required by an executable.
-
-   The GNU project and cooperating development efforts (including the Linux
-   community) use a vendor name string of "GNU", and a note type field with
-   value 1 for a note descriptor that indicates ABI requirements.  */
+   The GNU project and cooperating development efforts (including the
+   Linux community) use note type 1 and a vendor name string of "GNU"
+   for a note descriptor that indicates ABI requirements.  The note data
+   is four 32-bit words.  The first of these is an operating system
+   number (0=Hurd, 1=Linux, 2=Solaris, ...) and the remaining three
+   identify the earliest release of that OS that supports this ABI.
+   See abi-tags (top level) for details. */
 
 #include <abi-tag.h>		/* OS-specific ABI tag value */
+	
+/* The linker (GNU ld 2.8 and later) recognizes an allocated section whose
+   name begins with `.note' and creates a PT_NOTE program header entry
+   pointing at it. */
 
-ELF_NOTE_BEGIN(".note.ABI-tag", "a", 1, "GNU")
-	.long ABI_TAG
-ELF_NOTE_END
+	.section ".note.ABI-tag", "a"
+	.align 4
+	.long 1f - 0f		/* name length */
+	.long 3f - 2f		/* data length */
+	.long  1		/* note type */
+0:	.asciz "GNU"		/* vendor name */
+1:	.align 4		
+2:	.long ABI_TAG		/* note data: the ABI tag */
+3:	.align 4		/* pad out section */
diff --git a/intl/localealias.c b/intl/localealias.c
index 01fbe04f2e..78a704f185 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -83,7 +83,9 @@ void free ();
    file and the name space must not be polluted.  */
 # define strcasecmp __strcasecmp
 
-# define mempcpy __mempcpy
+# ifndef mempcpy
+#  define mempcpy __mempcpy
+# endif
 # define HAVE_MEMPCPY	1
 
 /* We need locking here since we can be called from different places.  */
diff --git a/malloc/Makefile b/malloc/Makefile
index 521037a51a..53251ba58a 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -64,7 +64,8 @@ include ../Rules
 
 $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
 	-rm -f $@
-	$(LN_S) $< $@
+	$(patsubst %/,cd % &&,$(objpfx)) \
+	$(LN_S) $(<F) $(@F)
 
 lib: $(objpfx)libmcheck.a
 
diff --git a/math/Makefile b/math/Makefile
index 6988e8b04b..59e085d2bc 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -140,7 +140,8 @@ override CFLAGS += -Wno-uninitialized -Wno-write-strings
 # It's not a library to make sure it is linked in instead of s_lib_version.o.
 $(objpfx)libieee.a: $(objpfx)ieee-math.o
 	rm -f $@
-	$(LN_S) $< $@
+	$(patsubst %/,cd % &&,$(objpfx)) \
+	$(LN_S) $(<F) $(@F)
 
 ifeq ($(build-shared),yes)
 $(addprefix $(objpfx),$(tests)): $(objpfx)libm.so$(libm.so-version)
diff --git a/string/bits/string2.h b/string/bits/string2.h
index 8051c48162..172c21734a 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -101,6 +101,151 @@ __STRING2_COPY_TYPE (8);
 #endif
 
 
+/* Copy N bytes from SRC to DEST, returning pointer to byte following the
+   last copied.  */
+#ifdef __USE_GNU
+# ifndef _HAVE_STRING_ARCH_mempcpy
+#  define __mempcpy(dest, src, n) \
+  (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
+		  && __string2_1bptr_p (src) && n <= 8			      \
+		  ? __mempcpy_small (dest, src, n)			      \
+		  : __mempcpy (dest, src, n)))
+/* In glibc we use this function frequently but for namespace reasons
+   we have to use the name `__mempcpy'.  */
+#  define mempcpy(dest, src, n) __mempcpy (dest, src, n)
+
+#  if _STRING_ARCH_unaligned
+#   define __mempcpy_small(dest, src, srclen) \
+  (__extension__ ({ char *__dest = (char *) (dest);			      \
+		    switch (srclen)					      \
+		      {							      \
+		      case 1:						      \
+			*__dest++ = *(char *) src;			      \
+			break;						      \
+		      case 2:						      \
+			*((__uint16_t *) __dest) =			      \
+			  __STRING2_SMALL_GET16 (src, 0);		      \
+			__dest += 2;					      \
+			break;						      \
+		      case 3:						      \
+			*((__uint16_t *) __dest) =			      \
+			  __STRING2_SMALL_GET16 (src, 0);		      \
+			__dest += sizeof (__uint16_t);			      \
+			*__dest++ = ((char *) src)[2];			      \
+			break;						      \
+		      case 4:						      \
+			*((__uint32_t *) __dest) =			      \
+			  __STRING2_SMALL_GET32 (src, 0);		      \
+			__dest += 4;					      \
+			break;						      \
+		      case 5:						      \
+			*((__uint32_t *) __dest) =			      \
+			  __STRING2_SMALL_GET32 (src, 0);		      \
+			__dest += 4;					      \
+			*__dest++ = ((char *) src)[4];			      \
+			break;						      \
+		      case 6:						      \
+			*((__uint32_t *) __dest) =			      \
+			  __STRING2_SMALL_GET32 (src, 0);		      \
+			*((__uint16_t *) (__dest + 4)) =		      \
+			  __STRING2_SMALL_GET16 (src, 4);		      \
+			__dest += 6;					      \
+			break;						      \
+		      case 7:						      \
+			*((__uint32_t *) __dest) =			      \
+			  __STRING2_SMALL_GET32 (src, 0);		      \
+			*((__uint16_t *) (__dest + 4)) =		      \
+			  __STRING2_SMALL_GET16 (src, 4);		      \
+			__dest += 6;					      \
+			*__dest++ = ((char *) src)[6];			      \
+			break;						      \
+		      case 8:						      \
+			*((__uint32_t *) __dest) =			      \
+			  __STRING2_SMALL_GET32 (src, 0);		      \
+			*((__uint32_t *) (__dest + 4)) =		      \
+			  __STRING2_SMALL_GET32 (src, 4);		      \
+			__dest += 8;					      \
+			break;						      \
+		      }							      \
+		    __dest; }))
+#  else
+#   define __mempcpy_small(dest, src, srclen) \
+  (__extension__ ({ char *__dest = (char *) (dest);			      \
+		    switch (srclen)					      \
+		      {							      \
+		      case 1:						      \
+			*__dest = '\0';					      \
+			break;						      \
+		      case 2:						      \
+			*((__STRING2_COPY_ARR2 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR2)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1] } });	      \
+			break;						      \
+		      case 3:						      \
+			*((__STRING2_COPY_ARR3 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR3)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2] } });	      \
+			break;						      \
+		      case 4:						      \
+			*((__STRING2_COPY_ARR4 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR4)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3] } });	      \
+			break;						      \
+		      case 5:						      \
+			*((__STRING2_COPY_ARR5 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR5)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4] } });	      \
+			break;						      \
+		      case 6:						      \
+			*((__STRING2_COPY_ARR6 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR6)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5] } });	      \
+			break;						      \
+		      case 7:						      \
+			*((__STRING2_COPY_ARR7 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR7)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5],		      \
+			       ((__const char *) (src))[6] } });	      \
+			break;						      \
+		      case 8:						      \
+			*((__STRING2_COPY_ARR8 *) __dest) =		      \
+			  ((__STRING2_COPY_ARR8)			      \
+			   { { ((__const char *) (src))[0],		      \
+			       ((__const char *) (src))[1],		      \
+			       ((__const char *) (src))[2],		      \
+			       ((__const char *) (src))[3],		      \
+			       ((__const char *) (src))[4],		      \
+			       ((__const char *) (src))[5],		      \
+			       ((__const char *) (src))[6],		      \
+			       ((__const char *) (src))[7] } });	      \
+			break;						      \
+		    }							      \
+		  __dest + (srclen); }))
+#  endif
+# endif
+#endif
+
+
 /* Copy SRC to DEST.  */
 #ifndef _HAVE_STRING_ARCH_strcpy
 # define strcpy(dest, src) \
@@ -274,7 +419,7 @@ __STRING2_COPY_TYPE (8);
 		      case 5:						      \
 			*((__uint32_t *) __dest) =			      \
 			  __STRING2_SMALL_GET32 (src, 0);		      \
-			__dest += sizeof (__uint32_t);			      \
+			__dest += 4;					      \
 			*__dest = '\0';					      \
 			break;						      \
 		      case 6:						      \
diff --git a/sysdeps/generic/getpt.c b/sysdeps/generic/getpt.c
index 6dee1e12df..4260d5fd34 100644
--- a/sysdeps/generic/getpt.c
+++ b/sysdeps/generic/getpt.c
@@ -28,7 +28,7 @@ __getpt ()
   __set_errno (ENOSYS);
   return -1;
 }
-weak_alias (getpt, __getpt)
+weak_alias (__getpt, getpt)
 
 stub_warning (getpt)
 #include <stub-tag.h>
diff --git a/sysdeps/generic/mempcpy.c b/sysdeps/generic/mempcpy.c
index 43873405c5..6117e1503a 100644
--- a/sysdeps/generic/mempcpy.c
+++ b/sysdeps/generic/mempcpy.c
@@ -1,7 +1,7 @@
 /* Copy memory to memory until the specified number of bytes
    has been copied, return pointer to following byte.
    Overlap is NOT handled correctly.
-   Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Torbjorn Granlund (tege@sics.se).
 
@@ -25,6 +25,7 @@
 #include <pagecopy.h>
 
 #undef mempcpy
+#undef __mempcpy
 
 void *
 __mempcpy (dstpp, srcpp, len)
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h
index 134f117377..9c4bb525cc 100644
--- a/sysdeps/i386/i486/bits/string.h
+++ b/sysdeps/i386/i486/bits/string.h
@@ -1582,7 +1582,9 @@ __strstr_g (__const char *__haystack, __const char *__needle)
 			     : "rm" (word), "1" (-1));			      \
 			  __cnt + 1; }))
 
-#  define ffsl(word) ffs(word)
+#  ifndef ffsl
+#   define ffsl(word) ffs(word)
+#  endif
 # endif	/* i686 */
 #endif	/* BSD || X/Open */
 
diff --git a/sysdeps/unix/bsd/getpt.c b/sysdeps/unix/bsd/getpt.c
index ec339c8335..55d87fa2bc 100644
--- a/sysdeps/unix/bsd/getpt.c
+++ b/sysdeps/unix/bsd/getpt.c
@@ -31,13 +31,13 @@
 #ifndef PTYNAME1
 #define PTYNAME1 "pqrsPQRS"
 #endif
-const char *__libc_ptyname1 = PTYNAME1;
+const char __libc_ptyname1[] = PTYNAME1;
 
 /* Letters indicating the position within a series.  */
 #ifndef PTYNAME2
 #define PTYNAME2 "0123456789abcdefghijklmnopqrstuv";
 #endif
-const char *__libc_ptyname2 = PTYNAME2;
+const char __libc_ptyname2[] = PTYNAME2;
 
 
 /* Open a master pseudo terminal and return its file descriptor.  */
@@ -47,32 +47,31 @@ __getpt (void)
   char buf[sizeof (_PATH_PTY) + 2];
   const char *p, *q;
   char *s;
-  
-  s = __stpcpy (buf, _PATH_PTY);
-  s[0] = '?';
-  s[1] = '?';
-  s[2] = 0;
 
-  for (p = __libc_ptyname1; *p; p++)
+  s = __mempcpy (buf, _PATH_PTY, sizeof (_PATH_PTY) - 1);
+  /* s[0] and s[1] will be filled in the loop.  */
+  s[2] = '\0';
+
+  for (p = __libc_ptyname1; *p != '\0'; ++p)
     {
       s[0] = *p;
 
-      for (q = __libc_ptyname2; *q; q++)
+      for (q = __libc_ptyname2; *q != '\0'; ++q)
 	{
 	  int fd;
-	  
+
 	  s[1] = *q;
-	  
+
 	  fd = __open (buf, O_RDWR);
 	  if (fd != -1)
 	    {
 	      if (__isatty (fd))
 		return fd;
-	      
+
 	      __close (fd);
 	      continue;
 	    }
-	  
+
 	  if (errno != EIO)
 	    return -1;
 	}
diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c
index 048ac96551..d852fb3658 100644
--- a/sysdeps/unix/sysv/linux/ptsname.c
+++ b/sysdeps/unix/sysv/linux/ptsname.c
@@ -33,8 +33,8 @@
 #define _PATH_DEVPTS "/dev/pts/"
 
 /* The are declared in getpt.c.  */
-extern const char *__libc_ptyname1;
-extern const char *__libc_ptyname2;
+extern const char __libc_ptyname1[];
+extern const char __libc_ptyname2[];
 
 /* Static buffer for `ptsname'.  */
 static char buffer[sizeof (_PATH_DEVPTS) + 20];
@@ -59,7 +59,7 @@ __ptsname_r (int fd, char *buf, size_t buflen)
   int save_errno = errno;
   struct stat st;
   int ptyno;
-  
+
   if (buf == NULL)
     {
       __set_errno (EINVAL);
@@ -97,7 +97,7 @@ __ptsname_r (int fd, char *buf, size_t buflen)
 #endif
     {
       char *p;
-      
+
       if (buflen < strlen (_PATH_TTY) + 3)
 	{
 	  __set_errno (ERANGE);
@@ -116,13 +116,13 @@ __ptsname_r (int fd, char *buf, size_t buflen)
 	  __set_errno (ENOTTY);
 	  return ENOTTY;
 	}
-      
+
       p = __stpcpy (buf, _PATH_TTY);
       p[0] = __libc_ptyname1[ptyno / 16];
       p[1] = __libc_ptyname2[ptyno % 16];
       p[2] = '\0';
     }
-    
+
   if (__stat (buf, &st) < 0)
     return errno;