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
91b82383
Commit
91b82383
authored
9 years ago
by
Herbert Valerio Riedel
Browse files
Options
Downloads
Patches
Plain Diff
Replace `__hsunix_getpw{nam,uid_r}` wrappers with CApiFFI
parent
3e32e391
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
System/Posix/User.hsc
+6
-3
6 additions, 3 deletions
System/Posix/User.hsc
cbits/HsUnix.c
+0
-18
0 additions, 18 deletions
cbits/HsUnix.c
include/HsUnix.h
+0
-12
0 additions, 12 deletions
include/HsUnix.h
with
6 additions
and
33 deletions
System/Posix/User.hsc
+
6
−
3
View file @
91b82383
...
...
@@ -53,7 +53,6 @@ import Foreign.C
import Foreign.Ptr
import Foreign.Marshal
import Foreign.Storable
import System.Posix.Internals ( CGroup, CPasswd )
#if !defined(HAVE_GETPWNAM_R) || !defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
import Control.Concurrent.MVar ( MVar, newMVar, withMVar )
...
...
@@ -64,6 +63,10 @@ import Control.Exception
import Control.Monad
import System.IO.Error
-- internal types
data {-# CTYPE "struct passwd" #-} CPasswd
data {-# CTYPE "struct group" #-} CGroup
-- -----------------------------------------------------------------------------
-- user environemnt
...
...
@@ -318,7 +321,7 @@ getUserEntryForID uid =
doubleAllocWhileERANGE "getUserEntryForID" "user" pwBufSize unpackUserEntry $
c_getpwuid_r uid ppw
foreign import c
call
unsafe "
__hsunix_
getpwuid_r"
foreign import c
api
unsafe "
HsUnix.h
getpwuid_r"
c_getpwuid_r :: CUid -> Ptr CPasswd ->
CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt
#elif HAVE_GETPWUID
...
...
@@ -345,7 +348,7 @@ getUserEntryForName name =
doubleAllocWhileERANGE "getUserEntryForName" "user" pwBufSize unpackUserEntry $
c_getpwnam_r pstr ppw
foreign import c
call
unsafe "
__hsunix_
getpwnam_r"
foreign import c
api
unsafe "
HsUnix.h
getpwnam_r"
c_getpwnam_r :: CString -> Ptr CPasswd
-> CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt
#elif HAVE_GETPWNAM
...
...
This diff is collapsed.
Click to expand it.
cbits/HsUnix.c
+
0
−
18
View file @
91b82383
...
...
@@ -16,24 +16,6 @@ void *__hsunix_rtldNext (void) {return RTLD_NEXT;}
void
*
__hsunix_rtldDefault
(
void
)
{
return
RTLD_DEFAULT
;}
#endif
#if HAVE_GETPWNAM_R
// getpwnam_r is a macro on some platforms, so we need a wrapper:
int
__hsunix_getpwnam_r
(
const
char
*
name
,
struct
passwd
*
pw
,
char
*
buffer
,
size_t
buflen
,
struct
passwd
**
result
)
{
return
getpwnam_r
(
name
,
pw
,
buffer
,
buflen
,
result
);
}
#endif
#ifdef HAVE_GETPWUID_R
// getpwuid_r is a macro on some platforms, so we need a wrapper:
int
__hsunix_getpwuid_r
(
uid_t
uid
,
struct
passwd
*
pw
,
char
*
buffer
,
size_t
buflen
,
struct
passwd
**
result
)
{
return
getpwuid_r
(
uid
,
pw
,
buffer
,
buflen
,
result
);
}
#endif
#ifdef HAVE_PTSNAME
// On Linux (and others), <stdlib.h> needs to be included while
// `_XOPEN_SOURCE` is already defined. However, GHCs before GHC 8.0
...
...
This diff is collapsed.
Click to expand it.
include/HsUnix.h
+
0
−
12
View file @
91b82383
...
...
@@ -113,18 +113,6 @@ fall back to O_FSYNC, which should be the same */
# define WCOREDUMP(s) 0
#endif
#if HAVE_GETPWNAM_R
// getpwnam_r is a macro on some platforms, so we need a wrapper:
int
__hsunix_getpwnam_r
(
const
char
*
,
struct
passwd
*
,
char
*
,
size_t
,
struct
passwd
**
);
#endif
#ifdef HAVE_GETPWUID_R
// getpwuid_r is a macro on some platforms, so we need a wrapper:
int
__hsunix_getpwuid_r
(
uid_t
,
struct
passwd
*
,
char
*
,
size_t
,
struct
passwd
**
);
#endif
#ifdef HAVE_PTSNAME
char
*
__hsunix_ptsname
(
int
fd
);
int
__hsunix_grantpt
(
int
fd
);
...
...
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