Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r91445:a65f0a6fd69b Date: 2017-05-30 13:35 +0200 http://bitbucket.org/pypy/pypy/changeset/a65f0a6fd69b/
Log: merge back changes to RPython in py3.5 (3ee9941e823c) diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -235,6 +235,7 @@ includes = ['unistd.h', 'sys/types.h', 'sys/wait.h', 'utime.h', 'sys/time.h', 'sys/times.h', 'sys/resource.h', + 'sched.h', 'grp.h', 'dirent.h', 'sys/stat.h', 'fcntl.h', 'signal.h', 'sys/utsname.h', _ptyh] if sys.platform.startswith('linux'): @@ -255,6 +256,10 @@ PRIO_PROCESS = rffi_platform.DefinedConstantInteger('PRIO_PROCESS') PRIO_PGRP = rffi_platform.DefinedConstantInteger('PRIO_PGRP') PRIO_USER = rffi_platform.DefinedConstantInteger('PRIO_USER') + SCHED_FIFO = rffi_platform.DefinedConstantInteger('SCHED_FIFO') + SCHED_RR = rffi_platform.DefinedConstantInteger('SCHED_RR') + SCHED_OTHER = rffi_platform.DefinedConstantInteger('SCHED_OTHER') + SCHED_BATCH = rffi_platform.DefinedConstantInteger('SCHED_BATCH') O_NONBLOCK = rffi_platform.DefinedConstantInteger('O_NONBLOCK') OFF_T = rffi_platform.SimpleType('off_t') OFF_T_SIZE = rffi_platform.SizeOf('off_t') @@ -1818,6 +1823,21 @@ def setpriority(which, who, prio): handle_posix_error('setpriority', c_setpriority(which, who, prio)) + c_sched_get_priority_max = external('sched_get_priority_max', [rffi.INT], + rffi.INT, save_err=rffi.RFFI_FULL_ERRNO_ZERO) + c_sched_get_priority_min = external('sched_get_priority_min', [rffi.INT], + rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO) + + @enforceargs(int) + def sched_get_priority_max(policy): + return handle_posix_error('sched_get_priority_max', c_sched_get_priority_max(policy)) + + @enforceargs(int) + def sched_get_priority_min(policy): + return handle_posix_error('sched_get_priority_min', c_sched_get_priority_min(policy)) + + + #___________________________________________________________________ diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py --- a/rpython/rlib/test/test_rposix.py +++ b/rpython/rlib/test/test_rposix.py @@ -781,3 +781,27 @@ raise finally: os.close(fd) + +@rposix_requires('sched_get_priority_max') +def test_sched_get_priority_max(): + assert rposix.sched_get_priority_max(rposix.SCHED_FIFO) != -1 + assert rposix.sched_get_priority_max(rposix.SCHED_RR) != -1 + assert rposix.sched_get_priority_max(rposix.SCHED_OTHER) != -1 + assert rposix.sched_get_priority_max(rposix.SCHED_BATCH) != -1 + +@rposix_requires('sched_get_priority_min') +def test_sched_get_priority_min(): + assert rposix.sched_get_priority_min(rposix.SCHED_FIFO) != -1 + assert rposix.sched_get_priority_min(rposix.SCHED_RR) != -1 + assert rposix.sched_get_priority_min(rposix.SCHED_OTHER) != -1 + assert rposix.sched_get_priority_min(rposix.SCHED_BATCH) != -1 + +@rposix_requires('sched_get_priority_min') +def test_os_sched_priority_max_greater_than_min(): + policy = rposix.SCHED_RR + low = rposix.sched_get_priority_min(policy) + high = rposix.sched_get_priority_max(policy) + assert isinstance(low, int) == True + assert isinstance(high, int) == True + assert high > low + _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit