]> xenbits.xensource.com Git - people/liuw/mini-os.git/commitdiff
minios: do not expose #define current to applications
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 27 Oct 2008 18:51:52 +0000 (18:51 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 27 Oct 2008 18:51:52 +0000 (18:51 +0000)
Currently the minios headers do this:
 #define current get_current()
Obviously when porting general code to this environment, this can
cause problems !

The attached patch arranges for this only to be done if
 #define __MINIOS__
is declared, which is set up by the makefile in extras/mini-os.

Suppressing the namespace pollution is necessary to get recent
upstream qemu's to compile, since they (quite properly) use `current'
as an ordinary identifier.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Makefile
include/sched.h
include/wait.h

index ec24cba14af5a9edda1ac3d8d0da3b3110c5f405..7d57086c53a8909e282a57c7ae73f7b24eee705b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,9 @@ include minios.mk
 # Set tester flags
 # CFLAGS += -DBLKTEST_WRITE
 
+# Make the headers define our internal stuff
+CFLAGS += -D__MINIOS__
+
 # Define some default flags for linking.
 LDLIBS := 
 APP_LDLIBS := 
index 3359439b55d5f62fc5d273bd98f5f744839b4642..62dc4a93c68934410a1338dfebba207642e012bd 100644 (file)
@@ -48,8 +48,9 @@ struct thread* create_thread(char *name, void (*function)(void *), void *data);
 void exit_thread(void) __attribute__((noreturn));
 void schedule(void);
 
+#ifdef __MINIOS__
 #define current get_current()
-
+#endif
 
 void wake(struct thread *thread);
 void block(struct thread *thread);
index 14e98ba755df5099c423a3e2652eb7ed8c39b1a7..10b9f29b078d47d099321bd1aab6e18064192630 100644 (file)
@@ -7,7 +7,7 @@
 
 #define DEFINE_WAIT(name)                               \
 struct wait_queue name = {                              \
-    .thread       = current,                            \
+    .thread       = get_current(),                            \
     .thread_list  = MINIOS_LIST_HEAD_INIT((name).thread_list), \
 }
 
@@ -53,7 +53,7 @@ static inline void wake_up(struct wait_queue_head *head)
     unsigned long flags;        \
     local_irq_save(flags);      \
     add_wait_queue(&wq, &w);    \
-    block(current);             \
+    block(get_current());       \
     local_irq_restore(flags);   \
 } while (0)
 
@@ -74,8 +74,8 @@ static inline void wake_up(struct wait_queue_head *head)
         /* protect the list */                                  \
         local_irq_save(flags);                                  \
         add_wait_queue(&wq, &__wait);                           \
-        current->wakeup_time = deadline;                        \
-        clear_runnable(current);                                \
+        get_current()->wakeup_time = deadline;                  \
+        clear_runnable(get_current());                          \
         local_irq_restore(flags);                               \
         if((condition) || (deadline && NOW() >= deadline))      \
             break;                                              \
@@ -83,7 +83,7 @@ static inline void wake_up(struct wait_queue_head *head)
     }                                                           \
     local_irq_save(flags);                                      \
     /* need to wake up */                                       \
-    wake(current);                                              \
+    wake(get_current());                                        \
     remove_wait_queue(&__wait);                                 \
     local_irq_restore(flags);                                   \
 } while(0)