enhanced va_copy detection

This commit is contained in:
hyung-hwan 2013-11-04 02:33:52 +00:00
parent be129e743b
commit 9588bf2910
16 changed files with 292 additions and 131 deletions

60
qse/configure vendored
View File

@ -18982,6 +18982,66 @@ _ACEOF
fi fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
int
main ()
{
va_list x, y;
va_copy(x,y);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_VA_COPY 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
int
main ()
{
va_list x, y;
__va_copy(x,y);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE___VA_COPY 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
# The cast to long int works around a bug in the HP C Compiler # The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.

View File

@ -335,6 +335,32 @@ AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], [], [],
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h>]) #include <netinet/in.h>])
AC_TRY_LINK(
[#include <stdarg.h>],
[
va_list x, y;
va_copy(x,y);
],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_VA_COPY], [1], [va_copy is available])
],
[AC_MSG_RESULT(no)]
)
AC_TRY_LINK(
[#include <stdarg.h>],
[
va_list x, y;
__va_copy(x,y);
],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE___VA_COPY], [1], [__va_copy is available])
],
[AC_MSG_RESULT(no)]
)
dnl check the size of primitive data types dnl check the size of primitive data types
AC_CHECK_SIZEOF(char,,[[]]) AC_CHECK_SIZEOF(char,,[[]])
AC_CHECK_SIZEOF(short,,[[]]) AC_CHECK_SIZEOF(short,,[[]])

View File

