~n-muench/ubuntu/quantal/open-vm-tools/open-vm-tools.may2.sid-sync

« back to all changes in this revision

Viewing changes to lib/include/vm_assert.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-05-30 09:48:43 UTC
  • mfrom: (1.1.5 upstream) (2.4.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090530094843-gdpza57r5iqsf124
Tags: 2009.05.22-167859-1
MergingĀ upstreamĀ versionĀ 2009.05.22-167859.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 *
17
17
 *********************************************************/
18
18
 
 
19
/*********************************************************
 
20
 * Redistribution and use in source and binary forms, with or without
 
21
 * modification, are permitted provided that the following conditions
 
22
 * are met:
 
23
 *
 
24
 * 1. Redistributions of source code must retain the above copyright
 
25
 *    notice, this list of conditions and the following disclaimer.
 
26
 * 2. Redistributions in binary form must reproduce the above copyright
 
27
 *    notice, this list of conditions and the following disclaimer in the
 
28
 *    documentation and/or other materials provided with the distribution.
 
29
 * 3. Neither the name of VMware Inc. nor the names of its contributors
 
30
 *    may be used to endorse or promote products derived from this software
 
31
 *    without specific prior written permission of VMware Inc.
 
32
 *
 
33
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
34
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
35
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
36
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
37
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
38
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
39
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
40
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
41
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
42
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
43
 * SUCH DAMAGE.
 
44
 *
 
45
 *********************************************************/
 
46
 
 
47
/*********************************************************
 
48
 * The contents of this file are subject to the terms of the Common
 
49
 * Development and Distribution License (the "License") version 1.0
 
50
 * and no later version.  You may not use this file except in
 
51
 * compliance with the License.
 
52
 *
 
53
 * You can obtain a copy of the License at
 
54
 *         http://www.opensource.org/licenses/cddl1.php
 
55
 *
 
56
 * See the License for the specific language governing permissions
 
57
 * and limitations under the License.
 
58
 *
 
59
 *********************************************************/
 
60
 
19
61
/*
20
62
 * vm_assert.h --
21
63
 *
86
128
   /*
87
129
    * PR 271512: When compiling with gcc, catch assignments inside an ASSERT.
88
130
    *
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.
 
131
    * 'UNLIKELY' is defined with __builtin_expect, which does not warn when
 
132
    * passed an assignment (gcc bug 36050). To get around this, we put 'cond'
 
133
    * in an 'if' statement and make sure it never gets executed by putting
 
134
    * that inside of 'if (0)'. We use gcc's statement expression syntax to
 
135
    * make ASSERT an expression because some code uses it that way.
95
136
    *
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.
 
137
    * Since statement expression syntax is a gcc extension and since it's
 
138
    * not clear if this is a problem with other compilers, the ASSERT
 
139
    * definition was not changed for them. Using a bare 'cond' with the
 
140
    * ternary operator may provide a solution.
99
141
    */
 
142
 
100
143
   #ifdef __GNUC__
101
144
      #define ASSERT_IFNOT(cond, panic)                                              \
102
145
                 ({if (UNLIKELY(!(cond))) { panic; if (0) { if (cond) { ; } } } (void)0;})