[m-rev.] diff: some cleanups in runtime

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jun 20 12:17:31 AEST 2005


runtime/mercury_calls.h:
runtime/mercury_prof.h:
runtime/mercury_signal.h:
runtime/mercury_string.h:
runtime/mercury_thread.c:
runtime/mercury_thread.h:
	Fix some layout issues in these files. There are no algorithmic
	changes.

Zoltan.

cvs diff: Diffing .
Index: mercury_calls.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_calls.h,v
retrieving revision 1.12
diff -u -b -r1.12 mercury_calls.h
--- mercury_calls.h	7 Jul 2004 07:11:09 -0000	1.12
+++ mercury_calls.h	19 Jun 2005 14:00:45 -0000
@@ -20,7 +20,7 @@
 */
 
 /*
-** On some systems [basically those using PIC (Position Independent MR_Code)],
+** On some systems [basically those using PIC (Position Independent Code)],
 ** if we're using gcc non-local gotos to jump between functions then
 ** we need to do ASM_FIXUP_REGS after each return from a procedure call.
 ** However, if we're using asm labels, then this is done in the
Index: mercury_prof.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_prof.h,v
retrieving revision 1.15
diff -u -b -r1.15 mercury_prof.h
--- mercury_prof.h	19 Jan 2004 01:02:54 -0000	1.15
+++ mercury_prof.h	19 Jun 2005 14:01:13 -0000
@@ -76,7 +76,8 @@
 ** mercury_label.c to record the address of each entry label.
 */
 
-extern void	MR_prof_output_addr_decl(const char *name, const MR_Code *address);
+extern void	MR_prof_output_addr_decl(const char *name,
+			const MR_Code *address);
 
 
 /*
Index: mercury_signal.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_signal.h,v
retrieving revision 1.13
diff -u -b -r1.13 mercury_signal.h
--- mercury_signal.h	24 May 2004 04:32:48 -0000	1.13
+++ mercury_signal.h	19 Jun 2005 14:01:10 -0000
@@ -57,59 +57,65 @@
 typedef MR_Code *		MR_signal_action;
 #endif
 
-	/*
-	** MR_setup_signal sets a signal handler (handler) to handle
-	** signals of the given signal type (sig).  
-	** If the handler cannot be setup, it aborts with the given
-	** error message.
-	** 
-	** If the signal handler requires siginfo to be provided (e.g.
-	** it needs access to stored registers), need_info must be 
-	** MR_TRUE.  Note that on some platforms, signal information is
-	** provided regardless of the value of need_info.
-	*/
+/*
+** MR_setup_signal sets a signal handler (handler) to handle
+** signals of the given signal type (sig).  
+** If the handler cannot be setup, it aborts with the given
+** error message.
+** 
+** If the signal handler requires siginfo to be provided (e.g.
+** it needs access to stored registers), need_info must be 
+** MR_TRUE.  Note that on some platforms, signal information is
+** provided regardless of the value of need_info.
+*/
+
 extern void MR_setup_signal(int sig, MR_Code *handler, MR_bool need_info, 
 	const char * error_message);
 
-	/*
-	** As above, but don't arrange for system calls to be
-	** restarted if the signal is received.
-	*/
+/*
+** As above, but don't arrange for system calls to be
+** restarted if the signal is received.
+*/
+
 extern void MR_setup_signal_no_restart(int sig, MR_Code *handler,
 	MR_bool need_info, const char * error_message);
 
-	/*
-	** As above, but initialize a signal action suitable to be
-	** passed to MR_set_signal_action rather than setting a
-	** signal handler for a signal.
-	*/
+/*
+** As above, but initialize a signal action suitable to be
+** passed to MR_set_signal_action rather than setting a
+** signal handler for a signal.
+*/
+
 extern void MR_init_signal_action(MR_signal_action* act, MR_Code *handler,
 	MR_bool need_info, MR_bool should_restart_system_call);
 
-	/*
-	** Get the current action for the given signal.
-	** If the action cannot be retrieved, it aborts with the given
-	** error message.
-	*/
+/*
+** Get the current action for the given signal.
+** If the action cannot be retrieved, it aborts with the given
+** error message.
+*/
+
 extern void MR_get_signal_action(int sig, MR_signal_action *old_action,
 	const char *error_message);
 
-	/*
-	** Restore the action for the given signal to the result
-	** of a previous call to MR_get_signal_action().
-	** If the action cannot be set, it aborts with the given
-	** error message.
-	*/
+/*
+** Restore the action for the given signal to the result
+** of a previous call to MR_get_signal_action().
+** If the action cannot be set, it aborts with the given
+** error message.
+*/
+
 extern void MR_set_signal_action(int sig, MR_signal_action *action,
 	const char *error_message);
 
