diff: making MR_memcpy work on void *, not char *

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Mar 26 15:43:10 AEDT 1999


runtime/mercury_misc.[ch]:
	Make the arguments of MR_memcpy void * instead of char *, to make
	its signature agree with the signature of memcpy.

runtime/mercury_array_macros.h:
	Update a cast in a call to MR_memcpy.

Zoltan.

cvs diff: Diffing runtime
Index: runtime/mercury_array_macros.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_array_macros.h,v
retrieving revision 1.3
diff -u -b -u -r1.3 mercury_array_macros.h
--- mercury_array_macros.h	1999/02/08 10:51:43	1.3
+++ mercury_array_macros.h	1999/03/24 06:18:02
@@ -25,8 +25,8 @@
 
   #define MR_copy_array_element(array, to_index, from_index)		\
 	do {								\
-		MR_memcpy((char *) &array[to_index],			\
-			(const char *) &array[from_index],		\
+		MR_memcpy((void *) &array[to_index],			\
+			(const void *) &array[from_index],		\
 			sizeof(array[to_index]));			\
 	} while(0)
 
Index: runtime/mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.15
diff -u -b -u -r1.15 mercury_misc.c
--- mercury_misc.c	1999/03/17 00:35:06	1.15
+++ mercury_misc.c	1999/03/24 06:11:53
@@ -533,12 +533,18 @@
 	exit(EXIT_FAILURE);
 }
 
-	/* See header file for documentation on why we need this function */
+/*
+** See the header file for documentation on why we need this function.
+*/
+
 void
-MR_memcpy(char *dest, const char *src, size_t nbytes)
+MR_memcpy(void *dest, const void *src, size_t nbytes)
 {
+	char		*d = (char *) dest;
+	const char	*s = (const char *) src;
+
 	while (nbytes-- > 0)
-		*dest++ = *src++;
+		*d++ = *s++;
 }
 
 /*
Index: runtime/mercury_misc.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.h,v
retrieving revision 1.13
diff -u -b -u -r1.13 mercury_misc.h
--- mercury_misc.h	1999/03/17 00:35:07	1.13
+++ mercury_misc.h	1999/03/24 06:12:19
@@ -78,6 +78,6 @@
 ** XXX We should fix this eventually by using -fno-builtin since pragma
 ** c_code may call the builtin functions.
 */
-extern	void	MR_memcpy(char *dest, const char *src, size_t nbytes);
+extern	void	MR_memcpy(void *dest, const void *src, size_t nbytes);
 
 #endif /* not MERCURY_MISC_H */
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps



More information about the developers mailing list