summaryrefslogtreecommitdiff
path: root/mcon/U/d_sanemcmp.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/d_sanemcmp.U')
-rw-r--r--mcon/U/d_sanemcmp.U88
1 files changed, 88 insertions, 0 deletions
diff --git a/mcon/U/d_sanemcmp.U b/mcon/U/d_sanemcmp.U
new file mode 100644
index 0000000..07d1f84
--- /dev/null
+++ b/mcon/U/d_sanemcmp.U
@@ -0,0 +1,88 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?RCS: $Log: d_sanemcmp.U,v $
+?RCS: Revision 3.0.1.1 1997/02/28 15:41:19 ram
+?RCS: patch61: created
+?RCS:
+?RCS:
+?MAKE:d_sanemcmp: cat d_memcmp +cc +optimize +ccflags +libs +ldflags rm \
+ i_memory i_stdlib i_string i_unistd Oldconfig Setvar
+?MAKE: -pick add $@ %<
+?S:d_sanemcmp:
+?S: This variable conditionally defines the HAS_SANE_MEMCMP symbol if
+?S: the memcpy() routine is available and can be used to compare relative
+?S: magnitudes of chars with their high bits set.
+?S:.
+?C:HAS_SANE_MEMCMP:
+?C: This symbol, if defined, indicates that the memcmp routine is available
+?C: and can be used to compare relative magnitudes of chars with their high
+?C: bits set. If it is not defined, roll your own version.
+?C:.
+?H:#$d_sanemcmp HAS_SANE_MEMCMP /**/
+?H:.
+?F:!sanemcmp
+?LINT: set d_sanemcmp
+: can memcmp be trusted to compare relative magnitude?
+?X: assume the worst
+val="$undef"
+case "$d_memcmp" in
+"$define")
+ echo " "
+ echo \
+ "Checking to see if your memcmp() can compare relative magnitude..." >&4
+ $cat >foo.c <<EOCP
+#$i_memory I_MEMORY
+#$i_stdlib I_STDLIB
+#$i_string I_STRING
+#$i_unistd I_UNISTD
+EOCP
+ $cat >>foo.c <<'EOCP'
+#include <stdio.h>
+#ifdef I_MEMORY
+# include <memory.h>
+#endif
+#ifdef I_STDLIB
+# include <stdlib.h>
+#endif
+#ifdef I_STRING
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+#ifdef I_UNISTD
+# include <unistd.h> /* Needed for NetBSD */
+#endif
+int main()
+{
+char a = -1;
+char b = 0;
+if ((a < b) && memcmp(&a, &b, 1) < 0)
+ exit(1);
+exit(0);
+}
+EOCP
+ if $cc $optimize $ccflags $ldflags \
+ -o sanemcmp foo.c $libs >/dev/null 2>&1; then
+ if ./sanemcmp 2>/dev/null; then
+ echo "Yes, it can."
+ val="$define"
+ else
+ echo "No, it can't (it uses signed chars)."
+ fi
+ else
+ echo "(I can't compile the test program, so we'll assume not...)"
+ fi
+ ;;
+esac
+$rm -f foo.* sanemcmp core
+set d_sanemcmp
+eval $setvar
+