Global variables in system programs
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Oct 15 15:14:04 UTC 2013
Hello,
I work currently on a port of the FreeBSD network stack to a real-time
operating system for embedded targets. Here the applications are statically
linked with the operating system and the network stack. We would like to use
the standard FreeBSD system programs to configure the network stack, e.g.
ROUTE(8), IFCONFIG(8), etc. For example
static const char *const argv[] = {
"ifconfig",
"lo0",
"127.0.0.1"
};
ifconfig(3, &argv[0]);
These programs use some global variables. In a statically linked context we
have now the following problems
o we cannot call the programs concurrently,
o we have to initialize the values each time.
We would like to follow the FreeBSD sources to stay up-to-date. So it is
desirable for us to keep the divergence from the original sources as small as
possible. Are patches acceptable for the FreeBSD project that alter system
programs such that
o global variables are moved into context structures,
o constant global variables are declared as "const", and
o variables and functions are declared as "static" if possible?
Attached is a patch for the ROUTE(8) program to give an example.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-FIXME-Add-and-use-context-for-route-command.patch
Type: text/x-patch
Size: 26969 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20131015/fa69331e/attachment.bin>
More information about the freebsd-hackers
mailing list