RPM Community Forums

Mailing List Message of <popt-devel>

POPT 2.0: adding setjmp/longjmp?

From: Jeff Johnson <n3npq@mac.com>
Date: Fri 18 Jun 2010 - 17:31:06 CEST
Message-id: <B6397424-FE6F-4578-B56B-119A5C0588EE@mac.com>
Related to the issue of throwing exceptions to
C++ and other modern application environments on
errors is providing some sort of restart handling
within POPT itself.

In C this is usually done using setjmp(3)/longjmp(3).

Note that POPT has always had a rather primitive method
to restart implemented in

	/** \ingroup popt
	 * Reinitialize popt context.
	 * @param con           context
	 */
	/*@unused@*/
	void poptResetContext(/*@null@*/poptContext con)
	        /*@modifies con @*/;

so it would not be very hard to tie the already implemented "reinitialize"
method into a setjmp(3)/longjmp(3) exception handling framework.

(aside)
With a little thought, I believe I can likely add other restart
points within option/arg handling, its just another stack (and
POPT already has 2 stacks now in the process of being unified
into one. Adding a dynamic run-time element such as implied
by setjmp(3)/longjmp(3) is largely adding another token to
a union "item" which is pushed/popped accirding to well-defined
rules.

(aside to the aside)
There's other automagic doing, say, cleanup using atexit(3)
that would simplify using POPT's API as well (and get
POPT off of everyone's bleeping widdle valgrind exercise
hit lists without forcing me to debug everyone's POPT
bugs ad nauseum.

I can go many ways here. Some exception handling framework
is needed for POPT to be easily used in modern languages
like C++/Java/... and (in C) this means setjmp(3)/longjmp(3)/atexit(3).

Opinions?

73 de Jeff
Received on Fri Jun 18 17:31:40 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.