• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <stdarg.h>
17 
18 #include <zephyr.h>
19 
20 #include "jerryscript-port.h"
21 
22 
23 /**
24  * Provide log message implementation for the engine.
25  */
26 void
jerry_port_log(jerry_log_level_t level,const char * format,...)27 jerry_port_log (jerry_log_level_t level, /**< log level */
28                 const char *format, /**< format string */
29                 ...)  /**< parameters */
30 {
31   (void) level; /* ignore log level */
32 
33   va_list args;
34   va_start (args, format);
35   vfprintf (stderr, format, args);
36   va_end (args);
37 } /* jerry_port_log */
38 
39 
40 /**
41  * Provide fatal message implementation for the engine.
42  */
jerry_port_fatal(jerry_fatal_code_t code)43 void jerry_port_fatal (jerry_fatal_code_t code)
44 {
45   jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Jerry Fatal Error!\n");
46   while (true);
47 } /* jerry_port_fatal */
48 
49 /**
50  * Implementation of jerry_port_get_current_time.
51  *
52  * @return current timer's counter value in milliseconds
53  */
54 double
jerry_port_get_current_time(void)55 jerry_port_get_current_time (void)
56 {
57   int64_t ms = k_uptime_get();
58   return (double) ms;
59 } /* jerry_port_get_current_time */
60 
61 /**
62  * Dummy function to get the time zone adjustment.
63  *
64  * @return 0
65  */
66 double
jerry_port_get_local_time_zone_adjustment(double unix_ms,bool is_utc)67 jerry_port_get_local_time_zone_adjustment (double unix_ms, bool is_utc)
68 {
69   /* We live in UTC. */
70   return 0;
71 } /* jerry_port_get_local_time_zone_adjustment */
72 
73 /**
74  * Provide the implementation of jerry_port_print_char.
75  * Uses 'printf' to print a single character to standard output.
76  */
77 void
jerry_port_print_char(char c)78 jerry_port_print_char (char c) /**< the character to print */
79 {
80   printf ("%c", c);
81 } /* jerry_port_print_char */
82