add set-priority and get-priority
add clear_err_no and check-errno for dealing with get-prioritydb4
parent
17356ece95
commit
9c745c44d3
|
@ -0,0 +1,5 @@
|
|||
USING: io.backend kernel ;
|
||||
IN: io.priority
|
||||
|
||||
HOOK: get-priority io-backend ( -- n )
|
||||
HOOK: set-priority io-backend ( n -- )
|
|
@ -72,6 +72,9 @@ M: mx unregister-io-task ( task mx -- )
|
|||
|
||||
: (io-error) ( -- * ) err_no strerror throw ;
|
||||
|
||||
: check-errno ( -- )
|
||||
err_no dup zero? [ drop ] [ strerror throw ] if ;
|
||||
|
||||
: check-null ( n -- ) zero? [ (io-error) ] when ;
|
||||
|
||||
: io-error ( n -- ) 0 < [ (io-error) ] when ;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
USING: alien.syntax kernel io.priority io.unix.backend
|
||||
unix ;
|
||||
IN: io.unix.priority
|
||||
|
||||
: PRIO_PROCESS 0 ; inline
|
||||
: PRIO_PGRP 1 ; inline
|
||||
: PRIO_USER 2 ; inline
|
||||
|
||||
: PRIO_MIN -20 ; inline
|
||||
: PRIO_MAX 20 ; inline
|
||||
|
||||
! which/who = 0 for current process
|
||||
FUNCTION: int getpriority ( int which, int who ) ;
|
||||
FUNCTION: int setpriority ( int which, int who, int prio ) ;
|
||||
|
||||
M: unix-io get-priority ( -- n )
|
||||
clear_err_no
|
||||
0 0 getpriority dup -1 = [ check-errno ] when ;
|
||||
|
||||
M: unix-io set-priority ( n -- )
|
||||
0 0 rot setpriority io-error ;
|
|
@ -1,5 +1,5 @@
|
|||
USING: io.unix.backend io.unix.files io.unix.sockets io.timeouts
|
||||
io.unix.launcher io.unix.mmap io.backend
|
||||
io.unix.launcher io.unix.mmap io.backend io.priority
|
||||
combinators namespaces system vocabs.loader sequences ;
|
||||
|
||||
"io.unix." os append require
|
||||
|
|
|
@ -27,6 +27,7 @@ TYPEDEF: ulong size_t
|
|||
! ! ! Unix functions
|
||||
LIBRARY: factor
|
||||
FUNCTION: int err_no ( ) ;
|
||||
FUNCTION: void clear_err_no ( ) ;
|
||||
|
||||
LIBRARY: libc
|
||||
|
||||
|
|
5
vm/io.c
5
vm/io.c
|
@ -194,3 +194,8 @@ int err_no(void)
|
|||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
void clear_err_no(void)
|
||||
{
|
||||
errno = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue