[waffle] [PATCH 1/4] core: Refactor wcore_tinfo.c
Chad Versace
chad.versace at linux.intel.com
Thu Jul 11 00:12:43 PDT 2013
The refactor prepares for supporting environments without TLS and
introduces no behavioral change.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
src/waffle/core/wcore_tinfo.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/waffle/core/wcore_tinfo.c b/src/waffle/core/wcore_tinfo.c
index e40cb30..654802e 100644
--- a/src/waffle/core/wcore_tinfo.c
+++ b/src/waffle/core/wcore_tinfo.c
@@ -55,31 +55,32 @@ static __thread struct wcore_tinfo wcore_tinfo
#endif
;
+static void __attribute__((noreturn))
+wcore_tinfo_abort_init(void)
+{
+ printf("waffle: fatal-error: failed to initialize thread local info\n");
+ abort();
+}
+
static void
-wcore_tinfo_init(void)
+wcore_tinfo_init(struct wcore_tinfo *tinfo)
{
- assert(!wcore_tinfo.is_init);
+ if (tinfo->is_init)
+ return;
// FIXME: wcore_tinfo.error leaks at thread exit. To fix this, Waffle
// FIXME: needs a function like eglTerminate().
- wcore_tinfo.error = wcore_error_tinfo_create();
- if (!wcore_tinfo.error)
- goto error;
+ tinfo->error = wcore_error_tinfo_create();
+ if (!tinfo->error)
+ wcore_tinfo_abort_init();
- wcore_tinfo.is_init = true;
- return;
-
-error:
- printf("waffle: fatal-error: failed to initialize thread local info\n");
- abort();
+ tinfo->is_init = true;
}
struct wcore_tinfo*
wcore_tinfo_get(void)
{
- if (!wcore_tinfo.is_init)
- wcore_tinfo_init();
-
+ wcore_tinfo_init(&wcore_tinfo);
return &wcore_tinfo;
}
--
1.8.3.1
More information about the waffle
mailing list