newlib-2.1.0
git-svn-id: svn://kolibrios.org@4921 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
914e67bd24
commit
7315bb05c0
|
@ -1,9 +1,10 @@
|
|||
|
||||
|
||||
CC = kos32-gcc
|
||||
AR = kos32-ar
|
||||
LD = kos32-ld
|
||||
|
||||
CFLAGS = -c -O2 -fomit-frame-pointer -DBUILD_DLL
|
||||
CFLAGS = -c -O2 -fomit-frame-pointer -DBUILD_DLL -DMISSING_SYSCALL_NAMES
|
||||
LDFLAGS = -shared -s -T libcdll.lds --out-implib libc.dll.a --image-base 0
|
||||
#LDFLAGS+= --output-def libc.orig.def
|
||||
ARFLAGS = crs
|
||||
|
@ -53,28 +54,28 @@ LIBCRT_SRCS:= \
|
|||
CORE_SRCS:= \
|
||||
argz/buf_findstr.c \
|
||||
argz/envz_get.c \
|
||||
crt/emutls.c \
|
||||
crt/thread.S \
|
||||
crt/tls.S \
|
||||
crt/emutls.c \
|
||||
crt/thread.S \
|
||||
crt/tls.S \
|
||||
crt/setjmp.S \
|
||||
crt/cpu_features.c \
|
||||
ctype/ctype_.c \
|
||||
ctype/isascii.c \
|
||||
ctype/isblank.c \
|
||||
ctype/isalnum.c \
|
||||
ctype/isalpha.c \
|
||||
ctype/iscntrl.c \
|
||||
ctype/isdigit.c \
|
||||
ctype/islower.c \
|
||||
ctype/isalnum.c \
|
||||
ctype/isalpha.c \
|
||||
ctype/iscntrl.c \
|
||||
ctype/isdigit.c \
|
||||
ctype/islower.c \
|
||||
ctype/isupper.c \
|
||||
ctype/isprint.c \
|
||||
ctype/ispunct.c \
|
||||
ctype/isspace.c \
|
||||
ctype/iswctype.c \
|
||||
ctype/iswalnum.c \
|
||||
ctype/iswalpha.c \
|
||||
ctype/iswblank.c \
|
||||
ctype/iswcntrl.c \
|
||||
ctype/isprint.c \
|
||||
ctype/ispunct.c \
|
||||
ctype/isspace.c \
|
||||
ctype/iswctype.c \
|
||||
ctype/iswalnum.c \
|
||||
ctype/iswalpha.c \
|
||||
ctype/iswblank.c \
|
||||
ctype/iswcntrl.c \
|
||||
ctype/iswdigit.c \
|
||||
ctype/iswgraph.c \
|
||||
ctype/iswlower.c \
|
||||
|
@ -85,55 +86,71 @@ CORE_SRCS:= \
|
|||
ctype/iswxdigit.c \
|
||||
ctype/isxdigit.c \
|
||||
ctype/toascii.c \
|
||||
ctype/tolower.c \
|
||||
ctype/tolower.c \
|
||||
ctype/toupper.c \
|
||||
ctype/towctrans.c \
|
||||
ctype/towlower.c \
|
||||
ctype/towupper.c \
|
||||
ctype/towctrans.c \
|
||||
ctype/towlower.c \
|
||||
ctype/towupper.c \
|
||||
ctype/wctrans.c \
|
||||
ctype/wctype.c \
|
||||
errno/errno.c \
|
||||
ctype/wctype.c \
|
||||
errno/errno.c \
|
||||
locale/locale.c \
|
||||
locale/lctype.c \
|
||||
reent/impure.c \
|
||||
locale/ldpart.c \
|
||||
reent/impure.c \
|
||||
reent/init_reent.c \
|
||||
reent/getreent.c \
|
||||
reent/getreent.c \
|
||||
reent/mutex.c \
|
||||
reent/gettimeofdayr.c \
|
||||
reent/hdlman.c \
|
||||
reent/isattyr.c \
|
||||
reent/openr.c \
|
||||
reent/closer.c \
|
||||
reent/readr.c \
|
||||
reent/lseekr.c \
|
||||
reent/fstatr.c \
|
||||
reent/writer.c \
|
||||
search/qsort.c \
|
||||
search/bsearch.c \
|
||||
reent/openr.c \
|
||||
reent/closer.c \
|
||||
reent/linkr.c \
|
||||
reent/readr.c \
|
||||
reent/lseekr.c \
|
||||
reent/fstatr.c \
|
||||
reent/writer.c \
|
||||
reent/timesr.c \
|
||||
reent/unlinkr.c \
|
||||
search/qsort.c \
|
||||
search/bsearch.c \
|
||||
signal/signal.c \
|
||||
sys/create.c \
|
||||
sys/delete.c \
|
||||
sys/finfo.c \
|
||||
sys/read.c \
|
||||
sys/write.c \
|
||||
sys/fsize.c \
|
||||
time/asctime.c \
|
||||
time/asctime_r.c \
|
||||
time/clock.c \
|
||||
time/ctime.c \
|
||||
time/ctime_r.c \
|
||||
sys/close.c \
|
||||
sys/create.c \
|
||||
sys/delete.c \
|
||||
sys/errno.c \
|
||||
sys/finfo.c \
|
||||
sys/fsize.c \
|
||||
sys/fstat.c \
|
||||
sys/gettod.c \
|
||||
sys/io.c \
|
||||
sys/ioread.c \
|
||||
sys/iowrite.c \
|
||||
sys/isatty.c \
|
||||
sys/lseek.c \
|
||||
sys/open.c \
|
||||
sys/read.c \
|
||||
sys/unlink.c \
|
||||
sys/write.c \
|
||||
sys/io_alloc.S \
|
||||
time/asctime.c \
|
||||
time/asctime_r.c \
|
||||
time/clock.c \
|
||||
time/ctime.c \
|
||||
time/ctime_r.c \
|
||||
time/difftime.c \
|
||||
time/gettzinfo.c \
|
||||
time/gmtime.c \
|
||||
time/gettzinfo.c \
|
||||
time/gmtime.c \
|
||||
time/gmtime_r.c \
|
||||
time/mktime.c \
|
||||
time/mktm_r.c \
|
||||
time/lcltime.c \
|
||||
time/lcltime_r.c \
|
||||
time/mktime.c \
|
||||
time/mktm_r.c \
|
||||
time/lcltime.c \
|
||||
time/lcltime_r.c \
|
||||
time/strftime.c \
|
||||
time/time.c \
|
||||
time/tzlock.c \
|
||||
time/tzvars.c
|
||||
time/time.c \
|
||||
time/timelocal.c \
|
||||
time/tzlock.c \
|
||||
time/tzvars.c
|
||||
|
||||
|
||||
STDLIB_SRCS= \
|
||||
|
@ -252,7 +269,6 @@ STDIO_SRCS= \
|
|||
refill.c \
|
||||
rget.c \
|
||||
remove.c \
|
||||
rename.c \
|
||||
setvbuf.c \
|
||||
stdio.c \
|
||||
tmpfile.c \
|
||||
|
@ -369,7 +385,7 @@ LIB_OBJS+= \
|
|||
$(STRING_OBJS) \
|
||||
$(STDLIB_OBJS) \
|
||||
$(STDIO_OBJS) \
|
||||
$(PRINTF_OBJS) \
|
||||
$(PRINTF_OBJS) \
|
||||
$(MATH_OBJS)
|
||||
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ libc_crt_startup (void *libc_base)
|
|||
memset(_tls_map, 0xFF, 32*4);
|
||||
_tls_map[0] = 0xE0;
|
||||
init_reent();
|
||||
__initPOSIXHandles();
|
||||
init_stdio();
|
||||
|
||||
// __appenv = load_file("/sys/system.env", &__appenv_size);
|
||||
|
||||
|
|
|
@ -111,14 +111,21 @@ _CONST
|
|||
char __EXPORT *__ctype_ptr__ = (char *) _ctype_b + 127;
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
|
||||
# ifdef __x86_64__
|
||||
__asm__ (" \n\
|
||||
.data \n\
|
||||
.globl _ctype_ \n\
|
||||
.set _ctype_,_ctype_b+127 \n\
|
||||
.text \n\
|
||||
");
|
||||
# else
|
||||
__asm__ (" \n\
|
||||
.data \n\
|
||||
.globl __ctype_ \n\
|
||||
.set __ctype_,__ctype_b+127 \n\
|
||||
.text \n\
|
||||
");
|
||||
|
||||
# endif
|
||||
# else /* !__CYGWIN__ */
|
||||
|
||||
_CONST char _ctype_[1 + 256] = {
|
||||
|
|
|
@ -18,7 +18,7 @@ DESCRIPTION
|
|||
<<isalnum>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for alphabetic or
|
||||
numeric ASCII characters, and <<0>> for other arguments. It is defined
|
||||
for all integer values.
|
||||
only if <[c]> is representable as an unsigned char or if <[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef isalnum>>'.
|
||||
|
|
|
@ -16,8 +16,8 @@ TRAD_SYNOPSIS
|
|||
DESCRIPTION
|
||||
<<isalpha>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero when <[c]> represents an
|
||||
alphabetic ASCII character, and 0 otherwise. It is defined only when
|
||||
<<isascii>>(<[c]>) is true or <[c]> is EOF.
|
||||
alphabetic ASCII character, and 0 otherwise. It is defined only if
|
||||
<[c]> is representable as an unsigned char or if <[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef isalpha>>'.
|
||||
|
|
|
@ -17,7 +17,8 @@ TRAD_SYNOPSIS
|
|||
DESCRIPTION
|
||||
<<isblank>> is a function which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for blank characters, and 0
|
||||
for other characters.
|
||||
for other characters. It is defined only if <[c]> is representable as an
|
||||
unsigned char or if <[c]> is EOF.
|
||||
|
||||
RETURNS
|
||||
<<isblank>> returns non-zero if <[c]> is a blank character.
|
||||
|
|
|
@ -17,8 +17,8 @@ TRAD_SYNOPSIS
|
|||
DESCRIPTION
|
||||
<<iscntrl>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for control characters, and 0
|
||||
for other characters. It is defined only when <<isascii>>(<[c]>) is
|
||||
true or <[c]> is EOF.
|
||||
for other characters. It is defined only if <[c]> is representable as an
|
||||
unsigned char or if <[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef iscntrl>>'.
|
||||
|
|
|
@ -16,8 +16,8 @@ int isdigit(<[c]>);
|
|||
DESCRIPTION
|
||||
<<isdigit>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for decimal digits, and 0 for
|
||||
other characters. It is defined only when <<isascii>>(<[c]>) is true
|
||||
or <[c]> is EOF.
|
||||
other characters. It is defined only if <[c]> is representable as an
|
||||
unsigned char or if <[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef isdigit>>'.
|
||||
|
|
|
@ -18,7 +18,8 @@ DESCRIPTION
|
|||
<<islower>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for minuscules
|
||||
(lowercase alphabetic characters), and 0 for other characters.
|
||||
It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF.
|
||||
It is defined only if <[c]> is representable as an unsigned char or if
|
||||
<[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef islower>>'.
|
||||
|
|
|
@ -23,7 +23,8 @@ DESCRIPTION
|
|||
<<isprint>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for printable
|
||||
characters, and 0 for other character arguments.
|
||||
It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF.
|
||||
It is defined only if <[c]> is representable as an unsigned char or if
|
||||
<[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining either macro using `<<#undef isprint>>' or `<<#undef isgraph>>'.
|
||||
|
|
|
@ -17,8 +17,8 @@ int ispunct(<[c]>);
|
|||
DESCRIPTION
|
||||
<<ispunct>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for printable
|
||||
punctuation characters, and 0 for other characters. It is defined
|
||||
only when <<isascii>>(<[c]>) is true or <[c]> is EOF.
|
||||
punctuation characters, and 0 for other characters. It is defined only
|
||||
if <[c]> is representable as an unsigned char or if <[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef ispunct>>'.
|
||||
|
|
|
@ -17,8 +17,8 @@ int isxdigit(int <[c]>);
|
|||
DESCRIPTION
|
||||
<<isxdigit>> is a macro which classifies ASCII integer values by table
|
||||
lookup. It is a predicate returning non-zero for hexadecimal digits,
|
||||
and <<0>> for other characters. It is defined only when
|
||||
<<isascii>>(<[c]>) is true or <[c]> is EOF.
|
||||
and <<0>> for other characters. It is defined only if <[c]> is
|
||||
representable as an unsigned char or if <[c]> is EOF.
|
||||
|
||||
You can use a compiled subroutine instead of the macro definition by
|
||||
undefining the macro using `<<#undef isxdigit>>'.
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
/* Routine to translate from Japanese characters to Unicode */
|
||||
|
||||
/* Copyright (c) 2002 Red Hat Incorporated.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
The name of Red Hat Incorporated may not be used to endorse
|
||||
or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <newlib.h>
|
||||
|
||||
#ifdef _MB_CAPABLE
|
||||
/* Under Cygwin, the incoming wide character is already given in UTF due
|
||||
to the requirements of the underlying OS. */
|
||||
#ifndef __CYGWIN__
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <wctype.h>
|
||||
#include "local.h"
|
||||
#include "jp2uc.h"
|
||||
|
||||
/* Japanese encoding types supported */
|
||||
#define JP_JIS 1
|
||||
#define JP_SJIS 2
|
||||
#define JP_EUCJP 3
|
||||
|
||||
static wint_t
|
||||
_DEFUN (__jp2uc, (c, type), wint_t c _AND int type)
|
||||
{
|
||||
int index, adj;
|
||||
unsigned char byte1, byte2;
|
||||
wint_t ret;
|
||||
|
||||
/* we actually use tables of EUCJP to Unicode. For JIS, we simply
|
||||
note that EUCJP is essentially JIS with the top bits on in each
|
||||
byte and translate to EUCJP. For SJIS, we do a translation to EUCJP before
|
||||
accessing the tables. */
|
||||
switch (type)
|
||||
{
|
||||
case JP_JIS:
|
||||
byte1 = (c >> 8) + 0x80;
|
||||
byte2 = (c & 0xff) + 0x80;
|
||||
break;
|
||||
case JP_EUCJP:
|
||||
byte1 = (c >> 8);
|
||||
byte2 = (c & 0xff);
|
||||
break;
|
||||
case JP_SJIS:
|
||||
byte1 = c >> 8;
|
||||
byte2 = c & 0xff;
|
||||
if (byte2 <= 0x9e)
|
||||
{
|
||||
adj = 0xa1 - 0x22;
|
||||
byte2 = (byte2 - 31) + 0xa1;
|
||||
}
|
||||
else
|
||||
{
|
||||
adj = 0xa1 - 0x21;
|
||||
byte2 = (byte2 - 126) + 0xa1;
|
||||
}
|
||||
if (byte1 <= 0x9f)
|
||||
byte1 = ((byte1 - 112) << 1) + adj;
|
||||
else
|
||||
byte1 = ((byte1 - 176) << 1) + adj;
|
||||
break;
|
||||
default:
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
/* find conversion in jp2uc arrays */
|
||||
|
||||
/* handle larger ranges first */
|
||||
if (byte1 >= 0xb0 && byte1 <= 0xcf && c <= 0xcfd3)
|
||||
{
|
||||
index = (byte1 - 0xb0) * 0xfe + (byte2 - 0xa1);
|
||||
return b02cf[index];
|
||||
}
|
||||
else if (byte1 >= 0xd0 && byte1 <= 0xf4 && c <= 0xf4a6)
|
||||
{
|
||||
index = (byte1 - 0xd0) * 0xfe + (byte2 - 0xa1);
|
||||
return d02f4[index];
|
||||
}
|
||||
|
||||
/* handle smaller ranges here */
|
||||
switch (byte1)
|
||||
{
|
||||
case 0xA1:
|
||||
return (wint_t)a1[byte2 - 0xa1];
|
||||
case 0xA2:
|
||||
ret = a2[byte2 - 0xa1];
|
||||
if (ret != 0)
|
||||
return (wint_t)ret;
|
||||
break;
|
||||
case 0xA3:
|
||||
if (a3[byte2 - 0xa1])
|
||||
return (wint_t)(0xff00 + (byte2 - 0xa0));
|
||||
break;
|
||||
case 0xA4:
|
||||
if (byte2 <= 0xf3)
|
||||
return (wint_t)(0x3000 + (byte2 - 0x60));
|
||||
break;
|
||||
case 0xA5:
|
||||
if (byte2 <= 0xf6)
|
||||
return (wint_t)(0x3000 + byte2);
|
||||
break;
|
||||
case 0xA6:
|
||||
ret = 0;
|
||||
if (byte2 <= 0xd8)
|
||||
ret = (wint_t)a6[byte2 - 0xa1];
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
break;
|
||||
case 0xA7:
|
||||
ret = 0;
|
||||
if (byte2 <= 0xf1)
|
||||
ret = (wint_t)a7[byte2 - 0xa1];
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
break;
|
||||
case 0xA8:
|
||||
if (byte2 <= 0xc0)
|
||||
return (wint_t)a8[byte2 - 0xa1];
|
||||
break;
|
||||
default:
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
wint_t
|
||||
_DEFUN (_jp2uc, (c), wint_t c)
|
||||
{
|
||||
if (!strcmp (__locale_charset (), "JIS"))
|
||||
c = __jp2uc (c, JP_JIS);
|
||||
else if (!strcmp (__locale_charset (), "SJIS"))
|
||||
c = __jp2uc (c, JP_SJIS);
|
||||
else if (!strcmp (__locale_charset (), "EUCJP"))
|
||||
c = __jp2uc (c, JP_EUCJP);
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif /* !__CYGWIN__ */
|
||||
#endif /* _MB_CAPABLE */
|
|
@ -34,9 +34,7 @@
|
|||
#define _BEGIN_STD_C extern "C" {
|
||||
#define _END_STD_C }
|
||||
#endif
|
||||
#if defined(__GNUC__) && \
|
||||
( (__GNUC__ >= 4) || \
|
||||
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
|
||||
#if __GNUC_PREREQ (3, 3)
|
||||
#define _NOTHROW __attribute__ ((nothrow))
|
||||
#else
|
||||
#define _NOTHROW throw()
|
||||
|
@ -113,21 +111,34 @@
|
|||
to emit the function body unless the address is explicitly
|
||||
taken. However this behaviour is changing to match the C99
|
||||
standard, which uses 'extern inline' to indicate that the
|
||||
function body *must* be emitted. If we are using GCC, but do
|
||||
not have the new behaviour, we need to use extern inline; if
|
||||
we are using a new GCC with the C99-compatible behaviour, or
|
||||
a non-GCC compiler (which we will have to hope is C99, since
|
||||
there is no other way to achieve the effect of omitting the
|
||||
function if it isn't referenced) we just use plain 'inline',
|
||||
which c99 defines to mean more-or-less the same as the Gnu C
|
||||
'extern inline'. */
|
||||
function body *must* be emitted. Likewise, a function declared
|
||||
without either 'extern' or 'static' defaults to extern linkage
|
||||
(C99 6.2.2p5), and the compiler may choose whether to use the
|
||||
inline version or call the extern linkage version (6.7.4p6).
|
||||
If we are using GCC, but do not have the new behaviour, we need
|
||||
to use extern inline; if we are using a new GCC with the
|
||||
C99-compatible behaviour, or a non-GCC compiler (which we will
|
||||
have to hope is C99, since there is no other way to achieve the
|
||||
effect of omitting the function if it isn't referenced) we use
|
||||
'static inline', which c99 defines to mean more-or-less the same
|
||||
as the Gnu C 'extern inline'. */
|
||||
#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
|
||||
/* We're using GCC, but without the new C99-compatible behaviour. */
|
||||
#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
|
||||
#else
|
||||
/* We're using GCC in C99 mode, or an unknown compiler which
|
||||
we just have to hope obeys the C99 semantics of inline. */
|
||||
#define _ELIDABLE_INLINE __inline__
|
||||
#define _ELIDABLE_INLINE static __inline__
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ (3, 1)
|
||||
#define _NOINLINE __attribute__ ((__noinline__))
|
||||
#define _NOINLINE_STATIC _NOINLINE static
|
||||
#else
|
||||
/* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be
|
||||
trusted not to inline if it is static. */
|
||||
#define _NOINLINE
|
||||
#define _NOINLINE_STATIC
|
||||
#endif
|
||||
|
||||
#endif /* _ANSIDECL_H_ */
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/*
|
||||
assert.h
|
||||
*/
|
||||
#ifndef _NEWLIB_ASSERT_H
|
||||
#define _NEWLIB_ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,8 +41,10 @@ void _EXFUN(__assert, (const char *, int, const char *)
|
|||
void _EXFUN(__assert_func, (const char *, int, const char *, const char *)
|
||||
_ATTRIBUTE ((__noreturn__)));
|
||||
|
||||
#if __STDC_VERSION__ >= 201112L && !defined __cplusplus
|
||||
# define static_assert _Static_assert
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NEWLIB_ASSERT_H */
|
||||
|
|
|
@ -77,7 +77,7 @@ float complex clogf(float complex);
|
|||
|
||||
/* 7.3.8 Power and absolute-value functions */
|
||||
/* 7.3.8.1 The cabs functions */
|
||||
/*#ifndef __LIBM0_SOURCE__
|
||||
/*#ifndef __LIBM0_SOURCE__ */
|
||||
/* avoid conflict with historical cabs(struct complex) */
|
||||
/* double cabs(double complex) __RENAME(__c99_cabs);
|
||||
float cabsf(float complex) __RENAME(__c99_cabsf);
|
||||
|
|
|
@ -104,7 +104,7 @@ extern "C"
|
|||
/* types defined by this include file */
|
||||
struct option
|
||||
{
|
||||
char *name; /* the name of the long option */
|
||||
const char *name; /* the name of the long option */
|
||||
int has_arg; /* one of the above macros */
|
||||
int *flag; /* determines if getopt_long() returns a
|
||||
* value for a long option; if it is
|
||||
|
|
|
@ -82,7 +82,8 @@ typedef struct {
|
|||
#define GLOB_ABEND (-2) /* Unignored error. */
|
||||
|
||||
__BEGIN_DECLS
|
||||
int glob(const char *, int, int (*)(const char *, int), glob_t *);
|
||||
int glob(const char *__restrict, int, int (*)(const char *, int),
|
||||
glob_t *__restrict);
|
||||
void globfree(glob_t *);
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ iconv_t
|
|||
_EXFUN(iconv_open, (_CONST char *, _CONST char *));
|
||||
|
||||
size_t
|
||||
_EXFUN(iconv, (iconv_t, char **, size_t *, char **, size_t *));
|
||||
_EXFUN(iconv, (iconv_t, char **__restrict, size_t *__restrict,
|
||||
char **__restrict, size_t *__restrict));
|
||||
|
||||
int
|
||||
_EXFUN(iconv_close, (iconv_t));
|
||||
|
|
|
@ -13,10 +13,20 @@
|
|||
#ifndef _INTTYPES_H
|
||||
#define _INTTYPES_H
|
||||
|
||||
#include <sys/features.h>
|
||||
#include <stdint.h>
|
||||
#define __need_wchar_t
|
||||
#include <stddef.h>
|
||||
|
||||
/* Don't use __STDINT_EXP test since GCC's stdint.h provides different
|
||||
macros than newlib's stdint.h. */
|
||||
#if __GNUC_PREREQ(3, 2)
|
||||
#define __INTTYPES_EXP(x) __##x##__
|
||||
#else
|
||||
#define __INTTYPES_EXP(x) x
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#define __STRINGIFY(a) #a
|
||||
|
||||
/* 8-bit types */
|
||||
|
@ -242,15 +252,15 @@
|
|||
#define SCNxMAX __SCNMAX(x)
|
||||
|
||||
/* ptr types */
|
||||
#if __have_long64
|
||||
#define __PRIPTR(x) __STRINGIFY(l##x)
|
||||
#define __SCNPTR(x) __STRINGIFY(l##x)
|
||||
#elif __have_longlong64
|
||||
#define __PRIPTR(x) __STRINGIFY(ll##x)
|
||||
#define __SCNPTR(x) __STRINGIFY(ll##x)
|
||||
#if PTRDIFF_MAX <= __INTTYPES_EXP(INT_MAX)
|
||||
# define __PRIPTR(x) __STRINGIFY(x)
|
||||
# define __SCNPTR(x) __STRINGIFY(x)
|
||||
#elif PTRDIFF_MAX <= __INTTYPES_EXP(LONG_MAX) || !defined(__have_longlong64)
|
||||
# define __PRIPTR(x) __STRINGIFY(l##x)
|
||||
# define __SCNPTR(x) __STRINGIFY(l##x)
|
||||
#else
|
||||
#define __PRIPTR(x) __STRINGIFY(x)
|
||||
#define __SCNPTR(x) __STRINGIFY(x)
|
||||
# define __PRIPTR(x) __STRINGIFY(ll##x)
|
||||
# define __SCNPTR(x) __STRINGIFY(ll##x)
|
||||
#endif
|
||||
|
||||
#define PRIdPTR __PRIPTR(d)
|
||||
|
|
|
@ -96,7 +96,8 @@
|
|||
# define __LONG_LONG_MAX__ 9223372036854775807LL
|
||||
# endif
|
||||
|
||||
# if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
# if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
||||
(defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
/* Minimum and maximum values a `signed long long int' can hold. */
|
||||
# undef LLONG_MIN
|
||||
# define LLONG_MIN (-LLONG_MAX-1)
|
||||
|
@ -143,4 +144,3 @@
|
|||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
|
||||
#include "_ansi.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
/*
|
||||
* $Id: _default_types.h,v 1.2 2008/06/11 22:14:54 jjohnstn Exp $
|
||||
* $Id: _default_types.h,v 1.6 2013/12/03 16:04:41 corinna Exp $
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE__DEFAULT_TYPES_H
|
||||
#define _MACHINE__DEFAULT_TYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <sys/features.h>
|
||||
|
||||
/*
|
||||
* Guess on types by examining *_MIN / *_MAX defines.
|
||||
*/
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ >= 3 ) \
|
||||
&& defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ))
|
||||
#if __GNUC_PREREQ (3, 3)
|
||||
/* GCC >= 3.3.0 has __<val>__ implicitly defined. */
|
||||
#define __EXP(x) __##x##__
|
||||
#else
|
||||
|
@ -22,13 +19,25 @@ extern "C" {
|
|||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if __EXP(SCHAR_MAX) == 0x7f
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __INT8_TYPE__
|
||||
typedef __INT8_TYPE__ __int8_t;
|
||||
typedef __UINT8_TYPE__ __uint8_t;
|
||||
#define ___int8_t_defined 1
|
||||
#elif __EXP(SCHAR_MAX) == 0x7f
|
||||
typedef signed char __int8_t ;
|
||||
typedef unsigned char __uint8_t ;
|
||||
#define ___int8_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __EXP(INT_MAX) == 0x7fff
|
||||
#ifdef __INT16_TYPE__
|
||||
typedef __INT16_TYPE__ __int16_t;
|
||||
typedef __UINT16_TYPE__ __uint16_t;
|
||||
#define ___int16_t_defined 1
|
||||
#elif __EXP(INT_MAX) == 0x7fff
|
||||
typedef signed int __int16_t;
|
||||
typedef unsigned int __uint16_t;
|
||||
#define ___int16_t_defined 1
|
||||
|
@ -42,19 +51,11 @@ typedef unsigned char __uint16_t;
|
|||
#define ___int16_t_defined 1
|
||||
#endif
|
||||
|
||||
#if ___int16_t_defined
|
||||
typedef __int16_t __int_least16_t;
|
||||
typedef __uint16_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
|
||||
#if !___int8_t_defined
|
||||
typedef __int16_t __int_least8_t;
|
||||
typedef __uint16_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __EXP(INT_MAX) == 0x7fffffffL
|
||||
#ifdef __INT32_TYPE__
|
||||
typedef __INT32_TYPE__ __int32_t;
|
||||
typedef __UINT32_TYPE__ __uint32_t;
|
||||
#define ___int32_t_defined 1
|
||||
#elif __EXP(INT_MAX) == 0x7fffffffL
|
||||
typedef signed int __int32_t;
|
||||
typedef unsigned int __uint32_t;
|
||||
#define ___int32_t_defined 1
|
||||
|
@ -72,24 +73,11 @@ typedef unsigned char __uint32_t;
|
|||
#define ___int32_t_defined 1
|
||||
#endif
|
||||
|
||||
#if ___int32_t_defined
|
||||
typedef __int32_t __int_least32_t;
|
||||
typedef __uint32_t __uint_least32_t;
|
||||
#define ___int_least32_t_defined 1
|
||||
|
||||
#if !___int8_t_defined
|
||||
typedef __int32_t __int_least8_t;
|
||||
typedef __uint32_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#endif
|
||||
#if !___int16_t_defined
|
||||
typedef __int32_t __int_least16_t;
|
||||
typedef __uint32_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __EXP(LONG_MAX) > 0x7fffffff
|
||||
#ifdef __INT64_TYPE__
|
||||
typedef __INT64_TYPE__ __int64_t;
|
||||
typedef __UINT64_TYPE__ __uint64_t;
|
||||
#define ___int64_t_defined 1
|
||||
#elif __EXP(LONG_MAX) > 0x7fffffff
|
||||
typedef signed long __int64_t;
|
||||
typedef unsigned long __uint64_t;
|
||||
#define ___int64_t_defined 1
|
||||
|
@ -112,6 +100,81 @@ typedef unsigned int __uint64_t;
|
|||
#define ___int64_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST8_TYPE__
|
||||
typedef __INT_LEAST8_TYPE__ __int_least8_t;
|
||||
typedef __UINT_LEAST8_TYPE__ __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int8_t_defined)
|
||||
typedef __int8_t __int_least8_t;
|
||||
typedef __uint8_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int16_t_defined)
|
||||
typedef __int16_t __int_least8_t;
|
||||
typedef __uint16_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int32_t_defined)
|
||||
typedef __int32_t __int_least8_t;
|
||||
typedef __uint32_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least8_t;
|
||||
typedef __uint64_t __uint_least8_t;
|
||||
#define ___int_least8_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST16_TYPE__
|
||||
typedef __INT_LEAST16_TYPE__ __int_least16_t;
|
||||
typedef __UINT_LEAST16_TYPE__ __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#elif defined(___int16_t_defined)
|
||||
typedef __int16_t __int_least16_t;
|
||||
typedef __uint16_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#elif defined(___int32_t_defined)
|
||||
typedef __int32_t __int_least16_t;
|
||||
typedef __uint32_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least16_t;
|
||||
typedef __uint64_t __uint_least16_t;
|
||||
#define ___int_least16_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST32_TYPE__
|
||||
typedef __INT_LEAST32_TYPE__ __int_least32_t;
|
||||
typedef __UINT_LEAST32_TYPE__ __uint_least32_t;
|
||||
#define ___int_least32_t_defined 1
|
||||
#elif defined(___int32_t_defined)
|
||||
typedef __int32_t __int_least32_t;
|
||||
typedef __uint32_t __uint_least32_t;
|
||||
#define ___int_least32_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least32_t;
|
||||
typedef __uint64_t __uint_least32_t;
|
||||
#define ___int_least32_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INT_LEAST64_TYPE__
|
||||
typedef __INT_LEAST64_TYPE__ __int_least64_t;
|
||||
typedef __UINT_LEAST64_TYPE__ __uint_least64_t;
|
||||
#define ___int_least64_t_defined 1
|
||||
#elif defined(___int64_t_defined)
|
||||
typedef __int64_t __int_least64_t;
|
||||
typedef __uint64_t __uint_least64_t;
|
||||
#define ___int_least64_t_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef __INTPTR_TYPE__
|
||||
typedef __INTPTR_TYPE__ __intptr_t;
|
||||
typedef __UINTPTR_TYPE__ __uintptr_t;
|
||||
#elif defined(__PTRDIFF_TYPE__)
|
||||
typedef __PTRDIFF_TYPE__ __intptr_t;
|
||||
typedef unsigned __PTRDIFF_TYPE__ __uintptr_t;
|
||||
#else
|
||||
typedef long __intptr_t;
|
||||
typedef unsigned long __uintptr_t;
|
||||
#endif
|
||||
|
||||
#undef __EXP
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -69,10 +69,31 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__aarch64__)
|
||||
#if defined (__AARCH64EL__)
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#else
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __epiphany__
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#define Sudden_Underflow 1
|
||||
#endif
|
||||
|
||||
#ifdef __hppa__
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifdef __nds32__
|
||||
#ifdef __big_endian__
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#else
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __SPU__
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
|
||||
|
@ -275,7 +296,11 @@
|
|||
#endif
|
||||
|
||||
#ifdef __moxie__
|
||||
#ifdef __MOXIE_BIG_ENDIAN__
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#else
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __ia64__
|
||||
|
@ -339,7 +364,16 @@
|
|||
#endif
|
||||
|
||||
#ifdef __MICROBLAZE__
|
||||
#ifndef __MICROBLAZEEL__
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#else
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MSP430__
|
||||
#define __IEEE_LITTLE_ENDIAN
|
||||
#define __SMALL_BITFIELDS /* 16 Bit INT */
|
||||
#endif
|
||||
|
||||
#ifdef __RL78__
|
||||
|
@ -371,6 +405,14 @@
|
|||
#define __SMALL_BITFIELDS /* 16 Bit INT */
|
||||
#endif
|
||||
|
||||
#ifdef __NIOS2__
|
||||
# ifdef __nios2_big_endian__
|
||||
# define __IEEE_BIG_ENDIAN
|
||||
# else
|
||||
# define __IEEE_LITTLE_ENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __IEEE_BIG_ENDIAN
|
||||
#ifndef __IEEE_LITTLE_ENDIAN
|
||||
#error Endianess not declared!!
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1991 DJ Delorie
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms is permitted
|
||||
* Redistribution, modification, and use in source and binary forms is permitted
|
||||
* provided that the above copyright notice and following paragraph are
|
||||
* duplicated in all such forms.
|
||||
*
|
||||
|
|
|
@ -1,8 +1,414 @@
|
|||
|
||||
_BEGIN_STD_C
|
||||
|
||||
#include "setjmp-dj.h"
|
||||
#if defined(__arm__) || defined(__thumb__)
|
||||
/*
|
||||
* All callee preserved registers:
|
||||
* v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7
|
||||
*/
|
||||
#define _JBLEN 23
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#define _JBLEN 22
|
||||
#define _JBTYPE long long
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define _JBLEN 24
|
||||
#endif
|
||||
|
||||
#ifdef __sparc__
|
||||
/*
|
||||
* onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext).
|
||||
* All else recovered by under/over(flow) handling.
|
||||
*/
|
||||
#define _JBLEN 13
|
||||
#endif
|
||||
|
||||
#ifdef __BFIN__
|
||||
#define _JBLEN 40
|
||||
#endif
|
||||
|
||||
#ifdef __epiphany__
|
||||
/* All callee preserved registers: r4-r10,fp, sp, lr,r15, r32-r39 */
|
||||
#define _JBTYPE long long
|
||||
#define _JBLEN 10
|
||||
#endif
|
||||
|
||||
/* necv70 was 9 as well. */
|
||||
|
||||
#if defined(__m68k__) || defined(__mc68000__)
|
||||
/*
|
||||
* onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
|
||||
* fp2-fp7 for 68881.
|
||||
* All else recovered by under/over(flow) handling.
|
||||
*/
|
||||
#define _JBLEN 34
|
||||
#endif
|
||||
|
||||
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
|
||||
/*
|
||||
* D, X, Y are not saved.
|
||||
* Only take into account the pseudo soft registers (max 32).
|
||||
*/
|
||||
#define _JBLEN 32
|
||||
#endif
|
||||
|
||||
#ifdef __nds32__
|
||||
/* Only 17 words are currently needed.
|
||||
Preserve one word slot if we need to expand.
|
||||
Check newlib/libc/machine/nds32/setjmp.S for more information. */
|
||||
#define _JBLEN 18
|
||||
#endif
|
||||
|
||||
#if defined(__Z8001__) || defined(__Z8002__)
|
||||
/* 16 regs + pc */
|
||||
#define _JBLEN 20
|
||||
#endif
|
||||
|
||||
#ifdef _AM29K
|
||||
/*
|
||||
* onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext).
|
||||
* All else recovered by under/over(flow) handling.
|
||||
*/
|
||||
#define _JBLEN 9
|
||||
#endif
|
||||
|
||||
#ifdef __i386__
|
||||
# if defined(__CYGWIN__) && !defined (_JBLEN)
|
||||
# define _JBLEN (13 * 4)
|
||||
# elif defined(__unix__) || defined(__rtems__)
|
||||
# define _JBLEN 9
|
||||
# else
|
||||
# include "setjmp-dj.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
# ifdef __CYGWIN__
|
||||
# define _JBTYPE long
|
||||
# define _JBLEN 32
|
||||
# else
|
||||
# define _JBTYPE long long
|
||||
# define _JBLEN 8
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __i960__
|
||||
#define _JBLEN 35
|
||||
#endif
|
||||
|
||||
#ifdef __M32R__
|
||||
/* Only 8 words are currently needed. 10 gives us some slop if we need
|
||||
to expand. */
|
||||
#define _JBLEN 10
|
||||
#endif
|
||||
|
||||
#ifdef __mips__
|
||||
# if defined(__mips64) || (__mips_fpr == 64)
|
||||
# define _JBTYPE long long
|
||||
# endif
|
||||
# ifdef __mips_soft_float
|
||||
# define _JBLEN 11
|
||||
# else
|
||||
# define _JBLEN 23
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __m88000__
|
||||
#define _JBLEN 21
|
||||
#endif
|
||||
|
||||
#ifdef __H8300__
|
||||
#define _JBLEN 5
|
||||
#define _JBTYPE int
|
||||
#endif
|
||||
|
||||
#ifdef __H8300H__
|
||||
/* same as H8/300 but registers are twice as big */
|
||||
#define _JBLEN 5
|
||||
#define _JBTYPE long
|
||||
#endif
|
||||
|
||||
#if defined (__H8300S__) || defined (__H8300SX__)
|
||||
/* same as H8/300 but registers are twice as big */
|
||||
#define _JBLEN 5
|
||||
#define _JBTYPE long
|
||||
#endif
|
||||
|
||||
#ifdef __H8500__
|
||||
#define _JBLEN 4
|
||||
#endif
|
||||
|
||||
#ifdef __sh__
|
||||
#if __SH5__
|
||||
#define _JBLEN 50
|
||||
#define _JBTYPE long long
|
||||
#else
|
||||
#define _JBLEN 20
|
||||
#endif /* __SH5__ */
|
||||
#endif
|
||||
|
||||
#ifdef __v800
|
||||
#define _JBLEN 28
|
||||
#endif
|
||||
|
||||
#ifdef __PPC__
|
||||
#ifdef __ALTIVEC__
|
||||
#define _JBLEN 64
|
||||
#else
|
||||
#define _JBLEN 32
|
||||
#endif
|
||||
#define _JBTYPE double
|
||||
#endif
|
||||
|
||||
#ifdef __MICROBLAZE__
|
||||
#define _JBLEN 20
|
||||
#define _JBTYPE unsigned int
|
||||
#endif
|
||||
|
||||
#ifdef __hppa__
|
||||
/* %r30, %r2-%r18, %r27, pad, %fr12-%fr15.
|
||||
Note space exists for the FP registers, but they are not
|
||||
saved. */
|
||||
#define _JBLEN 28
|
||||
#endif
|
||||
|
||||
#if defined(__mn10300__) || defined(__mn10200__)
|
||||
#ifdef __AM33_2__
|
||||
#define _JBLEN 26
|
||||
#else
|
||||
/* A guess */
|
||||
#define _JBLEN 10
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __v850
|
||||
/* I think our setjmp is saving 15 regs at the moment. Gives us one word
|
||||
slop if we need to expand. */
|
||||
#define _JBLEN 16
|
||||
#endif
|
||||
|
||||
#if defined(_C4x)
|
||||
#define _JBLEN 10
|
||||
#endif
|
||||
#if defined(_C3x)
|
||||
#define _JBLEN 9
|
||||
#endif
|
||||
|
||||
#ifdef __TMS320C6X__
|
||||
#define _JBLEN 13
|
||||
#endif
|
||||
|
||||
#ifdef __TIC80__
|
||||
#define _JBLEN 13
|
||||
#endif
|
||||
|
||||
#ifdef __D10V__
|
||||
#define _JBLEN 8
|
||||
#endif
|
||||
|
||||
#ifdef __D30V__
|
||||
#define _JBLEN ((64 /* GPR */ + (2*2) /* ACs */ + 18 /* CRs */) / 2)
|
||||
#define _JBTYPE double
|
||||
#endif
|
||||
|
||||
#ifdef __frv__
|
||||
#define _JBLEN (68/2) /* room for 68 32-bit regs */
|
||||
#define _JBTYPE double
|
||||
#endif
|
||||
|
||||
#ifdef __moxie__
|
||||
#define _JBLEN 16
|
||||
#endif
|
||||
|
||||
#ifdef __CRX__
|
||||
#define _JBLEN 9
|
||||
#endif
|
||||
|
||||
#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
|
||||
/* r6, r7, r8, r9, r10, r11, r12 (r12L, r12H),
|
||||
* r13 (r13L, r13H), ra(raL, raH), sp(spL, spH) */
|
||||
#define _JBLEN 14
|
||||
#define _JBTYPE unsigned short
|
||||
#endif
|
||||
|
||||
#ifdef __fr30__
|
||||
#define _JBLEN 10
|
||||
#endif
|
||||
|
||||
#ifdef __iq2000__
|
||||
#define _JBLEN 32
|
||||
#endif
|
||||
|
||||
#ifdef __mcore__
|
||||
#define _JBLEN 16
|
||||
#endif
|
||||
|
||||
#ifdef __MMIX__
|
||||
/* Using a layout compatible with GCC's built-in. */
|
||||
#define _JBLEN 5
|
||||
#define _JBTYPE unsigned long
|
||||
#endif
|
||||
|
||||
#ifdef __mt__
|
||||
#define _JBLEN 16
|
||||
#endif
|
||||
|
||||
#ifdef __SPU__
|
||||
#define _JBLEN 50
|
||||
#define _JBTYPE __vector signed int
|
||||
#endif
|
||||
|
||||
#ifdef __xstormy16__
|
||||
/* 4 GPRs plus SP plus PC. */
|
||||
#define _JBLEN 8
|
||||
#endif
|
||||
|
||||
#ifdef __mep__
|
||||
/* 16 GPRs, pc, hi, lo */
|
||||
#define _JBLEN 19
|
||||
#endif
|
||||
|
||||
#ifdef __CRIS__
|
||||
#define _JBLEN 18
|
||||
#endif
|
||||
|
||||
#ifdef __lm32__
|
||||
#define _JBLEN 19
|
||||
#endif
|
||||
|
||||
#ifdef __m32c__
|
||||
#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
|
||||
#define _JBLEN (22/2)
|
||||
#else
|
||||
#define _JBLEN (34/2)
|
||||
#endif
|
||||
#define _JBTYPE unsigned short
|
||||
#endif /* __m32c__ */
|
||||
|
||||
#ifdef __MSP430__
|
||||
#define _JBLEN 9
|
||||
|
||||
#ifdef __MSP430X_LARGE__
|
||||
#define _JBTYPE unsigned long
|
||||
#else
|
||||
#define _JBTYPE unsigned short
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __RL78__
|
||||
/* Three banks of registers, SP, CS, ES, PC */
|
||||
#define _JBLEN (8*3+8)
|
||||
#define _JBTYPE unsigned char
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There are two versions of setjmp()/longjmp():
|
||||
* 1) Compiler (gcc) built-in versions.
|
||||
* 2) Function-call versions.
|
||||
*
|
||||
* The built-in versions are used most of the time. When used, gcc replaces
|
||||
* calls to setjmp()/longjmp() with inline assembly code. The built-in
|
||||
* versions save/restore a variable number of registers.
|
||||
|
||||
* _JBLEN is set to 40 to be ultra-safe with the built-in versions.
|
||||
* It only needs to be 12 for the function-call versions
|
||||
* but this data structure is used by both versions.
|
||||
*/
|
||||
#ifdef __NIOS2__
|
||||
#define _JBLEN 40
|
||||
#define _JBTYPE unsigned long
|
||||
#endif
|
||||
|
||||
#ifdef __RX__
|
||||
#define _JBLEN 0x44
|
||||
#endif
|
||||
|
||||
#ifdef _JBLEN
|
||||
#ifdef _JBTYPE
|
||||
typedef _JBTYPE jmp_buf[_JBLEN];
|
||||
#else
|
||||
typedef int jmp_buf[_JBLEN];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_END_STD_C
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* POSIX sigsetjmp/siglongjmp macros */
|
||||
#ifdef _JBTYPE
|
||||
typedef _JBTYPE sigjmp_buf[_JBLEN+1+((sizeof (_JBTYPE) + sizeof (sigset_t) - 1)
|
||||
/sizeof (_JBTYPE))];
|
||||
#else
|
||||
typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
|
||||
#endif
|
||||
|
||||
#define _SAVEMASK _JBLEN
|
||||
#define _SIGMASK (_JBLEN+1)
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# define _CYGWIN_WORKING_SIGSETJMP
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_THREADS
|
||||
#define __SIGMASK_FUNC pthread_sigmask
|
||||
#else
|
||||
#define __SIGMASK_FUNC sigprocmask
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
||||
#define sigsetjmp(env, savemask) \
|
||||
__extension__ \
|
||||
({ \
|
||||
sigjmp_buf *_sjbuf = &(env); \
|
||||
((*_sjbuf)[_SAVEMASK] = savemask,\
|
||||
__SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
|
||||
setjmp (*_sjbuf)); \
|
||||
})
|
||||
|
||||
#define siglongjmp(env, val) \
|
||||
__extension__ \
|
||||
({ \
|
||||
sigjmp_buf *_sjbuf = &(env); \
|
||||
((((*_sjbuf)[_SAVEMASK]) ? \
|
||||
__SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
|
||||
: 0), \
|
||||
longjmp (*_sjbuf, val)); \
|
||||
})
|
||||
|
||||
#else /* !__GNUC__ */
|
||||
|
||||
#define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
|
||||
__SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
|
||||
setjmp (env))
|
||||
|
||||
#define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
|
||||
__SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
|
||||
longjmp (env, val))
|
||||
|
||||
#endif
|
||||
|
||||
/* POSIX _setjmp/_longjmp, maintained for XSI compatibility. These
|
||||
are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
|
||||
New applications should use sigsetjmp/siglongjmp instead. */
|
||||
#ifdef __CYGWIN__
|
||||
extern void _longjmp(jmp_buf, int);
|
||||
extern int _setjmp(jmp_buf);
|
||||
#else
|
||||
#define _setjmp(env) sigsetjmp ((env), 0)
|
||||
#define _longjmp(env, val) siglongjmp ((env), (val))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __CYGWIN__ or __rtems__ */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#if defined(__rtems__)
|
||||
#define _CLOCKS_PER_SEC_ sysconf(_SC_CLK_TCK)
|
||||
#else /* !__rtems__ */
|
||||
#if defined(__arm__) || defined(__thumb__)
|
||||
#if defined(__aarch64__) || defined(__arm__) || defined(__thumb__)
|
||||
#define _CLOCKS_PER_SEC_ 100
|
||||
#endif
|
||||
#endif /* !__rtems__ */
|
||||
|
|
|
@ -20,16 +20,16 @@ extern "C" {
|
|||
libc/stdlib/mallocr.c. */
|
||||
|
||||
struct mallinfo {
|
||||
int arena; /* total space allocated from system */
|
||||
int ordblks; /* number of non-inuse chunks */
|
||||
int smblks; /* unused -- always zero */
|
||||
int hblks; /* number of mmapped regions */
|
||||
int hblkhd; /* total space in mmapped regions */
|
||||
int usmblks; /* unused -- always zero */
|
||||
int fsmblks; /* unused -- always zero */
|
||||
int uordblks; /* total allocated space */
|
||||
int fordblks; /* total non-inuse space */
|
||||
int keepcost; /* top-most, releasable (via malloc_trim) space */
|
||||
size_t arena; /* total space allocated from system */
|
||||
size_t ordblks; /* number of non-inuse chunks */
|
||||
size_t smblks; /* unused -- always zero */
|
||||
size_t hblks; /* number of mmapped regions */
|
||||
size_t hblkhd; /* total space in mmapped regions */
|
||||
size_t usmblks; /* unused -- always zero */
|
||||
size_t fsmblks; /* unused -- always zero */
|
||||
size_t uordblks; /* total allocated space */
|
||||
size_t fordblks; /* total non-inuse space */
|
||||
size_t keepcost; /* top-most, releasable (via malloc_trim) space */
|
||||
};
|
||||
|
||||
/* The routines. */
|
||||
|
|
|
@ -34,10 +34,7 @@ union __ldmath
|
|||
/* Natural log of 2 */
|
||||
#define _M_LN2 0.693147180559945309417
|
||||
|
||||
#if defined(__GNUC__) && \
|
||||
( (__GNUC__ >= 4) || \
|
||||
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
|
||||
|
||||
#if __GNUC_PREREQ (3, 3)
|
||||
/* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
|
||||
|
||||
# ifndef HUGE_VAL
|
||||
|
@ -143,11 +140,37 @@ extern double fmod _PARAMS((double, double));
|
|||
|
||||
/* ISO C99 types and macros. */
|
||||
|
||||
#ifndef FLT_EVAL_METHOD
|
||||
#define FLT_EVAL_METHOD 0
|
||||
typedef float float_t;
|
||||
typedef double double_t;
|
||||
/* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard,
|
||||
* considering that the standard says the includes it defines should not
|
||||
* include other includes that it defines) and that value used. (This can be
|
||||
* solved, but autoconf has a bug which makes the solution more difficult, so
|
||||
* it has been skipped for now.) */
|
||||
#if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__)
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
#define __TMP_FLT_EVAL_METHOD
|
||||
#endif /* FLT_EVAL_METHOD */
|
||||
#if defined FLT_EVAL_METHOD
|
||||
#if FLT_EVAL_METHOD == 0
|
||||
typedef float float_t;
|
||||
typedef double double_t;
|
||||
#elif FLT_EVAL_METHOD == 1
|
||||
typedef double float_t;
|
||||
typedef double double_t;
|
||||
#elif FLT_EVAL_METHOD == 2
|
||||
typedef long double float_t;
|
||||
typedef long double double_t;
|
||||
#else
|
||||
/* Implementation-defined. Assume float_t and double_t have been
|
||||
* defined previously for this configuration (e.g. config.h). */
|
||||
#endif
|
||||
#else
|
||||
/* Assume basic definitions. */
|
||||
typedef float float_t;
|
||||
typedef double double_t;
|
||||
#endif
|
||||
#if defined(__TMP_FLT_EVAL_METHOD)
|
||||
#undef FLT_EVAL_METHOD
|
||||
#endif
|
||||
|
||||
#define FP_NAN 0
|
||||
#define FP_INFINITE 1
|
||||
|
@ -355,9 +378,6 @@ extern float lgammaf _PARAMS((float));
|
|||
extern float erff _PARAMS((float));
|
||||
extern float erfcf _PARAMS((float));
|
||||
extern float log2f _PARAMS((float));
|
||||
#if !defined(__cplusplus)
|
||||
#define log2f(x) (logf (x) / (float_t) _M_LN2)
|
||||
#endif
|
||||
extern float hypotf _PARAMS((float, float));
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/* #undef _ELIX_LEVEL */
|
||||
|
||||
/* Newlib version */
|
||||
#define _NEWLIB_VERSION "1.19.0"
|
||||
#define _NEWLIB_VERSION "2.1.0"
|
||||
|
||||
/* C99 formats support (such as %a, %zu, ...) in IO functions like
|
||||
* printf/scanf enabled */
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define _PATHS_H_
|
||||
|
||||
#define _PATH_DEV "/dev/"
|
||||
#define _PATH_DEVNULL "/dev/null"
|
||||
#define _PATH_DEVZERO "/dev/zero"
|
||||
#define _PATH_BSHELL "/bin/sh"
|
||||
|
||||
#endif /* _PATHS_H_ */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Written by Joel Sherrill <joel@OARcorp.com>.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2010.
|
||||
* COPYRIGHT (c) 1989-2013.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
|
@ -15,7 +15,7 @@
|
|||
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
|
||||
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: pthread.h,v 1.9 2010/12/08 14:44:06 corinna Exp $
|
||||
* $Id: pthread.h,v 1.12 2013/11/29 23:35:34 joel Exp $
|
||||
*/
|
||||
|
||||
#ifndef __PTHREAD_h
|
||||
|
@ -32,6 +32,14 @@ extern "C" {
|
|||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
struct _pthread_cleanup_context {
|
||||
void (*_routine)(void *);
|
||||
void *_arg;
|
||||
int _canceltype;
|
||||
struct _pthread_cleanup_context *_previous;
|
||||
};
|
||||
|
||||
/* Register Fork Handlers */
|
||||
int _EXFUN(pthread_atfork,(void (*prepare)(void), void (*parent)(void),
|
||||
|
@ -104,7 +112,7 @@ int _EXFUN(pthread_cond_destroy, (pthread_cond_t *__mutex));
|
|||
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
|
||||
*/
|
||||
|
||||
#define PTHREAD_COND_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
|
||||
#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF)
|
||||
|
||||
/* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */
|
||||
|
||||
|
@ -206,6 +214,29 @@ int _EXFUN(pthread_attr_getguardsize,
|
|||
int _EXFUN(pthread_attr_setguardsize,
|
||||
(pthread_attr_t *__attr, size_t __guardsize));
|
||||
|
||||
/* POSIX thread APIs beyond the POSIX standard but provided
|
||||
* in GNU/Linux. They may be provided by other OSes for
|
||||
* compatibility.
|
||||
*/
|
||||
#if defined(__GNU_VISIBLE)
|
||||
#if defined(__rtems__)
|
||||
int _EXFUN(pthread_attr_setaffinity_np,
|
||||
(pthread_attr_t *__attr, size_t __cpusetsize,
|
||||
const cpu_set_t *__cpuset));
|
||||
int _EXFUN(pthread_attr_getaffinity_np,
|
||||
(const pthread_attr_t *__attr, size_t __cpusetsize,
|
||||
cpu_set_t *__cpuset));
|
||||
|
||||
int _EXFUN(pthread_setaffinity_np,
|
||||
(pthread_t __id, size_t __cpusetsize, const cpu_set_t *__cpuset));
|
||||
int _EXFUN(pthread_getaffinity_np,
|
||||
(const pthread_t __id, size_t __cpusetsize, cpu_set_t *__cpuset));
|
||||
|
||||
int _EXFUN(pthread_getattr_np,
|
||||
(pthread_t __id, pthread_attr_t *__attr));
|
||||
#endif /* defined(__rtems__) */
|
||||
#endif /* defined(__GNU_VISIBLE) */
|
||||
|
||||
/* Thread Creation, P1003.1c/Draft 10, p. 144 */
|
||||
|
||||
int _EXFUN(pthread_create,
|
||||
|
@ -280,9 +311,43 @@ void _EXFUN(pthread_testcancel, (void));
|
|||
|
||||
/* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */
|
||||
|
||||
void _EXFUN(pthread_cleanup_push,
|
||||
(void (*__routine)( void * ), void *__arg));
|
||||
void _EXFUN(pthread_cleanup_pop, (int __execute));
|
||||
void _EXFUN(_pthread_cleanup_push,
|
||||
(struct _pthread_cleanup_context *_context,
|
||||
void (*_routine)(void *), void *_arg));
|
||||
|
||||
void _EXFUN(_pthread_cleanup_pop,
|
||||
(struct _pthread_cleanup_context *_context,
|
||||
int _execute));
|
||||
|
||||
/* It is intentional to open and close the scope in two different macros */
|
||||
#define pthread_cleanup_push(_routine, _arg) \
|
||||
do { \
|
||||
struct _pthread_cleanup_context _pthread_clup_ctx; \
|
||||
_pthread_cleanup_push(&_pthread_clup_ctx, (_routine), (_arg))
|
||||
|
||||
#define pthread_cleanup_pop(_execute) \
|
||||
_pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \
|
||||
} while (0)
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
void _EXFUN(_pthread_cleanup_push_defer,
|
||||
(struct _pthread_cleanup_context *_context,
|
||||
void (*_routine)(void *), void *_arg));
|
||||
|
||||
void _EXFUN(_pthread_cleanup_pop_restore,
|
||||
(struct _pthread_cleanup_context *_context,
|
||||
int _execute));
|
||||
|
||||
/* It is intentional to open and close the scope in two different macros */
|
||||
#define pthread_cleanup_push_defer_np(_routine, _arg) \
|
||||
do { \
|
||||
struct _pthread_cleanup_context _pthread_clup_ctx; \
|
||||
_pthread_cleanup_push_defer(&_pthread_clup_ctx, (_routine), (_arg))
|
||||
|
||||
#define pthread_cleanup_pop_restore_np(_execute) \
|
||||
_pthread_cleanup_pop_restore(&_pthread_clup_ctx, (_execute)); \
|
||||
} while (0)
|
||||
#endif /* defined(_GNU_SOURCE) */
|
||||
|
||||
#if defined(_POSIX_THREAD_CPUTIME)
|
||||
|
||||
|
@ -328,6 +393,13 @@ int _EXFUN(pthread_spin_unlock, (pthread_spinlock_t *__spinlock));
|
|||
|
||||
#if defined(_POSIX_READER_WRITER_LOCKS)
|
||||
|
||||
/* This is used to statically initialize a pthread_rwlock_t. Example:
|
||||
|
||||
pthread_mutex_t mutex = PTHREAD_RWLOCK_INITIALIZER;
|
||||
*/
|
||||
|
||||
#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF)
|
||||
|
||||
int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr));
|
||||
int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr));
|
||||
int _EXFUN(pthread_rwlockattr_getpshared,
|
||||
|
|
|
@ -104,14 +104,6 @@ struct tms;
|
|||
struct timeval;
|
||||
struct timezone;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
unsigned int offset;
|
||||
int (*write)(const char*, const void *, size_t, size_t, size_t*);
|
||||
}__file_handle;
|
||||
|
||||
|
||||
#if defined(REENTRANT_SYSCALLS_PROVIDED) && defined(MISSING_SYSCALL_NAMES)
|
||||
|
||||
#define _close_r(__reent, __fd) close(__fd)
|
||||
|
@ -179,16 +171,22 @@ extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *__tp, void
|
|||
|
||||
#ifdef __LARGE64_FILES
|
||||
|
||||
#if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB)
|
||||
#define stat64 __stat64
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#define stat64 stat
|
||||
#endif
|
||||
struct stat64;
|
||||
|
||||
extern _off64_t _lseek64_r _PARAMS ((struct _reent *, int, _off64_t, int));
|
||||
extern int _fstat64_r _PARAMS ((struct _reent *, int, struct stat64 *));
|
||||
extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int));
|
||||
extern int _stat64_r _PARAMS ((struct _reent *, const char *, struct stat64 *));
|
||||
|
||||
/* Don't pollute namespace if not building newlib. */
|
||||
#if defined (__CYGWIN__) && !defined (_COMPILING_NEWLIB)
|
||||
#undef stat64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -93,9 +93,10 @@ typedef struct {
|
|||
#define REG_BACKR 02000 /* force use of backref code */
|
||||
|
||||
__BEGIN_DECLS
|
||||
int regcomp(regex_t *, const char *, int);
|
||||
size_t regerror(int, const regex_t *, char *, size_t);
|
||||
int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
|
||||
int regcomp(regex_t *__restrict, const char *__restrict, int);
|
||||
size_t regerror(int, const regex_t *__restrict, char *__restrict, size_t);
|
||||
int regexec(const regex_t *__restrict, const char *__restrict,
|
||||
size_t, regmatch_t [__restrict], int);
|
||||
void regfree(regex_t *);
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -59,9 +62,6 @@ typedef u_int32_t rpcprot_t;
|
|||
typedef u_int32_t rpcport_t;
|
||||
typedef int32_t rpc_inline_t;
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
#define __dontcare__ -1
|
||||
|
||||
#ifndef FALSE
|
||||
|
|
|
@ -42,6 +42,11 @@ struct hsearch_data
|
|||
size_t htablesize;
|
||||
};
|
||||
|
||||
#ifndef __compar_fn_t_defined
|
||||
#define __compar_fn_t_defined
|
||||
typedef int (*__compar_fn_t) (const void *, const void *);
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
int hcreate(size_t);
|
||||
void hdestroy(void);
|
||||
|
@ -49,10 +54,10 @@ ENTRY *hsearch(ENTRY, ACTION);
|
|||
int hcreate_r(size_t, struct hsearch_data *);
|
||||
void hdestroy_r(struct hsearch_data *);
|
||||
int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
|
||||
void *tdelete(const void *, void **, int (*)(const void *, const void *));
|
||||
void *tdelete(const void *__restrict, void **__restrict, __compar_fn_t);
|
||||
void tdestroy (void *, void (*)(void *));
|
||||
void *tfind(const void *, void **, int (*)(const void *, const void *));
|
||||
void *tsearch(const void *, void **, int (*)(const void *, const void *));
|
||||
void *tfind(const void *, void **, __compar_fn_t);
|
||||
void *tsearch(const void *, void **, __compar_fn_t);
|
||||
void twalk(const void *, void (*)(const void *, VISIT, int));
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/*-
|
||||
* Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SPAWN_H_
|
||||
#define _SPAWN_H_
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/_types.h>
|
||||
#define __need_sigset_t
|
||||
#include <signal.h>
|
||||
|
||||
struct sched_param;
|
||||
|
||||
typedef struct __posix_spawnattr *posix_spawnattr_t;
|
||||
typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t;
|
||||
|
||||
#define POSIX_SPAWN_RESETIDS 0x01
|
||||
#define POSIX_SPAWN_SETPGROUP 0x02
|
||||
#define POSIX_SPAWN_SETSCHEDPARAM 0x04
|
||||
#define POSIX_SPAWN_SETSCHEDULER 0x08
|
||||
#define POSIX_SPAWN_SETSIGDEF 0x10
|
||||
#define POSIX_SPAWN_SETSIGMASK 0x20
|
||||
|
||||
_BEGIN_STD_C
|
||||
/*
|
||||
* Spawn routines
|
||||
*
|
||||
* XXX both arrays should be __restrict, but this does not work when GCC
|
||||
* is invoked with -std=c99.
|
||||
*/
|
||||
int _EXFUN(posix_spawn, (pid_t * __restrict, const char * __restrict,
|
||||
const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
|
||||
char * const [], char * const [])
|
||||
);
|
||||
int _EXFUN(posix_spawnp, (pid_t * __restrict, const char * __restrict,
|
||||
const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict,
|
||||
char * const [], char * const [])
|
||||
);
|
||||
|
||||
/*
|
||||
* File descriptor actions
|
||||
*/
|
||||
int _EXFUN(posix_spawn_file_actions_init, (posix_spawn_file_actions_t *));
|
||||
int _EXFUN(posix_spawn_file_actions_destroy, (posix_spawn_file_actions_t *));
|
||||
|
||||
int _EXFUN(posix_spawn_file_actions_addopen,
|
||||
(posix_spawn_file_actions_t * __restrict, int, const char * __restrict, int, mode_t)
|
||||
);
|
||||
int _EXFUN(posix_spawn_file_actions_adddup2,
|
||||
(posix_spawn_file_actions_t *, int, int)
|
||||
);
|
||||
int _EXFUN(posix_spawn_file_actions_addclose,
|
||||
(posix_spawn_file_actions_t *, int)
|
||||
);
|
||||
|
||||
/*
|
||||
* Spawn attributes
|
||||
*/
|
||||
int _EXFUN(posix_spawnattr_init, (posix_spawnattr_t *));
|
||||
int _EXFUN(posix_spawnattr_destroy, (posix_spawnattr_t *));
|
||||
|
||||
int _EXFUN(posix_spawnattr_getflags,
|
||||
(const posix_spawnattr_t * __restrict, short * __restrict)
|
||||
);
|
||||
int _EXFUN(posix_spawnattr_getpgroup,
|
||||
(const posix_spawnattr_t * __restrict, pid_t * __restrict));
|
||||
int _EXFUN(posix_spawnattr_getschedparam,
|
||||
(const posix_spawnattr_t * __restrict, struct sched_param * __restrict)
|
||||
);
|
||||
int _EXFUN(posix_spawnattr_getschedpolicy,
|
||||
(const posix_spawnattr_t * __restrict, int * __restrict)
|
||||
);
|
||||
int _EXFUN(posix_spawnattr_getsigdefault,
|
||||
(const posix_spawnattr_t * __restrict, sigset_t * __restrict)
|
||||
);
|
||||
int _EXFUN(posix_spawnattr_getsigmask,
|
||||
(const posix_spawnattr_t * __restrict, sigset_t * __restrict)
|
||||
);
|
||||
|
||||
int _EXFUN(posix_spawnattr_setflags, (posix_spawnattr_t *, short));
|
||||
int _EXFUN(posix_spawnattr_setpgroup, (posix_spawnattr_t *, pid_t));
|
||||
int _EXFUN(posix_spawnattr_setschedparam,
|
||||
(posix_spawnattr_t * __restrict, const struct sched_param * __restrict)
|
||||
);
|
||||
int _EXFUN(posix_spawnattr_setschedpolicy, (posix_spawnattr_t *, int));
|
||||
int _EXFUN(posix_spawnattr_setsigdefault,
|
||||
(posix_spawnattr_t * __restrict, const sigset_t * __restrict)
|
||||
);
|
||||
int _EXFUN(posix_spawnattr_setsigmask,
|
||||
(posix_spawnattr_t * __restrict, const sigset_t * __restrict)
|
||||
);
|
||||
_END_STD_C
|
||||
|
||||
#endif /* !_SPAWN_H_ */
|
|
@ -0,0 +1,413 @@
|
|||
/*-
|
||||
* Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
|
||||
* David Chisnall <theraven@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _STDATOMIC_H_
|
||||
#define _STDATOMIC_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/_types.h>
|
||||
|
||||
#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
|
||||
#define __CLANG_ATOMICS
|
||||
#elif __GNUC_PREREQ__(4, 7)
|
||||
#define __GNUC_ATOMICS
|
||||
#elif defined(__GNUC__)
|
||||
#define __SYNC_ATOMICS
|
||||
#else
|
||||
#error "stdatomic.h does not support your compiler"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.17.1 Atomic lock-free macros.
|
||||
*/
|
||||
|
||||
#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE
|
||||
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE
|
||||
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE
|
||||
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE
|
||||
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE
|
||||
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE
|
||||
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_INT_LOCK_FREE
|
||||
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_LONG_LOCK_FREE
|
||||
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE
|
||||
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
|
||||
#endif
|
||||
#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE
|
||||
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.17.2 Initialization.
|
||||
*/
|
||||
|
||||
#if defined(__CLANG_ATOMICS)
|
||||
#define ATOMIC_VAR_INIT(value) (value)
|
||||
#define atomic_init(obj, value) __c11_atomic_init(obj, value)
|
||||
#else
|
||||
#define ATOMIC_VAR_INIT(value) { .__val = (value) }
|
||||
#define atomic_init(obj, value) ((void)((obj)->__val = (value)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Clang and recent GCC both provide predefined macros for the memory
|
||||
* orderings. If we are using a compiler that doesn't define them, use the
|
||||
* clang values - these will be ignored in the fallback path.
|
||||
*/
|
||||
|
||||
#ifndef __ATOMIC_RELAXED
|
||||
#define __ATOMIC_RELAXED 0
|
||||
#endif
|
||||
#ifndef __ATOMIC_CONSUME
|
||||
#define __ATOMIC_CONSUME 1
|
||||
#endif
|
||||
#ifndef __ATOMIC_ACQUIRE
|
||||
#define __ATOMIC_ACQUIRE 2
|
||||
#endif
|
||||
#ifndef __ATOMIC_RELEASE
|
||||
#define __ATOMIC_RELEASE 3
|
||||
#endif
|
||||
#ifndef __ATOMIC_ACQ_REL
|
||||
#define __ATOMIC_ACQ_REL 4
|
||||
#endif
|
||||
#ifndef __ATOMIC_SEQ_CST
|
||||
#define __ATOMIC_SEQ_CST 5
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.17.3 Order and consistency.
|
||||
*
|
||||
* The memory_order_* constants that denote the barrier behaviour of the
|
||||
* atomic operations.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
memory_order_relaxed = __ATOMIC_RELAXED,
|
||||
memory_order_consume = __ATOMIC_CONSUME,
|
||||
memory_order_acquire = __ATOMIC_ACQUIRE,
|
||||
memory_order_release = __ATOMIC_RELEASE,
|
||||
memory_order_acq_rel = __ATOMIC_ACQ_REL,
|
||||
memory_order_seq_cst = __ATOMIC_SEQ_CST
|
||||
} memory_order;
|
||||
|
||||
/*
|
||||
* 7.17.4 Fences.
|
||||
*/
|
||||
|
||||
static __inline void
|
||||
atomic_thread_fence(memory_order __order __unused)
|
||||
{
|
||||
|
||||
#ifdef __CLANG_ATOMICS
|
||||
__c11_atomic_thread_fence(__order);
|
||||
#elif defined(__GNUC_ATOMICS)
|
||||
__atomic_thread_fence(__order);
|
||||
#else
|
||||
__sync_synchronize();
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline void
|
||||
atomic_signal_fence(memory_order __order __unused)
|
||||
{
|
||||
|
||||
#ifdef __CLANG_ATOMICS
|
||||
__c11_atomic_signal_fence(__order);
|
||||
#elif defined(__GNUC_ATOMICS)
|
||||
__atomic_signal_fence(__order);
|
||||
#else
|
||||
__asm volatile ("" ::: "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* 7.17.5 Lock-free property.
|
||||
*/
|
||||
|
||||
#if defined(_KERNEL)
|
||||
/* Atomics in kernelspace are always lock-free. */
|
||||
#define atomic_is_lock_free(obj) \
|
||||
((void)(obj), (_Bool)1)
|
||||
#elif defined(__CLANG_ATOMICS)
|
||||
#define atomic_is_lock_free(obj) \
|
||||
__atomic_is_lock_free(sizeof(*(obj)), obj)
|
||||
#elif defined(__GNUC_ATOMICS)
|
||||
#define atomic_is_lock_free(obj) \
|
||||
__atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val)
|
||||
#else
|
||||
#define atomic_is_lock_free(obj) \
|
||||
((void)(obj), sizeof((obj)->__val) <= sizeof(void *))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.17.6 Atomic integer types.
|
||||
*/
|
||||
|
||||
typedef _Atomic(_Bool) atomic_bool;
|
||||
typedef _Atomic(char) atomic_char;
|
||||
typedef _Atomic(signed char) atomic_schar;
|
||||
typedef _Atomic(unsigned char) atomic_uchar;
|
||||
typedef _Atomic(short) atomic_short;
|
||||
typedef _Atomic(unsigned short) atomic_ushort;
|
||||
typedef _Atomic(int) atomic_int;
|
||||
typedef _Atomic(unsigned int) atomic_uint;
|
||||
typedef _Atomic(long) atomic_long;
|
||||
typedef _Atomic(unsigned long) atomic_ulong;
|
||||
typedef _Atomic(long long) atomic_llong;
|
||||
typedef _Atomic(unsigned long long) atomic_ullong;
|
||||
#if 0
|
||||
typedef _Atomic(__char16_t) atomic_char16_t;
|
||||
typedef _Atomic(__char32_t) atomic_char32_t;
|
||||
#endif
|
||||
typedef _Atomic(wchar_t) atomic_wchar_t;
|
||||
typedef _Atomic(int_least8_t) atomic_int_least8_t;
|
||||
typedef _Atomic(uint_least8_t) atomic_uint_least8_t;
|
||||
typedef _Atomic(int_least16_t) atomic_int_least16_t;
|
||||
typedef _Atomic(uint_least16_t) atomic_uint_least16_t;
|
||||
typedef _Atomic(int_least32_t) atomic_int_least32_t;
|
||||
typedef _Atomic(uint_least32_t) atomic_uint_least32_t;
|
||||
typedef _Atomic(int_least64_t) atomic_int_least64_t;
|
||||
typedef _Atomic(uint_least64_t) atomic_uint_least64_t;
|
||||
typedef _Atomic(int_fast8_t) atomic_int_fast8_t;
|
||||
typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t;
|
||||
typedef _Atomic(int_fast16_t) atomic_int_fast16_t;
|
||||
typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t;
|
||||
typedef _Atomic(int_fast32_t) atomic_int_fast32_t;
|
||||
typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t;
|
||||
typedef _Atomic(int_fast64_t) atomic_int_fast64_t;
|
||||
typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t;
|
||||
typedef _Atomic(intptr_t) atomic_intptr_t;
|
||||
typedef _Atomic(uintptr_t) atomic_uintptr_t;
|
||||
typedef _Atomic(size_t) atomic_size_t;
|
||||
typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t;
|
||||
typedef _Atomic(intmax_t) atomic_intmax_t;
|
||||
typedef _Atomic(uintmax_t) atomic_uintmax_t;
|
||||
|
||||
/*
|
||||
* 7.17.7 Operations on atomic types.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Compiler-specific operations.
|
||||
*/
|
||||
|
||||
#if defined(__CLANG_ATOMICS)
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, \
|
||||
desired, success, failure) \
|
||||
__c11_atomic_compare_exchange_strong(object, expected, desired, \
|
||||
success, failure)
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, \
|
||||
desired, success, failure) \
|
||||
__c11_atomic_compare_exchange_weak(object, expected, desired, \
|
||||
success, failure)
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
__c11_atomic_exchange(object, desired, order)
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
__c11_atomic_fetch_add(object, operand, order)
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
__c11_atomic_fetch_and(object, operand, order)
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
__c11_atomic_fetch_or(object, operand, order)
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
__c11_atomic_fetch_sub(object, operand, order)
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
__c11_atomic_fetch_xor(object, operand, order)
|
||||
#define atomic_load_explicit(object, order) \
|
||||
__c11_atomic_load(object, order)
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
__c11_atomic_store(object, desired, order)
|
||||
#elif defined(__GNUC_ATOMICS)
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, \
|
||||
desired, success, failure) \
|
||||
__atomic_compare_exchange_n(&(object)->__val, expected, \
|
||||
desired, 0, success, failure)
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, \
|
||||
desired, success, failure) \
|
||||
__atomic_compare_exchange_n(&(object)->__val, expected, \
|
||||
desired, 1, success, failure)
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
__atomic_exchange_n(&(object)->__val, desired, order)
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
__atomic_fetch_add(&(object)->__val, operand, order)
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
__atomic_fetch_and(&(object)->__val, operand, order)
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
__atomic_fetch_or(&(object)->__val, operand, order)
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
__atomic_fetch_sub(&(object)->__val, operand, order)
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
__atomic_fetch_xor(&(object)->__val, operand, order)
|
||||
#define atomic_load_explicit(object, order) \
|
||||
__atomic_load_n(&(object)->__val, order)
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
__atomic_store_n(&(object)->__val, desired, order)
|
||||
#else
|
||||
#define __atomic_apply_stride(object, operand) \
|
||||
(((__typeof__((object)->__val))0) + (operand))
|
||||
#define atomic_compare_exchange_strong_explicit(object, expected, \
|
||||
desired, success, failure) __extension__ ({ \
|
||||
__typeof__(expected) __ep = (expected); \
|
||||
__typeof__(*__ep) __e = *__ep; \
|
||||
(void)(success); (void)(failure); \
|
||||
(_Bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \
|
||||
__e, desired)) == __e); \
|
||||
})
|
||||
#define atomic_compare_exchange_weak_explicit(object, expected, \
|
||||
desired, success, failure) \
|
||||
atomic_compare_exchange_strong_explicit(object, expected, \
|
||||
desired, success, failure)
|
||||
#if __has_builtin(__sync_swap)
|
||||
/* Clang provides a full-barrier atomic exchange - use it if available. */
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
((void)(order), __sync_swap(&(object)->__val, desired))
|
||||
#else
|
||||
/*
|
||||
* __sync_lock_test_and_set() is only an acquire barrier in theory (although in
|
||||
* practice it is usually a full barrier) so we need an explicit barrier before
|
||||
* it.
|
||||
*/
|
||||
#define atomic_exchange_explicit(object, desired, order) \
|
||||
__extension__ ({ \
|
||||
__typeof__(object) __o = (object); \
|
||||
__typeof__(desired) __d = (desired); \
|
||||
(void)(order); \
|
||||
__sync_synchronize(); \
|
||||
__sync_lock_test_and_set(&(__o)->__val, __d); \
|
||||
})
|
||||
#endif
|
||||
#define atomic_fetch_add_explicit(object, operand, order) \
|
||||
((void)(order), __sync_fetch_and_add(&(object)->__val, \
|
||||
__atomic_apply_stride(object, operand)))
|
||||
#define atomic_fetch_and_explicit(object, operand, order) \
|
||||
((void)(order), __sync_fetch_and_and(&(object)->__val, operand))
|
||||
#define atomic_fetch_or_explicit(object, operand, order) \
|
||||
((void)(order), __sync_fetch_and_or(&(object)->__val, operand))
|
||||
#define atomic_fetch_sub_explicit(object, operand, order) \
|
||||
((void)(order), __sync_fetch_and_sub(&(object)->__val, \
|
||||
__atomic_apply_stride(object, operand)))
|
||||
#define atomic_fetch_xor_explicit(object, operand, order) \
|
||||
((void)(order), __sync_fetch_and_xor(&(object)->__val, operand))
|
||||
#define atomic_load_explicit(object, order) \
|
||||
((void)(order), __sync_fetch_and_add(&(object)->__val, 0))
|
||||
#define atomic_store_explicit(object, desired, order) \
|
||||
((void)atomic_exchange_explicit(object, desired, order))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convenience functions.
|
||||
*
|
||||
* Don't provide these in kernel space. In kernel space, we should be
|
||||
* disciplined enough to always provide explicit barriers.
|
||||
*/
|
||||
|
||||
#ifndef _KERNEL
|
||||
#define atomic_compare_exchange_strong(object, expected, desired) \
|
||||
atomic_compare_exchange_strong_explicit(object, expected, \
|
||||
desired, memory_order_seq_cst, memory_order_seq_cst)
|
||||
#define atomic_compare_exchange_weak(object, expected, desired) \
|
||||
atomic_compare_exchange_weak_explicit(object, expected, \
|
||||
desired, memory_order_seq_cst, memory_order_seq_cst)
|
||||
#define atomic_exchange(object, desired) \
|
||||
atomic_exchange_explicit(object, desired, memory_order_seq_cst)
|
||||
#define atomic_fetch_add(object, operand) \
|
||||
atomic_fetch_add_explicit(object, operand, memory_order_seq_cst)
|
||||
#define atomic_fetch_and(object, operand) \
|
||||
atomic_fetch_and_explicit(object, operand, memory_order_seq_cst)
|
||||
#define atomic_fetch_or(object, operand) \
|
||||
atomic_fetch_or_explicit(object, operand, memory_order_seq_cst)
|
||||
#define atomic_fetch_sub(object, operand) \
|
||||
atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst)
|
||||
#define atomic_fetch_xor(object, operand) \
|
||||
atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst)
|
||||
#define atomic_load(object) \
|
||||
atomic_load_explicit(object, memory_order_seq_cst)
|
||||
#define atomic_store(object, desired) \
|
||||
atomic_store_explicit(object, desired, memory_order_seq_cst)
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
/*
|
||||
* 7.17.8 Atomic flag type and operations.
|
||||
*
|
||||
* XXX: Assume atomic_bool can be used as an atomic_flag. Is there some
|
||||
* kind of compiler built-in type we could use?
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
atomic_bool __flag;
|
||||
} atomic_flag;
|
||||
|
||||
#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) }
|
||||
|
||||
static __inline _Bool
|
||||
atomic_flag_test_and_set_explicit(volatile atomic_flag *__object,
|
||||
memory_order __order)
|
||||
{
|
||||
return (atomic_exchange_explicit(&__object->__flag, 1, __order));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order)
|
||||
{
|
||||
|
||||
atomic_store_explicit(&__object->__flag, 0, __order);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
static __inline _Bool
|
||||
atomic_flag_test_and_set(volatile atomic_flag *__object)
|
||||
{
|
||||
|
||||
return (atomic_flag_test_and_set_explicit(__object,
|
||||
memory_order_seq_cst));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
atomic_flag_clear(volatile atomic_flag *__object)
|
||||
{
|
||||
|
||||
atomic_flag_clear_explicit(__object, memory_order_seq_cst);
|
||||
}
|
||||
#endif /* !_KERNEL */
|
||||
|
||||
#endif /* !_STDATOMIC_H_ */
|
|
@ -9,13 +9,13 @@
|
|||
#ifndef _STDINT_H
|
||||
#define _STDINT_H
|
||||
|
||||
#include <machine/_default_types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && \
|
||||
( (__GNUC__ >= 4) || \
|
||||
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) )
|
||||
#if __GNUC_PREREQ (3, 2)
|
||||
/* gcc > 3.2 implicitly defines the values we are interested */
|
||||
#define __STDINT_EXP(x) __##x##__
|
||||
#else
|
||||
|
@ -35,119 +35,54 @@ extern "C" {
|
|||
#define __have_long64 1
|
||||
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
|
||||
#define __have_long32 1
|
||||
#define __have_long64 0
|
||||
#endif
|
||||
|
||||
#if __STDINT_EXP(SCHAR_MAX) == 0x7f
|
||||
typedef signed char int8_t ;
|
||||
typedef unsigned char uint8_t ;
|
||||
#ifdef ___int8_t_defined
|
||||
typedef __int8_t int8_t ;
|
||||
typedef __uint8_t uint8_t ;
|
||||
#define __int8_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __int8_t_defined
|
||||
typedef signed char int_least8_t;
|
||||
typedef unsigned char uint_least8_t;
|
||||
#ifdef ___int_least8_t_defined
|
||||
typedef __int_least8_t int_least8_t;
|
||||
typedef __uint_least8_t uint_least8_t;
|
||||
#define __int_least8_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __STDINT_EXP(SHRT_MAX) == 0x7fff
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
#define __int16_t_defined 1
|
||||
#elif __STDINT_EXP(INT_MAX) == 0x7fff
|
||||
typedef signed int int16_t;
|
||||
typedef unsigned int uint16_t;
|
||||
#define __int16_t_defined 1
|
||||
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff
|
||||
typedef signed char int16_t;
|
||||
typedef unsigned char uint16_t;
|
||||
#ifdef ___int16_t_defined
|
||||
typedef __int16_t int16_t ;
|
||||
typedef __uint16_t uint16_t ;
|
||||
#define __int16_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __int16_t_defined
|
||||
typedef int16_t int_least16_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
#ifdef ___int_least16_t_defined
|
||||
typedef __int_least16_t int_least16_t;
|
||||
typedef __uint_least16_t uint_least16_t;
|
||||
#define __int_least16_t_defined 1
|
||||
|
||||
#if !__int_least8_t_defined
|
||||
typedef int16_t int_least8_t;
|
||||
typedef uint16_t uint_least8_t;
|
||||
#define __int_least8_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//#if __have_long32
|
||||
//typedef signed long int32_t;
|
||||
//typedef unsigned long uint32_t;
|
||||
//#define __int32_t_defined 1
|
||||
//#elif __STDINT_EXP(INT_MAX) == 0x7fffffffL
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#ifdef ___int32_t_defined
|
||||
typedef __int32_t int32_t ;
|
||||
typedef __uint32_t uint32_t ;
|
||||
#define __int32_t_defined 1
|
||||
//#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL
|
||||
//typedef signed short int32_t;
|
||||
//typedef unsigned short uint32_t;
|
||||
//#define __int32_t_defined 1
|
||||
//#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL
|
||||
//typedef signed char int32_t;
|
||||
//typedef unsigned char uint32_t;
|
||||
//#define __int32_t_defined 1
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
#if __int32_t_defined
|
||||
typedef int32_t int_least32_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
#ifdef ___int_least32_t_defined
|
||||
typedef __int_least32_t int_least32_t;
|
||||
typedef __uint_least32_t uint_least32_t;
|
||||
#define __int_least32_t_defined 1
|
||||
|
||||
#if !__int_least8_t_defined
|
||||
typedef int32_t int_least8_t;
|
||||
typedef uint32_t uint_least8_t;
|
||||
#define __int_least8_t_defined 1
|
||||
#endif
|
||||
|
||||
#if !__int_least16_t_defined
|
||||
typedef int32_t int_least16_t;
|
||||
typedef uint32_t uint_least16_t;
|
||||
#define __int_least16_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __have_long64
|
||||
typedef signed long int64_t;
|
||||
typedef unsigned long uint64_t;
|
||||
#define __int64_t_defined 1
|
||||
#elif __have_longlong64
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#define __int64_t_defined 1
|
||||
#elif __STDINT_EXP(INT_MAX) > 0x7fffffff
|
||||
typedef signed int int64_t;
|
||||
typedef unsigned int uint64_t;
|
||||
#ifdef ___int64_t_defined
|
||||
typedef __int64_t int64_t ;
|
||||
typedef __uint64_t uint64_t ;
|
||||
#define __int64_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __int64_t_defined
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
#ifdef ___int_least64_t_defined
|
||||
typedef __int_least64_t int_least64_t;
|
||||
typedef __uint_least64_t uint_least64_t;
|
||||
#define __int_least64_t_defined 1
|
||||
|
||||
#if !__int_least8_t_defined
|
||||
typedef int64_t int_least8_t;
|
||||
typedef uint64_t uint_least8_t;
|
||||
#define __int_least8_t_defined 1
|
||||
#endif
|
||||
|
||||
#if !__int_least16_t_defined
|
||||
typedef int64_t int_least16_t;
|
||||
typedef uint64_t uint_least16_t;
|
||||
#define __int_least16_t_defined 1
|
||||
#endif
|
||||
|
||||
#if !__int_least32_t_defined
|
||||
typedef int64_t int_least32_t;
|
||||
typedef uint64_t uint_least32_t;
|
||||
#define __int_least32_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -156,30 +91,44 @@ typedef uint64_t uint_least32_t;
|
|||
* Assume int to be the fastest type for all types with a width
|
||||
* less than __INT_MAX__ rsp. INT_MAX
|
||||
*/
|
||||
#if __STDINT_EXP(INT_MAX) >= 0x7f
|
||||
#ifdef __INT_FAST8_TYPE__
|
||||
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
#define __int_fast8_t_defined 1
|
||||
#elif __STDINT_EXP(INT_MAX) >= 0x7f
|
||||
typedef signed int int_fast8_t;
|
||||
typedef unsigned int uint_fast8_t;
|
||||
#define __int_fast8_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __STDINT_EXP(INT_MAX) >= 0x7fff
|
||||
#ifdef __INT_FAST16_TYPE__
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
#define __int_fast16_t_defined 1
|
||||
#elif __STDINT_EXP(INT_MAX) >= 0x7fff
|
||||
typedef signed int int_fast16_t;
|
||||
typedef unsigned int uint_fast16_t;
|
||||
#define __int_fast16_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
|
||||
#ifdef __INT_FAST32_TYPE__
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
#define __int_fast32_t_defined 1
|
||||
#elif __STDINT_EXP(INT_MAX) >= 0x7fffffff
|
||||
typedef signed int int_fast32_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
#define __int_fast32_t_defined 1
|
||||
#endif
|
||||
|
||||
#if __STDINT_EXP(INT_MAX) > 0x7fffffff
|
||||
#ifdef __INT_FAST64_TYPE__
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||
#define __int_fast64_t_defined 1
|
||||
#elif __STDINT_EXP(INT_MAX) > 0x7fffffff
|
||||
typedef signed int int_fast64_t;
|
||||
typedef unsigned int uint_fast64_t;
|
||||
#define __int_fast64_t_defined 1
|
||||
#else
|
||||
#define __int_fast64_t_defined 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -215,7 +164,6 @@ typedef uint64_t uint_least32_t;
|
|||
#if __int_least64_t_defined
|
||||
typedef int_least64_t int_fast64_t;
|
||||
typedef uint_least64_t uint_fast64_t;
|
||||
#undef __int_fast64_t_defined
|
||||
#define __int_fast64_t_defined 1
|
||||
#endif
|
||||
#endif
|
||||
|
@ -239,13 +187,14 @@ typedef uint64_t uint_least32_t;
|
|||
typedef unsigned long uintmax_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GCC doesn't provide an appropriate macro for [u]intptr_t
|
||||
* For now, use __PTRDIFF_TYPE__
|
||||
*/
|
||||
#if defined(__PTRDIFF_TYPE__)
|
||||
typedef signed __PTRDIFF_TYPE__ intptr_t;
|
||||
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
|
||||
typedef __intptr_t intptr_t;
|
||||
typedef __uintptr_t uintptr_t;
|
||||
|
||||
#ifdef __INTPTR_TYPE__
|
||||
#define INTPTR_MIN (-__INTPTR_MAX__ - 1)
|
||||
#define INTPTR_MAX __INTPTR_MAX__
|
||||
#define UINTPTR_MAX __UINTPTR_MAX__
|
||||
#elif defined(__PTRDIFF_TYPE__)
|
||||
#define INTPTR_MAX PTRDIFF_MAX
|
||||
#define INTPTR_MIN PTRDIFF_MIN
|
||||
#ifdef __UINTPTR_MAX__
|
||||
|
@ -258,8 +207,6 @@ typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
|
|||
* Fallback to hardcoded values,
|
||||
* should be valid on cpu's with 32bit int/32bit void*
|
||||
*/
|
||||
typedef signed long intptr_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
#define INTPTR_MAX __STDINT_EXP(LONG_MAX)
|
||||
#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
|
||||
#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
|
||||
|
@ -267,13 +214,21 @@ typedef unsigned long uintptr_t;
|
|||
|
||||
/* Limits of Specified-Width Integer Types */
|
||||
|
||||
#if __int8_t_defined
|
||||
#ifdef __INT8_MAX__
|
||||
#define INT8_MIN (-__INT8_MAX__ - 1)
|
||||
#define INT8_MAX __INT8_MAX__
|
||||
#define UINT8_MAX __UINT8_MAX__
|
||||
#elif defined(__int8_t_defined)
|
||||
#define INT8_MIN -128
|
||||
#define INT8_MAX 127
|
||||
#define UINT8_MAX 255
|
||||
#endif
|
||||
|
||||
#if __int_least8_t_defined
|
||||
#ifdef __INT_LEAST8_MAX__
|
||||
#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)
|
||||
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
|
||||
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
|
||||
#elif defined(__int_least8_t_defined)
|
||||
#define INT_LEAST8_MIN -128
|
||||
#define INT_LEAST8_MAX 127
|
||||
#define UINT_LEAST8_MAX 255
|
||||
|
@ -281,13 +236,21 @@ typedef unsigned long uintptr_t;
|
|||
#error required type int_least8_t missing
|
||||
#endif
|
||||
|
||||
#if __int16_t_defined
|
||||
#ifdef __INT16_MAX__
|
||||
#define INT16_MIN (-__INT16_MAX__ - 1)
|
||||
#define INT16_MAX __INT16_MAX__
|
||||
#define UINT16_MAX __UINT16_MAX__
|
||||
#elif defined(__int16_t_defined)
|
||||
#define INT16_MIN -32768
|
||||
#define INT16_MAX 32767
|
||||
#define UINT16_MAX 65535
|
||||
#endif
|
||||
|
||||
#if __int_least16_t_defined
|
||||
#ifdef __INT_LEAST16_MAX__
|
||||
#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1)
|
||||
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
|
||||
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
|
||||
#elif defined(__int_least16_t_defined)
|
||||
#define INT_LEAST16_MIN -32768
|
||||
#define INT_LEAST16_MAX 32767
|
||||
#define UINT_LEAST16_MAX 65535
|
||||
|
@ -295,7 +258,11 @@ typedef unsigned long uintptr_t;
|
|||
#error required type int_least16_t missing
|
||||
#endif
|
||||
|
||||
#if __int32_t_defined
|
||||
#ifdef __INT32_MAX__
|
||||
#define INT32_MIN (-__INT32_MAX__ - 1)
|
||||
#define INT32_MAX __INT32_MAX__
|
||||
#define UINT32_MAX __UINT32_MAX__
|
||||
#elif defined(__int32_t_defined)
|
||||
#if __have_long32
|
||||
#define INT32_MIN (-2147483647L-1)
|
||||
#define INT32_MAX 2147483647L
|
||||
|
@ -307,7 +274,11 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __int_least32_t_defined
|
||||
#ifdef __INT_LEAST32_MAX__
|
||||
#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1)
|
||||
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
|
||||
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
|
||||
#elif defined(__int_least32_t_defined)
|
||||
#if __have_long32
|
||||
#define INT_LEAST32_MIN (-2147483647L-1)
|
||||
#define INT_LEAST32_MAX 2147483647L
|
||||
|
@ -321,7 +292,11 @@ typedef unsigned long uintptr_t;
|
|||
#error required type int_least32_t missing
|
||||
#endif
|
||||
|
||||
#if __int64_t_defined
|
||||
#ifdef __INT64_MAX__
|
||||
#define INT64_MIN (-__INT64_MAX__ - 1)
|
||||
#define INT64_MAX __INT64_MAX__
|
||||
#define UINT64_MAX __UINT64_MAX__
|
||||
#elif defined(__int64_t_defined)
|
||||
#if __have_long64
|
||||
#define INT64_MIN (-9223372036854775807L-1L)
|
||||
#define INT64_MAX 9223372036854775807L
|
||||
|
@ -333,7 +308,11 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __int_least64_t_defined
|
||||
#ifdef __INT_LEAST64_MAX__
|
||||
#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1)
|
||||
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
|
||||
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
|
||||
#elif defined(__int_least64_t_defined)
|
||||
#if __have_long64
|
||||
#define INT_LEAST64_MIN (-9223372036854775807L-1L)
|
||||
#define INT_LEAST64_MAX 9223372036854775807L
|
||||
|
@ -345,7 +324,11 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __int_fast8_t_defined
|
||||
#ifdef __INT_FAST8_MAX__
|
||||
#define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1)
|
||||
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||
#elif defined(__int_fast8_t_defined)
|
||||
#if __STDINT_EXP(INT_MAX) >= 0x7f
|
||||
#define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1)
|
||||
#define INT_FAST8_MAX __STDINT_EXP(INT_MAX)
|
||||
|
@ -357,7 +340,11 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __int_fast16_t_defined
|
||||
#ifdef __INT_FAST16_MAX__
|
||||
#define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1)
|
||||
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||
#elif defined(__int_fast16_t_defined)
|
||||
#if __STDINT_EXP(INT_MAX) >= 0x7fff
|
||||
#define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1)
|
||||
#define INT_FAST16_MAX __STDINT_EXP(INT_MAX)
|
||||
|
@ -369,7 +356,11 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __int_fast32_t_defined
|
||||
#ifdef __INT_FAST32_MAX__
|
||||
#define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1)
|
||||
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||
#elif defined(__int_fast32_t_defined)
|
||||
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff
|
||||
#define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1)
|
||||
#define INT_FAST32_MAX __STDINT_EXP(INT_MAX)
|
||||
|
@ -381,7 +372,11 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if __int_fast64_t_defined
|
||||
#ifdef __INT_FAST64_MAX__
|
||||
#define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1)
|
||||
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||
#elif defined(__int_fast64_t_defined)
|
||||
#if __STDINT_EXP(INT_MAX) > 0x7fffffff
|
||||
#define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1)
|
||||
#define INT_FAST64_MAX __STDINT_EXP(INT_MAX)
|
||||
|
@ -448,20 +443,34 @@ typedef unsigned long uintptr_t;
|
|||
#endif
|
||||
|
||||
/** Macros for minimum-width integer constant expressions */
|
||||
#ifdef __INT8_C
|
||||
#define INT8_C(x) __INT8_C(x)
|
||||
#define UINT8_C(x) __UINT8_C(x)
|
||||
#else
|
||||
#define INT8_C(x) x
|
||||
#if __STDINT_EXP(INT_MAX) > 0x7f
|
||||
#define UINT8_C(x) x
|
||||
#else
|
||||
#define UINT8_C(x) x##U
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __INT16_C
|
||||
#define INT16_C(x) __INT16_C(x)
|
||||
#define UINT16_C(x) __UINT16_C(x)
|
||||
#else
|
||||
#define INT16_C(x) x
|
||||
#if __STDINT_EXP(INT_MAX) > 0x7fff
|
||||
#define UINT16_C(x) x
|
||||
#else
|
||||
#define UINT16_C(x) x##U
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __INT32_C
|
||||
#define INT32_C(x) __INT32_C(x)
|
||||
#define UINT32_C(x) __UINT32_C(x)
|
||||
#else
|
||||
#if __have_long32
|
||||
#define INT32_C(x) x##L
|
||||
#define UINT32_C(x) x##UL
|
||||
|
@ -469,7 +478,12 @@ typedef unsigned long uintptr_t;
|
|||
#define INT32_C(x) x
|
||||
#define UINT32_C(x) x##U
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __INT64_C
|
||||
#define INT64_C(x) __INT64_C(x)
|
||||
#define UINT64_C(x) __UINT64_C(x)
|
||||
#else
|
||||
#if __int64_t_defined
|
||||
#if __have_long64
|
||||
#define INT64_C(x) x##L
|
||||
|
@ -479,8 +493,13 @@ typedef unsigned long uintptr_t;
|
|||
#define UINT64_C(x) x##ULL
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Macros for greatest-width integer constant expression */
|
||||
#ifdef __INTMAX_C
|
||||
#define INTMAX_C(x) __INTMAX_C(x)
|
||||
#define UINTMAX_C(x) __UINTMAX_C(x)
|
||||
#else
|
||||
#if __have_long64
|
||||
#define INTMAX_C(x) x##L
|
||||
#define UINTMAX_C(x) x##UL
|
||||
|
@ -488,6 +507,7 @@ typedef unsigned long uintptr_t;
|
|||
#define INTMAX_C(x) x##LL
|
||||
#define UINTMAX_C(x) x##ULL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#define _FSTDIO /* ``function stdio'' */
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#define __need___va_list
|
||||
|
@ -96,10 +97,6 @@ typedef _fpos64_t fpos64_t;
|
|||
#define _IOLBF 1 /* setvbuf should set line buffered */
|
||||
#define _IONBF 2 /* setvbuf should set unbuffered */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define EOF (-1)
|
||||
|
||||
#ifdef __BUFSIZ__
|
||||
|
@ -142,15 +139,9 @@ typedef _fpos64_t fpos64_t;
|
|||
|
||||
#define TMP_MAX 26
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
#define stdin (_REENT->_stdin)
|
||||
#define stdout (_REENT->_stdout)
|
||||
#define stderr (_REENT->_stderr)
|
||||
#else /* _REENT_ONLY */
|
||||
#define stdin (_impure_ptr->_stdin)
|
||||
#define stdout (_impure_ptr->_stdout)
|
||||
#define stderr (_impure_ptr->_stderr)
|
||||
#endif /* _REENT_ONLY */
|
||||
|
||||
#define _stdin_r(x) ((x)->_stdin)
|
||||
#define _stdout_r(x) ((x)->_stdout)
|
||||
|
@ -172,29 +163,29 @@ FILE * _EXFUN(tmpfile, (void));
|
|||
char * _EXFUN(tmpnam, (char *));
|
||||
int _EXFUN(fclose, (FILE *));
|
||||
int _EXFUN(fflush, (FILE *));
|
||||
FILE * _EXFUN(freopen, (const char *, const char *, FILE *));
|
||||
void _EXFUN(setbuf, (FILE *, char *));
|
||||
int _EXFUN(setvbuf, (FILE *, char *, int, size_t));
|
||||
int _EXFUN(fprintf, (FILE *, const char *, ...)
|
||||
FILE * _EXFUN(freopen, (const char *__restrict, const char *__restrict, FILE *__restrict));
|
||||
void _EXFUN(setbuf, (FILE *__restrict, char *__restrict));
|
||||
int _EXFUN(setvbuf, (FILE *__restrict, char *__restrict, int, size_t));
|
||||
int _EXFUN(fprintf, (FILE *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
int _EXFUN(fscanf, (FILE *, const char *, ...)
|
||||
int _EXFUN(fscanf, (FILE *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
|
||||
int _EXFUN(printf, (const char *, ...)
|
||||
int _EXFUN(printf, (const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 1, 2))));
|
||||
int _EXFUN(scanf, (const char *, ...)
|
||||
int _EXFUN(scanf, (const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 1, 2))));
|
||||
int _EXFUN(sscanf, (const char *, const char *, ...)
|
||||
int _EXFUN(sscanf, (const char *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
|
||||
int _EXFUN(vfprintf, (FILE *, const char *, __VALIST)
|
||||
int _EXFUN(vfprintf, (FILE *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(vprintf, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 1, 0))));
|
||||
int _EXFUN(vsprintf, (char *, const char *, __VALIST)
|
||||
int _EXFUN(vsprintf, (char *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(fgetc, (FILE *));
|
||||
char * _EXFUN(fgets, (char *, int, FILE *));
|
||||
char * _EXFUN(fgets, (char *__restrict, int, FILE *__restrict));
|
||||
int _EXFUN(fputc, (int, FILE *));
|
||||
int _EXFUN(fputs, (const char *, FILE *));
|
||||
int _EXFUN(fputs, (const char *__restrict, FILE *__restrict));
|
||||
int _EXFUN(getc, (FILE *));
|
||||
int _EXFUN(getchar, (void));
|
||||
char * _EXFUN(gets, (char *));
|
||||
|
@ -202,12 +193,12 @@ int _EXFUN(putc, (int, FILE *));
|
|||
int _EXFUN(putchar, (int));
|
||||
int _EXFUN(puts, (const char *));
|
||||
int _EXFUN(ungetc, (int, FILE *));
|
||||
size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));
|
||||
size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));
|
||||
size_t _EXFUN(fread, (_PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
|
||||
size_t _EXFUN(fwrite, (const _PTR __restrict , size_t _size, size_t _n, FILE *));
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(fgetpos, (FILE *, _fpos_t *));
|
||||
#else
|
||||
int _EXFUN(fgetpos, (FILE *, fpos_t *));
|
||||
int _EXFUN(fgetpos, (FILE *__restrict, fpos_t *__restrict));
|
||||
#endif
|
||||
int _EXFUN(fseek, (FILE *, long, int));
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
|
@ -222,11 +213,14 @@ int _EXFUN(feof, (FILE *));
|
|||
int _EXFUN(ferror, (FILE *));
|
||||
void _EXFUN(perror, (const char *));
|
||||
#ifndef _REENT_ONLY
|
||||
FILE * _EXFUN(fopen, (const char *_name, const char *_type));
|
||||
int _EXFUN(sprintf, (char *, const char *, ...)
|
||||
FILE * _EXFUN(fopen, (const char *__restrict _name, const char *__restrict _type));
|
||||
int _EXFUN(sprintf, (char *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
int _EXFUN(remove, (const char *));
|
||||
int _EXFUN(rename, (const char *, const char *));
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(_rename, (const char *, const char *));
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K)
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
|
@ -243,9 +237,9 @@ int _EXFUN(asiprintf, (char **, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
char * _EXFUN(asnprintf, (char *, size_t *, const char *, ...)
|
||||
char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(asprintf, (char **, const char *, ...)
|
||||
int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
#ifndef diprintf
|
||||
int _EXFUN(diprintf, (int, const char *, ...)
|
||||
|
@ -264,7 +258,7 @@ int _EXFUN(siprintf, (char *, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
int _EXFUN(siscanf, (const char *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
|
||||
int _EXFUN(snprintf, (char *, size_t, const char *, ...)
|
||||
int _EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
|
@ -283,7 +277,7 @@ int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(vfscanf, (FILE *, const char *, __VALIST)
|
||||
int _EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(viprintf, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 1, 0))));
|
||||
|
@ -297,9 +291,9 @@ int _EXFUN(vsiscanf, (const char *, const char *, __VALIST)
|
|||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST)
|
||||
int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(vsscanf, (const char *, const char *, __VALIST)
|
||||
int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
#endif /* !_REENT_ONLY */
|
||||
#endif /* !__STRICT_ANSI__ */
|
||||
|
@ -335,17 +329,17 @@ int _EXFUN(putchar_unlocked, (int));
|
|||
#ifndef __STRICT_ANSI__
|
||||
# ifndef _REENT_ONLY
|
||||
# ifndef dprintf
|
||||
int _EXFUN(dprintf, (int, const char *, ...)
|
||||
int _EXFUN(dprintf, (int, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
# endif
|
||||
FILE * _EXFUN(fmemopen, (void *, size_t, const char *));
|
||||
FILE * _EXFUN(fmemopen, (void *__restrict, size_t, const char *__restrict));
|
||||
/* getdelim - see __getdelim for now */
|
||||
/* getline - see __getline for now */
|
||||
FILE * _EXFUN(open_memstream, (char **, size_t *));
|
||||
#if defined (__CYGWIN__)
|
||||
int _EXFUN(renameat, (int, const char *, int, const char *));
|
||||
#endif
|
||||
int _EXFUN(vdprintf, (int, const char *, __VALIST)
|
||||
int _EXFUN(vdprintf, (int, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
# endif
|
||||
#endif
|
||||
|
@ -358,22 +352,22 @@ int _EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
char * _EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 4, 5))));
|
||||
char * _EXFUN(_asnprintf_r, (struct _reent *, char *, size_t *, const char *, ...)
|
||||
char * _EXFUN(_asnprintf_r, (struct _reent *, char *__restrict, size_t *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 4, 5))));
|
||||
int _EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...)
|
||||
int _EXFUN(_asprintf_r, (struct _reent *, char **__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...)
|
||||
int _EXFUN(_dprintf_r, (struct _reent *, int, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(_fclose_r, (struct _reent *, FILE *));
|
||||
int _EXFUN(_fcloseall_r, (struct _reent *));
|
||||
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));
|
||||
int _EXFUN(_fflush_r, (struct _reent *, FILE *));
|
||||
int _EXFUN(_fgetc_r, (struct _reent *, FILE *));
|
||||
char * _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *));
|
||||
char * _EXFUN(_fgets_r, (struct _reent *, char *__restrict, int, FILE *__restrict));
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, _fpos_t *));
|
||||
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *__restrict, _fpos_t *__restrict));
|
||||
int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *));
|
||||
#else
|
||||
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, fpos_t *));
|
||||
|
@ -383,23 +377,23 @@ int _EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
|
||||
FILE * _EXFUN(_fmemopen_r, (struct _reent *, void *, size_t, const char *));
|
||||
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
|
||||
FILE * _EXFUN(_freopen_r, (struct _reent *, const char *, const char *, FILE *));
|
||||
int _EXFUN(_fprintf_r, (struct _reent *, FILE *, const char *, ...)
|
||||
FILE * _EXFUN(_fmemopen_r, (struct _reent *, void *__restrict, size_t, const char *__restrict));
|
||||
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *__restrict, const char *__restrict));
|
||||
FILE * _EXFUN(_freopen_r, (struct _reent *, const char *__restrict, const char *__restrict, FILE *__restrict));
|
||||
int _EXFUN(_fprintf_r, (struct _reent *, FILE *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(_fpurge_r, (struct _reent *, FILE *));
|
||||
int _EXFUN(_fputc_r, (struct _reent *, int, FILE *));
|
||||
int _EXFUN(_fputs_r, (struct _reent *, const char *, FILE *));
|
||||
size_t _EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *));
|
||||
int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...)
|
||||
int _EXFUN(_fputs_r, (struct _reent *, const char *__restrict, FILE *__restrict));
|
||||
size_t _EXFUN(_fread_r, (struct _reent *, _PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
|
||||
int _EXFUN(_fscanf_r, (struct _reent *, FILE *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
|
||||
int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int));
|
||||
int _EXFUN(_fseeko_r,(struct _reent *, FILE *, _off_t, int));
|
||||
long _EXFUN(_ftell_r, (struct _reent *, FILE *));
|
||||
_off_t _EXFUN(_ftello_r,(struct _reent *, FILE *));
|
||||
void _EXFUN(_rewind_r, (struct _reent *, FILE *));
|
||||
size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *));
|
||||
size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR __restrict, size_t _size, size_t _n, FILE *__restrict));
|
||||
int _EXFUN(_getc_r, (struct _reent *, FILE *));
|
||||
int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *));
|
||||
int _EXFUN(_getchar_r, (struct _reent *));
|
||||
|
@ -411,7 +405,7 @@ int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
|
||||
FILE * _EXFUN(_open_memstream_r, (struct _reent *, char **, size_t *));
|
||||
void _EXFUN(_perror_r, (struct _reent *, const char *));
|
||||
int _EXFUN(_printf_r, (struct _reent *, const char *, ...)
|
||||
int _EXFUN(_printf_r, (struct _reent *, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
|
||||
int _EXFUN(_putc_r, (struct _reent *, int, FILE *));
|
||||
int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *));
|
||||
|
@ -421,7 +415,7 @@ int _EXFUN(_puts_r, (struct _reent *, const char *));
|
|||
int _EXFUN(_remove_r, (struct _reent *, const char *));
|
||||
int _EXFUN(_rename_r, (struct _reent *,
|
||||
const char *_old, const char *_new));
|
||||
int _EXFUN(_scanf_r, (struct _reent *, const char *, ...)
|
||||
int _EXFUN(_scanf_r, (struct _reent *, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
|
||||
int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
|
@ -429,11 +423,11 @@ int _EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...)
|
|||
_ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
|
||||
int _EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 4, 5))));
|
||||
int _EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...)
|
||||
int _EXFUN(_snprintf_r, (struct _reent *, char *__restrict, size_t, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 4, 5))));
|
||||
int _EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...)
|
||||
int _EXFUN(_sprintf_r, (struct _reent *, char *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
|
||||
int _EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...)
|
||||
int _EXFUN(_sscanf_r, (struct _reent *, const char *__restrict, const char *__restrict, ...)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
|
||||
char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *));
|
||||
FILE * _EXFUN(_tmpfile_r, (struct _reent *));
|
||||
|
@ -449,23 +443,23 @@ int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST)
|
|||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST)
|
||||
int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
|
||||
int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST)
|
||||
int _EXFUN(_vfprintf_r, (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(_vfscanf_r, (struct _reent *, FILE *, const char *, __VALIST)
|
||||
int _EXFUN(_vfscanf_r, (struct _reent *, FILE *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
|
||||
int _EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST)
|
||||
int _EXFUN(_vprintf_r, (struct _reent *, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
|
||||
int _EXFUN(_vscanf_r, (struct _reent *, const char *, __VALIST)
|
||||
int _EXFUN(_vscanf_r, (struct _reent *, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
|
||||
int _EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
|
@ -473,11 +467,11 @@ int _EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST)
|
|||
_ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
|
||||
int _EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 4, 0))));
|
||||
int _EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST)
|
||||
int _EXFUN(_vsnprintf_r, (struct _reent *, char *__restrict, size_t, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 4, 0))));
|
||||
int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST)
|
||||
int _EXFUN(_vsprintf_r, (struct _reent *, char *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
|
||||
int _EXFUN(_vsscanf_r, (struct _reent *, const char *, const char *, __VALIST)
|
||||
int _EXFUN(_vsscanf_r, (struct _reent *, const char *__restrict, const char *__restrict, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
|
||||
|
||||
/* Other extensions. */
|
||||
|
@ -522,24 +516,32 @@ int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
|
|||
#ifndef __STRICT_ANSI__
|
||||
# ifdef __LARGE64_FILES
|
||||
FILE *_EXFUN(funopen,(const _PTR __cookie,
|
||||
int (*__readfn)(_PTR __c, char *__buf, int __n),
|
||||
int (*__writefn)(_PTR __c, const char *__buf, int __n),
|
||||
int (*__readfn)(_PTR __c, char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
int (*__writefn)(_PTR __c, const char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence),
|
||||
int (*__closefn)(_PTR __c)));
|
||||
FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
|
||||
int (*__readfn)(_PTR __c, char *__buf, int __n),
|
||||
int (*__writefn)(_PTR __c, const char *__buf, int __n),
|
||||
int (*__readfn)(_PTR __c, char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
int (*__writefn)(_PTR __c, const char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence),
|
||||
int (*__closefn)(_PTR __c)));
|
||||
# else
|
||||
FILE *_EXFUN(funopen,(const _PTR __cookie,
|
||||
int (*__readfn)(_PTR __cookie, char *__buf, int __n),
|
||||
int (*__writefn)(_PTR __cookie, const char *__buf, int __n),
|
||||
int (*__readfn)(_PTR __cookie, char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
int (*__writefn)(_PTR __cookie, const char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence),
|
||||
int (*__closefn)(_PTR __cookie)));
|
||||
FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
|
||||
int (*__readfn)(_PTR __cookie, char *__buf, int __n),
|
||||
int (*__writefn)(_PTR __cookie, const char *__buf, int __n),
|
||||
int (*__readfn)(_PTR __cookie, char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
int (*__writefn)(_PTR __cookie, const char *__buf,
|
||||
_READ_WRITE_BUFSIZE_TYPE __n),
|
||||
fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence),
|
||||
int (*__closefn)(_PTR __cookie)));
|
||||
# endif /* !__LARGE64_FILES */
|
||||
|
|
|
@ -17,6 +17,47 @@ _BEGIN_STD_C
|
|||
|
||||
void _EXFUN(__fpurge,(FILE *));
|
||||
|
||||
/* TODO:
|
||||
|
||||
void _flushlbf (void);
|
||||
int __fsetlocking (FILE *__fp, int __type);
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
_ELIDABLE_INLINE inline size_t
|
||||
__fbufsize (FILE *__fp) { return (size_t) __fp->_bf._size; }
|
||||
|
||||
_ELIDABLE_INLINE inline int
|
||||
__freading (FILE *__fp) { return (__fp->_flags & __SRD) != 0; }
|
||||
|
||||
_ELIDABLE_INLINE inline int
|
||||
__fwriting (FILE *__fp) { return (__fp->_flags & __SWR) != 0; }
|
||||
|
||||
_ELIDABLE_INLINE inline int
|
||||
__freadable (FILE *__fp) { return (__fp->_flags & (__SRD | __SRW)) != 0; }
|
||||
|
||||
_ELIDABLE_INLINE inline int
|
||||
__fwriteable (FILE *__fp) { return (__fp->_flags & (__SWR | __SRW)) != 0; }
|
||||
|
||||
_ELIDABLE_INLINE inline int
|
||||
__flbf (FILE *__fp) { return (__fp->_flags & __SLBF) != 0; }
|
||||
|
||||
_ELIDABLE_INLINE inline size_t
|
||||
__fpending (FILE *__fp) { return __fp->_p - __fp->_bf._base; }
|
||||
|
||||
#else
|
||||
|
||||
#define __fbufsize(__fp) ((size_t) (__fp)->_bf._size)
|
||||
#define __freading(__fp) (((__fp)->_flags & __SRD) != 0)
|
||||
#define __fwriting(__fp) (((__fp)->_flags & __SWR) != 0)
|
||||
#define __freadable(__fp) (((__fp)->_flags & (__SRD | __SRW)) != 0)
|
||||
#define __fwriteable(__fp) (((__fp)->_flags & (__SWR | __SRW)) != 0)
|
||||
#define __flbf(__fp) (((__fp)->_flags & __SLBF) != 0)
|
||||
#define __fpending(__fp) ((size_t) ((__fp)->_p - (__fp)->_bf._base))
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
_END_STD_C
|
||||
|
||||
#endif /* _STDIO_EXT_H_ */
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/reent.h>
|
||||
|
@ -38,7 +39,9 @@ typedef struct
|
|||
long rem; /* remainder */
|
||||
} ldiv_t;
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if !defined(__STRICT_ANSI__) || \
|
||||
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
|
||||
(defined(__cplusplus) && __cplusplus >= 201103L)
|
||||
typedef struct
|
||||
{
|
||||
long long int quot; /* quotient */
|
||||
|
@ -46,8 +49,9 @@ typedef struct
|
|||
} lldiv_t;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#ifndef __compar_fn_t_defined
|
||||
#define __compar_fn_t_defined
|
||||
typedef int (*__compar_fn_t) (const _PTR, const _PTR);
|
||||
#endif
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
|
@ -74,7 +78,7 @@ _PTR _EXFUN(bsearch,(const _PTR __key,
|
|||
const _PTR __base,
|
||||
size_t __nmemb,
|
||||
size_t __size,
|
||||
int _EXFNPTR(_compar,(const _PTR, const _PTR))));
|
||||
__compar_fn_t _compar));
|
||||
_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size));
|
||||
div_t _EXFUN(div,(int __numer, int __denom));
|
||||
_VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn)));
|
||||
|
@ -92,14 +96,14 @@ ldiv_t _EXFUN(ldiv,(long __numer, long __denom));
|
|||
_PTR _EXFUN_NOTHROW(malloc,(size_t __size));
|
||||
int _EXFUN(mblen,(const char *, size_t));
|
||||
int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *));
|
||||
int _EXFUN(mbtowc,(wchar_t *, const char *, size_t));
|
||||
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
|
||||
int _EXFUN(mbtowc,(wchar_t *__restrict, const char *__restrict, size_t));
|
||||
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
|
||||
int _EXFUN(wctomb,(char *, wchar_t));
|
||||
int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *));
|
||||
size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t));
|
||||
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
|
||||
size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t));
|
||||
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *));
|
||||
size_t _EXFUN(mbstowcs,(wchar_t *__restrict, const char *__restrict, size_t));
|
||||
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
|
||||
size_t _EXFUN(wcstombs,(char *__restrict, const wchar_t *__restrict, size_t));
|
||||
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *__restrict, const wchar_t *__restrict, size_t, _mbstate_t *));
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifndef _REENT_ONLY
|
||||
char * _EXFUN(mkdtemp,(char *));
|
||||
|
@ -116,26 +120,29 @@ int _EXFUN(_mkstemp_r, (struct _reent *, char *));
|
|||
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int));
|
||||
char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
|
||||
#endif
|
||||
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
|
||||
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
|
||||
int _EXFUN(rand,(_VOID));
|
||||
_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
|
||||
#ifndef __STRICT_ANSI__
|
||||
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
|
||||
char * _EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_path));
|
||||
#endif
|
||||
_VOID _EXFUN(srand,(unsigned __seed));
|
||||
double _EXFUN(strtod,(const char *__n, char **__end_PTR));
|
||||
double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR));
|
||||
float _EXFUN(strtof,(const char *__n, char **__end_PTR));
|
||||
double _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
|
||||
double _EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
|
||||
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
|
||||
float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
|
||||
#endif
|
||||
#ifndef __STRICT_ANSI__
|
||||
/* the following strtodf interface is deprecated...use strtof instead */
|
||||
# ifndef strtodf
|
||||
# define strtodf strtof
|
||||
# endif
|
||||
#endif
|
||||
long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base));
|
||||
long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base));
|
||||
unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base));
|
||||
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base));
|
||||
long _EXFUN(strtol,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
long _EXFUN(_strtol_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
unsigned long _EXFUN(strtoul,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
|
||||
int _EXFUN(system,(const char *__string));
|
||||
|
||||
|
@ -186,10 +193,18 @@ long long _EXFUN(atoll,(const char *__nptr));
|
|||
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
|
||||
long long _EXFUN(llabs,(long long));
|
||||
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
|
||||
long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base));
|
||||
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base));
|
||||
unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base));
|
||||
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base));
|
||||
#endif /* ! __STRICT_ANSI__ */
|
||||
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
|
||||
long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
#endif
|
||||
#ifndef __STRICT_ANSI__
|
||||
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
#endif /* ! __STRICT_ANSI__ */
|
||||
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
|
||||
unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
#endif
|
||||
#ifndef __STRICT_ANSI__
|
||||
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
_VOID _EXFUN(cfree,(_PTR));
|
||||
|
@ -217,8 +232,9 @@ _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *))
|
|||
|
||||
/* On platforms where long double equals double. */
|
||||
#ifdef _LDBL_EQ_DBL
|
||||
extern long double strtold (const char *, char **);
|
||||
extern long double wcstold (const wchar_t *, wchar_t **);
|
||||
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
|
||||
extern long double strtold (const char *__restrict, char **__restrict);
|
||||
#endif
|
||||
#endif /* _LDBL_EQ_DBL */
|
||||
|
||||
_END_STD_C
|
||||
|
|
|
@ -10,63 +10,71 @@
|
|||
#include "_ansi.h"
|
||||
#include <sys/reent.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/features.h>
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
_BEGIN_STD_C
|
||||
|
||||
_PTR _EXFUN(memchr,(const _PTR, int, size_t));
|
||||
int _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
|
||||
_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t));
|
||||
_PTR _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t));
|
||||
_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t));
|
||||
_PTR _EXFUN(memset,(_PTR, int, size_t));
|
||||
char *_EXFUN(strcat,(char *, const char *));
|
||||
char *_EXFUN(strcat,(char *__restrict, const char *__restrict));
|
||||
char *_EXFUN(strchr,(const char *, int));
|
||||
int _EXFUN(strcmp,(const char *, const char *));
|
||||
int _EXFUN(strcoll,(const char *, const char *));
|
||||
char *_EXFUN(strcpy,(char *, const char *));
|
||||
char *_EXFUN(strcpy,(char *__restrict, const char *__restrict));
|
||||
size_t _EXFUN(strcspn,(const char *, const char *));
|
||||
char *_EXFUN(strerror,(int));
|
||||
size_t _EXFUN(strlen,(const char *));
|
||||
char *_EXFUN(strncat,(char *, const char *, size_t));
|
||||
char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t));
|
||||
int _EXFUN(strncmp,(const char *, const char *, size_t));
|
||||
char *_EXFUN(strncpy,(char *, const char *, size_t));
|
||||
char *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t));
|
||||
char *_EXFUN(strpbrk,(const char *, const char *));
|
||||
char *_EXFUN(strrchr,(const char *, int));
|
||||
size_t _EXFUN(strspn,(const char *, const char *));
|
||||
char *_EXFUN(strstr,(const char *, const char *));
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
char *_EXFUN(strtok,(char *, const char *));
|
||||
char *_EXFUN(strtok,(char *__restrict, const char *__restrict));
|
||||
#endif
|
||||
|
||||
size_t _EXFUN(strxfrm,(char *, const char *, size_t));
|
||||
size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
char *_EXFUN(strtok_r,(char *, const char *, char **));
|
||||
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
|
||||
|
||||
int _EXFUN(bcmp,(const void *, const void *, size_t));
|
||||
void _EXFUN(bcopy,(const void *, void *, size_t));
|
||||
void _EXFUN(bzero,(void *, size_t));
|
||||
int _EXFUN(ffs,(int));
|
||||
char *_EXFUN(index,(const char *, int));
|
||||
_PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t));
|
||||
_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
|
||||
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
|
||||
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
|
||||
_PTR _EXFUN(memrchr,(const _PTR, int, size_t));
|
||||
_PTR _EXFUN(rawmemchr,(const _PTR, int));
|
||||
char *_EXFUN(rindex,(const char *, int));
|
||||
char *_EXFUN(stpcpy,(char *, const char *));
|
||||
char *_EXFUN(stpncpy,(char *, const char *, size_t));
|
||||
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
|
||||
char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
|
||||
int _EXFUN(strcasecmp,(const char *, const char *));
|
||||
char *_EXFUN(strcasestr,(const char *, const char *));
|
||||
char *_EXFUN(strchrnul,(const char *, int));
|
||||
#endif
|
||||
#if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE - 0) >= 500
|
||||
char *_EXFUN(strdup,(const char *));
|
||||
#endif
|
||||
#ifndef __STRICT_ANSI__
|
||||
char *_EXFUN(_strdup_r,(struct _reent *, const char *));
|
||||
#endif
|
||||
#if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE - 0) >= 700
|
||||
char *_EXFUN(strndup,(const char *, size_t));
|
||||
#endif
|
||||
#ifndef __STRICT_ANSI__
|
||||
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
|
||||
/* There are two common strerror_r variants. If you request
|
||||
_GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
|
||||
|
|
|
@ -42,15 +42,6 @@ extern "C" {
|
|||
/* O_NDELAY _FNBIO set in include/fcntl.h */
|
||||
#define O_NONBLOCK _FNONBLOCK
|
||||
#define O_NOCTTY _FNOCTTY
|
||||
|
||||
#define _FBINARY 0x10000
|
||||
#define _FTEXT 0x20000
|
||||
#define _FNOINHERIT 0x40000
|
||||
|
||||
#define O_BINARY _FBINARY
|
||||
#define O_TEXT _FTEXT
|
||||
#define O_NOINHERIT _FNOINHERIT
|
||||
|
||||
/* For machines which care - */
|
||||
#if defined (_WIN32) || defined (__CYGWIN__)
|
||||
#define _FBINARY 0x10000
|
||||
|
|
|
@ -16,14 +16,9 @@
|
|||
typedef long _off_t;
|
||||
#endif
|
||||
|
||||
#if defined(__rtems__)
|
||||
/* device numbers are 32-bit major and and 32-bit minor */
|
||||
typedef unsigned long long __dev_t;
|
||||
#else
|
||||
#ifndef __dev_t_defined
|
||||
typedef short __dev_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __uid_t_defined
|
||||
typedef unsigned short __uid_t;
|
||||
|
@ -52,12 +47,21 @@ typedef _off64_t _fpos64_t;
|
|||
#endif
|
||||
|
||||
#ifndef __ssize_t_defined
|
||||
#ifdef __SIZE_TYPE__
|
||||
/* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.
|
||||
We simply change "unsigned" to "signed" for this single definition
|
||||
to make sure ssize_t and size_t only differ by their signedness. */
|
||||
#define unsigned signed
|
||||
typedef __SIZE_TYPE__ _ssize_t;
|
||||
#undef unsigned
|
||||
#else
|
||||
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
|
||||
typedef int _ssize_t;
|
||||
#else
|
||||
typedef long _ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define __need_wint_t
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* Written 2000 by Werner Almesberger */
|
||||
|
||||
/*
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
|
@ -17,10 +17,6 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
|
@ -38,43 +34,20 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)cdefs.h 8.8 (Berkeley) 1/9/95
|
||||
* $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _SYS_CDEFS_H
|
||||
#define _SYS_CDEFS_H
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#define _SYS_CDEFS_H_
|
||||
|
||||
#define __FBSDID(x) /* nothing */
|
||||
/*
|
||||
* Note: the goal here is not compatibility to K&R C. Since we know that we
|
||||
* have GCC which understands ANSI C perfectly well, we make use of this.
|
||||
*/
|
||||
#include <machine/_default_types.h>
|
||||
#include <sys/features.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define __P(args) args
|
||||
#define __PMT(args) args
|
||||
#define __const const
|
||||
#define __signed signed
|
||||
#define __volatile volatile
|
||||
#define __DOTS , ...
|
||||
#define __THROW
|
||||
|
||||
/*
|
||||
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
|
||||
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
|
||||
* The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
|
||||
* mode -- there must be no spaces between its arguments, and for nested
|
||||
* __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
|
||||
* concatenate double-quoted strings produced by the __STRING macro, but
|
||||
* this only works with ANSI C.
|
||||
*
|
||||
* __XSTRING is like __STRING, but it expands any macros in its argument
|
||||
* first. It is only available with ANSI C.
|
||||
*/
|
||||
#define __CONCAT1(x,y) x ## y
|
||||
#define __CONCAT(x,y) __CONCAT1(x,y)
|
||||
#define __STRING(x) #x /* stringify without expanding x */
|
||||
#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define __ASMNAME(cname) __XSTRING (__USER_LABEL_PREFIX__) cname
|
||||
#endif
|
||||
|
@ -87,23 +60,452 @@
|
|||
#define __attribute_format_strfmon__(a,b)
|
||||
#define __flexarr [0]
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
#else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
#endif
|
||||
|
||||
#ifndef __BOUNDED_POINTERS__
|
||||
# define __bounded /* nothing */
|
||||
# define __unbounded /* nothing */
|
||||
# define __ptrvalue /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
/*
|
||||
* Testing against Clang-specific extensions.
|
||||
*/
|
||||
|
||||
#ifndef __has_extension
|
||||
#define __has_extension __has_feature
|
||||
#endif
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
#ifndef __has_include
|
||||
#define __has_include(x) 0
|
||||
#endif
|
||||
#ifndef __has_builtin
|
||||
#define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This code has been put in place to help reduce the addition of
|
||||
* compiler specific defines in FreeBSD code. It helps to aid in
|
||||
* having a compiler-agnostic source tree.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
|
||||
#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
|
||||
#define __GNUCLIKE_ASM 3
|
||||
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
|
||||
#else
|
||||
#define __GNUCLIKE_ASM 2
|
||||
#endif
|
||||
#define __GNUCLIKE___TYPEOF 1
|
||||
#define __GNUCLIKE___OFFSETOF 1
|
||||
#define __GNUCLIKE___SECTION 1
|
||||
|
||||
#ifndef __INTEL_COMPILER
|
||||
# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
|
||||
#endif
|
||||
|
||||
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
|
||||
# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
|
||||
&& __INTEL_COMPILER < 800
|
||||
# undef __GNUCLIKE_BUILTIN_CONSTANT_P
|
||||
# endif
|
||||
|
||||
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
|
||||
# define __GNUCLIKE_BUILTIN_VARARGS 1
|
||||
# define __GNUCLIKE_BUILTIN_STDARG 1
|
||||
# define __GNUCLIKE_BUILTIN_VAALIST 1
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define __GNUC_VA_LIST_COMPATIBILITY 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compiler memory barriers, specific to gcc and clang.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#define __compiler_membar() __asm __volatile(" " : : : "memory")
|
||||
#endif
|
||||
|
||||
#ifndef __INTEL_COMPILER
|
||||
# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
|
||||
# define __GNUCLIKE_MATH_BUILTIN_RELOPS
|
||||
#endif
|
||||
|
||||
#define __GNUCLIKE_BUILTIN_MEMCPY 1
|
||||
|
||||
/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
|
||||
#define __CC_SUPPORTS_INLINE 1
|
||||
#define __CC_SUPPORTS___INLINE 1
|
||||
#define __CC_SUPPORTS___INLINE__ 1
|
||||
|
||||
#define __CC_SUPPORTS___FUNC__ 1
|
||||
#define __CC_SUPPORTS_WARNING 1
|
||||
|
||||
#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
|
||||
|
||||
#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
|
||||
|
||||
#endif /* __GNUC__ || __INTEL_COMPILER */
|
||||
|
||||
/*
|
||||
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
|
||||
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
|
||||
* The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
|
||||
* mode -- there must be no spaces between its arguments, and for nested
|
||||
* __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
|
||||
* concatenate double-quoted strings produced by the __STRING macro, but
|
||||
* this only works with ANSI C.
|
||||
*
|
||||
* __XSTRING is like __STRING, but it expands any macros in its argument
|
||||
* first. It is only available with ANSI C.
|
||||
*/
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define __P(protos) protos /* full-blown ANSI C */
|
||||
#define __CONCAT1(x,y) x ## y
|
||||
#define __CONCAT(x,y) __CONCAT1(x,y)
|
||||
#define __STRING(x) #x /* stringify without expanding x */
|
||||
#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
|
||||
|
||||
#define __const const /* define reserved names to standard */
|
||||
#define __signed signed
|
||||
#define __volatile volatile
|
||||
#if defined(__cplusplus)
|
||||
#define __inline inline /* convert to C++ keyword */
|
||||
#else
|
||||
#if !(defined(__CC_SUPPORTS___INLINE))
|
||||
#define __inline /* delete GCC keyword */
|
||||
#endif /* ! __CC_SUPPORTS___INLINE */
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#else /* !(__STDC__ || __cplusplus) */
|
||||
#define __P(protos) () /* traditional C preprocessor */
|
||||
#define __CONCAT(x,y) x/**/y
|
||||
#define __STRING(x) "x"
|
||||
|
||||
#if !defined(__CC_SUPPORTS___INLINE)
|
||||
#define __const /* delete pseudo-ANSI C keywords */
|
||||
#define __inline
|
||||
#define __signed
|
||||
#define __volatile
|
||||
/*
|
||||
* In non-ANSI C environments, new programs will want ANSI-only C keywords
|
||||
* deleted from the program and old programs will want them left alone.
|
||||
* When using a compiler other than gcc, programs using the ANSI C keywords
|
||||
* const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
|
||||
* When using "gcc -traditional", we assume that this is the intent; if
|
||||
* __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
|
||||
*/
|
||||
#ifndef NO_ANSI_KEYWORDS
|
||||
#define const /* delete ANSI C keywords */
|
||||
#define inline
|
||||
#define signed
|
||||
#define volatile
|
||||
#endif /* !NO_ANSI_KEYWORDS */
|
||||
#endif /* !__CC_SUPPORTS___INLINE */
|
||||
#endif /* !(__STDC__ || __cplusplus) */
|
||||
|
||||
/*
|
||||
* Compiler-dependent macros to help declare dead (non-returning) and
|
||||
* pure (no side effects) functions, and unused variables. They are
|
||||
* null except for versions of gcc that are known to support the features
|
||||
* properly (old versions of gcc-2 supported the dead and pure features
|
||||
* in a different (wrong) way). If we do not provide an implementation
|
||||
* for a given compiler, let the compile fail if it is told to use
|
||||
* a feature that we cannot live without.
|
||||
*/
|
||||
#ifdef lint
|
||||
#define __dead2
|
||||
#define __pure2
|
||||
#define __unused
|
||||
#define __packed
|
||||
#define __aligned(x)
|
||||
#define __section(x)
|
||||
#else
|
||||
#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
|
||||
#define __dead2
|
||||
#define __pure2
|
||||
#define __unused
|
||||
#endif
|
||||
#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
|
||||
#define __dead2 __attribute__((__noreturn__))
|
||||
#define __pure2 __attribute__((__const__))
|
||||
#define __unused
|
||||
/* XXX Find out what to do for __packed, __aligned and __section */
|
||||
#endif
|
||||
#if __GNUC_PREREQ__(2, 7)
|
||||
#define __dead2 __attribute__((__noreturn__))
|
||||
#define __pure2 __attribute__((__const__))
|
||||
#define __unused __attribute__((__unused__))
|
||||
#define __used __attribute__((__used__))
|
||||
#define __packed __attribute__((__packed__))
|
||||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#define __section(x) __attribute__((__section__(x)))
|
||||
#endif
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define __dead2 __attribute__((__noreturn__))
|
||||
#define __pure2 __attribute__((__const__))
|
||||
#define __unused __attribute__((__unused__))
|
||||
#define __used __attribute__((__used__))
|
||||
#define __packed __attribute__((__packed__))
|
||||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#define __section(x) __attribute__((__section__(x)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !__GNUC_PREREQ__(2, 95)
|
||||
#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Keywords added in C11.
|
||||
*/
|
||||
|
||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
|
||||
|
||||
#if !__has_extension(c_alignas)
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||
__has_extension(cxx_alignas)
|
||||
#define _Alignas(x) alignas(x)
|
||||
#else
|
||||
/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
|
||||
#define _Alignas(x) __aligned(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||
#define _Alignof(x) alignof(x)
|
||||
#else
|
||||
#define _Alignof(x) __alignof(x)
|
||||
#endif
|
||||
|
||||
#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
|
||||
/*
|
||||
* No native support for _Atomic(). Place object in structure to prevent
|
||||
* most forms of direct non-atomic access.
|
||||
*/
|
||||
#define _Atomic(T) struct { T volatile __val; }
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||
#define _Noreturn [[noreturn]]
|
||||
#else
|
||||
#define _Noreturn __dead2
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus)
|
||||
/* Do nothing: _Static_assert() works as per C11 */
|
||||
#elif !__has_extension(c_static_assert)
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||
__has_extension(cxx_static_assert)
|
||||
#define _Static_assert(x, y) static_assert(x, y)
|
||||
#elif defined(__COUNTER__)
|
||||
#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
|
||||
#define __Static_assert(x, y) ___Static_assert(x, y)
|
||||
#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1]
|
||||
#else
|
||||
#define _Static_assert(x, y) struct __hack
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !__has_extension(c_thread_local)
|
||||
/* XXX: Change this to test against C++11 when clang in base supports it. */
|
||||
#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
|
||||
__has_extension(cxx_thread_local)
|
||||
#define _Thread_local thread_local
|
||||
#else
|
||||
#define _Thread_local __thread
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
|
||||
|
||||
/*
|
||||
* Emulation of C11 _Generic(). Unlike the previously defined C11
|
||||
* keywords, it is not possible to implement this using exactly the same
|
||||
* syntax. Therefore implement something similar under the name
|
||||
* __generic(). Unlike _Generic(), this macro can only distinguish
|
||||
* between a single type, so it requires nested invocations to
|
||||
* distinguish multiple cases.
|
||||
*/
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
#define __generic(expr, t, yes, no) \
|
||||
_Generic(expr, t: yes, default: no)
|
||||
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
|
||||
#define __generic(expr, t, yes, no) \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(expr), t), yes, no)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(2, 96)
|
||||
#define __malloc_like __attribute__((__malloc__))
|
||||
#define __pure __attribute__((__pure__))
|
||||
#else
|
||||
#define __malloc_like
|
||||
#define __pure
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
|
||||
#define __always_inline __attribute__((__always_inline__))
|
||||
#else
|
||||
#define __always_inline
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 1)
|
||||
#define __noinline __attribute__ ((__noinline__))
|
||||
#else
|
||||
#define __noinline
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 3)
|
||||
#define __nonnull(x) __attribute__((__nonnull__(x)))
|
||||
#else
|
||||
#define __nonnull(x)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 4)
|
||||
#define __fastcall __attribute__((__fastcall__))
|
||||
#else
|
||||
#define __fastcall
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 1)
|
||||
#define __returns_twice __attribute__((__returns_twice__))
|
||||
#else
|
||||
#define __returns_twice
|
||||
#endif
|
||||
|
||||
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
|
||||
#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
|
||||
#define __func__ NULL
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GCC 2.95 provides `__restrict' as an extension to C90 to support the
|
||||
* C99-specific `restrict' type qualifier. We happen to use `__restrict' as
|
||||
* a way to define the `restrict' type qualifier without disturbing older
|
||||
* software that is unaware of C99 keywords.
|
||||
*/
|
||||
#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
|
||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
|
||||
#define __restrict
|
||||
#else
|
||||
#define __restrict restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GNU C version 2.96 adds explicit branch prediction so that
|
||||
* the CPU back-end can hint the processor and also so that
|
||||
* code blocks can be reordered such that the predicted path
|
||||
* sees a more linear flow, thus improving cache behavior, etc.
|
||||
*
|
||||
* The following two macros provide us with a way to utilize this
|
||||
* compiler feature. Use __predict_true() if you expect the expression
|
||||
* to evaluate to true, and __predict_false() if you expect the
|
||||
* expression to evaluate to false.
|
||||
*
|
||||
* A few notes about usage:
|
||||
*
|
||||
* * Generally, __predict_false() error condition checks (unless
|
||||
* you have some _strong_ reason to do otherwise, in which case
|
||||
* document it), and/or __predict_true() `no-error' condition
|
||||
* checks, assuming you want to optimize for the no-error case.
|
||||
*
|
||||
* * Other than that, if you don't know the likelihood of a test
|
||||
* succeeding from empirical or other `hard' evidence, don't
|
||||
* make predictions.
|
||||
*
|
||||
* * These are meant to be used in places that are run `a lot'.
|
||||
* It is wasteful to make predictions in code that is run
|
||||
* seldomly (e.g. at subsystem initialization time) as the
|
||||
* basic block reordering that this affects can often generate
|
||||
* larger code.
|
||||
*/
|
||||
#if __GNUC_PREREQ__(2, 96)
|
||||
#define __predict_true(exp) __builtin_expect((exp), 1)
|
||||
#define __predict_false(exp) __builtin_expect((exp), 0)
|
||||
#else
|
||||
#define __predict_true(exp) (exp)
|
||||
#define __predict_false(exp) (exp)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 2)
|
||||
#define __hidden __attribute__((__visibility__("hidden")))
|
||||
#define __exported __attribute__((__visibility__("default")))
|
||||
#else
|
||||
#define __hidden
|
||||
#define __exported
|
||||
#endif
|
||||
|
||||
#define __offsetof(type, field) offsetof(type, field)
|
||||
#define __rangeof(type, start, end) \
|
||||
(__offsetof(type, end) - __offsetof(type, start))
|
||||
|
||||
/*
|
||||
* Given the pointer x to the member m of the struct s, return
|
||||
* a pointer to the containing structure. When using GCC, we first
|
||||
* assign pointer x to a local variable, to check that its type is
|
||||
* compatible with member m.
|
||||
*/
|
||||
#if __GNUC_PREREQ__(3, 1)
|
||||
#define __containerof(x, s, m) ({ \
|
||||
const volatile __typeof__(((s *)0)->m) *__x = (x); \
|
||||
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
|
||||
})
|
||||
#else
|
||||
#define __containerof(x, s, m) \
|
||||
__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compiler-dependent macros to declare that functions take printf-like
|
||||
* or scanf-like arguments. They are null except for versions of gcc
|
||||
* that are known to support the features properly (old versions of gcc-2
|
||||
* didn't permit keeping the keywords out of the application namespace).
|
||||
*/
|
||||
#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
|
||||
#define __printflike(fmtarg, firstvararg)
|
||||
#define __scanflike(fmtarg, firstvararg)
|
||||
#define __format_arg(fmtarg)
|
||||
#define __strfmonlike(fmtarg, firstvararg)
|
||||
#define __strftimelike(fmtarg, firstvararg)
|
||||
#else
|
||||
#define __printflike(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
|
||||
#define __scanflike(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
|
||||
#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
|
||||
#define __strfmonlike(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
|
||||
#define __strftimelike(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
|
||||
#endif
|
||||
|
||||
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
|
||||
#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
|
||||
defined(__GNUC__) && !defined(__INTEL_COMPILER)
|
||||
#define __printf0like(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
|
||||
#else
|
||||
#define __printf0like(fmtarg, firstvararg)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
#ifndef __INTEL_COMPILER
|
||||
#define __strong_reference(sym,aliassym) \
|
||||
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
|
||||
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
|
||||
#endif
|
||||
#ifdef __ELF__
|
||||
#ifdef __STDC__
|
||||
#define __weak_reference(sym,alias) \
|
||||
|
@ -113,6 +515,10 @@
|
|||
__asm__(".section .gnu.warning." #sym); \
|
||||
__asm__(".asciz \"" msg "\""); \
|
||||
__asm__(".previous")
|
||||
#define __sym_compat(sym,impl,verid) \
|
||||
__asm__(".symver " #impl ", " #sym "@" #verid)
|
||||
#define __sym_default(sym,impl,verid) \
|
||||
__asm__(".symver " #impl ", " #sym "@@" #verid)
|
||||
#else
|
||||
#define __weak_reference(sym,alias) \
|
||||
__asm__(".weak alias"); \
|
||||
|
@ -121,6 +527,10 @@
|
|||
__asm__(".section .gnu.warning.sym"); \
|
||||
__asm__(".asciz \"msg\""); \
|
||||
__asm__(".previous")
|
||||
#define __sym_compat(sym,impl,verid) \
|
||||
__asm__(".symver impl, sym@verid")
|
||||
#define __sym_default(impl,sym,verid) \
|
||||
__asm__(".symver impl, sym@@verid")
|
||||
#endif /* __STDC__ */
|
||||
#else /* !__ELF__ */
|
||||
#ifdef __STDC__
|
||||
|
@ -139,6 +549,162 @@
|
|||
__asm__(".stabs \"_/**/sym\",1,0,0,0")
|
||||
#endif /* __STDC__ */
|
||||
#endif /* __ELF__ */
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __GNUC__ || __INTEL_COMPILER */
|
||||
|
||||
#endif /* _SYS_CDEFS_H */
|
||||
#ifndef __FBSDID
|
||||
#define __FBSDID(s) struct __hack
|
||||
#endif
|
||||
|
||||
#ifndef __RCSID
|
||||
#define __RCSID(s) struct __hack
|
||||
#endif
|
||||
|
||||
#ifndef __RCSID_SOURCE
|
||||
#define __RCSID_SOURCE(s) struct __hack
|
||||
#endif
|
||||
|
||||
#ifndef __SCCSID
|
||||
#define __SCCSID(s) struct __hack
|
||||
#endif
|
||||
|
||||
#ifndef __COPYRIGHT
|
||||
#define __COPYRIGHT(s) struct __hack
|
||||
#endif
|
||||
|
||||
#ifndef __DECONST
|
||||
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
|
||||
#endif
|
||||
|
||||
#ifndef __DEVOLATILE
|
||||
#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
|
||||
#endif
|
||||
|
||||
#ifndef __DEQUALIFY
|
||||
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* The following definitions are an extension of the behavior originally
|
||||
* implemented in <sys/_posix.h>, but with a different level of granularity.
|
||||
* POSIX.1 requires that the macros we test be defined before any standard
|
||||
* header file is included.
|
||||
*
|
||||
* Here's a quick run-down of the versions:
|
||||
* defined(_POSIX_SOURCE) 1003.1-1988
|
||||
* _POSIX_C_SOURCE == 1 1003.1-1990
|
||||
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
|
||||
* _POSIX_C_SOURCE == 199309 1003.1b-1993
|
||||
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
|
||||
* and the omnibus ISO/IEC 9945-1: 1996
|
||||
* _POSIX_C_SOURCE == 200112 1003.1-2001
|
||||
* _POSIX_C_SOURCE == 200809 1003.1-2008
|
||||
*
|
||||
* In addition, the X/Open Portability Guide, which is now the Single UNIX
|
||||
* Specification, defines a feature-test macro which indicates the version of
|
||||
* that specification, and which subsumes _POSIX_C_SOURCE.
|
||||
*
|
||||
* Our macros begin with two underscores to avoid namespace screwage.
|
||||
*/
|
||||
|
||||
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
|
||||
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
|
||||
#define _POSIX_C_SOURCE 199009
|
||||
#endif
|
||||
|
||||
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199209
|
||||
#endif
|
||||
|
||||
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
|
||||
#ifdef _XOPEN_SOURCE
|
||||
#if _XOPEN_SOURCE - 0 >= 700
|
||||
#define __XSI_VISIBLE 700
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809
|
||||
#elif _XOPEN_SOURCE - 0 >= 600
|
||||
#define __XSI_VISIBLE 600
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200112
|
||||
#elif _XOPEN_SOURCE - 0 >= 500
|
||||
#define __XSI_VISIBLE 500
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199506
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Deal with all versions of POSIX. The ordering relative to the tests above is
|
||||
* important.
|
||||
*/
|
||||
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
|
||||
#define _POSIX_C_SOURCE 198808
|
||||
#endif
|
||||
#ifdef _POSIX_C_SOURCE
|
||||
#if _POSIX_C_SOURCE >= 200809
|
||||
#define __POSIX_VISIBLE 200809
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#elif _POSIX_C_SOURCE >= 200112
|
||||
#define __POSIX_VISIBLE 200112
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#elif _POSIX_C_SOURCE >= 199506
|
||||
#define __POSIX_VISIBLE 199506
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif _POSIX_C_SOURCE >= 199309
|
||||
#define __POSIX_VISIBLE 199309
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif _POSIX_C_SOURCE >= 199209
|
||||
#define __POSIX_VISIBLE 199209
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif _POSIX_C_SOURCE >= 199009
|
||||
#define __POSIX_VISIBLE 199009
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#else
|
||||
#define __POSIX_VISIBLE 198808
|
||||
#define __ISO_C_VISIBLE 0
|
||||
#endif /* _POSIX_C_SOURCE */
|
||||
#else
|
||||
/*-
|
||||
* Deal with _ANSI_SOURCE:
|
||||
* If it is defined, and no other compilation environment is explicitly
|
||||
* requested, then define our internal feature-test macros to zero. This
|
||||
* makes no difference to the preprocessor (undefined symbols in preprocessing
|
||||
* expressions are defined to have value zero), but makes it more convenient for
|
||||
* a test program to print out the values.
|
||||
*
|
||||
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as
|
||||
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation
|
||||
* environment (and in fact we will never get here).
|
||||
*/
|
||||
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 2011
|
||||
#elif defined(_GNU_SOURCE) /* Everything and the kitchen sink. */
|
||||
#define __POSIX_VISIBLE 200809
|
||||
#define __XSI_VISIBLE 700
|
||||
#define __BSD_VISIBLE 1
|
||||
#define __ISO_C_VISIBLE 2011
|
||||
#define __GNU_VISIBLE 1
|
||||
#else /* Default: everything except __GNU_VISIBLE. */
|
||||
#define __POSIX_VISIBLE 200809
|
||||
#define __XSI_VISIBLE 700
|
||||
#define __BSD_VISIBLE 1
|
||||
#define __ISO_C_VISIBLE 2011
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_CDEFS_H_ */
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#include <machine/ieeefp.h> /* floating point macros */
|
||||
#include <sys/features.h> /* POSIX defs */
|
||||
|
||||
#ifdef __aarch64__
|
||||
#define MALLOC_ALIGNMENT 16
|
||||
#endif
|
||||
|
||||
/* exceptions first */
|
||||
#if defined(__H8500__) || defined(__W65__)
|
||||
#define __SMALL_BITFIELDS
|
||||
|
@ -141,6 +145,21 @@
|
|||
#define __BUFSIZ__ 16
|
||||
#define _REENT_SMALL
|
||||
#endif
|
||||
|
||||
#if defined __MSP430__
|
||||
#ifndef _REENT_SMALL
|
||||
#define _REENT_SMALL
|
||||
#endif
|
||||
|
||||
#define __SMALL_BITFIELDS
|
||||
|
||||
#ifdef __MSP430X_LARGE__
|
||||
#define _POINTER_INT long
|
||||
#else
|
||||
#define _POINTER_INT int
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __m32c__
|
||||
#define __SMALL_BITFIELDS
|
||||
#undef INT_MAX
|
||||
|
@ -213,6 +232,8 @@
|
|||
#if defined(__rtems__)
|
||||
#define __FILENAME_MAX__ 255
|
||||
#define _READ_WRITE_RETURN_TYPE _ssize_t
|
||||
#define __DYNAMIC_REENT__
|
||||
#define _REENT_GLOBAL_ATEXIT
|
||||
#endif
|
||||
|
||||
#ifndef __EXPORT
|
||||
|
@ -229,6 +250,12 @@
|
|||
#ifndef _READ_WRITE_RETURN_TYPE
|
||||
#define _READ_WRITE_RETURN_TYPE int
|
||||
#endif
|
||||
/* Define `count' parameter of read/write routines. In POSIX, the `count'
|
||||
parameter is "size_t" but legacy newlib code has been using "int" for some
|
||||
time. If not specified, "int" is defaulted. */
|
||||
#ifndef _READ_WRITE_BUFSIZE_TYPE
|
||||
#define _READ_WRITE_BUFSIZE_TYPE int
|
||||
#endif
|
||||
|
||||
#ifndef __WCHAR_MAX__
|
||||
#if __INT_MAX__ == 32767 || defined (_WIN32)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
|
||||
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: features.h,v 1.27 2011/07/20 19:41:15 yselkowitz Exp $
|
||||
* $Id: features.h,v 1.30 2013/04/23 09:42:25 corinna Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_FEATURES_H
|
||||
|
@ -25,6 +25,18 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */
|
||||
#ifndef __GNUC_PREREQ
|
||||
# if defined __GNUC__ && defined __GNUC_MINOR__
|
||||
# define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
# else
|
||||
# define __GNUC_PREREQ(maj, min) 0
|
||||
# endif
|
||||
#endif /* __GNUC_PREREQ */
|
||||
/* Version with trailing underscores for BSD compatibility. */
|
||||
#define __GNUC_PREREQ__(ma, mi) __GNUC_PREREQ(ma, mi)
|
||||
|
||||
/* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */
|
||||
|
||||
#ifdef __rtems__
|
||||
|
@ -161,12 +173,18 @@ extern "C" {
|
|||
#define _POSIX2_SW_DEV 200112L
|
||||
#define _POSIX2_UPE 200112L
|
||||
#define _POSIX_V6_ILP32_OFF32 -1
|
||||
#define _XBS5_ILP32_OFF32 _POSIX_V6_ILP32_OFF32
|
||||
#ifdef __LP64__
|
||||
#define _POSIX_V6_ILP32_OFFBIG -1
|
||||
#define _POSIX_V6_LP64_OFF64 1
|
||||
#define _POSIX_V6_LPBIG_OFFBIG 1
|
||||
#else
|
||||
#define _POSIX_V6_ILP32_OFFBIG 1
|
||||
#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG
|
||||
#define _POSIX_V6_LP64_OFF64 -1
|
||||
#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64
|
||||
#define _POSIX_V6_LPBIG_OFFBIG -1
|
||||
#endif
|
||||
#define _XBS5_ILP32_OFF32 _POSIX_V6_ILP32_OFF32
|
||||
#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG
|
||||
#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64
|
||||
#define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG
|
||||
#define _XOPEN_CRYPT 1
|
||||
#define _XOPEN_ENH_I18N 1
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# define _SYS_PARAM_H
|
||||
|
||||
#include <sys/config.h>
|
||||
#include <sys/syslimits.h>
|
||||
#include <machine/endian.h>
|
||||
#include <machine/param.h>
|
||||
|
||||
|
@ -19,6 +20,8 @@
|
|||
# define PATHSIZE (1024)
|
||||
#endif
|
||||
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
|
@ -10,10 +10,6 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
|
@ -31,13 +27,13 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)queue.h 8.5 (Berkeley) 8/20/94
|
||||
* $FreeBSD: src/sys/sys/queue.h,v 1.48 2002/04/17 14:00:37 tmm Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _SYS_QUEUE_H_
|
||||
#define _SYS_QUEUE_H_
|
||||
|
||||
#include <machine/ansi.h> /* for __offsetof */
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*
|
||||
* This file defines four types of data structures: singly-linked lists,
|
||||
|
@ -69,7 +65,7 @@
|
|||
* so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before
|
||||
* or after an existing element or at the head of the list. A list
|
||||
* may only be traversed in the forward direction.
|
||||
* may be traversed in either direction.
|
||||
*
|
||||
* A tail queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
|
@ -89,19 +85,59 @@
|
|||
* _EMPTY + + + +
|
||||
* _FIRST + + + +
|
||||
* _NEXT + + + +
|
||||
* _PREV - - - +
|
||||
* _PREV - + - +
|
||||
* _LAST - - + +
|
||||
* _FOREACH + + + +
|
||||
* _FOREACH_SAFE + + + +
|
||||
* _FOREACH_REVERSE - - - +
|
||||
* _FOREACH_REVERSE_SAFE - - - +
|
||||
* _INSERT_HEAD + + + +
|
||||
* _INSERT_BEFORE - + - +
|
||||
* _INSERT_AFTER + + + +
|
||||
* _INSERT_TAIL - - + +
|
||||
* _CONCAT - - + +
|
||||
* _REMOVE_AFTER + - + -
|
||||
* _REMOVE_HEAD + - + -
|
||||
* _REMOVE + + + +
|
||||
* _SWAP + + + +
|
||||
*
|
||||
*/
|
||||
#ifdef QUEUE_MACRO_DEBUG
|
||||
/* Store the last 2 places the queue element or head was altered */
|
||||
struct qm_trace {
|
||||
unsigned long lastline;
|
||||
unsigned long prevline;
|
||||
const char *lastfile;
|
||||
const char *prevfile;
|
||||
};
|
||||
|
||||
#define TRACEBUF struct qm_trace trace;
|
||||
#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } ,
|
||||
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
|
||||
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
|
||||
|
||||
#define QMD_TRACE_HEAD(head) do { \
|
||||
(head)->trace.prevline = (head)->trace.lastline; \
|
||||
(head)->trace.prevfile = (head)->trace.lastfile; \
|
||||
(head)->trace.lastline = __LINE__; \
|
||||
(head)->trace.lastfile = __FILE__; \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TRACE_ELEM(elem) do { \
|
||||
(elem)->trace.prevline = (elem)->trace.lastline; \
|
||||
(elem)->trace.prevfile = (elem)->trace.lastfile; \
|
||||
(elem)->trace.lastline = __LINE__; \
|
||||
(elem)->trace.lastfile = __FILE__; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define QMD_TRACE_ELEM(elem)
|
||||
#define QMD_TRACE_HEAD(head)
|
||||
#define QMD_SAVELINK(name, link)
|
||||
#define TRACEBUF
|
||||
#define TRACEBUF_INITIALIZER
|
||||
#define TRASHIT(x)
|
||||
#endif /* QUEUE_MACRO_DEBUG */
|
||||
|
||||
/*
|
||||
* Singly-linked List declarations.
|
||||
|
@ -131,6 +167,16 @@ struct { \
|
|||
(var); \
|
||||
(var) = SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||
for ((varp) = &SLIST_FIRST((head)); \
|
||||
((var) = *(varp)) != NULL; \
|
||||
(varp) = &SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_INIT(head) do { \
|
||||
SLIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
@ -148,6 +194,7 @@ struct { \
|
|||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
|
||||
if (SLIST_FIRST((head)) == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
|
@ -155,15 +202,26 @@ struct { \
|
|||
struct type *curelm = SLIST_FIRST((head)); \
|
||||
while (SLIST_NEXT(curelm, field) != (elm)) \
|
||||
curelm = SLIST_NEXT(curelm, field); \
|
||||
SLIST_NEXT(curelm, field) = \
|
||||
SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
|
||||
SLIST_REMOVE_AFTER(curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_AFTER(elm, field) do { \
|
||||
SLIST_NEXT(elm, field) = \
|
||||
SLIST_NEXT(SLIST_NEXT(elm, field), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_SWAP(head1, head2, type) do { \
|
||||
struct type *swap_first = SLIST_FIRST(head1); \
|
||||
SLIST_FIRST(head1) = SLIST_FIRST(head2); \
|
||||
SLIST_FIRST(head2) = swap_first; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue declarations.
|
||||
*/
|
||||
|
@ -201,6 +259,12 @@ struct { \
|
|||
(var); \
|
||||
(var) = STAILQ_NEXT((var), field))
|
||||
|
||||
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define STAILQ_INIT(head) do { \
|
||||
STAILQ_FIRST((head)) = NULL; \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
|
@ -225,14 +289,13 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? \
|
||||
NULL : \
|
||||
((struct type *) \
|
||||
((char *)((head)->stqh_last) - __offsetof(struct type, field))))
|
||||
(STAILQ_EMPTY((head)) ? NULL : \
|
||||
__containerof((head)->stqh_last, struct type, field.stqe_next))
|
||||
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
|
||||
if (STAILQ_FIRST((head)) == (elm)) { \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
|
@ -240,10 +303,15 @@ struct { \
|
|||
struct type *curelm = STAILQ_FIRST((head)); \
|
||||
while (STAILQ_NEXT(curelm, field) != (elm)) \
|
||||
curelm = STAILQ_NEXT(curelm, field); \
|
||||
if ((STAILQ_NEXT(curelm, field) = \
|
||||
STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
|
||||
(head)->stqh_last = &STAILQ_NEXT((curelm), field);\
|
||||
STAILQ_REMOVE_AFTER(head, curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
|
||||
if ((STAILQ_NEXT(elm, field) = \
|
||||
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
||||
|
@ -257,6 +325,20 @@ struct { \
|
|||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_SWAP(head1, head2, type) do { \
|
||||
struct type *swap_first = STAILQ_FIRST(head1); \
|
||||
struct type **swap_last = (head1)->stqh_last; \
|
||||
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_FIRST(head2) = swap_first; \
|
||||
(head2)->stqh_last = swap_last; \
|
||||
if (STAILQ_EMPTY(head1)) \
|
||||
(head1)->stqh_last = &STAILQ_FIRST(head1); \
|
||||
if (STAILQ_EMPTY(head2)) \
|
||||
(head2)->stqh_last = &STAILQ_FIRST(head2); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* List declarations.
|
||||
*/
|
||||
|
@ -278,6 +360,31 @@ struct { \
|
|||
* List functions.
|
||||
*/
|
||||
|
||||
#if (defined(_KERNEL) && defined(INVARIANTS))
|
||||
#define QMD_LIST_CHECK_HEAD(head, field) do { \
|
||||
if (LIST_FIRST((head)) != NULL && \
|
||||
LIST_FIRST((head))->field.le_prev != \
|
||||
&LIST_FIRST((head))) \
|
||||
panic("Bad list head %p first->prev != head", (head)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_LIST_CHECK_NEXT(elm, field) do { \
|
||||
if (LIST_NEXT((elm), field) != NULL && \
|
||||
LIST_NEXT((elm), field)->field.le_prev != \
|
||||
&((elm)->field.le_next)) \
|
||||
panic("Bad link elm %p next->prev != elm", (elm)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_LIST_CHECK_PREV(elm, field) do { \
|
||||
if (*(elm)->field.le_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_LIST_CHECK_HEAD(head, field)
|
||||
#define QMD_LIST_CHECK_NEXT(elm, field)
|
||||
#define QMD_LIST_CHECK_PREV(elm, field)
|
||||
#endif /* (_KERNEL && INVARIANTS) */
|
||||
|
||||
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
|
||||
|
||||
#define LIST_FIRST(head) ((head)->lh_first)
|
||||
|
@ -287,11 +394,17 @@ struct { \
|
|||
(var); \
|
||||
(var) = LIST_NEXT((var), field))
|
||||
|
||||
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define LIST_INIT(head) do { \
|
||||
LIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
||||
QMD_LIST_CHECK_NEXT(listelm, field); \
|
||||
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
|
||||
LIST_NEXT((listelm), field)->field.le_prev = \
|
||||
&LIST_NEXT((elm), field); \
|
||||
|
@ -300,6 +413,7 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QMD_LIST_CHECK_PREV(listelm, field); \
|
||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||
LIST_NEXT((elm), field) = (listelm); \
|
||||
*(listelm)->field.le_prev = (elm); \
|
||||
|
@ -307,6 +421,7 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
QMD_LIST_CHECK_HEAD((head), field); \
|
||||
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
|
||||
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
|
||||
LIST_FIRST((head)) = (elm); \
|
||||
|
@ -315,11 +430,31 @@ struct { \
|
|||
|
||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||
|
||||
#define LIST_PREV(elm, head, type, field) \
|
||||
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
|
||||
__containerof((elm)->field.le_prev, struct type, field.le_next))
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
|
||||
QMD_LIST_CHECK_NEXT(elm, field); \
|
||||
QMD_LIST_CHECK_PREV(elm, field); \
|
||||
if (LIST_NEXT((elm), field) != NULL) \
|
||||
LIST_NEXT((elm), field)->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = LIST_NEXT((elm), field); \
|
||||
TRASHIT(*oldnext); \
|
||||
TRASHIT(*oldprev); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_SWAP(head1, head2, type, field) do { \
|
||||
struct type *swap_tmp = LIST_FIRST((head1)); \
|
||||
LIST_FIRST((head1)) = LIST_FIRST((head2)); \
|
||||
LIST_FIRST((head2)) = swap_tmp; \
|
||||
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
|
||||
swap_tmp->field.le_prev = &LIST_FIRST((head1)); \
|
||||
if ((swap_tmp = LIST_FIRST((head2))) != NULL) \
|
||||
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
|
@ -329,26 +464,61 @@ struct { \
|
|||
struct name { \
|
||||
struct type *tqh_first; /* first element */ \
|
||||
struct type **tqh_last; /* addr of last next element */ \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).tqh_first }
|
||||
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
|
||||
|
||||
#define TAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *tqe_next; /* next element */ \
|
||||
struct type **tqe_prev; /* address of previous next element */ \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#if (defined(_KERNEL) && defined(INVARIANTS))
|
||||
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
|
||||
if (!TAILQ_EMPTY(head) && \
|
||||
TAILQ_FIRST((head))->field.tqe_prev != \
|
||||
&TAILQ_FIRST((head))) \
|
||||
panic("Bad tailq head %p first->prev != head", (head)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
|
||||
if (*(head)->tqh_last != NULL) \
|
||||
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
|
||||
if (TAILQ_NEXT((elm), field) != NULL && \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev != \
|
||||
&((elm)->field.tqe_next)) \
|
||||
panic("Bad link elm %p next->prev != elm", (elm)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
|
||||
if (*(elm)->field.tqe_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_TAILQ_CHECK_HEAD(head, field)
|
||||
#define QMD_TAILQ_CHECK_TAIL(head, headname)
|
||||
#define QMD_TAILQ_CHECK_NEXT(elm, field)
|
||||
#define QMD_TAILQ_CHECK_PREV(elm, field)
|
||||
#endif /* (_KERNEL && INVARIANTS) */
|
||||
|
||||
#define TAILQ_CONCAT(head1, head2, field) do { \
|
||||
if (!TAILQ_EMPTY(head2)) { \
|
||||
*(head1)->tqh_last = (head2)->tqh_first; \
|
||||
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
TAILQ_INIT((head2)); \
|
||||
QMD_TRACE_HEAD(head1); \
|
||||
QMD_TRACE_HEAD(head2); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -361,34 +531,54 @@ struct { \
|
|||
(var); \
|
||||
(var) = TAILQ_NEXT((var), field))
|
||||
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var); \
|
||||
(var) = TAILQ_PREV((var), headname, field))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_INIT(head) do { \
|
||||
TAILQ_FIRST((head)) = NULL; \
|
||||
(head)->tqh_last = &TAILQ_FIRST((head)); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_NEXT(listelm, field); \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
||||
&TAILQ_NEXT((elm), field); \
|
||||
else \
|
||||
else { \
|
||||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} \
|
||||
TAILQ_NEXT((listelm), field) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_PREV(listelm, field); \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
TAILQ_NEXT((elm), field) = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_HEAD(head, field); \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
|
||||
TAILQ_FIRST((head))->field.tqe_prev = \
|
||||
&TAILQ_NEXT((elm), field); \
|
||||
|
@ -396,13 +586,18 @@ struct { \
|
|||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
TAILQ_FIRST((head)) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_TAIL(head, field); \
|
||||
TAILQ_NEXT((elm), field) = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_LAST(head, headname) \
|
||||
|
@ -414,14 +609,39 @@ struct { \
|
|||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
|
||||
QMD_TAILQ_CHECK_NEXT(elm, field); \
|
||||
QMD_TAILQ_CHECK_PREV(elm, field); \
|
||||
if ((TAILQ_NEXT((elm), field)) != NULL) \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
else \
|
||||
else { \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} \
|
||||
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
|
||||
TRASHIT(*oldnext); \
|
||||
TRASHIT(*oldprev); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_SWAP(head1, head2, type, field) do { \
|
||||
struct type *swap_first = (head1)->tqh_first; \
|
||||
struct type **swap_last = (head1)->tqh_last; \
|
||||
(head1)->tqh_first = (head2)->tqh_first; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
(head2)->tqh_first = swap_first; \
|
||||
(head2)->tqh_last = swap_last; \
|
||||
if ((swap_first = (head1)->tqh_first) != NULL) \
|
||||
swap_first->field.tqe_prev = &(head1)->tqh_first; \
|
||||
else \
|
||||
(head1)->tqh_last = &(head1)->tqh_first; \
|
||||
if ((swap_first = (head2)->tqh_first) != NULL) \
|
||||
swap_first->field.tqe_prev = &(head2)->tqh_first; \
|
||||
else \
|
||||
(head2)->tqh_last = &(head2)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ extern "C" {
|
|||
#define _SYS_REENT_H_
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/_types.h>
|
||||
|
||||
#define _NULL 0
|
||||
|
@ -85,6 +86,7 @@ struct _atexit {
|
|||
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
||||
struct _on_exit_args * _on_exit_args_ptr;
|
||||
};
|
||||
# define _ATEXIT_INIT {_NULL, 0, {_NULL}, _NULL}
|
||||
#else
|
||||
struct _atexit {
|
||||
struct _atexit *_next; /* next in list */
|
||||
|
@ -93,6 +95,14 @@ struct _atexit {
|
|||
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
||||
struct _on_exit_args _on_exit_args;
|
||||
};
|
||||
# define _ATEXIT_INIT {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}
|
||||
#endif
|
||||
|
||||
#ifdef _REENT_GLOBAL_ATEXIT
|
||||
# define _REENT_INIT_ATEXIT
|
||||
#else
|
||||
# define _REENT_INIT_ATEXIT \
|
||||
_NULL, _ATEXIT_INIT,
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -183,9 +193,10 @@ struct __sFILE {
|
|||
_PTR _cookie; /* cookie passed to io functions */
|
||||
|
||||
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
|
||||
char *, int));
|
||||
char *, _READ_WRITE_BUFSIZE_TYPE));
|
||||
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
|
||||
const char *, int));
|
||||
const char *,
|
||||
_READ_WRITE_BUFSIZE_TYPE));
|
||||
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
|
||||
int _EXFNPTR(_close, (struct _reent *, _PTR));
|
||||
|
||||
|
@ -203,7 +214,7 @@ struct __sFILE {
|
|||
|
||||
/* Unix stdio files get aligned to block boundaries on fseek() */
|
||||
int _blksize; /* stat.st_blksize (may be != _bf._size) */
|
||||
int _offset; /* current lseek offset */
|
||||
_off_t _offset; /* current lseek offset */
|
||||
|
||||
#ifndef _REENT_SMALL
|
||||
struct _reent *_data; /* Here for binary compatibility? Remove? */
|
||||
|
@ -238,9 +249,10 @@ struct __sFILE64 {
|
|||
_PTR _cookie; /* cookie passed to io functions */
|
||||
|
||||
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
|
||||
char *, int));
|
||||
char *, _READ_WRITE_BUFSIZE_TYPE));
|
||||
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
|
||||
const char *, int));
|
||||
const char *,
|
||||
_READ_WRITE_BUFSIZE_TYPE));
|
||||
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
|
||||
int _EXFNPTR(_close, (struct _reent *, _PTR));
|
||||
|
||||
|
@ -353,7 +365,7 @@ struct _misc_reent
|
|||
_mbstate_t _wcsrtombs_state;
|
||||
};
|
||||
|
||||
/* This version of _reent is layed our with "int"s in pairs, to help
|
||||
/* This version of _reent is laid out with "int"s in pairs, to help
|
||||
* ports with 16-bit int's but 32-bit pointers, align nicely. */
|
||||
struct _reent
|
||||
{
|
||||
|
@ -392,9 +404,11 @@ struct _reent
|
|||
/* signal info */
|
||||
void (**(_sig_func))(int);
|
||||
|
||||
# ifndef _REENT_GLOBAL_ATEXIT
|
||||
/* atexit stuff */
|
||||
struct _atexit *_atexit;
|
||||
struct _atexit _atexit0;
|
||||
# endif
|
||||
|
||||
struct _glue __sglue; /* root of glue chain */
|
||||
__FILE *__sf; /* file descriptors */
|
||||
|
@ -425,8 +439,7 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||
_NULL, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
{_NULL, 0, {_NULL}, _NULL}, \
|
||||
_REENT_INIT_ATEXIT \
|
||||
{_NULL, 0, _NULL}, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
|
@ -434,35 +447,11 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||
}
|
||||
|
||||
#define _REENT_INIT_PTR(var) \
|
||||
{ (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
|
||||
{ memset((var), 0, sizeof(*(var))); \
|
||||
(var)->_stdin = (__FILE *)&__sf_fake_stdin; \
|
||||
(var)->_stdout = (__FILE *)&__sf_fake_stdout; \
|
||||
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \
|
||||
(var)->_errno = 0; \
|
||||
(var)->_inc = 0; \
|
||||
(var)->_emergency = _NULL; \
|
||||
(var)->__sdidinit = 0; \
|
||||
(var)->_current_category = 0; \
|
||||
(var)->_current_locale = "C"; \
|
||||
(var)->_mp = _NULL; \
|
||||
(var)->__cleanup = _NULL; \
|
||||
(var)->_gamma_signgam = 0; \
|
||||
(var)->_cvtlen = 0; \
|
||||
(var)->_cvtbuf = _NULL; \
|
||||
(var)->_r48 = _NULL; \
|
||||
(var)->_localtime_buf = _NULL; \
|
||||
(var)->_asctime_buf = _NULL; \
|
||||
(var)->_sig_func = _NULL; \
|
||||
(var)->_atexit = _NULL; \
|
||||
(var)->_atexit0._next = _NULL; \
|
||||
(var)->_atexit0._ind = 0; \
|
||||
(var)->_atexit0._fns[0] = _NULL; \
|
||||
(var)->_atexit0._on_exit_args_ptr = _NULL; \
|
||||
(var)->__sglue._next = _NULL; \
|
||||
(var)->__sglue._niobs = 0; \
|
||||
(var)->__sglue._iobs = _NULL; \
|
||||
(var)->__sf = 0; \
|
||||
(var)->_misc = _NULL; \
|
||||
(var)->_signal_buf = _NULL; \
|
||||
}
|
||||
|
||||
/* Only built the assert() calls if we are built with debugging. */
|
||||
|
@ -641,9 +630,11 @@ struct _reent
|
|||
} _unused;
|
||||
} _new;
|
||||
|
||||
# ifndef _REENT_GLOBAL_ATEXIT
|
||||
/* atexit stuff */
|
||||
struct _atexit *_atexit; /* points to head of LIFO stack */
|
||||
struct _atexit _atexit0; /* one guaranteed table, required by ANSI */
|
||||
# endif
|
||||
|
||||
/* signal info */
|
||||
void (**(_sig_func))(int);
|
||||
|
@ -698,34 +689,17 @@ struct _reent
|
|||
{0, {0}} \
|
||||
} \
|
||||
}, \
|
||||
_NULL, \
|
||||
{_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \
|
||||
_REENT_INIT_ATEXIT \
|
||||
_NULL, \
|
||||
{_NULL, 0, _NULL} \
|
||||
}
|
||||
|
||||
#define _REENT_INIT_PTR(var) \
|
||||
{ (var)->_errno = 0; \
|
||||
{ memset((var), 0, sizeof(*(var))); \
|
||||
(var)->_stdin = &(var)->__sf[0]; \
|
||||
(var)->_stdout = &(var)->__sf[1]; \
|
||||
(var)->_stderr = &(var)->__sf[2]; \
|
||||
(var)->_inc = 0; \
|
||||
memset(&(var)->_emergency, 0, sizeof((var)->_emergency)); \
|
||||
(var)->_current_category = 0; \
|
||||
(var)->_current_locale = "C"; \
|
||||
(var)->__sdidinit = 0; \
|
||||
(var)->__cleanup = _NULL; \
|
||||
(var)->_result = _NULL; \
|
||||
(var)->_result_k = 0; \
|
||||
(var)->_p5s = _NULL; \
|
||||
(var)->_freelist = _NULL; \
|
||||
(var)->_cvtlen = 0; \
|
||||
(var)->_cvtbuf = _NULL; \
|
||||
(var)->_new._reent._unused_rand = 0; \
|
||||
(var)->_new._reent._strtok_last = _NULL; \
|
||||
(var)->_new._reent._asctime_buf[0] = 0; \
|
||||
memset(&(var)->_new._reent._localtime_buf, 0, sizeof((var)->_new._reent._localtime_buf)); \
|
||||
(var)->_new._reent._gamma_signgam = 0; \
|
||||
(var)->_new._reent._rand_next = 1; \
|
||||
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
|
||||
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
|
||||
|
@ -734,36 +708,6 @@ struct _reent
|
|||
(var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
|
||||
(var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
|
||||
(var)->_new._reent._r48._add = _RAND48_ADD; \
|
||||
(var)->_new._reent._mblen_state.__count = 0; \
|
||||
(var)->_new._reent._mblen_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._mbtowc_state.__count = 0; \
|
||||
(var)->_new._reent._mbtowc_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._wctomb_state.__count = 0; \
|
||||
(var)->_new._reent._wctomb_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._mbrlen_state.__count = 0; \
|
||||
(var)->_new._reent._mbrlen_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._mbrtowc_state.__count = 0; \
|
||||
(var)->_new._reent._mbrtowc_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._mbsrtowcs_state.__count = 0; \
|
||||
(var)->_new._reent._mbsrtowcs_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._wcrtomb_state.__count = 0; \
|
||||
(var)->_new._reent._wcrtomb_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._wcsrtombs_state.__count = 0; \
|
||||
(var)->_new._reent._wcsrtombs_state.__value.__wch = 0; \
|
||||
(var)->_new._reent._l64a_buf[0] = '\0'; \
|
||||
(var)->_new._reent._signal_buf[0] = '\0'; \
|
||||
(var)->_new._reent._getdate_err = 0; \
|
||||
(var)->_atexit = _NULL; \
|
||||
(var)->_atexit0._next = _NULL; \
|
||||
(var)->_atexit0._ind = 0; \
|
||||
(var)->_atexit0._fns[0] = _NULL; \
|
||||
(var)->_atexit0._on_exit_args._fntypes = 0; \
|
||||
(var)->_atexit0._on_exit_args._fnargs[0] = _NULL; \
|
||||
(var)->_sig_func = _NULL; \
|
||||
(var)->__sglue._next = _NULL; \
|
||||
(var)->__sglue._niobs = 0; \
|
||||
(var)->__sglue._iobs = _NULL; \
|
||||
memset(&(var)->__sf, 0, sizeof((var)->__sf)); \
|
||||
}
|
||||
|
||||
#define _REENT_CHECK_RAND48(ptr) /* nothing */
|
||||
|
@ -822,7 +766,8 @@ void _reclaim_reent _PARAMS ((struct _reent *));
|
|||
|
||||
/* #define _REENT_ONLY define this to get only reentrant routines */
|
||||
|
||||
|
||||
#if defined(__DYNAMIC_REENT__) && !defined(__SINGLE_THREAD__)
|
||||
#ifndef __getreent
|
||||
static inline struct _reent *__getreent(void)
|
||||
{
|
||||
struct _reent *ent;
|
||||
|
@ -831,10 +776,21 @@ static inline struct _reent *__getreent(void)
|
|||
:"=r"(ent));
|
||||
return ent;
|
||||
};
|
||||
|
||||
#endif
|
||||
# define _REENT (__getreent())
|
||||
#else /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
|
||||
# define _REENT _impure_ptr
|
||||
#endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
|
||||
|
||||
#define _GLOBAL_REENT _global_impure_ptr
|
||||
|
||||
#ifdef _REENT_GLOBAL_ATEXIT
|
||||
extern struct _atexit *_global_atexit; /* points to head of LIFO stack */
|
||||
# define _GLOBAL_ATEXIT _global_atexit
|
||||
#else
|
||||
# define _GLOBAL_ATEXIT (_GLOBAL_REENT->_atexit)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,7 +12,10 @@ extern "C" {
|
|||
|
||||
/* #ifndef __STRICT_ANSI__*/
|
||||
|
||||
/* Cygwin defines it's own sigset_t in include/cygwin/signal.h */
|
||||
#ifndef __CYGWIN__
|
||||
typedef unsigned long sigset_t;
|
||||
#endif
|
||||
|
||||
#if defined(__rtems__)
|
||||
|
||||
|
@ -143,6 +146,9 @@ int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
|
|||
#undef sigfillset
|
||||
#undef sigismember
|
||||
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(_kill, (pid_t, int));
|
||||
#endif
|
||||
int _EXFUN(kill, (pid_t, int));
|
||||
int _EXFUN(killpg, (pid_t, int));
|
||||
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
|
||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
#ifdef __CYGWIN__
|
||||
#include <cygwin/stat.h>
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
#define stat64 __stat64
|
||||
#define stat64 stat
|
||||
#endif
|
||||
#else
|
||||
struct stat
|
||||
|
@ -147,17 +147,17 @@ int _EXFUN(fchmod,(int __fd, mode_t __mode));
|
|||
int _EXFUN(fstat,( int __fd, struct stat *__sbuf ));
|
||||
int _EXFUN(mkdir,( const char *_path, mode_t __mode ));
|
||||
int _EXFUN(mkfifo,( const char *__path, mode_t __mode ));
|
||||
int _EXFUN(stat,( const char *__path, struct stat *__sbuf ));
|
||||
int _EXFUN(stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
|
||||
mode_t _EXFUN(umask,( mode_t __mask ));
|
||||
|
||||
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(lstat,( const char *__path, struct stat *__buf ));
|
||||
int _EXFUN(lstat,( const char *__restrict __path, struct stat *__restrict __buf ));
|
||||
int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
|
||||
#endif
|
||||
|
||||
#if defined (__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(fchmodat, (int, const char *, mode_t, int));
|
||||
int _EXFUN(fstatat, (int, const char *, struct stat *, int));
|
||||
int _EXFUN(fstatat, (int, const char *__restrict , struct stat *__restrict, int));
|
||||
int _EXFUN(mkdirat, (int, const char *, mode_t));
|
||||
int _EXFUN(mkfifoat, (int, const char *, mode_t));
|
||||
int _EXFUN(mknodat, (int, const char *, mode_t, dev_t));
|
||||
|
@ -169,9 +169,11 @@ int _EXFUN(futimens, (int, const struct timespec *));
|
|||
provided in newlib for some compilers. */
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(_fstat,( int __fd, struct stat *__sbuf ));
|
||||
int _EXFUN(_stat,( const char *__path, struct stat *__sbuf ));
|
||||
int _EXFUN(_stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
|
||||
int _EXFUN(_mkdir,( const char *_path, mode_t __mode ));
|
||||
#ifdef __LARGE64_FILES
|
||||
struct stat64;
|
||||
int _EXFUN(_stat64,( const char *__restrict __path, struct stat64 *__restrict __sbuf ));
|
||||
int _EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf ));
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -12,33 +12,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _WINSOCK_H
|
||||
#ifndef _TIMEVAL_DEFINED
|
||||
#define _TIMEVAL_DEFINED
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
|
||||
struct timezone {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include <cygwin/sys_time.h>
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#endif /* _WINSOCK_H */
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval;
|
||||
struct timeval it_value;
|
||||
};
|
||||
|
||||
/* BSD time macros used by RTEMS code */
|
||||
#if defined (__rtems__) || defined (__CYGWIN__)
|
||||
|
||||
|
@ -70,13 +50,37 @@ struct itimerval {
|
|||
} \
|
||||
} while (0)
|
||||
#endif /* defined (__rtems__) || defined (__CYGWIN__) */
|
||||
#endif /* !_TIMEVAL_DEFINED */
|
||||
|
||||
int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz));
|
||||
struct timezone {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include <cygwin/sys_time.h>
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval;
|
||||
struct timeval it_value;
|
||||
};
|
||||
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
|
||||
#endif
|
||||
|
||||
int _EXFUN(gettimeofday, (struct timeval *__restrict __p,
|
||||
void *__restrict __tz));
|
||||
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
|
||||
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
|
||||
int _EXFUN(getitimer, (int __which, struct itimerval *__value));
|
||||
int _EXFUN(setitimer, (int __which, const struct itimerval *__value,
|
||||
struct itimerval *__ovalue));
|
||||
int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
|
||||
struct itimerval *__restrict __ovalue));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ struct tms {
|
|||
};
|
||||
|
||||
clock_t _EXFUN(times,(struct tms *));
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
clock_t _EXFUN(_times,(struct tms *));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -89,10 +89,22 @@ typedef quad_t * qaddr_t;
|
|||
|
||||
#ifndef _BSDTYPES_DEFINED
|
||||
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
|
||||
#ifndef __u_char_defined
|
||||
typedef unsigned char u_char;
|
||||
#define __u_char_defined
|
||||
#endif
|
||||
#ifndef __u_short_defined
|
||||
typedef unsigned short u_short;
|
||||
#define __u_short_defined
|
||||
#endif
|
||||
#ifndef __u_int_defined
|
||||
typedef unsigned int u_int;
|
||||
#define __u_int_defined
|
||||
#endif
|
||||
#ifndef __u_long_defined
|
||||
typedef unsigned long u_long;
|
||||
#define __u_long_defined
|
||||
#endif
|
||||
#define _BSDTYPES_DEFINED
|
||||
#endif
|
||||
|
||||
|
@ -109,22 +121,31 @@ typedef _CLOCK_T_ clock_t;
|
|||
#ifndef __time_t_defined
|
||||
typedef _TIME_T_ time_t;
|
||||
#define __time_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __timespec_defined
|
||||
#define __timespec_defined
|
||||
/* Time Value Specification Structures, P1003.1b-1993, p. 261 */
|
||||
|
||||
struct timespec {
|
||||
time_t tv_sec; /* Seconds */
|
||||
long tv_nsec; /* Nanoseconds */
|
||||
};
|
||||
#endif
|
||||
|
||||
struct itimerspec {
|
||||
struct timespec it_interval; /* Timer period */
|
||||
struct timespec it_value; /* Timer expiration */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef __daddr_t_defined
|
||||
typedef long daddr_t;
|
||||
#define __daddr_t_defined
|
||||
#endif
|
||||
#ifndef __caddr_t_defined
|
||||
typedef char * caddr_t;
|
||||
#define __caddr_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
#if defined(__MS_types__) || defined(__rtems__) || \
|
||||
|
@ -207,7 +228,7 @@ typedef unsigned short nlink_t;
|
|||
includes the W32api winsock[2].h header must know what it is doing;
|
||||
it must not call the cygwin32 select function.
|
||||
*/
|
||||
# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
|
||||
# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
|
||||
# define _SYS_TYPES_FD_SET
|
||||
# define NBBY 8 /* number of bits in a byte */
|
||||
/*
|
||||
|
@ -244,7 +265,7 @@ typedef struct _types_fd_set {
|
|||
*__tmp++ = 0; \
|
||||
}))
|
||||
|
||||
# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */
|
||||
# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) */
|
||||
|
||||
#undef __MS_types__
|
||||
#undef _ST_INT32
|
||||
|
@ -301,38 +322,9 @@ typedef __uint32_t pthread_t; /* identify a thread */
|
|||
#define PTHREAD_CREATE_DETACHED 0
|
||||
#define PTHREAD_CREATE_JOINABLE 1
|
||||
|
||||
#if defined(__XMK__) || defined(__rtems__)
|
||||
/* The following defines are part of the X/Open System Interface (XSI). */
|
||||
|
||||
/* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking
|
||||
* it shall deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behavior.
|
||||
* Attempting to unlock an unlocked mutex results in undefined behavior.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_NORMAL 1
|
||||
|
||||
/*
|
||||
* This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking
|
||||
* it shall return with an error. A thread attempting to unlock a mutex which another thread has locked shall return
|
||||
* with an error. A thread attempting to unlock an unlocked mutex shall return with an error.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_ERRORCHECK 2
|
||||
|
||||
/* A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mutex.
|
||||
* The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex.
|
||||
* Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can
|
||||
* acquire the mutex. A thread attempting to unlock a mutex which another thread has locked shall return with an error.
|
||||
* A thread attempting to unlock an unlocked mutex shall return with an error.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_RECURSIVE 3
|
||||
|
||||
/* Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a
|
||||
* mutex of this type which was not locked by the calling thread results in undefined behavior. Attempting to
|
||||
* unlock a mutex of this type which is not locked results in undefined behavior. An implementation may map this
|
||||
* mutex to one of the other mutex types.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_DEFAULT 4
|
||||
|
||||
#endif /* defined(__XMK__) || defined(__rtems__) */
|
||||
#if defined(__rtems__)
|
||||
#include <sys/cpuset.h>
|
||||
#endif
|
||||
|
||||
#if defined(__XMK__)
|
||||
typedef struct pthread_attr_s {
|
||||
|
@ -363,7 +355,11 @@ typedef struct {
|
|||
int cputime_clock_allowed; /* see time.h */
|
||||
#endif
|
||||
int detachstate;
|
||||
|
||||
#if defined(__rtems__)
|
||||
size_t affinitysetsize;
|
||||
cpu_set_t *affinityset;
|
||||
cpu_set_t affinitysetpreallocated;
|
||||
#endif
|
||||
} pthread_attr_t;
|
||||
|
||||
#endif /* !defined(__XMK__) */
|
||||
|
@ -391,12 +387,49 @@ typedef struct {
|
|||
|
||||
/* Values for mutex type */
|
||||
|
||||
/* The following defines are part of the X/Open System Interface (XSI). */
|
||||
|
||||
/*
|
||||
* This type of mutex does not detect deadlock. A thread attempting to
|
||||
* relock this mutex without first unlocking it shall deadlock. Attempting
|
||||
* to unlock a mutex locked by a different thread results in undefined
|
||||
* behavior. Attempting to unlock an unlocked mutex results in undefined
|
||||
* behavior.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_NORMAL 0
|
||||
|
||||
/*
|
||||
* A thread attempting to relock this mutex without first unlocking
|
||||
* it shall succeed in locking the mutex. The relocking deadlock which
|
||||
* can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
|
||||
* this type of mutex. Multiple locks of this mutex shall require the
|
||||
* same number of unlocks to release the mutex before another thread can
|
||||
* acquire the mutex. A thread attempting to unlock a mutex which another
|
||||
* thread has locked shall return with an error. A thread attempting to
|
||||
* unlock an unlocked mutex shall return with an error.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_RECURSIVE 1
|
||||
|
||||
/*
|
||||
* This type of mutex provides error checking. A thread attempting
|
||||
* to relock this mutex without first unlocking it shall return with an
|
||||
* error. A thread attempting to unlock a mutex which another thread has
|
||||
* locked shall return with an error. A thread attempting to unlock an
|
||||
* unlocked mutex shall return with an error.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_ERRORCHECK 2
|
||||
|
||||
/*
|
||||
* Attempting to recursively lock a mutex of this type results
|
||||
* in undefined behavior. Attempting to unlock a mutex of this type
|
||||
* which was not locked by the calling thread results in undefined
|
||||
* behavior. Attempting to unlock a mutex of this type which is not locked
|
||||
* results in undefined behavior. An implementation may map this mutex to
|
||||
* one of the other mutex types.
|
||||
*/
|
||||
#define PTHREAD_MUTEX_DEFAULT 3
|
||||
|
||||
#endif
|
||||
#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
|
||||
|
||||
#if defined(__XMK__)
|
||||
typedef unsigned int pthread_mutex_t; /* identify a mutex */
|
||||
|
@ -463,13 +496,13 @@ typedef struct {
|
|||
|
||||
/* POSIX Spin Lock Types */
|
||||
|
||||
#if !defined (__CYGWIN__)
|
||||
#if defined(_POSIX_SPIN_LOCKS)
|
||||
typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */
|
||||
#endif /* defined(_POSIX_SPIN_LOCKS) */
|
||||
|
||||
/* POSIX Reader/Writer Lock Types */
|
||||
|
||||
#if !defined (__CYGWIN__)
|
||||
#if defined(_POSIX_READER_WRITER_LOCKS)
|
||||
typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */
|
||||
typedef struct {
|
||||
|
|
|
@ -71,6 +71,9 @@ pid_t _EXFUN(fork, (void ));
|
|||
long _EXFUN(fpathconf, (int __fd, int __name ));
|
||||
int _EXFUN(fsync, (int __fd));
|
||||
int _EXFUN(fdatasync, (int __fd));
|
||||
#if defined(__CYGWIN__)
|
||||
char * _EXFUN(get_current_dir_name, (void));
|
||||
#endif
|
||||
char * _EXFUN(getcwd, (char *__buf, size_t __size ));
|
||||
#if defined(__CYGWIN__)
|
||||
int _EXFUN(getdomainname ,(char *__name, size_t __len));
|
||||
|
@ -172,7 +175,7 @@ int _EXFUN(setuid, (uid_t __uid ));
|
|||
void _EXFUN(setusershell, (void));
|
||||
#endif
|
||||
unsigned _EXFUN(sleep, (unsigned int __seconds ));
|
||||
void _EXFUN(swab, (const void *, void *, ssize_t));
|
||||
void _EXFUN(swab, (const void *__restrict, void *__restrict, ssize_t));
|
||||
long _EXFUN(sysconf, (int __name ));
|
||||
pid_t _EXFUN(tcgetpgrp, (int __fildes ));
|
||||
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
|
||||
|
@ -219,7 +222,7 @@ _READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nb
|
|||
int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) || defined(__SPU__)
|
||||
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__aarch64__) || defined (__arm__) || defined(__sh__) || defined(__SPU__)
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(ftruncate, (int __fd, off_t __length));
|
||||
int _EXFUN(truncate, (const char *, off_t __length));
|
||||
|
@ -230,7 +233,7 @@ int _EXFUN(truncate, (const char *, off_t __length));
|
|||
int _EXFUN(getdtablesize, (void));
|
||||
int _EXFUN(setdtablesize, (int));
|
||||
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
|
||||
#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
|
||||
#if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
|
||||
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
|
||||
int _EXFUN(gethostname, (char *__name, size_t __len));
|
||||
#endif
|
||||
|
@ -241,9 +244,11 @@ char * _EXFUN(mktemp, (char *));
|
|||
void _EXFUN(sync, (void));
|
||||
#endif
|
||||
|
||||
ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen));
|
||||
ssize_t _EXFUN(readlink, (const char *__restrict __path,
|
||||
char *__restrict __buf, size_t __buflen));
|
||||
#if defined(__CYGWIN__)
|
||||
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen));
|
||||
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__restrict __path,
|
||||
char *__restrict __buf, size_t __buflen));
|
||||
#endif
|
||||
int _EXFUN(symlink, (const char *__name1, const char *__name2));
|
||||
#if defined(__CYGWIN__)
|
||||
|
@ -497,10 +502,6 @@ int _EXFUN(unlinkat, (int, const char *, int));
|
|||
#define _CS_V6_ENV _CS_V7_ENV
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
# define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,10 @@ extern "C" {
|
|||
pid_t wait (int *);
|
||||
pid_t waitpid (pid_t, int *, int);
|
||||
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
pid_t _wait (int *);
|
||||
#endif
|
||||
|
||||
/* Provide prototypes for most of the _<systemcall> names that are
|
||||
provided in newlib for some compilers. */
|
||||
pid_t _wait (int *);
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
/* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/tgmath.h.html */
|
||||
/*-
|
||||
* Copyright (c) 2004 Stefan Farfeleder.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _TGMATH_H_
|
||||
#define _TGMATH_H_
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef log2
|
||||
#undef log2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This implementation of <tgmath.h> requires two implementation-dependent
|
||||
* macros to be defined:
|
||||
* __tg_impl_simple(x, y, z, fn, fnf, fnl, ...)
|
||||
* Invokes fnl() if the corresponding real type of x, y or z is long
|
||||
* double, fn() if it is double or any has an integer type, and fnf()
|
||||
* otherwise.
|
||||
* __tg_impl_full(x, y, z, fn, fnf, fnl, cfn, cfnf, cfnl, ...)
|
||||
* Invokes [c]fnl() if the corresponding real type of x, y or z is long
|
||||
* double, [c]fn() if it is double or any has an integer type, and
|
||||
* [c]fnf() otherwise. The function with the 'c' prefix is called if
|
||||
* any of x, y or z is a complex number.
|
||||
* Both macros call the chosen function with all additional arguments passed
|
||||
* to them, as given by __VA_ARGS__.
|
||||
*
|
||||
* Note that these macros cannot be implemented with C's ?: operator,
|
||||
* because the return type of the whole expression would incorrectly be long
|
||||
* double complex regardless of the argument types.
|
||||
*/
|
||||
|
||||
/* requires GCC >= 3.1 */
|
||||
#if !__GNUC_PREREQ (3, 1)
|
||||
#error "<tgmath.h> not implemented for this compiler"
|
||||
#endif
|
||||
|
||||
#define __tg_type(__e, __t) \
|
||||
__builtin_types_compatible_p(__typeof__(__e), __t)
|
||||
#define __tg_type3(__e1, __e2, __e3, __t) \
|
||||
(__tg_type(__e1, __t) || __tg_type(__e2, __t) || \
|
||||
__tg_type(__e3, __t))
|
||||
#define __tg_type_corr(__e1, __e2, __e3, __t) \
|
||||
(__tg_type3(__e1, __e2, __e3, __t) || \
|
||||
__tg_type3(__e1, __e2, __e3, __t _Complex))
|
||||
#define __tg_integer(__e1, __e2, __e3) \
|
||||
(((__typeof__(__e1))1.5 == 1) || ((__typeof__(__e2))1.5 == 1) || \
|
||||
((__typeof__(__e3))1.5 == 1))
|
||||
#define __tg_is_complex(__e1, __e2, __e3) \
|
||||
(__tg_type3(__e1, __e2, __e3, float _Complex) || \
|
||||
__tg_type3(__e1, __e2, __e3, double _Complex) || \
|
||||
__tg_type3(__e1, __e2, __e3, long double _Complex) || \
|
||||
__tg_type3(__e1, __e2, __e3, __typeof__(_Complex_I)))
|
||||
|
||||
#ifdef _LDBL_EQ_DBL
|
||||
#define __tg_impl_simple(x, y, z, fn, fnf, fnl, ...) \
|
||||
__builtin_choose_expr(__tg_type_corr(x, y, z, long double), \
|
||||
fnl(__VA_ARGS__), __builtin_choose_expr( \
|
||||
__tg_type_corr(x, y, z, double) || __tg_integer(x, y, z),\
|
||||
fn(__VA_ARGS__), fnf(__VA_ARGS__)))
|
||||
#else
|
||||
#define __tg_impl_simple(__x, __y, __z, __fn, __fnf, __fnl, ...) \
|
||||
(__tg_type_corr(__x, __y, __z, double) || __tg_integer(__x, __y, __z)) \
|
||||
? __fn(__VA_ARGS__) : __fnf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define __tg_impl_full(__x, __y, __z, __fn, __fnf, __fnl, __cfn, __cfnf, __cfnl, ...) \
|
||||
__builtin_choose_expr(__tg_is_complex(__x, __y, __z), \
|
||||
__tg_impl_simple(__x, __y, __z, __cfn, __cfnf, __cfnl, __VA_ARGS__), \
|
||||
__tg_impl_simple(__x, __y, __z, __fn, __fnf, __fnl, __VA_ARGS__))
|
||||
|
||||
/* Macros to save lots of repetition below */
|
||||
#define __tg_simple(__x, __fn) \
|
||||
__tg_impl_simple(__x, __x, __x, __fn, __fn##f, __fn##l, __x)
|
||||
#define __tg_simple2(__x, __y, __fn) \
|
||||
__tg_impl_simple(__x, __x, __y, __fn, __fn##f, __fn##l, __x, __y)
|
||||
#define __tg_simplev(__x, __fn, ...) \
|
||||
__tg_impl_simple(__x, __x, __x, __fn, __fn##f, __fn##l, __VA_ARGS__)
|
||||
#define __tg_full(__x, __fn) \
|
||||
__tg_impl_full(__x, __x, __x, __fn, __fn##f, __fn##l, c##__fn, c##__fn##f, c##__fn##l, __x)
|
||||
|
||||
/* 7.22#4 -- These macros expand to real or complex functions, depending on
|
||||
* the type of their arguments. */
|
||||
#define acos(__x) __tg_full(__x, acos)
|
||||
#define asin(__x) __tg_full(__x, asin)
|
||||
#define atan(__x) __tg_full(__x, atan)
|
||||
#define acosh(__x) __tg_full(__x, acosh)
|
||||
#define asinh(__x) __tg_full(__x, asinh)
|
||||
#define atanh(__x) __tg_full(__x, atanh)
|
||||
#define cos(__x) __tg_full(__x, cos)
|
||||
#define sin(__x) __tg_full(__x, sin)
|
||||
#define tan(__x) __tg_full(__x, tan)
|
||||
#define cosh(__x) __tg_full(__x, cosh)
|
||||
#define sinh(__x) __tg_full(__x, sinh)
|
||||
#define tanh(__x) __tg_full(__x, tanh)
|
||||
#define exp(__x) __tg_full(__x, exp)
|
||||
#define log(__x) __tg_full(__x, log)
|
||||
#define pow(__x, __y) __tg_impl_full(__x, __x, __y, pow, powf, powl, \
|
||||
cpow, cpowf, cpowl, __x, __y)
|
||||
#define sqrt(__x) __tg_full(__x, sqrt)
|
||||
|
||||
/* "The corresponding type-generic macro for fabs and cabs is fabs." */
|
||||
#define fabs(__x) __tg_impl_full(__x, __x, __x, fabs, fabsf, fabsl, \
|
||||
cabs, cabsf, cabsl, __x)
|
||||
|
||||
/* 7.22#5 -- These macros are only defined for arguments with real type. */
|
||||
#define atan2(__x, __y) __tg_simple2(__x, __y, atan2)
|
||||
#define cbrt(__x) __tg_simple(__x, cbrt)
|
||||
#define ceil(__x) __tg_simple(__x, ceil)
|
||||
#define copysign(__x, __y) __tg_simple2(__x, __y, copysign)
|
||||
#define erf(__x) __tg_simple(__x, erf)
|
||||
#define erfc(__x) __tg_simple(__x, erfc)
|
||||
#define exp2(__x) __tg_simple(__x, exp2)
|
||||
#define expm1(__x) __tg_simple(__x, expm1)
|
||||
#define fdim(__x, __y) __tg_simple2(__x, __y, fdim)
|
||||
#define floor(__x) __tg_simple(__x, floor)
|
||||
#define fma(__x, __y, __z) __tg_impl_simple(__x, __y, __z, fma, fmaf, fmal, \
|
||||
__x, __y, __z)
|
||||
#define fmax(__x, __y) __tg_simple2(__x, __y, fmax)
|
||||
#define fmin(__x, __y) __tg_simple2(__x, __y, fmin)
|
||||
#define fmod(__x, __y) __tg_simple2(__x, __y, fmod)
|
||||
#define frexp(__x, __y) __tg_simplev(__x, frexp, __x, __y)
|
||||
#define hypot(__x, __y) __tg_simple2(__x, __y, hypot)
|
||||
#define ilogb(__x) __tg_simple(__x, ilogb)
|
||||
#define ldexp(__x, __y) __tg_simplev(__x, ldexp, __x, __y)
|
||||
#define lgamma(__x) __tg_simple(__x, lgamma)
|
||||
#define llrint(__x) __tg_simple(__x, llrint)
|
||||
#define llround(__x) __tg_simple(__x, llround)
|
||||
#define log10(__x) __tg_simple(__x, log10)
|
||||
#define log1p(__x) __tg_simple(__x, log1p)
|
||||
#define log2(__x) __tg_simple(__x, log2)
|
||||
#define logb(__x) __tg_simple(__x, logb)
|
||||
#define lrint(__x) __tg_simple(__x, lrint)
|
||||
#define lround(__x) __tg_simple(__x, lround)
|
||||
#define nearbyint(__x) __tg_simple(__x, nearbyint)
|
||||
#define nextafter(__x, __y) __tg_simple2(__x, __y, nextafter)
|
||||
/* not yet implemented even for _LDBL_EQ_DBL platforms
|
||||
#define nexttoward(__x, __y) __tg_simplev(__x, nexttoward, __x, __y)
|
||||
*/
|
||||
#define remainder(__x, __y) __tg_simple2(__x, __y, remainder)
|
||||
#define remquo(__x, __y, __z) __tg_impl_simple(__x, __x, __y, remquo, remquof, \
|
||||
remquol, __x, __y, __z)
|
||||
#define rint(__x) __tg_simple(__x, rint)
|
||||
#define round(__x) __tg_simple(__x, round)
|
||||
#define scalbn(__x, __y) __tg_simplev(__x, scalbn, __x, __y)
|
||||
#define scalbln(__x, __y) __tg_simplev(__x, scalbln, __x, __y)
|
||||
#define tgamma(__x) __tg_simple(__x, tgamma)
|
||||
#define trunc(__x) __tg_simple(__x, trunc)
|
||||
|
||||
/* 7.22#6 -- These macros always expand to complex functions. */
|
||||
#define carg(__x) __tg_simple(__x, carg)
|
||||
#define cimag(__x) __tg_simple(__x, cimag)
|
||||
#define conj(__x) __tg_simple(__x, conj)
|
||||
#define cproj(__x) __tg_simple(__x, cproj)
|
||||
#define creal(__x) __tg_simple(__x, creal)
|
||||
|
||||
#endif /* !_TGMATH_H_ */
|
|
@ -10,9 +10,9 @@
|
|||
#include "_ansi.h"
|
||||
#include <sys/reent.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
/* Get _CLOCKS_PER_SEC_ */
|
||||
#include <machine/time.h>
|
||||
|
@ -23,8 +23,6 @@
|
|||
|
||||
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
|
||||
#define CLK_TCK CLOCKS_PER_SEC
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -53,12 +51,17 @@ char *_EXFUN(ctime, (const time_t *_time));
|
|||
struct tm *_EXFUN(gmtime, (const time_t *_timer));
|
||||
struct tm *_EXFUN(localtime,(const time_t *_timer));
|
||||
#endif
|
||||
size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t));
|
||||
size_t _EXFUN(strftime, (char *__restrict _s,
|
||||
size_t _maxsize, const char *__restrict _fmt,
|
||||
const struct tm *__restrict _t));
|
||||
|
||||
char *_EXFUN(asctime_r, (const struct tm *, char *));
|
||||
char *_EXFUN(asctime_r, (const struct tm *__restrict,
|
||||
char *__restrict));
|
||||
char *_EXFUN(ctime_r, (const time_t *, char *));
|
||||
struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *));
|
||||
struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *));
|
||||
struct tm *_EXFUN(gmtime_r, (const time_t *__restrict,
|
||||
struct tm *__restrict));
|
||||
struct tm *_EXFUN(localtime_r, (const time_t *__restrict,
|
||||
struct tm *__restrict));
|
||||
|
||||
_END_STD_C
|
||||
|
||||
|
@ -67,7 +70,9 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
char *_EXFUN(strptime, (const char *, const char *, struct tm *));
|
||||
char *_EXFUN(strptime, (const char *__restrict,
|
||||
const char *__restrict,
|
||||
struct tm *__restrict));
|
||||
_VOID _EXFUN(tzset, (_VOID));
|
||||
_VOID _EXFUN(_tzset_r, (struct _reent *));
|
||||
|
||||
|
@ -152,7 +157,9 @@ int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res));
|
|||
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
|
||||
|
||||
int _EXFUN(timer_create,
|
||||
(clockid_t clock_id, struct sigevent *evp, timer_t *timerid));
|
||||
(clockid_t clock_id,
|
||||
struct sigevent *__restrict evp,
|
||||
timer_t *__restrict timerid));
|
||||
|
||||
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
|
||||
|
||||
|
@ -161,8 +168,9 @@ int _EXFUN(timer_delete, (timer_t timerid));
|
|||
/* Per-Process Timers, P1003.1b-1993, p. 267 */
|
||||
|
||||
int _EXFUN(timer_settime,
|
||||
(timer_t timerid, int flags, const struct itimerspec *value,
|
||||
struct itimerspec *ovalue));
|
||||
(timer_t timerid, int flags,
|
||||
const struct itimerspec *__restrict value,
|
||||
struct itimerspec *__restrict ovalue));
|
||||
int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value));
|
||||
int _EXFUN(timer_getoverrun, (timer_t timerid));
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
#define __need_wint_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#define __need___va_list
|
||||
|
@ -19,28 +20,35 @@
|
|||
/* For __STDC_ISO_10646__ */
|
||||
#include <sys/features.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef WEOF
|
||||
# define WEOF ((wint_t)-1)
|
||||
#endif
|
||||
|
||||
#ifndef WCHAR_MIN
|
||||
#define WCHAR_MIN 0
|
||||
#ifdef __WCHAR_MIN__
|
||||
#define WCHAR_MIN __WCHAR_MIN__
|
||||
#elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
|
||||
#define WCHAR_MIN (0 + L'\0')
|
||||
#else
|
||||
#define WCHAR_MIN (-0x7fffffff - 1 + L'\0')
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef WCHAR_MAX
|
||||
#ifdef __WCHAR_MAX__
|
||||
#define WCHAR_MAX __WCHAR_MAX__
|
||||
#elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
|
||||
#define WCHAR_MAX (0xffffffffu + L'\0')
|
||||
#else
|
||||
#define WCHAR_MAX 0x7fffffffu
|
||||
#define WCHAR_MAX (0x7fffffff + L'\0')
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_BEGIN_STD_C
|
||||
|
||||
/* As in stdio.h, <sys/reent.h> defines __FILE. */
|
||||
typedef __FILE FILE;
|
||||
|
||||
/* As required by POSIX.1-2008, declare tm as incomplete type.
|
||||
The actual definition is in time.h. */
|
||||
struct tm;
|
||||
|
@ -52,77 +60,96 @@ typedef _mbstate_t mbstate_t;
|
|||
|
||||
wint_t _EXFUN(btowc, (int));
|
||||
int _EXFUN(wctob, (wint_t));
|
||||
size_t _EXFUN(mbrlen, (const char * , size_t, mbstate_t *));
|
||||
size_t _EXFUN(mbrtowc, (wchar_t * , const char * , size_t, mbstate_t *));
|
||||
size_t _EXFUN(mbrlen, (const char *__restrict, size_t, mbstate_t *__restrict));
|
||||
size_t _EXFUN(mbrtowc, (wchar_t *__restrict, const char *__restrict, size_t,
|
||||
mbstate_t *__restrict));
|
||||
size_t _EXFUN(_mbrtowc_r, (struct _reent *, wchar_t * , const char * ,
|
||||
size_t, mbstate_t *));
|
||||
int _EXFUN(mbsinit, (const mbstate_t *));
|
||||
size_t _EXFUN(mbsnrtowcs, (wchar_t * , const char ** , size_t, size_t,
|
||||
mbstate_t *));
|
||||
size_t _EXFUN(mbsnrtowcs, (wchar_t *__restrict, const char **__restrict,
|
||||
size_t, size_t, mbstate_t *__restrict));
|
||||
size_t _EXFUN(_mbsnrtowcs_r, (struct _reent *, wchar_t * , const char ** ,
|
||||
size_t, size_t, mbstate_t *));
|
||||
size_t _EXFUN(mbsrtowcs, (wchar_t * , const char ** , size_t, mbstate_t *));
|
||||
size_t _EXFUN(mbsrtowcs, (wchar_t *__restrict, const char **__restrict, size_t,
|
||||
mbstate_t *__restrict));
|
||||
size_t _EXFUN(_mbsrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *));
|
||||
size_t _EXFUN(wcrtomb, (char * , wchar_t, mbstate_t *));
|
||||
size_t _EXFUN(wcrtomb, (char *__restrict, wchar_t, mbstate_t *__restrict));
|
||||
size_t _EXFUN(_wcrtomb_r, (struct _reent *, char * , wchar_t, mbstate_t *));
|
||||
size_t _EXFUN(wcsnrtombs, (char * , const wchar_t ** , size_t, size_t,
|
||||
mbstate_t *));
|
||||
size_t _EXFUN(wcsnrtombs, (char *__restrict, const wchar_t **__restrict,
|
||||
size_t, size_t, mbstate_t *__restrict));
|
||||
size_t _EXFUN(_wcsnrtombs_r, (struct _reent *, char * , const wchar_t ** ,
|
||||
size_t, size_t, mbstate_t *));
|
||||
size_t _EXFUN(wcsrtombs, (char * , const wchar_t ** , size_t, mbstate_t *));
|
||||
size_t _EXFUN(wcsrtombs, (char *__restrict, const wchar_t **__restrict,
|
||||
size_t, mbstate_t *__restrict));
|
||||
size_t _EXFUN(_wcsrtombs_r, (struct _reent *, char * , const wchar_t ** ,
|
||||
size_t, mbstate_t *));
|
||||
int _EXFUN(wcscasecmp, (const wchar_t *, const wchar_t *));
|
||||
wchar_t *_EXFUN(wcscat, (wchar_t * , const wchar_t *));
|
||||
wchar_t *_EXFUN(wcscat, (wchar_t *__restrict, const wchar_t *__restrict));
|
||||
wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t));
|
||||
int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *));
|
||||
int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *));
|
||||
wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *));
|
||||
wchar_t *_EXFUN(wcpcpy, (wchar_t * , const wchar_t *));
|
||||
wchar_t *_EXFUN(wcscpy, (wchar_t *__restrict, const wchar_t *__restrict));
|
||||
wchar_t *_EXFUN(wcpcpy, (wchar_t *__restrict,
|
||||
const wchar_t *__restrict));
|
||||
wchar_t *_EXFUN(wcsdup, (const wchar_t *));
|
||||
wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * ));
|
||||
size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *));
|
||||
size_t _EXFUN(wcsftime, (wchar_t *, size_t, const wchar_t *, const struct tm *));
|
||||
size_t _EXFUN(wcsftime, (wchar_t *__restrict, size_t,
|
||||
const wchar_t *__restrict, const struct tm *__restrict));
|
||||
size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t));
|
||||
size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t));
|
||||
size_t _EXFUN(wcslen, (const wchar_t *));
|
||||
int _EXFUN(wcsncasecmp, (const wchar_t *, const wchar_t *, size_t));
|
||||
wchar_t *_EXFUN(wcsncat, (wchar_t * , const wchar_t * , size_t));
|
||||
wchar_t *_EXFUN(wcsncat, (wchar_t *__restrict,
|
||||
const wchar_t *__restrict, size_t));
|
||||
int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t));
|
||||
wchar_t *_EXFUN(wcsncpy, (wchar_t * , const wchar_t * , size_t));
|
||||
wchar_t *_EXFUN(wcpncpy, (wchar_t * , const wchar_t * , size_t));
|
||||
wchar_t *_EXFUN(wcsncpy, (wchar_t *__restrict,
|
||||
const wchar_t *__restrict, size_t));
|
||||
wchar_t *_EXFUN(wcpncpy, (wchar_t *__restrict,
|
||||
const wchar_t *__restrict, size_t));
|
||||
size_t _EXFUN(wcsnlen, (const wchar_t *, size_t));
|
||||
wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *));
|
||||
wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t));
|
||||
size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *));
|
||||
wchar_t *_EXFUN(wcsstr, (const wchar_t *, const wchar_t *));
|
||||
wchar_t *_EXFUN(wcstok, (wchar_t *, const wchar_t *, wchar_t **));
|
||||
double _EXFUN(wcstod, (const wchar_t *, wchar_t **));
|
||||
wchar_t *_EXFUN(wcsstr, (const wchar_t *__restrict,
|
||||
const wchar_t *__restrict));
|
||||
wchar_t *_EXFUN(wcstok, (wchar_t *__restrict, const wchar_t *__restrict,
|
||||
wchar_t **__restrict));
|
||||
double _EXFUN(wcstod, (const wchar_t *__restrict, wchar_t **__restrict));
|
||||
double _EXFUN(_wcstod_r, (struct _reent *, const wchar_t *, wchar_t **));
|
||||
float _EXFUN(wcstof, (const wchar_t *, wchar_t **));
|
||||
float _EXFUN(wcstof, (const wchar_t *__restrict, wchar_t **__restrict));
|
||||
float _EXFUN(_wcstof_r, (struct _reent *, const wchar_t *, wchar_t **));
|
||||
int _EXFUN(wcswidth, (const wchar_t *, size_t));
|
||||
size_t _EXFUN(wcsxfrm, (wchar_t *, const wchar_t *, size_t));
|
||||
size_t _EXFUN(wcsxfrm, (wchar_t *__restrict, const wchar_t *__restrict,
|
||||
size_t));
|
||||
int _EXFUN(wcwidth, (const wchar_t));
|
||||
wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t));
|
||||
int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t));
|
||||
wchar_t *_EXFUN(wmemcpy, (wchar_t * , const wchar_t * , size_t));
|
||||
wchar_t *_EXFUN(wmemcpy, (wchar_t *__restrict, const wchar_t *__restrict,
|
||||
size_t));
|
||||
wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t));
|
||||
wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t));
|
||||
|
||||
long _EXFUN(wcstol, (const wchar_t *, wchar_t **, int));
|
||||
long long _EXFUN(wcstoll, (const wchar_t *, wchar_t **, int));
|
||||
unsigned long _EXFUN(wcstoul, (const wchar_t *, wchar_t **, int));
|
||||
unsigned long long _EXFUN(wcstoull, (const wchar_t *, wchar_t **, int));
|
||||
long _EXFUN(wcstol, (const wchar_t *__restrict, wchar_t **__restrict, int));
|
||||
long long _EXFUN(wcstoll, (const wchar_t *__restrict, wchar_t **__restrict,
|
||||
int));
|
||||
unsigned long _EXFUN(wcstoul, (const wchar_t *__restrict, wchar_t **__restrict,
|
||||
int));
|
||||
unsigned long long _EXFUN(wcstoull, (const wchar_t *__restrict,
|
||||
wchar_t **__restrict, int));
|
||||
long _EXFUN(_wcstol_r, (struct _reent *, const wchar_t *, wchar_t **, int));
|
||||
long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *, wchar_t **, int));
|
||||
unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int));
|
||||
unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int));
|
||||
/* On platforms where long double equals double. */
|
||||
#ifdef _LDBL_EQ_DBL
|
||||
long double _EXFUN(wcstold, (const wchar_t *, wchar_t **));
|
||||
#endif /* _LDBL_EQ_DBL */
|
||||
|
||||
wint_t _EXFUN(fgetwc, (__FILE *));
|
||||
wchar_t *_EXFUN(fgetws, (wchar_t *, int, __FILE *));
|
||||
wchar_t *_EXFUN(fgetws, (wchar_t *__restrict, int, __FILE *__restrict));
|
||||
wint_t _EXFUN(fputwc, (wchar_t, __FILE *));
|
||||
int _EXFUN(fputws, (const wchar_t *, __FILE *));
|
||||
int _EXFUN(fputws, (const wchar_t *__restrict, __FILE *__restrict));
|
||||
int _EXFUN (fwide, (__FILE *, int));
|
||||
wint_t _EXFUN (getwc, (__FILE *));
|
||||
wint_t _EXFUN (getwchar, (void));
|
||||
|
@ -152,12 +179,15 @@ __FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *));
|
|||
#endif
|
||||
#endif
|
||||
|
||||
int _EXFUN(fwprintf, (__FILE *, const wchar_t *, ...));
|
||||
int _EXFUN(swprintf, (wchar_t *, size_t, const wchar_t *, ...));
|
||||
int _EXFUN(vfwprintf, (__FILE *, const wchar_t *, __VALIST));
|
||||
int _EXFUN(vswprintf, (wchar_t *, size_t, const wchar_t *, __VALIST));
|
||||
int _EXFUN(vwprintf, (const wchar_t *, __VALIST));
|
||||
int _EXFUN(wprintf, (const wchar_t *, ...));
|
||||
int _EXFUN(fwprintf, (__FILE *__restrict, const wchar_t *__restrict, ...));
|
||||
int _EXFUN(swprintf, (wchar_t *__restrict, size_t,
|
||||
const wchar_t *__restrict, ...));
|
||||
int _EXFUN(vfwprintf, (__FILE *__restrict, const wchar_t *__restrict,
|
||||
__VALIST));
|
||||
int _EXFUN(vswprintf, (wchar_t *__restrict, size_t,
|
||||
const wchar_t *__restrict, __VALIST));
|
||||
int _EXFUN(vwprintf, (const wchar_t *__restrict, __VALIST));
|
||||
int _EXFUN(wprintf, (const wchar_t *__restrict, ...));
|
||||
|
||||
int _EXFUN(_fwprintf_r, (struct _reent *, __FILE *, const wchar_t *, ...));
|
||||
int _EXFUN(_swprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, ...));
|
||||
|
@ -166,12 +196,15 @@ int _EXFUN(_vswprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, _
|
|||
int _EXFUN(_vwprintf_r, (struct _reent *, const wchar_t *, __VALIST));
|
||||
int _EXFUN(_wprintf_r, (struct _reent *, const wchar_t *, ...));
|
||||
|
||||
int _EXFUN(fwscanf, (__FILE *, const wchar_t *, ...));
|
||||
int _EXFUN(swscanf, (const wchar_t *, const wchar_t *, ...));
|
||||
int _EXFUN(vfwscanf, (__FILE *, const wchar_t *, __VALIST));
|
||||
int _EXFUN(vswscanf, (const wchar_t *, const wchar_t *, __VALIST));
|
||||
int _EXFUN(vwscanf, (const wchar_t *, __VALIST));
|
||||
int _EXFUN(wscanf, (const wchar_t *, ...));
|
||||
int _EXFUN(fwscanf, (__FILE *__restrict, const wchar_t *__restrict, ...));
|
||||
int _EXFUN(swscanf, (const wchar_t *__restrict,
|
||||
const wchar_t *__restrict, ...));
|
||||
int _EXFUN(vfwscanf, (__FILE *__restrict, const wchar_t *__restrict,
|
||||
__VALIST));
|
||||
int _EXFUN(vswscanf, (const wchar_t *__restrict, const wchar_t *__restrict,
|
||||
__VALIST));
|
||||
int _EXFUN(vwscanf, (const wchar_t *__restrict, __VALIST));
|
||||
int _EXFUN(wscanf, (const wchar_t *__restrict, ...));
|
||||
|
||||
int _EXFUN(_fwscanf_r, (struct _reent *, __FILE *, const wchar_t *, ...));
|
||||
int _EXFUN(_swscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, ...));
|
||||
|
@ -182,13 +215,8 @@ int _EXFUN(_wscanf_r, (struct _reent *, const wchar_t *, ...));
|
|||
|
||||
#define getwc(fp) fgetwc(fp)
|
||||
#define putwc(wc,fp) fputwc((wc), (fp))
|
||||
#ifndef _REENT_ONLY
|
||||
#define getwchar() fgetwc(_REENT->_stdin)
|
||||
#define putwchar(wc) fputwc((wc), _REENT->_stdout)
|
||||
#else
|
||||
#define getwchar() fgetwc(_impure_ptr->_stdin)
|
||||
#define putwchar(wc) fputwc((wc), _impure_ptr->_stdout)
|
||||
#endif
|
||||
|
||||
_END_STD_C
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ enum {
|
|||
/* Note: This implementation of wordexp requires a version of bash
|
||||
that supports the --wordexp and --protected arguments to be present
|
||||
on the system. It does not support the WRDE_UNDEF flag. */
|
||||
int wordexp(const char *, wordexp_t *, int);
|
||||
int wordexp(const char *__restrict, wordexp_t *__restrict, int);
|
||||
void wordfree(wordexp_t *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syslimits.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "setlocale.h"
|
||||
#include "ldpart.h"
|
||||
|
||||
static int split_lines(char *, const char *);
|
||||
static void set_from_buf(const char *, int, const char **);
|
||||
|
||||
int
|
||||
__part_load_locale(const char *name,
|
||||
int *using_locale,
|
||||
char *locale_buf,
|
||||
const char *category_filename,
|
||||
int locale_buf_size_max,
|
||||
int locale_buf_size_min,
|
||||
const char **dst_localebuf) {
|
||||
|
||||
static char locale_buf_C[] = "C";
|
||||
static int num_lines;
|
||||
|
||||
int fd;
|
||||
char *lbuf;
|
||||
char *p;
|
||||
const char *plim;
|
||||
char filename[PATH_MAX];
|
||||
#ifdef __USE_INTERNAL_STAT64
|
||||
struct stat64 st;
|
||||
#else
|
||||
struct stat st;
|
||||
#endif
|
||||
size_t namesize;
|
||||
size_t bufsize;
|
||||
int save_using_locale;
|
||||
char *nptr;
|
||||
|
||||
save_using_locale = *using_locale;
|
||||
*using_locale = 0;
|
||||
|
||||
if (name == NULL)
|
||||
goto no_locale;
|
||||
|
||||
if (!strcmp(name, "C") || !strcmp(name, "POSIX"))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* If the locale name is the same as our cache, use the cache.
|
||||
*/
|
||||
lbuf = locale_buf;
|
||||
if (lbuf != NULL && strcmp(name, lbuf) == 0) {
|
||||
set_from_buf(lbuf, num_lines, dst_localebuf);
|
||||
*using_locale = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Slurp the locale file into the cache.
|
||||
*/
|
||||
namesize = strlen(name) + 1;
|
||||
|
||||
if (!_PathLocale)
|
||||
goto no_locale;
|
||||
/* Range checking not needed, 'name' size is limited */
|
||||
strcpy(filename, _PathLocale);
|
||||
strcat(filename, "/");
|
||||
strcat(filename, name);
|
||||
strcat(filename, "/");
|
||||
strcat(filename, category_filename);
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
goto no_locale;
|
||||
#ifdef __USE_INTERNAL_STAT64
|
||||
if (fstat64(fd, &st) != 0)
|
||||
#else
|
||||
if (fstat(fd, &st) != 0)
|
||||
#endif
|
||||
goto bad_locale;
|
||||
if (st.st_size <= 0)
|
||||
goto bad_locale;
|
||||
bufsize = namesize + st.st_size;
|
||||
locale_buf = NULL;
|
||||
|
||||
if (lbuf == NULL || lbuf == locale_buf_C)
|
||||
{
|
||||
lbuf = malloc(bufsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
nptr = realloc(lbuf, bufsize);
|
||||
if (!nptr && lbuf)
|
||||
free (lbuf);
|
||||
lbuf = nptr;
|
||||
}
|
||||
|
||||
if (lbuf == NULL)
|
||||
goto bad_locale;
|
||||
(void) strcpy(lbuf, name);
|
||||
p = lbuf + namesize;
|
||||
plim = p + st.st_size;
|
||||
if (read(fd, p, (size_t) st.st_size) != st.st_size)
|
||||
goto bad_lbuf;
|
||||
if (close(fd) != 0)
|
||||
goto bad_lbuf;
|
||||
/*
|
||||
* Parse the locale file into localebuf.
|
||||
*/
|
||||
if (plim[-1] != '\n')
|
||||
goto bad_lbuf;
|
||||
num_lines = split_lines(p, plim);
|
||||
if (num_lines >= locale_buf_size_max)
|
||||
num_lines = locale_buf_size_max;
|
||||
else if (num_lines >= locale_buf_size_min)
|
||||
num_lines = locale_buf_size_min;
|
||||
else
|
||||
goto reset_locale;
|
||||
set_from_buf(lbuf, num_lines, dst_localebuf);
|
||||
/*
|
||||
* Record the successful parse in the cache.
|
||||
*/
|
||||
locale_buf = lbuf;
|
||||
|
||||
*using_locale = 1;
|
||||
return 0;
|
||||
|
||||
reset_locale:
|
||||
locale_buf = locale_buf_C;
|
||||
save_using_locale = 0;
|
||||
bad_lbuf:
|
||||
free(lbuf);
|
||||
bad_locale:
|
||||
(void)close(fd);
|
||||
no_locale:
|
||||
*using_locale = save_using_locale;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
split_lines(char *p, const char *plim) {
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; p < plim; i++) {
|
||||
p = strchr(p, '\n');
|
||||
*p++ = '\0';
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static void
|
||||
set_from_buf(const char *p, int num_lines, const char **dst_localebuf) {
|
||||
|
||||
const char **ap;
|
||||
int i;
|
||||
|
||||
for (ap = dst_localebuf, i = 0; i < num_lines; ++ap, ++i)
|
||||
*ap = p += strlen(p) + 1;
|
||||
}
|
||||
|
|
@ -188,7 +188,11 @@ No supporting OS subroutines are required.
|
|||
#define _LC_LAST 7
|
||||
#define ENCODING_LEN 31
|
||||
|
||||
#ifdef __CYGWIN__ /* Cygwin starts with LC_CTYPE set to "C.UTF-8". */
|
||||
int __EXPORT __mb_cur_max = 6;
|
||||
#else
|
||||
int __EXPORT __mb_cur_max = 1;
|
||||
#endif
|
||||
|
||||
int __nlocale_changed = 0;
|
||||
int __mlocale_changed = 0;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -16,6 +15,9 @@
|
|||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -39,49 +41,18 @@ DESCRIPTION
|
|||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
extern unsigned __NFiles;
|
||||
|
||||
|
||||
#define __handle_check( __h, __r ) \
|
||||
if( (__h) < 0 || (__h) > __NFiles ) { \
|
||||
ptr->_errno = EBADF ; \
|
||||
return( __r ); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
_DEFUN(_close_r, (ptr, fd),
|
||||
struct _reent *ptr _AND
|
||||
int fd)
|
||||
_close_r (ptr, fd)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
{
|
||||
int ret;
|
||||
int h;
|
||||
int ret;
|
||||
|
||||
__file_handle *fh;
|
||||
|
||||
__handle_check( fd, -1 );
|
||||
|
||||
fh = (__file_handle*) __getOSHandle( fd );
|
||||
|
||||
if( fd > STDERR_FILENO )
|
||||
{
|
||||
_free_r(ptr, fh->name);
|
||||
_free_r(ptr, fh);
|
||||
__freePOSIXHandle( fd );
|
||||
__SetIOMode_nogrow( fd, 0 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_DEFUN( close,(fd),
|
||||
int fd)
|
||||
{
|
||||
return _close_r(_REENT, fd);
|
||||
errno = 0;
|
||||
if ((ret = _close (fd)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <_syslist.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -25,6 +22,8 @@ int _dummy_fstat_syscalls = 1;
|
|||
#else
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -51,106 +50,18 @@ DESCRIPTION
|
|||
<<errno>>.
|
||||
*/
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
char sec;
|
||||
char min;
|
||||
char hour;
|
||||
char rsv;
|
||||
}detime_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char day;
|
||||
char month;
|
||||
short year;
|
||||
}dedate_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned attr;
|
||||
unsigned flags;
|
||||
union
|
||||
{
|
||||
detime_t ctime;
|
||||
unsigned cr_time;
|
||||
};
|
||||
union
|
||||
{
|
||||
dedate_t cdate;
|
||||
unsigned cr_date;
|
||||
};
|
||||
union
|
||||
{
|
||||
detime_t atime;
|
||||
unsigned acc_time;
|
||||
};
|
||||
union
|
||||
{
|
||||
dedate_t adate;
|
||||
unsigned acc_date;
|
||||
};
|
||||
union
|
||||
{
|
||||
detime_t mtime;
|
||||
unsigned mod_time;
|
||||
};
|
||||
union
|
||||
{
|
||||
dedate_t mdate;
|
||||
unsigned mod_date;
|
||||
};
|
||||
unsigned size;
|
||||
unsigned size_high;
|
||||
} FILEINFO;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
extern unsigned __NFiles;
|
||||
|
||||
#define __handle_check( __h, __r ) \
|
||||
if( (__h) < 0 || (__h) > __NFiles ) { \
|
||||
ptr->_errno = EBADF ; \
|
||||
return( __r ); \
|
||||
}
|
||||
|
||||
int
|
||||
_fstat_r (ptr, fd, pstat)
|
||||
struct _reent *ptr;
|
||||
int fd;
|
||||
struct stat *pstat;
|
||||
{
|
||||
FILEINFO info;
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
__file_handle *fh;
|
||||
|
||||
__handle_check( fd, -1 );
|
||||
|
||||
if (fd < 3)
|
||||
{
|
||||
pstat->st_mode = S_IFCHR;
|
||||
pstat->st_blksize = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fh = (__file_handle*) __getOSHandle( fd );
|
||||
get_fileinfo(fh->name, &info);
|
||||
|
||||
memset (pstat, 0, sizeof (* pstat));
|
||||
pstat->st_mode = S_IFREG;
|
||||
pstat->st_blksize = 4096;
|
||||
pstat->st_size = info.size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_DEFUN (fstat, (fd, pstat),
|
||||
int fd _AND
|
||||
struct stat *pstat)
|
||||
{
|
||||
return _fstat_r (_REENT, fd, pstat);
|
||||
errno = 0;
|
||||
if ((ret = _fstat (fd, pstat)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -19,7 +19,3 @@ void init_reent()
|
|||
::"r"(ent));
|
||||
__sinit(ent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sys/time.h>
|
||||
#include <sys/times.h>
|
||||
#include <_syslist.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -27,7 +26,7 @@ int _dummy_gettimeofday_syscalls = 1;
|
|||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
static int errno;
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -74,40 +73,4 @@ _DEFUN (_gettimeofday_r, (ptr, ptimeval, ptimezone),
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
|
||||
|
||||
int
|
||||
_gettimeofday (struct timeval *tv, void *tz)
|
||||
{
|
||||
unsigned int xtmp;
|
||||
struct tm tmblk;
|
||||
|
||||
if( tv )
|
||||
{
|
||||
tv->tv_usec = 0;
|
||||
|
||||
__asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(3));
|
||||
tmblk.tm_sec = (xtmp>>16)&0xff;
|
||||
tmblk.tm_min = (xtmp>>8)&0xff;
|
||||
tmblk.tm_hour = xtmp&0xff;
|
||||
BCD_TO_BIN(tmblk.tm_sec);
|
||||
BCD_TO_BIN(tmblk.tm_min);
|
||||
BCD_TO_BIN(tmblk.tm_hour);
|
||||
__asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29));
|
||||
tmblk.tm_mday = (xtmp>>16)&0xff;
|
||||
tmblk.tm_mon = ((xtmp>>8)&0xff)-1;
|
||||
tmblk.tm_year = ((xtmp&0xff)+2000)-1900;
|
||||
tmblk.tm_wday = tmblk.tm_yday = 0;
|
||||
tmblk.tm_isdst = -1;
|
||||
tv->tv_sec = mktime(&tmblk);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Some targets provides their own versions of these functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -55,8 +54,10 @@ _isatty_r (ptr, fd)
|
|||
{
|
||||
int ret;
|
||||
|
||||
ptr->_errno = ENOTTY ;
|
||||
return 0;
|
||||
errno = 0;
|
||||
if ((ret = _isatty (fd)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/* 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
|
||||
_DEFUN (_link_r, (ptr, old, new),
|
||||
struct _reent *ptr _AND
|
||||
_CONST char *old _AND
|
||||
_CONST char *new)
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _link (old, new)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
|
@ -3,7 +3,6 @@
|
|||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -16,71 +15,9 @@
|
|||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
char sec;
|
||||
char min;
|
||||
char hour;
|
||||
char rsv;
|
||||
}detime_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char day;
|
||||
char month;
|
||||
short year;
|
||||
}dedate_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned attr;
|
||||
unsigned flags;
|
||||
union
|
||||
{
|
||||
detime_t ctime;
|
||||
unsigned cr_time;
|
||||
};
|
||||
union
|
||||
{
|
||||
dedate_t cdate;
|
||||
unsigned cr_date;
|
||||
};
|
||||
union
|
||||
{
|
||||
detime_t atime;
|
||||
unsigned acc_time;
|
||||
};
|
||||
union
|
||||
{
|
||||
dedate_t adate;
|
||||
unsigned acc_date;
|
||||
};
|
||||
union
|
||||
{
|
||||
detime_t mtime;
|
||||
unsigned mod_time;
|
||||
};
|
||||
union
|
||||
{
|
||||
dedate_t mdate;
|
||||
unsigned mod_date;
|
||||
};
|
||||
unsigned size;
|
||||
unsigned size_high;
|
||||
} FILEINFO;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
extern unsigned __NFiles;
|
||||
|
||||
#define __handle_check( __h, __r ) \
|
||||
if( (__h) < 0 || (__h) > __NFiles ) { \
|
||||
ptr->_errno = EBADF ; \
|
||||
return( __r ); \
|
||||
}
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -115,45 +52,12 @@ _DEFUN (_lseek_r, (ptr, fd, pos, whence),
|
|||
_off_t pos _AND
|
||||
int whence)
|
||||
{
|
||||
_off_t ret;
|
||||
__file_handle *fh;
|
||||
_off_t ret;
|
||||
|
||||
__handle_check( fd, -1 );
|
||||
fh = (__file_handle*) __getOSHandle( fd );
|
||||
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
ret = pos;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
ret = fh->offset + pos;
|
||||
break;
|
||||
case SEEK_END:
|
||||
{
|
||||
FILEINFO info;
|
||||
get_fileinfo(fh->name, &info);
|
||||
ret = pos + info.size;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ptr->_errno = EINVAL;
|
||||
return -1;
|
||||
};
|
||||
|
||||
fh->offset = ret;
|
||||
|
||||
return( ret );
|
||||
errno = 0;
|
||||
if ((ret = _lseek (fd, pos, whence)) == (_off_t) -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
_off_t
|
||||
_DEFUN (lseek, (fd, pos, whence),
|
||||
int fd _AND
|
||||
_off_t pos _AND
|
||||
int whence)
|
||||
|
||||
{
|
||||
return _lseek_r(_REENT, fd, pos, whence);
|
||||
};
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <_syslist.h>
|
||||
#include <sys/errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/kos_io.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -22,6 +17,8 @@
|
|||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -49,173 +46,20 @@ DESCRIPTION
|
|||
<<errno>>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define NULL_HANDLE (int)-1
|
||||
#define DUMMY_HANDLE (int)-2
|
||||
|
||||
#define _READ 0x0001 /* file opened for reading */
|
||||
#define _WRITE 0x0002 /* file opened for writing */
|
||||
#define _UNGET 0x0004 /* ungetc has been done */
|
||||
#define _BIGBUF 0x0008 /* big buffer allocated */
|
||||
#define _EOF 0x0010 /* EOF has occurred */
|
||||
#define _SFERR 0x0020 /* error has occurred on this file */
|
||||
#define _APPEND 0x0080 /* file opened for append */
|
||||
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */
|
||||
#define _TMPFIL 0x0800 /* this is a temporary file */
|
||||
#define _DIRTY 0x1000 /* buffer has been modified */
|
||||
#define _ISTTY 0x2000 /* is console device */
|
||||
#define _DYNAMIC 0x4000 /* FILE is dynamically allocated */
|
||||
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */
|
||||
#define _COMMIT 0x0001 /* extended flag: commit OS buffers on flush */
|
||||
|
||||
extern int _fmode;
|
||||
|
||||
|
||||
static inline void debug_out(const char val)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"int $0x40 \n\t"
|
||||
::"a"(63), "b"(1),"c"(val));
|
||||
}
|
||||
|
||||
int debugwrite(const char *path, const void *buff,
|
||||
size_t offset, size_t count, size_t *writes)
|
||||
{
|
||||
int ret = count;
|
||||
const char *p = buff;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
debug_out(*p++);
|
||||
};
|
||||
*writes = ret;
|
||||
return ret;
|
||||
};
|
||||
|
||||
static int __openFileHandle(const char *path, int mode, int *err)
|
||||
{
|
||||
fileinfo_t info;
|
||||
__file_handle *handle;
|
||||
|
||||
// path = getfullpath(name);
|
||||
|
||||
*err = get_fileinfo(path, &info);
|
||||
|
||||
if( mode & O_EXCL && mode & O_CREAT )
|
||||
{
|
||||
if( ! *err)
|
||||
{
|
||||
*err = EEXIST;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
if( *err)
|
||||
{
|
||||
if(mode & O_CREAT)
|
||||
*err=create_file(path);
|
||||
|
||||
if( *err)
|
||||
{
|
||||
return -1;
|
||||
};
|
||||
};
|
||||
if( mode & O_TRUNC )
|
||||
set_file_size(path, 0);
|
||||
|
||||
if ( !(handle=(__file_handle*)malloc(sizeof( __file_handle) )))
|
||||
{
|
||||
*err = ENOMEM;
|
||||
return -1;
|
||||
};
|
||||
|
||||
handle->name = strdup(path);
|
||||
handle->offset = 0;
|
||||
handle->write = write_file;
|
||||
|
||||
*err = 0;
|
||||
|
||||
return (int)handle;
|
||||
};
|
||||
|
||||
|
||||
|
||||
int
|
||||
_DEFUN (_open_r, (ptr, file, flags, dmode),
|
||||
_DEFUN (_open_r, (ptr, file, flags, mode),
|
||||
struct _reent *ptr _AND
|
||||
_CONST char *file _AND
|
||||
int flags _AND
|
||||
int dmode)
|
||||
int mode)
|
||||
{
|
||||
int hid;
|
||||
int handle;
|
||||
int err = 0;
|
||||
unsigned iomode_flags;
|
||||
int rwmode;
|
||||
|
||||
/*
|
||||
if (flags & ~(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_APPEND | O_TRUNC))
|
||||
{
|
||||
ptr->_errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
// First try to get the required slot.
|
||||
// No point in creating a file only to not use it. JBS 99/10/26
|
||||
hid = __allocPOSIXHandle( DUMMY_HANDLE );
|
||||
if( hid == -1 )
|
||||
{
|
||||
ptr->_errno = EMFILE;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
handle = __openFileHandle( file, flags, &err);
|
||||
|
||||
if( handle == -1 )
|
||||
{
|
||||
__freePOSIXHandle( hid );
|
||||
ptr->_errno = err;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
__setOSHandle( hid, handle ); // JBS 99/11/01
|
||||
|
||||
rwmode = flags & ( O_RDONLY | O_WRONLY | O_RDWR | O_NOINHERIT );
|
||||
|
||||
iomode_flags = 0;
|
||||
|
||||
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE;
|
||||
else if( rwmode == O_RDONLY) iomode_flags |= _READ;
|
||||
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE;
|
||||
if( flags & O_APPEND ) iomode_flags |= _APPEND;
|
||||
if( flags & (O_BINARY|O_TEXT) ) {
|
||||
if( flags & O_BINARY ) iomode_flags |= _BINARY;
|
||||
} else {
|
||||
if( _fmode == O_BINARY ) iomode_flags |= _BINARY;
|
||||
}
|
||||
__SetIOMode( hid, iomode_flags );
|
||||
|
||||
ptr->_errno = 0;
|
||||
|
||||
return (hid);
|
||||
}
|
||||
|
||||
int
|
||||
_DEFUN (open, (file, flags, ...),
|
||||
const char *file _AND
|
||||
int flags _DOTS)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start (ap, flags);
|
||||
ret = _open_r (_REENT, file, flags, va_arg (ap, int));
|
||||
va_end (ap);
|
||||
errno = 0;
|
||||
if ((ret = _open (file, flags, mode)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -17,6 +16,8 @@
|
|||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -44,29 +45,6 @@ DESCRIPTION
|
|||
<<errno>>.
|
||||
*/
|
||||
|
||||
|
||||
extern unsigned __NFiles;
|
||||
|
||||
#define _READ 0x0001 /* file opened for reading */
|
||||
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */
|
||||
#define _ISTTY 0x2000 /* is console device */
|
||||
|
||||
#define __handle_check( __h, __r ) \
|
||||
if( (__h) < 0 || (__h) > __NFiles ) { \
|
||||
ptr->_errno = EBADF; \
|
||||
return( __r ); \
|
||||
}
|
||||
|
||||
_ssize_t
|
||||
_DEFUN (_read, (fd, buf, cnt),
|
||||
int fd _AND
|
||||
_PTR buf _AND
|
||||
size_t cnt)
|
||||
{
|
||||
|
||||
return _read_r( _REENT, fd, buf, cnt);
|
||||
}
|
||||
|
||||
_ssize_t
|
||||
_DEFUN (_read_r, (ptr, fd, buf, cnt),
|
||||
struct _reent *ptr _AND
|
||||
|
@ -74,95 +52,12 @@ _DEFUN (_read_r, (ptr, fd, buf, cnt),
|
|||
_PTR buf _AND
|
||||
size_t cnt)
|
||||
{
|
||||
_ssize_t ret;
|
||||
_ssize_t ret;
|
||||
|
||||
_ssize_t read_len, total_len;
|
||||
unsigned reduce_idx, finish_idx;
|
||||
unsigned iomode_flags;
|
||||
char *buffer = buf;
|
||||
int rc;
|
||||
int h;
|
||||
unsigned amount_read;
|
||||
int err;
|
||||
|
||||
__file_handle *fh;
|
||||
|
||||
__handle_check( fd, -1 );
|
||||
__ChkTTYIOMode( fd );
|
||||
iomode_flags = __GetIOMode( fd );
|
||||
if( iomode_flags == 0 )
|
||||
{
|
||||
ptr->_errno = EBADF;
|
||||
return( -1 );
|
||||
}
|
||||
if( !(iomode_flags & _READ) )
|
||||
{
|
||||
ptr->_errno = EACCES; /* changed from EBADF to EACCES 23-feb-89 */
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
fh = (__file_handle*) __getOSHandle( fd );
|
||||
|
||||
if( iomode_flags & _BINARY ) /* if binary mode */
|
||||
{
|
||||
err = read_file(fh->name, buffer, fh->offset, cnt, &amount_read);
|
||||
fh->offset+= amount_read;
|
||||
total_len = amount_read;
|
||||
|
||||
if(err)
|
||||
if ( amount_read == 0)
|
||||
return (-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
total_len = 0;
|
||||
read_len = cnt;
|
||||
do
|
||||
{
|
||||
err=read_file(fh->name,buffer, fh->offset, cnt, &amount_read);
|
||||
fh->offset+=amount_read;
|
||||
|
||||
if( amount_read == 0 )
|
||||
break; /* EOF */
|
||||
|
||||
reduce_idx = 0;
|
||||
finish_idx = reduce_idx;
|
||||
for( ; reduce_idx < amount_read; ++reduce_idx )
|
||||
{
|
||||
if( buffer[ reduce_idx ] == 0x1a ) /* EOF */
|
||||
{
|
||||
_lseek_r(ptr, fd, ((long)reduce_idx - (long)amount_read)+1L,
|
||||
SEEK_CUR );
|
||||
total_len += finish_idx;
|
||||
return( total_len );
|
||||
}
|
||||
if( buffer[ reduce_idx ] != '\r' )
|
||||
{
|
||||
buffer[ finish_idx++ ] = buffer[ reduce_idx ];
|
||||
};
|
||||
}
|
||||
|
||||
total_len += finish_idx;
|
||||
buffer += finish_idx;
|
||||
read_len -= finish_idx;
|
||||
if( iomode_flags & _ISTTY )
|
||||
{
|
||||
break; /* 04-feb-88, FWC */
|
||||
}
|
||||
} while( read_len != 0 );
|
||||
}
|
||||
return( total_len );
|
||||
errno = 0;
|
||||
if ((ret = (_ssize_t)_read (fd, buf, cnt)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
_ssize_t
|
||||
_DEFUN (read, (fd, buf, cnt),
|
||||
int fd _AND
|
||||
_PTR buf _AND
|
||||
size_t cnt)
|
||||
{
|
||||
|
||||
return _read_r(_REENT, fd, buf, cnt);
|
||||
};
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/* Reentrant version of rename system call. */
|
||||
|
||||
#include <reent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.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
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<_rename_r>>---Reentrant version of rename
|
||||
|
||||
INDEX
|
||||
_rename_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _rename_r(struct _reent *<[ptr]>,
|
||||
const char *<[old]>, const char *<[new]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <reent.h>
|
||||
int _rename_r(<[ptr]>, <[old]>, <[new]>)
|
||||
struct _reent *<[ptr]>;
|
||||
char *<[old]>;
|
||||
char *<[new]>;
|
||||
|
||||
DESCRIPTION
|
||||
This is a reentrant version of <<rename>>. It
|
||||
takes a pointer to the global data block, which holds
|
||||
<<errno>>.
|
||||
*/
|
||||
|
||||
int
|
||||
_DEFUN (_rename_r, (ptr, old, new),
|
||||
struct _reent *ptr _AND
|
||||
_CONST char *old _AND
|
||||
_CONST char *new)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#ifdef HAVE_RENAME
|
||||
errno = 0;
|
||||
if ((ret = _rename (old, new)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
#else
|
||||
if (_link_r (ptr, old, new) == -1)
|
||||
return -1;
|
||||
|
||||
if (_unlink_r (ptr, old) == -1)
|
||||
{
|
||||
/* ??? Should we unlink new? (rhetorical question) */
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
|
@ -0,0 +1,63 @@
|
|||
/* Reentrant versions of times system calls */
|
||||
|
||||
#include <reent.h>
|
||||
#include <time.h>
|
||||
#include <sys/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_times_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
|
||||
_DEFUN (_times_r, (ptr, ptms),
|
||||
struct _reent *ptr _AND
|
||||
struct tms *ptms)
|
||||
{
|
||||
clock_t ret;
|
||||
|
||||
ret = _times (ptms);
|
||||
return ret;
|
||||
}
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
|
@ -0,0 +1,59 @@
|
|||
/* 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
|
||||
|
||||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
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
|
||||
_DEFUN (_unlink_r, (ptr, file),
|
||||
struct _reent *ptr _AND
|
||||
_CONST char *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = _unlink (file)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
|
@ -3,10 +3,6 @@
|
|||
#include <reent.h>
|
||||
#include <unistd.h>
|
||||
#include <_syslist.h>
|
||||
#include <alloca.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Some targets provides their own versions of this functions. Those
|
||||
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
||||
|
@ -20,6 +16,8 @@
|
|||
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||
|
||||
/* We use the errno variable used by the system dependent layer. */
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
|
@ -47,211 +45,19 @@ DESCRIPTION
|
|||
<<errno>>.
|
||||
*/
|
||||
|
||||
|
||||
#define _WRITE 0x0002 /* file opened for writing */
|
||||
#define _APPEND 0x0080 /* file opened for append */
|
||||
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */
|
||||
#define _ISTTY 0x2000 /* is console device */
|
||||
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */
|
||||
|
||||
#define __handle_check( __h, __r ) \
|
||||
if( (__h) < 0 || (__h) > __NFiles ) { \
|
||||
ptr->_errno = EBADF; \
|
||||
return( __r ); \
|
||||
}
|
||||
|
||||
extern unsigned __NFiles;
|
||||
|
||||
#define PAD_SIZE 512
|
||||
|
||||
static int zero_pad(struct _reent *ptr, int handle ) /* 09-jan-95 */
|
||||
/*******************************/
|
||||
{
|
||||
int rc;
|
||||
long curPos, eodPos;
|
||||
long bytesToWrite;
|
||||
unsigned writeAmt;
|
||||
char zeroBuf[PAD_SIZE];
|
||||
|
||||
// Pad with zeros due to lseek() past EOF (POSIX)
|
||||
curPos = _lseek_r( ptr, handle, 0L, SEEK_CUR ); /* current offset */
|
||||
if( curPos == -1 )
|
||||
return( -1 );
|
||||
eodPos = _lseek_r( ptr, handle, 0L, SEEK_END ); /* end of data offset */
|
||||
if( eodPos == -1 )
|
||||
return( -1 );
|
||||
|
||||
if( curPos > eodPos ) {
|
||||
bytesToWrite = curPos - eodPos; /* amount to pad by */
|
||||
|
||||
if( bytesToWrite > 0 ) { /* only write if needed */
|
||||
memset( zeroBuf, 0x00, PAD_SIZE ); /* zero out a buffer */
|
||||
do { /* loop until done */
|
||||
if( bytesToWrite > PAD_SIZE )
|
||||
writeAmt = 512;
|
||||
else
|
||||
writeAmt = (unsigned)bytesToWrite;
|
||||
rc = _write_r(ptr, handle, zeroBuf, writeAmt );
|
||||
if( rc < 0 )
|
||||
return( rc );
|
||||
bytesToWrite -= writeAmt; /* more bytes written */
|
||||
} while( bytesToWrite != 0 );
|
||||
}
|
||||
} else {
|
||||
curPos = _lseek_r( ptr, handle, curPos, SEEK_SET );
|
||||
if( curPos == -1 ) {
|
||||
return( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
return( 0 ); /* return success code */
|
||||
}
|
||||
|
||||
|
||||
static int os_write(struct _reent *ptr, int handle,
|
||||
const void *buffer, unsigned len, unsigned *amt )
|
||||
/********************************************************************************/
|
||||
{
|
||||
__file_handle *fh;
|
||||
int rc;
|
||||
|
||||
rc = 0;
|
||||
*amt = 0;
|
||||
|
||||
fh = (__file_handle*) __getOSHandle( handle );
|
||||
|
||||
rc = fh->write(fh->name,buffer,fh->offset,len,amt);
|
||||
|
||||
fh->offset+= *amt;
|
||||
|
||||
if( *amt != len )
|
||||
{
|
||||
rc = ENOSPC;
|
||||
ptr->_errno = ENOSPC;
|
||||
}
|
||||
return( rc );
|
||||
}
|
||||
_ssize_t
|
||||
_DEFUN (_write_r, (ptr, fd, buffer, cnt),
|
||||
_DEFUN (_write_r, (ptr, fd, buf, cnt),
|
||||
struct _reent *ptr _AND
|
||||
int fd _AND
|
||||
_CONST _PTR buffer _AND
|
||||
_CONST _PTR buf _AND
|
||||
size_t cnt)
|
||||
{
|
||||
_ssize_t ret;
|
||||
unsigned int iomode_flags;
|
||||
unsigned len_written, i, j;
|
||||
int rc2;
|
||||
char *buf;
|
||||
|
||||
__file_handle *fh;
|
||||
|
||||
__handle_check( fd, -1 );
|
||||
|
||||
iomode_flags = __GetIOMode( fd );
|
||||
if( iomode_flags == 0 )
|
||||
{
|
||||
ptr->_errno = EBADF;
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if( !(iomode_flags & _WRITE) ) {
|
||||
ptr->_errno = EACCES ; /* changed from EBADF to EACCES 23-feb-89 */
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if( (iomode_flags & _APPEND) && !(iomode_flags & _ISTTY) )
|
||||
{
|
||||
fh->offset = _lseek_r(ptr, fd, 0L, SEEK_END ); /* end of data offset */
|
||||
}
|
||||
|
||||
len_written = 0;
|
||||
rc2 = 0;
|
||||
|
||||
// Pad the file with zeros if necessary
|
||||
if( iomode_flags & _FILEEXT )
|
||||
{
|
||||
// turn off file extended flag
|
||||
__SetIOMode_nogrow( fd, iomode_flags&(~_FILEEXT) );
|
||||
|
||||
// It is not required to pad a file with zeroes on an NTFS file system;
|
||||
// unfortunately it is required on FAT (and probably FAT32). (JBS)
|
||||
rc2 = zero_pad( ptr, fd );
|
||||
}
|
||||
|
||||
if( rc2 == 0 )
|
||||
{
|
||||
if( iomode_flags & _BINARY ) { /* if binary mode */
|
||||
rc2 = os_write(ptr, fd, buffer, cnt, &len_written );
|
||||
/* end of binary mode part */
|
||||
} else { /* text mode */
|
||||
|
||||
int buf_size = 512;
|
||||
|
||||
buf = (char*)alloca( buf_size );
|
||||
|
||||
j = 0;
|
||||
for( i = 0; i < cnt; )
|
||||
{
|
||||
if( ((const char*)buffer)[i] == '\n' )
|
||||
{
|
||||
buf[j] = '\r';
|
||||
++j;
|
||||
if( j == buf_size )
|
||||
{
|
||||
rc2 = os_write(ptr, fd, buf, buf_size, &j );
|
||||
if( rc2 == -1 )
|
||||
break;
|
||||
len_written += j;
|
||||
if( rc2 == ENOSPC )
|
||||
break;
|
||||
len_written = i;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
buf[j] = ((const char*)buffer)[i];
|
||||
++i;
|
||||
++j;
|
||||
if( j == buf_size ) {
|
||||
rc2 = os_write(ptr, fd, buf, buf_size, &j );
|
||||
if( rc2 == -1 )
|
||||
break;
|
||||
len_written += j;
|
||||
if( rc2 == ENOSPC )
|
||||
break;
|
||||
len_written = i;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
if( j ) {
|
||||
rc2 = os_write(ptr, fd, buf, j, &i );
|
||||
if( rc2 == ENOSPC ) {
|
||||
len_written += i;
|
||||
} else {
|
||||
len_written = cnt;
|
||||
}
|
||||
}
|
||||
/* end of text mode part */
|
||||
}
|
||||
}
|
||||
|
||||
if( rc2 == -1 ) {
|
||||
return( rc2 );
|
||||
} else {
|
||||
return( len_written );
|
||||
}
|
||||
}
|
||||
|
||||
_ssize_t
|
||||
_DEFUN (write, ( fd, buffer, cnt),
|
||||
int fd _AND
|
||||
_CONST _PTR buffer _AND
|
||||
size_t cnt)
|
||||
|
||||
{
|
||||
|
||||
return _write_r(_REENT, fd, buffer, cnt);
|
||||
_ssize_t ret;
|
||||
|
||||
errno = 0;
|
||||
if ((ret = (_ssize_t)_write (fd, buf, cnt)) == -1 && errno != 0)
|
||||
ptr->_errno = errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
||||
|
|
|
@ -61,8 +61,6 @@ PORTABILITY
|
|||
No supporting OS subroutines are required.
|
||||
*/
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <reent.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
_PTR
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not 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.
|
||||
*/
|
||||
/* This code was copied from asprintf.c */
|
||||
/* doc in siprintf.c */
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <reent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include "local.h"
|
||||
|
||||
int
|
||||
_DEFUN(_asiprintf_r, (ptr, strp, fmt),
|
||||
struct _reent *ptr _AND
|
||||
char **strp _AND
|
||||
const char *fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
f._bf._base = f._p = NULL;
|
||||
f._bf._size = f._w = 0;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret >= 0)
|
||||
{
|
||||
*f._p = 0;
|
||||
*strp = (char *) f._bf._base;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
int
|
||||
_DEFUN(asiprintf, (strp, fmt),
|
||||
char **strp _AND
|
||||
const char *fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
f._bf._base = f._p = NULL;
|
||||
f._bf._size = f._w = 0;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfiprintf_r (_REENT, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret >= 0)
|
||||
{
|
||||
*f._p = 0;
|
||||
*strp = (char *) f._bf._base;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif /* ! _REENT_ONLY */
|
|
@ -0,0 +1,108 @@
|
|||
/* Copyright (C) 2007, 2008 Eric Blake
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
/* This code was derived from asprintf.c */
|
||||
/* doc in siprintf.c */
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <reent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include "local.h"
|
||||
|
||||
char *
|
||||
_DEFUN(_asniprintf_r, (ptr, buf, lenp, fmt),
|
||||
struct _reent *ptr _AND
|
||||
char *buf _AND
|
||||
size_t *lenp _AND
|
||||
const char *fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
size_t len = *lenp;
|
||||
|
||||
if (buf && len)
|
||||
{
|
||||
/* mark an existing buffer, but allow allocation of larger string */
|
||||
f._flags = __SWR | __SSTR | __SOPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
len = 0;
|
||||
buf = NULL;
|
||||
}
|
||||
f._bf._base = f._p = (unsigned char *) buf;
|
||||
/* For now, inherit the 32-bit signed limit of FILE._bf._size.
|
||||
FIXME - it would be nice to rewrite sys/reent.h to support size_t
|
||||
for _size. */
|
||||
if (len > INT_MAX)
|
||||
{
|
||||
ptr->_errno = EOVERFLOW;
|
||||
return NULL;
|
||||
}
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
*lenp = ret;
|
||||
*f._p = '\0';
|
||||
return (char *) f._bf._base;
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
char *
|
||||
_DEFUN(asniprintf, (buf, lenp, fmt),
|
||||
char *buf _AND
|
||||
size_t *lenp _AND
|
||||
const char *fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
size_t len = *lenp;
|
||||
struct _reent *ptr = _REENT;
|
||||
|
||||
if (buf && len)
|
||||
{
|
||||
/* mark an existing buffer, but allow allocation of larger string */
|
||||
f._flags = __SWR | __SSTR | __SOPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
len = 0;
|
||||
buf = NULL;
|
||||
}
|
||||
f._bf._base = f._p = (unsigned char *) buf;
|
||||
/* For now, inherit the 32-bit signed limit of FILE._bf._size.
|
||||
FIXME - it would be nice to rewrite sys/reent.h to support size_t
|
||||
for _size. */
|
||||
if (len > INT_MAX)
|
||||
{
|
||||
ptr->_errno = EOVERFLOW;
|
||||
return NULL;
|
||||
}
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
*lenp = ret;
|
||||
*f._p = '\0';
|
||||
return (char *) f._bf._base;
|
||||
}
|
||||
|
||||
#endif /* ! _REENT_ONLY */
|
|
@ -0,0 +1,108 @@
|
|||
/* Copyright (C) 2007, 2008 Eric Blake
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
/* This code was derived from asprintf.c */
|
||||
/* doc in sprintf.c */
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <reent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include "local.h"
|
||||
|
||||
char *
|
||||
_DEFUN(_asnprintf_r, (ptr, buf, lenp, fmt),
|
||||
struct _reent *__restrict ptr _AND
|
||||
char *buf _AND
|
||||
size_t *lenp _AND
|
||||
const char *__restrict fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
size_t len = *lenp;
|
||||
|
||||
if (buf && len)
|
||||
{
|
||||
/* mark an existing buffer, but allow allocation of larger string */
|
||||
f._flags = __SWR | __SSTR | __SOPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
len = 0;
|
||||
buf = NULL;
|
||||
}
|
||||
f._bf._base = f._p = (unsigned char *) buf;
|
||||
/* For now, inherit the 32-bit signed limit of FILE._bf._size.
|
||||
FIXME - it would be nice to rewrite sys/reent.h to support size_t
|
||||
for _size. */
|
||||
if (len > INT_MAX)
|
||||
{
|
||||
ptr->_errno = EOVERFLOW;
|
||||
return NULL;
|
||||
}
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
*lenp = ret;
|
||||
*f._p = '\0';
|
||||
return (char *) f._bf._base;
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
char *
|
||||
_DEFUN(asnprintf, (buf, lenp, fmt),
|
||||
char *__restrict buf _AND
|
||||
size_t *__restrict lenp _AND
|
||||
const char *__restrict fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
size_t len = *lenp;
|
||||
struct _reent *ptr = _REENT;
|
||||
|
||||
if (buf && len)
|
||||
{
|
||||
/* mark an existing buffer, but allow allocation of larger string */
|
||||
f._flags = __SWR | __SSTR | __SOPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
len = 0;
|
||||
buf = NULL;
|
||||
}
|
||||
f._bf._base = f._p = (unsigned char *) buf;
|
||||
/* For now, inherit the 32-bit signed limit of FILE._bf._size.
|
||||
FIXME - it would be nice to rewrite sys/reent.h to support size_t
|
||||
for _size. */
|
||||
if (len > INT_MAX)
|
||||
{
|
||||
ptr->_errno = EOVERFLOW;
|
||||
return NULL;
|
||||
}
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
*lenp = ret;
|
||||
*f._p = '\0';
|
||||
return (char *) f._bf._base;
|
||||
}
|
||||
|
||||
#endif /* ! _REENT_ONLY */
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not 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.
|
||||
*/
|
||||
/* This code was copied from sprintf.c */
|
||||
/* doc in sprintf.c */
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <reent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include "local.h"
|
||||
|
||||
int
|
||||
_DEFUN(_asprintf_r, (ptr, strp, fmt),
|
||||
struct _reent *ptr _AND
|
||||
char **__restrict strp _AND
|
||||
const char *__restrict fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
f._bf._base = f._p = NULL;
|
||||
f._bf._size = f._w = 0;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret >= 0)
|
||||
{
|
||||
*f._p = 0;
|
||||
*strp = (char *) f._bf._base;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
int
|
||||
_DEFUN(asprintf, (strp, fmt),
|
||||
char **__restrict strp _AND
|
||||
const char *__restrict fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
FILE f;
|
||||
|
||||
/* mark a zero-length reallocatable buffer */
|
||||
f._flags = __SWR | __SSTR | __SMBF;
|
||||
f._bf._base = f._p = NULL;
|
||||
f._bf._size = f._w = 0;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _svfprintf_r (_REENT, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret >= 0)
|
||||
{
|
||||
*f._p = 0;
|
||||
*strp = (char *) f._bf._base;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif /* ! _REENT_ONLY */
|
|
@ -65,7 +65,7 @@ _DEFUN(clearerr, (fp),
|
|||
FILE * fp)
|
||||
{
|
||||
CHECK_INIT(_REENT, fp);
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
__sclearerr (fp);
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
}
|
||||
|
|
|
@ -19,12 +19,13 @@ INDEX
|
|||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
int dprintf(int <[fd]>, const char *<[format]>, ...);
|
||||
int vdprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>);
|
||||
int dprintf(int <[fd]>, const char *restrict <[format]>, ...);
|
||||
int vdprintf(int <[fd]>, const char *restrict <[format]>,
|
||||
va_list <[ap]>);
|
||||
int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>,
|
||||
const char *<[format]>, ...);
|
||||
const char *restrict <[format]>, ...);
|
||||
int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>,
|
||||
const char *<[format]>, va_list <[ap]>);
|
||||
const char *restrict <[format]>, va_list <[ap]>);
|
||||
|
||||
DESCRIPTION
|
||||
<<dprintf>> and <<vdprintf>> allow printing a format, similarly to
|
||||
|
@ -55,7 +56,7 @@ int
|
|||
_DEFUN(_dprintf_r, (ptr, fd, format),
|
||||
struct _reent *ptr _AND
|
||||
int fd _AND
|
||||
const char *format _DOTS)
|
||||
const char *__restrict format _DOTS)
|
||||
{
|
||||
va_list ap;
|
||||
int n;
|
||||
|
@ -71,7 +72,7 @@ _DEFUN(_dprintf_r, (ptr, fd, format),
|
|||
int
|
||||
_DEFUN(dprintf, (fd, format),
|
||||
int fd _AND
|
||||
const char *format _DOTS)
|
||||
const char *__restrict format _DOTS)
|
||||
{
|
||||
va_list ap;
|
||||
int n;
|
||||
|
|
|
@ -76,11 +76,20 @@ _DEFUN(_fclose_r, (rptr, fp),
|
|||
|
||||
CHECK_INIT (rptr, fp);
|
||||
|
||||
/* We can't use the _newlib_flockfile_XXX macros here due to the
|
||||
interlocked locking with the sfp_lock. */
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
int __oldcancel;
|
||||
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
|
||||
#endif
|
||||
_flockfile (fp);
|
||||
|
||||
if (fp->_flags == 0) /* not open! */
|
||||
{
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
/* Unconditionally flush to allow special handling for seekable read
|
||||
|
@ -103,6 +112,9 @@ _DEFUN(_fclose_r, (rptr, fp),
|
|||
#endif
|
||||
|
||||
__sfp_lock_release ();
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
#endif
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ _DEFUN(_fdopen_r, (ptr, fd, mode),
|
|||
if ((fp = __sfp (ptr)) == 0)
|
||||
return 0;
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
|
||||
fp->_flags = flags;
|
||||
/* POSIX recommends setting the O_APPEND bit on fd to match append
|
||||
|
@ -127,7 +127,7 @@ _DEFUN(_fdopen_r, (ptr, fd, mode),
|
|||
fp->_flags |= __SCLE;
|
||||
#endif
|
||||
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<feof>>---test for end of file
|
||||
|
||||
INDEX
|
||||
feof
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
int feof(FILE *<[fp]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
int feof(<[fp]>)
|
||||
FILE *<[fp]>;
|
||||
|
||||
DESCRIPTION
|
||||
<<feof>> tests whether or not the end of the file identified by <[fp]>
|
||||
has been reached.
|
||||
|
||||
RETURNS
|
||||
<<feof>> returns <<0>> if the end of file has not yet been reached; if
|
||||
at end of file, the result is nonzero.
|
||||
|
||||
PORTABILITY
|
||||
<<feof>> is required by ANSI C.
|
||||
|
||||
No supporting OS subroutines are required.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "local.h"
|
||||
|
||||
/* A subroutine version of the macro feof. */
|
||||
|
||||
#undef feof
|
||||
|
||||
int
|
||||
_DEFUN(feof, (fp),
|
||||
FILE * fp)
|
||||
{
|
||||
int result;
|
||||
CHECK_INIT(_REENT, fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
result = __sfeof (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return result;
|
||||
}
|
|
@ -75,15 +75,19 @@ _DEFUN(__sflush_r, (ptr, fp),
|
|||
register FILE * fp)
|
||||
{
|
||||
register unsigned char *p;
|
||||
register int n, t;
|
||||
register _READ_WRITE_BUFSIZE_TYPE n;
|
||||
register _READ_WRITE_RETURN_TYPE t;
|
||||
short flags;
|
||||
|
||||
t = fp->_flags;
|
||||
if ((t & __SWR) == 0)
|
||||
flags = fp->_flags;
|
||||
if ((flags & __SWR) == 0)
|
||||
{
|
||||
#ifdef _FSEEK_OPTIMIZATION
|
||||
/* For a read stream, an fflush causes the next seek to be
|
||||
unoptimized (i.e. forces a system-level seek). This conforms
|
||||
to the POSIX and SUSv3 standards. */
|
||||
fp->_flags |= __SNPT;
|
||||
#endif
|
||||
|
||||
/* For a seekable stream with buffered read characters, we will attempt
|
||||
a seek to the current position now. A subsequent read will then get
|
||||
|
@ -152,7 +156,9 @@ _DEFUN(__sflush_r, (ptr, fp),
|
|||
{
|
||||
/* Seek successful or ignorable error condition.
|
||||
We can clear read buffer now. */
|
||||
#ifdef _FSEEK_OPTIMIZATION
|
||||
fp->_flags &= ~__SNPT;
|
||||
#endif
|
||||
fp->_r = 0;
|
||||
fp->_p = fp->_bf._base;
|
||||
if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0))
|
||||
|
@ -182,7 +188,7 @@ _DEFUN(__sflush_r, (ptr, fp),
|
|||
* write function.
|
||||
*/
|
||||
fp->_p = p;
|
||||
fp->_w = t & (__SLBF | __SNBF) ? 0 : fp->_bf._size;
|
||||
fp->_w = flags & (__SLBF | __SNBF) ? 0 : fp->_bf._size;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
|
@ -226,9 +232,9 @@ _DEFUN(_fflush_r, (ptr, fp),
|
|||
if (!fp->_flags)
|
||||
return 0;
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
ret = __sflush_r (ptr, fp);
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,9 +78,9 @@ _DEFUN(_fgetc_r, (ptr, fp),
|
|||
{
|
||||
int result;
|
||||
CHECK_INIT(ptr, fp);
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
result = __sgetc_r (ptr, fp);
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,12 @@ _DEFUN(fgetc, (fp),
|
|||
{
|
||||
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
|
||||
int result;
|
||||
CHECK_INIT(_REENT, fp);
|
||||
_flockfile (fp);
|
||||
result = __sgetc_r (_REENT, fp);
|
||||
_funlockfile (fp);
|
||||
struct _reent *reent = _REENT;
|
||||
|
||||
CHECK_INIT(reent, fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
result = __sgetc_r (reent, fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return result;
|
||||
#else
|
||||
return _fgetc_r (_REENT, fp);
|
||||
|
|
|
@ -26,10 +26,10 @@ INDEX
|
|||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
char *fgets(char *<[buf]>, int <[n]>, FILE *<[fp]>);
|
||||
char *fgets(char *restrict <[buf]>, int <[n]>, FILE *restrict <[fp]>);
|
||||
|
||||
#include <stdio.h>
|
||||
char *_fgets_r(struct _reent *<[ptr]>, char *<[buf]>, int <[n]>, FILE *<[fp]>);
|
||||
char *_fgets_r(struct _reent *<[ptr]>, char *restrict <[buf]>, int <[n]>, FILE *restrict <[fp]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
|
@ -83,9 +83,9 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
|||
char *
|
||||
_DEFUN(_fgets_r, (ptr, buf, n, fp),
|
||||
struct _reent * ptr _AND
|
||||
char *buf _AND
|
||||
char *__restrict buf _AND
|
||||
int n _AND
|
||||
FILE * fp)
|
||||
FILE *__restrict fp)
|
||||
{
|
||||
size_t len;
|
||||
char *s;
|
||||
|
@ -98,11 +98,11 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
|
|||
|
||||
CHECK_INIT(ptr, fp);
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
#ifdef __SCLE
|
||||
if (fp->_flags & __SCLE)
|
||||
{
|
||||
int c;
|
||||
int c = 0;
|
||||
/* Sorry, have to do it the slow way */
|
||||
while (--n > 0 && (c = __sgetc_r (ptr, fp)) != EOF)
|
||||
{
|
||||
|
@ -112,11 +112,11 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
|
|||
}
|
||||
if (c == EOF && s == buf)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return NULL;
|
||||
}
|
||||
*s = 0;
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
@ -134,7 +134,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
|
|||
/* EOF: stop with partial or no line */
|
||||
if (s == buf)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -159,7 +159,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
|
|||
fp->_p = t;
|
||||
_CAST_VOID memcpy ((_PTR) s, (_PTR) p, len);
|
||||
s[len] = 0;
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return (buf);
|
||||
}
|
||||
fp->_r -= len;
|
||||
|
@ -169,7 +169,7 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
|
|||
}
|
||||
while ((n -= len) != 0);
|
||||
*s = 0;
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -177,9 +177,9 @@ _DEFUN(_fgets_r, (ptr, buf, n, fp),
|
|||
|
||||
char *
|
||||
_DEFUN(fgets, (buf, n, fp),
|
||||
char *buf _AND
|
||||
char *__restrict buf _AND
|
||||
int n _AND
|
||||
FILE * fp)
|
||||
FILE *__restrict fp)
|
||||
{
|
||||
return _fgets_r (_REENT, buf, n, fp);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ Supporting OS subroutines required: none.
|
|||
|
||||
#include <_ansi.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "local.h"
|
||||
|
||||
int
|
||||
|
@ -55,8 +56,14 @@ _DEFUN(fileno, (f),
|
|||
{
|
||||
int result;
|
||||
CHECK_INIT (_REENT, f);
|
||||
_flockfile (f);
|
||||
_newlib_flockfile_start (f);
|
||||
if (f->_flags)
|
||||
result = __sfileno (f);
|
||||
_funlockfile (f);
|
||||
else
|
||||
{
|
||||
result = -1;
|
||||
_REENT->_errno = EBADF;
|
||||
}
|
||||
_newlib_flockfile_end (f);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,11 @@ _DEFUN(std, (ptr, flags, file, data),
|
|||
ptr->_flags |= __SL64;
|
||||
#endif /* __LARGE64_FILES */
|
||||
ptr->_seek = __sseek;
|
||||
#ifdef _STDIO_CLOSE_PER_REENT_STD_STREAMS
|
||||
ptr->_close = __sclose;
|
||||
#else /* _STDIO_CLOSE_STD_STREAMS */
|
||||
ptr->_close = NULL;
|
||||
#endif /* _STDIO_CLOSE_STD_STREAMS */
|
||||
#if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL)
|
||||
__lock_init_recursive (ptr->_lock);
|
||||
/*
|
||||
|
@ -77,23 +81,27 @@ _DEFUN(std, (ptr, flags, file, data),
|
|||
#endif
|
||||
}
|
||||
|
||||
struct glue_with_file {
|
||||
struct _glue glue;
|
||||
FILE file;
|
||||
};
|
||||
|
||||
struct _glue *
|
||||
_DEFUN(__sfmoreglue, (d, n),
|
||||
struct _reent *d _AND
|
||||
register int n)
|
||||
{
|
||||
struct _glue *g;
|
||||
FILE *p;
|
||||
struct glue_with_file *g;
|
||||
|
||||
g = (struct _glue *) _malloc_r (d, sizeof (*g) + n * sizeof (FILE));
|
||||
g = (struct glue_with_file *)
|
||||
_malloc_r (d, sizeof (*g) + (n - 1) * sizeof (FILE));
|
||||
if (g == NULL)
|
||||
return NULL;
|
||||
p = (FILE *) (g + 1);
|
||||
g->_next = NULL;
|
||||
g->_niobs = n;
|
||||
g->_iobs = p;
|
||||
memset (p, 0, n * sizeof (FILE));
|
||||
return g;
|
||||
g->glue._next = NULL;
|
||||
g->glue._niobs = n;
|
||||
g->glue._iobs = &g->file;
|
||||
memset (&g->file, 0, n * sizeof (FILE));
|
||||
return &g->glue;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -108,7 +116,7 @@ _DEFUN(__sfp, (d),
|
|||
int n;
|
||||
struct _glue *g;
|
||||
|
||||
__sfp_lock_acquire ();
|
||||
_newlib_sfp_lock_start ();
|
||||
|
||||
if (!_GLOBAL_REENT->__sdidinit)
|
||||
__sinit (_GLOBAL_REENT);
|
||||
|
@ -121,7 +129,7 @@ _DEFUN(__sfp, (d),
|
|||
(g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL)
|
||||
break;
|
||||
}
|
||||
__sfp_lock_release ();
|
||||
_newlib_sfp_lock_exit ();
|
||||
d->_errno = ENOMEM;
|
||||
return NULL;
|
||||
|
||||
|
@ -132,7 +140,7 @@ found:
|
|||
#ifndef __SINGLE_THREAD__
|
||||
__lock_init_recursive (fp->_lock);
|
||||
#endif
|
||||
__sfp_lock_release ();
|
||||
_newlib_sfp_lock_end ();
|
||||
|
||||
fp->_p = NULL; /* no current pointer */
|
||||
fp->_w = 0; /* nothing to read or write */
|
||||
|
@ -192,7 +200,6 @@ _DEFUN(__sinit, (s),
|
|||
|
||||
/* make sure we clean up on exit */
|
||||
s->__cleanup = _cleanup_r; /* conservative */
|
||||
s->__sdidinit = 1;
|
||||
|
||||
s->__sglue._next = NULL;
|
||||
#ifndef _REENT_SMALL
|
||||
|
@ -201,6 +208,11 @@ _DEFUN(__sinit, (s),
|
|||
#else
|
||||
s->__sglue._niobs = 0;
|
||||
s->__sglue._iobs = NULL;
|
||||
/* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The
|
||||
problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls
|
||||
__sinit if it's 0. */
|
||||
if (s == _GLOBAL_REENT)
|
||||
s->__sdidinit = 1;
|
||||
s->_stdin = __sfp(s);
|
||||
s->_stdout = __sfp(s);
|
||||
s->_stderr = __sfp(s);
|
||||
|
@ -224,6 +236,8 @@ _DEFUN(__sinit, (s),
|
|||
when the underlying fd 2 is write-only. */
|
||||
std (s->_stderr, __SRW | __SNBF, 2, s);
|
||||
|
||||
s->__sdidinit = 1;
|
||||
|
||||
__sinit_lock_release ();
|
||||
}
|
||||
|
||||
|
@ -235,25 +249,25 @@ __LOCK_INIT_RECURSIVE(static, __sinit_lock);
|
|||
_VOID
|
||||
_DEFUN_VOID(__sfp_lock_acquire)
|
||||
{
|
||||
__lock_acquire_recursive (__sfp_lock);
|
||||
//__lock_acquire_recursive (__sfp_lock);
|
||||
}
|
||||
|
||||
_VOID
|
||||
_DEFUN_VOID(__sfp_lock_release)
|
||||
{
|
||||
__lock_release_recursive (__sfp_lock);
|
||||
//__lock_release_recursive (__sfp_lock);
|
||||
}
|
||||
|
||||
_VOID
|
||||
_DEFUN_VOID(__sinit_lock_acquire)
|
||||
{
|
||||
__lock_acquire_recursive (__sinit_lock);
|
||||
//__lock_acquire_recursive (__sinit_lock);
|
||||
}
|
||||
|
||||
_VOID
|
||||
_DEFUN_VOID(__sinit_lock_release)
|
||||
{
|
||||
__lock_release_recursive (__sinit_lock);
|
||||
//__lock_release_recursive (__sinit_lock);
|
||||
}
|
||||
|
||||
/* Walkable file locking routine. */
|
||||
|
|
|
@ -60,27 +60,40 @@ _DEFUN(__sflags, (ptr, mode, optr),
|
|||
ptr->_errno = EINVAL;
|
||||
return (0);
|
||||
}
|
||||
if (mode[1] && (mode[1] == '+' || mode[2] == '+'))
|
||||
while (*++mode)
|
||||
{
|
||||
switch (*mode)
|
||||
{
|
||||
case '+':
|
||||
ret = (ret & ~(__SRD | __SWR)) | __SRW;
|
||||
m = O_RDWR;
|
||||
}
|
||||
if (mode[1] && (mode[1] == 'b' || mode[2] == 'b'))
|
||||
{
|
||||
m = (m & ~O_ACCMODE) | O_RDWR;
|
||||
break;
|
||||
case 'b':
|
||||
#ifdef O_BINARY
|
||||
m |= O_BINARY;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#ifdef __CYGWIN__
|
||||
else if (mode[1] && (mode[1] == 't' || mode[2] == 't'))
|
||||
#else
|
||||
else
|
||||
case 't':
|
||||
m |= O_TEXT;
|
||||
break;
|
||||
#endif
|
||||
{
|
||||
#ifdef O_TEXT
|
||||
#if defined (O_CLOEXEC) && defined (_GLIBC_EXTENSION)
|
||||
case 'e':
|
||||
m |= O_CLOEXEC;
|
||||
break;
|
||||
#endif
|
||||
case 'x':
|
||||
m |= O_EXCL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if defined (O_TEXT) && !defined (__CYGWIN__)
|
||||
if (!(m | O_BINARY))
|
||||
m |= O_TEXT;
|
||||
#endif
|
||||
}
|
||||
*optr = m | o;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ static char sccsid[] = "%W% (Berkeley) %G%";
|
|||
FILE *
|
||||
_DEFUN(_fopen_r, (ptr, file, mode),
|
||||
struct _reent *ptr _AND
|
||||
_CONST char *file _AND
|
||||
_CONST char *mode)
|
||||
_CONST char *__restrict file _AND
|
||||
_CONST char *__restrict mode)
|
||||
{
|
||||
register FILE *fp;
|
||||
register int f;
|
||||
|
@ -140,16 +140,16 @@ _DEFUN(_fopen_r, (ptr, file, mode),
|
|||
|
||||
if ((f = _open_r (ptr, file, oflags, 0666)) < 0)
|
||||
{
|
||||
__sfp_lock_acquire ();
|
||||
_newlib_sfp_lock_start ();
|
||||
fp->_flags = 0; /* release */
|
||||
#ifndef __SINGLE_THREAD__
|
||||
__lock_close_recursive (fp->_lock);
|
||||
#endif
|
||||
__sfp_lock_release ();
|
||||
_newlib_sfp_lock_end ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
|
||||
fp->_file = f;
|
||||
fp->_flags = flags;
|
||||
|
@ -167,7 +167,7 @@ _DEFUN(_fopen_r, (ptr, file, mode),
|
|||
fp->_flags |= __SCLE;
|
||||
#endif
|
||||
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
int
|
||||
_DEFUN(_fprintf_r, (ptr, fp, fmt),
|
||||
struct _reent *ptr _AND
|
||||
FILE *fp _AND
|
||||
const char *fmt _DOTS)
|
||||
FILE *__restrict fp _AND
|
||||
const char *__restrict fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
@ -40,8 +40,8 @@ _DEFUN(_fprintf_r, (ptr, fp, fmt),
|
|||
|
||||
int
|
||||
_DEFUN(fprintf, (fp, fmt),
|
||||
FILE *fp _AND
|
||||
const char *fmt _DOTS)
|
||||
FILE *__restrict fp _AND
|
||||
const char *__restrict fmt _DOTS)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
|
|
@ -83,9 +83,9 @@ _DEFUN(_fputc_r, (ptr, ch, file),
|
|||
{
|
||||
int result;
|
||||
CHECK_INIT(ptr, file);
|
||||
_flockfile (file);
|
||||
_newlib_flockfile_start (file);
|
||||
result = _putc_r (ptr, ch, file);
|
||||
_funlockfile (file);
|
||||
_newlib_flockfile_end (file);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -97,10 +97,12 @@ _DEFUN(fputc, (ch, file),
|
|||
{
|
||||
#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED)
|
||||
int result;
|
||||
CHECK_INIT(_REENT, file);
|
||||
_flockfile (file);
|
||||
result = _putc_r (_REENT, ch, file);
|
||||
_funlockfile (file);
|
||||
struct _reent *reent = _REENT;
|
||||
|
||||
CHECK_INIT(reent, file);
|
||||
_newlib_flockfile_start (file);
|
||||
result = _putc_r (reent, ch, file);
|
||||
_newlib_flockfile_end (file);
|
||||
return result;
|
||||
#else
|
||||
return _fputc_r (_REENT, ch, file);
|
||||
|
|
|
@ -26,10 +26,10 @@ INDEX
|
|||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
int fputs(const char *<[s]>, FILE *<[fp]>);
|
||||
int fputs(const char *restrict <[s]>, FILE *restrict <[fp]>);
|
||||
|
||||
#include <stdio.h>
|
||||
int _fputs_r(struct _reent *<[ptr]>, const char *<[s]>, FILE *<[fp]>);
|
||||
int _fputs_r(struct _reent *<[ptr]>, const char *restrict <[s]>, FILE *restrict <[fp]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
|
@ -74,9 +74,10 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
|||
int
|
||||
_DEFUN(_fputs_r, (ptr, s, fp),
|
||||
struct _reent * ptr _AND
|
||||
char _CONST * s _AND
|
||||
FILE * fp)
|
||||
char _CONST *__restrict s _AND
|
||||
FILE *__restrict fp)
|
||||
{
|
||||
#ifdef _FVWRITE_IN_STREAMIO
|
||||
int result;
|
||||
struct __suio uio;
|
||||
struct __siov iov;
|
||||
|
@ -88,18 +89,41 @@ _DEFUN(_fputs_r, (ptr, s, fp),
|
|||
|
||||
CHECK_INIT(ptr, fp);
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
ORIENT (fp, -1);
|
||||
result = __sfvwrite_r (ptr, fp, &uio);
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return result;
|
||||
#else
|
||||
_CONST char *p = s;
|
||||
|
||||
CHECK_INIT(ptr, fp);
|
||||
|
||||
_newlib_flockfile_start (fp);
|
||||
ORIENT (fp, -1);
|
||||
/* Make sure we can write. */
|
||||
if (cantwrite (ptr, fp))
|
||||
goto error;
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (__sputc_r (ptr, *p++, fp) == EOF)
|
||||
goto error;
|
||||
}
|
||||
_newlib_flockfile_exit (fp);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
_newlib_flockfile_end (fp);
|
||||
return EOF;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
int
|
||||
_DEFUN(fputs, (s, fp),
|
||||
char _CONST * s _AND
|
||||
FILE * fp)
|
||||
char _CONST *__restrict s _AND
|
||||
FILE *__restrict fp)
|
||||
{
|
||||
return _fputs_r (_REENT, s, fp);
|
||||
}
|
||||
|
|
|
@ -160,10 +160,10 @@ _DEFUN(_fputwc_r, (ptr, wc, fp),
|
|||
{
|
||||
wint_t r;
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
ORIENT(fp, 1);
|
||||
r = __fputwc(ptr, wc, fp);
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -172,6 +172,8 @@ _DEFUN(fputwc, (wc, fp),
|
|||
wchar_t wc _AND
|
||||
FILE *fp)
|
||||
{
|
||||
CHECK_INIT(_REENT, fp);
|
||||
return _fputwc_r (_REENT, wc, fp);
|
||||
struct _reent *reent = _REENT;
|
||||
|
||||
CHECK_INIT(reent, fp);
|
||||
return _fputwc_r (reent, wc, fp);
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ INDEX
|
|||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
size_t fread(void *<[buf]>, size_t <[size]>, size_t <[count]>,
|
||||
FILE *<[fp]>);
|
||||
size_t fread(void *restrict <[buf]>, size_t <[size]>, size_t <[count]>,
|
||||
FILE *restrict <[fp]>);
|
||||
|
||||
#include <stdio.h>
|
||||
size_t _fread_r(struct _reent *<[ptr]>, void *<[buf]>,
|
||||
size_t <[size]>, size_t <[count]>, FILE *<[fp]>);
|
||||
size_t _fread_r(struct _reent *<[ptr]>, void *restrict <[buf]>,
|
||||
size_t <[size]>, size_t <[count]>, FILE *restrict <[fp]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
|
@ -131,10 +131,10 @@ _DEFUN(crlf_r, (ptr, fp, buf, count, eof),
|
|||
size_t
|
||||
_DEFUN(_fread_r, (ptr, buf, size, count, fp),
|
||||
struct _reent * ptr _AND
|
||||
_PTR buf _AND
|
||||
_PTR __restrict buf _AND
|
||||
size_t size _AND
|
||||
size_t count _AND
|
||||
FILE * fp)
|
||||
FILE * __restrict fp)
|
||||
{
|
||||
register size_t resid;
|
||||
register char *p;
|
||||
|
@ -146,7 +146,7 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
|
|||
|
||||
CHECK_INIT(ptr, fp);
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
ORIENT (fp, -1);
|
||||
if (fp->_r < 0)
|
||||
fp->_r = 0;
|
||||
|
@ -195,11 +195,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
|
|||
#ifdef __SCLE
|
||||
if (fp->_flags & __SCLE)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return crlf_r (ptr, fp, buf, total-resid, 1) / size;
|
||||
}
|
||||
#endif
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return (total - resid) / size;
|
||||
}
|
||||
}
|
||||
|
@ -220,11 +220,11 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
|
|||
#ifdef __SCLE
|
||||
if (fp->_flags & __SCLE)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return crlf_r (ptr, fp, buf, total-resid, 1) / size;
|
||||
}
|
||||
#endif
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return (total - resid) / size;
|
||||
}
|
||||
}
|
||||
|
@ -237,21 +237,21 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp),
|
|||
#ifdef __SCLE
|
||||
if (fp->_flags & __SCLE)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return crlf_r(ptr, fp, buf, total, 0) / size;
|
||||
}
|
||||
#endif
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
size_t
|
||||
_DEFUN(fread, (buf, size, count, fp),
|
||||
_PTR buf _AND
|
||||
_PTR __restrict buf _AND
|
||||
size_t size _AND
|
||||
size_t count _AND
|
||||
FILE * fp)
|
||||
FILE *__restrict fp)
|
||||
{
|
||||
return _fread_r (_REENT, buf, size, count, fp);
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ INDEX
|
|||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
FILE *freopen(const char *<[file]>, const char *<[mode]>,
|
||||
FILE *<[fp]>);
|
||||
FILE *_freopen_r(struct _reent *<[ptr]>, const char *<[file]>,
|
||||
const char *<[mode]>, FILE *<[fp]>);
|
||||
FILE *freopen(const char *restrict <[file]>, const char *restrict <[mode]>,
|
||||
FILE *restrict <[fp]>);
|
||||
FILE *_freopen_r(struct _reent *<[ptr]>, const char *restrict <[file]>,
|
||||
const char *restrict <[mode]>, FILE *restrict <[fp]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
|
@ -90,9 +90,9 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
|||
FILE *
|
||||
_DEFUN(_freopen_r, (ptr, file, mode, fp),
|
||||
struct _reent *ptr _AND
|
||||
const char *file _AND
|
||||
const char *mode _AND
|
||||
register FILE *fp)
|
||||
const char *__restrict file _AND
|
||||
const char *__restrict mode _AND
|
||||
register FILE *__restrict fp)
|
||||
{
|
||||
register int f;
|
||||
int flags, oflags;
|
||||
|
@ -100,11 +100,20 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
|
||||
CHECK_INIT (ptr, fp);
|
||||
|
||||
/* We can't use the _newlib_flockfile_XXX macros here due to the
|
||||
interlocked locking with the sfp_lock. */
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
int __oldcancel;
|
||||
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
|
||||
#endif
|
||||
_flockfile (fp);
|
||||
|
||||
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
#endif
|
||||
_fclose_r (ptr, fp);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -199,7 +208,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
if (HASLB (fp))
|
||||
FREELB (ptr, fp);
|
||||
fp->_lb._size = 0;
|
||||
fp->_flags & ~__SORD;
|
||||
fp->_flags &= ~__SORD;
|
||||
fp->_flags2 = 0;
|
||||
memset (&fp->_mbstate, 0, sizeof (_mbstate_t));
|
||||
|
||||
|
@ -213,6 +222,9 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
__lock_close_recursive (fp->_lock);
|
||||
#endif
|
||||
__sfp_lock_release ();
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -230,6 +242,9 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
#endif
|
||||
|
||||
_funlockfile (fp);
|
||||
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
|
||||
pthread_setcancelstate (__oldcancel, &__oldcancel);
|
||||
#endif
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
@ -237,9 +252,9 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
|
|||
|
||||
FILE *
|
||||
_DEFUN(freopen, (file, mode, fp),
|
||||
_CONST char *file _AND
|
||||
_CONST char *mode _AND
|
||||
register FILE *fp)
|
||||
_CONST char *__restrict file _AND
|
||||
_CONST char *__restrict mode _AND
|
||||
register FILE *__restrict fp)
|
||||
{
|
||||
return _freopen_r (_REENT, file, mode, fp);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue