Exemple #1
0
/* AppWarmStart():
 * This function is provided to allow the application to partially
 * restart the monitor.  It supports the situation where an application
 * run but the monitor has not already been initialized.  This would be
 * the case if some type of debugger (JTAG or BDM probably) was attached
 * to the target and it was used to download and run the application.
 * If this type of debug connection does not support the ability to run
 * after the monitor runs, then the application must be able to somehow
 * get the monitor initialized without having it go through a complete
 * warmstart.
 * This will only run through the stack space provided by the application.
 */
void
AppWarmStart(ulong mask)
{
    /* First initialize monitor bss space (skipping over MonStack[]): */
    if(mask & WARMSTART_BSSINIT) {
        umonBssInit();
    }

    StateOfMonitor = INITIALIZE;

    /* Initialize some of the real fundamental stuff regardless of
     * the incoming mask.
     */
    init0();

    /* Subset of init1(): */
    if(mask & WARMSTART_IOINIT) {
        initCPUio();
        InitRemoteIO();
        if(ConsoleBaudRate == 0) {
            ConsoleBaudRate = DEFAULT_BAUD_RATE;
        }
        devInit(ConsoleBaudRate);
    }
    init2();
    _init3(mask);
}
void main(){
	int n = 4;
    	int a[] = {1, 2, 9, 3 };
    	int m = 3;
    	int b[] = { 9, 9, 2 };

    	Node* head1 = init0(a,n);
    	Node* head2 = init0(b,m);

    	Node* res = listAdd(head1,head2);
    	print(res);

    	destroy(head1);
    	destroy(head2);
    	destroy(res);
}
Exemple #3
0
RBBIDataWrapper::RBBIDataWrapper(UDataMemory* udm, UErrorCode &status) {
    init0();
    if (U_FAILURE(status)) {
        return;
    }
    const DataHeader *dh = udm->pHeader;
    int32_t headerSize = dh->dataHeader.headerSize;
    if (  !(headerSize >= 20 &&
            dh->info.isBigEndian == U_IS_BIG_ENDIAN &&
            dh->info.charsetFamily == U_CHARSET_FAMILY &&
            dh->info.dataFormat[0] == 0x42 &&  // dataFormat="Brk "
            dh->info.dataFormat[1] == 0x72 &&
            dh->info.dataFormat[2] == 0x6b &&
            dh->info.dataFormat[3] == 0x20)
            // Note: info.fFormatVersion is duplicated in the RBBIDataHeader, and is
            //       validated when checking that.
        ) {
        status = U_INVALID_FORMAT_ERROR;
        return;
    }
    const char *dataAsBytes = reinterpret_cast<const char *>(dh);
    const RBBIDataHeader *rbbidh = reinterpret_cast<const RBBIDataHeader *>(dataAsBytes + headerSize);
    init(rbbidh, status);
    fUDataMem = udm;
}
Exemple #4
0
//#define _SUBR		0x06	// 引数評価・C
//#define _EXPR		0x04	// 引数評価
//#define _FSUBR	0x02	// 引数評価しない・C
// 組み込み関数の登録
void init_subr()
{
	init0();
	init1();
	init2();
	init3();
	init4();
}
Exemple #5
0
U_NAMESPACE_BEGIN

