--- gforth/prim 2011/11/21 19:05:01 1.260 +++ gforth/prim 2012/02/21 21:34:10 1.265 @@ -1,6 +1,6 @@ \ Gforth primitives -\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -1103,6 +1103,22 @@ lshift ( u1 n -- u2 ) core l_shift : 0 ?DO 2* LOOP ; +umax ( u1 u2 -- u ) core +if (u1 IF swap THEN drop ; + \g compare \ comparisons(prefix, args, prefix, arg1, arg2, wordsets...) @@ -2036,7 +2052,14 @@ dsystem = DZERO; ntime ( -- dtime ) gforth ""Report the current time in nanoseconds since some epoch."" struct timespec time1; +#ifdef HAVE_CLOCK_GETTIME clock_gettime(CLOCK_REALTIME,&time1); +#else +struct timeval time2; +gettimeofday(&time2,NULL); +time1.tv_sec = time2.tv_sec; +time1.tv_nsec = time2.tv_usec*1000; +#endif dtime = timespec2ns(&time1); \+ @@ -2548,7 +2571,7 @@ u = (c_addr[0] << 8) | (c_addr[1]); be-ul@ ( c_addr -- u ) gforth l_fetch_be ""@i{u} is the zero-extended 32-bit big endian value stored at @i{c_addr}."" -u = (c_addr[0] << 24) | (c_addr[1] << 16) | (c_addr[2] << 8) | (c_addr[3]); +u = ((Cell)c_addr[0] << 24) | (c_addr[1] << 16) | (c_addr[2] << 8) | (c_addr[3]); le-uw@ ( c_addr -- u ) gforth w_fetch_le ""@i{u} is the zero-extended 16-bit little endian value stored at @i{c_addr}."" @@ -2556,7 +2579,7 @@ u = (c_addr[1] << 8) | (c_addr[0]); le-ul@ ( c_addr -- u ) gforth l_fetch_le ""@i{u} is the zero-extended 32-bit little endian value stored at @i{c_addr}."" -u = (c_addr[3] << 24) | (c_addr[2] << 16) | (c_addr[1] << 8) | (c_addr[0]); +u = ((Cell)c_addr[3] << 24) | (c_addr[2] << 16) | (c_addr[1] << 8) | (c_addr[0]); \+64bit