From: Ian Jackson Subject: [PATCH] minios: do not expose #define current to applications Date: Mon, 27 Oct 2008 16:32:11 +0000 Message-ID: <18693.60683.98148.588009@mariner.uk.xensource.com> References: <18688.43589.339402.607213@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LBfgs+z8W6" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <18688.43589.339402.607213@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --LBfgs+z8W6 Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit 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.) Signed-off-by: Ian Jackson --LBfgs+z8W6 Content-Type: text/plain Content-Description: do not pollute minios application namespace with `current' Content-Disposition: inline; filename="minios-no-current-define-2.patch" Content-Transfer-Encoding: 7bit diff -r 324b9b1dd71d extras/mini-os/Makefile --- a/extras/mini-os/Makefile Mon Oct 27 14:59:01 2008 +0000 +++ b/extras/mini-os/Makefile Mon Oct 27 15:58:06 2008 +0000 @@ -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 := diff -r 324b9b1dd71d extras/mini-os/include/sched.h --- a/extras/mini-os/include/sched.h Mon Oct 27 14:59:01 2008 +0000 +++ b/extras/mini-os/include/sched.h Mon Oct 27 15:59:02 2008 +0000 @@ -48,8 +48,9 @@ void exit_thread(void) __attribute__((no 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); diff -r 324b9b1dd71d extras/mini-os/include/wait.h --- a/extras/mini-os/include/wait.h Mon Oct 27 14:59:01 2008 +0000 +++ b/extras/mini-os/include/wait.h Mon Oct 27 15:56:36 2008 +0000 @@ -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_q 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_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) --LBfgs+z8W6 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --LBfgs+z8W6--