noobs 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYING +339 -0
- package/README.md +46 -0
- package/bin/64bit/obs.lib +0 -0
- package/binding.gyp +23 -0
- package/dist/bin/Qt6Core.dll +0 -0
- package/dist/bin/Qt6Gui.dll +0 -0
- package/dist/bin/Qt6Network.dll +0 -0
- package/dist/bin/Qt6Svg.dll +0 -0
- package/dist/bin/Qt6Widgets.dll +0 -0
- package/dist/bin/Qt6Xml.dll +0 -0
- package/dist/bin/avcodec-61.dll +0 -0
- package/dist/bin/avdevice-61.dll +0 -0
- package/dist/bin/avfilter-10.dll +0 -0
- package/dist/bin/avformat-61.dll +0 -0
- package/dist/bin/avutil-59.dll +0 -0
- package/dist/bin/datachannel.dll +0 -0
- package/dist/bin/libcurl.dll +0 -0
- package/dist/bin/libobs-d3d11.dll +0 -0
- package/dist/bin/libobs-opengl.dll +0 -0
- package/dist/bin/libobs-winrt.dll +0 -0
- package/dist/bin/librist.dll +0 -0
- package/dist/bin/libx264-164.dll +0 -0
- package/dist/bin/lua51.dll +0 -0
- package/dist/bin/obs-amf-test.exe +0 -0
- package/dist/bin/obs-ffmpeg-mux.exe +0 -0
- package/dist/bin/obs-frontend-api.dll +0 -0
- package/dist/bin/obs-scripting.dll +0 -0
- package/dist/bin/obs.dll +0 -0
- package/dist/bin/srt.dll +0 -0
- package/dist/bin/swresample-5.dll +0 -0
- package/dist/bin/swscale-8.dll +0 -0
- package/dist/bin/w32-pthreads.dll +0 -0
- package/dist/bin/zlib.dll +0 -0
- package/dist/effects/area.effect +250 -0
- package/dist/effects/bicubic_scale.effect +236 -0
- package/dist/effects/bilinear_lowres_scale.effect +123 -0
- package/dist/effects/color.effect +172 -0
- package/dist/effects/default.effect +254 -0
- package/dist/effects/default_rect.effect +84 -0
- package/dist/effects/deinterlace_base.effect +325 -0
- package/dist/effects/deinterlace_blend.effect +21 -0
- package/dist/effects/deinterlace_blend_2x.effect +21 -0
- package/dist/effects/deinterlace_discard.effect +21 -0
- package/dist/effects/deinterlace_discard_2x.effect +21 -0
- package/dist/effects/deinterlace_linear.effect +21 -0
- package/dist/effects/deinterlace_linear_2x.effect +21 -0
- package/dist/effects/deinterlace_yadif.effect +21 -0
- package/dist/effects/deinterlace_yadif_2x.effect +21 -0
- package/dist/effects/format_conversion.effect +1823 -0
- package/dist/effects/lanczos_scale.effect +292 -0
- package/dist/effects/opaque.effect +159 -0
- package/dist/effects/premultiplied_alpha.effect +38 -0
- package/dist/effects/repeat.effect +36 -0
- package/dist/effects/solid.effect +80 -0
- package/dist/noobs.node +0 -0
- package/dist/plugins/obs-ffmpeg.dll +0 -0
- package/dist/plugins/obs-x264.dll +0 -0
- package/dist/plugins/win-capture.dll +0 -0
- package/include/audio-monitoring/osx/mac-helpers.h +13 -0
- package/include/audio-monitoring/pulse/pulseaudio-wrapper.h +212 -0
- package/include/audio-monitoring/win32/wasapi-output.h +22 -0
- package/include/callback/calldata.h +195 -0
- package/include/callback/decl.h +61 -0
- package/include/callback/proc.h +52 -0
- package/include/callback/signal.h +73 -0
- package/include/graphics/axisang.h +65 -0
- package/include/graphics/bounds.h +108 -0
- package/include/graphics/device-exports.h +177 -0
- package/include/graphics/effect-parser.h +290 -0
- package/include/graphics/effect.h +190 -0
- package/include/graphics/graphics-internal.h +335 -0
- package/include/graphics/graphics.h +1024 -0
- package/include/graphics/half.h +100 -0
- package/include/graphics/image-file.h +124 -0
- package/include/graphics/input.h +34 -0
- package/include/graphics/libnsgif/libnsgif.h +142 -0
- package/include/graphics/math-defs.h +45 -0
- package/include/graphics/math-extra.h +61 -0
- package/include/graphics/matrix3.h +98 -0
- package/include/graphics/matrix4.h +102 -0
- package/include/graphics/plane.h +85 -0
- package/include/graphics/quat.h +170 -0
- package/include/graphics/shader-parser.h +273 -0
- package/include/graphics/srgb.h +177 -0
- package/include/graphics/vec2.h +148 -0
- package/include/graphics/vec3.h +224 -0
- package/include/graphics/vec4.h +241 -0
- package/include/media-io/audio-io.h +228 -0
- package/include/media-io/audio-math.h +43 -0
- package/include/media-io/audio-resampler.h +44 -0
- package/include/media-io/format-conversion.h +50 -0
- package/include/media-io/frame-rate.h +29 -0
- package/include/media-io/media-io-defs.h +20 -0
- package/include/media-io/media-remux.h +37 -0
- package/include/media-io/video-frame.h +64 -0
- package/include/media-io/video-io.h +338 -0
- package/include/media-io/video-scaler.h +43 -0
- package/include/obs-audio-controls.h +250 -0
- package/include/obs-av1.h +47 -0
- package/include/obs-avc.h +55 -0
- package/include/obs-config.h +52 -0
- package/include/obs-data.h +311 -0
- package/include/obs-defs.h +52 -0
- package/include/obs-encoder.h +361 -0
- package/include/obs-ffmpeg-compat.h +13 -0
- package/include/obs-hevc.h +81 -0
- package/include/obs-hotkey.h +271 -0
- package/include/obs-hotkeys.h +653 -0
- package/include/obs-interaction.h +56 -0
- package/include/obs-internal.h +1459 -0
- package/include/obs-missing-files.h +53 -0
- package/include/obs-module.h +181 -0
- package/include/obs-nal.h +37 -0
- package/include/obs-nix-platform.h +53 -0
- package/include/obs-nix-wayland.h +24 -0
- package/include/obs-nix-x11.h +22 -0
- package/include/obs-nix.h +42 -0
- package/include/obs-output.h +96 -0
- package/include/obs-properties.h +364 -0
- package/include/obs-scene.h +127 -0
- package/include/obs-service.h +115 -0
- package/include/obs-source.h +568 -0
- package/include/obs.h +2608 -0
- package/include/obsconfig.h +13 -0
- package/include/obsversion.h +5 -0
- package/include/util/apple/cfstring-utils.h +16 -0
- package/include/util/array-serializer.h +37 -0
- package/include/util/base.h +97 -0
- package/include/util/bitstream.h +28 -0
- package/include/util/bmem.h +94 -0
- package/include/util/buffered-file-serializer.h +32 -0
- package/include/util/c99defs.h +75 -0
- package/include/util/cf-lexer.h +199 -0
- package/include/util/cf-parser.h +281 -0
- package/include/util/circlebuf.h +319 -0
- package/include/util/config-file.h +103 -0
- package/include/util/crc32.h +29 -0
- package/include/util/curl/curl-helper.h +35 -0
- package/include/util/darray.h +606 -0
- package/include/util/deque.h +319 -0
- package/include/util/dstr.h +320 -0
- package/include/util/file-serializer.h +34 -0
- package/include/util/lexer.h +273 -0
- package/include/util/pipe.h +52 -0
- package/include/util/platform.h +223 -0
- package/include/util/profiler.h +97 -0
- package/include/util/serializer.h +158 -0
- package/include/util/simde/check.h +285 -0
- package/include/util/simde/debug-trap.h +117 -0
- package/include/util/simde/hedley.h +2123 -0
- package/include/util/simde/simde-align.h +481 -0
- package/include/util/simde/simde-arch.h +537 -0
- package/include/util/simde/simde-common.h +918 -0
- package/include/util/simde/simde-constify.h +925 -0
- package/include/util/simde/simde-detect-clang.h +114 -0
- package/include/util/simde/simde-diagnostic.h +447 -0
- package/include/util/simde/simde-features.h +550 -0
- package/include/util/simde/simde-math.h +1858 -0
- package/include/util/simde/x86/mmx.h +2456 -0
- package/include/util/simde/x86/sse.h +4479 -0
- package/include/util/simde/x86/sse2.h +7549 -0
- package/include/util/source-profiler.h +66 -0
- package/include/util/sse-intrin.h +32 -0
- package/include/util/task.h +22 -0
- package/include/util/text-lookup.h +45 -0
- package/include/util/threading-posix.h +77 -0
- package/include/util/threading-windows.h +142 -0
- package/include/util/threading.h +103 -0
- package/include/util/utf8.h +35 -0
- package/include/util/uthash.h +34 -0
- package/include/util/util_uint128.h +108 -0
- package/include/util/util_uint64.h +34 -0
- package/include/util/windows/device-enum.h +14 -0
- package/include/util/windows/obfuscate.h +16 -0
- package/include/util/windows/win-registry.h +37 -0
- package/include/util/windows/win-version.h +57 -0
- package/include/util/windows/window-helpers.h +47 -0
- package/index.d.ts +38 -0
- package/index.js +8 -0
- package/package.json +31 -0
- package/src/main.cpp +321 -0
- package/src/obs_interface.cpp +605 -0
- package/src/obs_interface.h +74 -0
- package/src/utils.cpp +80 -0
- package/src/utils.h +3 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "c99defs.h"
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* General programmable serialization functions. (A shared interface to
|
|
23
|
+
* various reading/writing to/from different inputs/outputs)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
enum serialize_seek_type { SERIALIZE_SEEK_START, SERIALIZE_SEEK_CURRENT, SERIALIZE_SEEK_END };
|
|
31
|
+
|
|
32
|
+
struct serializer {
|
|
33
|
+
void *data;
|
|
34
|
+
|
|
35
|
+
size_t (*read)(void *, void *, size_t);
|
|
36
|
+
size_t (*write)(void *, const void *, size_t);
|
|
37
|
+
int64_t (*seek)(void *, int64_t, enum serialize_seek_type);
|
|
38
|
+
int64_t (*get_pos)(void *);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
static inline size_t s_read(struct serializer *s, void *data, size_t size)
|
|
42
|
+
{
|
|
43
|
+
if (s && s->read && data && size)
|
|
44
|
+
return s->read(s->data, (void *)data, size);
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static inline size_t s_write(struct serializer *s, const void *data, size_t size)
|
|
49
|
+
{
|
|
50
|
+
if (s && s->write && data && size)
|
|
51
|
+
return s->write(s->data, (void *)data, size);
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static inline size_t serialize(struct serializer *s, void *data, size_t len)
|
|
56
|
+
{
|
|
57
|
+
if (s) {
|
|
58
|
+
if (s->write)
|
|
59
|
+
return s->write(s->data, data, len);
|
|
60
|
+
else if (s->read)
|
|
61
|
+
return s->read(s->data, data, len);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static inline int64_t serializer_seek(struct serializer *s, int64_t offset, enum serialize_seek_type seek_type)
|
|
68
|
+
{
|
|
69
|
+
if (s && s->seek)
|
|
70
|
+
return s->seek(s->data, offset, seek_type);
|
|
71
|
+
return -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static inline int64_t serializer_get_pos(struct serializer *s)
|
|
75
|
+
{
|
|
76
|
+
if (s && s->get_pos)
|
|
77
|
+
return s->get_pos(s->data);
|
|
78
|
+
return -1;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* formatted this to be similar to the AVIO layout that ffmpeg uses */
|
|
82
|
+
|
|
83
|
+
static inline void s_w8(struct serializer *s, uint8_t u8)
|
|
84
|
+
{
|
|
85
|
+
s_write(s, &u8, sizeof(uint8_t));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static inline void s_wl16(struct serializer *s, uint16_t u16)
|
|
89
|
+
{
|
|
90
|
+
s_w8(s, (uint8_t)u16);
|
|
91
|
+
s_w8(s, u16 >> 8);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static inline void s_wl24(struct serializer *s, uint32_t u24)
|
|
95
|
+
{
|
|
96
|
+
s_w8(s, (uint8_t)u24);
|
|
97
|
+
s_wl16(s, (uint16_t)(u24 >> 8));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static inline void s_wl32(struct serializer *s, uint32_t u32)
|
|
101
|
+
{
|
|
102
|
+
s_wl16(s, (uint16_t)u32);
|
|
103
|
+
s_wl16(s, (uint16_t)(u32 >> 16));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static inline void s_wl64(struct serializer *s, uint64_t u64)
|
|
107
|
+
{
|
|
108
|
+
s_wl32(s, (uint32_t)u64);
|
|
109
|
+
s_wl32(s, (uint32_t)(u64 >> 32));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static inline void s_wlf(struct serializer *s, float f)
|
|
113
|
+
{
|
|
114
|
+
s_wl32(s, *(uint32_t *)&f);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static inline void s_wld(struct serializer *s, double d)
|
|
118
|
+
{
|
|
119
|
+
s_wl64(s, *(uint64_t *)&d);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static inline void s_wb16(struct serializer *s, uint16_t u16)
|
|
123
|
+
{
|
|
124
|
+
s_w8(s, u16 >> 8);
|
|
125
|
+
s_w8(s, (uint8_t)u16);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static inline void s_wb24(struct serializer *s, uint32_t u24)
|
|
129
|
+
{
|
|
130
|
+
s_wb16(s, (uint16_t)(u24 >> 8));
|
|
131
|
+
s_w8(s, (uint8_t)u24);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static inline void s_wb32(struct serializer *s, uint32_t u32)
|
|
135
|
+
{
|
|
136
|
+
s_wb16(s, (uint16_t)(u32 >> 16));
|
|
137
|
+
s_wb16(s, (uint16_t)u32);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static inline void s_wb64(struct serializer *s, uint64_t u64)
|
|
141
|
+
{
|
|
142
|
+
s_wb32(s, (uint32_t)(u64 >> 32));
|
|
143
|
+
s_wb32(s, (uint32_t)u64);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static inline void s_wbf(struct serializer *s, float f)
|
|
147
|
+
{
|
|
148
|
+
s_wb32(s, *(uint32_t *)&f);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static inline void s_wbd(struct serializer *s, double d)
|
|
152
|
+
{
|
|
153
|
+
s_wb64(s, *(uint64_t *)&d);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
#ifdef __cplusplus
|
|
157
|
+
}
|
|
158
|
+
#endif
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/* Check (assertions)
|
|
2
|
+
* Portable Snippets - https://gitub.com/nemequ/portable-snippets
|
|
3
|
+
* Created by Evan Nemerson <evan@nemerson.com>
|
|
4
|
+
*
|
|
5
|
+
* To the extent possible under law, the authors have waived all
|
|
6
|
+
* copyright and related or neighboring rights to this code. For
|
|
7
|
+
* details, see the Creative Commons Zero 1.0 Universal license at
|
|
8
|
+
* https://creativecommons.org/publicdomain/zero/1.0/
|
|
9
|
+
*
|
|
10
|
+
* SPDX-License-Identifier: CC0-1.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#if !defined(SIMDE_CHECK_H)
|
|
14
|
+
#define SIMDE_CHECK_H
|
|
15
|
+
|
|
16
|
+
#if !defined(SIMDE_NDEBUG) && !defined(SIMDE_DEBUG)
|
|
17
|
+
#define SIMDE_NDEBUG 1
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#include "hedley.h"
|
|
21
|
+
#include "simde-diagnostic.h"
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
|
|
24
|
+
#if !defined(_WIN32)
|
|
25
|
+
#define SIMDE_SIZE_MODIFIER "z"
|
|
26
|
+
#define SIMDE_CHAR_MODIFIER "hh"
|
|
27
|
+
#define SIMDE_SHORT_MODIFIER "h"
|
|
28
|
+
#else
|
|
29
|
+
#if defined(_M_X64) || defined(__amd64__)
|
|
30
|
+
#define SIMDE_SIZE_MODIFIER "I64"
|
|
31
|
+
#else
|
|
32
|
+
#define SIMDE_SIZE_MODIFIER ""
|
|
33
|
+
#endif
|
|
34
|
+
#define SIMDE_CHAR_MODIFIER ""
|
|
35
|
+
#define SIMDE_SHORT_MODIFIER ""
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
|
|
39
|
+
#define SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
40
|
+
__pragma(warning(push)) __pragma(warning(disable : 4127))
|
|
41
|
+
#define SIMDE_POP_DISABLE_MSVC_C4127_ __pragma(warning(pop))
|
|
42
|
+
#else
|
|
43
|
+
#define SIMDE_PUSH_DISABLE_MSVC_C4127_
|
|
44
|
+
#define SIMDE_POP_DISABLE_MSVC_C4127_
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#if !defined(simde_errorf)
|
|
48
|
+
#if defined(__has_include)
|
|
49
|
+
#if __has_include(<stdio.h>)
|
|
50
|
+
#include <stdio.h>
|
|
51
|
+
#endif
|
|
52
|
+
#elif defined(SIMDE_STDC_HOSTED)
|
|
53
|
+
#if SIMDE_STDC_HOSTED == 1
|
|
54
|
+
#include <stdio.h>
|
|
55
|
+
#endif
|
|
56
|
+
#elif defined(__STDC_HOSTED__)
|
|
57
|
+
#if __STDC_HOSTETD__ == 1
|
|
58
|
+
#include <stdio.h>
|
|
59
|
+
#endif
|
|
60
|
+
#endif
|
|
61
|
+
|
|
62
|
+
#include "debug-trap.h"
|
|
63
|
+
|
|
64
|
+
HEDLEY_DIAGNOSTIC_PUSH
|
|
65
|
+
SIMDE_DIAGNOSTIC_DISABLE_VARIADIC_MACROS_
|
|
66
|
+
#if defined(EOF)
|
|
67
|
+
#define simde_errorf(format, ...) \
|
|
68
|
+
(fprintf(stderr, format, __VA_ARGS__), abort())
|
|
69
|
+
#else
|
|
70
|
+
#define simde_errorf(format, ...) (simde_trap())
|
|
71
|
+
#endif
|
|
72
|
+
HEDLEY_DIAGNOSTIC_POP
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
#define simde_error(msg) simde_errorf("%s", msg)
|
|
76
|
+
|
|
77
|
+
#if defined(SIMDE_NDEBUG) || \
|
|
78
|
+
(defined(__cplusplus) && (__cplusplus < 201103L)) || \
|
|
79
|
+
(defined(__STDC__) && (__STDC__ < 199901L))
|
|
80
|
+
#if defined(SIMDE_CHECK_FAIL_DEFINED)
|
|
81
|
+
#define simde_assert(expr)
|
|
82
|
+
#else
|
|
83
|
+
#if defined(HEDLEY_ASSUME)
|
|
84
|
+
#define simde_assert(expr) HEDLEY_ASSUME(expr)
|
|
85
|
+
#elif HEDLEY_GCC_VERSION_CHECK(4, 5, 0)
|
|
86
|
+
#define simde_assert(expr) ((void)(!!(expr) ? 1 : (__builtin_unreachable(), 1)))
|
|
87
|
+
#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0)
|
|
88
|
+
#define simde_assert(expr) __assume(expr)
|
|
89
|
+
#else
|
|
90
|
+
#define simde_assert(expr)
|
|
91
|
+
#endif
|
|
92
|
+
#endif
|
|
93
|
+
#define simde_assert_true(expr) simde_assert(expr)
|
|
94
|
+
#define simde_assert_false(expr) simde_assert(!(expr))
|
|
95
|
+
#define simde_assert_type_full(prefix, suffix, T, fmt, a, op, b) \
|
|
96
|
+
simde_assert(((a)op(b)))
|
|
97
|
+
#define simde_assert_double_equal(a, b, precision)
|
|
98
|
+
#define simde_assert_string_equal(a, b)
|
|
99
|
+
#define simde_assert_string_not_equal(a, b)
|
|
100
|
+
#define simde_assert_memory_equal(size, a, b)
|
|
101
|
+
#define simde_assert_memory_not_equal(size, a, b)
|
|
102
|
+
#else
|
|
103
|
+
#define simde_assert(expr) \
|
|
104
|
+
do { \
|
|
105
|
+
if (!HEDLEY_LIKELY(expr)) { \
|
|
106
|
+
simde_error("assertion failed: " #expr "\n"); \
|
|
107
|
+
} \
|
|
108
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
109
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
110
|
+
|
|
111
|
+
#define simde_assert_true(expr) \
|
|
112
|
+
do { \
|
|
113
|
+
if (!HEDLEY_LIKELY(expr)) { \
|
|
114
|
+
simde_error("assertion failed: " #expr \
|
|
115
|
+
" is not true\n"); \
|
|
116
|
+
} \
|
|
117
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
118
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
119
|
+
|
|
120
|
+
#define simde_assert_false(expr) \
|
|
121
|
+
do { \
|
|
122
|
+
if (!HEDLEY_LIKELY(!(expr))) { \
|
|
123
|
+
simde_error("assertion failed: " #expr \
|
|
124
|
+
" is not false\n"); \
|
|
125
|
+
} \
|
|
126
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
127
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
128
|
+
|
|
129
|
+
#define simde_assert_type_full(prefix, suffix, T, fmt, a, op, b) \
|
|
130
|
+
do { \
|
|
131
|
+
T simde_tmp_a_ = (a); \
|
|
132
|
+
T simde_tmp_b_ = (b); \
|
|
133
|
+
if (!(simde_tmp_a_ op simde_tmp_b_)) { \
|
|
134
|
+
simde_errorf("assertion failed: %s %s %s (" prefix \
|
|
135
|
+
"%" fmt suffix " %s " prefix \
|
|
136
|
+
"%" fmt suffix ")\n", \
|
|
137
|
+
#a, #op, #b, simde_tmp_a_, #op, \
|
|
138
|
+
simde_tmp_b_); \
|
|
139
|
+
} \
|
|
140
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
141
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
142
|
+
|
|
143
|
+
#define simde_assert_double_equal(a, b, precision) \
|
|
144
|
+
do { \
|
|
145
|
+
const double simde_tmp_a_ = (a); \
|
|
146
|
+
const double simde_tmp_b_ = (b); \
|
|
147
|
+
const double simde_tmp_diff_ = \
|
|
148
|
+
((simde_tmp_a_ - simde_tmp_b_) < 0) \
|
|
149
|
+
? -(simde_tmp_a_ - simde_tmp_b_) \
|
|
150
|
+
: (simde_tmp_a_ - simde_tmp_b_); \
|
|
151
|
+
if (HEDLEY_UNLIKELY(simde_tmp_diff_ > 1e-##precision)) { \
|
|
152
|
+
simde_errorf( \
|
|
153
|
+
"assertion failed: %s == %s (%0." #precision \
|
|
154
|
+
"g == %0." #precision "g)\n", \
|
|
155
|
+
#a, #b, simde_tmp_a_, simde_tmp_b_); \
|
|
156
|
+
} \
|
|
157
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
158
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
159
|
+
|
|
160
|
+
#include <string.h>
|
|
161
|
+
#define simde_assert_string_equal(a, b) \
|
|
162
|
+
do { \
|
|
163
|
+
const char *simde_tmp_a_ = a; \
|
|
164
|
+
const char *simde_tmp_b_ = b; \
|
|
165
|
+
if (HEDLEY_UNLIKELY(strcmp(simde_tmp_a_, simde_tmp_b_) != \
|
|
166
|
+
0)) { \
|
|
167
|
+
simde_errorf( \
|
|
168
|
+
"assertion failed: string %s == %s (\"%s\" == \"%s\")\n", \
|
|
169
|
+
#a, #b, simde_tmp_a_, simde_tmp_b_); \
|
|
170
|
+
} \
|
|
171
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
172
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
173
|
+
|
|
174
|
+
#define simde_assert_string_not_equal(a, b) \
|
|
175
|
+
do { \
|
|
176
|
+
const char *simde_tmp_a_ = a; \
|
|
177
|
+
const char *simde_tmp_b_ = b; \
|
|
178
|
+
if (HEDLEY_UNLIKELY(strcmp(simde_tmp_a_, simde_tmp_b_) == \
|
|
179
|
+
0)) { \
|
|
180
|
+
simde_errorf( \
|
|
181
|
+
"assertion failed: string %s != %s (\"%s\" == \"%s\")\n", \
|
|
182
|
+
#a, #b, simde_tmp_a_, simde_tmp_b_); \
|
|
183
|
+
} \
|
|
184
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
185
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
186
|
+
|
|
187
|
+
#define simde_assert_memory_equal(size, a, b) \
|
|
188
|
+
do { \
|
|
189
|
+
const unsigned char *simde_tmp_a_ = \
|
|
190
|
+
(const unsigned char *)(a); \
|
|
191
|
+
const unsigned char *simde_tmp_b_ = \
|
|
192
|
+
(const unsigned char *)(b); \
|
|
193
|
+
const size_t simde_tmp_size_ = (size); \
|
|
194
|
+
if (HEDLEY_UNLIKELY(memcmp(simde_tmp_a_, simde_tmp_b_, \
|
|
195
|
+
simde_tmp_size_)) != 0) { \
|
|
196
|
+
size_t simde_tmp_pos_; \
|
|
197
|
+
for (simde_tmp_pos_ = 0; \
|
|
198
|
+
simde_tmp_pos_ < simde_tmp_size_; \
|
|
199
|
+
simde_tmp_pos_++) { \
|
|
200
|
+
if (simde_tmp_a_[simde_tmp_pos_] != \
|
|
201
|
+
simde_tmp_b_[simde_tmp_pos_]) { \
|
|
202
|
+
simde_errorf( \
|
|
203
|
+
"assertion failed: memory %s == %s, at offset %" SIMDE_SIZE_MODIFIER \
|
|
204
|
+
"u\n", \
|
|
205
|
+
#a, #b, simde_tmp_pos_); \
|
|
206
|
+
break; \
|
|
207
|
+
} \
|
|
208
|
+
} \
|
|
209
|
+
} \
|
|
210
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
211
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
212
|
+
|
|
213
|
+
#define simde_assert_memory_not_equal(size, a, b) \
|
|
214
|
+
do { \
|
|
215
|
+
const unsigned char *simde_tmp_a_ = \
|
|
216
|
+
(const unsigned char *)(a); \
|
|
217
|
+
const unsigned char *simde_tmp_b_ = \
|
|
218
|
+
(const unsigned char *)(b); \
|
|
219
|
+
const size_t simde_tmp_size_ = (size); \
|
|
220
|
+
if (HEDLEY_UNLIKELY(memcmp(simde_tmp_a_, simde_tmp_b_, \
|
|
221
|
+
simde_tmp_size_)) == 0) { \
|
|
222
|
+
simde_errorf( \
|
|
223
|
+
"assertion failed: memory %s != %s (%" SIMDE_SIZE_MODIFIER \
|
|
224
|
+
"u bytes)\n", \
|
|
225
|
+
#a, #b, simde_tmp_size_); \
|
|
226
|
+
} \
|
|
227
|
+
SIMDE_PUSH_DISABLE_MSVC_C4127_ \
|
|
228
|
+
} while (0) SIMDE_POP_DISABLE_MSVC_C4127_
|
|
229
|
+
#endif
|
|
230
|
+
|
|
231
|
+
#define simde_assert_type(T, fmt, a, op, b) \
|
|
232
|
+
simde_assert_type_full("", "", T, fmt, a, op, b)
|
|
233
|
+
|
|
234
|
+
#define simde_assert_char(a, op, b) \
|
|
235
|
+
simde_assert_type_full("'\\x", "'", char, \
|
|
236
|
+
"02" SIMDE_CHAR_MODIFIER "x", a, op, b)
|
|
237
|
+
#define simde_assert_uchar(a, op, b) \
|
|
238
|
+
simde_assert_type_full("'\\x", "'", unsigned char, \
|
|
239
|
+
"02" SIMDE_CHAR_MODIFIER "x", a, op, b)
|
|
240
|
+
#define simde_assert_short(a, op, b) \
|
|
241
|
+
simde_assert_type(short, SIMDE_SHORT_MODIFIER "d", a, op, b)
|
|
242
|
+
#define simde_assert_ushort(a, op, b) \
|
|
243
|
+
simde_assert_type(unsigned short, SIMDE_SHORT_MODIFIER "u", a, op, b)
|
|
244
|
+
#define simde_assert_int(a, op, b) simde_assert_type(int, "d", a, op, b)
|
|
245
|
+
#define simde_assert_uint(a, op, b) \
|
|
246
|
+
simde_assert_type(unsigned int, "u", a, op, b)
|
|
247
|
+
#define simde_assert_long(a, op, b) simde_assert_type(long int, "ld", a, op, b)
|
|
248
|
+
#define simde_assert_ulong(a, op, b) \
|
|
249
|
+
simde_assert_type(unsigned long int, "lu", a, op, b)
|
|
250
|
+
#define simde_assert_llong(a, op, b) \
|
|
251
|
+
simde_assert_type(long long int, "lld", a, op, b)
|
|
252
|
+
#define simde_assert_ullong(a, op, b) \
|
|
253
|
+
simde_assert_type(unsigned long long int, "llu", a, op, b)
|
|
254
|
+
|
|
255
|
+
#define simde_assert_size(a, op, b) \
|
|
256
|
+
simde_assert_type(size_t, SIMDE_SIZE_MODIFIER "u", a, op, b)
|
|
257
|
+
|
|
258
|
+
#define simde_assert_float(a, op, b) simde_assert_type(float, "f", a, op, b)
|
|
259
|
+
#define simde_assert_double(a, op, b) simde_assert_type(double, "g", a, op, b)
|
|
260
|
+
#define simde_assert_ptr(a, op, b) \
|
|
261
|
+
simde_assert_type(const void *, "p", a, op, b)
|
|
262
|
+
|
|
263
|
+
#define simde_assert_int8(a, op, b) simde_assert_type(int8_t, PRIi8, a, op, b)
|
|
264
|
+
#define simde_assert_uint8(a, op, b) simde_assert_type(uint8_t, PRIu8, a, op, b)
|
|
265
|
+
#define simde_assert_int16(a, op, b) \
|
|
266
|
+
simde_assert_type(int16_t, PRIi16, a, op, b)
|
|
267
|
+
#define simde_assert_uint16(a, op, b) \
|
|
268
|
+
simde_assert_type(uint16_t, PRIu16, a, op, b)
|
|
269
|
+
#define simde_assert_int32(a, op, b) \
|
|
270
|
+
simde_assert_type(int32_t, PRIi32, a, op, b)
|
|
271
|
+
#define simde_assert_uint32(a, op, b) \
|
|
272
|
+
simde_assert_type(uint32_t, PRIu32, a, op, b)
|
|
273
|
+
#define simde_assert_int64(a, op, b) \
|
|
274
|
+
simde_assert_type(int64_t, PRIi64, a, op, b)
|
|
275
|
+
#define simde_assert_uint64(a, op, b) \
|
|
276
|
+
simde_assert_type(uint64_t, PRIu64, a, op, b)
|
|
277
|
+
|
|
278
|
+
#define simde_assert_ptr_equal(a, b) simde_assert_ptr(a, ==, b)
|
|
279
|
+
#define simde_assert_ptr_not_equal(a, b) simde_assert_ptr(a, !=, b)
|
|
280
|
+
#define simde_assert_null(ptr) simde_assert_ptr(ptr, ==, NULL)
|
|
281
|
+
#define simde_assert_not_null(ptr) simde_assert_ptr(ptr, !=, NULL)
|
|
282
|
+
#define simde_assert_ptr_null(ptr) simde_assert_ptr(ptr, ==, NULL)
|
|
283
|
+
#define simde_assert_ptr_not_null(ptr) simde_assert_ptr(ptr, !=, NULL)
|
|
284
|
+
|
|
285
|
+
#endif /* !defined(SIMDE_CHECK_H) */
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* Debugging assertions and traps
|
|
2
|
+
* Portable Snippets - https://gitub.com/nemequ/portable-snippets
|
|
3
|
+
* Created by Evan Nemerson <evan@nemerson.com>
|
|
4
|
+
*
|
|
5
|
+
* To the extent possible under law, the authors have waived all
|
|
6
|
+
* copyright and related or neighboring rights to this code. For
|
|
7
|
+
* details, see the Creative Commons Zero 1.0 Universal license at
|
|
8
|
+
* https://creativecommons.org/publicdomain/zero/1.0/
|
|
9
|
+
*
|
|
10
|
+
* SPDX-License-Identifier: CC0-1.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#if !defined(SIMDE_DEBUG_TRAP_H)
|
|
14
|
+
#define SIMDE_DEBUG_TRAP_H
|
|
15
|
+
|
|
16
|
+
#if !defined(SIMDE_NDEBUG) && defined(NDEBUG) && !defined(SIMDE_DEBUG)
|
|
17
|
+
#define SIMDE_NDEBUG 1
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#if defined(__has_builtin) && !defined(__ibmxl__)
|
|
21
|
+
#if __has_builtin(__builtin_debugtrap)
|
|
22
|
+
#define simde_trap() __builtin_debugtrap()
|
|
23
|
+
#elif __has_builtin(__debugbreak)
|
|
24
|
+
#define simde_trap() __debugbreak()
|
|
25
|
+
#endif
|
|
26
|
+
#endif
|
|
27
|
+
#if !defined(simde_trap)
|
|
28
|
+
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
|
29
|
+
#define simde_trap() __debugbreak()
|
|
30
|
+
#elif defined(__ARMCC_VERSION)
|
|
31
|
+
#define simde_trap() __breakpoint(42)
|
|
32
|
+
#elif defined(__ibmxl__) || defined(__xlC__)
|
|
33
|
+
#include <builtins.h>
|
|
34
|
+
#define simde_trap() __trap(42)
|
|
35
|
+
#elif defined(__DMC__) && defined(_M_IX86)
|
|
36
|
+
static inline void simde_trap(void)
|
|
37
|
+
{
|
|
38
|
+
__asm int 3h;
|
|
39
|
+
}
|
|
40
|
+
#elif defined(__i386__) || defined(__x86_64__)
|
|
41
|
+
static inline void simde_trap(void)
|
|
42
|
+
{
|
|
43
|
+
__asm__ __volatile__("int $03");
|
|
44
|
+
}
|
|
45
|
+
#elif defined(__thumb__)
|
|
46
|
+
static inline void simde_trap(void)
|
|
47
|
+
{
|
|
48
|
+
__asm__ __volatile__(".inst 0xde01");
|
|
49
|
+
}
|
|
50
|
+
#elif defined(__aarch64__)
|
|
51
|
+
static inline void simde_trap(void)
|
|
52
|
+
{
|
|
53
|
+
__asm__ __volatile__(".inst 0xd4200000");
|
|
54
|
+
}
|
|
55
|
+
#elif defined(__arm__)
|
|
56
|
+
static inline void simde_trap(void)
|
|
57
|
+
{
|
|
58
|
+
__asm__ __volatile__(".inst 0xe7f001f0");
|
|
59
|
+
}
|
|
60
|
+
#elif defined(__alpha__) && !defined(__osf__)
|
|
61
|
+
static inline void simde_trap(void)
|
|
62
|
+
{
|
|
63
|
+
__asm__ __volatile__("bpt");
|
|
64
|
+
}
|
|
65
|
+
#elif defined(_54_)
|
|
66
|
+
static inline void simde_trap(void)
|
|
67
|
+
{
|
|
68
|
+
__asm__ __volatile__("ESTOP");
|
|
69
|
+
}
|
|
70
|
+
#elif defined(_55_)
|
|
71
|
+
static inline void simde_trap(void)
|
|
72
|
+
{
|
|
73
|
+
__asm__ __volatile__(
|
|
74
|
+
";\n .if (.MNEMONIC)\n ESTOP_1\n .else\n ESTOP_1()\n .endif\n NOP");
|
|
75
|
+
}
|
|
76
|
+
#elif defined(_64P_)
|
|
77
|
+
static inline void simde_trap(void)
|
|
78
|
+
{
|
|
79
|
+
__asm__ __volatile__("SWBP 0");
|
|
80
|
+
}
|
|
81
|
+
#elif defined(_6x_)
|
|
82
|
+
static inline void simde_trap(void)
|
|
83
|
+
{
|
|
84
|
+
__asm__ __volatile__("NOP\n .word 0x10000000");
|
|
85
|
+
}
|
|
86
|
+
#elif defined(__STDC_HOSTED__) && (__STDC_HOSTED__ == 0) && defined(__GNUC__)
|
|
87
|
+
#define simde_trap() __builtin_trap()
|
|
88
|
+
#else
|
|
89
|
+
#include <signal.h>
|
|
90
|
+
#if defined(SIGTRAP)
|
|
91
|
+
#define simde_trap() raise(SIGTRAP)
|
|
92
|
+
#else
|
|
93
|
+
#define simde_trap() raise(SIGABRT)
|
|
94
|
+
#endif
|
|
95
|
+
#endif
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
#if defined(HEDLEY_LIKELY)
|
|
99
|
+
#define SIMDE_DBG_LIKELY(expr) HEDLEY_LIKELY(expr)
|
|
100
|
+
#elif defined(__GNUC__) && (__GNUC__ >= 3)
|
|
101
|
+
#define SIMDE_DBG_LIKELY(expr) __builtin_expect(!!(expr), 1)
|
|
102
|
+
#else
|
|
103
|
+
#define SIMDE_DBG_LIKELY(expr) (!!(expr))
|
|
104
|
+
#endif
|
|
105
|
+
|
|
106
|
+
#if !defined(SIMDE_NDEBUG) || (SIMDE_NDEBUG == 0)
|
|
107
|
+
#define simde_dbg_assert(expr) \
|
|
108
|
+
do { \
|
|
109
|
+
if (!SIMDE_DBG_LIKELY(expr)) { \
|
|
110
|
+
simde_trap(); \
|
|
111
|
+
} \
|
|
112
|
+
} while (0)
|
|
113
|
+
#else
|
|
114
|
+
#define simde_dbg_assert(expr)
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
#endif /* !defined(SIMDE_DEBUG_TRAP_H) */
|