aboutsummaryrefslogtreecommitdiff
path: root/jerry-libc
diff options
context:
space:
mode:
authorAkos Kiss <akiss@inf.u-szeged.hu>2016-04-12 14:59:19 +0200
committerAkos Kiss <akiss@inf.u-szeged.hu>2016-04-12 22:45:01 +0200
commita7f015ef47a3ea46699d9c7a28425576ae51886f (patch)
tree7e0e958e1e9f8f721f814c27f023fb87b5a0e823 /jerry-libc
parent7b10f912a9a36183d9190227ce45ff84bf421ba4 (diff)
Implement `raise ()` in libc
The core functionality (i.e., the equivalent of `kill (getpid (), sig);`) was already there in the implementation of `abort ()`. Now, it got factored out to `raise ()` so that others (most importantly, `__aeabi_ldiv0`) can call and link to it as well. Also, removed `LIBC_UNREACHABLE_STUB_FOR` macro, as it is not used anymore. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Diffstat (limited to 'jerry-libc')
-rw-r--r--jerry-libc/jerry-libc-defs.h15
-rw-r--r--jerry-libc/target/darwin/jerry-libc-target.c13
-rw-r--r--jerry-libc/target/linux/jerry-libc-target.c13
3 files changed, 20 insertions, 21 deletions
diff --git a/jerry-libc/jerry-libc-defs.h b/jerry-libc/jerry-libc-defs.h
index ad0a55e8..084f915e 100644
--- a/jerry-libc/jerry-libc-defs.h
+++ b/jerry-libc/jerry-libc-defs.h
@@ -54,19 +54,4 @@ libc_fatal (const char *msg,
} while (0)
#endif /* !LIBC_NDEBUG */
-/**
- * Stubs declaration
- */
-
-/**
- * Unreachable stubs for routines that are never called,
- * but referenced from third-party libraries.
- */
-#define LIBC_UNREACHABLE_STUB_FOR(...) \
-extern __VA_ARGS__; \
-__attr_used___ __VA_ARGS__ \
-{ \
- LIBC_UNREACHABLE (); \
-}
-
#endif /* !DEFS_H */
diff --git a/jerry-libc/target/darwin/jerry-libc-target.c b/jerry-libc/target/darwin/jerry-libc-target.c
index 921984f9..6e1d2aab 100644
--- a/jerry-libc/target/darwin/jerry-libc-target.c
+++ b/jerry-libc/target/darwin/jerry-libc-target.c
@@ -31,8 +31,6 @@
#include "jerry-libc-defs.h"
-LIBC_UNREACHABLE_STUB_FOR (int raise (int sig_no __attr_unused___))
-
extern long int syscall_0 (long int syscall_no);
extern long int syscall_1 (long int syscall_no, long int arg1);
extern long int syscall_2 (long int syscall_no, long int arg1, long int arg2);
@@ -92,7 +90,7 @@ abort (void)
syscall_1 (SYS_close, (long int) stdout);
syscall_1 (SYS_close, (long int) stderr);
- syscall_2 (SYS_kill, syscall_0 (SYS_getpid), SIGABRT);
+ raise (SIGABRT);
while (true)
{
@@ -101,6 +99,15 @@ abort (void)
} /* abort */
/**
+ * Send a signal to the current process.
+ */
+int __attr_used___
+raise (int sig)
+{
+ return (int) syscall_2 (SYS_kill, syscall_0 (SYS_getpid), sig);
+} /* raise */
+
+/**
* fopen
*
* @return FILE pointer - upon successful completion,
diff --git a/jerry-libc/target/linux/jerry-libc-target.c b/jerry-libc/target/linux/jerry-libc-target.c
index 3d52e3f1..e86f5147 100644
--- a/jerry-libc/target/linux/jerry-libc-target.c
+++ b/jerry-libc/target/linux/jerry-libc-target.c
@@ -31,8 +31,6 @@
#include "jerry-libc-defs.h"
-LIBC_UNREACHABLE_STUB_FOR (int raise (int sig_no __attr_unused___))
-
extern long int syscall_0 (long int syscall_no);
extern long int syscall_1 (long int syscall_no, long int arg1);
extern long int syscall_2 (long int syscall_no, long int arg1, long int arg2);
@@ -92,7 +90,7 @@ abort (void)
syscall_1 (__NR_close, (long int) stdout);
syscall_1 (__NR_close, (long int) stderr);
- syscall_2 (__NR_kill, syscall_0 (__NR_getpid), SIGABRT);
+ raise (SIGABRT);
while (true)
{
@@ -101,6 +99,15 @@ abort (void)
} /* abort */
/**
+ * Send a signal to the current process.
+ */
+int __attr_used___
+raise (int sig)
+{
+ return (int) syscall_2 (__NR_kill, syscall_0 (__NR_getpid), sig);
+} /* raise */
+
+/**
* fopen
*
* @return FILE pointer - upon successful completion,