xref: /aosp_15_r20/external/executorch/runtime/platform/default/minimal.cpp (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 /**
10  * @file
11  * Fallback PAL implementations that do not depend on any assumptions about
12  * capabililties of the system.
13  */
14 
15 // This cpp file will provide weak implementations of the symbols declared in
16 // Platform.h. Client users can strongly define any or all of the functions to
17 // override them.
18 #define ET_INTERNAL_PLATFORM_WEAKNESS ET_WEAK
19 #include <executorch/runtime/platform/platform.h>
20 
21 #include <executorch/runtime/platform/compiler.h>
22 
et_pal_init(void)23 void et_pal_init(void) {}
24 
et_pal_abort(void)25 ET_NORETURN void et_pal_abort(void) {
26   __builtin_trap();
27 }
28 
et_pal_current_ticks(void)29 et_timestamp_t et_pal_current_ticks(void) {
30   // This file cannot make any assumptions about the presence of functions that
31   // return the current time, so all users should provide a strong override for
32   // it. To help make it more obvious when this weak version is being used,
33   // return a number that should be easier to search for than 0.
34   return 11223344;
35 }
36 
et_pal_ticks_to_ns_multiplier(void)37 et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
38   // Since we don't define a tick rate, return a conversion ratio of 1.
39   return {1, 1};
40 }
41 
et_pal_emit_log_message(ET_UNUSED et_timestamp_t timestamp,ET_UNUSED et_pal_log_level_t level,ET_UNUSED const char * filename,ET_UNUSED const char * function,ET_UNUSED size_t line,ET_UNUSED const char * message,ET_UNUSED size_t length)42 void et_pal_emit_log_message(
43     ET_UNUSED et_timestamp_t timestamp,
44     ET_UNUSED et_pal_log_level_t level,
45     ET_UNUSED const char* filename,
46     ET_UNUSED const char* function,
47     ET_UNUSED size_t line,
48     ET_UNUSED const char* message,
49     ET_UNUSED size_t length) {}
50 
et_pal_allocate(ET_UNUSED size_t size)51 void* et_pal_allocate(ET_UNUSED size_t size) {
52   return nullptr;
53 }
54 
et_pal_free(ET_UNUSED void * ptr)55 void et_pal_free(ET_UNUSED void* ptr) {}
56