Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys The manipulation macros for struct dirent are also u...



details:   https://anonhg.NetBSD.org/src/rev/e0d9d7ae7a81
branches:  trunk
changeset: 766960:e0d9d7ae7a81
user:      dholland <dholland%NetBSD.org@localhost>
date:      Tue Jul 05 07:32:33 2011 +0000

description:
The manipulation macros for struct dirent are also used by the ufs/ffs
code to manipulate the similar but not identical struct direct. For
this reason they must remain type-polymorphic. Rev 1.25 broke that
property, so put it back by using typeof. Fixes PR 45119.

diffstat:

 sys/sys/dirent.h |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 09aff2d1edcd -r e0d9d7ae7a81 sys/sys/dirent.h
--- a/sys/sys/dirent.h  Tue Jul 05 07:08:17 2011 +0000
+++ b/sys/sys/dirent.h  Tue Jul 05 07:32:33 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dirent.h,v 1.25 2011/05/23 21:59:23 joerg Exp $        */
+/*     $NetBSD: dirent.h,v 1.26 2011/07/05 07:32:33 dholland Exp $     */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -74,6 +74,13 @@
 #define        DT_WHT          14
 
 /*
+ * Caution: the following macros are used by the ufs/ffs code on ffs's
+ * struct direct as well as the exposed struct dirent. The two
+ * structures are not the same, so it's important (until ufs is fixed,
+ * XXX) that the macro definitions remain type-polymorphic.
+ */
+
+/*
  * The _DIRENT_ALIGN macro returns the alignment of struct dirent.
  * struct direct and struct dirent12 used 4 byte alignment but
  * struct dirent uses 8.
@@ -84,7 +91,7 @@
  * struct dirent
  */
 #if __GNUC_PREREQ__(4, 0)
-#define        _DIRENT_NAMEOFF(dp)     __builtin_offsetof(struct dirent, d_name)
+#define        _DIRENT_NAMEOFF(dp)     __builtin_offsetof(__typeof(*dp), d_name)
 #else
 #define _DIRENT_NAMEOFF(dp) \
     ((char *)(void *)&(dp)->d_name - (char *)(void *)dp)



Home | Main Index | Thread Index | Old Index