OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [infra/] [current/] [tests/] [cxxsupp.cxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//        cxxsupp.cxx
4
//
5
//        C++ runtime support test
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2003, 2009 Free Software Foundation, Inc.                        
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     nickg
43
// Contributors:  nickg
44
// Date:          2003-04-01
45
// Description:   Simple test for C++ runtime support.
46
//
47
//####DESCRIPTIONEND####
48
//==========================================================================
49
 
50
#include <pkgconf/system.h>
51
#include <pkgconf/hal.h>
52
#include <pkgconf/isoinfra.h>
53
 
54
#include <cyg/infra/cyg_type.h>
55
#include <cyg/infra/testcase.h>
56
#include <cyg/infra/diag.h>
57
 
58
// The H8300 does not have C++ support in its toolchain
59
#ifndef CYGPKG_HAL_H8300
60
 
61
#include <new>
62
 
63
//==========================================================================
64
 
65
class Pure
66
{
67
protected:
68
    int instance;
69
public:
70
    Pure(int i);
71
    virtual ~Pure() {}
72
    virtual void pure_fun1(void) = 0;
73
    virtual void pure_fun2(void) = 0;
74
    virtual void impure_fun1(void);
75
    inline void inline_fun1(void);
76
};
77
 
78
Pure::Pure(int i)
79
{
80
    instance = i;
81
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
82
}
83
 
84
void Pure::impure_fun1()
85
{
86
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
87
}
88
 
89
inline void Pure::inline_fun1()
90
{
91
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
92
}
93
 
94
//==========================================================================
95
 
96
class Derived : public Pure
97
{
98
public:
99
    Derived(int i);
100
    virtual ~Derived() {}
101
    void pure_fun1(void);
102
    void pure_fun2(void);
103
    void impure_fun2(void);
104
};
105
 
106
Derived::Derived(int i)
107
    : Pure(i)
108
{
109
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
110
}
111
 
112
void Derived::pure_fun1(void)
113
{
114
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
115
}
116
 
117
void Derived::pure_fun2(void)
118
{
119
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
120
}
121
 
122
 
123
void Derived::impure_fun2(void)
124
{
125
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
126
}
127
 
128
//==========================================================================
129
 
130
__externC void
131
cyg_start( void )
132
{
133
 
134
    CYG_TEST_INIT();
135
 
136
    Derived derived(1);
137
    Pure *pure = &derived;
138
 
139
    CYG_TEST_INFO("Calling derived members");
140
    derived.pure_fun1();
141
    derived.pure_fun2();
142
    derived.impure_fun1();
143
    derived.impure_fun2();
144
    derived.inline_fun1();
145
 
146
    CYG_TEST_INFO("Calling pure members");
147
    pure->pure_fun1();
148
    pure->pure_fun2();
149
    pure->impure_fun1();
150
    pure->inline_fun1();
151
 
152
#if CYGINT_ISO_MALLOC && (!defined(CYGPKG_HAL_ARM) || (__GNUC_VERSION__ >= 30300))
153
    Derived *derived2 = new Derived(2);
154
    Pure *pure2 = derived2;
155
 
156
    CYG_TEST_INFO("Calling derived2 members");
157
    derived2->pure_fun1();
158
    derived2->pure_fun2();
159
    derived2->impure_fun1();
160
    derived2->impure_fun2();
161
    derived2->inline_fun1();
162
 
163
    CYG_TEST_INFO("Calling pure2 members");
164
    pure2->pure_fun1();
165
    pure2->pure_fun2();
166
    pure2->impure_fun1();
167
    pure2->inline_fun1();
168
 
169
    delete derived2;
170
 
171
#else
172
    CYG_TEST_INFO("No malloc support, new and delete not tested");
173
#endif
174
 
175
    CYG_TEST_PASS_FINISH("C++ Support OK");
176
}
177
 
178
//==========================================================================
179
 
180
#else
181
 
182
__externC void
183
cyg_start( void )
184
{
185
 
186
    CYG_TEST_INIT();
187
 
188
    CYG_TEST_NA("C++ not supported on this architecture\n");
189
}
190
 
191
#endif
192
 
193
//==========================================================================
194
// EOF cxxsupp.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.