aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/macros.rs
diff options
context:
space:
mode:
authorPaul Florence <[email protected]>2017-11-10 10:05:52 -0500
committerPaul Florence <[email protected]>2017-11-10 10:05:52 -0500
commit0bae121e1268565eb29e90e68b8c5e98ab1fe979 (patch)
treeac7fc87f39f98b905fa8c388b498749f28b18413 /openssl/src/macros.rs
parentMerge pull request #757 from bvinc/master (diff)
downloadrust-openssl-0bae121e1268565eb29e90e68b8c5e98ab1fe979.tar.xz
rust-openssl-0bae121e1268565eb29e90e68b8c5e98ab1fe979.zip
Added a macro that wraps foreign type, and impl Send and Sync for both,
the borrowed type and the owned one. Replaced all invocation of `foreign_type` by `foreign_type_and_impl_send_sync`.
Diffstat (limited to 'openssl/src/macros.rs')
-rw-r--r--openssl/src/macros.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/openssl/src/macros.rs b/openssl/src/macros.rs
index b2fe0c18..721f4b0c 100644
--- a/openssl/src/macros.rs
+++ b/openssl/src/macros.rs
@@ -214,3 +214,35 @@ macro_rules! from_pem {
from_pem, $t, $f);
}
}
+
+
+macro_rules! foreign_type_and_impl_send_sync {
+ (
+ $(#[$impl_attr:meta])*
+ type CType = $ctype:ty;
+ fn drop = $drop:expr;
+ $(fn clone = $clone:expr;)*
+
+ $(#[$owned_attr:meta])*
+ pub struct $owned:ident;
+ $(#[$borrowed_attr:meta])*
+ pub struct $borrowed:ident;
+ )
+ => {
+ foreign_type! {
+ $(#[$impl_attr])*
+ type CType = $ctype;
+ fn drop = $drop;
+ $(fn clone = $clone;)*
+ $(#[$owned_attr])*
+ pub struct $owned;
+ $(#[$borrowed_attr])*
+ pub struct $borrowed;
+ }
+
+ unsafe impl Send for $owned{}
+ unsafe impl Send for $borrowed{}
+ unsafe impl Sync for $owned{}
+ unsafe impl Sync for $borrowed{}
+ };
+}