Skip to contentSkip to conversation

updated asm-sparc/{processor,signal,sigcontext}.h to

PATCH Applied Jeremy Huddleston 3 participants 12 messages Dec 8, 2004 – Dec 28, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 6 lines · Jeremy Huddleston

asm-sparc/signal.h needs:

#include <linux/compiler>

because it uses __user around line 214. Without this include, userland code including asm/signal.h will fail to compile.

I've updated the patch to fix a few more problems with redefined structs, etc when using they are included after glibc headers.

Signature · 1 line
Jeremy Huddleston <[email protected]>
include/asm-sparc/signal.h renamed from include/asm-sparc/signal.h.orig +8 -0
@@ -3,6 +3,7 @@
 #define _ASMSPARC_SIGNAL_H
 
 #include <asm/sigcontext.h>
+#include <linux/compiler.h>
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -113,11 +114,14 @@
 	unsigned long	sig[_NSIG_WORDS];
 } __new_sigset_t;
 
+
+#ifndef _SIGNAL_H
 /* A SunOS sigstack */
 struct sigstack {
 	char *the_stack;
 	int   cur_status;
 };
+#endif
 
 /* Sigvec flags */
 #define _SV_SSTACK    1u    /* This signal handler should use sig-stack */
@@ -191,12 +195,14 @@
 #define SIG_IGN	((__sighandler_t)1)	/* ignore signal */
 #define SIG_ERR	((__sighandler_t)-1)	/* error return from signal */
 
+#ifndef _SIGNAL_H
 struct __new_sigaction {
 	__sighandler_t	sa_handler;
 	unsigned long	sa_flags;
 	void		(*sa_restorer)(void);	/* Not used by Linux/SPARC */
 	__new_sigset_t	sa_mask;
 };
+#endif
 
 #ifdef __KERNEL__
 struct k_sigaction {
@@ -205,6 +211,7 @@
 };
 #endif
 
+#ifndef _SIGNAL_H
 struct __old_sigaction {
 	__sighandler_t	sa_handler;
 	__old_sigset_t	sa_mask;
@@ -217,6 +224,7 @@
 	int		ss_flags;
 	size_t		ss_size;
 } stack_t;
+#endif
 
 #ifdef __KERNEL__
 struct sparc_deliver_cookie {
include/asm-sparc/sigcontext.h renamed from include/asm-sparc/sigcontext.h.orig +7 -4
@@ -4,9 +4,9 @@
 
 #ifdef __KERNEL__
 #include <asm/ptrace.h>
-#endif
 
 #ifndef __ASSEMBLY__
+#ifndef _SIGNAL_H
 
 #define __SUNOS_MAXWIN   31
 
@@ -57,8 +57,6 @@
 	} si_fpqueue [16];
 } __siginfo_fpu_t;
 
-#ifdef __KERNEL__
-
 /* This magic should be in g_upper[0] for all upper parts
    to be valid.
    This is generated by sparc64 only, but for 32bit processes,
@@ -69,8 +67,13 @@
 	unsigned   int o_upper[8];
 } siginfo_extra_v8plus_t;
 
-#endif
+#endif /* !(_SIGNAL_H) */
 
 #endif /* !(__ASSEMBLY__) */
 
+#else /* !(__KERNEL__) */
+#include <signal.h> /* Pulls in <bits/sigcontext.h> which contains both /*
+                    /* of these structures... */
+#endif
+
 #endif /* !(__SPARC_SIGCONTEXT_H) */
include/asm-sparc/processor.h renamed from include/asm-sparc/processor.h.orig +2 -0
@@ -43,10 +43,12 @@
 
 struct task_struct;
 
+#ifndef _SYS_UCONTEXT_H
 struct fpq {
 	unsigned long *insn_addr;
 	unsigned long insn;
 };
