]> git.ipfire.org Git - thirdparty/systemd.git/commit
types-fundamental: introduce sd_true + sd_false 21285/head
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Nov 2021 14:31:17 +0000 (15:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Nov 2021 16:23:34 +0000 (17:23 +0100)
commitf22abf384d1d2a6d1a303502a57366df7dd4b08e
tree2d9ed3b010c9eeb00b51e508a0afdd502109a771
parente514b5071c75c1a4d25a9fc925e5574007dd0ac3
types-fundamental: introduce sd_true + sd_false

I think we should stick to the rule that stuff defined in
types-fundamental.h either:

1. adds a prefixed concept "sd_xyz" that maps differently in the two
   environments

2. adds a non-prefixed concept "xyz" that adds a type otherwise missing
   in one of the two environments but with the same definition as in the
   other.

i.e. if have have some concept that might differ the way its set up in
the two environments it really should be prefixed by "sd_" to make clear
it has semantics we defined. Only drop the prefix if it really means the
exact same thin in all environments.

Now, sd_bool is defined prefixed, because its either mapped to "BOOLEAN"
(which is an integer) in UEFI or "bool" (which is C99 _Bool) in
userspace. size_t is not defined prefixed, because it's mapped to the
same thing ultimately (on the UEFI its mapped to UINTN, but that in turn
is defined as being the type for the size of memory objects, thus it's
really the same as userspace size_t).

So far "true" and "false" where defined unprefixed even though they map
to values of different types. typeof(true) in userspace would reveal
_Bool, but typeof(false) in UEFI would reveal BOOLEAN. The distinction
actually does matter in comparisons (i.e. (_Bool) 1 == (_Bool) 2 holds
while (BOOLEAN) 1 == (BOOLEAN) 2 does not hold).

Hence, let's add sd_true and sd_false, thus indicating we defined our
own concept here, and it has similar but different semantics in UEFI and
in userspace.
src/fundamental/bootspec-fundamental.c
src/fundamental/macro-fundamental.h
src/fundamental/types-fundamental.h