Skip to content

Commit 1501699

Browse files
Sanggyu Leezherczeg
authored andcommitted
Add setjmp and longjmp functions for tizenrt-artik05x (#1825)
This patch is based on nuttx-stm32f4 implementation. However, I removed vldm and vstm since artik05x has no FPU. It fixes the following error on running some testcases under tests/jerry/fail: System Information: Versionarm_dataabort: Data abort. PC: 0410d9d8 DFAR: 0a00001d DFSR: 00000008 up_assert: Assertion failed at file:armv7-r/arm_dataabort.c line: 111 task: appmain JerryScript-DCO-1.0-Signed-off-by: Sanggyu Lee [email protected]
1 parent f4fbf0b commit 1501699

File tree

4 files changed

+90
-27
lines changed

4 files changed

+90
-27
lines changed

targets/tizenrt-artik05x/apps/jerryscript/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ EXTRA_LIBS += libjerry-core.a libjerry-libm.a
100100
LINKLIBS=$(EXTRA_LIBS)
101101

102102

103-
ASRCS =
103+
ASRCS = setjmp.S
104104
CSRCS =
105105
MAINSRC = jerry_main.c
106106

targets/tizenrt-artik05x/apps/jerryscript/jerry_main.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
#include <stdio.h>
1717
#include <string.h>
1818
#include <stdlib.h>
19-
#include <setjmp.h>
2019

2120
#include "jerryscript.h"
2221
#include "jerryscript-ext/handler.h"
2322
#include "jerryscript-port.h"
2423
#include "jmem.h"
24+
#include "setjmp.h"
2525

2626
#include <apps/shell/tash.h> // To register tash command
2727

@@ -546,28 +546,3 @@ jerry_register_cmd (void) {
546546
tash_cmdlist_install(tash_cmds);
547547
return 0;
548548
}
549-
550-
/**
551-
* Compiler built-in setjmp function.
552-
*
553-
* @return 0 when called the first time
554-
* 1 when returns from a longjmp call
555-
*/
556-
int
557-
setjmp (jmp_buf buf)
558-
{
559-
return __builtin_setjmp (buf);
560-
} /* setjmp */
561-
562-
/**
563-
* Compiler built-in longjmp function.
564-
*
565-
* Note:
566-
* ignores value argument
567-
*/
568-
void
569-
longjmp (jmp_buf buf, int value)
570-
{
571-
/* Must be called with 1. */
572-
__builtin_longjmp (buf, 1);
573-
} /* longjmp */
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
.syntax unified
17+
18+
.macro func _name
19+
.global \_name
20+
.type \_name, %function
21+
\_name:
22+
.endm
23+
.macro endfunc _name
24+
.size \_name, .-\_name
25+
.endm
26+
27+
/**
28+
* setjmp (jmp_buf env)
29+
*
30+
* See also:
31+
* longjmp
32+
*
33+
* @return 0 - if returns from direct call,
34+
* nonzero - if returns after longjmp.
35+
*/
36+
func setjmp
37+
stmia r0!, {r4 - r11, lr}
38+
str sp, [r0], #4
39+
mov r0, #0
40+
bx lr
41+
endfunc setjmp
42+
43+
/**
44+
* longjmp (jmp_buf env, int val)
45+
*
46+
* Note:
47+
* if val is not 0, then it would be returned from setjmp,
48+
* otherwise - 0 would be returned.
49+
*
50+
* See also:
51+
* setjmp
52+
*/
53+
func longjmp
54+
ldmia r0!, {r4 - r11, lr}
55+
ldr sp, [r0]
56+
add r0, r0, #4
57+
mov r0, r1
58+
cmp r0, #0
59+
bne 1f
60+
mov r0, #1
61+
1:
62+
bx lr
63+
endfunc longjmp
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
#ifndef SETJMP_H
16+
#define SETJMP_H
17+
18+
#include <stdint.h>
19+
20+
typedef uint64_t jmp_buf[14];
21+
22+
int setjmp (jmp_buf env);
23+
void longjmp (jmp_buf env, int val);
24+
25+
#endif /* !SETJMP_H */

0 commit comments

Comments
 (0)