ia64/xen-unstable

changeset 18735:8d41996e6897

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.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Oct 27 18:51:52 2008 +0000 (2008-10-27)
parents 324b9b1dd71d
children 748af1e5d67c
files extras/mini-os/Makefile extras/mini-os/include/sched.h extras/mini-os/include/wait.h
line diff
     1.1 --- a/extras/mini-os/Makefile	Mon Oct 27 14:59:01 2008 +0000
     1.2 +++ b/extras/mini-os/Makefile	Mon Oct 27 18:51:52 2008 +0000
     1.3 @@ -18,6 +18,9 @@ include minios.mk
     1.4  # Set tester flags
     1.5  # CFLAGS += -DBLKTEST_WRITE
     1.6  
     1.7 +# Make the headers define our internal stuff
     1.8 +CFLAGS += -D__MINIOS__
     1.9 +
    1.10  # Define some default flags for linking.
    1.11  LDLIBS := 
    1.12  APP_LDLIBS := 
     2.1 --- a/extras/mini-os/include/sched.h	Mon Oct 27 14:59:01 2008 +0000
     2.2 +++ b/extras/mini-os/include/sched.h	Mon Oct 27 18:51:52 2008 +0000
     2.3 @@ -48,8 +48,9 @@ struct thread* create_thread(char *name,
     2.4  void exit_thread(void) __attribute__((noreturn));
     2.5  void schedule(void);
     2.6  
     2.7 +#ifdef __MINIOS__
     2.8  #define current get_current()
     2.9 -
    2.10 +#endif
    2.11  
    2.12  void wake(struct thread *thread);
    2.13  void block(struct thread *thread);
     3.1 --- a/extras/mini-os/include/wait.h	Mon Oct 27 14:59:01 2008 +0000
     3.2 +++ b/extras/mini-os/include/wait.h	Mon Oct 27 18:51:52 2008 +0000
     3.3 @@ -7,7 +7,7 @@
     3.4  
     3.5  #define DEFINE_WAIT(name)                               \
     3.6  struct wait_queue name = {                              \
     3.7 -    .thread       = current,                            \
     3.8 +    .thread       = get_current(),                            \
     3.9      .thread_list  = MINIOS_LIST_HEAD_INIT((name).thread_list), \
    3.10  }
    3.11  
    3.12 @@ -53,7 +53,7 @@ static inline void wake_up(struct wait_q
    3.13      unsigned long flags;        \
    3.14      local_irq_save(flags);      \
    3.15      add_wait_queue(&wq, &w);    \
    3.16 -    block(current);             \
    3.17 +    block(get_current());       \
    3.18      local_irq_restore(flags);   \
    3.19  } while (0)
    3.20  
    3.21 @@ -74,8 +74,8 @@ static inline void wake_up(struct wait_q
    3.22          /* protect the list */                                  \
    3.23          local_irq_save(flags);                                  \
    3.24          add_wait_queue(&wq, &__wait);                           \
    3.25 -        current->wakeup_time = deadline;                        \
    3.26 -        clear_runnable(current);                                \
    3.27 +        get_current()->wakeup_time = deadline;                  \
    3.28 +        clear_runnable(get_current());                          \
    3.29          local_irq_restore(flags);                               \
    3.30          if((condition) || (deadline && NOW() >= deadline))      \
    3.31              break;                                              \
    3.32 @@ -83,7 +83,7 @@ static inline void wake_up(struct wait_q
    3.33      }                                                           \
    3.34      local_irq_save(flags);                                      \
    3.35      /* need to wake up */                                       \
    3.36 -    wake(current);                                              \
    3.37 +    wake(get_current());                                        \
    3.38      remove_wait_queue(&__wait);                                 \
    3.39      local_irq_restore(flags);                                   \
    3.40  } while(0)