+#endif
 
 typedef struct {
 	int seg;
#1 lore raw
Quoted 10 lines · On Wed, 08 Dec 2004 02:53:23 -0800 Jeremy Huddleston <[email protected]>…
Quoted 6 lines · Jeremy Huddleston

asm-sparc/signal.h needs:

#include <linux/compiler>

because it uses __user around line 214. Without this include, userland code including asm/signal.h will fail to compile.

I've updated the patch to fix a few more problems with redefined structs, etc when using they are included after glibc headers.

Please use __KERNEL__ instead of things like _SIGNAL_H Thanks.

#2 lore raw
In reply to Jeremy Huddleston
Quoted 6 lines · On Wed, 08 Dec 2004 21:25:51 -0800 Jeremy Huddleston <[email protected]>…
Quoted 2 lines · David S. Miller

Please use __KERNEL__ instead of things like _SIGNAL_H Thanks.

Ok, I'll keep that in mind for next time. I was just copying the same behavior from asm-x86_64. Do you want me to update/resend the patch?

Please do, I'd like to apply your patch and have this fixed. :-)

#3 lore raw
In reply to Jeremy Huddleston
Quoted 2 lines · David S. Miller

Please use __KERNEL__ instead of things like _SIGNAL_H Thanks.

Ok, I'll keep that in mind for next time. I was just copying the same behavior from asm-x86_64. Do you want me to update/resend the patch?

Signature · 1 line
Jeremy Huddleston <[email protected]>
#4 lore raw
In reply to Jeremy Huddleston
Quoted 4 lines · David S. Miller
Quoted 2 lines

Ok, I'll keep that in mind for next time. I was just copying the same behavior from asm-x86_64. Do you want me to update/resend the patch?

Please do, I'd like to apply your patch and have this fixed. :-)

Ok, here's the updated one. It's much cleaner now, and I also did NOT do asm-x86_64's '#include <signal.h>' if we're !__KERNEL__. I found that to be a rather ugly kludge. It's the userland code that should change there, not us.

Signature · 1 line
Jeremy Huddleston <[email protected]>
include/asm-sparc/processor.h +2 -0
diff -Naur linux-2.6.8.1-vanilla/include/asm-sparc/processor.h linux-2.6.8.1.fixsparc/include/asm-sparc/processor.h
@@ -43,10 +43,12 @@
 
 struct task_struct;
 
+#ifdef __KERNEL__
 struct fpq {
 	unsigned long *insn_addr;
 	unsigned long insn;
 };
+#endif
 
 typedef struct {
 	int seg;
include/asm-sparc/sigcontext.h +3 -5
diff -Naur linux-2.6.8.1-vanilla/include/asm-sparc/sigcontext.h linux-2.6.8.1.fixsparc/include/asm-sparc/sigcontext.h
@@ -4,7 +4,6 @@
 
 #ifdef __KERNEL__
 #include <asm/ptrace.h>
-#endif
 
 #ifndef __ASSEMBLY__
 
@@ -57,8 +56,6 @@
 	} si_fpqueue [16];
 } __siginfo_fpu_t;
 
-#ifdef __KERNEL__
-
 /* This magic should be in g_upper[0] for all upper parts
    to be valid.
    This is generated by sparc64 only, but for 32bit processes,
@@ -69,8 +66,9 @@
 	unsigned   int o_upper[8];
 } siginfo_extra_v8plus_t;
 
-#endif
-
 #endif /* !(__ASSEMBLY__) */
 
+#endif /* (__KERNEL__) */
+
 #endif /* !(__SPARC_SIGCONTEXT_H) */
+
include/asm-sparc/signal.h +5 -3
diff -Naur linux-2.6.8.1-vanilla/include/asm-sparc/signal.h linux-2.6.8.1.fixsparc/include/asm-sparc/signal.h
@@ -3,6 +3,7 @@
 #define _ASMSPARC_SIGNAL_H
 
 #include <asm/sigcontext.h>
+#include <linux/compiler.h>
 
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
@@ -111,11 +112,14 @@
 	unsigned long	sig[_NSIG_WORDS];
 } __new_sigset_t;
 
+
+#ifdef __KERNEL__
 /* A SunOS sigstack */
 struct sigstack {
 	char *the_stack;
 	int   cur_status;
 };
+#endif
 
 /* Sigvec flags */
 #define _SV_SSTACK    1u    /* This signal handler should use sig-stack */
@@ -189,6 +193,7 @@
 #define SIG_IGN	((__sighandler_t)1)	/* ignore signal */
 #define SIG_ERR	((__sighandler_t)-1)	/* error return from signal */
 
+#ifdef __KERNEL__
 struct __new_sigaction {
 	__sighandler_t	sa_handler;
 	unsigned long	sa_flags;
@@ -196,12 +201,10 @@
 	__new_sigset_t	sa_mask;
 };
 
-#ifdef __KERNEL__
 struct k_sigaction {
 	struct __new_sigaction	sa;
 	void			__user *ka_restorer;
 };
-#endif
 
 struct __old_sigaction {
 	__sighandler_t	sa_handler;
@@ -216,7 +219,6 @@
 	size_t		ss_size;
 } stack_t;
 