@ -35,6 +35,12 @@
* - consider something like ${1:3,5} => $1, $2, $3, and $5 concatenated * - consider something like ${1:3,5} => $1, $2, $3, and $5 concatenated
*/ */
#if defined(QSE_AWK_USE_FLTMAX_T)
typedef qse_flt_t qse_awk_fltmax_t;
#else
typedef qse_flt_t qse_awk_flt_t;
#endif
/** \struct qse_awk_t /** \struct qse_awk_t
* The #qse_awk_t type defines an AWK interpreter. It provides an interface * The #qse_awk_t type defines an AWK interpreter. It provides an interface
* to parse an AWK script and run it to manipulate input and output data. * to parse an AWK script and run it to manipulate input and output data.
@ -167,8 +173,8 @@ typedef struct qse_awk_val_int_t qse_awk_val_int_t;
struct qse_awk_val_flt_t struct qse_awk_val_flt_t
{ {
QSE_AWK_VAL_HDR; QSE_AWK_VAL_HDR;
qse_flt_t val; qse_awk_flt_t val;
void* nde; void* nde;
}; };
typedef struct qse_awk_val_flt_t qse_awk_val_flt_t; typedef struct qse_awk_val_flt_t qse_awk_val_flt_t;
@ -396,15 +402,15 @@ typedef struct qse_awk_fun_t qse_awk_fun_t;
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
typedef qse_flt_t (*qse_awk_math1_t) ( typedef qse_awk_flt_t (*qse_awk_math1_t) (
qse_awk_t* awk, qse_awk_t* awk,
qse_flt_t x qse_awk_flt_t x
); );
typedef qse_flt_t (*qse_awk_math2_t) ( typedef qse_awk_flt_t (*qse_awk_math2_t) (
qse_awk_t* awk, qse_awk_t* awk,
qse_flt_t x, qse_awk_flt_t x,
qse_flt_t y qse_awk_flt_t y
); );
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -853,7 +859,7 @@ struct qse_awk_mod_sym_int_t
struct qse_awk_mod_sym_flt_t struct qse_awk_mod_sym_flt_t
{ {
qse_flt_t val; qse_awk_flt_t val;
}; };
struct qse_awk_mod_sym_t struct qse_awk_mod_sym_t
@ -1845,7 +1851,7 @@ QSE_EXPORT qse_long_t qse_awk_strxtolong (
* The qse_awk_strxtoflt() function converts a string to a floating-point * The qse_awk_strxtoflt() function converts a string to a floating-point
* number. * number.
*/ */
QSE_EXPORT qse_flt_t qse_awk_strxtoflt ( QSE_EXPORT qse_awk_flt_t qse_awk_strxtoflt (
qse_awk_t* awk, qse_awk_t* awk,
const qse_char_t* str, const qse_char_t* str,
qse_size_t len, qse_size_t len,
@ -2274,7 +2280,7 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_makeintval (
*/ */
QSE_EXPORT qse_awk_val_t* qse_awk_rtx_makefltval ( QSE_EXPORT qse_awk_val_t* qse_awk_rtx_makefltval (
qse_awk_rtx_t* rtx, qse_awk_rtx_t* rtx,
qse_flt_t v qse_awk_flt_t v
); );
/** /**
@ -2646,7 +2652,7 @@ QSE_EXPORT qse_wchar_t* qse_awk_rtx_valtowcsdup (
* *
* \code * \code
* qse_long_t l; * qse_long_t l;
* qse_flt_t r; * qse_awk_flt_t r;
* int n; * int n;
* n = qse_awk_rtx_valtonum (v, &l, &r); * n = qse_awk_rtx_valtonum (v, &l, &r);
* if (n <= -1) error (); * if (n <= -1) error ();
@ -2661,7 +2667,7 @@ QSE_EXPORT int qse_awk_rtx_valtonum (
qse_awk_rtx_t* rtx, qse_awk_rtx_t* rtx,
const qse_awk_val_t* val, const qse_awk_val_t* val,
qse_long_t* l, qse_long_t* l,
qse_flt_t* r qse_awk_flt_t* r
); );
QSE_EXPORT int qse_awk_rtx_valtolong ( QSE_EXPORT int qse_awk_rtx_valtolong (
@ -2673,7 +2679,7 @@ QSE_EXPORT int qse_awk_rtx_valtolong (
QSE_EXPORT int qse_awk_rtx_valtoflt ( QSE_EXPORT int qse_awk_rtx_valtoflt (
qse_awk_rtx_t* rtx, qse_awk_rtx_t* rtx,
const qse_awk_val_t* val, const qse_awk_val_t* val,
qse_flt_t* r qse_awk_flt_t* r
); );
/** /**
@ -2696,7 +2702,7 @@ QSE_EXPORT int qse_awk_rtx_strtonum (
const qse_char_t* ptr, /**< points to a string to convert */ const qse_char_t* ptr, /**< points to a string to convert */
qse_size_t len, /**< number of characters in a string */ qse_size_t len, /**< number of characters in a string */
qse_long_t* l, /**< stores a converted integer */ qse_long_t* l, /**< stores a converted integer */
qse_flt_t* r /**< stores a converted floating-poing number */ qse_awk_flt_t* r /**< stores a converted floating-poing number */
); );
/** /**

View File

@ -607,6 +607,9 @@
/* Define to 1 if you have the <utime.h> header file. */ /* Define to 1 if you have the <utime.h> header file. */
#undef HAVE_UTIME_H #undef HAVE_UTIME_H
/* va_copy is available */
#undef HAVE_VA_COPY
/* Define to 1 if you have the `vfork' function. */ /* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK #undef HAVE_VFORK
@ -643,6 +646,9 @@
/* Define to 1 if you have the `_vsnwprintf' function. */ /* Define to 1 if you have the `_vsnwprintf' function. */
#undef HAVE__VSNWPRINTF #undef HAVE__VSNWPRINTF
/* __va_copy is available */
#undef HAVE___VA_COPY
/* Define if the OS needs help to load dependent libraries for dlopen(). */ /* Define if the OS needs help to load dependent libraries for dlopen(). */
#undef LTDL_DLOPEN_DEPLIBS #undef LTDL_DLOPEN_DEPLIBS

View File

@ -31,6 +31,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#if defined(HAVE_QUADMATH_H)
# include <quadmath.h>
#endif
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> # include <windows.h>
@ -484,7 +487,7 @@ int StdAwk::setioattr (
} }
else else
{ {
qse_flt_t nsec; qse_awk_flt_t nsec;
ioattr->tmout[tmout].sec = (qse_long_t)fv; ioattr->tmout[tmout].sec = (qse_long_t)fv;
nsec = fv - ioattr->tmout[tmout].sec; nsec = fv - ioattr->tmout[tmout].sec;
ioattr->tmout[tmout].nsec = QSE_SEC_TO_NSEC(nsec); ioattr->tmout[tmout].nsec = QSE_SEC_TO_NSEC(nsec);
@ -545,7 +548,7 @@ int StdAwk::getioattr (
if (ioattr->tmout[tmout].nsec == 0) if (ioattr->tmout[tmout].nsec == 0)
xx = args[2].setInt ((long_t)ioattr->tmout[tmout].sec); xx = args[2].setInt ((long_t)ioattr->tmout[tmout].sec);
else else
xx = args[2].setFlt ((qse_flt_t)ioattr->tmout[tmout].sec + QSE_NSEC_TO_SEC((qse_flt_t)ioattr->tmout[tmout].nsec)); xx = args[2].setFlt ((qse_awk_flt_t)ioattr->tmout[tmout].sec + QSE_NSEC_TO_SEC((qse_awk_flt_t)ioattr->tmout[tmout].nsec));
} }
#if defined(QSE_CHAR_IS_WCHAR) #if defined(QSE_CHAR_IS_WCHAR)
else if (qse_strcasecmp (ptr[1], QSE_T("codepage")) == 0) else if (qse_strcasecmp (ptr[1], QSE_T("codepage")) == 0)
@ -1165,7 +1168,9 @@ void StdAwk::freeMem (void* ptr)
StdAwk::flt_t StdAwk::pow (flt_t x, flt_t y) StdAwk::flt_t StdAwk::pow (flt_t x, flt_t y)
{ {
#if defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_POWQ)
return ::powq (x, y);
#elif defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::powl (x, y); return ::powl (x, y);
#elif defined(HAVE_POW) #elif defined(HAVE_POW)
return ::pow (x, y); return ::pow (x, y);
@ -1178,7 +1183,9 @@ StdAwk::flt_t StdAwk::pow (flt_t x, flt_t y)
StdAwk::flt_t StdAwk::mod (flt_t x, flt_t y) StdAwk::flt_t StdAwk::mod (flt_t x, flt_t y)
{ {
#if defined(HAVE_FMODL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_FMODQ)
return ::fmodq (x, y);
#elif defined(HAVE_FMODL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::fmodl (x, y); return ::fmodl (x, y);
#elif defined(HAVE_FMOD) #elif defined(HAVE_FMOD)
return ::fmod (x, y); return ::fmod (x, y);
@ -1191,7 +1198,9 @@ StdAwk::flt_t StdAwk::mod (flt_t x, flt_t y)
StdAwk::flt_t StdAwk::sin (flt_t x) StdAwk::flt_t StdAwk::sin (flt_t x)
{ {
#if defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SINQ)
return ::sinq (x);
#elif defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::sinl (x); return ::sinl (x);
#elif defined(HAVE_SIN) #elif defined(HAVE_SIN)
return ::sin (x); return ::sin (x);
@ -1204,7 +1213,9 @@ StdAwk::flt_t StdAwk::sin (flt_t x)
StdAwk::flt_t StdAwk::cos (flt_t x) StdAwk::flt_t StdAwk::cos (flt_t x)
{ {
#if defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_COSQ)
return ::cosq (x);
#elif defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::cosl (x); return ::cosl (x);
#elif defined(HAVE_COS) #elif defined(HAVE_COS)
return ::cos (x); return ::cos (x);
@ -1217,7 +1228,9 @@ StdAwk::flt_t StdAwk::cos (flt_t x)
StdAwk::flt_t StdAwk::tan (flt_t x) StdAwk::flt_t StdAwk::tan (flt_t x)
{ {
#if defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_TANQ)
return ::tanq (x);
#elif defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::tanl (x); return ::tanl (x);
#elif defined(HAVE_TAN) #elif defined(HAVE_TAN)
return ::tan (x); return ::tan (x);
@ -1230,7 +1243,9 @@ StdAwk::flt_t StdAwk::tan (flt_t x)
StdAwk::flt_t StdAwk::atan (flt_t x) StdAwk::flt_t StdAwk::atan (flt_t x)
{ {
#if defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATANQ)
return ::atanq (x);
#elif defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::atanl (x); return ::atanl (x);
#elif defined(HAVE_ATAN) #elif defined(HAVE_ATAN)
return ::atan (x); return ::atan (x);
@ -1243,7 +1258,9 @@ StdAwk::flt_t StdAwk::atan (flt_t x)
StdAwk::flt_t StdAwk::atan2 (flt_t x, flt_t y) StdAwk::flt_t StdAwk::atan2 (flt_t x, flt_t y)
{ {
#if defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATAN2Q)
return ::atan2q (x, y);
#elif defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::atan2l (x, y); return ::atan2l (x, y);
#elif defined(HAVE_ATAN2) #elif defined(HAVE_ATAN2)
return ::atan2 (x, y); return ::atan2 (x, y);
@ -1257,7 +1274,9 @@ StdAwk::flt_t StdAwk::atan2 (flt_t x, flt_t y)
StdAwk::flt_t StdAwk::log (flt_t x) StdAwk::flt_t StdAwk::log (flt_t x)
{ {
/* natural logarithm */ /* natural logarithm */
#if defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOGQ)
return ::logq (x);
#elif defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::logl (x); return ::logl (x);
#elif defined(HAVE_LOG) #elif defined(HAVE_LOG)
return ::log (x); return ::log (x);
@ -1271,7 +1290,9 @@ StdAwk::flt_t StdAwk::log (flt_t x)
StdAwk::flt_t StdAwk::log10 (flt_t x) StdAwk::flt_t StdAwk::log10 (flt_t x)
{ {
/* common logarithm */ /* common logarithm */
#if defined(HAVE_LOG10L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOG10Q)
return ::log10q (x);
#elif defined(HAVE_LOG10L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::log10l (x); return ::log10l (x);
#elif defined(HAVE_LOG10) #elif defined(HAVE_LOG10)
return ::log10 (x); return ::log10 (x);
@ -1284,7 +1305,9 @@ StdAwk::flt_t StdAwk::log10 (flt_t x)
StdAwk::flt_t StdAwk::exp (flt_t x) StdAwk::flt_t StdAwk::exp (flt_t x)
{ {
#if defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_EXPQ)
return ::expq (x);
#elif defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::expl (x); return ::expl (x);
#elif defined(HAVE_EXP) #elif defined(HAVE_EXP)
return ::exp (x); return ::exp (x);
@ -1297,7 +1320,9 @@ StdAwk::flt_t StdAwk::exp (flt_t x)
StdAwk::flt_t StdAwk::sqrt (flt_t x) StdAwk::flt_t StdAwk::sqrt (flt_t x)
{ {
#if defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SQRTQ)
return ::sqrtq (x);
#elif defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::sqrtl (x); return ::sqrtl (x);
#elif defined(HAVE_SQRT) #elif defined(HAVE_SQRT)
return ::sqrt (x); return ::sqrt (x);

View File

@ -1339,7 +1339,7 @@ static int fnc_math_1 (
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0; qse_awk_val_t* a0;
qse_flt_t rv; qse_awk_flt_t rv;
qse_awk_val_t* r; qse_awk_val_t* r;
int n; int n;
@ -1363,7 +1363,7 @@ static int fnc_math_2 (
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1; qse_awk_val_t* a0, * a1;
qse_flt_t rv0, rv1; qse_awk_flt_t rv0, rv1;
qse_awk_val_t* r; qse_awk_val_t* r;
int n; int n;

View File

@ -184,19 +184,19 @@ qse_long_t qse_awk_strxtolong (
#define MAX_EXPONENT 511 #define MAX_EXPONENT 511
qse_flt_t qse_awk_strtoflt (qse_awk_t* awk, const qse_char_t* str) qse_awk_flt_t qse_awk_strtoflt (qse_awk_t* awk, const qse_char_t* str)
{ {
/* /*
* Table giving binary powers of 10. Entry is 10^2^i. * Table giving binary powers of 10. Entry is 10^2^i.
* Used to convert decimal exponents into floating-point numbers. * Used to convert decimal exponents into floating-point numbers.
*/ */
static qse_flt_t powers_of_10[] = static qse_awk_flt_t powers_of_10[] =
{ {
10., 100., 1.0e4, 1.0e8, 1.0e16, 10., 100., 1.0e4, 1.0e8, 1.0e16,
1.0e32, 1.0e64, 1.0e128, 1.0e256 1.0e32, 1.0e64, 1.0e128, 1.0e256
}; };
qse_flt_t fraction, dbl_exp, * d; qse_awk_flt_t fraction, dbl_exp, * d;
const qse_char_t* p; const qse_char_t* p;
qse_cint_t c; qse_cint_t c;
int exp = 0; /* Esseonent read from "EX" field */ int exp = 0; /* Esseonent read from "EX" field */
@ -374,7 +374,7 @@ done:
return (negative)? -fraction: fraction; return (negative)? -fraction: fraction;
} }
qse_flt_t qse_awk_strxtoflt ( qse_awk_flt_t qse_awk_strxtoflt (
qse_awk_t* awk, const qse_char_t* str, qse_size_t len, qse_awk_t* awk, const qse_char_t* str, qse_size_t len,
const qse_char_t** endptr) const qse_char_t** endptr)
{ {
@ -382,13 +382,13 @@ qse_flt_t qse_awk_strxtoflt (
* Table giving binary powers of 10. Entry is 10^2^i. * Table giving binary powers of 10. Entry is 10^2^i.
* Used to convert decimal exponents into floating-point numbers. * Used to convert decimal exponents into floating-point numbers.
*/ */
static qse_flt_t powers_of_10[] = static qse_awk_flt_t powers_of_10[] =
{ {
10., 100., 1.0e4, 1.0e8, 1.0e16, 10., 100., 1.0e4, 1.0e8, 1.0e16,
1.0e32, 1.0e64, 1.0e128, 1.0e256 1.0e32, 1.0e64, 1.0e128, 1.0e256
}; };
qse_flt_t fraction, dbl_exp, * d; qse_awk_flt_t fraction, dbl_exp, * d;
const qse_char_t* p, * end; const qse_char_t* p, * end;
qse_cint_t c; qse_cint_t c;
int exp = 0; /* Esseonent read from "EX" field */ int exp = 0; /* Esseonent read from "EX" field */
@ -458,7 +458,7 @@ qse_flt_t qse_awk_strxtoflt (
mant_size--; /* One of the digits was the point */ mant_size--; /* One of the digits was the point */
} }
if (mant_size > 18) /* TODO: is 18 correct for qse_flt_t??? */ if (mant_size > 18) /* TODO: is 18 correct for qse_awk_flt_t??? */
{ {
frac_exp = dec_pt - 18; frac_exp = dec_pt - 18;
mant_size = 18; mant_size = 18;

View File

@ -99,7 +99,7 @@ static int fnc_reduce (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{ {
qse_awk_val_t* retv; qse_awk_val_t* retv;
qse_long_t opidx, lv; qse_long_t opidx, lv;
qse_flt_t rv; qse_awk_flt_t rv;
int n; int n;
static MPI_Op optab[] = static MPI_Op optab[] =
@ -125,7 +125,7 @@ static int fnc_reduce (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
} }
else else
{ {
qse_flt_t fout; qse_awk_flt_t fout;
if (MPI_Allreduce (&rv, &fout, 1, MPI_LONG_DOUBLE, optab[opidx], MPI_COMM_WORLD) != MPI_SUCCESS) goto softfail; if (MPI_Allreduce (&rv, &fout, 1, MPI_LONG_DOUBLE, optab[opidx], MPI_COMM_WORLD) != MPI_SUCCESS) goto softfail;
retv = qse_awk_rtx_makefltval (rtx, fout); retv = qse_awk_rtx_makefltval (rtx, fout);
} }

View File

@ -375,7 +375,7 @@ static int fnc_getegid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi) static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
{ {
qse_long_t lv; qse_long_t lv;
qse_flt_t fv; qse_awk_flt_t fv;
qse_awk_val_t* retv; qse_awk_val_t* retv;
int rx; int rx;

View File

@ -3254,7 +3254,7 @@ static qse_awk_nde_t* parse_expr_withdc (
union folded_t union folded_t
{ {
qse_long_t l; qse_long_t l;
qse_flt_t r; qse_awk_flt_t r;
}; };
typedef union folded_t folded_t; typedef union folded_t folded_t;
@ -3288,8 +3288,8 @@ static int fold_constants_for_binop (
case QSE_AWK_BINOP_DIV: case QSE_AWK_BINOP_DIV:
if (INT_BINOP_INT(left,%,right)) if (INT_BINOP_INT(left,%,right))
{ {
folded->r = (qse_flt_t)((qse_awk_nde_int_t*)left)->val / folded->r = (qse_awk_flt_t)((qse_awk_nde_int_t*)left)->val /
(qse_flt_t)((qse_awk_nde_int_t*)right)->val; (qse_awk_flt_t)((qse_awk_nde_int_t*)right)->val;
fold = QSE_AWK_NDE_FLT; fold = QSE_AWK_NDE_FLT;
break; break;
} }
@ -3371,7 +3371,7 @@ static int fold_constants_for_binop (
case QSE_AWK_BINOP_IDIV: case QSE_AWK_BINOP_IDIV:
folded->l = (qse_long_t) folded->l = (qse_long_t)
((qse_flt_t)((qse_awk_nde_int_t*)left)->val / ((qse_awk_flt_t)((qse_awk_nde_int_t*)left)->val /
((qse_awk_nde_flt_t*)right)->val); ((qse_awk_nde_flt_t*)right)->val);
fold = QSE_AWK_NDE_INT; fold = QSE_AWK_NDE_INT;
break; break;
@ -3379,7 +3379,7 @@ static int fold_constants_for_binop (
case QSE_AWK_BINOP_MOD: case QSE_AWK_BINOP_MOD:
folded->r = awk->prm.math.mod ( folded->r = awk->prm.math.mod (
awk, awk,
(qse_flt_t)((qse_awk_nde_int_t*)left)->val, (qse_awk_flt_t)((qse_awk_nde_int_t*)left)->val,
((qse_awk_nde_flt_t*)right)->val ((qse_awk_nde_flt_t*)right)->val
); );
break; break;
@ -3414,7 +3414,7 @@ static int fold_constants_for_binop (
case QSE_AWK_BINOP_IDIV: case QSE_AWK_BINOP_IDIV:
folded->l = (qse_long_t) folded->l = (qse_long_t)
(((qse_awk_nde_int_t*)left)->val / (((qse_awk_nde_int_t*)left)->val /
(qse_flt_t)((qse_awk_nde_int_t*)right)->val); (qse_awk_flt_t)((qse_awk_nde_int_t*)right)->val);
fold = QSE_AWK_NDE_INT; fold = QSE_AWK_NDE_INT;
break; break;
@ -3422,7 +3422,7 @@ static int fold_constants_for_binop (
folded->r = awk->prm.math.mod ( folded->r = awk->prm.math.mod (
awk, awk,
((qse_awk_nde_flt_t*)left)->val, ((qse_awk_nde_flt_t*)left)->val,
(qse_flt_t)((qse_awk_nde_int_t*)right)->val (qse_awk_flt_t)((qse_awk_nde_int_t*)right)->val
); );
break; break;
@ -3473,7 +3473,7 @@ static qse_awk_nde_t* new_int_node (
} }
static qse_awk_nde_t* new_flt_node ( static qse_awk_nde_t* new_flt_node (
qse_awk_t* awk, qse_flt_t rv, const qse_awk_loc_t* loc) qse_awk_t* awk, qse_awk_flt_t rv, const qse_awk_loc_t* loc)
{ {
qse_awk_nde_flt_t* tmp; qse_awk_nde_flt_t* tmp;
@ -3502,7 +3502,7 @@ static QSE_INLINE void update_int_node (
} }
static QSE_INLINE void update_flt_node ( static QSE_INLINE void update_flt_node (
qse_awk_t* awk, qse_awk_nde_flt_t* node, qse_flt_t rv) qse_awk_t* awk, qse_awk_nde_flt_t* node, qse_awk_flt_t rv)
{ {
node->val = rv; node->val = rv;
if (node->str) if (node->str)

View File

@ -4207,7 +4207,7 @@ static int __cmp_int_str (
if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/) if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/)
{ {
qse_long_t ll; qse_long_t ll;
qse_flt_t rr; qse_awk_flt_t rr;
n = qse_awk_rtx_strtonum ( n = qse_awk_rtx_strtonum (
rtx, 1, rtx, 1,
@ -4293,7 +4293,7 @@ static int __cmp_flt_str (
if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/) if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/)
{ {
const qse_char_t* end; const qse_char_t* end;
qse_flt_t rr; qse_awk_flt_t rr;
rr = qse_awk_strxtoflt ( rr = qse_awk_strxtoflt (
rtx->awk, rtx->awk,
@ -4388,7 +4388,7 @@ static int __cmp_str_str (
} }
else else
{ {
qse_flt_t rr; qse_awk_flt_t rr;
QSE_ASSERT (rs->nstr == 2); QSE_ASSERT (rs->nstr == 2);
@ -4401,7 +4401,7 @@ static int __cmp_str_str (
} }
else else
{ {
qse_flt_t ll; qse_awk_flt_t ll;
QSE_ASSERT (ls->nstr == 2); QSE_ASSERT (ls->nstr == 2);
@ -4420,7 +4420,7 @@ static int __cmp_str_str (
} }
else else
{ {
qse_flt_t rr; qse_awk_flt_t rr;
QSE_ASSERT (rs->nstr == 2); QSE_ASSERT (rs->nstr == 2);
@ -4605,7 +4605,7 @@ static qse_awk_val_t* eval_binop_plus (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2; qse_awk_flt_t r1, r2;
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1); n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
n2 = qse_awk_rtx_valtonum (rtx, right, &l2, &r2); n2 = qse_awk_rtx_valtonum (rtx, right, &l2, &r2);
@ -4626,9 +4626,9 @@ static qse_awk_val_t* eval_binop_plus (
QSE_ASSERT (n3 >= 0 && n3 <= 3); QSE_ASSERT (n3 >= 0 && n3 <= 3);
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1+(qse_long_t)l2): return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1+(qse_long_t)l2):
(n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_flt_t)r1+(qse_flt_t)l2): (n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1+(qse_awk_flt_t)l2):
(n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_flt_t)l1+(qse_flt_t)r2): (n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)l1+(qse_awk_flt_t)r2):
qse_awk_rtx_makefltval(rtx,(qse_flt_t)r1+(qse_flt_t)r2); qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1+(qse_awk_flt_t)r2);
} }
static qse_awk_val_t* eval_binop_minus ( static qse_awk_val_t* eval_binop_minus (
@ -4636,7 +4636,7 @@ static qse_awk_val_t* eval_binop_minus (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2; qse_awk_flt_t r1, r2;
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1); n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
n2 = qse_awk_rtx_valtonum (rtx, right, &l2, &r2); n2 = qse_awk_rtx_valtonum (rtx, right, &l2, &r2);
@ -4650,9 +4650,9 @@ static qse_awk_val_t* eval_binop_minus (
n3 = n1 + (n2 << 1); n3 = n1 + (n2 << 1);
QSE_ASSERT (n3 >= 0 && n3 <= 3); QSE_ASSERT (n3 >= 0 && n3 <= 3);
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1-(qse_long_t)l2): return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1-(qse_long_t)l2):
(n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_flt_t)r1-(qse_flt_t)l2): (n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1-(qse_awk_flt_t)l2):
(n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_flt_t)l1-(qse_flt_t)r2): (n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)l1-(qse_awk_flt_t)r2):
qse_awk_rtx_makefltval(rtx,(qse_flt_t)r1-(qse_flt_t)r2); qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1-(qse_awk_flt_t)r2);
} }
static qse_awk_val_t* eval_binop_mul ( static qse_awk_val_t* eval_binop_mul (
@ -4660,7 +4660,7 @@ static qse_awk_val_t* eval_binop_mul (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2; qse_awk_flt_t r1, r2;
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1); n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
n2 = qse_awk_rtx_valtonum (rtx, right, &l2, &r2); n2 = qse_awk_rtx_valtonum (rtx, right, &l2, &r2);
@ -4674,9 +4674,9 @@ static qse_awk_val_t* eval_binop_mul (
n3 = n1 + (n2 << 1); n3 = n1 + (n2 << 1);
QSE_ASSERT (n3 >= 0 && n3 <= 3); QSE_ASSERT (n3 >= 0 && n3 <= 3);
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1*(qse_long_t)l2): return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1*(qse_long_t)l2):
(n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_flt_t)r1*(qse_flt_t)l2): (n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1*(qse_awk_flt_t)l2):
(n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_flt_t)l1*(qse_flt_t)r2): (n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)l1*(qse_awk_flt_t)r2):
qse_awk_rtx_makefltval(rtx,(qse_flt_t)r1*(qse_flt_t)r2); qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1*(qse_awk_flt_t)r2);
} }
static qse_awk_val_t* eval_binop_div ( static qse_awk_val_t* eval_binop_div (
@ -4684,7 +4684,7 @@ static qse_awk_val_t* eval_binop_div (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2; qse_awk_flt_t r1, r2;
qse_awk_val_t* res; qse_awk_val_t* res;
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1); n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
@ -4714,23 +4714,23 @@ static qse_awk_val_t* eval_binop_div (
else else
{ {
res = qse_awk_rtx_makefltval ( res = qse_awk_rtx_makefltval (
rtx, (qse_flt_t)l1 / (qse_flt_t)l2); rtx, (qse_awk_flt_t)l1 / (qse_awk_flt_t)l2);
} }
break; break;
case 1: case 1:
res = qse_awk_rtx_makefltval ( res = qse_awk_rtx_makefltval (
rtx, (qse_flt_t)r1 / (qse_flt_t)l2); rtx, (qse_awk_flt_t)r1 / (qse_awk_flt_t)l2);
break; break;
case 2: case 2:
res = qse_awk_rtx_makefltval ( res = qse_awk_rtx_makefltval (
rtx, (qse_flt_t)l1 / (qse_flt_t)r2); rtx, (qse_awk_flt_t)l1 / (qse_awk_flt_t)r2);
break; break;
case 3: case 3:
res = qse_awk_rtx_makefltval ( res = qse_awk_rtx_makefltval (
rtx, (qse_flt_t)r1 / (qse_flt_t)r2); rtx, (qse_awk_flt_t)r1 / (qse_awk_flt_t)r2);
break; break;
} }
@ -4742,7 +4742,7 @@ static qse_awk_val_t* eval_binop_idiv (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2, quo; qse_awk_flt_t r1, r2, quo;
qse_awk_val_t* res; qse_awk_val_t* res;
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1); n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
@ -4768,17 +4768,17 @@ static qse_awk_val_t* eval_binop_idiv (
break; break;
case 1: case 1:
quo = (qse_flt_t)r1 / (qse_flt_t)l2; quo = (qse_awk_flt_t)r1 / (qse_awk_flt_t)l2;
res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo); res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo);
break; break;
case 2: case 2:
quo = (qse_flt_t)l1 / (qse_flt_t)r2; quo = (qse_awk_flt_t)l1 / (qse_awk_flt_t)r2;
res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo); res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo);
break; break;
case 3: case 3:
quo = (qse_flt_t)r1 / (qse_flt_t)r2; quo = (qse_awk_flt_t)r1 / (qse_awk_flt_t)r2;
res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo); res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo);
break; break;
} }
@ -4791,7 +4791,7 @@ static qse_awk_val_t* eval_binop_mod (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2; qse_awk_flt_t r1, r2;
qse_awk_val_t* res; qse_awk_val_t* res;
QSE_ASSERTX (rtx->awk->prm.math.mod != QSE_NULL, QSE_ASSERTX (rtx->awk->prm.math.mod != QSE_NULL,
@ -4822,21 +4822,21 @@ static qse_awk_val_t* eval_binop_mod (
case 1: case 1:
res = qse_awk_rtx_makefltval (rtx, res = qse_awk_rtx_makefltval (rtx,
rtx->awk->prm.math.mod ( rtx->awk->prm.math.mod (
rtx->awk, (qse_flt_t)r1, (qse_flt_t)l2) rtx->awk, (qse_awk_flt_t)r1, (qse_awk_flt_t)l2)
); );
break; break;
case 2: case 2:
res = qse_awk_rtx_makefltval (rtx, res = qse_awk_rtx_makefltval (rtx,
rtx->awk->prm.math.mod ( rtx->awk->prm.math.mod (
rtx->awk, (qse_flt_t)l1, (qse_flt_t)r2) rtx->awk, (qse_awk_flt_t)l1, (qse_awk_flt_t)r2)
); );
break; break;
case 3: case 3:
res = qse_awk_rtx_makefltval (rtx, res = qse_awk_rtx_makefltval (rtx,
rtx->awk->prm.math.mod ( rtx->awk->prm.math.mod (
rtx->awk, (qse_flt_t)r1, (qse_flt_t)r2) rtx->awk, (qse_awk_flt_t)r1, (qse_awk_flt_t)r2)
); );
break; break;
} }
@ -4849,7 +4849,7 @@ static qse_awk_val_t* eval_binop_exp (
{ {
int n1, n2, n3; int n1, n2, n3;
qse_long_t l1, l2; qse_long_t l1, l2;
qse_flt_t r1, r2; qse_awk_flt_t r1, r2;
qse_awk_val_t* res; qse_awk_val_t* res;
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1); n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
@ -4879,7 +4879,7 @@ static qse_awk_val_t* eval_binop_exp (
} }
else else
{ {
qse_flt_t v = 1.0; qse_awk_flt_t v = 1.0;
l2 *= -1; l2 *= -1;
while (l2-- > 0) v /= l1; while (l2-- > 0) v /= l1;
res = qse_awk_rtx_makefltval (rtx, v); res = qse_awk_rtx_makefltval (rtx, v);
@ -4890,7 +4890,7 @@ static qse_awk_val_t* eval_binop_exp (
/* left - real, right - int */ /* left - real, right - int */
if (l2 >= 0) if (l2 >= 0)
{ {
qse_flt_t v = 1.0; qse_awk_flt_t v = 1.0;
while (l2-- > 0) v *= r1; while (l2-- > 0) v *= r1;
res = qse_awk_rtx_makefltval (rtx, v); res = qse_awk_rtx_makefltval (rtx, v);
} }
@ -4901,7 +4901,7 @@ static qse_awk_val_t* eval_binop_exp (
} }
else else
{ {
qse_flt_t v = 1.0; qse_awk_flt_t v = 1.0;
l2 *= -1; l2 *= -1;
while (l2-- > 0) v /= r1; while (l2-- > 0) v /= r1;
res = qse_awk_rtx_makefltval (rtx, v); res = qse_awk_rtx_makefltval (rtx, v);
@ -4913,7 +4913,7 @@ static qse_awk_val_t* eval_binop_exp (
res = qse_awk_rtx_makefltval ( res = qse_awk_rtx_makefltval (
rtx, rtx,
rtx->awk->prm.math.pow ( rtx->awk->prm.math.pow (
rtx->awk, (qse_flt_t)l1, (qse_flt_t)r2 rtx->awk, (qse_awk_flt_t)l1, (qse_awk_flt_t)r2
) )
); );
break; break;
@ -4923,7 +4923,7 @@ static qse_awk_val_t* eval_binop_exp (
res = qse_awk_rtx_makefltval ( res = qse_awk_rtx_makefltval (
rtx, rtx,
rtx->awk->prm.math.pow ( rtx->awk->prm.math.pow (
rtx->awk, (qse_flt_t)r1,(qse_flt_t)r2 rtx->awk, (qse_awk_flt_t)r1,(qse_awk_flt_t)r2
) )
); );
break; break;
@ -5079,7 +5079,7 @@ static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_nde_exp_t* exp = (qse_awk_nde_exp_t*)nde; qse_awk_nde_exp_t* exp = (qse_awk_nde_exp_t*)nde;
int n; int n;
qse_long_t l; qse_long_t l;
qse_flt_t r; qse_awk_flt_t r;
QSE_ASSERT ( QSE_ASSERT (
exp->type == QSE_AWK_NDE_EXP_UNR); exp->type == QSE_AWK_NDE_EXP_UNR);
@ -5191,7 +5191,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
} }
else if (left->type == QSE_AWK_VAL_FLT) else if (left->type == QSE_AWK_VAL_FLT)
{ {
qse_flt_t r = ((qse_awk_val_flt_t*)left)->val; qse_awk_flt_t r = ((qse_awk_val_flt_t*)left)->val;
res = qse_awk_rtx_makefltval (run, r + 1.0); res = qse_awk_rtx_makefltval (run, r + 1.0);
if (res == QSE_NULL) if (res == QSE_NULL)
{ {
@ -5203,7 +5203,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
else else
{ {
qse_long_t v1; qse_long_t v1;
qse_flt_t v2; qse_awk_flt_t v2;
int n; int n;
n = qse_awk_rtx_valtonum (run, left, &v1, &v2); n = qse_awk_rtx_valtonum (run, left, &v1, &v2);
@ -5247,7 +5247,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
} }
else if (left->type == QSE_AWK_VAL_FLT) else if (left->type == QSE_AWK_VAL_FLT)
{ {
qse_flt_t r = ((qse_awk_val_flt_t*)left)->val; qse_awk_flt_t r = ((qse_awk_val_flt_t*)left)->val;
res = qse_awk_rtx_makefltval (run, r - 1.0); res = qse_awk_rtx_makefltval (run, r - 1.0);
if (res == QSE_NULL) if (res == QSE_NULL)
{ {
@ -5259,7 +5259,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
else else
{ {
qse_long_t v1; qse_long_t v1;
qse_flt_t v2; qse_awk_flt_t v2;
int n; int n;
n = qse_awk_rtx_valtonum (run, left, &v1, &v2); n = qse_awk_rtx_valtonum (run, left, &v1, &v2);
@ -5355,7 +5355,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
} }
else if (left->type == QSE_AWK_VAL_FLT) else if (left->type == QSE_AWK_VAL_FLT)
{ {
qse_flt_t r = ((qse_awk_val_flt_t*)left)->val; qse_awk_flt_t r = ((qse_awk_val_flt_t*)left)->val;
res = qse_awk_rtx_makefltval (run, r); res = qse_awk_rtx_makefltval (run, r);
if (res == QSE_NULL) if (res == QSE_NULL)
{ {
@ -5376,7 +5376,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
else else
{ {
qse_long_t v1; qse_long_t v1;
qse_flt_t v2; qse_awk_flt_t v2;
int n; int n;
n = qse_awk_rtx_valtonum (run, left, &v1, &v2); n = qse_awk_rtx_valtonum (run, left, &v1, &v2);
@ -5452,7 +5452,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
} }
else if (left->type == QSE_AWK_VAL_FLT) else if (left->type == QSE_AWK_VAL_FLT)
{ {
qse_flt_t r = ((qse_awk_val_flt_t*)left)->val; qse_awk_flt_t r = ((qse_awk_val_flt_t*)left)->val;
res = qse_awk_rtx_makefltval (run, r); res = qse_awk_rtx_makefltval (run, r);
if (res == QSE_NULL) if (res == QSE_NULL)
{ {
@ -5473,7 +5473,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
else else
{ {
qse_long_t v1; qse_long_t v1;
qse_flt_t v2; qse_awk_flt_t v2;
int n; int n;
n = qse_awk_rtx_valtonum (run, left, &v1, &v2); n = qse_awk_rtx_valtonum (run, left, &v1, &v2);
@ -7287,10 +7287,14 @@ wp_mod_main:
fmt[i] == QSE_T('f')) fmt[i] == QSE_T('f'))
{ {
qse_awk_val_t* v; qse_awk_val_t* v;
qse_flt_t r; qse_awk_flt_t r;
int n; int n;
#if defined(QSE_AWK_USE_FLTMAX_T)
FMT_CHAR (QSE_T('j'));
#else
FMT_CHAR (QSE_T('z')); FMT_CHAR (QSE_T('z'));
#endif
FMT_CHAR (fmt[i]); FMT_CHAR (fmt[i]);
if (args == QSE_NULL) if (args == QSE_NULL)

View File

@ -158,9 +158,11 @@ typedef struct ioattr_t
static ioattr_t* get_ioattr (qse_htb_t* tab, const qse_char_t* ptr, qse_size_t len); static ioattr_t* get_ioattr (qse_htb_t* tab, const qse_char_t* ptr, qse_size_t len);
static qse_flt_t custom_awk_pow (qse_awk_t* awk, qse_flt_t x, qse_flt_t y) static qse_awk_flt_t custom_awk_pow (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
{ {
#if defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_POWQ)
return powq (x, y);
#elif defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return powl (x, y); return powl (x, y);
#elif defined(HAVE_POW) #elif defined(HAVE_POW)
return pow (x, y); return pow (x, y);
@ -171,9 +173,11 @@ static qse_flt_t custom_awk_pow (qse_awk_t* awk, qse_flt_t x, qse_flt_t y)
#endif #endif
} }
static qse_flt_t custom_awk_mod (qse_awk_t* awk, qse_flt_t x, qse_flt_t y) static qse_awk_flt_t custom_awk_mod (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
{ {
#if defined(HAVE_FMODL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_FMODQ)
return fmodq (x, y);
#elif defined(HAVE_FMODL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return fmodl (x, y); return fmodl (x, y);
#elif defined(HAVE_FMOD) #elif defined(HAVE_FMOD)
return fmod (x, y); return fmod (x, y);
@ -184,9 +188,11 @@ static qse_flt_t custom_awk_mod (qse_awk_t* awk, qse_flt_t x, qse_flt_t y)
#endif #endif
} }
static qse_flt_t custom_awk_sin (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_sin (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SINQ)
return sinq (x);
#elif defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return sinl (x); return sinl (x);
#elif defined(HAVE_SIN) #elif defined(HAVE_SIN)
return sin (x); return sin (x);
@ -197,9 +203,11 @@ static qse_flt_t custom_awk_sin (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_cos (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_cos (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_COSQ)
return cosq (x);
#elif defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return cosl (x); return cosl (x);
#elif defined(HAVE_COS) #elif defined(HAVE_COS)
return cos (x); return cos (x);
@ -210,9 +218,11 @@ static qse_flt_t custom_awk_cos (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_tan (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_tan (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_TANQ)
return tanq (x);
#elif defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return tanl (x); return tanl (x);
#elif defined(HAVE_TAN) #elif defined(HAVE_TAN)
return tan (x); return tan (x);
@ -223,9 +233,11 @@ static qse_flt_t custom_awk_tan (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_atan (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_atan (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATANQ)
return atanq (x);
#elif defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return atanl (x); return atanl (x);
#elif defined(HAVE_ATAN) #elif defined(HAVE_ATAN)
return atan (x); return atan (x);
@ -236,9 +248,11 @@ static qse_flt_t custom_awk_atan (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_atan2 (qse_awk_t* awk, qse_flt_t x, qse_flt_t y) static qse_awk_flt_t custom_awk_atan2 (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
{ {
#if defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATAN2Q)
return atan2q (x, y);
#elif defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return atan2l (x, y); return atan2l (x, y);
#elif defined(HAVE_ATAN2) #elif defined(HAVE_ATAN2)
return atan2 (x, y); return atan2 (x, y);
@ -249,9 +263,11 @@ static qse_flt_t custom_awk_atan2 (qse_awk_t* awk, qse_flt_t x, qse_flt_t y)
#endif #endif
} }
static qse_flt_t custom_awk_log (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_log (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOGQ)
return logq (x);
#elif defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return logl (x); return logl (x);
#elif defined(HAVE_LOG) #elif defined(HAVE_LOG)
return log (x); return log (x);
@ -262,9 +278,11 @@ static qse_flt_t custom_awk_log (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_log10 (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_log10 (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_LOG10L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOG10Q)
return log10q (x);
#elif defined(HAVE_LOG10L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return log10l (x); return log10l (x);
#elif defined(HAVE_LOG10) #elif defined(HAVE_LOG10)
return log10 (x); return log10 (x);
@ -275,9 +293,11 @@ static qse_flt_t custom_awk_log10 (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_exp (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_exp (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_EXPQ)
return expq (x);
#elif defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return expl (x); return expl (x);
#elif defined(HAVE_EXP) #elif defined(HAVE_EXP)
return exp (x); return exp (x);
@ -288,9 +308,11 @@ static qse_flt_t custom_awk_exp (qse_awk_t* awk, qse_flt_t x)
#endif #endif
} }
static qse_flt_t custom_awk_sqrt (qse_awk_t* awk, qse_flt_t x) static qse_awk_flt_t custom_awk_sqrt (qse_awk_t* awk, qse_awk_flt_t x)
{ {
#if defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) #if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SQRTQ)
return sqrtq (x);
#elif defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return sqrtl (x); return sqrtl (x);
#elif defined(HAVE_SQRT) #elif defined(HAVE_SQRT)
return sqrt (x); return sqrt (x);
@ -2134,7 +2156,7 @@ static int fnc_rand (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
rxtn->prand = qse_randxsulong (rxtn->prand); rxtn->prand = qse_randxsulong (rxtn->prand);
randv = rxtn->prand % RANDV_MAX; randv = rxtn->prand % RANDV_MAX;
r = qse_awk_rtx_makefltval (rtx, (qse_flt_t)randv / RANDV_MAX); r = qse_awk_rtx_makefltval (rtx, (qse_awk_flt_t)randv / RANDV_MAX);
if (r == QSE_NULL) return -1; if (r == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, r); qse_awk_rtx_setretval (rtx, r);
@ -2337,13 +2359,13 @@ static int fnc_setioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
ioattr_t* ioattr; ioattr_t* ioattr;
qse_long_t l; qse_long_t l;
qse_flt_t r; qse_awk_flt_t r;
int x; int x;
/* no error is returned by qse_awk_rtx_strnum() if the second /* no error is returned by qse_awk_rtx_strnum() if the second
* parameter is 0. so i don't check for an error */ * parameter is 0. so i don't check for an error */
x = qse_awk_rtx_strtonum (rtx, 0, ptr[2], len[2], &l, &r); x = qse_awk_rtx_strtonum (rtx, 0, ptr[2], len[2], &l, &r);
if (x == 0) r = (qse_flt_t)l; if (x == 0) r = (qse_awk_flt_t)l;
ioattr = find_or_make_ioattr (rtx, &rxtn->cmgrtab, ptr[0], len[0]); ioattr = find_or_make_ioattr (rtx, &rxtn->cmgrtab, ptr[0], len[0]);
if (ioattr == QSE_NULL) if (ioattr == QSE_NULL)
@ -2359,7 +2381,7 @@ static int fnc_setioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
} }
else if (x >= 1) else if (x >= 1)
{ {
qse_flt_t nsec; qse_awk_flt_t nsec;
ioattr->tmout[tmout].sec = (qse_long_t)r; ioattr->tmout[tmout].sec = (qse_long_t)r;
nsec = r - ioattr->tmout[tmout].sec; nsec = r - ioattr->tmout[tmout].sec;
ioattr->tmout[tmout].nsec = QSE_SEC_TO_NSEC(nsec); ioattr->tmout[tmout].nsec = QSE_SEC_TO_NSEC(nsec);
@ -2470,7 +2492,7 @@ static int fnc_getioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
if (ioattr->tmout[tmout].nsec == 0) if (ioattr->tmout[tmout].nsec == 0)
rv = qse_awk_rtx_makeintval (rtx, ioattr->tmout[tmout].sec); rv = qse_awk_rtx_makeintval (rtx, ioattr->tmout[tmout].sec);
else else
rv = qse_awk_rtx_makefltval (rtx, (qse_flt_t)ioattr->tmout[tmout].sec + QSE_NSEC_TO_SEC((qse_flt_t)ioattr->tmout[tmout].nsec)); rv = qse_awk_rtx_makefltval (rtx, (qse_awk_flt_t)ioattr->tmout[tmout].sec + QSE_NSEC_TO_SEC((qse_awk_flt_t)ioattr->tmout[tmout].nsec));
if (rv == QSE_NULL) if (rv == QSE_NULL)
{ {
ret = -1; ret = -1;

View File

@ -345,7 +345,11 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
qse_strxfmt ( qse_strxfmt (
buf, QSE_COUNTOF(buf), buf, QSE_COUNTOF(buf),
#if defined(QSE_AWK_USE_FLTMAX_T)
QSE_T("%jf"),
#else
QSE_T("%zf"), QSE_T("%zf"),
#endif
((qse_awk_nde_flt_t*)nde)->val ((qse_awk_nde_flt_t*)nde)->val
); );

View File

@ -137,7 +137,7 @@ struct qse_awk_nde_int_t
struct qse_awk_nde_flt_t struct qse_awk_nde_flt_t
{ {
QSE_AWK_NDE_HDR; QSE_AWK_NDE_HDR;
qse_flt_t val; qse_awk_flt_t val;
qse_char_t* str; qse_char_t* str;
qse_size_t len; qse_size_t len;
}; };

View File

@ -145,7 +145,7 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* rtx, qse_long_t v)
return (qse_awk_val_t*)val; return (qse_awk_val_t*)val;
} }
qse_awk_val_t* qse_awk_rtx_makefltval (qse_awk_rtx_t* rtx, qse_flt_t v) qse_awk_val_t* qse_awk_rtx_makefltval (qse_awk_rtx_t* rtx, qse_awk_flt_t v)
{ {
qse_awk_val_flt_t* val; qse_awk_val_flt_t* val;
@ -420,7 +420,7 @@ qse_awk_val_t* qse_awk_rtx_makenstrvalwithcstr (qse_awk_rtx_t* rtx, const qse_cs
int x; int x;
qse_awk_val_t* v; qse_awk_val_t* v;
qse_long_t l; qse_long_t l;
qse_flt_t r; qse_awk_flt_t r;
x = qse_awk_rtx_strtonum (rtx, 1, str->ptr, str->len, &l, &r); x = qse_awk_rtx_strtonum (rtx, 1, str->ptr, str->len, &l, &r);
v = qse_awk_rtx_makestrvalwithcstr (rtx, str); v = qse_awk_rtx_makestrvalwithcstr (rtx, str);
@ -592,7 +592,7 @@ qse_awk_val_t* qse_awk_rtx_makemapvalwithdata (qse_awk_rtx_t* rtx, qse_awk_val_m
break; break;
case QSE_AWK_VAL_MAP_DATA_FLT: case QSE_AWK_VAL_MAP_DATA_FLT:
tmp = qse_awk_rtx_makefltval (rtx, *(qse_flt_t*)p->vptr); tmp = qse_awk_rtx_makefltval (rtx, *(qse_awk_flt_t*)p->vptr);
break; break;
case QSE_AWK_VAL_MAP_DATA_STR: case QSE_AWK_VAL_MAP_DATA_STR:
@ -1472,7 +1472,7 @@ qse_wchar_t* qse_awk_rtx_valtowcsdup (
} }
static int val_ref_to_num ( static int val_ref_to_num (
qse_awk_rtx_t* rtx, const qse_awk_val_ref_t* ref, qse_long_t* l, qse_flt_t* r) qse_awk_rtx_t* rtx, const qse_awk_val_ref_t* ref, qse_long_t* l, qse_awk_flt_t* r)
{ {
switch (ref->id) switch (ref->id)
{ {
@ -1530,7 +1530,7 @@ static int val_ref_to_num (
int qse_awk_rtx_valtonum ( int qse_awk_rtx_valtonum (
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_long_t* l, qse_flt_t* r) qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_long_t* l, qse_awk_flt_t* r)
{ {
switch (v->type) switch (v->type)
{ {
@ -1583,7 +1583,7 @@ int qse_awk_rtx_valtolong (
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_long_t* l) qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_long_t* l)
{ {
int n; int n;
qse_flt_t r; qse_awk_flt_t r;
n = qse_awk_rtx_valtonum (rtx, v, l, &r); n = qse_awk_rtx_valtonum (rtx, v, l, &r);
if (n == 1) if (n == 1)
@ -1596,13 +1596,13 @@ int qse_awk_rtx_valtolong (
} }
int qse_awk_rtx_valtoflt ( int qse_awk_rtx_valtoflt (
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_flt_t* r) qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_awk_flt_t* r)
{ {
int n; int n;
qse_long_t l; qse_long_t l;
n = qse_awk_rtx_valtonum (rtx, v, &l, r); n = qse_awk_rtx_valtonum (rtx, v, &l, r);
if (n == 0) *r = (qse_flt_t)l; if (n == 0) *r = (qse_awk_flt_t)l;
else if (n == 1) n = 0; else if (n == 1) n = 0;
return n; return n;
@ -1611,7 +1611,7 @@ int qse_awk_rtx_valtoflt (
int qse_awk_rtx_strtonum ( int qse_awk_rtx_strtonum (
qse_awk_rtx_t* rtx, int strict, qse_awk_rtx_t* rtx, int strict,
const qse_char_t* ptr, qse_size_t len, const qse_char_t* ptr, qse_size_t len,
qse_long_t* l, qse_flt_t* r) qse_long_t* l, qse_awk_flt_t* r)
{ {
const qse_char_t* endptr; const qse_char_t* endptr;

View File

@ -22,6 +22,14 @@
#include <qse/cmn/mbwc.h> #include <qse/cmn/mbwc.h>
#include "mem.h" #include "mem.h"
#if !defined(HAVE_VA_COPY)
# if defined(HAVE___VA_COPY)
# define va_copy(dst,src) __va_copy((dst),(src))
# else
# define va_copy(dst,src) QSE_MEMCPY(&(dst),&(src),QSE_SIZEOF(va_list))
# endif
#endif
static int put_mchar_null (qse_mchar_t c, void* ctx) static int put_mchar_null (qse_mchar_t c, void* ctx)
{ {
return 1; return 1;