summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-06-12 21:45:10 +0000
committerEric Andersen <andersen@codepoet.org>2001-06-12 21:45:10 +0000
commit92773db48eb6be7bc3ef12f44e4b163a7f5e0af3 (patch)
tree7a5097716ad65c0899d917a25379131e26a7e47b /libc
parent23f586ed1edb81cea7c976eb1f2354ab24294908 (diff)
Cleanup the toploevel makefile handing of shared libs. Add weak_alias
define, and set things up so nasty old coff toolchains can now compile things and should actually work again. -Erik
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/internals/__uClibc_main.c15
-rw-r--r--libc/stdlib/random.c3
-rw-r--r--libc/stdlib/unix_grantpt.c4
-rw-r--r--libc/string/string.c6
-rw-r--r--libc/string/strtok_r.c2
-rw-r--r--libc/sysdeps/linux/m68k/Makefile2
-rw-r--r--libc/sysdeps/linux/m68k/README.m68k10
-rw-r--r--libc/sysdeps/linux/m68k/bits/vfork.h31
-rw-r--r--libc/sysdeps/linux/m68k/crt0.S5
-rw-r--r--libc/sysdeps/linux/m68k/vfork.c25
10 files changed, 51 insertions, 52 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 26c028015..dc8c62f97 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -36,6 +36,13 @@ void __uClibc_empty_func(void)
{
}
+#ifdef HAVE_ELF
+weak_alias(__environ, environ);
+weak_alias(__uClibc_empty_func, __init_stdio);
+weak_alias(__uClibc_empty_func, __stdio_close_all);
+#endif
+
+
extern void __init_stdio(void);
extern void __stdio_close_all(void);
@@ -80,7 +87,9 @@ void __uClibc_main(int argc, char **argv, char **envp)
char **__environ = 0;
-__asm__(".weak environ;environ = __environ");
-__asm__(".weak __init_stdio; __init_stdio = __uClibc_empty_func");
-__asm__(".weak __stdio_close_all; __stdio_close_all = __uClibc_empty_func");
+#ifndef HAVE_ELF
+weak_alias(__environ, environ);
+weak_alias(__uClibc_empty_func, __init_stdio);
+weak_alias(__uClibc_empty_func, __stdio_close_all);
+#endif
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index bef89c01f..cbd4206ae 100644
--- a/libc/stdlib/random.c
+++ b/libc/stdlib/random.c
@@ -34,5 +34,4 @@ void srandom(unsigned int seed)
seed3 = seed % 31656 + 1;
}
-__asm__(".weak srand; srand = srandom");
-
+weak_alias(srandom, srand);
diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c
index eb6ce0b35..c8d70ad64 100644
--- a/libc/stdlib/unix_grantpt.c
+++ b/libc/stdlib/unix_grantpt.c
@@ -140,7 +140,11 @@ grantpt (int fd)
/* We have to use the helper program. */
helper:
+#ifdef __UCLIBC_HAS_MMU__
pid = fork ();
+#else
+ pid = vfork ();
+#endif
if (pid == -1)
goto cleanup;
else if (pid == 0)
diff --git a/libc/string/string.c b/libc/string/string.c
index 0e2df303b..bb524eeac 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -77,7 +77,7 @@ int strcmp(const char *s1, const char *s2)
}
#ifndef __UCLIBC_HAS_LOCALE__
-__asm__(".weak strcoll; strcoll = strcmp");
+weak_alias(strcmp, strcoll);
#endif /* __UCLIBC_HAS_LOCALE__ */
#endif
@@ -191,7 +191,7 @@ char *strchr(const char *str, int c)
return 0;
}
-__asm__(".weak index; index = strchr");
+weak_alias(strchr, index);
#endif
/********************** Function strrchr ************************************/
@@ -214,7 +214,7 @@ char *strrchr(const char *str, int c)
return prev;
}
-__asm__(".weak rindex; rindex = strrchr");
+weak_alias(strrchr, rindex);
#endif
/********************** Function strdup ************************************/
diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c
index 37b313455..e6c24218a 100644
--- a/libc/string/strtok_r.c
+++ b/libc/string/strtok_r.c
@@ -52,4 +52,4 @@ char *__strtok_r(char *s, const char *delim, char **save_ptr)
return token;
}
-__asm__(".weak strtok_r; strtok_r = __strtok_r");
+weak_alias(__strtok_r, strtok_r);
diff --git a/libc/sysdeps/linux/m68k/Makefile b/libc/sysdeps/linux/m68k/Makefile
index e4346e4c8..5f2b73581 100644
--- a/libc/sysdeps/linux/m68k/Makefile
+++ b/libc/sysdeps/linux/m68k/Makefile
@@ -32,7 +32,7 @@ CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
SSRC=setjmp.S # longjmp.S _start.S clone.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
-CSRC=ptrace.c #errno.c
+CSRC=ptrace.c vfork.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(SOBJS) $(MOBJ) $(COBJS)
diff --git a/libc/sysdeps/linux/m68k/README.m68k b/libc/sysdeps/linux/m68k/README.m68k
index 697413852..f774e6f7a 100644
--- a/libc/sysdeps/linux/m68k/README.m68k
+++ b/libc/sysdeps/linux/m68k/README.m68k
@@ -40,16 +40,6 @@ Installation:
run:
make install
-Usage:
- Any program you compile should have this added to CFLAGS:
-
- -D__VFORK_MACRO__ -Dconst= -D__const=
-
- (You need the equal sign so that const and __const are defined
- as NULL instead of as '1') The 'const' keyword is broken for
- m68k-pic-coff-gcc 2.7.2.3-pic-060999. There _was_ a fix
- floating around, but apparently it didn't work.
-
Problems:
I _may_ be able to help if you run into problems. Create a
diff --git a/libc/sysdeps/linux/m68k/bits/vfork.h b/libc/sysdeps/linux/m68k/bits/vfork.h
deleted file mode 100644
index ceb9af8a6..000000000
--- a/libc/sysdeps/linux/m68k/bits/vfork.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* orginally from include/unistd.h, written by ndf@linux.mit.edu> */
-
-#ifndef _M68K_VFORK_H
-#define _M68K_VFORK_H 1
-
-extern int _clone __P ((int (*fn)(void *arg), void *child_stack, int flags, void *arg));
-
-#ifndef __NR_vfork
-#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
-#endif
-
-#define vfork() ({ \
-unsigned long __res; \
-__asm__ __volatile__ ("movel %1,%%d0;" \
- "trap #0;" \
- "movel %%d0,%0" \
- : "=d" (__res) \
- : "0" (__NR_vfork) \
- : "%d0"); \
-if (__res >= (unsigned long)-4096) { \
- errno = -__res; \
- __res = (pid_t)-1; \
-} \
-(pid_t)__res; \
-})
-
-
-#define clone clone_not_available_use__clone
-
-#endif /* _M68K_VFORK_H */
-
diff --git a/libc/sysdeps/linux/m68k/crt0.S b/libc/sysdeps/linux/m68k/crt0.S
index 182e8baea..06b4b54f5 100644
--- a/libc/sysdeps/linux/m68k/crt0.S
+++ b/libc/sysdeps/linux/m68k/crt0.S
@@ -50,8 +50,11 @@ __exit:
*/
empty_func:
rts
+#if defined HAVE_ELF
.weak atexit
-atexit = empty_func
+#else
+ .set atexit,empty_func
+#endif
/*
* a little bit of stuff to support C++
diff --git a/libc/sysdeps/linux/m68k/vfork.c b/libc/sysdeps/linux/m68k/vfork.c
new file mode 100644
index 000000000..9edcb650d
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/vfork.c
@@ -0,0 +1,25 @@
+/* orginally from include/unistd.h, written by ndf@linux.mit.edu> */
+#include <unistd.h>
+#include <sys/types.h>
+#include <asm/unistd.h>
+
+#ifndef __NR_vfork
+#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
+#endif
+
+pid_t vfork(void)
+{
+ pid_t __res;
+ __asm__ __volatile__ ("movel %1,%%d0;"
+ "trap #0;"
+ "movel %%d0,%0"
+ : "=d" (__res)
+ : "0" (__NR_vfork)
+ : "%d0");
+ if (__res >= (unsigned long)-4096) {
+ errno = -__res;
+ __res = (pid_t)-1;
+ }
+ return(__res);
+}
+