#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[789]; 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\335\002\000\000"
  "\113\120\220\013\004\000\000\000\335\002\000\000\004\000\114\000"
  "\344\002\000\000\350\002\000\000\016\107\266\230\005\000\000\000"
  "\350\002\000\000\004\000\114\000\354\002\000\000\360\002\000\000"
  "\260\267\044\060\001\000\000\000\360\002\000\000\006\000\114\000"
  "\370\002\000\000\374\002\000\000\324\265\002\000\377\377\377\377"
  "\374\002\000\000\001\000\114\000\000\003\000\000\004\003\000\000"
  "\031\154\341\353\003\000\000\000\004\003\000\000\011\000\114\000"
  "\020\003\000\000\024\003\000\000\150\145\154\160\055\157\166\145"
  "\162\154\141\171\056\165\151\000\275\021\000\000\001\000\000\000"
  "\170\332\335\230\121\157\332\060\020\200\337\373\053\054\077\364"
  "\215\061\366\262\111\015\251\246\116\260\207\015\261\101\327\307"
  "\312\070\107\342\341\330\231\175\111\310\277\237\243\004\215\102"
  "\240\122\153\125\054\157\266\357\316\167\376\316\071\237\022\334"
  "\156\123\111\012\060\126\150\065\246\243\167\357\051\001\305\165"
  "\044\124\074\246\367\313\311\340\023\275\015\257\002\241\020\314"
  "\232\161\010\257\010\011\364\352\067\160\044\134\062\153\307\164"
  "\212\233\105\242\015\362\034\355\203\120\221\056\051\021\321\230"
  "\046\040\263\107\355\366\226\254\242\265\235\263\314\214\316\300"
  "\140\105\024\113\141\114\123\035\061\111\303\245\311\041\030\356"
  "\144\255\052\117\204\214\232\361\131\227\013\267\356\202\247\073"
  "\325\143\057\266\321\030\324\063\032\332\235\341\241\307\316\000"
  "\331\166\220\200\210\023\244\341\350\143\247\305\223\070\237\211"
  "\165\152\164\236\321\175\345\143\227\050\120\002\045\150\230\262"
  "\222\041\133\111\267\130\201\245\204\153\227\205\055\272\003\265"
  "\373\221\262\301\035\116\101\201\141\262\053\276\356\030\237\143"
  "\332\016\350\241\215\237\160\147\120\022\050\100\341\251\200\273"
  "\034\061\316\101\272\123\242\066\064\274\226\170\063\067\042\145"
  "\246\272\216\361\146\166\172\243\140\330\034\363\200\310\260\003"
  "\311\245\141\272\223\332\102\073\363\105\352\107\057\111\055\200"
  "\031\236\370\142\064\351\047\243\104\227\244\256\311\057\306\064"
  "\031\365\025\314\351\007\341\045\367\347\117\016\266\176\160\074"
  "\320\072\126\074\122\272\210\007\150\306\012\021\263\163\207\276"
  "\264\254\117\065\131\061\276\171\125\316\077\113\254\363\375\015"
  "\326\110\346\054\206\307\373\254\227\137\210\143\265\326\246\144"
  "\046\362\201\353\147\335\116\065\274\276\350\122\365\267\330\242"
  "\353\156\053\037\304\152\114\344\240\310\054\311\127\235\102\057"
  "\341\315\334\062\051\004\170\153\172\372\175\327\346\006\012\241"
  "\163\353\037\231\227\162\366\277\074\141\277\316\320\273\264\224"
  "\077\000\154\136\237\356\266\272\364\263\253\373\356\044\211\067"
  "\106\037\336\342\103\170\252\260\047\374\047\010\206\173\177\142"
  "\376\002\202\275\104\325\000\050\165\165\141\171\051\157\162\147"
  "\057\000\000\000\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
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 * 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);
}
