Blame SOURCES/0004-python-Add-various-constants-to-the-API.patch

538efe
From b646050b8da51c39cf21f95fa847c12784a1169c Mon Sep 17 00:00:00 2001
538efe
From: "Richard W.M. Jones" <rjones@redhat.com>
538efe
Date: Thu, 21 Nov 2019 15:02:44 +0000
538efe
Subject: [PATCH 04/19] python: Add various constants to the API.
538efe
538efe
These are accessible from the plugin by:
538efe
538efe
  import nbdkit
538efe
538efe
  if flags & nbdkit.FLAG_MAY_TRIM:
538efe
  &c.
538efe
538efe
Many (all?) of these are not yet useful for plugins, some will never
538efe
be useful, but they only consume a tiny bit of memory and it's nice to
538efe
have the complete set available for future use.
538efe
538efe
(cherry picked from commit 14b7fe2e0de881e3dfc8803484ade29a61e323c9)
538efe
---
538efe
 plugins/python/python.c | 30 ++++++++++++++++++++++++++++++
538efe
 1 file changed, 30 insertions(+)
538efe
538efe
diff --git a/plugins/python/python.c b/plugins/python/python.c
538efe
index 7052aac0..47da0838 100644
538efe
--- a/plugins/python/python.c
538efe
+++ b/plugins/python/python.c
538efe
@@ -231,6 +231,36 @@ create_nbdkit_module (void)
538efe
     nbdkit_error ("could not create the nbdkit API module");
538efe
     exit (EXIT_FAILURE);
538efe
   }
538efe
+
538efe
+  /* Constants corresponding to various flags. */
538efe
+#define ADD_INT_CONSTANT(name)                                      \
538efe
+  if (PyModule_AddIntConstant (m, #name, NBDKIT_##name) == -1) {    \
538efe
+    nbdkit_error ("could not add constant %s to nbdkit API module", \
538efe
+                  #name);                                           \
538efe
+    exit (EXIT_FAILURE);                                            \
538efe
+  }
538efe
+  ADD_INT_CONSTANT (THREAD_MODEL_SERIALIZE_CONNECTIONS);
538efe
+  ADD_INT_CONSTANT (THREAD_MODEL_SERIALIZE_ALL_REQUESTS);
538efe
+  ADD_INT_CONSTANT (THREAD_MODEL_SERIALIZE_REQUESTS);
538efe
+  ADD_INT_CONSTANT (THREAD_MODEL_PARALLEL);
538efe
+
538efe
+  ADD_INT_CONSTANT (FLAG_MAY_TRIM);
538efe
+  ADD_INT_CONSTANT (FLAG_FUA);
538efe
+  ADD_INT_CONSTANT (FLAG_REQ_ONE);
538efe
+  ADD_INT_CONSTANT (FLAG_FAST_ZERO);
538efe
+
538efe
+  ADD_INT_CONSTANT (FUA_NONE);
538efe
+  ADD_INT_CONSTANT (FUA_EMULATE);
538efe
+  ADD_INT_CONSTANT (FUA_NATIVE);
538efe
+
538efe
+  ADD_INT_CONSTANT (CACHE_NONE);
538efe
+  ADD_INT_CONSTANT (CACHE_EMULATE);
538efe
+  ADD_INT_CONSTANT (CACHE_NATIVE);
538efe
+
538efe
+  ADD_INT_CONSTANT (EXTENT_HOLE);
538efe
+  ADD_INT_CONSTANT (EXTENT_ZERO);
538efe
+#undef ADD_INT_CONSTANT
538efe
+
538efe
   return m;
538efe
 }
538efe
 
538efe
-- 
538efe
2.18.2
538efe