fixed a minor build issue with mingw64.

renamed qse_real_t to qse_flt_t
This commit is contained in:
2011-11-22 05:03:31 +00:00
parent 5bd21d36b2
commit 350c75434c
38 changed files with 505 additions and 402 deletions

View File

@ -36,22 +36,44 @@ class Types
public:
/** boolean data type */
typedef qse_bool_t bool_t;
/** data type that can hold any character */
typedef qse_char_t char_t;
/** data type that can hold any character or an end-of-file value */
typedef qse_cint_t cint_t;
/** redefines an unsigned integer number of the same size as void* */
typedef qse_size_t size_t;
/** signed version of size_t */
typedef qse_ssize_t ssize_t;
/** redefines an integer */
/** redefines qse_long_t */
typedef qse_long_t long_t;
/** redefines qse_ulong_t */
typedef qse_ulong_t ulong_t;
/** redefines qse_intptr_t */
typedef qse_intptr_t intptr_t;
/** redefines qse_uintptr_t */
typedef qse_uintptr_t uintptr_t;
/** redefines qse_intmax_t */
typedef qse_intmax_t intmax_t;
/** redefines qse_uintmax_t */
typedef qse_uintmax_t uintmax_t;
/** redefines a floating-point number */
typedef qse_real_t real_t;
typedef qse_flt_t flt_t;
/** redefines a structure of a constant character pointer and length */
typedef qse_cstr_t cstr_t;
/** redefines a structure of a character pointer and length */
typedef qse_xstr_t xstr_t;
typedef qse_xstr_t xstr_t;
};
/////////////////////////////////

View File

