[dovecot-cvs] dovecot/src/lib macros.h,1.12,1.13

cras at procontrol.fi cras at procontrol.fi
Thu Jan 30 19:51:34 EET 2003


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv12058/lib

Modified Files:
	macros.h 
Log Message:
Removed STRUCT_OFFSET, offsetof() is ANSI-C for the same purpose. Added
MEMBER() macro to define C99-style struct labels.



Index: macros.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/macros.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- macros.h	28 Jan 2003 19:32:18 -0000	1.12
+++ macros.h	30 Jan 2003 17:51:32 -0000	1.13
@@ -57,12 +57,10 @@
 /* Provide convenience macros for handling structure
  * fields through their offsets.
  */
-#define STRUCT_OFFSET(struct_p, member) \
-    ((long) ((char *) &((struct_p)->member) - (char *) (struct_p)))
 #define STRUCT_MEMBER_P(struct_p, struct_offset) \
-    ((void *) ((char *) (struct_p) + (long) (struct_offset)))
+	((void *) ((char *) (struct_p) + (long) (struct_offset)))
 #define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
-    (*(member_type *) G_STRUCT_MEMBER_P((struct_p), (struct_offset)))
+	(*(member_type *) G_STRUCT_MEMBER_P((struct_p), (struct_offset)))
 
 /* Provide simple macro statement wrappers (adapted from Perl):
    STMT_START { statements; } STMT_END;
@@ -104,6 +102,13 @@
 #  define __attr_noreturn__
 #  define __attr_const__
 #  define __attr_unused__
+#endif
+
+/* C99-style struct member definitions */
+#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || __GNUC__ > 2
+#  define MEMBER(name) .name =
+#else
+#  define MEMBER(name)
 #endif
 
 /* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with




More information about the dovecot-cvs mailing list