Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
unix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rinat Striungis
unix
Commits
57d2cb2a
Commit
57d2cb2a
authored
9 years ago
by
Herbert Valerio Riedel
Browse files
Options
Downloads
Patches
Plain Diff
Replace `__hsunix_unsetenv` wrapper with CApiFFI
parent
fb9b3eb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
System/Posix/Env.hsc
+12
-3
12 additions, 3 deletions
System/Posix/Env.hsc
System/Posix/Env/ByteString.hsc
+12
-3
12 additions, 3 deletions
System/Posix/Env/ByteString.hsc
cbits/HsUnix.c
+0
-12
0 additions, 12 deletions
cbits/HsUnix.c
include/HsUnix.h
+0
-2
0 additions, 2 deletions
include/HsUnix.h
with
24 additions
and
20 deletions
System/Posix/Env.hsc
+
12
−
3
View file @
57d2cb2a
{-# LANGUAGE CApiFFI #-}
#if __GLASGOW_HASKELL__ >= 709
#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
{-# LANGUAGE Safe #-}
#else
#else
...
@@ -116,13 +117,21 @@ setEnvironment env = do
...
@@ -116,13 +117,21 @@ setEnvironment env = do
-- from the environment.
-- from the environment.
unsetEnv :: String -> IO ()
unsetEnv :: String -> IO ()
#if
def
HAVE_UNSETENV
#if HAVE_UNSETENV
# if !UNSETENV_RETURNS_VOID
unsetEnv name = withFilePath name $ \ s ->
unsetEnv name = withFilePath name $ \ s ->
throwErrnoIfMinus1_ "unsetenv" (c_unsetenv s)
throwErrnoIfMinus1_ "unsetenv" (c_unsetenv s)
foreign import ccall unsafe "__hsunix_unsetenv"
-- POSIX.1-2001 compliant unsetenv(3)
foreign import capi unsafe "HsUnix.h unsetenv"
c_unsetenv :: CString -> IO CInt
c_unsetenv :: CString -> IO CInt
# else
unsetEnv name = withFilePath name c_unsetenv
-- pre-POSIX unsetenv(3) returning @void@
foreign import capi unsafe "HsUnix.h unsetenv"
c_unsetenv :: CString -> IO ()
# endif
#else
#else
unsetEnv name = putEnv (name ++ "=")
unsetEnv name = putEnv (name ++ "=")
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
System/Posix/Env/ByteString.hsc
+
12
−
3
View file @
57d2cb2a
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE Trustworthy #-}
#if __GLASGOW_HASKELL__ >= 709
#if __GLASGOW_HASKELL__ >= 709
{-# OPTIONS_GHC -fno-warn-trustworthy-safe #-}
{-# OPTIONS_GHC -fno-warn-trustworthy-safe #-}
...
@@ -98,13 +99,21 @@ getEnvironment = do
...
@@ -98,13 +99,21 @@ getEnvironment = do
-- from the environment.
-- from the environment.
unsetEnv :: ByteString -> IO ()
unsetEnv :: ByteString -> IO ()
#if
def
HAVE_UNSETENV
#if HAVE_UNSETENV
# if !UNSETENV_RETURNS_VOID
unsetEnv name = B.useAsCString name $ \ s ->
unsetEnv name = B.useAsCString name $ \ s ->
throwErrnoIfMinus1_ "unsetenv" (c_unsetenv s)
throwErrnoIfMinus1_ "unsetenv" (c_unsetenv s)
foreign import ccall unsafe "__hsunix_unsetenv"
-- POSIX.1-2001 compliant unsetenv(3)
foreign import capi unsafe "HsUnix.h unsetenv"
c_unsetenv :: CString -> IO CInt
c_unsetenv :: CString -> IO CInt
# else
unsetEnv name = B.useAsCString name c_unsetenv
-- pre-POSIX unsetenv(3) returning @void@
foreign import capi unsafe "HsUnix.h unsetenv"
c_unsetenv :: CString -> IO ()
# endif
#else
#else
unsetEnv name = putEnv (name ++ "=")
unsetEnv name = putEnv (name ++ "=")
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
cbits/HsUnix.c
+
0
−
12
View file @
57d2cb2a
...
@@ -36,18 +36,6 @@ int __hsunix_push_module(int fd, const char *module)
...
@@ -36,18 +36,6 @@ int __hsunix_push_module(int fd, const char *module)
#endif
#endif
}
}
#ifdef HAVE_UNSETENV
int
__hsunix_unsetenv
(
const
char
*
name
)
{
#ifdef UNSETENV_RETURNS_VOID
unsetenv
(
name
);
return
0
;
#else
return
unsetenv
(
name
);
#endif
}
#endif
/* A size that will contain many path names, but not necessarily all
/* A size that will contain many path names, but not necessarily all
* (PATH_MAX is not defined on systems with unlimited path length,
* (PATH_MAX is not defined on systems with unlimited path length,
* e.g. the Hurd).
* e.g. the Hurd).
...
...
This diff is collapsed.
Click to expand it.
include/HsUnix.h
+
0
−
2
View file @
57d2cb2a
...
@@ -116,8 +116,6 @@ fall back to O_FSYNC, which should be the same */
...
@@ -116,8 +116,6 @@ fall back to O_FSYNC, which should be the same */
// push a SVR4 STREAMS module; do nothing if STREAMS not available
// push a SVR4 STREAMS module; do nothing if STREAMS not available
int
__hsunix_push_module
(
int
fd
,
const
char
*
module
);
int
__hsunix_push_module
(
int
fd
,
const
char
*
module
);
int
__hsunix_unsetenv
(
const
char
*
name
);
/* A size that will contain many path names, but not necessarily all
/* A size that will contain many path names, but not necessarily all
* (PATH_MAX is not defined on systems with unlimited path length,
* (PATH_MAX is not defined on systems with unlimited path length,
* e.g. the Hurd).
* e.g. the Hurd).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment