Disable date object related system calls by default
Use DATE_SYS_CALLS=ON for make target to enable the date related system calls. Also fix some minor issues. Related issue: #923 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
@@ -33,7 +33,9 @@
|
||||
#define BUILTIN_UNDERSCORED_ID date
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#ifdef JERRY_ENABLE_DATE_SYS_CALLS
|
||||
#include <sys/time.h>
|
||||
#endif /* JERRY_ENABLE_DATE_SYS_CALLS */
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -451,16 +453,19 @@ ecma_builtin_date_utc (ecma_value_t this_arg __attr_unused___, /**< this argumen
|
||||
static ecma_value_t
|
||||
ecma_builtin_date_now (ecma_value_t this_arg __attr_unused___) /**< this argument */
|
||||
{
|
||||
struct timeval tv;
|
||||
ecma_number_t *now_num_p = ecma_alloc_number ();
|
||||
*now_num_p = ECMA_NUMBER_ZERO;
|
||||
|
||||
#ifdef JERRY_ENABLE_DATE_SYS_CALLS
|
||||
struct timeval tv;
|
||||
|
||||
if (gettimeofday (&tv, NULL) != 0)
|
||||
{
|
||||
return ecma_raise_type_error ("gettimeofday failed");
|
||||
}
|
||||
|
||||
*now_num_p = ((ecma_number_t) tv.tv_sec) * 1000.0 + ((ecma_number_t) (tv.tv_usec / 1000));
|
||||
#endif /* JERRY_ENABLE_DATE_SYS_CALLS */
|
||||
|
||||
return ecma_make_number_value (now_num_p);
|
||||
} /* ecma_builtin_date_now */
|
||||
|
||||
Reference in New Issue
Block a user