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
b54bd5fc
Commit
b54bd5fc
authored
9 years ago
by
Herbert Valerio Riedel
Browse files
Options
Downloads
Patches
Plain Diff
Merge dirUtils.c into HsUnix.c
parent
72774b03
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
cbits/HsUnix.c
+63
-1
63 additions, 1 deletion
cbits/HsUnix.c
cbits/dirUtils.c
+0
-72
0 additions, 72 deletions
cbits/dirUtils.c
unix.cabal
+0
-1
0 additions, 1 deletion
unix.cabal
with
63 additions
and
74 deletions
cbits/HsUnix.c
+
63
−
1
View file @
b54bd5fc
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include
"HsUnix.h"
#include
"HsUnix.h"
#ifdef HAVE_RTLDNEXT
#ifdef HAVE_RTLDNEXT
void
*
__hsunix_rtldNext
(
void
)
{
return
RTLD_NEXT
;}
void
*
__hsunix_rtldNext
(
void
)
{
return
RTLD_NEXT
;}
#endif
#endif
#ifdef HAVE_RTLDDEFAULT
#ifdef HAVE_RTLDDEFAULT
...
@@ -71,3 +71,65 @@ HsInt __hsunix_long_path_size(void) {
...
@@ -71,3 +71,65 @@ HsInt __hsunix_long_path_size(void) {
#endif
#endif
}
}
/*
* read an entry from the directory stream; opt for the
* re-entrant friendly way of doing this, if available.
*/
int
__hscore_readdir
(
DIR
*
dirPtr
,
struct
dirent
**
pDirEnt
)
{
#if HAVE_READDIR_R
struct
dirent
*
p
;
int
res
;
static
unsigned
int
nm_max
=
(
unsigned
int
)
-
1
;
if
(
pDirEnt
==
NULL
)
{
return
-
1
;
}
if
(
nm_max
==
(
unsigned
int
)
-
1
)
{
#ifdef NAME_MAX
nm_max
=
NAME_MAX
+
1
;
#else
nm_max
=
pathconf
(
"."
,
_PC_NAME_MAX
);
if
(
nm_max
==
-
1
)
{
nm_max
=
255
;
}
nm_max
++
;
#endif
}
p
=
(
struct
dirent
*
)
malloc
(
sizeof
(
struct
dirent
)
+
nm_max
);
if
(
p
==
NULL
)
return
-
1
;
res
=
readdir_r
(
dirPtr
,
p
,
pDirEnt
);
if
(
res
!=
0
)
{
*
pDirEnt
=
NULL
;
free
(
p
);
}
else
if
(
*
pDirEnt
==
NULL
)
{
// end of stream
free
(
p
);
}
return
res
;
#else
if
(
pDirEnt
==
NULL
)
{
return
-
1
;
}
*
pDirEnt
=
readdir
(
dirPtr
);
if
(
*
pDirEnt
==
NULL
)
{
return
-
1
;
}
else
{
return
0
;
}
#endif
}
char
*
__hscore_d_name
(
struct
dirent
*
d
)
{
return
(
d
->
d_name
);
}
void
__hscore_free_dirent
(
struct
dirent
*
dEnt
)
{
#if HAVE_READDIR_R
free
(
dEnt
);
#endif
}
This diff is collapsed.
Click to expand it.
cbits/dirUtils.c
deleted
100644 → 0
+
0
−
72
View file @
72774b03
/*
* (c) The University of Glasgow 2002
*
* Directory Runtime Support
*/
#include
"HsUnix.h"
/*
* read an entry from the directory stream; opt for the
* re-entrant friendly way of doing this, if available.
*/
int
__hscore_readdir
(
DIR
*
dirPtr
,
struct
dirent
**
pDirEnt
)
{
#if HAVE_READDIR_R
struct
dirent
*
p
;
int
res
;
static
unsigned
int
nm_max
=
(
unsigned
int
)
-
1
;
if
(
pDirEnt
==
NULL
)
{
return
-
1
;
}
if
(
nm_max
==
(
unsigned
int
)
-
1
)
{
#ifdef NAME_MAX
nm_max
=
NAME_MAX
+
1
;
#else
nm_max
=
pathconf
(
"."
,
_PC_NAME_MAX
);
if
(
nm_max
==
-
1
)
{
nm_max
=
255
;
}
nm_max
++
;
#endif
}
p
=
(
struct
dirent
*
)
malloc
(
sizeof
(
struct
dirent
)
+
nm_max
);
if
(
p
==
NULL
)
return
-
1
;
res
=
readdir_r
(
dirPtr
,
p
,
pDirEnt
);
if
(
res
!=
0
)
{
*
pDirEnt
=
NULL
;
free
(
p
);
}
else
if
(
*
pDirEnt
==
NULL
)
{
// end of stream
free
(
p
);
}
return
res
;
#else
if
(
pDirEnt
==
NULL
)
{
return
-
1
;
}
*
pDirEnt
=
readdir
(
dirPtr
);
if
(
*
pDirEnt
==
NULL
)
{
return
-
1
;
}
else
{
return
0
;
}
#endif
}
char
*
__hscore_d_name
(
struct
dirent
*
d
)
{
return
(
d
->
d_name
);
}
void
__hscore_free_dirent
(
struct
dirent
*
dEnt
)
{
#if HAVE_READDIR_R
free
(
dEnt
);
#endif
}
This diff is collapsed.
Click to expand it.
unix.cabal
+
0
−
1
View file @
b54bd5fc
...
@@ -131,5 +131,4 @@ library
...
@@ -131,5 +131,4 @@ library
execvpe.h
execvpe.h
c-sources:
c-sources:
cbits/HsUnix.c
cbits/HsUnix.c
cbits/dirUtils.c
cbits/execvpe.c
cbits/execvpe.c
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