[arrayfire] 29/408: Add static checks to make sure ArrayInfo is the first mem var

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.

commit ee723706a98887cf0c9c80b42bc26ad3227e380a
Author: Umar Arshad <umar at arrayfire.com>
Date:   Mon Jun 22 17:06:08 2015 -0400

    Add static checks to make sure ArrayInfo is the first mem var
---
 src/backend/cpu/Array.cpp    | 2 ++
 src/backend/cuda/Array.cpp   | 2 ++
 src/backend/opencl/Array.cpp | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/src/backend/cpu/Array.cpp b/src/backend/cpu/Array.cpp
index bdb0954..bed7597 100644
--- a/src/backend/cpu/Array.cpp
+++ b/src/backend/cpu/Array.cpp
@@ -15,6 +15,7 @@
 #include <memory.hpp>
 #include <platform.hpp>
 #include <cstring>
+#include <cstddef>
 
 namespace cpu
 {
@@ -39,6 +40,7 @@ namespace cpu
         node(), offset(0), ready(true), owner(true)
     {
         static_assert(std::is_standard_layout<Array<T>>::value, "Array<T> must be a standard layout type");
+        static_assert(offsetof(Array<T>, info) == 0, "Array<T>::info must be the first member variable of Array<T>");
         std::copy(in_data, in_data + dims.elements(), data.get());
     }
 
diff --git a/src/backend/cuda/Array.cpp b/src/backend/cuda/Array.cpp
index f62fbc6..07f5ff6 100644
--- a/src/backend/cuda/Array.cpp
+++ b/src/backend/cuda/Array.cpp
@@ -15,6 +15,7 @@
 #include <scalar.hpp>
 #include <memory.hpp>
 #include <platform.hpp>
+#include <cstddef>
 
 using af::dim4;
 
@@ -42,6 +43,7 @@ namespace cuda
     {
 #if __cplusplus > 199711L
         static_assert(std::is_standard_layout<Array<T>>::value, "Array<T> must be a standard layout type");
+        static_assert(offsetof(Array<T>, info) == 0, "Array<T>::info must be the first member variable of Array<T>");
 #endif
         if (!is_device) {
             CUDA_CHECK(cudaMemcpy(data.get(), in_data, dims.elements() * sizeof(T), cudaMemcpyHostToDevice));
diff --git a/src/backend/opencl/Array.cpp b/src/backend/opencl/Array.cpp
index b0ae226..395f3c7 100644
--- a/src/backend/opencl/Array.cpp
+++ b/src/backend/opencl/Array.cpp
@@ -15,6 +15,7 @@
 #include <err_opencl.hpp>
 #include <memory.hpp>
 #include <platform.hpp>
+#include <cstddef>
 
 using af::dim4;
 
@@ -52,6 +53,7 @@ namespace opencl
         node(), offset(0), ready(true), owner(true)
     {
         static_assert(std::is_standard_layout<Array<T>>::value, "Array<T> must be a standard layout type");
+        static_assert(offsetof(Array<T>, info) == 0, "Array<T>::info must be the first member variable of Array<T>");
         getQueue().enqueueWriteBuffer(*data.get(), CL_TRUE, 0, sizeof(T)*info.elements(), in_data);
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list