PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/scripts/getsyscalls

http://github.com/Eelis/geordi
Shell | 22 lines | 20 code | 1 blank | 1 comment | 0 complexity | a301b206d8e3143522615e01a26a1635 MD5 | raw file
 1#!/bin/sh
 2set -e
 3
 4echo "module SysCalls where"
 5echo "import Foreign.C"
 6echo
 7echo "#include <asm/unistd.h>"
 8echo
 9echo "data SysCall = "
10echo "#include <asm/unistd.h>" | g++ -E -dM - | sed -nr 's/^#define __NR_(\w*) .*$/  SYS_\1 |/p' | sort | uniq
11echo "  UnknownSysCall CLong"
12echo "    deriving (Eq, Show)"
13echo
14echo "fromNumber :: CLong -> SysCall"
15echo "fromNumber x = case x of"
16echo "#include <asm/unistd.h>" | g++ -E -dM - | sed -nr 's/^#define __NR_(\w*) .*$/  (#const __NR_\1) -> SYS_\1/p' | sort | uniq
17echo "  _ -> UnknownSysCall x"
18echo
19echo "toNumber :: SysCall -> CLong"
20echo "toNumber x = case x of"
21echo "#include <asm/unistd.h>" | g++ -E -dM - | sed -nr 's/^#define __NR_(\w*) .*$/  SYS_\1 -> (#const __NR_\1)/p' | sort | uniq
22echo "  UnknownSysCall y -> y"