diff options
Diffstat (limited to 'cpukit/libcsupport/src/readdir_r.c')
-rw-r--r-- | cpukit/libcsupport/src/readdir_r.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/readdir_r.c b/cpukit/libcsupport/src/readdir_r.c new file mode 100644 index 0000000000..f1d53ae593 --- /dev/null +++ b/cpukit/libcsupport/src/readdir_r.c @@ -0,0 +1,30 @@ +/* + * readdir_r - reentrant version of readdir() + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef HAVE_READDIR_R + +#include <sys/types.h> +#include <dirent.h> +#include <errno.h> +#include <stdio.h> + +/* + * The RTEMS version of readdir is already thread-safe. + */ + +int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) +{ + *result = readdir(dirp); + if (*result) + *entry = **result; + return *result ? 0 : errno; +} + +#endif |