summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fixed-point/convert.c
blob: f4e373f2d60923f200e30188ceaa231853d632de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */

/* C99 6.3 Conversions.

   Check conversions involving fixed-point.  */

extern void abort (void);

/* Fixed-point to fixed-point.  */
#define CONV(TYPE1,POSTFIX1,TYPE2,POSTFIX2) \
  { \
    TYPE1 a = 0.5 ## POSTFIX1; \
    TYPE2 b = a; \
    if (b != 0.5 ## POSTFIX2) \
      abort(); \
  }

/* TYPE1 with VALUE1 to TYPE2 with VALUE2.  */
#define CONV2(TYPE1,VALUE1,TYPE2,VALUE2) \
  { \
    TYPE1 a = VALUE1; \
    TYPE2 b = a; \
    if (b != VALUE2) \
      abort(); \
  }

/* Fixed-point to integer, and integer to fixed-point.  */
#define CONV_INT(TYPE1,POSTFIX1,TYPE2) \
  { \
    TYPE1 a = 0.5 ## POSTFIX1; \
    TYPE2 b = a; \
    TYPE2 c = 0; \
    TYPE1 d = c; \
    if (b != 0) \
      abort(); \
    if (d != 0.0 ## POSTFIX1) \
      abort(); \
  }

/* Signed fixed-point to integer.  */
#define CONV_INT2(TYPE1,POSTFIX1,TYPE2) \
  { \
    TYPE1 a = -0.5 ## POSTFIX1; \
    TYPE2 b = a; \
    if (b != 0) \
      abort(); \
    a = -0.0 ## POSTFIX1; \
    b = a; \
    if (b != 0) \
      abort(); \
    a = +0.0 ## POSTFIX1; \
    b = a; \
    if (b != 0) \
      abort(); \
    a = +0.1 ## POSTFIX1; \
    b = a; \
    if (b != 0) \
      abort(); \
    a = -0.1 ## POSTFIX1; \
    b = a; \
    if (b != 0) \
      abort(); \
  }

/* Signed fixed-point to signed integer.  */
#define CONV_INT3(TYPE1,POSTFIX1,TYPE2) \
  { \
    TYPE1 a = -0.5 ## POSTFIX1 - 0.5 ## POSTFIX1; \
    TYPE2 b = a; \
    if (b != -1) \
      abort(); \
  }

/* Fixed-point to floating-point, and floating-point to fixed-point.  */
#define CONV_FLOAT(TYPE1,POSTFIX1,TYPE2) \
  { \
    TYPE1 a = 0.5 ## POSTFIX1; \
    TYPE2 b = a; \
    TYPE2 c = 0.25; \
    TYPE1 d = c; \
    if (b != 0.5) \
      abort(); \
    if (d != 0.25 ## POSTFIX1) \
      abort(); \
  }

/* Accum to integer, and integer to accum.  */
#define CONV_ACCUM_INT(TYPE1,POSTFIX1,TYPE2) \
  { \
    TYPE1 a = 99.12345 ## POSTFIX1; \
    TYPE2 b = a; \
    TYPE2 c = 123; \
    TYPE1 d = c; \
    if (b != 99) \
      abort(); \
    if (d != 123.0 ## POSTFIX1) \
      abort(); \
  }

#define ALL_CONV(TYPE,POSTFIX) \
  CONV(TYPE, POSTFIX, short _Fract, hr) \
  CONV(TYPE, POSTFIX, _Fract, r) \
  CONV(TYPE, POSTFIX, long _Fract, lr) \
  CONV(TYPE, POSTFIX, long long _Fract, llr) \
  CONV(TYPE, POSTFIX, unsigned short _Fract, uhr) \
  CONV(TYPE, POSTFIX, unsigned _Fract, ur) \
  CONV(TYPE, POSTFIX, unsigned long _Fract, ulr) \
  CONV(TYPE, POSTFIX, unsigned long long _Fract, ullr) \
  CONV(TYPE, POSTFIX, short _Accum, hk) \
  CONV(TYPE, POSTFIX, _Accum, k) \
  CONV(TYPE, POSTFIX, long _Accum, lk) \
  CONV(TYPE, POSTFIX, long long _Accum, llk) \
  CONV(TYPE, POSTFIX, unsigned short _Accum, uhk) \
  CONV(TYPE, POSTFIX, unsigned _Accum, uk) \
  CONV(TYPE, POSTFIX, unsigned long _Accum, ulk) \
  CONV(TYPE, POSTFIX, unsigned long long _Accum, ullk) \
  CONV(_Sat TYPE, POSTFIX, short _Fract, hr) \
  CONV(_Sat TYPE, POSTFIX, _Fract, r) \
  CONV(_Sat TYPE, POSTFIX, long _Fract, lr) \
  CONV(_Sat TYPE, POSTFIX, long long _Fract, llr) \
  CONV(_Sat TYPE, POSTFIX, unsigned short _Fract, uhr) \
  CONV(_Sat TYPE, POSTFIX, unsigned _Fract, ur) \
  CONV(_Sat TYPE, POSTFIX, unsigned long _Fract, ulr) \
  CONV(_Sat TYPE, POSTFIX, unsigned long long _Fract, ullr) \
  CONV(_Sat TYPE, POSTFIX, short _Accum, hk) \
  CONV(_Sat TYPE, POSTFIX, _Accum, k) \
  CONV(_Sat TYPE, POSTFIX, long _Accum, lk) \
  CONV(_Sat TYPE, POSTFIX, long long _Accum, llk) \
  CONV(_Sat TYPE, POSTFIX, unsigned short _Accum, uhk) \
  CONV(_Sat TYPE, POSTFIX, unsigned _Accum, uk) \
  CONV(_Sat TYPE, POSTFIX, unsigned long _Accum, ulk) \
  CONV(_Sat TYPE, POSTFIX, unsigned long long _Accum, ullk) \
  CONV(TYPE, POSTFIX, _Sat short _Fract, hr) \
  CONV(TYPE, POSTFIX, _Sat _Fract, r) \
  CONV(TYPE, POSTFIX, _Sat long _Fract, lr) \
  CONV(TYPE, POSTFIX, _Sat long long _Fract, llr) \
  CONV(TYPE, POSTFIX, _Sat unsigned short _Fract, uhr) \
  CONV(TYPE, POSTFIX, _Sat unsigned _Fract, ur) \
  CONV(TYPE, POSTFIX, _Sat unsigned long _Fract, ulr) \
  CONV(TYPE, POSTFIX, _Sat unsigned long long _Fract, ullr) \
  CONV(TYPE, POSTFIX, _Sat short _Accum, hk) \
  CONV(TYPE, POSTFIX, _Sat _Accum, k) \
  CONV(TYPE, POSTFIX, _Sat long _Accum, lk) \
  CONV(TYPE, POSTFIX, _Sat long long _Accum, llk) \
  CONV(TYPE, POSTFIX, _Sat unsigned short _Accum, uhk) \
  CONV(TYPE, POSTFIX, _Sat unsigned _Accum, uk) \
  CONV(TYPE, POSTFIX, _Sat unsigned long _Accum, ulk) \
  CONV(TYPE, POSTFIX, _Sat unsigned long long _Accum, ullk) \
  CONV_INT(TYPE, POSTFIX, signed char) \
  CONV_INT(TYPE, POSTFIX, short) \
  CONV_INT(TYPE, POSTFIX, int) \
  CONV_INT(TYPE, POSTFIX, long) \
  CONV_INT(TYPE, POSTFIX, long long) \
  CONV_INT(TYPE, POSTFIX, unsigned char) \
  CONV_INT(TYPE, POSTFIX, unsigned short) \
  CONV_INT(TYPE, POSTFIX, unsigned int) \
  CONV_INT(TYPE, POSTFIX, unsigned long) \
  CONV_INT(TYPE, POSTFIX, unsigned long long) \
  CONV_INT(_Sat TYPE, POSTFIX, signed char) \
  CONV_INT(_Sat TYPE, POSTFIX, short) \
  CONV_INT(_Sat TYPE, POSTFIX, int) \
  CONV_INT(_Sat TYPE, POSTFIX, long) \
  CONV_INT(_Sat TYPE, POSTFIX, long long) \
  CONV_INT(_Sat TYPE, POSTFIX, unsigned char) \
  CONV_INT(_Sat TYPE, POSTFIX, unsigned short) \
  CONV_INT(_Sat TYPE, POSTFIX, unsigned int) \
  CONV_INT(_Sat TYPE, POSTFIX, unsigned long) \
  CONV_INT(_Sat TYPE, POSTFIX, unsigned long long) \
  CONV_FLOAT(TYPE, POSTFIX, float) \
  CONV_FLOAT(TYPE, POSTFIX, double) \
  CONV_FLOAT(_Sat TYPE, POSTFIX, float) \
  CONV_FLOAT(_Sat TYPE, POSTFIX, double)

#define ALL_ACCUM_CONV(TYPE,POSTFIX) \
  CONV_ACCUM_INT(TYPE, POSTFIX, signed char) \
  CONV_ACCUM_INT(TYPE, POSTFIX, short) \
  CONV_ACCUM_INT(TYPE, POSTFIX, int) \
  CONV_ACCUM_INT(TYPE, POSTFIX, long) \
  CONV_ACCUM_INT(TYPE, POSTFIX, long long) \
  CONV_ACCUM_INT(TYPE, POSTFIX, unsigned char) \
  CONV_ACCUM_INT(TYPE, POSTFIX, unsigned short) \
  CONV_ACCUM_INT(TYPE, POSTFIX, unsigned int) \
  CONV_ACCUM_INT(TYPE, POSTFIX, unsigned long) \
  CONV_ACCUM_INT(TYPE, POSTFIX, unsigned long long) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, signed char) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, short) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, int) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, long) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, long long) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, unsigned char) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, unsigned short) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, unsigned int) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, unsigned long) \
  CONV_ACCUM_INT(_Sat TYPE, POSTFIX, unsigned long long)

