-#if __STDC__ || c_plusplus
-extern DIR *opendir(const char *);
-extern struct dirent *readdir(DIR *);
-extern void rewinddir(DIR *);
-extern int closedir(DIR *);
-#ifndef _POSIX_SOURCE
-extern long telldir(const DIR *);
-extern void seekdir(DIR *, long);
-extern int scandir(const char *, struct direct ***,
- int (* )(struct direct *), int (* )(void *, void *));
-extern int alphasort(const void *, const void *);
-#endif
-#else
-extern DIR *opendir();
-extern struct dirent *readdir();
-extern void rewinddir();
-extern int closedir();
+#ifndef KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+DIR *opendir __P((const char *));
+struct dirent *readdir __P((DIR *));
+void rewinddir __P((DIR *));
+int closedir __P((DIR *));