summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-18 00:19:18 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-18 00:19:18 +0000
commit428383e84f04663dde479fe5deb4310227e3e7e6 (patch)
treea9b89c301ff470bf136a282f3c03df74dd8b8526
parentd957279cfb6845616ef6e5be23d4a79b2f94d578 (diff)
downloadglibc-428383e84f04663dde479fe5deb4310227e3e7e6.tar.gz
glibc-428383e84f04663dde479fe5deb4310227e3e7e6.tar.xz
glibc-428383e84f04663dde479fe5deb4310227e3e7e6.zip
Update.
1999-07-17  Zack Weinberg  <zack@rabi.columbia.edu>

	* include/libc-symbol.h: Clean up definitions of weak_alias,
	strong_alias, symbol_version, etc. etc.
	* posix/getopt.h: Use ctype.h to get features.h included, and don't
	include it at all if __GNU_LIBRARY__ is already defined.
-rw-r--r--ChangeLog7
-rw-r--r--include/libc-symbols.h132
-rw-r--r--posix/getopt.h14
3 files changed, 61 insertions, 92 deletions
diff --git a/ChangeLog b/ChangeLog
index 61e519a599..189ea70b49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1999-07-17  Zack Weinberg  <zack@rabi.columbia.edu>
+
+	* include/libc-symbol.h: Clean up definitions of weak_alias,
+	strong_alias, symbol_version, etc. etc.
+	* posix/getopt.h: Use ctype.h to get features.h included, and don't
+	include it at all if __GNU_LIBRARY__ is already defined.
+
 1999-07-17  Ulrich Drepper  <drepper@cygnus.com>
 
 	* stdio-common/bug1.c: Include <stdlib.h> to get prototype for free.
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index dd573b32a8..8073fca575 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -76,121 +76,77 @@
 # endif
 #endif
 
+#ifndef __ASSEMBLER__
+/* GCC understands weak symbols and aliases; use its interface where
+   possible, instead of embedded assembly language.  */
 
-/* Define ALIAS as a strong alias for ORIGINAL.  */
-#ifdef HAVE_ASM_SET_DIRECTIVE
-# define strong_alias_asm(original, alias)	\
+/* Define ALIASNAME as a strong alias for NAME.  */
+# define strong_alias(name, aliasname) \
+  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+
+/* This comes between the return type and function name in
+   a function definition to make that definition weak.  */
+# define weak_function __attribute__ ((weak))
+# define weak_const_function __attribute__ ((weak, __const__))
+
+# ifdef HAVE_WEAK_SYMBOLS
+
+/* Define ALIASNAME as a weak alias for NAME.
+   If weak aliases are not available, this defines a strong alias.  */
+#  define weak_alias(name, aliasname) \
+  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
+
+/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
+#  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
+#   define weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
+#  else
+#   define weak_extern(symbol)      asm (".weak " __SYMBOL_PREFIX #symbol);
+#  endif
+
+# else
+
+#  define weak_alias(name, aliasname) strong_alias(name, aliasname)
+#  define weak_extern(symbol) /* Nothing. */
+
+# endif
+
+#else /* __ASSEMBLER__ */
+
+# ifdef HAVE_ASM_SET_DIRECTIVE
+#  define strong_alias(original, alias)		\
   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias);	\
   .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
-# ifdef __ASSEMBLER__
-#  define strong_alias(original, alias)	strong_alias_asm (original, alias)
 # else
-#  define strong_alias(original, alias)	\
-  asm (__string_1 (ASM_GLOBAL_DIRECTIVE) " " __SYMBOL_PREFIX #alias "\n" \
-       ".set " __SYMBOL_PREFIX #alias "," __SYMBOL_PREFIX #original);
-# endif
-#else
-# define strong_alias_asm(original, alias)	\
+#  define strong_alias(original, alias)		\
   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias);	\
   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-# ifdef __ASSEMBLER__
