示例#1
0
/*{
** Name: rms_intcmpl	- Complement an integer
**
** Description:
**	This routine computes the negation of a 2's complement integer either
**	8 bytes or 16 bytes long.
**
**	The method is to take the 1's complement (i.e. do a binary NOT on
**	each i4 component) and then add 1.
**
** Inputs:
**	iptr		Pointer to array of i4's
**	isize		Length of array (in # of i4's)
**	ires		Pointer to resultant array of i4's
**
** Outputs:
**	*ires		Negation of input is put here
**	
**	Returns:
**	    VOID
**	Exceptions:
**	    none
**
** Side Effects:
**	    none
**
** History:
**	11-apr-90 (jrb)
**	    Created.
[@history_template@]...
*/
VOID
rms_intcmpl
(
    u_i4 *iptr,
    i4	 isize,
    u_i4 *ires
)
{
    static u_i4	    ow1[] = { 1, 0, 0, 0 };
    i4		    tmp[3];


    if (isize == 2)
    {
	tmp[0] = ~iptr[0];
	tmp[1] = ~iptr[1];

	/* ow1 can be used for the quadword 1 too because of byte-swapping */
	lib$addx(tmp, ow1, ires, &isize);
    }
    else
    {
	tmp[0] = ~iptr[0];
	tmp[1] = ~iptr[1];
	tmp[2] = ~iptr[2];
	tmp[3] = ~iptr[3];

	lib$addx(tmp, ow1, ires, &isize);
    }
}
int main()
{
    char ch[10];
    int m,i,u,v,cas=0;
    while(scanf("%d%d",&n,&m),n+m)
    {
        cas++;
        chu();
        for(i=0;i<m;i++)
        {
            scanf("%s%d%d",ch,&u,&v);
            if('I' == ch[0])
            {
                addx(v,u+n);
                addx(u,v+n);
                addy(v,u+n);
                addy(u,v+n);
                addz(v,u+n);
                addz(u,v+n);
            }
            else if('X' == ch[0])
            {
                addx(u+n,v);    
            }
            else if('Y' == ch[0])
            {
                addy(u+n,v);    
            }
            else
            {
                addz(u+n,v);    
            }
        }
        printf("Case %d: ",cas); 
        fun();
        if(1 == flag)
        {
            printf("IMPOSSIBLE\n\n"); 
            continue; 
        }
         printf("POSSIBLE\n");
        for(i=1;i<=n;i++)
        {
            printf("%d %d %d %d %d %d\n",tx[i],ty[i],tz[i],tx[i+n],ty[i+n],tz[i+n]);
        } 
        printf("\n");
    }
    return 0;
}
示例#3
0
pwr_tStatus
time_Dmul (
  pwr_tDeltaTime *result,
  pwr_tDeltaTime *t1,
  pwr_tInt32 fac
)
{
  pwr_tInt64 nsec1, nsec2, sum;
  int sec = t1->tv_sec * fac;
  int mul = 1000000000;
  int addend = 0;
  int sts;

  sts = lib$emul(&sec, &mul, &addend, &nsec1);
  if (EVEN(sts))
    return sts;

  sts = lib$emul(&t1->tv_nsec, &fac, &addend, &nsec2);
  if (EVEN(sts))
    return sts;

  sts = lib$addx(&nsec1, &nsec2, &sum);
  if (EVEN(sts))
    return sts;

  sts = lib$ediv(&mul, &sum, &result->tv_sec, &result->tv_nsec);
  if (EVEN(sts))
    return sts;

 return TIME__SUCCESS;

}
示例#4
0
static time_tOs *
abs_to_vms (
  pwr_tStatus	*status,
  time_tOs	*result,
  pwr_tTime	*pt
)
{
  time_tOs	tmp;
  time_tOs	ofs = {0x4beb4000, 0x007c9567};
  int		multiplier = 10000000;	/* Used to convert 1 s to 100 ns, delta time.  */
  int		nsec = pt->tv_nsec/100;
  int		sec = pt->tv_sec;
  struct tm	*tmp_tm;
  unsigned long t = 0;

  pwr_dStatus(sts, status, TIME__SUCCESS);

  /* Get the time zone offset. */

  tmp_tm = localtime(&pt->tv_sec);
  sec += tmp_tm->tm_gmtoff - tmp_tm->tm_isdst * 3600;

  *sts = lib$emul(&sec, &multiplier, &nsec, &tmp);
  if (EVEN(*sts)) return NULL;
  *sts = lib$addx(&tmp, &ofs, result);
  if (EVEN(*sts)) return NULL;

  return result;
}
示例#5
0
unsigned long lib$add_times(const void *time1a, const void *time2a,
    void *result)
{
    const struct TIME* time1 = (const struct TIME*) time1a;
    const struct TIME* time2 = (const struct TIME*) time2a;

    if (time1->time[7] & 0x80)
    {
        if (time2->time[7] & 0x80)
	{
            return lib$addx(time1,time2,result,NULL);
        }
	else
	{
            return lib$subx(time2,time1,result,NULL);
        }
    }
    else
    {
        if (time2->time[7] & 0x80)
	{
            return lib$subx(time1,time2,result,NULL);
        }
	else
	{
            return LIB$_ONEDELTIM;
        }
    }
}
示例#6
0
static void
us_to_VMS(useconds_t mseconds, unsigned long v[])
{
    int iss;
    unsigned long qq[2];

    qq[0] = mseconds;
    qq[1] = 0;
    v[0] = v[1] = 0;

    iss = lib$addx(qq,qq,qq);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$subx(v,qq,v);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$addx(qq,qq,qq);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$subx(v,qq,v);
    if (VMSERR(iss)) lib$signal(iss);
    iss = lib$subx(v,qq,v);
    if (VMSERR(iss)) lib$signal(iss);
}
void chu()
{
    int i;
    flag=0; 
    for(i=1;i<=2*n;i++)
    {
        qx[i].clear();
        qy[i].clear();
        qz[i].clear();    
    }
    memset(dux,0,sizeof(dux));
    memset(duy,0,sizeof(duy));
    memset(duz,0,sizeof(duz));
    for(i=1;i<=n;i++)
    {
        addx(i,i+n);
        addy(i,i+n);
        addz(i,i+n);
    }
}
示例#8
0
/*
 * alarming - tell the world we've been alarmed
 */
