         throw error
     }
 }
+
+func wrapSyscall(function: @autoclosure () -> String,
+                 _ successCondition: (Int32) -> Bool, _ fn: () -> Int32) throws -> Int32 {
+    do {
+        return try withErrno(hint: "", successCondition: successCondition, fn)
+    } catch let e as POSIXReasonedError {
+        throw ioError(errno: e.code, function: function())
+    }
+}
+
+func wrapSyscall(_ successCondition: (Int32) -> Bool,
+                 function: @autoclosure () -> String, _ fn: () -> Int32) throws -> Int32 {
+    return try wrapSyscall(function: function, successCondition, fn)
+}
+
+func wrapSyscallMayBlock(_ successCondition: (Int32) -> Bool,
+                         function: @autoclosure () -> String, _ fn: () -> Int32) throws -> Int32? {
+    do {
+        return try withErrno(hint: "", successCondition: successCondition, fn)
+    } catch let e as POSIXReasonedError {
+        if e.code == EWOULDBLOCK {
+            return nil;
+        }
+        throw ioError(errno: e.code, function: function())
+    }
+}

    }
}

func wrapSyscall<A>(_ successCondition: (A) -> Bool,
                        function: @autoclosure () -> String, _ fn: () -> A) throws -> A {
    return try wrapSyscall(function: function, successCondition, fn)
}

func wrapSyscallMayBlock<A>(_ successCondition: (A) -> Bool,
                 function: @autoclosure () -> String, _ fn: () -> A) throws -> A? {
    do {
        return try wrapSyscall(function: function, successCondition, fn)
    } catch let error as IOError {

    }
}

func wrapSyscall(function: @autoclosure () -> String,
                    _ successCondition: (Int) -> Bool, _ fn: () -> Int) throws -> Int {
    do {
        return try withErrno(hint: "", successCondition: successCondition, fn)
    } catch let e as POSIXReasonedError {
