This transitions GMainContext.time and GSource.ready_time to
nanoseconds.
Special care had to be taken with g_source_set_ready_time() because of
potential overflows and the special meaning of certain values.
Avoid triggering an assertion when requesting help for the
help subcommand. Instead, report that help cannot be displayed
for the help subcommand and exit with an error.
Fixes: #4007
There is a small API surface of a single function between the poll()
code and the context/source time storage, so convert the poll() part to
nanoseconds first.
Makes it (hopefully) easier to track down any issues later.
This is the first API towards adding nanosecond precision ready time.
It provides an explicit way to unset ready times.
Some tests have been adapted to use this function.
Related: !5254
Split the meaning of an unset ready time from ready_time == -1 to
an explicit boolean.
Makes the code cleaner and prepares for future changes for nanosecond
accuracy.
Clang-tidy has a check to prohibit identifiers that are reserved for the
compiler. Those are identifiers that start with:
- an underscore plus an uppercase letter
- two underscores
- an underscore, and are in the global scope
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/reserved-identifier.html
Many public GLib macros define variables starting with two underscores,
which is technically not allowed. This is probably usually harmless, but
it causes false positives in the abovementioned clang-tidy check when
consumers of GLib use macros like G_VALUE_HOLDS_POINTER or
g_str_has_suffix.
This commit replaces all such names with one-underscore names, which are
not reserved because they're not in the global scope.
Here's the incantation I used to discover which macros needed editing:
git grep -P '\b__(?!builtin|atomic|sync|asm|volatile|pragma)[a-z].*\\$' \
-- '*.h' | grep -v valgrind.h
This generates a manageable number of false positives. It also fails to
find identifiers on the last line of a macro, but those are generally
already mentioned elsewhere in the macro.
I left valgrind.h untouched.
An equivalent to other g_set_* helper functions for GDateTime. It
replaces the previous value if it is not exactly the same, e.g. if the
timezones differ. This relyies on g_date_time_get_timezone_abbreviation
returning the same pointer for equal timezones.
The previous commit added separated doc blocks for certain enum members,
in those cases those needed to be capitalized accordingly so in this
commit we capitalize the remaining enum members.
... added since 2.74. 2.74 was selected arbitrarily.
When a Since annotation is written inline for an enum member, g-ir won't
parse it, they need dedicated doc blocks.
A variant of g_unix_fd_list_peek that can be used to lookup file
descriptors with an unvalidated index, to avoid manual validation.
This is especially handy when dealing with GDBus where the index is
usually attacker controlled. Experience has shown that validation is
spotty and often incomplete.
The variants hopefully will make this less of an issue.
Those variants allow users to avoid dup'ing the fd if there is no need
for it:
* `g_unix_fd_list_append_take` takes ownership over a fd
* `g_unix_fd_list_peek` gets a fd at an index without taking ownership