static RETSIGTYPE
alarming(
	int sig
	)
{
#if !defined(VMS)
	if (initializing)
		return;
	if (alarm_flag)
		alarm_overflow++;
	else
		alarm_flag++;
#else /* VMS AST routine */
	if (!initializing) {
		if (alarm_flag) alarm_overflow++;
		else alarm_flag = 1;	/* increment is no good */
	}
	lib$addx(&vmsinc,&vmstimer,&vmstimer);
	sys$setimr(0,&vmstimer,alarming,alarming,0);
#endif /* VMS */
}
示例#9
0
Game::Game() : univers(), simulator(&univers)
{
        glClearColor(BACKGROUND_COLOR);

#ifdef FULLSCREEN
                glutFullScreen();
#endif
        
        
        setSimulator(&simulator);
        setUnivers(&univers);
        
	Vvector pos(0, 0, 0);
	Vvector addx(10, 0, 0);
	Vvector addy(0, 10, 0);
	
	for (int i = 0; i < 48; i++) {
	for (int j = 0; j < 48; j++) {
		this->univers.addPlanet("Torus", pos);
		pos += addx;
	}
		pos = Vvector(0, pos.y() + addy.y(), pos.z());
	}
	
	
        {
                glutIgnoreKeyRepeat(GLUT_KEY_REPEAT_DEFAULT);
                glutTimerFunc(KEY_REPEAT_PERIOD, keyboard, 0);
        }
        {
                glutReshapeFunc(windowResizingHandler);
                glutWindowStatusFunc(windowStatusHandler);
#ifdef __APPLE__
                glutWMCloseFunc(windowClosingHandler);
#endif
                glutDisplayFunc(displayHandler);
        }
}
示例#10
0
文件: ntp_timer.c 项目: sambuc/netbsd
/*
 * alarming - tell the world we've been alarmed
 */
