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

Side by Side Diff: third_party/hwcplus/src/hwcplus_util.c

Issue 321353002: Add __android_log_assert. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: really fix formatting Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
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
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,
69 const char* tag,
70 const char* fmt,
71 ...) {
72 char buf[LOG_BUF_SIZE];
73
74 if (fmt) {
75 va_list ap;
76 va_start(ap, fmt);
77 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
78 va_end(ap);
79 } else {
80 /* Msg not provided, log condition. N.B. Do not use cond directly as
81 * format string as it could contain spurious '%' syntax (e.g.
82 * "%d" in "blocks%devs == 0").
83 */
84 if (cond)
85 snprintf(buf, LOG_BUF_SIZE, "Assertion failed: %s", cond);
86 else
87 snprintf(buf, LOG_BUF_SIZE, "Unspecified assertion failed");
88 }
89
90 __android_log_write(ANDROID_LOG_FATAL, tag, buf);
91
92 __builtin_trap(); /* trap so we have a chance to debug the situation */
93 }
94
67 int property_get(const char* key, char* value, const char* default_value) { 95 int property_get(const char* key, char* value, const char* default_value) {
68 printf("property_get %s\n", key); 96 printf("property_get %s\n", key);
69 const char* r = default_value; 97 const char* r = default_value;
70 if (!r) 98 if (!r)
71 r = ""; 99 r = "";
72 strncpy(value, r, PROPERTY_VALUE_MAX); 100 strncpy(value, r, PROPERTY_VALUE_MAX);
73 return strlen(r); 101 return strlen(r);
74 } 102 }
75
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698