From: Jean Privat Date: Mon, 6 Apr 2015 15:24:20 +0000 (+0700) Subject: lib: move errno and strerror to legacy FFI X-Git-Tag: v0.7.4~32^2~3 X-Git-Url: http://nitlanguage.org lib: move errno and strerror to legacy FFI Signed-off-by: Jean Privat --- diff --git a/lib/standard/kernel.nit b/lib/standard/kernel.nit index 01e72e3..dfff892 100644 --- a/lib/standard/kernel.nit +++ b/lib/standard/kernel.nit @@ -17,10 +17,6 @@ module kernel import end # Mark this module is a top level one. (must be only one) -`{ -#include -`} - ############################################################################### # System Classes # ############################################################################### @@ -111,9 +107,7 @@ class Sys fun run do main # Number of the last error - fun errno: Int is extern `{ - return errno; - `} + fun errno: Int is extern "sys_errno" end # Quit the program with a specific return code diff --git a/lib/standard/kernel_nit.h b/lib/standard/kernel_nit.h index 3a09c9c..ba97c06 100644 --- a/lib/standard/kernel_nit.h +++ b/lib/standard/kernel_nit.h @@ -12,7 +12,9 @@ */ #include +#include #define address_is_null(x) ((x)==NULL) +#define sys_errno(x) (errno) #endif diff --git a/lib/standard/string.nit b/lib/standard/string.nit index 409b4ed..8db6a4e 100644 --- a/lib/standard/string.nit +++ b/lib/standard/string.nit @@ -1952,9 +1952,7 @@ end redef class Int # Wrapper of strerror C function - private fun strerror_ext: NativeString is extern `{ - return strerror(recv); - `} + private fun strerror_ext: NativeString is extern "strerror" # Returns a string describing error number fun strerror: String do return strerror_ext.to_s