Skip to content

Commit 17cf7b3

Browse files
committed
ext/pcntl adding Pcntl namespace for Qos class.
Close phpGH-14892
1 parent 71defce commit 17cf7b3

File tree

5 files changed

+73
-74
lines changed

5 files changed

+73
-74
lines changed

Diff for: UPGRADING

+5-5
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,11 @@ PHP 8.4 UPGRADE NOTES
783783
. X509_PURPOSE_TIMESTAMP_SIGN.
784784

785785
- PCNTL:
786-
. QosClass::Background (macOs only).
787-
. QosClass::Default (macOs only).
788-
. QosClass::UserInteractive (macOs only).
789-
. QosClass::UserInitiated (macOs only).
790-
. QosClass::Utility (macOs only).
786+
. Pcntl\QosClass::Background (macOs only).
787+
. Pcntl\QosClass::Default (macOs only).
788+
. Pctnl\QosClass::UserInteractive (macOs only).
789+
. Pcntl\QosClass::UserInitiated (macOs only).
790+
. Pcntl\QosClass::Utility (macOs only).
791791
. SIGCKPT (DragonFlyBSD only).
792792
. SIGCKPTEXIT (DragonFlyBSD only).
793793
. WEXITED.

Diff for: ext/pcntl/pcntl.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ typedef psetid_t cpu_set_t;
123123

124124
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
125125
#include <pthread/qos.h>
126-
static zend_class_entry *QosClass_ce;
127126
#endif
128127

129128
#ifdef HAVE_PIDFD_OPEN
@@ -144,6 +143,7 @@ static zend_class_entry *QosClass_ce;
144143
#include "Zend/zend_max_execution_timer.h"
145144

146145
#include "pcntl_arginfo.h"
146+
static zend_class_entry *QosClass_ce;
147147

148148
ZEND_DECLARE_MODULE_GLOBALS(pcntl)
149149
static PHP_GINIT_FUNCTION(pcntl);
@@ -212,9 +212,7 @@ PHP_RINIT_FUNCTION(pcntl)
212212

213213
PHP_MINIT_FUNCTION(pcntl)
214214
{
215-
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
216-
QosClass_ce = register_class_QosClass();
217-
#endif
215+
QosClass_ce = register_class_Pcntl_QosClass();
218216
register_pcntl_symbols(module_number);
219217
orig_interrupt_function = zend_interrupt_function;
220218
zend_interrupt_function = pcntl_interrupt_function;

Diff for: ext/pcntl/pcntl.stub.php

+56-51
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
/* Wait Constants */
66

7+
namespace
8+
{
79
#ifdef WNOHANG
810
/**
911
* @var int
@@ -995,120 +997,123 @@
995997
const PCNTL_ECAPMODE = UNKNOWN;
996998
#endif
997999

998-
function pcntl_fork(): int {}
1000+
function pcntl_fork(): int {}
9991001

1000-
/**
1001-
* @param int $status
1002-
* @param array $resource_usage
1003-
*/
1004-
function pcntl_waitpid(int $process_id, &$status, int $flags = 0, &$resource_usage = []): int {}
1002+
/**
1003+
* @param int $status
1004+
* @param array $resource_usage
1005+
*/
1006+
function pcntl_waitpid(int $process_id, &$status, int $flags = 0, &$resource_usage = []): int {}
10051007

10061008
#if defined (HAVE_WAITID) && defined (HAVE_POSIX_IDTYPES) && defined (HAVE_DECL_WEXITED) && HAVE_DECL_WEXITED == 1
1007-
/** @param array $info */
1008-
function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $flags = WEXITED): bool {}
1009+
/** @param array $info */
1010+
function pcntl_waitid(int $idtype = P_ALL, ?int $id = null, &$info = [], int $flags = WEXITED): bool {}
10091011
#endif
10101012

1011-
/**
1012-
* @param int $status
1013-
* @param array $resource_usage
1014-
*/
1015-
function pcntl_wait(&$status, int $flags = 0, &$resource_usage = []): int {}
1013+
/**
1014+
* @param int $status
1015+
* @param array $resource_usage
1016+
*/
1017+
function pcntl_wait(&$status, int $flags = 0, &$resource_usage = []): int {}
10161018

1017-
/** @param callable|int $handler */
1018-
function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): bool {}
1019+
/** @param callable|int $handler */
1020+
function pcntl_signal(int $signal, $handler, bool $restart_syscalls = true): bool {}
10191021

1020-
/** @return callable|int */
1021-
function pcntl_signal_get_handler(int $signal) {}
1022+
/** @return callable|int */
1023+
function pcntl_signal_get_handler(int $signal) {}
10221024

1023-
function pcntl_signal_dispatch(): bool {}
1025+
function pcntl_signal_dispatch(): bool {}
10241026

10251027
#ifdef HAVE_SIGPROCMASK
10261028
/** @param array $old_signals */
1027-
function pcntl_sigprocmask(int $mode, array $signals, &$old_signals = null): bool {}
1029+
function pcntl_sigprocmask(int $mode, array $signals, &$old_signals = null): bool {}
10281030
#endif
10291031

10301032
#ifdef HAVE_STRUCT_SIGINFO_T
10311033
#if (defined(HAVE_SIGWAITINFO) && defined(HAVE_SIGTIMEDWAIT))
1032-
/** @param array $info */
1033-
function pcntl_sigwaitinfo(array $signals, &$info = []): int|false {}
1034+
/** @param array $info */
1035+
function pcntl_sigwaitinfo(array $signals, &$info = []): int|false {}
10341036

1035-
/** @param array $info */
1036-
function pcntl_sigtimedwait(array $signals, &$info = [], int $seconds = 0, int $nanoseconds = 0): int|false {}
1037+
/** @param array $info */
1038+
function pcntl_sigtimedwait(array $signals, &$info = [], int $seconds = 0, int $nanoseconds = 0): int|false {}
10371039
#endif
10381040
#endif
10391041

1040-
function pcntl_wifexited(int $status): bool {}
1042+
function pcntl_wifexited(int $status): bool {}
10411043

1042-
function pcntl_wifstopped(int $status): bool {}
1044+
function pcntl_wifstopped(int $status): bool {}
10431045

10441046
#ifdef HAVE_WCONTINUED
10451047
function pcntl_wifcontinued(int $status): bool {}
10461048
#endif
10471049

1048-
function pcntl_wifsignaled(int $status): bool {}
1050+
function pcntl_wifsignaled(int $status): bool {}
10491051

1050-
function pcntl_wexitstatus(int $status): int|false {}
1052+
function pcntl_wexitstatus(int $status): int|false {}
10511053

1052-
function pcntl_wtermsig(int $status): int|false {}
1054+
function pcntl_wtermsig(int $status): int|false {}
10531055

1054-
function pcntl_wstopsig(int $status): int|false {}
1056+
function pcntl_wstopsig(int $status): int|false {}
10551057

1056-
function pcntl_exec(string $path, array $args = [], array $env_vars = []): bool {}
1058+
function pcntl_exec(string $path, array $args = [], array $env_vars = []): bool {}
10571059

1058-
function pcntl_alarm(int $seconds): int {}
1060+
function pcntl_alarm(int $seconds): int {}
10591061

1060-
function pcntl_get_last_error(): int {}
1062+
function pcntl_get_last_error(): int {}
10611063

1062-
/** @alias pcntl_get_last_error */
1063-
function pcntl_errno(): int {}
1064+
/** @alias pcntl_get_last_error */
1065+
function pcntl_errno(): int {}
10641066

10651067
#ifdef HAVE_GETPRIORITY
1066-
function pcntl_getpriority(?int $process_id = null, int $mode = PRIO_PROCESS): int|false {}
1068+
function pcntl_getpriority(?int $process_id = null, int $mode = PRIO_PROCESS): int|false {}
10671069
#endif
10681070

10691071
#ifdef HAVE_SETPRIORITY
1070-
function pcntl_setpriority(int $priority, ?int $process_id = null, int $mode = PRIO_PROCESS): bool{}
1072+
function pcntl_setpriority(int $priority, ?int $process_id = null, int $mode = PRIO_PROCESS): bool{}
10711073
#endif
10721074

1073-
function pcntl_strerror(int $error_code): string {}
1075+
function pcntl_strerror(int $error_code): string {}
10741076

1075-
function pcntl_async_signals(?bool $enable = null): bool {}
1077+
function pcntl_async_signals(?bool $enable = null): bool {}
10761078

10771079
#ifdef HAVE_UNSHARE
1078-
function pcntl_unshare(int $flags): bool {}
1080+
function pcntl_unshare(int $flags): bool {}
10791081
#endif
10801082

10811083
#ifdef HAVE_RFORK
1082-
function pcntl_rfork(int $flags, int $signal = 0): int{}
1084+
function pcntl_rfork(int $flags, int $signal = 0): int{}
10831085
#endif
10841086

10851087
#ifdef HAVE_FORKX
1086-
function pcntl_forkx(int $flags): int{}
1088+
function pcntl_forkx(int $flags): int{}
10871089
#endif
10881090

10891091
#ifdef HAVE_PIDFD_OPEN
1090-
function pcntl_setns(?int $process_id = null, int $nstype = CLONE_NEWNET): bool {}
1092+
function pcntl_setns(?int $process_id = null, int $nstype = CLONE_NEWNET): bool {}
10911093
#endif
10921094

10931095
#ifdef HAVE_SCHED_SETAFFINITY
1094-
function pcntl_getcpuaffinity(?int $process_id = null): array|false {}
1095-
function pcntl_setcpuaffinity(?int $process_id = null, array $cpu_ids = []): bool {}
1096+
function pcntl_getcpuaffinity(?int $process_id = null): array|false {}
1097+
function pcntl_setcpuaffinity(?int $process_id = null, array $cpu_ids = []): bool {}
10961098
#endif
10971099

10981100
#ifdef HAVE_SCHED_GETCPU
1099-
function pcntl_getcpu(): int {}
1101+
function pcntl_getcpu(): int {}
11001102
#endif
1101-
11021103
#ifdef HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP
1103-
enum QosClass
1104+
function pcntl_getqos_class(): Pcntl\QosClass {}
1105+
function pcntl_setqos_class(Pcntl\QosClass $qos_class = Pcntl\QosClass::Default): void {}
1106+
#endif
1107+
}
1108+
1109+
namespace Pcntl
11041110
{
1111+
enum QosClass
1112+
{
11051113
case UserInteractive;
11061114
case UserInitiated;
11071115
case Default;
11081116
case Utility;
11091117
case Background;
1118+
}
11101119
}
1111-
1112-
function pcntl_getqos_class(): QosClass {}
1113-
function pcntl_setqos_class(QosClass $qos_class = QosClass::Default): void {}
1114-
#endif

Diff for: ext/pcntl/pcntl_arginfo.h

+6-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ext/pcntl/tests/pcntl_qosclass.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ if (getenv('SKIP_REPEAT')) die("skip Not repeatable");
99
?>
1010
--FILE--
1111
<?php
12-
pcntl_setqos_class(QosClass::Default);
13-
var_dump(QosClass::Default === pcntl_getqos_class());
14-
pcntl_setqos_class(QosClass::Background);
15-
var_dump(QosClass::Background == pcntl_getqos_class());
12+
pcntl_setqos_class(Pcntl\QosClass::Default);
13+
var_dump(Pcntl\QosClass::Default === pcntl_getqos_class());
14+
pcntl_setqos_class(Pcntl\QosClass::Background);
15+
var_dump(Pcntl\QosClass::Background == pcntl_getqos_class());
1616
?>
1717
--EXPECT--
1818
bool(true)

0 commit comments

Comments
 (0)