Example #1
0
 void setVariance(FP inVariance) {
   if (inVariance < FP(0.0)) {
     assert(0); // negative variance
   }
   variance = inVariance;
   stdDeviation = FP(-1.0);
 }
Example #2
0
void	print_tree(t_ast *ast)
{
	while (ast->leftcmd != NULL)
		ast = ast->leftcmd;
	FP("%s | %d | %s\n", ast->left, ast->type, ast->right);
	while (ast != NULL)
	{
		ast = ast->parent;
		if (ast != NULL)
			FP("%p | %d | %s\n", ast->leftcmd, ast->type, ast->right);
	}
}
Example #3
0
 GvmResult(GvmCluster<S,V,K,FP> cluster)
 : space(cluster.clusters.space)
 {
   count = cluster.count;
   mass = cluster.m0;
   variance = cluster.var / mass;
   stdDeviation = FP(-1.0);
   key = cluster.getKey();
   //space = cluster.clusters.space;
   point = space.newCopy(cluster.m1);
   space.scale(point, FP(1.0) / mass);
 }
Example #4
0
void
des_ecb3_encrypt(des_cblock (*input), des_cblock (*output),
    des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3,
    int encrypt)
{
	register u_int32_t l0, l1;
	register unsigned char *in, *out;
	u_int32_t ll[2];

	in = (unsigned char *) input;
	out = (unsigned char *) output;
	c2l(in, l0);
	c2l(in, l1);
	IP(l0, l1);
	ll[0] = l0;
	ll[1] = l1;
	des_encrypt2(ll, ks1, encrypt);
	des_encrypt2(ll, ks2, !encrypt);
	des_encrypt2(ll, ks3, encrypt);
	l0 = ll[0];
	l1 = ll[1];
	FP(l1, l0);
	l2c(l0, out);
	l2c(l1, out);
}
Example #5
0
int		ft_check_setenv_ag(char **arg, char **varn, char **varvalue, int *ow)
{
	if (arg[1] && arg[2] && arg[3])
	{
		*varn = ft_strtoupper(ft_strdup(arg[1]));
		*varvalue = ft_strdup(arg[2]);
		*ow = ft_atoi(arg[3]);
	}
	else
	{
		FP("Setenv error.\n");
		FP("Usage : setenv (char*)name (char*)value (int)overwrite\n");
		return (-1);
	}
	return (0);
}
Example #6
0
void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3)
  {
  register DES_LONG l,r;

  l=data[0];
  r=data[1];
  IP(l,r);
  data[0]=l;
  data[1]=r;

  /*des_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); */
  /*des_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); */
  /*des_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); */

  /* XID on 23-MAR-1999 */
  /* Modified to use Triple DES. Key must be 24 bytes. */
  des_encrypt((DES_LONG *)data,ks3,DES_DECRYPT);
  des_encrypt((DES_LONG *)data,ks2,DES_ENCRYPT);
  des_encrypt((DES_LONG *)data,ks1,DES_DECRYPT);

  l=data[0];
  r=data[1];
  FP(r,l);
  data[0]=l;
  data[1]=r;
}/*end des_decrypt3 */
Example #7
0
int CCMinFinder::FindMinimum(byte Meth)
{
    int Ret=-1;
    switch (Meth)
    {
    case CMM_None:
        ;
        break;
    case CMM_Controls:
    {
        CMFControls *p=new CMFControls(this);
        Ret=p->Solve();
        delete p;
        //CMFControls Cn(this);
        //Ret=Cn.Solve();
        break;
    };
    case CMM_LawBailey:
    {
        CMFLawBailey LB(this);
        Ret=LB.Solve();
        break;
    };
    case CMM_FlexiPlex:
    {
        //CMFFlexiPlex *p=new CMFFlexiPlex(this);
        //Ret=p->Solve();
        //delete p;
        CMFFlexiPlex FP(this);
        Ret=FP.Solve();
        break;
    };
    };
    return Ret;
};
Example #8
0
/**
 * @brief 对数据段进行 Triple DES 算法解密。
 *
 * @author Damien(2011/12/22)
 *
 * @param p_ctx  Triple DES 加密算法语境。
 * @param p_dst  输出明文保存地址。
 * @param p_src  输入密文保存地址。
 *
 * @note 数据段的长度为 8 个字节。
 */
