Added a g_memmove replacement for platforms without memmove, where bcopy

1999-07-01  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* configure.in, acconfig.h, gutils.c: Added a g_memmove
	replacement for platforms without memmove, where bcopy can't
	handle overlapping copies and the corresponding checks, which is
	taken form the PERL Configure routine.

	* glib.h: Updated the commentary about g_memmove to be right and
	more GLib-like.

	* configure.in: Removed test for rand_r, as it isn't used anymore.
This commit is contained in:
Sebastian Wilhelmi 1999-07-01 09:30:18 +00:00 committed by Sebastian Wilhelmi
parent f80d6cc540
commit d610460c22
14 changed files with 185 additions and 7 deletions

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -1,3 +1,15 @@
1999-07-01 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acconfig.h, gutils.c: Added a g_memmove
replacement for platforms without memmove, where bcopy can't
handle overlapping copies and the corresponding checks, which is
taken form the PERL Configure routine.
* glib.h: Updated the commentary about g_memmove to be right and
more GLib-like.
* configure.in: Removed test for rand_r, as it isn't used anymore.
1999-06-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib.h, grand.c: Finally removed the g_random_normal and

View File

@ -69,6 +69,7 @@
#undef HAVE_VALUES_H
#undef HAVE_WCHAR_H
#undef HAVE_WCTYPE_H
#undef HAVE_WORKING_BCOPY
#undef NO_FD_SET
#undef NO_SYS_ERRLIST

View File

@ -306,6 +306,31 @@ AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
# Check for some functions
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll)
# Check if bcopy can be used for overlapping copies, if memmove isn't found.
# The check is borrowed from the PERL Configure script.
if test "$ac_cv_func_memmove" != "yes"; then
AC_CACHE_CHECK(whether bcopy can handle overlapping copies,
glib_cv_working_bcopy,[AC_TRY_RUN([
int main() {
char buf[128], abc[128], *b;
int len, off, align;
bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
for (align = 7; align >= 0; align--) {
for (len = 36; len; len--) {
b = buf+align; bcopy(abc, b, len);
for (off = 1; off <= len; off++) {
bcopy(b, b+off, len); bcopy(b+off, b, len);
if (bcmp(b, abc, len)) return(1);
}
}
}
return(0);
}],glib_cv_working_bcopy=yes,glib_cv_working_bcopy=no)])
if test "$glib_cv_working_bcopy" == "yes"; then
AC_DEFINE(HAVE_WORKING_BCOPY)
fi
fi
# Check for sys_errlist
AC_MSG_CHECKING(for sys_errlist)
AC_TRY_LINK(, [
@ -787,7 +812,7 @@ if test x"$enable_threads" = xyes; then
# to always be linked with the thread libs on some platforms.
# LIBS="$LIBS $G_THREAD_LIBS"
CFLAGS="$CFLAGS $G_THREAD_CFLAGS"
AC_CHECK_FUNCS(localtime_r rand_r)
AC_CHECK_FUNCS(localtime_r)
if test "$ac_cv_header_pwd_h" = "yes"; then
AC_MSG_CHECKING([for getpwuid_r])
AC_CACHE_VAL(ac_cv_func_getpwuid_r,
@ -1330,13 +1355,17 @@ x$ac_cv_func_memmove)
glib_memmove='
#define g_memmove(d,s,n) G_STMT_START { memmove ((d), (s), (n)); } G_STMT_END'
;;
*)
x$glib_cv_working_bcopy)
glib_memmove="
/* We make the assumption that if memmove isn't available, then
* bcopy will do the job. This isn't safe everywhere. (bcopy can't
* necessarily handle overlapping copies) */
/* memmove isn't available, but bcopy can copy overlapping memory regions */
#define g_memmove(d,s,n) G_STMT_START { bcopy ((s), (d), (n)); } G_STMT_END"
;;
*)
glib_memmove="
/* memmove isn't found and bcopy can't copy overlapping memory regions,
* so we have to roll our own copy routine. */
void g_memmove (void* dest, const void * src, unsigned long len);"
;;
esac
glib_defines="

2
glib.h
View File

@ -58,7 +58,7 @@
* To register hooks which are executed on exit().
* Usually a wrapper for STDC atexit.
*
* void *g_memmove(void *dest, const void *src, guint count);
* void g_memmove(gpointer dest, gconstpointer void *src, gulong count);
* A wrapper for STDC memmove, or an implementation, if memmove doesn't
* exist. The prototype looks like the above, give or take a const,
* or size_t.

View File

@ -58,7 +58,7 @@
* To register hooks which are executed on exit().
* Usually a wrapper for STDC atexit.
*
* void *g_memmove(void *dest, const void *src, guint count);
* void g_memmove(gpointer dest, gconstpointer void *src, gulong count);
* A wrapper for STDC memmove, or an implementation, if memmove doesn't
* exist. The prototype looks like the above, give or take a const,
* or size_t.

View File

@ -81,6 +81,32 @@ const guint glib_micro_version = GLIB_MICRO_VERSION;
const guint glib_interface_age = GLIB_INTERFACE_AGE;
const guint glib_binary_age = GLIB_BINARY_AGE;
#if !defined (HAVE_MEMMOVE) && !defined (HAVE_WORKING_BCOPY)
void
g_memmove (gpointer dest, gconstpointer src, gulong len)
{
gchar* destptr = dest;
const gchar* srcptr = src;
if (src + len < dest || dest + len < src)
{
bcopy (src, dest, len);
return;
}
else if (dest <= src)
{
while (len--)
*(destptr++) = *(srcptr++);
}
else
{
destptr += len;
srcptr += len;
while (len--)
*(--destptr) = *(--srcptr);
}
}
#endif /* !HAVE_MEMMOVE && !HAVE_WORKING_BCOPY */
void
g_atexit (GVoidFunc func)
{

View File

@ -81,6 +81,32 @@ const guint glib_micro_version = GLIB_MICRO_VERSION;
const guint glib_interface_age = GLIB_INTERFACE_AGE;
const guint glib_binary_age = GLIB_BINARY_AGE;
#if !defined (HAVE_MEMMOVE) && !defined (HAVE_WORKING_BCOPY)
void
g_memmove (gpointer dest, gconstpointer src, gulong len)
{
gchar* destptr = dest;
const gchar* srcptr = src;
if (src + len < dest || dest + len < src)
{
bcopy (src, dest, len);
return;
}
else if (dest <= src)
{
while (len--)
*(destptr++) = *(srcptr++);
}
else
{
destptr += len;
srcptr += len;
while (len--)
*(--destptr) = *(--srcptr);
}
}
#endif /* !HAVE_MEMMOVE && !HAVE_WORKING_BCOPY */
void
g_atexit (GVoidFunc func)
{