[git commit] errno and *_init cleanup
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Fri Jun 15 12:00:32 UTC 2012
commit: http://git.uclibc.org/uClibc/commit/?id=87936cd0130414cccc8a7427498dd5491ec2664f
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master
Define a common view of __errno_location, __h_errno_location in common header
and use that everywhere, __uClibc_main.c is no special.
The rule adopted:
for enabled threads we make in libc the __GI_x() variants strong, x() weak
and (should) provide another strong x() in libpthread.
If threads are disabled, even the __GI_x() variants are weak.
_stdio_init,_stdio_term,_locale_init: make all hidden weak in common header
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
include/netdb.h | 5 +++++
libc/misc/internals/__errno_location.c | 9 +--------
libc/misc/internals/__h_errno_location.c | 2 +-
libc/misc/internals/__uClibc_main.c | 18 ++++++------------
libc/misc/locale/locale.c | 1 -
libc/stdio/_stdio.c | 2 +-
libc/sysdeps/linux/common/bits/errno.h | 5 +++++
libc/sysdeps/linux/common/bits/uClibc_locale.h | 2 +-
libc/sysdeps/linux/common/bits/uClibc_stdio.h | 4 ++--
9 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/include/netdb.h b/include/netdb.h
index 10669b9..0bf79c0 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -59,6 +59,11 @@ __BEGIN_DECLS
/* Function to get address of global `h_errno' variable. */
extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
+#ifdef _LIBC
+# ifndef __UCLIBC_HAS_THREADS__
+extern int weak_const_function *__h_errno_location(void);
+# endif
+#endif
libc_hidden_proto(__h_errno_location)
/* Macros for accessing h_errno from inside libc. */
diff --git a/libc/misc/internals/__errno_location.c b/libc/misc/internals/__errno_location.c
index aec7641..3409500 100644
--- a/libc/misc/internals/__errno_location.c
+++ b/libc/misc/internals/__errno_location.c
@@ -6,15 +6,8 @@
#include "internal_errno.h"
-/* psm: moved to bits/errno.h: */
-int *
-#ifndef __UCLIBC_HAS_THREADS__
-weak_const_function
-#endif
-__errno_location (void)
+int *__errno_location(void)
{
return &errno;
}
-#ifdef IS_IN_libc /* not really need, only to keep in sync w/ libc_hidden_proto */
libc_hidden_weak(__errno_location)
-#endif
diff --git a/libc/misc/internals/__h_errno_location.c b/libc/misc/internals/__h_errno_location.c
index 213d398..1136776 100644
--- a/libc/misc/internals/__h_errno_location.c
+++ b/libc/misc/internals/__h_errno_location.c
@@ -6,7 +6,7 @@
#include "internal_errno.h"
-int * weak_const_function __h_errno_location (void)
+int *__h_errno_location(void)
{
return &h_errno;
}
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index bda1bb8..9f7258d 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -15,9 +15,6 @@
*/
#include <features.h>
-#ifndef __UCLIBC_HAS_THREADS_NATIVE__
-#define _ERRNO_H
-#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -25,13 +22,13 @@
#include <link.h>
#include <bits/uClibc_page.h>
#include <paths.h>
-#include <unistd.h>
-#include <asm/errno.h>
+#include <errno.h>
+#include <netdb.h>
+#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <errno.h>
#include <pthread-functions.h>
#include <not-cancel.h>
#include <atomic.h>
@@ -39,6 +36,9 @@
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
#endif
+#ifdef __UCLIBC_HAS_LOCALE__
+#include <locale.h>
+#endif
#ifndef SHARED
void *__libc_stack_end = NULL;
@@ -116,12 +116,6 @@ static __always_inline int not_null_ptr(const void *p)
/*
* Prototypes.
*/
-extern int *weak_const_function __errno_location(void);
-extern int *weak_const_function __h_errno_location(void);
-extern void weak_function _stdio_init(void) attribute_hidden;
-#ifdef __UCLIBC_HAS_LOCALE__
-extern void weak_function _locale_init(void) attribute_hidden;
-#endif
#ifdef __UCLIBC_HAS_THREADS__
#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
extern void weak_function __pthread_initialize_minimal(void);
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 254eb70..2c99f06 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -906,7 +906,6 @@ void attribute_hidden _locale_init_l(__locale_t base)
_locale_set_l((unsigned char*) C_LOCALE_SELECTOR, base);
}
-void _locale_init(void) attribute_hidden;
void _locale_init(void)
{
/* TODO: mmap the locale file */
diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c
index f9cbd46..3979972 100644
--- a/libc/stdio/_stdio.c
+++ b/libc/stdio/_stdio.c
@@ -252,7 +252,7 @@ void _stdio_term(void)
}
#if defined __STDIO_BUFFERS || !defined __UCLIBC__
-void attribute_hidden _stdio_init(void)
+void _stdio_init(void)
{
#ifdef __STDIO_BUFFERS
int old_errno = errno;
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index 0bf6354..459cc70 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -43,6 +43,11 @@
# ifndef __ASSEMBLER__
/* Function to get address of global `errno' variable. */
extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+# ifdef _LIBC
+# ifndef __UCLIBC_HAS_THREADS__
+extern int weak_const_function *__errno_location(void);
+# endif
+# endif
libc_hidden_proto(__errno_location)
# ifdef __UCLIBC_HAS_THREADS__
diff --git a/libc/sysdeps/linux/common/bits/uClibc_locale.h b/libc/sysdeps/linux/common/bits/uClibc_locale.h
index 05d9b4d..6273fa3 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_locale.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_locale.h
@@ -93,7 +93,7 @@ typedef struct __uclibc_locale_struct *__locale_t;
#ifdef _LIBC
/* extern void _locale_set(const unsigned char *p); */
-/* extern void _locale_init(void); */
+extern void weak_function _locale_init(void) attribute_hidden;
#include <stddef.h>
#include <stdint.h>
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index 06000a8..095220a 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -327,8 +327,8 @@ struct __STDIO_FILE_STRUCT {
**********************************************************************/
#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
-extern void _stdio_init(void) attribute_hidden;
-extern void _stdio_term(void) attribute_hidden;
+extern void weak_function _stdio_init(void) attribute_hidden;
+extern void weak_function _stdio_term(void) attribute_hidden;
#ifdef __STDIO_HAS_OPENLIST
More information about the uClibc-cvs
mailing list