#define NEG_CONV(TYPE,POSTFIX) \
  CONV_INT2(TYPE, POSTFIX, signed char) \
  CONV_INT2(TYPE, POSTFIX, short) \
  CONV_INT2(TYPE, POSTFIX, int) \
  CONV_INT2(TYPE, POSTFIX, long) \
  CONV_INT2(TYPE, POSTFIX, long long) \
  CONV_INT2(TYPE, POSTFIX, unsigned char) \
  CONV_INT2(TYPE, POSTFIX, unsigned short) \
  CONV_INT2(TYPE, POSTFIX, unsigned int) \
  CONV_INT2(TYPE, POSTFIX, unsigned long) \
  CONV_INT2(TYPE, POSTFIX, unsigned long long) \
  CONV_INT3(TYPE, POSTFIX, signed char) \
  CONV_INT3(TYPE, POSTFIX, short) \
  CONV_INT3(TYPE, POSTFIX, int) \
  CONV_INT3(TYPE, POSTFIX, long) \
  CONV_INT3(TYPE, POSTFIX, long long)

/* Signed accum to _Sat unsigned/signed fract.  */
#define SAT_CONV1(TYPE, POSTFIX) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat short _Fract, -0.5hr - 0.5hr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat _Fract, 1.0r) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat _Fract, -0.5r - 0.5r) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat long _Fract, -0.5lr - 0.5lr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat long long _Fract, -0.5llr - 0.5llr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat unsigned _Fract, 0.0ur) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, -3.2 ## POSTFIX, _Sat unsigned long long _Fract, 0.0ullr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat short _Fract, -0.5hr - 0.5hr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat _Fract, 1.0r) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat _Fract, -0.5r - 0.5r) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat long _Fract, -0.5lr - 0.5lr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat long long _Fract, -0.5llr - 0.5llr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat unsigned _Fract, 0.0ur) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, -1.0 ## POSTFIX, _Sat unsigned long long _Fract, 0.0ullr)

