clover: make module::symbol::name a string
authorEdB <edb+mesa@sigluy.net>
Fri, 24 Apr 2015 10:59:56 +0000 (12:59 +0200)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 29 Apr 2015 12:45:07 +0000 (12:45 +0000)
Acked-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/state_trackers/clover/api/program.cpp
src/gallium/state_trackers/clover/core/module.cpp
src/gallium/state_trackers/clover/core/module.hpp

index b3be2b8d1bb287d6daf50f5bc959e32f80a01d47..913d195a16f2b5c8e9a8cf1cb669b9d492ae84bb 100644 (file)
@@ -293,8 +293,7 @@ clGetProgramInfo(cl_program d_prog, cl_program_info param,
 
    case CL_PROGRAM_KERNEL_NAMES:
       buf.as_string() = fold([](const std::string &a, const module::symbol &s) {
-            return ((a.empty() ? "" : a + ";") +
-                    std::string(s.name.begin(), s.name.size()));
+            return ((a.empty() ? "" : a + ";") + s.name);
          }, std::string(), prog.symbols());
       break;
 
index be10e35d15d4cd39e456f31ad534d40d6b582624..f098b05312b9899bd4e0e4620dd7c160a34b28cc 100644 (file)
@@ -133,6 +133,27 @@ namespace {
       }
    };
 
+   /// (De)serialize a string.
+   template<>
+   struct _serializer<std::string> {
+      static void
+      proc(compat::ostream &os, const std::string &s) {
+         _proc<uint32_t>(os, s.size());
+         os.write(&s[0], s.size() * sizeof(std::string::value_type));
+      }
+
+      static void
+      proc(compat::istream &is, std::string &s) {
+         s.resize(_proc<uint32_t>(is));
+         is.read(&s[0], s.size() * sizeof(std::string::value_type));
+      }
+
+      static void
+      proc(module::size_t &sz, const std::string &s) {
+         sz += sizeof(uint32_t) + sizeof(std::string::value_type) * s.size();
+      }
+   };
+
    /// (De)serialize a module::section.
    template<>
    struct _serializer<module::section> {
index ee6caf9690c776ef1a9ed62b17a66d2f15a22d83..46112a38c916d40811851a92efcdfd8c58c3b913 100644 (file)
@@ -100,12 +100,12 @@ namespace clover {
       };
 
       struct symbol {
-         symbol(const compat::vector<char> &name, resource_id section,
+         symbol(const std::string &name, resource_id section,
                 size_t offset, const compat::vector<argument> &args) :
                 name(name), section(section), offset(offset), args(args) { }
          symbol() : name(), section(0), offset(0), args() { }
 
-         compat::vector<char> name;
+         std::string name;
          resource_id section;
          size_t offset;
          compat::vector<argument> args;