2020-08-23 08:22:14 -05:00
|
|
|
#include <sys/syscalls.h>
|
2019-09-01 13:49:01 -05:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2020-08-23 08:22:14 -05:00
|
|
|
#define QUAUX(X) #X
|
|
|
|
#define QU(X) QUAUX(X)
|
|
|
|
|
2019-09-01 13:49:01 -05:00
|
|
|
pid_t getpid() {
|
|
|
|
pid_t pid;
|
|
|
|
asm volatile(" \
|
2020-08-23 08:22:14 -05:00
|
|
|
mov $" QU(SYSCALL_GET_PID) ", %%eax; \
|
2019-09-01 13:49:01 -05:00
|
|
|
int $80; \
|
|
|
|
":"=b"(pid));
|
|
|
|
return pid;
|
|
|
|
}
|