mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 13:43:22 +00:00
Implement getcpu
syscall and add corresponding test application
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
9b8c6b5aa9
commit
6d42a07e95
24
test/apps/getcpu/getcpu.c
Normal file
24
test/apps/getcpu/getcpu.c
Normal file
@ -0,0 +1,24 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned int cpu, node;
|
||||
|
||||
// Directly test the getcpu syscall because glibc's getcpu() may not
|
||||
// use the getcpu syscall to retrieve CPU info
|
||||
long ret = syscall(SYS_getcpu, &cpu, &node, NULL);
|
||||
if (ret != 0) {
|
||||
perror("syscall getcpu");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("getcpu syscall: cpu = %u, node = %u\n", cpu, node);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user