aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorimiklos <36988640+imiklos@users.noreply.github.com>2018-03-22 02:36:40 +0100
committeryichoi <duddlf.choi@samsung.com>2018-03-22 10:36:40 +0900
commit15f6ca9f70b96e6d9a956b5cf5ced605ef7ba127 (patch)
treea4df476513d721841b89243347fcc9db142698d6 /docs
parentd701a7bfb157e53d24d8366ad64dea27b28c1eec (diff)
Move the sleep function to jerry-port (#2245)
Now the jerry-debugger uses the jerry-port's sleep, therefore if there are systems that don't support usleep or nanosleep can now define their own function. JerryScript-DCO-1.0-Signed-off-by: Istvan Miklos imiklos2@inf.u-szeged.hu
Diffstat (limited to 'docs')
-rw-r--r--docs/05.PORT-API.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/05.PORT-API.md b/docs/05.PORT-API.md
index 4974d54a..69f7337a 100644
--- a/docs/05.PORT-API.md
+++ b/docs/05.PORT-API.md
@@ -112,6 +112,15 @@ Allow user to provide external buffer for jerry instance (which includes an isol
struct jerry_instance_t *jerry_port_get_current_instance (void);
```
+## Sleep
+
+```c
+/**
+ * Makes the process sleep for a given time.
+ */
+void jerry_port_sleep (uint32_t sleep_time);
+```
+
# How to port JerryScript
This section describes a basic port implementation which was created for Unix based systems.
@@ -231,3 +240,32 @@ jerry_port_get_current_instance (void)
return current_instance_p;
} /* jerry_port_get_current_instance */
```
+
+## Sleep
+
+```c
+#include "jerryscript-port.h"
+#include "jerryscript-port-default.h"
+
+#ifdef HAVE_TIME_H
+#include <time.h>
+#elif defined (HAVE_UNISTD_H)
+#include <unistd.h>
+#endif /* HAVE_TIME_H */
+
+#ifdef JERRY_DEBUGGER
+void jerry_port_sleep (uint32_t sleep_time)
+{
+#ifdef HAVE_TIME_H
+ nanosleep (&(const struct timespec)
+ {
+ sleep_time / 1000, (sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */
+ }
+ , NULL);
+#elif defined (HAVE_UNISTD_H)
+ usleep ((useconds_t) sleep_time * 1000);
+#endif /* HAVE_TIME_H */
+ (void) sleep_time;
+} /* jerry_port_sleep */
+#endif /* JERRY_DEBUGGER */
+```