container_support.cc revision 3c07cf6ae2bfc39236e0983a44bab1d4833d5b6d
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 <chre.h>
18
19#include <cinttypes>
20#include <cstdio>
21#include <cstdlib>
22
23/**
24 * @file
25 *
26 * This file supplies implementations for functions used by container_support.h
27 * to allow CHRE containers to be used standalone.
28 */
29
30void *chreHeapAlloc(uint32_t bytes) {
31  return malloc(bytes);
32}
33
34void chreHeapFree(void *ptr) {
35  free(ptr);
36}
37
38void chreAbort(uint32_t abortCode) {
39  // We do not use exit() here because it accepts a signed int and we really
40  // want abort() semantics. Log the failure and abort().
41  fprintf(stderr, "Aborting with code %" PRIu32 "\n", abortCode);
42  abort();
43}
44