-	/*
-	** Change the behaviour of system calls when the
-	** the specified signal is received.
-	** If restart is MR_TRUE they will be restarted, if it
-	** is MR_FALSE, they won't. This function may have no
-	** effect on some systems.
-	*/
+/*
+** Change the behaviour of system calls when the
+** the specified signal is received.
+** If restart is MR_TRUE they will be restarted, if it
+** is MR_FALSE, they won't. This function may have no
+** effect on some systems.
+*/
+
 extern void MR_signal_should_restart(int sig, MR_bool restart);
 
 #endif /* not MERCURY_SIGNAL_H */
Index: mercury_string.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_string.h,v
retrieving revision 1.31
diff -u -b -r1.31 mercury_string.h
--- mercury_string.h	7 Jul 2004 07:11:17 -0000	1.31
+++ mercury_string.h	19 Jun 2005 14:01:38 -0000
@@ -79,7 +79,7 @@
 	} while(0)
 
 /*
-** void MR_make_aligned_string_copy(MR_String ptr, const char * string);
+** void MR_make_aligned_string_copy(MR_String ptr, const char * string):
 **	Same as MR_make_aligned_string(ptr, string), except that the string
 **	is guaranteed to be copied. This is useful for copying C strings
 **	onto the Mercury heap.
@@ -105,7 +105,7 @@
 
 /*
 ** void MR_make_aligned_string_copy_saved_hp(MR_String ptr,
-** 		const char * string);
+** 	const char * string):
 **	Same as MR_make_aligned_string_copy(ptr, string), except that it uses
 **	MR_offset_incr_saved_hp_atomic instead of MR_offset_incr_hp_atomic.
 */
@@ -125,7 +125,7 @@
 
 /*
 ** void MR_make_aligned_string_copy_saved_hp_quote(MR_String ptr,
-** 		const char * string);
+**		const char * string):
 **	Same as MR_make_aligned_string_copy_saved_hp(ptr, string), except that
 **	it puts double quote marks at the start and end of the string.
 */
