File: init.lua

package info (click to toggle)
lua-ljsyscall 0.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,732 kB
  • sloc: ansic: 434; sh: 59; makefile: 3
file content (90 lines) | stat: -rw-r--r-- 2,111 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
-- NetBSD init

-- This returns NetBSD types and constants (but no syscalls) under any OS.
-- Also returns util, which is a bit of a problem, as some of these will use syscalls
-- Currently used by kdump example to get NetBSD ktrace types

local require = require

local abi = require "syscall.abi"

local oldos, oldbsd = abi.os, abi.bsd

abi.os = "netbsd"
abi.bsd = true

-- TODO this should be shared with rump! temporarily here
local unchanged = {
  char = true,
  int = true,
  long = true,
  unsigned = true,
  ["unsigned char"] = true,
  ["unsigned int"] = true,
  ["unsigned long"] = true,
  int8_t = true,
  int16_t = true,
  int32_t = true,
  int64_t = true,
  intptr_t = true,
  uint8_t = true,
  uint16_t = true,
  uint32_t = true,
  uint64_t = true,
  uintptr_t = true,
-- same in all OSs at present
  in_port_t = true,
  uid_t = true,
  gid_t = true,
  pid_t = true,
  off_t = true,
  size_t = true,
  ssize_t = true,
  socklen_t = true,
  ["struct in_addr"] = true,
  ["struct in6_addr"] = true,
  ["struct iovec"] = true,
  ["struct iphdr"] = true,
  ["struct udphdr"] = true,
  ["struct ethhdr"] = true,
  ["struct winsize"] = true,
  ["struct {int count; struct iovec iov[?];}"] = true,
}

local function rumpfn(tp)
  if unchanged[tp] then return tp end
  if tp == "void (*)(int, siginfo_t *, void *)" then return "void (*)(int, _netbsd_siginfo_t *, void *)" end
    if tp == "struct {dev_t dev;}" then return "struct {_netbsd_dev_t dev;}" end
  if string.find(tp, "struct") then
    return (string.gsub(tp, "struct (%a)", "struct _netbsd_%1"))
  end
  return "_netbsd_" .. tp
end

abi.rumpfn = rumpfn

abi.types = "netbsd"

local S = {}

require "syscall.netbsd.ffitypes"

local ostypes = require "syscall.netbsd.types"
local c = require "syscall.netbsd.constants"
local bsdtypes = require "syscall.bsd.types"
local types = require "syscall.types".init(c, ostypes, bsdtypes)

c.IOCTL = require("syscall." .. abi.os .. ".ioctl").init(types)
S.c = c
S.types = types
S.t = types.t
S.abi = abi
S.util = require "syscall.util".init(S)

abi.os, abi.bsd = oldos, oldbsd
abi.rumpfn = nil

return S