//-----------------------------------------------------------------------------
//
//    Constructors.
//
//-----------------------------------------------------------------------------
RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, UErrorCode &status) {
    init0();
    init(data, status);
}
Exemple #6
0
void Waiter::wait()
{
    if (proceeder.unique())
    {
        JLOG("everything done, nothing to do");
        return;
    }
    defer([this] {
        auto toDestroy = std::move(proceeder);
    });
    init0();
}
Exemple #7
0
MYFLT csoundEvalCode(CSOUND *csound, const char *str)
{
  int async = 0;
  if (str && csoundCompileOrcInternal(csound,str,async)
      == CSOUND_SUCCESS){
    if(!(csound->engineStatus & CS_STATE_COMP)) {
      init0(csound);
    }
      return csound->instr0->instance[0].retval;
    }
#ifdef NAN
  else return NAN;
#else
  else return 0;
Exemple #8
0
Coro::Coro(Handler handler)
{
    init0();
    start(std::move(handler));
}
Exemple #9
0
Coro::Coro()
{
    init0();
}
        void init(init_desc* desc_ptr)
        {
            std::string t;

#ifdef OX_DEBUG
            t += "OX_DEBUG ";
#endif

#ifdef NDEBUG
            t += "NDEBUG ";
#endif

#ifdef _DEBUG
            t += "_DEBUG ";
#endif

#ifdef DEBUG
            t += "DEBUG ";
#endif

            log::messageln("build settings %s", t.c_str());

            init0();


            log::messageln("initialize oxygine");
            if (desc_ptr)
                desc = *desc_ptr;

#ifdef __S3E__
            log::messageln("S3E build");
            if (!IwGLInit())
            {
                s3eDebugErrorShow(S3E_MESSAGE_CONTINUE, "IwGLInit failed");
                return;
            }
            //init_ext();

            int width = IwGLGetInt(IW_GL_WIDTH);
            int height = IwGLGetInt(IW_GL_HEIGHT);

            log::messageln("Screen BPP  : %d", s3eSurfaceGetInt(S3E_SURFACE_PIXEL_TYPE) & S3E_SURFACE_PIXEL_SIZE_MASK);
            log::messageln("Screen Size : %dx%d", width, height);
            log::messageln("Vendor      : %s", (const char*)glGetString(GL_VENDOR));
            log::messageln("Renderer    : %s", (const char*)glGetString(GL_RENDERER));

            const char* version = (const char*)glGetString(GL_VERSION);
            log::messageln("Version    : %s", version);

            s3ePointerUpdate();
            if (s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE))
            {
                s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, &pointerTouchEvent, 0);
                s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &pointerTouchMotionEvent, 0);
            }
            else
            {
                s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &pointerEvent, 0);
                s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &pointerMotionEvent, 0);
            }

            s3eDeviceRegister(S3E_DEVICE_UNPAUSE, applicationUnPause, 0);
            s3eDeviceRegister(S3E_DEVICE_PAUSE, applicationPause, 0);

#elif OXYGINE_SDL

            log::messageln("SDL build");


            SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");

            SDL_Init(SDL_INIT_VIDEO);


            if (desc.mode24bpp)
            {
                SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
                SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
                SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
            }
            else
            {
                SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
                SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
                SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
            }

            SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
            //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
            //SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

            if (desc.force_gles)
            {
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
            }

            SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);

            int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;

#if TARGET_OS_IPHONE
            flags |= SDL_WINDOW_BORDERLESS;
            flags |= SDL_WINDOW_ALLOW_HIGHDPI;
            flags |= SDL_WINDOW_FULLSCREEN;
#endif

            //SDL_DisplayMode mode;
            //SDL_GetCurrentDisplayMode(0, &mode);
            //log::messageln("display mode: %d %d", mode.w, mode.h);

            if (desc.w == -1 && desc.h == -1)
            {
                desc.w = 960;
                desc.h = 640;
            }

            if (desc.fullscreen)
                flags |= SDL_WINDOW_FULLSCREEN;

            {
                Event ev(EVENT_PRECREATEWINDOW);
                _dispatcher->dispatchEvent(&ev);
            }

            log::messageln("creating window %d %d", desc.w, desc.h);

            _window = SDL_CreateWindow(desc.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, desc.w, desc.h, flags);

            if (!_window)
            {
                log::error("can't create window: %s", SDL_GetError());
                return;
            }
            _context = SDL_GL_CreateContext(_window);
            if (!_context)
            {
                log::error("can't create gl context: %s", SDL_GetError());
                return;
            }

            SDL_GL_SetSwapInterval(desc.vsync ? 1 : 0);

