[tor-commits] [tor/master] Move SUBTYPE_P into compat_compiler.h

nickm at torproject.org nickm at torproject.org
Fri Jun 29 16:59:55 UTC 2018


commit 207fc4cffe21b58b7f0447706a903e5f66b8bcd8
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jun 29 10:23:52 2018 -0400

    Move SUBTYPE_P into compat_compiler.h
---
 src/common/util.h            | 12 ------------
 src/lib/cc/compat_compiler.h | 12 ++++++++++++
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/common/util.h b/src/common/util.h
index c59c79c30..032842d8d 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -43,18 +43,6 @@
 #include "lib/encoding/cstring.h"
 #include "lib/fs/winlib.h"
 
-/** Macro: yield a pointer to an enclosing structure given a pointer to
- * a substructure at offset <b>off</b>. Example:
- * <pre>
- *   struct base { ... };
- *   struct subtype { int x; struct base b; } x;
- *   struct base *bp = &x.base;
- *   struct *sp = SUBTYPE_P(bp, struct subtype, b);
- * </pre>
- */
-#define SUBTYPE_P(p, subtype, basemember) \
-  ((void*) ( ((char*)(p)) - offsetof(subtype, basemember) ))
-
 /* Math functions */
 
 /* String manipulation */
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index 67d945cfa..c631a7e82 100644
--- a/src/lib/cc/compat_compiler.h
+++ b/src/lib/cc/compat_compiler.h
@@ -253,6 +253,18 @@
  */
 #define STRUCT_VAR_P(st, off) ((void*) ( ((char*)(st)) + (off) ) )
 
+/** Macro: yield a pointer to an enclosing structure given a pointer to
+ * a substructure at offset <b>off</b>. Example:
+ * <pre>
+ *   struct base { ... };
+ *   struct subtype { int x; struct base b; } x;
+ *   struct base *bp = &x.base;
+ *   struct *sp = SUBTYPE_P(bp, struct subtype, b);
+ * </pre>
+ */
+#define SUBTYPE_P(p, subtype, basemember) \
+  ((void*) ( ((char*)(p)) - offsetof(subtype, basemember) ))
+
 /** Macro: Yields the number of elements in array x. */
 #define ARRAY_LENGTH(x) ((sizeof(x)) / sizeof(x[0]))
 





More information about the tor-commits mailing list