/* Unsigned accum to _Sat unsigned/signed fract.  */
#define SAT_CONV2(TYPE, POSTFIX) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat _Fract, 1.0r) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, 3.2 ## POSTFIX, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat _Fract, 1.0r) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, 1.0 ## POSTFIX, _Sat unsigned long long _Fract, 1.0ullr)

/* Signed fract to _Sat unsigned fract.  */
#define SAT_CONV3(TYPE, POSTFIX) \
  CONV2(TYPE, -0.5 ## POSTFIX, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, -0.5 ## POSTFIX, _Sat unsigned  _Fract, 0.0ur) \
  CONV2(TYPE, -0.5 ## POSTFIX, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, -0.5 ## POSTFIX, _Sat unsigned long long _Fract, 0.0ullr)

/* Signed integer to _Sat signed/unsigned fract.  */
#define SAT_CONV4(TYPE) \
  CONV2(TYPE, 100, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, -100, _Sat short _Fract, -0.5hr - 0.5hr) \
  CONV2(TYPE, 100, _Sat _Fract, 1.0r) \
  CONV2(TYPE, -100, _Sat _Fract, -0.5r - 0.5r) \
  CONV2(TYPE, 100, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, -100, _Sat long _Fract, -0.5lr - 0.5lr) \
  CONV2(TYPE, 100, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, -100, _Sat long long _Fract, -0.5llr - 0.5llr) \
  CONV2(TYPE, 100, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, -100, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, 100, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, -100, _Sat unsigned _Fract, 0.0ur) \
  CONV2(TYPE, 100, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, -100, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, 100, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, -100, _Sat unsigned long long _Fract, 0.0ullr) \
  CONV2(TYPE, 1, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, -1, _Sat short _Fract, -0.5hr - 0.5hr) \
  CONV2(TYPE, 1, _Sat _Fract, 1.0r) \
  CONV2(TYPE, -1, _Sat _Fract, -0.5r - 0.5r) \
  CONV2(TYPE, 1, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, -1, _Sat long _Fract, -0.5lr - 0.5lr) \
  CONV2(TYPE, 1, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, -1, _Sat long long _Fract, -0.5llr - 0.5llr) \
  CONV2(TYPE, 1, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, -1, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, 1, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, -1, _Sat unsigned _Fract, 0.0ur) \
  CONV2(TYPE, 1, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, -1, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, 1, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, -1, _Sat unsigned long long _Fract, 0.0ullr)

/* Unsigned integer to _Sat signed/unsigned fract.  */
#define SAT_CONV5(TYPE) \
  CONV2(TYPE, 100, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, 100, _Sat _Fract, 1.0r) \
  CONV2(TYPE, 100, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, 100, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, 100, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, 100, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, 100, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, 100, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, 1, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, 1, _Sat _Fract, 1.0r) \
  CONV2(TYPE, 1, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, 1, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, 1, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, 1, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, 1, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, 1, _Sat unsigned long long _Fract, 1.0ullr)

/* Floating-point to _Sat signed/unsigned fract.  */
#define SAT_CONV6(TYPE) \
  CONV2(TYPE, 100.0, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, -100.0, _Sat short _Fract, -0.5hr - 0.5hr) \
  CONV2(TYPE, 100.0, _Sat _Fract, 1.0r) \
  CONV2(TYPE, -100.0, _Sat _Fract, -0.5r - 0.5r) \
  CONV2(TYPE, 100.0, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, -100.0, _Sat long _Fract, -0.5lr - 0.5lr) \
  CONV2(TYPE, 100.0, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, -100.0, _Sat long long _Fract, -0.5llr - 0.5llr) \
  CONV2(TYPE, 100.0, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, -100.0, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, 100.0, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, -100.0, _Sat unsigned _Fract, 0.0ur) \
  CONV2(TYPE, 100.0, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, -100.0, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, 100.0, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, -100.0, _Sat unsigned long long _Fract, 0.0ullr) \
  CONV2(TYPE, 1.0, _Sat short _Fract, 1.0hr) \
  CONV2(TYPE, -1.0, _Sat short _Fract, -0.5hr - 0.5hr) \
  CONV2(TYPE, 1.0, _Sat _Fract, 1.0r) \
  CONV2(TYPE, -1.0, _Sat _Fract, -0.5r - 0.5r) \
  CONV2(TYPE, 1.0, _Sat long _Fract, 1.0lr) \
  CONV2(TYPE, -1.0, _Sat long _Fract, -0.5lr - 0.5lr) \
  CONV2(TYPE, 1.0, _Sat long long _Fract, 1.0llr) \
  CONV2(TYPE, -1.0, _Sat long long _Fract, -0.5llr - 0.5llr) \
  CONV2(TYPE, 1.0, _Sat unsigned short _Fract, 1.0uhr) \
  CONV2(TYPE, -1.0, _Sat unsigned short _Fract, 0.0uhr) \
  CONV2(TYPE, 1.0, _Sat unsigned _Fract, 1.0ur) \
  CONV2(TYPE, -1.0, _Sat unsigned _Fract, 0.0ur) \
  CONV2(TYPE, 1.0, _Sat unsigned long _Fract, 1.0ulr) \
  CONV2(TYPE, -1.0, _Sat unsigned long _Fract, 0.0ulr) \
  CONV2(TYPE, 1.0, _Sat unsigned long long _Fract, 1.0ullr) \
  CONV2(TYPE, -1.0, _Sat unsigned long long _Fract, 0.0ullr)

int main ()
{
  ALL_CONV (short _Fract, hr);
  ALL_CONV (_Fract, r);
  ALL_CONV (long _Fract, lr);
  ALL_CONV (long long _Fract, llr);
  ALL_CONV (unsigned short _Fract, uhr);
  ALL_CONV (unsigned _Fract, ur);
  ALL_CONV (unsigned long _Fract, ulr);
  ALL_CONV (unsigned long long _Fract, ullr);
  ALL_CONV (short _Accum, hk);
  ALL_CONV (_Accum, k);
  ALL_CONV (long _Accum, lk);
  ALL_CONV (long long _Accum, llk);
  ALL_CONV (unsigned short _Accum, uhk);
  ALL_CONV (unsigned _Accum, uk);
  ALL_CONV (unsigned long _Accum, ulk);
  ALL_CONV (unsigned long long _Accum, ullk);

  ALL_ACCUM_CONV (short _Accum, hk);
  ALL_ACCUM_CONV (_Accum, k);
  ALL_ACCUM_CONV (long _Accum, lk);
  ALL_ACCUM_CONV (long long _Accum, llk);
  ALL_ACCUM_CONV (unsigned short _Accum, uhk);
  ALL_ACCUM_CONV (unsigned _Accum, uk);
  ALL_ACCUM_CONV (unsigned long _Accum, ulk);
  ALL_ACCUM_CONV (unsigned long long _Accum, ullk);

  NEG_CONV (short _Fract, hr);
  NEG_CONV (_Fract, r);
  NEG_CONV (long _Fract, lr);
  NEG_CONV (long long _Fract, llr);
  NEG_CONV (short _Accum, hk);
  NEG_CONV (_Accum, k);
  NEG_CONV (long _Accum, lk);
  NEG_CONV (long long _Accum, llk);

  SAT_CONV1 (short _Accum, hk);
  SAT_CONV1 (_Accum, k);
  SAT_CONV1 (long _Accum, lk);
  SAT_CONV1 (long long _Accum, llk);

  SAT_CONV2 (unsigned short _Accum, uhk);
  SAT_CONV2 (unsigned _Accum, uk);
  SAT_CONV2 (unsigned long _Accum, ulk);
  SAT_CONV2 (unsigned long long _Accum, ullk);

  SAT_CONV3 (short _Fract, hr);
  SAT_CONV3 (_Fract, r);
  SAT_CONV3 (long _Fract, lr);
  SAT_CONV3 (long long _Fract, llr);

  SAT_CONV4 (signed char);
  SAT_CONV4 (short);
  SAT_CONV4 (int);
  SAT_CONV4 (long);
  SAT_CONV4 (long long);

  SAT_CONV5 (unsigned char);
  SAT_CONV5 (unsigned short);
  SAT_CONV5 (unsigned int);
  SAT_CONV5 (unsigned long);
  SAT_CONV5 (unsigned long long);

  SAT_CONV6 (float);
  SAT_CONV6 (double);

  return 0;
}