[m-dev.] diff: fix bug in none.par grade
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Feb 10 06:07:53 AEDT 2000
Estimated hours taken: 0.75
Fix bugs that caused compilation errors in grade `none.gc.par'.
runtime/mercury_engine.h:
Add a new macro MR_cur_engine() which returns
a pointer to the current engine struct.
runtime/mercury_thread.c:
runtime/mercury_context.c:
Use MR_cur_engine() rather than MR_engine_base
or &MR_engine_base. Also fix the code in
mercury_thread.c to handle the case when
MR_THREAD_SAFE is set but MR_ENGINE_BASE_REGISTER is not.
Workspace: /mnt/local/ender2/fjh/mercury
Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.20
diff -u -d -r1.20 mercury_context.c
--- runtime/mercury_context.c 1999/10/18 15:46:51 1.20
+++ runtime/mercury_context.c 2000/02/09 10:24:27
@@ -308,7 +308,7 @@
while (1) {
if (MR_exit_now == TRUE) {
MR_UNLOCK(MR_runqueue_lock, "do_runnext (ii)");
- destroy_thread(MR_engine_base);
+ destroy_thread(MR_cur_engine());
}
tmp = MR_runqueue_head;
/* XXX check pending io */
Index: runtime/mercury_engine.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.h,v
retrieving revision 1.14
diff -u -d -r1.14 mercury_engine.h
--- runtime/mercury_engine.h 2000/01/03 08:53:06 1.14
+++ runtime/mercury_engine.h 2000/02/09 10:32:16
@@ -258,13 +258,15 @@
#define MR_engine_base MR_thread_engine_base
#endif
- #define MR_ENGINE(x) (((MercuryEngine *)MR_engine_base)->x)
- #define MR_get_engine() MR_thread_engine_base
+ #define MR_ENGINE(x) (((MercuryEngine *) MR_engine_base)->x)
+ #define MR_cur_engine() ((MercuryEngine *) MR_engine_base)
+ #define MR_get_engine() ((MercuryEngine *) MR_thread_engine_base)
#else /* !MR_THREAD_SAFE */
extern MercuryEngine MR_engine_base;
#define MR_ENGINE(x) (MR_engine_base.x)
+ #define MR_cur_engine() (&MR_engine_base)
#define MR_get_engine() (&MR_engine_base)
#endif /* !MR_THREAD_SAFE */
Index: runtime/mercury_thread.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.c,v
retrieving revision 1.10
diff -u -d -r1.10 mercury_thread.c
--- runtime/mercury_thread.c 1999/10/18 15:47:01 1.10
+++ runtime/mercury_thread.c 2000/02/09 10:26:15
@@ -73,28 +73,21 @@
eng = create_engine();
-#ifdef MR_THREAD_SAFE
+#ifdef MR_THREAD_SAFE
pthread_setspecific(MR_engine_base_key, eng);
-#endif
-
-#ifdef MR_ENGINE_BASE_REGISTER
restore_registers();
-
+ #ifdef MR_ENGINE_BASE_REGISTER
MR_engine_base = eng;
- load_engine_regs(eng);
- load_context(eng->this_context);
-
- save_registers();
+ #endif
#else
- MR_memcpy((void *) &MR_engine_base, (void *) eng,
+ MR_memcpy(&MR_engine_base, eng,
sizeof(MercuryEngine));
restore_registers();
-
- load_engine_regs(&MR_engine_base);
- load_context(MR_engine_base.this_context);
+#endif
+ load_engine_regs(MR_cur_engine());
+ load_context(MR_ENGINE(this_context));
save_registers();
-#endif
#ifdef MR_THREAD_SAFE
MR_ENGINE(owner_thread) = pthread_self();
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list