void
crypto_des3_decrypt(const crypto_des3_ctx_t* p_ctx,
                    unsigned char*           p_dst,
                    const unsigned char*     p_src) {
  unsigned long  i;
  unsigned long  l;
  unsigned long  r;
  unsigned long  a;
  unsigned long  b;
  unsigned long*       p_dst_u32 = (      unsigned long* )p_dst;
  const unsigned long* p_src_u32 = (const unsigned long* )p_src;
  const unsigned long* p_exp_key = p_ctx->expkey + CRYPTO_DES3_EXPKEY_WORDS - 2;


  l = le32_to_cpu(p_src_u32[0]);
  r = le32_to_cpu(p_src_u32[1]);

  IP(l, r, a);
  for (i = 0; i < 8; i++) {
    ROUND(l, r, a, b, p_exp_key, -2);
    ROUND(r, l, a, b, p_exp_key, -2);
  }
  for (i = 0; i < 8; i++) {
    ROUND(r, l, a, b, p_exp_key, -2);
    ROUND(l, r, a, b, p_exp_key, -2);
  }
  for (i = 0; i < 8; i++) {
    ROUND(l, r, a, b, p_exp_key, -2);
    ROUND(r, l, a, b, p_exp_key, -2);
  }
  FP(r, l, a);

  p_dst_u32[0] = cpu_to_le32(r);
  p_dst_u32[1] = cpu_to_le32(l);
}
Example #9
0
 GvmStdVector<FP,D>()
 {
   assert(D >= 1);
   for (int i = 0; i < D; i++) {
     values[i] = FP(0.0);
   }
 }
