1 $NetBSD: patch-src_glx_dri__common.c,v 1.1 2022/03/13 15:52:50 tnn Exp $
3 atexit() is not a good idea in shared libraries.
5 FreeBSD reported atexit bug for 10.6:
6 https://bugs.freedesktop.org/show_bug.cgi?id=91869
8 --- src/glx/dri_common.c.orig 2021-07-14 20:04:55.743010300 +0000
9 +++ src/glx/dri_common.c
10 @@ -690,9 +690,19 @@ static struct driver_config_entry *drive
11 /* Called as an atexit function. Otherwise, this would have to be called with
12 * driver_config_mutex locked.
14 +#if defined(HAVE_NOATEXIT)
15 +static Bool e_next_ever_null = False;
17 +static void __attribute__((__destructor__))
21 clear_driver_config_cache()
23 +#if defined(HAVE_NOATEXIT)
24 + if (!e_next_ever_null)
27 while (driver_config_cache) {
28 struct driver_config_entry *e = driver_config_cache;
29 driver_config_cache = e->next;
30 @@ -777,7 +787,11 @@ glXGetDriverConfig(const char *driverNam
31 driver_config_cache = e;
34 +#if defined(HAVE_NOATEXIT)
35 + e_next_ever_null = True;
37 atexit(clear_driver_config_cache);
41 pthread_mutex_unlock(&driver_config_mutex);