@ -566,7 +566,7 @@ public:
operator val_t* () const { return val; }
operator long_t () const;
operator real_t () const;
operator flt_t () const;
operator const char_t* () const;
val_t* toVal () const
@ -579,9 +579,9 @@ public:
return operator long_t ();
}
real_t toReal () const
flt_t toFlt () const
{
return operator real_t ();
return operator flt_t ();
}
const char_t* toStr (size_t* len) const
@ -600,7 +600,7 @@ public:
}
int getInt (long_t* v) const;
int getReal (real_t* v) const;
int getFlt (flt_t* v) const;
int getStr (const char_t** str, size_t* len) const;
int setVal (val_t* v);
@ -608,8 +608,8 @@ public:
int setInt (long_t v);
int setInt (Run* r, long_t v);
int setReal (real_t v);
int setReal (Run* r, real_t v);
int setFlt (flt_t v);
int setFlt (Run* r, flt_t v);
int setStr (const char_t* str, size_t len);
int setStr (Run* r, const char_t* str, size_t len);
int setStr (const char_t* str);
@ -636,15 +636,15 @@ public:
const Index& idx,
long_t v);
int setIndexedReal (
int setIndexedFlt (
const Index& idx,
real_t v
flt_t v
);
int setIndexedReal (
int setIndexedFlt (
Run* r,
const Index& idx,
real_t v
flt_t v
);
int setIndexedStr (
@ -775,7 +775,7 @@ public:
/// to @a v.
/// @return 0 on success, -1 on failure
///
int setGlobal (int id, real_t v);
int setGlobal (int id, flt_t v);
///
/// The setGlobal() function sets the value of a global
@ -1091,16 +1091,16 @@ protected:
virtual int vsprintf (char_t* buf, size_t size,
const char_t* fmt, va_list arg) = 0;
virtual real_t pow (real_t x, real_t y) = 0;
virtual real_t mod (real_t x, real_t y) = 0;
virtual real_t sin (real_t x) = 0;
virtual real_t cos (real_t x) = 0;
virtual real_t tan (real_t x) = 0;
virtual real_t atan (real_t x) = 0;
virtual real_t atan2 (real_t x, real_t y) = 0;
virtual real_t log (real_t x) = 0;
virtual real_t exp (real_t x) = 0;
virtual real_t sqrt (real_t x) = 0;
virtual flt_t pow (flt_t x, flt_t y) = 0;
virtual flt_t mod (flt_t x, flt_t y) = 0;
virtual flt_t sin (flt_t x) = 0;
virtual flt_t cos (flt_t x) = 0;
virtual flt_t tan (flt_t x) = 0;
virtual flt_t atan (flt_t x) = 0;
virtual flt_t atan2 (flt_t x, flt_t y) = 0;
virtual flt_t log (flt_t x) = 0;
virtual flt_t exp (flt_t x) = 0;
virtual flt_t sqrt (flt_t x) = 0;
// static glue members for various handlers
static ssize_t readSource (
@ -1124,16 +1124,16 @@ protected:
static int sprintf (awk_t* data, char_t* buf, size_t size,
const char_t* fmt, ...);
static real_t pow (awk_t* data, real_t x, real_t y);
static real_t mod (awk_t* data, real_t x, real_t y);
static real_t sin (awk_t* data, real_t x);
static real_t cos (awk_t* data, real_t x);
static real_t tan (awk_t* data, real_t x);
static real_t atan (awk_t* data, real_t x);
static real_t atan2 (awk_t* data, real_t x, real_t y);
static real_t log (awk_t* data, real_t x);
static real_t exp (awk_t* data, real_t x);
static real_t sqrt (awk_t* data, real_t x);
static flt_t pow (awk_t* data, flt_t x, flt_t y);
static flt_t mod (awk_t* data, flt_t x, flt_t y);
static flt_t sin (awk_t* data, flt_t x);
static flt_t cos (awk_t* data, flt_t x);
static flt_t tan (awk_t* data, flt_t x);
static flt_t atan (awk_t* data, flt_t x);
static flt_t atan2 (awk_t* data, flt_t x, flt_t y);
static flt_t log (awk_t* data, flt_t x);
static flt_t exp (awk_t* data, flt_t x);
static flt_t sqrt (awk_t* data, flt_t x);
protected:
awk_t* awk;

View File

@ -141,16 +141,16 @@ protected:
int vsprintf (char_t* buf, size_t size,
const char_t* fmt, va_list arg);
real_t pow (real_t x, real_t y);
real_t mod (real_t x, real_t y);
real_t sin (real_t x);
real_t cos (real_t x);
real_t tan (real_t x);
real_t atan (real_t x);
real_t atan2 (real_t x, real_t y);
real_t log (real_t x);
real_t exp (real_t x);
real_t sqrt (real_t x);
flt_t pow (flt_t x, flt_t y);
flt_t mod (flt_t x, flt_t y);
flt_t sin (flt_t x);
flt_t cos (flt_t x);
flt_t tan (flt_t x);
flt_t atan (flt_t x);
flt_t atan2 (flt_t x, flt_t y);
flt_t log (flt_t x);
flt_t exp (flt_t x);
flt_t sqrt (flt_t x);
protected:
unsigned int seed;

View File

@ -183,16 +183,16 @@ struct qse_awk_val_int_t
typedef struct qse_awk_val_int_t qse_awk_val_int_t;
/**
* The qse_awk_val_real_t type is a floating-point number type. The type field
* is #QSE_AWK_VAL_REAL.
* The qse_awk_val_flt_t type is a floating-point number type. The type field
* is #QSE_AWK_VAL_FLT.
*/
struct qse_awk_val_real_t
struct qse_awk_val_flt_t
{
QSE_AWK_VAL_HDR;
qse_real_t val;
void* nde;
qse_flt_t val;
void* nde;
};
typedef struct qse_awk_val_real_t qse_awk_val_real_t;
typedef struct qse_awk_val_flt_t qse_awk_val_flt_t;
/**
* The qse_awk_val_str_t type is a string type. The type field is
@ -318,7 +318,7 @@ enum qse_awk_nde_type_t
QSE_AWK_NDE_FNC,
QSE_AWK_NDE_FUN,
QSE_AWK_NDE_INT,
QSE_AWK_NDE_REAL,
QSE_AWK_NDE_FLT,
QSE_AWK_NDE_STR,
QSE_AWK_NDE_REX,
@ -379,15 +379,15 @@ typedef int (*qse_awk_sprintf_t) (
...
);
typedef qse_real_t (*qse_awk_math1_t) (
typedef qse_flt_t (*qse_awk_math1_t) (
qse_awk_t* awk,
qse_real_t x
qse_flt_t x
);
typedef qse_real_t (*qse_awk_math2_t) (
typedef qse_flt_t (*qse_awk_math2_t) (
qse_awk_t* awk,
qse_real_t x,
qse_real_t y
qse_flt_t x,
qse_flt_t y
);
@ -1046,7 +1046,7 @@ enum qse_awk_val_type_t
* function in run.c */
QSE_AWK_VAL_NIL = 0, /**< nil */
QSE_AWK_VAL_INT = 1, /**< integer */
QSE_AWK_VAL_REAL = 2, /**< floating-pointer number */
QSE_AWK_VAL_FLT = 2, /**< floating-pointer number */
QSE_AWK_VAL_STR = 3, /**< string */
QSE_AWK_VAL_REX = 4, /**< regular expression */
@ -1509,10 +1509,10 @@ qse_long_t qse_awk_strxtolong (
);
/**
* The qse_awk_strxtoreal() function converts a string to a floating-point
* The qse_awk_strxtoflt() function converts a string to a floating-point
* number.
*/
qse_real_t qse_awk_strxtoreal (
qse_flt_t qse_awk_strxtoflt (
qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len,
@ -1879,12 +1879,12 @@ qse_awk_val_t* qse_awk_rtx_makeintval (
);
/**
* The qse_awk_rtx_makerealval() function creates a floating-point value.
* The qse_awk_rtx_makefltval() function creates a floating-point value.
* @return value on success, QSE_NULL on failure
*/
qse_awk_val_t* qse_awk_rtx_makerealval (
qse_awk_val_t* qse_awk_rtx_makefltval (
qse_awk_rtx_t* rtx,
qse_real_t v
qse_flt_t v
);
/**
@ -2196,7 +2196,7 @@ qse_char_t* qse_awk_rtx_valtocpldup (
*
* @code
* qse_long_t l;
* qse_real_t r;
* qse_flt_t r;
* int n;
* n = qse_awk_rtx_valtonum (v, &l, &r);
* if (n <= -1) error ();
@ -2211,7 +2211,7 @@ int qse_awk_rtx_valtonum (
qse_awk_rtx_t* rtx,
const qse_awk_val_t* val,
qse_long_t* l,
qse_real_t* r
qse_flt_t* r
);
int qse_awk_rtx_valtolong (
@ -2220,10 +2220,10 @@ int qse_awk_rtx_valtolong (
qse_long_t* l
);
int qse_awk_rtx_valtoreal (
int qse_awk_rtx_valtoflt (
qse_awk_rtx_t* rtx,
const qse_awk_val_t* val,
qse_real_t* r
qse_flt_t* r
);
/**
@ -2246,7 +2246,7 @@ int qse_awk_rtx_strtonum (
const qse_char_t* ptr, /**< points to a string to convert */
qse_size_t len, /**< number of characters in a string */
qse_long_t* l, /**< stores a converted integer */
qse_real_t* r /**< stores a converted floating-poing number */
qse_flt_t* r /**< stores a converted floating-poing number */
);
/**

View File

@ -51,6 +51,12 @@ typedef qse_search_comper_t qse_sort_comper_t;
/**
* The qse_bsearch() function performs binary search over a sorted array.
* It looks for an item matching @a key in an array @a base containing
* @a nmemb items each of which is as large as @a size. The comparison
* function @a comper is invoked with @a key as the first parameter and
* an item being tested as the second parameter. The @a ctx parameter is
* passed to @a comper as the third parameter.
*
* See the example below:
* @code
* static int compstr (const void* s1, const void* s2, void* ctx)

View File

@ -389,6 +389,9 @@
/* sizeof(wchar_t) */
#undef QSE_SIZEOF_WCHAR_T
/* sizeof(__float128) */
#undef QSE_SIZEOF___FLOAT128
/* sizeof(__int128) */
#undef QSE_SIZEOF___INT128
@ -449,6 +452,9 @@
/* The size of `wchar_t', as computed by sizeof. */
#undef SIZEOF_WCHAR_T
/* The size of `__float128', as computed by sizeof. */
#undef SIZEOF___FLOAT128
/* The size of `__int128', as computed by sizeof. */
#undef SIZEOF___INT128

View File

@ -434,40 +434,61 @@ typedef qse_int_t qse_intptr_t;
#elif (QSE_SIZEOF_INTMAX_T == QSE_SIZEOF_INT128_T)
typedef qse_int128_t qse_intmax_t;
typedef qse_uint128_t qse_uintmax_t;
/* QSE_SIZEOF_INTMAX_T and QSE_SIZEOF_UINTMAX_T are
* defined when qse_int128_t is defined */
#elif (QSE_SIZEOF_INTMAX_T == QSE_SIZEOF_INT64_T)
typedef qse_int64_t qse_intmax_t;
typedef qse_uint64_t qse_uintmax_t;
/* QSE_SIZEOF_INTMAX_T and QSE_SIZEOF_UINTMAX_T are
* defined when qse_int64_t is defined */
#elif (QSE_SIZEOF_INTMAX_T == QSE_SIZEOF_INT32_T)
typedef qse_int32_t qse_intmax_t;
typedef qse_uint32_t qse_uintmax_t;
/* QSE_SIZEOF_INTMAX_T and QSE_SIZEOF_UINTMAX_T are
* defined when qse_int32_t is defined */
#elif (QSE_SIZEOF_INTMAX_T == QSE_SIZEOF_INT16_T)
typedef qse_int16_t qse_intmax_t;
typedef qse_uint16_t qse_uintmax_t;
/* QSE_SIZEOF_INTMAX_T and QSE_SIZEOF_UINTMAX_T are
* defined when qse_int16_t is defined */
#elif (QSE_SIZEOF_INTMAX_T == QSE_SIZEOF_INT8_T)
typedef qse_int8_t qse_intmax_t;
typedef qse_uint8_t qse_uintmax_t;
/* QSE_SIZEOF_INTMAX_T and QSE_SIZEOF_UINTMAX_T are
* defined when qse_int8_t is defined */
#else
# error FATAL. THIS MUST NOT HAPPEN
#endif
/** @typedef qse_real_t
* The qse_real_t type defines the largest floating-pointer number type
/** @typedef qse_flt_t
* The qse_flt_t type defines the largest floating-pointer number type
* supported.
*/
#if defined(__FreeBSD__)
/* TODO: check if the support for long double is complete.
* if so, use long double for qse_real_t */
# define QSE_SIZEOF_REAL QSE_SIZEOF_DOUBLE
typedef double qse_real_t;
* if so, use long double for qse_flt_t */
typedef double qse_flt_t;
# define QSE_SIZEOF_FLT_T QSE_SIZEOF_DOUBLE
#elif QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE
# define QSE_SIZEOF_REAL QSE_SIZEOF_LONG_DOUBLE
typedef long double qse_real_t;
typedef long double qse_flt_t;
# define QSE_SIZEOF_FLT_T QSE_SIZEOF_LONG_DOUBLE
#else
# define QSE_SIZEOF_REAL QSE_SIZEOF_DOUBLE
typedef double qse_real_t;
typedef double qse_flt_t;
# define QSE_SIZEOF_FLT_T QSE_SIZEOF_DOUBLE
#endif
/* TODO: qse_fltmax_t to include the quadruple precision floating-point type.
*
#if QSE_SIZEOF___FLOAT128 > 0
typedef __float128 qse_fltmax_t;
# define QSE_SIZEOF_FLTMAX_T QSE_SIZEOF___FLOAT128
#else
typedef qse_flt_t qse_fltmax_t;
# define QSE_SIZEOF_FLTMAX_T QSE_SIZEOF_FLT_T
#endif
*/
/**
* The qse_mchar_t type defines a multi-byte character type.
*/
@ -754,11 +775,11 @@ union qse_ubi_t
qse_uintptr_t uintptr;
qse_intmax_t intmax;
qse_uintmax_t uintmax;
qse_real_t real;
qse_flt_t flt;
qse_char_t cha;
qse_mchar_t mchar;
qse_wchar_t wchar;
qse_char_t ch;
qse_mchar_t mch;
qse_wchar_t wch;
qse_cint_t cint;
qse_mcint_t mcint;
qse_wcint_t wcint;