OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [tools/] [riscv-gnu-toolchain-master/] [glibc/] [sysdeps/] [riscv/] [nptl/] [sysdep-cancel.h] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
 
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
 
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Lesser General Public License for more details.
13
 
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, write to the Free
16
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17
   02111-1307 USA.  */
18
 
19
#include <sysdep.h>
20
#include <sysdeps/generic/sysdep.h>
21
#include <tls.h>
22
#ifndef __ASSEMBLER__
23
# include <nptl/pthreadP.h>
24
#endif
25
#include <sys/asm.h>
26
 
27
/* Gas will put the initial save of $gp into the CIE, because it appears to
28
   happen before any instructions.  So we use cfi_same_value instead of
29
   cfi_restore.  */
30
 
31
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
32
 
33
# undef PSEUDO
34
# define PSEUDO(name, syscall_name, args)                               \
35
      .align 2;                                                         \
36
  L(pseudo_start):                                                      \
37
  99: j __syscall_error;                                                \
38
  ENTRY (name)                                                          \
39
    SINGLE_THREAD_P(t0);                                                \
40
    bnez t0, L(pseudo_cancel);                                          \
41
  .type __##syscall_name##_nocancel, @function;                         \
42
  .globl __##syscall_name##_nocancel;                                   \
43
  __##syscall_name##_nocancel:                                          \
44
    li a7, SYS_ify(syscall_name);                                       \
45
    scall;                                                              \
46
    bltz a0, 99b;                                                       \
47
    ret;                                                                \
48
  .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;      \
49
  L(pseudo_cancel):                                                     \
50
    addi sp, sp, -STKSPACE;                                             \
51
    REG_S ra, STKOFF_RA(sp);                                            \
52
    cfi_rel_offset (ra, STKOFF_RA);                                     \
53
    PUSHARGS_##args;                    /* save syscall args */         \
54
    CENABLE;                                                            \
55
    REG_S a0, STKOFF_SVMSK(sp);         /* save mask */                 \
56
    POPARGS_##args;                     /* restore syscall args */      \
57
    li a7, SYS_ify (syscall_name);                                      \
58
    scall;                                                              \
59
    REG_S a0, STKOFF_A0(sp);            /* save syscall result */       \
60
    REG_L a0, STKOFF_SVMSK(sp);         /* pass mask as arg1 */         \
61
    CDISABLE;                                                           \
62
    REG_L ra, STKOFF_RA(sp);            /* restore return address */    \
63
    REG_L a0, STKOFF_A0(sp);            /* restore syscall result */    \
64
    addi sp, sp, STKSPACE;                                              \
65
    bltz a0, 99b;                                                       \
66
  L(pseudo_end):
67
 
68
 
69
# define PUSHARGS_0     /* nothing to do */
70
# define PUSHARGS_1     PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0);
71
# define PUSHARGS_2     PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1);
72
# define PUSHARGS_3     PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2);
73
# define PUSHARGS_4     PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3);
74
# define PUSHARGS_5     PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a4, STKOFF_A4);
75
# define PUSHARGS_6     PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a5, STKOFF_A5);
76
 
77
# define POPARGS_0      /* nothing to do */
78
# define POPARGS_1      POPARGS_0 REG_L a0, STKOFF_A0(sp);
79
# define POPARGS_2      POPARGS_1 REG_L a1, STKOFF_A1(sp);
80
# define POPARGS_3      POPARGS_2 REG_L a2, STKOFF_A2(sp);
81
# define POPARGS_4      POPARGS_3 REG_L a3, STKOFF_A3(sp);
82
# define POPARGS_5      POPARGS_4 REG_L a4, STKOFF_A4(sp);
83
# define POPARGS_6      POPARGS_5 REG_L a5, STKOFF_A5(sp);
84
 
85
/* Avoid D$ misses by keeping less-used arguments further down stack.  */
86
# define STKOFF_A5      0
87
# define STKOFF_A4      (STKOFF_A5 + SZREG)
88
# define STKOFF_A3      (STKOFF_A4 + SZREG)
89
# define STKOFF_A2      (STKOFF_A3 + SZREG)
90
# define STKOFF_A1      (STKOFF_A2 + SZREG)
91
# define STKOFF_A0      (STKOFF_A1 + SZREG)
92
# define STKOFF_SVMSK   (STKOFF_A0 + SZREG)
93
# define STKOFF_RA      (STKOFF_SVMSK + SZREG)
94
# define STKSPACE       (STKOFF_RA + SZREG)
95
 
96
# if IS_IN (libpthread)
97
#  define CENABLE  call __pthread_enable_asynccancel
98
#  define CDISABLE call __pthread_disable_asynccancel
99
# elif IS_IN (librt)
100
#  define CENABLE  call __librt_enable_asynccancel
101
#  define CDISABLE call __librt_disable_asynccancel
102
# else
103
#  define CENABLE  call __libc_enable_asynccancel
104
#  define CDISABLE call __libc_disable_asynccancel
105
# endif
106
 
107
# ifndef __ASSEMBLER__
108
#  define SINGLE_THREAD_P                                               \
109
        __builtin_expect (THREAD_GETMEM (THREAD_SELF,                   \
110
                                         header.multiple_threads)       \
111
                          == 0, 1)
112
# else
113
#  include "tcb-offsets.h"
114
#  define SINGLE_THREAD_P(reg)                                          \
115
        lw reg, MULTIPLE_THREADS_OFFSET(tp)
116
#endif
117
 
118
#elif !defined __ASSEMBLER__
119
 
120
# define SINGLE_THREAD_P 1
121
# define NO_CANCELLATION 1
122
 
123
#endif
124
 
125
#ifndef __ASSEMBLER__
126
# define RTLD_SINGLE_THREAD_P \
127
  __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
128
                                   header.multiple_threads) == 0, 1)
129
#endif

powered by: WebSVN 2.1.0

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