Browse Source

Merge pull request #1122 from beevik/ps4-compat

Add compatibility fixes for the Orbis (PS4) platform.
pull/831/head
Sami Vaarala 8 years ago
committed by GitHub
parent
commit
62aa25f063
  1. 4
      config/helper-snippets/DUK_F_ORBIS.h.in
  2. 4
      config/platforms.yaml
  3. 12
      config/platforms/platform_orbis.h.in
  4. 5
      src-input/duk_bi_date_unix.c
  5. 2
      src-input/duk_bi_protos.h

4
config/helper-snippets/DUK_F_ORBIS.h.in

@ -0,0 +1,4 @@
/* Orbis (PS4) variant */
#if defined(DUK_F_FREEBSD) && defined(__ORBIS__)
#define DUK_F_ORBIS
#endif

4
config/platforms.yaml

@ -7,6 +7,10 @@ autodetect:
name: Mac OSX, iPhone, Darwin
check: DUK_F_APPLE
include: platform_apple.h.in
-
name: Orbis
check: DUK_F_ORBIS
include: platform_orbis.h.in
-
name: OpenBSD
check: DUK_F_OPENBSD

12
config/platforms/platform_orbis.h.in

@ -0,0 +1,12 @@
/* Orbis = PS4 */
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_S
/* no parsing (not an error) */
#define DUK_USE_DATE_FMT_STRFTIME
#include <sys/types.h>
#include <machine/endian.h>
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_OS_STRING "orbis"

5
src-input/duk_bi_date_unix.c

@ -44,7 +44,7 @@ DUK_INTERNAL duk_double_t duk_bi_date_get_now_time(duk_context *ctx) {
}
#endif /* DUK_USE_DATE_NOW_TIME */
#if defined(DUK_USE_DATE_TZO_GMTIME) || defined(DUK_USE_DATE_TZO_GMTIME_R)
#if defined(DUK_USE_DATE_TZO_GMTIME) || defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S)
/* Get local time offset (in seconds) for a certain (UTC) instant 'd'. */
DUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d) {
time_t t, t1, t2;
@ -134,6 +134,9 @@ DUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d) {
#if defined(DUK_USE_DATE_TZO_GMTIME_R)
(void) gmtime_r(&t, &tms[0]);
(void) localtime_r(&t, &tms[1]);
#elif defined(DUK_USE_DATE_TZO_GMTIME_S)
(void) gmtime_s(&t, &tms[0]);
(void) localtime_s(&t, &tms[1]);
#elif defined(DUK_USE_DATE_TZO_GMTIME)
tm_ptr = gmtime(&t);
DUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm));

2
src-input/duk_bi_protos.h

@ -31,7 +31,7 @@ DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_time(duk_context *ctx);
#if defined(DUK_USE_DATE_NOW_WINDOWS)
DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_windows(duk_context *ctx);
#endif
#if defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME)
#if defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)
DUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d);
#endif
#if defined(DUK_USE_DATE_TZO_WINDOWS)

Loading…
Cancel
Save