Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,58 @@
/* Copyright 2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/time.h>
#include "jerry-port.h"
#include "jerry-port-default.h"
/**
* Default implementation of jerry_port_get_time_zone.
*/
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
{
struct timeval tv;
struct timezone tz;
/* gettimeofday may not fill tz, so zero-initializing */
tz.tz_minuteswest = 0;
tz.tz_dsttime = 0;
if (gettimeofday (&tv, &tz) != 0)
{
return false;
}
tz_p->offset = tz.tz_minuteswest;
tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
return true;
} /* jerry_port_get_time_zone */
/**
* Default implementation of jerry_port_get_current_time.
*/
double jerry_port_get_current_time ()
{
struct timeval tv;
if (gettimeofday (&tv, NULL) != 0)
{
return 0;
}
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
} /* jerry_port_get_current_time */

View file

@ -0,0 +1,62 @@
/* Copyright 2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include "jerry-port.h"
#include "jerry-port-default.h"
static bool abort_on_fail = false;
/**
* Sets whether 'abort' should be called instead of 'exit' upon exiting with
* non-zero exit code in the default implementation of jerry_port_fatal.
*/
void jerry_port_default_set_abort_on_fail (bool flag) /**< new value of 'abort on fail' flag */
{
abort_on_fail = flag;
} /* jerry_port_default_set_abort_on_fail */
/**
* Check whether 'abort' should be called instead of 'exit' upon exiting with
* non-zero exit code in the default implementation of jerry_port_fatal.
*
* @return true - if 'abort on fail' flag is set,
* false - otherwise.
*/
bool jerry_port_default_is_abort_on_fail ()
{
return abort_on_fail;
} /* jerry_port_default_is_abort_on_fail */
/**
* Default implementation of jerry_port_fatal.
*/
void jerry_port_fatal (jerry_fatal_code_t code, /**< fatal code enum item, */
void *lr) /**< return address at time failure occurred */
{
JERRY_UNUSED (lr);
if (code != 0
&& code != ERR_OUT_OF_MEMORY
&& jerry_port_default_is_abort_on_fail ())
{
abort ();
}
else
{
exit (code);
}
} /* jerry_port_fatal */

View file

@ -0,0 +1,74 @@
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdarg.h>
#include "jerry-port.h"
#include "jerry-port-default.h"
/**
* Actual log level
*/
static jerry_log_level_t jerry_log_level = JERRY_LOG_LEVEL_ERROR;
/**
* Get the log level
*
* @return current log level
*/
jerry_log_level_t
jerry_port_default_get_log_level (void)
{
return jerry_log_level;
} /* jerry_port_default_get_log_level */
/**
* Set the log level
*/
void
jerry_port_default_set_log_level (jerry_log_level_t level) /**< log level */
{
jerry_log_level = level;
} /* jerry_port_default_set_log_level */
/**
* Provide console message implementation for the engine.
*/
void
jerry_port_console (const char *format, /**< format string */
...) /**< parameters */
{
va_list args;
va_start (args, format);
vfprintf (stdout, format, args);
va_end (args);
} /* jerry_port_console */
/**
* Provide log message implementation for the engine.
*/
void
jerry_port_log (jerry_log_level_t level, /**< log level */
const char *format, /**< format string */
...) /**< parameters */
{
if (level <= jerry_log_level)
{
va_list args;
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
}
} /* jerry_port_log */

View file

@ -0,0 +1,40 @@
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdarg.h>
#include "jerry-port.h"
#define JMEM_HEAP_INTERNAL
#ifndef JERRY_HEAP_SECTION_ATTR
static jmem_heap_t jmem_heap;
#else
static jmem_heap_t jmem_heap __attribute__ ((section (JERRY_HEAP_SECTION_ATTR)));
#endif
jmem_heap_t *jerry_port_init_heap(void) {
memset(&jmem_heap, 0, sizeof(jmem_heap));
return &jmem_heap;
}
void jerry_port_finalize_heap(jmem_heap_t *jmem_heap) {
return;
}
jmem_heap_t *jerry_port_get_heap(void) {
return &jmem_heap;
}

View file

@ -0,0 +1,47 @@
/* Copyright 2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef JERRY_PORT_DEFAULT_H
#define JERRY_PORT_DEFAULT_H
#include "jerry-port.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/** \addtogroup jerry_port_default Default Jerry engine port API
* These functions are only available if the default port of Jerry is used.
* @{
*/
void jerry_port_default_set_abort_on_fail (bool);
bool jerry_port_default_is_abort_on_fail (void);
jerry_log_level_t jerry_port_default_get_log_level (void);
void jerry_port_default_set_log_level (jerry_log_level_t);
/**
* @}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !JERRY_PORT_DEFAULT_H */