! 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 ;
-USING: alien.syntax ;
+USING: alien.c-types alien.syntax destructors kernel system ;
IN: libc
LIBRARY: libc
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 ;
-USING: alien.syntax ;
+USING: alien.c-types alien.strings alien.syntax destructors
+kernel system ;
IN: libc
LIBRARY: libc
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 ;
+++ /dev/null
-Doug Coleman
+++ /dev/null
-! 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 ;