--- gforth/prim 2010/12/31 18:09:02 1.257 +++ gforth/prim 2011/12/02 21:59:09 1.261 @@ -1804,6 +1804,8 @@ if (a_addr1==NULL) else a_addr2 = (Cell *)realloc(a_addr1, u); wior = IOR(a_addr2==NULL); /* !! Define a return code */ +if (a_addr2==NULL) + a_addr2 = a_addr1; strerror ( n -- c_addr u ) gforth c_addr = (Char *)strerror(n); @@ -2031,6 +2033,18 @@ duser = timeval2us(&time1); dsystem = DZERO; #endif +ntime ( -- dtime ) gforth +""Report the current time in nanoseconds since some epoch."" +#ifdef HAVE_CLOCK_GETTIME +struct timespec time1; +clock_gettime(CLOCK_REALTIME,&time1); +dtime = timespec2ns(&time1); +#else +struct timeval time1; +gettimeofday(&time1,NULL); +dtime = timeval2us(&time1) * 1000LL; +#endif + \+ \+floating