<feed xmlns='http://www.w3.org/2005/Atom'>
<title>unit.git/src, branch bool</title>
<subtitle>Universal Web Application Server</subtitle>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/'/>
<entry>
<title>Use nxt_bool_t in the configuration type system.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T21:29:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=3c3d59833aaade452ab00df29d13ecc67130433d'/>
<id>3c3d59833aaade452ab00df29d13ecc67130433d</id>
<content type='text'>
This replaces the use of uint8_t to represent booleans in the
configuration type system with the nxt_bool_t type (which happens to be
a uint8_t).

This is part of the work to use nxt_bool_t in structures to represent
booleans rather than uint8_t's which is more intuitive.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This replaces the use of uint8_t to represent booleans in the
configuration type system with the nxt_bool_t type (which happens to be
a uint8_t).

This is part of the work to use nxt_bool_t in structures to represent
booleans rather than uint8_t's which is more intuitive.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove an erroneous semi-colon.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T21:01:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=f6da981b218e9e817121a9087fb2e0cccae4e549'/>
<id>f6da981b218e9e817121a9087fb2e0cccae4e549</id>
<content type='text'>
Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove NXT_CONF_MAP_INT8.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T21:33:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=cb99f1e11ffd20f71291903cf30f1a121801cd4e'/>
<id>cb99f1e11ffd20f71291903cf30f1a121801cd4e</id>
<content type='text'>
This has been replaced by NXT_CONF_MAP_BOOL.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This has been replaced by NXT_CONF_MAP_BOOL.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Use NXT_CONF_MAP_BOOL.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T21:23:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=d54e63d8dda8a859c16197f181a59e804d165eaf'/>
<id>d54e63d8dda8a859c16197f181a59e804d165eaf</id>
<content type='text'>
This replaces the use of NXT_CONF_MAP_INT8 for denoting boolean values.
It also makes NXT_CONF_MAP_BOOL an alias for NXT_CONF_MAP_INT8 in
nxt_conf_map_object(). A future commit will remove NXT_CONF_MAP_INT8.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This replaces the use of NXT_CONF_MAP_INT8 for denoting boolean values.
It also makes NXT_CONF_MAP_BOOL an alias for NXT_CONF_MAP_INT8 in
nxt_conf_map_object(). A future commit will remove NXT_CONF_MAP_INT8.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add NXT_CONF_MAP_BOOL.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T21:14:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=5d0f586d56da625bc7bcc3ad6d4e3445eeac0fa3'/>
<id>5d0f586d56da625bc7bcc3ad6d4e3445eeac0fa3</id>
<content type='text'>
When adding a boolean config option, this is of type
NXT_CONF_VALUE_BOOLEAN, however when mapping such an entry to a
structure member via nxt_conf_map_object() this is done as a
NXT_CONF_MAP_INT8. It took a bit of head scratching to find out that it
should have been a NXT_CONF_MAP_INT8 and not a NXT_CONF_MAP_INT.

Introduce a new map type of NXT_CONF_MAP_BOOL that will eventually
replace NXT_CONF_MAP_INT8 for representing booleans...

We use the short form _BOOL as that matches the naming convention of the
other types in nxt_conf_map_type_t.

This is part of a set of patches and eventually NXT_CONF_MAP_BOOL will
simply replace NXT_CONF_MAP_INT8.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When adding a boolean config option, this is of type
NXT_CONF_VALUE_BOOLEAN, however when mapping such an entry to a
structure member via nxt_conf_map_object() this is done as a
NXT_CONF_MAP_INT8. It took a bit of head scratching to find out that it
should have been a NXT_CONF_MAP_INT8 and not a NXT_CONF_MAP_INT.

Introduce a new map type of NXT_CONF_MAP_BOOL that will eventually
replace NXT_CONF_MAP_INT8 for representing booleans...

We use the short form _BOOL as that matches the naming convention of the
other types in nxt_conf_map_type_t.

This is part of a set of patches and eventually NXT_CONF_MAP_BOOL will
simply replace NXT_CONF_MAP_INT8.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Convert uint32_t struct boolean members to nxt_bool_t.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-27T21:41:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=aa0009f8dcecfefd3c123baa316c2f86d3525f8c'/>
<id>aa0009f8dcecfefd3c123baa316c2f86d3525f8c</id>
<content type='text'>
This commit complements the earlier one that changed a bunch of uint8_t
struct members to nxt_bool_t (aka uint8_t).

It's not entirely clear why these were specifically done as uint32_t's.

I've checked these structure layouts with pahole(1) after this change on
both 32 and 64bit and the layouts haven't changed.

