[tor-commits] [tor/master] Move STRUCT_VAR_P to compat_compiler.

nickm at torproject.org nickm at torproject.org
Tue Jun 26 15:27:41 UTC 2018


commit 479c2ab503a3a051200339a7df9a99dcfb0ed976
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Jun 21 16:29:24 2018 -0400

    Move STRUCT_VAR_P to compat_compiler.
---
 src/common/util.h             | 11 -----------
 src/lib/cc/compat_compiler.h  | 11 +++++++++++
 src/lib/container/smartlist.c |  3 ++-
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/common/util.h b/src/common/util.h
index 1c889082b..916bddc1f 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -41,17 +41,6 @@ uint64_t tor_ntohll(uint64_t a);
 
 void tor_log_mallinfo(int severity);
 
-/** Macro: yield a pointer to the field at position <b>off</b> within the
- * structure <b>st</b>.  Example:
- * <pre>
- *   struct a { int foo; int bar; } x;
- *   off_t bar_offset = offsetof(struct a, bar);
- *   int *bar_p = STRUCT_VAR_P(&x, bar_offset);
- *   *bar_p = 3;
- * </pre>
- */
-#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>
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index 31e84bcc5..763c3d06d 100644
--- a/src/lib/cc/compat_compiler.h
+++ b/src/lib/cc/compat_compiler.h
@@ -242,4 +242,15 @@
 #error Unknown: SIZEOF_INTPTR_T
 #endif /* (SIZEOF_INTPTR_T == SIZEOF_INT) || ... */
 
+/** Macro: yield a pointer to the field at position <b>off</b> within the
+ * structure <b>st</b>.  Example:
+ * <pre>
+ *   struct a { int foo; int bar; } x;
+ *   off_t bar_offset = offsetof(struct a, bar);
+ *   int *bar_p = STRUCT_VAR_P(&x, bar_offset);
+ *   *bar_p = 3;
+ * </pre>
+ */
+#define STRUCT_VAR_P(st, off) ((void*) ( ((char*)(st)) + (off) ) )
+
 #endif /* !defined(TOR_COMPAT_H) */
diff --git a/src/lib/container/smartlist.c b/src/lib/container/smartlist.c
index 6aef72854..0fe11c670 100644
--- a/src/lib/container/smartlist.c
+++ b/src/lib/container/smartlist.c
@@ -13,7 +13,8 @@
 
 #include "lib/malloc/util_malloc.h"
 #include "lib/container/smartlist.h"
-#include "common/util.h"
+#include "lib/err/torerr.h"
+#include "common/util.h" // For strstrip.
 #include "lib/crypt_ops/crypto_digest.h"
 #include "lib/ctime/di_ops.h"
 





More information about the tor-commits mailing list