1 /* Ensure that the current compiler regime is happy with error sizes.
2 * See <tlspool/commands.h> above PIOC_ERROR_V2 for backgrounds.
3 * We move error codes back and forth between pioc_error.tlserrno and
4 * errno, where the former is an integer limited to int32_t values and
5 * the latter has wild implementations but usually holds a small range
6 * but is nonetheless the replacement for an "extern int errno" practice.
8 * From: Rick van Rein <rick@openfortress.nl>
17 #include <tlspool/commands.h>
22 long req_okay_vals [NUM_VALS] = {
23 (long) (int32_t) 0x80000000,
24 (long) (int32_t) 0x80000001,
25 (long) (int32_t) 0x80100000,
26 (long) (int32_t) 0xc0000000,
27 (long) (int32_t) 0xf0000000,
28 (long) (int32_t) 0xff000000,
29 (long) (int32_t) 0xffffff00,
30 (long) (int32_t) 0xffffffff,
31 (long) (int32_t) 0x00000000,
32 (long) (int32_t) 0x00000001,
33 (long) (int32_t) 0x00000100,
34 (long) (int32_t) 0x10000000,
35 (long) (int32_t) 0x10000001,
36 (long) (int32_t) 0x7f000000,
37 (long) (int32_t) 0x7fffff00,
38 (long) (int32_t) 0x7fffff01,
39 (long) (int32_t) 0x7ffffff0,
40 (long) (int32_t) 0x7fffffff
44 int main (int argc, char *argv []) {
45 struct pioc_error pe1, pe2;
49 for (i=0; i<NUM_VALS; i++) {
51 // in.long -> tlserrno -> errno -> out.long
52 pe1.tlserrno = req_okay_vals [i];
55 if (out1 != req_okay_vals [i]) {
56 fprintf (stderr, "FAILURE. in %ld -> tlserrno %d -> errno %d -> out %ld\n",
64 // in.long -> errno -> tlserrno -> out.long
65 errno = req_okay_vals [i];
68 if (out2 != req_okay_vals [i]) {
69 fprintf (stderr, "FAILURE. in %ld -> errno %d -> tlserrno %d -> out %ld\n",