From 7c1b18655e6a450b5f1270a956c7146f821a2c23 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 3 Jan 2010 18:33:00 -0500 Subject: [PATCH] Reduce #ifs by weeding out some cross-chunk function definitions. Reduce the need for placing #if guards around functions that are marked as VISIBLE in another code chunk by declaring the functions as "weak" when they are not needed. It's still necessary to ensure that no C code references the data from a different chunk (or an -fwhole-program compile might try to keep a local reference). --- src/apm.c | 2 -- src/pcibios.c | 2 -- src/resume.c | 2 -- src/types.h | 12 ++++++------ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/apm.c b/src/apm.c index 479d47c..1b151e9 100644 --- a/src/apm.c +++ b/src/apm.c @@ -224,11 +224,9 @@ handle_apm16(struct bregs *regs) handle_1553(regs); } -#if MODE16 == 0 && MODESEGMENT == 1 void VISIBLE32SEG handle_apm32(struct bregs *regs) { debug_enter(regs, DEBUG_HDL_apm); handle_1553(regs); } -#endif diff --git a/src/pcibios.c b/src/pcibios.c index 2e44c01..a23248b 100644 --- a/src/pcibios.c +++ b/src/pcibios.c @@ -202,7 +202,6 @@ handle_1ab1(struct bregs *regs) * 32bit interface ****************************************************************/ -#if MODE16 == 0 && MODESEGMENT == 1 // Entry point for 32bit pci bios functions. void VISIBLE32SEG handle_pcibios32(struct bregs *regs) @@ -210,7 +209,6 @@ handle_pcibios32(struct bregs *regs) debug_enter(regs, DEBUG_HDL_pcibios32); handle_1ab1(regs); } -#endif struct bios32_s { u32 signature; diff --git a/src/resume.c b/src/resume.c index 6cdfc69..e9115d0 100644 --- a/src/resume.c +++ b/src/resume.c @@ -93,7 +93,6 @@ handle_resume(u8 status) panic("Unimplemented shutdown status: %02x\n", status); } -#if MODESEGMENT == 0 void VISIBLE32FLAT s3_resume(void) { @@ -123,4 +122,3 @@ s3_resume(void) } call16big(&br); } -#endif diff --git a/src/types.h b/src/types.h index 7b87b86..5da299d 100644 --- a/src/types.h +++ b/src/types.h @@ -44,9 +44,9 @@ extern void __force_link_error__only_in_16bit(void) __noreturn; // Notes a function as externally visible in the 16bit code chunk. # define VISIBLE16 __VISIBLE // Notes a function as externally visible in the 32bit flat code chunk. -# define VISIBLE32FLAT __section(".discard.func32flat." UNIQSEC) noinline +# define VISIBLE32FLAT __section(".discard.func32flat." UNIQSEC) noinline __weak // Notes a function as externally visible in the 32bit segmented code chunk. -# define VISIBLE32SEG __section(".discard.func32seg." UNIQSEC) noinline +# define VISIBLE32SEG __section(".discard.func32seg." UNIQSEC) noinline __weak // Designate a variable as (only) visible to 16bit code. # define VAR16 __section(".data16." UNIQSEC) // Designate a variable as visible to 16bit, 32bit, and assembler code. @@ -68,8 +68,8 @@ extern void __force_link_error__only_in_16bit(void) __noreturn; # define ASSERT32SEG() __force_link_error__only_in_32bit_segmented() # define ASSERT32FLAT() __force_link_error__only_in_32bit_flat() #elif MODESEGMENT == 1 -# define VISIBLE16 __section(".discard.func16." UNIQSEC) noinline -# define VISIBLE32FLAT __section(".discard.func32flat." UNIQSEC) noinline +# define VISIBLE16 __section(".discard.func16." UNIQSEC) noinline __weak +# define VISIBLE32FLAT __section(".discard.func32flat." UNIQSEC) noinline __weak # define VISIBLE32SEG __VISIBLE # define VAR16 __section(".discard.var16." UNIQSEC) # define VAR16VISIBLE VAR16 __VISIBLE __weak @@ -83,9 +83,9 @@ extern void __force_link_error__only_in_16bit(void) __noreturn; # define ASSERT32SEG() do { } while (0) # define ASSERT32FLAT() __force_link_error__only_in_32bit_flat() #else -# define VISIBLE16 __section(".discard.func16." UNIQSEC) noinline +# define VISIBLE16 __section(".discard.func16." UNIQSEC) noinline __weak # define VISIBLE32FLAT __VISIBLE -# define VISIBLE32SEG __section(".discard.func32seg." UNIQSEC) noinline +# define VISIBLE32SEG __section(".discard.func32seg." UNIQSEC) noinline __weak # define VAR16 __section(".discard.var16." UNIQSEC) # define VAR16VISIBLE VAR16 __VISIBLE __weak # define VAR16EXPORT VAR16VISIBLE -- 2.25.1