Skip to content

Commit

Permalink
Add own memmove() implementation
Browse files Browse the repository at this point in the history
This is required for SunOS 4.1.4 aka Solaris 1.1.
Thanks to Götz Hoffart for testing!
  • Loading branch information
alexbarton committed Jan 29, 2017
1 parent 77e8852 commit d6b39fc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
8 changes: 3 additions & 5 deletions configure.ng
Expand Up @@ -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])
Expand All @@ -235,7 +233,6 @@ AC_CHECK_FUNCS([ \
gethostname \
gettimeofday \
inet_ntoa \
memmove \
memset \
setsid \
socket \
Expand All @@ -257,6 +254,7 @@ AC_CHECK_FUNCS_ONCE([
gai_strerror \
getnameinfo \
inet_aton \
memmove \
setgroups \
sigaction \
sigprocmask \
Expand Down
1 change: 1 addition & 0 deletions src/portab/Makefile.ng
Expand Up @@ -16,6 +16,7 @@ EXTRA_DIST = Makefile.ng
noinst_LIBRARIES = libngportab.a

libngportab_a_SOURCES = \
memmove.c \
strdup.c \
strlcpy.c \
strndup.c \
Expand Down
33 changes: 33 additions & 0 deletions 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

0 comments on commit d6b39fc

Please sign in to comment.