Changeset c4c5de5 in mainline for libc/arch


Ignore:
Timestamp:
2006-03-24T14:29:19Z (20 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8fe1cdb
Parents:
520492a
Message:

Completed support for TLS in GCC (modifier thread) for ia32,amd64,ia64 and mips.

Location:
libc/arch
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • libc/arch/amd64/Makefile.inc

    r520492a rc4c5de5  
    3434
    3535ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
    36                 arch/$(ARCH)/src/psthread.S
     36                arch/$(ARCH)/src/psthread.S \
     37                arch/$(ARCH)/src/thread.c
    3738
    3839LFLAGS += -N
  • libc/arch/amd64/_link.ld.in

    r520492a rc4c5de5  
    2121                *(.data);
    2222        } :data
     23        .tdata : {
     24                _tdata_start = .;
     25                *(.tdata);
     26                _tdata_end = .;
     27        } :data
     28        .tbss : {
     29                _tbss_start = .;
     30                *(.tbss);
     31                _tbss_end = .;
     32        } :data
     33       
    2334        .bss : {
    2435                *(COMMON);
  • libc/arch/amd64/include/thread.h

    r520492a rc4c5de5  
    3232#include <libc.h>
    3333
    34 static inline void __tls_set(void *tls)
     34typedef struct {
     35        void *self;
     36        void *pst_data;
     37} tcb_t;
     38
     39static inline void __tcb_set(tcb_t *tcb)
    3540{
    36         __SYSCALL1(SYS_TLS_SET, (sysarg_t) tls);
     41        __SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb);
    3742}
    3843
    39 static inline void * __tls_get(void)
     44static inline tcb_t * __tcb_get(void)
    4045{
    4146        void * retval;
  • libc/arch/ia32/Makefile.inc

    r520492a rc4c5de5  
    3434
    3535ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    36                 arch/$(ARCH)/src/psthread.S
     36                arch/$(ARCH)/src/psthread.S \
     37                arch/$(ARCH)/src/thread.c
    3738
    3839LFLAGS += -N
  • libc/arch/ia32/_link.ld.in

    r520492a rc4c5de5  
    2121                *(.data);
    2222        } :data
     23        .tdata : {
     24                _tdata_start = .;
     25                *(.tdata);
     26                _tdata_end = .;
     27        } :data
     28        .tbss : {
     29                _tbss_start = .;
     30                *(.tbss);
     31                _tbss_end = .;
     32        } :data
    2333        .bss : {
    2434                *(COMMON);
  • libc/arch/ia32/include/thread.h

    r520492a rc4c5de5  
    3232#include <libc.h>
    3333
    34 static inline void __tls_set(void *tls)
     34typedef struct {
     35        void *self;
     36        void *pst_data;
     37} tcb_t;
     38
     39static inline void __tcb_set(tcb_t *tcb)
    3540{
    36         __SYSCALL1(SYS_TLS_SET, (sysarg_t) tls);
     41        __SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb);
    3742}
    3843
    39 static inline void * __tls_get(void)
     44static inline tcb_t * __tcb_get(void)
    4045{
    4146        void * retval;
  • libc/arch/ia64/Makefile.inc

    r520492a rc4c5de5  
    3737
    3838ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
    39                 arch/$(ARCH)/src/psthread.S
     39                arch/$(ARCH)/src/psthread.S \
     40                arch/$(ARCH)/src/thread.c
  • libc/arch/ia64/_link.ld.in

    r520492a rc4c5de5  
    2727                *(.sdata);
    2828        } :data
     29        .tdata : {
     30                _tdata_start = .;
     31                *(.tdata);
     32                _tdata_end = .;
     33        } :data
     34        .tbss : {
     35                _tbss_start = .;
     36                *(.tbss);
     37                _tbss_end = .;
     38        } :data
    2939        .bss : {
    3040                *(.sbss);
  • libc/arch/ia64/include/thread.h

    r520492a rc4c5de5  
    3030#define __LIBC__ia64THREAD_H__
    3131
    32 static inline void __tls_set(void *tls)
     32/* This structure must be exactly 16 bytes long */
     33typedef struct {
     34        void *dtv; /* unused in static linking*/
     35        void *pst_data;
     36} tcb_t;
     37
     38static inline void __tcb_set(tcb_t *tcb)
    3339{
    34         __asm__ volatile ("mov r13 = %0\n" : : "r" (tls) : "r13");
     40        __asm__ volatile ("mov r13 = %0\n" : : "r" (tcb) : "r13");
    3541}
    3642
    37 static inline void *__tls_get(void)
     43static inline tcb_t *__tcb_get(void)
    3844{
    3945        void *retval;
  • libc/arch/mips32/Makefile.inc

    r520492a rc4c5de5  
    3535
    3636ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    37         arch/$(ARCH)/src/psthread.S
     37        arch/$(ARCH)/src/psthread.S \
     38        arch/$(ARCH)/src/thread.c
    3839
    3940
  • libc/arch/mips32/_link.ld.in

    r520492a rc4c5de5  
    2222                *(.data.rel*);
    2323        } :data
     24
    2425        .got : {
    2526                _gp = .;
    2627                *(.got);
    2728        } :data
     29
     30        .tdata : {
     31                _tdata_start = .;
     32                *(.tdata);
     33                _tdata_end = .;
     34        } :data
     35        .tbss : {
     36                _tbss_start = .;
     37                *(.tbss);
     38                _tbss_end = .;
     39        } :data
     40
    2841        .sbss : {
    2942                *(.scommon);
  • libc/arch/mips32/include/psthread.h

    r520492a rc4c5de5  
    3232#include <types.h>
    3333
     34/* We define our own context_set, because we need to set
     35 * the TLS pointer to the tcb+0x7000
     36 *
     37 * See tls_set in thread.h
     38 */
     39#define context_set(c, _pc, stack, size, ptls)                  \
     40        (c)->pc = (sysarg_t) (_pc);                             \
     41        (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA;     \
     42        (c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t);
     43
     44
    3445/* +16 is just for sure that the called function
    3546 * have space to store it's arguments
  • libc/arch/mips32/include/thread.h

    r520492a rc4c5de5  
    3232#define __LIBC__mips32THREAD_H__
    3333
    34 static inline void __tls_set(void *tls)
     34/* I did not find any specification (neither MIPS nor PowerPC), but
     35 * as I found it
     36 * - it uses Variant II
     37 * - TCB is at Address(First TLS Block)+0x7000.
     38 * - DTV is at Address(First TLS Block)+0x8000
     39 * - What would happen if the TLS data was larger then 0x7000?
     40 * - The linker never accesses DTV directly, has the second definition any
     41 *   sense?
     42 * We will make it this way:
     43 * - TCB is at TP-0x7000-sizeof(tcb)
     44 * - No assumption about DTV etc., but it will not have a fixed address
     45 */
     46#define MIPS_TP_OFFSET 0x7000
     47
     48typedef struct {
     49        void *pst_data;
     50} tcb_t;
     51
     52static inline void __tcb_set(tcb_t *tcb)
    3553{
    36         __asm__ volatile ("add $27, %0, $0" : : "r"(tls)); /* Move tls to K1 */
     54        void *tp = tcb;
     55        tp += MIPS_TP_OFFSET + sizeof(tcb_t);
     56
     57        __asm__ volatile ("add $27, %0, $0" : : "r"(tp)); /* Move tls to K1 */
    3758}
    3859
    39 static inline void * __tls_get(void)
     60static inline tcb_t * __tcb_get(void)
    4061{
    4162        void * retval;
    4263
    4364        __asm__ volatile("add %0, $27, $0" : "=r"(retval));
    44         return retval;
     65
     66        return (tcb_t *)(retval - MIPS_TP_OFFSET - sizeof(tcb_t));
    4567}
    4668
Note: See TracChangeset for help on using the changeset viewer.