Esempio n. 1
0
	void Dis_FPU2op(MIPSOpcode op, char *out)
	{
		int fs = _FS;
		int fd = _FD;
		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, %s",name,FN(fd),FN(fs));
	}
Esempio n. 2
0
	void Dis_FPUComp(MIPSOpcode op, char *out)
	{
		int fs = _FS;
		int ft = _FT;
		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, %s",name,FN(fs),FN(ft));
	}
Esempio n. 3
0
static bool setup_engine(
	struct i2c_engine *i2c_engine)
{
	struct i2c_hw_engine_dce110 *hw_engine = FROM_I2C_ENGINE(i2c_engine);

	/* Program pin select */
	REG_UPDATE_6(
			DC_I2C_CONTROL,
			DC_I2C_GO, 0,
			DC_I2C_SOFT_RESET, 0,
			DC_I2C_SEND_RESET, 0,
			DC_I2C_SW_STATUS_RESET, 1,
			DC_I2C_TRANSACTION_COUNT, 0,
			DC_I2C_DDC_SELECT, hw_engine->engine_id);

	/* Program time limit */
	REG_UPDATE_N(
			SETUP, 2,
			FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT), I2C_SETUP_TIME_LIMIT,
			FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 1);

	/* Program HW priority
	 * set to High - interrupt software I2C at any time
	 * Enable restart of SW I2C that was interrupted by HW
	 * disable queuing of software while I2C is in use by HW */
	REG_UPDATE_2(
			DC_I2C_ARBITRATION,
			DC_I2C_NO_QUEUED_SW_GO, 0,
			DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL);

	return true;
}
Esempio n. 4
0
static bool setup_engine(
	struct dce_i2c_hw *dce_i2c_hw)
{
	uint32_t i2c_setup_limit = I2C_SETUP_TIME_LIMIT_DCE;

	if (dce_i2c_hw->setup_limit != 0)
		i2c_setup_limit = dce_i2c_hw->setup_limit;
	/* Program pin select */
	REG_UPDATE_6(DC_I2C_CONTROL,
		     DC_I2C_GO, 0,
		     DC_I2C_SOFT_RESET, 0,
		     DC_I2C_SEND_RESET, 0,
		     DC_I2C_SW_STATUS_RESET, 1,
		     DC_I2C_TRANSACTION_COUNT, 0,
		     DC_I2C_DDC_SELECT, dce_i2c_hw->engine_id);

