diff options
author | Bruce Momjian | 2001-12-20 21:23:05 +0000 |
---|---|---|
committer | Bruce Momjian | 2001-12-20 21:23:05 +0000 |
commit | 8799d84603d607f614198d7967ee6cff0d274ff4 (patch) | |
tree | 11883d415291e68f3b940b7b0fec47aba6d97cbb /src | |
parent | 960f6a5fdf9aafea93585cd7a4cef5044aebe078 (diff) |
Add memcmp() test and new memcmp.c file, for SunOS. Tested by Tatsuo.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.global.in | 3 | ||||
-rw-r--r-- | src/backend/port/Makefile.in | 4 | ||||
-rw-r--r-- | src/backend/port/memcmp.c | 36 |
3 files changed, 40 insertions, 3 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 9bed4dcc02c..c2e37f8e9de 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.140 2001/10/13 15:24:23 tgl Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.141 2001/12/20 21:23:05 momjian Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -328,6 +328,7 @@ INET_ATON = @INET_ATON@ STRERROR = @STRERROR@ SNPRINTF = @SNPRINTF@ STRDUP = @STRDUP@ +MEMCMP = @MEMCMP@ STRTOUL = @STRTOUL@ diff --git a/src/backend/port/Makefile.in b/src/backend/port/Makefile.in index adae5364722..fdc1008743a 100644 --- a/src/backend/port/Makefile.in +++ b/src/backend/port/Makefile.in @@ -13,7 +13,7 @@ # be converted to Method 2. # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.29 2001/05/08 19:38:57 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/port/Attic/Makefile.in,v 1.30 2001/12/20 21:23:05 momjian Exp $ # #------------------------------------------------------------------------- @@ -22,7 +22,7 @@ top_builddir = ../../.. include $(top_builddir)/src/Makefile.global OBJS = dynloader.o @INET_ATON@ @STRERROR@ @MISSING_RANDOM@ @SRANDOM@ -OBJS+= @GETHOSTNAME@ @GETRUSAGE@ @STRCASECMP@ @TAS@ @ISINF@ +OBJS+= @GETHOSTNAME@ @GETRUSAGE@ @MEMCMP@ @STRCASECMP@ @TAS@ @ISINF@ OBJS+= @STRTOL@ @STRTOUL@ @SNPRINTF@ ifdef STRDUP OBJS += $(top_builddir)/src/utils/strdup.o diff --git a/src/backend/port/memcmp.c b/src/backend/port/memcmp.c new file mode 100644 index 00000000000..8e4997ace1d --- /dev/null +++ b/src/backend/port/memcmp.c @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + * + * memcmp.c + * compares memory bytes + * + * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/Attic/memcmp.c,v 1.1 2001/12/20 21:23:05 momjian Exp $ + * + * This file was taken from NetBSD and is used by SunOS because memcmp + * on that platform does not properly compare negative bytes. + * + *------------------------------------------------------------------------- + */ + +#include <string.h> + +/* + * Compare memory regions. + */ +int +memcmp(const void *s1, const void *s2, size_t n) +{ + if (n != 0) { + const unsigned char *p1 = s1, *p2 = s2; + + do { + if (*p1++ != *p2++) + return (*--p1 - *--p2); + } while (--n != 0); + } + return 0; +} |