Skip to content

Build fix #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion jerry-core/ecma/builtin-objects/ecma-builtin-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#define BUILTIN_UNDERSCORED_ID date
#include "ecma-builtin-internal-routines-template.inc.h"

#include <sys/time.h>

/** \addtogroup ecma ECMA
* @{
*
Expand Down Expand Up @@ -449,7 +451,7 @@ 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;
struct timeval tv;
ecma_number_t *now_num_p = ecma_alloc_number ();
*now_num_p = ECMA_NUMBER_ZERO;

Expand Down
17 changes: 14 additions & 3 deletions jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@

#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN

#include <time.h>
#include <sys/time.h>

/**
* Timezone structure
*/
struct timezone
{
int tz_minuteswest; /**< minutes west of Greenwich */
int tz_dsttime; /**< type of DST correction */
};

/** \addtogroup ecma ECMA
* @{
Expand Down Expand Up @@ -447,9 +456,10 @@ ecma_date_week_day (ecma_number_t time) /**< time value */
ecma_number_t __attr_always_inline___
ecma_date_local_tza ()
{
struct timeval tv;
struct timezone tz;

if (gettimeofday (NULL, &tz) != 0)
if (gettimeofday (&tv, &tz) != 0)
{
return ecma_raise_type_error ("gettimeofday failed");
}
Expand All @@ -473,9 +483,10 @@ ecma_date_daylight_saving_ta (ecma_number_t time) /**< time value */
return time; /* time is NaN */
}

struct timeval tv;
struct timezone tz;

if (gettimeofday (NULL, &tz) != 0)
if (gettimeofday (&tv, &tz) != 0)
{
return ecma_raise_type_error ("gettimeofday failed");
}
Expand Down
11 changes: 1 addition & 10 deletions jerry-libc/include/time.h → jerry-libc/include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@ extern "C"
/**
* Time value structure
*/
struct _timeval
struct timeval
{
unsigned long tv_sec; /**< seconds */
unsigned long tv_usec; /**< microseconds */
};

/**
* Timezone structure
*/
struct timezone
{
int tz_minuteswest; /**< minutes west of Greenwich */
int tz_dsttime; /**< type of DST correction */
};

int gettimeofday (void *tp, void *tzp);

#ifdef __cplusplus
Expand Down
5 changes: 2 additions & 3 deletions jerry-libc/target/darwin/jerry-libc-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>

#include "jerry-libc-defs.h"

Expand Down Expand Up @@ -394,5 +393,5 @@ int
gettimeofday (void *tp, /**< struct timeval */
void *tzp) /**< struct timezone */
{
return (int) syscall_2 (__NR_gettimeofday, (long int) tp, (long int) tzp);
return (int) syscall_2 (gettimeofday, (long int) tp, (long int) tzp);
} /* gettimeofday */
3 changes: 1 addition & 2 deletions jerry-libc/target/linux/jerry-libc-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
#include <stdlib.h>
#include <string.h>
#include <syscall.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>

#include "jerry-libc-defs.h"

Expand Down
2 changes: 1 addition & 1 deletion jerry-libc/target/mcu-stubs/jerry-libc-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>

#include "jerry-libc-defs.h"

Expand Down