Beispiel #1
0
/* sets a time value to a certain nanoseconds */
void
nano_to_Time(TimeInternal *x, int nano)
{
	x->seconds     = 0;
	x->nanoseconds = nano;
	normalizeTime(x);
}
Beispiel #2
0
TimeBase& TimeBase::operator -= (const TimeBase& span)
{
  secs -= span.secs;
  nsecs -= span.nsecs;
  normalizeTime();
  return *this;
}
Beispiel #3
0
void div2Time(TimeInternal *r)
{
    r->nanoseconds += r->seconds % 2 * 1000000000;
    r->seconds /= 2;
    r->nanoseconds /= 2;
	
    normalizeTime(r);
}
Beispiel #4
0
void 
subTime(TimeInternal * r, const TimeInternal * x, const TimeInternal * y)
{
	r->seconds = x->seconds - y->seconds;
	r->nanoseconds = x->nanoseconds - y->nanoseconds;

	normalizeTime(r);
}
Beispiel #5
0
/* remove sign from variable */
void
absTime(TimeInternal *r)
{
	/* Make sure signs are the same */
	normalizeTime(r);
	r->seconds       = abs(r->seconds);
	r->nanoseconds   = abs(r->nanoseconds);
}
Beispiel #6
0
/* TODO: this function could be simplified, as currently it is only called to halve the time */
void
divTime(TimeInternal *r, int divisor)
{

	uint64_t nanoseconds;

	if (divisor <= 0)
		return;

	nanoseconds = ((uint64_t)r->seconds * 1000000000) + r->nanoseconds;
	nanoseconds /= divisor;

	r->seconds = 0;
	r->nanoseconds = nanoseconds;
	normalizeTime(r);
} 
Beispiel #7
0
// opens a binary cd image and calculates its length
void openBin(const char* filename)
{
    long end, size, blocks;

//    SysPrintf("start openBin()\r\n");

    CD.cd = fopen(filename, "rb");

    printf("CD.cd = %08x\n",CD.cd);

//	if (CD.cd == NULL) CD.cd = -1;
	
/*    if (CD.cd == 0)
    {
        SysPrintf("Error opening cd\r\n");
        exit(0);
    }
*/
    end = fseek(CD.cd, 0, SEEK_END);
    end = ftell(CD.cd);
    size = end;
    printf("size of CD in MB = %d\r\n",size/1048576);

    rc = fseek(CD.cd, 0, SEEK_SET);
    blocks = size / 2352;

    // put the track length info in the track list
    CD.tl = (Track*) malloc(sizeof(Track));

    CD.tl[0].type = Mode2;
    CD.tl[0].num = 1;
    CD.tl[0].start[0] = 0;
    CD.tl[0].start[1] = 0;
    CD.tl[0].start[2] = 0;
    CD.tl[0].end[2] = blocks % 75;
    CD.tl[0].end[1] = ((blocks - CD.tl[0].end[2]) / 75) % 60;
    CD.tl[0].end[0] = (((blocks - CD.tl[0].end[2]) / 75) - CD.tl[0].end[1]) / 60;

    CD.tl[0].start[1] += 2;
    CD.tl[0].end[1] += 2;

    normalizeTime(CD.tl[0].end);

    CD.numtracks = 1;

//    SysPrintf("end openBin()\r\n");
}
Beispiel #8
0
void integer64_to_internalTime(Integer64 bigint,TimeInternal *internal)
{
	int s_msb;
	double ns_msb;
	int entire;
	char  *p_lsb,*p_msb;
	Boolean negative = FALSE;

	p_lsb = (char *)&bigint.lsb;
	p_msb = (char *)&bigint.msb;

	/*Test if bigint is a negative number*/
	negative = ((bigint.msb & 0x80000000) == 0x80000000);

	if (!negative)
	{
	  /*Positive case*/

			/*fractional nanoseconds are excluded (see 5.3.2)*/
			bigint.lsb = bigint.lsb>>16;
			/*copy two least significant octet of msb to most significant octet of lsb*/
			*(p_lsb+2)=*p_msb;
			*(p_lsb+3)=*(p_msb+1);
			bigint.msb = bigint.msb>>16;

			internal->nanoseconds = bigint.lsb % 1000000000;
			internal->seconds = bigint.lsb / 1000000000;

			/*(2^32 / 10^9) = 4,294967296*/
			s_msb = 4*bigint.msb;
			ns_msb = 0.294967296*(double)bigint.msb;
			entire = (int)ns_msb;
			s_msb += entire;
			ns_msb -= entire;
			ns_msb *= 1000000000;
			internal->nanoseconds = internal->nanoseconds + (int)ns_msb;
			internal->seconds += s_msb;
			normalizeTime(internal);

	}
Beispiel #9
0
/* sets a time value to a certain nanoseconds */
void nano_to_Time(TimeInternal *time, int nano)
{
	time->seconds     = 0;
	time->nanoseconds = nano;
	normalizeTime(time);
}
Beispiel #10
0
void TimeBase::fromTimespec(const struct timespec& time)
{
  secs = time.tv_sec;
  nsecs = time.tv_nsec;
  normalizeTime();
}
Beispiel #11
0
TimeBase::TimeBase(const struct timespec& time)
  : secs(time.tv_sec),
    nsecs(time.tv_nsec)
{
  normalizeTime();
}
Beispiel #12
0
TimeBase::TimeBase(int64_t secs, int32_t nsecs)
  : secs(secs),
    nsecs(nsecs)
{
  normalizeTime();
}
Beispiel #13
0
 void TimeBase::NormalizeTime()
 {
   normalizeTime();
 }