import from github
This commit is contained in:
58
agbcc/libc/reent/closer.c
Normal file
58
agbcc/libc/reent/closer.c
Normal file
@ -0,0 +1,58 @@
|
||||
/* Reentrant version of close system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_close_r>>---Reentrant version of close
|
||||
|
||||
INDEX
|
||||
_close_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _close_r(struct _reent *<[ptr]>, int <[fd]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _close_r(<[ptr]>, <[fd]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int <[fd]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<close>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_close_r (ptr, fd)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _close (fd)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
144
agbcc/libc/reent/execr.c
Normal file
144
agbcc/libc/reent/execr.c
Normal file
@ -0,0 +1,144 @@
|
||||
/* Reentrant versions of execution system calls. These
|
||||
implementations just call the usual system calls. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* If NO_EXEC is defined, we don't need these functions. */
|
||||
|
||||
#if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC)
|
||||
|
||||
int _dummy_exec_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_execve_r>>---Reentrant version of execve
|
||||
INDEX
|
||||
_execve_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _execve_r(struct _reent *<[ptr]>, char *<[name]>,
|
||||
char **<[argv]>, char **<[env]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _execve_r(<[ptr]>, <[name]>, <[argv]>, <[env]>)
|
||||
struct _reent *<[ptr]>;
|
||||
char *<[name]>;
|
||||
char **<[argv]>;
|
||||
char **<[env]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<execve>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_execve_r (ptr, name, argv, env)
|
||||
struct _reent *ptr;
|
||||
char *name;
|
||||
char **argv;
|
||||
char **env;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _execve (name, argv, env)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_fork_r>>---Reentrant version of fork
|
||||
|
||||
INDEX
|
||||
_fork_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _fork_r(struct _reent *<[ptr]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _fork_r(<[ptr]>)
|
||||
struct _reent *<[ptr]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<fork>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
#ifndef NO_FORK
|
||||
|
||||
int
|
||||
_fork_r (ptr)
|
||||
struct _reent *ptr;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _fork ()) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_wait_r>>---Reentrant version of wait
|
||||
|
||||
INDEX
|
||||
_wait_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _wait_r(struct _reent *<[ptr]>, int *<[status]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _wait_r(<[ptr]>, <[status]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int *<[status]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<wait>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_wait_r (ptr, status)
|
||||
struct _reent *ptr;
|
||||
int *status;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _wait (status)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
66
agbcc/libc/reent/fstatr.c
Normal file
66
agbcc/libc/reent/fstatr.c
Normal file
@ -0,0 +1,66 @@
|
||||
/* Reentrant versions of fstat system call. This implementation just
|
||||
calls the fstat system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
int _dummy_fstat_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_fstat_r>>---Reentrant version of fstat
|
||||
|
||||
INDEX
|
||||
_fstat_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _fstat_r(struct _reent *<[ptr]>,
|
||||
int <[fd]>, struct stat *<[pstat]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _fstat_r(<[ptr]>, <[fd]>, <[pstat]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int <[fd]>;
|
||||
struct stat *<[pstat]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<fstat>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_fstat_r (ptr, fd, pstat)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
struct stat *pstat;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _fstat (fd, pstat)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
13
agbcc/libc/reent/impure.c
Normal file
13
agbcc/libc/reent/impure.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include <reent.h>
|
||||
|
||||
/* Note that there is a copy of this in sys/reent.h. */
|
||||
#ifndef __ATTRIBUTE_IMPURE_PTR__
|
||||
#define __ATTRIBUTE_IMPURE_PTR__
|
||||
#endif
|
||||
|
||||
#ifndef __ATTRIBUTE_IMPURE_DATA__
|
||||
#define __ATTRIBUTE_IMPURE_DATA__
|
||||
#endif
|
||||
|
||||
static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure_data);
|
||||
struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data;
|
102
agbcc/libc/reent/linkr.c
Normal file
102
agbcc/libc/reent/linkr.c
Normal file
@ -0,0 +1,102 @@
|
||||
/* Reentrant versions of file system calls. These implementations
|
||||
just call the usual system calls. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
int _dummy_link_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_link_r>>---Reentrant version of link
|
||||
|
||||
INDEX
|
||||
_link_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _link_r(struct _reent *<[ptr]>,
|
||||
const char *<[old]>, const char *<[new]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _link_r(<[ptr]>, <[old]>, <[new]>)
|
||||
struct _reent *<[ptr]>;
|
||||
char *<[old]>;
|
||||
char *<[new]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<link>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_link_r (ptr, old, new)
|
||||
struct _reent *ptr;
|
||||
_CONST char *old;
|
||||
_CONST char *new;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _link (old, new)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_unlink_r>>---Reentrant version of unlink
|
||||
|
||||
INDEX
|
||||
_unlink_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _unlink_r(struct _reent *<[ptr]>, const char *<[file]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _unlink_r(<[ptr]>, <[file]>)
|
||||
struct _reent *<[ptr]>;
|
||||
char *<[file]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<unlink>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_unlink_r (ptr, file)
|
||||
struct _reent *ptr;
|
||||
_CONST char *file;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _unlink (file)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
63
agbcc/libc/reent/lseekr.c
Normal file
63
agbcc/libc/reent/lseekr.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* Reentrant versions of lseek system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_lseek_r>>---Reentrant version of lseek
|
||||
|
||||
INDEX
|
||||
_lseek_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
off_t _lseek_r(struct _reent *<[ptr]>,
|
||||
int <[fd]>, off_t <[pos]>, int <[whence]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
off_t _lseek_r(<[ptr]>, <[fd]>, <[pos]>, <[whence]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int <[fd]>;
|
||||
off_t <[pos]>;
|
||||
int <[whence]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<lseek>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
off_t
|
||||
_lseek_r (ptr, fd, pos, whence)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
off_t pos;
|
||||
int whence;
|
||||
{
|
||||
off_t ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _lseek (fd, pos, whence)) == (off_t) -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
64
agbcc/libc/reent/openr.c
Normal file
64
agbcc/libc/reent/openr.c
Normal file
@ -0,0 +1,64 @@
|
||||
/* Reentrant versions of open system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_open_r>>---Reentrant version of open
|
||||
|
||||
INDEX
|
||||
_open_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _open_r(struct _reent *<[ptr]>,
|
||||
const char *<[file]>, int <[flags]>, int <[mode]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _open_r(<[ptr]>, <[file]>, <[flags]>, <[mode]>)
|
||||
struct _reent *<[ptr]>;
|
||||
char *<[file]>;
|
||||
int <[flags]>;
|
||||
int <[mode]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<open>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_open_r (ptr, file, flags, mode)
|
||||
struct _reent *ptr;
|
||||
_CONST char *file;
|
||||
int flags;
|
||||
int mode;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _open (file, flags, mode)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
63
agbcc/libc/reent/readr.c
Normal file
63
agbcc/libc/reent/readr.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* Reentrant versions of read system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_read_r>>---Reentrant version of read
|
||||
|
||||
INDEX
|
||||
_read_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
long _read_r(struct _reent *<[ptr]>,
|
||||
int <[fd]>, void *<[buf]>, size_t <[cnt]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
long _read_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int <[fd]>;
|
||||
char *<[buf]>;
|
||||
size_t <[cnt]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<read>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
long
|
||||
_read_r (ptr, fd, buf, cnt)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
_PTR buf;
|
||||
size_t cnt;
|
||||
{
|
||||
long ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _read (fd, buf, cnt)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
107
agbcc/libc/reent/reent.c
Normal file
107
agbcc/libc/reent/reent.c
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
FUNCTION
|
||||
<<reent>>---definition of impure data.
|
||||
|
||||
INDEX
|
||||
reent
|
||||
|
||||
DESCRIPTION
|
||||
This module defines the impure data area used by the
|
||||
non-rentrant functions, such as strtok.
|
||||
*/
|
||||
|
||||
#include <reent.h>
|
||||
|
||||
/* Interim cleanup code */
|
||||
|
||||
void
|
||||
cleanup_glue (ptr, glue)
|
||||
struct _reent *ptr;
|
||||
struct _glue *glue;
|
||||
{
|
||||
/* Have to reclaim these in reverse order: */
|
||||
if (glue->_next)
|
||||
cleanup_glue (ptr, glue->_next);
|
||||
|
||||
_free_r (ptr, glue);
|
||||
}
|
||||
|
||||
void
|
||||
_reclaim_reent (ptr)
|
||||
struct _reent *ptr;
|
||||
{
|
||||
if (ptr != _impure_ptr)
|
||||
{
|
||||
/* used by mprec routines. */
|
||||
if (ptr->_freelist)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 15 /* _Kmax */; i++)
|
||||
{
|
||||
struct _Bigint *thisone, *nextone;
|
||||
|
||||
nextone = ptr->_freelist[i];
|
||||
while (nextone)
|
||||
{
|
||||
thisone = nextone;
|
||||
nextone = nextone->_next;
|
||||
_free_r (ptr, thisone);
|
||||
}
|
||||
}
|
||||
|
||||
_free_r (ptr, ptr->_freelist);
|
||||
}
|
||||
|
||||
/* atexit stuff */
|
||||
if ((ptr->_atexit) && (ptr->_atexit != &ptr->_atexit0))
|
||||
{
|
||||
struct _atexit *p, *q;
|
||||
for (p = ptr->_atexit; p != &ptr->_atexit0;)
|
||||
{
|
||||
q = p;
|
||||
p = p->_next;
|
||||
_free_r (ptr, q);
|
||||
}
|
||||
}
|
||||
|
||||
if (ptr->_cvtbuf)
|
||||
_free_r (ptr, ptr->_cvtbuf);
|
||||
|
||||
if (ptr->__sdidinit)
|
||||
{
|
||||
/* cleanup won't reclaim memory 'coz usually it's run
|
||||
before the program exits, and who wants to wait for that? */
|
||||
ptr->__cleanup (ptr);
|
||||
|
||||
if (ptr->__sglue._next)
|
||||
cleanup_glue (ptr, ptr->__sglue._next);
|
||||
}
|
||||
|
||||
/* Malloc memory not reclaimed; no good way to return memory anyway. */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Do atexit() processing and cleanup
|
||||
*
|
||||
* NOTE: This is to be executed at task exit. It does not tear anything
|
||||
* down which is used on a global basis.
|
||||
*/
|
||||
|
||||
void
|
||||
_wrapup_reent(struct _reent *ptr)
|
||||
{
|
||||
register struct _atexit *p;
|
||||
register int n;
|
||||
|
||||
if (ptr == 0)
|
||||
ptr = _REENT;
|
||||
|
||||
for (p = ptr->_atexit; p; p = p->_next)
|
||||
for (n = p->_ind; --n >= 0;)
|
||||
(*p->_fns[n]) ();
|
||||
if (ptr->__cleanup)
|
||||
(*ptr->__cleanup) (ptr);
|
||||
}
|
||||
|
66
agbcc/libc/reent/sbrkr.c
Normal file
66
agbcc/libc/reent/sbrkr.c
Normal file
@ -0,0 +1,66 @@
|
||||
/* Reentrant versions of sbrk system call. This implementation just
|
||||
calls the stat system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* If MALLOC_PROVIDED is defined, we don't need this function. */
|
||||
|
||||
#if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (MALLOC_PROVIDED)
|
||||
|
||||
int _dummy_sbrk_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_sbrk_r>>---Reentrant version of sbrk
|
||||
|
||||
INDEX
|
||||
_sbrk_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
void *_sbrk_r(struct _reent *<[ptr]>, size_t <[incr]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
void *_sbrk_r(<[ptr]>, <[incr]>)
|
||||
struct _reent *<[ptr]>;
|
||||
size_t <[incr]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<sbrk>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
void *
|
||||
_sbrk_r (ptr, incr)
|
||||
struct _reent *ptr;
|
||||
size_t incr;
|
||||
{
|
||||
char *ret;
|
||||
void *_sbrk(size_t);
|
||||
|
||||
errno = 0;
|
||||
if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
98
agbcc/libc/reent/signalr.c
Normal file
98
agbcc/libc/reent/signalr.c
Normal file
@ -0,0 +1,98 @@
|
||||
/* Reentrant versions of syscalls need to support signal/raise.
|
||||
These implementations just call the usual system calls. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
int _dummy_link_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_kill_r>>---Reentrant version of kill
|
||||
|
||||
INDEX
|
||||
_kill_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _kill_r(struct _reent *<[ptr]>, int <[pid]>, int <[sig]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _kill_r(<[ptr]>, <[pid]>, <[sig]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int <[pid]>;
|
||||
int <[sig]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<kill>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_kill_r (ptr, pid, sig)
|
||||
struct _reent *ptr;
|
||||
int pid;
|
||||
int sig;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _kill (pid, sig)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_getpid_r>>---Reentrant version of getpid
|
||||
|
||||
INDEX
|
||||
_getpid_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _getpid_r(struct _reent *<[ptr]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _getpid_r(<[ptr]>)
|
||||
struct _reent *<[ptr]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<getpid>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
|
||||
We never need <<errno>>, of course, but for consistency we
|
||||
still must have the reentrant pointer argument.
|
||||
*/
|
||||
|
||||
int
|
||||
_getpid_r (ptr)
|
||||
struct _reent *ptr;
|
||||
{
|
||||
int ret;
|
||||
ret = _getpid ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
67
agbcc/libc/reent/statr.c
Normal file
67
agbcc/libc/reent/statr.c
Normal file
@ -0,0 +1,67 @@
|
||||
/* Reentrant versions of stat system call. This implementation just
|
||||
calls the stat system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in
|
||||
TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
int _dummy_stat_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_stat_r>>---Reentrant version of stat
|
||||
|
||||
INDEX
|
||||
_stat_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _stat_r(struct _reent *<[ptr]>,
|
||||
const char *<[file]>, struct stat *<[pstat]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _stat_r(<[ptr]>, <[file]>, <[pstat]>)
|
||||
struct _reent *<[ptr]>;
|
||||
char *<[file]>;
|
||||
struct stat *<[pstat]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<stat>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_stat_r (ptr, file, pstat)
|
||||
struct _reent *ptr;
|
||||
_CONST char *file;
|
||||
struct stat *pstat;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _stat (file, pstat)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
112
agbcc/libc/reent/timer.c
Normal file
112
agbcc/libc/reent/timer.c
Normal file
@ -0,0 +1,112 @@
|
||||
/* Reentrant versions of times and gettimeofday system calls for the
|
||||
clock and time ANSI C routines.
|
||||
This implementation just calls the times/gettimeofday system calls.
|
||||
Gettimeofday may not be available on all targets. It's presence
|
||||
here is dubious. Consider it for internal use only. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <time.h>
|
||||
#include <sys/times.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
int _dummy_time_syscalls = 1;
|
||||
|
||||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_times_r>>---Reentrant version of times
|
||||
|
||||
INDEX
|
||||
_times_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
#include <sys/times.h>
|
||||
clock_t _times_r(struct _reent *<[ptr]>, struct tms *<[ptms]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
#include <sys/times.h>
|
||||
clock_t _times_r(<[ptr]>, <[ptms]>)
|
||||
struct _reent *<[ptr]>;
|
||||
struct tms *<[ptms]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<times>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
clock_t
|
||||
_times_r (ptr, ptms)
|
||||
struct _reent *ptr;
|
||||
struct tms *ptms;
|
||||
{
|
||||
clock_t ret;
|
||||
|
||||
ret = _times (ptms);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_gettimeofday_r>>---Reentrant version of gettimeofday
|
||||
|
||||
INDEX
|
||||
_gettimeofday_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
#include <time.h>
|
||||
int _gettimeofday_r(struct _reent *<[ptr]>,
|
||||
struct timeval *<[ptimeval]>,
|
||||
struct timezone *<[ptimezone]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
#include <time.h>
|
||||
int _gettimeofday_r(<[ptr]>, <[ptimeval]>, <[ptimezone]>)
|
||||
struct _reent *<[ptr]>;
|
||||
struct timeval *<[ptimeval]>;
|
||||
struct timezone *<[ptimezone]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<gettimeofday>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
|
||||
This function is only available for a few targets.
|
||||
Check libc.a to see if its available on yours.
|
||||
*/
|
||||
|
||||
int
|
||||
_gettimeofday_r (ptr, ptimeval, ptimezone)
|
||||
struct _reent *ptr;
|
||||
struct timeval *ptimeval;
|
||||
struct timezone *ptimezone;
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
63
agbcc/libc/reent/writer.c
Normal file
63
agbcc/libc/reent/writer.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* Reentrant versions of write system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
||||
#ifdef _REENT_ONLY
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
#define REENTRANT_SYSCALLS_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_write_r>>---Reentrant version of write
|
||||
|
||||
INDEX
|
||||
_write_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
long _write_r(struct _reent *<[ptr]>,
|
||||
int <[fd]>, const void *<[buf]>, size_t <[cnt]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
long _write_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>)
|
||||
struct _reent *<[ptr]>;
|
||||
int <[fd]>;
|
||||
char *<[buf]>;
|
||||
size_t <[cnt]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<write>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
long
|
||||
_write_r (ptr, fd, buf, cnt)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
_CONST _PTR buf;
|
||||
size_t cnt;
|
||||
{
|
||||
long ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _write (fd, buf, cnt)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
Reference in New Issue
Block a user