+#ifdef __thumb__
+
+/* Avoid use of r7 in asm constraints when producing thumb code,
+ * since it's reserved as frame pointer and might not be supported. */
+#define __ASM____R7__
+#define __asm_syscall(...) do { \
+ __asm__ __volatile__ ( "mov %1,r7 ; mov r7,%2 ; svc 0 ; mov r7,%1" \
+ : "=r"(r0), "=&r"((int){0}) : __VA_ARGS__ : "memory"); \
+ return r0; \
+ } while (0)
+
+#else
+
+#define __ASM____R7__ __asm__("r7")