#ifdef EMSCRIPTEN
            SDL_SetEventFilter(SDL_eventsHandler, 0);

            int v = EM_ASM_INT(
            {
                var p = navigator.platform;
                if (p == 'iPad' || p == 'iPhone' || p == 'iPod')
                    return 1;
                return 0;
            }, 0);
int AUTO(AutoData *Data)
{
  struct timeval  *time0,*time1;
  integer icp[NPARX2];
  doublereal par[NPARX2], thl[NPARX];
  iap_type *iap;
  rap_type *rap;
  doublereal *thu;
  integer *iuz;
  doublereal *vuz;
  function_list list;
  
  integer i, j, k;

  // Initialize structures and constants
  gData = Data;
  
  iap = &(Data->iap);
  rap = &(Data->rap);

  Data->sp_len = Data->num_sp + (1 + floor(iap->nmx/iap->npr));
  Data->sp_inc = 5;

#ifdef USAGE
  struct rusage *init_usage,*total_usage;
  usage_start(&init_usage);
  usage_start(&total_usage);
#endif

#ifdef FLOATING_POINT_TRAP
  trapfpe();
#endif

#ifdef PTHREADS
  global_conpar_type = CONPAR_PTHREADS;
  global_setubv_type = SETUBV_PTHREADS;
  global_reduce_type = REDUCE_PTHREADS;
#endif

  fp9 = fopen("fort.9","w");
  if(fp9 == NULL) {
    fprintf(stderr,"Error:  Could not open fort.9\n");
    exit(1);
  }
  

  /* Initialization : */

  iap->mynode = mynode();
  iap->numnodes = numnodes();
  if (iap->numnodes > 1) {
    iap->parallel_flag = 1;
  } else {
    iap->parallel_flag = 0;
  }


    /* NOTE:  thu is allocated inside this function, and the
       pointer is passed back.  I know this is ugly, but
       this function does a bit of work to get thu setup correctly,
       as well as figuring out the size the array should be.
       What really should happen is to have one function which
       reads fort.2 and another fuction which initializes the array.
       That way the allocation could happen between the two calls.
    */
    init0(iap, rap, par, icp, thl, &thu, &iuz, &vuz);      

    /* Find restart label and determine type of restart point. */
    if (iap->irs > 0) {
      logical found = FALSE_;

      findlb(iap, rap, iap->irs, &(iap->nfpr), &found);
      if (! found) {
	if (iap->mynode == 0) {
	  fprintf(stderr,"\nRestart label %4ld not found\n",iap->irs);
	}
	exit(0);
      }
    }
    set_function_pointers(*iap,&list);
    init1(iap, rap, icp, par);
    chdim(iap);

    /* Create the allocations for the global structures used in 
       autlib3.c and autlib5.c.  These are purely an efficiency thing.
       The allocation and deallocation of these scratch areas takes
       up a nontrivial amount of time if done directly in the
       wrapper functions in autlib3.c*/
    allocate_global_memory(*iap);

    /* ---------------------------------------------------------- */
    /* ---------------------------------------------------------- */
    /*  One-parameter continuations */
    /* ---------------------------------------------------------- */
    /* ---------------------------------------------------------- */

#ifdef USAGE
    usage_end(init_usage,"main initialization");
#endif
    
    if (Data->print_input)
        PrintInput(Data, par, icp);
    
    // Initialize output variables
    if(list.type==AUTOAE)
        Data->u = DMATRIX(iap->nmx, iap->ndim);
    else {
        // Solution measures
        Data->usm = (doublereal ***)MALLOC((2+(int)(log2(Data->nsm)))*sizeof(doublereal **));
        Data->usm[0] = DMATRIX(iap->nmx, iap->ndim);    // MAX
        Data->usm[1] = DMATRIX(iap->nmx, iap->ndim);    // MIN
        for (i=0; i<(int)(log2(Data->nsm)); i++)
            Data->usm[2+i] = DMATRIX(iap->nmx, iap->ndim);
        
        // Jacobian of flow
        if (Data->sjac) {
            Data->c0 = DMATRIX_3D(iap->nmx, iap->ndim, iap->ndim);
            Data->c1 = DMATRIX_3D(iap->nmx, iap->ndim, iap->ndim);
        }
        
        // Jacobian of flow along cycles (temporary storage)
        if (Data->sflow) {
            Data->a1 = DMATRIX_3D(iap->ntst, iap->ndim, iap->ndim);
            Data->a2 = DMATRIX_3D(iap->ntst, iap->ndim, iap->ndim);
        }
    }
    Data->par = DMATRIX(iap->nmx, iap->nicp);
    if (iap->isp >= 1) {
        Data->ev = DCMATRIX(iap->nmx, iap->ndim);
        for (i=0; i<iap->nmx; i++) {
            for (j=0; j<iap->ndim; j++) {
                Data->ev[i][j].r = NAN; // This is a flag for bad floquet multipliers
                Data->ev[i][j].i = NAN;
            }
        }
    }
    Data->num_u = 0;

    if (Data->sp == NULL)
        Data->num_sp = 0;
    
    Data->sp = (AutoSPData *)REALLOC(Data->sp, (Data->sp_len)*sizeof(AutoSPData));

    for (i=Data->num_sp; i<Data->sp_len; i++) {
        Data->sp[i].u = NULL;
        Data->sp[i].icp = NULL;
        Data->sp[i].ups = NULL;
        Data->sp[i].udotps = NULL;
        Data->sp[i].rldot = NULL;
        Data->sp[i].a1 = NULL;
        Data->sp[i].a2 = NULL;
    }

    if(list.type==AUTOAE)
      autoae(iap, rap, par, icp, list.aelist.funi, list.aelist.stpnt, list.aelist.pvli, thl, thu, iuz, vuz);
    if(list.type==AUTOBV)
      autobv(iap, rap, par, icp, list.bvlist.funi, list.bvlist.bcni, 
	     list.bvlist.icni, list.bvlist.stpnt, list.bvlist.pvli, thl, thu, iuz, vuz);
     
    // Testing output
    if (Data->print_output)
        PrintOutput(Data);
     
#ifdef USAGE
    usage_end(total_usage,"total");

#endif
    //time_end(time0,"Total Time ",fp9);
    fprintf(fp9,"----------------------------------------------");
    fprintf(fp9,"----------------------------------------------\n");
    //time_end(time1,"",stdout);


  //}
  FREE(thu);
  FREE(iuz);
  FREE(vuz);
  fclose(fp9);

  // Clean up special solution points that were allocated and not used
  Data->sp = (AutoSPData *)REALLOC(Data->sp, (Data->num_sp)*sizeof(AutoSPData));
  assert(Data->sp);
  Data->sp_len = Data->num_sp;

  return 1;
} 
Exemple #12
0
RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, enum EDontAdopt, UErrorCode &status) {
    init0();
    init(data, status);
    fDontFreeData = TRUE;
}
Exemple #13
0
Waiter::Waiter()
{
    proceed = journey().proceedHandler();
    init0();
}
Exemple #14
0
 void init1()
 {
     init0();
     for (int i = 0; i < 8; i++)
         val[i][i] = 1;
 }
Exemple #15
0
static int lp_parse_message(lp_parse_env* lp_p, char* at_mes)
{
	llp_uint32 out_count = 0;
	int a_ret = LP_FAIL;
	int ret = LP_FAIL;
	llp_uint32 id = 0;
	lp_token* temp = NULL;
	lp_token* mes_name = NULL;
	lp_token* mes_id = NULL;
	lp_list temp_out;
	lp_string mes;
	lp_table ide_table;
	
	init0(temp_out);
	init0(mes);
	init0(ide_table);

	check_null(lp_p, LP_FAIL);
	check_null(lp_p->token_list, LP_FAIL);

	lp_watch(lp_p, t_Kmessage);				// message
	lp_get_token(lp_p, t_ide, mes_name);	// test
	
	temp = lp_at_token(lp_p);		
	if(temp==NULL)
		lp_watch(lp_p, t_lb);
	
	switch(temp->type)					
	{
	case t_ass:								// if =
		lp_watch(lp_p, t_ass);
		lp_get_token(lp_p, t_num, mes_id);	// 1223
	case t_lb:
		{
			lp_list_new(&temp_out, 1, NULL, NULL);
			mes = lp_string_new("");
			if(at_mes)
			{
				lp_string_cats(&mes, at_mes);
				lp_string_cat(&mes, '.');
			}
			lp_string_cats(&mes, (char*)mes_name->name.str.list_p);
			if((a_ret=lp_table_add(&lp_p->parse_table, (char*)mes.str.list_p, fmes_internal)) == LP_EXIST)
			{
				print("parse[error line: %d]the new message \"%s\" is exist!\n", lp_p->line, mes.str.list_p);
				goto C_END;
			}
			else if(a_ret==LP_FAIL)
				goto C_END;
			lp_table_new(&ide_table);
			out_count = 0;
			if(lp_parse_closure(lp_p, &temp_out, &out_count, &ide_table, (char*)mes.str.list_p) == LP_FAIL)
				goto C_END;
		}
		break;
	default:
		lp_watch(lp_p, t_lb);
		break;
	}
	
	id = (llp_uint32)((mes_id)?(atoi((char*)mes_id->name.str.list_p)):(0));

	lp_parse_push(lp_p, mes.str.list_p, mes.str.list_len+1);	// write message name
	lp_parse_push_uint32(lp_p, id);								// write message id
	lp_parse_push_uint32(lp_p, out_count);						// write message count
	lp_parse_push(lp_p, temp_out.list_p, temp_out.list_len);	// write message body
	
	ret = LP_TRUE;

C_END:
	lp_table_free(&ide_table);
	lp_string_free(&mes);
	lp_list_free(&temp_out);
	return ret;
}
Exemple #16
0
static int lp_parse_defM(lp_parse_env* lp_p, char* at_mes, lp_string* out_name, int* out_fmes)
{
	lp_token* lp_t = NULL;
	int ret = LP_FAIL;
	lp_string name;
	lp_string full_name;

	init0(name);
	init0(full_name);
	
	check_null(lp_p, LP_FAIL);
	check_null(out_name, LP_FAIL);
	
	at_mes = (at_mes)?(at_mes):("");
	full_name = lp_string_new(at_mes);
	name = lp_string_new("");

	if(lp_parse_mes(lp_p, &name)==LP_FAIL)
		goto DEFM_ERROR_END;
	
	if( (lp_t=lp_at_token(lp_p))==NULL )
		lp_check(lp_p, t_ide);

	switch(lp_t->type)
	{
		case t_ll:
		case t_ide:
			{
				lp_string_cat(&full_name, '.');
				lp_string_cats(&full_name, (char*)name.str.list_p);
				int* vp = NULL;
				if((vp=lp_table_query(&lp_p->parse_table, (char*)full_name.str.list_p))!=NULL)		// search at local
				{
					ret = LP_TRUE, lp_string_cats(out_name, (char*)full_name.str.list_p);
					*out_fmes = *vp;
					goto DEFM_END;
				}
				else if((vp=lp_table_query(&lp_p->parse_table, (char*)name.str.list_p))!=NULL)			// search at global
				{
					ret = LP_TRUE, lp_string_cats(out_name, (char*)name.str.list_p);
					*out_fmes = *vp;
					goto DEFM_END;
				}
				else
				{
					print("parse[error line: %d] not find message body \"%s\" !\n", lp_p->line, (char*)name.str.list_p);
					goto DEFM_ERROR_END;
				}
			}
			break;
		default:
			goto DEFM_ERROR_END;
	}

DEFM_ERROR_END:
	print("parse[error line: %d] the message def is error!\n", lp_p->line);
DEFM_END:
	lp_string_free(&name);
	lp_string_free(&full_name);
	return ret;
}
Exemple #17
0
/* start():
 * Called at the end of reset.s as the first C function after processor
 * bootup.  It is passed a state that is used to determine whether or not
 * the CPU is restarting as a result of a warmstart or a coldstart.  If
 * the restart is a coldstart, then state will be INITIALIZE.  if the
 * restart is a warmstart, then there are a few typical values of state,
 * the most common of which are APP_EXIT and EXCEPTION.
 *
 * The bss_start and bss_end variables are usually defined in the
 * target-specific linker memory-map definition file.  They symbolically
 * identify the beginning and end of the .bss section.  Many compilers
 * support intrinsic tags for this; however, since it is apparently not
 * consistent from one toolset to the next; I chose to make up my own
 * tags so that this file never changes from one toolset to the next.
 *
 * The FORCE_BSS_INIT definition can be established in the target-specific
 * config.h file to force .bss space initialization regardless of warm/cold
 * start.
 */
