On Sat, Nov 25, 2017 at 07:44:54PM -0500, teknopaul wrote:
> I'm trying to compile nginx on for a raspberry pi
> time_t sec;
> ngx_uint_t msec;
> struct timeval tv;
> sec = tv.tv_sec;
> msec = tv.tv_usec / 1000;
> ngx_current_msec = (ngx_msec_t) sec * 1000 + msec;
> ngx_current_msec is defined as a ngx_msec_t which in turn is ngx_uint_t. In
> an rpi is not big enough to hold Unix epoc in millis. (sec * 1000)
> nginx code does compile, but my tests fail: they have hardcoded values for
> the epoc.
> Is this deliberate? I guess its cropping the high order bits? So millis
> comparisons might work but timestamps generated from this value might not?
Yes, this is intentional. The ngx_current_msec variable (and the
ngx_msec_t type) is to be used to effectively implement timers,
and hence it uses platform-specific fast integer. As such, it can
easily overflow on 32-bit platforms. You have to fix your tests.