#include <gio/gio.h>

#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
# define SECTION __attribute__ ((section (".gresource.gtk"), aligned (8)))
#else
# define SECTION
#endif

static const SECTION union { const guint8 data[797]; const double alignment; void * const ptr;}  gtk_resource_data = {
  "\107\126\141\162\151\141\156\164\000\000\000\000\000\000\000\000"
  "\030\000\000\000\310\000\000\000\000\000\000\050\006\000\000\000"
  "\000\000\000\000\001\000\000\000\002\000\000\000\005\000\000\000"
  "\005\000\000\000\005\000\000\000\322\055\374\355\002\000\000\000"
  "\310\000\000\000\017\000\166\000\330\000\000\000\350\002\000\000"
  "\113\120\220\013\004\000\000\000\350\002\000\000\004\000\114\000"
  "\354\002\000\000\360\002\000\000\016\107\266\230\005\000\000\000"
  "\360\002\000\000\004\000\114\000\364\002\000\000\370\002\000\000"
  "\260\267\044\060\001\000\000\000\370\002\000\000\006\000\114\000"
  "\000\003\000\000\004\003\000\000\324\265\002\000\377\377\377\377"
  "\004\003\000\000\001\000\114\000\010\003\000\000\014\003\000\000"
  "\031\154\341\353\003\000\000\000\014\003\000\000\011\000\114\000"
  "\030\003\000\000\034\003\000\000\150\145\154\160\055\157\166\145"
  "\162\154\141\171\056\165\151\000\340\022\000\000\001\000\000\000"
  "\170\332\335\230\121\157\323\060\020\200\337\367\053\054\077\354"
  "\255\224\302\003\110\113\062\041\120\313\003\124\205\166\114\074"
  "\115\256\163\115\114\035\073\330\227\244\375\367\070\112\052\272"
  "\066\355\244\315\102\045\157\261\357\316\167\376\316\071\137\022"
  "\334\156\062\111\112\060\126\150\025\322\321\253\327\224\200\342"
  "\072\026\052\011\351\335\142\074\170\117\157\243\253\100\050\004"
  "\263\142\034\242\053\102\002\275\374\005\034\011\227\314\332\220"
  "\116\160\075\117\265\101\136\240\275\027\052\326\025\045\042\016"
  "\151\012\062\177\320\156\155\311\266\264\266\163\226\271\321\071"
  "\030\334\022\305\062\010\151\246\143\046\151\264\060\005\004\303"
  "\235\254\125\345\251\220\161\363\174\326\345\334\315\273\340\351"
  "\116\365\330\213\155\064\006\365\210\106\166\147\170\350\261\063"
  "\100\266\031\244\040\222\024\151\064\172\327\151\361\050\316\047"
  "\142\235\030\135\344\164\137\371\330\045\012\224\100\011\032\246"
  "\254\144\310\226\322\115\156\301\122\302\265\313\302\006\335\206"
  "\332\365\110\325\340\216\046\240\300\060\331\025\137\167\214\117"
  "\061\155\037\350\241\215\237\160\247\120\021\050\101\341\251\200"
  "\273\034\061\316\101\272\135\242\066\064\272\226\170\063\063\042"
  "\143\146\173\235\340\315\364\364\102\301\260\331\346\001\221\141"
  "\007\222\113\303\364\121\152\013\355\310\027\251\157\275\044\065"
  "\007\146\170\352\213\321\270\237\214\122\135\221\272\046\077\033"
  "\323\170\324\127\060\247\057\204\347\234\237\337\005\330\372\302"
  "\361\100\353\130\361\110\351\042\056\240\051\053\105\302\316\155"
  "\372\322\262\076\321\144\311\370\372\105\071\377\040\261\316\367"
  "\027\130\041\231\261\004\036\356\362\136\276\041\216\325\112\233"
  "\212\231\330\007\256\357\165\073\325\360\372\244\053\325\337\142"
  "\213\256\273\335\372\040\126\143\042\007\105\146\101\076\353\014"
  "\172\011\157\352\246\111\051\300\133\323\323\357\263\066\063\120"
  "\012\135\130\377\310\274\224\263\377\345\012\373\161\206\336\245"
  "\245\374\036\140\375\362\164\267\325\245\237\135\335\127\047\111"
  "\275\061\172\323\113\106\077\335\147\223\067\104\157\377\105\255"
  "\170\254\260\047\374\053\010\206\173\077\253\376\000\343\047\231"
  "\140\000\050\165\165\141\171\051\157\162\147\057\003\000\000\000"
  "\147\164\153\057\000\000\000\000\147\156\157\155\145\057\000\000"
  "\005\000\000\000\057\000\000\000\001\000\000\000\143\141\154\145"
  "\156\144\141\162\057\000\000\000\002\000\000\000" };

