* include/_mingw.h: Increment version to 2.0.
* Makefile.in: Ditto. Merge in mingwex branch.
This commit is contained in:
236
winsup/mingw/mingwex/Makefile.in
Normal file
236
winsup/mingw/mingwex/Makefile.in
Normal file
@@ -0,0 +1,236 @@
|
||||
#
|
||||
# mingw/mingwex/Makefile.in: This file is part of Mingw runtime.
|
||||
#
|
||||
# This makefile requires GNU make.
|
||||
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
objdir = .
|
||||
|
||||
target_alias = @target_alias@
|
||||
prefix = @prefix@
|
||||
|
||||
program_transform_name = @program_transform_name@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
tooldir = $(exec_prefix)/$(target_alias)
|
||||
datadir = @datadir@
|
||||
infodir = @infodir@
|
||||
includedir = @includedir@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
mkinstalldirs = $(SHELL) $(srcdir)/../mkinstalldirs
|
||||
DISTFILES = Makefile.in configure configure.in \
|
||||
mingw-fseek.c \
|
||||
_Exit.c \
|
||||
atoll.c \
|
||||
copysignl.S \
|
||||
dirent.c \
|
||||
fdim.c \
|
||||
fdimf.c \
|
||||
fdiml.c \
|
||||
feclearexcept.c \
|
||||
fegetenv.c \
|
||||
fegetexceptflag.c \
|
||||
fegetround.c \
|
||||
feholdexcept.c \
|
||||
feraiseexcept.c \
|
||||
fesetenv.c \
|
||||
fesetround.c \
|
||||
fetestexcept.c \
|
||||
fesetexceptflag.c \
|
||||
feupdateenv.c \
|
||||
fma.S \
|
||||
fmaf.S \
|
||||
fmal.c \
|
||||
fmax.c \
|
||||
fmaxf.c \
|
||||
fmaxl.c \
|
||||
fmin.c \
|
||||
fminf.c \
|
||||
fminl.c \
|
||||
fp_consts.c \
|
||||
fpclassify.c \
|
||||
fpclassifyf.c \
|
||||
fpclassifyl.c \
|
||||
fucom.c \
|
||||
fwide.c \
|
||||
imaxabs.c \
|
||||
imaxdiv.c \
|
||||
isnan.c \
|
||||
isnanf.c \
|
||||
isnanl.c \
|
||||
lltoa.c \
|
||||
lltow.c \
|
||||
log2.c \
|
||||
log2f.c \
|
||||
log2l.c \
|
||||
math_stubs.c \
|
||||
mbsinit.c \
|
||||
rint.c \
|
||||
rintf.c \
|
||||
rintl.c \
|
||||
round.c \
|
||||
roundf.c \
|
||||
roundl.c \
|
||||
signbit.c \
|
||||
signbitf.c \
|
||||
signbitl.c \
|
||||
sitest.c \
|
||||
snprintf.c \
|
||||
snwprintf.c \
|
||||
strtof.c \
|
||||
strtoimax.c \
|
||||
strtoumax.c \
|
||||
testwmem.c \
|
||||
trunc.c \
|
||||
truncf.c \
|
||||
truncl.c \
|
||||
ulltoa.c \
|
||||
ulltow.c \
|
||||
vsnprintf.c \
|
||||
vsnwprintf.c \
|
||||
wcstof.c \
|
||||
wcstoimax.c \
|
||||
wcstoumax.c \
|
||||
wdirent.c \
|
||||
wmemchr.c \
|
||||
wmemcmp.c \
|
||||
wmemcpy.c \
|
||||
wmemmove.c \
|
||||
wmemset.c \
|
||||
wtoll.c
|
||||
|
||||
CC = @CC@
|
||||
# FIXME: Which is it, CC or CC_FOR_TARGET?
|
||||
CC_FOR_TARGET = $(CC)
|
||||
AS_FOR_TARGET = $(AS)
|
||||
CFLAGS = @CFLAGS@ -Wall
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
OPTFLAGS= -fomit-frame-pointer
|
||||
|
||||
# compiling with Cygwin?
|
||||
MNO_CYGWIN = @MNO_CYGWIN@
|
||||
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(srcdir)/../include \
|
||||
-I$(srcdir)/../../w32api/include \
|
||||
-nostdinc -nostdinc++ \
|
||||
-iwithprefixbefore include
|
||||
ALL_CFLAGS = $(CFLAGS) $(OPTFLAGS) $(INCLUDES) $(MNO_CYGWIN)
|
||||
ALL_CXXFLAGS = $(CXXFLAGS) $(OPTFLAGS) $(INCLUDES) $(MNO_CYGWIN)
|
||||
|
||||
AS = @AS@
|
||||
AR = @AR@
|
||||
LD = @LD@
|
||||
AR_FLAGS = rcv
|
||||
RANLIB = @RANLIB@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DLLTOOLFLAGS =
|
||||
DLLTOOL_FOR_TARGET = $(DLLTOOL)
|
||||
DLLTOOL_FLAGS = --as $(AS_FOR_TARGET)
|
||||
|
||||
LIBMINGWEX_A = libmingwex.a
|
||||
|
||||
Q8_OBJS = \
|
||||
fwide.o imaxabs.o imaxdiv.o mbsinit.o \
|
||||
strtoimax.o strtoumax.o wcstoimax.o wcstoumax.o \
|
||||
wmemchr.o wmemcmp.o wmemcpy.o wmemmove.o wmemset.o
|
||||
STDLIB_STUB_OBJS = \
|
||||
lltoa.o ulltoa.o \
|
||||
lltow.o ulltow.o \
|
||||
atoll.o wtoll.o \
|
||||
strtof.o wcstof.o \
|
||||
_Exit.o
|
||||
STDIO_STUB_OBJS = \
|
||||
snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o
|
||||
MATH_OBJS = \
|
||||
fpclassify.o fpclassifyf.o fpclassifyl.o \
|
||||
fucom.o \
|
||||
round.o roundf.o roundl.o \
|
||||
rint.o rintf.o rintl.o \
|
||||
signbit.o signbitf.o signbitl.o \
|
||||
trunc.o truncf.o truncl.o \
|
||||
isnan.o isnanf.o isnanl.o \
|
||||
fp_consts.o \
|
||||
fdim.o fdimf.o fdiml.o \
|
||||
fmax.o fmaxf.o fmaxl.o \
|
||||
fmin.o fminf.o fminl.o \
|
||||
fma.o fmaf.o fmal.o \
|
||||
log2.o log2f.o log2l.o \
|
||||
copysignl.o
|
||||
MATH_STUB_OBJS = \
|
||||
math_stubs.o
|
||||
FENV_OBJS = fesetround.o fegetround.o \
|
||||
fegetenv.o fesetenv.o feupdateenv.o \
|
||||
feclearexcept.o feholdexcept.o fegetexceptflag.o \
|
||||
feraiseexcept.o fetestexcept.o fesetexceptflag.o
|
||||
POSIX_OBJS = \
|
||||
dirent.o wdirent.o
|
||||
REPLACE_OBJS = \
|
||||
mingw-fseek.o
|
||||
|
||||
LIB_OBJS = $(Q8_OBJS) $(STDLIB_STUB_OBJS) $(STDIO_STUB_OBJS) \
|
||||
$(MATH_OBJS) $(MATH_STUB_OBJS) $(FENV_OBJS) $(POSIX_OBJS) \
|
||||
$(REPLACE_OBJS)
|
||||
|
||||
LIBS = $(LIBMINGWEX_A)
|
||||
DLLS =
|
||||
|
||||
all: $(LIBMINGWEX_A)
|
||||
|
||||
$(LIBMINGWEX_A): $(LIB_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(LIB_OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
|
||||
Makefile: Makefile.in config.status configure
|
||||
$(SHELL) config.status
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) config.status --recheck
|
||||
|
||||
info:
|
||||
|
||||
info-html:
|
||||
|
||||
install-info: info
|
||||
|
||||
install: all
|
||||
$(mkinstalldirs) $(inst_libdir)
|
||||
for i in $(LIBS); do \
|
||||
$(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \
|
||||
done
|
||||
|
||||
clean:
|
||||
-rm -f $(LIB_OBJS) $(LIBMINGWEX_A)
|
||||
|
||||
distclean:
|
||||
-rm -f *.o *.a *~ core a.out
|
||||
-rm -f config.cache config.status config.log
|
||||
-rm -f Makefile
|
||||
.c.o:
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
.S.o:
|
||||
$(CC) -c $< -o $@
|
||||
.s.o:
|
||||
$(CC) -c $< -o $@
|
||||
|
||||
|
||||
#
|
||||
# Dependancies
|
||||
#
|
||||
wdirent.o: $(srcdir)/dirent.c $(srcdir)/wdirent.c
|
||||
|
||||
|
||||
dist:
|
||||
mkdir $(distdir)/mingwex
|
||||
chmod 755 $(distdir)/mingwex
|
||||
@for i in $(DISTFILES); do\
|
||||
cp -p $(srcdir)/$$i $(distdir)/mingwex/$$i ; \
|
||||
done
|
3
winsup/mingw/mingwex/_Exit.c
Normal file
3
winsup/mingw/mingwex/_Exit.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
void _Exit(int status)
|
||||
{ _exit(status); }
|
3
winsup/mingw/mingwex/atoll.c
Normal file
3
winsup/mingw/mingwex/atoll.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
long long atoll (const char * _c)
|
||||
{ return _atoi64 (_c); }
|
1007
winsup/mingw/mingwex/configure
vendored
Executable file
1007
winsup/mingw/mingwex/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
52
winsup/mingw/mingwex/configure.in
Normal file
52
winsup/mingw/mingwex/configure.in
Normal file
@@ -0,0 +1,52 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
dnl This file is part of Mingw runtime.
|
||||
dnl
|
||||
dnl This program is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2 of the License, or
|
||||
dnl (at your option) any later version.
|
||||
dnl
|
||||
dnl This program is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with this program; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
AC_PREREQ(2.13)
|
||||
AC_INIT(imaxabs.c)
|
||||
|
||||
CC=${CC-cc}
|
||||
AC_SUBST(CC)
|
||||
AS=${AS-as}
|
||||
AC_SUBST(AS)
|
||||
AR=${AR-ar}
|
||||
AC_SUBST(AR)
|
||||
LD=${LD-ld}
|
||||
AC_SUBST(LD)
|
||||
RANLIB=${RANLIB-ranlib}
|
||||
AC_SUBST(RANLIB)
|
||||
DLLTOOL=${DLLTOOL-dlltool}
|
||||
AC_SUBST(DLLTOOL)
|
||||
DLLWRAP=${DLLWRAP-dllwrap}
|
||||
AC_SUBST(DLLWRAP)
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
case "$target_os" in
|
||||
*cygwin*)
|
||||
MNO_CYGWIN=-mno-cygwin
|
||||
;;
|
||||
*)
|
||||
# Build it for MSVCRT by default.
|
||||
MNO_CYGWIN=
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(MNO_CYGWIN)
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_OUTPUT(Makefile)
|
||||
|
21
winsup/mingw/mingwex/copysignl.S
Normal file
21
winsup/mingw/mingwex/copysignl.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Changes for long double by Ulrich Drepper <drepper@cygnus.com>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
.file "copysignl.S"
|
||||
.text
|
||||
.align 2
|
||||
.p2align 4,,15
|
||||
.globl _copysignl
|
||||
.def _copysignl; .scl 2; .type 32; .endef
|
||||
_copysignl:
|
||||
movl 24(%esp),%edx
|
||||
movl 12(%esp),%eax
|
||||
andl $0x8000,%edx
|
||||
andl $0x7fff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,12(%esp)
|
||||
fldt 4(%esp)
|
||||
ret
|
320
winsup/mingw/mingwex/dirent.c
Normal file
320
winsup/mingw/mingwex/dirent.c
Normal file
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* dirent.c
|
||||
*
|
||||
* Derived from DIRLIB.C by Matt J. Weinstein
|
||||
* This note appears in the DIRLIB.H
|
||||
* DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89
|
||||
*
|
||||
* Updated by Jeremy Bettis <jeremy@hksys.com>
|
||||
* Significantly revised and rewinddir, seekdir and telldir added by Colin
|
||||
* Peters <colin@fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* $Revision$
|
||||
* $Author$
|
||||
* $Date$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h> /* for GetFileAttributes */
|
||||
|
||||
#include <tchar.h>
|
||||
#define SUFFIX _T("*")
|
||||
#define SLASH _T("\\")
|
||||
|
||||
/*
|
||||
* opendir
|
||||
*
|
||||
* Returns a pointer to a DIR structure appropriately filled in to begin
|
||||
* searching a directory.
|
||||
*/
|
||||
_TDIR *
|
||||
_topendir (const _TCHAR *szPath)
|
||||
{
|
||||
_TDIR *nd;
|
||||
unsigned int rc;
|
||||
_TCHAR szFullPath[MAX_PATH];
|
||||
|
||||
errno = 0;
|
||||
|
||||
if (!szPath)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return (_TDIR *) 0;
|
||||
}
|
||||
|
||||
if (szPath[0] == _T('\0'))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return (_TDIR *) 0;
|
||||
}
|
||||
|
||||
/* Attempt to determine if the given path really is a directory. */
|
||||
rc = GetFileAttributes (szPath);
|
||||
if (rc == -1)
|
||||
{
|
||||
/* call GetLastError for more error info */
|
||||
errno = ENOENT;
|
||||
return (_TDIR *) 0;
|
||||
}
|
||||
if (!(rc & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
/* Error, entry exists but not a directory. */
|
||||
errno = ENOTDIR;
|
||||
return (_TDIR *) 0;
|
||||
}
|
||||
|
||||
/* Make an absolute pathname. */
|
||||
_tfullpath (szFullPath, szPath, MAX_PATH);
|
||||
|
||||
/* Allocate enough space to store DIR structure and the complete
|
||||
* directory path given. */
|
||||
nd = (_TDIR *) malloc (sizeof (_TDIR) + _tcslen (szFullPath) + _tcslen (SLASH) +
|
||||
_tcslen (SUFFIX));
|
||||
|
||||
if (!nd)
|
||||
{
|
||||
/* Error, out of memory. */
|
||||
errno = ENOMEM;
|
||||
return (_TDIR *) 0;
|
||||
}
|
||||
|
||||
/* Create the search expression. */
|
||||
_tcscpy (nd->dd_name, szFullPath);
|
||||
|
||||
/* Add on a slash if the path does not end with one. */
|
||||
if (nd->dd_name[0] != _T('\0') &&
|
||||
nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('/') &&
|
||||
nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('\\'))
|
||||
{
|
||||
_tcscat (nd->dd_name, SLASH);
|
||||
}
|
||||
|
||||
/* Add on the search pattern */
|
||||
_tcscat (nd->dd_name, SUFFIX);
|
||||
|
||||
/* Initialize handle to -1 so that a premature closedir doesn't try
|
||||
* to call _findclose on it. */
|
||||
nd->dd_handle = -1;
|
||||
|
||||
/* Initialize the status. */
|
||||
nd->dd_stat = 0;
|
||||
|
||||
/* Initialize the dirent structure. ino and reclen are invalid under
|
||||
* Win32, and name simply points at the appropriate part of the
|
||||
* findfirst_t structure. */
|
||||
nd->dd_dir.d_ino = 0;
|
||||
nd->dd_dir.d_reclen = 0;
|
||||
nd->dd_dir.d_namlen = 0;
|
||||
nd->dd_dir.d_name = nd->dd_dta.name;
|
||||
|
||||
return nd;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* readdir
|
||||
*
|
||||
* Return a pointer to a dirent structure filled with the information on the
|
||||
* next entry in the directory.
|
||||
*/
|
||||
struct _tdirent *
|
||||
_treaddir (_TDIR * dirp)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
/* Check for valid DIR struct. */
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return (struct _tdirent *) 0;
|
||||
}
|
||||
|
||||
if (dirp->dd_dir.d_name != dirp->dd_dta.name)
|
||||
{
|
||||
/* The structure does not seem to be set up correctly. */
|
||||
errno = EINVAL;
|
||||
return (struct _tdirent *) 0;
|
||||
}
|
||||
|
||||
if (dirp->dd_stat < 0)
|
||||
{
|
||||
/* We have already returned all files in the directory
|
||||
* (or the structure has an invalid dd_stat). */
|
||||
return (struct _tdirent *) 0;
|
||||
}
|
||||
else if (dirp->dd_stat == 0)
|
||||
{
|
||||
/* We haven't started the search yet. */
|
||||
/* Start the search */
|
||||
dirp->dd_handle = _tfindfirst (dirp->dd_name, &(dirp->dd_dta));
|
||||
|
||||
if (dirp->dd_handle == -1)
|
||||
{
|
||||
/* Whoops! Seems there are no files in that
|
||||
* directory. */
|
||||
dirp->dd_stat = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dirp->dd_stat = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the next search entry. */
|
||||
if (_tfindnext (dirp->dd_handle, &(dirp->dd_dta)))
|
||||
{
|
||||
/* We are off the end or otherwise error. */
|
||||
_findclose (dirp->dd_handle);
|
||||
dirp->dd_handle = -1;
|
||||
dirp->dd_stat = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update the status to indicate the correct
|
||||
* number. */
|
||||
dirp->dd_stat++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirp->dd_stat > 0)
|
||||
{
|
||||
/* Successfully got an entry. Everything about the file is
|
||||
* already appropriately filled in except the length of the
|
||||
* file name. */
|
||||
dirp->dd_dir.d_namlen = _tcslen (dirp->dd_dir.d_name);
|
||||
return &dirp->dd_dir;
|
||||
}
|
||||
|
||||
return (struct _tdirent *) 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* closedir
|
||||
*
|
||||
* Frees up resources allocated by opendir.
|
||||
*/
|
||||
int
|
||||
_tclosedir (_TDIR * dirp)
|
||||
{
|
||||
int rc;
|
||||
|
||||
errno = 0;
|
||||
rc = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dirp->dd_handle != -1)
|
||||
{
|
||||
rc = _findclose (dirp->dd_handle);
|
||||
}
|
||||
|
||||
/* Delete the dir structure. */
|
||||
free (dirp);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* rewinddir
|
||||
*
|
||||
* Return to the beginning of the directory "stream". We simply call findclose
|
||||
* and then reset things like an opendir.
|
||||
*/
|
||||
void
|
||||
_trewinddir (_TDIR * dirp)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (dirp->dd_handle != -1)
|
||||
{
|
||||
_findclose (dirp->dd_handle);
|
||||
}
|
||||
|
||||
dirp->dd_handle = -1;
|
||||
dirp->dd_stat = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* telldir
|
||||
*
|
||||
* Returns the "position" in the "directory stream" which can be used with
|
||||
* seekdir to go back to an old entry. We simply return the value in stat.
|
||||
*/
|
||||
long
|
||||
_ttelldir (_TDIR * dirp)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return dirp->dd_stat;
|
||||
}
|
||||
|
||||
/*
|
||||
* seekdir
|
||||
*
|
||||
* Seek to an entry previously returned by telldir. We rewind the directory
|
||||
* and call readdir repeatedly until either dd_stat is the position number
|
||||
* or -1 (off the end). This is not perfect, in that the directory may
|
||||
* have changed while we weren't looking. But that is probably the case with
|
||||
* any such system.
|
||||
*/
|
||||
void
|
||||
_tseekdir (_TDIR * dirp, long lPos)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lPos < -1)
|
||||
{
|
||||
/* Seeking to an invalid position. */
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
else if (lPos == -1)
|
||||
{
|
||||
/* Seek past end. */
|
||||
if (dirp->dd_handle != -1)
|
||||
{
|
||||
_findclose (dirp->dd_handle);
|
||||
}
|
||||
dirp->dd_handle = -1;
|
||||
dirp->dd_stat = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Rewind and read forward to the appropriate index. */
|
||||
_trewinddir (dirp);
|
||||
|
||||
while ((dirp->dd_stat < lPos) && _treaddir (dirp))
|
||||
;
|
||||
}
|
||||
}
|
7
winsup/mingw/mingwex/fdim.c
Normal file
7
winsup/mingw/mingwex/fdim.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fdim (double x, double y)
|
||||
{
|
||||
return (isgreater(x, y) ? (x - y) : 0.0);
|
||||
}
|
7
winsup/mingw/mingwex/fdimf.c
Normal file
7
winsup/mingw/mingwex/fdimf.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fdimf (float x, float y)
|
||||
{
|
||||
return (isgreater(x, y) ? (x - y) : 0.0F);
|
||||
}
|
7
winsup/mingw/mingwex/fdiml.c
Normal file
7
winsup/mingw/mingwex/fdiml.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
fdiml (long double x, long double y)
|
||||
{
|
||||
return (isgreater(x, y) ? (x - y) : 0.0L);
|
||||
}
|
14
winsup/mingw/mingwex/feclearexcept.c
Normal file
14
winsup/mingw/mingwex/feclearexcept.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.2.1
|
||||
The feclearexcept function clears the supported exceptions
|
||||
represented by its argument. */
|
||||
|
||||
int feclearexcept (int excepts)
|
||||
{
|
||||
fenv_t _env;
|
||||
__asm__ volatile ("fnstenv %0;" : "=m" (_env)); /* get the env */
|
||||
_env.__status_word &= ~(excepts & FE_ALL_EXCEPT); /* clear the except */
|
||||
__asm__ volatile ("fldenv %0;" :: "m" (_env)); /*set the env */
|
||||
return 0;
|
||||
}
|
12
winsup/mingw/mingwex/fegetenv.c
Normal file
12
winsup/mingw/mingwex/fegetenv.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.4.1
|
||||
The fegetenv function stores the current floating-point environment
|
||||
in the object pointed to by envp. */
|
||||
|
||||
int fegetenv (fenv_t * envp)
|
||||
{
|
||||
__asm__ ("fnstenv %0;": "=m" (*envp));
|
||||
return 0;
|
||||
}
|
||||
|
15
winsup/mingw/mingwex/fegetexceptflag.c
Normal file
15
winsup/mingw/mingwex/fegetexceptflag.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <fenv.h>
|
||||
|
||||
|
||||
/* 7.6.2.2
|
||||
The fegetexceptflag function stores an implementation-defined
|
||||
representation of the exception flags indicated by the argument
|
||||
excepts in the object pointed to by the argument flagp. */
|
||||
|
||||
int fegetexceptflag (fexcept_t * flagp, int excepts)
|
||||
{
|
||||
unsigned short _sw;
|
||||
__asm__ ("fnstsw %%ax;": "=a" (_sw));
|
||||
*flagp = _sw & excepts & FE_ALL_EXCEPT;
|
||||
return 0;
|
||||
}
|
14
winsup/mingw/mingwex/fegetround.c
Normal file
14
winsup/mingw/mingwex/fegetround.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.3.1
|
||||
The fegetround function returns the value of the rounding direction
|
||||
macro representing the current rounding direction. */
|
||||
|
||||
int
|
||||
fegetround (void)
|
||||
{
|
||||
unsigned short _cw;
|
||||
__asm__ ("fnstcw %0;" : "=m" (_cw));
|
||||
return _cw
|
||||
& (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO);
|
||||
}
|
18
winsup/mingw/mingwex/feholdexcept.c
Normal file
18
winsup/mingw/mingwex/feholdexcept.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.4.2
|
||||
The feholdexcept function saves the current floating-point
|
||||
environment in the object pointed to by envp, clears the exception
|
||||
flags, and then installs a non-stop (continue on exceptions) mode,
|
||||
if available, for all exceptions. */
|
||||
|
||||
int feholdexcept (fenv_t * envp)
|
||||
{
|
||||
fenv_t tmp_env;
|
||||
__asm__ ("fnstenv %0;" : "=m" (* envp)); /* save current into envp */
|
||||
tmp_env = * envp;
|
||||
tmp_env.__status_word &= ~FE_ALL_EXCEPT; /* clear exception flags */
|
||||
tmp_env.__control_word |= FE_ALL_EXCEPT; /* set cw to non-stop */
|
||||
__asm__ volatile ("fldenv %0;" : : "m" (tmp_env)); /* install the copy */
|
||||
return 0;
|
||||
}
|
19
winsup/mingw/mingwex/feraiseexcept.c
Normal file
19
winsup/mingw/mingwex/feraiseexcept.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.2.3
|
||||
The feraiseexcept function raises the supported exceptions
|
||||
represented by its argument The order in which these exceptions
|
||||
are raised is unspecified, except as stated in F.7.6.
|
||||
Whether the feraiseexcept function additionally raises
|
||||
the inexact exception whenever it raises the overflow
|
||||
or underflow exception is implementation-defined. */
|
||||
|
||||
int feraiseexcept (int excepts)
|
||||
{
|
||||
fenv_t _env;
|
||||
__asm__ volatile ("fnstenv %0;" : "=m" (_env));
|
||||
_env.__status_word |= excepts & FE_ALL_EXCEPT;
|
||||
__asm__ volatile ("fldenv %0;"
|
||||
"fwait;" : : "m" (_env));
|
||||
return 0;
|
||||
}
|
41
winsup/mingw/mingwex/fesetenv.c
Normal file
41
winsup/mingw/mingwex/fesetenv.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.4.3
|
||||
The fesetenv function establishes the floating-point environment
|
||||
represented by the object pointed to by envp. The argument envp
|
||||
points to an object set by a call to fegetenv or feholdexcept, or
|
||||
equal the macro FE_DFL_ENV or an implementation-defined environment
|
||||
macro. Note that fesetenv merely installs the state of the exception
|
||||
flags represented through its argument, and does not raise these
|
||||
exceptions.
|
||||
*/
|
||||
|
||||
extern void (*_imp___fpreset)( void ) ;
|
||||
|
||||
int fesetenv (const fenv_t * envp)
|
||||
{
|
||||
if (envp == FE_PC64_ENV)
|
||||
/*
|
||||
* fninit initializes the control register to 0x37f,
|
||||
* the status register to zero and the tag word to 0FFFFh.
|
||||
* The other registers are unaffected.
|
||||
*/
|
||||
__asm__ ("fninit");
|
||||
|
||||
else if (envp == FE_PC53_ENV)
|
||||
/*
|
||||
* MS _fpreset() does same *except* it sets control word
|
||||
* to 0x27f (53-bit precison).
|
||||
* We force calling _fpreset in msvcrt.dll
|
||||
*/
|
||||
|
||||
(*_imp___fpreset)();
|
||||
|
||||
else if (envp == FE_DFL_ENV)
|
||||
/* Use the choice made at app startup */
|
||||
_fpreset();
|
||||
|
||||
else
|
||||
__asm__ ("fldenv %0;" : : "m" (*envp));
|
||||
return 0;
|
||||
}
|
22
winsup/mingw/mingwex/fesetexceptflag.c
Normal file
22
winsup/mingw/mingwex/fesetexceptflag.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.2.4
|
||||
The fesetexceptflag function sets the complete status for those
|
||||
exception flags indicated by the argument excepts, according to the
|
||||
representation in the object pointed to by flagp. The value of
|
||||
*flagp shall have been set by a previous call to fegetexceptflag
|
||||
whose second argument represented at least those exceptions
|
||||
represented by the argument excepts. This function does not raise
|
||||
exceptions, but only sets the state of the flags. */
|
||||
|
||||
int fesetexceptflag (const fexcept_t * flagp, int excepts)
|
||||
{
|
||||
fenv_t _env;
|
||||
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
__asm__ volatile ("fnstenv %0;" : "=m" (_env));
|
||||
_env.__status_word &= ~excepts;
|
||||
_env.__status_word |= (*flagp & excepts);
|
||||
__asm__ volatile ("fldenv %0;" : : "m" (_env));
|
||||
return 0;
|
||||
}
|
19
winsup/mingw/mingwex/fesetround.c
Normal file
19
winsup/mingw/mingwex/fesetround.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <fenv.h>
|
||||
/* 7.6.3.2
|
||||
The fesetround function establishes the rounding direction
|
||||
represented by its argument round. If the argument is not equal
|
||||
to the value of a rounding direction macro, the rounding direction
|
||||
is not changed. */
|
||||
|
||||
int fesetround (int mode)
|
||||
{
|
||||
unsigned short _cw;
|
||||
if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||
!= 0)
|
||||
return -1;
|
||||
__asm__ volatile ("fnstcw %0;": "=m" (_cw));
|
||||
_cw &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO);
|
||||
_cw |= mode;
|
||||
__asm__ volatile ("fldcw %0;" : : "m" (_cw));
|
||||
return 0;
|
||||
}
|
15
winsup/mingw/mingwex/fetestexcept.c
Normal file
15
winsup/mingw/mingwex/fetestexcept.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <fenv.h>
|
||||
/* 7.6.2.5
|
||||
The fetestexcept function determines which of a specified subset of
|
||||
the exception flags are currently set. The excepts argument
|
||||
specifies the exception flags to be queried.
|
||||
The fetestexcept function returns the value of the bitwise OR of the
|
||||
exception macros corresponding to the currently set exceptions
|
||||
included in excepts. */
|
||||
|
||||
int fetestexcept (int excepts)
|
||||
{
|
||||
unsigned short _sw;
|
||||
__asm__ ("fnstsw %%ax" : "=a" (_sw));
|
||||
return _sw & excepts & FE_ALL_EXCEPT;
|
||||
}
|
20
winsup/mingw/mingwex/feupdateenv.c
Normal file
20
winsup/mingw/mingwex/feupdateenv.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* 7.6.4.4
|
||||
The feupdateenv function saves the currently raised exceptions in
|
||||
its automatic storage, installs the floating-point environment
|
||||
represented by the object pointed to by envp, and then raises the
|
||||
saved exceptions. The argument envp shall point to an object
|
||||
set by a call to feholdexcept or fegetenv, or equal the macro
|
||||
FE_DFL_ENV or an implementation-defined environment macro. */
|
||||
|
||||
/* FIXME: this works but surely there must be a better way. */
|
||||
|
||||
int feupdateenv (const fenv_t * envp)
|
||||
{
|
||||
unsigned int _fexcept = fetestexcept (FE_ALL_EXCEPT); /*save excepts */
|
||||
fesetenv (envp); /* install the env */
|
||||
feraiseexcept (_fexcept); /* raise the execept */
|
||||
return 0;
|
||||
}
|
||||
|
12
winsup/mingw/mingwex/fma.S
Normal file
12
winsup/mingw/mingwex/fma.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.file "fma.S"
|
||||
.text
|
||||
.align 2
|
||||
.p2align 4,,15
|
||||
.globl _fma
|
||||
.def _fma; .scl 2; .type 32; .endef
|
||||
_fma:
|
||||
fldl 4(%esp)
|
||||
fmull 12(%esp)
|
||||
fldl 20(%esp)
|
||||
faddp
|
||||
ret
|
12
winsup/mingw/mingwex/fmaf.S
Normal file
12
winsup/mingw/mingwex/fmaf.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.file "fmaf.S"
|
||||
.text
|
||||
.align 2
|
||||
.p2align 4,,15
|
||||
.globl _fmaf
|
||||
.def _fmaf; .scl 2; .type 32; .endef
|
||||
_fmaf:
|
||||
flds 4(%esp)
|
||||
fmuls 8(%esp)
|
||||
flds 12(%esp)
|
||||
faddp
|
||||
ret
|
4
winsup/mingw/mingwex/fmal.c
Normal file
4
winsup/mingw/mingwex/fmal.c
Normal file
@@ -0,0 +1,4 @@
|
||||
long double
|
||||
fmal ( long double _x, long double _y, long double _z){
|
||||
return ((_x * _y) + _z);
|
||||
}
|
7
winsup/mingw/mingwex/fmax.c
Normal file
7
winsup/mingw/mingwex/fmax.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fmax (double _x, double _y)
|
||||
{
|
||||
return ( isgreaterequal (_x, _y)|| __isnan (_y) ? _x : _y );
|
||||
}
|
7
winsup/mingw/mingwex/fmaxf.c
Normal file
7
winsup/mingw/mingwex/fmaxf.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fmaxf (float _x, float _y)
|
||||
{
|
||||
return (( isgreaterequal(_x, _y) || __isnanf (_y)) ? _x : _y );
|
||||
}
|
7
winsup/mingw/mingwex/fmaxl.c
Normal file
7
winsup/mingw/mingwex/fmaxl.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
fmaxl (long double _x, long double _y)
|
||||
{
|
||||
return (( isgreaterequal(_x, _y) || __isnanl (_y)) ? _x : _y );
|
||||
}
|
7
winsup/mingw/mingwex/fmin.c
Normal file
7
winsup/mingw/mingwex/fmin.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fmin (double _x, double _y)
|
||||
{
|
||||
return ((islessequal(_x, _y) || __isnan (_y)) ? _x : _y );
|
||||
}
|
7
winsup/mingw/mingwex/fminf.c
Normal file
7
winsup/mingw/mingwex/fminf.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fminf (float _x, float _y)
|
||||
{
|
||||
return ((islessequal(_x, _y) || _isnan (_y)) ? _x : _y );
|
||||
}
|
7
winsup/mingw/mingwex/fminl.c
Normal file
7
winsup/mingw/mingwex/fminl.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
fminl (long double _x, long double _y)
|
||||
{
|
||||
return ((islessequal(_x, _y) || __isnanl (_y)) ? _x : _y );
|
||||
}
|
81
winsup/mingw/mingwex/fp_consts.c
Normal file
81
winsup/mingw/mingwex/fp_consts.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Floating point consts needed by STL class mumeric_limits<float>
|
||||
and numeric_limits<double>. Also used as return values by nan, inf */
|
||||
|
||||
#include <math.h>
|
||||
/*
|
||||
According to IEEE 754 a QNaN has exponent bits of all 1 values and
|
||||
initial significand bit of 1. A SNaN has has an exponent of all 1
|
||||
values and initial significand bit of 0 (with one or more other
|
||||
significand bits of 1). An Inf has significand of 0 and
|
||||
exponent of all 1 values. A denormal value has all exponent bits of 0.
|
||||
|
||||
The following does _not_ follow those rules, but uses values
|
||||
equal to those exported from MS C++ runtime lib, msvcprt.dll
|
||||
for float and double. MSVC however, does not have long doubles.
|
||||
*/
|
||||
|
||||
|
||||
#define __DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
|
||||
#define __DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 } /* { 0, 0, 0, 0x7ff8 } */
|
||||
#define __DOUBLE_SNAN_REP { 0, 0, 0, 0xfff0 } /* { 1, 0, 0, 0x7ff0 } */
|
||||
#define __DOUBLE_DENORM_REP {1, 0, 0, 0}
|
||||
#define D_NAN_MASK 0x7ff0000000000000LL /* this will mask NaN's and Inf's */
|
||||
|
||||
#define __FLOAT_INF_REP { 0, 0x7f80 }
|
||||
#define __FLOAT_QNAN_REP { 0, 0xffc0 } /* { 0, 0x7fc0 } */
|
||||
#define __FLOAT_SNAN_REP { 0, 0xff80 } /* { 1, 0x7f80 } */
|
||||
#define __FLOAT_DENORM_REP {1,0}
|
||||
#define F_NAN_MASK 0x7f800000
|
||||
|
||||
/* This assumes no implicit (hidden) bit in extended mode */
|
||||
#define __LONG_DOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff }
|
||||
#define __LONG_DOUBLE_QNAN_REP { 0, 0, 0, 0xc000, 0xffff }
|
||||
#define __LONG_DOUBLE_SNAN_REP { 0, 0, 0, 0x8000, 0xffff }
|
||||
#define __LONG_DOUBLE_DENORM_REP {1, 0, 0, 0, 0}
|
||||
|
||||
union _ieee_rep
|
||||
{
|
||||
unsigned short rep[5];
|
||||
float float_val;
|
||||
double double_val;
|
||||
long double ldouble_val;
|
||||
} ;
|
||||
|
||||
const union _ieee_rep __QNAN = { __DOUBLE_QNAN_REP };
|
||||
/*
|
||||
const union _ieee_rep __SNAN = { __DOUBLE_SNAN_REP };
|
||||
const union _ieee_rep __INF = { __DOUBLE_INF_REP };
|
||||
const union _ieee_rep __DENORM = { __DOUBLE_DENORM_REP };
|
||||
*/
|
||||
/* ISO C99 */
|
||||
|
||||
#undef nan
|
||||
/* FIXME */
|
||||
double nan (const char * tagp __attribute__((unused)) )
|
||||
{ return __QNAN.double_val; }
|
||||
|
||||
|
||||
const union _ieee_rep __QNANF = { __FLOAT_QNAN_REP };
|
||||
/*
|
||||
const union _ieee_rep __SNANF = { __FLOAT_SNAN_REP };
|
||||
const union _ieee_rep __INFF = { __FLOAT_INF_REP };
|
||||
const union _ieee_rep __DENORMF = { __FLOAT_DENORM_REP };
|
||||
*/
|
||||
|
||||
#undef nanf
|
||||
/* FIXME */
|
||||
float nanf(const char * tagp __attribute__((unused)) )
|
||||
{ return __QNANF.float_val;}
|
||||
|
||||
|
||||
const union _ieee_rep __QNANL = { __LONG_DOUBLE_QNAN_REP };
|
||||
/*
|
||||
const union _ieee_rep __SNANL = { __LONG_DOUBLE_SNAN_REP };
|
||||
const union _ieee_rep __INFL = { __LONG_DOUBLE_INF_REP };
|
||||
const union _ieee_rep __DENORML = { __LONG_DOUBLE_DENORM_REP };
|
||||
*/
|
||||
|
||||
#undef nanl
|
||||
/* FIXME */
|
||||
long double nanl (const char * tagp __attribute__((unused)) )
|
||||
{ return __QNANL.ldouble_val;}
|
20
winsup/mingw/mingwex/fpclassify.c
Normal file
20
winsup/mingw/mingwex/fpclassify.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <math.h>
|
||||
|
||||
/* 'fxam' sets FPU flags C3,C2,C0 'fstsw' stores:
|
||||
FP_NAN 001 0x0100
|
||||
FP_NORMAL 010 0x0400
|
||||
FP_INFINITE 011 0x0500
|
||||
FP_ZERO 100 0x4000
|
||||
FP_SUBNORMAL 110 0x4400
|
||||
|
||||
and sets C1 flag (signbit) if neg */
|
||||
|
||||
int __fpclassify (double _x){
|
||||
unsigned short sw;
|
||||
__asm__ (
|
||||
"fxam; fstsw %%ax;"
|
||||
: "=a" (sw)
|
||||
: "t" (_x)
|
||||
);
|
||||
return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
|
||||
}
|
10
winsup/mingw/mingwex/fpclassifyf.c
Normal file
10
winsup/mingw/mingwex/fpclassifyf.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <math.h>
|
||||
int __fpclassifyf (float _x){
|
||||
unsigned short sw;
|
||||
__asm__ (
|
||||
"fxam; fstsw %%ax;"
|
||||
: "=a" (sw)
|
||||
: "t" (_x)
|
||||
);
|
||||
return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
|
||||
}
|
10
winsup/mingw/mingwex/fpclassifyl.c
Normal file
10
winsup/mingw/mingwex/fpclassifyl.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <math.h>
|
||||
int __fpclassifyl (long double _x){
|
||||
unsigned short sw;
|
||||
__asm__ (
|
||||
"fxam; fstsw %%ax;"
|
||||
: "=a" (sw)
|
||||
: "t" (_x)
|
||||
);
|
||||
return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
|
||||
}
|
11
winsup/mingw/mingwex/fucom.c
Normal file
11
winsup/mingw/mingwex/fucom.c
Normal file
@@ -0,0 +1,11 @@
|
||||
int
|
||||
__fp_unordered_compare (long double x, long double y){
|
||||
unsigned short retval;
|
||||
__asm__ (
|
||||
"fucom %%st(1);"
|
||||
"fnstsw;"
|
||||
: "=a" (retval)
|
||||
: "t" (x), "u" (y)
|
||||
);
|
||||
return retval;
|
||||
}
|
25
winsup/mingw/mingwex/fwide.c
Normal file
25
winsup/mingw/mingwex/fwide.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
This is a minimal implementation for environments where
|
||||
internationalization is not considered important.
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
int
|
||||
fwide(stream, mode)
|
||||
FILE *stream;
|
||||
int mode;
|
||||
{
|
||||
return -1; /* limited to byte orientation */
|
||||
}
|
||||
|
17
winsup/mingw/mingwex/imaxabs.c
Normal file
17
winsup/mingw/mingwex/imaxabs.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
This source code was extracted from the Q8 package created and
|
||||
placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
This particular implementation requires the matching <inttypes.h>.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
intmax_t
|
||||
imaxabs (intmax_t _j)
|
||||
{ return _j >= 0 ? _j : -_j; }
|
||||
|
||||
long long __attribute__ ((alias ("imaxabs"))) llabs (long long);
|
25
winsup/mingw/mingwex/imaxdiv.c
Normal file
25
winsup/mingw/mingwex/imaxdiv.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
This source code was extracted from the Q8 package created and
|
||||
placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
imaxdiv_t
|
||||
imaxdiv(intmax_t numer, intmax_t denom)
|
||||
{
|
||||
imaxdiv_t result;
|
||||
result.quot = numer / denom;
|
||||
result.rem = numer % denom;
|
||||
return result;
|
||||
}
|
||||
|
||||
long long __attribute__ ((alias ("imaxdiv")))
|
||||
lldiv (long long, long long);
|
14
winsup/mingw/mingwex/isnan.c
Normal file
14
winsup/mingw/mingwex/isnan.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
__isnan (double _x)
|
||||
{
|
||||
unsigned short _sw;
|
||||
__asm__ ("fxam;"
|
||||
"fstsw %%ax": "=a" (_sw) : "t" (_x));
|
||||
return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
|
||||
== FP_NAN;
|
||||
}
|
||||
|
||||
#undef isnan
|
||||
int __attribute__ ((alias ("__isnan"))) isnan (double);
|
12
winsup/mingw/mingwex/isnanf.c
Normal file
12
winsup/mingw/mingwex/isnanf.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <math.h>
|
||||
int
|
||||
__isnanf (float _x)
|
||||
{
|
||||
unsigned short _sw;
|
||||
__asm__ ("fxam;"
|
||||
"fstsw %%ax": "=a" (_sw) : "t" (_x) );
|
||||
return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
|
||||
== FP_NAN;
|
||||
}
|
||||
|
||||
int __attribute__ ((alias ("__isnanf"))) isnanf (float);
|
13
winsup/mingw/mingwex/isnanl.c
Normal file
13
winsup/mingw/mingwex/isnanl.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
__isnanl (long double _x)
|
||||
{
|
||||
unsigned short _sw;
|
||||
__asm__ ("fxam;"
|
||||
"fstsw %%ax": "=a" (_sw) : "t" (_x));
|
||||
return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
|
||||
== FP_NAN;
|
||||
}
|
||||
|
||||
int __attribute__ ((alias ("__isnanl"))) isnanl (long double);
|
3
winsup/mingw/mingwex/lltoa.c
Normal file
3
winsup/mingw/mingwex/lltoa.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
char* lltoa(long long _n, char * _c, int _i)
|
||||
{ return _i64toa (_n, _c, _i); }
|
3
winsup/mingw/mingwex/lltow.c
Normal file
3
winsup/mingw/mingwex/lltow.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
wchar_t* lltow(long long _n, wchar_t * _w, int _i)
|
||||
{ return _i64tow (_n, _w, _i); }
|
8
winsup/mingw/mingwex/log2.c
Normal file
8
winsup/mingw/mingwex/log2.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <math.h>
|
||||
double
|
||||
log2 (double _x)
|
||||
{
|
||||
double retval;
|
||||
__asm__ ("fyl2x;" : "=t" (retval) : "0" (_x), "u" (1.0L) : "st(1)");
|
||||
return retval;
|
||||
}
|
8
winsup/mingw/mingwex/log2f.c
Normal file
8
winsup/mingw/mingwex/log2f.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <math.h>
|
||||
float
|
||||
log2f (float _x)
|
||||
{
|
||||
float retval;
|
||||
__asm__ ("fyl2x;" : "=t" (retval) : "0" (_x), "u" (1.0L) : "st(1)");
|
||||
return retval;
|
||||
}
|
8
winsup/mingw/mingwex/log2l.c
Normal file
8
winsup/mingw/mingwex/log2l.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <math.h>
|
||||
long double
|
||||
log2l (long double _x)
|
||||
{
|
||||
long double retval;
|
||||
__asm__ ("fyl2x;" : "=t" (retval) : "0" (_x), "u" (1.0L) : "st(1)");
|
||||
return retval;
|
||||
}
|
12
winsup/mingw/mingwex/math_stubs.c
Normal file
12
winsup/mingw/mingwex/math_stubs.c
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double copysign (double x, double y) {return _copysign(x, y);}
|
||||
float copysignf (float x, float y) {return _copysign(x, y);}
|
||||
double logb (double x) {return _logb(x);}
|
||||
float logbf (float x) {return _logb( x );}
|
||||
double nextafter(double x, double y) {return _nextafter(x, y);}
|
||||
float nextafterf(float x, float y) {return _nextafter(x, y);}
|
||||
double scalb (double x, long i) {return _scalb (x, i);}
|
||||
float scalbf (float x, long i) {return _scalb(x, i);}
|
||||
|
21
winsup/mingw/mingwex/mbsinit.c
Normal file
21
winsup/mingw/mingwex/mbsinit.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
int
|
||||
mbsinit(ps)
|
||||
const mbstate_t *ps;
|
||||
{
|
||||
return 1; /* don't have shift states */
|
||||
}
|
||||
|
119
winsup/mingw/mingwex/mingw-fseek.c
Normal file
119
winsup/mingw/mingwex/mingw-fseek.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Workaround for limitations on win9x where a file contents are
|
||||
* not zero'd out if you seek past the end and then write.
|
||||
* Copied from ming local-patch to binutils/bfd/libbfd.c written by
|
||||
* Mumit Khan <khan@xraylith.wisc.edu>
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define INLINE __inline__
|
||||
#elif defined _MSC_VER
|
||||
# define INLINE __inline
|
||||
#else
|
||||
# define INLINE
|
||||
#endif
|
||||
|
||||
#define ZEROBLOCKSIZE 512
|
||||
static int __mingw_fseek_called;
|
||||
|
||||
/* FIXME: put this in startup code and make os_platform_id global?
|
||||
Or just get _osver from msvcrt.dll and bitest (_osver & 0x8000)? */
|
||||
|
||||
INLINE
|
||||
static
|
||||
int
|
||||
__mingw_is_win9x (void)
|
||||
{
|
||||
static DWORD os_platform_id = -1 ;
|
||||
|
||||
if (os_platform_id == -1)
|
||||
{
|
||||
OSVERSIONINFO os_version_info;
|
||||
memset (&os_version_info, 0, sizeof (OSVERSIONINFO));
|
||||
os_version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
GetVersionEx (&os_version_info);
|
||||
|
||||
os_platform_id = os_version_info.dwPlatformId;
|
||||
}
|
||||
|
||||
/* Don't even bother to check for Win32s. */
|
||||
return os_platform_id == VER_PLATFORM_WIN32_WINDOWS;
|
||||
}
|
||||
|
||||
/* The fseek in Win9x runtime does not zero out the file if seeking past
|
||||
the end; if you don't want random stuff from your disk included in your
|
||||
output DLL/executable, use this version instead. On WinNT/Win2k, it
|
||||
just calls runtime fseek().
|
||||
|
||||
CHECK/FIXME: Does this work for both text and binary modes?? */
|
||||
|
||||
|
||||
int
|
||||
__mingw_fseek (FILE *fp, long offset, int whence)
|
||||
{
|
||||
# undef fseek
|
||||
__mingw_fseek_called = 1;
|
||||
return fseek (fp, offset, whence);
|
||||
}
|
||||
|
||||
int
|
||||
__mingw_fwrite (const void *buffer, size_t size, size_t count, FILE *fp)
|
||||
{
|
||||
# undef fwrite
|
||||
if ( __mingw_is_win9x () && __mingw_fseek_called)
|
||||
{
|
||||
DWORD actual_length, current_position;
|
||||
__mingw_fseek_called = 0;
|
||||
fflush (fp);
|
||||
actual_length = GetFileSize ((HANDLE) _get_osfhandle (fileno (fp)),
|
||||
NULL);
|
||||
current_position = SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)),
|
||||
0, 0, FILE_CURRENT);
|
||||
#ifdef DEBUG
|
||||
printf ("__mingw_fwrite: current %ld, actual %ld\n",
|
||||
current_position, actual_length);
|
||||
#endif /* DEBUG */
|
||||
if (current_position > actual_length)
|
||||
{
|
||||
static char __mingw_zeros[ZEROBLOCKSIZE];
|
||||
long numleft;
|
||||
|
||||
SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)),
|
||||
0, 0, FILE_END);
|
||||
numleft = current_position - actual_length;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("__mingw_fwrite: Seeking %ld bytes past end\n", numleft);
|
||||
#endif /* DEBUG */
|
||||
while (numleft > 0)
|
||||
{
|
||||
DWORD nzeros = (numleft > ZEROBLOCKSIZE)
|
||||
? ZEROBLOCKSIZE : numleft;
|
||||
DWORD written;
|
||||
if (! WriteFile ((HANDLE) _get_osfhandle (fileno (fp)),
|
||||
__mingw_zeros, nzeros, &written, NULL))
|
||||
{
|
||||
/* Best we can hope for, or at least DJ says so. */
|
||||
SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)),
|
||||
0, 0, FILE_BEGIN);
|
||||
return -1;
|
||||
}
|
||||
if (written < nzeros)
|
||||
{
|
||||
/* Likewise. */
|
||||
SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)),
|
||||
0, 0, FILE_BEGIN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
numleft -= written;
|
||||
}
|
||||
FlushFileBuffers ((HANDLE) _get_osfhandle (fileno (fp)));
|
||||
}
|
||||
}
|
||||
return fwrite (buffer, size, count, fp);
|
||||
}
|
6
winsup/mingw/mingwex/rint.c
Normal file
6
winsup/mingw/mingwex/rint.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <math.h>
|
||||
double rint (double x){
|
||||
double retval;
|
||||
__asm__ ("frndint;" : "=t" (retval) : "0" (x));
|
||||
return retval;
|
||||
}
|
7
winsup/mingw/mingwex/rintf.c
Normal file
7
winsup/mingw/mingwex/rintf.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
float rintf (float x){
|
||||
float retval;
|
||||
__asm__ ("frndint;": "=t" (retval) : "0" (x));
|
||||
return retval;
|
||||
}
|
7
winsup/mingw/mingwex/rintl.c
Normal file
7
winsup/mingw/mingwex/rintl.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <math.h>
|
||||
|
||||
long double rintl (long double x){
|
||||
long double retval;
|
||||
__asm__ ("frndint;": "=t" (retval) : "0" (x));
|
||||
return retval;
|
||||
}
|
29
winsup/mingw/mingwex/round.c
Normal file
29
winsup/mingw/mingwex/round.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <fenv.h>
|
||||
|
||||
double
|
||||
round (double x) {
|
||||
double retval;
|
||||
unsigned short saved_cw, _cw;
|
||||
__asm__ (
|
||||
"fnstcw %0;"
|
||||
: "=m" (saved_cw)
|
||||
); /* save control word */
|
||||
_cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)
|
||||
| (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */
|
||||
__asm__ (
|
||||
"fldcw %0;"
|
||||
:
|
||||
: "m" (_cw)
|
||||
); /* load the rounding control */
|
||||
__asm__ (
|
||||
"frndint;"
|
||||
: "=t" (retval)
|
||||
: "0" (x)
|
||||
); /* do the rounding */
|
||||
__asm__ (
|
||||
"fldcw %0;"
|
||||
:
|
||||
: "m" (saved_cw)
|
||||
); /* restore control word */
|
||||
return retval;
|
||||
}
|
29
winsup/mingw/mingwex/roundf.c
Normal file
29
winsup/mingw/mingwex/roundf.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <fenv.h>
|
||||
|
||||
float
|
||||
roundf (float x) {
|
||||
double retval;
|
||||
unsigned short saved_cw, _cw;
|
||||
__asm__ (
|
||||
"fnstcw %0;"
|
||||
: "=m" (saved_cw)
|
||||
); /* save control word */
|
||||
_cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)
|
||||
| (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */
|
||||
__asm__ (
|
||||
"fldcw %0;"
|
||||
:
|
||||
: "m" (_cw)
|
||||
); /* load the rounding control */
|
||||
__asm__ (
|
||||
"frndint;"
|
||||
: "=t" (retval)
|
||||
: "0" (x)
|
||||
); /* do the rounding */
|
||||
__asm__ (
|
||||
"fldcw %0;"
|
||||
:
|
||||
: "m" (saved_cw)
|
||||
); /* restore control word */
|
||||
return retval;
|
||||
}
|
30
winsup/mingw/mingwex/roundl.c
Normal file
30
winsup/mingw/mingwex/roundl.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <fenv.h>
|
||||
|
||||
long double
|
||||
roundl (long double x) {
|
||||
long double retval;
|
||||
unsigned short saved_cw, _cw;
|
||||
__asm__ (
|
||||
"fnstcw %0;"
|
||||
: "=m" (saved_cw)
|
||||
); /* save control word */
|
||||
_cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)
|
||||
| (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */
|
||||
__asm__ (
|
||||
"fldcw %0;"
|
||||
:
|
||||
: "m" (_cw)
|
||||
); /* load the rounding control */
|
||||
__asm__ (
|
||||
"frndint;"
|
||||
: "=t" (retval)
|
||||
: "0" (x)
|
||||
); /* do the rounding */
|
||||
__asm__ (
|
||||
"fldcw %0;"
|
||||
:
|
||||
: "m" (saved_cw)
|
||||
); /* restore control word */
|
||||
return retval;
|
||||
}
|
||||
|
13
winsup/mingw/mingwex/signbit.c
Normal file
13
winsup/mingw/mingwex/signbit.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#define __FP_SIGNBIT 0x0200
|
||||
|
||||
int __signbit (double x) {
|
||||
unsigned short sw;
|
||||
__asm__ ("fxam; fstsw %%ax;"
|
||||
: "=a" (sw)
|
||||
: "t" (x) );
|
||||
return sw & __FP_SIGNBIT;
|
||||
}
|
||||
|
||||
#undef signbit
|
||||
int __attribute__ ((alias ("__signbit"))) signbit (double);
|
||||
|
10
winsup/mingw/mingwex/signbitf.c
Normal file
10
winsup/mingw/mingwex/signbitf.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#define __FP_SIGNBIT 0x0200
|
||||
|
||||
int __signbitf (float x) {
|
||||
unsigned short sw;
|
||||
__asm__ ("fxam; fstsw %%ax;"
|
||||
: "=a" (sw)
|
||||
: "t" (x) );
|
||||
return sw & __FP_SIGNBIT;
|
||||
}
|
||||
int __attribute__ ((alias ("__signbitf"))) signbitf (float);
|
11
winsup/mingw/mingwex/signbitl.c
Normal file
11
winsup/mingw/mingwex/signbitl.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#define __FP_SIGNBIT 0x0200
|
||||
|
||||
int __signbitl (long double x) {
|
||||
unsigned short sw;
|
||||
__asm__ ("fxam; fstsw %%ax;"
|
||||
: "=a" (sw)
|
||||
: "t" (x) );
|
||||
return sw & __FP_SIGNBIT;
|
||||
}
|
||||
|
||||
int __attribute__ ((alias ("__signbitl"))) signbitl (long double);
|
1527
winsup/mingw/mingwex/sitest.c
Normal file
1527
winsup/mingw/mingwex/sitest.c
Normal file
File diff suppressed because it is too large
Load Diff
13
winsup/mingw/mingwex/snprintf.c
Normal file
13
winsup/mingw/mingwex/snprintf.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int snprintf(char* buffer, size_t n, const char* format, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list argptr;
|
||||
|
||||
va_start( argptr, format );
|
||||
retval = _vsnprintf( buffer, n, format, argptr );
|
||||
va_end( argptr );
|
||||
return retval;
|
||||
}
|
13
winsup/mingw/mingwex/snwprintf.c
Normal file
13
winsup/mingw/mingwex/snwprintf.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int snwprintf(wchar_t* buffer, size_t n, const wchar_t* format, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list argptr;
|
||||
|
||||
va_start( argptr, format );
|
||||
retval = _vsnwprintf( buffer, n, format, argptr );
|
||||
va_end( argptr );
|
||||
return retval;
|
||||
}
|
6
winsup/mingw/mingwex/strtof.c
Normal file
6
winsup/mingw/mingwex/strtof.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
float strtof( const char *nptr, char **endptr)
|
||||
{
|
||||
return (strtod(nptr, endptr));
|
||||
}
|
112
winsup/mingw/mingwex/strtoimax.c
Normal file
112
winsup/mingw/mingwex/strtoimax.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
This source code was extracted from the Q8 package created and
|
||||
placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
This particular implementation requires the matching <inttypes.h>.
|
||||
It also assumes that character codes for A..Z and a..z are in
|
||||
contiguous ascending order; this is true for ASCII but not EBCDIC.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* Helper macros */
|
||||
|
||||
/* convert digit character to number, in any base */
|
||||
#define ToNumber(c) (isdigit(c) ? (c) - '0' : \
|
||||
isupper(c) ? (c) - 'A' + 10 : \
|
||||
islower(c) ? (c) - 'a' + 10 : \
|
||||
-1 /* "invalid" flag */ \
|
||||
)
|
||||
/* validate converted digit character for specific base */
|
||||
#define valid(n, b) ((n) >= 0 && (n) < (b))
|
||||
|
||||
intmax_t
|
||||
strtoimax(nptr, endptr, base)
|
||||
register const char * __restrict__ nptr;
|
||||
char ** __restrict__ endptr;
|
||||
register int base;
|
||||
{
|
||||
register uintmax_t accum; /* accumulates converted value */
|
||||
register int n; /* numeral from digit character */
|
||||
int minus; /* set iff minus sign seen */
|
||||
int toobig; /* set iff value overflows */
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (char *)nptr; /* in case no conversion's performed */
|
||||
|
||||
if ( base < 0 || base == 1 || base > 36 )
|
||||
{
|
||||
errno = EDOM;
|
||||
return 0; /* unspecified behavior */
|
||||
}
|
||||
|
||||
/* skip initial, possibly empty sequence of white-space characters */
|
||||
|
||||
while ( isspace(*nptr) )
|
||||
++nptr;
|
||||
|
||||
/* process subject sequence: */
|
||||
|
||||
/* optional sign */
|
||||
if ( (minus = *nptr == '-') || *nptr == '+' )
|
||||
++nptr;
|
||||
|
||||
if ( base == 0 ) {
|
||||
if ( *nptr == '0' ) {
|
||||
if ( nptr[1] == 'X' || nptr[1] == 'x' )
|
||||
base = 16;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
/* optional "0x" or "0X" for base 16 */
|
||||
|
||||
if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') )
|
||||
nptr += 2; /* skip past this prefix */
|
||||
|
||||
/* check whether there is at least one valid digit */
|
||||
|
||||
n = ToNumber(*nptr);
|
||||
++nptr;
|
||||
|
||||
if ( !valid(n, base) )
|
||||
return 0; /* subject seq. not of expected form */
|
||||
|
||||
accum = n;
|
||||
|
||||
for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr )
|
||||
if ( accum > INTMAX_MAX / base + 2 ) /* major wrap-around */
|
||||
toobig = 1; /* but keep scanning */
|
||||
else
|
||||
accum = base * accum + n;
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (char *)nptr; /* points to first not-valid-digit */
|
||||
|
||||
if ( minus )
|
||||
{
|
||||
if ( accum > (uintmax_t)INTMAX_MAX + 1 )
|
||||
toobig = 1;
|
||||
}
|
||||
else
|
||||
if ( accum > (uintmax_t)INTMAX_MAX )
|
||||
toobig = 1;
|
||||
|
||||
if ( toobig )
|
||||
{
|
||||
errno = ERANGE;
|
||||
return minus ? INTMAX_MIN : INTMAX_MAX;
|
||||
}
|
||||
else
|
||||
return (intmax_t)(minus ? -accum : accum);
|
||||
}
|
||||
|
||||
long long __attribute__ ((alias ("strtoimax")))
|
||||
strtoll (const char* __restrict__ nptr, char ** __restrict__ endptr, int base);
|
110
winsup/mingw/mingwex/strtoumax.c
Normal file
110
winsup/mingw/mingwex/strtoumax.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
This source code was extracted from the Q8 package created and
|
||||
placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
This particular implementation requires the matching <inttypes.h>.
|
||||
It also assumes that character codes for A..Z and a..z are in
|
||||
contiguous ascending order; this is true for ASCII but not EBCDIC.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* Helper macros */
|
||||
|
||||
/* convert digit character to number, in any base */
|
||||
#define ToNumber(c) (isdigit(c) ? (c) - '0' : \
|
||||
isupper(c) ? (c) - 'A' + 10 : \
|
||||
islower(c) ? (c) - 'a' + 10 : \
|
||||
-1 /* "invalid" flag */ \
|
||||
)
|
||||
/* validate converted digit character for specific base */
|
||||
#define valid(n, b) ((n) >= 0 && (n) < (b))
|
||||
|
||||
uintmax_t
|
||||
strtoumax(nptr, endptr, base)
|
||||
register const char * __restrict__ nptr;
|
||||
char ** __restrict__ endptr;
|
||||
register int base;
|
||||
{
|
||||
register uintmax_t accum; /* accumulates converted value */
|
||||
register uintmax_t next; /* for computing next value of accum */
|
||||
register int n; /* numeral from digit character */
|
||||
int minus; /* set iff minus sign seen (yes!) */
|
||||
int toobig; /* set iff value overflows */
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (char *)nptr; /* in case no conversion's performed */
|
||||
|
||||
if ( base < 0 || base == 1 || base > 36 )
|
||||
{
|
||||
errno = EDOM;
|
||||
return 0; /* unspecified behavior */
|
||||
}
|
||||
|
||||
/* skip initial, possibly empty sequence of white-space characters */
|
||||
|
||||
while ( isspace(*nptr) )
|
||||
++nptr;
|
||||
|
||||
/* process subject sequence: */
|
||||
|
||||
/* optional sign (yes!) */
|
||||
|
||||
if ( (minus = *nptr == '-') || *nptr == '+' )
|
||||
++nptr;
|
||||
|
||||
if ( base == 0 )
|
||||
{
|
||||
if ( *nptr == '0' )
|
||||
{
|
||||
if ( nptr[1] == 'X' || nptr[1] == 'x' )
|
||||
base = 16;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
|
||||
/* optional "0x" or "0X" for base 16 */
|
||||
|
||||
if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') )
|
||||
nptr += 2; /* skip past this prefix */
|
||||
|
||||
/* check whether there is at least one valid digit */
|
||||
|
||||
n = ToNumber(*nptr);
|
||||
++nptr;
|
||||
|
||||
if ( !valid(n, base) )
|
||||
return 0; /* subject seq. not of expected form */
|
||||
|
||||
accum = n;
|
||||
|
||||
for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr )
|
||||
if ( accum > UINTMAX_MAX / base + 1 /* major wrap-around */
|
||||
|| (next = base * accum + n) < accum /* minor wrap-around */
|
||||
)
|
||||
toobig = 1; /* but keep scanning */
|
||||
else
|
||||
accum = next;
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (char *)nptr; /* points to first not-valid-digit */
|
||||
|
||||
if ( toobig )
|
||||
{
|
||||
errno = ERANGE;
|
||||
return UINTMAX_MAX;
|
||||
}
|
||||
else
|
||||
return minus ? -accum : accum; /* (yes!) */
|
||||
}
|
||||
|
||||
unsigned long long __attribute__ ((alias ("strtoumax")))
|
||||
strtoull (const char* __restrict__ nptr, char ** __restrict__ endptr, int base);
|
104
winsup/mingw/mingwex/testwmem.c
Normal file
104
winsup/mingw/mingwex/testwmem.c
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <memory.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
wchar_t fmt1[] = L" 1 2 3 4 5";
|
||||
wchar_t fmt2[] = L"12345678901234567890123456789012345678901234567890";
|
||||
|
||||
void test_wmemchr( void )
|
||||
{
|
||||
wchar_t* dest;
|
||||
wint_t result;
|
||||
wint_t ch = L'r';
|
||||
wchar_t str[] = L"lazy";
|
||||
wchar_t string1[60] = L"The quick brown dog jumps over the lazy fox";
|
||||
|
||||
wprintf( L"Wmemchr\n" );
|
||||
wprintf( L"String to be searched:\n\t\t%s\n", string1 );
|
||||
wprintf( L"\t\t%s\n\t\t%s\n\n", fmt1, fmt2 );
|
||||
|
||||
wprintf( L"Search char:\t%c\n", ch );
|
||||
dest = wmemchr( string1, ch, sizeof( string1 ) );
|
||||
result = dest - string1 + 1;
|
||||
if( dest != NULL )
|
||||
wprintf( L"Result:\t\t%c found at position %d\n\n", ch, result );
|
||||
else
|
||||
wprintf( L"Result:\t\t%c not found\n\n" );
|
||||
return;
|
||||
}
|
||||
void test_wmemset( void )
|
||||
{/* 1 2
|
||||
0123456789012345678901234567890 */
|
||||
wchar_t buffer[] = L"This is a test of the wmemset function";
|
||||
wprintf( L"Before: %s\n", buffer );
|
||||
wmemset( buffer+22, L'*', 7 );
|
||||
wprintf( L"After: %s\n\n", buffer );
|
||||
return;
|
||||
}
|
||||
|
||||
void test_wmemmove( void )
|
||||
{
|
||||
wchar_t string1[60] = L"The quick brown dog jumps over the lazy fox";
|
||||
wchar_t string2[60] = L"The quick brown fox jumps over the lazy dog";
|
||||
|
||||
wprintf( L"Wmemcpy without overlap\n" );
|
||||
wprintf( L"Source:\t\t%s\n", string1 + 40 );
|
||||
wprintf( L"Destination:\t%s\n", string1 + 16 );
|
||||
wmemcpy( string1 + 16, string1 + 40, 3 );
|
||||
wprintf( L"Result:\t\t%s\n", string1 );
|
||||
wprintf( L"Length:\t\t%d characters\n\n", wcslen( string1 ) );
|
||||
wmemcpy( string1 + 16, string2 + 40, 3 );
|
||||
|
||||
wprintf( L"Wmemmove with overlap\n" );
|
||||
wprintf( L"Source:\t\t%s\n", string2 + 4 );
|
||||
wprintf( L"Destination:\t%s\n", string2 + 10 );
|
||||
wmemmove( string2 + 10, string2 + 4, 40 );
|
||||
wprintf( L"Result:\t\t%s\n", string2 );
|
||||
wprintf( L"Length:\t\t%d characters\n\n", wcslen( string2 ) );
|
||||
|
||||
wprintf( L"Wmemcpy with overlap\n" );
|
||||
wprintf( L"Source:\t\t%s\n", string1 + 4 );
|
||||
wprintf( L"Destination:\t%s\n", string1 + 10 );
|
||||
wmemcpy( string1 + 10, string1 + 4, 40 );
|
||||
wprintf( L"Result:\t\t%s\n", string1 );
|
||||
wprintf( L"Length:\t\t%d characters\n\n", wcslen( string1 ) );
|
||||
}
|
||||
|
||||
|
||||
void test_wmemcmp( void )
|
||||
{
|
||||
wchar_t first[] = L"12345678901234567890";
|
||||
wchar_t second[] = L"12345678901234567891";
|
||||
wint_t result;
|
||||
wprintf(L"Wmemcmp\n");
|
||||
wprintf( L"Compare '%.19s' to '%.19s':\n", first, second );
|
||||
result = wmemcmp( first, second, 19 );
|
||||
if( result < 0 )
|
||||
wprintf( L"First is less than second.\n" );
|
||||
else if( result == 0 )
|
||||
wprintf( L"First is equal to second.\n" );
|
||||
else if( result > 0 )
|
||||
wprintf( L"First is greater than second.\n" );
|
||||
wprintf( L"\nCompare '%.20s' to '%.20s':\n", first, second );
|
||||
result = wmemcmp( first, second, 20 );
|
||||
if( result < 0 )
|
||||
wprintf( L"First is less than second.\n\n" );
|
||||
else if( result == 0 )
|
||||
wprintf( L"First is equal to second.\n\n" );
|
||||
else if( result > 0 )
|
||||
wprintf( L"First is greater than second.\n\n" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
test_wmemset();
|
||||
test_wmemmove();
|
||||
test_wmemchr();
|
||||
test_wmemcmp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
17
winsup/mingw/mingwex/trunc.c
Normal file
17
winsup/mingw/mingwex/trunc.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <fenv.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
trunc (double _x){
|
||||
double retval;
|
||||
unsigned short saved_cw;
|
||||
__asm__ ("fnstcw %0;": "=m" (saved_cw)); /* save FPU control word */
|
||||
__asm__ ("fldcw %0;"
|
||||
:
|
||||
: "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD
|
||||
| FE_TOWARDZERO)) | FE_TOWARDZERO)
|
||||
);
|
||||
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||
return retval;
|
||||
}
|
17
winsup/mingw/mingwex/truncf.c
Normal file
17
winsup/mingw/mingwex/truncf.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <fenv.h>
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
truncf (float _x){
|
||||
float retval;
|
||||
unsigned short saved_cw;
|
||||
__asm__ ("fnstcw %0;": "=m" (saved_cw)); /* save FPU control word */
|
||||
__asm__ ("fldcw %0;"
|
||||
:
|
||||
: "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD
|
||||
| FE_TOWARDZERO)) | FE_TOWARDZERO)
|
||||
);
|
||||
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||
return retval;
|
||||
}
|
17
winsup/mingw/mingwex/truncl.c
Normal file
17
winsup/mingw/mingwex/truncl.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <fenv.h>
|
||||
#include <math.h>
|
||||
|
||||
long double
|
||||
truncl (long double _x){
|
||||
long double retval;
|
||||
unsigned short saved_cw;
|
||||
__asm__ ("fnstcw %0;": "=m" (saved_cw)); /* save FPU control word */
|
||||
__asm__ ("fldcw %0;"
|
||||
:
|
||||
: "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD
|
||||
| FE_TOWARDZERO)) | FE_TOWARDZERO)
|
||||
);
|
||||
__asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||
__asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||
return retval;
|
||||
}
|
3
winsup/mingw/mingwex/ulltoa.c
Normal file
3
winsup/mingw/mingwex/ulltoa.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
char* ulltoa(unsigned long long _n, char * _c, int _i)
|
||||
{ return _ui64toa (_n, _c, _i); }
|
3
winsup/mingw/mingwex/ulltow.c
Normal file
3
winsup/mingw/mingwex/ulltow.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
wchar_t* ulltow(unsigned long long _n, wchar_t * _w, int _i)
|
||||
{ return _ui64tow (_n, _w, _i); }
|
5
winsup/mingw/mingwex/vsnprintf.c
Normal file
5
winsup/mingw/mingwex/vsnprintf.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int vsnprintf (char* s, size_t n, const char* format, va_list arg)
|
||||
{ return _vsnprintf ( s, n, format, arg); }
|
5
winsup/mingw/mingwex/vsnwprintf.c
Normal file
5
winsup/mingw/mingwex/vsnwprintf.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int vsnwprintf(wchar_t *buffer, size_t n, const wchar_t * format, va_list argptr)
|
||||
{ return _vsnwprintf( buffer, n, format, argptr );}
|
6
winsup/mingw/mingwex/wcstof.c
Normal file
6
winsup/mingw/mingwex/wcstof.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <wchar.h>
|
||||
|
||||
float wcstof( const wchar_t *nptr, wchar_t **endptr)
|
||||
{
|
||||
return (wcstod(nptr, endptr));
|
||||
}
|
119
winsup/mingw/mingwex/wcstoimax.c
Normal file
119
winsup/mingw/mingwex/wcstoimax.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
This source code was extracted from the Q8 package created and
|
||||
placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
This particular implementation requires the matching <inttypes.h>.
|
||||
It also assumes that character codes for A..Z and a..z are in
|
||||
contiguous ascending order; this is true for ASCII but not EBCDIC.
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* convert digit wide character to number, in any base */
|
||||
|
||||
#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \
|
||||
iswupper(c) ? (c) - L'A' + 10 : \
|
||||
iswlower(c) ? (c) - L'a' + 10 : \
|
||||
-1 /* "invalid" flag */ \
|
||||
)
|
||||
|
||||
/* validate converted digit character for specific base */
|
||||
#define valid(n, b) ((n) >= 0 && (n) < (b))
|
||||
|
||||
intmax_t
|
||||
wcstoimax(nptr, endptr, base)
|
||||
register const wchar_t * __restrict__ nptr;
|
||||
wchar_t ** __restrict__ endptr;
|
||||
register int base;
|
||||
{
|
||||
register uintmax_t accum; /* accumulates converted value */
|
||||
register int n; /* numeral from digit character */
|
||||
int minus; /* set iff minus sign seen */
|
||||
int toobig; /* set iff value overflows */
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (wchar_t *)nptr; /* in case no conv performed */
|
||||
|
||||
if ( base < 0 || base == 1 || base > 36 )
|
||||
{
|
||||
errno = EDOM;
|
||||
return 0; /* unspecified behavior */
|
||||
}
|
||||
|
||||
/* skip initial, possibly empty sequence of white-space w.characters */
|
||||
|
||||
while ( iswspace(*nptr) )
|
||||
++nptr;
|
||||
|
||||
/* process subject sequence: */
|
||||
|
||||
/* optional sign */
|
||||
|
||||
if ( (minus = *nptr == L'-') || *nptr == L'+' )
|
||||
++nptr;
|
||||
|
||||
if ( base == 0 )
|
||||
{
|
||||
if ( *nptr == L'0' )
|
||||
{
|
||||
if ( nptr[1] == L'X' || nptr[1] == L'x' )
|
||||
base = 16;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
/* optional "0x" or "0X" for base 16 */
|
||||
|
||||
if ( base == 16 && *nptr == L'0'
|
||||
&& (nptr[1] == L'X' || nptr[1] == L'x')
|
||||
)
|
||||
nptr += 2; /* skip past this prefix */
|
||||
|
||||
/* check whether there is at least one valid digit */
|
||||
|
||||
n = ToWNumber(*nptr);
|
||||
++nptr;
|
||||
|
||||
if ( !valid(n, base) )
|
||||
return 0; /* subject seq. not of expected form */
|
||||
|
||||
accum = n;
|
||||
|
||||
for ( toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr )
|
||||
if ( accum > INTMAX_MAX / base + 2 ) /* major wrap-around */
|
||||
toobig = 1; /* but keep scanning */
|
||||
else
|
||||
accum = base * accum + n;
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (wchar_t *)nptr; /* -> first not-valid-digit */
|
||||
|
||||
if ( minus )
|
||||
{
|
||||
if ( accum > (uintmax_t)INTMAX_MAX + 1 )
|
||||
toobig = 1;
|
||||
}
|
||||
else
|
||||
if ( accum > (uintmax_t)INTMAX_MAX )
|
||||
toobig = 1;
|
||||
|
||||
if ( toobig )
|
||||
{
|
||||
errno = ERANGE;
|
||||
return minus ? INTMAX_MIN : INTMAX_MAX;
|
||||
}
|
||||
else
|
||||
return (intmax_t)(minus ? -accum : accum);
|
||||
}
|
||||
|
||||
long long __attribute__ ((alias ("wcstoimax")))
|
||||
wcstoll (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, int base);
|
113
winsup/mingw/mingwex/wcstoumax.c
Normal file
113
winsup/mingw/mingwex/wcstoumax.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
This source code was extracted from the Q8 package created and
|
||||
placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
This particular implementation requires the matching <inttypes.h>.
|
||||
It also assumes that character codes for A..Z and a..z are in
|
||||
contiguous ascending order; this is true for ASCII but not EBCDIC.
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* convert digit wide character to number, in any base */
|
||||
|
||||
#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \
|
||||
iswupper(c) ? (c) - L'A' + 10 : \
|
||||
iswlower(c) ? (c) - L'a' + 10 : \
|
||||
-1 /* "invalid" flag */ \
|
||||
)
|
||||
|
||||
/* validate converted digit character for specific base */
|
||||
#define valid(n, b) ((n) >= 0 && (n) < (b))
|
||||
|
||||
uintmax_t
|
||||
wcstoumax(nptr, endptr, base)
|
||||
register const wchar_t * __restrict__ nptr;
|
||||
wchar_t ** __restrict__ endptr;
|
||||
register int base;
|
||||
{
|
||||
register uintmax_t accum; /* accumulates converted value */
|
||||
register uintmax_t next; /* for computing next value of accum */
|
||||
register int n; /* numeral from digit character */
|
||||
int minus; /* set iff minus sign seen (yes!) */
|
||||
int toobig; /* set iff value overflows */
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (wchar_t *)nptr; /* in case no conv performed */
|
||||
|
||||
if ( base < 0 || base == 1 || base > 36 )
|
||||
{
|
||||
errno = EDOM;
|
||||
return 0; /* unspecified behavior */
|
||||
}
|
||||
|
||||
/* skip initial, possibly empty sequence of white-space w.characters */
|
||||
|
||||
while ( iswspace(*nptr) )
|
||||
++nptr;
|
||||
|
||||
/* process subject sequence: */
|
||||
|
||||
/* optional sign */
|
||||
|
||||
if ( (minus = *nptr == L'-') || *nptr == L'+' )
|
||||
++nptr;
|
||||
|
||||
if ( base == 0 )
|
||||
{
|
||||
if ( *nptr == L'0' )
|
||||
{
|
||||
if ( nptr[1] == L'X' || nptr[1] == L'x' )
|
||||
base = 16;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
/* optional "0x" or "0X" for base 16 */
|
||||
|
||||
if ( base == 16 && *nptr == L'0'
|
||||
&& (nptr[1] == L'X' || nptr[1] == L'x')
|
||||
)
|
||||
nptr += 2; /* skip past this prefix */
|
||||
|
||||
/* check whether there is at least one valid digit */
|
||||
|
||||
n = ToWNumber(*nptr);
|
||||
++nptr;
|
||||
|
||||
if ( !valid(n, base) )
|
||||
return 0; /* subject seq. not of expected form */
|
||||
|
||||
accum = n;
|
||||
|
||||
for ( toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr )
|
||||
if ( accum > UINTMAX_MAX / base + 1 /* major wrap-around */
|
||||
|| (next = base * accum + n) < accum /* minor wrap-around */
|
||||
)
|
||||
toobig = 1; /* but keep scanning */
|
||||
else
|
||||
accum = next;
|
||||
|
||||
if ( endptr != NULL )
|
||||
*endptr = (wchar_t *)nptr; /* -> first not-valid-digit */
|
||||
|
||||
if ( toobig )
|
||||
{
|
||||
errno = ERANGE;
|
||||
return UINTMAX_MAX;
|
||||
}
|
||||
else
|
||||
return minus ? -accum : accum; /* (yes!) */
|
||||
}
|
||||
|
||||
unsigned long long __attribute__ ((alias ("wcstoumax")))
|
||||
wcstoull (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, int base);
|
3
winsup/mingw/mingwex/wdirent.c
Normal file
3
winsup/mingw/mingwex/wdirent.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define _UNICODE 1
|
||||
#define UNICODE 1
|
||||
#include "dirent.c"
|
28
winsup/mingw/mingwex/wmemchr.c
Normal file
28
winsup/mingw/mingwex/wmemchr.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t*
|
||||
wmemchr(s, c, n)
|
||||
register const wchar_t *s;
|
||||
register wchar_t c;
|
||||
register size_t n;
|
||||
{
|
||||
if ( s != NULL )
|
||||
for ( ; n > 0; ++s, --n )
|
||||
if ( *s == c )
|
||||
return (wchar_t *)s;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
32
winsup/mingw/mingwex/wmemcmp.c
Normal file
32
winsup/mingw/mingwex/wmemcmp.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
int
|
||||
wmemcmp(s1, s2, n)
|
||||
register const wchar_t *s1;
|
||||
register const wchar_t *s2;
|
||||
size_t n;
|
||||
{
|
||||
if ( n == 0 || s1 == s2 )
|
||||
return 0; /* even for NULL pointers */
|
||||
|
||||
if ( (s1 != NULL) != (s2 != NULL) )
|
||||
return s2 == NULL ? 1 : -1; /* robust */
|
||||
|
||||
for ( ; n > 0; ++s1, ++s2, --n )
|
||||
if ( *s1 != *s2 )
|
||||
return *s1 - *s2;
|
||||
|
||||
return 0;
|
||||
}
|
32
winsup/mingw/mingwex/wmemcpy.c
Normal file
32
winsup/mingw/mingwex/wmemcpy.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
wchar_t *
|
||||
wmemcpy(s1, s2, n)
|
||||
register wchar_t * __restrict__ s1;
|
||||
register const wchar_t * __restrict__ s2;
|
||||
register size_t n;
|
||||
{
|
||||
wchar_t *orig_s1 = s1;
|
||||
|
||||
if ( s1 == NULL || s2 == NULL || n == 0 )
|
||||
return orig_s1; /* robust */
|
||||
|
||||
for ( ; n > 0; --n )
|
||||
*s1++ = *s2++;
|
||||
|
||||
return orig_s1;
|
||||
}
|
||||
|
43
winsup/mingw/mingwex/wmemmove.c
Normal file
43
winsup/mingw/mingwex/wmemmove.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *
|
||||
wmemmove(s1, s2, n)
|
||||
register wchar_t *s1;
|
||||
register const wchar_t *s2;
|
||||
register size_t n;
|
||||
{
|
||||
wchar_t *orig_s1 = s1;
|
||||
|
||||
if ( s1 == NULL || s2 == NULL || n == 0 )
|
||||
return orig_s1; /* robust */
|
||||
|
||||
/* XXX -- The following test works only within a flat address space! */
|
||||
if ( s2 >= s1 )
|
||||
for ( ; n > 0; --n )
|
||||
*s1++ = *s2++;
|
||||
else {
|
||||
s1 += n;
|
||||
s2 += n;
|
||||
|
||||
for ( ; n > 0; --n )
|
||||
*--s1 = *--s2;
|
||||
}
|
||||
|
||||
return orig_s1;
|
||||
}
|
||||
|
30
winsup/mingw/mingwex/wmemset.c
Normal file
30
winsup/mingw/mingwex/wmemset.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/* This source code was extracted from the Q8 package created and placed
|
||||
in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil>
|
||||
last edit: 1999/11/05 gwyn@arl.mil
|
||||
|
||||
Implements subclause 7.24 of ISO/IEC 9899:1999 (E).
|
||||
|
||||
It supports an encoding where all char codes are mapped
|
||||
to the *same* code values within a wchar_t or wint_t,
|
||||
so long as no other wchar_t codes are used by the program.
|
||||
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
wchar_t *
|
||||
wmemset(s, c, n)
|
||||
register wchar_t *s;
|
||||
register wchar_t c;
|
||||
register size_t n;
|
||||
{
|
||||
wchar_t *orig_s = s;
|
||||
|
||||
if ( s != NULL )
|
||||
for ( ; n > 0; --n )
|
||||
*s++ = c;
|
||||
|
||||
return orig_s;
|
||||
}
|
||||
|
3
winsup/mingw/mingwex/wtoll.c
Normal file
3
winsup/mingw/mingwex/wtoll.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stdlib.h>
|
||||
long long wtoll(const wchar_t * _w)
|
||||
{ return _wtoi64 (_w); };
|
Reference in New Issue
Block a user