summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/mips/fork.S
blob: 6d2b33dba45af2a2d56537582c1eec8c34e27463 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <features.h>

#define ALIGN   2

/* Note: .abicalls goes at top of routine, and only one of them. */
#if defined(USER_ABICALLS)
#define ABISETUP                                \
        .set    noreorder;                      \
        .cpload t9;                             \
        .set    reorder;

        .abicalls
#else
#define ABISETUP
#endif

#ifndef __UCLIBC_USE_UNIFIED_SYSCALL__
#define SYSCALL__(name)                         \
        .text;                                  \
        .align  ALIGN;                          \
        .globl  name;                           \
        .ent    name, 0;                        \
  name: ;                                       \
        ABISETUP                                \
        li      v0, __NR_##name ;               \
        syscall;                                \
        la      t3, errno;                      \
        beqz    a3, 1f;                         \
        negu    a1, v0;                         \
        sw      a1, 0(t3);                      \
        li      v0, -1;                         \
  1: ;                                          \
        j ra;                                   \
        .end    name;                           \
        .size   name,.-name;
#else   /* Unified syscall */
#define SYSCALL__(name)                         \
        .text;                                  \
/*      .align  ALIGN;*/                        \
        .globl  name;                           \
        .ent    name, 0;                        \
  name: ;                                       \
        ABISETUP                                \
        .set    push;                           \
        .set    noreorder;                      \
        j       __uClibc_syscall;               \
        addiu   v0, zero, __NR_##name ;         \
        .set    pop;                            \
        .end    name;                           \
        .size   name,.-name;
#endif  /* __UCLIBC_USE_UNIFIED_SYSCALL__ */

#undef ALIGN
#define __ASSEMBLY__
#include <asm/asm.h>
#include <asm/unistd.h>
#include <asm/mipsregs.h>
#include <asm/regdef.h>
/* #include <asm/stackframe.h> */

#undef ALIGN
#define ALIGN   2
#define _SYSCALL0(type,name)    SYSCALL__(name)
_SYSCALL0(pid_t, fork);