-# $OpenBSD: Makefile.inc,v 1.1 2021/04/29 18:33:36 drahn Exp $
+# $OpenBSD: Makefile.inc,v 1.2 2021/05/04 04:26:00 drahn Exp $
.include <bsd.own.mk>
-CERROR= cerror.S
+# Suppress DWARF2 warnings
+DEBUG?= -gdwarf-4
-/* $OpenBSD: SYS.h,v 1.2 2021/05/02 20:08:49 drahn Exp $ */
+/* $OpenBSD: SYS.h,v 1.3 2021/05/04 04:26:00 drahn Exp $ */
/*-
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
* Copyright (c) 1990 The Regents of the University of California.
#include "DEFS.h"
#include <sys/syscall.h>
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO (-12)
+
+/* offset of errno from tp */
+#define TP_OFFSET_ERRNO TCB_OFFSET_ERRNO
+
#define SYSENTRY(x) \
.weak _C_LABEL(x); \
_C_LABEL(x) = _C_LABEL(_thread_sys_ ## x); \
li t0, SYS_ ## x; \
ecall
-#define CERROR _C_LABEL(__cerror)
#define HANDLE_ERROR() \
- beqz t0, 2f; \
-1: auipc t0, %got_pcrel_hi(CERROR); \
- ld t1, %pcrel_lo(1b)(t0); \
- jr t1; \
-2:
+ beqz t0, 200f; \
+ sw a0, TP_OFFSET_ERRNO(tp); \
+ li a0, -1; \
+200:
+
+#define HANDLE_ERROR_TARGET(target) \
+ beqz t0, 200f; \
+ sw a0, TP_OFFSET_ERRNO(tp); \
+ li a0, -1; \
+ j target; \
+200:
#define _SYSCALL_NOERROR(x,y) \
SYSENTRY(x); \
SYSTRAP(y)
#define _SYSCALL(x, y) \
_SYSCALL_NOERROR(x,y); \
- HANDLE_ERROR
+ HANDLE_ERROR() \
#define _SYSCALL_HIDDEN(x, y) \
_SYSCALL_HIDDEN_NOERROR(x,y); \
- HANDLE_ERROR
+ HANDLE_ERROR() \
#define SYSCALL_NOERROR(x) \
_SYSCALL_NOERROR(x,x)
__END(x)
#define SYSCALL_END_HIDDEN(x) \
__END_HIDDEN(x)
-
- .globl CERROR
+++ /dev/null
-/* $OpenBSD: cerror.S,v 1.1 2021/04/29 18:33:36 drahn Exp $ */
-/*-
- * Copyright (c) 2020 Mars Li <mengshi.li.mars@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "SYS.h"
-
-/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
-#define TCB_OFFSET_ERRNO (-12)
-
-_ENTRY(CERROR)
- RETGUARD_SETUP(CERROR, t6)
- sw a0, TCB_OFFSET_ERRNO(tp)
- li a0, -1
- RETGUARD_CHECK(CERROR, t6)
- ret
-END(CERROR)
-/* $OpenBSD: sigpending.S,v 1.1 2021/04/29 18:33:36 drahn Exp $ */
+/* $OpenBSD: sigpending.S,v 1.2 2021/05/04 04:26:00 drahn Exp $ */
/*
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
* All rights reserved.
RETGUARD_SETUP(sigpending, t6)
mv a2, a0
SYSTRAP(sigpending)
- HANDLE_ERROR()
+ HANDLE_ERROR_TARGET(1f)
sw a0, 0(a2) /* 4 bytes */
mv a0, x0
+1:
RETGUARD_CHECK(sigpending, t6)
ret
SYSCALL_END(sigpending)
-/* $OpenBSD: sigprocmask.S,v 1.1 2021/04/29 18:33:36 drahn Exp $ */
+/* $OpenBSD: sigprocmask.S,v 1.2 2021/05/04 04:26:00 drahn Exp $ */
/*
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
* All rights reserved.
2:
SYSTRAP(sigprocmask)
- HANDLE_ERROR()
+ HANDLE_ERROR_TARGET(3f)
beqz a2, 1f
sw a0, (a2)
1:
- mv a0, x0
+ li a0, 0
+3:
RETGUARD_CHECK(sigprocmask, t6)
ret
SYSCALL_END_HIDDEN(sigprocmask)
-/* $OpenBSD: sigsuspend.S,v 1.1 2021/04/29 18:33:36 drahn Exp $ */
+/* $OpenBSD: sigsuspend.S,v 1.2 2021/05/04 04:26:00 drahn Exp $ */
/*
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
* All rights reserved.
RETGUARD_SETUP(sigsuspend, t6)
lw a0, (a0)
SYSTRAP(sigsuspend)
- HANDLE_ERROR()
+ HANDLE_ERROR_TARGET(1f)
li a0, 0
+1:
RETGUARD_CHECK(sigsuspend, t6)
ret
SYSCALL_END_HIDDEN(sigsuspend)
-/* $OpenBSD: tfork_thread.S,v 1.1 2021/04/29 18:33:36 drahn Exp $ */
+/* $OpenBSD: tfork_thread.S,v 1.2 2021/05/04 04:26:00 drahn Exp $ */
/*
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
* All rights reserved.
ENTRY(__tfork_thread)
RETGUARD_SETUP(__tfork_thread, t6)
SYSTRAP(__tfork)
- HANDLE_ERROR()
+ HANDLE_ERROR_TARGET(2f)
beqz a0, 1f
/* parent thread */
+2:
RETGUARD_CHECK(__tfork_thread, t6)
ret