When compiling with gcc don't register jas_cleanup with atexit.
Instead, mark it as a destructor using a gcc-only extension.

This will avoid crashes, when an application, which has explicitly
dlclosed() libjasper, exits.

If a similar method exists for other compilers, it should be used
too.  Or, maybe, something can be done with __cxa_atexit() here...

	-mi

--- src/libjasper/include/jasper/jas_init.h	2007-01-19 16:43:04.000000000 -0500
+++ src/libjasper/include/jasper/jas_init.h	2007-08-05 11:42:41.000000000 -0400
@@ -75,5 +75,9 @@
 int jas_init(void);
 
+#ifdef __GNUC__
+void jas_cleanup(void) __attribute__ ((destructor));
+#else
 void jas_cleanup(void);
+#endif
 
 #ifdef __cplusplus
--- src/libjasper/base/jas_init.c	2007-01-19 16:43:05.000000000 -0500
+++ src/libjasper/base/jas_init.c	2007-08-05 11:44:00.000000000 -0400
@@ -152,5 +152,4 @@
 	as it ensures that the JasPer exit handler is called before the
 	debug memory allocator exit handler. */
-	atexit(jas_cleanup);
 
 	return 0;
