コード例 #1
0
ファイル: if_sc_lpe.c プロジェクト: 0xCA5A/dd-wrt
bool 
cyg_sc_lpe_init(struct cyg_netdevtab_entry *tab)
{
    struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance;
    dp83902a_priv_data_t *dp = (dp83902a_priv_data_t *)sc->driver_private;
    struct cf_slot* slot;

    cf_init();  // Make sure Compact Flash subsystem is initialized
    slot = dp->plf_priv = (void*)cf_get_slot(0);
    dp->tab = tab;

#ifdef CYGPKG_KERNEL
    // Create card handling [background] thread
    cyg_thread_create(CYGPKG_NET_THREAD_PRIORITY-1,          // Priority
                      sc_lpe_card_handler,                   // entry
                      (cyg_addrword_t)sc,                    // entry parameter
                      "SC LP-E card support",                // Name
                      &sc_lpe_card_handler_stack[0],         // Stack
                      STACK_SIZE,                            // Size
                      &sc_lpe_card_handler_thread_handle,    // Handle
                      &sc_lpe_card_handler_thread_data       // Thread data structure
            );
    cyg_thread_resume(sc_lpe_card_handler_thread_handle);    // Start it

    // Initialize environment, setup interrupt handler
    // eth_drv_dsr is used to tell the fast net thread to run the deliver funcion.
    cf_register_handler(slot, eth_drv_dsr, sc);

    return false;  // Device is not ready until inserted, powered up, etc.
#else
    // Initialize card
    return sc_lpe_card_handler((cyg_addrword_t)sc);
#endif
}
コード例 #2
0
ファイル: main.c プロジェクト: EdCornejo/emu-ex-plus-alpha
int main(int argc, char *argv[])
{
    char *rom_name;



#ifdef __AMIGA__
    BPTR file_lock = GetProgramDir();
    SetProgramDir(file_lock);
#endif
	signal(SIGSEGV, catch_me);

#ifdef WII
	//   SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);

	fatInitDefault();
#endif

    cf_init(); /* must be the first thing to do */
    cf_init_cmd_line();
    cf_open_file(NULL); /* Open Default configuration file */

    rom_name=cf_parse_cmd_line(argc,argv);

    /* print effect/blitter list if asked by user */
    if (!strcmp(CF_STR(cf_get_item_by_name("effect")),"help")) {
	print_effect_list();
	exit(0);
    }
    if (!strcmp(CF_STR(cf_get_item_by_name("blitter")),"help")) {
	print_blitter_list();
	exit(0);
    }

	init_sdl();

/* GP2X stuff */
#ifdef GP2X
    gp2x_init();
#endif
    if (gn_init_skin()!=SDL_TRUE) {
	    printf("Can't load skin...\n");
            exit(1);
    }    

	reset_frame_skip();

    if (conf.debug) conf.sound=0;

/* Launch the specified game, or the rom browser if no game was specified*/
	if (!rom_name) {
	//	rom_browser_menu();
		run_menu();
		printf("GAME %s\n",conf.game);
		if (conf.game==NULL) return 0;
	} else {

		if (init_game(rom_name)!=SDL_TRUE) {
			printf("Can't init %s...\n",rom_name);
            exit(1);
		}    
	}

	/* If asked, do a .gno dump and exit*/
    if (CF_BOOL(cf_get_item_by_name("dump"))) {
        char dump[8+4+1];
        sprintf(dump,"%s.gno",rom_name);
        dr_save_gno(&memory.rom,dump);
        close_game();
        return 0;
    }

    if (conf.debug)
	    debug_loop();
    else
	    main_loop();

    close_game();

    return 0;
}
コード例 #3
0
ファイル: test_wiener.c プロジェクト: fxfactorial/bachelor
/**
 * \brief Testing the continued fractions generator.
 *
 *
 */
void test_cf(void)
{
  bigfraction_t x = {NULL, NULL};
  cf_t* f;
  size_t i;
  bigfraction_t *it;
  BIGNUM* expected;

  f = cf_new();
  x.h = BN_new();
  x.k = BN_new();
  expected = BN_new();

   /*
   *  Testing aᵢ
   *
   *              1
   * √2 = 1 + ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽
   *                  1
   *           2 +  ⎽⎽⎽⎽⎽⎽
   *                 2 + …
   *
   */
  BN_dec2bn(&x.h, "14142135623730951");
  BN_dec2bn(&x.k, "10000000000000000");
  BN_dec2bn(&expected, "2");
  cf_init(f, x.h, x.k);

  it = cf_next(f);
  assert(BN_is_one(f->a));
  for (i=0; i!=5 && it; i++) {
    it = cf_next(f);
    assert(!BN_cmp(f->a, expected));
  }
  assert(i==5);

  /*
   * Testing hᵢ/kᵢ
   *
   *                        1
   * φ = (1+√5)/2  = 1 + ⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽
   *                            1
   *                      1 + ⎽⎽⎽⎽⎽
   *                          1 + …
   */
  const char* fib[] = {"1", "1", "2", "3", "5", "8", "13"};
  BN_dec2bn(&x.h, "323606797749979");
  BN_dec2bn(&x.k, "200000000000000");
  cf_init(f, x.h, x.k);
  it = cf_next(f);
  for (i=1; i!=7; i++) {
    BN_dec2bn(&expected, fib[i]);
    assert(!BN_cmp(it->h, expected));

    BN_dec2bn(&expected, fib[i-1]);
    assert(!BN_cmp(it->k, expected));

    it=cf_next(f);
  }

  BN_dec2bn(&x.h, "60728973");
  BN_dec2bn(&x.k, "160523347");
  cf_init(f, x.h, x.k);
  /* 0 */
  it = cf_next(f);
  /* 1 / 2 */
  it = cf_next(f);
  BN_dec2bn(&expected, "2");
  assert(BN_is_one(it->h) && !BN_cmp(it->k, expected));
  /* 1 / 3 */
  it = cf_next(f);
  BN_dec2bn(&expected, "3");
  assert(BN_is_one(it->h) && !BN_cmp(it->k, expected));
  /* 2 / 5 */
  it = cf_next(f);
  BN_dec2bn(&expected, "2");
  assert(!BN_cmp(expected, it->h));
  BN_dec2bn(&expected, "5");
  assert(!BN_cmp(expected, it->k));
  /* 3 / 8 */
  it = cf_next(f);
  BN_dec2bn(&expected, "3");
  assert(!BN_cmp(expected, it->h));
  BN_dec2bn(&expected, "8");
  assert(!BN_cmp(expected, it->k));
  /* 14/ 37 */
  it = cf_next(f);
  BN_dec2bn(&expected, "14");
  assert(!BN_cmp(expected, it->h));
  BN_dec2bn(&expected, "37");
  assert(!BN_cmp(expected, it->k));
}
コード例 #4
0
ファイル: dbconvert.c プロジェクト: Haunted-Memories/rhost
int 
main(int argc, char *argv[])
{
    int setflags, clrflags, ver, nochk;
    int db_ver, db_format, db_flags, do_check, do_write;
    char *fp;
    FILE *f_ptr;
    char s_filename[120];

    f_ptr = NULL;
    nochk = 0;
    if (argc == 3) {
	for (fp = argv[2]; *fp; fp++) {
           if (*fp == 'x') {
              nochk = 1;
              break;
           }
        }
    }
    if (!nochk) {
       sprintf(s_filename, "%.115s.db", argv[1]);
       if ( (f_ptr = fopen(s_filename, "r")) != NULL ) {
          fprintf(stderr, "GDBM file(s) already exist for %s\n", s_filename);
          fclose(f_ptr);
          exit(1);
       }
       sprintf(s_filename, "%.115s.dir", argv[1]);
       if ( (f_ptr = fopen(s_filename, "r")) != NULL ) {
          fprintf(stderr, "GDBM file(s) already exist for %s\n", s_filename);
          fclose(f_ptr);
          exit(1);
       }
       sprintf(s_filename, "%.115s.pag", argv[1]);
       if ( (f_ptr = fopen(s_filename, "r")) != NULL ) {
          fprintf(stderr, "GDBM file(s) already exist for %s\n", s_filename);
          fclose(f_ptr);
          exit(1);
       }
    }
    debugmem = (Debugmem *)malloc(sizeof(Debugmem));

    if( !debugmem )
      abort();

    INITDEBUG(debugmem);

    if ((argc < 2) || (argc > 3)) {
	usage(argv[0]);
	exit(1);
    }
    dddb_var_init();
    cache_var_init();
    cf_init();

    /* Decide what conversions to do and how to format the output file */

    setflags = clrflags = ver = do_check = 0;
    do_write = 1;

    if (argc == 3) {
	for (fp = argv[2]; *fp; fp++) {
	    switch (*fp) {
	    case 'C':
		do_check = 1;
		break;
	    case 'G':
		setflags |= V_GDBM;
		break;
	    case 'g':
		clrflags |= V_GDBM;
		break;
	    case 'Z':
		setflags |= V_ZONE;
		break;
	    case 'z':
		clrflags |= V_ZONE;
		break;
	    case 'L':
		setflags |= V_LINK;
		break;
	    case 'l':
		clrflags |= V_LINK;
		break;
	    case 'N':
		setflags |= V_ATRNAME;
		break;
	    case 'n':
		clrflags |= V_ATRNAME;
		break;
	    case 'K':
		setflags |= V_ATRKEY;
		break;
	    case 'k':
		clrflags |= V_ATRKEY;
		break;
	    case 'P':
		setflags |= V_PARENT;
		break;
	    case 'p':
		clrflags |= V_PARENT;
		break;
	    case 'W':
		do_write = 1;
		break;
	    case 'w':
		do_write = 0;
		break;
	    case 'X':
		clrflags = 0xffffffff;
		setflags = OUTPUT_FLAGS;
		ver = OUTPUT_VERSION;
		break;
	    case 'x':
		clrflags = 0xffffffff;
		setflags = UNLOAD_OUTFLAGS;
		ver = UNLOAD_VERSION;
		break;
	    case '0':
	    case '1':
	    case '2':
	    case '3':
	    case '4':
	    case '5':
	    case '6':
	    case '7':
	    case '8':
	    case '9':
		ver = ver * 10 + (*fp - '0');
		break;
	    default:
		fprintf(stderr, "Unknown flag: '%c'\n", *fp);
		usage(argv[0]);
		exit(1);
	    }
	}
    }
    /* Open the gdbm file */

    if (init_gdbm_db(argv[1]) < 0) {
	fprintf(stderr, "Can't open GDBM file\n");
	exit(1);
    }
    /* Go do it */

    db_read(stdin, &db_format, &db_ver, &db_flags);
    fprintf(stderr, "Input: ");
    info(db_format, db_flags, db_ver);
    val_count();

    if (do_check)
	do_dbck(NOTHING, NOTHING, DBCK_FULL);

    if (do_write) {
	db_flags = (db_flags & ~clrflags) | setflags;
	if (db_format != F_MUSH)
	    db_ver = 3;
	if (ver != 0)
	    db_ver = ver;
	fprintf(stderr, "Output: ");
	info(F_MUSH, db_flags, db_ver);
	db_write(stdout, F_MUSH, db_ver | db_flags);
    }
    CLOSE;
    return(0);
}