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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [alpha/] [clone.S] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
   Contributed by Richard Henderson , 1996.
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
/* clone() is even more special than fork() as it mucks with stacks
21
   and invokes a function in the right context after its all over.  */
22
 
23
#include 
24
#define _ERRNO_H        1
25
#include 
26
 
27
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
28
 
29
#define a0  $16
30
#define a1  $17
31
#define a2  $18
32
#define a3  $19
33
#define v0  $0
34
#define fp  $15
35
#define gp  $29
36
#define ra  $26
37
#define pv  $27
38
#define zero  $31
39
 
40
        .text
41
.globl  __clone;
42
.align 3;
43
.ent  __clone , 0;
44
 
45
__clone:
46
        .frame $30 , 0, $26
47
#ifdef PROF
48
        ldgp    gp,0(pv)
49
        .set noat
50
        lda     AT, _mcount
51
        jsr     AT, (AT), _mcount
52
        .set at
53
        .prologue 1
54
#else
55
        .prologue 0
56
#endif
57
 
58
        /* Sanity check arguments.  */
59
        ldiq    v0,EINVAL
60
        beq     a0,$error               /* no NULL function pointers */
61
        beq     a1,$error               /* no NULL stack pointers */
62
 
63
        /* Save the fn ptr and arg on the new stack.  */
64
        subq    a1,16,a1
65
        stq     a0,0(a1)
66
        stq     a3,8(a1)
67
 
68
        /* Do the system call */
69
        mov     a2,a0
70
        ldiq    v0,__NR_clone
71
        call_pal 131
72
 
73
        bne     a3,$error
74
        beq     v0,thread_start
75
 
76
        /* Successful return from the parent */
77
        ret
78
 
79
        /* Something bad happened -- no child created */
80
$error:
81
#ifndef PROF
82
        br      gp,1f
83
1:      ldgp    gp,0(gp)
84
#endif
85
        jmp     zero,__syscall_error
86
 
87
.end __clone
88
 
89
/* Load up the arguments to the function.  Put this block of code in
90
   its own function so that we can terminate the stack trace with our
91
   debug info.  */
92
 
93
        .ent thread_start
94
thread_start:
95
        .frame fp,0,zero,0
96
        mov     zero,fp
97
        .prologue 0
98
 
99
        /* Load up the arguments.  */
100
        ldq     pv,0($30)
101
        ldq     a0,8($30)
102
        addq    $30,16,$30
103
 
104
        /* Call the user's function */
105
        jsr     ra,(pv)
106
        ldgp    gp,0(ra)
107
 
108
        /* Call _exit rather than doing it inline for breakpoint purposes */
109
        mov     v0,a0
110
        jsr     ra,_exit
111
 
112
        /* Die horribly.  */
113
        halt
114
 
115
        .end thread_start
116
 
117
.weak    clone;
118
    clone    =   __clone
119
 

powered by: WebSVN 2.1.0

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