• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *   http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LIBC_H
17 #define LIBC_H
18 
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <limits.h>
22 #include <link.h>
23 #include <locale.h>
24 struct __locale_map;
25 
26 struct __locale_struct {
27     const struct __locale_map *cat[LC_ALL];
28 };
29 
30 struct tls_module {
31     struct tls_module *next;
32     void *image;
33     size_t len, size, align, offset;
34 };
35 
36 struct __libc {
37 	char can_do_threads;
38 	char threaded;
39 	char secure;
40 	volatile signed char need_locks;
41 	int threads_minus_1;
42 	size_t *auxv;
43 	struct tls_module *tls_head;
44 	size_t tls_size, tls_align, tls_cnt;
45 	size_t page_size;
46 	struct __locale_struct global_locale;
47 #ifdef ENABLE_HWASAN
48 	void (*load_hook)(unsigned long int base, const Elf64_Phdr* phdr, int phnum);
49 	void (*unload_hook)(unsigned long int base, const Elf64_Phdr* phdr, int phnum);
50 #endif
51 };
52 
53 #ifndef PAGE_SIZE
54 #define PAGE_SIZE libc.page_size
55 #endif
56 
57 extern hidden struct __libc __libc;
58 #define libc __libc
59 
60 hidden void __init_libc(char **, char *);
61 hidden void __init_tls(size_t *);
62 hidden void __init_ssp(void *);
63 hidden void __libc_start_init(void);
64 hidden void __funcs_on_exit(void);
65 hidden void __funcs_on_quick_exit(void);
66 hidden void __libc_exit_fini(void);
67 hidden void __fork_handler(int);
68 
69 extern hidden size_t __hwcap;
70 extern hidden size_t __sysinfo;
71 extern char *__progname, *__progname_full;
72 
73 extern hidden const char __libc_version[];
74 
75 hidden void __synccall(void (*)(void *), void *);
76 hidden int __setxid(int, int, int, int);
77 
78 #endif
79