From 30d2fa573ddb591831cf834353b798891e24295a Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 3 Jun 2019 20:41:28 +0200
Subject: [PATCH 2/4] <sys/signal.h>: Adjust the type of stack_t's ss_sp from
 char * to void *.

---
 lib/libc/sys/sigaltstack.2               | 4 ++--
 lib/libc/x86_64/gen/makecontext.c        | 2 +-
 lib/libc/x86_64/gen/quickcontext.c       | 3 ++-
 sys/platform/pc64/x86_64/machdep.c       | 4 ++--
 sys/platform/vkernel64/x86_64/cpu_regs.c | 4 ++--
 sys/sys/signal.h                         | 2 +-
 6 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/libc/sys/sigaltstack.2 b/lib/libc/sys/sigaltstack.2
index ebf3057cf5..0aed6ad4e7 100644
--- a/lib/libc/sys/sigaltstack.2
+++ b/lib/libc/sys/sigaltstack.2
@@ -28,7 +28,7 @@
 .\"     @(#)sigaltstack.2	8.2 (Berkeley) 5/1/95
 .\" $FreeBSD: src/lib/libc/sys/sigaltstack.2,v 1.11.2.7 2002/09/15 00:32:41 archie Exp $
 .\"
-.Dd February 22, 2018
+.Dd June 3, 2019
 .Dt SIGALTSTACK 2
 .Os
 .Sh NAME
@@ -40,7 +40,7 @@
 .In signal.h
 .Bd -literal
 typedef struct sigaltstack {
-        char    *ss_sp;
+        void    *ss_sp;
         size_t  ss_size;
         int     ss_flags;
 } stack_t;
diff --git a/lib/libc/x86_64/gen/makecontext.c b/lib/libc/x86_64/gen/makecontext.c
index aa7b69b818..80078d4b4a 100644
--- a/lib/libc/x86_64/gen/makecontext.c
+++ b/lib/libc/x86_64/gen/makecontext.c
@@ -81,7 +81,7 @@ _makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
 	if (ucp->uc_mcontext.mc_len == sizeof(mcontext_t)) {
 		/*
 		 */
-		stack_top = (uint64_t *)(ucp->uc_stack.ss_sp +
+		stack_top = (uint64_t *)((char *)ucp->uc_stack.ss_sp +
                                          ucp->uc_stack.ss_size);
 		stack_top = (uint64_t *)((uint64_t)(stack_top) & ~15UL);
 
diff --git a/lib/libc/x86_64/gen/quickcontext.c b/lib/libc/x86_64/gen/quickcontext.c
index 1f7db28d5b..ff1abf8f71 100644
--- a/lib/libc/x86_64/gen/quickcontext.c
+++ b/lib/libc/x86_64/gen/quickcontext.c
@@ -70,7 +70,8 @@ _makecontext_quick(ucontext_t *ucp)
 	ucp->uc_link = NULL;
 	ucp->uc_mcontext.mc_len = sizeof(mcontext_t);
 
-	stack_top = (uint64_t *)(ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
+	stack_top =
+	    (uint64_t *)((char *)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
 	stack_top = (uint64_t *)((uint64_t)(stack_top) & ~63UL);
 	stack_top -= 1;
 
diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c
index 17cd25590e..18395d135d 100644
--- a/sys/platform/pc64/x86_64/machdep.c
+++ b/sys/platform/pc64/x86_64/machdep.c
@@ -760,8 +760,8 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
 	/* Allocate and validate space for the signal handler context. */
         if ((lp->lwp_flags & LWP_ALTSTACK) != 0 && !oonstack &&
 	    SIGISMEMBER(psp->ps_sigonstack, sig)) {
-		sp = (char *)(lp->lwp_sigstk.ss_sp + lp->lwp_sigstk.ss_size -
-			      sizeof(struct sigframe));
+		sp = (char *)lp->lwp_sigstk.ss_sp + lp->lwp_sigstk.ss_size -
+		    sizeof(struct sigframe);
 		lp->lwp_sigstk.ss_flags |= SS_ONSTACK;
 	} else {
 		/* We take red zone into account */
diff --git a/sys/platform/vkernel64/x86_64/cpu_regs.c b/sys/platform/vkernel64/x86_64/cpu_regs.c
index bde09d6939..03136405fa 100644
--- a/sys/platform/vkernel64/x86_64/cpu_regs.c
+++ b/sys/platform/vkernel64/x86_64/cpu_regs.c
@@ -182,8 +182,8 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
 	/* Allocate and validate space for the signal handler context. */
         if ((lp->lwp_flags & LWP_ALTSTACK) != 0 && !oonstack &&
 	    SIGISMEMBER(psp->ps_sigonstack, sig)) {
-		sp = (char *)(lp->lwp_sigstk.ss_sp + lp->lwp_sigstk.ss_size -
-			      sizeof(struct sigframe));
+		sp = (char *)lp->lwp_sigstk.ss_sp + lp->lwp_sigstk.ss_size -
+		    sizeof(struct sigframe);
 		lp->lwp_sigstk.ss_flags |= SS_ONSTACK;
 	} else {
 		/* We take red zone into account */
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index c17004add0..6125456124 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -335,7 +335,7 @@ typedef	struct sigaltstack {
 #else
 typedef	struct {
 #endif
-	char	*ss_sp;			/* signal stack base */
+	void	*ss_sp;			/* signal stack base */
 	__size_t ss_size;		/* signal stack length */
 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
 } stack_t;
-- 
2.21.0

