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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [infra/] [v2_0/] [tests/] [cxxsupp.cxx] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
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 Nick Garnett <nickg@calivar.com>
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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting the copyright
37
// holders.
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):     nickg
44
// Contributors:  nickg
45
// Date:          2003-04-01
46
// Description:   Simple test for C++ runtime support.
47
//
48
//####DESCRIPTIONEND####
49
//==========================================================================
50
 
51
#include <pkgconf/hal.h>
52
#include <pkgconf/isoinfra.h>
53
 
54
#include <cyg/infra/testcase.h>
55
#include <cyg/infra/diag.h>
56
 
57
#include <new>
58
 
59
//==========================================================================
60
 
61
class Pure
62
{
63
protected:
64
    int instance;
65
public:
66
    Pure(int i);
67
    virtual void pure_fun1(void) = 0;
68
    virtual void pure_fun2(void) = 0;
69
    virtual void impure_fun1(void);
70
    inline void inline_fun1(void);
71
};
72
 
73
Pure::Pure(int i)
74
{
75
    instance = i;
76
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
77
}
78
 
79
void Pure::impure_fun1()
80
{
81
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
82
}
83
 
84
//==========================================================================
85
 
86
class Derived : public Pure
87
{
88
public:
89
    Derived(int i);
90
    void pure_fun1(void);
91
    void pure_fun2(void);
92
    void impure_fun2(void);
93
};
94
 
95
Derived::Derived(int i)
96
    : Pure(i)
97
{
98
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
99
}
100
 
101
void Derived::pure_fun1(void)
102
{
103
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
104
}
105
 
106
void Derived::pure_fun2(void)
107
{
108
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
109
}
110
 
111
 
112
void Derived::impure_fun2(void)
113
{
114
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
115
}
116
 
117
//==========================================================================
118
 
119
__externC void
120
cyg_start( void )
121
{
122
 
123
    CYG_TEST_INIT();
124
 
125
    Derived derived(1);
126
    Pure *pure = &derived;
127
 
128
    CYG_TEST_INFO("Calling derived members");
129
    derived.pure_fun1();
130
    derived.pure_fun2();
131
    derived.impure_fun1();
132
    derived.impure_fun2();
133
    derived.inline_fun1();
134
 
135
    CYG_TEST_INFO("Calling pure members");
136
    pure->pure_fun1();
137
    pure->pure_fun2();
138
    pure->impure_fun1();
139
    pure->inline_fun1();
140
 
141
#if CYGINT_ISO_MALLOC
142
    Derived *derived2 = new Derived(2);
143
    Pure *pure2 = derived2;
144
 
145
    CYG_TEST_INFO("Calling derived2 members");
146
    derived2->pure_fun1();
147
    derived2->pure_fun2();
148
    derived2->impure_fun1();
149
    derived2->impure_fun2();
150
    derived2->inline_fun1();
151
 
152
    CYG_TEST_INFO("Calling pure2 members");
153
    pure2->pure_fun1();
154
    pure2->pure_fun2();
155
    pure2->impure_fun1();
156
    pure2->inline_fun1();
157
 
158
    delete derived2;
159
 
160
#else
161
    CYG_TEST_INFO("No malloc support, new and delete not tested");
162
#endif
163
 
164
    CYG_TEST_PASS_FINISH("C++ Support OK");
165
}
166
 
167
//==========================================================================
168
 
169
void Pure::inline_fun1()
170
{
171
    diag_printf("%s(%d) called\n",__PRETTY_FUNCTION__,instance);
172
}
173
 
174
//==========================================================================
175
// EOF cxxsupp.cxx

powered by: WebSVN 2.1.0

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