diff --git a/System/Posix/ByteString/FilePath.hsc b/System/Posix/ByteString/FilePath.hsc
index 2b1382d4495bd72a4663af1cf86a9ad11066912b..5e3692a692f98fc93b736f843d18286839f3d535 100644
--- a/System/Posix/ByteString/FilePath.hsc
+++ b/System/Posix/ByteString/FilePath.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.ByteString.FilePath
diff --git a/System/Posix/Directory/Common.hsc b/System/Posix/Directory/Common.hsc
index ea43c5ca37f331dfc8cd66b6dd38e81a68aab501..4ea8f787dc5b07ce06839cbbfad955760e0f1fc7 100644
--- a/System/Posix/Directory/Common.hsc
+++ b/System/Posix/Directory/Common.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 
diff --git a/System/Posix/DynamicLinker.hsc b/System/Posix/DynamicLinker.hsc
index b15f5075f3b5137c13acd2acbd6131ccdb9f2be1..a2b733642c498ff5394582ea78bf67ed45298363 100644
--- a/System/Posix/DynamicLinker.hsc
+++ b/System/Posix/DynamicLinker.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/DynamicLinker/ByteString.hsc b/System/Posix/DynamicLinker/ByteString.hsc
index b13c8089e1c6dec304c47716587d9425e0fbee48..2111aa2ab72485bd4075470da26405e54aed26fa 100644
--- a/System/Posix/DynamicLinker/ByteString.hsc
+++ b/System/Posix/DynamicLinker/ByteString.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.DynamicLinker.ByteString
diff --git a/System/Posix/DynamicLinker/Common.hsc b/System/Posix/DynamicLinker/Common.hsc
index ff36a28bc88946c4245dd14f59bfe56e8c42caf3..8a44d95569398d639ae762e8bc029f4ab5fdcf10 100644
--- a/System/Posix/DynamicLinker/Common.hsc
+++ b/System/Posix/DynamicLinker/Common.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/DynamicLinker/Module/ByteString.hsc b/System/Posix/DynamicLinker/Module/ByteString.hsc
index 325dae3f0ec9ee120903f3a3badc65638e21fc1d..d5973a8845315d4987e26bad1937948639f4a411 100644
--- a/System/Posix/DynamicLinker/Module/ByteString.hsc
+++ b/System/Posix/DynamicLinker/Module/ByteString.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.DynamicLinker.Module.ByteString
diff --git a/System/Posix/Env/ByteString.hsc b/System/Posix/Env/ByteString.hsc
index 9f69c4cd9cd68f1f121fbd8509da7758dc52b9fa..9217525388cade5ff0911f0a0b6426ef01f97b43 100644
--- a/System/Posix/Env/ByteString.hsc
+++ b/System/Posix/Env/ByteString.hsc
@@ -1,6 +1,10 @@
 #ifdef __GLASGOW_HASKELL__
 {-# LANGUAGE Trustworthy #-}
+#if __GLASGOW_HASKELL__ >= 709
+{-# OPTIONS_GHC -fno-warn-trustworthy-safe #-}
 #endif
+#endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Env.ByteString
diff --git a/System/Posix/Error.hs b/System/Posix/Error.hs
index db4b5a952f247792fa5476ed84f520753c1ba0f4..d3b10a787a254b5d5c8f6daa28fddeb74c033fe2 100644
--- a/System/Posix/Error.hs
+++ b/System/Posix/Error.hs
@@ -1,5 +1,7 @@
 {-# LANGUAGE CPP #-}
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc
index 6aea6a9ead2e1c2cd451795fa1698e56242cb7b7..b18a8df91d1ac58537cc42fe5be49e448c31301e 100644
--- a/System/Posix/Files.hsc
+++ b/System/Posix/Files.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 {-# LANGUAGE CApiFFI #-}
diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc
index 0d19ae8a1fb6cf56019198201555163ed13acdaf..3f26f734ddb088749a109ce27169ad2252148d4d 100644
--- a/System/Posix/Files/ByteString.hsc
+++ b/System/Posix/Files/ByteString.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 {-# LANGUAGE CApiFFI #-}
diff --git a/System/Posix/IO/Common.hsc b/System/Posix/IO/Common.hsc
index 8de0ac0559ba6c3ab2d788f9788b980ed93c2b07..198b3f13b6dd99018df264fd3d2c52e6267969c9 100644
--- a/System/Posix/IO/Common.hsc
+++ b/System/Posix/IO/Common.hsc
@@ -1,7 +1,10 @@
 {-# LANGUAGE NondecreasingIndentation, RecordWildCards #-}
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.IO.Common
diff --git a/System/Posix/Process.hsc b/System/Posix/Process.hsc
index 7d356c1bef1d12383d682cc30c81a68cc919f071..42426a3585222fa9f4ab5f132349c84f785df643 100644
--- a/System/Posix/Process.hsc
+++ b/System/Posix/Process.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Process/ByteString.hsc b/System/Posix/Process/ByteString.hsc
index 294970ec028c4ddf26582e1a63cc06935ae1d148..ee2c9cf364d8f5902f00999a0b489ecd21dfe6e3 100644
--- a/System/Posix/Process/ByteString.hsc
+++ b/System/Posix/Process/ByteString.hsc
@@ -1,6 +1,9 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Process.ByteString
diff --git a/System/Posix/Resource.hsc b/System/Posix/Resource.hsc
index b610f5b10e46c24d121b0246845e8eebb51033ba..4c5ca4883a5c7730db4ebd54423eaa53ad14b2be 100644
--- a/System/Posix/Resource.hsc
+++ b/System/Posix/Resource.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Semaphore.hsc b/System/Posix/Semaphore.hsc
index 541bbdbff012d7ec2ef5d422c85beabde924df78..02959ae996cd4557094cd12300ccb9f6f410cc45 100644
--- a/System/Posix/Semaphore.hsc
+++ b/System/Posix/Semaphore.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Signals/Exts.hsc b/System/Posix/Signals/Exts.hsc
index f539245d4f7a12b68405c7235b0f28053e7917da..a8893404d690a4dbd6a4375161c8c35eb3718b75 100644
--- a/System/Posix/Signals/Exts.hsc
+++ b/System/Posix/Signals/Exts.hsc
@@ -1,6 +1,11 @@
 #ifdef __GLASGOW_HASKELL__
+#if defined(SIGINFO) || defined(SIGWINCH)
 {-# LANGUAGE Trustworthy #-}
+#else
+{-# LANGUAGE Safe #-}
 #endif
+#endif
+
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  System.Posix.Signals.Exts
diff --git a/System/Posix/Terminal.hsc b/System/Posix/Terminal.hsc
index be2d040b77005b655220070e3ea0911f5ed6f3b4..c8335a641150c9b7b4507bb6f46aa709995f28e7 100644
--- a/System/Posix/Terminal.hsc
+++ b/System/Posix/Terminal.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Terminal/ByteString.hsc b/System/Posix/Terminal/ByteString.hsc
index df851f53d5fffe5078462e128d93c48548ba6c43..fd44c85b068bacd1f76d521fde29d04cb373dc40 100644
--- a/System/Posix/Terminal/ByteString.hsc
+++ b/System/Posix/Terminal/ByteString.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Time.hsc b/System/Posix/Time.hsc
index 91b8fadc46d4fe1ae2bc5b2ff9ae45ffefefaa9f..a28050d8c63e528a4181083c88cd51fc9a38a62e 100644
--- a/System/Posix/Time.hsc
+++ b/System/Posix/Time.hsc
@@ -1,4 +1,6 @@
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------
diff --git a/System/Posix/Unistd.hsc b/System/Posix/Unistd.hsc
index afb8c08636475c81b4e52f32a318f055a613bad4..2cbfaa278c6ae152939eedd2142c7107ad6808e7 100644
--- a/System/Posix/Unistd.hsc
+++ b/System/Posix/Unistd.hsc
@@ -1,6 +1,8 @@
 {-# LANGUAGE CApiFFI #-}
 {-# LANGUAGE NondecreasingIndentation #-}
-#ifdef __GLASGOW_HASKELL__
+#if __GLASGOW_HASKELL__ >= 709
+{-# LANGUAGE Safe #-}
+#elif __GLASGOW_HASKELL__ >= 703
 {-# LANGUAGE Trustworthy #-}
 #endif
 -----------------------------------------------------------------------------