[clang] Handle __declspec() attributes in using
[llvm-project.git] / compiler-rt / lib / sanitizer_common / sanitizer_freebsd.h
blob82b227eab6dab73dbce734891a4a138dcb94da99
1 //===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of Sanitizer runtime. It contains FreeBSD-specific
10 // definitions.
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_FREEBSD_H
15 #define SANITIZER_FREEBSD_H
17 #include "sanitizer_internal_defs.h"
19 // x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
20 // 32-bit mode.
21 #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
22 #include <osreldate.h>
23 #if __FreeBSD_version <= 902001 // v9.2
24 #include <link.h>
25 #include <sys/param.h>
26 #include <ucontext.h>
28 namespace __sanitizer {
30 typedef unsigned long long __xuint64_t;
32 typedef __int32_t __xregister_t;
34 typedef struct __xmcontext {
35 __xregister_t mc_onstack;
36 __xregister_t mc_gs;
37 __xregister_t mc_fs;
38 __xregister_t mc_es;
39 __xregister_t mc_ds;
40 __xregister_t mc_edi;
41 __xregister_t mc_esi;
42 __xregister_t mc_ebp;
43 __xregister_t mc_isp;
44 __xregister_t mc_ebx;
45 __xregister_t mc_edx;
46 __xregister_t mc_ecx;
47 __xregister_t mc_eax;
48 __xregister_t mc_trapno;
49 __xregister_t mc_err;
50 __xregister_t mc_eip;
51 __xregister_t mc_cs;
52 __xregister_t mc_eflags;
53 __xregister_t mc_esp;
54 __xregister_t mc_ss;
56 int mc_len;
57 int mc_fpformat;
58 int mc_ownedfp;
59 __xregister_t mc_flags;
61 int mc_fpstate[128] __aligned(16);
62 __xregister_t mc_fsbase;
63 __xregister_t mc_gsbase;
64 __xregister_t mc_xfpustate;
65 __xregister_t mc_xfpustate_len;
67 int mc_spare2[4];
68 } xmcontext_t;
70 typedef struct __xucontext {
71 sigset_t uc_sigmask;
72 xmcontext_t uc_mcontext;
74 struct __ucontext *uc_link;
75 stack_t uc_stack;
76 int uc_flags;
77 int __spare__[4];
78 } xucontext_t;
80 struct xkinfo_vmentry {
81 int kve_structsize;
82 int kve_type;
83 __xuint64_t kve_start;
84 __xuint64_t kve_end;
85 __xuint64_t kve_offset;
86 __xuint64_t kve_vn_fileid;
87 __uint32_t kve_vn_fsid;
88 int kve_flags;
89 int kve_resident;
90 int kve_private_resident;
91 int kve_protection;
92 int kve_ref_count;
93 int kve_shadow_count;
94 int kve_vn_type;
95 __xuint64_t kve_vn_size;
96 __uint32_t kve_vn_rdev;
97 __uint16_t kve_vn_mode;
98 __uint16_t kve_status;
99 int _kve_ispare[12];
100 char kve_path[PATH_MAX];
103 typedef struct {
104 __uint32_t p_type;
105 __uint32_t p_offset;
106 __uint32_t p_vaddr;
107 __uint32_t p_paddr;
108 __uint32_t p_filesz;
109 __uint32_t p_memsz;
110 __uint32_t p_flags;
111 __uint32_t p_align;
112 } XElf32_Phdr;
114 struct xdl_phdr_info {
115 Elf_Addr dlpi_addr;
116 const char *dlpi_name;
117 const XElf32_Phdr *dlpi_phdr;
118 Elf_Half dlpi_phnum;
119 unsigned long long int dlpi_adds;
120 unsigned long long int dlpi_subs;
121 size_t dlpi_tls_modid;
122 void *dlpi_tls_data;
125 typedef int (*__xdl_iterate_hdr_callback)(struct xdl_phdr_info *, size_t,
126 void *);
127 typedef int xdl_iterate_phdr_t(__xdl_iterate_hdr_callback, void *);
129 #define xdl_iterate_phdr(callback, param) \
130 (((xdl_iterate_phdr_t *)dl_iterate_phdr)((callback), (param)))
132 } // namespace __sanitizer
134 #endif // __FreeBSD_version <= 902001
135 #endif // SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
137 #endif // SANITIZER_FREEBSD_H