	/* Program time limit */
	if (dce_i2c_hw->send_reset_length == 0) {
		/*pre-dcn*/
		REG_UPDATE_N(SETUP, 2,
			     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT), i2c_setup_limit,
			     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 1);
	}
	/* Program HW priority
	 * set to High - interrupt software I2C at any time
	 * Enable restart of SW I2C that was interrupted by HW
	 * disable queuing of software while I2C is in use by HW
	 */
	REG_UPDATE_2(DC_I2C_ARBITRATION,
		     DC_I2C_NO_QUEUED_SW_GO, 0,
		     DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL);

	return true;
}
Esempio n. 5
0
static void execute_transaction(
	struct dce_i2c_hw *dce_i2c_hw)
{
	REG_UPDATE_N(SETUP, 5,
		     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_EN), 0,
		     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_CLK_DRIVE_EN), 0,
		     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_SEL), 0,
		     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_TRANSACTION_DELAY), 0,
		     FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_BYTE_DELAY), 0);


	REG_UPDATE_5(DC_I2C_CONTROL,
		     DC_I2C_SOFT_RESET, 0,
		     DC_I2C_SW_STATUS_RESET, 0,
		     DC_I2C_SEND_RESET, 0,
		     DC_I2C_GO, 0,
		     DC_I2C_TRANSACTION_COUNT, dce_i2c_hw->transaction_count - 1);

	/* start I2C transfer */
	REG_UPDATE(DC_I2C_CONTROL, DC_I2C_GO, 1);

	/* all transactions were executed and HW buffer became empty
	 * (even though it actually happens when status becomes DONE)
	 */
	dce_i2c_hw->transaction_count = 0;
	dce_i2c_hw->buffer_used_bytes = 0;
}
Esempio n. 6
0
void Dis_FPU3op(u32 op, char *out)
{
    int ft = _FT;
    int fs = _FS;
    int fd = _FD;;
    const char *name = MIPSGetName(op);
    sprintf(out, "%s\t%s, %s, %s",name,FN(fd),FN(fs),FN(ft));
}
Esempio n. 7
0
/* determine the correct filename for the config file */
static int
get_config_name(fnchar * buf, nh_bool ui)
{
    buf[0] = '\0';

    /* If running in connection-only mode, we can't get the options until we're
       already logged into the server. */
    if (ui_flags.connection_only && !*ui_flags.username)
        return 0;

#if defined(UNIX)
    char *envval;

    if (!ui) {
        /* check for env override first */
        envval = getenv("NETHACK4OPTIONS");
        if (envval) {
            strncpy(buf, envval, BUFSZ);
            return 1;
        }
    }
#endif

    /* look in regular location */
    if (!get_gamedir(CONFIG_DIR, buf))
        return 0;

#ifdef WIN32
    wchar_t usernamew[BUFSZ];
    int i = 0;

    while (i < BUFSZ - 2 && ui_flags.username[i]) {
        usernamew[i] = ui_flags.username[i];
        i++;
    }
    usernamew[i] = 0;
#else
    /* This is to avoid putting a directive inside the arguments to fnncat,
     * which is a macro. */
    char *usernamew = ui_flags.username;
#endif

    fnncat(buf, ui_flags.connection_only ? usernamew :
                ui ? FN("curses.conf") :
                FN("NetHack4.conf"),
           BUFSZ - fnlen(buf) - 1);
    if (ui_flags.connection_only)
        fnncat(buf, ui ? FN(".curses.rc") : FN(".NetHack4.rc"),
               BUFSZ - fnlen(buf) - 1);

    return 1;
}
Esempio n. 8
0
int FN(bscc_main)()
{
	int *arr;
	int i, j, t, sz;

	sz=1<<22;

	arr=malloc(sz*sizeof(int));

	for(i=0; i<sz; i++)arr[i]=rand()*251+rand();

	t=clock();
	FN(hsortm)(arr, sz);
	printf("HSort %d\n", clock()-t);
	FN(sortchk)(arr, sz);


	for(i=0; i<sz; i++)arr[i]=rand()*251+rand();

	t=clock();
	FN(Sort0)(arr, 0, sz);
	printf("Sort0 %d\n", clock()-t);
	FN(sortchk)(arr, sz);


	for(i=0; i<sz; i++)arr[i]=rand()*251+rand();

	t=clock();
	FN(Sort1)(arr, 0, sz);
	printf("Sort1 %d\n", clock()-t);
	FN(sortchk)(arr, sz);

	for(i=0; i<sz; i++)arr[i]=rand()*251+rand();

	t=clock();
	FN(Sort2)(arr, 0, sz);
	printf("Sort2 %d\n", clock()-t);
	FN(sortchk)(arr, sz);


	for(i=0; i<sz; i++)arr[i]=rand()*251+rand();
	t=clock();
	qsort(arr, sz, 4, FN(qs_cmp_i));
	printf("QSort %d\n", clock()-t);
	FN(sortchk)(arr, sz);

	return(0);
}
Esempio n. 9
0
//---------------------------------------------------------------------------
bool File::Exists(const Ztring &File_Name)
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(File_Name.c_str());
        return FN.FileExists();
    #else //ZENLIB_USEWX
        #ifdef ZENLIB_STANDARD
            if (File_Name.find(__T('*'))!=std::string::npos || File_Name.find(__T('?'))!=std::string::npos)
                return false;
            struct stat buffer;
            int         status;
            #ifdef UNICODE
                status=stat(File_Name.To_Local().c_str(), &buffer);
            #else
                status=stat(File_Name.c_str(), &buffer);
            #endif //UNICODE
            return status==0 && S_ISREG(buffer.st_mode);
        #elif defined WINDOWS
            if (File_Name.find(__T('*'))!=std::string::npos || (File_Name.find(__T("\\\\?\\"))!=0 && File_Name.find(__T('?'))!=std::string::npos) || (File_Name.find(__T("\\\\?\\"))==0 && File_Name.find(__T('?'), 4)!=std::string::npos))
                return false;
            #ifdef UNICODE
                DWORD FileAttributes=GetFileAttributesW(File_Name.c_str());
            #else
                DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
            #endif //UNICODE
            return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
        #endif
    #endif //ZENLIB_USEWX
}
Esempio n. 10
0
//---------------------------------------------------------------------------
Ztring& FileName::Extension_Set(const Ztring &Extension)
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(c_str());
        FN.SetExt(Extension.c_str());
        assign (FN.GetFullPath().c_str());
    #else //ZENLIB_USEWX
        #ifdef WINDOWS
            //Path limit
            size_t Pos_Path=rfind(_T('\\'));
            if (Pos_Path==Ztring::npos)
                Pos_Path=0; //Not found
            //Extension limit
            size_t Pos_Ext=rfind(_T('.'));
            if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
            {
                append(1, _T('.')); //Not found
                Pos_Ext=size()-1;
            }
            replace(Pos_Ext+1, size()-Pos_Ext-1, Extension, 0, Ztring::npos);
        #else
            //Not supported
        #endif
    #endif //ZENLIB_USEWX
    return *this;
}
Esempio n. 11
0
//---------------------------------------------------------------------------
bool Dir::Exists(const Ztring &File_Name)
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(File_Name.c_str());
        return FN.DirExists();
    #else //ZENLIB_USEWX
       #ifdef WINDOWS
            #ifdef UNICODE
                DWORD FileAttributes;
                #ifndef ZENLIB_NO_WIN9X_SUPPORT
                if (IsWin9X_Fast())
                    FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
                else
                #endif //ZENLIB_NO_WIN9X_SUPPORT
                    FileAttributes=GetFileAttributesW(File_Name.c_str());
            #else
                DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
            #endif //UNICODE
            return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && (FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
        #else //WINDOWS
            struct stat buffer;
            int         status;
            #ifdef UNICODE
                status=stat(File_Name.To_Local().c_str(), &buffer);
            #else
                status=stat(File_Name.c_str(), &buffer);
            #endif //UNICODE
            return status==0 && S_ISDIR(buffer.st_mode);
        #endif
    #endif //ZENLIB_USEWX
}
Esempio n. 12
0
//---------------------------------------------------------------------------
bool File::Exists(const Ztring &File_Name)
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(File_Name.c_str());
        return FN.FileExists();
    #else //ZENLIB_USEWX
        #ifdef ZENLIB_STANDARD
            struct stat buffer;
            int         status;
            #ifdef UNICODE
                status=stat(File_Name.To_Local().c_str(), &buffer);
            #else
                status=stat(File_Name.c_str(), &buffer);
            #endif //UNICODE
            return status==0 && S_ISREG(buffer.st_mode);
        #elif defined WINDOWS
            #ifdef UNICODE
                DWORD FileAttributes;
                if (IsWin9X())
                    FileAttributes=GetFileAttributesA(File_Name.To_Local().c_str());
                else
                    FileAttributes=GetFileAttributesW(File_Name.c_str());
            #else
                DWORD FileAttributes=GetFileAttributes(File_Name.c_str());
            #endif //UNICODE
            return ((FileAttributes!=INVALID_FILE_ATTRIBUTES) && !(FileAttributes&FILE_ATTRIBUTE_DIRECTORY));
        #endif
    #endif //ZENLIB_USEWX
}
void wxWidgetsGUIConfigPanel::OnButton1Click(wxCommandEvent& event)
{
    wxString FileName = ::wxFileSelector(
        _("Select resource file"),
        _T(""),_T(""),_T(""),
        _("XRC files (*.xrc)|*.xrc|"
          "Zipped files (*.zip)|*.zip|"
          "All files (*)|*"),
        wxFD_OPEN | wxFD_FILE_MUST_EXIST | compatibility::wxHideReadonly);

    if ( !FileName.empty() )
    {
        wxFileName FN(FileName);
        FN.MakeRelativeTo(m_GUI->GetProjectPath());
        wxString Ext = FN.GetExt();
        FileName = FN.GetFullPath();
        if ( Ext == _T("zip") || Ext == _T("ZIP") )
        {
            FileName.Append(_T("#zip:*.xrc"));
        }
        wxString CurrentContent = AutoLoad->GetValue();
        if ( CurrentContent.Length() && ( CurrentContent[CurrentContent.Length()-1] != _T('\n') ) )
        {
            AutoLoad->AppendText(_T("\n"));
        }
        AutoLoad->AppendText(FileName);
        AutoLoad->AppendText(_T("\n"));
    }
}
Esempio n. 14
0
static void release_engine(
	struct dce_i2c_hw *dce_i2c_hw)
{
	bool safe_to_reset;

