--- gforth/prim 2010/08/31 20:10:59 1.255 +++ 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. @@ -618,6 +618,18 @@ f_fp = fp; c_lp = lp; a_newhandler = rp-5; +(throw1) ( ... wball a_handler -- ... wball ) gforth paren_throw1 +rp = a_handler; +lp = (Address)rp[1]; +fp = (Float *)rp[2]; +sp = (Cell *)rp[3]; +#ifndef NO_IP +ip=IP; +#endif +SUPER_END; +VM_JUMP(EXEC1(*(Xt *)rp[4])); + + \+ \ don't make any assumptions where the return stack is!! @@ -1792,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); @@ -2019,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