This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [SH][PATCH] fix headers for new kernel headers


I tried Andrew's patch. It worked for compiling glibc itself, but
'struct user' is needed for compile native gdb. So I modified the patch as follows
and then succeeded.

I tried your patch and it did not work for me. The problem is that including asm/ptrace.h polutes the namespace and prevents use of ptrace.h from glibc.


This patch is a combination of the two patches, with fixes for my problems.

This patch includes some #undef directives to sort out the namespace clashes. I know there were objections to this idea when I posted something like this before, but really, I can't find a better solution. It may be better to patch the kernel headers, but, in reality, people don't (can't) always use the latest kernel, and it's much better to fix glibc to work with all recent kernels anyway.

If I don't use asm/ptrace.h then I have to copy pretty much the entire contents into glibc, but if I do use asm/ptrace.h there are a few problem macros which aren't going to just go away.

There's a precident for doing this; sparc has the same problem.

Hopefully I've also fixed all the formatting issues.

Please approve and apply this version.

Andrew
2009-02-25  Andrew Stubbs  <ams@codesourcery.com>
	    SUGIOKA Toshinobu  <sugioka@itonet.co.jp>

	* sysdeps/unix/sysv/linux/sh/sys/procfs.h: Don't include signal.h,
	sys/ucontext.h, and asm/elf.h.
	Include sys/user.h.
	* sysdeps/unix/sysv/linux/sh/sys/user.h: Don't include features.h and
	asm/user.h.
	Include asm/ptrace.h.
	(PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS,
	PTRACE_SETFPREGS, PTRACE_GETFDPIC, PTRACE_GETFDPIC_EXEC,
	PTRACE_GETFDPIC_INTERP, PTRACE_GETDSPREGS,
	PTRACE_SETDSPREGS): Undefine.
	Don't undef start_thread.
	(elf_greg_t, ELF_NGREG): Copy from linux asm-sh/elf.h.
	(elf_fpregset_t): Copy from linux asm-sh/elf.h.
	(user_fpu_struct, user): Copy from linux asm-sh/elf.h.


---
 src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/procfs.h |    5 -
 src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/user.h   |   47 +++++++++++-
 2 files changed, 45 insertions(+), 7 deletions(-)

Index: src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/procfs.h
===================================================================
--- src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/procfs.h.orig
+++ src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/procfs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1999, 2004, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -24,12 +24,9 @@
    used on Linux.  */
 
 #include <features.h>
-#include <signal.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <sys/ucontext.h>
 #include <sys/user.h>
-#include <asm/elf.h>
 
 __BEGIN_DECLS
 
Index: src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/user.h
===================================================================
--- src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/user.h.orig
+++ src/glibc-mainline/sysdeps/unix/sysv/linux/sh/sys/user.h
@@ -19,10 +19,51 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
-#include <features.h>
+#include <asm/ptrace.h>
 
-#include <asm/user.h>
+/* asm/ptrace.h polutes the namespace.  */
+#undef PTRACE_GETREGS
+#undef PTRACE_SETREGS
+#undef PTRACE_GETFPREGS
+#undef PTRACE_SETFPREGS
+#undef PTRACE_GETFDPIC
+#undef PTRACE_GETFDPIC_EXEC
+#undef PTRACE_GETFDPIC_INTERP
+#undef	PTRACE_GETDSPREGS
+#undef	PTRACE_SETDSPREGS
 
-#undef start_thread
+typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof (struct pt_regs) / sizeof (elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+struct user_fpu_struct
+  {
+    unsigned long fp_regs[16];
+    unsigned long xfp_regs[16];
+    unsigned long fpscr;
+    unsigned long fpul;
+  };
+typedef struct user_fpu_struct elf_fpregset_t;
+
+struct user
+  {
+    struct pt_regs		regs;		/* entire machine state */
+    struct user_fpu_struct	fpu;		/* Math Co-processor
+						   registers  */
+    int				u_fpvalid;	/* True if math co-processor
+						   being used */
+    size_t			u_tsize;	/* text size (pages) */
+    size_t			u_dsize;	/* data size (pages) */
+    size_t			u_ssize;	/* stack size (pages) */
+    unsigned long		start_code;	/* text starting address */
+    unsigned long		start_data;	/* data starting address */
+    unsigned long		start_stack;	/* stack starting address */
+    long int			signal;		/* signal causing core dump */
+    unsigned long		u_ar0;		/* help gdb find registers */
+    struct user_fpu_struct	*u_fpstate;	/* Math Co-processor pointer */
+    unsigned long		magic;		/* identifies a core file */
+    char			u_comm[32];	/* user command name */
+  };
 
 #endif  /* sys/user.h */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]