{-# LINE 1 "libraries/unix/System/Posix/Env/Internal.hsc" #-}
module System.Posix.Env.Internal where



import Foreign
import Foreign.C

getEnvironmentPrim :: IO [Ptr CChar]
getEnvironmentPrim :: IO [CString]
getEnvironmentPrim = do
  Ptr CString
c_environ <- IO (Ptr CString)
getCEnviron
  if Ptr CString
c_environ Ptr CString -> Ptr CString -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr CString
forall a. Ptr a
nullPtr
    then [CString] -> IO [CString]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return []
    else do
      CString -> Ptr CString -> IO [CString]
forall a. (Storable a, Eq a) => a -> Ptr a -> IO [a]
peekArray0 CString
forall a. Ptr a
nullPtr Ptr CString
c_environ

getCEnviron :: IO (Ptr CString)

{-# LINE 25 "libraries/unix/System/Posix/Env/Internal.hsc" #-}
getCEnviron :: IO (Ptr CString)
getCEnviron = Ptr (Ptr CString) -> IO (Ptr CString)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr CString)
c_environ_p

foreign import ccall unsafe "&environ"
   c_environ_p :: Ptr (Ptr CString)

{-# LINE 30 "libraries/unix/System/Posix/Env/Internal.hsc" #-}