-#  define strong_alias(original, alias)	strong_alias_asm (original, alias)
-# else
-#  define strong_alias(original, alias)	\
-  asm (__string_1 (ASM_GLOBAL_DIRECTIVE) " " __SYMBOL_PREFIX #alias "\n" \
-       __SYMBOL_PREFIX #alias " = " __SYMBOL_PREFIX #original);
 # endif
-#endif
-
-/* Helper macros used above.  */
-#define __string_1(x) __string_0(x)
-#define __string_0(x) #x
-
-
-#ifdef HAVE_WEAK_SYMBOLS
-
-# ifdef __ASSEMBLER__
 
+# ifdef HAVE_WEAK_SYMBOLS
 #  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
-
-/* Define ALIAS as a weak alias for ORIGINAL.
-   If weak aliases are not available, this defines a strong alias.  */
 #   define weak_alias(original, alias)	\
   .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
-
-/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
 #   define weak_extern(symbol)	\
   .weakext C_SYMBOL_NAME (symbol)
 
 #  else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
 
-/* Define ALIAS as a weak alias for ORIGINAL.
-   If weak aliases are not available, this defines a strong alias.  */
 #   define weak_alias(original, alias)	\
   .weak C_SYMBOL_NAME (alias);	\
   C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
 
-
-/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
 #   define weak_extern(symbol)	\
   .weak C_SYMBOL_NAME (symbol)
 
 #  endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
 
-# else /* ! __ASSEMBLER__ */
-
-#  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
-#   define weak_extern_asm(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
-#   define weak_alias_asm(original, alias) \
-  asm (".weakext " __SYMBOL_PREFIX #alias ", " __SYMBOL_PREFIX #original);
-#  else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
-#   define weak_extern_asm(symbol)	asm (".weak " __SYMBOL_PREFIX #symbol);
-#   define weak_alias_asm(original, alias) \
-  asm (".weak " __SYMBOL_PREFIX #alias "\n" \
-       __SYMBOL_PREFIX #alias " = " __SYMBOL_PREFIX #original);
-#  endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
+# else /* ! HAVE_WEAK_SYMBOLS */
 
-#  define weak_alias(o, a) weak_alias_asm (o, a)
-#  define weak_extern(symbol) weak_extern_asm (symbol)
+#  define weak_alias(original, alias) strong_alias(original, alias)
+#  define weak_extern(symbol) /* Nothing */
+# endif /* ! HAVE_WEAK_SYMBOLS */
 
-# endif /* ! __ASSEMBLER__ */
-#else
-# define weak_alias(original, alias) strong_alias(original, alias)
-# define weak_extern(symbol)	/* Do nothing; the ref will be strong.  */
-#endif
-
-
-#if (!defined __ASSEMBLER__ && \
-     (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)))
-/* GCC 2.7 and later has special syntax for weak symbols and aliases.
-   Using that is better when possible, because the compiler and assembler
-   are better clued in to what we are doing.  */
-# undef	strong_alias
-# define strong_alias(name, aliasname) \
-  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
-
-# ifdef HAVE_WEAK_SYMBOLS
-#  undef weak_alias
-#  define weak_alias(name, aliasname) \
-  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
-
-/* This comes between the return type and function name in
-   a function definition to make that definition weak.  */
-#  define weak_function __attribute__ ((weak))
-#  define weak_const_function __attribute__ ((weak, __const__))
-
-# endif	/* HAVE_WEAK_SYMBOLS.  */
-#endif	/* Not __ASSEMBLER__, and GCC 2.7 or later.  */
-
-
-#ifndef weak_function
-/* If we do not have the __attribute__ ((weak)) syntax, there is no way we
-   can define functions as weak symbols.  The compiler will emit a `.globl'
-   directive for the function symbol, and a `.weak' directive in addition
-   will produce an error from the assembler.  */
-# define weak_function		/* empty */
-# define weak_const_function	/* empty */
-#endif
+#endif /* __ASSEMBLER__ */
 
 /* On some platforms we can make internal function calls (i.e., calls of
    functions not exported) a bit faster by using a different calling
diff --git a/posix/getopt.h b/posix/getopt.h
index aec5d92a3d..12b7ad568e 100644
--- a/posix/getopt.h
+++ b/posix/getopt.h
@@ -23,10 +23,16 @@
 # define _GETOPT_H 1
 #endif
 
-/* We include this here since on system susing GNU libc we need some
-   macros defined.  <stdio.h> is probably the most portable header
-   file and it does what we need.  */
-#include <stdio.h>
+/* If __GNU_LIBRARY__ is not already defined, either we are being used
+   standalone, or this is the first header included in the source file.
+   If we are being used with glibc, we need to include <features.h>, but
+   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
+   not defined, include <ctype.h>, which will pull in <features.h> for us
+   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
+   doesn't flood the namespace with stuff the way some other headers do.)  */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
 
 #ifdef	__cplusplus
 extern "C" {