libc: fix for linux using GNU strerror_r (for now).

db4
John Benediktsson 2014-07-06 10:41:51 -07:00
parent ccfd9101f0
commit fd19fadcc6
6 changed files with 18 additions and 16 deletions

View File

@ -46,8 +46,6 @@ FUNCTION-ALIAS: strerror_unsafe
! Add a default strerror even though it's not threadsafe
M: object strerror strerror_unsafe ;
FUNCTION: int strerror_r ( int errno, char* buf, size_t buflen ) ;
ERROR: libc-error errno message ;
: (io-error) ( -- * ) errno dup strerror libc-error ;

View File

@ -1,4 +1,4 @@
USING: alien.syntax ;
USING: alien.c-types alien.syntax destructors kernel system ;
IN: libc
LIBRARY: libc
@ -169,3 +169,10 @@ CONSTANT: SIGIO 29
ALIAS: SIGPOLL SIGIO
CONSTANT: SIGPWR 30
CONSTANT: SIGSYS 31
FUNCTION: c-string strerror_r ( int errno, char* buf, size_t buflen ) ;
M: linux strerror ( errno -- str )
[
1024 [ malloc &free ] keep strerror_r
] with-destructors ;

View File

@ -1,4 +1,5 @@
USING: alien.syntax ;
USING: alien.c-types alien.strings alien.syntax destructors
kernel system ;
IN: libc
LIBRARY: libc
@ -139,3 +140,11 @@ CONSTANT: SIGWINCH 28
CONSTANT: SIGINFO 29
CONSTANT: SIGUSR1 30
CONSTANT: SIGUSR2 31
FUNCTION: int strerror_r ( int errno, char* buf, size_t buflen ) ;
M: macosx strerror ( errno -- str )
[
1024 [ malloc &free ] keep [ strerror_r ] 2keep drop nip
alien>native-string
] with-destructors ;

View File

@ -1 +0,0 @@
Doug Coleman

View File

@ -1 +0,0 @@
unix

View File

@ -1,10 +0,0 @@
! Copyright (C) 2014 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.strings destructors kernel libc system ;
IN: libc.unix
M: unix strerror ( errno -- str )
[
1024 [ malloc &free ] keep [ strerror_r ] 2keep drop nip
alien>native-string
] with-destructors ;