Example #10
0
static void write_snapshots_to_file(void)
{
    Int i;

    Char* elune_out_file =
        VG_(expand_file_name)("--output-filename", clo_outputfilename);

    sres = VG_(open)(clo_outputfilename, VKI_O_CREAT|VKI_O_TRUNC|VKI_O_WRONLY,
                     VKI_S_IRUSR|VKI_S_IWUSR);
    if (sr_isError(sres)) {
        // If the file can't be opened for whatever reason (conflict
        // between multiple cachegrinded processes?), give up now.
        VG_(umsg)("error: can't open output file '%s'\n", elune_out_file );
        VG_(umsg)("       ... so the log will be missing.\n");
        VG_(free)(elune_out_file);
        return;
    } else {
        fd = sr_Res(sres);
        VG_(free)(elune_out_file);
    }
    // Print elune-specific options that were used.
    if (VG_(args_the_exename)) {
        /*FP("%s", VG_(args_the_exename));*/
        for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
            HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
            if (arg)
                FP(" %s", arg);
        }
    }
    /*FP("\n");*/
}
Example #11
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		GetWindDirVel
//Author		Craig Beeston
//Date			Thu 10 Jun 1999
//
//Description	Returns the wind speed and direction at a given altitude
//
//Inputs		Alt
//
//Returns		Wind Heading and Speed
//
//------------------------------------------------------------------------------
Bool Atmosphere::GetWindDirVel (SLong alt, SWord& hdg, SLong& speed)
{
	if(!Save_Data.flightdifficulty [FD_WINDEFFECTS])
	{
		hdg = 0;
		speed = 0;
		return(TRUE);
	}

	if(alt > 914400)	// 30,000 ft
	{
		hdg	  = SWord(diralt * 182.04);
//DeadCode RJS 16Dec99		speed = (51 * windalt) / 10;
		speed = SLong(5148. * windalt);					//RJS 16Dec99
		return(TRUE);
	}

//DeadCode RJS 16Dec99	SWord Dir0   = SWord(182.04 * dir0);
//DeadCode RJS 16Dec99	SWord DirAlt = SWord(182.04 * diralt);
//DeadCode RJS 16Dec99
//DeadCode RJS 16Dec99	SWord DeltaDir = DirAlt - Dir0;
	FP Dir0   = 182.04 * dir0;							//RJS 16Dec99
	FP DirAlt = 182.04 * diralt;						//RJS 16Dec99

	FP DeltaDir = DirAlt - Dir0;						//RJS 16Dec99
	FP Fract = FP(alt) / 914411.0;
	FP fdir   = Dir0 + Fract * DeltaDir;
	FP fspeed = ((1. - Fract) * wind0 + Fract * windalt) * 5148.;//RJS 16Dec99

	hdg   = SWord(fdir);
	speed = SLong(fspeed);
	
	return(TRUE);
}
// Generator for toplevel expression
// It also evaluates the generated function
llvm::Function * ProgCodegen::operator()(const ast::Expr      & expr)  const 
{
    std::vector<llvm::Type*> doubles(0,llvm::Type::getDoubleTy(llvm::getGlobalContext()));
    llvm::FunctionType * FT       = llvm::FunctionType::get   (llvm::Type::getDoubleTy(llvm::getGlobalContext()),llvm::ArrayRef<llvm::Type*>(doubles), false);
    llvm::Function     * funcVal  = llvm::Function    ::Create(FT, llvm::Function::ExternalLinkage,"", module);
    if (funcVal == 0) return 0;

    //Creating ExprCodegen to process the function body.
    ExprCodegen expCG(module);
    //Building
    llvm::BasicBlock * BB = llvm::BasicBlock::Create(llvm::getGlobalContext(), "entry", funcVal);
    expCG.pimpl->builder.SetInsertPoint(BB);

    if(llvm::Value * bodyVal = boost::apply_visitor(expCG,expr)) 
    {
        expCG.pimpl->builder.CreateRet(bodyVal);
        llvm::verifyFunction(*funcVal);
        //Evaluation
        std::cout << "ready " << engine << "\n";
        void *FPtr = engine->getPointerToFunction(funcVal);
        double (*FP)() = (double (*)())FPtr;
        std::cout << "Evaluated to " << FP() << "\n";

        return funcVal;
    }

    funcVal->eraseFromParent();
    return 0;
}
Example #13
0
File: sshdes.c Project: rdebath/sgt
void des_decipher(word32 *output, word32 L, word32 R, DESContext *sched) {
    word32 swap, s0246, s1357;

    IP(L, R);

    L = rotl(L, 1);
    R = rotl(R, 1);

    L ^= f(R, sched->k0246[15], sched->k1357[15]);
    R ^= f(L, sched->k0246[14], sched->k1357[14]);
    L ^= f(R, sched->k0246[13], sched->k1357[13]);
    R ^= f(L, sched->k0246[12], sched->k1357[12]);
    L ^= f(R, sched->k0246[11], sched->k1357[11]);
    R ^= f(L, sched->k0246[10], sched->k1357[10]);
    L ^= f(R, sched->k0246[ 9], sched->k1357[ 9]);
    R ^= f(L, sched->k0246[ 8], sched->k1357[ 8]);
    L ^= f(R, sched->k0246[ 7], sched->k1357[ 7]);
    R ^= f(L, sched->k0246[ 6], sched->k1357[ 6]);
    L ^= f(R, sched->k0246[ 5], sched->k1357[ 5]);
    R ^= f(L, sched->k0246[ 4], sched->k1357[ 4]);
    L ^= f(R, sched->k0246[ 3], sched->k1357[ 3]);
    R ^= f(L, sched->k0246[ 2], sched->k1357[ 2]);
    L ^= f(R, sched->k0246[ 1], sched->k1357[ 1]);
    R ^= f(L, sched->k0246[ 0], sched->k1357[ 0]);

    L = rotl(L, 31);
    R = rotl(R, 31);

    swap = L; L = R; R = swap;

    FP(L, R);

    output[0] = L;
    output[1] = R;
}
Example #14
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		GetWindDirVel
//Author		Robert Slater
//Date			Thu 16 Dec 1999
//
//Description	Returns the wind speed and direction at a given altitude
//
//Inputs		Alt
//
//Returns		Wind Heading and Speed
//
//------------------------------------------------------------------------------
void Atmosphere::GetWindDirVel (SLong alt, SWord& hdg, FP& speed)
{
	if(!Save_Data.flightdifficulty [FD_WINDEFFECTS])
	{
		hdg = 0;
		speed = 0;
	}
	else
	{
		if(alt > 914400)	// 30,000 ft
		{
			hdg	  = SWord(diralt * 182.04);
			speed = 5148. * windalt;	//from knotts... to vel*1000
		}
		else
		{
			FP Dir0   = 182.04 * dir0;
			FP DirAlt = 182.04 * diralt;
			FP DeltaDir = DirAlt - Dir0;
			FP Fract = FP(alt) / 914411.0;
			FP fdir   = Dir0 + Fract * DeltaDir;
			
			speed = ((1. - Fract) * wind0 + Fract * windalt) * 5148.;
			hdg   = SWord(fdir);
		}
	}
}
Example #15
0
File: dz80.c Project: rasky/pacman
int diz80_worddata()
{
	if(t[1]==-1) {
		return diz80_bytedata();
	}

	FP(fx, "\tdefw 0%04xh", t[0]+256*t[1]);
	return 2;
}
Example #16
0
static int fsync_paranoid(const char *name) {
    char rp[1+PATH_MAX], *file = (char *) malloc(sizeof(char)*(strlen(name)+1));
    strcpy(file, name);
    FP(stderr, "fsync to root '%s'\n", file);
    if (NULL == realpath(file, rp))              BAIL("realpath failed");
    FP(stderr, "     realpath '%s'\n", rp);
    do {
        int fd;
            FP(stderr, "    fsync-ing '%s'\n", rp);
            if (-1 == (fd = open(rp, O_RDONLY)))       BAIL("open failed");
            if (-1 == fsync(fd))                       BAIL("fsync failed");
            if (-1 == close(fd))                       BAIL("close failed");
            trim_rightmost_path_component(rp);
        } while (*rp);
    FP(stderr, "         done\n");
    free(file);
    return 0;
}
Example #17
0
int main(int argc, char** argv)
{
    gsm gsmh;
    gsm_signal src[GSM_SAMPLE_BLOCK], dec[GSM_SAMPLE_BLOCK];
    gsm_frame dst;
    const char* inFN;
    FILE* inFile;
    const char* encFN;
    FILE* encFile;
    const char* decFN; 
    FILE* decFile;
    int n;      /* For status dots */
    
    if (4 != argc)
		fail ("Usage:  testjms input encode decode");
    inFN = argv[1];
    inFile = mustOpen(inFN, "rb");
    encFN = argv[2];
    encFile = mustOpen(encFN, "wb");
    decFN = argv[3];
    decFile = mustOpen(decFN, "wb");
    gsmh = gsm_create();
    if (! gsmh)
		fail ("Can't create gsm\n");
    
    while (fread(FP(src), inFile) == GSM_SAMPLE_BLOCK) {
		if ((n++) % 100) {
			(void) printf (".");
			n = 0;
		}       
		gsm_encode(gsmh, src, dst);
		fwrite(FP(dst), encFile);
		gsm_decode(gsmh, dst, dec);
		fwrite(FP(dec), decFile);
    }

    fclose (inFile);
    fclose (encFile);
    fclose (decFile);
    (void) puts ("\ndone");
    return 0;
}
Example #18
0
File: listen.c Project: Succubae/42
void		do_even_more_shit(char **env, char **path)
{
	int			i;
	t_print		*print;
/*	char		**commands;*/

	(void)env;
	(void)path;
	print = (t_print*)malloc(sizeof(t_print));
	print->line = NULL;
	print->histo = NULL;
	while (create_prompt(NULL))
	{
		change_term_info(malloc_struct());
		i = -1;
		wait_and_read(print);
		build_history_list(print);

/* ************************************************************************** */
/*  STRSPLIT SUR LES ; A REMPLACER PAR LE PARSER ? */
/*  LA LIGNE DE COMMANDE EST STOCKEE DANS LA STRUCTURE PRINT : PRINT->LINE */
		/*commands = ft_strsplit(print->line, ';');*/
/* ************************************************************************** */

/**************************************************************************** */
/*  JE FAIS UN STRCMP-exit POUR QUITTER EN ATTENDANT LA GESTION DES BUILTINS  */
/*  CE BLOC DEVRA ETRE SUPPRIME                                               */
		if (ft_strcmp(print->line, "exit") == 0)
		{
			change_back_term_info(NULL);
			exit(-1);
		}
/* ************************************************************************** */

/* ************************************************************************** */
/*  REMISE A ZERO DES PARAMETRES DU SHELL AVANT L'EXECUTION D'UNE COMMANDE    */
		if (print->line != NULL)
			free(print->line);
		FP("\n");
		tputs(tgetstr("ei", NULL), 1, out);
		change_back_term_info(NULL);
/* ************************************************************************** */

/* ************************************************************************** */
/*  EXECUTION DES COMMANDES SEPAREES PAR LES ;                                */
		/*while (++i, commands[i] != NULL)
			start_commands(commands[i], &env, path);
			delete_char_tab_tab(commands);*/
/* ************************************************************************** */

		revers_insert_mode(print);
	}
	free(print);
}
Example #19
0
static int fsync_dir(const char *name) 
{
    char *file = (char*) malloc(sizeof(char)*(strlen(name)+1));
    strcpy(file, name);
    trim_rightmost_path_component(file);
    FP(stderr, "    fsync-ing '%s'\n", file);
    int fd;
    if (-1 == (fd = open(file, O_RDONLY)))       BAIL("open failed");
    if (-1 == fsync(fd))                       BAIL("fsync failed");
    if (-1 == close(fd))                       BAIL("close failed");
    free(file);
    return 0;
}
Example #20
0
NodeDesc * JITEngine::loadNodeDescription(const char *filename)
{
    NodeCompiler nodeCompiler;
    // TODO add nc.addIncludeDir();
    llvm::Module *nodeModule = nodeCompiler.compile(filename);
    if (!nodeModule) {
        std::cout << "Unable to compile " << std::string(filename) << std::endl;
        return NULL;
    } else {
        std::cout << "Compiled " << std::string(filename) << std::endl;
    }

    // Search for the function getInstance in all the functions of 
    // this module
    llvm::Module::FunctionListType &flist = nodeModule->getFunctionList();
    llvm::Module::FunctionListType::iterator it=flist.begin();
    std::string createInstanceFunc;
    for(;it!=flist.end();++it) {
        if(it->getName().find("getInstance")!=std::string::npos) {
            //std::cout << it->getName().data() <<"\n";
            createInstanceFunc=it->getName().data();
        }
    }

    /// Link the new module in the current one
    std::string err2;
    if(Linker::LinkModules(m_llvmModule, nodeModule, llvm::Linker::PreserveSource, &err2)) {
        std::cout << "error linking module :" << err2 << std::endl;
    }

    delete nodeModule; nodeModule=NULL;

    //m_llvmPassManager->run(*m_llvmModule);
    m_llvmEngine->runStaticConstructorsDestructors(false); // Will allocate the static values
    llvm::Function* LF = m_llvmEngine->FindFunctionNamed(createInstanceFunc.c_str());

    // Run a graph viewer
    //LF->viewCFG();

    // Call the getInstance function
    void *FPtr = m_llvmEngine->getPointerToFunction(LF);
    NodeDesc * (*FP)() = (NodeDesc * (*)())(intptr_t)FPtr;
    NodeDesc *nodedesc = FP();

    return nodedesc;
}
Example #21
0
File: dz80.c Project: rasky/pacman
int diz80_pointers()
{
	char bstr[MAX_LINE_LEN];

	if(t[1]==-1) {
		return diz80_bytedata();
	}

	ckrange(0, bstr);
	FP(fx, "\tdefw %s", bstr);

	if(pass == 1 && a_labels) {
		symbol_newref(t[0]+256*t[1], pc, cstdfw);
	}

	return 2;
}
Example #22
0
void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
                  DES_key_schedule *ks2, DES_key_schedule *ks3)
{
    register DES_LONG l, r;

    l = data[0];
    r = data[1];
    IP(l, r);
    data[0] = l;
    data[1] = r;
    DES_encrypt2((DES_LONG *)data, ks3, DES_DECRYPT);
    DES_encrypt2((DES_LONG *)data, ks2, DES_ENCRYPT);
    DES_encrypt2((DES_LONG *)data, ks1, DES_DECRYPT);
    l = data[0];
    r = data[1];
    FP(r, l);
    data[0] = l;
    data[1] = r;
}
Example #23
0
void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
	     des_key_schedule ks3)
{
	DES_LONG l,r;

	l=data[0];
	r=data[1];
	IP(l,r);
	data[0]=l;
	data[1]=r;
	des_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT);
	des_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT);
	des_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT);
	l=data[0];
	r=data[1];
	FP(r,l);
	data[0]=l;
	data[1]=r;
}
Example #24
0
int
cpu_run(cpu_t *cpu, debug_function_t debug_function)
{
	addr_t pc = 0, orig_pc = 0;
	uint32_t i;
	int ret;
	bool success;
	bool do_translate = true;

	/* try to find the entry in all functions */
	while(true) {
		if (do_translate) {
			cpu_translate(cpu);
			pc = cpu->f.get_pc(cpu, cpu->rf.grf);
		}

		orig_pc = pc;
		success = false;
		for (i = 0; i < cpu->functions; i++) {
			fp_t FP = (fp_t)cpu->fp[i];
			update_timing(cpu, TIMER_RUN, true);
			breakpoint();
			ret = FP(cpu->RAM, cpu->rf.grf, cpu->rf.frf, debug_function);
			update_timing(cpu, TIMER_RUN, false);
			pc = cpu->f.get_pc(cpu, cpu->rf.grf);
			if (ret != JIT_RETURN_FUNCNOTFOUND)
				return ret;
			if (!is_inside_code_area(cpu, pc))
				return ret;
			if (pc != orig_pc) {
				success = true;
				break;
			}
		}
		if (!success) {
			LOG("{%" PRIx64 "}", pc);
			cpu_tag(cpu, pc);
			do_translate = true;
		}
	}
}
Example #25
0
void JITEngine::runFunctionNamed(const char *functionName)
{
    llvm::Function* LF = m_llvmEngine->FindFunctionNamed(functionName);

    //*m_llvmModule.dump();
    //m_llvmPassManager->run(*m_llvmModule);
    // DEBUG PRRINT
    //std::cerr << "=========================================" << std::endl;
    //*m_llvmModule.dump();
    //m_llvmFuncPassManager->run(*LF);

    LF->viewCFG();

    //LF->dump();
    // Compile the function and returns a pointer to it
    void *FPtr = m_llvmEngine->getPointerToFunction(LF);
    double (*FP)() = (double (*)())(intptr_t)FPtr;

    // Execute the function
    FP();
    //std::cout << "result=" << FP() << std::endl;
}
Example #26
0
	void Camera::setView(bool classic)
	{
		zfar2 = zfar * zfar;

		glMatrixMode (GL_PROJECTION);
		glLoadIdentity ();
		if (lp_CONFIG && lp_CONFIG->ortho_camera)
			glOrtho(-0.5f * zoomFactor * float(SCREEN_W), 0.5f * zoomFactor * float(SCREEN_W), -0.5f * zoomFactor * float(SCREEN_H), 0.5f * zoomFactor * float(SCREEN_H), znear, zfar);
		else
			glFrustum(-widthFactor * znear, widthFactor * znear, -0.75f * znear, 0.75f * znear, znear, zfar);

		if (classic)
		{
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();
		}

		pos = rpos;
		Vector3D FP(pos);
		FP += dir;
		FP += shakeVector;
		gluLookAt(pos.x + shakeVector.x, pos.y + shakeVector.y, pos.z + shakeVector.z,
				  FP.x, FP.y, FP.z,
				  up.x, up.y, up.z);

		if (!classic)
		{
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();
		}

		if (mirror)
		{
			glScalef(1.0f, -1.0f, 1.0f);
			glTranslatef(0.0f, mirrorPos - 2.0f * shakeVector.y, 0.0f);
		}
	}
