1 /* 2 * Copyright (C) 2024 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 MUSL_FDSAN_H 17 #define MUSL_FDSAN_H 18 19 #include <string.h> 20 #include <stdint.h> 21 #include <stdio.h> 22 23 #include "stdatomic_impl.h" 24 25 #define FdTableSize 128 26 27 struct FdEntry { 28 _Atomic(uint64_t) close_tag; 29 _Atomic(char) signal_flag; 30 }; 31 32 struct FdTableOverflow { 33 size_t len; 34 struct FdEntry entries[]; 35 }; 36 37 struct FdTable { 38 _Atomic(enum fdsan_error_level) error_level; 39 struct FdEntry entries[FdTableSize]; 40 _Atomic(struct FdTableOverflow*) overflow; 41 }; 42 43 void __init_fdsan(); 44 45 #endif