Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cbits/HsUnix.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,30 @@ int __hsunix_push_module(int fd, const char *module)
#endif
}

/*
* GNU glibc 2.23 and later deprecate `readdir_r` in favour of plain old
* `readdir` which in some upcoming POSIX standard is going to required to be
* re-entrant.
* Eventually we want to drop `readder_r` all together, but want to be
* compatible with older unixen which may not have a re-entrant `readdir`.
* Solution is to make systems with *known* re-entrant `readir` use that and use
* `readdir_r` whereever we have it and don't *know* that `readdir` is
* re-entrant.
*/

#if defined (__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 23)
#define USE_READDIR_R 0
#else
#define USE_READDIR_R 1
#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
#if HAVE_READDIR_R && USE_READDIR_R
struct dirent* p;
int res;
static unsigned int nm_max = (unsigned int)-1;
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for [`unix` package](http://hackage.haskell.org/package/unix)

## 2.7.2.1 *Sep 2016*

* Don't use `readdir_r` if its deprecated.

## 2.7.2.0 *Apr 2016*

* Bundled with GHC 8.0.1
Expand Down