FFmpeg
x86_32.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2025, Niklas Haas
3  * Copyright © 2018, VideoLAN and dav1d authors
4  * Copyright © 2018, Two Orioles, LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef CHECKASM_PLATFORM_X86_32_H
30 #define CHECKASM_PLATFORM_X86_32_H
31 
32 #include "checkasm/attributes.h"
33 #include "checkasm/checkasm.h"
34 
35 CHECKASM_API void checkasm_checked_call(void *func, ...);
38 
40 
41 #if CHECKASM_HAVE_GENERIC
42  #define checked_call_fn(ret) \
43  _Generic((ret (*)(void)) NULL, \
44  float (*)(void): checkasm_checked_call_float, \
45  double (*)(void): checkasm_checked_call_float, \
46  default: checkasm_checked_call)
47 #else
48  /* Always use float version to not trigger false positives */
49  #define checked_call_fn(ret) checkasm_checked_call_float
50 #endif
51 
52 #define checkasm_declare_impl(ret, ...) \
53  ret (*checked_call)(void *, __VA_ARGS__, int, int, int, int, int, int, int, int, \
54  int, int, int, int, int, int, int) \
55  = (ret (*)(void *, __VA_ARGS__, int, int, int, int, int, int, int, int, int, \
56  int, int, int, int, int, int))(void *) checked_call_fn(ret); \
57  int emms_needed = 0; \
58  (void) emms_needed
59 
60 #define checkasm_call_checked(func, ...) \
61  (checkasm_set_signal_handler_state(1), \
62  checked_call(func, __VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, \
63  1)); \
64  checkasm_set_signal_handler_state(0)
65 
66 #define checkasm_declare_emms(cpu_flags, ret, ...) \
67  checkasm_declare(ret, __VA_ARGS__); \
68  if (checkasm_get_cpu_flags() & (cpu_flags)) { \
69  checked_call = (ret (*)(void *, __VA_ARGS__, int, int, int, int, int, int, int, \
70  int, int, int, int, int, int, int, \
71  int))(void *) checkasm_checked_call_emms; \
72  emms_needed = 1; \
73  }
74 
75 #if defined(__GNUC__) || defined(__clang__)
76  #define checkasm_emms() __asm__ volatile("emms" ::: "memory")
77 #else
78  #define checkasm_emms() checkasm_empty_mmx()
79 #endif
80 
81 #define checkasm_clear_cpu_state() \
82  do { \
83  if (emms_needed) \
84  checkasm_emms(); \
85  } while (0)
86 
87 #define CHECKASM_ALIGNMENT 64
88 
89 #endif /* CHECKASM_PLATFORM_X86_32_H */
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:66
checkasm_empty_mmx
CHECKASM_API void checkasm_empty_mmx(void)
attributes.h
Platform and compiler attribute macros.
checkasm_checked_call
CHECKASM_API void checkasm_checked_call(void *func,...)
checkasm_checked_call_float
CHECKASM_API void checkasm_checked_call_float(void *func,...)
checkasm_checked_call_emms
CHECKASM_API void checkasm_checked_call_emms(void *func,...)
CHECKASM_API
#define CHECKASM_API
Symbol visibility attribute for public API functions.
Definition: attributes.h:90