mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/pcntl adding Pcntl namespace for Qos class.
Close GH-14892
This commit is contained in:
10
UPGRADING
10
UPGRADING
@@ -783,11 +783,11 @@ PHP 8.4 UPGRADE NOTES
|
||||
. X509_PURPOSE_TIMESTAMP_SIGN.
|
||||
|
||||
- PCNTL:
|
||||
. QosClass::Background (macOs only).
|
||||
. QosClass::Default (macOs only).
|
||||
. QosClass::UserInteractive (macOs only).
|
||||
. QosClass::UserInitiated (macOs only).
|
||||
. QosClass::Utility (macOs only).
|
||||
. Pcntl\QosClass::Background (macOs only).
|
||||
. Pcntl\QosClass::Default (macOs only).
|
||||
. Pctnl\QosClass::UserInteractive (macOs only).
|
||||
. Pcntl\QosClass::UserInitiated (macOs only).
|
||||
. Pcntl\QosClass::Utility (macOs only).
|
||||
. SIGCKPT (DragonFlyBSD only).
|
||||
. SIGCKPTEXIT (DragonFlyBSD only).
|
||||
. WEXITED.
|
||||
|
||||
@@ -123,7 +123,6 @@ typedef psetid_t cpu_set_t;
|
||||
|
||||
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
|
||||
#include <pthread/qos.h>
|
||||
static zend_class_entry *QosClass_ce;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PIDFD_OPEN
|
||||
@@ -144,6 +143,7 @@ static zend_class_entry *QosClass_ce;
|
||||
#include "Zend/zend_max_execution_timer.h"
|
||||
|
||||
#include "pcntl_arginfo.h"
|
||||
static zend_class_entry *QosClass_ce;
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(pcntl)
|
||||
static PHP_GINIT_FUNCTION(pcntl);
|
||||
@@ -212,9 +212,7 @@ PHP_RINIT_FUNCTION(pcntl)
|
||||
|
||||
PHP_MINIT_FUNCTION(pcntl)
|
||||
{
|
||||
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
|
||||
QosClass_ce = register_class_QosClass();
|
||||
#endif
|
||||
QosClass_ce = register_class_Pcntl_QosClass();
|
||||
register_pcntl_symbols(module_number);
|
||||
orig_interrupt_function = zend_interrupt_function;
|
||||
zend_interrupt_function = pcntl_interrupt_function;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
/* Wait Constants */
|
||||
|
||||
namespace
|
||||
{
|
||||
#ifdef WNOHANG
|
||||
/**
|
||||
* @var int
|
||||
@@ -995,120 +997,123 @@ const PCNTL_EUSERS = UNKNOWN;
|
||||
const PCNTL_ECAPMODE = UNKNOWN;
|
||||
#endif
|
||||
|
||||
function pcntl_fork(): int {}
|
||||
function pcntl_fork(): int {}
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* @param array $resource_usage
|
||||
*/
|
||||
function pcntl_waitpid(int $process_id, &$status, int $flags = 0, &$resource_usage = []): int {}
|
||||
/**
|
||||
* @param int $status
|
||||
* @param array $resource_usage
|
||||
*/
|
||||
function pcntl_waitpid(int $process_id, &$status, int $flags = 0, &$resource_usage = []): int {}
|
||||
|
||||
#if defined (HAVE_WAITID) && defined (HAVE_POSIX_IDTYPES) && defined (HAVE_DECL_WEXITED) && HAVE_DECL_WEXITED == 1
|
||||
/** @param array $info */
|
||||
function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $flags = WEXITED): bool {}
|
||||
/** @param array $info */
|
||||
function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $flags = WEXITED): bool {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* @param array $resource_usage
|
||||
*/
|
||||
function pcntl_wait(&$status, int $flags = 0, &$resource_usage = []): int {}
|
||||
/**
|
||||
* @param int $status
|
||||
* @param array $resource_usage
|
||||
*/
|
||||
function pcntl_wait(&$status, int $flags = 0, &$resource_usage = []): int {}
|
||||
|
||||
/** @param callable|int $handler */
|
||||
function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): bool {}
|
||||
/** @param callable|int $handler */
|
||||
function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): bool {}
|
||||
|
||||
/** @return callable|int */
|
||||
function pcntl_signal_get_handler(int $signal) {}
|
||||
/** @return callable|int */
|
||||
function pcntl_signal_get_handler(int $signal) {}
|
||||
|
||||
function pcntl_signal_dispatch(): bool {}
|
||||
function pcntl_signal_dispatch(): bool {}
|
||||
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
/** @param array $old_signals */
|
||||
function pcntl_sigprocmask(int $mode, array $signals, &$old_signals = null): bool {}
|
||||
function pcntl_sigprocmask(int $mode, array $signals, &$old_signals = null): bool {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRUCT_SIGINFO_T
|
||||
#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT))
|
||||
/** @param array $info */
|
||||
function pcntl_sigwaitinfo(array $signals, &$info = []): int|false {}
|
||||
/** @param array $info */
|
||||
function pcntl_sigwaitinfo(array $signals, &$info = []): int|false {}
|
||||
|
||||
/** @param array $info */
|
||||
function pcntl_sigtimedwait(array $signals, &$info = [], int $seconds = 0, int $nanoseconds = 0): int|false {}
|
||||
/** @param array $info */
|
||||
function pcntl_sigtimedwait(array $signals, &$info = [], int $seconds = 0, int $nanoseconds = 0): int|false {}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
function pcntl_wifexited(int $status): bool {}
|
||||
function pcntl_wifexited(int $status): bool {}
|
||||
|
||||
function pcntl_wifstopped(int $status): bool {}
|
||||
function pcntl_wifstopped(int $status): bool {}
|
||||
|
||||
#ifdef HAVE_WCONTINUED
|
||||
function pcntl_wifcontinued(int $status): bool {}
|
||||
#endif
|
||||
|
||||
function pcntl_wifsignaled(int $status): bool {}
|
||||
function pcntl_wifsignaled(int $status): bool {}
|
||||
|
||||
function pcntl_wexitstatus(int $status): int|false {}
|
||||
function pcntl_wexitstatus(int $status): int|false {}
|
||||
|
||||
function pcntl_wtermsig(int $status): int|false {}
|
||||
function pcntl_wtermsig(int $status): int|false {}
|
||||
|
||||
function pcntl_wstopsig(int $status): int|false {}
|
||||
function pcntl_wstopsig(int $status): int|false {}
|
||||
|
||||
function pcntl_exec(string $path, array $args = [], array $env_vars = []): bool {}
|
||||
function pcntl_exec(string $path, array $args = [], array $env_vars = []): bool {}
|
||||
|
||||
function pcntl_alarm(int $seconds): int {}
|
||||
function pcntl_alarm(int $seconds): int {}
|
||||
|
||||
function pcntl_get_last_error(): int {}
|
||||
function pcntl_get_last_error(): int {}
|
||||
|
||||
/** @alias pcntl_get_last_error */
|
||||
function pcntl_errno(): int {}
|
||||
/** @alias pcntl_get_last_error */
|
||||
function pcntl_errno(): int {}
|
||||
|
||||
#ifdef HAVE_GETPRIORITY
|
||||
function pcntl_getpriority(?int $process_id = null, int $mode = PRIO_PROCESS): int|false {}
|
||||
function pcntl_getpriority(?int $process_id = null, int $mode = PRIO_PROCESS): int|false {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETPRIORITY
|
||||
function pcntl_setpriority(int $priority, ?int $process_id = null, int $mode = PRIO_PROCESS): bool{}
|
||||
function pcntl_setpriority(int $priority, ?int $process_id = null, int $mode = PRIO_PROCESS): bool{}
|
||||
#endif
|
||||
|
||||
function pcntl_strerror(int $error_code): string {}
|
||||
function pcntl_strerror(int $error_code): string {}
|
||||
|
||||
function pcntl_async_signals(?bool $enable = null): bool {}
|
||||
function pcntl_async_signals(?bool $enable = null): bool {}
|
||||
|
||||
#ifdef HAVE_UNSHARE
|
||||
function pcntl_unshare(int $flags): bool {}
|
||||
function pcntl_unshare(int $flags): bool {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RFORK
|
||||
function pcntl_rfork(int $flags, int $signal = 0): int{}
|
||||
function pcntl_rfork(int $flags, int $signal = 0): int{}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FORKX
|
||||
function pcntl_forkx(int $flags): int{}
|
||||
function pcntl_forkx(int $flags): int{}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PIDFD_OPEN
|
||||
function pcntl_setns(?int $process_id = null, int $nstype = CLONE_NEWNET): bool {}
|
||||
function pcntl_setns(?int $process_id = null, int $nstype = CLONE_NEWNET): bool {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SCHED_SETAFFINITY
|
||||
function pcntl_getcpuaffinity(?int $process_id = null): array|false {}
|
||||
function pcntl_setcpuaffinity(?int $process_id = null, array $cpu_ids = []): bool {}
|
||||
function pcntl_getcpuaffinity(?int $process_id = null): array|false {}
|
||||
function pcntl_setcpuaffinity(?int $process_id = null, array $cpu_ids = []): bool {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SCHED_GETCPU
|
||||
function pcntl_getcpu(): int {}
|
||||
function pcntl_getcpu(): int {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP
|
||||
enum QosClass
|
||||
function pcntl_getqos_class(): Pcntl\QosClass {}
|
||||
function pcntl_setqos_class(Pcntl\QosClass $qos_class = Pcntl\QosClass::Default): void {}
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Pcntl
|
||||
{
|
||||
enum QosClass
|
||||
{
|
||||
case UserInteractive;
|
||||
case UserInitiated;
|
||||
case Default;
|
||||
case Utility;
|
||||
case Background;
|
||||
}
|
||||
}
|
||||
|
||||
function pcntl_getqos_class(): QosClass {}
|
||||
function pcntl_setqos_class(QosClass $qos_class = QosClass::Default): void {}
|
||||
#endif
|
||||
|
||||
16
ext/pcntl/pcntl_arginfo.h
generated
16
ext/pcntl/pcntl_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 71d0cbd8d2b1ae57d289ec421e9dcaa4040d857b */
|
||||
* Stub hash: 897062ad1dfe06326e561429509360174820379e */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
@@ -167,13 +167,13 @@ ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_pcntl_getqos_class, 0, 0, QosClass, 0)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_pcntl_getqos_class, 0, 0, Pcntl\\QosClass, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_setqos_class, 0, 0, IS_VOID, 0)
|
||||
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, qos_class, QosClass, 0, "QosClass::Default")
|
||||
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, qos_class, Pcntl\\QosClass, 0, "Pcntl\\QosClass::Default")
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
@@ -313,11 +313,9 @@ static const zend_function_entry ext_functions[] = {
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
|
||||
static const zend_function_entry class_QosClass_methods[] = {
|
||||
static const zend_function_entry class_Pcntl_QosClass_methods[] = {
|
||||
ZEND_FE_END
|
||||
};
|
||||
#endif
|
||||
|
||||
static void register_pcntl_symbols(int module_number)
|
||||
{
|
||||
@@ -712,10 +710,9 @@ static void register_pcntl_symbols(int module_number)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
|
||||
static zend_class_entry *register_class_QosClass(void)
|
||||
static zend_class_entry *register_class_Pcntl_QosClass(void)
|
||||
{
|
||||
zend_class_entry *class_entry = zend_register_internal_enum("QosClass", IS_UNDEF, class_QosClass_methods);
|
||||
zend_class_entry *class_entry = zend_register_internal_enum("Pcntl\\QosClass", IS_UNDEF, class_Pcntl_QosClass_methods);
|
||||
|
||||
zend_enum_add_case_cstr(class_entry, "UserInteractive", NULL);
|
||||
|
||||
@@ -729,4 +726,3 @@ static zend_class_entry *register_class_QosClass(void)
|
||||
|
||||
return class_entry;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,10 +9,10 @@ if (getenv('SKIP_REPEAT')) die("skip Not repeatable");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
pcntl_setqos_class(QosClass::Default);
|
||||
var_dump(QosClass::Default === pcntl_getqos_class());
|
||||
pcntl_setqos_class(QosClass::Background);
|
||||
var_dump(QosClass::Background == pcntl_getqos_class());
|
||||
pcntl_setqos_class(Pcntl\QosClass::Default);
|
||||
var_dump(Pcntl\QosClass::Default === pcntl_getqos_class());
|
||||
pcntl_setqos_class(Pcntl\QosClass::Background);
|
||||
var_dump(Pcntl\QosClass::Background == pcntl_getqos_class());
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
|
||||
Reference in New Issue
Block a user