aboutsummaryrefslogtreecommitdiff
path: root/src/lib/cc
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-21 16:29:24 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-22 09:49:13 -0400
commit479c2ab503a3a051200339a7df9a99dcfb0ed976 (patch)
treeef708dd688b506a8b8eddbbd20fccd5cafa1237d /src/lib/cc
parent657ff55408d82f49fc9599cb662702cdc0995f08 (diff)
downloadtor-479c2ab503a3a051200339a7df9a99dcfb0ed976.tar.gz
tor-479c2ab503a3a051200339a7df9a99dcfb0ed976.zip
Move STRUCT_VAR_P to compat_compiler.
Diffstat (limited to 'src/lib/cc')
-rw-r--r--src/lib/cc/compat_compiler.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index 31e84bcc5b..763c3d06d5 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) */