From 1608c2cc6dbb781e082b9525dc143b7d1863532f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 25 Nov 1992 03:28:54 +0000 Subject: [PATCH] Initial revision --- sysdeps/alpha/Dist | 1 + sysdeps/alpha/Makefile | 3 ++ sysdeps/alpha/__math.h | 28 +++++++++++++++++ sysdeps/alpha/copysign.c | 27 +++++++++++++++++ sysdeps/alpha/fabs.c | 26 ++++++++++++++++ sysdeps/alpha/memchr.c | 65 ++++++++++++++++++++++++++++++++++++++++ sysdeps/alpha/setjmp.S | 28 +++++++++++++++++ sysdeps/alpha/strlen.c | 57 +++++++++++++++++++++++++++++++++++ 8 files changed, 235 insertions(+) create mode 100644 sysdeps/alpha/Dist create mode 100644 sysdeps/alpha/Makefile create mode 100644 sysdeps/alpha/__math.h create mode 100644 sysdeps/alpha/copysign.c create mode 100644 sysdeps/alpha/fabs.c create mode 100644 sysdeps/alpha/memchr.c create mode 100644 sysdeps/alpha/setjmp.S create mode 100644 sysdeps/alpha/strlen.c diff --git a/sysdeps/alpha/Dist b/sysdeps/alpha/Dist new file mode 100644 index 0000000000..ad6ea0313a --- /dev/null +++ b/sysdeps/alpha/Dist @@ -0,0 +1 @@ +setjmp_aux.c diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile new file mode 100644 index 0000000000..736414197a --- /dev/null +++ b/sysdeps/alpha/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),setjmp) +sysdep_routines := $(sysdep_routines) setjmp_aux +endif diff --git a/sysdeps/alpha/__math.h b/sysdeps/alpha/__math.h new file mode 100644 index 0000000000..e9893f5e4f --- /dev/null +++ b/sysdeps/alpha/__math.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#if defined (__GNUC__) && !defined (__NO_MATH_INLINES) + +extern __inline +__copysign (double __x, double __y) +{ + __asm ("cpys %1, %2, %0" : "=f" (__x) : "f" (__y), "f" (__x)); + return __x; +} + +#endif diff --git a/sysdeps/alpha/copysign.c b/sysdeps/alpha/copysign.c new file mode 100644 index 0000000000..ad74994f25 --- /dev/null +++ b/sysdeps/alpha/copysign.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* Return X with its signed changed to Y's. */ +double +__copysign (double x, double y) +{ + asm ("cpys %1, %2, %0" : "=f" (x) : "f" (y), "f" (x)); + return x; +} diff --git a/sysdeps/alpha/fabs.c b/sysdeps/alpha/fabs.c new file mode 100644 index 0000000000..936202704a --- /dev/null +++ b/sysdeps/alpha/fabs.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +double +fabs (double x) +{ + asm ("cpys $f31, %1, %0" : "=f" (x) : "f" (x)); + return x; +} diff --git a/sysdeps/alpha/memchr.c b/sysdeps/alpha/memchr.c new file mode 100644 index 0000000000..01a8c3eeac --- /dev/null +++ b/sysdeps/alpha/memchr.c @@ -0,0 +1,65 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* Search no more than N bytes of S for C. */ + +void * +memchr (const void *s, int c, size_t n) +{ + const char *char_ptr; + const unsigned long int *longword_ptr; + unsigned long int charmask; + + c = (unsigned char) c; + + /* Handle the first few characters by reading one character at a time. + Do this until STR is aligned on a 8-byte border. */ + for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 7) != 0; + --n, ++char_ptr) + if (*char_ptr == c) + return char_ptr; + + longword_ptr = (unsigned long int *) char_ptr; + + /* Set up a longword, each of whose bytes is C. */ + charmask = c | (c << 8); + charmask |= charmask << 16; + charmask |= charmask << 32; + + for (;;) + { + int mask; + asm ("cmpbge %1, %2, %0" + : "=r" (mask) : "r" (charmask), "r" (*longword_ptr++)); + if (mask) + { + /* Which of the bytes was the C? */ + + const char *cp = (const char *) (longword_ptr - 1); + + if (cp[0] == c) + return cp - str; + if (cp[1] == c) + return cp - str + 1; + if (cp[2] == c) + return cp - str + 2; + return cp - str + 3; + } + } +} diff --git a/sysdeps/alpha/setjmp.S b/sysdeps/alpha/setjmp.S new file mode 100644 index 0000000000..a5de80cd38 --- /dev/null +++ b/sysdeps/alpha/setjmp.S @@ -0,0 +1,28 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* The function __setjmp_aux saves all the registers, but it can't + reliably access the stack or frame pointers, so we pass them in as + extra arguments. */ +ENTRY (__setjmp) + lda $27, __setjmp_aux /* Load address to jump to. */ + bis $15, $15, $17 /* Pass FP as 2nd arg. */ + bis $30, $30, $18 /* Pass SP as 3nd arg. */ + jmp $31, ($27), __setjmp_aux /* Call __setjmp_aux. */ diff --git a/sysdeps/alpha/strlen.c b/sysdeps/alpha/strlen.c new file mode 100644 index 0000000000..0c108534e5 --- /dev/null +++ b/sysdeps/alpha/strlen.c @@ -0,0 +1,57 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* Return the length of the null-terminated string STR. Scan for + the null terminator quickly by testing eight bytes at a time. */ + +size_t +strlen (const char *str) +{ + const char *char_ptr; + const unsigned long int *longword_ptr; + unsigned long int longword; + + /* Handle the first few characters by reading one character at a time. + Do this until STR is aligned on a 8-byte border. */ + for (char_ptr = str; ((unsigned long int) char_ptr & 7) != 0; ++char_ptr) + if (*char_ptr == '\0') + return char_ptr - str; + + longword_ptr = (unsigned long int *) char_ptr; + + for (;;) + { + int mask; + asm ("cmpbge %1, %2, %0" : "=r" (mask) : "r" (0), "r" (*longword_ptr++)); + if (mask) + { + /* Which of the bytes was the zero? */ + + const char *cp = (const char *) (longword_ptr - 1); + + if (cp[0] == 0) + return cp - str; + if (cp[1] == 0) + return cp - str + 1; + if (cp[2] == 0) + return cp - str + 2; + return cp - str + 3; + } + } +} -- 2.43.5