We may get a 3 or 7 byte hole after the nxt_bool_t or 3 bytes of padding
at the end of the structure, but the structure members are still at the
same offsets and the structure sizes have remained the same.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit complements the earlier one that changed a bunch of uint8_t
struct members to nxt_bool_t (aka uint8_t).

It's not entirely clear why these were specifically done as uint32_t's.

I've checked these structure layouts with pahole(1) after this change on
both 32 and 64bit and the layouts haven't changed.

We may get a 3 or 7 byte hole after the nxt_bool_t or 3 bytes of padding
at the end of the structure, but the structure members are still at the
same offsets and the structure sizes have remained the same.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Convert uint8_t struct boolean members to nxt_bool_t.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T20:16:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=c1303660eda80c5e17fde06bb8f17715e7be049b'/>
<id>c1303660eda80c5e17fde06bb8f17715e7be049b</id>
<content type='text'>
Replace the usage of uint8_t in structures to represent boolean values
with our nxt_bool_t type.

This will result in no change in structure layout as the nxt_bool_t is
now a uint8_t, same as what it's replacing.

Even though it's essentially the same type, it makes it much clearer as
to what its purpose is.

This was largely done with the following script from Alex, with some
manual conversions

  $ grep -rl 'uint8_t.*1 bit' src/ \
  | xargs sed -i '/uint8_t.*1 bit/{s/uint8_t     /nxt_bool_t  /;s/; *\/\*.*/;/}'

This doesn't convert the non-uint8_t booleans, they will be handled
separately.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replace the usage of uint8_t in structures to represent boolean values
with our nxt_bool_t type.

This will result in no change in structure layout as the nxt_bool_t is
now a uint8_t, same as what it's replacing.

Even though it's essentially the same type, it makes it much clearer as
to what its purpose is.

This was largely done with the following script from Alex, with some
manual conversions

  $ grep -rl 'uint8_t.*1 bit' src/ \
  | xargs sed -i '/uint8_t.*1 bit/{s/uint8_t     /nxt_bool_t  /;s/; *\/\*.*/;/}'

This doesn't convert the non-uint8_t booleans, they will be handled
separately.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Change nxt_bool_t from a nxt_uint_t to a uint8_t.</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T16:44:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=f20172e5959d2029fdc7f084a332a748563dd50e'/>
<id>f20172e5959d2029fdc7f084a332a748563dd50e</id>
<content type='text'>
We have a 'bool' type, nxt_bool_t which is defined as a nxt_uint_t, that
is used as local variables, and function return types and arguments.

However in structs we use a uint8_t, due to not wanting to waste memory
in structures, but the use of uint8_t in structs is confusing and
unintuitive.

We could just switch to using the C99 _Bool type, however there are
concerns about this possibly not always being 1-byte on platforms on
which Unit runs and might mess with structure layouts.

(Switching to _Bool as the underlying type is still an eventual goal)

The alternative is to just make our nxt_bool_t be a uint8_t.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We have a 'bool' type, nxt_bool_t which is defined as a nxt_uint_t, that
is used as local variables, and function return types and arguments.

However in structs we use a uint8_t, due to not wanting to waste memory
in structures, but the use of uint8_t in structs is confusing and
unintuitive.

We could just switch to using the C99 _Bool type, however there are
concerns about this possibly not always being 1-byte on platforms on
which Unit runs and might mess with structure layouts.

(Switching to _Bool as the underlying type is still an eventual goal)

The alternative is to just make our nxt_bool_t be a uint8_t.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't conflate the error variable in nxt_kqueue_poll().</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-24T14:23:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=9b848c515ed9b72625c835c2eda1c0278892e97c'/>
<id>9b848c515ed9b72625c835c2eda1c0278892e97c</id>
<content type='text'>
In nxt_kqueue_poll() error is declared as a nxt_bool_t aka unsigned int
(on x86-64 anyway).

It is used both as a boolean and as the return storage for a bitwise AND
operation.

This causes the following issue after we have changed nxt_bool_t to be a
uint8_t (which will happen in a subsequent commit)

gcc12 -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -O2 -I src -I build     -I/usr/local/include  -o build/src/nxt_kqueue_engine.o  -MMD -MF build/src/nxt_kqueue_engine.dep -MT build/src/nxt_kqueue_engine.o  src/nxt_kqueue_engine.c
src/nxt_kqueue_engine.c: In function 'nxt_kqueue_poll':
src/nxt_kqueue_engine.c:728:17: error: overflow in conversion from 'int' to 'nxt_bool_t' {aka 'unsigned char'} changes value from '(int)kev-&gt;flags &amp; 16384' to '0' [-Werror=overflow]
  728 |         error = (kev-&gt;flags &amp; EV_ERROR);
      |                 ^
