summaryrefslogtreecommitdiff
path: root/util-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-04-17 06:55:08 +0000
committerNick Mathewson <nickm@torproject.org>2009-04-17 06:55:08 +0000
commit838d0a81c3343432897739d14e2af1a4e5edb7db (patch)
tree13ce8ca399a18d808bb808b93169a5ce7644f18f /util-internal.h
parent433e2339ca1605326f35c2d873a42f6d2abe505d (diff)
downloadlibevent-838d0a81c3343432897739d14e2af1a4e5edb7db.tar.gz
Document many internal functions and pieces of code.
svn:r1181
Diffstat (limited to 'util-internal.h')
-rw-r--r--util-internal.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/util-internal.h b/util-internal.h
index 31f2239f..73f11ae4 100644
--- a/util-internal.h
+++ b/util-internal.h
@@ -101,6 +101,21 @@ extern const char EVUTIL_TOLOWER_TABLE[];
#define EVUTIL_TOLOWER(c) (EVUTIL_TOLOWER_TABLE[(ev_uint8_t)c])
#define EVUTIL_TOUPPER(c) (EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c])
+/** Helper macro. If we know that a given pointer points to a field in a
+ structure, return a pointer to the structure itself. Used to implement
+ our half-baked C OO. Example:
+
+ struct subtype {
+ int x;
+ struct supertype common;
+ int y;
+ };
+ ...
+ void fn(struct supertype *super) {
+ struct subtype *sub = EVUTIL_UPCAST(super, struct subtype, common);
+ ...
+ }
+ */
#define EVUTIL_UPCAST(ptr, type, field) \
((type *)((char*)ptr) - evutil_offsetof(type, field))