Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: minidump/minidump_system_info_writer.cc

Issue 615923004: Convert COMPILE_ASSERT to static_assert (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 void MinidumpSystemInfoWriter::SetCPUX86Vendor(uint32_t ebx, 42 void MinidumpSystemInfoWriter::SetCPUX86Vendor(uint32_t ebx,
43 uint32_t edx, 43 uint32_t edx,
44 uint32_t ecx) { 44 uint32_t ecx) {
45 DCHECK_EQ(state(), kStateMutable); 45 DCHECK_EQ(state(), kStateMutable);
46 DCHECK(system_info_.ProcessorArchitecture == kMinidumpCPUArchitectureX86 || 46 DCHECK(system_info_.ProcessorArchitecture == kMinidumpCPUArchitectureX86 ||
47 system_info_.ProcessorArchitecture == 47 system_info_.ProcessorArchitecture ==
48 kMinidumpCPUArchitectureX86Win64); 48 kMinidumpCPUArchitectureX86Win64);
49 49
50 COMPILE_ASSERT(arraysize(system_info_.Cpu.X86CpuInfo.VendorId) == 3, 50 static_assert(arraysize(system_info_.Cpu.X86CpuInfo.VendorId) == 3,
51 vendor_id_must_have_3_elements); 51 "vendor id must have 3 elements");
52 52
53 system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx; 53 system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx;
54 system_info_.Cpu.X86CpuInfo.VendorId[1] = edx; 54 system_info_.Cpu.X86CpuInfo.VendorId[1] = edx;
55 system_info_.Cpu.X86CpuInfo.VendorId[2] = ecx; 55 system_info_.Cpu.X86CpuInfo.VendorId[2] = ecx;
56 } 56 }
57 57
58 void MinidumpSystemInfoWriter::SetCPUX86VendorString( 58 void MinidumpSystemInfoWriter::SetCPUX86VendorString(
59 const std::string& vendor) { 59 const std::string& vendor) {
60 DCHECK_EQ(state(), kStateMutable); 60 DCHECK_EQ(state(), kStateMutable);
61 CHECK_EQ(vendor.size(), sizeof(system_info_.Cpu.X86CpuInfo.VendorId)); 61 CHECK_EQ(vendor.size(), sizeof(system_info_.Cpu.X86CpuInfo.VendorId));
62 62
63 uint32_t registers[3]; 63 uint32_t registers[3];
64 COMPILE_ASSERT( 64 static_assert(
65 sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId), 65 sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId),
66 vendor_id_sizes_must_be_equal); 66 "vendor id sizes must be equal");
67 67
68 for (size_t index = 0; index < arraysize(registers); ++index) { 68 for (size_t index = 0; index < arraysize(registers); ++index) {
69 memcpy(&registers[index], 69 memcpy(&registers[index],
70 &vendor[index * sizeof(*registers)], 70 &vendor[index * sizeof(*registers)],
71 sizeof(*registers)); 71 sizeof(*registers));
72 } 72 }
73 73
74 SetCPUX86Vendor(registers[0], registers[1], registers[2]); 74 SetCPUX86Vendor(registers[0], registers[1], registers[2]);
75 } 75 }
76 76
(...skipping 21 matching lines...) Expand all
98 system_info_.Cpu.X86CpuInfo.AMDExtendedCpuFeatures = extended_features; 98 system_info_.Cpu.X86CpuInfo.AMDExtendedCpuFeatures = extended_features;
99 } 99 }
100 100
101 void MinidumpSystemInfoWriter::SetCPUOtherFeatures(uint64_t features_0, 101 void MinidumpSystemInfoWriter::SetCPUOtherFeatures(uint64_t features_0,
102 uint64_t features_1) { 102 uint64_t features_1) {
103 DCHECK_EQ(state(), kStateMutable); 103 DCHECK_EQ(state(), kStateMutable);
104 DCHECK(system_info_.ProcessorArchitecture != kMinidumpCPUArchitectureX86 && 104 DCHECK(system_info_.ProcessorArchitecture != kMinidumpCPUArchitectureX86 &&
105 system_info_.ProcessorArchitecture != 105 system_info_.ProcessorArchitecture !=
106 kMinidumpCPUArchitectureX86Win64); 106 kMinidumpCPUArchitectureX86Win64);
107 107
108 COMPILE_ASSERT( 108 static_assert(arraysize(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2,
109 arraysize(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2, 109 "processor features must have 2 elements");
110 processor_features_must_have_2_elements);
111 110
112 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0; 111 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0;
113 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1; 112 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1;
114 } 113 }
115 114
116 bool MinidumpSystemInfoWriter::Freeze() { 115 bool MinidumpSystemInfoWriter::Freeze() {
117 DCHECK_EQ(state(), kStateMutable); 116 DCHECK_EQ(state(), kStateMutable);
118 CHECK(csd_version_); 117 CHECK(csd_version_);
119 118
120 if (!MinidumpStreamWriter::Freeze()) { 119 if (!MinidumpStreamWriter::Freeze()) {
(...skipping 23 matching lines...) Expand all
144 DCHECK_EQ(state(), kStateWritable); 143 DCHECK_EQ(state(), kStateWritable);
145 144
146 return file_writer->Write(&system_info_, sizeof(system_info_)); 145 return file_writer->Write(&system_info_, sizeof(system_info_));
147 } 146 }
148 147
149 MinidumpStreamType MinidumpSystemInfoWriter::StreamType() const { 148 MinidumpStreamType MinidumpSystemInfoWriter::StreamType() const {
150 return kMinidumpStreamTypeSystemInfo; 149 return kMinidumpStreamTypeSystemInfo;
151 } 150 }
152 151
153 } // namespace crashpad 152 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698