From 7e9ffb6b095fff756dec717f337e6a6aa42dd208 Mon Sep 17 00:00:00 2001 From: "P. F. Chimento" Date: Mon, 22 Apr 2013 13:43:11 +0200 Subject: Rename C source and header files For consistency with GTK, blah.[ch] should be named eosblah.[ch]. [#23] --- endless/eosinit.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 endless/eosinit.c (limited to 'endless/eosinit.c') diff --git a/endless/eosinit.c b/endless/eosinit.c new file mode 100644 index 0000000..fadc9b4 --- /dev/null +++ b/endless/eosinit.c @@ -0,0 +1,53 @@ +/* Copyright 2013 Endless Mobile, Inc. */ + +#include +#include +#include + +#include "eosinit-private.h" + +/* Constructors supported since GCC 2.7; I have this on GLib's authority. This +should also work on Clang. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) + +#define _EOS_CONSTRUCTOR(func) static void __attribute__((constructor)) func (void); +#define _EOS_DESTRUCTOR(func) static void __atrribute__((destructor)) func (void); + +#else + +#error "We do not currently support constructors for your compiler." + +#endif /* compiler version */ + +static gboolean _eos_initialized = FALSE; + +/* + * _eos_init: + * + * This function initializes the library. It is called automatically when the + * library is loaded. + */ +_EOS_CONSTRUCTOR(_eos_init); +static void +_eos_init (void) +{ + if (G_UNLIKELY (!_eos_initialized)) + { + /* Initialize Gettext */ + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + + _eos_initialized = TRUE; + } +} + +/* + * eos_is_inited: + * + * For testing purposes. + */ +gboolean +eos_is_inited (void) +{ + return _eos_initialized; +} -- cgit v1.2.3