diff options
author | Khem Raj <raj.khem@gmail.com> | 2010-05-05 22:50:19 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2010-05-09 22:53:25 -0700 |
commit | e3dec33ba03ef7080a39444388a01e59135bb3aa (patch) | |
tree | 9693449a78a556a91ddba349116d9c988399071a | |
parent | d2ab6ee38dd6ef107bac77f485ab1bb35b177e6c (diff) | |
download | uClibc-alpine-e3dec33ba03ef7080a39444388a01e59135bb3aa.tar.bz2 uClibc-alpine-e3dec33ba03ef7080a39444388a01e59135bb3aa.tar.xz |
powerpc: Add TLS and NPTL support
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
42 files changed, 957 insertions, 396 deletions
diff --git a/Makefile.in b/Makefile.in index 5474d37bc..126670970 100644 --- a/Makefile.in +++ b/Makefile.in @@ -214,8 +214,6 @@ HEADERS_RM- := \ bits/utmpx.h \ bits/uClibc_errno.h \ bits/uClibc_uintmaxtostr.h \ - atomic.h \ - bits/atomic.h \ bits/sigcontextinfo.h \ bits/stackinfo.h \ tls.h \ @@ -257,6 +255,9 @@ HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += \ sys/sysctl.h \ sys/sysinfo.h \ sys/vfs.h +HEADERS_RM-$(UCLIBC_HAS_THREADS_NATIVE) += \ + atomic.h \ + bits/atomic.h HEADERS_RM-$(HAVE_SHARED) += dlfcn.h bits/dlfcn.h HEADERS_RM-$(PTHREADS_DEBUG_SUPPORT) += thread_db.h HEADERS_RM-$(UCLIBC_HAS_BSD_ERR) += err.h diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h index 4675dd7f4..69b5dd75a 100644 --- a/ldso/include/ldso.h +++ b/ldso/include/ldso.h @@ -78,6 +78,10 @@ extern void _dl_add_to_slotinfo (struct link_map *l); extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void); #endif +#ifdef USE_TLS +void _dl_add_to_slotinfo (struct link_map *l); +void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void); +#endif #ifdef __SUPPORT_LD_DEBUG__ extern char *_dl_debug; extern char *_dl_debug_symbols; diff --git a/ldso/ldso/powerpc/dl-sysdep.h b/ldso/ldso/powerpc/dl-sysdep.h index f33214cbe..a665d4e75 100644 --- a/ldso/ldso/powerpc/dl-sysdep.h +++ b/ldso/ldso/powerpc/dl-sysdep.h @@ -77,6 +77,8 @@ void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt); #define elf_machine_type_class(type) \ ((((type) == R_PPC_JMP_SLOT \ || (type) == R_PPC_REL24 \ + || ((type) >= R_PPC_DTPMOD32 /* contiguous TLS */ \ + && (type) <= R_PPC_DTPREL32) \ || (type) == R_PPC_ADDR24) * ELF_RTYPE_CLASS_PLT) \ | (((type) == R_PPC_COPY) * ELF_RTYPE_CLASS_COPY)) diff --git a/ldso/ldso/powerpc/elfinterp.c b/ldso/ldso/powerpc/elfinterp.c index 0dcb175bf..855c040d3 100644 --- a/ldso/ldso/powerpc/elfinterp.c +++ b/ldso/ldso/powerpc/elfinterp.c @@ -30,6 +30,8 @@ */ #include "ldso.h" +#define TLS_DTV_OFFSET 0x8000 +#define TLS_TP_OFFSET 0x7000 extern int _dl_linux_resolve(void); @@ -157,15 +159,15 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) *reloc_addr = OPCODE_BA (finaladdr); } else { /* Warning: we don't handle double-sized PLT entries */ - Elf32_Word *plt, *data_words, index, offset; + Elf32_Word *plt, *data_words, idx, offset; plt = (Elf32_Word *)tpnt->dynamic_info[DT_PLTGOT]; offset = reloc_addr - plt; - index = (offset - PLT_INITIAL_ENTRY_WORDS)/2; + idx = (offset - PLT_INITIAL_ENTRY_WORDS)/2; data_words = (Elf32_Word *)tpnt->data_words; reloc_addr += 1; - data_words[index] = finaladdr; + data_words[idx] = finaladdr; PPC_SYNC; *reloc_addr = OPCODE_B ((PLT_LONGBRANCH_ENTRY_WORDS - (offset+1)) * 4); } @@ -185,28 +187,36 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, { int reloc_type; int symtab_index; - char *symname; + ElfW(Sym) *sym; Elf32_Addr *reloc_addr; Elf32_Addr finaladdr; - + struct elf_resolve *tls_tpnt = NULL; unsigned long symbol_addr; + char *symname; #if defined (__SUPPORT_LD_DEBUG__) unsigned long old_val; #endif - reloc_addr = (Elf32_Addr *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset); - reloc_type = ELF32_R_TYPE(rpnt->r_info); + symbol_addr = tpnt->loadaddr; /* For R_PPC_RELATIVE */ + reloc_addr = (Elf32_Addr *)(intptr_t) (symbol_addr + (unsigned long) rpnt->r_offset); + reloc_type = ELF32_R_TYPE(rpnt->r_info); symtab_index = ELF32_R_SYM(rpnt->r_info); - symname = strtab + symtab[symtab_index].st_name; + sym = &symtab[symtab_index]; + symname = strtab + sym->st_name; if (symtab_index) { symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt, - elf_machine_type_class(reloc_type), NULL); + elf_machine_type_class(reloc_type), &tls_tpnt); /* We want to allow undefined references to weak symbols - this might * have been intentional. We should not be linking local symbols * here, so all bases should be covered. */ - if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) + if (unlikely(!symbol_addr + && (ELF32_ST_TYPE(sym->st_info) != STT_TLS + && ELF32_ST_BIND(sym->st_info) != STB_WEAK))) return 1; + } else { + symbol_addr = sym->st_value; + tls_tpnt = tpnt; } #if defined (__SUPPORT_LD_DEBUG__) old_val = *reloc_addr; @@ -232,15 +242,15 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, *reloc_addr = OPCODE_BA (finaladdr); } else { /* Warning: we don't handle double-sized PLT entries */ - Elf32_Word *plt, *data_words, index, offset; + Elf32_Word *plt, *data_words, idx, offset; plt = (Elf32_Word *)tpnt->dynamic_info[DT_PLTGOT]; offset = reloc_addr - plt; - index = (offset - PLT_INITIAL_ENTRY_WORDS)/2; + idx = (offset - PLT_INITIAL_ENTRY_WORDS)/2; data_words = (Elf32_Word *)tpnt->data_words; - data_words[index] = finaladdr; - reloc_addr[0] = OPCODE_LI(11,index*4); + data_words[idx] = finaladdr; + reloc_addr[0] = OPCODE_LI(11,idx*4); reloc_addr[1] = OPCODE_B((PLT_LONGBRANCH_ENTRY_WORDS - (offset+1)) * 4); /* instructions were modified */ @@ -255,10 +265,10 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, #if defined (__SUPPORT_LD_DEBUG__) if (_dl_debug_move) _dl_dprintf(_dl_debug_file,"\n%s move %x bytes from %x to %x", - symname, symtab[symtab_index].st_size, + symname, sym->st_size, symbol_addr, reloc_addr); #endif - _dl_memcpy((char *) reloc_addr, (char *) finaladdr, symtab[symtab_index].st_size); + _dl_memcpy((char *) reloc_addr, (char *) finaladdr, sym->st_size); goto out_nocode; /* No code code modified */ case R_PPC_ADDR16_HA: finaladdr += 0x8000; /* fall through. */ @@ -267,6 +277,19 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, case R_PPC_ADDR16_LO: *(short *)reloc_addr = finaladdr; break; +#if USE_TLS + case R_PPC_DTPMOD32: + *reloc_addr = tls_tpnt->l_tls_modid; + break; + case R_PPC_DTPREL32: + /* During relocation all TLS symbols are defined and used. + Therefore the offset is already correct. */ + *reloc_addr = finaladdr - TLS_DTV_OFFSET; + break; + case R_PPC_TPREL32: + *reloc_addr = tls_tpnt->l_tls_offset + finaladdr - TLS_TP_OFFSET; + break; +#endif case R_PPC_REL24: #if 0 { diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index a6fa6d091..6f833cec4 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -98,6 +98,9 @@ ifeq ($(TARGET_ARCH),i386) CSRC := $(filter-out vfork.c,$(CSRC)) endif +# provided via pthreads builddir +CSRC := $(filter-out $(libc_a_CSRC) $(libc_a_SSRC:.S=.c),$(CSRC)) + # fails for some reason ifneq ($(strip $(ARCH_OBJS)),) CSRC := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)) $(ARCH_OBJ_FILTEROUT),$(CSRC)) diff --git a/libc/sysdeps/linux/powerpc/Makefile.arch b/libc/sysdeps/linux/powerpc/Makefile.arch index 8c7fc2de6..cdb35ba43 100644 --- a/libc/sysdeps/linux/powerpc/Makefile.arch +++ b/libc/sysdeps/linux/powerpc/Makefile.arch @@ -13,7 +13,10 @@ endif SSRC := \ __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \ - clone.S __uClibc_syscall.S syscall.S vfork.S + __uClibc_syscall.S syscall.S +ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y) +SSRC += clone.S vfork.S +endif ifeq ($(CONFIG_E500),y) ARCH_HEADERS := fenv.h diff --git a/libc/sysdeps/linux/powerpc/bits/atomic.h b/libc/sysdeps/linux/powerpc/bits/atomic.h index 1088d2f3c..3dbbb3a09 100644 --- a/libc/sysdeps/linux/powerpc/bits/atomic.h +++ b/libc/sysdeps/linux/powerpc/bits/atomic.h @@ -335,12 +335,28 @@ # define __arch_atomic_decrement_if_positive_64(mem) \ ({ abort (); (*mem)--; }) +#ifdef _ARCH_PWR4 +/* + * Newer powerpc64 processors support the new "light weight" sync (lwsync) + * So if the build is using -mcpu=[power4,power5,power5+,970] we can + * safely use lwsync. + */ +# define atomic_read_barrier() __asm ("lwsync" ::: "memory") +/* + * "light weight" sync can also be used for the release barrier. + */ +# ifndef UP +# define __ARCH_REL_INSTR "lwsync" +# endif +#else + /* * Older powerpc32 processors don't support the new "light weight" * sync (lwsync). So the only safe option is to use normal sync * for all powerpc32 applications. */ # define atomic_read_barrier() __asm__ ("sync" ::: "memory") +#endif #endif @@ -387,6 +403,13 @@ typedef uintmax_t uatomic_max_t; # endif #endif +#ifndef MUTEX_HINT_ACQ +# define MUTEX_HINT_ACQ +#endif +#ifndef MUTEX_HINT_REL +# define MUTEX_HINT_REL +#endif + #define atomic_full_barrier() __asm__ ("sync" ::: "memory") #define atomic_write_barrier() __asm__ ("eieio" ::: "memory") diff --git a/libc/sysdeps/linux/powerpc/bits/mathdef.h b/libc/sysdeps/linux/powerpc/bits/mathdef.h index d6d35dda0..c64b8a395 100644 --- a/libc/sysdeps/linux/powerpc/bits/mathdef.h +++ b/libc/sysdeps/linux/powerpc/bits/mathdef.h @@ -46,12 +46,9 @@ typedef double double_t; /* `double' expressions are evaluated as #endif /* ISO C99 */ #ifndef __NO_LONG_DOUBLE_MATH -#include <bits/wordsize.h> /* Signal that we do not really have a `long double'. The disables the declaration of all the `long double' function variants. */ -# if __WORDSIZE == 32 +# if !defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ # define __NO_LONG_DOUBLE_MATH 1 -# elif !defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ -# define __NO_LONG_DOUBLE_MATH 1 -# endif /* __WORDSIZE == 32 */ +# endif #endif /* __NO_LONG_DOUBLE_MATH */ diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h index f689c60ae..1c7b929b2 100644 --- a/libc/sysdeps/linux/powerpc/bits/syscalls.h +++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h @@ -116,7 +116,7 @@ register long int r10 __asm__ ("r10"); \ register long int r11 __asm__ ("r11"); \ register long int r12 __asm__ ("r12"); \ - LOADARGS_##nr (funcptr, args); \ + LOAD_ARGS_##nr (funcptr, args); \ __asm__ __volatile__ \ ("mtctr %0\n\t" \ "bctrl\n\t" \ @@ -153,7 +153,7 @@ register long int r10 __asm__ ("r10"); \ register long int r11 __asm__ ("r11"); \ register long int r12 __asm__ ("r12"); \ - LOADARGS_##nr(name, args); \ + LOAD_ARGS_##nr(name, args); \ __asm__ __volatile__ \ ("sc \n\t" \ "mfcr %0" \ @@ -178,41 +178,41 @@ extern void __illegally_sized_syscall_arg4(void); extern void __illegally_sized_syscall_arg5(void); extern void __illegally_sized_syscall_arg6(void); -# define LOADARGS_0(name, dummy) \ +# define LOAD_ARGS_0(name, dummy) \ r0 = name -# define LOADARGS_1(name, __arg1) \ +# define LOAD_ARGS_1(name, __arg1) \ long int arg1 = (long int) (__arg1); \ - LOADARGS_0(name, 0); \ + LOAD_ARGS_0(name, 0); \ if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \ __illegally_sized_syscall_arg1 (); \ r3 = arg1 -# define LOADARGS_2(name, __arg1, __arg2) \ +# define LOAD_ARGS_2(name, __arg1, __arg2) \ long int arg2 = (long int) (__arg2); \ - LOADARGS_1(name, __arg1); \ + LOAD_ARGS_1(name, __arg1); \ if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \ __illegally_sized_syscall_arg2 (); \ r4 = arg2 -# define LOADARGS_3(name, __arg1, __arg2, __arg3) \ +# define LOAD_ARGS_3(name, __arg1, __arg2, __arg3) \ long int arg3 = (long int) (__arg3); \ - LOADARGS_2(name, __arg1, __arg2); \ + LOAD_ARGS_2(name, __arg1, __arg2); \ if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \ __illegally_sized_syscall_arg3 (); \ r5 = arg3 -# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \ +# define LOAD_ARGS_4(name, __arg1, __arg2, __arg3, __arg4) \ long int arg4 = (long int) (__arg4); \ - LOADARGS_3(name, __arg1, __arg2, __arg3); \ + LOAD_ARGS_3(name, __arg1, __arg2, __arg3); \ if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \ __illegally_sized_syscall_arg4 (); \ r6 = arg4 -# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \ +# define LOAD_ARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \ long int arg5 = (long int) (__arg5); \ - LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \ + LOAD_ARGS_4(name, __arg1, __arg2, __arg3, __arg4); \ if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \ __illegally_sized_syscall_arg5 (); \ r7 = arg5 -# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \ +# define LOAD_ARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \ long int arg6 = (long int) (__arg6); \ - LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \ + LOAD_ARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \ if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \ __illegally_sized_syscall_arg6 (); \ r8 = arg6 diff --git a/libc/sysdeps/linux/powerpc/bits/sysdep.h b/libc/sysdeps/linux/powerpc/bits/sysdep.h deleted file mode 100644 index 478ebdd7a..000000000 --- a/libc/sysdeps/linux/powerpc/bits/sysdep.h +++ /dev/null @@ -1,301 +0,0 @@ -/* Copyright (C) 1992,1997-2003,2004,2005,2006 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _LINUX_POWERPC_SYSDEP_H -#define _LINUX_POWERPC_SYSDEP_H 1 - -#include <sysdeps/unix/powerpc/sysdep.h> -#include <tls.h> - -/* Some systen calls got renamed over time, but retained the same semantics. - Handle them here so they can be catched by both C and assembler stubs in - glibc. */ - -#ifdef __NR_pread64 -# ifdef __NR_pread -# error "__NR_pread and __NR_pread64 both defined???" -# endif -# define __NR_pread __NR_pread64 -#endif - -#ifdef __NR_pwrite64 -# ifdef __NR_pwrite -# error "__NR_pwrite and __NR_pwrite64 both defined???" -# endif -# define __NR_pwrite __NR_pwrite64 -#endif - -/* For Linux we can use the system call table in the header file - /usr/include/asm/unistd.h - of the kernel. But these symbols do not follow the SYS_* syntax - so we have to redefine the `SYS_ify' macro here. */ -#undef SYS_ify -#ifdef __STDC__ -# define SYS_ify(syscall_name) __NR_##syscall_name -#else -# define SYS_ify(syscall_name) __NR_/**/syscall_name -#endif - -#ifndef __ASSEMBLER__ - -# include <errno.h> - -# ifdef SHARED -# define INLINE_VSYSCALL(name, nr, args...) \ - ({ \ - __label__ out; \ - __label__ iserr; \ - INTERNAL_SYSCALL_DECL (sc_err); \ - long int sc_ret; \ - \ - if (__vdso_##name != NULL) \ - { \ - sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args); \ - if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ - goto out; \ - if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ - goto iserr; \ - } \ - \ - sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ - if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ - { \ - iserr: \ - __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ - sc_ret = -1L; \ - } \ - out: \ - sc_ret; \ - }) -# else -# define INLINE_VSYSCALL(name, nr, args...) \ - INLINE_SYSCALL (name, nr, ##args) -# endif - -# ifdef SHARED -# define INTERNAL_VSYSCALL(name, err, nr, args...) \ - ({ \ - __label__ out; \ - long int v_ret; \ - \ - if (__vdso_##name != NULL) \ - { \ - v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \ - if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ - || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ - goto out; \ - } \ - v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ - out: \ - v_ret; \ - }) -# else -# define INTERNAL_VSYSCALL(name, err, nr, args...) \ - INTERNAL_SYSCALL (name, err, nr, ##args) -# endif - -# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \ - ({ \ - long int sc_ret = ENOSYS; \ - \ - if (__vdso_##name != NULL) \ - sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \ - else \ - err = 1 << 28; \ - sc_ret; \ - }) - -/* List of system calls which are supported as vsyscalls. */ -# define HAVE_CLOCK_GETRES_VSYSCALL 1 -# define HAVE_CLOCK_GETTIME_VSYSCALL 1 - -/* Define a macro which expands inline into the wrapper code for a VDSO - call. This use is for internal calls that do not need to handle errors - normally. It will never touch errno. - On powerpc a system call basically clobbers the same registers like a - function call, with the exception of LR (which is needed for the - "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal - an error return status). */ -# define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \ - ({ \ - register void *r0 __asm__ ("r0"); \ - register long int r3 __asm__ ("r3"); \ - register long int r4 __asm__ ("r4"); \ - register long int r5 __asm__ ("r5"); \ - register long int r6 __asm__ ("r6"); \ - register long int r7 __asm__ ("r7"); \ - register long int r8 __asm__ ("r8"); \ - register long int r9 __asm__ ("r9"); \ - register long int r10 __asm__ ("r10"); \ - register long int r11 __asm__ ("r11"); \ - register long int r12 __asm__ ("r12"); \ - LOADARGS_##nr (funcptr, args); \ - __asm__ __volatile__ \ - ("mtctr %0\n\t" \ - "bctrl\n\t" \ - "mfcr %0" \ - : "=&r" (r0), \ - "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \ - "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \ - : ASM_INPUT_##nr \ - : "cr0", "ctr", "lr", "memory"); \ - err = (long int) r0; \ - (int) r3; \ - }) - -# undef INLINE_SYSCALL -# define INLINE_SYSCALL(name, nr, args...) \ - ({ \ - INTERNAL_SYSCALL_DECL (sc_err); \ - long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \ - if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ - sc_ret = -1L; \ - } \ - sc_ret; \ - }) - -/* Define a macro which expands inline into the wrapper code for a system - call. This use is for internal calls that do not need to handle errors - normally. It will never touch errno. - On powerpc a system call basically clobbers the same registers like a - function call, with the exception of LR (which is needed for the - "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal - an error return status). */ - -# undef INTERNAL_SYSCALL_DECL -# define INTERNAL_SYSCALL_DECL(err) long int err - -# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ - ({ \ - register long int r0 __asm__ ("r0"); \ - register long int r3 __asm__ ("r3"); \ - register long int r4 __asm__ ("r4"); \ - register long int r5 __asm__ ("r5"); \ - register long int r6 __asm__ ("r6"); \ - register long int r7 __asm__ ("r7"); \ - register long int r8 __asm__ ("r8"); \ - register long int r9 __asm__ ("r9"); \ - register long int r10 __asm__ ("r10"); \ - register long int r11 __asm__ ("r11"); \ - register long int r12 __asm__ ("r12"); \ - LOADARGS_##nr(name, args); \ - __asm__ __volatile__ \ - ("sc \n\t" \ - "mfcr %0" \ - : "=&r" (r0), \ - "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \ - "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \ - : ASM_INPUT_##nr \ - : "cr0", "ctr", "memory"); \ - err = r0; \ - (int) r3; \ - }) -# undef INTERNAL_SYSCALL -# define INTERNAL_SYSCALL(name, err, nr, args...) \ - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args) - -# undef INTERNAL_SYSCALL_ERROR_P -# define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((void) (val), __builtin_expect ((err) & (1 << 28), 0)) - -# undef INTERNAL_SYSCALL_ERRNO -# define INTERNAL_SYSCALL_ERRNO(val, err) (val) - -# define LOADARGS_0(name, dummy) \ - r0 = name -# define LOADARGS_1(name, __arg1) \ - long int arg1 = (long int) (__arg1); \ - LOADARGS_0(name, 0); \ - extern void __illegally_sized_syscall_arg1 (void); \ - if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \ - __illegally_sized_syscall_arg1 (); \ - r3 = arg1 -# define LOADARGS_2(name, __arg1, __arg2) \ - long int arg2 = (long int) (__arg2); \ - LOADARGS_1(name, __arg1); \ - extern void __illegally_sized_syscall_arg2 (void); \ - if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \ - __illegally_sized_syscall_arg2 (); \ - r4 = arg2 -# define LOADARGS_3(name, __arg1, __arg2, __arg3) \ - long int arg3 = (long int) (__arg3); \ - LOADARGS_2(name, __arg1, __arg2); \ - extern void __illegally_sized_syscall_arg3 (void); \ - if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \ - __illegally_sized_syscall_arg3 (); \ - r5 = arg3 -# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \ - long int arg4 = (long int) (__arg4); \ - LOADARGS_3(name, __arg1, __arg2, __arg3); \ - extern void __illegally_sized_syscall_arg4 (void); \ - if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \ - __illegally_sized_syscall_arg4 (); \ - r6 = arg4 -# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \ - long int arg5 = (long int) (__arg5); \ - LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \ - extern void __illegally_sized_syscall_arg5 (void); \ - if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \ - __illegally_sized_syscall_arg5 (); \ - r7 = arg5 -# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \ - long int arg6 = (long int) (__arg6); \ - LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \ - extern void __illegally_sized_syscall_arg6 (void); \ - if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \ - __illegally_sized_syscall_arg6 (); \ - r8 = arg6 - -# define ASM_INPUT_0 "0" (r0) -# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3) -# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4) -# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5) -# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6) -# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7) -# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8) - -#endif /* __ASSEMBLER__ */ - - -/* Pointer mangling support. */ -#if defined NOT_IN_libc && defined IS_IN_rtld -/* We cannot use the thread descriptor because in ld.so we use setjmp - earlier than the descriptor is initialized. */ -#else -# ifdef __ASSEMBLER__ -# define PTR_MANGLE(reg, tmpreg) \ - lwz tmpreg,POINTER_GUARD(r2); \ - xor reg,tmpreg,reg -# define PTR_MANGLE2(reg, tmpreg) \ - xor reg,tmpreg,reg -# define PTR_MANGLE3(destreg, reg, tmpreg) \ - lwz tmpreg,POINTER_GUARD(r2); \ - xor destreg,tmpreg,reg -# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg) -# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg) -# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg) -# else -# define PTR_MANGLE(var) \ - (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) -# define PTR_DEMANGLE(var) PTR_MANGLE (var) -# endif -#endif - -#endif /* linux/powerpc/powerpc32/sysdep.h */ diff --git a/libc/sysdeps/linux/powerpc/clone.S b/libc/sysdeps/linux/powerpc/clone.S index 15d03f679..307053fe5 100644 --- a/libc/sysdeps/linux/powerpc/clone.S +++ b/libc/sysdeps/linux/powerpc/clone.S @@ -18,24 +18,27 @@ 02111-1307 USA. */ #include <features.h> -#include "ppc_asm.h" #define _ERRNO_H 1 #include <bits/errno.h> -#include <sys/syscall.h> +#include <sysdep.h> + +#define CLONE_VM 0x00000100 +#define CLONE_THREAD 0x00010000 /* This is the only really unusual system call in PPC linux, but not because of any weirdness in the system call itself; because of all the freaky stuff we have to do to make the call useful. */ /* int [r3] clone(int (*fn)(void *arg) [r3], void *child_stack [r4], - int flags [r5], void *arg [r6]); */ + int flags [r5], void *arg [r6], void *parent_tid [r7], + void *tls [r8], void *child_tid [r9]); */ #ifdef __NR_clone - .globl clone - .type clone,@function + .globl __clone + .type __clone,@function .align 2 -clone: +__clone: /* Check for child_stack == NULL || fn == NULL. */ cmpwi cr0,r4,0 cmpwi cr1,r3,0 @@ -44,22 +47,44 @@ clone: /* Set up stack frame for parent. */ stwu r1,-32(r1) + cfi_adjust_cfa_offset (32) +#ifdef RESET_PID + stmw r28,16(r1) +#else +# ifdef __ASSUME_FIXED_CLONE_SYSCALL stmw r29,16(r1) - +# else + stmw r30,16(r1) +# endif +#endif + /* Set up stack frame for child. */ clrrwi r4,r4,4 li r0,0 stwu r0,-16(r4) /* Save fn, args, stack across syscall. */ - mr r29,r3 /* Function in r29. */ - mr r30,r4 /* Stack pointer in r30. */ + mr r30,r3 /* Function in r30. */ +#ifndef __ASSUME_FIXED_CLONE_SYSCALL + mr r29,r4 /* Stack pointer in r29. */ +#endif +#ifdef RESET_PID + mr r28,r5 +#endif mr r31,r6 /* Argument in r31. */ /* 'flags' argument is first parameter to clone syscall. (The other argument is the stack pointer, already in r4.) */ mr r3,r5 + /* Move the parent_tid, child_tid and tls arguments. */ + mr r5,r7 + mr r6,r8 + mr r7,r9 + + /* End FDE now, because in the child the unwind info will be wrong. */ + cfi_endproc + /* Do the call. */ li 0, __NR_clone sc @@ -69,13 +94,27 @@ clone: crandc cr1*4+eq,cr1*4+eq,cr0*4+so bne- cr1,.Lparent /* The '-' is to minimise the race. */ +#ifndef __ASSUME_FIXED_CLONE_SYSCALL /* On at least mklinux DR3a5, clone() doesn't actually change the stack pointer. I'm pretty sure this is a bug, because it adds a race condition if a signal is sent to a thread just after it is created (in the previous three instructions). */ - mr r1,r30 + mr r1,r29 +#endif + +#ifdef RESET_PID + andis. r0,r28,CLONE_THREAD>>16 + bne+ r0,.Loldpid + andi. r0,r28,CLONE_VM + li r3,-1 + bne- r0,.Lnomoregetpid +.Lnomoregetpid: + stw r3,TID(r2) + stw r3,PID(r2) +.Loldpid: +#endif /* Call procedure. */ - mtctr r29 + mtctr r30 mr r3,r31 bctrl /* Call _exit with result from procedure. */ @@ -83,16 +122,24 @@ clone: .Lparent: /* Parent. Restore registers & return. */ +#ifdef RESET_PID + lmw r28,16(r1) +#else +# ifndef __ASSUME_FIXED_CLONE_SYSCALL lmw r29,16(r1) +# else + lmw r30,16(r1) +# endif +#endif addi r1,r1,32 bnslr+ - b __syscall_error .Lbadargs: li r3,EINVAL - b __syscall_error - .size clone,.-clone + cfi_startproc + .size __clone,.-__clone +weak_alias(__clone, clone) #endif diff --git a/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h b/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h new file mode 100644 index 000000000..3f6fefdcb --- /dev/null +++ b/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h @@ -0,0 +1,151 @@ +/* Assembly macros for 32-bit PowerPC. + Copyright (C) 1999, 2001, 2002, 2003, 2006 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ + +#ifdef __ASSEMBLER__ + +#ifdef __ELF__ + +/* If compiled for profiling, call `_mcount' at the start of each + function. */ +#ifdef PROF +/* The mcount code relies on a the return address being on the stack + to locate our caller and so it can restore it; so store one just + for its benefit. */ +# define CALL_MCOUNT \ + mflr r0; \ + stw r0,4(r1); \ + cfi_offset (lr, 4); \ + bl JUMPTARGET(_mcount); +#else /* PROF */ +# define CALL_MCOUNT /* Do nothing. */ +#endif /* PROF */ + +#define ENTRY(name) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ + .align ALIGNARG(2); \ + C_LABEL(name) \ + cfi_startproc; \ + CALL_MCOUNT + +#define EALIGN_W_0 /* No words to insert. */ +#define EALIGN_W_1 nop +#define EALIGN_W_2 nop;nop +#define EALIGN_W_3 nop;nop;nop +#define EALIGN_W_4 EALIGN_W_3;nop +#define EALIGN_W_5 EALIGN_W_4;nop +#define EALIGN_W_6 EALIGN_W_5;nop +#define EALIGN_W_7 EALIGN_W_6;nop + +/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes + past a 2^align boundary. */ +#ifdef PROF +# define EALIGN(name, alignt, words) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ + .align ALIGNARG(2); \ + C_LABEL(name) \ + cfi_startproc; \ + CALL_MCOUNT \ + b 0f; \ + .align ALIGNARG(alignt); \ + EALIGN_W_##words; \ + 0: +#else /* PROF */ +# define EALIGN(name, alignt, words) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ + .align ALIGNARG(alignt); \ + EALIGN_W_##words; \ + C_LABEL(name) \ + cfi_startproc; +#endif + +#undef END +#define END(name) \ + cfi_endproc; \ + ASM_SIZE_DIRECTIVE(name) + +#define DO_CALL(syscall) \ + li 0,syscall; \ + sc + +#undef JUMPTARGET +#ifdef PIC +# define JUMPTARGET(name) name##@plt +#else +# define JUMPTARGET(name) name +#endif + +#if defined SHARED && defined DO_VERSIONING && defined PIC \ + && !defined NO_HIDDEN +# undef HIDDEN_JUMPTARGET +# define HIDDEN_JUMPTARGET(name) __GI_##name##@local +#endif + +#define PSEUDO(name, syscall_name, args) \ + .section ".text"; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); + +#define PSEUDO_RET \ + bnslr+; \ + b __syscall_error@local +#define ret PSEUDO_RET + +#undef PSEUDO_END +#define PSEUDO_END(name) \ + END (name) + +#define PSEUDO_NOERRNO(name, syscall_name, args) \ + .section ".text"; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); + +#define PSEUDO_RET_NOERRNO \ + blr +#define ret_NOERRNO PSEUDO_RET_NOERRNO + +#undef PSEUDO_END_NOERRNO +#define PSEUDO_END_NOERRNO(name) \ + END (name) + +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + .section ".text"; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); + +#define PSEUDO_RET_ERRVAL \ + blr +#define ret_ERRVAL PSEUDO_RET_ERRVAL + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) \ + END (name) + +/* Local labels stripped out by the linker. */ +#undef L +#define L(x) .L##x + +/* Label in text section. */ +#define C_TEXT(name) name + +#endif /* __ELF__ */ + +#endif /* __ASSEMBLER__ */ diff --git a/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h b/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h new file mode 100644 index 000000000..467288576 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h @@ -0,0 +1,264 @@ +/* Assembly macros for 64-bit PowerPC. + Copyright (C) 2002, 2003, 2004, 2006 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ + +#ifdef __ELF__ + +#ifdef __ASSEMBLER__ + +/* Support macros for CALL_MCOUNT. */ + .macro SAVE_ARG NARG + .if \NARG + SAVE_ARG \NARG-1 + std 2+\NARG,-72+8*(\NARG)(1) + .endif + .endm + + .macro REST_ARG NARG + .if \NARG + REST_ARG \NARG-1 + ld 2+\NARG,40+8*(\NARG)(1) + .endif + .endm + +/* If compiled for profiling, call `_mcount' at the start of each function. + see ppc-mcount.S for more details. */ + .macro CALL_MCOUNT NARG +#ifdef PROF + mflr r0 + SAVE_ARG \NARG + std r0,16(r1) + stdu r1,-112(r1) + bl JUMPTARGET (_mcount) + ld r0,128(r1) + REST_ARG \NARG + addi r1,r1,112 + mtlr r0 +#endif + .endm + +#ifdef USE_PPC64_OVERLAPPING_OPD +# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase +#else +# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase, 0 +#endif + +#define ENTRY_1(name) \ + .section ".text"; \ + .type BODY_LABEL(name),@function; \ + .globl name; \ + .section ".opd","aw"; \ + .align 3; \ +name##: OPD_ENT (name); \ + .previous; + +#ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define DOT_LABEL(X) .##X +# define BODY_LABEL(X) .##X +# define ENTRY_2(name) \ + .globl BODY_LABEL(name); \ + ENTRY_1(name) \ + .size name, 24; +# define END_2(name) \ + .size BODY_LABEL(name),.-BODY_LABEL(name); +#else +# define DOT_LABEL(X) X +# define BODY_LABEL(X) .LY##X +# define ENTRY_2(name) \ + .type name,@function; \ + ENTRY_1(name) +# define END_2(name) \ + .size name,.-BODY_LABEL(name); \ + .size BODY_LABEL(name),.-BODY_LABEL(name); +#endif + +#define ENTRY(name) \ + ENTRY_2(name) \ + .align ALIGNARG(2); \ +BODY_LABEL(name): \ + cfi_startproc; + +#define EALIGN_W_0 /* No words to insert. */ +#define EALIGN_W_1 nop +#define EALIGN_W_2 nop;nop +#define EALIGN_W_3 nop;nop;nop +#define EALIGN_W_4 EALIGN_W_3;nop +#define EALIGN_W_5 EALIGN_W_4;nop +#define EALIGN_W_6 EALIGN_W_5;nop +#define EALIGN_W_7 EALIGN_W_6;nop + +/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes + past a 2^alignt boundary. */ +#define EALIGN(name, alignt, words) \ + ENTRY_2(name) \ + .align ALIGNARG(alignt); \ + EALIGN_W_##words; \ +BODY_LABEL(name): \ + cfi_startproc; + +/* Local labels stripped out by the linker. */ +#undef L +#define L(x) .L##x + +#define tostring(s) #s +#define stringify(s) tostring(s) +#define XGLUE(a,b) a##b +#define GLUE(a,b) XGLUE(a,b) +#define LT_LABEL(name) GLUE(.LT,name) +#define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix) + +/* Support Traceback tables */ +#define TB_ASM 0x000c000000000000 +#define TB_GLOBALLINK 0x0000800000000000 +#define TB_IS_EPROL 0x0000400000000000 +#define TB_HAS_TBOFF 0x0000200000000000 +#define TB_INT_PROC 0x0000100000000000 +#define TB_HAS_CTL 0x0000080000000000 +#define TB_TOCLESS 0x0000040000000000 +#define TB_FP_PRESENT 0x0000020000000000 +#define TB_LOG_ABORT 0x0000010000000000 +#define TB_INT_HANDL 0x0000008000000000 +#define TB_NAME_PRESENT 0x0000004000000000 +#define TB_USES_ALLOCA 0x0000002000000000 +#define TB_SAVES_CR 0x0000000200000000 +#define TB_SAVES_LR 0x0000000100000000 +#define TB_STORES_BC 0x0000000080000000 +#define TB_FIXUP 0x0000000040000000 +#define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24) +#define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16) +#define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8) +#define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1) +#define TB_PARMSONSTK 0x0000000000000001 + +#define PPC_HIGHER(v) (((v) >> 32) & 0xffff) +#define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT + +#define TRACEBACK(name) \ +LT_LABEL(name): ; \ + .long 0 ; \ + .quad TB_DEFAULT ; \ + .long LT_LABEL(name)-BODY_LABEL(name) ; \ + .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ +LT_LABELSUFFIX(name,_name_start): ;\ + .ascii stringify(name) ; \ +LT_LABELSUFFIX(name,_name_end): ; \ + .align 2 ; + +#define TRACEBACK_MASK(name,mask) \ +LT_LABEL(name): ; \ + .long 0 ; \ + .quad TB_DEFAULT | mask ; \ + .long LT_LABEL(name)-BODY_LABEL(name) ; \ + .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ +LT_LABELSUFFIX(name,_name_start): ;\ + .ascii stringify(name) ; \ +LT_LABELSUFFIX(name,_name_end): ; \ + .align 2 ; + +/* END generates Traceback tables */ +#undef END +#define END(name) \ + cfi_endproc; \ + TRACEBACK(name) \ + END_2(name) + +/* This form supports more informative traceback tables */ +#define END_GEN_TB(name,mask) \ + cfi_endproc; \ + TRACEBACK_MASK(name,mask) \ + END_2(name) + +#define DO_CALL(syscall) \ + li 0,syscall; \ + sc + +/* ppc64 is always PIC */ +#undef JUMPTARGET +#define JUMPTARGET(name) DOT_LABEL(name) + +#define PSEUDO(name, syscall_name, args) \ + .section ".text"; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); + +#define PSEUDO_RET \ + bnslr+; \ + b JUMPTARGET(__syscall_error) + +#define ret PSEUDO_RET + +#undef PSEUDO_END +#define PSEUDO_END(name) \ + END (name) + +#define PSEUDO_NOERRNO(name, syscall_name, args) \ + .section ".text"; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); + +#define PSEUDO_RET_NOERRNO \ + blr + +#define ret_NOERRNO PSEUDO_RET_NOERRNO + +#undef PSEUDO_END_NOERRNO +#define PSEUDO_END_NOERRNO(name) \ + END (name) + +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + .section ".text"; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); + +#define PSEUDO_RET_ERRVAL \ + blr + +#define ret_ERRVAL PSEUDO_RET_ERRVAL + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) \ + END (name) + +#else /* !__ASSEMBLER__ */ + +#ifdef USE_PPC64_OVERLAPPING_OPD +# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase;" +#else +# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0;" +#endif + +#ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define DOT_PREFIX "." +# define BODY_PREFIX "." +# define ENTRY_2(name) \ + ".globl " BODY_PREFIX #name ";\n" \ + ".size " #name ", 24;" +# define END_2(name) \ + ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";" +#else +# define DOT_PREFIX "" +# define BODY_PREFIX ".LY" +# define ENTRY_2(name) ".type " #name ",@function;" +# define END_2(name) \ + ".size " #name ",.-" BODY_PREFIX #name ";\n" \ + ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";" +#endif + +#endif /* __ASSEMBLER__ */ + +#endif /* __ELF__ */ diff --git a/libc/sysdeps/linux/powerpc/pread_write.c b/libc/sysdeps/linux/powerpc/pread_write.c index 83628512a..7f988d301 100644 --- a/libc/sysdeps/linux/powerpc/pread_write.c +++ b/libc/sysdeps/linux/powerpc/pread_write.c @@ -146,6 +146,7 @@ static ssize_t __fake_pread_write64(int fd, void *buf, #endif /* ! defined __NR_pread || ! defined __NR_pwrite */ #ifndef __NR_pread +ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset); ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) { return(__fake_pread_write(fd, buf, count, offset, 0)); @@ -153,6 +154,7 @@ ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) weak_alias(__libc_pread,pread) # ifdef __UCLIBC_HAS_LFS__ +ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset); ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) { return(__fake_pread_write64(fd, buf, count, offset, 0)); @@ -163,6 +165,7 @@ weak_alias(__libc_pread64,pread64) #ifndef __NR_pwrite +ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset); ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset) { return(__fake_pread_write(fd, (void*)buf, count, offset, 1)); @@ -170,6 +173,7 @@ ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset) weak_alias(__libc_pwrite,pwrite) # ifdef __UCLIBC_HAS_LFS__ +ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset); ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset) { return(__fake_pread_write64(fd, (void*)buf, count, offset, 1)); diff --git a/libc/sysdeps/linux/powerpc/sysdep.h b/libc/sysdeps/linux/powerpc/sysdep.h new file mode 100644 index 000000000..14b86ac49 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/sysdep.h @@ -0,0 +1,196 @@ +/* Copyright (C) 1999, 2001, 2002, 2006 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <common/sysdep.h> + +/* + * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP). + * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup. + * The following must match the kernels linux/asm/cputable.h. + */ +#define PPC_FEATURE_32 0x80000000 /* 32-bit mode. */ +#define PPC_FEATURE_64 0x40000000 /* 64-bit mode. */ +#define PPC_FEATURE_601_INSTR 0x20000000 /* 601 chip, Old POWER ISA. */ +#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 /* SIMD/Vector Unit. */ +#define PPC_FEATURE_HAS_FPU 0x08000000 /* Floating Point Unit. */ +#define PPC_FEATURE_HAS_MMU 0x04000000 /* Memory Management Unit. */ +#define PPC_FEATURE_HAS_4xxMAC 0x02000000 /* 4xx Multiply Accumulator. */ +#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 /* Unified I/D cache. */ +#define PPC_FEATURE_HAS_SPE 0x00800000 /* Signal Processing ext. */ +#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 /* SPE Float. */ +#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 /* SPE Double. */ +#define PPC_FEATURE_NO_TB 0x00100000 /* 601/403gx have no timebase */ +#define PPC_FEATURE_POWER4 0x00080000 /* POWER4 ISA 2.00 */ +#define PPC_FEATURE_POWER5 0x00040000 /* POWER5 ISA 2.02 */ +#define PPC_FEATURE_POWER5_PLUS 0x00020000 /* POWER5+ ISA 2.03 */ +#define PPC_FEATURE_CELL_BE 0x00010000 /* CELL Broadband Engine */ +#define PPC_FEATURE_BOOKE 0x00008000 +#define PPC_FEATURE_SMT 0x00004000 /* Simultaneous Multi-Threading */ +#define PPC_FEATURE_ICACHE_SNOOP 0x00002000 +#define PPC_FEATURE_ARCH_2_05 0x00001000 /* ISA 2.05 */ +#define PPC_FEATURE_PA6T 0x00000800 /* PA Semi 6T Core */ +#define PPC_FEATURE_HAS_DFP 0x00000400 /* Decimal FP Unit */ +#define PPC_FEATURE_POWER6_EXT 0x00000200 /* P6 + mffgpr/mftgpr */ +#define PPC_FEATURE_ARCH_2_06 0x00000100 /* ISA 2.06 */ +#define PPC_FEATURE_HAS_VSX 0x00000080 /* P7 Vector Extension. */ +#define PPC_FEATURE_970 (PPC_FEATURE_POWER4 + PPC_FEATURE_HAS_ALTIVEC) + +#ifdef __ASSEMBLER__ + +/* Symbolic names for the registers. The only portable way to write asm + code is to use number but this produces really unreadable code. + Therefore these symbolic names. */ + +/* Integer registers. */ +#define r0 0 +#define r1 1 +#define r2 2 +#define r3 3 +#define r4 4 +#define r5 5 +#define r6 6 +#define r7 7 +#define r8 8 +#define r9 9 +#define r10 10 +#define r11 11 +#define r12 12 +#define r13 13 +#define r14 14 +#define r15 15 +#define r16 16 +#define r17 17 +#define r18 18 +#define r19 19 +#define r20 20 +#define r21 21 +#define r22 22 +#define r23 23 +#define r24 24 +#define r25 25 +#define r26 26 +#define r27 27 +#define r28 28 +#define r29 29 +#define r30 30 +#define r31 31 + +/* Floating-point registers. */ +#define fp0 0 +#define fp1 1 +#define fp2 2 +#define fp3 3 +#define fp4 4 +#define fp5 5 +#define fp6 6 +#define fp7 7 +#define fp8 8 +#define fp9 9 +#define fp10 10 +#define fp11 11 +#define fp12 12 +#define fp13 13 +#define fp14 14 +#define fp15 15 +#define fp16 16 +#define fp17 17 +#define fp18 18 +#define fp19 19 +#define fp20 20 +#define fp21 21 +#define fp22 22 +#define fp23 23 +#define fp24 24 +#define fp25 25 +#define fp26 26 +#define fp27 27 +#define fp28 28 +#define fp29 29 +#define fp30 30 +#define fp31 31 + +/* Condition code registers. */ +#define cr0 0 +#define cr1 1 +#define cr2 2 +#define cr3 3 +#define cr4 4 +#define cr5 5 +#define cr6 6 +#define cr7 7 + +/* Vector registers. */ +#define v0 0 +#define v1 1 +#define v2 2 +#define v3 3 +#define v4 4 +#define v5 5 +#define v6 6 +#define v7 7 +#define v8 8 +#define v9 9 +#define v10 10 +#define v11 11 +#define v12 12 +#define v13 13 +#define v14 14 +#define v15 15 +#define v16 16 +#define v17 17 +#define v18 18 +#define v19 19 +#define v20 20 +#define v21 21 +#define v22 22 +#define v23 23 +#define v24 24 +#define v25 25 +#define v26 26 +#define v27 27 +#define v28 28 +#define v29 29 +#define v30 30 +#define v31 31 + +#define VRSAVE 256 + + +#ifdef __ELF__ + +/* This seems to always be the case on PPC. */ +#define ALIGNARG(log2) log2 +/* For ELF we need the `.type' directive to make shared libs work right. */ +#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; +#define ASM_SIZE_DIRECTIVE(name) .size name,.-name + +/* In ELF C symbols are asm symbols. */ +#undef NO_UNDERSCORES +#define NO_UNDERSCORES + +#endif /* __ELF__ */ + +# include <sys/syscall.h> +# if defined(__powerpc64__) +# include "powerpc64/sysdep.h" +# else +# include "powerpc32/sysdep.h" +# endif + +#endif /* __ASSEMBLER__ */ + diff --git a/libc/sysdeps/linux/powerpc/vfork.S b/libc/sysdeps/linux/powerpc/vfork.S index 600c980a8..008374260 100644 --- a/libc/sysdeps/linux/powerpc/vfork.S +++ b/libc/sysdeps/linux/powerpc/vfork.S @@ -1,3 +1,4 @@ +/* vi: set sw=4 ts=4: */ /* * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> * diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile b/libpthread/nptl/sysdeps/powerpc/Makefile deleted file mode 100644 index 3af245600..000000000 --- a/libpthread/nptl/sysdeps/powerpc/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2003 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 Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 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 -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -ifeq ($(subdir),csu) -gen-as-const-headers += tcb-offsets.sym -endif diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/powerpc/Makefile.arch new file mode 100644 index 000000000..bd34063b5 --- /dev/null +++ b/libpthread/nptl/sysdeps/powerpc/Makefile.arch @@ -0,0 +1,50 @@ +# Makefile for uClibc NPTL +# +# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/powerpc +PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/powerpc + +libpthread_SSRC = +libpthread_CSRC = pthread_spin_lock.c pthread_spin_trylock.c + +PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC)) +PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC)) + +ifeq ($(DOPIC),y) +libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os) +else +libpthread-a-y += $(PTHREAD_ARCH_OBJ) +endif +libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS) + +libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ) + +CFLAGS-powerpc = $(SSP_ALL_CFLAGS) + +# +# Create 'tcb-offsets.h' header file. +# +CFLAGS-tcb-offsets.c = -S + +$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym + $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@ + +$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c + $(compile.c) + +$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s + $(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@ + +pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h + +nptl_arch_headers_clean: + $(RM) $(PTHREAD_ARCH_OUT)/tcb-offsets.c \ + $(PTHREAD_ARCH_OUT)/tcb-offsets.s \ + $(PTHREAD_ARCH_OUT)/tcb-offsets.h + +nptl_arch_objclean: + $(RM) $(PTHREAD_ARCH_OUT)/*.{o,os,oS} diff --git a/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c b/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c index e2293fda1..9334d4217 100644 --- a/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c +++ b/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c @@ -20,12 +20,11 @@ #include "pthreadP.h" int -pthread_spin_lock (lock) - pthread_spinlock_t *lock; +pthread_spin_lock (pthread_spinlock_t *lock) { unsigned int __tmp; - asm volatile ( + __asm__ __volatile__ ( "1: lwarx %0,0,%1\n" " cmpwi 0,%0,0\n" " bne- 2f\n" diff --git a/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c index d8e1dbcc8..a2757e207 100644 --- a/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c +++ b/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c @@ -21,13 +21,12 @@ #include "pthreadP.h" int -pthread_spin_trylock (lock) - pthread_spinlock_t *lock; +pthread_spin_trylock (pthread_spinlock_t *lock) { unsigned int old; int err = EBUSY; - asm ("1: lwarx %0,0,%2\n" + __asm__ ("1: lwarx %0,0,%2\n" " cmpwi 0,%0,0\n" " bne 2f\n" " stwcx. %3,0,%2\n" diff --git a/libpthread/nptl/sysdeps/powerpc/tls.h b/libpthread/nptl/sysdeps/powerpc/tls.h index ce5559eef..990972eaa 100644 --- a/libpthread/nptl/sysdeps/powerpc/tls.h +++ b/libpthread/nptl/sysdeps/powerpc/tls.h @@ -40,6 +40,13 @@ typedef union dtv # include <tcb-offsets.h> #endif /* __ASSEMBLER__ */ +/* We require TLS support in the tools. */ +#define HAVE_TLS_SUPPORT 1 +#define HAVE_TLS_MODEL_ATTRIBUTE 1 +#define HAVE___THREAD 1 + +/* Signal that TLS support is available. */ +#define USE_TLS 1 /* We require TLS support in the tools. */ #ifndef HAVE_TLS_SUPPORT @@ -61,7 +68,7 @@ typedef union dtv #define TLS_MULTIPLE_THREADS_IN_TCB 1 /* Get the thread descriptor definition. */ -# include <nptl/descr.h> +# include <../../descr.h> /* The stack_guard is accessed directly by GCC -fstack-protector code, so it is a part of public ABI. The dtv and pointer_guard fields diff --git a/libpthread/nptl/sysdeps/pthread/Makefile.in b/libpthread/nptl/sysdeps/pthread/Makefile.in index 000d18b1d..36d9eeb90 100644 --- a/libpthread/nptl/sysdeps/pthread/Makefile.in +++ b/libpthread/nptl/sysdeps/pthread/Makefile.in @@ -43,6 +43,17 @@ SH_PTHREAD_EXCLUDE_LIST = pthread_spin_unlock.c pthread_spin_init.c \ libpthread_CSRC := $(filter-out $(SH_PTHREAD_EXCLUDE_LIST),$(libpthread_CSRC)) endif +ifeq ($(TARGET_ARCH),powerpc) +#EXCLUDE_LIST := pthread_cond_broadcast.c \ +# pthread_cond_signal.c pthread_cond_timedwait.c \ +# pthread_cond_wait.c \ +# pthread_spin_init.c \ +# pthread_spin_unlock.c pt-sigfillset.c \ +# pt-longjmp.c +# +#libpthread_CSRC := $(filter-out $(EXCLUDE_LIST),$(libpthread_CSRC)) +endif + ifeq ($(TARGET_ARCH),sparc) SPARC_PTHREAD_EXCLUDE_LIST = pthread_barrier_init.c pthread_barrier_wait.c \ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in index 1c75c14c5..c2ade848e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in @@ -45,9 +45,9 @@ libc_CSRC += libc-lowlevellock.c endif ifeq ($(TARGET_ARCH),powerpc) -libpthread_CSRC += lowlevellock.c +libpthread_CSRC += lowlevellock.c lowlevelrobustlock.c libc_CSRC += libc-lowlevellock.c -librt_CSRC := mq_notify.c +librt_CSRC += __syscall_error.c endif ifeq ($(TARGET_ARCH),sparc) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c index 6a51e73da..2b19fd5d9 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c @@ -20,4 +20,4 @@ #define TLS_VALUE (pd + 1) /* Get the real implementation. */ -#include <nptl/sysdeps/pthread/createthread.c> +#include <sysdeps/pthread/createthread.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile index e98c9bd86..421a62b3d 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -1,2 +1,13 @@ -# pull in __syscall_error routine -libpthread-routines += sysdep +# Makefile for uClibc NPTL +# +# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +top_srcdir=../../../../../../../ +top_builddir=../../../../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch new file mode 100644 index 000000000..2c39551dc --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch @@ -0,0 +1,62 @@ +# Makefile for uClibc NPTL +# +# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +libpthread_LINUX_ARCH_SSRC = pt-vfork.S +libpthread_LINUX_ARCH_CSRC = pthread_once.c pt-__syscall_error.c + +libc_a_CSRC = fork.c +libc_a_SSRC = clone.S vfork.S + +ARCH_OBJS += $(libc_a_SSRC:.S=.c) + +CFLAGS += $(SSP_ALL_CFLAGS) +ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y) +CFLAGS-fork.c = -D__USE_STDIO_FUTEXES__ +endif + +CFLAGS-pthread_once.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 +CFLAGS-lowlevellock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 +CFLAGS-pt-__syscall_error.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 + +ASFLAGS-pt-vfork.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD +#ASFLAGS-libc-lowlevellock.S = -D_LIBC_REENTRANT -DUSE___THREAD +#ASFLAGS-lowlevellock.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD +ASFLAGS-clone.S = -D_LIBC_REENTRANT +ASFLAGS-vfork.S = -D_LIBC_REENTRANT + +ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) +#Needed to use the correct SYSCALL_ERROR_HANDLER +ASFLAGS-clone.S += -DUSE___THREAD +ASFLAGS-vfork.S += -DUSE___THREAD +endif + +LINUX_ARCH_DIR:=$(top_srcdir)libpthread/nptl/sysdeps/unix/sysv/linux/powerpc +LINUX_ARCH_OUT:=$(top_builddir)libpthread/nptl/sysdeps/unix/sysv/linux/powerpc +LINUX_ARCH_OBJ:=$(patsubst %.S,$(LINUX_ARCH_OUT)/%.o,$(libpthread_LINUX_ARCH_SSRC)) +LINUX_ARCH_OBJ+=$(patsubst %.c,$(LINUX_ARCH_OUT)/%.o,$(libpthread_LINUX_ARCH_CSRC)) + +ifeq ($(DOPIC),y) +libpthread-a-y += $(LINUX_ARCH_OBJ:.o=.os) +else +libpthread-a-y += $(LINUX_ARCH_OBJ) +endif +libpthread-so-y += $(LINUX_ARCH_OBJ:.o=.oS) + +libpthread-multi-y+=$(libpthread_LINUX_ARCH_CSRC) + +LIBC_LINUX_ARCH_OBJ:=$(patsubst %.c,$(LINUX_ARCH_OUT)/%.o,$(libc_a_CSRC)) +LIBC_LINUX_ARCH_OBJ+=$(patsubst %.S,$(LINUX_ARCH_OUT)/%.o,$(libc_a_SSRC)) + +libc-static-y+=$(LIBC_LINUX_ARCH_OBJ) +libc-shared-y+=$(LIBC_LINUX_ARCH_OBJ:.o=.oS) + +libc-multi-y+=$(libc_a_CSRC) + +objclean-y+=nptl_linux_arch_clean + +nptl_linux_arch_clean: + $(do_rm) $(addprefix $(LINUX_ARCH_OUT)/*., o os oS) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S new file mode 100644 index 000000000..91c939e57 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S @@ -0,0 +1,5 @@ +#if defined __powerpc64__ +# include "powerpc64/clone.S" +#else +# include "powerpc32/clone.S" +#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c index e811ad74e..26efabd0d 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c @@ -22,4 +22,4 @@ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE) /* Get the real implementation. */ -#include <nptl/sysdeps/pthread/createthread.c> +#include <sysdeps/pthread/createthread.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index 66c02cbbd..ecfa9702e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -24,7 +24,8 @@ #include <sys/param.h> #include <bits/pthreadtypes.h> #include <atomic.h> -#include <kernel-features.h> +#include <bits/kernel-features.h> +#include <sysdep.h> #ifndef __NR_futex # define __NR_futex 221 diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h index 88b24e7d9..4daa115ed 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h @@ -21,7 +21,7 @@ #include <sysdep.h> #include <tls.h> #ifndef __ASSEMBLER__ -# include <nptl/pthreadP.h> +# include <pthreadP.h> #endif #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S index eed2a8f1a..8d3773ca4 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S @@ -55,3 +55,4 @@ ENTRY (__vfork) PSEUDO_END (__vfork) libc_hidden_def (__vfork) weak_alias (__vfork, vfork) +libc_hidden_weak(vfork) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h index 707765ab5..8e5e477b3 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h @@ -21,7 +21,7 @@ #include <sysdep.h> #include <tls.h> #ifndef __ASSEMBLER__ -# include <nptl/pthreadP.h> +# include <pthreadP.h> #endif #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S index 26885bb95..64aa952cd 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S @@ -53,3 +53,5 @@ ENTRY (__vfork) PSEUDO_END (__vfork) libc_hidden_def (__vfork) weak_alias (__vfork, vfork) +libc_hidden_weak(vfork) + diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c new file mode 100644 index 000000000..2a402e5af --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c @@ -0,0 +1 @@ +#include <../../../../../../../libc/sysdeps/linux/powerpc/__syscall_error.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-vfork.S new file mode 100644 index 000000000..0225219d9 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-vfork.S @@ -0,0 +1,5 @@ +#if defined __powerpc64__ +# include "powerpc64/pt-vfork.S" +#else +# include "powerpc32/pt-vfork.S" +#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h new file mode 100644 index 000000000..dab7e0beb --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h @@ -0,0 +1,5 @@ +#if defined(__powerpc64__) +#include "powerpc64/sysdep-cancel.h" +#else +#include "powerpc32/sysdep-cancel.h" +#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S new file mode 100644 index 000000000..27d29020e --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S @@ -0,0 +1,5 @@ +#if defined __powerpc64__ +# include "powerpc64/vfork.S" +#else +# include "powerpc32/vfork.S" +#endif diff --git a/test/misc/opendir-tst1.c b/test/misc/opendir-tst1.c index 983d4b482..302158d0e 100644 --- a/test/misc/opendir-tst1.c +++ b/test/misc/opendir-tst1.c @@ -92,4 +92,4 @@ do_cleanup (void) /* Include the test skeleton. */ -#include <test-skeleton.c> +#include "../test-skeleton.c" diff --git a/test/misc/tst-utmp.c b/test/misc/tst-utmp.c index 12a208855..06ba1409b 100644 --- a/test/misc/tst-utmp.c +++ b/test/misc/tst-utmp.c @@ -50,7 +50,7 @@ static void do_prepare (int argc, char *argv[]); #define PREPARE do_prepare /* This defines the `main' function and some more. */ -#include <test-skeleton.c> +#include "../test-skeleton.c" /* These are for the temporary file we generate. */ diff --git a/test/stdlib/test-canon.c b/test/stdlib/test-canon.c index 9770a948d..788754f47 100644 --- a/test/stdlib/test-canon.c +++ b/test/stdlib/test-canon.c @@ -31,7 +31,7 @@ /* Prototype for our test function. */ extern int do_test (int argc, char *argv[]); -#include <test-skeleton.c> +#include "../test-skeleton.c" #ifndef PATH_MAX # define PATH_MAX 4096 diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h index 0eaca6574..3a9a21adc 100644 --- a/test/tls/tls-macros.h +++ b/test/tls/tls-macros.h @@ -713,7 +713,7 @@ register void *__gp __asm__("$29"); #elif defined __powerpc__ && !defined __powerpc64__ -#include "config.h" +/*#include "config.h"*/ # define __TLS_CALL_CLOBBERS \ "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \ diff --git a/test/unistd/tst-preadwrite.c b/test/unistd/tst-preadwrite.c index 281044858..4aca98aa4 100644 --- a/test/unistd/tst-preadwrite.c +++ b/test/unistd/tst-preadwrite.c @@ -44,7 +44,7 @@ extern int do_test (int argc, char *argv[]); #define TIMEOUT 20 /* sec */ /* This defines the `main' function and some more. */ -#include <test-skeleton.c> +#include "../test-skeleton.c" /* These are for the temporary file we generate. */ char *name; |