static RETSIGTYPE
alarming(
	int sig
	)
{
# ifdef DEBUG
	const char *msg = "alarming: initializing TRUE\n";
# endif

	if (!initializing) {
		if (alarm_flag) {
			alarm_overflow++;
# ifdef DEBUG
			msg = "alarming: overflow\n";
# endif
		} else {
# ifndef VMS
			alarm_flag++;
# else
			/* VMS AST routine, increment is no good */
			alarm_flag = 1;
# endif
# ifdef DEBUG
			msg = "alarming: normal\n";
# endif
		}
	}
# ifdef VMS
	lib$addx(&vmsinc, &vmstimer, &vmstimer);
	sys$setimr(0, &vmstimer, alarming, alarming, 0);
# endif
# ifdef DEBUG
	if (debug >= 4)
		(void)(-1 == write(1, msg, strlen(msg)));
# endif
}
示例#11
0
i4
TMtostr (i4 secs, char* op_str)
{
    i4 j;
    i4 sts;
    GENERIC_64 vms_time;
    struct dsc$descriptor_s timdsc = {20, DSC$K_DTYPE_T, DSC$K_CLASS_S, op_str};

    /*
    ** clear output string in case of errors
    ** you will note that there is an implicit assumption that the
    ** the caller provided an output  buffer of at least 21 characters
    */

    op_str[0] = 0;

    /* convert time in secs to VMS 100nSec units */


    sts = lib$emul(&secs, &10000000, &0, (int64 *)&vms_time);
    if (!(sts & STS$M_SUCCESS))
        return 0;
    sts = lib$addx ((u_i8 *)&vms_time, (u_i8 *)&unix_epoch, (u_i8 *)&vms_time);
    if (!(sts & STS$M_SUCCESS))
        return 0;

    /*
    ** restrict the o/p buffer length to a max of 20 chars
    ** i.e. lose the trailing ".nn" millisecs of the string
    */

    sts = sys$asctim (&timdsc.dsc$w_length, &timdsc, &vms_time, 0);
    j = (sts & STS$M_SUCCESS) ? timdsc.dsc$w_length : 0;
    op_str[j] = 0;
    return ((sts & STS$M_SUCCESS) ? j : 0);
}
示例#12
0
/*
 * init_timer - initialize the timer data structures
 */
void
init_timer(void)
{
	/*
	 * Initialize...
	 */
	alarm_flag = 0;
	alarm_overflow = 0;
	adjust_timer = 1;
	stats_timer = 0;
	huffpuff_timer = 0;
	interface_timer = 0;
	current_time = 0;
	timer_overflows = 0;
	timer_xmtcalls = 0;
	timer_timereset = 0;

#if !defined(SYS_WINNT)
	/*
	 * Set up the alarm interrupt.	The first comes 2**EVENT_TIMEOUT
	 * seconds from now and they continue on every 2**EVENT_TIMEOUT
	 * seconds.
	 */
# if !defined(VMS)
#  if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
	if (timer_create (CLOCK_REALTIME, NULL, &ntpd_timerid) ==
#	ifdef SYS_VXWORKS
		ERROR
#	else
		-1
#	endif
	   )
	{
		fprintf (stderr, "timer create FAILED\n");
		exit (0);
	}
	(void) signal_no_reset(SIGALRM, alarming);
	itimer.it_interval.tv_sec = itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
	itimer.it_interval.tv_nsec = itimer.it_value.tv_nsec = 0;
	timer_settime(ntpd_timerid, 0 /*!TIMER_ABSTIME*/, &itimer, NULL);
#  else
	(void) signal_no_reset(SIGALRM, alarming);
	nap_time = 1;
	itimer.it_interval.tv_sec = itimer.it_value.tv_sec = nap_time;
	itimer.it_interval.tv_usec = itimer.it_value.tv_usec = 0;
	setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
#  endif
# else /* VMS */
	vmsinc[0] = 10000000;		/* 1 sec */
	vmsinc[1] = 0;
	lib$emul(&(1<<EVENT_TIMEOUT), &vmsinc, &0, &vmsinc);

	sys$gettim(&vmstimer);	/* that's "now" as abstime */

	lib$addx(&vmsinc, &vmstimer, &vmstimer);
	sys$setimr(0, &vmstimer, alarming, alarming, 0);
# endif /* VMS */
#else /* SYS_WINNT */
	/*
	 * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds
	 * Under Windows/NT, 
	 */

	WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);
	if (WaitableTimerHandle == NULL) {
		msyslog(LOG_ERR, "CreateWaitableTimer failed: %m");
		exit(1);
	}
	else {
		DWORD Period = (1<<EVENT_TIMEOUT) * 1000;
		LARGE_INTEGER DueTime;
		DueTime.QuadPart = Period * 10000i64;
		if (!SetWaitableTimer(WaitableTimerHandle, &DueTime, Period, NULL, NULL, FALSE) != NO_ERROR) {
			msyslog(LOG_ERR, "SetWaitableTimer failed: %m");
			exit(1);
		}
	}

#endif /* SYS_WINNT */
}
示例#13
0
int
sysbintim (char *ci_, DATENT *obfr)
{
	static	char	bigbfr[MAXBFR];	/* FIXME */
	static	char	midbfr[MAXBFR];
	$DESCRIPTOR(DSCx,bigbfr);
	$DESCRIPTOR(midnite,midbfr);
	DATENT	base;
	int	j;
	int	num	= strlen(ci_);
	char	*c_, *d_, *e_;

	if (num >= (MAXBFR-1))
		num = (MAXBFR-1);
	for (j = 0; j < num; j++)
		bigbfr[j] = _toupper(ci_[j]);
	bigbfr[num] = '\0';

	/*
	 * Compute the base of the current day, to use in keyword-dates:
	 */
	sys$gettim (obfr);
	sysasctim (midbfr, obfr, MAXDAY);
	strcpy (&midbfr[11], zeros);
	midnite.dsc$a_pointer = midbfr;
	midnite.dsc$w_length  = strlen(midbfr);
	sys$bintim (&midnite, obfr);
	base = *obfr;

	if (strabbr (bigbfr, "TODAY", num, 3))
		num = 0;
	else if (strabbr (bigbfr, "YESTERDAY", num, 1))
	{
		lib$subx (base, day, obfr, 0);
		num = 0;
	}
	else if (strabbr (bigbfr, "TOMORROW", num, 3))
	{
		lib$addx (base, day, obfr, 0);
		num = 0;
	}
	/*
	 * $BINTIM cannot parse the ':' used in DCL to separate date, time.
	 * Convert this to a trailing space and supply trailing zeros.  Also,
	 * if the year and/or month is not given, supply these:
	 */
	else
	{
		register int dash = 0;
		d_ = zeros;
		for (c_ = bigbfr; *c_; c_++)
		{
			if (*c_ == '-')
				dash++;
			else
			{
				if (*c_ == ':' && dash)		*c_ = ' ';
				if (*c_ == ' ')
				{
					if (*d_)		d_ += 3;
					break;
				}
				if (ispunct(*c_) && *d_)	d_ += 3;
			}
		}

		if (*d_ && !dash)	d_ += 3;
		e_ = dash ? c_ : bigbfr;
		if (*c_ || !dash)
		{
			if (*c_ == ' ')		c_++;
			while (*c_ && *d_)
			{
				if (ispunct(*c_))	d_ += 3;
				c_++;
			}
			if (*d_) strcpy (c_, d_);
		}
		else		/* Default to midnight for time	*/
			strcpy (c_, zeros);

		/*
		 * Insert month (mmm) and year (yyyy) if omitted, since
		 * $BINTIM does not permit *gaps*, but only loss of significance.
		 */
		if (dash < 2)
		{
			char	time[sizeof(zeros)+2];
			strcpy (time, e_);
			*e_ = '\0';
			if (dash == 1)	/* dd-mmm given	*/
			{
				strncpy (e_, midbfr+6, 5);
				strcpy (e_+5, time);
			}
			else		/* dash==0, assume 'hh' of 'hh:mm' */
			{
				strcpy (bigbfr, midbfr);
				strcpy (bigbfr+12, time);
			}
		}

		DSCx.dsc$w_length  = strlen(bigbfr);

		if ((num = sys$bintim (&DSCx, obfr)) == SS$_NORMAL)	num = 0;
	}
	return (num);
}
示例#14
0
文件: ntp_timer.c 项目: sambuc/netbsd
/*
 * init_timer - initialize the timer data structures
 */
void
init_timer(void)
{
	/*
	 * Initialize...
	 */
	alarm_flag = FALSE;
	alarm_overflow = 0;
	adjust_timer = 1;
	stats_timer = SECSPERHR;
	leapf_timer = SECSPERDAY;
	huffpuff_timer = 0;
	interface_timer = 0;
	current_time = 0;
	timer_overflows = 0;
	timer_xmtcalls = 0;
	timer_timereset = 0;

#ifndef SYS_WINNT
	/*
	 * Set up the alarm interrupt.	The first comes 2**EVENT_TIMEOUT
	 * seconds from now and they continue on every 2**EVENT_TIMEOUT
	 * seconds.
	 */
# ifndef VMS
#  ifdef HAVE_TIMER_CREATE
	if (TC_ERR == timer_create(CLOCK_REALTIME, NULL, &timer_id)) {
		msyslog(LOG_ERR, "timer_create failed, %m");
		exit(1);
	}
#  endif
	signal_no_reset(SIGALRM, alarming);
	itimer.it_interval.tv_sec =
		itimer.it_value.tv_sec = (1 << EVENT_TIMEOUT);
	itimer.it_interval.itv_frac = itimer.it_value.itv_frac = 0;
	set_timer_or_die(&itimer);
# else	/* VMS follows */
	vmsinc[0] = 10000000;		/* 1 sec */
	vmsinc[1] = 0;
	lib$emul(&(1<<EVENT_TIMEOUT), &vmsinc, &0, &vmsinc);

	sys$gettim(&vmstimer);	/* that's "now" as abstime */

	lib$addx(&vmsinc, &vmstimer, &vmstimer);
	sys$setimr(0, &vmstimer, alarming, alarming, 0);
# endif	/* VMS */
#else	/* SYS_WINNT follows */
	/*
	 * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds
	 * Under Windows/NT,
	 */

	WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);
	if (WaitableTimerHandle == NULL) {
		msyslog(LOG_ERR, "CreateWaitableTimer failed: %m");
		exit(1);
	}
	else {
		DWORD		Period;
		LARGE_INTEGER	DueTime;
		BOOL		rc;

		Period = (1 << EVENT_TIMEOUT) * 1000;
		DueTime.QuadPart = Period * 10000i64;
		rc = SetWaitableTimer(WaitableTimerHandle, &DueTime,
				      Period, NULL, NULL, FALSE);
		if (!rc) {
			msyslog(LOG_ERR, "SetWaitableTimer failed: %m");
			exit(1);
		}
	}

