| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file is based on the SMSLib library. | 5 // This file is based on the SMSLib library. |
| 6 // | 6 // |
| 7 // SMSLib Sudden Motion Sensor Access Library | 7 // SMSLib Sudden Motion Sensor Access Library |
| 8 // Copyright (c) 2010 Suitable Systems | 8 // Copyright (c) 2010 Suitable Systems |
| 9 // All rights reserved. | 9 // All rights reserved. |
| 10 // | 10 // |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // Request model name from the kernel. | 303 // Request model name from the kernel. |
| 304 char local_model[32]; // size from SMSLib | 304 char local_model[32]; // size from SMSLib |
| 305 size_t local_model_size = sizeof(local_model); | 305 size_t local_model_size = sizeof(local_model); |
| 306 int params[2] = { CTL_HW, HW_MODEL }; | 306 int params[2] = { CTL_HW, HW_MODEL }; |
| 307 if (sysctl(params, 2, local_model, &local_model_size, NULL, 0) != 0) | 307 if (sysctl(params, 2, local_model, &local_model_size, NULL, 0) != 0) |
| 308 return false; | 308 return false; |
| 309 | 309 |
| 310 const SensorDescriptor* sensor_candidate = NULL; | 310 const SensorDescriptor* sensor_candidate = NULL; |
| 311 | 311 |
| 312 // Look for the current model in the supported sensor list. | 312 // Look for the current model in the supported sensor list. |
| 313 base::mac::ScopedCFTypeRef<CFDataRef> board_id_data; | 313 base::ScopedCFTypeRef<CFDataRef> board_id_data; |
| 314 const int kNumSensors = arraysize(kSupportedSensors); | 314 const int kNumSensors = arraysize(kSupportedSensors); |
| 315 | 315 |
| 316 for (int i = 0; i < kNumSensors; ++i) { | 316 for (int i = 0; i < kNumSensors; ++i) { |
| 317 // Check if the supported sensor model name is a prefix | 317 // Check if the supported sensor model name is a prefix |
| 318 // of the local hardware model (empty names are accepted). | 318 // of the local hardware model (empty names are accepted). |
| 319 const char* p1 = kSupportedSensors[i].model_name; | 319 const char* p1 = kSupportedSensors[i].model_name; |
| 320 for (const char* p2 = local_model; *p1 != '\0' && *p1 == *p2; ++p1, ++p2) | 320 for (const char* p2 = local_model; *p1 != '\0' && *p1 == *p2; ++p1, ++p2) |
| 321 continue; | 321 continue; |
| 322 if (*p1 != '\0') | 322 if (*p1 != '\0') |
| 323 continue; | 323 continue; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (value & 0x00800000) | 407 if (value & 0x00800000) |
| 408 return value | 0xff000000; | 408 return value | 0xff000000; |
| 409 break; | 409 break; |
| 410 | 410 |
| 411 default: | 411 default: |
| 412 LOG(FATAL) << "Invalid integer size for sign extension: " << size; | 412 LOG(FATAL) << "Invalid integer size for sign extension: " << size; |
| 413 } | 413 } |
| 414 | 414 |
| 415 return value; | 415 return value; |
| 416 } | 416 } |
| OLD | NEW |