[m-rev.] diff: compile extras/concurrency using MSVC

Peter Ross pro at missioncriticalit.com
Thu Oct 31 02:58:03 AEDT 2002


Hi,


===================================================================


Estimated hours taken: 0.5
Branches: main

Update the concurrency samples so that they compile with MSVC.

extras/concurrency/philo2.m:
extras/concurrency/philo3.m:
	Use the Win32 Sleep function instead of sleep when compiling
	with MSVC.


Index: extras/concurrency/philo2.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/concurrency/philo2.m,v
retrieving revision 1.2
diff -u -r1.2 philo2.m
--- extras/concurrency/philo2.m	29 May 2001 08:51:58 -0000	1.2
+++ extras/concurrency/philo2.m	30 Oct 2002 15:56:10 -0000
@@ -92,6 +92,10 @@
 :- pred rand_sleep(int::in, io__state::di, io__state::uo) is det.
 :- pragma c_code(rand_sleep(Int::in, IO0::di, IO::uo),
 		[thread_safe, will_not_call_mercury], "{
-	sleep(rand() % Int);
+#ifdef _MSC_VER
+	Sleep(1000 * (rand() % Int));
+#else
+	sleep((rand() % Int));
+#endif
 	IO =  IO0;
 }").
Index: extras/concurrency/philo3.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/concurrency/philo3.m,v
retrieving revision 1.1
diff -u -r1.1 philo3.m
--- extras/concurrency/philo3.m	15 May 2001 10:25:34 -0000	1.1
+++ extras/concurrency/philo3.m	30 Oct 2002 15:56:10 -0000
@@ -79,7 +79,11 @@
 :- pred rand_sleep(int::in, io__state::di, io__state::uo) is det.
 :- pragma c_code(rand_sleep(Int::in, IO0::di, IO::uo),
 		[thread_safe, will_not_call_mercury], "{
-	sleep(rand() % Int);
+#ifdef _MSC_VER
+	Sleep(1000 * (rand() % Int));
+#else
+	sleep((rand() % Int));
+#endif
 	IO =  IO0;
 }").
 

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list