#endif	/* SYS_WINNT */
}
示例#15
0
/*
 * init_timer - initialize the timer data structures
 */
void
init_timer(void)
{
# if defined SYS_WINNT & !defined(SYS_CYGWIN32)
	HANDLE hToken = INVALID_HANDLE_VALUE;
	TOKEN_PRIVILEGES tkp;
# endif /* SYS_WINNT */

	/*
	 * Initialize...
	 */
	alarm_flag = 0;
	alarm_overflow = 0;
	adjust_timer = 1;
	stats_timer = 0;
	huffpuff_timer = 0;
	interface_timer = 0;
	current_time = 0;
	timer_overflows = 0;
	timer_xmtcalls = 0;
	timer_timereset = 0;

#if !defined(SYS_WINNT)
	/*
	 * Set up the alarm interrupt.	The first comes 2**EVENT_TIMEOUT
	 * seconds from now and they continue on every 2**EVENT_TIMEOUT
	 * seconds.
	 */
# if !defined(VMS)
#  if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
	if (timer_create (CLOCK_REALTIME, NULL, &ntpd_timerid) ==
#	ifdef SYS_VXWORKS
		ERROR
#	else
		-1
#	endif
	   )
	{
		fprintf (stderr, "timer create FAILED\n");
		exit (0);
	}
	(void) signal_no_reset(SIGALRM, alarming);
	itimer.it_interval.tv_sec = itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
	itimer.it_interval.tv_nsec = itimer.it_value.tv_nsec = 0;
	timer_settime(ntpd_timerid, 0 /*!TIMER_ABSTIME*/, &itimer, NULL);
#  else
	(void) signal_no_reset(SIGALRM, alarming);
	itimer.it_interval.tv_sec = itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
	itimer.it_interval.tv_usec = itimer.it_value.tv_usec = 0;
	setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
#  endif
# else /* VMS */
	vmsinc[0] = 10000000;		/* 1 sec */
	vmsinc[1] = 0;
	lib$emul(&(1<<EVENT_TIMEOUT), &vmsinc, &0, &vmsinc);

	sys$gettim(&vmstimer);	/* that's "now" as abstime */

	lib$addx(&vmsinc, &vmstimer, &vmstimer);
	sys$setimr(0, &vmstimer, alarming, alarming, 0);
# endif /* VMS */
#else /* SYS_WINNT */
	_tzset();

	/*
	 * Get privileges needed for fiddling with the clock
	 */

	/* get the current process token handle */
	if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
		msyslog(LOG_ERR, "OpenProcessToken failed: %m");
		exit(1);
	}
	/* get the LUID for system-time privilege. */
	LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
	tkp.PrivilegeCount = 1;  /* one privilege to set */
	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	/* get set-time privilege for this process. */
	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
	/* cannot test return value of AdjustTokenPrivileges. */
	if (GetLastError() != ERROR_SUCCESS) {
		msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
	}

	/*
	 * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds
	 * Under Windows/NT, 
	 */

	WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);
	if (WaitableTimerHandle == NULL) {
		msyslog(LOG_ERR, "CreateWaitableTimer failed: %m");
		exit(1);
	}
	else {
		DWORD Period = (1<<EVENT_TIMEOUT) * 1000;
		LARGE_INTEGER DueTime;
		DueTime.QuadPart = Period * 10000i64;
		if (!SetWaitableTimer(WaitableTimerHandle, &DueTime, Period, NULL, NULL, FALSE) != NO_ERROR) {
			msyslog(LOG_ERR, "SetWaitableTimer failed: %m");
			exit(1);
		}
	}

#endif /* SYS_WINNT */
}