The number of callouts is a compile-time constant in libbsd. Use this
in struct callout_cpu and avoid dynamic allocation of tables. This
signficantly reduces the count of load instructions in the callout
handling.
This firewall was not ported to RTEMS and is just dead code which may
make trouble during FreeBSD baseline updates. It also increased the
compile-time of the library for nothing.
Update #3472.
The getsockaddr() function is used to allocate a struct sockaddr of the
right length and initialize it with userspace provided data. It is used
for the connect(), bind() and sendit() family functions. In particular,
the sendit() function is used by the UDP send functions. This means
each UDP send needs a malloc() and free() invocation. This is a
performance problem in RTEMS (first-fit heap) and may lead to heap
fragmentation. Replace the malloc() allocation with a stack allocation.
This requires SOCK_MAXADDRLEN (= 255) of additional stack space for
libbsd.
A further optimization would be to get rid of the stack copy of the
socket address. However, this would require to check each consumer of
the address to ensure that it is not modified.