-#ifdef __KERNEL__
 struct sparc_deliver_cookie {
 	int restart_syscall;
 	unsigned long orig_i0;
#5 lore raw
In reply to Jeremy Huddleston
Quoted 10 lines · On Wed, 08 Dec 2004 22:00:42 -0800 Jeremy Huddleston <[email protected]>…
Quoted 4 lines · David S. Miller
Quoted 2 lines

Ok, I'll keep that in mind for next time. I was just copying the same behavior from asm-x86_64. Do you want me to update/resend the patch?

Please do, I'd like to apply your patch and have this fixed. :-)

Ok, here's the updated one. It's much cleaner now, and I also did NOT do asm-x86_64's '#include <signal.h>' if we're !__KERNEL__. I found that to be a rather ugly kludge. It's the userland code that should change there, not us.

Applied, thanks Jeremy.

#6 lore raw
In reply to Jeremy Huddleston
Quoted 6 lines
Quoted 4 lines

Ok, here's the updated one. It's much cleaner now, and I also did NOT do asm-x86_64's '#include <signal.h>' if we're !__KERNEL__. I found that to be a rather ugly kludge. It's the userland code that should change there, not us.

Applied, thanks Jeremy.

In changing from the glibc check to __KERNEL__, processor.h doesn't work for some userland code. Here's an update to correct this.

Signature · 1 line
Jeremy Huddleston <[email protected]>
asm-sparc/processor.h renamed from asm-sparc/processor.h.orig +9 -3
@@ -44,11 +44,13 @@
 struct task_struct;
 
 #ifdef __KERNEL__
-struct fpq {
+#define __fpq fpq
+#endif
+
+struct __fpq {
 	unsigned long *insn_addr;
 	unsigned long insn;
 };
-#endif
 
 typedef struct {
 	int seg;
@@ -67,13 +69,17 @@ struct thread_struct {
 	unsigned long   float_regs[32] __attribute__ ((aligned (8)));
 	unsigned long   fsr;
 	unsigned long   fpqdepth;
-	struct fpq	fpqueue[16];
+	struct __fpq	fpqueue[16];
 	unsigned long flags;
 	mm_segment_t current_ds;
 	struct exec core_exec;     /* just what it says. */
 	int new_signal;
 };
 
+#ifdef __KERNEL__
+#undef __fpq
+#endif
+
 #define SPARC_FLAG_KTHREAD      0x1    /* task is a kernel thread */
 #define SPARC_FLAG_UNALIGNED    0x2    /* is allowed to do unaligned accesses */
 
#7 lore raw
In reply to Jeremy Huddleston
Quoted 9 lines · On Sat, 11 Dec 2004 16:06:39 -0800 Jeremy Huddleston <[email protected]>…
Quoted 6 lines
Quoted 4 lines

Ok, here's the updated one. It's much cleaner now, and I also did NOT do asm-x86_64's '#include <signal.h>' if we're !__KERNEL__. I found that to be a rather ugly kludge. It's the userland code that should change there, not us.

Applied, thanks Jeremy.

In changing from the glibc check to __KERNEL__, processor.h doesn't work for some userland code. Here's an update to correct this.

I don't think this is too pleasant.

Actually, I can't see much of anything that userland needs to get at inside of processor.h, so why don't you just __KERNEL__ ifdef out nearly the entire file?

#8 lore raw

Re: [PATCH] updated asm-sparc/{processor,signal,sigcontext}.h to behave nicely in userland

In reply to Jeremy Huddleston
Quoted 2 lines · On Sat, 11 Dec 2004 16:06:39 -0800 Jeremy Huddleston <[email protected]>…
Quoted 2 lines

In changing from the glibc check to __KERNEL__, processor.h doesn't work for some userland code. Here's an update to correct this.

Quoted 4 lines · David S. Miller

I don't think this is too pleasant.
Actually, I can't see much of anything that userland needs to get at inside of processor.h, so why don't you just __KERNEL__ ifdef out nearly the entire file?

I'm vaguely disinclined to take fixes for userspace inclusion of kernel headers unless, say, other arches are taking such steps and we would only penalize ourselves by not doing so.

By and large I'd prefer to discourage userspace code from using kernel headers. Does this work in a significant number of other arches as things stand now?

-- wli

#9 lore raw
In reply to Jeremy Huddleston
Quoted 3 lines · On Mon, 27 Dec 2004 19:06:57 -0800 William Lee Irwin III <[email protected]>…

By and large I'd prefer to discourage userspace code from using kernel headers. Does this work in a significant number of other arches as things stand now?

Glibc includes them. It works for sparc64 and a lot of this is painless stuff to include.

#10 lore raw
In reply to Jeremy Huddleston
Quoted 9 lines · David S. Miller
Quoted 3 lines · On Mon, 27 Dec 2004 19:06:57 -0800 William Lee Irwin III <[email protected]>…

By and large I'd prefer to discourage userspace code from using kernel headers. Does this work in a significant number of other arches as things stand now?

Glibc includes them. It works for sparc64 and a lot of this is painless stuff to include.

Yeah, that patch was specifically for glibc. Some other things include them as well... samba comes to mind. I agree that it's good to discourage userland code from using the kernel headers, but in some cases, it's unavoidable.

Signature · 1 line
Jeremy Huddleston <[email protected]>
#11 lore raw

Re: [PATCH] updated asm-sparc/{processor,signal,sigcontext}.h to behave nicely in userland

In reply to Jeremy Huddleston
Quoted 3 lines · On Mon, 27 Dec 2004 19:06:57 -0800 William Lee Irwin III <[email protected]>…
Quoted 3 lines

By and large I'd prefer to discourage userspace code from using kernel headers. Does this work in a significant number of other arches as things stand now?

Quoted 2 lines · David S. Miller

Glibc includes them. It works for sparc64 and a lot of this is painless stuff to include.

As long as I'm not the first to coddle glibc, I guess I can live with it.

-- wli