void
start(int state)
{
    char    buf[48];

#ifdef FORCE_BSS_INIT
    state = INITIALIZE;
#endif

    /* Based on the incoming value of 'state' we may or may not initialize
     * monitor-owned ram.  Ideally, we only want to initialize
     * monitor-owned ram when 'state' is INITIALIZE (power-up or reset);
     * however, to support the case where the incoming state variable may
     * be corrupted, we also initialize monitor-owned ram when 'state'
     * is anything unexpected...
     */
    switch(state) {
    case EXCEPTION:
    case APP_EXIT:
        break;
    case INITIALIZE:
    default:
        umonBssInit();
        break;
    }

    /* Now that the BSS clear loop has been done, we can copy the
     * value of state (either a register or on stack) to the global
     * variable (in BSS) StateOfMonitor...
     */
    StateOfMonitor = state;

    /* Step through different phases of startup...
     */
    init0();
    init1();
    init2();

    /* Depending on the type of startup, alert the console and do
     * further initialization as needed...
     */
    switch(StateOfMonitor) {
    case INITIALIZE:
        reginit();
        init3();
        break;
    case APP_EXIT:
        EthernetStartup(0,0);
        if(!MFLAGS_NOEXITSTATUS()) {
            printf("\nApplication Exit Status: %d (0x%x)\n",
                   AppExitStatus,AppExitStatus);
        }
        break;
    case EXCEPTION:
        EthernetStartup(0,0);
        printf("\n%s: '%s'\n",EXCEPTION_HEADING,
               ExceptionType2String(ExceptionType));
        printf("           Occurred near 0x%lx",ExceptionAddr);
        if(AddrToSym(-1,ExceptionAddr,buf,0)) {
            printf(" (within %s)",buf);
        }
        printf("\n\n");
        exceptionAutoRestart(INITIALIZE);
        break;
    default:
        printf("Unexpected monitor state: 0x%x (sp @ 0x%x)\n",
               StateOfMonitor, buf);
        /* To attempt to recover from the bad state, just do
         * what INITIALIZE would do...
         */
        reginit();
        init3();
        break;
    }

#ifdef LOCK_FLASH_PROTECT_RANGE
    /* Issue the command that will cause the range of sectors
     * designated by FLASH_PROTECT_RANGE to be locked.  This only
     * works if the flash device is capable of being locked.
     */
    sprintf(buf,"flash lock %s",FLASH_PROTECT_RANGE);
    docommand(buf,0);
#endif

#ifdef PRE_COMMANDLOOP_HOOK
    PRE_COMMANDLOOP_HOOK();
#endif

    /* Enter the endless loop of command processing: */
    CommandLoop();

    printf("ERROR: CommandLoop() returned\n");
    monrestart(INITIALIZE);
}