Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
26 pmbaty 1
/* ACC -- Automatic Compiler Configuration
2
 
3
   Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
4
   All Rights Reserved.
5
 
6
   This software is a copyrighted work licensed under the terms of
7
   the GNU General Public License. Please consult the file "ACC_LICENSE"
8
   for details.
9
 
10
   Markus F.X.J. Oberhumer
11
   <markus@oberhumer.com>
12
   http://www.oberhumer.com/
13
 */
14
 
15
 
16
/*************************************************************************
17
//
18
**************************************************************************/
19
 
20
#if !defined(__ACCCHKR_FUNCNAME)
21
#  define __ACCCHKR_FUNCNAME(f) accchkr_ ## f
22
#endif
23
 
24
 
25
 
26
#if !defined(ACCCHKR_ASSERT)
27
 
28
#if 0 || defined(ACCCHKR_CONFIG_DEBUG)
29
 
30
#include <stdio.h>
31
static int __ACCCHKR_FUNCNAME(assert_fail)(const char* s, unsigned l)
32
{
33
    fprintf(stderr, "ACCCHKR assertion failed in line %u: `%s'\n", l, s);
34
    return 0;
35
}
36
#define ACCCHKR_ASSERT(expr)    ((expr) ? 1 : __ACCCHKR_FUNCNAME(assert_fail)(#expr,__LINE__))
37
 
38
#else
39
 
40
#define ACCCHKR_ASSERT(expr)    ((expr) ? 1 : 0)
41
 
42
#endif
43
 
44
#endif
45
 
46
 
47
 
48
/* avoid inlining */
49
static int __ACCCHKR_FUNCNAME(schedule_insns_bug)(void);
50
static int __ACCCHKR_FUNCNAME(strength_reduce_bug)(int*);
51
 
52
 
53
/*************************************************************************
54
// main entry
55
**************************************************************************/
56
 
57
static int __ACCCHKR_FUNCNAME(check)(int r)
58
{
59
#if defined(ACC_ENDIAN_BIG_ENDIAN)
60
    {
61
        union { long l; unsigned char c[sizeof(long)]; } u;
62
        u.l = 0; u.c[sizeof(long)-1] = 0x80;
63
        r &= ACCCHKR_ASSERT(u.l == 128);
64
        u.l = 0; u.c[0] = 0x80;
65
        r &= ACCCHKR_ASSERT(u.l < 0);
66
        ACC_UNUSED(u);
67
    }
68
#endif
69
#if defined(ACC_ENDIAN_LITTLE_ENDIAN)
70
    {
71
        union { long l; unsigned char c[sizeof(long)]; } u;
72
        u.l = 0; u.c[0] = 0x80;
73
        r &= ACCCHKR_ASSERT(u.l == 128);
74
        u.l = 0; u.c[sizeof(long)-1] = 0x80;
75
        r &= ACCCHKR_ASSERT(u.l < 0);
76
        ACC_UNUSED(u);
77
    }
78
#endif
79
 
80
    /* check for the gcc schedule-insns optimization bug */
81
    if (r == 1)
82
    {
83
        r &= ACCCHKR_ASSERT(!__ACCCHKR_FUNCNAME(schedule_insns_bug()));
84
    }
85
 
86
    /* check for the gcc strength-reduce optimization bug */
87
    if (r == 1)
88
    {
89
        static int x[3];
90
        static unsigned xn = 3;
91
        register unsigned j;
92
 
93
        for (j = 0; j < xn; j++)
94
            x[j] = (int)j - 3;
95
        r &= ACCCHKR_ASSERT(!__ACCCHKR_FUNCNAME(strength_reduce_bug(x)));
96
    }
97
 
98
    return r;
99
}
100
 
101
 
102
/*************************************************************************
103
//
104
**************************************************************************/
105
 
106
static int __ACCCHKR_FUNCNAME(schedule_insns_bug)(void)
107
{
108
    const int a[] = {1, 2, 0}; const int* b;
109
    b = a; return (*b) ? 0 : 1;
110
}
111
 
112
 
113
static int __ACCCHKR_FUNCNAME(strength_reduce_bug)(int* x)
114
{
115
#if 0 && (ACC_CC_DMC || ACC_CC_SYMANTECC || ACC_CC_ZORTECHC)
116
    ACC_UNUSED(x); return 0;
117
#else
118
    return x[0] != -3 || x[1] != -2 || x[2] != -1;
119
#endif
120
}
121
 
122
 
123
 
124
/*
125
vi:ts=4:et
126
*/