	/* Restore original HW engine speed */

	set_speed(dce_i2c_hw, dce_i2c_hw->original_speed);

	/* Release I2C */
	REG_UPDATE(DC_I2C_ARBITRATION, DC_I2C_SW_DONE_USING_I2C_REG, 1);

	/* Reset HW engine */
	{
		uint32_t i2c_sw_status = 0;

		REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status);
		/* if used by SW, safe to reset */
		safe_to_reset = (i2c_sw_status == 1);
	}

	if (safe_to_reset)
		REG_UPDATE_2(DC_I2C_CONTROL,
			     DC_I2C_SOFT_RESET, 1,
			     DC_I2C_SW_STATUS_RESET, 1);
	else
		REG_UPDATE(DC_I2C_CONTROL, DC_I2C_SW_STATUS_RESET, 1);
	/* HW I2c engine - clock gating feature */
	if (!dce_i2c_hw->engine_keep_power_up_count)
		REG_UPDATE_N(SETUP, 1, FN(SETUP, DC_I2C_DDC1_ENABLE), 0);

}
Esempio n. 15
0
	void Dis_mxc1(MIPSOpcode op, char *out)
	{
		int fs = _FS;
		int rt = _RT;
		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, %s",name,RN(rt),FN(fs));
	}
Esempio n. 16
0
//---------------------------------------------------------------------------
Ztring& FileName::Name_Set(const Ztring &Name)
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(c_str());
        if (FN==FN.GetName()) //Bug of WxWidgets? if C:\\dir\\(no name), name is C:\\dir\\(no name)
            FN.SetPath(c_str());
        FN.SetName(Name.c_str());
        assign ((FN.GetFullPath()+FN.GetPathSeparator()/*FileName_PathSeparator*/+FN.GetFullName()).c_str());
    #else //ZENLIB_USEWX
        #ifdef WINDOWS
            //Path limit
            size_t Pos_Path=rfind(_T('\\'));
            if (Pos_Path==Ztring::npos)
                Pos_Path=0; //Not found
            //Extension limit
            size_t Pos_Ext=rfind(_T('.'));
            if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
                Pos_Ext=size(); //Not found
            replace(Pos_Path+1, Pos_Ext-Pos_Path-1, Name, 0, Ztring::npos);
        #else
            //Not supported
        #endif
    #endif //ZENLIB_USEWX
    return *this;
}
Esempio n. 17
0
int main(){
	prepare_shuffling_dictionary();
	prepare_shuffling_dictionary_avx();

	const testcase tests[] = {
		{
			"equal lists",
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64}, // list1
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64}, // list2
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64}, // intersection result
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64}, // union result
			{}  // difference result
		},{
			"completely different lists",
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64},
			{1,3,5,6, 10,12,27,31, 36,47,50,51, 52,66,77,88},
			{},
			{0,1,2,3,4,5,6,7, 10,11,12,13,23,27,31,32, 33,36,42,44,47,48,50,51, 52,53,55,60,64,66,77,88},
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64}
		},{
			"no match in first",
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64, 66,67,68,69, 77,78,79,80, 81,82,83,84, 87,88,89,99},
			{1,3,5,6, 10,12,27,31, 36,47,50,51, 52,66,77,88},
			{66,77,88},
			{0,1,2,3,4,5,6,7, 10,11,12,13,23,27,31,32, 33,36,42,44,47,48,50,51, 52,53,55,60,64, 66,67,68,69, 77,78,79,80, 81,82,83,84, 87,88,89,99},
			{0,2,4,7, 11,13,23,32, 33,42,44,48, 53,55,60,64, 67,68,69, 78,79,80, 81,82,83,84, 87,89,99}
		}
	};
	constexpr int tests_size = sizeof(tests) / sizeof(testcase);

	#define FN(x) {#x, x}
	run(
		tests, tests_size,
		{
			FN(intersect_vector_sse),
			FN(intersect_vector_sse_asm),
			FN(intersect_vector_avx),
#ifdef __AVX2__
			FN(intersect_vector_avx2),
			FN(intersect_vector_avx2_asm)
#endif
		},
		{
			FN(union_vector_sse)
		},
		{
			FN(difference_vector_sse),
#ifdef __AVX2__
			FN(difference_vector_avx2),
#endif
		}
	);

	free(shuffle_mask_avx);
	return 0;
}
Esempio n. 18
0
static void set_speed(
	struct dce_i2c_hw *dce_i2c_hw,
	uint32_t speed)
{

	if (speed) {
		if (dce_i2c_hw->masks->DC_I2C_DDC1_START_STOP_TIMING_CNTL)
			REG_UPDATE_N(SPEED, 3,
				     FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed,
				     FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2,
				     FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL), speed > 50 ? 2:1);
		else
			REG_UPDATE_N(SPEED, 2,
				     FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed,
				     FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2);
	}
}
Esempio n. 19
0
void Dis_FPULS(u32 op, char *out)
{
    int offset = (signed short)(op&0xFFFF);
    int ft = _FT;
    int rs = _RS;
    const char *name = MIPSGetName(op);
    sprintf(out, "%s\t%s, %d(%s)",name,FN(ft),offset,RN(rs));
}
Esempio n. 20
0
	void Dis_FPULS(MIPSOpcode op, char *out)
	{
		int offset = (signed short)(op&0xFFFF);
		int ft = _FT;
		int rs = _RS;
		const char *name = MIPSGetName(op);
		sprintf(out, "%s\t%s, %s(%s)",name,FN(ft),SignedHex(offset),RN(rs));
	}
