add directory gnu
This commit is contained in:
40
gnu/glibc/glibc-1.03/sysdeps/am29k/ffs.c
Normal file
40
gnu/glibc/glibc-1.03/sysdeps/am29k/ffs.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/* ffs -- find first set bit in a word, counted from least significant end.
|
||||
For Amd 290x0.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <bstring.h>
|
||||
|
||||
#undef ffs
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
int
|
||||
DEFUN(ffs, (x), int x)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
asm ("clz %0,%1" : "=r" (cnt) : "r" (x & -x));
|
||||
|
||||
return 32 - cnt;
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/generic/ffs.c>
|
||||
#endif
|
||||
9
gnu/glibc/glibc-1.03/sysdeps/generic/Dist
Normal file
9
gnu/glibc/glibc-1.03/sysdeps/generic/Dist
Normal file
@@ -0,0 +1,9 @@
|
||||
make_siglist.c signame.c signame.h
|
||||
det_endian.c
|
||||
../../math/bsd/common_source/mathimpl.h
|
||||
../../math/bsd/common/trig.h
|
||||
../../math/bsd/sys/stdc.h
|
||||
../../math/bsd/common/sincos.c
|
||||
../../math/bsd/common_source/asincos.c
|
||||
../../math/bsd/common_source/exp__E.c
|
||||
../../math/bsd/common_source/log__L.c
|
||||
60
gnu/glibc/glibc-1.03/sysdeps/generic/Makefile
Normal file
60
gnu/glibc/glibc-1.03/sysdeps/generic/Makefile
Normal file
@@ -0,0 +1,60 @@
|
||||
# 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.
|
||||
|
||||
ifeq ($(subdir),math)
|
||||
ifndef math-twiddled
|
||||
|
||||
routines:= $(filter-out acos asin cos sin ceil __rint hypot,$(routines)) \
|
||||
sincos asincos
|
||||
aux := $(aux) exp__E log__L
|
||||
|
||||
math-twiddled := t
|
||||
|
||||
endif
|
||||
|
||||
bsdmath_dirs := $(bsdmath_dirs) common common_source
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(subdir),string)
|
||||
dont_distribute := $(dont_distribute) endian.h # Generated.
|
||||
endif
|
||||
|
||||
$(objpfx)endian.h: $(objpfx)det_endian
|
||||
$(dir $<)$(notdir $<) > $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
$(objpfx)det_endian: $(sysdep_dir)/generic/det_endian.c
|
||||
cd $(objdir); $(CC) $(<:$(objpfx)%=%) -o $(@:$(objpfx)%=%)
|
||||
|
||||
before-compile := $(before-compile) $(objpfx)endian.h
|
||||
|
||||
ifeq ($(subdir),stdio)
|
||||
|
||||
ifeq "$(filter $(objpfx)siglist.c,$(before-compile))" ""
|
||||
before-compile := $(before-compile) $(objpfx)siglist.c
|
||||
$(objpfx)siglist.c: $(objpfx)make_siglist
|
||||
@rm -f $@
|
||||
$< > $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
$(objpfx)make_siglist: $(sysdep_dir)/generic/make_siglist.c
|
||||
cd $(objdir); $(CC) $< -o $(@:$(objpfx)%=%)
|
||||
endif
|
||||
|
||||
endif
|
||||
46
gnu/glibc/glibc-1.03/sysdeps/generic/__infnan.c
Normal file
46
gnu/glibc/glibc-1.03/sysdeps/generic/__infnan.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Deal with an infinite or NaN result.
|
||||
If ERROR is ERANGE, result is +Inf;
|
||||
if ERROR is - ERANGE, result is -Inf;
|
||||
otherwise result is NaN.
|
||||
This will set `errno' to either ERANGE or EDOM,
|
||||
and may return an infinity or NaN, or may do something else. */
|
||||
double
|
||||
DEFUN(__infnan, (error), int error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case ERANGE:
|
||||
errno = ERANGE;
|
||||
return HUGE_VAL;
|
||||
|
||||
case - ERANGE:
|
||||
errno = ERANGE;
|
||||
return - HUGE_VAL;
|
||||
|
||||
default:
|
||||
errno = EDOM;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
27
gnu/glibc/glibc-1.03/sysdeps/generic/__isnan.c
Normal file
27
gnu/glibc/glibc-1.03/sysdeps/generic/__isnan.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return nonzero if VALUE is not a number. */
|
||||
int
|
||||
DEFUN(__isnan, (value), double value)
|
||||
{
|
||||
return value != value;
|
||||
}
|
||||
27
gnu/glibc/glibc-1.03/sysdeps/generic/__lstat.c
Normal file
27
gnu/glibc/glibc-1.03/sysdeps/generic/__lstat.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/stat.h>
|
||||
#include <gnu-stabs.h>
|
||||
|
||||
function_alias (__lstat, __stat, int, (file, buf),
|
||||
DEFUN(__lstat, (file, buf),
|
||||
CONST char *file AND struct stat *buf))
|
||||
42
gnu/glibc/glibc-1.03/sysdeps/generic/__memccpy.c
Normal file
42
gnu/glibc/glibc-1.03/sysdeps/generic/__memccpy.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <stddef.h> /* For size_t and NULL. */
|
||||
|
||||
|
||||
/*
|
||||
* Copy no more than N bytes of SRC to DEST, stopping when C is found.
|
||||
* Return the position in DEST one byte past where C was copied,
|
||||
* or NULL if C was not found in the first N bytes of SRC.
|
||||
*/
|
||||
PTR
|
||||
DEFUN(__memccpy, (dest, src, c, n),
|
||||
PTR dest AND CONST PTR src AND int c AND size_t n)
|
||||
{
|
||||
register CONST char *s = src;
|
||||
register char *d = dest;
|
||||
register CONST int x = (unsigned char) c;
|
||||
register size_t i = n;
|
||||
|
||||
while (i-- > 0)
|
||||
if ((*d++ = *s++) == x)
|
||||
return d;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
25
gnu/glibc/glibc-1.03/sysdeps/generic/__rint.c
Normal file
25
gnu/glibc/glibc-1.03/sysdeps/generic/__rint.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <gnu-stabs.h>
|
||||
|
||||
/* We decide by fiat that the prevailing rounding mode is towards zero. */
|
||||
|
||||
function_alias(__rint, floor, double, (x),
|
||||
DEFUN(__rint, (x), double x))
|
||||
42
gnu/glibc/glibc-1.03/sysdeps/generic/acos.c
Normal file
42
gnu/glibc/glibc-1.03/sysdeps/generic/acos.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return the inverse cosine of X. */
|
||||
double
|
||||
DEFUN(acos, (x), double x)
|
||||
{
|
||||
double t;
|
||||
|
||||
if (__isnan(x))
|
||||
{
|
||||
errno = EDOM;
|
||||
return x;
|
||||
}
|
||||
|
||||
if (x == -1.0)
|
||||
/* If X is -1, the general formula blows up (zero divided by zero loses),
|
||||
but we know that acos(-1) = pi. */
|
||||
t = atan2(1.0, 0.0);
|
||||
else
|
||||
t = atan2(sqrt((1.0 - x) / (1.0 + x)), 1.0);
|
||||
return t + t;
|
||||
}
|
||||
44
gnu/glibc/glibc-1.03/sysdeps/generic/asin.c
Normal file
44
gnu/glibc/glibc-1.03/sysdeps/generic/asin.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return the inverse sine of X. */
|
||||
double
|
||||
DEFUN(asin, (x), double x)
|
||||
{
|
||||
double abs_x;
|
||||
|
||||
if (__isnan(x))
|
||||
{
|
||||
errno = EDOM;
|
||||
return x;
|
||||
}
|
||||
|
||||
abs_x = fabs(x);
|
||||
|
||||
if (abs_x <= 0.5)
|
||||
return atan2(x, sqrt(1.0 - (x * x)));
|
||||
else
|
||||
{
|
||||
double t = 1.0 - abs_x;
|
||||
return atan2(x, sqrt((t + t) - (t * t)));
|
||||
}
|
||||
}
|
||||
27
gnu/glibc/glibc-1.03/sysdeps/generic/atan.c
Normal file
27
gnu/glibc/glibc-1.03/sysdeps/generic/atan.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return the inverse tangent of X. */
|
||||
double
|
||||
DEFUN(atan, (x), register double x)
|
||||
{
|
||||
return atan2(x, 1.0);
|
||||
}
|
||||
32
gnu/glibc/glibc-1.03/sysdeps/generic/bcopy.c
Normal file
32
gnu/glibc/glibc-1.03/sysdeps/generic/bcopy.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <bstring.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define memmove bcopy
|
||||
#define rettype void
|
||||
#define RETURN(s) return
|
||||
#define a1 src
|
||||
#define a1const CONST
|
||||
#define a2 dest
|
||||
#define a2const
|
||||
|
||||
#include <memmove.c>
|
||||
81
gnu/glibc/glibc-1.03/sysdeps/generic/bzero.c
Normal file
81
gnu/glibc/glibc-1.03/sysdeps/generic/bzero.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <bstring.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* Set N bytes of S to 0. */
|
||||
void
|
||||
DEFUN(bzero, (s, n), PTR s AND size_t len)
|
||||
{
|
||||
long int dstp = (long int) s;
|
||||
CONST op_t zero = 0;
|
||||
|
||||
if (len >= 8)
|
||||
{
|
||||
size_t xlen;
|
||||
|
||||
/* There are at least some bytes to zero. No need to test
|
||||
for LEN == 0 in this alignment loop. */
|
||||
while (dstp % OPSIZ != 0)
|
||||
{
|
||||
((byte *) dstp)[0] = 0;
|
||||
dstp += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
/* Write 8 op_t per iteration until less than 8 op_t remain. */
|
||||
xlen = len / (OPSIZ * 8);
|
||||
while (xlen != 0)
|
||||
{
|
||||
((op_t *) dstp)[0] = zero;
|
||||
((op_t *) dstp)[1] = zero;
|
||||
((op_t *) dstp)[2] = zero;
|
||||
((op_t *) dstp)[3] = zero;
|
||||
((op_t *) dstp)[4] = zero;
|
||||
((op_t *) dstp)[5] = zero;
|
||||
((op_t *) dstp)[6] = zero;
|
||||
((op_t *) dstp)[7] = zero;
|
||||
dstp += 8 * OPSIZ;
|
||||
xlen -= 1;
|
||||
}
|
||||
len %= OPSIZ * 8;
|
||||
|
||||
/* Write 1 op_t per iteration until less than op_t remain. */
|
||||
xlen = len / OPSIZ;
|
||||
while (xlen != 0)
|
||||
{
|
||||
((op_t *) dstp)[0] = zero;
|
||||
dstp += OPSIZ;
|
||||
xlen -= 1;
|
||||
}
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* Write the last few bytes. */
|
||||
while (len != 0)
|
||||
{
|
||||
((byte *) dstp)[0] = 0;
|
||||
dstp += 1;
|
||||
len -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
43
gnu/glibc/glibc-1.03/sysdeps/generic/det_endian.c
Normal file
43
gnu/glibc/glibc-1.03/sysdeps/generic/det_endian.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Determine the "endianess" of the CPU.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
unsigned long int i;
|
||||
|
||||
puts("#ifndef\t_ENDIAN_H\n#define\t_ENDIAN_H\t1");
|
||||
|
||||
if (sizeof(i) != 4)
|
||||
puts("#error \"Not a 32-bit machine!\"");
|
||||
|
||||
i = (((((('A' << 8) + 'B') << 8) + 'C') << 8) + 'D');
|
||||
|
||||
if (!strncmp ("ABCD", (char *) &i, 4))
|
||||
puts ("#define __BIG_ENDIAN");
|
||||
else if (!strncmp ("DCBA", (char *) &i, 4))
|
||||
puts ("#define __LITTLE_ENDIAN");
|
||||
else
|
||||
puts ("#define __MIXED_ENDIAN");
|
||||
|
||||
puts("#endif\t/* endian.h */");
|
||||
|
||||
exit (0);
|
||||
}
|
||||
27
gnu/glibc/glibc-1.03/sysdeps/generic/fabs.c
Normal file
27
gnu/glibc/glibc-1.03/sysdeps/generic/fabs.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return the absolute value of X. */
|
||||
double
|
||||
DEFUN(fabs, (x), register double x)
|
||||
{
|
||||
return x < 0.0 ? -x : x;
|
||||
}
|
||||
47
gnu/glibc/glibc-1.03/sysdeps/generic/ffs.c
Normal file
47
gnu/glibc/glibc-1.03/sysdeps/generic/ffs.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <limits.h>
|
||||
#include <bstring.h>
|
||||
|
||||
#undef ffs
|
||||
|
||||
|
||||
/* Find the first bit set in I. */
|
||||
int
|
||||
DEFUN(ffs, (i), int i)
|
||||
{
|
||||
static CONST unsigned char table[] =
|
||||
{
|
||||
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
|
||||
};
|
||||
unsigned long int a;
|
||||
unsigned long int x = i & -i;
|
||||
|
||||
a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24);
|
||||
|
||||
return table[x >> a] + a;
|
||||
}
|
||||
31
gnu/glibc/glibc-1.03/sysdeps/generic/frexp.c
Normal file
31
gnu/glibc/glibc-1.03/sysdeps/generic/frexp.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Break VALUE into a normalized fraction and an integral power of 2. */
|
||||
double
|
||||
DEFUN(frexp, (value, exp), double value AND int *exp)
|
||||
{
|
||||
/* Add one to the exponent of the number,
|
||||
so we have one digit before the binary point. */
|
||||
*exp = (int) __logb (value) + 1;
|
||||
return ldexp (value, - *exp);
|
||||
}
|
||||
10
gnu/glibc/glibc-1.03/sysdeps/generic/htonl.c
Normal file
10
gnu/glibc/glibc-1.03/sysdeps/generic/htonl.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <ansidecl.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#undef htonl
|
||||
|
||||
unsigned long int
|
||||
DEFUN(htonl, (x), unsigned long int x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
10
gnu/glibc/glibc-1.03/sysdeps/generic/htons.c
Normal file
10
gnu/glibc/glibc-1.03/sysdeps/generic/htons.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <ansidecl.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#undef htons
|
||||
|
||||
unsigned short int
|
||||
DEFUN(htons, (x), unsigned short int x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
27
gnu/glibc/glibc-1.03/sysdeps/generic/hypot.c
Normal file
27
gnu/glibc/glibc-1.03/sysdeps/generic/hypot.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return `sqrt(x*x + y*y)'. */
|
||||
double
|
||||
DEFUN(hypot, (x, y), double x AND double y)
|
||||
{
|
||||
return sqrt(x*x + y*y);
|
||||
}
|
||||
16
gnu/glibc/glibc-1.03/sysdeps/generic/inet-cvt.h
Normal file
16
gnu/glibc/glibc-1.03/sysdeps/generic/inet-cvt.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/* Generic Internet number representation conversion macros. */
|
||||
|
||||
#undef ntohl
|
||||
#undef ntohs
|
||||
#undef htonl
|
||||
#undef htons
|
||||
|
||||
extern unsigned long int EXFUN(ntohl, (unsigned long int));
|
||||
extern unsigned short int EXFUN(ntohs, (unsigned short int));
|
||||
extern unsigned long int EXFUN(htonl, (unsigned long int));
|
||||
extern unsigned short int EXFUN(htons, (unsigned short int));
|
||||
|
||||
#define ntohl(x) (x)
|
||||
#define ntohs(x) (x)
|
||||
#define htonl(x) (x)
|
||||
#define htons(x) (x)
|
||||
27
gnu/glibc/glibc-1.03/sysdeps/generic/ldexp.c
Normal file
27
gnu/glibc/glibc-1.03/sysdeps/generic/ldexp.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return X times (two to the EXP power). */
|
||||
double
|
||||
DEFUN(ldexp, (x, exp), register double x AND register int exp)
|
||||
{
|
||||
return x * pow(2.0, (double) exp);
|
||||
}
|
||||
37
gnu/glibc/glibc-1.03/sysdeps/generic/log10.c
Normal file
37
gnu/glibc/glibc-1.03/sysdeps/generic/log10.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef LN10
|
||||
#define LN10 log(10.0)
|
||||
#endif
|
||||
|
||||
/* Return the base-ten logarithm of X. */
|
||||
double
|
||||
DEFUN(log10, (x), double x)
|
||||
{
|
||||
static double ln10 = 0.0;
|
||||
|
||||
if (ln10 == 0.0)
|
||||
ln10 = LN10;
|
||||
|
||||
return log(x) / ln10;
|
||||
}
|
||||
52
gnu/glibc/glibc-1.03/sysdeps/generic/make_siglist.c
Normal file
52
gnu/glibc/glibc-1.03/sysdeps/generic/make_siglist.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 1991, 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 General Public License as published by
|
||||
the Free Software Foundation; either version 2, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the GNU C Library; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* Make a definition for sys_siglist. */
|
||||
|
||||
|
||||
#undef SYS_SIGLIST_MISSING
|
||||
#include "signame.c"
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
register int i;
|
||||
|
||||
init_sigs ();
|
||||
|
||||
puts ("#include \"ansidecl.h\"\n#include <stddef.h>\n");
|
||||
|
||||
puts ("#ifndef HAVE_GNU_LD");
|
||||
puts ("#define _sys_siglist\tsys_siglist");
|
||||
puts ("#endif");
|
||||
|
||||
puts ("\n/* This is a list of all known signal numbers. */");
|
||||
|
||||
puts ("\nCONST char *CONST _sys_siglist[] =\n {");
|
||||
|
||||
for (i = 0; i < NSIG; ++i)
|
||||
printf (" \"%s\",\n", sys_siglist[i]);
|
||||
|
||||
puts (" NULL\n };\n");
|
||||
|
||||
exit (0);
|
||||
}
|
||||
143
gnu/glibc/glibc-1.03/sysdeps/generic/memchr.c
Normal file
143
gnu/glibc/glibc-1.03/sysdeps/generic/memchr.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Search no more than N bytes of S for C. */
|
||||
|
||||
PTR
|
||||
DEFUN(memchr, (s, c, n), CONST PTR s AND int c AND size_t n)
|
||||
{
|
||||
CONST unsigned char *char_ptr;
|
||||
CONST unsigned long int *longword_ptr;
|
||||
unsigned long int longword, magic_bits, charmask;
|
||||
|
||||
c = (unsigned char) c;
|
||||
|
||||
/* Handle the first few characters by reading one character at a time.
|
||||
Do this until CHAR_PTR is aligned on a 4-byte border. */
|
||||
for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 3) != 0;
|
||||
--n, ++char_ptr)
|
||||
if (*char_ptr == c)
|
||||
return (PTR) char_ptr;
|
||||
|
||||
longword_ptr = (unsigned long int *) char_ptr;
|
||||
|
||||
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
|
||||
the "holes." Note that there is a hole just to the left of
|
||||
each byte, with an extra at the end:
|
||||
|
||||
bits: 01111110 11111110 11111110 11111111
|
||||
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
|
||||
|
||||
The 1-bits make sure that carries propagate to the next 0-bit.
|
||||
The 0-bits provide holes for carries to fall into. */
|
||||
magic_bits = 0x7efefeff;
|
||||
|
||||
/* Set up a longword, each of whose bytes is C. */
|
||||
charmask = c | (c << 8);
|
||||
charmask |= charmask << 16;
|
||||
|
||||
/* Instead of the traditional loop which tests each character,
|
||||
we will test a longword at a time. The tricky part is testing
|
||||
if *any of the four* bytes in the longword in question are zero. */
|
||||
while (n >= 4)
|
||||
{
|
||||
/* We tentatively exit the loop if adding MAGIC_BITS to
|
||||
LONGWORD fails to change any of the hole bits of LONGWORD.
|
||||
|
||||
1) Is this safe? Will it catch all the zero bytes?
|
||||
Suppose there is a byte with all zeros. Any carry bits
|
||||
propagating from its left will fall into the hole at its
|
||||
least significant bit and stop. Since there will be no
|
||||
carry from its most significant bit, the LSB of the
|
||||
byte to the left will be unchanged, and the zero will be
|
||||
detected.
|
||||
|
||||
2) Is this worthwhile? Will it ignore everything except
|
||||
zero bytes? Suppose every byte of LONGWORD has a bit set
|
||||
somewhere. There will be a carry into bit 8. If bit 8
|
||||
is set, this will carry into bit 16. If bit 8 is clear,
|
||||
one of bits 9-15 must be set, so there will be a carry
|
||||
into bit 16. Similarly, there will be a carry into bit
|
||||
24. If one of bits 24-30 is set, there will be a carry
|
||||
into bit 31, so all of the hole bits will be changed.
|
||||
|
||||
The one misfire occurs when bits 24-30 are clear and bit
|
||||
31 is set; in this case, the hole at bit 31 is not
|
||||
changed. If we had access to the processor carry flag,
|
||||
we could close this loophole by putting the fourth hole
|
||||
at bit 32!
|
||||
|
||||
So it ignores everything except 128's, when they're aligned
|
||||
properly.
|
||||
|
||||
3) But wait! Aren't we looking for C, not zero?
|
||||
Good point. So what we do is XOR LONGWORD with a longword,
|
||||
each of whose bytes is C. This turns each byte that is C
|
||||
into a zero. */
|
||||
|
||||
longword = *longword_ptr++ ^ charmask;
|
||||
|
||||
/* Add MAGIC_BITS to LONGWORD. */
|
||||
if ((((longword + magic_bits)
|
||||
|
||||
/* Set those bits that were unchanged by the addition. */
|
||||
^ ~longword)
|
||||
|
||||
/* Look at only the hole bits. If any of the hole bits
|
||||
are unchanged, most likely one of the bytes was a
|
||||
zero. */
|
||||
& ~magic_bits) != 0)
|
||||
{
|
||||
/* Which of the bytes was C? If none of them were, it was
|
||||
a misfire; continue the search. */
|
||||
|
||||
CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1);
|
||||
|
||||
if (cp[0] == c)
|
||||
return (PTR) cp;
|
||||
if (cp[1] == c)
|
||||
return (PTR) &cp[1];
|
||||
if (cp[2] == c)
|
||||
return (PTR) &cp[2];
|
||||
if (cp[3] == c)
|
||||
return (PTR) &cp[3];
|
||||
}
|
||||
|
||||
n -= 4;
|
||||
}
|
||||
|
||||
char_ptr = (CONST unsigned char *) longword_ptr;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
if (*char_ptr == c)
|
||||
return (PTR) char_ptr;
|
||||
else
|
||||
++char_ptr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
285
gnu/glibc/glibc-1.03/sysdeps/generic/memcmp.c
Normal file
285
gnu/glibc/glibc-1.03/sysdeps/generic/memcmp.c
Normal file
@@ -0,0 +1,285 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */
|
||||
|
||||
/* The strategy of this memcmp is:
|
||||
|
||||
1. Compare bytes until one of the block pointers is aligned.
|
||||
|
||||
2. Compare using memcmp_common_alignment or
|
||||
memcmp_not_common_alignment, regarding the alignment of the other
|
||||
block after the initial byte operations. The maximum number of
|
||||
full words (of type op_t) are compared in this way.
|
||||
|
||||
3. Compare the few remaining bytes. */
|
||||
|
||||
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
|
||||
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
|
||||
memory operations on `op_t's. */
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
DEFUN(memcmp_common_alignment, (srcp1, srcp2, len),
|
||||
long int srcp1 AND long int srcp2 AND size_t len)
|
||||
{
|
||||
op_t a0, a1;
|
||||
op_t b0, b1;
|
||||
op_t res;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
case 2:
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= 2 * OPSIZ;
|
||||
srcp2 -= 2 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= OPSIZ;
|
||||
srcp2 -= OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return 0;
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
goto do3;
|
||||
case 1:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp1 += OPSIZ;
|
||||
srcp2 += OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
/* Fall through. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
res = a1 - b1;
|
||||
if (res != 0)
|
||||
return res;
|
||||
do3:
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[1];
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
do2:
|
||||
a0 = ((op_t *) srcp1)[2];
|
||||
b0 = ((op_t *) srcp2)[2];
|
||||
res = a1 - b1;
|
||||
if (res != 0)
|
||||
return res;
|
||||
do1:
|
||||
a1 = ((op_t *) srcp1)[3];
|
||||
b1 = ((op_t *) srcp2)[3];
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
srcp1 += 4 * OPSIZ;
|
||||
srcp2 += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
return a1 - b1;
|
||||
}
|
||||
|
||||
|
||||
/* SRCP2 should be aligned for memory operations on `op_t',
|
||||
but SRCP1 *should be unaligned*. */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
DEFUN(memcmp_not_common_alignment, (srcp1, srcp2, len),
|
||||
long int srcp1 AND long int srcp2 AND size_t len)
|
||||
{
|
||||
op_t a0, a1, a2, a3;
|
||||
op_t b0, b1, b2, b3;
|
||||
op_t res;
|
||||
op_t x;
|
||||
int shl, shr;
|
||||
|
||||
/* Calculate how to shift a word read at the memory operation
|
||||
aligned srcp1 to make it aligned for comparison. */
|
||||
|
||||
shl = 8 * (srcp1 % OPSIZ);
|
||||
shr = 8 * OPSIZ - shl;
|
||||
|
||||
/* Make SRCP1 aligned by rounding it down to the beginning of the `op_t'
|
||||
it points in the middle of. */
|
||||
srcp1 &= -OPSIZ;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
case 2:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
a2 = ((op_t *) srcp1)[1];
|
||||
b2 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= 1 * OPSIZ;
|
||||
srcp2 -= 2 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp2 -= 1 * OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return 0;
|
||||
a3 = ((op_t *) srcp1)[0];
|
||||
a0 = ((op_t *) srcp1)[1];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
srcp1 += 1 * OPSIZ;
|
||||
goto do3;
|
||||
case 1:
|
||||
a2 = ((op_t *) srcp1)[0];
|
||||
a3 = ((op_t *) srcp1)[1];
|
||||
b3 = ((op_t *) srcp2)[0];
|
||||
srcp1 += 2 * OPSIZ;
|
||||
srcp2 += 1 * OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
/* Fall through. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
x = MERGE(a2, shl, a3, shr);
|
||||
res = x - b3;
|
||||
if (res != 0)
|
||||
return res;
|
||||
do3:
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[1];
|
||||
x = MERGE(a3, shl, a0, shr);
|
||||
res = x - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
do2:
|
||||
a2 = ((op_t *) srcp1)[2];
|
||||
b2 = ((op_t *) srcp2)[2];
|
||||
x = MERGE(a0, shl, a1, shr);
|
||||
res = x - b1;
|
||||
if (res != 0)
|
||||
return res;
|
||||
do1:
|
||||
a3 = ((op_t *) srcp1)[3];
|
||||
b3 = ((op_t *) srcp2)[3];
|
||||
x = MERGE(a1, shl, a2, shr);
|
||||
res = x - b2;
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
srcp1 += 4 * OPSIZ;
|
||||
srcp2 += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
x = MERGE(a2, shl, a3, shr);
|
||||
return x - b3;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(memcmp, (s1, s2, n),
|
||||
CONST PTR s1 AND CONST PTR s2 AND size_t len)
|
||||
{
|
||||
op_t a0;
|
||||
op_t b0;
|
||||
long int srcp1 = (long int) s1;
|
||||
long int srcp2 = (long int) s2;
|
||||
op_t res;
|
||||
|
||||
if (len >= OP_T_THRES)
|
||||
{
|
||||
/* There are at least some bytes to compare. No need to test
|
||||
for LEN == 0 in this alignment loop. */
|
||||
while (srcp2 % OPSIZ != 0)
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
/* SRCP2 is now aligned for memory operations on `op_t'.
|
||||
SRCP1 alignment determines if we can do a simple,
|
||||
aligned compare or need to shuffle bits. */
|
||||
|
||||
if (srcp1 % OPSIZ == 0)
|
||||
res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ);
|
||||
else
|
||||
res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
/* Number of bytes remaining in the interval [0..OPSIZ-1]. */
|
||||
srcp1 += len & -OPSIZ;
|
||||
srcp2 += len & -OPSIZ;
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* There are just a few bytes to compare. Use byte memory operations. */
|
||||
while (len != 0)
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
148
gnu/glibc/glibc-1.03/sysdeps/generic/memcopy.h
Normal file
148
gnu/glibc/glibc-1.03/sysdeps/generic/memcopy.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/* memcopy.h -- definitions for memory copy functions. Generic C version.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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. */
|
||||
|
||||
/* The strategy of the memory functions is:
|
||||
|
||||
1. Copy bytes until the destination pointer is aligned.
|
||||
|
||||
2. Copy words in unrolled loops. If the source and destination
|
||||
are not aligned in the same way, use word memory operations,
|
||||
but shift and merge two read words before writing.
|
||||
|
||||
3. Copy the few remaining bytes.
|
||||
|
||||
This is fast on processors that have at least 10 registers for
|
||||
allocation by GCC, and that can access memory at reg+const in one
|
||||
instruction.
|
||||
|
||||
I made an "exhaustive" test of this memmove when I wrote it,
|
||||
exhaustive in the sense that I tried all alignment and length
|
||||
combinations, with and without overlap. */
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
/* The macros defined in this file are:
|
||||
|
||||
BYTE_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_to_copy)
|
||||
|
||||
BYTE_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_to_copy)
|
||||
|
||||
WORD_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_remaining, nbytes_to_copy)
|
||||
|
||||
WORD_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_remaining, nbytes_to_copy)
|
||||
|
||||
MERGE(old_word, sh_1, new_word, sh_2)
|
||||
[I fail to understand. I feel stupid. --roland]
|
||||
*/
|
||||
|
||||
/* Type to use for aligned memory operations.
|
||||
This should normally be the biggest type supported by a single load
|
||||
and store. */
|
||||
#define op_t unsigned long int
|
||||
#define OPSIZ (sizeof(op_t))
|
||||
|
||||
/* Type to use for unaligned operations. */
|
||||
typedef unsigned char byte;
|
||||
|
||||
/* Optimal type for storing bytes in registers. */
|
||||
#define reg_char char
|
||||
|
||||
#ifdef __LITTLE_ENDIAN
|
||||
#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
|
||||
#endif
|
||||
#ifdef __BIG_ENDIAN
|
||||
#define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
|
||||
#endif
|
||||
|
||||
/* Copy exactly NBYTES bytes from SRC_BP to DST_BP,
|
||||
without any assumptions about alignment of the pointers. */
|
||||
#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
size_t __nbytes = (nbytes); \
|
||||
while (__nbytes > 0) \
|
||||
{ \
|
||||
byte __x = ((byte *) src_bp)[0]; \
|
||||
src_bp += 1; \
|
||||
__nbytes -= 1; \
|
||||
((byte *) dst_bp)[0] = __x; \
|
||||
dst_bp += 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Copy exactly NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
|
||||
beginning at the bytes right before the pointers and continuing towards
|
||||
smaller addresses. Don't assume anything about alignment of the
|
||||
pointers. */
|
||||
#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
size_t __nbytes = (nbytes); \
|
||||
while (__nbytes > 0) \
|
||||
{ \
|
||||
byte __x; \
|
||||
src_ep -= 1; \
|
||||
__x = ((byte *) src_ep)[0]; \
|
||||
dst_ep -= 1; \
|
||||
__nbytes -= 1; \
|
||||
((byte *) dst_ep)[0] = __x; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with
|
||||
the assumption that DST_BP is aligned on an OPSIZ multiple. If
|
||||
not all bytes could be easily copied, store remaining number of bytes
|
||||
in NBYTES_LEFT, otherwise store 0. */
|
||||
extern void EXFUN(_wordcopy_fwd_aligned, (long int, long int, size_t));
|
||||
extern void EXFUN(_wordcopy_fwd_dest_aligned, (long int, long int, size_t));
|
||||
#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
if (src_bp % OPSIZ == 0) \
|
||||
_wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
|
||||
else \
|
||||
_wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
|
||||
src_bp += (nbytes) & -OPSIZ; \
|
||||
dst_bp += (nbytes) & -OPSIZ; \
|
||||
(nbytes_left) = (nbytes) % OPSIZ; \
|
||||
} while (0)
|
||||
|
||||
/* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
|
||||
beginning at the words (of type op_t) right before the pointers and
|
||||
continuing towards smaller addresses. May take advantage of that
|
||||
DST_END_PTR is aligned on an OPSIZ multiple. If not all bytes could be
|
||||
easily copied, store remaining number of bytes in NBYTES_REMAINING,
|
||||
otherwise store 0. */
|
||||
extern void EXFUN(_wordcopy_bwd_aligned, (long int, long int, size_t));
|
||||
extern void EXFUN(_wordcopy_bwd_dest_aligned, (long int, long int, size_t));
|
||||
#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
if (src_ep % OPSIZ == 0) \
|
||||
_wordcopy_bwd_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
|
||||
else \
|
||||
_wordcopy_bwd_dest_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
|
||||
src_ep -= (nbytes) & -OPSIZ; \
|
||||
dst_ep -= (nbytes) & -OPSIZ; \
|
||||
(nbytes_left) = (nbytes) % OPSIZ; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Threshold value for when to enter the unrolled loops. */
|
||||
#define OP_T_THRES 16
|
||||
55
gnu/glibc/glibc-1.03/sysdeps/generic/memcpy.c
Normal file
55
gnu/glibc/glibc-1.03/sysdeps/generic/memcpy.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* memcpy -- copy memory to memory until the specified number of bytes
|
||||
has been copied. Overlap is NOT handled correctly.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
PTR
|
||||
DEFUN(memcpy, (dstpp, srcpp, len),
|
||||
PTR dstpp AND CONST PTR srcpp AND size_t len)
|
||||
{
|
||||
unsigned long int dstp = (long int) dstpp;
|
||||
unsigned long int srcp = (long int) srcpp;
|
||||
|
||||
/* Copy from the beginning to the end. */
|
||||
|
||||
/* If there not too few bytes to copy, use word copy. */
|
||||
if (len >= OP_T_THRES)
|
||||
{
|
||||
/* Copy just a few bytes to make DSTP aligned. */
|
||||
len -= (-dstp) % OPSIZ;
|
||||
BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
|
||||
|
||||
/* Copy from SRCP to DSTP taking advantage of the known
|
||||
alignment of DSTP. Number of bytes remaining is put
|
||||
in the third argumnet, i.e. in LEN. This number may
|
||||
vary from machine to machine. */
|
||||
|
||||
WORD_COPY_FWD (dstp, srcp, len, len);
|
||||
|
||||
/* Fall out and copy the tail. */
|
||||
}
|
||||
|
||||
/* There are just a few bytes to copy. Use byte memory operations. */
|
||||
BYTE_COPY_FWD (dstp, srcp, len);
|
||||
|
||||
return dstpp;
|
||||
}
|
||||
99
gnu/glibc/glibc-1.03/sysdeps/generic/memmove.c
Normal file
99
gnu/glibc/glibc-1.03/sysdeps/generic/memmove.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/* memmove -- copy memory to memory until the specified number of bytes
|
||||
has been copied. Overlap is handled correctly.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* All this is so that bcopy.c can #include
|
||||
this file after defining some things. */
|
||||
#ifndef a1
|
||||
#define a1 dest /* First arg is DEST. */
|
||||
#define a1const
|
||||
#define a2 src /* Second arg is SRC. */
|
||||
#define a2const CONST
|
||||
#endif
|
||||
#if !defined(RETURN) || !defined(rettype)
|
||||
#define RETURN(s) return (s) /* Return DEST. */
|
||||
#define rettype PTR
|
||||
#endif
|
||||
|
||||
rettype
|
||||
DEFUN(memmove, (a1, a2, len),
|
||||
a1const PTR a1 AND a2const PTR a2 AND size_t len)
|
||||
{
|
||||
unsigned long int dstp = (long int) dest;
|
||||
unsigned long int srcp = (long int) src;
|
||||
|
||||
/* This test makes the forward copying code be used whenever possible.
|
||||
Reduces the working set. */
|
||||
if (dstp - srcp >= len) /* *Unsigned* compare! */
|
||||
{
|
||||
/* Copy from the beginning to the end. */
|
||||
|
||||
/* If there not too few bytes to copy, use word copy. */
|
||||
if (len >= OP_T_THRES)
|
||||
{
|
||||
/* Copy just a few bytes to make DSTP aligned. */
|
||||
len -= (-dstp) % OPSIZ;
|
||||
BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
|
||||
|
||||
/* Copy from SRCP to DSTP taking advantage of the known
|
||||
alignment of DSTP. Number of bytes remaining is put
|
||||
in the third argumnet, i.e. in LEN. This number may
|
||||
vary from machine to machine. */
|
||||
|
||||
WORD_COPY_FWD (dstp, srcp, len, len);
|
||||
|
||||
/* Fall out and copy the tail. */
|
||||
}
|
||||
|
||||
/* There are just a few bytes to copy. Use byte memory operations. */
|
||||
BYTE_COPY_FWD (dstp, srcp, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Copy from the end to the beginning. */
|
||||
srcp += len;
|
||||
dstp += len;
|
||||
|
||||
/* If there not too few bytes to copy, use word copy. */
|
||||
if (len >= OP_T_THRES)
|
||||
{
|
||||
/* Copy just a few bytes to make DSTP aligned. */
|
||||
len -= dstp % OPSIZ;
|
||||
BYTE_COPY_BWD (dstp, srcp, dstp % OPSIZ);
|
||||
|
||||
/* Copy from SRCP to DSTP taking advantage of the known
|
||||
alignment of DSTP. Number of bytes remaining is put
|
||||
in the third argumnet, i.e. in LEN. This number may
|
||||
vary from machine to machine. */
|
||||
|
||||
WORD_COPY_BWD (dstp, srcp, len, len);
|
||||
|
||||
/* Fall out and copy the tail. */
|
||||
}
|
||||
|
||||
/* There are just a few bytes to copy. Use byte memory operations. */
|
||||
BYTE_COPY_BWD (dstp, srcp, len);
|
||||
}
|
||||
|
||||
RETURN(dest);
|
||||
}
|
||||
85
gnu/glibc/glibc-1.03/sysdeps/generic/memset.c
Normal file
85
gnu/glibc/glibc-1.03/sysdeps/generic/memset.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
PTR
|
||||
DEFUN(memset, (dstpp, c, len), PTR dstpp AND int c AND size_t len)
|
||||
{
|
||||
long int dstp = (long int) dstpp;
|
||||
|
||||
if (len >= 8)
|
||||
{
|
||||
size_t xlen;
|
||||
op_t cccc;
|
||||
|
||||
cccc = (unsigned char) c;
|
||||
cccc |= cccc << 8;
|
||||
cccc |= cccc << 16;
|
||||
if (OPSIZ > 4)
|
||||
cccc |= cccc << 32;
|
||||
|
||||
/* There are at least some bytes to set.
|
||||
No need to test for LEN == 0 in this alignment loop. */
|
||||
while (dstp % OPSIZ != 0)
|
||||
{
|
||||
((byte *) dstp)[0] = c;
|
||||
dstp += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
/* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */
|
||||
xlen = len / (OPSIZ * 8);
|
||||
while (xlen > 0)
|
||||
{
|
||||
((op_t *) dstp)[0] = cccc;
|
||||
((op_t *) dstp)[1] = cccc;
|
||||
((op_t *) dstp)[2] = cccc;
|
||||
((op_t *) dstp)[3] = cccc;
|
||||
((op_t *) dstp)[4] = cccc;
|
||||
((op_t *) dstp)[5] = cccc;
|
||||
((op_t *) dstp)[6] = cccc;
|
||||
((op_t *) dstp)[7] = cccc;
|
||||
dstp += 8 * OPSIZ;
|
||||
xlen -= 1;
|
||||
}
|
||||
len %= OPSIZ * 8;
|
||||
|
||||
/* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */
|
||||
xlen = len / OPSIZ;
|
||||
while (xlen > 0)
|
||||
{
|
||||
((op_t *) dstp)[0] = cccc;
|
||||
dstp += OPSIZ;
|
||||
xlen -= 1;
|
||||
}
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* Write the last few bytes. */
|
||||
while (len > 0)
|
||||
{
|
||||
((byte *) dstp)[0] = c;
|
||||
dstp += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return dstpp;
|
||||
}
|
||||
31
gnu/glibc/glibc-1.03/sysdeps/generic/modf.c
Normal file
31
gnu/glibc/glibc-1.03/sysdeps/generic/modf.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef modf
|
||||
|
||||
/* Break VALUE into integral and fractional parts. */
|
||||
double
|
||||
DEFUN(modf, (value, iptr), double value AND double *iptr)
|
||||
{
|
||||
register double ipart = floor(value);
|
||||
*iptr = ipart;
|
||||
return value - ipart;
|
||||
}
|
||||
10
gnu/glibc/glibc-1.03/sysdeps/generic/ntohl.c
Normal file
10
gnu/glibc/glibc-1.03/sysdeps/generic/ntohl.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <ansidecl.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#undef ntohl
|
||||
|
||||
unsigned long int
|
||||
DEFUN(ntohl, (x), unsigned long int x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
10
gnu/glibc/glibc-1.03/sysdeps/generic/ntohs.c
Normal file
10
gnu/glibc/glibc-1.03/sysdeps/generic/ntohs.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <ansidecl.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#undef ntohs
|
||||
|
||||
unsigned short int
|
||||
DEFUN(ntohs, (x), unsigned short int x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
37
gnu/glibc/glibc-1.03/sysdeps/generic/pow.c
Normal file
37
gnu/glibc/glibc-1.03/sysdeps/generic/pow.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return X to the Y power. */
|
||||
double
|
||||
DEFUN(pow, (x, y), double x AND double y)
|
||||
{
|
||||
if (y == 0.0 || x == 1.0)
|
||||
return 1.0;
|
||||
else if (y == 1.0)
|
||||
return x;
|
||||
else if (y == 2.0)
|
||||
return x * x;
|
||||
else if (y == -1.0)
|
||||
return 1.0 / x;
|
||||
|
||||
return exp(y * log(x));
|
||||
}
|
||||
499
gnu/glibc/glibc-1.03/sysdeps/generic/printf_fp.c
Normal file
499
gnu/glibc/glibc-1.03/sysdeps/generic/printf_fp.c
Normal file
@@ -0,0 +1,499 @@
|
||||
/* Floating-point printing for `printf'.
|
||||
This is an implementation of a restricted form of the `Dragon4'
|
||||
algorithm described in "How to Print Floating-Point Numbers Accurately",
|
||||
by Guy L. Steele, Jr. and Jon L. White, presented at the ACM SIGPLAN '90
|
||||
Conference on Programming Language Design and Implementation.
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <localeinfo.h>
|
||||
|
||||
#include <printf.h>
|
||||
|
||||
#define outchar(x) \
|
||||
do \
|
||||
{ \
|
||||
register CONST int outc = (x); \
|
||||
if (putc(outc, s) == EOF) \
|
||||
return -1; \
|
||||
else \
|
||||
++done; \
|
||||
} while (0)
|
||||
|
||||
#if FLT_RADIX != 2
|
||||
|
||||
double
|
||||
frexp (double f, int *e)
|
||||
{
|
||||
#error "Don't know how to extract fraction and exponent from `double'."
|
||||
}
|
||||
|
||||
#undef ldexp
|
||||
#ifdef __GNUC__
|
||||
inline
|
||||
#endif
|
||||
static double
|
||||
ldexp (double f, int e)
|
||||
{
|
||||
while (e > 0)
|
||||
{
|
||||
f *= FLT_RADIX;
|
||||
--e;
|
||||
}
|
||||
while (e < 0)
|
||||
{
|
||||
f /= FLT_RADIX;
|
||||
++e;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
DEFUN(__printf_fp, (s, info, args),
|
||||
FILE *s AND CONST struct printf_info *info AND va_list *args)
|
||||
{
|
||||
int done = 0;
|
||||
|
||||
/* Decimal point character. */
|
||||
CONST char *CONST decimal = _numeric_info->decimal_point;
|
||||
|
||||
LONG_DOUBLE fpnum; /* Input. */
|
||||
int is_neg;
|
||||
|
||||
LONG_DOUBLE f; /* Fraction. */
|
||||
|
||||
int e; /* Base-2 exponent of the input. */
|
||||
CONST int p = DBL_MANT_DIG; /* Internal precision. */
|
||||
LONG_DOUBLE scale, scale10; /* Scale factor. */
|
||||
LONG_DOUBLE loerr, hierr; /* Potential error in the fraction. */
|
||||
int k; /* Digits to the left of the decimal point. */
|
||||
int cutoff; /* Where to stop generating digits. */
|
||||
LONG_DOUBLE r, r2, r10; /* Remainder. */
|
||||
int roundup;
|
||||
int low, high;
|
||||
char digit;
|
||||
|
||||
int j;
|
||||
|
||||
char type = tolower (info->spec);
|
||||
int prec = info->prec;
|
||||
int width = info->width;
|
||||
|
||||
/* This algorithm has the nice property of not needing a buffer.
|
||||
However, to get the padding right for %g format, we need to know
|
||||
the length of the number before printing it. */
|
||||
char *buf = __alloca ((prec > LDBL_DIG ? prec : LDBL_DIG) +
|
||||
LDBL_MAX_10_EXP + 3); /* Dot, e, exp. sign. */
|
||||
register char *bp = buf;
|
||||
#define put(c) *bp++ = (c)
|
||||
|
||||
/* Fetch the argument value. */
|
||||
if (info->is_long_double)
|
||||
fpnum = va_arg (*args, LONG_DOUBLE);
|
||||
else
|
||||
fpnum = (LONG_DOUBLE) va_arg (*args, double);
|
||||
|
||||
#ifdef HANDLE_SPECIAL
|
||||
/* Allow for machine-dependent (or floating point format-dependent) code. */
|
||||
HANDLE_SPECIAL (done, s, info, fpnum);
|
||||
#endif
|
||||
|
||||
#ifndef IS_NEGATIVE
|
||||
#define IS_NEGATIVE(num) ((num) < 0)
|
||||
#endif
|
||||
|
||||
is_neg = IS_NEGATIVE (fpnum);
|
||||
if (is_neg)
|
||||
fpnum = - fpnum;
|
||||
|
||||
if (prec == -1)
|
||||
prec = 6;
|
||||
|
||||
if (type == 'g')
|
||||
{
|
||||
if (prec == 0)
|
||||
prec = 1;
|
||||
|
||||
if (fpnum != 0)
|
||||
{
|
||||
if (fpnum < 1e-4)
|
||||
type = 'e';
|
||||
else
|
||||
{
|
||||
f = 10;
|
||||
j = prec;
|
||||
if (j > p)
|
||||
j = p;
|
||||
while (--j > 0)
|
||||
{
|
||||
f *= 10;
|
||||
if (f > fpnum)
|
||||
{
|
||||
type = 'e';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* For 'g'/'G' format, the precision specifies "significant digits",
|
||||
not digits to come after the decimal point. */
|
||||
--prec;
|
||||
}
|
||||
|
||||
if (fpnum == 0)
|
||||
/* Special case for zero.
|
||||
The general algorithm does not work for zero. */
|
||||
{
|
||||
put ('0');
|
||||
if (tolower (info->spec) != 'g' || info->alt)
|
||||
{
|
||||
if (prec > 0 || info->alt)
|
||||
put (*decimal);
|
||||
while (--prec > 0)
|
||||
put ('0');
|
||||
}
|
||||
if (type == 'e')
|
||||
{
|
||||
put (info->spec);
|
||||
put ('+');
|
||||
put ('0');
|
||||
put ('0');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Split the number into a fraction and base-2 exponent. */
|
||||
f = frexp (fpnum, &e);
|
||||
|
||||
/* Scale the fractional part by the highest possible number of
|
||||
significant bits of fraction. We want to represent the
|
||||
fractional part as a (very) large integer. */
|
||||
f = ldexp (f, p);
|
||||
|
||||
cutoff = -prec;
|
||||
|
||||
roundup = 0;
|
||||
|
||||
if (e > p)
|
||||
{
|
||||
/* The exponent is bigger than the number of fractional digits. */
|
||||
r = ldexp (f, e - p);
|
||||
scale = 1;
|
||||
/* The number is (E - P) factors of two larger than
|
||||
the fraction can represent; this is the potential error. */
|
||||
loerr = ldexp (1.0, e - p);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The number of fractional digits is greater than the exponent.
|
||||
Scale by the difference factors of two. */
|
||||
r = f;
|
||||
scale = ldexp (1.0, p - e);
|
||||
loerr = 1.0;
|
||||
}
|
||||
hierr = loerr;
|
||||
|
||||
/* Fixup. */
|
||||
|
||||
if (f == ldexp (1.0, p - 1))
|
||||
{
|
||||
/* Account for unequal gaps. */
|
||||
hierr = ldexp (hierr, 1);
|
||||
r = ldexp (r, 1);
|
||||
scale = ldexp (scale, 1);
|
||||
}
|
||||
|
||||
scale10 = ceil (scale / 10.0);
|
||||
k = 0;
|
||||
while (r < scale10)
|
||||
{
|
||||
--k;
|
||||
r *= 10;
|
||||
loerr *= 10;
|
||||
hierr *= 10;
|
||||
}
|
||||
do
|
||||
{
|
||||
r2 = 2 * r;
|
||||
|
||||
while (r2 + hierr >= 2 * scale)
|
||||
{
|
||||
scale *= 10;
|
||||
++k;
|
||||
}
|
||||
|
||||
/* Perform any necessary adjustment of loerr and hierr to
|
||||
take into account the formatting requirements. */
|
||||
|
||||
if (type == 'e')
|
||||
cutoff += k; /* CutOffMode == "relative". */
|
||||
/* Otherwise CutOffMode == "absolute". */
|
||||
|
||||
{ /* CutOffAdjust. */
|
||||
int a = cutoff - k;
|
||||
double y = scale;
|
||||
while (a > 0)
|
||||
{
|
||||
y *= 10;
|
||||
--a;
|
||||
}
|
||||
while (a < 0)
|
||||
{
|
||||
y = ceil (y / 10);
|
||||
++a;
|
||||
}
|
||||
/* y == ceil (scale * pow (10.0, (double) (cutoff - k))) */
|
||||
if (y > loerr)
|
||||
loerr = y;
|
||||
if (y > hierr)
|
||||
{
|
||||
hierr = y;
|
||||
roundup = 1;
|
||||
}
|
||||
} /* End CutOffAdjust. */
|
||||
} while (r2 + hierr >= 2 * scale);
|
||||
|
||||
/* End Fixup. */
|
||||
|
||||
/* First digit. */
|
||||
--k;
|
||||
r10 = r * 10;
|
||||
digit = '0' + (unsigned int) floor (r10 / scale);
|
||||
r = fmod (r10, scale);
|
||||
loerr *= 10;
|
||||
hierr *= 10;
|
||||
|
||||
low = 2 * r < loerr;
|
||||
if (roundup)
|
||||
high = 2 * r >= (2 * scale) - hierr;
|
||||
else
|
||||
high = 2 * r > (2 * scale) - hierr;
|
||||
|
||||
if (low || high || k == cutoff)
|
||||
{
|
||||
if ((high && !low) || (2 * r > scale))
|
||||
++digit;
|
||||
}
|
||||
|
||||
if (type == 'e')
|
||||
{
|
||||
/* Exponential notation. */
|
||||
|
||||
int expt = k; /* Base-10 exponent. */
|
||||
|
||||
/* Find the magnitude of the exponent. */
|
||||
j = 1;
|
||||
do
|
||||
j *= 10;
|
||||
while (j <= expt);
|
||||
|
||||
/* Write the first digit. */
|
||||
put (digit);
|
||||
|
||||
if (low || high || k == cutoff)
|
||||
{
|
||||
if (prec > 0 || info->alt)
|
||||
put (*decimal);
|
||||
}
|
||||
else
|
||||
{
|
||||
put (*decimal);
|
||||
|
||||
/* First post-decimal digit. */
|
||||
--k;
|
||||
r10 = r * 10;
|
||||
digit = '0' + (unsigned int) floor (r10 / scale);
|
||||
r = fmod (r10, scale);
|
||||
loerr *= 10;
|
||||
hierr *= 10;
|
||||
|
||||
low = 2 * r < loerr;
|
||||
if (roundup)
|
||||
high = 2 * r >= (2 * scale) - hierr;
|
||||
else
|
||||
high = 2 * r > (2 * scale) - hierr;
|
||||
|
||||
if (low || high || k == cutoff)
|
||||
{
|
||||
if ((high && !low) || (2 * r > scale))
|
||||
++digit;
|
||||
put (digit);
|
||||
}
|
||||
else
|
||||
{
|
||||
put (digit);
|
||||
|
||||
/* Remaining digits. */
|
||||
while (1)
|
||||
{
|
||||
--k;
|
||||
r10 = r * 10;
|
||||
digit = '0' + (unsigned int) floor (r10 / scale);
|
||||
r = fmod (r10, scale);
|
||||
loerr *= 10;
|
||||
hierr *= 10;
|
||||
|
||||
low = 2 * r < loerr;
|
||||
if (roundup)
|
||||
high = 2 * r >= (2 * scale) - hierr;
|
||||
else
|
||||
high = 2 * r > (2 * scale) - hierr;
|
||||
|
||||
if (low || high || k == cutoff)
|
||||
{
|
||||
if ((high && !low) || (2 * r > scale))
|
||||
++digit;
|
||||
put (digit);
|
||||
break;
|
||||
}
|
||||
|
||||
put (digit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tolower (info->spec) != 'g' || info->alt)
|
||||
/* Pad with zeros. */
|
||||
while (k-- >= cutoff)
|
||||
put ('0');
|
||||
|
||||
/* Write the exponent. */
|
||||
put (isupper (info->spec) ? 'E' : 'e');
|
||||
put (expt < 0 ? '-' : '+');
|
||||
expt = abs (expt);
|
||||
if (expt < 10)
|
||||
/* Exponent always has at least two digits. */
|
||||
put ('0');
|
||||
do
|
||||
{
|
||||
j /= 10;
|
||||
put ('0' + (expt / j));
|
||||
expt %= j;
|
||||
}
|
||||
while (j > 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Decimal fraction notation. */
|
||||
|
||||
if (k < 0)
|
||||
{
|
||||
put ('0');
|
||||
if (prec > 0 || info->alt)
|
||||
put (*decimal);
|
||||
}
|
||||
|
||||
/* Write leading fractional zeros. */
|
||||
j = 0;
|
||||
while (--j > k)
|
||||
put ('0');
|
||||
|
||||
if (low || high || k == cutoff)
|
||||
put (digit);
|
||||
else
|
||||
while (1)
|
||||
{
|
||||
put (digit);
|
||||
|
||||
--k;
|
||||
digit = '0' + (unsigned int) floor ((r * 10) / scale);
|
||||
r = fmod (r * 10, scale);
|
||||
loerr *= 10;
|
||||
hierr *= 10;
|
||||
|
||||
low = 2 * r < loerr;
|
||||
if (roundup)
|
||||
high = 2 * r >= (2 * scale) - hierr;
|
||||
else
|
||||
high = 2 * r > (2 * scale) - hierr;
|
||||
|
||||
if (low || high || k == cutoff)
|
||||
{
|
||||
if ((high && !low) || (2 * r > scale))
|
||||
++digit;
|
||||
put (digit);
|
||||
break;
|
||||
}
|
||||
|
||||
if (k == -1)
|
||||
put (*decimal);
|
||||
}
|
||||
while (k > 0)
|
||||
{
|
||||
put ('0');
|
||||
--k;
|
||||
}
|
||||
if (k == 0 && (prec > 0 || info->alt))
|
||||
{
|
||||
put (*decimal);
|
||||
while (prec-- > 0)
|
||||
put ('0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef put
|
||||
|
||||
/* The number is all converted in BUF.
|
||||
Now write it with sign and appropriate padding. */
|
||||
|
||||
if (is_neg || info->showsign || info->space)
|
||||
--width;
|
||||
|
||||
width -= bp - buf;
|
||||
|
||||
if (!info->left && info->pad == ' ')
|
||||
/* Pad with spaces on the left. */
|
||||
while (width-- > 0)
|
||||
outchar (' ');
|
||||
|
||||
/* Write the sign. */
|
||||
if (is_neg)
|
||||
outchar ('-');
|
||||
else if (info->showsign)
|
||||
outchar ('+');
|
||||
else if (info->space)
|
||||
outchar (' ');
|
||||
|
||||
if (!info->left && info->pad == '0')
|
||||
/* Pad with zeros on the left. */
|
||||
while (width-- > 0)
|
||||
outchar ('0');
|
||||
|
||||
if (fwrite (buf, bp - buf, 1, s) != 1)
|
||||
return -1;
|
||||
done += bp - buf;
|
||||
|
||||
if (info->left)
|
||||
/* Pad with spaces on the right. */
|
||||
while (width-- > 0)
|
||||
outchar (' ');
|
||||
|
||||
return done;
|
||||
}
|
||||
248
gnu/glibc/glibc-1.03/sysdeps/generic/signame.c
Normal file
248
gnu/glibc/glibc-1.03/sysdeps/generic/signame.c
Normal file
@@ -0,0 +1,248 @@
|
||||
/* Convert between signal names and numbers.
|
||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include "signame.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
#define CONST const
|
||||
#else
|
||||
#define CONST
|
||||
#endif
|
||||
|
||||
#ifdef SYS_SIGLIST_MISSING
|
||||
/* There is too much variation in Sys V signal numbers and names, so
|
||||
we must initialize them at runtime. */
|
||||
|
||||
static CONST char undoc[] = "unknown signal";
|
||||
|
||||
CONST char *sys_siglist[NSIG];
|
||||
#endif /* SYS_SIGLIST_MISSING */
|
||||
|
||||
/* Table of abbreviations for signals. Note: A given number can
|
||||
appear more than once with different abbreviations. */
|
||||
typedef struct
|
||||
{
|
||||
int number;
|
||||
CONST char *abbrev;
|
||||
} num_abbrev;
|
||||
static num_abbrev sig_table[NSIG*2];
|
||||
/* Number of elements of sig_table used. */
|
||||
static int sig_table_nelts = 0;
|
||||
|
||||
/* Enter signal number NUMBER into the tables with ABBREV and NAME. */
|
||||
static void
|
||||
init_sig (number, abbrev, name)
|
||||
int number;
|
||||
CONST char *abbrev;
|
||||
CONST char *name;
|
||||
{
|
||||
#ifdef SYS_SIGLIST_MISSING
|
||||
sys_siglist[number] = name;
|
||||
#endif
|
||||
sig_table[sig_table_nelts].number = number;
|
||||
sig_table[sig_table_nelts++].abbrev = abbrev;
|
||||
}
|
||||
|
||||
static void
|
||||
init_sigs ()
|
||||
{
|
||||
#ifdef SYS_SIGLIST_MISSING
|
||||
int i;
|
||||
/* Initialize signal names. */
|
||||
for (i = 0; i < NSIG; i++)
|
||||
sys_siglist[i] = undoc;
|
||||
#endif /* SYS_SIGLIST_MISSING */
|
||||
|
||||
/* Initialize signal names. */
|
||||
#if defined (SIGHUP)
|
||||
init_sig (SIGHUP, "HUP", "Hangup");
|
||||
#endif
|
||||
#if defined (SIGINT)
|
||||
init_sig (SIGINT, "INT", "Interrupt");
|
||||
#endif
|
||||
#if defined (SIGQUIT)
|
||||
init_sig (SIGQUIT, "QUIT", "Quit");
|
||||
#endif
|
||||
#if defined (SIGILL)
|
||||
init_sig (SIGILL, "ILL", "Illegal Instruction");
|
||||
#endif
|
||||
#if defined (SIGTRAP)
|
||||
init_sig (SIGTRAP, "TRAP", "Trace/breakpoint trap");
|
||||
#endif
|
||||
/* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
|
||||
SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
|
||||
#if defined (SIGABRT)
|
||||
init_sig (SIGABRT, "ABRT", "Aborted");
|
||||
#endif
|
||||
#if defined (SIGIOT)
|
||||
init_sig (SIGIOT, "IOT", "IOT trap");
|
||||
#endif
|
||||
#if defined (SIGEMT)
|
||||
init_sig (SIGEMT, "EMT", "EMT trap");
|
||||
#endif
|
||||
#if defined (SIGFPE)
|
||||
init_sig (SIGFPE, "FPE", "Floating point exception");
|
||||
#endif
|
||||
#if defined (SIGKILL)
|
||||
init_sig (SIGKILL, "KILL", "Killed");
|
||||
#endif
|
||||
#if defined (SIGBUS)
|
||||
init_sig (SIGBUS, "BUS", "Bus error");
|
||||
#endif
|
||||
#if defined (SIGSEGV)
|
||||
init_sig (SIGSEGV, "SEGV", "Segmentation fault");
|
||||
#endif
|
||||
#if defined (SIGSYS)
|
||||
init_sig (SIGSYS, "SYS", "Bad system call");
|
||||
#endif
|
||||
#if defined (SIGPIPE)
|
||||
init_sig (SIGPIPE, "PIPE", "Broken pipe");
|
||||
#endif
|
||||
#if defined (SIGALRM)
|
||||
init_sig (SIGALRM, "ALRM", "Alarm clock");
|
||||
#endif
|
||||
#if defined (SIGTERM)
|
||||
init_sig (SIGTERM, "TERM", "Terminated");
|
||||
#endif
|
||||
#if defined (SIGUSR1)
|
||||
init_sig (SIGUSR1, "USR1", "User defined signal 1");
|
||||
#endif
|
||||
#if defined (SIGUSR2)
|
||||
init_sig (SIGUSR2, "USR2", "User defined signal 2");
|
||||
#endif
|
||||
/* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
|
||||
is what is in POSIX.1. */
|
||||
#if defined (SIGCHLD)
|
||||
init_sig (SIGCHLD, "CHLD", "Child exited");
|
||||
#endif
|
||||
#if defined (SIGCLD)
|
||||
init_sig (SIGCLD, "CLD", "Child exited");
|
||||
#endif
|
||||
#if defined (SIGPWR)
|
||||
init_sig (SIGPWR, "PWR", "Power failure");
|
||||
#endif
|
||||
#if defined (SIGTSTP)
|
||||
init_sig (SIGTSTP, "TSTP", "Stopped");
|
||||
#endif
|
||||
#if defined (SIGTTIN)
|
||||
init_sig (SIGTTIN, "TTIN", "Stopped (tty input)");
|
||||
#endif
|
||||
#if defined (SIGTTOU)
|
||||
init_sig (SIGTTOU, "TTOU", "Stopped (tty output)");
|
||||
#endif
|
||||
#if defined (SIGSTOP)
|
||||
init_sig (SIGSTOP, "STOP", "Stopped (signal)");
|
||||
#endif
|
||||
#if defined (SIGXCPU)
|
||||
init_sig (SIGXCPU, "XCPU", "CPU time limit exceeded");
|
||||
#endif
|
||||
#if defined (SIGXFSZ)
|
||||
init_sig (SIGXFSZ, "XFSZ", "File size limit exceeded");
|
||||
#endif
|
||||
#if defined (SIGVTALRM)
|
||||
init_sig (SIGVTALRM, "VTALRM", "Virtual timer expired");
|
||||
#endif
|
||||
#if defined (SIGPROF)
|
||||
init_sig (SIGPROF, "PROF", "Profiling timer expired");
|
||||
#endif
|
||||
#if defined (SIGWINCH)
|
||||
/* "Window size changed" might be more accurate, but even if that
|
||||
is all that it means now, perhaps in the future it will be
|
||||
extended to cover other kinds of window changes. */
|
||||
init_sig (SIGWINCH, "WINCH", "Window changed");
|
||||
#endif
|
||||
#if defined (SIGCONT)
|
||||
init_sig (SIGCONT, "CONT", "Continued");
|
||||
#endif
|
||||
#if defined (SIGURG)
|
||||
init_sig (SIGURG, "URG", "Urgent I/O condition");
|
||||
#endif
|
||||
#if defined (SIGIO)
|
||||
/* "I/O pending" has also been suggested. A disadvantage is
|
||||
that signal only happens when the process has
|
||||
asked for it, not everytime I/O is pending. Another disadvantage
|
||||
is the confusion from giving it a different name than under Unix. */
|
||||
init_sig (SIGIO, "IO", "I/O possible");
|
||||
#endif
|
||||
#if defined (SIGWIND)
|
||||
init_sig (SIGWIND, "WIND", "SIGWIND");
|
||||
#endif
|
||||
#if defined (SIGPHONE)
|
||||
init_sig (SIGPHONE, "PHONE", "SIGPHONE");
|
||||
#endif
|
||||
#if defined (SIGPOLL)
|
||||
init_sig (SIGPOLL, "POLL", "I/O possible");
|
||||
#endif
|
||||
#if defined (SIGLOST)
|
||||
init_sig (SIGLOST, "LOST", "Resource lost");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the abbreviation for signal NUMBER. */
|
||||
char *
|
||||
sig_abbrev (number)
|
||||
int number;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (sig_table_nelts == 0)
|
||||
init_sigs ();
|
||||
|
||||
for (i = 0; i < sig_table_nelts; i++)
|
||||
if (sig_table[i].number == number)
|
||||
return (char *)sig_table[i].abbrev;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return the signal number for an ABBREV, or -1 if there is no
|
||||
signal by that name. */
|
||||
int
|
||||
sig_number (abbrev)
|
||||
CONST char *abbrev;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (sig_table_nelts == 0)
|
||||
init_sigs ();
|
||||
|
||||
/* Skip over "SIG" if present. */
|
||||
if (abbrev[0] == 'S' && abbrev[1] == 'I' && abbrev[2] == 'G')
|
||||
abbrev += 3;
|
||||
|
||||
for (i = 0; i < sig_table_nelts; i++)
|
||||
if (abbrev[0] == sig_table[i].abbrev[0]
|
||||
&& strcmp (abbrev, sig_table[i].abbrev) == 0)
|
||||
return sig_table[i].number;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined (SYS_SIGLIST_MISSING)
|
||||
/* Print to standard error the name of SIGNAL, preceded by MESSAGE and
|
||||
a colon, and followed by a newline. */
|
||||
void
|
||||
psignal (signal, message)
|
||||
int signal;
|
||||
CONST char *message;
|
||||
{
|
||||
if (signal <= 0 || signal >= NSIG)
|
||||
fprintf (stderr, "%s: unknown signal", message);
|
||||
else
|
||||
fprintf (stderr, "%s: %s\n", message, sys_siglist[signal]);
|
||||
}
|
||||
#endif
|
||||
42
gnu/glibc/glibc-1.03/sysdeps/generic/signame.h
Normal file
42
gnu/glibc/glibc-1.03/sysdeps/generic/signame.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Convert between signal names and numbers.
|
||||
Copyright (C) 1990 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifdef __STDC__
|
||||
/* Return the abbreviation (e.g. ABRT, FPE, etc.) for signal NUMBER.
|
||||
Do not return this as a const char *. The caller might want to
|
||||
assign it to a char *. */
|
||||
char *sig_abbrev (int number);
|
||||
|
||||
/* Return the signal number for an ABBREV, or -1 if there is no
|
||||
signal by that name. */
|
||||
int sig_number (const char *abbrev);
|
||||
|
||||
/* Print to standard error the name of SIGNAL, preceded by MESSAGE and
|
||||
a colon, and followed by a newline. */
|
||||
void psignal (int signal, const char *message);
|
||||
|
||||
/* Names for signals from 0 to NSIG-1. */
|
||||
extern const char *sys_siglist[];
|
||||
|
||||
#else
|
||||
|
||||
char *sig_abbrev ();
|
||||
int sig_number ();
|
||||
void psignal ();
|
||||
extern char *sys_siglist[];
|
||||
|
||||
#endif
|
||||
35
gnu/glibc/glibc-1.03/sysdeps/generic/stpcpy.c
Normal file
35
gnu/glibc/glibc-1.03/sysdeps/generic/stpcpy.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
|
||||
char *
|
||||
DEFUN(stpcpy, (dest, src), char *dest AND CONST char *src)
|
||||
{
|
||||
register char *d = dest;
|
||||
register CONST char *s = src;
|
||||
|
||||
do
|
||||
*d++ = *s;
|
||||
while (*s++ != '\0');
|
||||
|
||||
return d - 1;
|
||||
}
|
||||
51
gnu/glibc/glibc-1.03/sysdeps/generic/strcasecmp.c
Normal file
51
gnu/glibc/glibc-1.03/sysdeps/generic/strcasecmp.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
/* Compare S1 and S2, ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexiographically less than,
|
||||
equal to or greater than S2. */
|
||||
int
|
||||
DEFUN(strcasecmp, (s1, s2), CONST char *s1 AND CONST char *s2)
|
||||
{
|
||||
register CONST unsigned char *p1 = (CONST unsigned char *) s1;
|
||||
register CONST unsigned char *p2 = (CONST unsigned char *) s2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2)
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = tolower(*p1++);
|
||||
c2 = tolower(*p2++);
|
||||
if (c1 != c2)
|
||||
break;
|
||||
}
|
||||
while (c1 != '\0');
|
||||
|
||||
if (c1 == '\0')
|
||||
return -1;
|
||||
else if (c2 == '\0')
|
||||
return 1;
|
||||
return c1 - c2;
|
||||
}
|
||||
48
gnu/glibc/glibc-1.03/sysdeps/generic/strcat.c
Normal file
48
gnu/glibc/glibc-1.03/sysdeps/generic/strcat.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* Append SRC on the end of DEST. */
|
||||
char *
|
||||
DEFUN(strcat, (dest, src), char *dest AND CONST char *src)
|
||||
{
|
||||
register char *s1 = dest;
|
||||
register CONST char *s2 = src;
|
||||
reg_char c;
|
||||
|
||||
/* Find the end of the string. */
|
||||
do
|
||||
c = *s1++;
|
||||
while (c != '\0');
|
||||
|
||||
/* Make S1 point before the next character, so we can increment
|
||||
it while memory is read (wins on pipelined cpus). */
|
||||
s1 -= 2;
|
||||
|
||||
do
|
||||
{
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
}
|
||||
while (c != '\0');
|
||||
|
||||
return dest;
|
||||
}
|
||||
146
gnu/glibc/glibc-1.03/sysdeps/generic/strchr.c
Normal file
146
gnu/glibc/glibc-1.03/sysdeps/generic/strchr.c
Normal file
@@ -0,0 +1,146 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
bug fix and commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
adaptation to strchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
|
||||
and implemented by Roland McGrath (roland@ai.mit.edu).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Find the first ocurrence of C in S. */
|
||||
|
||||
char *
|
||||
DEFUN(strchr, (s, c), CONST char *s AND int c)
|
||||
{
|
||||
CONST unsigned char *char_ptr;
|
||||
CONST unsigned long int *longword_ptr;
|
||||
unsigned long int longword, magic_bits, charmask;
|
||||
|
||||
c = (unsigned char) c;
|
||||
|
||||
/* Handle the first few characters by reading one character at a time.
|
||||
Do this until CHAR_PTR is aligned on a 4-byte border. */
|
||||
for (char_ptr = (CONST unsigned char *) s;
|
||||
((unsigned long int) char_ptr & 3) != 0; ++char_ptr)
|
||||
{
|
||||
if (*char_ptr == c)
|
||||
return (char *) char_ptr;
|
||||
else if (*char_ptr == '\0')
|
||||
return NULL;
|
||||
}
|
||||
|
||||
longword_ptr = (unsigned long int *) char_ptr;
|
||||
|
||||
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
|
||||
the "holes." Note that there is a hole just to the left of
|
||||
each byte, with an extra at the end:
|
||||
|
||||
bits: 01111110 11111110 11111110 11111111
|
||||
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
|
||||
|
||||
The 1-bits make sure that carries propagate to the next 0-bit.
|
||||
The 0-bits provide holes for carries to fall into. */
|
||||
magic_bits = 0x7efefeff;
|
||||
|
||||
/* Set up a longword, each of whose bytes is C. */
|
||||
charmask = (c << 24) | (c << 16) | (c << 8) | c;
|
||||
|
||||
/* Instead of the traditional loop which tests each character,
|
||||
we will test a longword at a time. The tricky part is testing
|
||||
if *any of the four* bytes in the longword in question are zero. */
|
||||
for (;;)
|
||||
{
|
||||
/* We tentatively exit the loop if adding MAGIC_BITS to
|
||||
LONGWORD fails to change any of the hole bits of LONGWORD.
|
||||
|
||||
1) Is this safe? Will it catch all the zero bytes?
|
||||
Suppose there is a byte with all zeros. Any carry bits
|
||||
propagating from its left will fall into the hole at its
|
||||
least significant bit and stop. Since there will be no
|
||||
carry from its most significant bit, the LSB of the
|
||||
byte to the left will be unchanged, and the zero will be
|
||||
detected.
|
||||
|
||||
2) Is this worthwhile? Will it ignore everything except
|
||||
zero bytes? Suppose every byte of LONGWORD has a bit set
|
||||
somewhere. There will be a carry into bit 8. If bit 8
|
||||
is set, this will carry into bit 16. If bit 8 is clear,
|
||||
one of bits 9-15 must be set, so there will be a carry
|
||||
into bit 16. Similarly, there will be a carry into bit
|
||||
24. If one of bits 24-30 is set, there will be a carry
|
||||
into bit 31, so all of the hole bits will be changed.
|
||||
|
||||
The one misfire occurs when bits 24-30 are clear and bit
|
||||
31 is set; in this case, the hole at bit 31 is not
|
||||
changed. If we had access to the processor carry flag,
|
||||
we could close this loophole by putting the fourth hole
|
||||
at bit 32!
|
||||
|
||||
So it ignores everything except 128's, when they're aligned
|
||||
properly.
|
||||
|
||||
3) But wait! Aren't we looking for C as well as zero?
|
||||
Good point. So what we do is XOR LONGWORD with a longword,
|
||||
each of whose bytes is C. This turns each byte that is C
|
||||
into a zero. */
|
||||
|
||||
longword = *longword_ptr++;
|
||||
|
||||
/* Add MAGIC_BITS to LONGWORD. */
|
||||
if ((((longword + magic_bits)
|
||||
|
||||
/* Set those bits that were unchanged by the addition. */
|
||||
^ ~longword)
|
||||
|
||||
/* Look at only the hole bits. If any of the hole bits
|
||||
are unchanged, most likely one of the bytes was a
|
||||
zero. */
|
||||
& ~magic_bits) != 0 ||
|
||||
|
||||
/* That caught zeroes. Now test for C. */
|
||||
((((longword ^ charmask) + magic_bits) ^ ~(longword ^ charmask))
|
||||
& ~magic_bits) != 0)
|
||||
{
|
||||
/* Which of the bytes was C or zero?
|
||||
If none of them were, it was a misfire; continue the search. */
|
||||
|
||||
CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1);
|
||||
|
||||
if (*cp == c)
|
||||
return (char *) cp;
|
||||
else if (*cp == '\0')
|
||||
return NULL;
|
||||
if (*++cp == c)
|
||||
return (char *) cp;
|
||||
else if (*cp == '\0')
|
||||
return NULL;
|
||||
if (*++cp == c)
|
||||
return (char *) cp;
|
||||
else if (*cp == '\0')
|
||||
return NULL;
|
||||
if (*++cp == c)
|
||||
return (char *) cp;
|
||||
else if (*cp == '\0')
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
43
gnu/glibc/glibc-1.03/sysdeps/generic/strcmp.c
Normal file
43
gnu/glibc/glibc-1.03/sysdeps/generic/strcmp.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* Compare S1 and S2, returning less than, equal to or
|
||||
greater than zero if S1 is lexiographically less than,
|
||||
equal to or greater than S2. */
|
||||
int
|
||||
DEFUN(strcmp, (p1, p2), CONST char *p1 AND CONST char *p2)
|
||||
{
|
||||
register CONST unsigned char *s1 = (CONST unsigned char *) p1;
|
||||
register CONST unsigned char *s2 = (CONST unsigned char *) p2;
|
||||
unsigned reg_char c1, c2;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = (unsigned char) *s1++;
|
||||
c2 = (unsigned char) *s2++;
|
||||
if (c1 == '\0')
|
||||
return c1 - c2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
41
gnu/glibc/glibc-1.03/sysdeps/generic/strcpy.c
Normal file
41
gnu/glibc/glibc-1.03/sysdeps/generic/strcpy.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* Copy SRC to DEST. */
|
||||
char *
|
||||
DEFUN(strcpy, (dest, src), char *dest AND CONST char *src)
|
||||
{
|
||||
reg_char c;
|
||||
char *s = (char *) src;
|
||||
CONST ptrdiff_t off = dest - src - 1;
|
||||
|
||||
do
|
||||
{
|
||||
c = *s++;
|
||||
s[off] = c;
|
||||
}
|
||||
while (c != '\0');
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
38
gnu/glibc/glibc-1.03/sysdeps/generic/strcspn.c
Normal file
38
gnu/glibc/glibc-1.03/sysdeps/generic/strcspn.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Return the length of the maximum inital segment of S
|
||||
which contains no characters from REJECT. */
|
||||
size_t
|
||||
DEFUN(strcspn, (s, reject),
|
||||
register CONST char *s AND register CONST char *reject)
|
||||
{
|
||||
register size_t count = 0;
|
||||
|
||||
while (*s != '\0')
|
||||
if (strchr(reject, *s++) == NULL)
|
||||
++count;
|
||||
else
|
||||
return count;
|
||||
|
||||
return count;
|
||||
}
|
||||
125
gnu/glibc/glibc-1.03/sysdeps/generic/strlen.c
Normal file
125
gnu/glibc/glibc-1.03/sysdeps/generic/strlen.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/* Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Written by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se);
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Return the length of the null-terminated string STR. Scan for
|
||||
the null terminator quickly by testing four bytes at a time. */
|
||||
|
||||
size_t
|
||||
DEFUN(strlen, (str), CONST char *str)
|
||||
{
|
||||
CONST char *char_ptr;
|
||||
CONST unsigned long int *longword_ptr;
|
||||
unsigned long int longword, magic_bits, himagic, lomagic;
|
||||
|
||||
/* Handle the first few characters by reading one character at a time.
|
||||
Do this until STR is aligned on a 4-byte border. */
|
||||
for (char_ptr = str; ((unsigned long int) char_ptr & 3) != 0; ++char_ptr)
|
||||
if (*char_ptr == 0)
|
||||
return char_ptr - str;
|
||||
|
||||
longword_ptr = (unsigned long int *) char_ptr;
|
||||
|
||||
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
|
||||
the "holes." Note that there is a hole just to the left of
|
||||
each byte, with an extra at the end:
|
||||
|
||||
bits: 01111110 11111110 11111110 11111111
|
||||
bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
|
||||
|
||||
The 1-bits make sure that carries propagate to the next 0-bit.
|
||||
The 0-bits provide holes for carries to fall into. */
|
||||
magic_bits = 0x7efefeff;
|
||||
|
||||
himagic = 0x80808080;
|
||||
lomagic = 0x01010101;
|
||||
|
||||
/* Instead of the traditional loop which tests each character,
|
||||
we will test a longword at a time. The tricky part is testing
|
||||
if *any of the four* bytes in the longword in question are zero. */
|
||||
for (;;)
|
||||
{
|
||||
/* We tentatively exit the loop if adding MAGIC_BITS to
|
||||
LONGWORD fails to change any of the hole bits of LONGWORD.
|
||||
|
||||
1) Is this safe? Will it catch all the zero bytes?
|
||||
Suppose there is a byte with all zeros. Any carry bits
|
||||
propagating from its left will fall into the hole at its
|
||||
least significant bit and stop. Since there will be no
|
||||
carry from its most significant bit, the LSB of the
|
||||
byte to the left will be unchanged, and the zero will be
|
||||
detected.
|
||||
|
||||
2) Is this worthwhile? Will it ignore everything except
|
||||
zero bytes? Suppose every byte of LONGWORD has a bit set
|
||||
somewhere. There will be a carry into bit 8. If bit 8
|
||||
is set, this will carry into bit 16. If bit 8 is clear,
|
||||
one of bits 9-15 must be set, so there will be a carry
|
||||
into bit 16. Similarly, there will be a carry into bit
|
||||
24. If one of bits 24-30 is set, there will be a carry
|
||||
into bit 31, so all of the hole bits will be changed.
|
||||
|
||||
The one misfire occurs when bits 24-30 are clear and bit
|
||||
31 is set; in this case, the hole at bit 31 is not
|
||||
changed. If we had access to the processor carry flag,
|
||||
we could close this loophole by putting the fourth hole
|
||||
at bit 32!
|
||||
|
||||
So it ignores everything except 128's, when they're aligned
|
||||
properly. */
|
||||
|
||||
longword = *longword_ptr++;
|
||||
|
||||
if (
|
||||
#if 0
|
||||
/* Add MAGIC_BITS to LONGWORD. */
|
||||
(((longword + magic_bits)
|
||||
|
||||
/* Set those bits that were unchanged by the addition. */
|
||||
^ ~longword)
|
||||
|
||||
/* Look at only the hole bits. If any of the hole bits
|
||||
are unchanged, most likely one of the bytes was a
|
||||
zero. */
|
||||
& ~magic_bits)
|
||||
#else
|
||||
((longword - lomagic) & himagic)
|
||||
#endif
|
||||
!= 0)
|
||||
{
|
||||
/* Which of the bytes was the zero? If none of them were, it was
|
||||
a misfire; continue the search. */
|
||||
|
||||
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;
|
||||
if (cp[3] == 0)
|
||||
return cp - str + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
76
gnu/glibc/glibc-1.03/sysdeps/generic/strncat.c
Normal file
76
gnu/glibc/glibc-1.03/sysdeps/generic/strncat.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
char *
|
||||
DEFUN(strncat, (s1, s2, n), char *s1 AND CONST char *s2 AND size_t n)
|
||||
{
|
||||
reg_char c;
|
||||
char *s = s1;
|
||||
|
||||
/* Find the end of S1. */
|
||||
do
|
||||
c = *s1++;
|
||||
while (c != '\0');
|
||||
|
||||
/* Make S1 point before next character, so we can increment
|
||||
it while memory is read (wins on pipelined cpus). */
|
||||
s1 -= 2;
|
||||
|
||||
if (n >= 4)
|
||||
{
|
||||
size_t n4 = n >> 2;
|
||||
do
|
||||
{
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
return s;
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
return s;
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
return s;
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
return s;
|
||||
} while (--n4 > 0);
|
||||
n &= 3;
|
||||
}
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
return s;
|
||||
n--;
|
||||
}
|
||||
|
||||
if (c != '\0')
|
||||
*++s1 = '\0';
|
||||
|
||||
return s;
|
||||
}
|
||||
69
gnu/glibc/glibc-1.03/sysdeps/generic/strncmp.c
Normal file
69
gnu/glibc/glibc-1.03/sysdeps/generic/strncmp.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* Compare no more than N characters of S1 and S2,
|
||||
returning less than, equal to or greater than zero
|
||||
if S1 is lexiographically less than, equal to or
|
||||
greater than S2. */
|
||||
int
|
||||
DEFUN(strncmp, (s1, s2, n),
|
||||
CONST char *s1 AND CONST char *s2 AND size_t n)
|
||||
{
|
||||
unsigned reg_char c1 = '\0';
|
||||
unsigned reg_char c2 = '\0';
|
||||
|
||||
if (n >= 4)
|
||||
{
|
||||
size_t n4 = n >> 2;
|
||||
do
|
||||
{
|
||||
c1 = (unsigned char) *s1++;
|
||||
c2 = (unsigned char) *s2++;
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
return c1 - c2;
|
||||
c1 = (unsigned char) *s1++;
|
||||
c2 = (unsigned char) *s2++;
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
return c1 - c2;
|
||||
c1 = (unsigned char) *s1++;
|
||||
c2 = (unsigned char) *s2++;
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
return c1 - c2;
|
||||
c1 = (unsigned char) *s1++;
|
||||
c2 = (unsigned char) *s2++;
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
return c1 - c2;
|
||||
} while (--n4 > 0);
|
||||
n &= 3;
|
||||
}
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
c1 = (unsigned char) *s1++;
|
||||
c2 = (unsigned char) *s2++;
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
return c1 - c2;
|
||||
n--;
|
||||
}
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
82
gnu/glibc/glibc-1.03/sysdeps/generic/strncpy.c
Normal file
82
gnu/glibc/glibc-1.03/sysdeps/generic/strncpy.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
char *
|
||||
DEFUN(strncpy, (s1, s2, n), char *s1 AND CONST char *s2 AND size_t n)
|
||||
{
|
||||
reg_char c;
|
||||
char *s = s1;
|
||||
|
||||
--s1;
|
||||
|
||||
if (n >= 4)
|
||||
{
|
||||
size_t n4 = n >> 2;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (--n4 == 0)
|
||||
goto last_chars;
|
||||
}
|
||||
n = n - (s1 - s) - 1;
|
||||
if (n == 0)
|
||||
return s;
|
||||
goto zero_fill;
|
||||
}
|
||||
|
||||
last_chars:
|
||||
n &= 3;
|
||||
if (n == 0)
|
||||
return s;
|
||||
|
||||
do
|
||||
{
|
||||
c = *s2++;
|
||||
*++s1 = c;
|
||||
if (--n == 0)
|
||||
return s;
|
||||
}
|
||||
while (c != '\0');
|
||||
|
||||
zero_fill:
|
||||
do
|
||||
*++s1 = '\0';
|
||||
while (--n > 0);
|
||||
|
||||
return s;
|
||||
}
|
||||
35
gnu/glibc/glibc-1.03/sysdeps/generic/strpbrk.c
Normal file
35
gnu/glibc/glibc-1.03/sysdeps/generic/strpbrk.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Find the first ocurrence in S of any character in ACCEPT. */
|
||||
char *
|
||||
DEFUN(strpbrk, (s, accept),
|
||||
register CONST char *s AND register CONST char *accept)
|
||||
{
|
||||
while (*s != '\0')
|
||||
if (strchr(accept, *s) == NULL)
|
||||
++s;
|
||||
else
|
||||
return (char *) s;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
44
gnu/glibc/glibc-1.03/sysdeps/generic/strrchr.c
Normal file
44
gnu/glibc/glibc-1.03/sysdeps/generic/strrchr.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Find the last ocurrence of C in S. */
|
||||
char *
|
||||
DEFUN(strrchr, (s, c), CONST char *s AND int c)
|
||||
{
|
||||
register CONST char *found, *p;
|
||||
|
||||
c = (unsigned char) c;
|
||||
|
||||
/* Since strchr is fast, we use it rather than the obvious loop. */
|
||||
|
||||
if (c == '\0')
|
||||
return strchr(s, '\0');
|
||||
|
||||
found = NULL;
|
||||
while ((p = strchr(s, c)) != NULL)
|
||||
{
|
||||
found = p;
|
||||
s = p + 1;
|
||||
}
|
||||
|
||||
return (char *) found;
|
||||
}
|
||||
44
gnu/glibc/glibc-1.03/sysdeps/generic/strspn.c
Normal file
44
gnu/glibc/glibc-1.03/sysdeps/generic/strspn.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Return the length of the maximum initial segment
|
||||
of S which contains only characters in ACCEPT. */
|
||||
size_t
|
||||
DEFUN(strspn, (s, accept), CONST char *s AND CONST char *accept)
|
||||
{
|
||||
register CONST char *p;
|
||||
register CONST char *a;
|
||||
register size_t count = 0;
|
||||
|
||||
for (p = s; *p != '\0'; ++p)
|
||||
{
|
||||
for (a = accept; *a != '\0'; ++a)
|
||||
if (*p == *a)
|
||||
break;
|
||||
if (*a == '\0')
|
||||
return count;
|
||||
else
|
||||
++count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
55
gnu/glibc/glibc-1.03/sysdeps/generic/strstr.c
Normal file
55
gnu/glibc/glibc-1.03/sysdeps/generic/strstr.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Return the first ocurrence of NEEDLE in HAYSTACK. */
|
||||
char *
|
||||
DEFUN(strstr, (haystack, needle),
|
||||
CONST char *CONST haystack AND
|
||||
CONST char *CONST needle)
|
||||
{
|
||||
register CONST char *CONST needle_end = strchr(needle, '\0');
|
||||
register CONST char *CONST haystack_end = strchr(haystack, '\0');
|
||||
register CONST size_t needle_len = needle_end - needle;
|
||||
register CONST size_t needle_last = needle_len - 1;
|
||||
register CONST char *begin;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (char *) haystack_end;
|
||||
if ((size_t) (haystack_end - haystack) < needle_len)
|
||||
return NULL;
|
||||
|
||||
for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
|
||||
{
|
||||
register CONST char *n = &needle[needle_last];
|
||||
register CONST char *h = begin;
|
||||
do
|
||||
if (*h != *n)
|
||||
goto loop;
|
||||
while (--n >= needle && --h >= haystack);
|
||||
|
||||
return (char *) h;
|
||||
loop:;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
61
gnu/glibc/glibc-1.03/sysdeps/generic/uname.c
Normal file
61
gnu/glibc/glibc-1.03/sysdeps/generic/uname.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* This file is created by the configuration process, and defines
|
||||
LIBC_MACHINE to a string containing the machine configured for. */
|
||||
#include <config-name.h>
|
||||
|
||||
|
||||
/* Put information about the system in NAME. */
|
||||
int
|
||||
DEFUN(uname, (name), struct utsname *name)
|
||||
{
|
||||
extern CONST char __libc_release[], __libc_version[];
|
||||
int save;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
save = errno;
|
||||
if (__gethostname (name->nodename, sizeof (name->nodename)) < 0)
|
||||
{
|
||||
if (errno == ENOSYS)
|
||||
{
|
||||
/* Hostname is meaningless for this machine. */
|
||||
name->nodename[0] = '\0';
|
||||
errno = save;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
strcpy (name->sysname, "GNU C Library");
|
||||
strncpy (name->release, __libc_release, sizeof (name->release));
|
||||
strncpy (name->version, __libc_version, sizeof (name->version));
|
||||
strncpy (name->machine, LIBC_MACHINE, sizeof (name->machine));
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
gnu/glibc/glibc-1.03/sysdeps/generic/vlimit.c
Normal file
51
gnu/glibc/glibc-1.03/sysdeps/generic/vlimit.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 1991 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. */
|
||||
|
||||
/* This is generic in the sense that it will work with the BSD, SYSV,
|
||||
or stub versions of getrlimit. Separate versions could be written
|
||||
for efficiency, but it's probably not worth it. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <sys/vlimit.h>
|
||||
#include <sys/resource.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Set the soft limit for RESOURCE to be VALUE.
|
||||
Returns 0 for success, -1 for failure. */
|
||||
int
|
||||
DEFUN(vlimit, (resource, value),
|
||||
enum __vlimit_resource resource AND int value)
|
||||
{
|
||||
if (resource >= LIM_CPU && resource <= LIM_MAXRSS)
|
||||
{
|
||||
/* The rlimit codes happen to each be one less
|
||||
than the corresponding vlimit codes. */
|
||||
enum __rlimit_resource rlimit_res =
|
||||
(enum __rlimit_resource) ((int) resource - 1);
|
||||
struct rlimit lims;
|
||||
|
||||
if (getrlimit(rlimit_res, &lims) < 0)
|
||||
return -1;
|
||||
|
||||
lims.rlim_cur = value;
|
||||
return setrlimit(rlimit_res, &lims);
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
66
gnu/glibc/glibc-1.03/sysdeps/generic/vtimes.c
Normal file
66
gnu/glibc/glibc-1.03/sysdeps/generic/vtimes.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/vtimes.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
/* Return the number of 1/VTIMES_UNITS_PER_SECOND-second
|
||||
units in the `struct timeval' TV. */
|
||||
#define TIMEVAL_TO_VTIMES(tv) \
|
||||
((tv.tv_sec * VTIMES_UNITS_PER_SECOND) + \
|
||||
(tv.tv_usec * VTIMES_UNITS_PER_SECOND / 1000000))
|
||||
|
||||
/* If VT is not NULL, write statistics for WHO into *VT.
|
||||
Return 0 for success, -1 for failure. */
|
||||
static int
|
||||
DEFUN(vtimes_one, (vt, who),
|
||||
struct vtimes *vt AND enum __rusage_who who)
|
||||
{
|
||||
if (vt != NULL)
|
||||
{
|
||||
struct rusage usage;
|
||||
|
||||
if (getrusage(who, &usage) < 0)
|
||||
return -1;
|
||||
|
||||
vt->vm_utime = TIMEVAL_TO_VTIMES(usage.ru_utime);
|
||||
vt->vm_stime = TIMEVAL_TO_VTIMES(usage.ru_stime);
|
||||
vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss;
|
||||
vt->vm_majflt = usage.ru_majflt;
|
||||
vt->vm_minflt = usage.ru_minflt;
|
||||
vt->vm_nswap = usage.ru_nswap;
|
||||
vt->vm_inblk = usage.ru_inblock;
|
||||
vt->vm_oublk = usage.ru_oublock;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If CURRENT is not NULL, write statistics for the current process into
|
||||
*CURRENT. If CHILD is not NULL, write statistics for all terminated child
|
||||
processes into *CHILD. Returns 0 for success, -1 for failure. */
|
||||
int
|
||||
DEFUN(vtimes, (current, child),
|
||||
struct vtimes *current AND struct vtimes *child)
|
||||
{
|
||||
if (vtimes_one(current, RUSAGE_SELF) < 0 ||
|
||||
vtimes_one(child, RUSAGE_CHILDREN) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
405
gnu/glibc/glibc-1.03/sysdeps/generic/wordcopy.c
Normal file
405
gnu/glibc/glibc-1.03/sysdeps/generic/wordcopy.c
Normal file
@@ -0,0 +1,405 @@
|
||||
/* _memcopy.c -- subroutines for memory copy functions.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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. */
|
||||
|
||||
/* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
/* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
|
||||
block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
|
||||
Both SRCP and DSTP should be aligned for memory operations on `op_t's. */
|
||||
|
||||
void
|
||||
DEFUN(_wordcopy_fwd_aligned, (dstp, srcp, len),
|
||||
long int dstp AND long int srcp AND size_t len)
|
||||
{
|
||||
op_t a0, a1;
|
||||
|
||||
switch (len % 8)
|
||||
{
|
||||
case 2:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
srcp -= 6 * OPSIZ;
|
||||
dstp -= 7 * OPSIZ;
|
||||
len += 6;
|
||||
goto do1;
|
||||
case 3:
|
||||
a1 = ((op_t *) srcp)[0];
|
||||
srcp -= 5 * OPSIZ;
|
||||
dstp -= 6 * OPSIZ;
|
||||
len += 5;
|
||||
goto do2;
|
||||
case 4:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
srcp -= 4 * OPSIZ;
|
||||
dstp -= 5 * OPSIZ;
|
||||
len += 4;
|
||||
goto do3;
|
||||
case 5:
|
||||
a1 = ((op_t *) srcp)[0];
|
||||
srcp -= 3 * OPSIZ;
|
||||
dstp -= 4 * OPSIZ;
|
||||
len += 3;
|
||||
goto do4;
|
||||
case 6:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
srcp -= 2 * OPSIZ;
|
||||
dstp -= 3 * OPSIZ;
|
||||
len += 2;
|
||||
goto do5;
|
||||
case 7:
|
||||
a1 = ((op_t *) srcp)[0];
|
||||
srcp -= 1 * OPSIZ;
|
||||
dstp -= 2 * OPSIZ;
|
||||
len += 1;
|
||||
goto do6;
|
||||
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return;
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
srcp -= 0 * OPSIZ;
|
||||
dstp -= 1 * OPSIZ;
|
||||
goto do7;
|
||||
case 1:
|
||||
a1 = ((op_t *) srcp)[0];
|
||||
srcp -=-1 * OPSIZ;
|
||||
dstp -= 0 * OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
goto do8; /* No-op. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
do8:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
((op_t *) dstp)[0] = a1;
|
||||
do7:
|
||||
a1 = ((op_t *) srcp)[1];
|
||||
((op_t *) dstp)[1] = a0;
|
||||
do6:
|
||||
a0 = ((op_t *) srcp)[2];
|
||||
((op_t *) dstp)[2] = a1;
|
||||
do5:
|
||||
a1 = ((op_t *) srcp)[3];
|
||||
((op_t *) dstp)[3] = a0;
|
||||
do4:
|
||||
a0 = ((op_t *) srcp)[4];
|
||||
((op_t *) dstp)[4] = a1;
|
||||
do3:
|
||||
a1 = ((op_t *) srcp)[5];
|
||||
((op_t *) dstp)[5] = a0;
|
||||
do2:
|
||||
a0 = ((op_t *) srcp)[6];
|
||||
((op_t *) dstp)[6] = a1;
|
||||
do1:
|
||||
a1 = ((op_t *) srcp)[7];
|
||||
((op_t *) dstp)[7] = a0;
|
||||
|
||||
srcp += 8 * OPSIZ;
|
||||
dstp += 8 * OPSIZ;
|
||||
len -= 8;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
((op_t *) dstp)[0] = a1;
|
||||
}
|
||||
|
||||
/* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
|
||||
block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
|
||||
DSTP should be aligned for memory operations on `op_t's, but SRCP must
|
||||
*not* be aligned. */
|
||||
|
||||
void
|
||||
DEFUN(_wordcopy_fwd_dest_aligned, (dstp, srcp, len),
|
||||
long int dstp AND long int srcp AND size_t len)
|
||||
{
|
||||
op_t a0, a1, a2, a3;
|
||||
int sh_1, sh_2;
|
||||
|
||||
/* Calculate how to shift a word read at the memory operation
|
||||
aligned srcp to make it aligned for copy. */
|
||||
|
||||
sh_1 = 8 * (srcp % OPSIZ);
|
||||
sh_2 = 8 * OPSIZ - sh_1;
|
||||
|
||||
/* Make SRCP aligned by rounding it down to the beginning of the `op_t'
|
||||
it points in the middle of. */
|
||||
srcp &= -OPSIZ;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
case 2:
|
||||
a1 = ((op_t *) srcp)[0];
|
||||
a2 = ((op_t *) srcp)[1];
|
||||
srcp -= 1 * OPSIZ;
|
||||
dstp -= 3 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
a1 = ((op_t *) srcp)[1];
|
||||
srcp -= 0 * OPSIZ;
|
||||
dstp -= 2 * OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return;
|
||||
a3 = ((op_t *) srcp)[0];
|
||||
a0 = ((op_t *) srcp)[1];
|
||||
srcp -=-1 * OPSIZ;
|
||||
dstp -= 1 * OPSIZ;
|
||||
len += 0;
|
||||
goto do3;
|
||||
case 1:
|
||||
a2 = ((op_t *) srcp)[0];
|
||||
a3 = ((op_t *) srcp)[1];
|
||||
srcp -=-2 * OPSIZ;
|
||||
dstp -= 0 * OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
goto do4; /* No-op. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
do4:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2);
|
||||
do3:
|
||||
a1 = ((op_t *) srcp)[1];
|
||||
((op_t *) dstp)[1] = MERGE (a3, sh_1, a0, sh_2);
|
||||
do2:
|
||||
a2 = ((op_t *) srcp)[2];
|
||||
((op_t *) dstp)[2] = MERGE (a0, sh_1, a1, sh_2);
|
||||
do1:
|
||||
a3 = ((op_t *) srcp)[3];
|
||||
((op_t *) dstp)[3] = MERGE (a1, sh_1, a2, sh_2);
|
||||
|
||||
srcp += 4 * OPSIZ;
|
||||
dstp += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2);
|
||||
}
|
||||
|
||||
/* _wordcopy_bwd_aligned -- Copy block finishing right before
|
||||
SRCP to block finishing right before DSTP with LEN `op_t' words
|
||||
(not LEN bytes!). Both SRCP and DSTP should be aligned for memory
|
||||
operations on `op_t's. */
|
||||
|
||||
void
|
||||
DEFUN(_wordcopy_bwd_aligned, (dstp, srcp, len),
|
||||
long int dstp AND long int srcp AND size_t len)
|
||||
{
|
||||
op_t a0, a1;
|
||||
|
||||
switch (len % 8)
|
||||
{
|
||||
case 2:
|
||||
srcp -= 2 * OPSIZ;
|
||||
dstp -= 1 * OPSIZ;
|
||||
a0 = ((op_t *) srcp)[1];
|
||||
len += 6;
|
||||
goto do1;
|
||||
case 3:
|
||||
srcp -= 3 * OPSIZ;
|
||||
dstp -= 2 * OPSIZ;
|
||||
a1 = ((op_t *) srcp)[2];
|
||||
len += 5;
|
||||
goto do2;
|
||||
case 4:
|
||||
srcp -= 4 * OPSIZ;
|
||||
dstp -= 3 * OPSIZ;
|
||||
a0 = ((op_t *) srcp)[3];
|
||||
len += 4;
|
||||
goto do3;
|
||||
case 5:
|
||||
srcp -= 5 * OPSIZ;
|
||||
dstp -= 4 * OPSIZ;
|
||||
a1 = ((op_t *) srcp)[4];
|
||||
len += 3;
|
||||
goto do4;
|
||||
case 6:
|
||||
srcp -= 6 * OPSIZ;
|
||||
dstp -= 5 * OPSIZ;
|
||||
a0 = ((op_t *) srcp)[5];
|
||||
len += 2;
|
||||
goto do5;
|
||||
case 7:
|
||||
srcp -= 7 * OPSIZ;
|
||||
dstp -= 6 * OPSIZ;
|
||||
a1 = ((op_t *) srcp)[6];
|
||||
len += 1;
|
||||
goto do6;
|
||||
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return;
|
||||
srcp -= 8 * OPSIZ;
|
||||
dstp -= 7 * OPSIZ;
|
||||
a0 = ((op_t *) srcp)[7];
|
||||
goto do7;
|
||||
case 1:
|
||||
srcp -= 9 * OPSIZ;
|
||||
dstp -= 8 * OPSIZ;
|
||||
a1 = ((op_t *) srcp)[8];
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
goto do8; /* No-op. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
do8:
|
||||
a0 = ((op_t *) srcp)[7];
|
||||
((op_t *) dstp)[7] = a1;
|
||||
do7:
|
||||
a1 = ((op_t *) srcp)[6];
|
||||
((op_t *) dstp)[6] = a0;
|
||||
do6:
|
||||
a0 = ((op_t *) srcp)[5];
|
||||
((op_t *) dstp)[5] = a1;
|
||||
do5:
|
||||
a1 = ((op_t *) srcp)[4];
|
||||
((op_t *) dstp)[4] = a0;
|
||||
do4:
|
||||
a0 = ((op_t *) srcp)[3];
|
||||
((op_t *) dstp)[3] = a1;
|
||||
do3:
|
||||
a1 = ((op_t *) srcp)[2];
|
||||
((op_t *) dstp)[2] = a0;
|
||||
do2:
|
||||
a0 = ((op_t *) srcp)[1];
|
||||
((op_t *) dstp)[1] = a1;
|
||||
do1:
|
||||
a1 = ((op_t *) srcp)[0];
|
||||
((op_t *) dstp)[0] = a0;
|
||||
|
||||
srcp -= 8 * OPSIZ;
|
||||
dstp -= 8 * OPSIZ;
|
||||
len -= 8;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
((op_t *) dstp)[7] = a1;
|
||||
}
|
||||
|
||||
/* _wordcopy_bwd_dest_aligned -- Copy block finishing right
|
||||
before SRCP to block finishing right before DSTP with LEN `op_t'
|
||||
words (not LEN bytes!). DSTP should be aligned for memory
|
||||
operations on `op_t', but SRCP must *not* be aligned. */
|
||||
|
||||
void
|
||||
DEFUN(_wordcopy_bwd_dest_aligned, (dstp, srcp, len),
|
||||
long int dstp AND long int srcp AND size_t len)
|
||||
{
|
||||
op_t a0, a1, a2, a3;
|
||||
int sh_1, sh_2;
|
||||
|
||||
/* Calculate how to shift a word read at the memory operation
|
||||
aligned srcp to make it aligned for copy. */
|
||||
|
||||
sh_1 = 8 * (srcp % OPSIZ);
|
||||
sh_2 = 8 * OPSIZ - sh_1;
|
||||
|
||||
/* Make srcp aligned by rounding it down to the beginning of the op_t
|
||||
it points in the middle of. */
|
||||
srcp &= -OPSIZ;
|
||||
srcp += OPSIZ;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
case 2:
|
||||
srcp -= 3 * OPSIZ;
|
||||
dstp -= 1 * OPSIZ;
|
||||
a2 = ((op_t *) srcp)[2];
|
||||
a1 = ((op_t *) srcp)[1];
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
srcp -= 4 * OPSIZ;
|
||||
dstp -= 2 * OPSIZ;
|
||||
a3 = ((op_t *) srcp)[3];
|
||||
a2 = ((op_t *) srcp)[2];
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return;
|
||||
srcp -= 5 * OPSIZ;
|
||||
dstp -= 3 * OPSIZ;
|
||||
a0 = ((op_t *) srcp)[4];
|
||||
a3 = ((op_t *) srcp)[3];
|
||||
goto do3;
|
||||
case 1:
|
||||
srcp -= 6 * OPSIZ;
|
||||
dstp -= 4 * OPSIZ;
|
||||
a1 = ((op_t *) srcp)[5];
|
||||
a0 = ((op_t *) srcp)[4];
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
goto do4; /* No-op. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
do4:
|
||||
a3 = ((op_t *) srcp)[3];
|
||||
((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2);
|
||||
do3:
|
||||
a2 = ((op_t *) srcp)[2];
|
||||
((op_t *) dstp)[2] = MERGE (a3, sh_1, a0, sh_2);
|
||||
do2:
|
||||
a1 = ((op_t *) srcp)[1];
|
||||
((op_t *) dstp)[1] = MERGE (a2, sh_1, a3, sh_2);
|
||||
do1:
|
||||
a0 = ((op_t *) srcp)[0];
|
||||
((op_t *) dstp)[0] = MERGE (a1, sh_1, a2, sh_2);
|
||||
|
||||
srcp -= 4 * OPSIZ;
|
||||
dstp -= 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2);
|
||||
}
|
||||
1
gnu/glibc/glibc-1.03/sysdeps/i386/Implies
Normal file
1
gnu/glibc/glibc-1.03/sysdeps/i386/Implies
Normal file
@@ -0,0 +1 @@
|
||||
ieee754
|
||||
66
gnu/glibc/glibc-1.03/sysdeps/i386/__longjmp.c
Normal file
66
gnu/glibc/glibc-1.03/sysdeps/i386/__longjmp.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifndef __GNUC__
|
||||
#error This file uses GNU C extensions; you must compile with GCC.
|
||||
#endif
|
||||
|
||||
|
||||
#define REGS \
|
||||
REG (bx);\
|
||||
REG (si);\
|
||||
REG (di);\
|
||||
REG (bp);\
|
||||
REG (sp)
|
||||
|
||||
#define REG(xx) register long int xx asm (#xx)
|
||||
REGS;
|
||||
#undef REG
|
||||
|
||||
/* Jump to the position specified by ENV, causing the
|
||||
setjmp call there to return VAL, or 1 if VAL is 0. */
|
||||
__NORETURN
|
||||
void
|
||||
DEFUN(__longjmp, (env, val),
|
||||
CONST jmp_buf env AND
|
||||
int val)
|
||||
{
|
||||
/* We specify explicit registers because, when not optimizing,
|
||||
the compiler will generate code that uses the frame pointer
|
||||
after it's been munged. */
|
||||
|
||||
register CONST __typeof (env[0]) *e asm ("cx");
|
||||
register int v asm ("ax");
|
||||
|
||||
e = env;
|
||||
v = val == 0 ? 1 : val;
|
||||
|
||||
#define REG(xx) xx = (long int) e->__##xx
|
||||
REGS;
|
||||
|
||||
asm volatile ("jmp %*%0" : : "g" (e->__pc), "a" (v));
|
||||
|
||||
/* NOTREACHED */
|
||||
abort ();
|
||||
}
|
||||
79
gnu/glibc/glibc-1.03/sysdeps/i386/bzero.c
Normal file
79
gnu/glibc/glibc-1.03/sysdeps/i386/bzero.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/* bzero -- set a block of memory to zero.
|
||||
For Intel 80x86, x>=3.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <bstring.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
#undef bzero
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
void
|
||||
DEFUN(bzero, (dstpp, len),
|
||||
PTR dstpp AND size_t len)
|
||||
{
|
||||
/* N.B.: This code is almost verbatim from memset.c. */
|
||||
|
||||
unsigned long int dstp = (unsigned long int) dstpp;
|
||||
|
||||
/* This explicit register allocation
|
||||
improves code very much indeed. */
|
||||
register op_t x asm("ax");
|
||||
|
||||
x = 0;
|
||||
|
||||
/* Clear the direction flag, so filling will move forward. */
|
||||
asm volatile("cld");
|
||||
|
||||
/* This threshold value is optimal. */
|
||||
if (len >= 12)
|
||||
{
|
||||
/* There are at least some bytes to set.
|
||||
No need to test for LEN == 0 in this alignment loop. */
|
||||
|
||||
/* Fill bytes until DSTP is aligned on a longword boundary. */
|
||||
asm volatile("rep\n"
|
||||
"stosb" /* %0, %2, %3 */ :
|
||||
"=D" (dstp) :
|
||||
"0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) :
|
||||
"cx");
|
||||
len -= (-dstp) % OPSIZ;
|
||||
|
||||
/* Fill longwords. */
|
||||
asm volatile("rep\n"
|
||||
"stosl" /* %0, %2, %3 */ :
|
||||
"=D" (dstp) :
|
||||
"0" (dstp), "c" (len / OPSIZ), "a" (x) :
|
||||
"cx");
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* Write the last few bytes. */
|
||||
asm volatile("rep\n"
|
||||
"stosb" /* %0, %2, %3 */ :
|
||||
"=D" (dstp) :
|
||||
"0" (dstp), "c" (len), "a" (x) :
|
||||
"cx");
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/generic/bzero.c>
|
||||
#endif
|
||||
45
gnu/glibc/glibc-1.03/sysdeps/i386/ffs.c
Normal file
45
gnu/glibc/glibc-1.03/sysdeps/i386/ffs.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ffs -- find first set bit in a word, counted from least significant end.
|
||||
For Intel 80x86, x>=3.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <bstring.h>
|
||||
|
||||
#undef ffs
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
int
|
||||
DEFUN(ffs, (x), int x)
|
||||
{
|
||||
int cnt;
|
||||
int tmp;
|
||||
|
||||
asm ("xorl %0,%0\n" /* Set CNT to zero. */
|
||||
"bsfl %2,%1\n" /* Count low bits in X and store in %1. */
|
||||
"jz 1f\n" /* Jump if OK, i.e. X was non-zero. */
|
||||
"leal 1(%3),%0\n" /* Return bsfl-result plus one on %0. */
|
||||
"1:" : "=a" (cnt), "=r" (tmp) : "rm" (x), "1" (tmp));
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/generic/ffs.c>
|
||||
#endif
|
||||
9
gnu/glibc/glibc-1.03/sysdeps/i386/jmp_buf.h
Normal file
9
gnu/glibc/glibc-1.03/sysdeps/i386/jmp_buf.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/* Define the machine-dependent type `jmp_buf'. Intel 386 version. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long int __bx, __si, __di;
|
||||
PTR __bp;
|
||||
PTR __sp;
|
||||
PTR __pc;
|
||||
} __jmp_buf[1];
|
||||
47
gnu/glibc/glibc-1.03/sysdeps/i386/memchr.c
Normal file
47
gnu/glibc/glibc-1.03/sysdeps/i386/memchr.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
|
||||
than N.
|
||||
For Intel 80x86, x>=3.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
PTR
|
||||
DEFUN(memchr, (str, c, len),
|
||||
CONST PTR str AND int c AND size_t len)
|
||||
{
|
||||
PTR retval;
|
||||
asm("cld\n" /* Search forward. */
|
||||
"testl %1,%1\n" /* Clear Z flag, to handle LEN == 0. */
|
||||
"repne\n" /* Search for C in al. */
|
||||
"scasb\n"
|
||||
"movl %2,%0\n" /* Set %0 to 0 (without affecting Z flag) */
|
||||
"jnz 1f\n" /* Jump if we found nothing equal to C */
|
||||
"leal -1(%1),%0\n" /* edi has been incremented. Return edi-1. */
|
||||
"1:" :
|
||||
"=a" (retval), "=D" (str), "=c" (len) :
|
||||
"0" (c), "1" (str), "2" (len));
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/generic/memchr.c>
|
||||
#endif
|
||||
86
gnu/glibc/glibc-1.03/sysdeps/i386/memcopy.h
Normal file
86
gnu/glibc/glibc-1.03/sysdeps/i386/memcopy.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* memcopy.h -- definitions for memory copy functions. i386 version.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <sysdeps/generic/memcopy.h>
|
||||
|
||||
#undef OP_T_THRES
|
||||
#define OP_T_THRES 8
|
||||
|
||||
#undef BYTE_COPY_FWD
|
||||
#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
|
||||
asm volatile(/* Clear the direction flag, so copying goes forward. */ \
|
||||
"cld\n" \
|
||||
/* Copy bytes. */ \
|
||||
"rep\n" \
|
||||
"movsb" : \
|
||||
"=D" (dst_bp), "=S" (src_bp) : \
|
||||
"0" (dst_bp), "1" (src_bp), "c" (nbytes) : \
|
||||
"cx")
|
||||
|
||||
#undef BYTE_COPY_BWD
|
||||
#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
asm volatile(/* Set the direction flag, so copying goes backwards. */ \
|
||||
"std\n" \
|
||||
/* Copy bytes. */ \
|
||||
"rep\n" \
|
||||
"movsb\n" \
|
||||
/* Clear the dir flag. Convention says it should be 0. */ \
|
||||
"cld" : \
|
||||
"=D" (dst_ep), "=S" (src_ep) : \
|
||||
"0" (dst_ep - 1), "1" (src_ep - 1), "c" (nbytes) : \
|
||||
"cx"); \
|
||||
dst_ep += 1; \
|
||||
src_ep += 1; \
|
||||
} while (0)
|
||||
|
||||
#undef WORD_COPY_FWD
|
||||
#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
asm volatile(/* Clear the direction flag, so copying goes forward. */ \
|
||||
"cld\n" \
|
||||
/* Copy longwords. */ \
|
||||
"rep\n" \
|
||||
"movsl" : \
|
||||
"=D" (dst_bp), "=S" (src_bp) : \
|
||||
"0" (dst_bp), "1" (src_bp), "c" ((nbytes) / 4) : \
|
||||
"cx"); \
|
||||
(nbytes_left) = (nbytes) % 4; \
|
||||
} while (0)
|
||||
|
||||
#undef WORD_COPY_BWD
|
||||
#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
|
||||
do \
|
||||
{ \
|
||||
asm volatile(/* Set the direction flag, so copying goes backwards. */ \
|
||||
"std\n" \
|
||||
/* Copy longwords. */ \
|
||||
"rep\n" \
|
||||
"movsl\n" \
|
||||
/* Clear the dir flag. Convention says it should be 0. */ \
|
||||
"cld" : \
|
||||
"=D" (dst_ep), "=S" (src_ep) : \
|
||||
"0" (dst_ep - 4), "1" (src_ep - 4), "c" ((nbytes) / 4) : \
|
||||
"cx"); \
|
||||
dst_ep += 4; \
|
||||
src_ep += 4; \
|
||||
(nbytes_left) = (nbytes) % 4; \
|
||||
} while (0)
|
||||
81
gnu/glibc/glibc-1.03/sysdeps/i386/memset.c
Normal file
81
gnu/glibc/glibc-1.03/sysdeps/i386/memset.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/* memset -- set a block of memory to some byte value.
|
||||
For Intel 80x86, x>=3.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
#include <memcopy.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
PTR
|
||||
DEFUN(memset, (dstpp, c, len),
|
||||
PTR dstpp AND int c AND size_t len)
|
||||
{
|
||||
unsigned long int dstp = (unsigned long int) dstpp;
|
||||
|
||||
/* This explicit register allocation
|
||||
improves code very much indeed. */
|
||||
register op_t x asm("ax");
|
||||
|
||||
x = (unsigned char) c;
|
||||
|
||||
/* Clear the direction flag, so filling will move forward. */
|
||||
asm volatile("cld");
|
||||
|
||||
/* This threshold value is optimal. */
|
||||
if (len >= 12)
|
||||
{
|
||||
/* Fill X with four copies of the char we want to fill with. */
|
||||
x |= (x << 8);
|
||||
x |= (x << 16);
|
||||
|
||||
/* There are at least some bytes to set.
|
||||
No need to test for LEN == 0 in this alignment loop. */
|
||||
|
||||
/* Fill bytes until DSTP is aligned on a longword boundary. */
|
||||
asm volatile("rep\n"
|
||||
"stosb" /* %0, %2, %3 */ :
|
||||
"=D" (dstp) :
|
||||
"0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) :
|
||||
"cx");
|
||||
len -= (-dstp) % OPSIZ;
|
||||
|
||||
/* Fill longwords. */
|
||||
asm volatile("rep\n"
|
||||
"stosl" /* %0, %2, %3 */ :
|
||||
"=D" (dstp) :
|
||||
"0" (dstp), "c" (len / OPSIZ), "a" (x) :
|
||||
"cx");
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* Write the last few bytes. */
|
||||
asm volatile("rep\n"
|
||||
"stosb" /* %0, %2, %3 */ :
|
||||
"=D" (dstp) :
|
||||
"0" (dstp), "c" (len), "a" (x) :
|
||||
"cx");
|
||||
|
||||
return dstpp;
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/generic/memset.c>
|
||||
#endif
|
||||
51
gnu/glibc/glibc-1.03/sysdeps/i386/setjmp.c
Normal file
51
gnu/glibc/glibc-1.03/sysdeps/i386/setjmp.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
|
||||
#define REGS \
|
||||
REG (bx);\
|
||||
REG (si);\
|
||||
REG (di)
|
||||
|
||||
#define REG(xx) register long int xx asm (#xx)
|
||||
REGS;
|
||||
#undef REG
|
||||
|
||||
/* Save the current program position in ENV and return 0. */
|
||||
int
|
||||
DEFUN(__setjmp, (env), jmp_buf env)
|
||||
{
|
||||
/* Save the general registers. */
|
||||
#define REG(xx) env[0].__##xx = xx
|
||||
REGS;
|
||||
|
||||
/* Save the return PC. */
|
||||
env[0].__pc = (PTR) ((PTR *) &env)[-1];
|
||||
|
||||
/* Save caller's FP, not our own. */
|
||||
env[0].__bp = (PTR) ((PTR *) &env)[-2];
|
||||
|
||||
/* Save caller's SP, not our own. */
|
||||
env[0].__sp = (PTR) &env;
|
||||
|
||||
return 0;
|
||||
}
|
||||
35
gnu/glibc/glibc-1.03/sysdeps/i386/strlen.c
Normal file
35
gnu/glibc/glibc-1.03/sysdeps/i386/strlen.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* strlen -- determine the length of a string.
|
||||
For Intel 80x86, x>=3.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
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 <ansidecl.h>
|
||||
#include <string.h>
|
||||
|
||||
size_t
|
||||
DEFUN(strlen, (str), CONST char *str)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
asm("cld\n" /* Search forward. */
|
||||
"repne\n" /* Look for a zero byte. */
|
||||
"scasb" /* %0, %1, %3 */ :
|
||||
"=c" (cnt) : "D" (str), "0" (-1), "a" (0));
|
||||
|
||||
return -2 - cnt;
|
||||
}
|
||||
33
gnu/glibc/glibc-1.03/sysdeps/i860/memcopy.h
Normal file
33
gnu/glibc/glibc-1.03/sysdeps/i860/memcopy.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 1991 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 <sysdeps/generic/memcopy.h>
|
||||
|
||||
#if 0
|
||||
#undef MERGE
|
||||
/* In order to make this work properly, an 's' constraint need to be added
|
||||
to tm-i860.h, to mean the SC register. */
|
||||
#define MERGE(w0, sh_1, w1, sh_2) \
|
||||
({ \
|
||||
unsigned int __merge; \
|
||||
asm("shrd %2,%1,%0" : \
|
||||
"=r" (__merge) : \
|
||||
"r" (w0), "r" (w1), "s" (sh_1)); \
|
||||
__merge; \
|
||||
})
|
||||
#endif
|
||||
2
gnu/glibc/glibc-1.03/sysdeps/ieee754/Dist
Normal file
2
gnu/glibc/glibc-1.03/sysdeps/ieee754/Dist
Normal file
@@ -0,0 +1,2 @@
|
||||
../../math/bsd/ieee/support.c
|
||||
ieee754.h
|
||||
5
gnu/glibc/glibc-1.03/sysdeps/ieee754/Makefile
Normal file
5
gnu/glibc/glibc-1.03/sysdeps/ieee754/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
ifeq ($(subdir),math)
|
||||
|
||||
bsdmath_dirs := $(bsdmath_dirs) ieee
|
||||
|
||||
endif
|
||||
35
gnu/glibc/glibc-1.03/sysdeps/ieee754/__copysign.c
Normal file
35
gnu/glibc/glibc-1.03/sysdeps/ieee754/__copysign.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
/* Return X with its signed changed to Y's. */
|
||||
double
|
||||
DEFUN(__copysign, (x, y), double x AND double y)
|
||||
{
|
||||
union ieee754_double ux, uy;
|
||||
|
||||
ux.d = x;
|
||||
uy.d = y;
|
||||
|
||||
ux.ieee.negative = uy.ieee.negative;
|
||||
|
||||
return ux.d;
|
||||
}
|
||||
105
gnu/glibc/glibc-1.03/sysdeps/ieee754/__drem.c
Normal file
105
gnu/glibc/glibc-1.03/sysdeps/ieee754/__drem.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/* 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. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted provided
|
||||
* that: (1) source distributions retain this entire copyright notice and
|
||||
* comment, and (2) distributions including binaries display the following
|
||||
* acknowledgement: ``This product includes software developed by the
|
||||
* University of California, Berkeley and its contributors'' in the
|
||||
* documentation or other materials provided with the distribution and in
|
||||
* all advertising materials mentioning features or use of this software.
|
||||
* Neither the name of the University nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
/* Return the remainder of X/Y. */
|
||||
double
|
||||
DEFUN(__drem, (x, y),
|
||||
double x AND double y)
|
||||
{
|
||||
union ieee754_double ux, uy;
|
||||
|
||||
ux.d = x;
|
||||
uy.d = y;
|
||||
#define x ux.d
|
||||
#define y uy.d
|
||||
|
||||
uy.ieee.negative = 0;
|
||||
|
||||
if (!__finite (x) || y == 0.0)
|
||||
return NAN;
|
||||
else if (__isnan (y))
|
||||
return y;
|
||||
else if (__isinf (y))
|
||||
return x;
|
||||
else if (uy.ieee.exponent <= 1)
|
||||
{
|
||||
/* Subnormal (or almost subnormal) Y value. */
|
||||
double b = __scalb (1.0, 54);
|
||||
y *= b;
|
||||
x = __drem (x, y);
|
||||
x *= b;
|
||||
return __drem (x, y) / b;
|
||||
}
|
||||
else if (y >= 1.7e308 / 2)
|
||||
{
|
||||
y /= 2;
|
||||
x /= 2;
|
||||
return __drem (x, y) * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
union ieee754_double a;
|
||||
double b;
|
||||
unsigned int negative = ux.ieee.negative;
|
||||
a.d = y + y;
|
||||
b = y / 2;
|
||||
ux.ieee.negative = 0;
|
||||
while (x > a.d)
|
||||
{
|
||||
unsigned short int k = ux.ieee.exponent - a.ieee.exponent;
|
||||
union ieee754_double tmp;
|
||||
tmp.d = a.d;
|
||||
tmp.ieee.exponent += k;
|
||||
if (x < tmp.d)
|
||||
--tmp.ieee.exponent;
|
||||
x -= tmp.d;
|
||||
}
|
||||
if (x > b)
|
||||
{
|
||||
x -= y;
|
||||
if (x >= b)
|
||||
x -= y;
|
||||
}
|
||||
ux.ieee.negative ^= negative;
|
||||
return x;
|
||||
}
|
||||
}
|
||||
48
gnu/glibc/glibc-1.03/sysdeps/ieee754/__infnan.c
Normal file
48
gnu/glibc/glibc-1.03/sysdeps/ieee754/__infnan.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
/* Deal with an infinite or NaN result.
|
||||
If ERROR is ERANGE, result is +Inf;
|
||||
if ERROR is - ERANGE, result is -Inf;
|
||||
otherwise result is NaN.
|
||||
This will set `errno' to either ERANGE or EDOM,
|
||||
and may return an infinity or NaN, or may do something else. */
|
||||
double
|
||||
DEFUN(__infnan, (error), int error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case ERANGE:
|
||||
errno = ERANGE;
|
||||
return HUGE_VAL;
|
||||
|
||||
case - ERANGE:
|
||||
errno = ERANGE;
|
||||
return - HUGE_VAL;
|
||||
|
||||
default:
|
||||
errno = EDOM;
|
||||
return NAN;
|
||||
}
|
||||
}
|
||||
38
gnu/glibc/glibc-1.03/sysdeps/ieee754/__isinf.c
Normal file
38
gnu/glibc/glibc-1.03/sysdeps/ieee754/__isinf.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
/* Return 0 if VALUE is finite or NaN, +1 if it
|
||||
is +Infinity, -1 if it is -Infinity. */
|
||||
int
|
||||
DEFUN(__isinf, (value), double value)
|
||||
{
|
||||
union ieee754_double u;
|
||||
|
||||
u.d = value;
|
||||
/* An IEEE 754 infinity has an exponent with the
|
||||
maximum possible value and a zero mantissa. */
|
||||
if ((u.ieee.exponent & 0x7ff) == 0x7ff &&
|
||||
u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
|
||||
return u.ieee.negative ? -1 : 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
35
gnu/glibc/glibc-1.03/sysdeps/ieee754/__isnan.c
Normal file
35
gnu/glibc/glibc-1.03/sysdeps/ieee754/__isnan.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
/* Return nonzero if VALUE is not a number. */
|
||||
int
|
||||
DEFUN(__isnan, (value), double value)
|
||||
{
|
||||
union ieee754_double u;
|
||||
|
||||
u.d = value;
|
||||
|
||||
/* IEEE 754 NaN's have the maximum possible
|
||||
exponent and a nonzero mantissa. */
|
||||
return ((u.ieee.exponent & 0x7ff) == 0x7ff &&
|
||||
(u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
|
||||
}
|
||||
46
gnu/glibc/glibc-1.03/sysdeps/ieee754/__logb.c
Normal file
46
gnu/glibc/glibc-1.03/sysdeps/ieee754/__logb.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/* 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
/* Return the base 2 signed integral exponent of X. */
|
||||
double
|
||||
DEFUN(__logb, (x), double x)
|
||||
{
|
||||
union ieee754_double u;
|
||||
|
||||
if (__isnan (x))
|
||||
return x;
|
||||
else if (__isinf (x))
|
||||
return HUGE_VAL;
|
||||
else if (x == 0.0)
|
||||
return - HUGE_VAL;
|
||||
|
||||
u.d = x;
|
||||
|
||||
if (u.ieee.exponent == 0)
|
||||
/* A denormalized number.
|
||||
Multiplying by 2 ** DBL_MANT_DIG normalizes it;
|
||||
we then subtract the DBL_MANT_DIG we added to the exponent. */
|
||||
return (__logb (x * ldexp (1.0, DBL_MANT_DIG)) - DBL_MANT_DIG);
|
||||
|
||||
return (int) u.ieee.exponent - (DBL_MAX_EXP - 1);
|
||||
}
|
||||
112
gnu/glibc/glibc-1.03/sysdeps/ieee754/fl.h
Normal file
112
gnu/glibc/glibc-1.03/sysdeps/ieee754/fl.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/* Floating-point constants for IEEE 754 machines,
|
||||
where `float' is single-precision, and `double' and `long double'
|
||||
are both double-precision.
|
||||
|
||||
Copyright (C) 1991, 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. */
|
||||
|
||||
#ifndef __need_HUGE_VAL
|
||||
|
||||
#define FLT_RADIX 2
|
||||
|
||||
#define FLT_ROUNDS _FLT_ROUNDS_TONEAREST /* IEEE default. */
|
||||
|
||||
#define FLT_MANT_DIG 24
|
||||
#define DBL_MANT_DIG 53
|
||||
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define DBL_DIG 15
|
||||
#define LDBL_DIG DBL_DIG
|
||||
|
||||
#define FLT_MIN_EXP (-125)
|
||||
#define DBL_MIN_EXP (-1021)
|
||||
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
|
||||
#define FLT_MIN_10_EXP (-37)
|
||||
#define DBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
|
||||
#define FLT_MAX_EXP 128
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
|
||||
#define FLT_MAX 3.40282347e38
|
||||
#define DBL_MAX 1.7976931348623157e308
|
||||
#define LDBL_MAX DBL_MAX
|
||||
|
||||
#define FLT_EPSILON 1.19209290e-7
|
||||
#define DBL_EPSILON 2.2204460492503131e-16
|
||||
#define LDBL_EPSILON DBL_EPSILON
|
||||
|
||||
#define FLT_MIN 1.17549435e-38
|
||||
#define DBL_MIN 2.2250738585072014e-308
|
||||
#define LDBL_MIN DBL_MIN
|
||||
|
||||
#ifdef __USE_GNU
|
||||
/* IEEE Not A Number. */
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
#ifdef __BIG_ENDIAN
|
||||
#define __nan_bytes { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
|
||||
#else
|
||||
#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define NAN \
|
||||
(__extension__ ((union { unsigned char __c[8]; \
|
||||
double __d; }) \
|
||||
{ __nan_bytes }).__d)
|
||||
#else /* Not GCC. */
|
||||
static CONST char __nan[8] = __nan_bytes;
|
||||
#define NAN (*(CONST double *) __nan)
|
||||
#endif /* GCC. */
|
||||
|
||||
#endif /* Use GNU. */
|
||||
|
||||
#else /* Need HUGE_VAL. */
|
||||
|
||||
/* Used by <stdlib.h> and <math.h> functions for overflow. */
|
||||
|
||||
/* IEEE positive infinity. */
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
#ifdef __BIG_ENDIAN
|
||||
#define __huge_val_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
|
||||
#else
|
||||
#define __huge_val_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define HUGE_VAL \
|
||||
(__extension__ ((union { unsigned char __c[8]; \
|
||||
double __d; }) \
|
||||
{ __huge_val_bytes }).__d)
|
||||
#else /* Not GCC. */
|
||||
static CONST char __huge_val[8] = __huge_val_bytes;
|
||||
#define HUGE_VAL (*(CONST double *) __huge_val)
|
||||
#endif /* GCC. */
|
||||
|
||||
#endif /* Don't need HUGE_VAL. */
|
||||
43
gnu/glibc/glibc-1.03/sysdeps/ieee754/ieee754.h
Normal file
43
gnu/glibc/glibc-1.03/sysdeps/ieee754/ieee754.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* 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 <endian.h>
|
||||
|
||||
union ieee754_double
|
||||
{
|
||||
double d;
|
||||
|
||||
/* This is the IEEE 754 double-precision format. */
|
||||
struct
|
||||
{
|
||||
#ifdef __BIG_ENDIAN
|
||||
unsigned int negative:1;
|
||||
unsigned int exponent:11;
|
||||
/* Together these comprise the mantissa. */
|
||||
unsigned int mantissa0:20;
|
||||
unsigned int mantissa1:32;
|
||||
#endif
|
||||
#ifdef __LITTLE_ENDIAN
|
||||
/* Together these comprise the mantissa. */
|
||||
unsigned int mantissa1:32;
|
||||
unsigned int mantissa0:20;
|
||||
unsigned int exponent:11;
|
||||
unsigned int negative:1;
|
||||
#endif
|
||||
} ieee;
|
||||
};
|
||||
141
gnu/glibc/glibc-1.03/sysdeps/ieee754/ldexp.c
Normal file
141
gnu/glibc/glibc-1.03/sysdeps/ieee754/ldexp.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/* 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. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted provided
|
||||
* that: (1) source distributions retain this entire copyright notice and
|
||||
* comment, and (2) distributions including binaries display the following
|
||||
* acknowledgement: ``This product includes software developed by the
|
||||
* University of California, Berkeley and its contributors'' in the
|
||||
* documentation or other materials provided with the distribution and in
|
||||
* all advertising materials mentioning features or use of this software.
|
||||
* Neither the name of the University nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
double
|
||||
DEFUN(ldexp, (x, exp),
|
||||
double x AND int exp)
|
||||
{
|
||||
union ieee754_double u;
|
||||
unsigned int exponent;
|
||||
|
||||
u.d = x;
|
||||
#define x u.d
|
||||
|
||||
exponent = u.ieee.exponent;
|
||||
|
||||
/* The order of the tests is carefully chosen to handle
|
||||
the usual case first, with no branches taken. */
|
||||
|
||||
if (exponent != 0)
|
||||
{
|
||||
/* X is nonzero and not denormalized. */
|
||||
|
||||
if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1)
|
||||
{
|
||||
/* X is finite. When EXP < 0, overflow is actually underflow. */
|
||||
|
||||
exponent += exp;
|
||||
|
||||
if (exponent != 0)
|
||||
{
|
||||
if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1)
|
||||
{
|
||||
/* In range. */
|
||||
u.ieee.exponent = exponent;
|
||||
return x;
|
||||
}
|
||||
|
||||
if (exp >= 0)
|
||||
overflow:
|
||||
{
|
||||
CONST int negative = u.ieee.negative;
|
||||
u.d = HUGE_VAL;
|
||||
u.ieee.negative = negative;
|
||||
errno = ERANGE;
|
||||
return u.d;
|
||||
}
|
||||
|
||||
if (exponent <= - (unsigned int) (DBL_MANT_DIG + 1))
|
||||
{
|
||||
/* Underflow. */
|
||||
CONST int negative = u.ieee.negative;
|
||||
u.d = 0.0;
|
||||
u.ieee.negative = negative;
|
||||
errno = ERANGE;
|
||||
return u.d;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gradual underflow. */
|
||||
u.ieee.exponent = 1;
|
||||
u.d *= ldexp (1.0, (int) exponent - 1);
|
||||
if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
|
||||
/* Underflow. */
|
||||
errno = ERANGE;
|
||||
return u.d;
|
||||
}
|
||||
|
||||
/* X is +-infinity or NaN. */
|
||||
if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
|
||||
{
|
||||
/* X is +-infinity. */
|
||||
if (exp >= 0)
|
||||
goto overflow;
|
||||
else
|
||||
{
|
||||
/* (infinity * number < 1). With infinite precision,
|
||||
(infinity / finite) would be infinity, but otherwise it's
|
||||
safest to regard (infinity / 2) as indeterminate. The
|
||||
infinity might be (2 * finite). */
|
||||
CONST int negative = u.ieee.negative;
|
||||
u.d = NAN;
|
||||
u.ieee.negative = negative;
|
||||
errno = EDOM;
|
||||
return u.d;
|
||||
}
|
||||
}
|
||||
|
||||
/* X is NaN. */
|
||||
errno = EDOM;
|
||||
return u.d;
|
||||
}
|
||||
|
||||
/* X is zero or denormalized. */
|
||||
if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
|
||||
/* X is +-0.0. */
|
||||
return x;
|
||||
|
||||
/* X is denormalized.
|
||||
Multiplying by 2 ** DBL_MANT_DIG normalizes it;
|
||||
we then subtract the DBL_MANT_DIG we added to the exponent. */
|
||||
return ldexp (x * ldexp (1.0, DBL_MANT_DIG), exp - DBL_MANT_DIG);
|
||||
}
|
||||
30
gnu/glibc/glibc-1.03/sysdeps/ieee754/log10.c
Normal file
30
gnu/glibc/glibc-1.03/sysdeps/ieee754/log10.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return the base-ten logarithm of X. */
|
||||
double
|
||||
DEFUN(log10, (x), double x)
|
||||
{
|
||||
CONST double inverse_ln10 = 4.3429448190325181667e-1; /* 1 / log(10) */
|
||||
|
||||
return inverse_ln10 * log(x);
|
||||
}
|
||||
122
gnu/glibc/glibc-1.03/sysdeps/ieee754/printf_fp.c
Normal file
122
gnu/glibc/glibc-1.03/sysdeps/ieee754/printf_fp.c
Normal file
@@ -0,0 +1,122 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <printf.h>
|
||||
#include "ieee754.h"
|
||||
|
||||
#define outchar(x) \
|
||||
do \
|
||||
{ \
|
||||
register CONST int outc = (x); \
|
||||
if (putc (outc, s) == EOF) \
|
||||
return -1; \
|
||||
else \
|
||||
++done; \
|
||||
} while (0)
|
||||
|
||||
#ifndef HANDLE_SPECIAL
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
DEFUN(special_ieee754, (s, info, fpnum),
|
||||
FILE *s AND CONST struct printf_info *info AND LONG_DOUBLE fpnum)
|
||||
{
|
||||
int is_neg;
|
||||
CONST char *string;
|
||||
|
||||
if (__isnan ((double) fpnum))
|
||||
{
|
||||
string = "NaN";
|
||||
is_neg = 0;
|
||||
}
|
||||
else if (__isinf ((double) fpnum))
|
||||
{
|
||||
string = "Inf";
|
||||
is_neg = fpnum < 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
{
|
||||
size_t done = 0;
|
||||
int width = info->prec > info->width ? info->prec : info->width;
|
||||
|
||||
if (is_neg || info->showsign || info->space)
|
||||
--width;
|
||||
width -= 3;
|
||||
|
||||
if (!info->left)
|
||||
while (width-- > 0)
|
||||
outchar (' ');
|
||||
|
||||
if (is_neg)
|
||||
outchar ('-');
|
||||
else if (info->showsign)
|
||||
outchar ('+');
|
||||
else if (info->space)
|
||||
outchar (' ');
|
||||
|
||||
{
|
||||
register size_t len = 3;
|
||||
while (len-- > 0)
|
||||
outchar (*string++);
|
||||
}
|
||||
|
||||
if (info->left)
|
||||
while (width-- > 0)
|
||||
outchar (' ');
|
||||
|
||||
return done;
|
||||
}
|
||||
}
|
||||
|
||||
#define HANDLE_SPECIAL(done, s, info, fpnum) \
|
||||
{ \
|
||||
int more_done = special_ieee754 (s, info, fpnum); \
|
||||
if (more_done == -1) \
|
||||
return -1; \
|
||||
else if (more_done != 0) \
|
||||
return done + more_done; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef IS_NEGATIVE
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
DEFUN(is_neg_ieee754, (num), register LONG_DOUBLE num)
|
||||
{
|
||||
union ieee754_double u;
|
||||
|
||||
u.d = (double) num;
|
||||
return u.ieee.negative;
|
||||
}
|
||||
|
||||
#define IS_NEGATIVE(num) is_neg_ieee754 (num)
|
||||
|
||||
#endif
|
||||
|
||||
#include <../sysdeps/generic/printf_fp.c>
|
||||
120
gnu/glibc/glibc-1.03/sysdeps/ieee754/sqrt.c
Normal file
120
gnu/glibc/glibc-1.03/sysdeps/ieee754/sqrt.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted provided
|
||||
* that: (1) source distributions retain this entire copyright notice and
|
||||
* comment, and (2) distributions including binaries display the following
|
||||
* acknowledgement: ``This product includes software developed by the
|
||||
* University of California, Berkeley and its contributors'' in the
|
||||
* documentation or other materials provided with the distribution and in
|
||||
* all advertising materials mentioning features or use of this software.
|
||||
* Neither the name of the University nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Return the square root of X. */
|
||||
double
|
||||
DEFUN (sqrt, (x), double x)
|
||||
{
|
||||
double q, s, b, r, t;
|
||||
CONST double zero = 0.0;
|
||||
int m, n, i;
|
||||
|
||||
/* sqrt (NaN) is NaN; sqrt (+-0) is +-0. */
|
||||
if (__isnan (x) || x == zero)
|
||||
return x;
|
||||
|
||||
if (x < zero)
|
||||
return zero / zero;
|
||||
|
||||
/* sqrt (Inf) is Inf. */
|
||||
if (__isinf (x))
|
||||
return x;
|
||||
|
||||
/* Scale X to [1,4). */
|
||||
n = __logb (x);
|
||||
x = __scalb (x, -n);
|
||||
m = __logb (x);
|
||||
if (m != 0)
|
||||
/* Subnormal number. */
|
||||
x = __scalb (x, -m);
|
||||
|
||||
m += n;
|
||||
n = m / 2;
|
||||
|
||||
if ((n + n) != m)
|
||||
{
|
||||
x *= 2;
|
||||
--m;
|
||||
n = m / 2;
|
||||
}
|
||||
|
||||
/* Generate sqrt (X) bit by bit (accumulating in Q). */
|
||||
q = 1.0;
|
||||
s = 4.0;
|
||||
x -= 1.0;
|
||||
r = 1;
|
||||
for (i = 1; i <= 51; i++)
|
||||
{
|
||||
t = s + 1;
|
||||
x *= 4;
|
||||
r /= 2;
|
||||
if (t <= x)
|
||||
{
|
||||
s = t + t + 2, x -= t;
|
||||
q += r;
|
||||
}
|
||||
else
|
||||
s *= 2;
|
||||
}
|
||||
|
||||
/* Generate the last bit and determine the final rounding. */
|
||||
r /= 2;
|
||||
x *= 4;
|
||||
if (x == zero)
|
||||
goto end;
|
||||
(void) (100 + r); /* Trigger inexact flag. */
|
||||
if (s < x)
|
||||
{
|
||||
q += r;
|
||||
x -= s;
|
||||
s += 2;
|
||||
s *= 2;
|
||||
x *= 4;
|
||||
t = (x - s) - 5;
|
||||
b = 1.0 + 3 * r / 4;
|
||||
if (b == 1.0)
|
||||
goto end; /* B == 1: Round to zero. */
|
||||
b = 1.0 + r / 4;
|
||||
if (b > 1.0)
|
||||
t = 1; /* B > 1: Round to +Inf. */
|
||||
if (t >= 0)
|
||||
q += r;
|
||||
} /* Else round to nearest. */
|
||||
else
|
||||
{
|
||||
s *= 2;
|
||||
x *= 4;
|
||||
t = (x - s) - 1;
|
||||
b = 1.0 + 3 * r / 4;
|
||||
if (b == 1.0)
|
||||
goto end;
|
||||
b = 1.0 + r / 4;
|
||||
if (b > 1.0)
|
||||
t = 1;
|
||||
if (t >= 0)
|
||||
q += r;
|
||||
}
|
||||
|
||||
end:
|
||||
return __scalb (q, n);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/* Copyright (C) 1991 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. */
|
||||
|
||||
#ifndef _68881_SWITCH_H
|
||||
|
||||
#define _68881_SWITCH_H 1
|
||||
|
||||
|
||||
/* This is the format of the data at the code label for a function which
|
||||
wants to switch depending on whether or not a 68881 is present.
|
||||
|
||||
Initially, `insn' is a `jsr' instruction, and `target' is __68881_switch.
|
||||
The first time such a function is called, __68881_switch determines whether
|
||||
or not a 68881 is present, and modifies the function accordingly.
|
||||
Then `insn' is a `jmp' instruction, and `target' is the value of `fpu'
|
||||
if there is 68881, or the value of `soft' if not. */
|
||||
|
||||
struct switch_caller
|
||||
{
|
||||
unsigned short int insn; /* The `jsr' or `jmp' instruction. */
|
||||
PTR target; /* The target of the instruction. */
|
||||
PTR soft; /* The address of the soft function. */
|
||||
PTR fpu; /* The address of the 68881 function. */
|
||||
};
|
||||
|
||||
/* These are opcodes (values for `insn', above) for `jmp' and `jsr'
|
||||
instructions, respectively, to 32-bit absolute addresses. */
|
||||
#define JMP 0x4ef9
|
||||
#define JSR 0x4eb9
|
||||
|
||||
|
||||
/* Function to determine whether or not a 68881 is available,
|
||||
and modify its caller (which must be a `struct switch_caller', above,
|
||||
in data space) to use the appropriate version. */
|
||||
extern void EXFUN(__68881_switch, (int __dummy));
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
#define __paste(a, b) a ## b
|
||||
#else
|
||||
#define __paste(a, b) a/**/b
|
||||
#endif
|
||||
|
||||
/* Define FUNCTION as a `struct switch_caller' which will call
|
||||
`__FUNCTION_68881' if a 68881 is present, and `__FUNCTION_soft' if not.
|
||||
#define switching_function(FUNCTION) \
|
||||
struct switch_caller FUNCTION = \
|
||||
{ \
|
||||
JSR, (PTR) __68881_switch, \
|
||||
__paste(__paste(__, FUNCTION), _soft), \
|
||||
__paste(__paste(__, FUNCTION), _68881) \
|
||||
}
|
||||
|
||||
|
||||
#endif /* 68881-switch.h */
|
||||
@@ -0,0 +1 @@
|
||||
68881-sw.h switch.c
|
||||
@@ -0,0 +1,52 @@
|
||||
# Copyright (C) 1991, 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.
|
||||
|
||||
ifeq ($(subdir),math)
|
||||
|
||||
sysdep_routines := $(sysdep_routines) switch
|
||||
|
||||
# Find all the sources that have 68881 versions.
|
||||
+68881-sources := \
|
||||
$(notdir $(wildcard $(addprefix $(filter %/68881,$(sysdirs)),$(sources))))
|
||||
|
||||
# Sysdep directories other than 68881 and 68881-sw (this one).
|
||||
+non68881-dirs := $(filter-out %/68881 %/68881-switch,$(+sysdep_dirs))
|
||||
|
||||
# Get a non-68881 version of the target.
|
||||
+non68881-version = $(firstword $(wildcard $(addsuffix /$@,$(+non68881-dirs))))
|
||||
|
||||
# Directory containing 68881 sources.
|
||||
+68881-dir := $(filter %/68881,$(+sysdep_dirs))
|
||||
|
||||
# For all the files that have 68881 versions and don't exist already in
|
||||
# the source directory (math), automatically make ones that switch between
|
||||
# 68881 and soft versions.
|
||||
$(addprefix $(objpfx), \
|
||||
$(filter-out $(wildcard $(+68881-sources)),$(+68881-sources))):
|
||||
(echo '#include <ansidecl.h>' ;\
|
||||
echo '#include <68881-sw.h>' ;\
|
||||
echo '#define $* __$*_68881' ;\
|
||||
echo '#include <$(+68881-dir)/$@>' ;\
|
||||
echo '#undef $*' ;\
|
||||
echo '#define $* __$*_soft' ;\
|
||||
echo '#include <$(non68881-version)>' ;\
|
||||
echo '#undef $*' ;\
|
||||
echo 'switching_function($*);') > $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
endif
|
||||
@@ -0,0 +1 @@
|
||||
/* We don't want any inlines when we might not have a 68881. */
|
||||
@@ -0,0 +1,86 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <signal.h>
|
||||
#include <68881-switch.h>
|
||||
|
||||
|
||||
/* The signal that is sent when a 68881 instruction
|
||||
is executed and there is no 68881. */
|
||||
#ifndef TRAPSIG
|
||||
#define TRAPSIG SIGILL
|
||||
#endif
|
||||
|
||||
/* Zero if no 68881, one if we have a 68881, or -1 if we don't know yet. */
|
||||
static int have_fpu = -1;
|
||||
|
||||
|
||||
/* Signal handler for the trap that happens if we don't have a 68881. */
|
||||
static void
|
||||
DEFUN(trap, (sig), int sig)
|
||||
{
|
||||
have_fpu = 0;
|
||||
}
|
||||
|
||||
/* This function is called by functions that want to switch.
|
||||
The calling function must be a `struct switch_caller' in data space.
|
||||
It determines whether a 68881 is present, and modifies its caller
|
||||
to be a static jump to either the 68881 version or the soft version.
|
||||
It then returns into the function it has chosen to do the work. */
|
||||
void
|
||||
DEFUN(__68881_switch, (dummy), int dummy)
|
||||
{
|
||||
PTR *return_address_location = &((PTR *) &dummy)[-1];
|
||||
struct switch_caller *CONST caller
|
||||
= (struct switch_caller *) (((short int *) *return_address_location) - 1);
|
||||
|
||||
if (have_fpu < 0)
|
||||
{
|
||||
/* Figure out whether or not we have a 68881. */
|
||||
__sighandler_t handler = signal (TRAPSIG, trap);
|
||||
if (handler == SIG_ERR)
|
||||
/* We can't figure it out, so assume we don't have a 68881.
|
||||
This assumption will never cause us any problems other than
|
||||
lost performance, while the reverse assumption could cause
|
||||
the program to crash. */
|
||||
have_fpu = 0;
|
||||
else
|
||||
{
|
||||
/* We set `have_fpu' to nonzero, and then execute a 68881
|
||||
no-op instruction. If we have a 68881, this will do nothing.
|
||||
If we don't have one, this will trap and the signal handler
|
||||
will clear `have_fpu'. */
|
||||
have_fpu = 1;
|
||||
asm ("fnop");
|
||||
|
||||
/* Restore the old signal handler. */
|
||||
(void) signal (TRAPSIG, handler);
|
||||
}
|
||||
}
|
||||
|
||||
/* Modify the caller to be a jump to the appropriate address. */
|
||||
caller->insn = JMP;
|
||||
caller->target = have_fpu ? caller->fpu : caller->soft;
|
||||
|
||||
/* Make the address we will return to be the target we have chosen.
|
||||
Our return will match the `jsr' done by the caller we have
|
||||
just modified, and it will be just as if that had instead
|
||||
been a `jmp' to the new target. */
|
||||
*return_address_location = caller->target;
|
||||
}
|
||||
11
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/Makefile
Normal file
11
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
ifeq ($(subdir),math)
|
||||
ifndef math-twiddled
|
||||
|
||||
# Avoid twiddling in generic/Makefile.
|
||||
math-twiddled := t
|
||||
|
||||
endif
|
||||
|
||||
bsdmath_dirs := $(bsdmath_dirs) mc68881
|
||||
|
||||
endif
|
||||
29
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__drem.c
Normal file
29
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__drem.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#define __NO_MATH_INLINES
|
||||
#include <math.h>
|
||||
|
||||
#undef drem
|
||||
|
||||
double
|
||||
DEFUN(drem, (x, y), double x AND double y)
|
||||
{
|
||||
return __drem(x, y);
|
||||
}
|
||||
3
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__expm1.c
Normal file
3
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__expm1.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define FUNC __expm1
|
||||
#define OP expm1
|
||||
#include <../sysdeps/m68k/68881/acos.c>
|
||||
32
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__isinf.c
Normal file
32
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__isinf.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#define __NO_MATH_INLINES
|
||||
#include <math.h>
|
||||
|
||||
#ifndef FUNC
|
||||
#define FUNC __isinf
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
DEFUN(FUNC, (x), double x)
|
||||
{
|
||||
return __m81_u(FUNC)(x);
|
||||
}
|
||||
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__isnan.c
Normal file
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__isnan.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define FUNC __isnan
|
||||
#include <../sysdeps/m68k/68881/__isinf.c>
|
||||
43
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__logb.c
Normal file
43
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__logb.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
/* Return the base 2 signed integral exponent of X. */
|
||||
double
|
||||
DEFUN(__logb, (x), double x)
|
||||
{
|
||||
if (__isnan(x))
|
||||
return x;
|
||||
if (__isinf(x))
|
||||
return fabs(x);
|
||||
|
||||
if (x == 0.0)
|
||||
asm("flog2%.x %0" : "=f" (x) : "0" (x));
|
||||
else
|
||||
asm("fgetexp%.x %0" : "=f" (x) : "0" (x));
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/ieee754/__logb.c>
|
||||
#endif
|
||||
172
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__math.h
Normal file
172
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__math.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/* Copyright (C) 1991 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. */
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
/* IGNORE($ */
|
||||
#ifdef __STDC__
|
||||
/* $) IFANSI($ */
|
||||
#define __m81_s(x) #x
|
||||
#define __m81_ul(x) __ ## x
|
||||
/* $) IGNORE($ */
|
||||
#else
|
||||
/* $) IFTRAD($ */
|
||||
#define __m81_s(x) "x"
|
||||
#define __m81_ul(x) __/**/x
|
||||
/* $) IGNORE($ */
|
||||
#endif
|
||||
/* $) */
|
||||
|
||||
#ifdef __NO_MATH_INLINES
|
||||
#define __m81_u(x) __m81_ul(x)
|
||||
#else
|
||||
#define __m81_u(x) x
|
||||
#define __MATH_INLINES 1
|
||||
#endif
|
||||
|
||||
#define __inline_mathop2(func, op) \
|
||||
extern __inline __const double \
|
||||
__m81_u(func)(double __mathop_x) \
|
||||
{ \
|
||||
double __result; \
|
||||
__asm("f" __m81_s(op) "%.x %1, %0" : "=f" (__result) : "f" (__mathop_x)); \
|
||||
return __result; \
|
||||
}
|
||||
#define __inline_mathop(op) __inline_mathop2(op, op)
|
||||
|
||||
__inline_mathop(acos)
|
||||
__inline_mathop(asin)
|
||||
__inline_mathop(atan)
|
||||
__inline_mathop(cos)
|
||||
__inline_mathop(sin)
|
||||
__inline_mathop(tan)
|
||||
__inline_mathop(cosh)
|
||||
__inline_mathop(sinh)
|
||||
__inline_mathop(tanh)
|
||||
__inline_mathop2(exp, etox)
|
||||
__inline_mathop2(fabs, abs)
|
||||
__inline_mathop(log10)
|
||||
__inline_mathop2(log, logn)
|
||||
__inline_mathop2(floor, intrz)
|
||||
__inline_mathop(sqrt)
|
||||
|
||||
#ifdef __USE_MISC
|
||||
__inline_mathop2(rint, int)
|
||||
__inline_mathop2(expm1, etoxm1)
|
||||
__inline_mathop2(log1p, lognp1)
|
||||
__inline_mathop(atanh)
|
||||
#endif
|
||||
|
||||
extern __inline __const double
|
||||
__m81_u(__drem)(double __x, double __y)
|
||||
{
|
||||
double __result;
|
||||
__asm("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
|
||||
return __result;
|
||||
}
|
||||
|
||||
extern __inline __const double
|
||||
__m81_u(ldexp)(double __x, int __e)
|
||||
{
|
||||
double __result;
|
||||
double __double_e = (double) __e;
|
||||
__asm("fscale%.x %1, %0" : "=f" (__result) : "f" (__double_e), "0" (__x));
|
||||
return __result;
|
||||
}
|
||||
|
||||
extern __inline __const double
|
||||
__m81_u(fmod)(double __x, double __y)
|
||||
{
|
||||
double __result;
|
||||
__asm("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
|
||||
return __result;
|
||||
}
|
||||
|
||||
extern __inline double
|
||||
__m81_u(frexp)(double __value, int *__expptr)
|
||||
{
|
||||
double __mantissa, __exponent;
|
||||
__asm("fgetexp%.x %1, %0" : "=f" (__exponent) : "f" (__value));
|
||||
__asm("fgetman%.x %1, %0" : "=f" (__mantissa) : "f" (__value));
|
||||
*__expptr = (int) __exponent;
|
||||
return __mantissa;
|
||||
}
|
||||
|
||||
extern __inline __const double
|
||||
__m81_u(pow)(double __x, double __y)
|
||||
{
|
||||
double __result;
|
||||
if (__y == 0.0 || __x == 1.0)
|
||||
__result = 1.0;
|
||||
else if (__y == 1.0)
|
||||
__result = __x;
|
||||
else if (__y == 2.0)
|
||||
__result = __x * __x;
|
||||
else if (__x == 10.0)
|
||||
__asm("ftentox%.x %1, %0" : "=f" (__result) : "f" (__y));
|
||||
else if (__x == 2.0)
|
||||
__asm("ftwotox%.x %1, %0" : "=f" (__result) : "f" (__y));
|
||||
else
|
||||
__result = __m81_u(exp)(__y * __m81_u(log)(__x));
|
||||
return __result;
|
||||
}
|
||||
|
||||
extern __inline __const double
|
||||
__m81_u(ceil)(double __x)
|
||||
{
|
||||
double __result;
|
||||
unsigned long int __ctrl_reg;
|
||||
__asm("fmove%.l fpcr, %0" : "=g" (__ctrl_reg));
|
||||
/* Set rounding towards positive infinity. */
|
||||
__asm("fmove%.l %0, fpcr" : /* No outputs. */ : "g" (__ctrl_reg | 0x30));
|
||||
/* Convert X to an integer, using +Inf rounding. */
|
||||
__asm("fint%.x %1, %0" : "=f" (__result) : "f" (__x));
|
||||
/* Restore the previous rounding mode. */
|
||||
__asm("fmove%.l %0, fpcr" : /* No outputs. */ : "g" (__ctrl_reg));
|
||||
return __result;
|
||||
}
|
||||
|
||||
extern __inline double
|
||||
__m81_u(modf)(double __value, double *__iptr)
|
||||
{
|
||||
double __modf_int = __m81_u(floor)(__value);
|
||||
*__iptr = __modf_int;
|
||||
return __value - __modf_int;
|
||||
}
|
||||
|
||||
extern __inline int
|
||||
__m81_u(__isinf)(double __value)
|
||||
{
|
||||
/* There is no branch-condition for infinity,
|
||||
so we must extract and examine the condition codes manually. */
|
||||
unsigned long int __fpsr;
|
||||
__asm("ftst%.x %1\n"
|
||||
"fmove%.l fpsr, %0" : "=g" (__fpsr) : "f" (__value));
|
||||
return (__fpsr & (2 << (3 * 8))) ? (__value < 0 ? -1 : 1) : 0;
|
||||
}
|
||||
|
||||
extern __inline int
|
||||
__m81_u(__isnan)(double __value)
|
||||
{
|
||||
char __result;
|
||||
__asm("ftst%.x %1\n"
|
||||
"fsun %0" : "=g" (__result) : "f" (__value));
|
||||
return __result;
|
||||
}
|
||||
|
||||
#endif /* GCC. */
|
||||
3
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__rint.c
Normal file
3
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/__rint.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define FUNC __rint
|
||||
#define OP intr
|
||||
#include <../sysdeps/m68k/68881/acos.c>
|
||||
32
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/acos.c
Normal file
32
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/acos.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 1991 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 <ansidecl.h>
|
||||
#define __NO_MATH_INLINES
|
||||
#include <math.h>
|
||||
|
||||
#ifndef FUNC
|
||||
#define FUNC acos
|
||||
#endif
|
||||
|
||||
|
||||
double
|
||||
DEFUN(FUNC, (x), double x)
|
||||
{
|
||||
return __m81_u(FUNC)(x);
|
||||
}
|
||||
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/asin.c
Normal file
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/asin.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define FUNC asin
|
||||
#include <../sysdeps/m68k/68881/acos.c>
|
||||
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/atan.c
Normal file
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/atan.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define FUNC atan
|
||||
#include <../sysdeps/m68k/68881/acos.c>
|
||||
74
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/atan2.c
Normal file
74
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/atan2.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/* Copyright (C) 1991, 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 <ansidecl.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
static CONST double
|
||||
PIo4 = 7.8539816339744827900E-1 , /*Hex 2^ -1 * 1.921FB54442D18 */
|
||||
PIo2 = 1.5707963267948965580E0 , /*Hex 2^ 0 * 1.921FB54442D18 */
|
||||
PI = 3.1415926535897931160E0 ; /*Hex 2^ 1 * 1.921FB54442D18 */
|
||||
|
||||
double
|
||||
DEFUN(atan2, (y, x), double y AND double x)
|
||||
{
|
||||
static CONST double one = 1.0, zero = 0.0;
|
||||
double signx, signy;
|
||||
double pi;
|
||||
|
||||
if (__isnan(x))
|
||||
return x;
|
||||
if (__isnan(y))
|
||||
return y;
|
||||
|
||||
signy = __copysign(one, y);
|
||||
signx = __copysign(one, x);
|
||||
|
||||
asm("fmovecr%.x %1, %0" : "=f" (pi) : "i" (0));
|
||||
|
||||
if (y == zero)
|
||||
return signx == one ? y : __copysign(pi, signy);
|
||||
|
||||
if (x == zero)
|
||||
return __copysign(PIo2, signy);
|
||||
|
||||
if (__isinf(x))
|
||||
{
|
||||
if (__isinf(y))
|
||||
return __copysign(signx == one ? PIo4 : 3 * PIo4, signy);
|
||||
else
|
||||
return __copysign(signx == one ? zero : pi, signy);
|
||||
}
|
||||
|
||||
if (__isinf(y))
|
||||
return __copysign(PIo2, signy);
|
||||
|
||||
y = fabs(y);
|
||||
|
||||
if (x < 0.0)
|
||||
/* X is negative. */
|
||||
return __copysign(pi - atan(y / -x), signy);
|
||||
|
||||
return __copysign(atan(y / x), signy);
|
||||
}
|
||||
|
||||
#else
|
||||
#include <sysdeps/ieee754/atan2.c>
|
||||
#endif
|
||||
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/atanh.c
Normal file
2
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/atanh.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define FUNC atanh
|
||||
#include <../sysdeps/m68k/68881/acos.c>
|
||||
4
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/ceil.c
Normal file
4
gnu/glibc/glibc-1.03/sysdeps/m68k/68881/ceil.c
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
#define FUNC ceil
|
||||
|
||||
#include <../sysdeps/m68k/68881/acos.c>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user