Skip to content
Snippets Groups Projects
Commit 201c4ace authored by Simon McVittie's avatar Simon McVittie
Browse files

Provide compatibility versions of g_clear_pointer(), g_steal_pointer()


This is necessary to be able to compile on SteamRT 1 'scout'.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 1ed792d0
Branches
Tags
1 merge request!5Finish initial check-gl: add to packaging, and be compatible with SteamRT 1 'scout'
......@@ -91,6 +91,8 @@
#include <GL/gl.h>
#include <GL/glx.h>
#include "steam-runtime-tools/glib-compat.h"
#include "gnome-session-check-accelerated-common.h"
#define SIZE_UNSET 0
......
......@@ -35,6 +35,8 @@
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>
#include "steam-runtime-tools/glib-compat.h"
#include "gnome-session-check-accelerated-common.h"
static char *
......
......@@ -37,6 +37,7 @@ x11_dep = dependency('x11')
executable(
multiarch + '-check-gl',
'check-gl.c',
include_directories : project_include_dirs,
install : true,
install_dir : join_paths(
get_option('libexecdir'),
......@@ -52,6 +53,7 @@ executable(
executable(
multiarch + '-check-gles',
'check-gles.c',
include_directories : project_include_dirs,
install : true,
install_dir : join_paths(
get_option('libexecdir'),
......
/*
* Copyright © 2019 Collabora Ltd.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include <glib.h>
#if !GLIB_CHECK_VERSION(2, 44, 0)
#define g_steal_pointer(x) _srt_steal_pointer (x)
/* A simplified version of g_steal_pointer without type-safety. */
static inline gpointer
_srt_steal_pointer (gpointer pointer_to_pointer)
{
gpointer *pp = pointer_to_pointer;
gpointer ret;
ret = *pp;
*pp = NULL;
return ret;
}
#endif
#if !GLIB_CHECK_VERSION(2, 34, 0)
#define g_clear_pointer(x, destroy) _srt_clear_pointer (x, destroy)
/* A simplified version of g_clear_pointer without type-safety. */
static inline void
_srt_clear_pointer (gpointer pointer_to_pointer,
GDestroyNotify destroy)
{
gpointer *pp = pointer_to_pointer;
gpointer p = g_steal_pointer (pp);
if (p != NULL)
destroy (p);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment