add directory gnu

This commit is contained in:
gohigh
2024-02-19 00:24:47 -05:00
parent 32616db5a4
commit a40f4cadb0
5086 changed files with 1860970 additions and 0 deletions

View File

@@ -0,0 +1 @@
ieee754

View 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 ();
}

View 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

View 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

View 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];

View 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

View 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)

View 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

View 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;
}

View 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;
}