1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2025-10-22 13:11:25 +02:00
Files
.gitlab-ci
.reuse
LICENSES
docs
fuzzing
gio
girepository
glib
deprecated
dirent
glib-mirroring-tab
gnulib
libcharset
tests
docs.c
galloca.h
garcbox.c
garray.c
garray.h
gasyncqueue.c
gasyncqueue.h
gasyncqueueprivate.h
gatomic.c
gatomic.h
gbacktrace.c
gbacktrace.h
gbase64.c
gbase64.h
gbitlock.c
gbitlock.h
gbookmarkfile.c
gbookmarkfile.h
gbsearcharray.h
gbytes.c
gbytes.h
gcharset.c
gcharset.h
gcharsetprivate.h
gchecksum.c
gchecksum.h
gconstructor.h
gconstructorprivate.h
gconvert.c
gconvert.h
gconvertprivate.h
gdataset.c
gdataset.h
gdatasetprivate.h
gdate.c
gdate.h
gdatetime-private.c
gdatetime-private.h
gdatetime.c
gdatetime.h
gdir.c
gdir.h
gen-unicode-tables.pl
genviron.c
genviron.h
gerror.c
gerror.h
gfileutils.c
gfileutils.h
ggettext.c
ggettext.h
ghash.c
ghash.h
ghmac.c
ghmac.h
ghook.c
ghook.h
ghostutils.c
ghostutils.h
gi18n-lib.h
gi18n.h
giochannel.c
giochannel.h
giounix.c
giowin32.c
gjournal-private.c
gjournal-private.h
gkeyfile.c
gkeyfile.h
glib-autocleanups.h
glib-init.c
glib-init.h
glib-object.h
glib-private.c
glib-private.h
glib-typeof.h
glib-unix.c
glib-unix.h
glib-unixprivate.h
glib.h
glib.rc.in
glib.stp.in
glib_gdb.py
glib_probes.d
glib_trace.h
glibconfig.h.in
glibintl.h
glist.c
glist.h
gmacros.h
gmain-internal.h
gmain.c
gmain.h
gmappedfile.c
gmappedfile.h
gmarkup.c
gmarkup.h
gmem.c
gmem.h
gmessages.c
gmessages.h
gmirroringtable.h
gnode.c
gnode.h
goption.c
goption.h
gosxutils.m
gpathbuf.c
gpathbuf.h
gpattern.c
gpattern.h
gpoll.c
gpoll.h
gprimes.c
gprimes.h
gprintf.c
gprintf.h
gprintfint.h
gqsort.c
gqsort.h
gquark.c
gquark.h
gqueue.c
gqueue.h
grand.c
grand.h
grcbox.c
grcbox.h
grcboxprivate.h
grefcount.c
grefcount.h
grefstring.c
grefstring.h
gregex.c
gregex.h
gscanner.c
gscanner.h
gscripttable.h
gsequence.c
gsequence.h
gshell.c
gshell.h
gslice.c
gslice.h
gslist.c
gslist.h
gspawn-posix.c
gspawn-private.h
gspawn-win32-helper.c
gspawn-win32.c
gspawn.c
gspawn.h
gstdio-private.c
gstdio.c
gstdio.h
gstdioprivate.h
gstrfuncs.c
gstrfuncs.h
gstring.c
gstring.h
gstringchunk.c
gstringchunk.h
gstrvbuilder.c
gstrvbuilder.h
gtester-report.in
gtester.c
gtestutils.c
gtestutils.h
gthread-posix.c
gthread-win32.c
gthread.c
gthread.h
gthreadpool.c
gthreadpool.h
gthreadprivate.h
gtimer.c
gtimer.h
gtimezone.c
gtimezone.h
gtrace-private.h
gtrace.c
gtranslit-data.h
gtranslit.c
gtrashstack.c
gtrashstack.h
gtree.c
gtree.h
gtypes.h
gunibreak.c
gunibreak.h
gunichartables.h
gunicode.h
gunicodeprivate.h
gunicollate.c
gunicomp.h
gunidecomp.c
gunidecomp.h
guniprop.c
guri.c
guri.h
guriprivate.h
gutf8.c
gutils.c
gutils.h
gutilsprivate.h
guuid.c
guuid.h
gvalgrind.h
gvariant-core.c
gvariant-core.h
gvariant-internal.h
gvariant-parser.c
gvariant-serialiser.c
gvariant-serialiser.h
gvariant.c
gvariant.h
gvarianttype-private.h
gvarianttype.c
gvarianttype.h
gvarianttypeinfo.c
gvarianttypeinfo.h
gversion.c
gversion.h
gversionmacros.h.in
gwakeup.c
gwakeup.h
gwin32-private.c
gwin32.c
gwin32.h
libglib-gdb.py.in
meson.build
msvc_recommended_pragmas.h
update-gtranslit.py
valgrind.h
win_iconv.c
gmodule
gobject
gthread
m4macros
po
subprojects
tests
tools
.clang-format
.dir-locals.el
.editorconfig
.gitignore
.gitlab-ci.yml
.gitmodules
.lcovrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
INSTALL.md
NEWS
README.md
SECURITY.md
glib.doap
meson.build
meson.options
glib/glib/glib-private.c
Philip Withnall 2638f97b3e Merge branch 'th/weak-ref-lock-2' into 'main'
[th/weak-ref-lock-2] gobject: use per-object bit-lock instead of global RWLock for GWeakRef

