How to use _syscall3 correctly

Our embedded Linux has the ability to establish proximity to the processor, however, ucLibc does not support proximity functions {set / get}.

Therefore, we are trying to use the syscall interface to call into the kernel. We wrote:

#include <sys/syscall.h> _syscall3 (int, sched_setaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr) _syscall3 (int, sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr) 

Having compiled it using regular gcc (x86, Fedora Linux, gcc 4.1.2 Redhat), we get:

 bind.c:114: error: expected declaration specifiers or รข...รข before รขsched_setaffinityรข bind.c:114: error: expected declaration specifiers or รข...รข before รขpid_tรข bind.c:114: error: expected declaration specifiers or รข...รข before รขpidรข bind.c:114: error: expected declaration specifiers or รข...รข before รขlenรข bind.c:114: error: expected declaration specifiers or รข...รข before รขuser_mask_ptrรข 

How do you use _syscall3 correctly to make this work?

Thanks.

+4
source share
1 answer

You should use the syscall shell:

 syscall(__NR_sched_setaffinity, pid, len, user_mask_ptr); 
+3
source

All Articles