From 2d112ed96152bc62e5417472270f29966c8feece Mon Sep 17 00:00:00 2001 From: EdB Date: Fri, 24 Apr 2015 12:59:56 +0200 Subject: [PATCH] clover: make module::symbol::name a string Acked-by: Francisco Jerez Reviewed-by: Tom Stellard --- .../state_trackers/clover/api/program.cpp | 3 +-- .../state_trackers/clover/core/module.cpp | 21 +++++++++++++++++++ .../state_trackers/clover/core/module.hpp | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index b3be2b8d1bb..913d195a16f 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -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; diff --git a/src/gallium/state_trackers/clover/core/module.cpp b/src/gallium/state_trackers/clover/core/module.cpp index be10e35d15d..f098b05312b 100644 --- a/src/gallium/state_trackers/clover/core/module.cpp +++ b/src/gallium/state_trackers/clover/core/module.cpp @@ -133,6 +133,27 @@ namespace { } }; + /// (De)serialize a string. + template<> + struct _serializer { + static void + proc(compat::ostream &os, const std::string &s) { + _proc(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(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 { diff --git a/src/gallium/state_trackers/clover/core/module.hpp b/src/gallium/state_trackers/clover/core/module.hpp index ee6caf9690c..46112a38c91 100644 --- a/src/gallium/state_trackers/clover/core/module.hpp +++ b/src/gallium/state_trackers/clover/core/module.hpp @@ -100,12 +100,12 @@ namespace clover { }; struct symbol { - symbol(const compat::vector &name, resource_id section, + symbol(const std::string &name, resource_id section, size_t offset, const compat::vector &args) : name(name), section(section), offset(offset), args(args) { } symbol() : name(), section(0), offset(0), args() { } - compat::vector name; + std::string name; resource_id section; size_t offset; compat::vector args; -- 2.30.2