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
fb9b3eb7
Commit
fb9b3eb7
authored
9 years ago
by
Herbert Valerio Riedel
Browse files
Options
Downloads
Patches
Plain Diff
Use CApiFFI for `ptsname(3)` et al for GHC>=8.0
This improves on
2ddf4b2b
parent
176d73e4
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/Terminal.hsc
+15
-0
15 additions, 0 deletions
System/Posix/Terminal.hsc
System/Posix/Terminal/ByteString.hsc
+16
-1
16 additions, 1 deletion
System/Posix/Terminal/ByteString.hsc
cbits/HsUnix.c
+4
-16
4 additions, 16 deletions
cbits/HsUnix.c
include/HsUnix.h
+0
-6
0 additions, 6 deletions
include/HsUnix.h
with
35 additions
and
23 deletions
System/Posix/Terminal.hsc
+
15
−
0
View file @
fb9b3eb7
...
...
@@ -134,8 +134,14 @@ getSlaveTerminalName (Fd fd) = do
s <- throwErrnoIfNull "getSlaveTerminalName" (c_ptsname fd)
peekFilePath s
# if __GLASGOW_HASKELL__ < 800
-- see comment in cbits/HsUnix.c
foreign import ccall unsafe "__hsunix_ptsname"
c_ptsname :: CInt -> IO CString
# else
foreign import capi unsafe "HsUnix.h ptsname"
c_ptsname :: CInt -> IO CString
# endif
#else
getSlaveTerminalName _ =
ioError (errnoToIOError "getSlaveTerminalName" eNOSYS Nothing Nothing)
...
...
@@ -188,11 +194,20 @@ foreign import ccall unsafe "__hsunix_push_module"
c_push_module :: CInt -> CString -> IO CInt
#ifdef HAVE_PTSNAME
# if __GLASGOW_HASKELL__ < 800
-- see comment in cbits/HsUnix.c
foreign import ccall unsafe "__hsunix_grantpt"
c_grantpt :: CInt -> IO CInt
foreign import ccall unsafe "__hsunix_unlockpt"
c_unlockpt :: CInt -> IO CInt
# else
foreign import capi unsafe "HsUnix.h grantpt"
c_grantpt :: CInt -> IO CInt
foreign import capi unsafe "HsUnix.h unlockpt"
c_unlockpt :: CInt -> IO CInt
# endif
#else
c_grantpt :: CInt -> IO CInt
c_grantpt _ = return (fromIntegral 0)
...
...
This diff is collapsed.
Click to expand it.
System/Posix/Terminal/ByteString.hsc
+
16
−
1
View file @
fb9b3eb7
...
...
@@ -142,8 +142,14 @@ getSlaveTerminalName (Fd fd) = do
s <- throwErrnoIfNull "getSlaveTerminalName" (c_ptsname fd)
peekFilePath s
# if __GLASGOW_HASKELL__ < 800
-- see comment in cbits/HsUnix.c
foreign import ccall unsafe "__hsunix_ptsname"
c_ptsname :: CInt -> IO CString
# else
foreign import capi unsafe "HsUnix.h ptsname"
c_ptsname :: CInt -> IO CString
# endif
#else
getSlaveTerminalName _ =
ioError (errnoToIOError "getSlaveTerminalName" eNOSYS Nothing Nothing)
...
...
@@ -195,12 +201,21 @@ pushModule (Fd fd) name =
foreign import ccall unsafe "__hsunix_push_module"
c_push_module :: CInt -> CString -> IO CInt
#ifdef HAVE_PTSNAME
#if HAVE_PTSNAME
# if __GLASGOW_HASKELL__ < 800
-- see comment in cbits/HsUnix.c
foreign import ccall unsafe "__hsunix_grantpt"
c_grantpt :: CInt -> IO CInt
foreign import ccall unsafe "__hsunix_unlockpt"
c_unlockpt :: CInt -> IO CInt
# else
foreign import capi unsafe "HsUnix.h grantpt"
c_grantpt :: CInt -> IO CInt
foreign import capi unsafe "HsUnix.h unlockpt"
c_unlockpt :: CInt -> IO CInt
# endif
#else
c_grantpt :: CInt -> IO CInt
c_grantpt _ = return (fromIntegral (0::Int))
...
...
This diff is collapsed.
Click to expand it.
cbits/HsUnix.c
+
4
−
16
View file @
fb9b3eb7
...
...
@@ -16,25 +16,14 @@ void *__hsunix_rtldNext (void) {return RTLD_NEXT;}
void
*
__hsunix_rtldDefault
(
void
)
{
return
RTLD_DEFAULT
;}
#endif
#if
def
HAVE_PTSNAME
#if HAVE_PTSNAME
&& (__GLASGOW_HASKELL__ < 800)
// On Linux (and others), <stdlib.h> needs to be included while
// `_XOPEN_SOURCE` is already defined. However, GHCs before GHC 8.0
// didn't do that yet for CApiFFI, so we need this workaround here.
char
*
__hsunix_ptsname
(
int
fd
)
{
return
ptsname
(
fd
);
}
int
__hsunix_grantpt
(
int
fd
)
{
return
grantpt
(
fd
);
}
int
__hsunix_unlockpt
(
int
fd
)
{
return
unlockpt
(
fd
);
}
char
*
__hsunix_ptsname
(
int
fd
)
{
return
ptsname
(
fd
);
}
int
__hsunix_grantpt
(
int
fd
)
{
return
grantpt
(
fd
);
}
int
__hsunix_unlockpt
(
int
fd
)
{
return
unlockpt
(
fd
);
}
#endif
// push a SVR4 STREAMS module; do nothing if STREAMS not available
...
...
@@ -71,7 +60,6 @@ HsInt __hsunix_long_path_size(void) {
#endif
}
/*
* read an entry from the directory stream; opt for the
* re-entrant friendly way of doing this, if available.
...
...
This diff is collapsed.
Click to expand it.
include/HsUnix.h
+
0
−
6
View file @
fb9b3eb7
...
...
@@ -113,12 +113,6 @@ fall back to O_FSYNC, which should be the same */
# define WCOREDUMP(s) 0
#endif
#ifdef HAVE_PTSNAME
char
*
__hsunix_ptsname
(
int
fd
);
int
__hsunix_grantpt
(
int
fd
);
int
__hsunix_unlockpt
(
int
fd
);
#endif
// push a SVR4 STREAMS module; do nothing if STREAMS not available
int
__hsunix_push_module
(
int
fd
,
const
char
*
module
);
...
...
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