glibc/inet
Zack Weinberg 4a39c34c4f Change most internal uses of __gettimeofday to __clock_gettime.
Since gettimeofday will shortly be implemented in terms of
clock_gettime on all platforms, internal code should use clock_gettime
directly; in addition to removing a layer of indirection, this will
allow us to remove the PLT-bypass gunk for gettimeofday.  (We can't
quite do that yet, but it'll be coming later in this patch series.)
In many cases, the changed code does fewer conversions.

The changed code always assumes __clock_gettime (CLOCK_REALTIME)
cannot fail.  Most of the call sites were assuming gettimeofday could
not fail, but a few places were checking for errors.  POSIX says
clock_gettime can only fail if the clock constant is invalid or
unsupported, and CLOCK_REALTIME is the one and only clock constant
that's required to be supported.  For consistency I grepped the entire
source tree for any other places that checked for errors from
__clock_gettime (CLOCK_REALTIME), found one, and changed it too.

(For the record, POSIX also says gettimeofday can never fail.)

(It would be nice if we could declare that GNU systems will always
support CLOCK_MONOTONIC as well as CLOCK_REALTIME; there are several
places where we are using CLOCK_REALTIME where _MONOTONIC would be
more appropriate, and/or trying to use _MONOTONIC and then falling
back to _REALTIME.  But the Hurd doesn't support CLOCK_MONOTONIC yet,
and it looks like adding it would involve substantial changes to
gnumach's internals and API.  Oh well.)

A few Hurd-specific files were changed to use __host_get_time instead
of __clock_gettime, as this seemed tidier.  We also assume this cannot
fail.  Skimming the code in gnumach leads me to believe the only way
it could fail is if __mach_host_self also failed, and our
Hurd-specific code consistently assumes that can't happen, so I'm
going with that.

With the exception of support/support_test_main.c, test cases are not
modified, mainly because I didn't want to have to figure out which
test cases were testing gettimeofday specifically.

The definition of GETTIME in sysdeps/generic/memusage.h had a typo and
was not reading tv_sec at all.  I fixed this.  It appears nobody has been
generating malloc traces on a machine that doesn't have a superseding
definition.

There are a whole bunch of places where the code could be simplified
by factoring out timespec subtraction and/or comparison logic, but I
want to keep this patch as mechanical as possible.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-10-30 17:04:10 -03:00
..
arpa Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
netinet Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
protocols Installed-header hygiene (BZ#20366): conditionally defined structures. 2016-09-23 08:43:56 -04:00
aliases.h Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
bug-if1.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
check_native.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
check_pf.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
deadline.c Change most internal uses of __gettimeofday to __clock_gettime. 2019-10-30 17:04:10 -03:00
ether_aton_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ether_aton.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ether_hton.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ether_line.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ether_ntoa_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ether_ntoa.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ether_ntoh.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getaliasent_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getaliasent.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getaliasname_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getaliasname.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstbyad_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstbyad.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstbynm2_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstbynm2.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstbynm_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstbynm.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstent_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
gethstent.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getipv4sourcefilter.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnameinfo.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetbyad_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetbyad.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetbynm_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetbynm.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetent_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetent.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetgrent_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getnetgrent.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getproto_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getproto.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getprtent_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getprtent.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getprtname_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getprtname.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getservent_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getservent.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getsourcefilter.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getsrvbynm_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getsrvbynm.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getsrvbypt_r.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
getsrvbypt.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
herrno-loc.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
herrno.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
htonl.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
htons.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
htontest.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
idna_name_classify.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
idna.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
if_index.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ifaddrs.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ifaddrs.h Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ifreq.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
in6_addr.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
inet6_opt.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
inet6_option.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
inet6_rth.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
inet6_scopeid_pton.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
inet_lnaof.c Consistently use uintN_t not u_intN_t everywhere. 2017-08-07 19:55:34 +00:00
inet_mkadr.c inet: Remove SCCS keywords 2016-04-28 12:53:50 +02:00
inet_net.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
inet_netof.c Consistently use uintN_t not u_intN_t everywhere. 2017-08-07 19:55:34 +00:00
inet_ntoa.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
Makefile resolv/tst-idna_name_classify: Isolate from system libraries 2019-10-30 17:44:09 +01:00
net-internal.h inet/net-internal.h: Fix uninitalised clntudp_call() variable 2019-09-24 21:55:36 +01:00
netgroup.h Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
rcmd.c inet: Remove internal_function attribute 2017-08-31 18:52:00 +02:00
rexec.c rcmd/rexec: Fix typo in comment 2017-04-19 22:19:17 +02:00
ruserpass.c manual: Revise crypt.texi. 2018-06-29 16:53:37 +02:00
setipv4sourcefilter.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
setsourcefilter.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
test_ifindex.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
test-hnto-types.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
test-ifaddrs.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
test-inet6_opt.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-checks-posix.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-checks.c inet: Make IN6_IS_ADDR_UNSPECIFIED etc. usable with POSIX [BZ #16421] 2016-12-09 11:27:44 +01:00
tst-deadline.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-ether_aton.c Modify several tests to use test-skeleton.c 2015-08-06 02:59:04 -04:00
tst-ether_line.c
tst-gethnm.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-getni1.c
tst-getni2.c
tst-idna_name_classify.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-if_index-long.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-inet6_rth.c
tst-inet6_scopeid_pton.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-network.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
tst-ntoa.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-sockaddr.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
Versions Switch IDNA implementation to libidn2 [BZ #19728] [BZ #19729] [BZ #22247] 2018-05-23 15:27:24 +02:00