mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 19:00:07 +00:00
edf5b2d716
Sat Sep 7 05:15:45 1996 Ulrich Drepper <drepper@cygnus.com> * libio/iofdopen: Initialize _lock field only if _IO_MTSAFE_IO. * libio/iofopen: Likewise. * libio/iofopncook.c: Likewise. * libio/iopopen.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/memstream.c: Likewise. * libio/vasprintf.c: Likewise. * libio/vdprintf.c: Likewise. * libio/vsnprintf.c: Likewise. Sat Sep 7 03:55:47 1996 Ulrich Drepper <drepper@cygnus.com> * Makeconfig (soversions.mk): Also use shlib-versions files in add-on directories. * config.make.in (config-defines): Remove. Not used anymore. (defines): New variable. Initiliazed by @DEFINES@. * configure.in: Add AC_SUBST(DEFINES). * libio/Makefile (routines): When compiling reentrant libc add clearerr_u, feof_u, ferror_u, fputc_u, getc_u, getchar_u, iofflush_u, putc_u, putchar_u, ioflockfile. (CPPFLAGS): Add -D_IO_MTSAFE_IO for reentrant libc. * sysdeps/stub/libc-lock.h: Add stubs for __libc_cleanup_region_start and __libc_cleanup_region_end. * sysdeps/unix/i386/sysdep.S [_LIBC_REENTRANT]: Set errno using __errno_location function. * sysdeps/unix/sysv/linux/i386/sysdep.S [_LIBC_REENTRANT]: Set errno using __errno_location function. (__errno_location): New function. * sysdeps/unix/sysv/linux/i386/sysdep.h [PIC]: Add second syscall_error handler for reentrant libc. * sysdeps/unix/opendir.c: Remove unneeded `;'. * libio.h [_IO_MTSAFE_IO]: Include <pthread.h>. [!_IO_MTSAFE_IO]: Define _IO_flockfile and _IO_funlockfile as empty macros. * libioP.h: Include <libc-lock.h>. * libio/stdio.h: Add prototypes for *_locked and *_unlocked functions. * libio/clearerr.c: Use _IO_ protected versions of flockfile and funlockfile to be namespace clean. * libio/genops.c: Use __libc_lock_* macros for handling lock. * libio/iofdopen: Add initialization of _lock in _IO_FILE. * libio/iofopen: Likewise. * libio/iofopncook.c: Likewise. * libio/iopopen.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/memstream.c: Likewise. * libio/vasprintf.c: Likewise. * libio/vdprintf.c: Likewise. * libio/vsnprintf.c: Likewise. * libio/fgetc.c: Use __libc_cleanup_region_* macros instead of flockfile etc. * libio/fputc.c: Likewise. * libio/freopen.c: Likewise. * libio/fseek.c: Likewise. * libio/getc.c: Likewise. * libio/getchar.c: Likewise. * libio/iofclose.c: Likewise. * libio/iofflush.c: Likewise. * libio/iofgetpos.c: Likewise. * libio/iofgets.c: Likewise. * libio/iofputs.c: Likewise. * libio/iofread.c: Likewise. * libio/iofsetpos.c: Likewise. * libio/ioftell.c: Likewise. * libio/iofwrite.c: Likewise. * libio/iogetdelim.c: Likewise. * libio/iogets.c: Likewise. * libio/ioputs.c: Likewise. * libio/iosetbuffer.c: Likewise. * libio/iosetvbuf.c: Likewise. * libio/ioungetc.c: Likewise. * libio/putc.c: Likewise. * libio/putchar.c: Likewise. * libio/rewind.c: Likewise. * stdio-common/vfprintf.c: Likewise. * stdio-common/vfscanf.c: Likewise. * libio/clearerr_u.c: Correct alias name. * libio/ferror_u.c: Likewise. * libio/fileno.c: Likewise. * libio/fputc_u.c: Likewise. * libio/getc.c: Likewise. * libio/getc_u.c: Likewise. * libio/getchar.c: Likewise. * libio/getchar_u.c: Likewise. * libio/putc.c: Likewise. * libio/putchar.c: Likewise. * libio/feof_u.c: Undefine macro with name of function before definition of function itself. * libio/ioflockfile.c: New file. Implementation of flockfile and funlockfile. * libio/putchar_u.c: Fix typo. Use stdout instead of fp. * malloc/malloc.h: Don't include <libc-lock.h> and don't declare _malloc_loc. * malloc/free.c: Include <libc-lock.h>. * malloc/realloc.c: Likewise. * malloc/malloc-find.c: Likewise. * malloc/malloc-size.c: Likewise. * malloc/malloc-walk.c: Likewise. * malloc/memalign.c: Likewise. * malloc/malloc.c: Likewise. * sysdeps/i386/dl-machine.h: Correct clearing of _dl_starting_up. Fri Sep 6 19:38:49 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/stub/libc-lock.h: Define __libc_lock_critical_start and __libc_lock_critical_end as empty macros. * malloc/malloc.h: Don't include <libc-lock.h> and don't declare __libc_malloc_lock. * malloc/free.c: Include <libc-lock.h>. * malloc/malloc-find.c: Likewise. * malloc/malloc-size.c: Likewise. * malloc/malloc-walk.c: Likewise. * malloc/malloc.c: Likewise. * malloc/memalign.c: Likewise. * malloc/realloc.c: Likewise. * Makefile: Undo change from Mon Sep 2 22:15:14 1996. No more extra_solibs pass. * Rules: Likewise. * extra-lib.mk: Likewise. * manual/Makefile: Likewise. * db/Makefile (makedb): Choose dependecies based on build-shared. Patch by Andres Schwab. * sysdeps/posix/sysconf.c: Don't use PTHREAD_DESTRUCTOR_ITERATIONS but _POSIX_THREAD_DESTRUCTOR_ITERATIONS. * sysdeps/unix/sysv/linux/errnos.h: New file. * sysdeps/unix/sysv/linux/schedbits.h: New file. * sysdeps/unix/sysv/linux/waitflags.h: New file. * sysdeps/unix/sysv/linux/gnu/types.h: Add definition of `key_t'. Fri Sep 6 08:26:31 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * rpm/template: Fix typo in %build section. Fri Sep 6 03:31:07 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/errnos.h: Don't define errno macro when building libc without thread support. * resolv/netdb.h: Likewise for h_errno macro. Thu Sep 5 23:01:48 1996 Ulrich Drepper <drepper@cygnus.com> * libc-symbols.h: Add new macro weak_const_function. It's like weak_function, but the function is additionally marked as const. * features.h: Only include <sys/cdefs.h> if !__ASSEMBLER__. Thu Sep 5 22:55:49 1996 Richard Henderson <rth@tamu.edu> * inet/herrno.c (__h_errno_location): New function. (h_errno): Make strong_alias __h_errno so that we can access the variable even if `h_errno' is a macro. * resolv/netdb.h: Define macro h_errno to access thread specific version of h_errno variable. Declare alias __h_errno for h_errno. * resolv/res_query (h_errno): Remove definition. * sysdeps/unix/sysv/linux/errnos.h [!__ASSEMBLER__ && __USE_REENTRANT]: Add macro `errno' to get thread specific variable. * sysdeps/unix/alpha/sysdep.S [_LIBC_REENTRANT]: Set errno using __errno_location function. (__errno_location): New function. Thu Sep 5 21:08:44 1996 Ulrich Drepper <drepper@cygnus.com> * posix/gnu/types.h: Remove definition of key_t. * sysdeps/generic/gnu/types.h: Move it to here. * sysdeps/unix/sysv/linux/gnu/types.h: Add Linux specific definition of key_t. * sysdeps/unix/sysv/linux/waitflags.h: New file. Linux specific definitions. * sysdeps/unix/sysv/linux/schedbits.h: New file. Include clone prototypes and associated flags. Thu Sep 5 08:58:47 1996 Richard Henderson <rth@tamu.edu> * sysdeps/alpha/elf/start.S: Make _start global again. hertz. here. Wed Sep 4 16:16:13 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/mach/hurd/send.c (__send): De-ANSI-fy. * sysdeps/mach/hurd/sendto.c (sendto): Likewise.
308 lines
10 KiB
C
308 lines
10 KiB
C
/* Support macros for making weak and strong aliases for symbols,
|
||
and for using symbol sets and linker warnings with GNU ld.
|
||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||
This file is part of the GNU C Library.
|
||
|
||
The GNU C Library is free software; you can redistribute it and/or
|
||
modify it under the terms of the GNU Library General Public License as
|
||
published by the Free Software Foundation; either version 2 of the
|
||
License, or (at your option) any later version.
|
||
|
||
The GNU C Library is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
Library General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Library General Public
|
||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||
Cambridge, MA 02139, USA. */
|
||
|
||
#ifndef _LIBC_SYMBOLS_H
|
||
#define _LIBC_SYMBOLS_H
|
||
|
||
/* This file's macros are included implicitly in the compilation of every
|
||
file in the C library by -imacros.
|
||
|
||
We include config.h which is generated by configure.
|
||
It should define for us the following symbols:
|
||
|
||
* HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
|
||
* ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
|
||
* HAVE_GNU_LD if using GNU ld, with support for weak symbols in a.out,
|
||
and for symbol set and warning messages extensions in a.out and ELF.
|
||
* HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
|
||
* HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
|
||
* HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
|
||
|
||
*/
|
||
|
||
/* This is defined for the compilation of all C library code. features.h
|
||
tests this to avoid inclusion of stubs.h while compiling the library,
|
||
before stubs.h has been generated. Some library code that is shared
|
||
with other packages also tests this symbol to see if it is being
|
||
compiled as part of the C library. We must define this before including
|
||
config.h, because it makes some definitions conditional on whether libc
|
||
itself is being compiled, or just some generator program. */
|
||
#define _LIBC 1
|
||
|
||
/* Enable declarations of GNU extensions, since we are compiling them. */
|
||
#define _GNU_SOURCE 1
|
||
|
||
#include <config.h>
|
||
/*
|
||
|
||
*/
|
||
|
||
#ifndef ASSEMBLER
|
||
|
||
/* Define the macros `_' and `N_' for conveniently marking translatable
|
||
strings in the libc source code. */
|
||
|
||
#define N_(msgid) msgid
|
||
|
||
#include <libintl.h>
|
||
extern const char _libc_intl_domainname[];
|
||
|
||
#ifdef dgettext
|
||
/* This is defined as an optimizing macro, so use it. */
|
||
#define _(msgid) dgettext (_libc_intl_domainname, (msgid))
|
||
#else
|
||
/* Be sure to use only the __ name when `dgettext' is a plain function
|
||
instead of an optimizing macro. */
|
||
#define _(msgid) __dgettext (_libc_intl_domainname, (msgid))
|
||
#endif
|
||
|
||
#endif
|
||
|
||
/*
|
||
|
||
*/
|
||
/* The symbols in all the user (non-_) macros are C symbols.
|
||
HAVE_GNU_LD without HAVE_ELF implies a.out. */
|
||
|
||
#if defined (HAVE_ASM_WEAK_DIRECTIVE) || defined (HAVE_ASM_WEAKEXT_DIRECTIVE)
|
||
#define HAVE_WEAK_SYMBOLS
|
||
#endif
|
||
|
||
#ifndef __SYMBOL_PREFIX
|
||
#ifdef NO_UNDERSCORES
|
||
#define __SYMBOL_PREFIX
|
||
#else
|
||
#define __SYMBOL_PREFIX "_"
|
||
#endif
|
||
#endif
|
||
|
||
#ifndef C_SYMBOL_NAME
|
||
#ifdef NO_UNDERSCORES
|
||
#define C_SYMBOL_NAME(name) name
|
||
#else
|
||
#define C_SYMBOL_NAME(name) _##name
|
||
#endif
|
||
#endif
|
||
|
||
|
||
/* Define ALIAS as a strong alias for ORIGINAL. */
|
||
#ifdef HAVE_ASM_SET_DIRECTIVE
|
||
#define strong_alias_asm(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) \
|
||
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_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 */
|
||
|
||
#define weak_alias(o, a) weak_alias_asm (o, a)
|
||
#define weak_extern(symbol) weak_extern_asm (symbol)
|
||
|
||
#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
|
||
|
||
|
||
/* When a reference to SYMBOL is encountered, the linker will emit a
|
||
warning message MSG. */
|
||
#ifdef HAVE_GNU_LD
|
||
#ifdef HAVE_ELF
|
||
#define link_warning(symbol, msg) \
|
||
static const char __evoke_link_warning_##symbol[] \
|
||
__attribute__ ((section (".gnu.warning." #symbol))) = msg;
|
||
#else
|
||
#define link_warning(symbol, msg) \
|
||
asm(".stabs \"" msg "\",30,0,0,0\n" \
|
||
".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
|
||
#endif
|
||
#else
|
||
/* We will never be heard; they will all die horribly. */
|
||
#define link_warning(symbol, msg)
|
||
#endif
|
||
|
||
/* A canned warning for sysdeps/stub functions. */
|
||
#define stub_warning(name) \
|
||
link_warning (name, \
|
||
"warning: " #name " is not implemented and will always fail")
|
||
|
||
/*
|
||
|
||
*/
|
||
|
||
#ifdef HAVE_GNU_LD
|
||
|
||
/* Symbol set support macros. */
|
||
|
||
#ifdef HAVE_ELF
|
||
|
||
/* Make SYMBOL, which is in the text segment, an element of SET. */
|
||
#define text_set_element(set, symbol) _elf_set_element(set, symbol)
|
||
/* Make SYMBOL, which is in the data segment, an element of SET. */
|
||
#define data_set_element(set, symbol) _elf_set_element(set, symbol)
|
||
/* Make SYMBOL, which is in the bss segment, an element of SET. */
|
||
#define bss_set_element(set, symbol) _elf_set_element(set, symbol)
|
||
|
||
/* These are all done the same way in ELF.
|
||
There is a new section created for each set. */
|
||
#ifdef PIC
|
||
/* When building a shared library, make the set section writable,
|
||
because it will need to be relocated at run time anyway. */
|
||
#define _elf_set_element(set, symbol) \
|
||
static const void *__elf_set_##set##_element_##symbol##__ \
|
||
__attribute__ ((unused, section (#set))) = &(symbol)
|
||
#else
|
||
#define _elf_set_element(set, symbol) \
|
||
static const void *const __elf_set_##set##_element_##symbol##__ \
|
||
__attribute__ ((unused, section (#set))) = &(symbol)
|
||
#endif
|
||
|
||
/* Define SET as a symbol set. This may be required (it is in a.out) to
|
||
be able to use the set's contents. */
|
||
#define symbol_set_define(set) symbol_set_declare(set)
|
||
|
||
/* Declare SET for use in this module, if defined in another module. */
|
||
#define symbol_set_declare(set) \
|
||
extern void *const __start_##set __attribute__ ((__weak__)); \
|
||
extern void *const __stop_##set __attribute__ ((__weak__)); \
|
||
weak_extern (__start_##set) weak_extern (__stop_##set)
|
||
|
||
/* Return a pointer (void *const *) to the first element of SET. */
|
||
#define symbol_set_first_element(set) (&__start_##set)
|
||
|
||
/* Return true iff PTR (a void *const *) has been incremented
|
||
past the last element in SET. */
|
||
#define symbol_set_end_p(set, ptr) ((ptr) >= &__stop_##set)
|
||
|
||
#else /* Not ELF: a.out. */
|
||
|
||
#define text_set_element(set, symbol) \
|
||
asm(".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
|
||
#define data_set_element(set, symbol) \
|
||
asm(".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
|
||
#define bss_set_element(set, symbol) ?error Must use initialized data.
|
||
#define symbol_set_define(set) void *const (set)[1];
|
||
#define symbol_set_declare(set) extern void *const (set)[1];
|
||
|
||
#define symbol_set_first_element(set) &(set)[1]
|
||
#define symbol_set_end_p(set, ptr) (*(ptr) == 0)
|
||
|
||
#endif /* ELF. */
|
||
#endif /* Have GNU ld. */
|
||
|
||
#endif /* libc-symbols.h */
|