summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-15 01:16:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-15 01:16:27 -0400
commit88ef64e566cac30f552982354642feb993d13823 (patch)
tree1cb741cae1fc4597f07006ed73204cd32c0b9cc1
parentbc5c54c987f548505a3877e8a0e460abe0b2a081 (diff)
calculate alignment in a way I can understand
-rw-r--r--Touch.hsc8
1 files changed, 5 insertions, 3 deletions
diff --git a/Touch.hsc b/Touch.hsc
index ad36761c4..f85873125 100644
--- a/Touch.hsc
+++ b/Touch.hsc
@@ -22,12 +22,14 @@ import Foreign.C
#include <sys/stat.h>
#include <fcntl.h>
-#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
-
data TimeSpec = TimeSpec CTime CLong
instance Storable TimeSpec where
- alignment _ = #{alignment struct timespec}
+ -- use the larger alignment of the two types in the struct
+ alignment _ = max sec_alignment nsec_alignment
+ where
+ sec_alignment = alignment $ undefined::CTime
+ nsec_alignment = alignment $ undefined::CLong
sizeOf _ = #{size struct timespec}
peek ptr = do
sec <- #{peek struct timespec, tv_sec} ptr