Skip to content

posix add sysconf call. #9481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
30 changes: 30 additions & 0 deletions ext/posix/posix.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,34 @@
*/
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 {}

Expand Down Expand Up @@ -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 {}
20 changes: 19 additions & 1 deletion ext/posix/posix_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ext/posix/tests/posix_sysconf.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Test posix_sysconf
--EXTENSIONS--
posix
--FILE--
<?php
var_dump(posix_sysconf(-1));
var_dump(posix_errno() != 0);
var_dump(posix_sysconf(POSIX_SC_NPROCESSORS_ONLN));
?>
--EXPECTF--
int(-1)
bool(false)
int(%d)