Esempio n. 1
0
File: fd.c Progetto: huangrui/Thunix
/*
 * This waits for FDC command to complete 
 *
 * @param: sensei
 * @return: if successfull then returns TRUE, or FALSE
 *
 */
static int wait_fdc(int sensei)
{
        int time_out;
        count_down = 30; /* set count_down init. value to 300 ms*/

	/* 
 	 * As I was developing thunix on bochs, that means we don't
	 * need a hardware delay, so I make the count_down to 10 ms
	 */
        count_down = 1; 

        /* wait for FLOPPY_INTERRUPT hander to signal command finished */
        while (!done && count_down)
                ;
        time_out = count_down;
#if 0       
        do{
                printk("time_out:%d\n",time_out);
                printk("done:    %d\n",done);
        }while(0);
        res = get_result(); /* get the result of the command */
#endif

        /* 
         * we use get_byte() but NOT get_result() here, because i don't
         * know where the error happened. or maybe get_byte() is better
         * than get_result(), it just come from the test
         *
        ST0 = get_byte();
        ST1 = get_byte();
        ST2 = get_byte();
        ST3 = get_byte();
         */
	
	memset(reply_buffer, 0, sizeof(reply_buffer));
	get_result();
#if 0
	hexdump(reply_buffer, sizeof(reply_buffer));
#endif

        if (sensei) {
                /* send a "sense interrupt status" command */
                send_byte(FD_SENSEI);
                sr0 = get_byte();
                fdc_track = get_byte();
        }
        
	LOG("time left: %d\t done: %d\n", time_out, done);
        done = FALSE;
        if (time_out == 0)
                return FALSE;
        else
                return TRUE;
}
Esempio n. 2
0
/**
 * Returns the widest property this node can prove without invalidating one of the successors.
 */
property node::maximal() const
{
  property res;
  property const &current = get_result();
  for(node_set::const_iterator i = succ.begin(), end = succ.end(); i != end; ++i)
  {
    property p = (*i)->maximal_for(this);
    if (res.null()) res = p;
    else res.intersect(p);
    if (!current.strict_implies(res)) break;
  }
  return res.null() ? get_result() : res;
}
Esempio n. 3
0
oop processOopClass::TWAINS_prim(objVectorOop resultArg, 
                                 bool stepping, oop stop, void *FH) {
  if (SignalInterface::are_self_signals_blocked())
    warning("_TWAINS: signals are blocked (with _BlockSignals)");
  
  Process* proc= TWAINS_receiver_check(FH);
  if (proc == NULL) return NULL;
  if (!TWAINS_result_vector_check( resultArg, FH)) return NULL;
  vframeOop stop_vfo= TWAINS_stop_activation_check(proc, stop, FH);
  if (stop_vfo == vframeOop(badOop)) return NULL;
  if (!TWAINS_parallel_check(FH)) return NULL;

  preemptCause = cNoCause;
  twainsProcess = currentProcess;
  if (PendingSelfSignals::are_any_pending() && !SignalInterface::are_self_signals_blocked()) {
    // return immediately - have unhandled signals
    preemptCause = cSignal;
  }
  else if (proc != twainsProcess) {
    TWAINS_transfer_to_another_process(proc, resultArg, stepping, stop_vfo);
  }
  else {
    TWAINS_await_signal();
  }
  twainsProcess = NULL;
  
  oop res = get_result(resultArg);
  LOG_EVENT3("TWAINS: res = %#lx { %#lx, %#lx, ... }", res,
             resultArg->obj_at(0), resultArg->obj_at(1));
  preemptCause = cNoCause;
  return res;
}
Esempio n. 4
0
hasher_md5_result hasher_md5::process_single(const void * p_buffer,t_size p_bytes)
{
	hasher_md5_state state;
	initialize(state);
	process(state,p_buffer,p_bytes);
	return get_result(state);
}
Esempio n. 5
0
int main(int argc, char *argv[])
{
	int i;
	int len;

	char * c;
	char buf[256];
	char out[256];

	c = fgets(buf, sizeof(buf), stdin);
	if (c == NULL) {
		return 0;
	}

	len = strlen(buf) - 1;
	buf[len] = 0;

	for (i = 0; i < len/2; i++) {
		char tmp = buf[i];
		buf[i] = buf[len - i - 1];
		buf[len - i - 1] = tmp;
	}

	get_result(buf);

	return 0;
}
Esempio n. 6
0
INT64_T chirp_client_fsync(struct chirp_client * c, INT64_T fd, time_t stoptime)
{
	INT64_T result = chirp_client_fsync_begin(c, fd, stoptime);
	if(result >= 0)
		return get_result(c, stoptime);
	return result;
}
//move all sides till stop/end
possible_end_play_signal replay_controller::play_replay(){

	if (recorder.at_end()){
		//shouldn't actually happen
		return boost::none;
	}

	is_playing_ = true;
	replay_ui_playback_should_start();

	possible_end_play_signal signal = play_replay_main_loop();

	if(signal) {
		switch ( boost::apply_visitor(get_signal_type(), *signal)) {
			case END_TURN:
				return signal;
			case END_LEVEL:
				if ( boost::apply_visitor(get_result(), *signal) == QUIT) {
					return signal;
				}
		}

	}

	if (!is_playing_) {
		gui_->scroll_to_leader(player_number_,game_display::ONSCREEN,false);
	}

	replay_ui_playback_should_stop();

	return boost::none;
}
Esempio n. 8
0
void test_simple_job() {
	JobManager manager{4};
	manager.start();

	std::atomic<int> finish_count(0);
	int job_count = 1337;
	bool result = false;

	auto job_function = []() -> int {
		return 42;
	};

	auto job_callback = [&](result_function_t<int> get_result) {
		int job_result = get_result();
		if (job_result == 42) {
			result = true;
		}
		finish_count++;
	};

	for (int i = 0; i < job_count; i++) {
		manager.enqueue<int>(job_function, job_callback);
	}

	while (finish_count.load() < job_count) {
		manager.execute_callbacks();
	}

	manager.stop();

	result or TESTFAIL;
}
Esempio n. 9
0
File: dbase.c Progetto: OPSF/uClinux
/*
 * Query table for specified rows
 * _h: structure representing database connection
 * _k: key names
 * _op: operators
 * _v: values of the keys that must match
 * _c: column names to return
 * _n: nmber of key=values pairs to compare
 * _nc: number of columns to return
 * _o: order by the specified column
 */
int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op,
	     db_val_t* _v, db_key_t* _c, int _n, int _nc,
	     db_key_t _o, db_res_t** _r)
{
	int off, rv;
	if (!_c) {
		off = snprintf(sql_buf, SQL_BUF_LEN,
			"select * from %s ", CON_TABLE(_h));
	} else {
		off = snprintf(sql_buf, SQL_BUF_LEN, "select ");
		off += print_columns(sql_buf + off, SQL_BUF_LEN - off, _c, _nc);
		off += snprintf(sql_buf + off, SQL_BUF_LEN - off,
			"from %s ", CON_TABLE(_h));
	}
	if (_n) {
		off += snprintf(sql_buf + off, SQL_BUF_LEN - off, "where ");
		off += print_where(sql_buf + off, SQL_BUF_LEN - off,
			_k, _op, _v, _n);
	}
	if (_o) {
		off += snprintf(sql_buf + off, SQL_BUF_LEN - off,
			"order by %s", _o);
	}

	if(begin_transaction(_h, sql_buf)) return(-1);
	if (submit_query(_h, sql_buf) < 0) {
		LOG(L_ERR, "db_query(): Error while submitting query\n");
		return -2;
	}
	rv = get_result(_h, _r);
	free_query(_h);
	commit_transaction(_h);
	return(rv);
}
Esempio n. 10
0
int main(){
  apisock *sock;
  binresult *res;
  sock=api_connect();
  if (!sock){
    fprintf(stderr, "Cannot connect to server\n");
    return 1;
  }
  res=send_command(sock, "userinfo", P_STR("auth", "Ec7QkEjFUnzZ7Z8W2YH1qLgxY7gGvTe09AH0i7V3kX"));
  if (!res){
    fprintf(stderr, "Command failed\n");
    return 1;
  }
  print_tree(res, 0);
  free(res);
  res=send_command(sock, "diff", P_NUM("folderid", 0), P_BOOL("recursive", 1), P_STR("timeformat", "timestamp"));
  if (!res){
    fprintf(stderr, "Command failed\n");
    return 1;
  }
  print_tree(res, 0);
  free(res);
  return 0;
  send_command_nb(sock, "diff", P_NUM("diffid", 0));
  res=get_result(sock);
  if (!res){
    fprintf(stderr, "Command failed\n");
    return 1;
  }
  print_tree(res, 0);
//  printf("%u %llu\n", res->type, res->num);
  free(res);
  api_close(sock);
  return 0;
}
void MeshPara::LSCM()
{
	is_Parameterized = true;
	int nb_vertices = mesh_.n_vertices();

	nlNewContext();
	nlSolverParameteri(NL_SOLVER, NL_CG);
	nlSolverParameteri(NL_PRECONDITIONER, NL_PRECOND_JACOBI);
	nlSolverParameteri(NL_NB_VARIABLES, 2 * nb_vertices);
	nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE);
	nlSolverParameteri(NL_MAX_ITERATIONS, 5 * nb_vertices);
	nlSolverParameterd(NL_THRESHOLD, 1e-10);
	
	nlBegin(NL_SYSTEM);
	init_slover();
	nlBegin(NL_MATRIX);
	setup_LSCM();
	nlEnd(NL_MATRIX);
	nlEnd(NL_SYSTEM);
	std::cout << "Solving ..." << std::endl;
	nlSolve();

	// Get results
	get_result();

	// Display time and iter_num
	double time;
	NLint iterations;
	nlGetDoublev(NL_ELAPSED_TIME, &time);
	nlGetIntergerv(NL_USED_ITERATIONS, &iterations);
	std::cout << "Solver time: " << time << std::endl;
	std::cout << "Used iterations: " << iterations << std::endl;

	nlDeleteContext(nlGetCurrent());	
}
Esempio n. 12
0
DLLEXPORT int
chirp_client_swrite( struct chirp_client *c, int fd, const void *buffer,
					int length, int offset, int stride_length, int stride_skip )
{
	int actual;
	int result;

	char command[CHIRP_LINE_MAX];
	sprintf(command, "swrite %d %d %d %d %d\n", fd, length, offset, 
			stride_length, stride_skip);

#ifdef DEBUG_CHIRP
	printf("chirp sending: %s", command);
#endif
	
	result = fputs(command, c->wstream);
	if(result < 0) chirp_fatal_request("swrite");

	result = fflush(c->wstream);
	if(result < 0) chirp_fatal_request("swrite");

	actual = fwrite(buffer,1,length,c->wstream);
	if(actual != length) chirp_fatal_request("swrite");

	return convert_result(get_result(c->rstream));
}
Esempio n. 13
0
int main()
{
	int i, j, k, t = 0;

	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
			break;
		for (i = 1; i <= n; i++)
			scanf("%d%d", &stones[i].x, &stones[i].y);

		k = 0;
		for (i = 1; i <= n; i++)
			for (j = i+1; j <= n; j++)
			{
				paths[k].u = i;
				paths[k].v = j;
				paths[k].w = (stones[i].x-stones[j].x)*(stones[i].x-stones[j].x) + 
					(stones[i].y-stones[j].y)*(stones[i].y-stones[j].y);
				k++;
			}

		edge_num = k;
		kruskal();
		t++;
		printf("Scenario #%d\nFrog Distance = %.3f\n\n", t, sqrt(get_result()));
	}

	return 0;
}
Esempio n. 14
0
/*
 * This is the service routine for the syscall #48 (signal funcs).
 *
 * Examine the request code and branch on the request to the appropriate
 * function.
 */
int
abi_sigfunc(struct pt_regs *regp)
{
	int			sig_type = (int)HIDDEN_PARAM(regp);

#if defined(CONFIG_ABI_TRACE)
	abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
		"sig%s(%ld, 0x%08lx, 0x%08lx)\n",
			sig_type == 0 ? "nal"
			: (sig_type == 0x100 ? "set"
			: (sig_type == 0x200 ? "hold"
			: (sig_type == 0x400 ? "relse"
			: (sig_type == 0x800 ? "ignore"
			: (sig_type == 0x1000 ? "pause"
			: "???" ))))),
			SIGNAL_NUMBER(regp) & 0xff,
			SECOND_PARAM(regp),
			THIRD_PARAM(regp));
#endif

	_FLG(regp)   &= ~1;
	_AX(regp)     = 0;

	switch (sig_type) {
	case 0x0000:
		abi_signal(regp);
		break;
	case 0x0100:
		abi_sigset(regp);
		break;
	case 0x0200:
		abi_sighold(regp);
		break;
	case 0x0400:
		abi_sigrelse(regp);
		break;
	case 0x0800:
		abi_sigignore(regp);
		break;
	case 0x1000:
		abi_sigpause(regp);
		break;
	default:
		set_error(regp, EINVAL);

#if defined(CONFIG_ABI_TRACE)
		abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
				"sigfunc(%x, %ld, %lx, %lx) unsupported\n",
				sig_type, SIGNAL_NUMBER(regp),
				SECOND_PARAM(regp), THIRD_PARAM(regp));
#endif
		return 0;
	}

#if defined(CONFIG_ABI_TRACE)
	abi_trace(ABI_TRACE_SIGNAL|ABI_TRACE_SIGNAL_F,
			"returns %d\n", get_result(regp));
#endif
	return 0;
}
Esempio n. 15
0
INT64_T chirp_client_fstat_finish(struct chirp_client * c, INT64_T fd, struct chirp_stat * info, time_t stoptime)
{
	INT64_T result = get_result(c, stoptime);
	if(result >= 0)
		return get_stat_result(c, info, stoptime);
	return result;
}
Esempio n. 16
0
//=========================================================================
scx::ScriptRef* SQLiteQuery::result() const
{
  int count = ::sqlite3_data_count(m_stmt);
  scx::ScriptMap* row = new scx::ScriptMap();
  for (int i=0; i<count; ++i) {
    row->give(::sqlite3_column_name(m_stmt, i), get_result(i));
  }
  return new scx::ScriptRef(row);
}
Esempio n. 17
0
wait::~wait()
{
	try {
		if (get_result() == QUIT) {
			state_ = saved_game();
			state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;
		}
	} catch (...) {}
}
Esempio n. 18
0
MediaEntries InstagramClient::get_media(const Http::HttpUrl& url){
    const Http::HttpResponse response = http_client << url;

    if(response.get_code() == Http::Status::OK){
        return parser.parse_media_entries(response.get_data());
    }else{
        return get_result(response);
    }
}
Esempio n. 19
0
int main(int argc, char * argv[]){
	int threads = parse_number_threads(argc, argv);
	double **A; int size; 
    Lab3LoadInput(&A, &size);
    double storage[size];

    // Initialize Times
	double start_time;
	double end_time;
	GET_TIME(start_time);


 	int k;
 	for (k = 0; k < size; k++){
 		int max_indice = find_max_indice(k, A, size);
 		swap_rows(A, k, max_indice);

 		int i;
 		int j;
		//printf("Current k value: %d \n",k);
		//printf("----------------------------\n");
 		for (i = k+1; i < size; i++){
		//printf("Current Row: %d \n",i);
			double subtrahend_coefficient = (A[i][k]/A[k][k]);
			//printf("Subtrahend Coefficient: %f \n",subtrahend_coefficient);
 			for (j = k; j < size + 1; j++){
				//printf("Current Col: %d \n",j);
 				A[i][j] = A[i][j] - (subtrahend_coefficient* A[k][j]);
 			}
 		}
 	}

 	//Lab2_saveoutput(A, size, 10, "Gauss.txt");

 	
 	for (k = size-1; k > 0; k--){
		int i;
 		for (i = 0; i < k; i++){
 			//double result = A[i][size] - ( (A[i][k] / A[k][k]) * A[k][size]);;
 			//printf("A[%d][%d] = %f \n", i, size, result);
 			A[i][size] = A[i][size] - ( (A[i][k] / A[k][k]) * A[k][size]);
 			A[i][k] = A[i][k] - ( (A[i][k] / A[k][k]) * A[k][k]);
 		}
 	}

 	//Lab2_saveoutput(A, size, 10, "Jordan.txt");


 	// Retrieve elapsed time
	GET_TIME(end_time);

	get_result(storage, A, size);
	printf("Total Time: %f \n",end_time-start_time);
 	Lab3SaveOutput(storage, size, end_time - start_time);

	return 0;
}
Esempio n. 20
0
//=========================================================================
scx::ScriptRef* SQLiteQuery::result_list() const
{
  int count = ::sqlite3_data_count(m_stmt);
  scx::ScriptList* row = new scx::ScriptList();
  for (int i=0; i<count; ++i) {
    row->give(get_result(i));
  }
  return new scx::ScriptRef(row);
}
Esempio n. 21
0
binresult *do_send_command(apisock *sock, const char *command, size_t cmdlen, binparam *params, size_t paramcnt, int64_t datalen, int readres){
  size_t i, plen;
  unsigned char *data;
  void *sdata;
  /* 2 byte len (not included), 1 byte cmdlen, 1 byte paramcnt, cmdlen bytes cmd*/
  plen=cmdlen+2;
  if (datalen!=-1)
    plen+=sizeof(uint64_t);
  for (i=0; i<paramcnt; i++)
    if (params[i].paramtype==PARAM_STR)
      plen+=params[i].paramnamelen+params[i].opts+5; /* 1byte type+paramnamelen, nbytes paramnamelen, 4byte strlen, nbytes str */
    else if (params[i].paramtype==PARAM_NUM)
      plen+=params[i].paramnamelen+1+sizeof(uint64_t);
    else if (params[i].paramtype==PARAM_BOOL)
      plen+=params[i].paramnamelen+2;
  if (plen>0xffff)
    return NULL;
  sdata=data=(unsigned char *)malloc(plen+2);
  memcpy(data, &plen, 2);
  data+=2;
  if (datalen!=-1){
    *data++=cmdlen|0x80;
    memcpy(data, &datalen, sizeof(uint64_t));
    data+=sizeof(uint64_t);
  }
  else
    *data++=cmdlen;
  memcpy(data, command, cmdlen);
  data+=cmdlen;
  *data++=paramcnt;
  for (i=0; i<paramcnt; i++){
    *data++=(params[i].paramtype<<6)+params[i].paramnamelen;
    memcpy(data, params[i].paramname, params[i].paramnamelen);
    data+=params[i].paramnamelen;
    if (params[i].paramtype==PARAM_STR){
      memcpy(data, &params[i].opts, 4);
      data+=4;
      memcpy(data, params[i].un.str, params[i].opts);
      data+=params[i].opts;
    }
    else if (params[i].paramtype==PARAM_NUM){
      memcpy(data, &params[i].un.num, sizeof(uint64_t));
      data+=sizeof(uint64_t);
    }
    else if (params[i].paramtype==PARAM_BOOL)
      *data++=params[i].un.num&1;
  }
  if (writeall(sock, sdata, plen+2)){
    free(sdata);
    return NULL;
  }
  free(sdata);
  if (readres)
    return get_result(sock);
  else
    return PTR_OK;
}
Esempio n. 22
0
void				ft_print_c(va_list *ap, t_format *f)
{
	t_ullong		arg;

	arg = va_arg(*ap, t_ullong);
	update_format(f);
	get_result(arg, f);
	init_f(f);
}
Esempio n. 23
0
wait::~wait()
{
	if (get_result() == QUIT) {
		state_ = game_state();
		state_.classification().campaign_type = "multiplayer";

		resources::config_manager->
			load_game_config_for_game(state_.classification());
	}
}
Esempio n. 24
0
static bool tk_start(char **result)
{
  static bool first_init = false;
  Tk_Window mainw;
  if (!first_init) {
    first_init = true;
    /* this works around a bug in some Tcl/Tk versions */
    Tcl_FindExecutable(NULL);
    /* finalize Tcl at program exit */
    atexit(Tcl_Finalize);
  }
  *result = NULL;
  if (interp) return true;
  /* start up a new interpreter */
  if (!(interp = Tcl_CreateInterp())) return false;
  if (Tcl_Init(interp) != TCL_OK) {
    if (check_result(interp))
      set_result(result, get_result(interp));
    else
      set_result(result, "error initializing Tcl");
    tk_stop();
    return false;
  }
  /* create a command to invoke Pure callbacks from Tcl */
  Tcl_CreateCommand(interp, "pure", (Tcl_CmdProc*)tk_pure,
		    (ClientData)0, NULL);
  /* oddly, there are no `env' variables passed, and this one is needed */
  Tcl_SetVar2(interp, "env", "DISPLAY", getenv("DISPLAY"), TCL_GLOBAL_ONLY);
  if (Tk_Init(interp) != TCL_OK) {
    if (check_result(interp))
      set_result(result, get_result(interp));
    else
      set_result(result, "error initializing Tk");
    tk_stop();
    return false;
  }
  /* set up an X error handler */
  mainw = Tk_MainWindow(interp);
  Tk_CreateErrorHandler(Tk_Display(mainw), -1, -1, -1,
			XErrorProc, (ClientData)mainw);
  return true;
}
Esempio n. 25
0
static int ipslr_status(ipslr_handle_t *p, uint8_t *buf)
{
    int n;
    CHECK(command(p, 0, 1, 0));
    n = get_result(p);
    if (n == 16 || n == 28) {
        return read_result(p, buf, n);
    } else {
        return PSLR_READ_ERROR;
    }
}
Esempio n. 26
0
long Query::get_count(const std::string& sql)
{
	long l = 0;
	if (get_result(sql))
	{
		if (fetch_row())
			l = getval();
		free_result();
	}
	return l;
}
Esempio n. 27
0
memory_cptr
calculate(algorithm_e algorithm,
          void const *buffer,
          size_t size,
          uint64_t initial_value) {
  auto worker = for_algorithm(algorithm, initial_value);

  worker->add(buffer, size);
  worker->finish();
  return worker->get_result();
}
Esempio n. 28
0
wait::~wait()
{
	try {
	if (get_result() == QUIT) {
		state_ = saved_game();
		state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;

		game_config_manager::get()->
			load_game_config_for_game(state_.classification());
	}
	} catch (...) {}
}
Esempio n. 29
0
bool remember_table_list::lookup_entry(function const & f, ex & result) const
{
	auto i = begin(), iend = end();
	while (i != iend) {
		if (i->is_equal(f)) {
			result = i->get_result();
			return true;
		}
		++i;
	}
	return false;
}
Esempio n. 30
0
int main(int argc, char *argv[])
{
	int err;
	int match;
	uint64_t match_bits;
	int op;
	int type;
	datatype_t tgt, din, dout, z;
	int length;
	time_t cur_time = time(NULL);
	int fetch;

	seed = cur_time;

	err = arg_process(argc, argv);
	if (err)
		goto done;

	srandom(seed);

	/* Generate one of each kind. */
	for (fetch =0; fetch <= 1; fetch ++) {

		for (op=PTL_MIN; op<=PTL_BXOR; op++) {

			for (type = PTL_INT8_T; type <= PTL_LONG_DOUBLE_COMPLEX; type ++) {

				if (!check_op_type_valid(op, type))
					continue;

				match = random() & 1;
				match_bits = random();
				match_bits = match_bits << 32 | random();

				tgt = get_data(type);
				dout = get_data(type);
				din = get_data(type);
				z = get_result(tgt, dout, op, type);

				length = random() % (max_length/atom_type[type].size);
				length = (length + 1)*atom_type[type].size;

				generate_case(op, type, match, match_bits, din, dout, tgt,
							  z, length, fetch);
			}
		}
	}

	err = 0;

 done:
	return err;
}