Esempio n. 21
0
void fill_array_ic(aveq *A, function *G, function *S, int k, int l_or_not) { //intero per decidere se utilizzare onda quadra o gaussiana
                                                                          //l_or_not = 0 tutti, l_or_not = 1 Leapfrog

    int i;

        switch(l_or_not) {
            case 0:
                    if( k == 1 ) { //condizione fissata per la gaussiana
                        for(i = 0; i < A->dim; i++) {
                            A->tsol[i] = FN(G,i*A->xstep);
                            A->solution[i] = FN(G,i*A->xstep);
                            A->tsol_1[i] = FN(G,i*A->xstep);
                        }
                    } else if ( k == 0 ) { //condizione fissata per l'onda quadra
                        for(i = 0; i < A->dim; i++) {
                            A->tsol[i] = FN(S,i*A->xstep);
                            A->solution[i] = FN(S,i*A->xstep);
                            A->tsol_1[i] = FN(S,i*A->xstep);
                        }
                    } else { //condizione a casaccio: errore
                        printf("#Errore: inserire una condizione valida (0 o 1).\n");
                        exit(0); //blocca esecuzione del programma??
                    }
            case 1:
                    if( k == 1 ) { //condizione fissata per la gaussiana
                        for(i = 0; i < A->dim; i++) {
                            A->tsol[i] = FN(G,i*A->xstep);
                            A->tsol_1[i] = FN(G,i*A->xstep + A->tstep);
                        }
                    } else if ( k == 0 ) { //condizione fissata per l'onda quadra
                        for(i = 0; i < A->dim; i++) {
                        A->tsol[i] = FN(S,i*A->xstep);
                        A->tsol_1[i] = FN(S,i*A->xstep + A->tstep);
                        }
                    } else { //condizione a casaccio: errore
                        printf("#Errore: inserire una condizione valida (0 o 1).\n");
                        exit(0); //blocca esecuzione del programma??
                    }
        }



}
Esempio n. 22
0
/* Evaluate "u" in the void point "pnt".
 * In particular, return the value NaN.
 */
static __isl_give isl_val *FN(UNION,eval_void)(__isl_take UNION *u,
	__isl_take isl_point *pnt)
{
	isl_ctx *ctx;

	ctx = isl_point_get_ctx(pnt);
	FN(UNION,free)(u);
	isl_point_free(pnt);
	return isl_val_nan(ctx);
}
Esempio n. 23
0
int main(void) {
  uint8_t in[200];
  for (size_t i = 0; i < 200; i++) {
    in[i] = Frama_C_interval(0, 255);
  }
  uint8_t out[BYTES];
  //  uint8_t out256[256 / 8];
  //  uint8_t out384[384 / 8];
  //  uint8_t out512[512 / 8];

  uint8_t invalid;

  void* maybeout = Frama_C_nondet_ptr(&invalid, (void*)0);
  size_t outlen;
  void* maybein = Frama_C_nondet_ptr(&invalid, (void*)0);
  size_t inlen = Frama_C_interval(0, 4294967295);

  int err = 0;
  int fn = Frama_C_interval(0, 3);
  switch (fn) {
    case 0:
      FN(sha3_224);
      //@assert err < 0;
      break;
    case 1:
      FN(sha3_256);
      //@assert err < 0;
      break;
    case 2:
      FN(sha3_384);
      //@assert err < 0;
      break;
    case 3:
      FN(sha3_512);
      //@assert err < 0;
      break;
  }
  //@assert err < 0;

  //  sha3_256(out256, 256 / 8, in, Frama_C_interval(0, 200));
  //  sha3_384(out384, 384 / 8, in, Frama_C_interval(0, 200));
  //  sha3_512(out512, 512 / 8, in, Frama_C_interval(0, 200));
}
Esempio n. 24
0
static void set_speed(
	struct i2c_engine *i2c_engine,
	uint32_t speed)
{
	struct i2c_hw_engine_dce110 *hw_engine = FROM_I2C_ENGINE(i2c_engine);

	if (speed) {
		if (hw_engine->i2c_mask->DC_I2C_DDC1_START_STOP_TIMING_CNTL)
			REG_UPDATE_N(
				SPEED, 3,
				FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), hw_engine->reference_frequency / speed,
				FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2,
				FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL), speed > 50 ? 2:1);
		else
			REG_UPDATE_N(
				SPEED, 2,
				FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), hw_engine->reference_frequency / speed,
				FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2);
	}
}
Esempio n. 25
0
File: eval.c Progetto: samsonjs/lake
LakeVal *apply(LakeCtx *ctx, LakeVal *fnVal, LakeList *args)
{
  LakeVal *result = NULL;
  if (lake_is_type(TYPE_PRIM, fnVal)) {
    LakePrimitive *prim = PRIM(fnVal);
    int arity = prim->arity;
    if (arity == ARITY_VARARGS || LIST_N(args) == arity) {
      result = prim->fn(ctx, args);
    }
    else {
      ERR("%s expects %d params but got %zu", prim->name, arity, LIST_N(args));
      result = NULL;
    }
  }
  else if (lake_is_type(TYPE_FN, fnVal)) {
    LakeFn *fn = FN(fnVal);

    /* Check # of params */
    size_t nparams = LIST_N(fn->params);
    if (!fn->varargs && LIST_N(args) != nparams) {
      ERR("expected %zu params but got %zu", nparams, LIST_N(args));
      return NULL;
    }
    else if (fn->varargs && LIST_N(args) < nparams) {
      ERR("expected at least %zu params but got %zu", nparams, LIST_N(args));
      return NULL;
    }

    Env *env = env_make(fn->closure);

    /* bind each (param,arg) pair in env */
    size_t i;
    for (i = 0; i < nparams; ++i) {
      env_define(env, SYM(LIST_VAL(fn->params, i)), LIST_VAL(args, i));
    }

    /* bind varargs */
    if (fn->varargs) {
      LakeList *remainingArgs = list_make_with_capacity(LIST_N(args) - nparams);
      for (; i < LIST_N(args); ++i) {
        list_append(remainingArgs, LIST_VAL(args, i));
      }
      env_define(env, fn->varargs, VAL(remainingArgs));
    }

    /* evaluate body */
    result = eval_exprs1(ctx, env, fn->body);
  }
  else {
    ERR("not a function: %s", lake_repr(fnVal));
  }
  return result;
}
Esempio n. 26
0
/* determine the correct filename for the config file */
static void get_config_name(fnchar *buf, nh_bool ui)
{
    buf[0] = '\0';

#if defined(UNIX)
    char *envval;
    if (!ui) {
	/* check for env override first */
	envval = getenv("DYNAHACKOPTIONS");
	if (envval) {
	    strncpy(buf, envval, BUFSZ);
	    return;
	}
    }
#endif
    
    /* look in regular location */
    if (!get_gamedir(CONFIG_DIR, buf))
	return;

    fnncat(buf, ui ? FN("curses.conf") : FN("DynaHack.conf"), BUFSZ);
}
Esempio n. 27
0
//---------------------------------------------------------------------------
Ztring FileName::Path_Get() const
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(c_str());
        return FN.GetPath().c_str();
    #else //ZENLIB_USEWX
        //Path limit
        size_t Pos_Path=rfind(FileName_PathSeparator);
        if (Pos_Path==Ztring::npos)
            return Ztring(); //Not found
        else
            return Ztring(*this, 0, Pos_Path);
    #endif //ZENLIB_USEWX
}
Esempio n. 28
0
void FN(Sort2)(int *arr, int base, int lim)
{
    static int depth=0;
    int mp;
    int low, mid, high;
    int i, j, k;

	if((lim-base)<2)return;

#if 1	//heapsort fallback, aka: crude intro sort
	if(depth>=64)
	{
		FN(hsortm)(arr+base, lim-base);
		return;
	}
#endif

	depth++;

    low=base; high=lim; mid=(low+high)/2;
//    mp=arr[mid];
    i=arr[low]; j=arr[mid]; k=arr[high-1];
    mp=(i<j)?((k<i)?i:j):((i<k)?i:j);

    i=low;
    while(i<high)
    {
        if(arr[i]<mp) { FN(Swap)(arr, low++, i++); continue; }
        if(arr[i]>mp) { FN(Swap)(arr, --high, i); continue; }
        i++;
    }

    FN(Sort2)(arr, base, low);
    FN(Sort2)(arr, high, lim);
    depth--;
}
Esempio n. 29
0
void FN(Sort0)(int *arr, int base, int lim)
{
    static int depth=0;
    int mp;
    int low, mid, high;
    int i, j, k;

	if((lim-base)<2)return;

	if(depth>=64) //bad case, use selection sort
	{
		for(i=base; i<lim; i++)
			for(j=i+1; j<lim; j++)
				if(arr[j]<arr[i])FN(Swap)(arr, i, j);
		return;
	}

	depth++;

    low=base; high=lim; mid=(low+high)/2;
//    mp=arr[mid];
    i=arr[low]; j=arr[mid]; k=arr[high-1];
    mp=(i<j)?((k<i)?i:j):((i<k)?i:j);

    i=low;
    while(i<high)
    {
        if(arr[i]<mp) { FN(Swap)(arr, low++, i++); continue; }
        if(arr[i]>mp) { FN(Swap)(arr, --high, i); continue; }
        i++;
    }

    FN(Sort0)(arr, base, low);
    FN(Sort0)(arr, high, lim);
    depth--;
}
Esempio n. 30
0
//---------------------------------------------------------------------------
Ztring FileName::Extension_Get() const
{
    #ifdef ZENLIB_USEWX
        wxFileName FN(c_str());
        return FN.GetExt().c_str();
    #else //ZENLIB_USEWX
        //Path limit
        size_t Pos_Path=rfind(FileName_PathSeparator);
        if (Pos_Path==Ztring::npos)
            Pos_Path=0; //Not found
        //Extension limit
        size_t Pos_Ext=rfind(_T('.'));
        if (Pos_Ext==Ztring::npos || Pos_Ext<Pos_Path)
            return Ztring(); //Not found
        else
            return Ztring(*this, Pos_Ext+1, size()-Pos_Ext-1);
    #endif //ZENLIB_USEWX
}