Skip to content

Commit 766a983

Browse files
committed
posix add sysconf call.
providing handful of common and most used constants.
1 parent 79ac6e0 commit 766a983

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

ext/posix/posix.c

+11
Original file line numberDiff line numberDiff line change
@@ -1145,3 +1145,14 @@ PHP_FUNCTION(posix_initgroups)
11451145
}
11461146
/* }}} */
11471147
#endif
1148+
1149+
PHP_FUNCTION(posix_sysconf)
1150+
{
1151+
zend_long conf_id;
1152+
1153+
ZEND_PARSE_PARAMETERS_START(1, 1)
1154+
Z_PARAM_LONG(conf_id)
1155+
ZEND_PARSE_PARAMETERS_END();
1156+
1157+
RETURN_LONG(sysconf(conf_id));
1158+
}

ext/posix/posix.stub.php

+30
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,34 @@
191191
*/
192192
const POSIX_RLIMIT_INFINITY = UNKNOWN;
193193
#endif
194+
#ifdef _SC_ARG_MAX
195+
/**
196+
* @var int
197+
* @cvalue _SC_ARG_MAX
198+
*/
199+
const POSIX_SC_ARG_MAX = UNKNOWN;
200+
#endif
201+
#ifdef _SC_PAGESIZE
202+
/**
203+
* @var int
204+
* @cvalue _SC_PAGESIZE
205+
*/
206+
const POSIX_SC_PAGESIZE = UNKNOWN;
207+
#endif
208+
#ifdef _SC_NPROCESSORS_CONF
209+
/**
210+
* @var int
211+
* @cvalue _SC_NPROCESSORS_CONF
212+
*/
213+
const POSIX_SC_NPROCESSORS_CONF = UNKNOWN;
214+
#endif
215+
#ifdef _SC_NPROCESSORS_ONLN
216+
/**
217+
* @var int
218+
* @cvalue _SC_NPROCESSORS_ONLN
219+
*/
220+
const POSIX_SC_NPROCESSORS_ONLN = UNKNOWN;
221+
#endif
194222

195223
function posix_kill(int $process_id, int $signal): bool {}
196224

@@ -327,3 +355,5 @@ function posix_strerror(int $error_code): string {}
327355
#ifdef HAVE_INITGROUPS
328356
function posix_initgroups(string $username, int $group_id): bool {}
329357
#endif
358+
359+
function posix_sysconf(int $conf_id): int {}

ext/posix/posix_arginfo.h

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

ext/posix/tests/posix_sysconf.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test posix_sysconf
3+
--EXTENSIONS--
4+
posix
5+
--FILE--
6+
<?php
7+
var_dump(posix_sysconf(-1));
8+
var_dump(posix_errno() != 0);
9+
var_dump(posix_sysconf(POSIX_SC_NPROCESSORS_ONLN));
10+
?>
11+
--EXPECTF--
12+
int(-1)
13+
bool(false)
14+
int(%d)

0 commit comments

Comments
 (0)