@@ -145,7 +145,7 @@
 
 /*
 ** void MR_allocate_aligned_string_msg(MR_String ptr, size_t len,
-**		MR_Code *proclabel);
+**	MR_Code *proclabel):
 ** Allocate enough word aligned memory to hold len characters.  Also
 ** record for memory profiling purposes the location, proclabel, of the
 ** allocation if profiling is enabled.
Index: mercury_thread.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_thread.c,v
retrieving revision 1.21
diff -u -b -r1.21 mercury_thread.c
--- mercury_thread.c	3 Mar 2003 14:58:34 -0000	1.21
+++ mercury_thread.c	19 Jun 2005 14:00:04 -0000
@@ -1,4 +1,7 @@
 /*
+** vim: ts=4 sw=4 expandtab
+*/
+/*
 ** Copyright (C) 1997-2001, 2003 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -25,8 +28,7 @@
 
 #ifdef MR_THREAD_SAFE
 
-static void *
-MR_create_thread_2(void *goal);
+static void         *MR_create_thread_2(void *goal);
 
 MercuryThread *
 MR_create_thread(MR_ThreadGoal *goal)
@@ -37,16 +39,15 @@
 
 	thread = MR_GC_NEW(MercuryThread);
 	pthread_attr_init(&attrs);
-	err = pthread_create(thread, &attrs, MR_create_thread_2,
-		(void *) goal);
+    err = pthread_create(thread, &attrs, MR_create_thread_2, (void *) goal);
 
 #if 0
-	fprintf(stderr, "pthread_create returned %d (errno = %d)\n",
-		err, errno);
+    fprintf(stderr, "pthread_create returned %d (errno = %d)\n", err, errno);
 #endif
 
-	if (err != 0)
+    if (err != 0) {
 		MR_fatal_error("error creating thread");
+    }
 
 	return thread;
 }
@@ -76,9 +77,8 @@
 
 #ifdef MR_THREAD_SAFE
 		/* 
-		** Check to see whether there is already an engine 
-		** that is initialized in this thread.  If so we just
-		** return, there's nothing for us to do.
+    ** Check to see whether there is already an engine that is initialized
+    ** in this thread.  If so we just return, there's nothing for us to do.
 		*/
 	if (MR_GETSPECIFIC(MR_engine_base_key)) {
 		return MR_FALSE;
@@ -93,8 +93,7 @@
 	MR_engine_base = eng;
   #endif
 #else
-	MR_memcpy(&MR_engine_base, eng,
-		sizeof(MercuryEngine));
+    MR_memcpy(&MR_engine_base, eng, sizeof(MercuryEngine));
 	MR_restore_registers();
 #endif
 	MR_load_engine_regs(MR_cur_engine());
@@ -112,8 +111,7 @@
 			MR_fatal_error("Sorry, not implemented: "
 				"--high-level-code and multiple engines");
 #else
-			(void) MR_call_engine(MR_ENTRY(MR_do_runnext),
-					     MR_FALSE);
+            (void) MR_call_engine(MR_ENTRY(MR_do_runnext), MR_FALSE);
 #endif
 			MR_destroy_engine(eng);
 			return MR_FALSE;
@@ -164,7 +162,8 @@
 {
 	int err;
 
-	fprintf(stderr, "%d locking on %p (%s)\n", pthread_self(), lock, from);
+    fprintf(stderr, "%ld locking on %p (%s)\n",
+        (long) pthread_self(), lock, from);
 	err = pthread_mutex_lock(lock);
 	assert(err == 0);
 }
@@ -174,8 +173,8 @@
 {
 	int err;
 
-	fprintf(stderr, "%d unlocking on %p (%s)\n",
-		pthread_self(), lock, from);
+    fprintf(stderr, "%ld unlocking on %p (%s)\n",
+        (long) pthread_self(), lock, from);
 	err = pthread_mutex_unlock(lock);
 	assert(err == 0);
 }
@@ -185,7 +184,7 @@
 {
 	int err;
 
-	fprintf(stderr, "%d signaling %p\n", pthread_self(), cond);
+    fprintf(stderr, "%ld signaling %p\n", (long) pthread_self(), cond);
 	err = pthread_cond_broadcast(cond);
 	assert(err == 0);
 }
Index: mercury_thread.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_thread.h,v
retrieving revision 1.16
diff -u -b -r1.16 mercury_thread.h
--- mercury_thread.h	7 Mar 2003 13:27:16 -0000	1.16
+++ mercury_thread.h	19 Jun 2005 14:00:01 -0000
@@ -51,20 +51,28 @@
     #define	MR_LOCK(lck, from)					\
     				( MR_debug_threads ?			\
 					MR_mutex_lock((lck), (from))	\
-				:	pthread_mutex_lock((lck)))
+				:					\
+					pthread_mutex_lock((lck))	\
+				)
     #define	MR_UNLOCK(lck, from)					\
     				( MR_debug_threads ?			\
     					MR_mutex_unlock((lck), (from))	\
-				:	pthread_mutex_unlock((lck)))
+				:					\
+					pthread_mutex_unlock((lck))	\
+				)
 
     #define	MR_SIGNAL(cnd)						\
     				( MR_debug_threads ?			\
 					MR_cond_signal((cnd))		\
-				:	pthread_cond_signal((cnd)))
+				:					\
+					pthread_cond_signal((cnd))	\
+				)
     #define	MR_WAIT(cnd, mtx)					\
     				( MR_debug_threads ?			\
 					MR_cond_wait((cnd), (mtx))	\
-				:	pthread_cond_wait((cnd), (mtx)))
+				:					\
+					pthread_cond_wait((cnd), (mtx))	\
+				)
 
   #endif
 
@@ -101,6 +109,7 @@
   ** structure containing a function and an argument. The function will
   ** be called with the given argument in the new thread.
   */
+
   MercuryThread		*MR_create_thread(MR_ThreadGoal *);
   void			MR_destroy_thread(void *eng);
   extern MR_bool	MR_exit_now;
@@ -116,12 +125,14 @@
 	** (the defaults) are specified since if you obtain the lock then
 	** call back into Mercury deadlock could result.
 	*/
+
   extern MercuryLock MR_global_lock;
 
   	/*
 	** MR_exception_handler_key stores a key which can be used to get
 	** the current exception handler for the current thread.
 	*/
+
   extern MercuryThreadKey MR_exception_handler_key;
 
 #else /* not MR_THREAD_SAFE */
@@ -147,6 +158,7 @@
 ** runqueue. The engine is destroyed when the execution of work from
 ** the runqueue returns.
 */
+
 typedef enum { MR_use_now, MR_use_later } MR_when_to_use;
 
 /*
cvs diff: Diffing GETOPT
cvs diff: Diffing machdeps
--------------------------------------------------------------------------
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