11/*=====================================================================*/
2- /* serrano/prgm/project/bigloo/flt /runtime/Clib/csystem.c */
2+ /* serrano/prgm/project/bigloo/bigloo /runtime/Clib/csystem.c */
33/* ------------------------------------------------------------- */
44/* Author : Manuel Serrano */
55/* Creation : Wed Jan 20 08:45:23 1993 */
6- /* Last change : Mon Nov 18 15:44:07 2024 (serrano) */
7- /* Copyright : 2002-24 Manuel Serrano */
6+ /* Last change : Thu Jul 3 12:55:19 2025 (serrano) */
7+ /* Copyright : 2002-25 Manuel Serrano */
88/* ------------------------------------------------------------- */
99/* System interface */
1010/*=====================================================================*/
@@ -535,6 +535,10 @@ bgl_time(obj_t thunk) {
535535
536536 return BGL_PROCEDURE_CALL0 (thunk );
537537#else
538+ # if (BGL_HAVE_TIMEVAL )
539+ struct timeval tv1 , tv2 ;
540+ # endif
541+
538542 static long ctick = 0 ;
539543 obj_t env = BGL_CURRENT_DYNAMIC_ENV ();
540544 struct tms buf1 , buf2 ;
@@ -544,13 +548,29 @@ bgl_time(obj_t thunk) {
544548 if (!ctick ) ctick = sysconf (_SC_CLK_TCK );
545549
546550 t1 = times (& buf1 );
551+ # if (BGL_HAVE_TIMEVAL )
552+ gettimeofday (& tv1 , 0 );
553+ # endif
554+
547555 res = BGL_PROCEDURE_CALL0 (thunk );
556+
557+ # if (BGL_HAVE_TIMEVAL )
558+ gettimeofday (& tv2 , 0 );
559+ # endif
548560 t2 = times (& buf2 );
549561
550562 BGL_ENV_MVALUES_NUMBER_SET (env , 4 );
551563
552564# define BTICK (v ) BINT((v) * 1000 / ctick)
565+ # if (BGL_HAVE_TIMEVAL )
566+ {
567+ BGL_LONGLONG_T ms1 = (BGL_LONGLONG_T )(tv1 .tv_sec ) * 1000 + (BGL_LONGLONG_T )(tv1 .tv_usec / 1000 );
568+ BGL_LONGLONG_T ms2 = (BGL_LONGLONG_T )(tv2 .tv_sec ) * 1000 + (BGL_LONGLONG_T )(tv2 .tv_usec / 1000 );
569+ BGL_ENV_MVALUES_VAL_SET (env , 1 , BINT (ms2 - ms1 ));
570+ }
571+ # else
553572 BGL_ENV_MVALUES_VAL_SET (env , 1 , BTICK (t2 - t1 ));
573+ # endif
554574 BGL_ENV_MVALUES_VAL_SET (env , 2 , BTICK (buf2 .tms_stime - buf1 .tms_stime ));
555575 BGL_ENV_MVALUES_VAL_SET (env , 3 , BTICK ((buf2 .tms_cutime - buf1 .tms_cutime )
556576 + (buf2 .tms_utime - buf1 .tms_utime )));
0 commit comments