/* _UnitInternals.c generated by valac 0.56.19, the Vala compiler
 * generated from _UnitInternals.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 *
 * Auto-generated file.  Do not modify!
 */

#include <glib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

VALA_EXTERN gint unit__unit_init_count;
gint unit__unit_init_count = 0;

VALA_EXTERN void unit_init_entry (GError** error);
VALA_EXTERN void unit_init (GError** error);
VALA_EXTERN void unit_terminate_entry (void);
VALA_EXTERN void unit_terminate (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
unit_init_entry (GError** error)
{
	gint _tmp0_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = unit__unit_init_count;
	unit__unit_init_count = _tmp0_ + 1;
	if (_tmp0_ != 0) {
		return;
	}
	unit_init (&_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

void
unit_terminate_entry (void)
{
	gboolean _tmp0_ = FALSE;
	if (unit__unit_init_count == 0) {
		_tmp0_ = TRUE;
	} else {
		gint _tmp1_;
		unit__unit_init_count = unit__unit_init_count - 1;
		_tmp1_ = unit__unit_init_count;
		_tmp0_ = _tmp1_ != 0;
	}
	if (_tmp0_) {
		return;
	}
	unit_terminate ();
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

