File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -36,13 +36,30 @@ int __hsunix_push_module(int fd, const char *module)
3636#endif
3737}
3838
39+ /*
40+ * GNU glibc 2.23 and later deprecate `readdir_r` in favour of plain old
41+ * `readdir` which in some upcoming POSIX standard is going to required to be
42+ * re-entrant.
43+ * Eventually we want to drop `readder_r` all together, but want to be
44+ * compatible with older unixen which may not have a re-entrant `readdir`.
45+ * Solution is to make systems with *known* re-entrant `readir` use that and use
46+ * `readdir_r` whereever we have it and don't *know* that `readdir` is
47+ * re-entrant.
48+ */
49+
50+ #if defined (__GLIBC__ ) && (__GLIBC__ >= 2 ) && (__GLIBC_MINOR__ >= 23 )
51+ #define USE_READDIR_R 0
52+ #else
53+ #define USE_READDIR_R 1
54+ #endif
55+
3956/*
4057 * read an entry from the directory stream; opt for the
4158 * re-entrant friendly way of doing this, if available.
4259 */
4360int __hscore_readdir ( DIR * dirPtr , struct dirent * * pDirEnt )
4461{
45- #if HAVE_READDIR_R
62+ #if HAVE_READDIR_R && USE_READDIR_R
4663 struct dirent * p ;
4764 int res ;
4865 static unsigned int nm_max = (unsigned int )-1 ;
Original file line number Diff line number Diff line change 11# Changelog for [ ` unix ` package] ( http://hackage.haskell.org/package/unix )
22
3+ ## 2.7.2.1 * Sep 2016*
4+
5+ * Don't use ` readdir_r ` if its deprecated.
6+
37## 2.7.2.0 * Apr 2016*
48
59 * Bundled with GHC 8.0.1
You can’t perform that action at this time.
0 commit comments