summary refs log tree commit diff stats
path: root/lib/posix
diff options
context:
space:
mode:
authorJacek Sieka <arnetheduck@gmail.com>2017-04-13 04:57:10 +0800
committerAndreas Rumpf <rumpf_a@web.de>2017-04-12 22:57:10 +0200
commite512358bc96b7be58bf4f2d5a2c5de75f119138a (patch)
tree6e850d378e87e93d441237042eb63f5f139f82ee /lib/posix
parent926563f0e6c4fe13b8f88f58ac33ccd7826692f4 (diff)
downloadNim-e512358bc96b7be58bf4f2d5a2c5de75f119138a.tar.gz
Linux abi take 3 (#5692)
* avoid generating object fields for imported types
* fix some abi/type issues for linux_amd64
Diffstat (limited to 'lib/posix')
-rw-r--r--lib/posix/epoll.nim6
-rw-r--r--lib/posix/termios.nim26
2 files changed, 23 insertions, 9 deletions
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: "<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
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: "<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