cc1: all warnings being treated as errors

EV_ERROR has the value 16384, after the AND operation error holds 16384,
however this overflows and wraps around (64 times) exactly to 0.

Rather than conflating the use of error, keep error as a boolean (it is
used further down the function) but do the AND operation inside the
if ().

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In nxt_kqueue_poll() error is declared as a nxt_bool_t aka unsigned int
(on x86-64 anyway).

It is used both as a boolean and as the return storage for a bitwise AND
operation.

This causes the following issue after we have changed nxt_bool_t to be a
uint8_t (which will happen in a subsequent commit)

gcc12 -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g -O2 -I src -I build     -I/usr/local/include  -o build/src/nxt_kqueue_engine.o  -MMD -MF build/src/nxt_kqueue_engine.dep -MT build/src/nxt_kqueue_engine.o  src/nxt_kqueue_engine.c
src/nxt_kqueue_engine.c: In function 'nxt_kqueue_poll':
src/nxt_kqueue_engine.c:728:17: error: overflow in conversion from 'int' to 'nxt_bool_t' {aka 'unsigned char'} changes value from '(int)kev-&gt;flags &amp; 16384' to '0' [-Werror=overflow]
  728 |         error = (kev-&gt;flags &amp; EV_ERROR);
      |                 ^
cc1: all warnings being treated as errors

EV_ERROR has the value 16384, after the AND operation error holds 16384,
however this overflows and wraps around (64 times) exactly to 0.

Rather than conflating the use of error, keep error as a boolean (it is
used further down the function) but do the AND operation inside the
if ().

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Use unsigned int for nxt_bool_t in va_arg().</title>
<updated>2023-03-28T22:15:28+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-23T16:40:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=ecbefc519ec968f31ac659779ac2dedfe8545d3b'/>
<id>ecbefc519ec968f31ac659779ac2dedfe8545d3b</id>
<content type='text'>
This is required for the next patch which will change nxt_bool_t from a
nxt_uint_t to a uint8_t, which produces the following compiler warning

cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g   -I src -I build   \
                      \
                     \
-o build/src/nxt_sprintf.o \
-MMD -MF build/src/nxt_sprintf.dep -MT build/src/nxt_sprintf.o \
src/nxt_sprintf.c
In file included from src/nxt_unix.h:160,
                 from src/nxt_main.h:31,
                 from src/nxt_sprintf.c:7:
src/nxt_sprintf.c: In function ‘nxt_vsprintf’:
src/nxt_sprintf.c:368:44: error: ‘nxt_bool_t’ {aka ‘unsigned char’} is promoted to ‘int’ when passed through ‘...’ [-Werror]
  368 |             ui64 = (uint64_t) va_arg(args, nxt_bool_t);
      |                                            ^
src/nxt_sprintf.c:368:44: note: (so you should pass ‘int’ not ‘nxt_bool_t’ {aka ‘unsigned char’} to ‘va_arg’)
src/nxt_sprintf.c:368:44: note: if this code is reached, the program will abort
cc1: all warnings being treated as errors

Lets use unsigned int as it matches the signedness of nxt_bool_t.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is required for the next patch which will change nxt_bool_t from a
nxt_uint_t to a uint8_t, which produces the following compiler warning

cc -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -g   -I src -I build   \
                      \
                     \
-o build/src/nxt_sprintf.o \
-MMD -MF build/src/nxt_sprintf.dep -MT build/src/nxt_sprintf.o \
src/nxt_sprintf.c
In file included from src/nxt_unix.h:160,
                 from src/nxt_main.h:31,
                 from src/nxt_sprintf.c:7:
src/nxt_sprintf.c: In function ‘nxt_vsprintf’:
src/nxt_sprintf.c:368:44: error: ‘nxt_bool_t’ {aka ‘unsigned char’} is promoted to ‘int’ when passed through ‘...’ [-Werror]
  368 |             ui64 = (uint64_t) va_arg(args, nxt_bool_t);
      |                                            ^
src/nxt_sprintf.c:368:44: note: (so you should pass ‘int’ not ‘nxt_bool_t’ {aka ‘unsigned char’} to ‘va_arg’)
src/nxt_sprintf.c:368:44: note: if this code is reached, the program will abort
cc1: all warnings being treated as errors

Lets use unsigned int as it matches the signedness of nxt_bool_t.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
