~psusi/ubuntu/natty/parted/fix-dmraid

« back to all changes in this revision

Viewing changes to lib/verify.h

  • Committer: Colin Watson
  • Date: 2010-08-05 21:06:19 UTC
  • mfrom: (7.2.9 sid)
  • Revision ID: cjwatson@canonical.com-20100805210619-f9ld2tuntueagfeo
* Resynchronise with Debian.  Remaining changes:
  - gptsync.dpatch: On Intel Mac systems, write a synced MBR rather than a
    protective MBR.
  - Add -fno-stack-protector on sparc.
  - loop-partitions.dpatch: Loop devices can only have one partition, so
    don't generate device names such as "/dev/loop0p1".
  - udevadm-settle.dpatch: Run 'udevadm settle' either side of rereading
    the partition table, to avoid a variety of races.
  - dmraid.dpatch: Ensure that device-mapper devices for dmraid arrays do
    not have extra nodes created needlessly, as well as making sure that
    partition nodes for dmraid devices are not probed.
  - loop-limits.patch: Remove limits on loop labels.
  - fix-dmraid-regression.path: Reverse upstream change that broke
    installation on dmraid disks for lucid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
     if the entity names are not disambiguated.  A workaround is to
70
70
     attach the current line number to the entity name:
71
71
 
72
 
       #define GL_CONCAT0(x, y) x##y
73
 
       #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
74
 
       extern struct {...} * GL_CONCAT(dummy,__LINE__);
 
72
       #define _GL_CONCAT0(x, y) x##y
 
73
       #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
 
74
       extern struct {...} * _GL_CONCAT (dummy, __LINE__);
75
75
 
76
76
     But this has the problem that two invocations of verify from
77
77
     within the same macro would collide, since the __LINE__ value
78
 
     would be the same for both invocations.
 
78
     would be the same for both invocations.  (The GCC __COUNTER__
 
79
     macro solves this problem, but is not portable.)
79
80
 
80
81
     A solution is to use the sizeof operator.  It yields a number,
81
82
     getting rid of the identity of the type.  Declarations like
103
104
 
104
105
       extern int (*dummy (void)) [sizeof (struct {...})];
105
106
 
 
107
   * GCC warns about duplicate declarations of the dummy function if
 
108
     -Wredundant_decls is used.  GCC 4.3 and later have a builtin
 
109
     __COUNTER__ macro that can let us generate unique identifiers for
 
110
     each dummy function, to suppress this warning.
 
111
 
106
112
   * This implementation exploits the fact that GCC does not warn about
107
113
     the last declaration mentioned above.  If a future version of GCC
108
114
     introduces a warning for this, the problem could be worked around
109
 
     by using code specialized to GCC, e.g.,:
 
115
     by using code specialized to GCC, just as __COUNTER__ is already
 
116
     being used if available.
110
117
 
111
118
       #if 4 <= __GNUC__
112
 
       # define verify(R) \
113
 
           extern int (* verify_function__ (void)) \
114
 
                      [__builtin_constant_p (R) && (R) ? 1 : -1]
 
119
       # define verify(R) [another version to keep GCC happy]
115
120
       #endif
116
121
 
117
122
   * In C++, any struct definition inside sizeof is invalid.
118
123
     Use a template type to work around the problem.  */
119
124
 
 
125
/* Concatenate two preprocessor tokens.  */
 
126
# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
 
127
# define _GL_CONCAT0(x, y) x##y
 
128
 
 
129
/* _GL_COUNTER is an integer, preferably one that changes each time we
 
130
   use it.  Use __COUNTER__ if it works, falling back on __LINE__
 
131
   otherwise.  __LINE__ isn't perfect, but it's better than a
 
132
   constant.  */
 
133
# if defined __COUNTER__ && __COUNTER__ != __COUNTER__
 
134
#  define _GL_COUNTER __COUNTER__
 
135
# else
 
136
#  define _GL_COUNTER __LINE__
 
137
# endif
 
138
 
 
139
/* Generate a symbol with the given prefix, making it unique if
 
140
   possible.  */
 
141
# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
120
142
 
121
143
/* Verify requirement R at compile-time, as an integer constant expression.
122
144
   Return 1.  */
135
157
/* Verify requirement R at compile-time, as a declaration without a
136
158
   trailing ';'.  */
137
159
 
138
 
# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
 
160
# define verify(R) \
 
161
    extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)]
139
162
 
140
163
#endif