[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-hackers
Subject: Re: Global variables in system programs
From: Sebastian Huber <sebastian.huber () embedded-brains ! de>
Date: 2013-12-05 15:07:45
Message-ID: 52A096C1.9090400 () embedded-brains ! de
[Download RAW message or body]
Hello,
a small status update since some of my ROUTE(8) patches have been committed=
to =
FreeBSD HEAD recently.
A library interface to the core network commands and utilities is useful, b=
ut =
it turned out that the ROUTE(8) program was just the most simple one to =
convert. I tried to do this also with IFCONFIG(8), but gave up (it uses so=
me =
sort of module registry via linker sets, etc.). I use now a different =
approach. I initialize/destroy all global variables in a custom =
set-up/tear-down routine and protect the commands with a global mutex. Cal=
ls =
to the error and exit functions are wrapped to use a long jump. This works =
well so far with ROUTE(8), IFCONFIG(8), NETSTAT(1), PING(8) and PING6(8).
What really helps is adding static and const qualifiers whenever possible. =
Function static variables are a problem since they cannot be initialized wi=
th a =
single set-up/tear-down routine for a module. Signals are also a problem i=
n a =
multi-threaded environment (used by PING6(8)).
-- =
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@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine gesch=E4ftliche Mitteilung im Sinne des EHUG.
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic