Skip to content

Commit 29e7330

Browse files
authored
Move all (nano|u)sleep-related decisions to default port implementation (#2462)
... where they belong. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent fb35e34 commit 29e7330

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

jerry-core/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,6 @@ if(FEATURE_DEBUGGER)
211211
message(FATAL_ERROR "This configuration is not supported. Please build against your system libc to enable the JerryScript debugger.")
212212
endif()
213213

214-
# Sleep function availability check
215-
INCLUDE (CheckIncludeFiles)
216-
CHECK_INCLUDE_FILES (time.h HAVE_TIME_H)
217-
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
218-
if(HAVE_TIME_H)
219-
set(DEFINES_JERRY ${DEFINES_JERRY} HAVE_TIME_H)
220-
elseif(HAVE_UNISTD_H)
221-
set(DEFINES_JERRY ${DEFINES_JERRY} HAVE_UNISTD_H)
222-
endif()
223-
224214
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_DEBUGGER)
225215
endif()
226216

jerry-core/api/jerry-debugger-transport.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ jerry_debugger_transport_receive_completed (jerry_debugger_transport_receive_con
261261
} /* jerry_debugger_transport_receive_completed */
262262

263263
/**
264-
* Suspend execution for a given time.
265-
* Note: If the platform does not have nanosleep or usleep, this function does not sleep at all.
264+
* Suspend execution for a predefined time (JERRY_DEBUGGER_TRANSPORT_TIMEOUT ms).
266265
*/
267266
void
268267
jerry_debugger_transport_sleep (void)

jerry-core/jrt/jrt.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#ifndef JRT_H
1717
#define JRT_H
1818

19-
#if !defined (_XOPEN_SOURCE) || _XOPEN_SOURCE < 500
20-
#undef _XOPEN_SOURCE
21-
/* Required macro for sleep functions (nanosleep or usleep) */
22-
#define _XOPEN_SOURCE 500
23-
#endif
24-
2519
#include <stdio.h>
2620
#include <string.h>
2721

jerry-ext/common/jext-common.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#ifndef JEXT_COMMON_H
1717
#define JEXT_COMMON_H
1818

19-
#if !defined (_XOPEN_SOURCE) || _XOPEN_SOURCE < 500
20-
#undef _XOPEN_SOURCE
21-
/* Required macro for sleep functions (nanosleep or usleep) */
22-
#define _XOPEN_SOURCE 500
23-
#endif
24-
2519
#include <stdio.h>
2620
#include <string.h>
2721

jerry-port/default/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ file(GLOB SOURCE_PORT_DEFAULT *.c)
2626
# (should only be necessary if we used compiler default libc but not checking that)
2727
set(DEFINES_PORT_DEFAULT _BSD_SOURCE _DEFAULT_SOURCE)
2828

29+
# Sleep function availability check
30+
INCLUDE (CheckIncludeFiles)
31+
CHECK_INCLUDE_FILES (time.h HAVE_TIME_H)
32+
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
33+
if(HAVE_TIME_H)
34+
set(DEFINES_PORT_DEFAULT ${DEFINES_PORT_DEFAULT} HAVE_TIME_H)
35+
elseif(HAVE_UNISTD_H)
36+
set(DEFINES_PORT_DEFAULT ${DEFINES_PORT_DEFAULT} HAVE_UNISTD_H)
37+
endif()
38+
2939
# Default Jerry port implementation library variants:
3040
# - default
3141
# - default-minimal (no extra termination and log APIs)

jerry-port/default/default-debugger.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
* limitations under the License.
1414
*/
1515

16+
#if !defined (_XOPEN_SOURCE) || _XOPEN_SOURCE < 500
17+
#undef _XOPEN_SOURCE
18+
/* Required macro for sleep functions (nanosleep or usleep) */
19+
#define _XOPEN_SOURCE 500
20+
#endif
21+
1622
#ifdef HAVE_TIME_H
1723
#include <time.h>
1824
#elif defined (HAVE_UNISTD_H)

0 commit comments

Comments
 (0)