1 // SPDX-License-Identifier: GPL-2.0-only
3 * vdso_test_getcpu.c: Sample code to test parse_vdso.c and vDSO getcpu()
5 * Copyright (c) 2020 Arm Ltd
14 #include "../kselftest.h"
15 #include "parse_vdso.h"
16 #include "vdso_config.h"
17 #include "vdso_call.h"
20 typedef long (*getcpu_t
)(unsigned int *, unsigned int *,
21 struct getcpu_cache
*);
23 int main(int argc
, char **argv
)
25 const char *version
= versions
[VDSO_VERSION
];
26 const char **name
= (const char **)&names
[VDSO_NAMES
];
27 unsigned long sysinfo_ehdr
;
28 unsigned int cpu
, node
;
32 sysinfo_ehdr
= getauxval(AT_SYSINFO_EHDR
);
34 printf("AT_SYSINFO_EHDR is not present!\n");
38 vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR
));
40 get_cpu
= (getcpu_t
)vdso_sym(version
, name
[4]);
42 printf("Could not find %s\n", name
[4]);
46 ret
= VDSO_CALL(get_cpu
, 3, &cpu
, &node
, 0);
48 printf("Running on CPU %u node %u\n", cpu
, node
);
50 printf("%s failed\n", name
[4]);