minios: do not expose #define current to applications
PATCH 1/1 minios: do not expose #define current to applications
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 the .c file in question declares
#define _INSIDE_MINIOS
Suppressing the namespace pollution is necessary to get recent upstream qemu's to compile, since they (quite properly) use `current' as an ordinary identifier.
Ian.
extras/mini-os/arch/x86/sched.c +2 -0
@@ -34,6 +34,8 @@* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#define _INSIDE_MINIOS#include <os.h> #include <hypervisor.h>
extras/mini-os/arch/x86/traps.c +2 -0
@@ -1,3 +1,5 @@ + +#define _INSIDE_MINIOS#include <os.h> #include <traps.h>
extras/mini-os/fs-front.c +2 -0
@@ -23,6 +23,8 @@* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#define _INSIDE_MINIOS#undef NDEBUG#include <os.h>
extras/mini-os/include/sched.h +2 -1
@@ -48,8 +48,9 @@ void exit_thread(void) __attribute__((novoid exit_thread (void ) __attribute__((noreturn));void schedule (void ); +#ifdef _INSIDE_MINIOS#define current get_current() - +#endif void wake (struct thread *thread);void block (struct thread *thread);
extras/mini-os/include/wait.h +5 -5
@@ -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_qunsigned 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_q/* 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_q } \local_irq_save (flags); \/* need to wake up */ \ -wake (current); \ +wake (get_current ()); \remove_wait_queue (&__wait); \local_irq_restore (flags); \ }while (0 )
extras/mini-os/lwip-net.c +2 -0
@@ -40,6 +40,8 @@* Author: Adam Dunkels <[email protected]> * */ + +#define _INSIDE_MINIOS#include <os.h>
extras/mini-os/netfront.c +2 -0
@@ -4,6 +4,8 @@* * Does not handle fragments or extras. */ + +#define _INSIDE_MINIOS#include <os.h> #include <xenbus.h>
extras/mini-os/sched.c +2 -0
@@ -34,6 +34,8 @@* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#define _INSIDE_MINIOS#include <os.h> #include <hypervisor.h>
extras/mini-os/xenbus/xenbus.c +3 -0
@@ -15,6 +15,9 @@* **************************************************************************** **/ + +#define _INSIDE_MINIOS +#include <os.h> #include <mm.h> #include <traps.h>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 1/1 minios: do not expose #define current to applications
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.
(This is a revised version of my earlier patch, and supersedes it.)
extras/mini-os/Makefile +3 -0
@@ -17,6 +17,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 :=
extras/mini-os/include/sched.h +2 -1
@@ -48,8 +48,9 @@ void exit_thread(void) __attribute__((novoid 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);
extras/mini-os/include/wait.h +5 -5
@@ -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_qunsigned 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_q/* 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_q } \local_irq_save (flags); \/* need to wake up */ \ -wake (current); \ +wake (get_current ()); \remove_wait_queue (&__wait); \local_irq_restore (flags); \ }while (0 )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 3 lines · I wrote:
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.
It turns out that __MINIOS__ is already used to mean we are running under minios' rather than this is a source file which is part of minios. This causes a build failure (but apparently on amd64 only!)
The attached patch changes the __MINIOS__ introduced in c/s 18727 to __INSIDE__MINIOS__. It also arranges to define it for the arch/ subdirectories too.
Ian.
extras/mini-os/Makefile +0 -3
@@ -17,9 +17,6 @@ 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 :=
extras/mini-os/include/sched.h +1 -1
@@ -48,7 +48,7 @@ void exit_thread(void) __attribute__((novoid exit_thread (void ) __attribute__((noreturn));void schedule (void ); -#ifdef __MINIOS__ +#ifdef __INSIDE_MINIOS__#define current get_current()#endif
extras/mini-os/minios.mk +3 -0
@@ -25,6 +25,9 @@ else else DEF_CFLAGS += -O3 endif + +# Make the headers define our internal stuff +DEF_CFLAGS += -D__INSIDE_MINIOS__ # Build the CFLAGS and ASFLAGS for compiling and assembling. # DEF_... flags are the common mini-os flags,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel