Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/compat/sys



    Date:        Fri, 15 Jun 2018 12:41:56 +0300
    From:        Valery Ushakov <uwe%stderr.spb.ru@localhost>
    Message-ID:  <20180615094156.GD3351%pony.stderr.spb.ru@localhost>

  | Re memset - I now wonder if
  | compiler is even allowed to be smart here b/c strict aliasing

Another way would be

	static const struct timespec50 zts = { 0 };
and
	*ts50 = zts;

which is unlikely to have that problem, and which the compiler might
be smart enough to optimise into a single assignment where there is
padding, and perhaps even nothing where there is none.

I'm also not really a fan of the #if that tests the number of bits in
int and long (by testing their max values) - that is assuming that
when long is wider than int, it also has wider alignment, which is
not necessarily so - a system with 4 byte ints and 8 byte long,
could have long with 4 byte alignment (and that struct be 12 bytes
long, alogned 4).     The code as it is isn't wrong, ijust the attempt
to avoid the memset() when it isn't needed might fail, and do the
memset() when there is nothing to clear - and if the compiler doesn't
or even can't, optimise it away then it is wasteful.

kre



Home | Main Index | Thread Index | Old Index