From 15bdd2c13f480eb9d72821982ce305f0a28c7340 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 6 Apr 2015 22:24:20 +0700 Subject: [PATCH] lib: move errno and strerror to legacy FFI Signed-off-by: Jean Privat --- lib/standard/kernel.nit | 8 +------- lib/standard/kernel_nit.h | 2 ++ lib/standard/string.nit | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) 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 -- 1.7.9.5