Skip to content

[libc][thumb] support syscalls from thumb mode #96558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions libc/src/__support/OSUtil/linux/arm/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@
#include "src/__support/common.h"

#ifdef __thumb__
#error "The arm syscall implementation does not yet support thumb flavor."
#endif // __thumb__
#define R7 long r7 = number
#define SYSCALL_INSTR(input_constraint) \
int temp; \
LIBC_INLINE_ASM(R"(
mov %[temp], r7
mov r7, %2
svc #0
mov r7, %[temp]
)" \
: "=r"(r0), [temp] "=&r"(temp) \
: input_constraint \
: "memory", "cc")
#else
#define R7 register long r7 asm("r7") = number
#define SYSCALL_INSTR(input_constraint) \
LIBC_INLINE_ASM("svc 0" : "=r"(r0) : input_constraint : "memory", "cc")
#endif

#define REGISTER_DECL_0 \
register long r7 __asm__("r7") = number; \
R7; \
register long r0 __asm__("r0");
#define REGISTER_DECL_1 \
register long r7 __asm__("r7") = number; \
R7; \
register long r0 __asm__("r0") = arg1;
#define REGISTER_DECL_2 \
REGISTER_DECL_1 \
Expand All @@ -45,9 +60,6 @@
#define REGISTER_CONSTRAINT_5 REGISTER_CONSTRAINT_4, "r"(r4)
#define REGISTER_CONSTRAINT_6 REGISTER_CONSTRAINT_5, "r"(r5)

#define SYSCALL_INSTR(input_constraint) \
LIBC_INLINE_ASM("svc 0" : "=r"(r0) : input_constraint : "memory", "cc")

namespace LIBC_NAMESPACE {

LIBC_INLINE long syscall_impl(long number) {
Expand Down
Loading