diff options
author | Roland McGrath <roland@gnu.org> | 1995-09-01 22:25:08 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-09-01 22:25:08 +0000 |
commit | 44c8d1a2a8775ad8c67fa1c46ccc67cccf585d93 (patch) | |
tree | c77e32c88b64caccdd673fc54efdba189361a6e6 /stdlib/msort.c | |
parent | e3726b056b3b1cfde7019e29d5d3c50ce70e08e9 (diff) | |
download | glibc-44c8d1a2a8775ad8c67fa1c46ccc67cccf585d93.tar.gz glibc-44c8d1a2a8775ad8c67fa1c46ccc67cccf585d93.tar.xz glibc-44c8d1a2a8775ad8c67fa1c46ccc67cccf585d93.zip |
Fri Sep 1 16:16:12 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* 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.
Diffstat (limited to 'stdlib/msort.c')
-rw-r--r-- | stdlib/msort.c | 56 |
1 files changed, 34 insertions, 22 deletions
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 <ansidecl.h> #include <stdlib.h> #include <string.h> - -#define MEMCPY(dst, src, s) \ - ((s) == sizeof (int) \ - ? (*(int *) (dst) = *(int *) (src), (dst)) \ - : memcpy (dst, src, s)) +#include <memcopy.h> 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); |