1 /* Copyright JS Foundation and other contributors, http://js.foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16
17 #include <stdio.h>
18 #include <stdarg.h>
19 #include <sys/time.h>
20
21 #include "esp_common.h"
22
23 #include "jerryscript-port.h"
24
25 /**
26 * Provide log message implementation for the engine.
27 */
28 void
jerry_port_log(jerry_log_level_t level,const char * format,...)29 jerry_port_log (jerry_log_level_t level, /**< log level */
30 const char *format, /**< format string */
31 ...) /**< parameters */
32 {
33 (void) level; /* ignore log level */
34
35 va_list args;
36 va_start (args, format);
37 vfprintf (stderr, format, args);
38 va_end (args);
39 } /* jerry_port_log */
40
41 /**
42 * Provide fatal message implementation for the engine.
43 */
44 void
jerry_port_fatal(jerry_fatal_code_t code)45 jerry_port_fatal (jerry_fatal_code_t code)
46 {
47 jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Jerry Fatal Error!\n");
48 while (true);
49 } /* jerry_port_fatal */
50
51 /**
52 * Implementation of jerry_port_get_current_time.
53 *
54 * @return current timer's counter value in milliseconds
55 */
56 double
jerry_port_get_current_time(void)57 jerry_port_get_current_time (void)
58 {
59 uint32_t rtc_time = system_rtc_clock_cali_proc();
60 return (double) rtc_time;
61 } /* jerry_port_get_current_time */
62
63 /**
64 * Dummy function to get the time zone adjustment.
65 *
66 * @return 0
67 */
68 double
jerry_port_get_local_time_zone_adjustment(double unix_ms,bool is_utc)69 jerry_port_get_local_time_zone_adjustment (double unix_ms, bool is_utc)
70 {
71 /* We live in UTC. */
72 return 0;
73 } /* jerry_port_get_local_time_zone_adjustment */
74