Skip to content

Commit 8559625

Browse files
luoliwoshangclaude
andauthored
refactor(esp): split _exit into separate file for QEMU support (#10)
Move _exit implementation from syscalls.c to syscalls_exit.c to allow easy replacement with semihosting version for QEMU emulator support. This separation enables llgo to compile the semihosting _exit as a separate object file that can override the default implementation when building for QEMU targets. Related to: goplus/llgo#1539 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 175b208 commit 8559625

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

libgloss/riscv/esp/syscalls.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ _getpid (void)
7474
return -1;
7575
}
7676

77-
void
78-
__attribute__ ((noreturn))
79-
_exit (int status)
80-
{
81-
// refer to esp-idf, use an invalid instruction to make it panic
82-
asm("unimp");
83-
84-
for (;;) {
85-
;
86-
}
87-
}
88-
8977
int
9078
_open (const char *file, int flags, int mode)
9179
{

libgloss/riscv/esp/syscalls_exit.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* Default _exit implementation for ESP32 RISC-V chips.
2+
* This is separated from syscalls.c to allow easy replacement
3+
* with semihosting version for QEMU emulator support.
4+
*/
5+
6+
void
7+
__attribute__ ((noreturn))
8+
_exit (int status)
9+
{
10+
// refer to esp-idf, use an invalid instruction to make it panic
11+
asm("unimp");
12+
13+
for (;;) {
14+
;
15+
}
16+
}

0 commit comments

Comments
 (0)