[m-dev.] diff: minor fixes to extras/concurrency/semaphore.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Sep 18 20:06:45 AEDT 2000
Estimated hours taken: 0.5
extras/concurrency/semaphore.m:
Fix some bugs that resulted in compiler warnings:
- ensure that ME_finalize_semaphore() is declared before it is used
- the first argument to incr_hp() must have type `MR_Word'
Also:
- improve (clarify) the error message you get when compiling in
grade hlc.gc
- change the layout in one spot to match our coding guidelines
Workspace: /home/pgrad/fjh/ws/hg
Index: extras/concurrency/semaphore.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/concurrency/semaphore.m,v
retrieving revision 1.5
diff -u -d -r1.5 semaphore.m
--- extras/concurrency/semaphore.m 2000/09/14 14:02:38 1.5
+++ extras/concurrency/semaphore.m 2000/09/18 09:04:01
@@ -55,7 +55,7 @@
:- pragma c_header_code("
#if defined(MR_HIGHLEVEL_CODE) && !defined(MR_THREAD_SAFE)
- #error Semaphores only work in the hlc.par.* grades.
+ #error Semaphores only work in the hlc.par.* or non-hlc grades.
#endif
#include <stdio.h>
@@ -75,11 +75,19 @@
} ME_Semaphore;
").
+:- pragma c_header_code("
+#ifdef CONSERVATIVE_GC
+ void ME_finalize_semaphore(GC_PTR obj, GC_PTR cd);
+#endif
+").
+
:- pragma c_code(semaphore__new(Semaphore::out, IO0::di, IO::uo),
[will_not_call_mercury, thread_safe], "{
+ MR_Word sem_mem;
ME_Semaphore *sem;
- incr_hp(sem, round_up(sizeof(ME_Semaphore), sizeof(MR_Word)));
+ incr_hp(sem_mem, round_up(sizeof(ME_Semaphore), sizeof(MR_Word)));
+ sem = (ME_Semaphore *) sem_mem;
sem->count = 0;
#ifndef MR_HIGHLEVEL_CODE
sem->suspended = NULL;
@@ -104,7 +112,8 @@
:- pragma c_code("
#ifdef CONSERVATIVE_GC
- void ME_finalize_semaphore(GC_PTR obj, GC_PTR cd)
+ void
+ ME_finalize_semaphore(GC_PTR obj, GC_PTR cd)
{
ME_Semaphore *sem;
--
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