diff options
author | Tobias Burnus <burnus@net-b.de> | 2016-09-20 21:49:12 +0000 |
---|---|---|
committer | Tobias Burnus <burnus@net-b.de> | 2016-09-20 21:49:12 +0000 |
commit | abf704d05073530028336551d8565aca6403e985 (patch) | |
tree | 0ac440db6513ee01deb5e5dc6142769d1e5b7b2d /gcc/go/gofrontend/export.cc | |
parent | c720aaa3bf123cbfabe14016711f3683d840b6a5 (diff) | |
parent | 168ff71ac9c1c9ad651456fc6350b3ab43e6aa2a (diff) |
Merge from trunk (r239915 to r240230)fortran-dev
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/fortran-dev@240290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend/export.cc')
-rw-r--r-- | gcc/go/gofrontend/export.cc | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc index e9040efeda9..bec4c7ff978 100644 --- a/gcc/go/gofrontend/export.cc +++ b/gcc/go/gofrontend/export.cc @@ -6,8 +6,7 @@ #include "go-system.h" -#include "sha1.h" - +#include "go-sha1.h" #include "go-c.h" #include "gogo.h" @@ -40,6 +39,7 @@ const int Export::checksum_len; Export::Export(Stream* stream) : stream_(stream), type_refs_(), type_index_(1), packages_() { + go_assert(Export::checksum_len == Go_sha1_helper::checksum_len); } // A functor to sort Named_object pointers by name. @@ -686,9 +686,8 @@ Export::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code) Export::Stream::Stream() { - this->checksum_ = new sha1_ctx; - memset(this->checksum_, 0, sizeof(sha1_ctx)); - sha1_init_ctx(this->checksum_); + this->sha1_helper_ = go_create_sha1_helper(); + go_assert(this->sha1_helper_ != NULL); } Export::Stream::~Stream() @@ -701,7 +700,7 @@ Export::Stream::~Stream() void Export::Stream::write_and_sum_bytes(const char* bytes, size_t length) { - sha1_process_bytes(bytes, length, this->checksum_); + this->sha1_helper_->process_bytes(bytes, length); this->do_write(bytes, length); } @@ -710,14 +709,9 @@ Export::Stream::write_and_sum_bytes(const char* bytes, size_t length) std::string Export::Stream::checksum() { - // Use a union to provide the required alignment. - union - { - char checksum[Export::checksum_len]; - long align; - } u; - sha1_finish_ctx(this->checksum_, u.checksum); - return std::string(u.checksum, Export::checksum_len); + std::string rval = this->sha1_helper_->finish(); + delete this->sha1_helper_; + return rval; } // Write the checksum string to the export data. |