mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
Merge branch 'threadpool-sched-getattr' into 'master'
Check for SYS_sched_getattr before using it unconditionally See merge request GNOME/glib!1325
This commit is contained in:
commit
457ea97c75
@ -68,7 +68,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(HAVE_SYS_SCHED_GETATTR)
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1167,7 +1167,7 @@ g_system_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_sett
|
|||||||
{
|
{
|
||||||
/* FIXME: Implement the same for macOS and the BSDs so it doesn't go through
|
/* FIXME: Implement the same for macOS and the BSDs so it doesn't go through
|
||||||
* the fallback code using an additional thread. */
|
* the fallback code using an additional thread. */
|
||||||
#if defined(__linux__)
|
#if defined(HAVE_SYS_SCHED_GETATTR)
|
||||||
pid_t tid;
|
pid_t tid;
|
||||||
int res;
|
int res;
|
||||||
/* FIXME: The struct definition does not seem to be possible to pull in
|
/* FIXME: The struct definition does not seem to be possible to pull in
|
||||||
@ -1210,7 +1210,7 @@ g_system_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_sett
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(HAVE_SYS_SCHED_GETATTR)
|
||||||
static void *
|
static void *
|
||||||
linux_pthread_proxy (void *data)
|
linux_pthread_proxy (void *data)
|
||||||
{
|
{
|
||||||
@ -1284,7 +1284,7 @@ g_system_thread_new (GThreadFunc proxy,
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_PTHREAD_ATTR_SETINHERITSCHED */
|
#endif /* HAVE_PTHREAD_ATTR_SETINHERITSCHED */
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(HAVE_SYS_SCHED_GETATTR)
|
||||||
ret = pthread_create (&thread->system_thread, &attr, linux_pthread_proxy, thread);
|
ret = pthread_create (&thread->system_thread, &attr, linux_pthread_proxy, thread);
|
||||||
#else
|
#else
|
||||||
ret = pthread_create (&thread->system_thread, &attr, (void* (*)(void*))proxy, thread);
|
ret = pthread_create (&thread->system_thread, &attr, (void* (*)(void*))proxy, thread);
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#ifndef __G_THREADPRIVATE_H__
|
#ifndef __G_THREADPRIVATE_H__
|
||||||
#define __G_THREADPRIVATE_H__
|
#define __G_THREADPRIVATE_H__
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "deprecated/gthread.h"
|
#include "deprecated/gthread.h"
|
||||||
|
|
||||||
typedef struct _GRealThread GRealThread;
|
typedef struct _GRealThread GRealThread;
|
||||||
@ -40,7 +42,8 @@ struct _GRealThread
|
|||||||
typedef struct _GThreadSchedulerSettings GThreadSchedulerSettings;
|
typedef struct _GThreadSchedulerSettings GThreadSchedulerSettings;
|
||||||
|
|
||||||
/* TODO: Add the same for macOS and the BSDs */
|
/* TODO: Add the same for macOS and the BSDs */
|
||||||
#if defined(__linux__)
|
#if defined(HAVE_SYS_SCHED_GETATTR)
|
||||||
|
/* This is for modern Linux */
|
||||||
struct _GThreadSchedulerSettings
|
struct _GThreadSchedulerSettings
|
||||||
{
|
{
|
||||||
struct sched_attr *attr;
|
struct sched_attr *attr;
|
||||||
|
@ -1730,6 +1730,11 @@ else
|
|||||||
if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix)
|
if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix)
|
||||||
glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
|
glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if cc.has_header_symbol('sys/syscall.h', 'SYS_sched_getattr,')
|
||||||
|
glib_conf.set('HAVE_SYS_SCHED_GETATTR', 1)
|
||||||
|
endif
|
||||||
|
|
||||||
# Assume that pthread_setname_np is available in some form; same as configure
|
# Assume that pthread_setname_np is available in some form; same as configure
|
||||||
if cc.links(pthread_prefix + '''
|
if cc.links(pthread_prefix + '''
|
||||||
int main() {
|
int main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user