Commit 96123836 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved [efg]cvt functions to msvcrt and fixed them to use a per-thread

buffer.
parent 195574e2
......@@ -13078,9 +13078,6 @@ fi
for ac_func in \
_lwp_create \
_pclose \
......@@ -13091,13 +13088,10 @@ for ac_func in \
_vsnprintf \
chsize \
clone \
ecvt \
fcvt \
finite \
fpclass \
ftruncate \
ftruncate64 \
gcvt \
getnetbyaddr \
getnetbyname \
getopt_long \
......
......@@ -916,13 +916,10 @@ AC_CHECK_FUNCS(\
_vsnprintf \
chsize \
clone \
ecvt \
fcvt \
finite \
fpclass \
ftruncate \
ftruncate64 \
gcvt \
getnetbyaddr \
getnetbyname \
getopt_long \
......
......@@ -21,6 +21,7 @@
#include "msvcrt.h"
#include "msvcrt/errno.h"
#include <stdio.h>
#define __USE_ISOC9X 1
#define __USE_ISOC99 1
#include <math.h>
......@@ -681,6 +682,53 @@ double _nextafter(double num, double next)
return retval;
}
/*********************************************************************
* _ecvt (MSVCRT.@)
*/
char *_ecvt( double number, int ndigits, int *decpt, int *sign )
{
MSVCRT_thread_data *data = msvcrt_get_thread_data();
char *dec;
if (!data->efcvt_buffer)
data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
snprintf(data->efcvt_buffer, 80, "%.*e", ndigits /* FIXME wrong */, number);
*sign = (number < 0);
dec = strchr(data->efcvt_buffer, '.');
*decpt = (dec) ? dec - data->efcvt_buffer : -1;
return data->efcvt_buffer;
}
/***********************************************************************
* _fcvt (MSVCRT.@)
*/
char *_fcvt( double number, int ndigits, int *decpt, int *sign )
{
MSVCRT_thread_data *data = msvcrt_get_thread_data();
char *dec;
if (!data->efcvt_buffer)
data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
snprintf(data->efcvt_buffer, 80, "%.*e", ndigits, number);
*sign = (number < 0);
dec = strchr(data->efcvt_buffer, '.');
*decpt = (dec) ? dec - data->efcvt_buffer : -1;
return data->efcvt_buffer;
}
/***********************************************************************
* _gcvt (MSVCRT.@)
*
* FIXME: uses both E and F.
*/
char *_gcvt( double number, int ndigit, char *buff )
{
sprintf(buff, "%.*E", ndigit, number);
return buff;
}
#include <stdlib.h> /* div_t, ldiv_t */
/*********************************************************************
......
......@@ -39,6 +39,7 @@ typedef struct __MSVCRT_thread_data
int errno;
unsigned long doserrno;
char *mbstok_next; /* next ptr for mbstok() */
char *efcvt_buffer; /* buffer for ecvt/fcvt */
terminate_function terminate_handler;
unexpected_function unexpected_handler;
_se_translator_function se_translator;
......
......@@ -197,7 +197,7 @@
@ stub _dstbias
@ cdecl _dup (long)
@ cdecl _dup2 (long long)
@ cdecl _ecvt( double long ptr ptr) ecvt
@ cdecl _ecvt(double long ptr ptr)
@ cdecl _endthread ()
@ cdecl _endthreadex(long)
@ extern _environ MSVCRT__environ
......@@ -216,7 +216,7 @@
@ cdecl _exit(long) MSVCRT__exit
@ cdecl _expand(ptr long)
@ cdecl _fcloseall()
@ cdecl _fcvt( double long ptr ptr) fcvt
@ cdecl _fcvt(double long ptr ptr)
@ cdecl _fdopen(long str)
@ cdecl _fgetchar()
@ cdecl _fgetwchar()
......@@ -246,7 +246,7 @@
@ cdecl _ftol() ntdll._ftol
@ cdecl _fullpath(ptr str long)
@ cdecl _futime(long ptr)
@ cdecl _gcvt( double long str) gcvt
@ cdecl _gcvt(double long str)
@ cdecl _get_osfhandle(long)
@ stub _get_sbh_threshold #()
@ cdecl _getch()
......
......@@ -71,15 +71,9 @@
/* Define if you have dlopen */
#undef HAVE_DLOPEN
/* Define to 1 if you have the `ecvt' function. */
#undef HAVE_ECVT
/* Define to 1 if you have the <elf.h> header file. */
#undef HAVE_ELF_H
/* Define to 1 if you have the `fcvt' function. */
#undef HAVE_FCVT
/* Define to 1 if you have the `finite' function. */
#undef HAVE_FINITE
......@@ -125,9 +119,6 @@
/* Define to 1 if you have the `ftruncate64' function. */
#undef HAVE_FTRUNCATE64
/* Define to 1 if you have the `gcvt' function. */
#undef HAVE_GCVT
/* Define to 1 if you have the `getbkgd' function. */
#undef HAVE_GETBKGD
......
......@@ -189,65 +189,6 @@ void *wine_anon_mmap( void *start, size_t size, int prot, int flags )
}
#ifndef HAVE_ECVT
/***********************************************************************
* ecvt
*/
char *ecvt (double number, int ndigits, int *decpt, int *sign)
{
static char buf[40]; /* ought to be enough */
char *dec;
sprintf(buf, "%.*e", ndigits /* FIXME wrong */, number);
*sign = (number < 0);
dec = strchr(buf, '.');
*decpt = (dec) ? (int)dec - (int)buf : -1;
return buf;
}
#endif /* HAVE_ECVT */
#ifndef HAVE_FCVT
/***********************************************************************
* fcvt
*/
char *fcvt (double number, int ndigits, int *decpt, int *sign)
{
static char buf[40]; /* ought to be enough */
char *dec;
sprintf(buf, "%.*e", ndigits, number);
*sign = (number < 0);
dec = strchr(buf, '.');
*decpt = (dec) ? (int)dec - (int)buf : -1;
return buf;
}
#endif /* HAVE_FCVT */
#ifndef HAVE_GCVT
/***********************************************************************
* gcvt
*
* FIXME: uses both E and F.
*/
char *gcvt (double number, size_t ndigit, char *buff)
{
sprintf(buff, "%.*E", (int)ndigit, number);
return buff;
}
#endif /* HAVE_GCVT */
#ifndef wine_memcpy_unaligned
/***********************************************************************
* wine_memcpy_unaligned
*
* This is necessary to defeat optimizations of memcpy by gcc.
*/
void *wine_memcpy_unaligned( void *dst, const void *src, size_t size )
{
return memcpy( dst, src, size );
}
#endif
/***********************************************************************
* pthread functions
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment