Пример #1
0
/*
 * set PD mode (DN_PDMODE)
 */
LOCAL ER setPdMode( PdMode *mode )
{
#define	settime(time)					\
	if ( mode->time >= 0 ) {			\
		kpMgrInfo.pd.pdMode.time		\
			= min(mode->time, PD_MAXTIME);	\
	}

	union {
		PdAttr	attr;
		UW	uw;
	} u;

        /* change PD mode */
	settime(ontime);
	settime(offtime);
	settime(invtime);
	settime(timeout);
	kpMgrInfo.pd.pdMode.attr = mode->attr;

        /* change PD scan frequency */
	kpChangePdScanRate(mode->attr.rate);

        /* change sensitivity */
	u.attr = mode->attr;
	kpChangePdSense(u.uw & (PD_ACMSK|PD_ABS|PD_SNMSK));

	return E_OK;

#undef settime
}
Пример #2
0
void
save_minimum()
{
	if (results->N == 0) {
		save_n(1);
		settime(0);
	} else {
		save_n(results->v[results->N - 1].n);
		settime(results->v[results->N - 1].u);
	}
}
Пример #3
0
void
save_minimum()
{
    if (results.N == 0) {
        save_n(1);
        settime(0);
    } else {
        save_n(results.n[results.N - 1]);
        settime(results.u[results.N - 1]);
    }
}
Пример #4
0
/** call select and callbacks for that */
static int handle_select(struct event_base* base, struct timeval* wait)
{
	fd_set r, w;
	int ret, i;

#ifndef S_SPLINT_S
	if(wait->tv_sec==(time_t)-1)
		wait = NULL;
#endif
	memmove(&r, &base->reads, sizeof(fd_set));
	memmove(&w, &base->writes, sizeof(fd_set));
	memmove(&base->ready, &base->content, sizeof(fd_set));

	if((ret = select(base->maxfd+1, &r, &w, NULL, wait)) == -1) {
		ret = errno;
		if(settime(base) < 0)
			return -1;
		errno = ret;
		if(ret == EAGAIN || ret == EINTR)
			return 0;
		return -1;
	}
	if(settime(base) < 0)
		return -1;
	
	for(i=0; i<base->maxfd+1; i++) {
		short bits = 0;
		if(!base->fds[i] || !(FD_ISSET(i, &base->ready))) {
			continue;
		}
		if(FD_ISSET(i, &r)) {
			bits |= EV_READ;
			ret--;
		}
		if(FD_ISSET(i, &w)) {
			bits |= EV_WRITE;
			ret--;
		}
		bits &= base->fds[i]->ev_events;
		if(bits) {
			fptr_ok(fptr_whitelist_event(
				base->fds[i]->ev_callback));
			(*base->fds[i]->ev_callback)(base->fds[i]->ev_fd, 
				bits, base->fds[i]->ev_arg);
			if(ret==0)
				break;
		}
	}
	return 0;
}
Пример #5
0
void comhandle()
{
	serial_println("");
	serial_println("Welcome to the MPX OS.");
	serial_println("Feel free to begin entering commands.");
	serial_println("");
	while(1) {
		char *command = polling();
		if (!strcmpigncase(command, "Shutdown")) {
			if (shutdownConfirmed()) {
				serial_println("System shutting down...");
				break;
			} else {
				serial_println("Shutdown canceled.");
			}
		} else if (!strcmpigncase(command, "Version")) {
			version();
		} else if (!strcmpigncase(command, "Help")) {
			help();
		} else if (!strcmpigncase(command, "Setdate")) {
			setdate();
		} else if (!strcmpigncase(command, "Getdate")) {
			getdate();
		} else if (!strcmpigncase(command, "Settime")) {
			settime();
		} else if (!strcmpigncase(command, "Gettime")) {
			gettime();
		}
	}
}
int
compat_50_netbsd32_settimeofday(struct lwp *l,
    const struct compat_50_netbsd32_settimeofday_args *uap, register_t *retval)
{
	/* {
		syscallarg(const netbsd32_timeval50p_t) tv;
		syscallarg(const netbsd32_timezonep_t) tzp;
	} */
	struct netbsd32_timeval50 atv32;
	struct timeval atv;
	struct timespec ats;
	int error;
	struct proc *p = l->l_proc;

	/* Verify all parameters before changing time. */

	/*
	 * NetBSD has no kernel notion of time zone, and only an
	 * obsolete program would try to set it, so we log a warning.
	 */
	if (SCARG_P32(uap, tzp))
		printf("pid %d attempted to set the "
		    "(obsolete) kernel time zone\n", p->p_pid);

	if (SCARG_P32(uap, tv) == 0)
		return 0;

	if ((error = copyin(SCARG_P32(uap, tv), &atv32, sizeof(atv32))) != 0)
		return error;

	netbsd32_to_timeval50(&atv32, &atv);
	TIMEVAL_TO_TIMESPEC(&atv, &ats);
	return settime(p, &ats);
}
Пример #7
0
/* settimestamp(seconds1970) sets the date and time from a single parameter: the
 * number of seconds since 1 January 1970.
 */
static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params)
{
  #if defined __WIN32__ || defined _WIN32 || defined WIN32
    int year, month, day, hour, minute, second;

    stamp2datetime(params[1],
                   &year, &month, &day,
                   &hour, &minute, &second);
    setdate(year, month, day);
    settime(hour, minute, second);
  #else
    /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you
     * must have "root" permission to call stime(); many POSIX systems will
     * have settimeofday() instead
     */
    #if defined __APPLE__ /* also valid for other POSIX systems */
      struct timeval tv;
      tv.tv_sec = params[1];
      tv.tv_usec = 0;
      settimeofday(&tv, 0);
    #else
      time_t sec1970=(time_t)params[1];
      stime(&sec1970);
    #endif
  #endif
  (void)amx;

  return 0;
}
Пример #8
0
void __Disc_SetTime(void) {
    /* Extern */
    extern void settime(u64);

    /* Set proper time */
    settime(secs_to_ticks(time(NULL) - 946684800));
}
Пример #9
0
void
test_AlwaysInLimit(void) {
	/* Timestamp is: 2010-01-02 11:00:00Z */
	const u_int32 timestamp = 3471418800UL;
	const u_short prime_incs[] = { 127, 151, 163, 179 };
	int	cyc;
	int	yday;
	u_char	whichprime;
	u_short	ydayinc;
	int	hour;
	int	minute;
	int	second;
	u_long	yearstart;
	u_int32	actual;
	u_int32	diff;

	yearstart = 0;
	for (cyc = 0; cyc < 5; cyc++) {
		settime(1900 + cyc * 65, 1, 1, 0, 0, 0);
		for (yday = -26000; yday < 26000; yday += ydayinc) {
			whichprime = abs(yday) % COUNTOF(prime_incs);
			ydayinc = prime_incs[whichprime];
			for (hour = -204; hour < 204; hour += 2) {
				for (minute = -60; minute < 60; minute++) {
					clocktime(yday, hour, minute, 30, 0,
						  timestamp, &yearstart, &actual);
					diff = actual - timestamp;
					if (diff >= 0x80000000UL)
						diff = ~diff + 1;
					TEST_ASSERT_TRUE(isLE(diff, (183u * SECSPERDAY)));
				}
			}
		}
	}
}
Пример #10
0
void __distub_restregs(void)
{
	int i;
	for(i=1;i<6;i++)
		_piReg[i] = di_regs.piReg[i];
	//i = _piReg[0]; //clear all interrupts
	settime(di_regs.timebase);
}
Пример #11
0
// ppstate:  -1: full strength  0: even strength  1: vis power play  2: home power play
void HockeyDrop::ppdata(short adv, unsigned short strength, unsigned short pmin, unsigned short psec) {
	if ( adv == 0 ) {
		if (strength == 5) {
			lines[SI_PP] = "FULL STRENGTH";
			lines[SI_PP_EN] = "EMPTY NET";
			// automatically change to the normal (yellow) EMPTY NET graphic when 
			// the power play expires (assumes same team has PP and EN simultaneously)
			if (state == SI_PP_EN && ppstate > 0) state = SI_EN_V - 1 + ppstate;
			settime(0,0);
			ppstate = -1;
		}
		else {
			if (strength == 4) {
				lines[SI_PP] = "4-ON-4";
				lines[SI_PP_EN] = "4-ON-4 + EMPTY NET";
			}
			else if (strength == 3) {
				lines[SI_PP] = "3-ON-3"; 
				lines[SI_PP_EN] = "3-ON-3 + EMPTY NET";
			}
			settime(pmin, psec);
			ppstate = 0;
		}
	}
	else if ( abs(adv) == 1 ) {
		if (strength == 3) {
			lines[SI_PP] = "4-ON-3";
			lines[SI_PP_EN] = "4-ON-3 + EMPTY NET";
		}
		else {
			lines[SI_PP] = "POWER PLAY";
			lines[SI_PP_EN] = "PP + EMPTY NET";
		}
		settime(pmin, psec);
		if (adv > 0) ppstate = 1;
		else ppstate = 2;
	}
	else if ( abs(adv) == 2 ) {
		lines[SI_PP] = "2-MAN ADV";
		lines[SI_PP_EN] = "2MA + EMPTY NET";
		settime(pmin, psec);
		if (adv > 0) ppstate = 1;
		else ppstate = 2;
	}
	else state = -1;   // invalid case
}
Пример #12
0
void main (void)
 {
   struct time desired_time;

   desired_time.ti_hour = 12;
   desired_time.ti_min = 30;

   settime(&desired_time);
 }
Пример #13
0
void
setUp()
{
    ntpcal_set_timefunc(timefunc);
    settime(1970, 1, 1, 0, 0, 0);
    init_lib();

    return;
}
Пример #14
0
void
Reverb::settype (int Ptype)
{
    const int NUM_TYPES = 2;
    int combtunings[NUM_TYPES][REV_COMBS] = {
        //this is unused (for random)
        {0, 0, 0, 0, 0, 0, 0, 0},
        //Freeverb by Jezar at Dreampoint
        {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617}
    };
    int aptunings[NUM_TYPES][REV_APS] = {
        //this is unused (for random)
        {0, 0, 0, 0},
        //Freeverb by Jezar at Dreampoint
        {225, 341, 441, 556}
    };

    if (Ptype >= NUM_TYPES)
        Ptype = NUM_TYPES - 1;
    this->Ptype = Ptype;

    float tmp;
    for (int i = 0; i < REV_COMBS * 2; i++) {
        if (Ptype == 0)
            tmp = 800.0f + (float)(RND*1400.0f);
        else
            tmp = (float)combtunings[Ptype][i % REV_COMBS];
        tmp *= roomsize;
        if (i > REV_COMBS)
            tmp += 23.0f;
        tmp *= fSAMPLE_RATE / 44100.0f;	//adjust the combs according to the samplerate
        if (tmp < 10)
            tmp = 10;

        comblen[i] = lrintf(tmp);
        combk[i] = 0;
        lpcomb[i] = 0;
    };

    for (int i = 0; i < REV_APS * 2; i++) {
        if (Ptype == 0)
            tmp = 500.0f + (float)(RND*500.0f);
        else
            tmp = (float)aptunings[Ptype][i % REV_APS];
        tmp *= roomsize;
        if (i > REV_APS)
            tmp += 23.0f;
        tmp *= fSAMPLE_RATE / 44100.0f;	//adjust the combs according to the samplerate
        if (tmp < 10)
            tmp = 10;
        aplen[i] = lrintf(tmp);
        apk[i] = 0;
    };
    settime (Ptime);
    cleanup ();
};
Пример #15
0
int fb_hSetTime( int h, int m, int s )
{
	struct time t;
	t.ti_hour = h;
	t.ti_min = m;
	t.ti_sec = s;
	t.ti_hund = 0;
	settime(&t);
	return 0;
}
Пример #16
0
main()
{
  struct time curtm;
  gettime(&curtm);
  printf("\nCurrent time %02d:%02d:%02d.%d",curtm.ti_hour,curtm.ti_min,curtm.ti_sec,curtm.ti_hund);
  curtm.ti_hour=20;
  settime(&curtm);
  gettime(&curtm);
  printf("\nAfter setting time %02d:%02d:%02d.%d",curtm.ti_hour,curtm.ti_min,curtm.ti_sec,curtm.ti_hund);
  getch();
}
Пример #17
0
int
build(void)
{
	CF cf;
	int afd, tfd;
	int current_mid;
	off_t size;

	current_mid = -1;
	afd = open_archive(O_RDWR);
	fp = fdopen(afd, "r+");
	tfd = tmp();

	SETCF(afd, archive, tfd, tname, RPAD|WPAD);

	/* Read through the archive, creating list of symbols. */
	symcnt = tsymlen = 0;
	pnext = &rhead;
	while(get_arobj(afd)) {
		int new_mid;

		if (!strcmp(chdr.name, RANLIBMAG)) {
			skip_arobj(afd);
			continue;
		}
		new_mid = rexec(afd, tfd);
		if (new_mid != -1) {
			if (current_mid == -1)
				current_mid = new_mid;
			else if (new_mid != current_mid)
				errx(1, "Mixed object format archive: %d / %d", 
					new_mid, current_mid);
		}
		put_arobj(&cf, (struct stat *)NULL);
	}
	*pnext = NULL;

	/* Create the symbol table.  Endianess the same as last mid seen */
	symobj(current_mid);

	/* Copy the saved objects into the archive. */
	size = lseek(tfd, (off_t)0, SEEK_CUR);
	(void)lseek(tfd, (off_t)0, SEEK_SET);
	SETCF(tfd, tname, afd, archive, NOPAD);
	copy_ar(&cf, size);
	(void)ftruncate(afd, lseek(afd, (off_t)0, SEEK_CUR));
	(void)close(tfd);

	/* Set the time. */
	settime(afd);
	close_archive(afd);
	return(0);
}
Пример #18
0
void comhandle()
{
	serial_println("");
	serial_println("Welcome to the MPX OS.");
	serial_println("Feel free to begin entering commands.");
	serial_println("");
	while(1) {
		char *command = polling();
		if (!strcmpigncase(command, "shutdown")) {
			if (shutdownConfirmed()) {
				serial_println("System shutting down...");
				clearAllQueues();
				break;
			} else {
				serial_println("Shutdown canceled.");
			}
		} else if (!strcmpigncase(command, "version")) {
			version();
		} else if (!strcmpigncase(command, "help")) {
			help();
		} else if (!strcmpigncase(command, "setdate")) {
			setdate();
		} else if (!strcmpigncase(command, "getdate")) {
			getdate();
		} else if (!strcmpigncase(command, "settime")) {
			settime();
		} else if (!strcmpigncase(command, "gettime")) {
			gettime();
		} else if (!strcmpigncase(command, "suspend")) {
			suspendPCB();
		} else if (!strcmpigncase(command, "resume")) {
			resumePCB();
		} else if (!strcmpigncase(command, "setpriority")) {
			setPriority();
		} else if (!strcmpigncase(command, "showPCB")) {
		        showPCB();
		} else if (!strcmpigncase(command, "showReady")) {
		        showReady();
		} else if (!strcmpigncase(command, "showBlocked")) {
		        showBlocked();
		} else if (!strcmpigncase(command, "showAll")) {
		        showAll();
		} else if (!strcmpigncase(command, "yield")) {
		        asm volatile ("int $60");
		        serial_println("");
		} else if (!strcmpigncase(command, "loadr3")) {
		        loadR3();
		} else if (strcmp(command, '\0')) {
			serial_println("Command not recognized. Type help to view commands.");
			serial_println("");
		}
		sys_free_mem(command);
	}
Пример #19
0
/*
 * Cost of catching the signal less the cost of sending it
 */
void
bench_catch(int parallel, int warmup, int repetitions)
{
	uint64 t, send_usecs, send_n;

	/* measure cost of sending signal */
	benchmp(NULL, do_send, NULL, 0, parallel, 
		warmup, repetitions, NULL);
	send_usecs = gettime();
	send_n = get_n();

	/* measure cost of sending & catching signal */
	benchmp(NULL, do_catch, NULL, 0, parallel, 
		warmup, repetitions, NULL);

	/* subtract cost of sending signal */
	if (gettime() > (send_usecs * get_n()) / send_n) {
		settime(gettime() - (send_usecs * get_n()) / send_n);
	} else {
		settime(0);
	}
}
Пример #20
0
/* main loop */
int
main(void)
{
	input_line = (char *)malloc(6 * sizeof(char));

	led_setperm();

	set_time = 200000;

	while (strncmp(input_line, "quit", 4) != 0)
	{
		input_line = readline("Led Control> ");

		/* I know instruction parsing is really lame :/ */
		if (!strncmp(input_line, "help", 4))
			help();
		if (!strncmp(input_line, "ledon", 5))
			ledon();
		if (!strncmp(input_line, "ledoff", 6))
			ledoff();
		if (!strncmp(input_line, "settime", 7))
			settime();
		if (!strncmp(input_line, "volume", 6))
			volume();
		if (!strncmp(input_line, "bin", 3))
			bin();
		if (!strncmp(input_line, "slide", 5))
			slide();
		if (!strncmp(input_line, "blink", 5))
			blink();
		if (!strncmp(input_line, "bislide", 7))
			bislide();
		if (!strncmp(input_line, "biblink", 7))
			biblink();
		if (!strncmp(input_line, "grow", 4))
			grow();
		if (!strncmp(input_line, "center", 6))
			center();
		if (!strncmp(input_line, "side", 4))
			side();
		if (!strncmp(input_line, "biside", 6))
			biside();
		if (!strncmp(input_line, "demo", 4))
			demo();
	}

	led_off_all();

	exit(0);
}
Пример #21
0
void
bench_prot(char* fname, int parallel, int warmup, int repetitions)
{
	uint64 catch_usecs, catch_n;
	struct _state state;

	state.fname = fname;

	/*
	 * Catch protection faults.
	 * Assume that they will cost the same as a normal catch.
	 */
	bench_catch(parallel, warmup, repetitions);
	catch_usecs = gettime();
	catch_n = get_n();

	benchmp(initialize, do_prot, NULL, 0, parallel, 
		warmup, repetitions, &state);
	if (gettime() > (catch_usecs * get_n()) / catch_n) {
		settime(gettime() - (catch_usecs * get_n()) / catch_n);
	} else {
		settime(0);
	}
}
Пример #22
0
int touch()
{
	int afd;

	afd = open_archive(O_RDWR);

	if (!get_arobj(afd) ||
	    strncmp(RANLIBMAG, chdr.name, sizeof(RANLIBMAG) - 1)) {
		(void)fprintf(stderr,
		    "ranlib: %s: no symbol table.\n", archive);
		return(1);
	}
	settime(afd);
	close_archive(afd);
	return(0);
}
Пример #23
0
int
touch(void)
{
	FILE *afp;

	afp = open_archive(O_RDWR);

	if (!get_arobj(afp) ||
	    (strncmp(RANLIBMAG, chdr.name, sizeof(RANLIBMAG) - 1) &&
	     strncmp(RANLIBMAG2, chdr.name, sizeof(RANLIBMAG2) - 1))) {
		warnx("%s: no symbol table.", archive);
		return(1);
	}
	settime(afp);
	close_archive(afp);
	return(0);
}
Пример #24
0
static int l_set_clock(lua_State *L)
{
	double value;
	luaL_argcheck(L, lua_istable(L, 1), 1, "table expected");

	lua_getfield(L, 1, "now");
	value = luaL_checknumber(L, -1);
	lua_pop(L, 1);
	settime(value);

	lua_getfield(L, 1, "freq");
	value = luaL_checknumber(L, -1);
	lua_pop(L, 1);
	clock.freq = (long)value;

	return 0;
}
void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode,
                            int aspectRatio, u32 returnTo, u8 BootType, bool use_led)
{
    normalCFG.vidMode = vidMode;
    normalCFG.vipatch = vipatch;
    normalCFG.countryString = countryString;
    normalCFG.patchVidMode = patchVidMode;
    normalCFG.aspectRatio = aspectRatio;
    normalCFG.returnTo = returnTo;
    normalCFG.configbytes[0] = configbytes[0];
    normalCFG.configbytes[1] = configbytes[1];
    normalCFG.IOS = CurrentIOS;
    normalCFG.codelist = codelist;
    normalCFG.codelistend = codelistend;
    normalCFG.cheats = code_buf;
    normalCFG.cheatSize = code_size;
    normalCFG.hooktype = hooktype;
    normalCFG.debugger = debuggerselect;
    normalCFG.gameconf = gameconf;
    normalCFG.gameconfsize = gameconfsize;
    normalCFG.BootType = BootType;
    normalCFG.use_led = use_led;
    normalCFG.wip_list = get_wip_list();
    normalCFG.wip_count = get_wip_count();
    /* Copy CFG Into lower MEM1 so it doesnt get destroyed */
    DCFlushRange(&normalCFG, sizeof(the_CFG));
    the_CFG *lowCFG = (the_CFG*)MEM1_lo_alloc(sizeof(the_CFG));
    memcpy(lowCFG, &normalCFG, sizeof(the_CFG));
    DCFlushRange(&lowCFG, sizeof(the_CFG));
    *EXT_ADDR_CFG = ((u32)lowCFG);
    /* Unmount devices etc */
    ShutdownBeforeExit();
    /* Wii Games will need it */
    net_wc24cleanup();
    /* Set proper time */
    settime(secs_to_ticks(time(NULL) - 946684800));
    /* Copy in booter */
    memcpy(EXT_ADDR, booter_ptr, booter_size);
    DCFlushRange(EXT_ADDR, booter_size);
    /* Loader just for the booter */
    memcpy(LDR_ADDR, extldr_ptr, extldr_size);
    DCFlushRange(LDR_ADDR, extldr_size);
    /* Boot it */
    JumpToEntry(LDR_ENTRY);
}
Пример #26
0
int
kern_clock_settime(clockid_t clock_id, struct timespec *ats)
{
	struct thread *td = curthread;
	struct timeval atv;
	int error;

	if ((error = priv_check(td, PRIV_CLOCK_SETTIME)) != 0)
		return (error);
	if (clock_id != CLOCK_REALTIME)
		return (EINVAL);
	if (ats->tv_nsec < 0 || ats->tv_nsec >= 1000000000)
		return (EINVAL);

	TIMESPEC_TO_TIMEVAL(&atv, ats);
	error = settime(&atv);
	return (error);
}
Пример #27
0
static int movetime(double offset)
{
	double new_time;
	int ret;
	dprint("movetime: offset:%f\n", offset);
	if (offset == 0)
		return NTP_OK;
#if DEBUG
	ret = gettime();
	if (ret)
		return ret;
#endif
	new_time = clock.now + offset;
	ret = settime(new_time);
	if (ret != NTP_OK)
		return ret;
	return NTP_OK;
}
Пример #28
0
void
save_median()
{
    int	i = results.N / 2;
    uint64	u, n;

    if (results.N == 0) {
        n = 1;
        u = 0;
    } else if (results.N % 2) {
        n = results.n[i];
        u = results.u[i];
    } else {
        n = (results.n[i] + results.n[i-1]) / 2;
        u = (results.u[i] + results.u[i-1]) / 2;
    }
    save_n(n);
    settime(u);
}
Пример #29
0
void Reverb::changepar(int npar, unsigned char value)
{
    switch(npar) {
    case 0:
        setvolume(value);
        break;
    case 1:
        setpan(value);
        break;
    case 2:
        settime(value);
        break;
    case 3:
        setidelay(value);
        break;
    case 4:
        setidelayfb(value);
        break;
//  case 5: setrdelay(value);
//      break;
//  case 6: seterbalance(value);
//      break;
    case 7:
        setlpf(value);
        break;
    case 8:
        sethpf(value);
        break;
    case 9:
        setlohidamp(value);
        break;
    case 10:
        settype(value);
        break;
    case 11:
        setroomsize(value);
        break;
    case 12:
        setbandwidth(value);
        break;
    }
}
Пример #30
0
static int l_clock_update(lua_State *L)
{
	double t[4];
	if (lua_gettop(L) < 1)
		return ntp_pushresult(L, ntp_process(&peer, 0, 0));
	else if (lua_gettop(L) < 4) {
		int ret;
		t[0] = luaL_checknumber(L, 1);
		ret = settime(t[0]);
		if (ret)
			return ntp_pushresult(L, ret);
		peer_clear(&peer);
		return ntp_pushresult(L, NTP_OK);
	}
	t[0] = luaL_checknumber(L, 1);
	t[1] = luaL_checknumber(L, 2);
	t[2] = luaL_checknumber(L, 3);
	t[3] = luaL_checknumber(L, 4);
	return ntp_pushresult(L, ntp_process(&peer, t, 0));
}