Changeset 2c2295ab in mainline


Ignore:
Timestamp:
2007-10-28T21:03:02Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8ecba18b
Parents:
941cc8b
Message:

For architectures that make use of TLS variant II (i.e. amd64, ia32 and
sparc64), fix the way TLS and TCB is allocated. Now, TLS is allocated using
memalign() with the alignment specified in _tls_alignment. Size of TLS data
itself is rounded up to be a multiple of _tls_alignment.

Location:
uspace/lib/libc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/arch/amd64/src/thread.c

    r941cc8b r2c2295ab  
    3737#include <thread.h>
    3838#include <malloc.h>
     39#include <align.h>
    3940
    4041/** Allocate TLS & TCB for initial module threads
     
    4748        tcb_t *tcb;
    4849       
    49         *data = malloc(sizeof(tcb_t) + size);
     50        size = ALIGN_UP(size, &_tls_alignment);
     51        *data = memalign(&_tls_alignment, sizeof(tcb_t) + size);
    5052
    5153        tcb = (tcb_t *) (*data + size);
     
    5759void __free_tls_arch(tcb_t *tcb, size_t size)
    5860{
     61        size = ALIGN_UP(size, &_tls_alignment);
    5962        void *start = ((void *)tcb) - size;
    6063        free(start);
  • uspace/lib/libc/arch/sparc64/src/thread.c

    r941cc8b r2c2295ab  
    3737#include <thread.h>
    3838#include <malloc.h>
     39#include <align.h>
    3940
    4041/*
     
    5758        tcb_t *tcb;
    5859       
    59         *data = malloc(sizeof(tcb_t) + size);
     60        size = ALIGN_UP(size, &_tls_alignment);
     61        *data = memalign(&_tls_alignment, sizeof(tcb_t) + size);
    6062
    6163        tcb = (tcb_t *) (*data + size);
     
    7476void __free_tls_arch(tcb_t *tcb, size_t size)
    7577{
     78        size = ALIGN_UP(size, &_tls_alignment);
    7679        void *start = ((void *) tcb) - size;
    7780        free(start);
  • uspace/lib/libc/include/thread.h

    r941cc8b r2c2295ab  
    4242typedef uint64_t thread_id_t;
    4343
     44extern char _tls_alignment;
     45
    4446extern void __thread_entry(void);
    4547extern void __thread_main(uspace_arg_t *uarg);
Note: See TracChangeset for help on using the changeset viewer.