summaryrefslogtreecommitdiff
path: root/mit-pthreads/machdep/syscall-sparc-sunos4.S
blob: ec293b0ca3f58e29c5f6ed6f7279d300bbd104b4 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* ==== syscall.S ============================================================
 * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
 * All rights reserved.
 *
 */

#ifndef lint
	.text
	.asciz "$Id$";
#endif
 
#include <sys/syscall.h>

#define	SYSCALL(x)					\
	.globl _machdep_sys_##x;		\
									\
_machdep_sys_##x:;					\
									\
	mov SYS_##x, %g1;   			\
	ta 0;							\
	bcs,a 2b;						\
	sub %r0,%o0,%o0;				\
	retl							


/*
 * Initial asm stuff for all functions.
 */
	.text
	.align	4

/* ==========================================================================
 * error code for all syscalls. The error value is returned as the negative
 * of the errno value.
 */

1:
	sub		%r0, %o0, %o0
2:
	retl
	nop

/* ==========================================================================
 * machdep_sys_pipe()
 */
    .globl _machdep_sys_pipe

_machdep_sys_pipe:
    mov  %o0, %o2
    mov  SYS_pipe, %g1
    ta  0
    bcs 1b
    nop
    st  %o0, [ %o2 ]
    st  %o1, [ %o2 + 4 ]
    retl 
    mov  %g0, %o0

/* ==========================================================================
 * machdep_sys_fork()
 */
    .globl _machdep_sys_fork;

_machdep_sys_fork:;

    mov SYS_fork, %g1;
    ta 0;
    bcs 1b;
    nop;
    tst %o1
    bne,a __fork_parent
    mov  %g0, %o0
__fork_parent:;
    retl

/* POSIX-compliant getpgrp() takes no arguments.  The SunOS syscall wants
   one, and gives the POSIXy result if that argument is zero.  */
	.globl _getpgrp
_getpgrp:
	mov SYS_getpgrp, %g1
	mov 0, %i0
	ta 0
	bcs 1b
	nop
	retl
	nop

#if 0
/* I think this bit of magic will do the right thing for other syscalls.
   We get here with the new `errno' code in %o0.  It should get stored in
   *__error(), and -1 returned to the caller.  */
	.globl cerror
cerror:
	save %sp,-104,%sp
	/* Now value is in %i0.  Store it in *__error().  */
	call ___error
	nop
	st %i0,[%o0]

	/* Now also store a copy in global variable errno, for routines
	   like isatty that want to examine it and which haven't been
	   converted yet.  */
	sethi %hi(_errno), %o0
	st %i0,[%o0+%lo(_errno)]

#if 0 /* use this if you want -errno returned */
	sub %r0,%i0,%i0
#else /* return -1 */
	mov -1,%i0
#endif
	retl
	restore
#endif