From: Alexander Barton Date: Sun, 29 Jan 2017 21:33:23 +0000 (+0100) Subject: Add own memmove() implementation X-Git-Url: https://arthur.barton.de/gitweb/?p=ngircd-alex.git;a=commitdiff_plain;h=52584d1fbec71c51ded6e9fcdffae3f5f8fb95ee Add own memmove() implementation This is required for SunOS 4.1.4 aka Solaris 1.1. Thanks to Götz Hoffart for testing! --- diff --git a/configure.ng b/configure.ng index 57ae8bb8..da1c7c2f 100644 --- a/configure.ng +++ b/configure.ng @@ -207,10 +207,8 @@ AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),, # -- Libraries -- -# memmove: A/UX libUTIL -AC_SEARCH_LIBS([memmove], [UTIL], [], [ - AC_MSG_ERROR([unable to find the memmove() function]) -]) +# memmove: A/UX libUTIL; but we can use our own implementation. +AC_SEARCH_LIBS([memmove], [UTIL]) # gethostbyname: Solaris libnsl AC_SEARCH_LIBS([gethostbyname], [bind nsl network], [], [ AC_MSG_ERROR([unable to find the gethostbyname() function]) @@ -235,7 +233,6 @@ AC_CHECK_FUNCS([ \ gethostname \ gettimeofday \ inet_ntoa \ - memmove \ memset \ setsid \ socket \ @@ -257,6 +254,7 @@ AC_CHECK_FUNCS_ONCE([ gai_strerror \ getnameinfo \ inet_aton \ + memmove \ setgroups \ sigaction \ sigprocmask \ diff --git a/src/portab/Makefile.ng b/src/portab/Makefile.ng index 30b77fc3..206cc774 100644 --- a/src/portab/Makefile.ng +++ b/src/portab/Makefile.ng @@ -16,6 +16,7 @@ EXTRA_DIST = Makefile.ng noinst_LIBRARIES = libngportab.a libngportab_a_SOURCES = \ + memmove.c \ strdup.c \ strlcpy.c \ strndup.c \ diff --git a/src/portab/memmove.c b/src/portab/memmove.c new file mode 100644 index 00000000..60aa1262 --- /dev/null +++ b/src/portab/memmove.c @@ -0,0 +1,33 @@ +/* + * ngIRCd -- The Next Generation IRC Daemon + */ + +#include "portab.h" + +/** + * @file + * memmove() implementation. + * Source: http://c-faq.com/~scs/cgi-bin/faqcat.cgi?sec=ansi + */ + +#ifndef HAVE_MEMMOVE + +GLOBAL void * +memmove(void *dest, void const *src, size_t n) +{ + register char *dp = dest; + register char const *sp = src; + if(dp < sp) { + while(n-- > 0) + *dp++ = *sp++; + } else { + dp += n; + sp += n; + while(n-- > 0) + *--dp = *--sp; + } + + return dest; +} + +#endif