macro_rules! syscall_api {
    (
        number = $in_num:expr;
        args = $in_args:expr;
        abi_type = $abitype:ty;
        abi = $abi:expr;
        handlers = { $(($type:ty, $call:expr)),* }
        fast_handlers = { $(($fasttype:ty, $fastcall:expr)),* }
    ) => { ... };
}
Expand description

Define the entire syscall table based on types that implement SyscallApi and SyscallFastApi. Also acts as the match statement for that table, and so takes in the syscall number and args for the syscall we are handling. For example:

struct Foo {...};
impl SyscallApi<...> for Foo {
    ...
}
struct FastFoo {...};
impl SyscallFastApi<...> for Foo {
    ...
}

fn handle(num: NumType, args: ArgType) -> RetType {
    let abi = X86Abi::default();
    syscall_api! {
        // The number of the incoming
        number = num;
        // The incoming args.
        args = args;
        // The type of the ABI we are using.
        abi_type = X86Abi;
        // An instance of that ABI.
        abi = abi;
        // List of handlers.
        handlers = {
            (Foo, |num, foo| {
                ...;
                Ok(FooRet{...})
            }), ...
        }
        // List of handlers that use the Fast API.
        fast_handlers = {
            (FastFoo, |num, foo| {
                ...;
                FastFooRet{...}
            }), ...
        }
    }
}