diff options
author | 2012-03-22 04:11:53 +0000 | |
---|---|---|
committer | 2012-03-22 04:11:53 +0000 | |
commit | e55576ca586feb852d7d9044bd637f0e55131029 (patch) | |
tree | 7d257fd2705586c2ba8713c384afea5af8f4954e | |
parent | Hide behind #if 0 the sched_*() functions that we don't have yet (diff) | |
download | wireguard-openbsd-e55576ca586feb852d7d9044bd637f0e55131029.tar.xz wireguard-openbsd-e55576ca586feb852d7d9044bd637f0e55131029.zip |
Make DIR a private type within libc, give it the same underlying
typedef regardless of __BSD_VISIBLE, and eliminate the dirfd() macro.
ok guenther@
-rw-r--r-- | include/dirent.h | 29 | ||||
-rw-r--r-- | lib/libc/gen/dirfd.c | 3 | ||||
-rw-r--r-- | lib/libc/gen/readdir.c | 3 | ||||
-rw-r--r-- | lib/libc/gen/readdir_r.c | 3 | ||||
-rw-r--r-- | lib/libc/gen/scandir.c | 3 | ||||
-rw-r--r-- | lib/libc/gen/telldir.h | 16 |
6 files changed, 27 insertions, 30 deletions
diff --git a/include/dirent.h b/include/dirent.h index 0d5884cb3cb..bebed33dc9a 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dirent.h,v 1.26 2012/03/22 01:44:19 guenther Exp $ */ +/* $OpenBSD: dirent.h,v 1.27 2012/03/22 04:11:53 matthew Exp $ */ /* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */ /*- @@ -54,30 +54,13 @@ #define d_ino d_fileno /* backward compatibility */ #endif -#if __BSD_VISIBLE || __XPG_VISIBLE > 600 -#define dirfd(dirp) ((dirp)->dd_fd) -#endif +typedef struct _dirdesc DIR; #if __BSD_VISIBLE /* definitions for library routines operating on directories. */ #define DIRBLKSIZ 1024 -struct _telldir; -/* structure describing an open directory. */ -typedef struct _dirdesc { - int dd_fd; /* file descriptor associated with directory */ - long dd_loc; /* offset in current buffer */ - long dd_size; /* amount of data returned by getdirentries */ - char *dd_buf; /* data buffer */ - int dd_len; /* size of data buffer */ - off_t dd_seek; /* magic cookie returned by getdirentries */ - off_t dd_rewind; /* magic cookie for rewinding */ - int dd_unused; /* was flags for readdir */ - struct _telldir *dd_td; /* telldir position recording */ - void *dd_lock; /* mutex to protect struct */ -} DIR; - #ifndef NULL #ifdef __GNUG__ #define NULL __null @@ -88,11 +71,7 @@ typedef struct _dirdesc { #endif /* __GNUG__ */ #endif /* !NULL */ -#else /* !__BSD_VISIBLE */ - -typedef void * DIR; - -#endif /* !__BSD_VISIBLE */ +#endif /* __BSD_VISIBLE */ #ifndef _KERNEL __BEGIN_DECLS @@ -121,7 +100,7 @@ int scandir(const char *, struct dirent ***, int (*)(struct dirent *), int alphasort(const struct dirent **, const struct dirent **); #endif #if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE > 600 -int (dirfd)(DIR *); +int dirfd(DIR *); #endif __END_DECLS diff --git a/lib/libc/gen/dirfd.c b/lib/libc/gen/dirfd.c index 5e3123c0fdc..3188a7cf5a7 100644 --- a/lib/libc/gen/dirfd.c +++ b/lib/libc/gen/dirfd.c @@ -4,9 +4,10 @@ */ #include <dirent.h> +#include "telldir.h" int -(dirfd)(DIR *dirp) +dirfd(DIR *dirp) { return (dirp->dd_fd); } diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index bbf178b0c42..eb9216219cb 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readdir.c,v 1.16 2012/02/04 23:02:40 guenther Exp $ */ +/* $OpenBSD: readdir.c,v 1.17 2012/03/22 04:11:53 matthew Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -30,6 +30,7 @@ #include <dirent.h> #include <errno.h> +#include "telldir.h" #include "thread_private.h" /* diff --git a/lib/libc/gen/readdir_r.c b/lib/libc/gen/readdir_r.c index 04a7fdc953f..f32d08a7044 100644 --- a/lib/libc/gen/readdir_r.c +++ b/lib/libc/gen/readdir_r.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readdir_r.c,v 1.1 2009/11/18 07:43:22 guenther Exp $ */ +/* $OpenBSD: readdir_r.c,v 1.2 2012/03/22 04:11:53 matthew Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -32,6 +32,7 @@ #include <dirent.h> #include <string.h> #include <errno.h> +#include "telldir.h" #include "thread_private.h" int diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c index b2b08a64c82..cbd7148f28b 100644 --- a/lib/libc/gen/scandir.c +++ b/lib/libc/gen/scandir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scandir.c,v 1.13 2012/03/22 01:44:19 guenther Exp $ */ +/* $OpenBSD: scandir.c,v 1.14 2012/03/22 04:11:53 matthew Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -42,6 +42,7 @@ #include <limits.h> #include <stdlib.h> #include <string.h> +#include "telldir.h" /* * The DIRSIZ macro is the minimum record length which will hold the directory diff --git a/lib/libc/gen/telldir.h b/lib/libc/gen/telldir.h index 0101db5c216..7209278a648 100644 --- a/lib/libc/gen/telldir.h +++ b/lib/libc/gen/telldir.h @@ -1,4 +1,4 @@ -/* $OpenBSD: telldir.h,v 1.4 2010/10/28 15:02:41 millert Exp $ */ +/* $OpenBSD: telldir.h,v 1.5 2012/03/22 04:11:53 matthew Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -58,6 +58,20 @@ struct _telldir { long td_last; /* last tell/seekdir */ }; +/* structure describing an open directory. */ +struct _dirdesc { + int dd_fd; /* file descriptor associated with directory */ + long dd_loc; /* offset in current buffer */ + long dd_size; /* amount of data returned by getdirentries */ + char *dd_buf; /* data buffer */ + int dd_len; /* size of data buffer */ + off_t dd_seek; /* magic cookie returned by getdirentries */ + off_t dd_rewind; /* magic cookie for rewinding */ + int dd_unused; /* was flags for readdir */ + struct _telldir *dd_td; /* telldir position recording */ + void *dd_lock; /* mutex to protect struct */ +}; + long _telldir_unlocked(DIR *); void __seekdir(DIR *, long); |