From e512358bc96b7be58bf4f2d5a2c5de75f119138a Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Thu, 13 Apr 2017 04:57:10 +0800 Subject: Linux abi take 3 (#5692) * avoid generating object fields for imported types * fix some abi/type issues for linux_amd64 --- lib/posix/epoll.nim | 6 ++++-- lib/posix/termios.nim | 26 +++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'lib/posix') diff --git a/lib/posix/epoll.nim b/lib/posix/epoll.nim index 276dd812d..86b977576 100644 --- a/lib/posix/epoll.nim +++ b/lib/posix/epoll.nim @@ -38,8 +38,10 @@ type epoll_data* {.importc: "union epoll_data", header: "", 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: "", pure, final.} = object diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index af62bdb3d..21b21aefb 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -18,13 +18,25 @@ type const NCCS* = when defined(macosx): 20 else: 32 -type - Termios* {.importc: "struct termios", header: "".} = 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: "".} = 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: "".} = 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 -- cgit 1.4.1-2-gfad0