static GStaticResource static_resource = { gtk_resource_data.data, sizeof (gtk_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };

G_GNUC_INTERNAL
GResource *gtk_get_resource (void);
GResource *gtk_get_resource (void)
{
  return g_static_resource_get_resource (&static_resource);
}
/* GLIB - Library of useful routines for C programming
 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
 * file for a list of people on the GLib Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GLib at ftp://ftp.gtk.org/pub/gtk/.
 */

#ifndef __G_CONSTRUCTOR_H__
#define __G_CONSTRUCTOR_H__

/*
  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
  destructors, in a usable way, including e.g. on library unload. If not you're on
  your own.

  Some compilers need #pragma to handle this, which does not work with macros,
  so the way you need to use this is (for constructors):

  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
  #endif
  G_DEFINE_CONSTRUCTOR(my_constructor)
  static void my_constructor(void) {
   ...
  }

*/

#ifndef __GTK_DOC_IGNORE__

#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)

#define G_HAS_CONSTRUCTORS 1

#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);

#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
/* Visual studio 2008 and later has _Pragma */

/*
 * Only try to include gslist.h if not already included via glib.h,
 * so that items using gconstructor.h outside of GLib (such as
 * GResources) continue to build properly.
 */
#ifndef __G_LIB_H__
#include "gslist.h"
#endif

#include <stdlib.h>

#define G_HAS_CONSTRUCTORS 1

/* We do some weird things to avoid the constructors being optimized
 * away on VS2015 if WholeProgramOptimization is enabled. First we
 * make a reference to the array from the wrapper to make sure its
 * references. Then we use a pragma to make sure the wrapper function
 * symbol is always included at the link stage. Also, the symbols
 * need to be extern (but not dllexport), even though they are not
 * really used from another object file.
 */

/* We need to account for differences between the mangling of symbols
 * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
 * with an underscore but symbols on x64/ARM/ARM64 are not.
 */
#ifdef _M_IX86
#define G_MSVC_SYMBOL_PREFIX "_"
#else
#define G_MSVC_SYMBOL_PREFIX ""
#endif

#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)

#define G_MSVC_CTOR(_func,_sym_prefix) \
  static void _func(void); \
  extern int (* _array ## _func)(void);              \
  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
  __pragma(section(".CRT$XCU",read)) \
  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;

#define G_MSVC_DTOR(_func,_sym_prefix) \
  static void _func(void); \
  extern int (* _array ## _func)(void);              \
  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
  __pragma(section(".CRT$XCU",read)) \
  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;

#elif defined (_MSC_VER)

#define G_HAS_CONSTRUCTORS 1

/* Pre Visual studio 2008 must use #pragma section */
#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1

#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
  section(".CRT$XCU",read)
#define G_DEFINE_CONSTRUCTOR(_func) \
  static void _func(void); \
  static int _func ## _wrapper(void) { _func(); return 0; } \
  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;

#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
  section(".CRT$XCU",read)
#define G_DEFINE_DESTRUCTOR(_func) \
  static void _func(void); \
  static int _func ## _constructor(void) { atexit (_func); return 0; } \
  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;

#elif defined(__SUNPRO_C)

/* This is not tested, but i believe it should work, based on:
 * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
 */

#define G_HAS_CONSTRUCTORS 1

#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1

#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
  init(_func)
#define G_DEFINE_CONSTRUCTOR(_func) \
  static void _func(void);

#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
  fini(_func)
#define G_DEFINE_DESTRUCTOR(_func) \
  static void _func(void);

#else

/* constructors not supported for this compiler */

#endif

#endif /* __GTK_DOC_IGNORE__ */
#endif /* __G_CONSTRUCTOR_H__ */

#ifdef G_HAS_CONSTRUCTORS

#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(gtkresource_constructor)
#endif
G_DEFINE_CONSTRUCTOR(gtkresource_constructor)
#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(gtkresource_destructor)
#endif
G_DEFINE_DESTRUCTOR(gtkresource_destructor)

#else
#warning "Constructor not supported on this compiler, linking in resources will not work"
#endif

static void gtkresource_constructor (void)
{
  g_static_resource_init (&static_resource);
}

static void gtkresource_destructor (void)
{
  g_static_resource_fini (&static_resource);
}
