SYS.h (3e492f6e) SYS.h (83762a71)
1/* $OpenBSD: SYS.h,v 1.2 2022/09/02 06:19:05 miod Exp $ */
1/* $OpenBSD: SYS.h,v 1.3 2023/12/10 16:45:50 deraadt Exp $ */
2
3/*
4 * Copyright (c) 2006 Dale Rahn
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <machine/asm.h>
30#include <sys/syscall.h>
31
2
3/*
4 * Copyright (c) 2006 Dale Rahn
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <machine/asm.h>
30#include <sys/syscall.h>
31
32#define PINSYSCALL(sysno, label) \
33 .pushsection .openbsd.syscalls,"",@progbits ;\
34 .long label ;\
35 .long sysno ;\
36 .popsection
37
32#ifdef __ASSEMBLER__
33/*
34 * If the system call number fits in a 8-bit signed value (i.e. fits in 7 bits),
35 * then we can use the #imm8 addressing mode.
36 */
37
38.macro systrap num
39.iflt \num - 128
40 mov # \num, r0
38#ifdef __ASSEMBLER__
39/*
40 * If the system call number fits in a 8-bit signed value (i.e. fits in 7 bits),
41 * then we can use the #imm8 addressing mode.
42 */
43
44.macro systrap num
45.iflt \num - 128
46 mov # \num, r0
41 trapa #0x80
4799: trapa #0x80
48 PINSYSCALL(\num, 99b)
42.else
43 mov.l 903f, r0
49.else
50 mov.l 903f, r0
44 trapa #0x80
5199: trapa #0x80
52 PINSYSCALL(\num, 99b)
45 bra 904f
46 nop
47 .align 2
48 903: .long \num
49 904:
50.endif
51.endm
52#endif
53
53 bra 904f
54 nop
55 .align 2
56 903: .long \num
57 904:
58.endif
59.endm
60#endif
61
54#define SYSTRAP(x) \
55 systrap SYS_ ## x
62#define SYSTRAP(x) \
63 systrap SYS_ ## x
56
64
57#define DL_SYSCALL(n) \
58 .global __CONCAT(_dl_,n) ;\
59 .type __CONCAT(_dl_,n)%function ;\
60__CONCAT(_dl_,n): ;\
61 SYSTRAP(n) ;\
62 bf .L_cerr ;\
63 nop ;\
64 rts ;\
65#define DL_SYSCALL(n) \
66 .global __CONCAT(_dl_,n) ;\
67 .type __CONCAT(_dl_,n)%function ;\
68__CONCAT(_dl_,n): ;\
69 SYSTRAP(n) ;\
70 bf .L_cerr ;\
71 nop ;\
72 rts ;\
65 nop
66
67.L_cerr:
68 neg r0, r0
69 rts
70 nop
73 nop
74
75.L_cerr:
76 neg r0, r0
77 rts
78 nop