Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <android/log.h> | |
|
rjkroege
2014/06/11 16:02:45
this wouldn't compile on CrOS right? The includes
fjhenigman
2014/06/11 17:43:04
This is src/third_party/hwcplus/include/android/lo
| |
| 10 #include <cutils/properties.h> | |
| 9 #include <hardware/hardware.h> | 11 #include <hardware/hardware.h> |
| 10 #include <cutils/properties.h> | |
| 11 | 12 |
| 12 #define LOG_BUF_SIZE 1024 | 13 #define LOG_BUF_SIZE 1024 |
| 13 | 14 |
| 14 static int default_log_fn(int prio, const char* tag, const char* msg); | 15 static int default_log_fn(int prio, const char* tag, const char* msg); |
| 15 | 16 |
| 16 static hwcplus_log_fn_t hwcplus_log_fn = default_log_fn; | 17 static hwcplus_log_fn_t hwcplus_log_fn = default_log_fn; |
| 17 | 18 |
| 18 void hwcplus_set_log_fn(hwcplus_log_fn_t fn) { | 19 void hwcplus_set_log_fn(hwcplus_log_fn_t fn) { |
| 19 hwcplus_log_fn = fn; | 20 hwcplus_log_fn = fn; |
| 20 } | 21 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 va_list ap; | 58 va_list ap; |
| 58 char buf[LOG_BUF_SIZE]; | 59 char buf[LOG_BUF_SIZE]; |
| 59 | 60 |
| 60 va_start(ap, fmt); | 61 va_start(ap, fmt); |
| 61 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); | 62 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); |
| 62 va_end(ap); | 63 va_end(ap); |
| 63 | 64 |
| 64 return __android_log_write(prio, tag, buf); | 65 return __android_log_write(prio, tag, buf); |
| 65 } | 66 } |
| 66 | 67 |
| 68 void __android_log_assert(const char* cond, const char* tag, const char* fmt, | |
|
rjkroege
2014/06/11 16:02:45
can you line-break per chromium style
fjhenigman
2014/06/11 17:43:04
I made the second line start after the open paren
| |
| 69 ...) { | |
| 70 char buf[LOG_BUF_SIZE]; | |
| 71 | |
| 72 if (fmt) { | |
| 73 va_list ap; | |
| 74 va_start(ap, fmt); | |
| 75 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); | |
| 76 va_end(ap); | |
| 77 } else { | |
| 78 /* Msg not provided, log condition. N.B. Do not use cond directly as | |
| 79 * format string as it could contain spurious '%' syntax (e.g. | |
| 80 * "%d" in "blocks%devs == 0"). | |
| 81 */ | |
| 82 if (cond) | |
| 83 snprintf(buf, LOG_BUF_SIZE, "Assertion failed: %s", cond); | |
| 84 else | |
| 85 snprintf(buf, LOG_BUF_SIZE, "Unspecified assertion failed"); | |
| 86 } | |
| 87 | |
| 88 __android_log_write(ANDROID_LOG_FATAL, tag, buf); | |
| 89 | |
| 90 __builtin_trap(); /* trap so we have a chance to debug the situation */ | |
| 91 } | |
| 92 | |
| 67 int property_get(const char* key, char* value, const char* default_value) { | 93 int property_get(const char* key, char* value, const char* default_value) { |
| 68 printf("property_get %s\n", key); | 94 printf("property_get %s\n", key); |
| 69 const char* r = default_value; | 95 const char* r = default_value; |
| 70 if (!r) | 96 if (!r) |
| 71 r = ""; | 97 r = ""; |
| 72 strncpy(value, r, PROPERTY_VALUE_MAX); | 98 strncpy(value, r, PROPERTY_VALUE_MAX); |
| 73 return strlen(r); | 99 return strlen(r); |
| 74 } | 100 } |
| 75 | |
| OLD | NEW |