]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/outcome/experimental/result.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / outcome / experimental / result.h
index 8051ebcc691c7a2a49bfb4a1c6f20c573bdc94c0..61f8e1a224a496c048996dedb4e726df6ad8a9b7 100644 (file)
@@ -1,5 +1,5 @@
 /* C interface for result
-(C) 2017-2020 Niall Douglas <http://www.nedproductions.biz/> (6 commits)
+(C) 2017-2022 Niall Douglas <http://www.nedproductions.biz/> (6 commits)
 File Created: Aug 2017
 
 
@@ -33,12 +33,20 @@ DEALINGS IN THE SOFTWARE.
 
 #include <stdint.h>  // for intptr_t
 
-#define BOOST_OUTCOME_C_DECLARE_RESULT(ident, R, S)                                                                                                                                                                                                                                                                                        \
-  struct cxx_result_##ident                                                                                                                                                                                                                                                                                                    \
-  {                                                                                                                                                                                                                                                                                                                            \
-    R value;                                                                                                                                                                                                                                                                                                                   \
-    unsigned flags;                                                                                                                                                                                                                                                                                                            \
-    S error;                                                                                                                                                                                                                                                                                                                   \
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define BOOST_OUTCOME_C_DECLARE_RESULT(ident, R, S)                                                                                                                        \
+  struct cxx_result_##ident                                                                                                                                    \
+  {                                                                                                                                                            \
+    union                                                                                                                                                      \
+    {                                                                                                                                                          \
+      R value;                                                                                                                                                 \
+      S error;                                                                                                                                                 \
+    };                                                                                                                                                         \
+    unsigned flags;                                                                                                                                            \
   }
 
 #define BOOST_OUTCOME_C_RESULT(ident) struct cxx_result_##ident
@@ -51,32 +59,46 @@ DEALINGS IN THE SOFTWARE.
 #define BOOST_OUTCOME_C_RESULT_ERROR_IS_ERRNO(r) (((r).flags & (1U << 4U)) == (1U << 4U))
 
 
-/***************************** <system_error2> support ******************************/
+  /***************************** <system_error2> support ******************************/
 
-#define BOOST_OUTCOME_C_DECLARE_STATUS_CODE(ident, value_type)                                                                                                                                                                                                                                                                             \
-  struct cxx_status_code_##ident                                                                                                                                                                                                                                                                                               \
-  {                                                                                                                                                                                                                                                                                                                            \
-    void *domain;                                                                                                                                                                                                                                                                                                              \
-    value_type value;                                                                                                                                                                                                                                                                                                          \
+#define BOOST_OUTCOME_C_DECLARE_STATUS_CODE(ident, value_type)                                                                                                             \
+  struct cxx_status_code_##ident                                                                                                                               \
+  {                                                                                                                                                            \
+    void *domain;                                                                                                                                              \
+    value_type value;                                                                                                                                          \
   };
 
 #define BOOST_OUTCOME_C_STATUS_CODE(ident) struct cxx_status_code_##ident
 
+#define BOOST_OUTCOME_C_DECLARE_RESULT_STATUS_CODE(ident, R, S)                                                                                                            \
+  struct cxx_result_status_code_##ident                                                                                                                        \
+  {                                                                                                                                                            \
+    R value;                                                                                                                                                   \
+    unsigned flags;                                                                                                                                            \
+    S error;                                                                                                                                                   \
+  }
 
-struct cxx_status_code_posix
-{
-  void *domain;
-  int value;
-};
-#define BOOST_OUTCOME_C_DECLARE_RESULT_ERRNO(ident, R) BOOST_OUTCOME_C_DECLARE_RESULT(posix_##ident, R, struct cxx_status_code_posix)
-#define BOOST_OUTCOME_C_RESULT_ERRNO(ident) BOOST_OUTCOME_C_RESULT(posix_##ident)
+#define BOOST_OUTCOME_C_RESULT_STATUS_CODE(ident) struct cxx_result_status_code_##ident
 
-struct cxx_status_code_system
-{
-  void *domain;
-  intptr_t value;
-};
-#define BOOST_OUTCOME_C_DECLARE_RESULT_SYSTEM(ident, R) BOOST_OUTCOME_C_DECLARE_RESULT(system_##ident, R, struct cxx_status_code_system)
-#define BOOST_OUTCOME_C_RESULT_SYSTEM(ident) BOOST_OUTCOME_C_RESULT(system_##ident)
+
+  struct cxx_status_code_posix
+  {
+    void *domain;
+    int value;
+  };
+#define BOOST_OUTCOME_C_DECLARE_RESULT_ERRNO(ident, R) BOOST_OUTCOME_C_DECLARE_RESULT_STATUS_CODE(posix_##ident, R, struct cxx_status_code_posix)
+#define BOOST_OUTCOME_C_RESULT_ERRNO(ident) BOOST_OUTCOME_C_RESULT_STATUS_CODE(posix_##ident)
+
+  struct cxx_status_code_system
+  {
+    void *domain;
+    intptr_t value;
+  };
+#define BOOST_OUTCOME_C_DECLARE_RESULT_SYSTEM(ident, R) BOOST_OUTCOME_C_DECLARE_RESULT_STATUS_CODE(system_##ident, R, struct cxx_status_code_system)
+#define BOOST_OUTCOME_C_RESULT_SYSTEM(ident) BOOST_OUTCOME_C_RESULT_STATUS_CODE(system_##ident)
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif