• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  * conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  * of conditions and the following disclaimer in the documentation and/or other materials
13  * provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  * to endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _LOS_LMS_H
33 #define _LOS_LMS_H
34 
35 #include <stdio.h>
36 #include <stdint.h>
37 #include <stdlib.h>
38 
39 #ifdef __cplusplus
40 #if __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43 #endif /* __cplusplus */
44 
45 /*
46  * If LMS_CRASH_MODE == 0
47  * the program would NOT be crashed once the sanitizer detected an error.
48  * If LMS_CRASM_MODE > 0
49  * the program would be crashed once the sanitizer detected an error.
50  */
51 #define LMS_CRASH_MODE 0
52 
53 /*
54  * USPACE_MAP_BASE
55  * is the start address of user space.
56  */
57 #define USPACE_MAP_BASE 0x00000000
58 
59 /*
60  * USPACE_MAP_SIZE
61  * is the address size of the user space, and [USPACE_MAP_BASE, USPACE_MAP_BASE + USPACE_MAP_SIZE]
62  * must cover the HEAP section.
63  */
64 #define USPACE_MAP_SIZE 0x3ef00000
65 
66 /*
67  * LMS_OUTPUT_ERROR can be redefined to redirect output logs.
68  */
69 #ifndef LMS_OUTPUT_ERROR
70 #define LMS_OUTPUT_ERROR(fmt, ...)                                             \
71     do {                                                                       \
72         (printf("\033[31;1m"), printf(fmt, ##__VA_ARGS__), printf("\033[0m")); \
73     } while (0)
74 #endif
75 
76 /*
77  * LMS_OUTPUT_INFO can be redefined to redirect output logs.
78  */
79 #ifndef LMS_OUTPUT_INFO
80 #define LMS_OUTPUT_INFO(fmt, ...)                                              \
81     do {                                                                       \
82         (printf("\033[33;1m"), printf(fmt, ##__VA_ARGS__), printf("\033[0m")); \
83     } while (0)
84 #endif
85 
86 
87 #ifdef __cplusplus
88 #if __cplusplus
89 }
90 #endif /* __cplusplus */
91 #endif /* __cplusplus */
92 
93 #endif /* _LOS_LMS_H */