--- gforth/prim 2010/09/01 16:52:12 1.256 +++ gforth/prim 2011/12/02 21:59:09 1.261 @@ -1,6 +1,6 @@ \ Gforth primitives -\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -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