1 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 def check_clock_monotonic_support(lib=None, when=None):
10 check_msg = "for clock_gettime(CLOCK_MONOTONIC)"
14 check_msg += f" in {lib}"
15 flags.append(f"-l{lib}")
17 check_when = building_with_gnu_cc
23 body="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);",
30 have_raw_clock_monotonic_support = check_clock_monotonic_support()
31 have_rt_clock_monotonic_support = check_clock_monotonic_support(
32 lib="rt", when=~have_raw_clock_monotonic_support
36 "HAVE_CLOCK_MONOTONIC",
37 have_raw_clock_monotonic_support | have_rt_clock_monotonic_support,
40 "HAVE_CLOCK_MONOTONIC",
41 have_raw_clock_monotonic_support | have_rt_clock_monotonic_support,
44 set_config("REALTIME_LIBS", ["-lrt"], when=have_rt_clock_monotonic_support)
47 have_res_ninit = try_link(
48 includes=["sys/types.h", "netinet/in.h", "arpa/nameser.h", "resolv.h"],
49 body="int foo = res_ninit(&_res);",
50 check_msg="for res_ninit()",
51 flags=depends(when=building_linux)(["-D_BSD_SOURCE=1"]),
52 when=building_with_gnu_cc & ~target_is_netbsd & ~target_is_openbsd,
55 set_define("HAVE_RES_NINIT", have_res_ninit)