Exemplo n.º 1
0
int library_3rd_party(int foobar){

    volatile int status = LIBRARY_SUCCESS;

    /* We know that the client is exception-unaware */
    TEST_ASSERT( !e4c_context_is_ready() );

    {
        e4c_reusing_context(status, LIBRARY_FAILURE){

            E4C_TRY{

                library_function(foobar);
            }
        }
    }
Exemplo n.º 2
0
int library_3rd_party(int foobar){

    volatile int status = LIBRARY_SUCCESS;

    /* We know that the client is exception-unaware */
    TEST_ASSERT( !e4c_context_is_ready() );

    {
        e4c_reusing_context(status, LIBRARY_FAILURE){

            E4C_TRY{

                library_function(foobar);

            }E4C_CATCH(RuntimeException){

                TEST_ASSERT( e4c_is_instance_of(e4c_get_exception(), &IllegalArgumentException) );
            }
        }
    }
Exemplo n.º 3
0
void builtin_init(void)
{
    initfpconst(&fc_zero, "0.0");
#ifdef PASCAL /*ECN*/
    initfpconst(&fc_half, "0.5");
    fc_big.s = real_of_string("3.40282347e+38", bitoftype_(s_double) |
                                                bitoftype_(s_short));
    fc_big.d = real_of_string("1.79769313486231571e+308",
                                                bitoftype_(s_double));
#endif
    initfpconst(&fc_one, "1.0");
    initfpconst(&fc_two, "2.0");
    initfpconst(&fc_minusone, "-1.0");

    fc_two_31 = real_of_string("2147483648.0", bitoftype_(s_double));
#define initprimtype_(t) (TypeExpr*)global_list4(SU_Other, s_typespec, (t),0,0);
    te_int = initprimtype_(bitoftype_(s_int));
    te_uint = initprimtype_(bitoftype_(s_int)|bitoftype_(s_unsigned));
    te_lint = initprimtype_(bitoftype_(s_int)|bitoftype_(s_long));
    te_ulint = initprimtype_(bitoftype_(s_int)|bitoftype_(s_long)|
                             bitoftype_(s_unsigned));
    te_double = initprimtype_(bitoftype_(s_double));
    te_float = initprimtype_(bitoftype_(s_double)|bitoftype_(s_short));
    te_ldble = initprimtype_(bitoftype_(s_double)|bitoftype_(s_long));
    te_void = initprimtype_(bitoftype_(s_void));

#if defined(TARGET_IS_UNIX) && !defined(TARGET_IS_SPARC)
    sim.mulfn = library_function("x$mul", 2, 2, bitoffnaux_(s_pure));
    sim.divfn = library_function("x$div", 2, 2, bitoffnaux_(s_pure));
    sim.udivfn = library_function("x$udiv", 2, 2, bitoffnaux_(s_pure));
    sim.divtestfn = library_function("x$divtest", 1, 1, bitoffnaux_(s_pure));
    sim.remfn = library_function("x$mod", 2, 2, bitoffnaux_(s_pure));
    sim.uremfn = library_function("x$umod", 2, 2, bitoffnaux_(s_pure));
    sim.fdivfn = library_function("x$fdiv", 2, 2, bitoffnaux_(s_pure));
    sim.ddivfn = library_function("x$ddiv", 2, 2, bitoffnaux_(s_pure));
#else
#ifdef TARGET_LINKER_OMITS_DOLLAR
    sim.mulfn = library_function("__multiply", 2, 2, bitoffnaux_(s_pure));
    sim.divfn = library_function("__divide", 2, 2, bitoffnaux_(s_pure));
    sim.udivfn = library_function("__udivide", 2, 2, bitoffnaux_(s_pure));
    sim.divtestfn = library_function("__divtest", 1, 1, bitoffnaux_(s_pure));
    sim.remfn = library_function("__remainder", 2, 2, bitoffnaux_(s_pure));
    sim.uremfn = library_function("__uremainder", 2, 2, bitoffnaux_(s_pure));
    sim.fdivfn = library_function("__fdivide", 2, 2, bitoffnaux_(s_pure));
    sim.ddivfn = library_function("__ddivide", 2, 2, bitoffnaux_(s_pure));
#else
/* the 'obsolete's below refer to the ARM only.                         */
    sim.mulfn = library_function("x$multiply", 2, 2, bitoffnaux_(s_pure));  /* obsolete */
#if defined(TARGET_IS_ARM) && !defined(OBSOLETE_ARM_NAMES)
    sim.divfn = library_function("__rt_sdiv", 2, 2, bitoffnaux_(s_pure));
    sim.udivfn = library_function("__rt_udiv", 2, 2, bitoffnaux_(s_pure));
    sim.divtestfn = library_function("__rt_divtest", 1, 1, bitoffnaux_(s_pure));
#else
    sim.divfn = library_function("x$divide", 2, 2, bitoffnaux_(s_pure));
    sim.udivfn = library_function("x$udivide", 2, 2, bitoffnaux_(s_pure));
    sim.divtestfn = library_function("x$divtest", 1, 1, bitoffnaux_(s_pure));
#endif
    sim.remfn = library_function("x$remainder", 2, 2, bitoffnaux_(s_pure));     /* obsolete */
    sim.uremfn = library_function("x$uremainder", 2, 2, bitoffnaux_(s_pure));   /* obsolete */
    sim.fdivfn = library_function("x$fdivide", 2, 2, bitoffnaux_(s_pure));
    sim.ddivfn = library_function("x$ddivide", 2, 2, bitoffnaux_(s_pure));
#endif
#endif
#ifdef TARGET_HAS_DIV_10_FUNCTION
#if defined(TARGET_IS_ARM) && !defined(OBSOLETE_ARM_NAMES)
    sim.div10fn = library_function("__rt_sdiv10", 1, 1, bitoffnaux_(s_pure));
    sim.udiv10fn = library_function("__rt_udiv10", 1, 1, bitoffnaux_(s_pure));
#else
    sim.div10fn = library_function("_kernel_sdiv10", 1, 1, bitoffnaux_(s_pure));
    sim.udiv10fn = library_function("_kernel_udiv10", 1, 1, bitoffnaux_(s_pure));
#endif
    sim.rem10fn = library_function("_kernel_srem10", 1, 1, bitoffnaux_(s_pure));  /* obsolete */
    sim.urem10fn = library_function("_kernel_urem10", 1, 1, bitoffnaux_(s_pure)); /* obsolete */
#endif
    sim.xprintf = library_function("_printf", 1, 1999, 0L);
    sim.xfprintf = library_function("_fprintf", 2, 1999, 0L);
    sim.xsprintf = library_function("_sprintf", 2, 1999, 0L);
    sim.yprintf = sym_insert_id("printf");
    sim.yfprintf = sym_insert_id("fprintf");
    sim.ysprintf = sym_insert_id("sprintf");
#ifdef SOFTWARE_FLOATING_POINT
    sim.dadd = floating_function(2,te_double,te_double,te_double,"_dadd");
    sim.dsubtract = floating_function(2,te_double,te_double,te_double,"_dsub");
    sim.dmultiply = floating_function(2,te_double,te_double,te_double,"_dmul");
    sim.ddivide = floating_function(2,te_double,te_double,te_double,"_ddiv");
    sim.dnegate = floating_function(1,te_double,te_double,NULL,"_dneg");
    sim.dgreater = floating_function(2,te_int,te_double,te_double,"_dgr");
    sim.dgeq = floating_function(2,te_int,te_double,te_double,"_dgeq");
    sim.dless = floating_function(2,te_int,te_double,te_double,"_dls");
    sim.dleq = floating_function(2,te_int,te_double,te_double,"_dleq");
    sim.dequal = floating_function(2,te_int,te_double,te_double,"_deq");
    sim.dneq = floating_function(2,te_int,te_double,te_double,"_dneq");
    sim.dfloat = floating_function(1,te_double,te_int,NULL,"_dflt");
    sim.dfloatu = floating_function(1,te_double,te_uint,NULL,"_dfltu");
    sim.dfix = floating_function(1,te_int,te_double,NULL,"_dfix");
    sim.dfixu = floating_function(1,te_uint,te_double,NULL,"_dfixu");

    sim.fadd = floating_function(2,te_float,te_int,te_int,"_fadd");
    sim.fsubtract = floating_function(2,te_float,te_int,te_int,"_fsub");
    sim.fmultiply = floating_function(2,te_float,te_int,te_int,"_fmul");
    sim.fdivide = floating_function(2,te_float,te_int,te_int,"_fdiv");
    sim.fnegate = floating_function(1,te_float,te_int,NULL,"_fneg");
    sim.fgreater = floating_function(2,te_int,te_int,te_int,"_fgr");
    sim.fgeq = floating_function(2,te_int,te_int,te_int,"_fgeq");
    sim.fless = floating_function(2,te_int,te_int,te_int,"_fls");
    sim.fleq = floating_function(2,te_int,te_int,te_int,"_fleq");
    sim.fequal = floating_function(2,te_int,te_int,te_int,"_feq");
    sim.fneq = floating_function(2,te_int,te_int,te_int,"_fneq");
    sim.ffloat = floating_function(1,te_float,te_int,NULL,"_fflt");
    sim.ffloatu = floating_function(1,te_float,te_uint,NULL,"_ffltu");
    sim.ffix = floating_function(1,te_int,te_int,NULL,"_ffix");
    sim.ffixu = floating_function(1,te_uint,te_int,NULL,"_ffixu");

    sim.fnarrow = floating_function(1,te_float,te_double,NULL,"_d2f");
    sim.dwiden = floating_function(1,te_double,te_float,NULL,"_f2d");
#endif
#if defined(TARGET_IS_ARM) && !defined(OBSOLETE_ARM_NAMES)
    sim.readcheck1 = library_function("__rt_rd1chk", 1, 1, bitoffnaux_(s_pure));
    sim.readcheck2 = library_function("__rt_rd2chk", 1, 1, bitoffnaux_(s_pure));
    sim.readcheck4 = library_function("__rt_rd4chk", 1, 1, bitoffnaux_(s_pure));
    sim.writecheck1 = library_function("__rt_wr1chk", 1, 1, bitoffnaux_(s_pure));
    sim.writecheck2 = library_function("__rt_wr2chk", 1, 1, bitoffnaux_(s_pure));
    sim.writecheck4 = library_function("__rt_wr4chk", 1, 1, bitoffnaux_(s_pure));
#else
    sim.readcheck1 = library_function("_rd1chk", 1, 1, bitoffnaux_(s_pure));
    sim.readcheck2 = library_function("_rd2chk", 1, 1, bitoffnaux_(s_pure));
    sim.readcheck4 = library_function("_rd4chk", 1, 1, bitoffnaux_(s_pure));
    sim.writecheck1 = library_function("_wr1chk", 1, 1, bitoffnaux_(s_pure));
    sim.writecheck2 = library_function("_wr2chk", 1, 1, bitoffnaux_(s_pure));
    sim.writecheck4 = library_function("_wr4chk", 1, 1, bitoffnaux_(s_pure));
#endif
#if alignof_struct == 1
/* The following is a bit of a hack for MIPS, but the essence is that   */
/* if we hope to inline memcpy then we may wish to rely on alignment    */
/* of structs to do word copy.  If we used memcpy instead of _memcpy    */
/* when alignof_struct=4 then we would not be able to distinguish an    */
/* aligned call struct a=b; from a non-aligned call memcpy(a+1,b+1,4).  */
    sim.memcpyfn = library_function("memcpy", 3, 3, 0L);
    sim.memsetfn = library_function("memset", 3, 3, 0L);
    sim.realmemcpyfn = sim.memcpyfn;
#else
    sim.memcpyfn = library_function("_memcpy", 3, 3, 0L);
    sim.memsetfn = library_function("_memset", 3, 3, 0L);
    sim.realmemcpyfn = library_function("memcpy", 3, 3, 0L);
#endif
    sim.strcpysym = sym_insert_id("strcpy");
    mallocsym = sym_insert_id("malloc");
    callocsym = sym_insert_id("calloc");
    reallocsym = sym_insert_id("realloc");
/* _word(nnn) is a specially-treated 'function' to put nnn in-line in the */
/* generated code.  People may have views on a better name for it, esp.   */
/* in view of machines with byte and halfword instructions!               */
/* Introduced by ACN to help him with an 88000 library.                   */
    sim.inserted_word = library_function("_word", 1, 1, 0L);
#ifndef TARGET_IS_C40
    add_toplevel_binder((Binder *)arg1_(sim.inserted_word));
#endif

#ifdef TARGET_IS_ACW
    c_handler = sym_insert_id(SYSPFX"c_handler");
    stackcheck = sym_insert_id(SYSPFX"stackcheck");
    heapend = sym_insert_id("CurrentHeapEnd");
#endif
#ifdef TARGET_LINKER_OMITS_DOLLAR
    stackoverflow = sym_insert_id("__stack_overflow");
    stack1overflow = sym_insert_id("__stack_overflow_1");
#else
#if defined(TARGET_IS_ARM) && !defined(OBSOLETE_ARM_NAMES)
    stackoverflow  = sym_insert_id("__rt_stkovf_split_small");
    stack1overflow = sym_insert_id("__rt_stkovf_split_big");
#else
    stackoverflow = sym_insert_id("x$stack_overflow");
    stack1overflow = sym_insert_id("x$stack_overflow_1");
#endif
#endif
    datasegment = global_mk_binder(0,
#ifdef UNIQUE_DATASEG_NAMES
                sym_insert_id(probably_unique_name('d')),
#else
#ifdef TARGET_LINKER_OMITS_DOLLAR
                sym_insert_id("__dataseg"),
#else
                sym_insert_id("x$dataseg"),
#endif
#endif
                bitofstg_(s_static),
                te_int);

    codesegment = global_mk_binder(0,
#ifdef UNIQUE_DATASEG_NAMES
                sym_insert_id(probably_unique_name('c')),
#else
#ifdef TARGET_LINKER_OMITS_DOLLAR
                sym_insert_id("__codeseg"),
#else
                sym_insert_id("x$codeseg"),
#endif
#endif
                bitofstg_(s_static),
                te_int);
    
#ifdef TARGET_HAS_BSS
    bsssegment = global_mk_binder(0,
#ifdef UNIQUE_DATASEG_NAMES
                sym_insert_id(probably_unique_name('z')),
#else
#ifdef TARGET_LINKER_OMITS_DOLLAR
                sym_insert_id("_bssseg"),
#else
                sym_insert_id("x$bssseg"),
#endif
#endif
                bitofstg_(s_static),
                te_int);
#endif
    constdatasegment = global_mk_binder(0,
#ifdef UNIQUE_DATASEG_NAMES
                sym_insert_id(probably_unique_name('q')),
#else
#ifdef TARGET_LINKER_OMITS_DOLLAR
                sym_insert_id("_constdata"),
#else
                sym_insert_id("x$constdata"),
#endif
#endif
                bitofstg_(s_static),
                te_int);
#ifdef CPLUSPLUS
    thissym = sym_insert_id("___this");         /* CPLUSPLUS            */
/* The next 2 lines have these exact names to match [ES] and overload.c */
    ctorsym = sym_insert_id("__ctor");          /* CPLUSPLUS            */
    dtorsym = sym_insert_id("__dtor");          /* CPLUSPLUS            */
    vtabsym = sym_insert_id("__VTABLE__");      /* CPLUSPLUS            */
#endif
    mainsym = sym_insert_id("main");
    setjmpsym = sym_insert_id("setjmp");
#ifdef TARGET_IS_C40
    /* SaveCPUState() is functionally equivalent to setjmp() and must have similar protection */
    SaveCPUStatesym = sym_insert_id( "SaveCPUState" );
#endif
    assertsym = sym_insert_id("___assert");
/* AM: hmm, is the name '___assert right in that users might get to see */
/* it if (say) a semicolon is omitted (check macro which use) and       */
/* query the next line which would mean ___assert without () fn call    */
/* would not get reported, or be done confusingly.  Probably OK.        */
    implicit_decl(assertsym, 1);    /* forge an 'extern int ___assert()' */
    first_arg_sym = sym_insert_id("___first_arg");
    last_arg_sym = sym_insert_id("___last_arg");
    libentrypoint = sym_insert_id("__main");
#ifdef TARGET_LINKER_OMITS_DOLLAR
    countroutine = sym_insert_id("__mcount");/*for Unix, x$ goes*/
#else
    countroutine = sym_insert_id("x$mcount");/*for Unix, x$ goes*/
#endif
    count1routine = sym_insert_id("_count1");
#ifdef RANGECHECK_SUPPORTED
#ifdef PASCAL /*ECN*/
    sim.abcfault = sym_insert_id("_range");
    sim.valfault = sym_insert_id("_badvalue");
#else
    sim.abcfault = sym_insert_id("s_rnge"); /* BSD F77 library name */
    sim.valfault = sym_insert_id("x$badvalue");
#endif
#endif
#ifdef TARGET_IS_KCM
    FPArg1         = sym_insert_id("_ARG1");
    FPArg2         = sym_insert_id("_ARG2");
    FPArg1x        = sym_insert_id("_ARG1_x1");
    FPArg2x        = sym_insert_id("_ARG2_x1");
    cnvtdw_routine = sym_insert_id("_CNVTDW");
    cnvtwd_routine = sym_insert_id("_CNVTWD");
    cnvtds_routine = sym_insert_id("_CNVTDS");
    cnvtsd_routine = sym_insert_id("_CNVTSD");
    addd_routine   = sym_insert_id("_ADDD");
    subd_routine   = sym_insert_id("_SUBD");
    negd_routine   = sym_insert_id("_NEGD");
    muld_routine   = sym_insert_id("_MULD");
    divd_routine   = sym_insert_id("_DIVD");
    cmpd_routine   = sym_insert_id("_CMPD");
    divu_routine   = sym_insert_id("_DIVU");
    remu_routine   = sym_insert_id("_REMU");
#endif
#ifdef TARGET_IS_SPARC
    fparg1         = sym_insert_id("_fparg1");
    multiply       = sym_insert_id("__multiply");
    divide         = sym_insert_id("__divide");
    udivide        = sym_insert_id("__udivide");
#endif
#if defined TARGET_HAS_DEBUGGER && TARGET_IS_HELIOS
    _notify_entry   = sym_insert_id( "_notify_entry"   );
    _notify_return  = sym_insert_id( "_notify_return"  );
    _notify_command = sym_insert_id( "_notify_command" );
#endif
}
Exemplo n.º 4
0
void call_static_library() {
  library_function("Hello from static function call \n");
};