Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Unified Diff: native_client_sdk/src/libraries/nacl_io/kernel_wrap.h

Issue 271513002: [NaCl SDK] nacl_io: Make IRT intercepts (and their test code) more robust. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h b/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
index 6211e8cca44bbaf5a932070ece6c3293bd252394..d290da25bc46e40e2c39206f124aeba0f6518e02 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap.h
@@ -5,6 +5,7 @@
#ifndef LIBRARIES_NACL_IO_KERNEL_WRAP_H_
#define LIBRARIES_NACL_IO_KERNEL_WRAP_H_
+#include <assert.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
@@ -24,6 +25,20 @@
#define NOTHROW
#endif
+// Most kernel intercept functions (ki_*) return -1 and set the global errno.
+// However, the IRT wrappers are expected to return errno on failure. These
+// macros are used in the wrappers to check that the ki_ function actually
+// set errno and to its value.
+#define RTN_ERRNO_IF(cond) \
+ if (cond) { \
+ assert(errno != 0); \
+ return errno; \
+ }
+
+#define ERRNO_RTN(cond) \
+ RTN_ERRNO_IF(cond < 0); \
+ return 0;
+
#if defined(WIN32)
typedef int chmod_mode_t;
typedef int getcwd_size_t;

Powered by Google App Engine
This is Rietveld 408576698