Example #27
0
void ss_write_flonum(ss v, ss port)
{
  char buf[64];
  ss_minimal_double_str(ss_unb(flonum, v), buf, 63);
  fprintf(FP(port), "%s", buf);
}
Example #28
0
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴
//Procedure		GetKeyCommon
//Author		R. Hyde
//Date			Tue 31 Oct 1995
//
//Description	f
//
//Inputs
//
//Returns
//
//------------------------------------------------------------------------------
void	ManualPilot::GetKeyCommon(AirStrucPtr const ControlledAC)
{
	PMODEL pModel = ControlledAC->fly.pModel;

//#define PRINT_STICK_RUDDER
#ifdef PRINT_STICK_RUDDER
SWord temp;
temp = 39 + ControlledAC->fly.aileron / 1000;
PrintString(temp, 0, "      ");
temp = 39 + ControlledAC->fly.rudder / 1000;
PrintString(temp, 23, "      ");
temp = 12 + ControlledAC->fly.elevator / 2700;
PrintString(66, temp, "      ");

temp = 39 + pModel->Aileron / 1000;
PrintString(temp, 1, "      ");
temp = 39 + pModel->Rudder / 1000;
PrintString(temp, 24, "      ");
temp = 12 + pModel->Elevator / 2700;
PrintString(73, temp, "      ");
#endif

	GetStickKeys (ControlledAC2);							//RDH 04Mar96

//Set control values in Model including Central deadzone and end clipping

//#define PRINT_INPUT_DATA
#ifdef PRINT_INPUT_DATA
PrintVar(40, 15, "Raw Elev %.0f  ", (FP)ControlledAC->fly.elevator);
PrintVar(40, 16, "Raw Ailn %.0f  ", (FP)ControlledAC->fly.aileron);
PrintVar(40, 17, "Raw Rudd %.0f  ", (FP)ControlledAC->fly.rudder);
#endif

	if(_Analogue.tune[AU_ELEVATOR].mode == AM_REALISTIC)
		ApplyDeadZone (ControlledAC, ControlledAC->fly.elevator, pModel->Elevator, _Analogue.tune[AU_ELEVATOR].deadzones);
	else
		ApplyDeadZone2(ControlledAC, ControlledAC->fly.elevator, pModel->Elevator, _Analogue.tune[AU_ELEVATOR].deadzones);

	if(_Analogue.tune[AU_AILERON].mode == AM_REALISTIC)
		ApplyDeadZone (ControlledAC, ControlledAC->fly.aileron,  pModel->Aileron,  _Analogue.tune[AU_AILERON].deadzones);
	else
		ApplyDeadZone2(ControlledAC, ControlledAC->fly.aileron,  pModel->Aileron,  _Analogue.tune[AU_AILERON].deadzones);

	if(_Analogue.tune[AU_RUDDER].mode == AM_REALISTIC)
		ApplyDeadZone (ControlledAC, ControlledAC->fly.rudder,   pModel->Rudder,   _Analogue.tune[AU_RUDDER].deadzones);
	else
		ApplyDeadZone2(ControlledAC, ControlledAC->fly.rudder,   pModel->Rudder,   _Analogue.tune[AU_RUDDER].deadzones);

	FP temp = 1.0 - pModel->Speed / pModel->ControlLossV1;
	if(temp < 0.0)	temp = 0.0;
	ControlledAC->fly.rudder = temp * ControlledAC->fly.rudder;
	pModel->Rudder = temp * pModel->Rudder;

	SecondaryControls (ControlledAC2);

	if(Save_Data.flightdifficulty[FD_SPINS])
	{
		if(pModel->BombingPhase == 1)
			pModel->ElevatorTrim = 8192;

		if(pModel->BombingPhase == 2)
		{
			pModel->ElevatorTrim = 0;

			if(pModel->Elevator < -30000)
				pModel->Elevator = pModel->Elevator + 30000;
			else
				pModel->Elevator = 0;
		}

		pModel->Elevator += pModel->ElevatorTrim;
		pModel->Aileron  += pModel->AileronTrim;
		pModel->Rudder   += pModel->RudderTrim;

		if(Save_Data.flightdifficulty [FD_SLIPSTREAMEFFECTS])
			pModel->Rudder += pModel->SlipstreamRudder;
	}

	MODLIMIT(pModel->Elevator, 32767);
	MODLIMIT(pModel->Aileron,  32767);
	MODLIMIT(pModel->Rudder,   32767);

#ifdef PRINT_INPUT_DATA
PrintVar(60, 15, "Mod Elev %.0f  ", (FP)pModel->Elevator);
PrintVar(60, 16, "Mod Ailn %.0f  ", (FP)pModel->Aileron);
PrintVar(60, 17, "Mod Rudd %.0f  ", (FP)pModel->Rudder);
#endif

#ifdef PRINT_STICK_RUDDER
temp = 39 + ControlledAC->fly.aileron / 1000;
PrintVar(temp, 0, "%.0f", FP(ControlledAC->fly.aileron));
temp = 39 + ControlledAC->fly.rudder / 1000;
PrintVar(temp, 23, "%.0f", FP(ControlledAC->fly.rudder));
temp = 12 + ControlledAC->fly.elevator / 2700;
PrintVar(66, temp, "%.0f", FP(ControlledAC->fly.elevator));

temp = 39 + pModel->Aileron / 1000;
PrintVar(temp, 1, "%.0f", FP(pModel->Aileron));
temp = 39 + pModel->Rudder / 1000;
PrintVar(temp, 24, "%.0f", FP(pModel->Rudder));
temp = 12 + pModel->Elevator / 2700;
PrintVar(73, temp, "%.0f", FP(pModel->Elevator));
#endif

	bool ThrottleSettingChanged = FALSE;
	bool PropSettingChanged = FALSE;

	PENGINE pEngine0 = pModel->EngineList;
	PENGINE pEngine1 = pModel->EngineList->List.NextItem();

	if(pEngine0)
	{
		if(Key_Tests.KeyPress3d(FK_THROTTLE0))
		{
			SLong	tmpacthrust = pEngine0->ThrottleSetting;
			SLong	delta = _Interactive.GetDelta(INST_THROTTLE, tmpacthrust);

			tmpacthrust += (delta*100)>>7;
			MODMAXMIN(tmpacthrust,0,100);

			pEngine0->ThrottleSetting		= tmpacthrust;
			pModel->ModelThrottle			= tmpacthrust;
			ControlledAC->fly.thrustpercent = tmpacthrust;
		}
		if(Key_Tests.KeyPress3d(FK_PROPPITCH0))
		{
			SLong	tmpacprop = 100.0 * pEngine0->PropSetting;
			SLong	delta = _Interactive.GetDelta(INST_PROPPITCH, tmpacprop);

			tmpacprop += (delta*100)>>7;
			MODMAXMIN(tmpacprop,0,100);

			pEngine0->PropSetting			= 0.01 * tmpacprop;
			pModel->ModelPropSetting		= tmpacprop;
			ControlledAC->fly.propsetting	= tmpacprop;
		}
Example #29
0
void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
{
    register DES_LONG l, r, t, u;
#ifdef DES_PTR
    register const unsigned char *des_SP = (const unsigned char *)DES_SPtrans;
#endif
#ifndef DES_UNROLL
    register int i;
#endif
    register DES_LONG *s;

    r = data[0];
    l = data[1];

    IP(r, l);
    /*
     * Things have been modified so that the initial rotate is done outside
     * the loop.  This required the DES_SPtrans values in sp.h to be rotated
     * 1 bit to the right. One perl script later and things have a 5% speed
     * up on a sparc2. Thanks to Richard Outerbridge
     * <*****@*****.**> for pointing this out.
     */
    /* clear the top bits on machines with 8byte longs */
    /* shift left by 2 */
    r = ROTATE(r, 29) & 0xffffffffL;
    l = ROTATE(l, 29) & 0xffffffffL;

    s = ks->ks->deslong;
    /*
     * I don't know if it is worth the effort of loop unrolling the inner
     * loop
     */
    if (enc) {
#ifdef DES_UNROLL
        D_ENCRYPT(l, r, 0);     /* 1 */
        D_ENCRYPT(r, l, 2);     /* 2 */
        D_ENCRYPT(l, r, 4);     /* 3 */
        D_ENCRYPT(r, l, 6);     /* 4 */
        D_ENCRYPT(l, r, 8);     /* 5 */
        D_ENCRYPT(r, l, 10);    /* 6 */
        D_ENCRYPT(l, r, 12);    /* 7 */
        D_ENCRYPT(r, l, 14);    /* 8 */
        D_ENCRYPT(l, r, 16);    /* 9 */
        D_ENCRYPT(r, l, 18);    /* 10 */
        D_ENCRYPT(l, r, 20);    /* 11 */
        D_ENCRYPT(r, l, 22);    /* 12 */
        D_ENCRYPT(l, r, 24);    /* 13 */
        D_ENCRYPT(r, l, 26);    /* 14 */
        D_ENCRYPT(l, r, 28);    /* 15 */
        D_ENCRYPT(r, l, 30);    /* 16 */
#else
        for (i = 0; i < 32; i += 4) {
            D_ENCRYPT(l, r, i + 0); /* 1 */
            D_ENCRYPT(r, l, i + 2); /* 2 */
        }
#endif
    } else {
#ifdef DES_UNROLL
        D_ENCRYPT(l, r, 30);    /* 16 */
        D_ENCRYPT(r, l, 28);    /* 15 */
        D_ENCRYPT(l, r, 26);    /* 14 */
        D_ENCRYPT(r, l, 24);    /* 13 */
        D_ENCRYPT(l, r, 22);    /* 12 */
        D_ENCRYPT(r, l, 20);    /* 11 */
        D_ENCRYPT(l, r, 18);    /* 10 */
        D_ENCRYPT(r, l, 16);    /* 9 */
        D_ENCRYPT(l, r, 14);    /* 8 */
        D_ENCRYPT(r, l, 12);    /* 7 */
        D_ENCRYPT(l, r, 10);    /* 6 */
        D_ENCRYPT(r, l, 8);     /* 5 */
        D_ENCRYPT(l, r, 6);     /* 4 */
        D_ENCRYPT(r, l, 4);     /* 3 */
        D_ENCRYPT(l, r, 2);     /* 2 */
        D_ENCRYPT(r, l, 0);     /* 1 */
#else
        for (i = 30; i > 0; i -= 4) {
            D_ENCRYPT(l, r, i - 0); /* 16 */
            D_ENCRYPT(r, l, i - 2); /* 15 */
        }
#endif
    }

    /* rotate and clear the top bits on machines with 8byte longs */
    l = ROTATE(l, 3) & 0xffffffffL;
    r = ROTATE(r, 3) & 0xffffffffL;

    FP(r, l);
    data[0] = l;
    data[1] = r;
    l = r = t = u = 0;
}
Example #30
0
#define GDB_FPSCR 71
#define GDB_LAST GDB_FPSCR

#define FP(NAME, n)					\
	{						\
		.off    = sizeof(double) * n,		\
			.size   = sizeof(double),	\
			.gdb    = GDB_FPR##n,		\
			.name   = #NAME,		\
			.gdb_size   = sizeof(double),	\
	}

/* Floating point */
struct reg_location_list frll[] = {
	FP(fp0, 0),   FP(fp1, 1),   FP(fp2, 2),   FP(fp3, 3),
	FP(fp4, 4),   FP(fp5, 5),   FP(fp6, 6),   FP(fp7, 7),
	FP(fp8, 8),   FP(fp9, 9),   FP(fp10, 10), FP(fp11, 11),
	FP(fp12, 12), FP(fp13, 13), FP(fp14, 14), FP(fp15, 15),
	FP(fp16, 16), FP(fp17, 17), FP(fp18, 18), FP(fp19, 19),
	FP(fp20, 20), FP(fp21, 21), FP(fp22, 22), FP(fp23, 23),
	FP(fp24, 24), FP(fp25, 25), FP(fp26, 26), FP(fp27, 27),
	FP(fp28, 28), FP(fp29, 29), FP(fp30, 30), FP(fp31, 31),
	{ .name = "scr", .off = 32 * sizeof(double) ,
	  .size = 4, .gdb_size = 4, .gdb = GDB_FPSCR, },
	{0},
};

/*
 * FreeBSD as of 9.0 does not support altivec
 */