Always define macro MODE16 - that way it can be used in C conditionals.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 13 Jul 2008 15:08:36 +0000 (11:08 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 13 Jul 2008 15:08:36 +0000 (11:08 -0400)
When in 32bit mode - just define it to 0.

Makefile
src/clock.c
src/farptr.h
src/types.h
src/util.c

index 30a394365a6c44f17bfd9d3457a3a1e1bffc7014..c7ab73a8dea4c8d176661ba1773b1b11b247a3ce 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,8 +27,8 @@ COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
 COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
 COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
 
-CFLAGS = $(COMMONCFLAGS) -g
-CFLAGS16INC = $(COMMONCFLAGS) -DMODE16 -fno-jump-tables -fno-defer-pop \
+CFLAGS = $(COMMONCFLAGS) -g -DMODE16=0
+CFLAGS16INC = $(COMMONCFLAGS) -DMODE16=1 -fno-jump-tables -fno-defer-pop \
               $(call cc-option,$(CC),--param large-stack-frame=8,)
 CFLAGS16 = $(CFLAGS16INC) -g
 
index d3756865bc2382d7d270194d5dd174ceb84df6dc..a490a9b3d489b90da84f97ffacd161beb0fa59bf 100644 (file)
@@ -369,29 +369,29 @@ clear_usertimer()
 int
 usleep(u32 count)
 {
-#ifdef MODE16
-    // In 16bit mode, use the rtc to wait for the specified time.
-    u8 statusflag = 0;
-    int ret = set_usertimer(count, GET_SEG(SS), (u32)&statusflag);
-    if (ret)
-        return -1;
-    irq_enable();
-    while (!statusflag)
-        cpu_relax();
-    irq_disable();
-    return 0;
-#else
-    // In 32bit mode, we need to call into 16bit mode to sleep.
-    struct bregs br;
-    memset(&br, 0, sizeof(br));
-    br.ah = 0x86;
-    br.cx = count >> 16;
-    br.dx = count;
-    call16_int(0x15, &br);
-    if (br.flags & F_CF)
-        return -1;
-    return 0;
-#endif
+    if (MODE16) {
+        // In 16bit mode, use the rtc to wait for the specified time.
+        u8 statusflag = 0;
+        int ret = set_usertimer(count, GET_SEG(SS), (u32)&statusflag);
+        if (ret)
+            return -1;
+        irq_enable();
+        while (!statusflag)
+            cpu_relax();
+        irq_disable();
+        return 0;
+    } else {
+        // In 32bit mode, we need to call into 16bit mode to sleep.
+        struct bregs br;
+        memset(&br, 0, sizeof(br));
+        br.ah = 0x86;
+        br.cx = count >> 16;
+        br.dx = count;
+        call16_int(0x15, &br);
+        if (br.flags & F_CF)
+            return -1;
+        return 0;
+    }
 }
 
 #define RET_ECLOCKINUSE  0x83
index ef0aa423e69bfe26c3720abec2c24c67b13b61e1..d5b64f7d8c445d23ead864a2cea0ffb71e90ac95 100644 (file)
@@ -133,7 +133,7 @@ extern void __force_link_error__unknown_type();
 #define MAKE_FARPTR(seg,off) ((void*)(((seg)<<4)+(off)))
 
 
-#ifdef MODE16
+#if MODE16 == 1
 
 // Definitions when in 16 bit mode.
 #define GET_FARVAR(seg, var) __GET_FARVAR((seg), (var))
index 81b6739cddf349193c75c9a51d48bfa6d3287f95..dfc3f16226715259b62cc9dfd4d25fe6f312f159 100644 (file)
@@ -22,7 +22,7 @@ union u64_u32_u {
 };
 
 #define __VISIBLE __attribute__((externally_visible))
-#ifdef MODE16
+#if MODE16 == 1
 // Notes a function as externally visible in the 16bit code chunk.
 #define VISIBLE16 __VISIBLE
 // Notes a function as externally visible in the 32bit code chunk.
index 6ae6965d8bdc7821d7e074be53148c2e0be512f6..60d9d09003fb59c36020b534eba8ebcde5f1d5a7 100644 (file)
@@ -15,7 +15,7 @@ inline void
 call16(struct bregs *callregs)
 {
     asm volatile(
-#ifdef MODE16
+#if MODE16 == 1
         "calll __call16\n"
 #else
         "calll __call16_from32\n"