summaryrefslogtreecommitdiff
path: root/libc/misc/internals
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/internals')
-rw-r--r--libc/misc/internals/.cvsignore1
-rw-r--r--libc/misc/internals/Makefile2
-rw-r--r--libc/misc/internals/__errno_location.c8
-rw-r--r--libc/misc/internals/__uClibc_main.c31
-rw-r--r--libc/misc/internals/errno.c29
5 files changed, 54 insertions, 17 deletions
diff --git a/libc/misc/internals/.cvsignore b/libc/misc/internals/.cvsignore
new file mode 100644
index 000000000..10e486705
--- /dev/null
+++ b/libc/misc/internals/.cvsignore
@@ -0,0 +1 @@
+interp.c
diff --git a/libc/misc/internals/Makefile b/libc/misc/internals/Makefile
index 29ffdec7b..c81e02078 100644
--- a/libc/misc/internals/Makefile
+++ b/libc/misc/internals/Makefile
@@ -24,7 +24,7 @@
TOPDIR=../../../
include $(TOPDIR)Rules.mak
-CSRC=ultostr.c ltostr.c __uClibc_main.c tempname.c
+CSRC=ultostr.c ltostr.c __uClibc_main.c tempname.c errno.c __errno_location.c
ifeq ($(HAS_FLOATING_POINT),true)
CSRC += dtostr.c zoicheck.c
endif
diff --git a/libc/misc/internals/__errno_location.c b/libc/misc/internals/__errno_location.c
new file mode 100644
index 000000000..10b97753f
--- /dev/null
+++ b/libc/misc/internals/__errno_location.c
@@ -0,0 +1,8 @@
+#include <errno.h>
+#undef errno
+
+int * weak_const_function __errno_location (void)
+{
+ return &errno;
+}
+
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 299e1abdf..fd4e9552b 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -10,9 +10,13 @@
* avoided in the static library case.
*/
+#define _ERRNO_H
#include <stdlib.h>
#include <unistd.h>
-#include <errno.h>
+//#include <errno.h>
+#undef errno
+
+#define __set_errno(val) (*__errno_location ()) = (val)
/*
* Prototypes.
@@ -29,13 +33,21 @@ void __uClibc_main(int argc, char **argv, char **envp)
weak_alias(__environ, environ);
extern void weak_function __init_stdio(void);
extern void weak_function __stdio_flush_buffers(void);
-extern void weak_function __pthread_initialize_minimal (void);
+extern int *weak_function __errno_location (void);
#else
extern void __init_stdio(void);
extern void __stdio_flush_buffers(void);
-extern void __pthread_initialize_minimal (void);
+extern int *__errno_location (void);
#endif
+/*
+ * Declare the __environ global variable and create a weak alias environ.
+ * Note: Apparently we must initialize __environ for the weak environ
+ * symbol to be included.
+ */
+
+char **__environ = 0;
+
/*
* Now for our main routine.
@@ -48,11 +60,6 @@ void __uClibc_main(int argc, char **argv, char **envp)
*/
__environ = envp;
- /* Initialize the thread library at least a bit so at least
- * errno will be properly setup */
- if (__pthread_initialize_minimal)
- __pthread_initialize_minimal ();
-
#if 0
/* Some security at this point. Prevent starting a SUID binary
* where the standard file descriptors are not opened. We have
@@ -81,14 +88,6 @@ void __uClibc_main(int argc, char **argv, char **envp)
exit(main(argc, argv, envp));
}
-/*
- * Declare the __environ global variable and create a weak alias environ.
- * Note: Apparently we must initialize __environ for the weak environ
- * symbol to be included.
- */
-
-char **__environ = 0;
-
#ifndef HAVE_ELF
/*
* Define an empty function and use it as a weak alias for the stdio
diff --git a/libc/misc/internals/errno.c b/libc/misc/internals/errno.c
new file mode 100644
index 000000000..06978c430
--- /dev/null
+++ b/libc/misc/internals/errno.c
@@ -0,0 +1,29 @@
+#if 0
+#include <features.h>
+/* Unforunately, this produces noisy warnings... */
+int errno __attribute__ ((section (".bss")));
+int h_errno __attribute__ ((section (".bss")));
+weak_alias(errno, _errno);
+weak_alias(h_errno, _h_errno);
+#else
+__asm__("
+.weak _errno;
+_errno = errno
+.weak _h_errno;
+_h_errno = h_errno
+
+.bss
+.globl errno
+.type errno,%object
+.size errno,4
+errno:
+ .space 4
+
+.bss
+.globl h_errno
+.type h_errno,%object
+.size h_errno,4
+h_errno:
+ .space 4
+");
+#endif