From 44c8d1a2a8775ad8c67fa1c46ccc67cccf585d93 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 1 Sep 1995 22:25:08 +0000 Subject: Fri Sep 1 16:16:12 1995 Roland McGrath * libc-symbols.h (link_warning): Take new first arg SYMBOL; ask for a warning on references to that specific symbol, not the entire containing object file. (stub_warning): Pass symbol name to link_warning. * stdio/gets.c: Pass function name in link_warning invocation. * hurd/intr-msg.c: Treat apparent EINTR return from msg trap like MACH_SEND_INTERRUPTED. That indicates interrupt_operation was sent, but failed. * stdlib/msort.c: Include memcopy.h. (msort_with_tmp): If operating on aligned op_t words, use direct word fetches and stores. * sysdeps/i386/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC): Add missing backslash. --- stdlib/msort.c | 56 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'stdlib/msort.c') diff --git a/stdlib/msort.c b/stdlib/msort.c index 92ba5182ed..959aaa3dda 100644 --- a/stdlib/msort.c +++ b/stdlib/msort.c @@ -1,5 +1,5 @@ /* msort -- an alternative to qsort, with an identical interface. - Copyright (C) 1992 Free Software Foundation, Inc. + Copyright (C) 1992, 1995 Free Software Foundation, Inc. Written by Mike Haertel, September 1988. This file is part of the GNU C Library. @@ -22,11 +22,7 @@ Cambridge, MA 02139, USA. */ #include #include #include - -#define MEMCPY(dst, src, s) \ - ((s) == sizeof (int) \ - ? (*(int *) (dst) = *(int *) (src), (dst)) \ - : memcpy (dst, src, s)) +#include static void DEFUN(msort_with_tmp, (b, n, s, cmp, t), @@ -49,22 +45,38 @@ DEFUN(msort_with_tmp, (b, n, s, cmp, t), tmp = t; - while (n1 > 0 && n2 > 0) - { - if ((*cmp) (b1, b2) <= 0) - { - MEMCPY (tmp, b1, s); - b1 += s; - --n1; - } - else - { - MEMCPY (tmp, b2, s); - b2 += s; - --n2; - } - tmp += s; - } + if (s == OPSIZ && (b1 - b2) % OPSIZ == 0) + /* We are operating on aligned words. Use direct word stores. */ + while (n1 > 0 && n2 > 0) + { + if ((*cmp) (b1, b2) <= 0) + { + --n1; + *((op_t *) tmp)++ = *((op_t *) b1)++; + } + else + { + --n2; + *((op_t *) tmp)++ = *((op_t *) b2)++; + } + } + else + while (n1 > 0 && n2 > 0) + { + if ((*cmp) (b1, b2) <= 0) + { + memcpy (tmp, b1, s); + b1 += s; + --n1; + } + else + { + memcpy (tmp, b2, s); + b2 += s; + --n2; + } + tmp += s; + } if (n1 > 0) memcpy (tmp, b1, n1 * s); memcpy (b, t, (n - n2) * s); -- cgit v1.2.3