~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to modules/freebsd/vmblock/vm_assert.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-03-20 10:19:00 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090320101900-1o604camiubq2de8
Tags: 2009.03.18-154848-2
Correcting patch system depends (Closes: #520493).

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
 */
96
96
 
97
97
#ifndef ASSERT_IFNOT
98
 
   #ifdef __cplusplus
99
 
      #define ASSERT_IFNOT(cond, panic) (UNLIKELY(!(cond)) ? (panic) : (void)0)
 
98
   /*
 
99
    * PR 271512: When compiling with gcc, catch assignments inside an ASSERT.
 
100
    *
 
101
    * 'UNLIKELY' is defined with __builtin_expect, which does not warn when passed an
 
102
    * assignment (gcc bug 36050).
 
103
    * To get around this, we put 'cond' in an 'if' statement and make sure it never gets
 
104
    * executed by putting that inside of 'if (0)'.
 
105
    * We use gcc's statement expression syntax to make ASSERT an expression because some
 
106
    * code uses it that way.
 
107
    *
 
108
    * Since statement expression syntax is a gcc extension and since it's not clear if
 
109
    * this is a problem with other compilers, the ASSERT definition was not changed for
 
110
    * them.  Using a bare 'cond' with the ternary operator may provide a solution.
 
111
    */
 
112
   #ifdef __GNUC__
 
113
      #define ASSERT_IFNOT(cond, panic)                                              \
 
114
                 ({if (UNLIKELY(!(cond))) { panic; if (0) { if (cond) { ; } } } (void)0;})
100
115
   #else
101
 
      #define ASSERT_IFNOT(cond, panic) (UNLIKELY(!(cond)) ? (panic) : 0)
 
116
      #define ASSERT_IFNOT(cond, panic)                               \
 
117
                 (UNLIKELY(!(cond)) ? (panic) : (void)0)
102
118
   #endif
103
119
#endif
104
120