Own getpid cache, because getpid cache was removed in glibc 2-25, and getpid is now slow

parent a38b9d10
......@@ -49,7 +49,8 @@ c-library libc
c-function write write n a n -- n ( fd addr u -- u' )
c-function close close n -- n ( fd -- r )
c-function setlocale setlocale n s -- a ( category locale len -- locale )
c-function fork() fork -- n ( -- pid_t )
c-function (getpid) getpid -- n ( -- n ) \ for completion
c-function (fork) fork -- n ( -- pid_t )
c-function execvp execvp s a -- n ( filename len argv -- ret )
c-function exit() exit n -- void ( ret -- )
c-function symlink symlink s s -- n ( target len1 path len2 -- ret )
......@@ -94,5 +95,10 @@ $004 Constant POLLOUT
: fd>file ( fd -- file ) s" w+" fdopen ;
(getpid) Value getpid
: fork() ( -- pid )
(fork) (getpid) to getpid ;
: fork+exec ( filename len argv -- )
fork() 0= IF ['] exit() is throw execvp exit() ELSE drop 2drop THEN ;
......@@ -157,7 +157,6 @@ c-library pthread
c-function create_pipe create_pipe a -- void ( pipefd[2] -- )
c-function check_read check_read a -- n ( pipefd -- n )
c-function wait_read wait_read a n n -- n ( pipefd timeoutns timeouts -- n )
c-function getpid getpid -- n ( -- n ) \ for completion
c-function stick-to-core stick_to_core n -- n ( core -- n )
\c #define get_pthread_id(addr) *(pthread_t*)(addr) = pthread_self()
c-function pthread_self get_pthread_id a -- void ( pthread-id -- )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment