diff --git a/ext/posix/posix.c b/ext/posix/posix.c index ed7a93c5409..b462cc8b7ad 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -1145,3 +1145,14 @@ PHP_FUNCTION(posix_initgroups) } /* }}} */ #endif + +PHP_FUNCTION(posix_sysconf) +{ + zend_long conf_id; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(conf_id) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_LONG(sysconf(conf_id)); +} diff --git a/ext/posix/posix.stub.php b/ext/posix/posix.stub.php index d3df0cd69d4..ecb462695cc 100644 --- a/ext/posix/posix.stub.php +++ b/ext/posix/posix.stub.php @@ -191,6 +191,34 @@ const POSIX_RLIMIT_NPTS = UNKNOWN; */ const POSIX_RLIMIT_INFINITY = UNKNOWN; #endif +#ifdef _SC_ARG_MAX +/** + * @var int + * @cvalue _SC_ARG_MAX + */ +const POSIX_SC_ARG_MAX = UNKNOWN; +#endif +#ifdef _SC_PAGESIZE +/** + * @var int + * @cvalue _SC_PAGESIZE + */ +const POSIX_SC_PAGESIZE = UNKNOWN; +#endif +#ifdef _SC_NPROCESSORS_CONF +/** + * @var int + * @cvalue _SC_NPROCESSORS_CONF + */ +const POSIX_SC_NPROCESSORS_CONF = UNKNOWN; +#endif +#ifdef _SC_NPROCESSORS_ONLN +/** + * @var int + * @cvalue _SC_NPROCESSORS_ONLN + */ +const POSIX_SC_NPROCESSORS_ONLN = UNKNOWN; +#endif function posix_kill(int $process_id, int $signal): bool {} @@ -327,3 +355,5 @@ function posix_strerror(int $error_code): string {} #ifdef HAVE_INITGROUPS function posix_initgroups(string $username, int $group_id): bool {} #endif + +function posix_sysconf(int $conf_id): int {} diff --git a/ext/posix/posix_arginfo.h b/ext/posix/posix_arginfo.h index e91a9950447..f45e8644b29 100644 --- a/ext/posix/posix_arginfo.h +++ b/ext/posix/posix_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e7f501e4ca2c30f6bf52ea5912037c1e59743949 */ + * Stub hash: 82454cec6f55336a530c23663efeb7ac71932bba */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_posix_kill, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, process_id, IS_LONG, 0) @@ -159,6 +159,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_posix_initgroups, 0, 2, _IS_BOOL ZEND_END_ARG_INFO() #endif +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_posix_sysconf, 0, 1, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, conf_id, IS_LONG, 0) +ZEND_END_ARG_INFO() + ZEND_FUNCTION(posix_kill); ZEND_FUNCTION(posix_getpid); @@ -222,6 +226,7 @@ ZEND_FUNCTION(posix_strerror); #if defined(HAVE_INITGROUPS) ZEND_FUNCTION(posix_initgroups); #endif +ZEND_FUNCTION(posix_sysconf); static const zend_function_entry ext_functions[] = { @@ -288,6 +293,7 @@ static const zend_function_entry ext_functions[] = { #if defined(HAVE_INITGROUPS) ZEND_FE(posix_initgroups, arginfo_posix_initgroups) #endif + ZEND_FE(posix_sysconf, arginfo_posix_sysconf) ZEND_FE_END }; @@ -369,4 +375,16 @@ static void register_posix_symbols(int module_number) #if defined(HAVE_SETRLIMIT) REGISTER_LONG_CONSTANT("POSIX_RLIMIT_INFINITY", RLIM_INFINITY, CONST_PERSISTENT); #endif +#if defined(_SC_ARG_MAX) + REGISTER_LONG_CONSTANT("POSIX_SC_ARG_MAX", _SC_ARG_MAX, CONST_PERSISTENT); +#endif +#if defined(_SC_PAGESIZE) + REGISTER_LONG_CONSTANT("POSIX_SC_PAGESIZE", _SC_PAGESIZE, CONST_PERSISTENT); +#endif +#if defined(_SC_NPROCESSORS_CONF) + REGISTER_LONG_CONSTANT("POSIX_SC_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, CONST_PERSISTENT); +#endif +#if defined(_SC_NPROCESSORS_ONLN) + REGISTER_LONG_CONSTANT("POSIX_SC_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, CONST_PERSISTENT); +#endif } diff --git a/ext/posix/tests/posix_sysconf.phpt b/ext/posix/tests/posix_sysconf.phpt new file mode 100644 index 00000000000..6acebe1f0e0 --- /dev/null +++ b/ext/posix/tests/posix_sysconf.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test posix_sysconf +--EXTENSIONS-- +posix +--FILE-- + +--EXPECTF-- +int(-1) +bool(false) +int(%d)