~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

Viewing changes to src/lib/macros.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
#  define ATTR_CONST
110
110
#  define ATTR_PURE
111
111
#endif
 
112
#ifdef HAVE_ATTR_NULL
 
113
#  define ATTR_NULL(...) __attribute__((null(__VA_ARGS__)))
 
114
#else
 
115
#  define ATTR_NULL(...)
 
116
#endif
 
117
#ifdef HAVE_ATTR_NOWARN_UNUSED_RESULT
 
118
#  define ATTR_NOWARN_UNUSED_RESULT __attribute__((nowarn_unused_result))
 
119
#else
 
120
#  define ATTR_NOWARN_UNUSED_RESULT
 
121
#endif
112
122
#if __GNUC__ > 2
113
123
#  define ATTR_MALLOC __attribute__((malloc))
114
124
#else
132
142
#endif
133
143
 
134
144
/* Macros to provide type safety for callback functions' context parameters */
135
 
#ifdef __GNUC__
136
 
#  define CONTEXT_TYPE_SAFETY
137
 
#endif
138
 
#ifdef CONTEXT_TYPE_SAFETY
139
 
#  define CONTEXT_CALLBACK(name, callback_type, callback, context, ...) \
140
 
        ({(void)(1 ? 0 : callback(context)); \
141
 
        name(__VA_ARGS__, (callback_type *)callback, context); })
142
 
#  define CONTEXT_CALLBACK2(name, callback_type, callback, arg1_type, context, ...) \
143
 
        ({(void)(1 ? 0 : callback((arg1_type)0, context)); \
144
 
        name(__VA_ARGS__, (callback_type *)callback, context); })
 
145
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
 
146
#  define CALLBACK_TYPECHECK(callback, type) \
 
147
        (COMPILE_ERROR_IF_TRUE(!__builtin_types_compatible_p( \
 
148
                typeof(&callback), type)) ? 1 : 0)
145
149
#else
146
 
#  define CONTEXT_CALLBACK(name, callback_type, callback, context, ...) \
147
 
        name(__VA_ARGS__, (callback_type *)callback, context)
148
 
#  define CONTEXT_CALLBACK2(name, callback_type, callback, arg1_type, context, ...) \
149
 
        name(__VA_ARGS__, (callback_type *)callback, context)
 
150
#  define CALLBACK_TYPECHECK(callback, type) 0
150
151
#endif
151
152
 
152
 
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
153
 
#  define HAVE_TYPEOF
 
153
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) && !defined(__cplusplus)
154
154
#  define COMPILE_ERROR_IF_TRUE(condition) \
155
155
        (sizeof(char[1 - 2 * !!(condition)]) - 1)
156
156
#  define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) \
157
157
        COMPILE_ERROR_IF_TRUE( \
158
158
                !__builtin_types_compatible_p(typeof(_a), typeof(_b)))
 
159
#define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) \
 
160
        COMPILE_ERROR_IF_TRUE( \
 
161
                !__builtin_types_compatible_p(typeof(_a1), typeof(_b)) && \
 
162
                !__builtin_types_compatible_p(typeof(_a2), typeof(_b)))
159
163
#else
160
164
#  define COMPILE_ERROR_IF_TRUE(condition) 0
161
165
#  define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) 0
 
166
#  define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) 0
162
167
#endif
163
168
 
164
169
#if __GNUC__ > 2
193
198
 
194
199
#endif
195
200
 
 
201
#define i_close_fd(fd) STMT_START {  \
 
202
        if (unlikely(close_keep_errno(fd) < 0)) \
 
203
                i_error("close(%d[%s:%d]) failed: %m", \
 
204
                        *(fd), __FILE__, __LINE__); \
 
205
        } STMT_END
 
206
 
196
207
#define i_unreached() \
197
208
        i_panic("file %s: line %d: unreached", __FILE__, __LINE__)
198
209
 
 
210
/* Convenience macros to test the versions of dovecot. */
 
211
#if defined DOVECOT_VERSION_MAJOR && defined DOVECOT_VERSION_MINOR
 
212
#  define DOVECOT_PREREQ(maj, min) \
 
213
          ((DOVECOT_VERSION_MAJOR << 16) + DOVECOT_VERSION_MINOR >= ((maj) << 16) + (min))
 
214
#else
 
215
#  define DOVECOT_PREREQ(maj, min) 0
 
216
#endif
 
217
 
199
218
#endif