// 标准C库(musl)syscall 实现
#define __asm_syscall(...) do { \__asm__ __volatile__ ( "svc 0" \: "=r"(x0) : __VA_ARGS__ : "memory", "cc"); \return x0; \ //使用 x0传递返回值} while (0)static inline long __syscall0(long n)
{ register long x8 __asm__("x8") = n; //使用 x8传递系统编译编号register long x0 __asm__("x0");__asm_syscall("r"(x8));
}
...
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
{register long x8 __asm__("x8") = n; register long x0 __asm__("x0") = a; //使用x0 ~ x5传递参数register long x1 __asm__("x1") = b;register long x2 __asm__("x2") = c;register long x3 __asm__("x3") = d;register long x4 __asm__("x4") = e;register long x5 __asm__("x5") = f;__asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5));
}
实现代码:
#include <stdio.h>#define GET_TYPE_SIZE(TYPE) ((char *)(&TYPE 1) - (char *) & TYPE)int main(void)
{char a a;short b 0;int c 0;long d 0;long long e 0;float f 0.0;double g 0.0;long double h 0.0;char* i NULL;print…
1.HandlerThread 首先它是Thread,继承自Thread
public class HandlerThread extends Thread {}
2.与Thread不同的地方
在Thread的run方法里面
调用Looper.prepare()创建Looper调用Looper.loop(),可循环处理消息
public class HandlerThread extends…