Hey,

Sorry for the delay.

On Sun, Nov 26, 2017 at 07:00:36PM +0100, Jeremie Courreges-Anglas wrote:
> On Sun, Nov 26 2017, Jeremie Courreges-Anglas <[email protected]> wrote:
> > On Sat, Nov 25 2017, Brent Cook <[email protected]> wrote:
> >> Thanks guys. This will make enabling this on the odder platforms in
> >> portable easier.
> >
> > NB: if we want to able to mix app_tminterval() for real and user time, the
> > static storage used for "start" should be different.  This is not the
> > case for the Windows implementation, which *seems* to support only user
> > time:
> >
> >   
> > https://github.com/libressl-portable/portable/blob/master/apps/openssl/apps_win.c
> >
> > Another approach, which would require more changes, would be to just
> > provide two seperate functions, possibly named app_timer_real() and
> > app_timer_user().  The Windows version of app_timer_real() could start
> > as a simple copy of app_timer_user(), marked with XXX...
> 
> So here's a diff similar to what Scott proposed in his first diff.
> 
> The apps_win.c diff for portable would look like this
> (untested):
> 
>   https://pbot.rmdir.de/sy3XxnKuTQHgotB35BJ6vQ

That looks fine to me, but I prefer the names you gave above,
"app_timer_real" and "app_timer_user".

> I resisted the temptation to make use of TM_START/TM_STOP instead of
> local defines, this could be another TODO entry.  I don't like the
> TM_START/TM_STOP names btw, TM_STOP doesn't actually stop the timer,
> it's just a "get" operation.

Agreed re. the operation names.  Can we call them TM_SET/TM_GET?
One does "set" a timer.

> Do you folks agree with this approach?

Assuming you feel the same way about what you wrote two weeks ago,
yeah I'm good with that.

I'll send a pull request with a mix of your changes and an
implementation for app_timer_user() on Windows to libressl-portable
today or tomorrow and reply here with the same.

A subsequent diff will expose the separate functions to the rest of
the modules via apps.h, and later diffs in, e.g., speed and s_time,
can make use of the now-distinct timer routines at their leisure.

--
Scott Cheloha

> Index: apps.h
> ===================================================================
> RCS file: /d/cvs/src/usr.bin/openssl/apps.h,v
> retrieving revision 1.19
> diff -u -p -r1.19 apps.h
> --- apps.h    30 Aug 2016 14:34:59 -0000      1.19
> +++ apps.h    26 Nov 2017 17:46:01 -0000
> @@ -279,7 +279,8 @@ int app_isdir(const char *);
>  
>  #define TM_START     0
>  #define TM_STOP              1
> -double app_tminterval (int stop, int usertime);
> +double app_timer_realtime(int stop);
> +double app_timer_usertime(int stop);
>  
>  #define OPENSSL_NO_SSL_INTERN
>  
> Index: apps_posix.c
> ===================================================================
> RCS file: /d/cvs/src/usr.bin/openssl/apps_posix.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 apps_posix.c
> --- apps_posix.c      24 Nov 2017 13:48:12 -0000      1.3
> +++ apps_posix.c      26 Nov 2017 17:43:18 -0000
> @@ -123,8 +123,8 @@
>  
>  #include "apps.h"
>  
> -static double
> -real_interval(int stop)
> +double
> +app_timer_realtime(int stop)
>  {
>       static struct timespec start;
>       struct timespec elapsed, now;
> @@ -138,8 +138,8 @@ real_interval(int stop)
>       return 0.0;
>  }
>  
> -static double
> -user_interval(int stop)
> +double
> +app_timer_usertime(int stop)
>  {
>       static struct timeval start;
>       struct timeval elapsed;
> @@ -152,12 +152,6 @@ user_interval(int stop)
>       }
>       start = now.ru_utime;
>       return 0.0;
> -}
> -
> -double
> -app_tminterval(int stop, int usertime)
> -{
> -     return (usertime) ? user_interval(stop) : real_interval(stop);
>  }
>  
>  int
> Index: s_time.c
> ===================================================================
> RCS file: /d/cvs/src/usr.bin/openssl/s_time.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 s_time.c
> --- s_time.c  2 Nov 2017 00:31:49 -0000       1.18
> +++ s_time.c  26 Nov 2017 17:40:54 -0000
> @@ -233,9 +233,9 @@ s_time_usage(void)
>  #define STOP 1
>  
>  static double
> -tm_Time_F(int s)
> +tm_Time_F(int op)
>  {
> -     return app_tminterval(s, 1);
> +     return app_timer_usertime(op);
>  }
>  
>  /***********************************************************************
> Index: speed.c
> ===================================================================
> RCS file: /d/cvs/src/usr.bin/openssl/speed.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 speed.c
> --- speed.c   7 Oct 2017 06:16:54 -0000       1.20
> +++ speed.c   26 Nov 2017 17:45:29 -0000
> @@ -202,7 +202,10 @@ sig_done(int sig)
>  static double
>  Time_F(int s)
>  {
> -     return app_tminterval(s, usertime);
> +     if (usertime)
> +             return app_timer_usertime(s);
> +     else
> +             return app_timer_realtime(s);
>  }
>  
>  
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to