OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libpthread/] [linuxthreads/] [sysdeps/] [sh/] [tls.h] - Blame information for rev 1325

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Definition for thread-local data handling.  linuxthreads/SH version.
2
   Copyright (C) 2002 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Lesser General Public
7
   License as published by the Free Software Foundation; either
8
   version 2.1 of the License, or (at your option) any later version.
9
 
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Lesser General Public License for more details.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   02111-1307 USA.  */
19
 
20
#ifndef _TLS_H
21
#define _TLS_H
22
 
23
#ifndef __ASSEMBLER__
24
#include <stddef.h>
25
 
26
#include <pt-machine.h>
27
 
28
/* Type for the dtv.  */
29
typedef union dtv
30
{
31
  size_t counter;
32
  void *pointer;
33
} dtv_t;
34
 
35
 
36
typedef struct
37
{
38
  void *tcb;            /* Pointer to the TCB.  Not necessary the
39
                           thread descriptor used by libpthread.  */
40
  dtv_t *dtv;
41
  void *self;           /* Pointer to the thread descriptor.  */
42
} tcbhead_t;
43
 
44
 
45
/* We can support TLS only if the floating-stack support is available.  */
46
#if defined FLOATING_STACKS && defined HAVE_TLS_SUPPORT
47
 
48
/* Get system call information.  */
49
# include <sysdep.h>
50
 
51
/* Signal that TLS support is available.  */
52
//# define USE_TLS      1
53
 
54
 
55
/* Get the thread descriptor definition.  */
56
# include <linuxthreads/descr.h>
57
 
58
/* This is the size of the initial TCB.  */
59
# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
60
 
61
/* Alignment requirements for the initial TCB.  */
62
# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
63
 
64
/* This is the size of the TCB.  */
65
# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
66
 
67
/* Alignment requirements for the TCB.  */
68
# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
69
 
70
/* The TLS blocks start right after the TCB.  */
71
# define TLS_DTV_AT_TP  1
72
 
73
 
74
/* Install the dtv pointer.  The pointer passed is to the element with
75
   index -1 which contain the length.  */
76
# define INSTALL_DTV(descr, dtvp) \
77
  ((tcbhead_t *) (descr))->dtv = dtvp + 1
78
 
79
/* Install new dtv for current thread.  */
80
# define INSTALL_NEW_DTV(dtv) \
81
  ({ struct _pthread_descr_struct *__descr;                                   \
82
     THREAD_SETMEM (__descr, p_header.data.dtvp, (dtv)); })
83
 
84
/* Return dtv of given thread descriptor.  */
85
# define GET_DTV(descr) \
86
  (((tcbhead_t *) (descr))->dtv)
87
 
88
/* Code to initially initialize the thread pointer.  This might need
89
   special attention since 'errno' is not yet available and if the
90
   operation can cause a failure 'errno' must not be touched.  */
91
# define TLS_INIT_TP(descr, secondcall) \
92
  ({                                                                          \
93
    void *_descr = (descr);                                                   \
94
    int result;                                                               \
95
    tcbhead_t *head = _descr;                                                 \
96
                                                                              \
97
    head->tcb = _descr;                                                       \
98
    /* For now the thread descriptor is at the same address.  */              \
99
    head->self = _descr;                                                      \
100
                                                                              \
101
    asm ("ldc %0,gbr" : : "r" (_descr));                                      \
102
                                                                              \
103
    0;                                                                         \
104
  })
105
 
106
 
107
/* Return the address of the dtv for the current thread.  */
108
# define THREAD_DTV() \
109
  ({ struct _pthread_descr_struct *__descr;                                   \
110
     THREAD_GETMEM (__descr, p_header.data.dtvp); })
111
 
112
#endif  /* FLOATING_STACKS && HAVE_TLS_SUPPORT */
113
#endif /* __ASSEMBLER__ */
114
 
115
#endif  /* tls.h */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.