lkml.org 
[lkml]   [2000]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectexporting struct offsets to assembler
This is a little proof-of-concept RFC thing.  It demonstrates a
way to get rid of the magical task_struct structure offsets
in entry.S (and other places), so things won't break if the
structure layout (or compiler) changes.

It uses some compiler tricks to export the structure offset
into a global absolute symbol and uses that symbol in the
assembly code.

This _should_ be arch-independent, but there is one potential
drawback: Some architectures (eg 68k) will produce better
code with

movl 8(a0),d0

than with

.globl some_label
movl some_label(a0),d0


This can be avoided if the assembler is smart enough with

move some_label:b(a0),d0

but I don't know if gas does that.



--- linux-2.4.0-test6-pre2/kernel/ksyms.c Sun Jul 30 02:28:18 2000
+++ linux-akpm/kernel/ksyms.c Sat Aug 5 12:09:15 2000
@@ -540,3 +540,21 @@

EXPORT_SYMBOL(tasklist_lock);
EXPORT_SYMBOL(pidhash);
+
+
+#define OFFSETOF(struct_name, item) ((unsigned long)&(((struct struct_name *)0)->item))
+
+#define EXPORT_ASM_CONSTANT(asm_label, value) \
+ __asm__ __volatile__("\t.equ " #asm_label ",%c0" :: "i" (value) ); \
+ __asm__ __volatile__("\t.globl " #asm_label)
+
+#define EXPORT_ASM_STRUCT_OFFSET(asm_label, struct_name, item) \
+ EXPORT_ASM_CONSTANT(asm_label, OFFSETOF(struct_name, item))
+
+
+static void wrapper()
+{
+ EXPORT_ASM_STRUCT_OFFSET(TS_SIGPENDING, task_struct, sigpending);
+ EXPORT_ASM_STRUCT_OFFSET(TS_NEED_RESCHED, task_struct, need_resched);
+}
+
--- linux-2.4.0-test6-pre2/arch/i386/kernel/entry.S Tue Jul 11 22:21:12 2000
+++ linux-akpm/arch/i386/kernel/entry.S Sat Aug 5 12:11:20 2000
@@ -73,10 +73,8 @@
*/
state = 0
flags = 4
-sigpending = 8
addr_limit = 12
exec_domain = 16
-need_resched = 20
tsk_ptrace = 24
processor = 52

@@ -215,9 +213,9 @@
jne handle_softirq

ret_with_reschedule:
- cmpl $0,need_resched(%ebx)
+ cmpl $0,TS_NEED_RESCHED(%ebx)
jne reschedule
- cmpl $0,sigpending(%ebx)
+ cmpl $0,TS_SIGPENDING(%ebx)
jne signal_return
restore_all:
RESTORE_ALL
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2011 Jasper Spaans