#include <gio/gio.h>

#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
# define SECTION __attribute__ ((section (".gresource.io"), aligned (sizeof(void *) > 8 ? sizeof(void *) : 8)))
#else
# define SECTION
#endif

static const SECTION union { const guint8 data[605]; const double alignment; void * const ptr;}  io_resource_data = {
  "\107\126\141\162\151\141\156\164\000\000\000\000\000\000\000\000"
  "\030\000\000\000\254\000\000\000\000\000\000\050\005\000\000\000"
  "\000\000\000\000\002\000\000\000\002\000\000\000\003\000\000\000"
  "\004\000\000\000\240\342\141\216\004\000\000\000\254\000\000\000"
  "\013\000\114\000\270\000\000\000\274\000\000\000\324\265\002\000"
  "\377\377\377\377\274\000\000\000\001\000\114\000\300\000\000\000"
  "\304\000\000\000\026\267\013\121\003\000\000\000\304\000\000\000"
  "\017\000\166\000\330\000\000\000\106\002\000\000\253\153\362\161"
  "\000\000\000\000\106\002\000\000\011\000\114\000\120\002\000\000"
  "\124\002\000\000\173\242\170\174\001\000\000\000\124\002\000\000"
  "\003\000\114\000\130\002\000\000\134\002\000\000\145\154\145\155"
  "\145\156\164\141\162\171\057\000\003\000\000\000\057\000\000\000"
  "\004\000\000\000\101\160\160\154\151\143\141\164\151\157\156\056"
  "\143\163\163\000\000\000\000\000\302\002\000\000\001\000\000\000"
  "\170\332\205\222\117\113\304\100\014\305\357\375\024\101\057\272"
  "\354\264\165\025\304\172\021\024\104\130\101\360\342\115\322\151"
  "\154\303\116\047\145\046\335\165\025\277\273\335\372\147\105\121"
  "\347\064\044\357\367\136\062\114\066\111\140\002\347\322\255\003"
  "\327\215\302\054\077\070\066\263\174\166\004\344\250\045\257\030"
  "\326\123\270\362\066\205\275\106\265\213\105\226\155\073\051\313"
  "\376\206\277\275\271\270\063\163\266\344\043\231\253\152\150\362"
  "\003\123\050\140\176\171\063\067\207\151\156\304\273\365\240\314"
  "\222\044\233\300\065\056\010\142\037\010\224\102\313\036\035\224"
  "\150\027\165\220\336\127\140\321\103\037\011\254\070\011\021\126"
  "\254\015\240\353\032\334\340\351\007\141\126\354\053\131\245\137"
  "\300\347\004\206\263\055\230\321\241\000\015\350\143\207\141\030"
  "\353\064\171\111\376\362\110\133\174\344\226\237\250\232\376\051"
  "\123\166\364\173\340\156\236\347\143\222\212\270\022\303\222\151"
  "\005\201\226\204\216\102\252\322\231\241\010\015\141\105\141\163"
  "\373\356\123\300\131\131\337\217\146\243\315\122\311\174\276\324"
  "\233\270\303\252\142\137\027\220\303\111\367\370\266\326\010\230"
  "\262\127\025\017\001\053\226\167\261\251\165\141\330\212\067\261"
  "\301\141\223\002\274\170\372\011\245\266\217\052\355\157\254\364"
  "\301\122\261\255\150\063\374\203\275\035\307\121\315\060\216\211"
  "\353\266\024\307\166\147\377\037\353\302\066\144\027\237\017\370"
  "\177\304\250\067\150\225\227\364\075\346\025\075\017\355\044\000"
  "\050\165\165\141\171\051\164\145\162\155\151\156\141\154\057\000"
  "\002\000\000\000\151\157\057\000\000\000\000\000" };

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

G_GNUC_INTERNAL
GResource *io_get_resource (void);
GResource *io_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)

/*
 * 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);              \
  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);              \
  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(__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(ioresource_constructor)
#endif
G_DEFINE_CONSTRUCTOR(ioresource_constructor)
#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(ioresource_destructor)
#endif
G_DEFINE_DESTRUCTOR(ioresource_destructor)

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

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

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