From 8367a4cd1271fc23260bb3681379f87288253e14 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 27 Aug 2012 15:53:53 +0000 Subject: [PATCH] fixed a bug in qse_gettime(). fixed wrong declaraations in alg.h --- qse/include/qse/awk/StdAwk.hpp | 3 ++- qse/include/qse/cmn/alg.h | 46 ++++++++++++++++++++++++++++++++++ qse/lib/cmn/time.c | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/qse/include/qse/awk/StdAwk.hpp b/qse/include/qse/awk/StdAwk.hpp index 1e1f87df..00a86ba2 100644 --- a/qse/include/qse/awk/StdAwk.hpp +++ b/qse/include/qse/awk/StdAwk.hpp @@ -201,7 +201,8 @@ protected: flt_t sqrt (flt_t x); protected: - unsigned int seed; + qse_long_t seed; + qse_ulong_t prand; qse_htb_t cmgrtab; bool cmgrtab_inited; diff --git a/qse/include/qse/cmn/alg.h b/qse/include/qse/cmn/alg.h index 524f5736..f433dcc3 100644 --- a/qse/include/qse/cmn/alg.h +++ b/qse/include/qse/cmn/alg.h @@ -49,6 +49,10 @@ typedef int (*qse_search_comper_t) ( */ typedef qse_search_comper_t qse_sort_comper_t; +#ifdef __cplusplus +extern "C" { +#endif + /** * 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 @@ -128,4 +132,46 @@ qse_uint32_t qse_rand31 ( qse_uint32_t seed ); + +#if (QSE_SIZEOF_UINT32_T > 0) +/** + * The qse_randxs32() function implements the xorshift random number generator + * by George Marsaglia. + */ +qse_uint32_t qse_randxs32 ( + qse_uint32_t seed +); +#endif + +#if (QSE_SIZEOF_UINT64_T > 0) +/** + * The qse_randxs64() function implements the xorshift random number generator + * by George Marsaglia. + */ +qse_uint64_t qse_randxs64 ( + qse_uint64_t seed +); +#endif + +#if (QSE_SIZEOF_ULONG_T == QSE_SIZEOF_UINT64_T) +# define qse_randxsulong(seed) qse_randxs64(seed) +#elif (QSE_SIZEOF_ULONG_T == QSE_SIZEOF_UINT32_T) +# define qse_randxsulong(seed) qse_randxs32(seed) +#else +# error Unsupported +#endif + +#if (QSE_SIZEOF_UINT_T == QSE_SIZEOF_UINT64_T) +# define qse_randxsuint(seed) qse_randxs64(seed) +#elif (QSE_SIZEOF_UINT_T == QSE_SIZEOF_UINT32_T) +# define qse_randxsuint(seed) qse_randxs32(seed) +#else +# error Unsupported +#endif + + +#ifdef __cplusplus +} +#endif + #endif diff --git a/qse/lib/cmn/time.c b/qse/lib/cmn/time.c index b21e1f96..9200e261 100644 --- a/qse/lib/cmn/time.c +++ b/qse/lib/cmn/time.c @@ -476,7 +476,7 @@ int qse_timelocal (const qse_btime_t* bt, qse_ntime_t* nt) return 0; #else *nt = ((qse_ntime_t)mktime(&tm)*QSE_MSECS_PER_SEC) + bt->msec; - return -1; + return 0; #endif }