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

« back to all changes in this revision

Viewing changes to modules/freebsd/vmhgfs/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:
83
83
 */
84
84
 
85
85
#ifndef ASSERT_IFNOT
86
 
   #ifdef __cplusplus
87
 
      #define ASSERT_IFNOT(cond, panic) (UNLIKELY(!(cond)) ? (panic) : (void)0)
 
86
   /*
 
87
    * PR 271512: When compiling with gcc, catch assignments inside an ASSERT.
 
88
    *
 
89
    * 'UNLIKELY' is defined with __builtin_expect, which does not warn when passed an
 
90
    * assignment (gcc bug 36050).
 
91
    * To get around this, we put 'cond' in an 'if' statement and make sure it never gets
 
92
    * executed by putting that inside of 'if (0)'.
 
93
    * We use gcc's statement expression syntax to make ASSERT an expression because some
 
94
    * code uses it that way.
 
95
    *
 
96
    * Since statement expression syntax is a gcc extension and since it's not clear if
 
97
    * this is a problem with other compilers, the ASSERT definition was not changed for
 
98
    * them.  Using a bare 'cond' with the ternary operator may provide a solution.
 
99
    */
 
100
   #ifdef __GNUC__
 
101
      #define ASSERT_IFNOT(cond, panic)                                              \
 
102
                 ({if (UNLIKELY(!(cond))) { panic; if (0) { if (cond) { ; } } } (void)0;})
88
103
   #else
89
 
      #define ASSERT_IFNOT(cond, panic) (UNLIKELY(!(cond)) ? (panic) : 0)
 
104
      #define ASSERT_IFNOT(cond, panic)                               \
 
105
                 (UNLIKELY(!(cond)) ? (panic) : (void)0)
90
106
   #endif
91
107
#endif
92
108