From d7595bbb7cfc95c8921fdcd262bc255c632332d9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 4 Jul 2014 03:11:45 -0700 Subject: [PATCH] libc: First stab at using strerror_r and (strerror_s on Windows) instead of thread-unsafe strerror. --- basis/libc/libc.factor | 18 ++++++++++-------- basis/libc/windows/windows.factor | 13 ++++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/basis/libc/libc.factor b/basis/libc/libc.factor index ee5f7abad7..fdb8ca6487 100644 --- a/basis/libc/libc.factor +++ b/basis/libc/libc.factor @@ -25,14 +25,6 @@ FUNCTION-ALIAS: set-errno LIBRARY: libc -FUNCTION: c-string strerror ( int errno ) ; - -ERROR: libc-error errno message ; - -: (io-error) ( -- * ) errno dup strerror libc-error ; - -: io-error ( n -- ) 0 < [ (io-error) ] when ; - FUNCTION-ALIAS: (malloc) void* malloc ( size_t size ) ; @@ -45,6 +37,16 @@ FUNCTION-ALIAS: (free) FUNCTION-ALIAS: (realloc) void* realloc ( void* alien, size_t size ) ; +HOOK: strerror os ( errno -- str ) + +FUNCTION: int strerror_r ( int errno, char* buf, size_t buflen ) ; + +ERROR: libc-error errno message ; + +: (io-error) ( -- * ) errno dup strerror libc-error ; + +: io-error ( n -- ) 0 < [ (io-error) ] when ; + native-string + ] with-destructors ;