comparison packages/hal/common/current/tests/cpp1.c @ 159:511f4dc167f6

Merge from eCos master repository on 2001-05-18-01:30:05-BST
author jlarmour
date Fri, 18 May 2001 06:32:28 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
158:f2545e5de153 159:511f4dc167f6
1 /*=================================================================
2 //
3 // cpp1.c
4 //
5 // cpp arithmetic bug regression test
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Red Hat eCos Public License
12 // Version 1.1 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://www.redhat.com/
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000, 2001 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //==========================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): hmt
35 // Contributors: hmt
36 // Date: 2001-04-30
37 //####DESCRIPTIONEND####
38 */
39
40 #include <pkgconf/hal.h>
41
42 #include <pkgconf/infra.h>
43
44 #include <cyg/infra/testcase.h>
45
46 // -----------------------------------------------------------------
47 // This is smaller than 2048.
48 // Unless the parser binds '+' too strongly because it is after a ket, so
49 // it is mistaken for unary plus, when (4 * 20 + 2) * 4 * 20 is larger.
50 #define CYGNUM_HAL_STACK_SIZE_MINIMUM ((4 * 20) + 2 * 4 * 20)
51
52 #define CYGNUM_UITRON_STACK_SIZE (2048)
53
54 #ifdef CYGNUM_HAL_STACK_SIZE_MINIMUM
55 # ifdef CYGNUM_UITRON_STACK_SIZE
56 # if CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM
57
58 // then override the configured stack size
59 # undef CYGNUM_UITRON_STACK_SIZE
60 # define CYGNUM_UITRON_STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM
61
62 # endif // CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM
63 # endif // CYGNUM_UITRON_STACK_SIZE
64 #endif // CYGNUM_HAL_STACK_SIZE_MINIMUM
65
66
67 // This tests for the bug per se:
68 int i = CYGNUM_UITRON_STACK_SIZE;
69
70 // This tests the workaround independently of more complex context:
71 #define MAX(_x_,_y_) ((_x_) > (_y_) ? (_x_) : (_y_))
72
73 static char stack1[
74 MAX(
75 CYGNUM_HAL_STACK_SIZE_MINIMUM,
76 2048)
77 ];
78
79 // Better to report a fully-fledged failure and test the workaround than
80 // fail early.
81 #if 0
82 # if CYGNUM_UITRON_STACK_SIZE != 2048
83 # error FAIL: CPP '+' binding bug detected
84 # endif
85 #endif
86
87 // -------------------------------------------------------------------------
88 externC void
89 cyg_start( void )
90 {
91 CYG_TEST_INIT();
92 CYG_TEST_PASS("CPP '+' binding test compiled OK");
93 CYG_TEST_PASS_FAIL( 2048 == i, "initialized i should be 2048" );
94 CYG_TEST_PASS_FAIL( 2048 == sizeof( stack1 ),
95 "workaround: sizeof( stack1 ) should be 2048" );
96 CYG_TEST_EXIT("All done");
97 }
98
99 // -------------------------------------------------------------------------
100 /* EOF cpp1.c */