lib: move errno and strerror to legacy FFI
authorJean Privat <jean@pryen.org>
Mon, 6 Apr 2015 15:24:20 +0000 (22:24 +0700)
committerJean Privat <jean@pryen.org>
Thu, 9 Apr 2015 13:47:27 +0000 (20:47 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/kernel.nit
lib/standard/kernel_nit.h
lib/standard/string.nit

index 01e72e3..dfff892 100644 (file)
@@ -17,10 +17,6 @@ module kernel
 
 import end # Mark this module is a top level one. (must be only one)
 
-`{
-#include <errno.h>
-`}
-
 ###############################################################################
 # 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
index 3a09c9c..ba97c06 100644 (file)
@@ -12,7 +12,9 @@
  */
 
 #include <stdlib.h>
+#include <errno.h>
 
 #define address_is_null(x) ((x)==NULL)
+#define sys_errno(x) (errno)
 
 #endif
index 409b4ed..8db6a4e 100644 (file)
@@ -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