diff --git a/System/Posix.hs b/System/Posix.hs
index 40fb85d194854b3a9963ca96bdd2d0cfa1eca70a..ad51792b6376157120e738bc0e239f04dc15b994 100644
--- a/System/Posix.hs
+++ b/System/Posix.hs
@@ -1,3 +1,6 @@
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Safe #-}
+#endif
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix
diff --git a/System/Posix/Directory.hsc b/System/Posix/Directory.hsc
index 47fd91f01010f759ac75def622fd5f2296392203..48e73907a16c16569fcaeb723d583f6510383984 100644
--- a/System/Posix/Directory.hsc
+++ b/System/Posix/Directory.hsc
@@ -1,8 +1,8 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Files
diff --git a/System/Posix/DynamicLinker/Module.hsc b/System/Posix/DynamicLinker/Module.hsc
index 15d19dfe1e36b1eaf071d685e26cc7e71c774ec3..c678fed0e7e17e15206b3b3e4eb8dcda8d4d47ee 100644
--- a/System/Posix/DynamicLinker/Module.hsc
+++ b/System/Posix/DynamicLinker/Module.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.DynamicLinker.Module
diff --git a/System/Posix/DynamicLinker/Prim.hsc b/System/Posix/DynamicLinker/Prim.hsc
index d285ff60317f2cc32686e0acdbf7bca65ffda4d5..2b112615992162c73e2b9c2a9611a2ee31f606d7 100644
--- a/System/Posix/DynamicLinker/Prim.hsc
+++ b/System/Posix/DynamicLinker/Prim.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.DynamicLinker.Prim
diff --git a/System/Posix/Env.hsc b/System/Posix/Env.hsc
index ba24c29a828c6fe1f915b7cbb8286d9344ea1126..374d0a88cb6550518efe176fe232bc8498473919 100644
--- a/System/Posix/Env.hsc
+++ b/System/Posix/Env.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Env
diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc
index 0831bc46fb73af0dc4b363df07ee8dd9b7a94cb8..56063889ea0c45389b8dfe3c6cf26e53584d748a 100644
--- a/System/Posix/Files.hsc
+++ b/System/Posix/Files.hsc
@@ -1,8 +1,8 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Files
diff --git a/System/Posix/IO.hsc b/System/Posix/IO.hsc
index 31ee04bd98ce2001a2957cc7e9f33b55f305f70e..c1a2d0cab3ffd3aea2947e4624de3e1acb73a03c 100644
--- a/System/Posix/IO.hsc
+++ b/System/Posix/IO.hsc
@@ -1,9 +1,9 @@
-#if __GLASGOW_HASKELL__ >= 701
-{-# LANGUAGE Trustworthy #-}
-#endif
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
 {-# OPTIONS_GHC -XRecordWildCards #-}
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Trustworthy #-}
+#endif
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.IO
diff --git a/System/Posix/Process.hsc b/System/Posix/Process.hsc
index 87277ae4e00582f43956ec49854590c38f32a4a8..99c3962122cb3ebedc5a6487e354cb77460caf87 100644
--- a/System/Posix/Process.hsc
+++ b/System/Posix/Process.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Process
diff --git a/System/Posix/Resource.hsc b/System/Posix/Resource.hsc
index 84aa00923f2b5154451e63cb15d6c998c4f0e0e6..665199880fba6b13aa72b74a7626cc506a9a817e 100644
--- a/System/Posix/Resource.hsc
+++ b/System/Posix/Resource.hsc
@@ -1,8 +1,8 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -w #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# OPTIONS_GHC -w #-}
 -- The above warning supression flag is a temporary kludge.
 -- While working on this module you are encouraged to remove it and fix
 -- any warnings in the module. See
diff --git a/System/Posix/Semaphore.hsc b/System/Posix/Semaphore.hsc
index 900f7da8b2c8b015870b57236a6a597c70e344fa..9ff39f4f450f79bc82246b0e4219e9be66cd174a 100644
--- a/System/Posix/Semaphore.hsc
+++ b/System/Posix/Semaphore.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Semaphore
diff --git a/System/Posix/SharedMem.hsc b/System/Posix/SharedMem.hsc
index 81febd3e0bc0481268d7532192c033daeb918856..8e515684ed48aa33337c5f3cb80b4369fba1bf81 100644
--- a/System/Posix/SharedMem.hsc
+++ b/System/Posix/SharedMem.hsc
@@ -1,8 +1,8 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.SharedMem
diff --git a/System/Posix/Signals.hsc b/System/Posix/Signals.hsc
index 13e1e0523867ed05d5c542a02e03a8050012d243..a284d4805a94a36d63b896976bf7a044437e33b2 100644
--- a/System/Posix/Signals.hsc
+++ b/System/Posix/Signals.hsc
@@ -1,8 +1,8 @@
+{-# LANGUAGE DeriveDataTypeable,PatternGuards #-}
+{-# OPTIONS_GHC -fno-cse #-} -- global variables
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE DeriveDataTypeable,PatternGuards #-}
-{-# OPTIONS_GHC -fno-cse #-} -- global variables
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Signals
diff --git a/System/Posix/Signals/Exts.hsc b/System/Posix/Signals/Exts.hsc
index 1ff404917ee81ede2652c78f1f688583d2b13967..4b466f1f9679db9faeeeda14531d1d4dd59aa797 100644
--- a/System/Posix/Signals/Exts.hsc
+++ b/System/Posix/Signals/Exts.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Signals.Exts
diff --git a/System/Posix/Temp.hsc b/System/Posix/Temp.hsc
index b6af83eaa4abdd3137c44366183527842b7c6acb..a55d5fea17aa262ed26c07517994abb8e6640e80 100644
--- a/System/Posix/Temp.hsc
+++ b/System/Posix/Temp.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Temp
diff --git a/System/Posix/Terminal.hsc b/System/Posix/Terminal.hsc
index 54f15895039a5933613be5fe4e3fa2a140235e39..368558960d7a0c133aacd0132a558f0096ecfa42 100644
--- a/System/Posix/Terminal.hsc
+++ b/System/Posix/Terminal.hsc
@@ -1,5 +1,8 @@
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
+#if __GLASGOW_HASKELL__ >= 701
+{-# LANGUAGE Trustworthy #-}
+#endif
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Terminal
diff --git a/System/Posix/Time.hsc b/System/Posix/Time.hsc
index 9de3937e3422c12756fd1f68adfb5b8a21a2a9fe..641b955cc9de745d76f7b998eca330a24992f64a 100644
--- a/System/Posix/Time.hsc
+++ b/System/Posix/Time.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Time
diff --git a/System/Posix/Unistd.hsc b/System/Posix/Unistd.hsc
index 8fbb525f484787834bffde3698ba6261df7a5887..7312daea69c1e33b7f242f0a5f11ffd28029cd6d 100644
--- a/System/Posix/Unistd.hsc
+++ b/System/Posix/Unistd.hsc
@@ -1,8 +1,8 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-binds #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-binds #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Unistd
diff --git a/System/Posix/User.hsc b/System/Posix/User.hsc
index f1d4fc4cef03315a043edfe7f34d2aaf543582f6..71d2ea0e184eddb134ff7a4f270d6221d85794d7 100644
--- a/System/Posix/User.hsc
+++ b/System/Posix/User.hsc
@@ -1,7 +1,7 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
 #if __GLASGOW_HASKELL__ >= 701
 {-# LANGUAGE Trustworthy #-}
 #endif
-{-# LANGUAGE ForeignFunctionInterface #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.User