/*=================================================================
|
/*=================================================================
|
//
|
//
|
// cpp1.c
|
// cpp1.c
|
//
|
//
|
// cpp arithmetic bug regression test
|
// cpp arithmetic bug regression test
|
//
|
//
|
//==========================================================================
|
//==========================================================================
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
// -------------------------------------------
|
// -------------------------------------------
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
//
|
//
|
// eCos is free software; you can redistribute it and/or modify it under
|
// eCos is free software; you can redistribute it and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
// Software Foundation; either version 2 or (at your option) any later version.
|
// Software Foundation; either version 2 or (at your option) any later version.
|
//
|
//
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along
|
// You should have received a copy of the GNU General Public License along
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
//
|
//
|
// As a special exception, if other files instantiate templates or use macros
|
// As a special exception, if other files instantiate templates or use macros
|
// or inline functions from this file, or you compile this file and link it
|
// or inline functions from this file, or you compile this file and link it
|
// with other works to produce a work based on this file, this file does not
|
// with other works to produce a work based on this file, this file does not
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// License. However the source code for this file must still be made available
|
// License. However the source code for this file must still be made available
|
// in accordance with section (3) of the GNU General Public License.
|
// in accordance with section (3) of the GNU General Public License.
|
//
|
//
|
// This exception does not invalidate any other reasons why a work based on
|
// This exception does not invalidate any other reasons why a work based on
|
// this file might be covered by the GNU General Public License.
|
// this file might be covered by the GNU General Public License.
|
//
|
//
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// -------------------------------------------
|
// -------------------------------------------
|
//####ECOSGPLCOPYRIGHTEND####
|
//####ECOSGPLCOPYRIGHTEND####
|
//==========================================================================
|
//==========================================================================
|
//#####DESCRIPTIONBEGIN####
|
//#####DESCRIPTIONBEGIN####
|
//
|
//
|
// Author(s): hmt
|
// Author(s): hmt
|
// Contributors: hmt
|
// Contributors: hmt
|
// Date: 2001-04-30
|
// Date: 2001-04-30
|
//####DESCRIPTIONEND####
|
//####DESCRIPTIONEND####
|
*/
|
*/
|
|
|
#include <pkgconf/hal.h>
|
#include <pkgconf/hal.h>
|
|
|
#include <pkgconf/infra.h>
|
#include <pkgconf/infra.h>
|
|
|
#include <cyg/infra/testcase.h>
|
#include <cyg/infra/testcase.h>
|
|
|
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
// This is smaller than 2048.
|
// This is smaller than 2048.
|
// Unless the parser binds '+' too strongly because it is after a ket, so
|
// Unless the parser binds '+' too strongly because it is after a ket, so
|
// it is mistaken for unary plus, when (4 * 20 + 2) * 4 * 20 is larger.
|
// it is mistaken for unary plus, when (4 * 20 + 2) * 4 * 20 is larger.
|
#define CYGNUM_HAL_STACK_SIZE_MINIMUM ((4 * 20) + 2 * 4 * 20)
|
#define CYGNUM_HAL_STACK_SIZE_MINIMUM ((4 * 20) + 2 * 4 * 20)
|
|
|
#define CYGNUM_UITRON_STACK_SIZE (2048)
|
#define CYGNUM_UITRON_STACK_SIZE (2048)
|
|
|
#ifdef CYGNUM_HAL_STACK_SIZE_MINIMUM
|
#ifdef CYGNUM_HAL_STACK_SIZE_MINIMUM
|
# ifdef CYGNUM_UITRON_STACK_SIZE
|
# ifdef CYGNUM_UITRON_STACK_SIZE
|
# if CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM
|
# if CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM
|
|
|
// then override the configured stack size
|
// then override the configured stack size
|
# undef CYGNUM_UITRON_STACK_SIZE
|
# undef CYGNUM_UITRON_STACK_SIZE
|
# define CYGNUM_UITRON_STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM
|
# define CYGNUM_UITRON_STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM
|
|
|
# endif // CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM
|
# endif // CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM
|
# endif // CYGNUM_UITRON_STACK_SIZE
|
# endif // CYGNUM_UITRON_STACK_SIZE
|
#endif // CYGNUM_HAL_STACK_SIZE_MINIMUM
|
#endif // CYGNUM_HAL_STACK_SIZE_MINIMUM
|
|
|
|
|
// This tests for the bug per se:
|
// This tests for the bug per se:
|
int i = CYGNUM_UITRON_STACK_SIZE;
|
int i = CYGNUM_UITRON_STACK_SIZE;
|
|
|
// This tests the workaround independently of more complex context:
|
// This tests the workaround independently of more complex context:
|
#define MAX(_x_,_y_) ((_x_) > (_y_) ? (_x_) : (_y_))
|
#define MAX(_x_,_y_) ((_x_) > (_y_) ? (_x_) : (_y_))
|
|
|
static char stack1[
|
static char stack1[
|
MAX(
|
MAX(
|
CYGNUM_HAL_STACK_SIZE_MINIMUM,
|
CYGNUM_HAL_STACK_SIZE_MINIMUM,
|
2048)
|
2048)
|
];
|
];
|
|
|
// Better to report a fully-fledged failure and test the workaround than
|
// Better to report a fully-fledged failure and test the workaround than
|
// fail early.
|
// fail early.
|
#if 0
|
#if 0
|
# if CYGNUM_UITRON_STACK_SIZE != 2048
|
# if CYGNUM_UITRON_STACK_SIZE != 2048
|
# error FAIL: CPP '+' binding bug detected
|
# error FAIL: CPP '+' binding bug detected
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
externC void
|
externC void
|
cyg_start( void )
|
cyg_start( void )
|
{
|
{
|
CYG_TEST_INIT();
|
CYG_TEST_INIT();
|
CYG_TEST_PASS("CPP '+' binding test compiled OK");
|
CYG_TEST_PASS("CPP '+' binding test compiled OK");
|
CYG_TEST_PASS_FAIL( 2048 == i, "initialized i should be 2048" );
|
CYG_TEST_PASS_FAIL( 2048 == i, "initialized i should be 2048" );
|
CYG_TEST_PASS_FAIL( 2048 == sizeof( stack1 ),
|
CYG_TEST_PASS_FAIL( 2048 == sizeof( stack1 ),
|
"workaround: sizeof( stack1 ) should be 2048" );
|
"workaround: sizeof( stack1 ) should be 2048" );
|
CYG_TEST_EXIT("All done");
|
CYG_TEST_EXIT("All done");
|
}
|
}
|
|
|
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
/* EOF cpp1.c */
|
/* EOF cpp1.c */
|
|
|