Closes 

See merge request 
2024-01-31 16:51:50 +00:00

155 lines
4.8 KiB
C

/* GLIB - Library of useful routines for C programming
* Copyright (C) 2011 Red Hat, Inc.
*
* 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/>.
*
* Author: Colin Walters <walters@verbum.org>
*/
#include "config.h"
#include "glib-private.h"
#include "glib-init.h"
#include "gutilsprivate.h"
#include "gdatasetprivate.h"
#ifdef USE_INVALID_PARAMETER_HANDLER
#include <crtdbg.h>
#endif
/**
* glib__private__:
* @arg: Do not use this argument
*
* Do not call this function; it is used to share private
* API between glib, gobject, and gio.
*/
const GLibPrivateVTable *
glib__private__ (void)
{
static const GLibPrivateVTable table = {
g_wakeup_new,
g_wakeup_free,
g_wakeup_get_pollfd,
g_wakeup_signal,
g_wakeup_acknowledge,
g_get_worker_context,
g_check_setuid,
g_main_context_new_with_next_id,
g_dir_open_with_errno,
g_dir_new_from_dirp,
glib_init,
#ifdef G_OS_WIN32
g_win32_stat_utf8,
g_win32_lstat_utf8,
g_win32_readlink_utf8,
g_win32_fstat,
g_win32_find_helper_executable_path,
g_win32_reopen_noninherited,
g_win32_handle_is_socket,
#endif
g_win32_push_empty_invalid_parameter_handler,
g_win32_pop_invalid_parameter_handler,
g_find_program_for_path,
g_uri_get_default_scheme_port,
g_set_prgname_once,
g_datalist_id_update_atomic,
};
return &table;
}
#ifdef USE_INVALID_PARAMETER_HANDLER
/*
* This is the (empty) invalid parameter handler
* that is used for Visual C++ 2005 (and later) builds
* so that we can use this instead of the system automatically
* aborting the process, when calling _get_osfhandle(), isatty()
* and _commit() (via g_fsync()) and so on with an invalid file
* descriptor.
*
* This is necessary so that the gspawn helper and the test programs
* will continue to run as expected, since we are purposely or
* forced to use invalid FDs.
*
* Please see https://learn.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation?view=msvc-170
* for an explanation on this.
*/
static void
empty_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
unsigned int line,
uintptr_t pReserved)
{
}
/* fallback to _set_invalid_parameter_handler() if we don't have _set_thread_local_invalid_parameter_handler() */
#ifndef HAVE__SET_THREAD_LOCAL_INVALID_PARAMETER_HANDLER
# define _set_thread_local_invalid_parameter_handler _set_invalid_parameter_handler
#endif
#endif
/*
* g_win32_push_empty_invalid_parameter_handler:
* @handler: a possibly uninitialized GWin32InvalidParameterHandler
*/
void
g_win32_push_empty_invalid_parameter_handler (GWin32InvalidParameterHandler *handler)
{
#ifdef USE_INVALID_PARAMETER_HANDLER
/* use the empty invalid parameter handler to override the default invalid parameter_handler */
handler->pushed_handler = empty_invalid_parameter_handler;
handler->old_handler = _set_thread_local_invalid_parameter_handler (handler->pushed_handler);
/* Disable the message box for assertions. */
handler->pushed_report_mode = 0;
handler->prev_report_mode = _CrtSetReportMode(_CRT_ASSERT, handler->pushed_report_mode);
#endif
}
/*
* g_win32_pop_invalid_parameter_handler:
* @handler: a GWin32InvalidParameterHandler processed with
* g_win32_push_empty_invalid_parameter_handler()
*/
void
g_win32_pop_invalid_parameter_handler (GWin32InvalidParameterHandler *handler)
{
#ifdef USE_INVALID_PARAMETER_HANDLER
G_GNUC_UNUSED _invalid_parameter_handler popped_handler;
G_GNUC_UNUSED int popped_report_mode;
/* Restore previous/default invalid parameter handler, check the value returned matches the one we previously pushed */
popped_handler = _set_thread_local_invalid_parameter_handler (handler->old_handler);
g_return_if_fail (handler->pushed_handler == popped_handler);
/* Restore the message box for assertions, check the value returned matches the one we previously pushed */
popped_report_mode = _CrtSetReportMode(_CRT_ASSERT, handler->prev_report_mode);
g_return_if_fail (handler->pushed_report_mode == popped_report_mode);
#endif
}