1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <cinttypes>
18 #include <cstdarg>
19 #include <cstdio>
20 #include <cstdlib>
21 #include "chre_api/chre.h"
22
23 #include "chre/util/macros.h"
24
25 /**
26 * @file
27 *
28 * This file supplies implementations for functions used by container_support.h
29 * to allow CHRE containers to be used standalone.
30 */
31
chreHeapAlloc(uint32_t bytes)32 void *chreHeapAlloc(uint32_t bytes) {
33 return malloc(bytes);
34 }
35
chreHeapFree(void * ptr)36 void chreHeapFree(void *ptr) {
37 free(ptr);
38 }
39
chreAbort(uint32_t abortCode)40 void chreAbort(uint32_t abortCode) {
41 // We do not use exit() here because it accepts a signed int and we really
42 // want abort() semantics. Log the failure and abort().
43 fprintf(stderr, "Aborting with code %" PRIu32 "\n", abortCode);
44 abort();
45 }
46
47 WEAK_SYMBOL
chreLog(enum chreLogLevel level,const char * formatStr,...)48 void chreLog(enum chreLogLevel level, const char *formatStr, ...) {
49 UNUSED_VAR(level);
50 va_list argList;
51 va_start(argList, formatStr);
52 vprintf(formatStr, argList);
53 printf("\n");
54 va_end(argList);
55 }