From 4fbbf651d7cb91983801904f5ed2b07d15566c1d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 30 Jun 2008 18:52:13 -0700 Subject: [i386] Change semantics of __from_data16 and __from_text16 __from_data16 and __from_text16 now take a pointer to a .data16/.text16 variable, and return the real-mode offset within the appropriate segment. This matches the use case for every occurrence of these macros, and prevents potential future bugs such as that fixed in commit d51d80f. (The bug arose essentially because "&pointer" is still syntactically valid.) --- src/arch/i386/include/libkir.h | 4 ++-- src/arch/i386/include/librm.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/arch/i386/include') diff --git a/src/arch/i386/include/libkir.h b/src/arch/i386/include/libkir.h index 5f67a56d..1f5b1350 100644 --- a/src/arch/i386/include/libkir.h +++ b/src/arch/i386/include/libkir.h @@ -19,8 +19,8 @@ #define __text16_array( variable,array ) variable array #define __use_data16( variable ) variable #define __use_text16( variable ) variable -#define __from_data16( variable ) variable -#define __from_text16( variable ) variable +#define __from_data16( pointer ) pointer +#define __from_text16( pointer ) pointer /* Real-mode data and code segments */ static inline __attribute__ (( always_inline )) unsigned int _rm_cs ( void ) { diff --git a/src/arch/i386/include/librm.h b/src/arch/i386/include/librm.h index 31b50979..413f0362 100644 --- a/src/arch/i386/include/librm.h +++ b/src/arch/i386/include/librm.h @@ -51,13 +51,13 @@ extern char *text16; ( * ( ( typeof ( _text16_ ## variable ) * ) \ & ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) ) -#define __from_data16( variable ) \ - ( * ( ( typeof ( variable ) * ) \ - ( ( ( void * ) &(variable) ) - ( ( void * ) data16 ) ) ) ) +#define __from_data16( pointer ) \ + ( ( unsigned int ) \ + ( ( ( void * ) (pointer) ) - ( ( void * ) data16 ) ) ) -#define __from_text16( variable ) \ - ( * ( ( typeof ( variable ) * ) \ - ( ( ( void * ) &(variable) ) - ( ( void * ) text16 ) ) ) ) +#define __from_text16( pointer ) \ + ( ( unsigned int ) \ + ( ( ( void * ) (pointer) ) - ( ( void * ) text16 ) ) ) /* Variables in librm.S, present in the normal data segment */ extern uint16_t __data16 ( rm_cs ); -- cgit