Reduce #ifs by weeding out some cross-chunk function definitions.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 3 Jan 2010 23:33:00 +0000 (18:33 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 3 Jan 2010 23:33:00 +0000 (18:33 -0500)
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
src/pcibios.c
src/resume.c
src/types.h

index 479d47c5629ba21a9564f6b02031f4f9884458fb..1b151e902f3c69613697417f952406c6349ae191 100644 (file)
--- 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
index 2e44c015d4b72d2eeb87ffa047d3fcadf1dc5451..a23248b4965a95ba398027059fca63c20cf91fb5 100644 (file)
@@ -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;
index 6cdfc69e0b3ef8b1889ee5849bf6860888748225..e9115d0919422bc9bf941cac0f3a63b07a62629f 100644 (file)
@@ -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
index 7b87b8670d823ec3b5ff85e935d2795c96fbcedd..5da299d929c4efc0c414f4d1c695644c481ff7aa 100644 (file)
@@ -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