Linux abi take 3 (#5692)

* avoid generating object fields for imported types
* fix some abi/type issues for linux_amd64
This commit is contained in:
Jacek Sieka 2017-04-13 04:57:10 +08:00 • committed by Andreas Rumpf
commit e512358bc9
7 changed files with 86 additions and 35 deletions

View file

@ -38,8 +38,10 @@ type
epoll_data* {.importc: "union epoll_data",
header: "<sys/epoll.h>", pure, final.} = object # TODO: This is actually a union.
#thePtr* {.importc: "ptr".}: pointer
fd* {.importc: "fd".}: cint # \
#u32*: uint32
fd* {.importc: "fd".}: cint
when defined(linux) and defined(amd64):
u32: uint32 # this field ensures that binary size is right - it cannot be
# used because its offset is wrong
#u64*: uint64
epoll_event* {.importc: "struct epoll_event", header: "<sys/epoll.h>", pure, final.} = object

View file

@ -18,13 +18,25 @@ type
const
NCCS* = when defined(macosx): 20 else: 32
type
Termios* {.importc: "struct termios", header: "<termios.h>".} = object
c_iflag*: Cflag # input mode flags
c_oflag*: Cflag # output mode flags
c_cflag*: Cflag # control mode flags
c_lflag*: Cflag # local mode flags
c_cc*: array[NCCS, cuchar] # control characters
when defined(linux) and defined(amd64):
type
Termios* {.importc: "struct termios", header: "<termios.h>".} = object
c_iflag*: Cflag # input mode flags
c_oflag*: Cflag # output mode flags
c_cflag*: Cflag # control mode flags
c_lflag*: Cflag # local mode flags
c_line*: cuchar
c_cc*: array[NCCS, cuchar] # control characters
c_ispeed*: Speed
c_ospeed*: Speed
else:
type
Termios* {.importc: "struct termios", header: "<termios.h>".} = object
c_iflag*: Cflag # input mode flags
c_oflag*: Cflag # output mode flags
c_cflag*: Cflag # control mode flags
c_lflag*: Cflag # local mode flags
c_cc*: array[NCCS, cuchar] # control characters
# cc characters