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

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

Issue 2643643008: Delete third_party/hwcplus/ (Closed)
Patch Set: Created 3 years, 11 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 | « third_party/hwcplus/src/hardware.c ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <stdarg.h>
6 #include <stdio.h>
7 #include <string.h>
8
9 #include <android/log.h>
10 #include <cutils/properties.h>
11 #include <hardware/hardware.h>
12
13 #define LOG_BUF_SIZE 1024
14
15 static int default_log_fn(int prio, const char* tag, const char* msg);
16
17 static hwcplus_log_fn_t hwcplus_log_fn = default_log_fn;
18
19 void hwcplus_set_log_fn(hwcplus_log_fn_t fn) {
20 hwcplus_log_fn = fn;
21 }
22
23 #ifndef HAVE_STRLCPY
24 size_t strlcpy(char* dst, const char* src, size_t siz) {
25 char* d = dst;
26 const char* s = src;
27 size_t n = siz;
28
29 /* Copy as many bytes as will fit */
30 if (n != 0) {
31 while (--n != 0) {
32 if ((*d++ = *s++) == '\0')
33 break;
34 }
35 }
36
37 /* Not enough room in dst, add NUL and traverse rest of src */
38 if (n == 0) {
39 if (siz != 0)
40 *d = '\0'; /* NUL-terminate dst */
41 while (*s++) {
42 }
43 }
44
45 return(s - src - 1); /* count does not include NUL */
46 }
47 #endif
48
49 static int default_log_fn(int prio, const char* tag, const char* msg) {
50 fprintf(stderr, "<%d> %s %s\n", prio, tag, msg);
51 }
52
53 int __android_log_write(int prio, const char* tag, const char* msg) {
54 hwcplus_log_fn(prio, tag, msg);
55 }
56
57 int __android_log_print(int prio, const char* tag, const char* fmt, ...) {
58 va_list ap;
59 char buf[LOG_BUF_SIZE];
60
61 va_start(ap, fmt);
62 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
63 va_end(ap);
64
65 return __android_log_write(prio, tag, buf);
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
95 int property_get(const char* key, char* value, const char* default_value) {
96 printf("property_get %s\n", key);
97 const char* r = default_value;
98 if (!r)
99 r = "";
100 strncpy(value, r, PROPERTY_VALUE_MAX);
101 return strlen(r);
102 }
OLDNEW
« no previous file with comments | « third_party/hwcplus/src/hardware.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698