How to implement incompatible pointer type in dispatch table

Legion Daeth Source

So I'm adding functions to XV6's dispatch table and I noticed that if I need to add a function that doesn't match the signature of the table I get returned an initialization from incompatible pointer type error from the compiler. Since this is C I can't use function overloading so the only solution I can think of is to write a dispatch table for every type of function which seems too complicated.

TL;DR

Need to add

110 extern uint sys_getuid(void);
111 extern uint sys_getgid(void);
112 extern uint sys_getppid(void);
114 extern int sys_setuid(uint);
115 extern int sys_setgid(uint);

to

118 static int (*syscalls[])(void) = {
119 [SYS_fork]    sys_fork, //#1
120 [SYS_exit]    sys_exit,
121 [SYS_wait]    sys_wait,
...
150 [SYS_setuid]    sys_setuid, //#27
151 [SYS_setgid]    sys_setgid, //#28
152
153 #endif
154 };

but these functions do not return int and accept void arguments. Besides coding multiple tables, what is an elegant solution to this?

coperating-systemxv6

Answers

comments powered by Disqus