Skip to content

Commit

Permalink
Merge pull request #51 from hammond/sysconf-errno
Browse files Browse the repository at this point in the history
Reset 'errno' after 'sysconf()'
  • Loading branch information
pdimov authored Jun 5, 2018
2 parents 37b324c + 1e8de36 commit 5a93351
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,18 +2113,21 @@ namespace
inline int readdir_r_simulator(DIR * dirp, struct dirent * entry,
struct dirent ** result)// *result set to 0 on end of directory
{
errno = 0;

# if !defined(__CYGWIN__)\
&& defined(_POSIX_THREAD_SAFE_FUNCTIONS)\
&& defined(_SC_THREAD_SAFE_FUNCTIONS)\
&& (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0)\
&& (!defined(__hpux) || defined(_REENTRANT)) \
&& (!defined(_AIX) || defined(__THREAD_SAFE))

errno = 0;

if (::sysconf(_SC_THREAD_SAFE_FUNCTIONS)>= 0)
{ return ::readdir_r(dirp, entry, result); }
# endif

errno = 0;

struct dirent * p;
*result = 0;
if ((p = ::readdir(dirp))== 0)
Expand Down

0 comments on commit 5a93351

Please sign in to comment.