pax_global_header00006660000000000000000000000064150533545030014515gustar00rootroot0000000000000052 comment=5879eaff925c72c06e672bea4a0f84bd47b07fb7 chibicc-1.0.23.1/000077500000000000000000000000001505335450300133235ustar00rootroot00000000000000chibicc-1.0.23.1/.devcontainer.json000077500000000000000000000004671505335450300167670ustar00rootroot00000000000000{ "build": { "dockerfile": "Dockerfile" }, "customizations": { "vscode": { "extensions": [ "ms-vscode.cpptools", "ms-vscode.cpptools-extension-pack", "ms-vscode.cpptools-themes", "ms-vscode.makefile-tools", "ms-azuretools.vscode-docker" ] } } } chibicc-1.0.23.1/.gitignore000077500000000000000000000001761505335450300153220ustar00rootroot00000000000000**/*~ **/\#* **/*.o **/*.s **/a.out **/*.exe .vscode/ /tmp* /thirdparty /chibicc /test/*.exe /stage2 /build /cmake-build-debugchibicc-1.0.23.1/CMakeLists.txt000066400000000000000000000005621505335450300160660ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.22.1) install(PROGRAMS ${Boost_LIBRARIES} DESTINATION ~/install/lib) set(CMAKE_CXX_STANDARD 20) project(chibicc) FIND_PACKAGE(Boost 1.48 COMPONENTS REQUIRED) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} ) file(GLOB SOURCE "*.h" "*.c" "include/*.h") add_executable(chibicc ./main.c ${SOURCE} ${Boost_LIBRARIES})chibicc-1.0.23.1/Dockerfile000077500000000000000000000016441505335450300153250ustar00rootroot00000000000000FROM ubuntu:20.04 RUN \ apt-get update && \ apt-get upgrade -y && \ apt-get install -y build-essential # dependencies for thirdparty cpython RUN \ sed -i 's/# deb-src http:\/\/archive.ubuntu.com\/ubuntu\/ focal-updates universe/deb-src http:\/\/archive.ubuntu.com\/ubuntu\/ focal-updates universe/' /etc/apt/sources.list && \ apt-get update && \ DEBIAN_FRONTEND="noninteractive" apt-get build-dep -y python3.9 # dependencies for thirdparty git RUN \ DEBIAN_FRONTEND="noninteractive" apt-get install -y gettext libcurl4-openssl-dev libexpat-dev libssl-dev tclsh zlib1g-dev # dependencies for thirdparty libpng RUN \ apt-get install -y zlib1g-dev # dependencies for thirdparty sqlite RUN \ DEBIAN_FRONTEND="noninteractive" apt-get install -y tcl-dev tclsh zlib1g-dev # dependencies for thirdparty tinycc RUN \ DEBIAN_FRONTEND="noninteractive" apt-get install -y texinfo git ADD . /opt/chibicc WORKDIR /opt/chibicc chibicc-1.0.23.1/ISSUES.md000066400000000000000000000147211505335450300146650ustar00rootroot00000000000000# issues List all issues found and fixed ## issues and pull requests fixed - Add dockerfile #23 pull request from 0xc0 - Issue #30 from ludocode - Typecheck void type expressions in return and assignment #41 pull request from StrongerXi - Binary add segfaults when at least 1 arg is non-numeric, and both are non-pointer types #42 pull request from StrongerXi - It's UB to have a call to va_start without a corresponding call to va_end #51 pull request from camel-cdr - Fix bug in codegen.c if (ty->size == 4) instead of if (ty->size == 12) #52 pull request from mtsamis - difficulty in understanding priorities. #54 pull request from ihsinme - Fixed bug in preprocessor process extraneous tokens. #95 pull request from memleaker - Hashmap: Do not insert duplicate keys #98 pull request from boki1 - issue #65 assembler error on larger than 32-bit bitfields from GabrielRavier - issue #28 bitfield validation from zamfofex - issue #48 asan issues with memcmp from math4tots - issue #36 assertion when using empty structs from edubart - issue #31 Anonymously named bitfield member segfaults compiler from Anonymously named bitfield member segfaults compiler fixed by zamfofex - issue #45 When anonymous union field is specified by designator, compiler crashe from vain0x fixed by zamfofex - issue #80 Size of string is wrong from tyfkda - issue #72 Internal error when initializing array of long with string literals from GabrielRavier - issue #47 postfix tails on compound literals from vain0x - issue #62 Nested designators error from sanxiyn - issue #37 Using goto inside statement expressions gives an error from edubart - issue #63 Function type parameter without identifier errs from sanxiyn - issue #69 Internal error on long double initializer from GabrielRavier - issue #71 Codegen error on _Atomic long double operation assignments from GabrielRavier - Fix atomic fetch operations #101 pull request from chjj - issue #107 string intialized by function-like failed during compilation - issue #108 if a macro ends a line and the next line starts by "#ifdef" the "#" is not recognized starting from beginning of the line. - issue #109 managing #warning as preprocess instruction - issue #110 union initialized by "input_control_param_t it = { .id = p_input, .time.i_val = 1};" failed due to comma. - issue #113 depending where is _Atomic parsing failed ./issues/issue113.c:7: char *_Atomic str; /**< Current value (if character string) */ ^ expected ',' - issue #116 (issue #110 at rui314/chibicc) token incorrectly splitted into two tokens the first one considered wrongly as number ./issues/issue116.c:26: make_dh(1024_160); ^ expected ',' - issue #117 parsing failed if a generic argument in macro starts by a number example ...(void))fromtype##2obj_decode... in this case chibicc considers wrongly 2 as a number. - issue #118 issues/issue118.c:1: NID_sha_224 ^ parse.c: in primary : error: undefined variable - issue #119 caused by _Complex attribute /usr/include/x86_64-linux-gnu/bits/cmathcalls.h:55: __MATHCALL (cacos, (_Mdouble_complex_ __z)); ^ expected ',' - issue #120 in VLC static_assert function outside a function caused an issue with chibicc issues/issue120.c:30: static_assert(AOUT_CHANIDX_MAX == AOUT_CHAN_MAX, "channel count mismatch"); ^ tokenize.c: in skip : expected ',' - issue #121 in VLC static_assert function with sizeof or offsetof caused an issue with chibicc: ./include/stddef.h:11: #define offsetof(type, member) ((size_t)&(((type *)0)->member)) ^ tokenize.c: in skip : expected ',' - issue #122 in util_linux compilation it fails during assembly "file number less than 0" when #line generates negative number - issue #123 in util_linux compilation fails with regex when a local variable in arguments it's used for another argument. extern int regexec(..., size_t __nmatch,... regmatch_t __pmatch[_Restrict_arr_ _REGEX_NELTS(__nmatch)],... - issue #124 some macro defined after their used caused issue with chibicc. gcc allows it. - issue #125 extended assembly not managed yet. First taken in account of extended assembly (basic one only one operand) - issue #126 old C style with declaration argument type after the function parameters and before the beginning of the function body : size_t strlcpy(dst, src, siz) char *dst; const char *src; size_t siz; {... strlcpy.c:44:2: error: char *dst; ^ tokenize.c: in skip : expected '{' - issue #127 incorrect fix for old C style that cause issue later during linkage. - issue #128 union initialized by an expression failed : issues/issue127.c:49: union sockaddr_u localaddr = lfdi->remoteaddr; ^ tokenize.c: in skip : expected ',' - issue #131 (ISS-131) parsing issue when trying to compile nginx project caused by fix #121 - issue #133 with old C style function declaration using comma to declare same type of variable : test/example.c:89: Byte *compr, *uncompr; ^ tokenize.c: in skip : expected ';' - issue #134 (ISS-134) with parameter expression during zlib project due to bug in func_params2. - issue #136 (ISS-136) zlib project error with unknown extension: main.c : in get_file_type : unknown file extension: libz.so.1.2.12 - issue #139 (ISS-139) extended assembly compiling but execution doesn't return the correct result. - issue #142 (ISS-142) Preprocessor fail with nested macros. First temporary fix. - adding install in makefile (#PR24 from rurban). - Adding ND_MOD in is_const_expr(#issue 134 from matthewsot). - Fixing incorrect small struct passing in 5th argument position (issue #127 from sgraham). - ISS-140 fixing compiling chibicc with chibicc tests failed with trying to parse the object.o file instead of linking only.chibicc-1.0.23.1/LICENSE000077500000000000000000000020531505335450300143330ustar00rootroot00000000000000MIT License Copyright (c) 2019 Rui Ueyama Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. chibicc-1.0.23.1/Makefile000077500000000000000000000100461505335450300147670ustar00rootroot00000000000000CC=gcc CFLAGS =-std=c11 -g -fno-common -Wall -Wno-switch CFLAGS_DIAG=-dotfile -std=c11 OBJECT=chibicc OBJECTLIB=libchibicc SRCS=$(wildcard *.c) OBJS=$(SRCS:.c=.o) TEST_SRCS=$(wildcard test/*.c) TESTS=$(TEST_SRCS:.c=.exe) ISSUES_SRCS=$(wildcard issues/*.c) #PNG=$(TEST_SRCS:.c=.tmp) #PNG2=$(ISSUES_SRCS:.c=.tmp) # Stage 1 $(OBJECT): $(OBJS) $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(OBJS): $(OBJECT).h test/%.exe: $(OBJECT) test/%.c ./$(OBJECT) $(CFLAGS_DIAG) -Iinclude -Itest -c -o test/$*.o test/$*.c $(CC) -pthread -o $@ test/$*.o -xc test/common -lm # dot -Tpng test/$*.dot -o diagram/$*.png || echo $*.dot failed test: $(TESTS) for i in $^; do echo $$i; ./$$i || exit 1; echo; done test/driver.sh ./$(OBJECT) # #for managing dot diagram # test-png: $(TESTS) test-all: test test-stage2 # Stage 2 stage2/$(OBJECT): $(OBJS:%=stage2/%) $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) stage2/%.o: $(OBJECT) %.c mkdir -p stage2/test ./chibicc -c -o $(@D)/$*.o $*.c stage2/test/%.exe: stage2/$(OBJECT) test/%.c mkdir -p stage2/test ./stage2/$(OBJECT) -Iinclude -Itest -c -o stage2/test/$*.o test/$*.c $(CC) -pthread -o $@ stage2/test/$*.o -xc test/common test-stage2: $(TESTS:test/%=stage2/test/%) for i in $^; do echo $$i; ./$$i || exit 1; echo; done test/driver.sh ./stage2/$(OBJECT) projects-all: projects projects-oth git projects-oth: openssl vim nmap curl projects: zlib util-linux nginx curl: cd ../curl && make clean && CC=chibicc CFLAGS="-std=c11" ./configure --with-openssl && make && make test zlib: cd ../zlib && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test nmap: cd ../nmap && make clean && CC=chibicc LDFLAGS="-fPIC -std=c11 -ldbus-1" LIBS="-ldbus-1 -latomic" ./configure --with-dbus && make && make check openssl: cd ../openssl && make clean && CC=chibicc CFLAGS="-std=c11" ./configure && make util-linux: cd ../util-linux && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make check-programs && cd tests && ./run.sh nginx: cd ../nginx && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./auto/configure --with-http_ssl_module && make vim: cd ../vim && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test lxc: cd ../lxc && rm -rf build && CC=gcc \ meson setup build && cd build && sudo cp /usr/bin/gcc /usr/bin/gcc_backup \ sudo cp /usr/local/bin/chibicc /usr/bin/gcc && meson compile && sudo cp /usr/bin/gcc_backup /usr/bin/gcc vlc: cd ../vlc && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure \ --disable-lua --disable-xcb --disable-qt --disable-alsa --disable-sse --host x86_64-linux-gnu && \ make all cpython: cd ../cpython && make clean && CC=chibicc ./configure \ --build=x86_64-pc-linux-gnu ac_cv_have_lchflags=no ac_cv_have_chflags=no && make && make test # vlc2: # cd ../vlc && rm -rf build && mymeson setup build && cd build && mymeson compile git: cd ../git && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test memcached: cd ../memcached && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test openssh-portable: cd ../openssh-portable && make clean && CC=chibicc CFLAGS="-std=c11" ./configure && make && make tests # Misc. libchibicc: $(OBJECT) $(OBJECTLIB).so CFLAGS +=-fPIC libchibicc.so: $(OBJS) $(CC) $(CFLAGS) -o $@ $^ -shared clean: rm -rf $(OBJECT) tmp* $(TESTS) issues/*.s issues/*.exe issues/*.dot test/*.s test/*.exe stage2 diagram/*.png test/*.dot $(OBJECTLIB) find * -type f '(' -name '*~' -o -name '*.o' ')' -exec rm {} ';' install: sudo rm -rf /usr/local/include/x86_64-linux-gnu/chibicc && sudo rm -rf /usr/local/bin/chibicc test -d /usr/local/include/x86_64-linux-gnu/chibicc || \ sudo mkdir -p /usr/local/include/x86_64-linux-gnu/chibicc sudo cp -r include/* /usr/local/include/x86_64-linux-gnu/chibicc/ sudo cp ./chibicc /usr/local/bin/chibicc uninstall: sudo rm -rf /usr/local/include/x86_64-linux-gnu/chibicc && sudo rm /usr/local/bin/chibicc .PHONY: test clean test-stage2 libchibicc projects projects-all projects-oth test-all install uninstall chibicc-1.0.23.1/README.md000077500000000000000000000513651505335450300146170ustar00rootroot00000000000000# chibicc: A Small C Compiler from Rui Ueyama This project has been forked from https://github.com/rui314/chibicc I want to play with it and to add some other options like choosing other linker than default ld. It's for learning purposes too, to try to understand existing code and to extend it. Using PVS.studio to find some potential issues and fix them. Trying to work on issues and pull requests done in the original repository. ## usage ./chibicc --help or ./chibicc -h chibicc is a C compiler based on chibicc created by Rui Ueyama. See original project https://github.com/rui314/chibicc for more information this chibicc contains only some differences for now like new parameters chibicc usage : --help or -h print the help --version or -v print the version of chibicc -cc1 run the cc1 function needs -cc1-input (-cc1-output optional) parameter -fuse-ld to specify other linker than ld used by default -x Specify the language of the following input files. Permissible languages include: c assembler none 'none' means revert to the default behavior of guessing the language based on the file's extension. -S generate assembly file -o path to output executable if omitted a.out generated -c path to source to compile -Xlinker Pass on to the linker. -Wl, Pass comma-separated on to the linker. -z Pass on to the linker. -soname Pass -soname on to the linker. --version-script Pass --version-script to the linker. -I Pass path to the include directories -L Pass path to the lib directories -D define macro example -DM13 -U undefine macro example -UM13 -s to strip all symbols during linkage phasis -M -MD -MP -MMD -MF -MT -MQ compiler write a list of input files to stdout in a format that "make" command can read. This feature is used to automate file dependency management -fpic or -fPIC Generate position-independent code (PIC) -fno-pic disables the generation of position-independent code with relative address references -pie Create a dynamically linked position independent -fpie Create a dynamically linked position independent -fPIE Create a dynamically linked position independent -fcommon is the default if not specified, it's mainly useful to enable legacy code to link without errors -fno-common specifies that the compiler places uninitialized global variables in the BSS section of the object file. -static pass to the linker to link a program statically -pthread pass to the linker to link with lpthread library -shared pass to the linker to produce a shared object which can then be linked with other objects to form an executable. -hashmap-test to test the hashmap function -idirafter apply to lookup for both the #include "file" and #include directives. -### to dump all commands executed by chibicc -debug to dump all commands executed by chibicc in a log file in /tmp/chibicc.log -E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files that don’t require preprocessing are ignored. -rpath Add a directory to the runtime library search path this parameter is passed to the linker. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link. -dumpmachine it's required by some projects returns x86_64-linux-gnu -dotfile generates a file with .dot extension that can be visualized using graphviz package -dM Print macro definitions in -E mode instead of normal output -print print all tokens in a log file in /tmp/chibicc.log -A print Abstract Syntax Tree in a log file in /tmp/chibicc.log -msse3 enabling sse3 support -msse4 enabling sse4 support -nostdlib Do not use the standard system startup files or libraries when linking -nostdinc Do not use the standard system header files when compiling -std=c99 generates an error on implicit function declaration (without -std only a warning is emitted) -std=c11 generates an error on implicit function declaration (without -std only a warning is emitted) -mmmx to allow mmx instructions and builtin functions linked to mmx like __builtin_packuswb... -print-search-dirs prints minimal information on install dir. chibicc [ -o ] ## compile To compile chibicc with make : make To compile chibicc with cmake you need to install boost library. Then you can compile it with cmake : cmake -S . -B ./build cd build make ## Examples Note that probably you need to define the include parameter and lib parameter to be able to execute these examples outside the chibicc directory. If you forgot you will have similar error message : /usr/include/stdio.h:33: #include ^ stddef.h: cannot open file: No such file or directory To solve it, add the include and lib parameter like below assuming that we are in the parent chibicc directory : chibicc pointerofpointers.c -I./chibicc/include -L./chibicc/lib printing the help ./chibicc --help ./chibicc -h printing the version ./chibicc --version ./chibicc -v compiling and generating an executable ./chibicc -o ./test/hello ./test/hello.c specifying another linker than the default one here lld : ./chibicc -o ./test/hello ./test/hello.c -fuse-ld ld.lld specifying another linker than the default one here mold (https://github.com/rui314/mold) ./chibicc -o ./test/hello ./test/hello.c -fuse-ld mold generating assembly file ./chibicc -S ./test/hello.c generating a.out file if no parameter -o provided ./chibicc ./test/hello.c generating the object only : it generates the pointerofpointers.o ./chibicc -c pointerofpointers.c -I./chibicc/include -L./chibicc/lib generating executable from objects : ./chibicc pointerofpointers.o -o pointersofpointers defining condition at compile time : ./chibicc -o ./test/mydefine ./test/define.c -DM13 -I../include -L../lib ./test/mydefine 3 undefining condition at compile time : ./chibicc -o ./test/mydefine ./test/define.c -UM13 -I../include -L../lib ./test/mydefine 4 By default the symbol tables is populated: chibicc -o ./test/mydefine ./test/define.c objdump -t ./test/mydefine ./test/mydefine: file format elf64-x86-64 SYMBOL TABLE: 0000000000000000 l df *ABS* 0000000000000000 crt1.o 0000000000400320 l O .note.ABI-tag 0000000000000020 \_\_abi_tag 0000000000000000 l df *ABS* 0000000000000000 crtstuff.c Stripping symbol tables during linkage phasis adding -s parameter : ./chibicc -o ./test/mydefine ./test/define.c -s objdump -t ./test/mydefine ./test/mydefine: file format elf64-x86-64 SYMBOL TABLE: no symbols other way to generate assembly file ./chibicc ./test/define.c -cc1 -cc1-input ./test/define.c -cc1-output mydefine.s generating dependencies in std output : ./chibicc ./test/define.c -M define.o: \ ./test/define.c \ /usr/include/stdio.h \ /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \ /usr/include/features.h \ generating dependencies in a output file with ".d" extension and generating executable a.out : ./chibicc ./test/define.c -MD ls *.d define.d ## options always passed to the linker it means that if you don't use the ld linker or ld.lld probably some options should be conditionned depending your linker lld-link: warning: ignoring unknown argument '-o' lld-link: warning: ignoring unknown argument '-m' lld-link: warning: ignoring unknown argument '-L/usr/lib/gcc/x86_64-linux-gnu/9' lld-link: warning: ignoring unknown argument '-L/usr/lib/x86_64-linux-gnu' lld-link: warning: ignoring unknown argument '-L/usr/lib64' lld-link: warning: ignoring unknown argument '-L/lib64' lld-link: warning: ignoring unknown argument '-L/usr/lib/x86_64-linux-gnu' lld-link: warning: ignoring unknown argument '-L/usr/lib/x86_64-pc-linux-gnu' lld-link: warning: ignoring unknown argument '-L/usr/lib/x86_64-redhat-linux' lld-link: warning: ignoring unknown argument '-L/usr/lib' lld-link: warning: ignoring unknown argument '-L/lib' lld-link: warning: ignoring unknown argument '-dynamic-linker' lld-link: warning: ignoring unknown argument '-lc' lld-link: warning: ignoring unknown argument '-lgcc' lld-link: warning: ignoring unknown argument '--as-needed' lld-link: warning: ignoring unknown argument '-lgcc_s' lld-link: warning: ignoring unknown argument '--no-as-needed' ## options ignored List of options ignored : "-O" "-P" "-Wall" "-Wextra" "-Wno-switch" "-Wno-unused-variable" "-Wno-format-y2k" "-Wno-uninitialized" "-Wmissing-prototypes" "-Wmissing-declarations" "-Wredundant-decls" "-Winit-self" "-fno-math-errno" "-fno-rounding-math" "-fno-signaling-nans" "-fcx-limited-range" "-funsafe-math-optimizations" "-funroll-loops" "-ffreestanding" "-fno-omit-frame-pointer" "-fomit-frame-pointer" "-funwind-tables" "-fno-stack-protector" "-fno-strict-aliasing" "-m64" "-m32" "--whole-archive" "--no-whole-archive" "-fsigned-char" "-Bsymbolic" "-pedantic" "-nostdinc" "-mno-red-zone" "-fvisibility=default" "-fvisibility=hidden" "-Wsign-compare" "-Wundef" "-Wpointer-arith" "-Wvolatile-register-var" "-Wformat" "-Wformat-security" "-Wduplicated-branches" "-Wduplicated-cond" "-Wbad-function-cast" "-Wwrite-strings" "-Wlogical-op" "-Wshadow=local" "-Wmultistatement-macros" "-fstack-protector" "-fstack-protector-strong" "-fstack-clash-protection" "-fdiagnostics-show-option" "-fasynchronous-unwind-tables" "-fexceptions" "-fprofile-arcs" "-ftest-coverage" "-fdiagnostics-show-option" "-Xc" "-Aa" "-w" "-w2" "--param=ssp-buffer-size=4" "-fno-lto" "-fp-model" "-fprofile-arcs" "-ftest-coverage" "-ansi_alias" "-ffat-lto-objects" "-static-libstdc++" "-static-libgcc" "-pipe" "-mindirect-branch-register" ## Dockerfile and devcontainer Adding dockerfile suggested by 0xc0 https://github.com/0xc0/chibicc/tree/new To build : docker build -t chibicc . Adding also a devcontainer for those that want to use visual code inside a container (needs vs code extension remote-containers). ## Examples of C projects compiled successfully using chibicc tcc : tcc compiler (https://github.com/LuaDist/tcc.git) chibicc -o tcc tcc.c -DTCC_TARGET_X86_64 -O2 -g -Wall -Wno-pointer-sign -lm -ldl chibicc -o libtcc1.o -c lib/libtcc1.c -O2 -Wall ar rcs libtcc1.a libtcc1.o chibicc -o libtcc.o -c libtcc.c -DTCC_TARGET_X86_64 -O2 -g -Wall -Wno-pointer-sign ar rcs libtcc.a libtcc.o ./texi2pod.pl tcc-doc.texi tcc.pod pod2man --section=1 --center=" " --release=" " tcc.pod > tcc.1 chibicc -o libtcc_test tests/libtcc_test.c libtcc.a -I. -O2 -g -Wall -Wno-pointer-sign -lm -ldl for some projects you need to define CC=chibicc before executing ./configure. curl : https://github.com/curl/curl.git autoreconf -fi CC=chibicc CFLAGS=-fpic LDFLAGS=-fpic ./configure --with-openssl make make[2]: Entering directory ... CC libcurl_la-altsvc.lo CC libcurl_la-amigaos.lo ... CC ../lib/curl_multibyte.o CC ../lib/version_win32.o CC ../lib/dynbuf.o CCLD curl make test TESTDONE: 1855 tests were considered during 3598 seconds. TESTDONE: 1574 tests out of 1574 reported OK: 100% openssl : https://github.com/openssl/openssl.git CC=chibicc ./Configure You need to remove from the file from openssl/crypto/perlasm/x86_64-xlate.pl my $section='.note.gnu.property, #alloc'; by : my $section='.note.gnu.property'; make make test openssh-portable : https://github.com/openssh/openssh-portable.git autoreconf -fi CC=chibicc ./configure make luajit: https://github.com/LuaJIT/LuaJIT.git CC=chibicc make git: https://github.com/git/git.git autoreconf -fi CC=chibicc CFLAGS=-fPIC ./configure make make test util-linux : https://github.com/util-linux/util-linux.git Manually fixing the config.status and removing D["HAVE_UNION_SEMUN"]=" 1" ./autogen.sh CC=chibicc CFLAGS=-fPIC ./configure make //to check if the compiled programs by chibicc work : make check-programs cd tests run.sh --------------------------------------------------------------------- All 340 tests PASSED --------------------------------------------------------------------- nginx: https://github.com/nginx/nginx.git CC=chibicc CFLAGS=-fPIC ./auto/configure make zlib: https://github.com/madler/zlib.git CC=chibicc CFLAGS="-fPIC" ./configure make make test ... *** zlib test OK *** ... *** zlib shared test OK *** ... *** zlib 64-bit test OK *** vim: https://github.com/vim/vim.git CC=chibicc CFLAGS="-fPIC" ./configure make make test == SUMMARY == Test run on 2023 Sep 23 14:15:31 OK: 10 FAILED: 0: [] skipped: 0 libwepb: https://github.com/webmproject/libwebp.git CC=chibicc CFLAGS="-fpic" LDFLAGS="-fpic -lpng -ljpeg" cmake -S . -B ./build cd build cmake --build . ~/libwebp/build$ ./img2webp -version WebP Encoder version: 1.3.2 WebP Mux version: 1.3.2 libsharpyuv: 0.4.0 [no output file specified] [0 frames, 0 bytes]. memcached: https://github.com/memcached/memcached.git autoreconf -fi CC=chibicc CFLAGS=-fpic LDFLAGS=-fpic ./configure make make test nmap : https://github.com/nmap/nmap CC=chibicc ./configure --with-dbus make make check Testing nmap_dns Testing nmap_dns finished without errors Ran 292 tests. 0 failures. vlc : https://github.com/videolan/vlc.git autoreconf -fiv ./bootstrap CC=chibicc CFLAGS="-fPIC -std=c11" ./configure --disable-lua --disable-xcb --disable-qt --disable-alsa --disable-sse --host x86_64-linux-gnu make all failed during linkage : with undefined references to missing dependency in their Makefile. Adding the missing librtp_plugin_la-sdp.o solves this issue. Changes done in modules/Makefile : libg64rtp_plugin_la_OBJECTS = $(am_libg64rtp_plugin_la_OBJECTS) access/rtp/.libs/librtp_plugin_la-sdp.o after that make all succeeds! ## meson to be able to use meson with chibicc (meson hack is to do the meson configure using gcc and rename gcc to gcc_old chibicc to gcc and meson compile will call chibicc). lxc: https://github.com/lxc/lxc.git CC=chibicc CFLAGS="-fpic" meson build && cd build && meson compile ## Limits Some C projects doesn't compile for now or crash after being compiled with chibicc. It helps to find some bugs and to try to fix them! cpython: git clone https://github.com/python/cpython.git CC=chibicc ./configure --host=x86_64-pc-linux-gnu ac_cv_have_lchflags=no ac_cv_have_chflags=no make && make test failure with : do_fork_exec () at ./Modules/_posixsubprocess.c:911 #1 0x0000767b99afefdf in subprocess_fork_exec_impl () at ./Modules/_posixsubprocess.c:1256 #2 0x0000767b99afd98d in subprocess_fork_exec () at ./Modules/clinic/_posixsubprocess.c.h:148 #3 0x00000000006de02f in cfunction_vectorcall_FASTCALL () at Objects/methodobject.c:449 #4 0x00000000005b53d1 in _PyObject_VectorcallTstate () at ./Include/internal/pycore_call.h:169 #5 0x00000000005b8424 in PyObject_Vectorcall () at Objects/call.c:327 #6 0x00000000009988ce in _PyEval_EvalFrameDefault () at Python/generated_cases.c.h:1620 #7 0x00000000009888dc in _PyEval_EvalFrame () at ./Include/internal/pycore_ceval.h:121 #8 0x0000000000988857 in _PyEval_Vector () at Python/ceval.c:1982 #9 0x00000000005b3b8e in _PyFunction_Vectorcall () at Objects/call.c:413 #10 0x00000000005b6638 in _PyObject_VectorcallDictTstate () at Objects/call.c:146 #11 0x00000000005b68da in _PyObject_Call_Prepend () at Objects/call.c:504 #12 0x000000000079c6dd in call_method () at Objects/typeobject.c:3060 #13 0x0000000000776ab5 in slot_tp_init () at Objects/typeobject.c:10791 #14 0x000000000079e913 in type_call () at Objects/typeobject.c:2444 #15 0x00000000005b630f in _PyObject_Call () at Objects/call.c:361 #16 0x00000000005b90c8 in PyObject_Call () at Objects/call.c:373 #17 0x00000000009a03fd in _PyEval_EvalFrameDefault () at Python/generated_cases.c.h:2616 #18 0x00000000009888dc in _PyEval_EvalFrame () at ./Include/internal/pycore_ceval.h:121 #19 0x0000000000988857 in _PyEval_Vector () at Python/ceval.c:1982 #20 0x00000000005b3b8e in _PyFunction_Vectorcall () at Objects/call.c:413 => chibicc doesn't manage well vfork due to their push/pop systems! postgres: https://github.com/postgres/postgres.git (in case of bad network use git clone --filter=blob:none --depth=1 https://github.com/postgres/postgres.git --branch master) CC=chibicc CFLAGS="-g -std=c11" ./configure --host x86_64-linux-gnu make make check failed with : 2025-08-19 21:36:40.890 CEST [1338239] PANIC: ProcKill() called in child process ## features added - some extended assembly syntax taken in account (only when on macro body they are failing) - adding basic support on int128 (probably some operations are still not supported) - adding vector management and scalar promotion to vector ## TODO - trying to compile other C projects from source to see what is missing or which bug we have with chibicc. - Trying to find the root cause of segmentation fault with postgres initdb command. ## issues and pull requests fixed ## known issues postgres execution : ko git 2 tests failed memcached test stuck at t/binary-extstore.t ......... 5947/? vim: compile OK, tests KO on test_channel.vim. cpython : compile OK, segfault at test execution due to vfork not managed well. ## projects compiled successfully with chibicc util-linux : compile OK, tests OK nginx: compile OK zlib: compile OK, tests OK nmap: compile OK, tests OK openssh-portable : compile OK, tests OK vlc: compile OK ## debug To debug with gdb don't forget to use the set follow-fork-mode child because chibicc creates a child job. gdb ./chibicc (gdb) set follow-fork-mode child (gdb) r issues/issue116.c -o issues/issue116 Starting program: /home/stormalf/ubuntu/chibicc/chibicc issues/issue116.c -o issues/issue116 [Attaching after process 174090 fork to child process 174091] [New inferior 2 (process 174091)] [Detaching after fork from parent process 174090] [Inferior 1 (process 174090) detached] process 174091 is executing new program: /home/stormalf/ubuntu/chibicc/chibicc [Switching to process 174091] Thread 2.1 "chibicc" hit Breakpoint 1, 0x0000000000432726 in parse () at parse.c:3703 3703 return "UNREACHABLE"; // Atomic e ## diagram Example of diagram generated with -dotfile parameter : ![diagram](https://github.com/stormalf/chibicc/blob/main/asm.png) ## release notes 1.0.23.1 Removing old fix on issue166 that causes side effect. Adding ND_POS for unary +. Adding new type for long long TY_LLONG. Fixing umull_overflow. Fixing issue with weak not printed for extern global variables. Adding lots of functions declarations on math.h needed for some projects. Ignoring few arguments. Fixing issue166. Fixing issue with external TLS (from @fuhsnn). Fixing temp issue with __cpuid_count (extended assembly not managed well this case) by adding my own cpuid.h. Adding some atomic_xx_n functions missing. Removing fix on VLC undefined references that causes issue with util-linux and fixing static inline references when they are referenced by address. ## old release notes chibicc-1.0.23.1/RELEASE_NOTES.md000066400000000000000000000436271505335450300157110ustar00rootroot00000000000000# Release notes This document contains all release notes delivered. Only the current one is on the README.md ## old release notes 1.0.0 Initial version 1.0.1 adding --version -v option and fixing the -cc1 parameter that caused segmentation fault if other mandatory parameters are missing. trying to document cc1 and x options and adding a max length control parameter. Adding documentation for other parameters too. 1.0.2 fixing issue with cc1 parameter only -cc1-input parameter is mandatory. Finishing parameters documentation. 1.0.3 trying to add some sanitizing functions and check if arguments have valid allowed characters (probably too strict!). 1.0.4 Fixing the output directory for dependencies "xxx.d" when -MD option is set, the output "xxx.d" file is generated in the current directory if no -o parameter defined or in the directory defined by -o parameter (issue #30). Adding Dockerfile and a devcontainer for those who want to play with that (issue #23). Typecheck void type expressions in return and assignment (issue #41). Binary add segfaults when at least 1 arg is non-numeric, and both are non-pointer types (issue #42). It's UB to have a call to va_start without a corresponding call to va_end (issue #51). Fix bug in codegen.c (issue #52). fix issue in main.c (issue #54). Fixed bug in preprocessor process extraneous tokens (issue #95). Hashmap: Do not insert duplicate keys (issue #98). 1.0.5 Fixing assembler error on larger than 32-bit bitfields (issue #65) by GabrielRavier. Fixing bitfield validation by zamfofex (issue #28). Replacing memcmp by strncmp (issue #48) by math4tots. Fixing empty structs as one-byte object (issue #36) by edubart. 1.0.6 Anonymously named bitfield member segfaults compiler (issue #31). Fixing anonymous union field (issue #45) by zamfofex. Fixing wrong size of string initialized by braces (issue #80) by zamfofex. 1.0.7 Internal error when initializing array of long with string literals (issue #72) by GabrielRavier. Fixing postfix tails on compound literals (issue #47) by zamfofex. Trying to fix nested designators error(issue #62). Fixing Using goto inside statement expressions gives an error (issue #37) by zamfofex. Fixing function type parameter without identifier errs (issue #63) by zamfofex. 1.0.8 Internal error on long double initializer (issue #69). Codegen error on atomic long double operation assignments (issue #71). Fix atomic fetch operations (issue #101) by chjj. Adding -soname < arg > and -rpath < dir > parameters (needed to be able to compile curl from source). Soname is used to create a symbolic link and rpath is passed to the linker. Testing chibicc with some C projects (compiling fine tcc, curl). 1.0.9 Adding pthread and pedantic to omitted parameters list. Added -fno-pic parameter. Adding ignored parameter: m32, nostdinc. Adding -dumpmachine parameter. Fixing issue with \_\_has_attribute(diagnose_if). Adding lots of attributes that can be applied to function (for now ignored them) : "\_\_attribute\_\_((noreturn))", "\_\_attribute\_\_((returns_twice))", "\_\_attribute\_\_((noinline))", "\_\_attribute\_\_((always_inline))", "\_\_attribute\_\_((flatten))", "\_\_attribute\_\_((pure))", "\_\_attribute\_\_((nothrow))", "\_\_attribute\_\_((sentinel))", "\_\_attribute\_\_((format))", "\_\_attribute\_\_((format_arg))", "\_\_attribute\_\_((no_instrument_function))", "\_\_attribute\_\_((section))", "\_\_attribute\_\_((constructor))", "\_\_attribute\_\_((destructor))", "\_\_attribute\_\_((used))", "\_\_attribute\_\_((unused))", "\_\_attribute\_\_((deprecated))", "\_\_attribute\_\_((weak))", "\_\_attribute\_\_((alias))", "\_\_attribute\_\_((malloc))", "\_\_attribute\_\_((warn_unused_result))", "\_\_attribute\_\_((nonnull))", "\_\_attribute\_\_((externally_visible))", "\_\_attribute\_\_((visibility(\"default\")))", "\_\_attribute\_\_((visibility(\"hidden\")))", "\_\_attribute\_\_((visibility(\"protected\")))", "\_\_attribute\_\_((visibility(\"internal\")))" 1.0.10 Fixing issue about string initialized by function-like (issue #107). Fixing issue when a macro ends a line and the next line starts by "#ifdef" the "#" is not recognized starting from beginning of the line (issue #108). Managing \#warning as preprocessor instruction (issue #109). Fixing issue with union initializer when comma found like "input_control_param_t it = { .id = p_input, .time.i_val = 1};" (issue #110) and input_control_param_t it = { .id = p_input,} (issue #113). Removing fix for issue 106 (caused other issues with VLC when trying to compile). 1.0.11 Fixing issue #113 about \_Atomic when it's placed after the type. Fixing other issue like issue #108 sometimes some #ifdef are not recognized if a macro ends the previous line and the next line starting by a preprocessing instruction. Managing differently -soname and adding option -z, and --version-script. Adding -debug option to write commands in /tmp/chibicc.log (later I'll add some debugs info/values on this file to help to fix bugs). Adding 2 functions in stdatomic.h needed by VLC atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) that returns false for now and atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) that returns false too. Managing .lo files (libtool object). Adding generic path for Fix 'gcc library path is not found' on some platforms #108 by [Stardust8502](https://github.com/Stardust8502/chibicc). 1.0.12 Adding -dotfile parameter that generates a xxx.dot file that we can visualized using graphviz package by [hdewig100](https://github.com/hedwig100/chibicc). Adding in error message chibicc file name and function when a message error is displayed to help for debugging. Adding in Makefile the way to create shared library libchibicc.so. Fixing issue #116 with 1024_160 splitted wrongly in two tokens. Fixing issue #117 with number after generic parameter like "fromtype##2obj_decode". Fixing issue #118 same as 117, to allow some identifiers to start by number when they are generics. Linking lpthread if -pthread is passed. Ignoring -z and -Bsymbolic. Fixing the issue with linkage need to add current directory to the path before the others (probably it's a security issue because it means that for compiling the objects library found in the current path will be taken in priority!) Fixing issue #119 about cmathcalls. Removing fix for #119 caused an infinite loop and fixing it by adding _Complex as attribute like _Atomic. 1.0.13 Adding other projects compiled successfully with chibicc. Adding some information in debug file like all tokens generated by tokenize function. Fixing some issues found with vlc static_assert function outside a function(#120 and #121). Adding -no-whole-archive and -whole-archive as ignored parameters. Fixing issue with #line that generates negative numbers that caused assembly issue. Fixing issue with argument used twice in regexec function that caused "undefined variable". 1.0.14 Removing sanitizing functions, causing issue during git compile. Fixing issue caused by fix issue 120. Fixing issue with -I \. Fixing also the preprocess when some macros are defined after they are used, gcc allows it. For now the temporary fix manages only macro with empty body that they are used before their definition. Fixing issue #126 about old C style skipping for now the extra tokens. Fixing issue #128 about union initialized by an expression. Fixing a basic extended assembly #125 (partially) for now only something like \__asm\__("bswapl %0" : "=r" (val) : "0" (val)); works (a lot of work to forecast to add other assembly possibilities step by step). Fixing #127(#126) more securely (ignoring was not enough causing issue during linkage). Fixing a mistake on removing the fix for issue #121 that caused an infinite loop. 1.0.15 -fsigned-char parameter is mandatory for util-linux project. Removed by mistake in the previous version. Re-added it! Removing lots of conditions created for debug purposes that causes now infinite loop! 1.0.16 Fixing issue #133 with old C style function declaration when using comma separator for same variable type parameter declaration. Fixing also issue #136 (ISS-136) zlib project error with unknown extension. Fixing issue #134 (ISS-134) with parameter expression during zlib project. Fixing issue #131 (ISS-131) parsing issue when trying to compile nginx project caused by fix #121. Adding some projects to test in Makefile because sometimes some fixes cause side effects! 1.0.17 Fixing ISS-129 need to manage output other than "=r". Fixing ISS-139 extended assembly compiling but execution doesn't return the correct result. Fixing temporary ISS-142 caused by join_adjacent_string_literals function. 1.0.18 adding install and uninstall in makefile (#PR24 from rurban). Adding ND_MOD in is_const_expr(#issue 134 from matthewsot). Fixing incorrect small struct passing in 5th argument position (issue #127 from sgraham). Fixing ISS-140 compiling chibicc with chibicc tests failed with trying to parse the object.o file instead of linking only. Fixing some issues with extended assembly (ISS-141) and reformating some but still have one issue with ASSERT used after assembly inline in some case (see ./issues/assign1.c) 1.0.19 fixing extended assembly issue when a register is already used in the template, the variable should be stored in another register available. 1.0.20 Fixing ISS-143 extended assembly doesn't manage well input with r. Removing assign1.c test doesn't work with gcc. Fixing ISS-144 compiling util-linux failed with expression returning void is not supported. Fixing ISS-145 compiling util-linux failed with invalid initalizer2. Fixing ISS-147 compiling util-linux failed with undefined variable __BYTE_ORDER__. Fixing ISS-148 compiling VLC failed with storage class specifier not allowed caused by static_assert function. Fixing also some issues with extended assembly not working in some cases. Fixing issue with extended assembly in string_replace that truncates the null terminated character and causing during nginx compile failure due to incorrect character. Generating "nop" instruction each time we found the memory barrier : __asm__ volatile ("" ::: "memory"). Compiling successfully some projects like curl, nginx, zlib, util-linux, openssl, openssh-portable. But some tests failed for util-linux, openssl and curl that means that probably we have some bugs somewhere. Fixing ISS-152 extended assembly __asm__ __volatile__ ("rep; nop" ::: "memory"). Fixing ISS-150 fix on issue 40 caused other failures during VLC compilation. Fixing ISS-151 compiling neovim failed in struct_initializer2. Fixing ISS-153 -fomit-frame-pointer, -funwind-tables caused failure during neovim compilation. Adding -dM option to print the macro definition (it's not exactly the same result given by gcc) needed for compile neovim project. 1.0.21 fixing missing information on README (about help and ignored options). Fixing ISS-149 some extended assembly not taken in account (arrays). Fixing ISS-153 extended assembly giving different results when compiling with gcc or with chibicc. Fixing ISS-154 Extended assembly compiled with chibicc failed with ASSERT and works fine without assert function. Ignoring some parameters like -fvisibility=default or -flto=8. 1.0.22 Fixing ISS-149 some extended assembly not taken in account during libwebp compilation. Fixing ISS-156 fpie/pie/-fPIE not recognized by chibicc. Adding other parameters in ignored list. Fixing ISS-157 about union empty initializer like "union string_value lval = {}, rval = {};". Fixing ISS-158 during neovim compilation failure with not a struct nor a union. Fixing ISS-160 memcached compilation failed with IOV_MAX undefined (adding __GNU__ macro). Fixing ISS-161 trying to compile memcached failed with incorrect offset or not managed yet. Fixing ISS-163 during postgres compile failure with "invalid pointer dereference". Fixing ISS-162 during postgres compile failure with __typeof not recognized. Adding macro __INTEL_COMPILER. Adding include path to gcc that has many includes needed for some projects (adding in chibicc/include some of them like emmintrin.h, omp.h...). Adding some builtin void functions like _builtin_ia32_emms. Fixing ISS-165 during postgres compile failure due to staticAssertDecl function. Fixing ISS-166 during postgres compile segmentation fault (caused by VLA type in sizeof function). Fixing ISS-167 during postgres compile failure with bad register. Fixing ISS-168 during postgres compile failure with expected an expression due to incorrect previous fix(ISS-121). Adding by default to the linker "-allow-multiple-definition". Fixing issue with tgmath.h and ignoring .rsp files. Adding -dumpversion support provided by Urs Janssen. Added Xcode SDK path (from MarcusJohnson91). Fixing issue on extract_path function that caused corrupt malloc (ISS-170). Adding -ignore-assert to ignore static assertions (not managed at compile time now). Merge pull request #64 from arbruijn/multiple-funFix function declarations with shared return type. Fix assembler error on large files #119 by @rurban. Integrating many fixes from @n0tknowing. Adding CMakeLists.txt and using BOOST library to generate chibicc (from @Seeingu). Removing fix about old C style that causes other issue, it means that old C style doesn't compile anymore with chibicc. 1.0.22.1 Fix for nginx execution core dumped (issue #171). And moving issue138.c component from test folder to issues folder because it fails even after compiled with gcc. 1.0.22.2 Reintroducing partial Old C style function declarations management (issue ISS-172 postgres doesn't compile anymore with 1.0.22 or higher due to old C style not supported anymore). Now it's possible to compile postgres with chibicc (but still a segmentation fault at execution time). The support of old C style function is partial for the moment. 1.0.22.3 Fixing some issues with extended assembly (managing diffrently depending letters used =r, =m, =q, =a, =b, =c, =d). Adding -print parameter to print all tokens in /tmp/chibicc.log file to help for debugging. Reformatting error messages. Adding color codes to error messages. 1.0.22.4 Fixing some issues with extended assembly (new test cases), adding r11 and r10 registers and adding "D" and "S" support for input and output. Removing -fsanitize=cfi not supported by gcc. Adding core dump and segfault handler to have useful information when a segfault occurs. Adding debug information for linker. Changing the order of extra linker parameters because if the specific path defined for a project is not the first one, it seems that the linker doesn't find the libraries (#ISS-173). Adding support for `chibicc -xc -E -v -` to print the include directories. Ignoring two other attributes for compatibility with GCC : \__attribute__((fallthrough)) and \__attribute__((nonnull(1))). Adding a trick to fix the issue with lxc project in the README.md and Makefile. Adding some test cases for builtin functions to test with chibicc for later. Adding macro \__builtin_choose_expr in stddef.h to fix issue found in the lxc project. Adding warning messages in purple like gcc. Fixing issue with extended assembly when atomic_sync_bool_compare_and_swap. Taking in account in extended assembly (-value) to negate the value. Adding builtin function __sync_fetch_and_add and __sync_fetch_and_sub. Adding other builtin_functions like gcc. Adding print AST with option -A (from @cosmopolitan). 1.0.22.5 Improvement: diagnose overflow in integer constant expression #96 from @pmor13. Fixing issue with old C style (K&R) when parameters order don't correspond to parameter definition. Adding \__LINE__ in parse.c in all error_tok messages. Removing \__builtin_memcpy \__builtin_memset macro from preprocess.c that causes segmentation fault on zlib project. Adding other tests from @cosmopolitan. Reporting some fixes from 1.0.23 to this version. Fixing last issue with curl due to sizeof_int and sizeof_long not taken in account (adding them in stddef.h). Fixing issue with semun (ISS-146). Fixing issue with \__builtin_clz that gives incorrect result. And adding \__builtin_ctzl and \__builtin_clzl. Adding __builtin_isnan (ISS-175) and __builtin_inff. Fixing issue with lock not correctly managed in extended assembly (ISS-174). Fxing other issues with extended assembly and adding several tests. Adding \__builtin_bswapxx (16, 32, 64). Experimenting the stddef.h from gcc and managing some issues with offsetof. Fixing issue with assembly (issue155.c). Fixing issue with vim (due to math.h) and merging some improvements from 1.0.23_vim tree. 1.0.22.6 fixing cmake issue. 1.0.22.7 Fixing issue with named operand on assembly. Fixing issue with struct union found during vlc compile. Reporting fix for c-testsuite 152, 162 and 205. Fixing constructor and destructor. Fixing bug on preprocess that skipped some attributes. Ignoring some other gcc attributes like nonnull. Fixing c-testsuite 213. Fixing issue 36 with empty struct. Fixing c-testsuite 204. Fixing issue 166 struct with VLA. Fixing issue with semun. 1.0.28 Fixing ISS-188 on old C style (K&R) parameter omitted by mistake. Reporting some fixes from 1.0.23 to 1.0.22.8. Fixing ISS-186 with lscpu tests (util-linux). 1.0.23 Reporting fixes from 1.0.22.9_dev (like implicit function declaration, -std=c11 -std=c99...). Fixing issue with \__atomic_load_n during linking of nmap. Fixing issue with vim (due to a mistake in ND_ASSIGN). Adding vector implementation (with TY_VECTOR type) in progress (basic operations seems to work fine issues with mixed non-vectors/vectors or multiple vectors parameters). Adding some builtin_ia32_xxxx (like builtin_ia32_emms...). Fixing issue with cvtpi2ps. Adding cvtps2pi builtin. Adding lots of builtin_ia32_xxxx. Reintroducing int128 management (from experimental_int128 branch). Allowing some bitwise operations for vectors of int. Fixing issue with compound literals and vectors. Adding scalar to vector promotion. Adding some missing declaration in math.h (found during postgres compile with -std=c11 that sends error on implicit function declaration). Renaming branch 1.0.22.9 to 1.0.23.chibicc-1.0.23.1/asm.png000066400000000000000000001710221505335450300146140ustar00rootroot00000000000000PNG  IHDR][.(bKGD IDATxw\W?." 4E0`BcbMAch$'<)555J ETAoKY:Kk_3sY̝sϽ#"`0 `0 `0:u*ʶ`0 `0 `0z,`0 `0 `0 2 `0 `0 F'"P@,EEE(..Fmm- ]ޖPTTT|>===|BOOPUUUu0())Aqq1Q^^*nii)jjjCMMD"ttt hhh(H$x)jkkQRR*hƥvH$ mmmz`t53zLCMM JKKQYYzbFe. h{]?ԄP(RWW**,hHYY4%Q5%3Uw{{@ v^EzLеiii@^^=z| ''yyy(**BII b:cccFFF033 `kk ===P555#!;;wi`aс>SSSFFF0559lmmann';=J#77O}B<}O>I74(UUUhiiAMM tuue~ׇz!3zL3C~~> 8)**(**j6@hx<с:{u}OO>066 } ܧOaa!QVV TVV*2@t _6uBPٗmQW!Jܺu {.Ґ4qijjrAN.𩧧eHvQ9) G G QRRe!//;;;puut!$ ӑdܻwks>3Baັ1,,,,h}}}hkksJ8f6IGHG>}ʵ5i+,,Ǐ[C"`kk [[[١_~pvv 2AAA233rQ999\!;;%%%ʩ@WWM>jhhp3===n$nv!! ۾> nfӧO!HPXXi4CeU\\,3`PSԐ SSSs-KKKXYYZfg`5Dff&233C0+5JH]]].)otDCpv~*fޯ1u౬k/EKKKX[[̌ 0Eaa!dee!;;ɓFe{oe7!'sOiJ:aJfKml211w422 D^κ.tEtt4^$$$$ -- bB\RMUTT ##iiiiiiHIIAyy9x<lmmgggxxx 6SQQ8 11 uwF~7i366V2nq] ggg 4^^^pvv뒗ܽ{<@FFױ7u:::J*AD(((vd$>|D߾}q;;;888ޞMw&0g]a13:"%%iii\'33YYYD"~&O>*@t_NNχ)aii ۗI;;;eF';;)))HMMYYY܀dYк}RmpА4HX_ofgg+kkkXXXpXkkk^iiiǮtŸ~:._h\rx\4#=n$KQ#}ЋGRR!aii /// >dkv \t QQQ͛7QSScccqoirO\Ljǭ[$ǣZZZ6l ___G&ZJJJw"%%0`ثLw'wn.>(Tx^`簾JAmm-rrr 6IKe[YYޞG{{{8::ޞ 4vs)H}nS卂u?x뿨qXSRyA״4 $$ϟGAAttt ___`044Ty]2\~qqqDxx8rss{!CzA)++Õ+Wv@smNNNŸ}6vwu;|}}eN dtZddd )) qqqupmH$r4vvvprr3u^Z|Cif;w@,C NNN30p@7L[ѣz~(]N:̌'''Ki0CUU8?uE_>AW)))|3-- ,r FHvzʼW&&&rKٙMggg <t%"DGG8z(ݻMMM5 cǎE@@ 88aaa(**K/aȑlC9r˗ADpwwڜ{pl Cpp0BBB ॗ^”)Sݻ> @ 2]]]777aTWWݻHHH>>gӚ oooxyy 5s`/>wM)))ALL PQQ-ܸYla HLLJLLģG<[B^^^􄧧'IRUUׯs{A"@]]NNN$%{_J}3))  :M.(tr /9r>=^z%L0Çgk:X,Fll,Ν;Ç#!!FFFx/ϯu333q>|)S0uT@&v{cǎ=O6׬VJKK(!" 2@zO>:n7Ζi`h .]Btt4),,P( wwwny. ϐGbb"^XnƁ%<==eX<>9qjjjЧOxzzbذa4h\]]ѯ_?d "񈍍ELL rrr/m]~͛7akk)S`a٬r$=='Nqecx뭷зo_e'7$ BCCm6=zژ>Gűcp &L1cepy 445555j^x =?CVo XH?~ǎCZZ1qD.cffl3=۷os%%% /@(DS\\ӧOs%%%2dƍ???(2TWW#::FTTB!ƍ@L2E/Z7n @>>>t)H$9%C\t&L@hСlDaa!-_̌6l@6 YYYb $###矩FfutO_~,,,h#(..^y!Gi&*((Py?z7Ett4-Z 8>fϤ RYYIO 255%dooO~))&MD{?MII -] w7'%%&MDhΜ9T\\lZGqɓ'ѣGZ٦1-Sںu+yzzׯoTYYlZς?X7͛4c  CAAAl6QSSC'N@RUU%===zwѣG6]b:pyxxrpp't1 y14h @}v[t%KZp!urF>#RQQ3fӧOmIWW)>>^0:'N 988еkהmL'---244/233mn魷"HD/t٬Q= N_:u*x<4h޽ʔmarrro%sssRSSŋmVݻw#Cg yիWi$ ʊ6nؑ]=zDCW{+ctqBBBԔ>EG, -^[t m';;IMMeQ^^N~!ijj }wZP l2RWW'333ھ}{(30g0CWܾ}{'8qK`tJߨo߾JAAAe$7ّ*͛7OqC^dddҥKI]]LMMi$zԿ0`f$2?F6l}366͛G}%HD4tP/ٲ1114o}HOO B7n)m鿔*/I$ѐ!Cܹs -KDD΍͘1;1cdPSux<244@i}57m$Skkki4|p!@@fff4qDڸq#sJ׶7vUV+v_LRER]]M;w$sss266?S64ǃh_W _>eAAm޼H__ޞfΜI7nh֖D,Fb 8YALׯ9;;Svvv,mׯ ŋ͍Њ+ZU%>|rJHH *(('OHf`S,ӪUH ի)99*++)''_ ]76gGhk5zmTTӌ3ѣGOo& w>iĈdllD"s璚:uJuvW%'' 7oREEݻw^}U@+Wlx<mڴI4Eii)ǣ@EԚ5j(ھ};s7hXNJll,׆.\d+WAm-W5kp4UmٶJSL!777icիWiРANׯWJ6(QZZJF/^rzKZ}m?ޢg&fͥǏӷ~Khɭ /%66ICC֯__ rgxi@ȑ#dllLb*~:Zzu#^}URQQo>|HJ~!xz>>h :x` .$t̙zg̘e'6=[?QKKЬYouv{F&ePTTD-"8qbXuӦMM /*~/ϟO~'Φ2 ''''э7hذa$ /hM]kkkiȑ4p@ئNKI>VVVӜ9str%߿?YXX4[ʓJ3g|O>/ϟOAAAq^֐D?M85Cj:vZD-v+C$:z)((eD2,'L@:::ޙTUUѤIHOOΞ=кR6/B]]TTTͰJDDdffF-^R RSS_oAd0ܹ022aϳeb7b#88iiim۶A"Xv "&9r#((H1C6'vfm ,,,uVlٲr7СC˽)www궩l[xرcjjj˵.Ĕ)S  ;;;^,Y˗ǏL>-io팶sNk:t(ܐӧOhm' -- 'O\|g7n[mm8y$͛Y'xiftC޽{k.9rDu1W_v +W B}ŲePPP!;Z _`y&>C磠}BBB駟6S_PP9s`Μ9OZ"033Ï?xd޽"pٹIΆ#F)Ν;'… :H$իADXn]}ظq#>vlXr%v mmK^B8p֘={v8tvڅ}Sj~yAG}:Mq1\p?s5 FPP~?mmm9UUUسgtYYYѣzlS?K.ٳ["f}ZZZvV/^s!??_nu۷^^^[M]c+|>GKh+ǡCVǣGi&[e8mϯ*zUTTo>XYYaǎطo_Ƿvm>|8lmmgφ*N:vјɓ'c֬YXf\;LeŋڵksN >O>m-m?l2߿{쁱1 cǎ n-|>7n[E/FFFXn޼yx瑗{{6ۊqQPUUO?bܸq3g΄*6mn<+++={~~~033ٳ~:t_8p`u `̙y䍺:vڅ(8qBuI$YsmSŽ"`~1_> /ήİaðj*|W(--yLk||< @DAZZ^yK6mjjj:\G[ۖ 6lС ҎOGli+&LD"ip9;Y|ǨBrr2k׶ێQFq1СCPSS VG{&~[!u*.\(sdCF[n׮]\vɓ'{i9Yz5޽c?`gg===̝;k֬ݻwaÆv3oD ̚5 .rrruaɒ%xWP[[l39D{⭷|ǧUe̜98p@w߅D"_ (//Ǐ?ئ̶^g[ؾ};RRRwu<cǎ+W 55\i/;FW'O`„ =ztgu}]Q޽{0`܍k@[[[|9s&9_~377VMW#-##kj8::ٳի?4yg\4DMz"с%RSSr~Xvt65D(7oԩS駟"$$ݶ'''W^BP bbqg/x{{c(++QQQ!юx`ڴiKws2 z\QKg4ZCsʔ)sεۖu0Fw={`XhVX"((|/lڴIfr[1cҥK8r-jqb@D"Ǐqq 6Ue2331c =z۶mkH$ܹsq1xW̞=ׯ_oE7ŋa``#55[nwiu ^;w9XqUI(2 Ǐץn }􁻻{(Z^^H˽*#GˣFqF޼y0zzee-83g@KK +Wl2-5f"5455<˰!"hhh>t75z#444ӧ (6m.9R\\l6MZlf̘D,YD1mi;wDII 455M-:u* ))IY}}}nٛΆ3666dOw*%>Lٳ 3CJx_{)N}Xb5qqqI)zT8??Ck5D"Q3m9 +e*|q}_QH`< ֲܴc 0;w9mmjjjo>DFF6ZDD۽zSw YYY2_0 vtL[v{鿬l ij=8e o733Sʕ+ &n ٳG jjjAD틌lVåϞxgҥK? СC;t殳-2Dwk׮w$--{@VVV,`~e… QUUެ*{{{DEEu{FAWiZ|Kn @۷op5lݺUX|9 eH^zɷ޹s[n/e6ň#p)hhh`ٲe^0j(899СC:ka&Mڟä~rSx<}D[mnժU={̲̋%66Uon/QޝׯtܿFFFm~> MMMoɓ'ahh{Nfئﮜ9sM]Qw aaagw^x`:AΠ ly_WW^^^-LuEhs!88VVV.\(a)ӧO;Ο?`n;!//ݽmŻ ]]eեH$9rƍk=(-- /[?GRR?%s$nܸԦ}dDK,K.\~P`` >#Gѣ5Srr25kϧ+VPbb"UVVRaa!baaA|>Y;r"&777zZ?3HwޥBG_0_XXHJ?3Ǐiǎ!Ss޽ƍr- xxx<> kjߩS 2$ ]t۷~OB<<_a˗H$SN)>;vZRQQQX@??Pgeey{{w+HNN&3339rB3O8@***g)N;uVxaÆt%" '>O۶m|݂gǣ})R0`;i"Maa!W>bx RUU-[(^+R]]M-"C(Keՙ(n+>Pqq߾};o4w7!> G_~eK7t%"裏HMMeBbbbHOO͛zUUUiQ\\L#F KKKzBH$7ߐ M<>|͛7iСIGQxL{/L l'zI7PmmR`0eeeϧ3f49\9sBCCfHHH oooDsi>*Hh$ ѣc%sUӧM8***^?C",X@bX3Oii)5LLL(!!AivӀHWWn?^AEE}g$ G bCyt%'zm7ߐH$"ww&_2`dN:E֤eG /ǣ zMb0JӐ!C(..E=K]p! B_:f)s֦f_~ oN>|H3f 4i$MX,~tuuo߾t!eh'UUUߒ6vӛoI$hƌ֝dti***h߾}G<,,,裏>G)۴VP,]"Hرc4qDdhhH˗/xe` XL!!!4sLRSS#MMM7o^T>}{8p  7776HVilll/8}ۃR.]D&PH .rSMMV"MMMׯ/_6l;vE)//75 Bz7(==]fuIII ###?>0g0CoYH$p-^,,, ˗SXXX 43ta;w.Ӈ+}ǽ&VRZZJw^x%ݻ6KȠ7Ҙ1cHUUB!7lB+:D"Ç>|8Ν9s@]]gtDPl۶ ǎ9VXny&6l؀?5kϟ+++esvڅ;wܣ68q<+W@$aȐ!E@@FUUUe!TTT .. ŋ!Hӧc077Wrׅ?|III8x ASSÇG@@ea͛ AHH"""P]x0 IDAT] wwwL< mҨ@HH8q999033&Ld@?~+Wpk׮A]]>}:N ===ySR$ N>m۶ӧ|4hPgUh)))طov܉L7Ĵiz\?99[l={PZZ)S_رc!m^ǎÎ; ;;;̟? ,S(YYY8wBCCqy@OOF˜1csͭ"C~!.. ŕ+WPYYcƌرclS ?a>RSSq9… x 0zh瞃+Met3p5DDD ,, (// H٦v9b1._#44Ѩ#0j(x{{o߾6 FLL .\0$$$ǨQ  iV]뒕;wǃ`oo^z ӦMСCQe')) Ç̛7 ,͓;8toߎK.AGGSLi0~ny ?Ç#$$0uTa̘1,s-sqA]]C 'eb$''#::$%%A,Ғ{0W|r~9rH*T]q!>|߇ &L3j'x"qYܹsfffx1m45 |>_f* 9r˗cbرAhy Hp5#88.]@ q0m4Ewk$ n߾ u0Iѣq R\\$#!! ~:JJJz6e?.LD"Arr2bbb8LHH@mm- WWW8;; NNNP 9SPP$&&r>yMASSIecv>,⺾x>o߆D"9<==1l0xyyaС6DA׆ѣF\\`С/X JKKʕ++ƍ@>H$PWW7Hҿ888Ύ-3ͨw")) HJJBII puu2]RXXPHMMÀQ]OOO899ո}6pʕzӋ0fnQxemATTyll,jjj`ddooo 4WܸqQQQիWQZZ ---1;v,\\\mnwAbb"n޼ɍedd@",--Nѯ_?XZZ@Wл " ##iiiHw|Se?OtI'RV T(2dCPn}G"2DlQ{EZ{'iӒIN^+/䜜+\}Ɗ;w 77`nn hhС)an[n[/RwYV񨮮kNB} <==9Q'J"))IL?JKKڵVŏEii)5f&GEE!== Q7H ڦB >>NLLLDMM b?)vIڲۭΝ;/fffڵ+[Hee%qmHĠZhGxx8(//Ǖ+W4]rr2CˆJ```WTHKKCll8(B.[nb0` ܽ{Wfܹst>>>󃟟|||о}{͍g렪 FJJ d$%%!99pºCŗ ?^2spo|3mjjj5'B///>>>/о}{Yc***BFFQSRR q{;;:7A*ֺΝ;{nZI___wWWWq#Jl --M~NNNgֺdj4i%]kS*ո(qT*С:t@򂻻da ++ HOOGVV8#-- DL2WvJOOGhye. ۷'Ѿ}{Inn.2334-..[(RWQQP DFo777xyy'nnnpvv5S6OII PXXo~~x.^dgff"??_=\\\$2|}}/^Tq2qKqόAT"55:%렇 GGG$>ZIUUX( u1++ bKj{zzdꢟDfEN 먫X7>Rx󨒒z)Wfggs8YKϔ|L;ZrܹsG#y)۵k8::^5 ƺd666: YZZ*TVVEEE(((@QQQXX(v ^lE0"뢙.Jz\ff666/Z&AޚA-eOAAX~2HDbW\\,>2%;Q/ke:fb򐞞dddmUVV2333;;[ O06 = xA:vvv077x?33:'(BY]eee(++Cee%JJJP]]|ASP(\BG8O|||`kkۤ=kg3PYYz@NN5L }#3338::B.ruumi >A=|T*uz2\grpp3<==Vd070}+,,DZZrrrB-((Q'$&e F-`mm-Z6*q um6BQ!%l/cj+$A777 e4̤!##CWVV 4rDg)d ?k˸3f:>2f8?zp ͛7RVPP{~kŜ`ee+W4^d3fc̠?k˸3f:>2f8?z 33Bf֬Y#On3.-2.OtU3k֬_777ܹs k &O L6ݻ"bx?k˸3f:>2f8?:pU͓O>(_uu5&OlĈXk쌑#GBо҇9̙cܠ3.-2.&OtUѣGkpd2BBBн{w "c̙35VW]]S9"ƌ?k˸?c#cS']kQ(={nĉL&C޽ѩS' b8?k˸3f:>2f8?qҵ &ں5554i&Lfffxꩧ$12.-ϘȘiTIZkt8r<%f3f@uusJR&pgm֖qgtp}dp~㤫ӧOpr9Of5f888r <FŘqpgm֖qgtp}d4q~e㤫#G;'0"ڙcL&㆔\Y[埵e\3\3Mj8骅Bi`nn333DDDUX+>%cIc埵e\Y[116mR0sLamСC5j\\\$12.-ϘȘiT˥: //@ii)());ڵkuoEee%򐗗rP} ̄sb333Ikj ??())gSTVVSN8|X΅vNNNpvvL&0V/R"TTT\,󵕕);w ,--5dprrzaoosssyLJBaa!jjjP\\JFSW\\:%llll/OBhX %EOwD$ uaΝbfffptt9`eekkkc|LFFD$uRVVhܽ{IIIHLLDbb">>񁷷7ѥKkNocmGEE\1Q߂'΅PTnaa[[[IT$k=qg~gL***L*,,D~~> QXX(>'\VV&&o ` =ptt 7773%EEE@vv6E?WUUqV?]\\e}h5Iל={.]Bdd$nܸ8T*~~~b]vVBLL 1j(qd g+"''b-%%Րd@pp0z聰0<h߾.|2Ο?7o͛ˊFWV--D-_8%z 2'$D!!!ѣzpC.EXddd˸vnݺ۷oI|||о}{u=3$ |r{ %%%ҚJOOGjj*RSS q+u.][n۷/w(Q555HMMERRLdff"==YYYHOOGaa~u:88'lqf899ՙ'$JwbT*5y![TT$^d (eeeШ+zX& 􄧧'ŤЗyyy?3e͛Q\\ c@xx8/STUU㯿˗q%ѵkWk׮ҥXS5d1 $ \Ν;#,, aaa6lBBBvV"''o?# Riiiš%&k'۷oWWWTJsc紴4񹴴4ddd `+++ B.]йs&}̴pXeee!66V$NLL'f&Ho߾N2QgJ2X`7$//OL@kKH ?'''{ B2600:uBPP/wІ 11wAll\MNNFRRC\. zxxh Fq؟u |! ] 猵BhPPСCqbB+r* OƁpAܸq666ǠAx:8s Ξ=ӧO;wƘ1c0vX 6GLD\\~7#FhՋ`޽ؾ};= L:/F^ȕ+WqFEHH{1<ӧI݋{"%%={6Ν ???Clqi9sOFtt4jjj`kk[|уpkrssqu\v ׮]q-TWW}%ܤ.n6"BLL Ο?/>n޼*( t !!!v={j WUU{9n޼H$$$ ;Y$PQQ+W… 8<.\ &DP7CBB*uج ĥ!,,Laaa~=`ZIׄ^7nDuu5fΜ~ :4Iܼy?6n܈J̘1/Ru`lشi֬YÇǂ 0~x ̷v999__#::CŒ%K0qD>le|z*v9s'4e2pEر[lANNFgy=X1Jk׮᯿鰰@hh(~w Hee%"##q5\pOƭ[Rйsg1 ;l0nqԩS8wdχ%o߾ѣaii)uH H\xϟ 5߿?ߊg믿zy5TWWGѫW/:tڐdDFFb>-- fffѣ  &ںb?N˗qIj,+5rH899Ijp:r'ODee%*=aaa|13m%%%v횸ɓ' #""ЧOH9998qN:ӧOP(ܹX/CCCѽ{wXiiib&pFDDF)\Pqq1-]Ϗ;2$Rhǎԭ[7R(Rvva8?-Y222ɤEFF?N2 @gϞ:$4zҒ<<JtB-#GPUUPoF~~~Ԯ];Zz5UTTHJSSSC7o&ruu~/Zup]5jr7o%''KRr%1brZhJGyy9XϏ*//:V%++}]oO?q;;PNВ%KTRR"uxʢm۶ٳŅd2n uuzw\\\hS||VJR?cǒiՔ$uy摇]K/DkJf0tz7O>i֬Y{n*--5FOԩS ͘1BQTTD/&\N#G|WdccCtii~Grss#ooo:~Z>LdggG˗/bKKK~r9 8CLvv6}ԵkW@~~~ꫯ9!8@O=999L&|6oܦ!>>Qǎ y{{… ѣ|%DQQ/4uTrpp LFqR?Yf0ZbEGGKk?ГO>ICָIכ7oRΝӓ:dCjΝ;RԩSRcRJJJhdffF׿RZ4iʕ+9b^ LFSLTCjS\BaaadccCk׮mSuٳ4k,"GGGz̙3moSQQAM<Օ^u{ԡ jT***#G\.'OOOZt);w̤<̙CdeeE3f̠?Uմ4裏;/%&&Jc233i4tPdCPK۷lmmi|2h4a277 6HIHMM=z+>|XpZ/%B$Kݺu#'''ڶmYUUUBqQQQ!Ծ}o߾Cׯ> 4araRɡwyڵkGfff4n8ڳgk1hR uؑVq uz'HP3-^]&uX$&&|M"\N?0_z{$]wM4o<ÀT*{$hڵR#$ ݻut &'''3fLS*Ν#777ׯuqi޽{AǏSxx8d2z̙3RĘjڽ{7׏d2MRRR&q=diiI>>>zyu?~H^poZc/2z֖<<bbLoRRR_$kkkELbcciر @{1]AhРA͹sʰIh Ĉ!555n:z yyyј1ch͚5hY\\L4Yt>˗/́SNdff˗/'sss zSSUUEΝ;Svvʝ`ݦ._L/Y]W^%{{{5kzj2رc:NֶKKK 1mիWiرHvvv4bK}.]Pnnch*^zщ'r܆G퇐ڔ)S1bk K&+M8.\s|+zzK9׭[wXG[ah&RI?#yxxF9p.T尵R:q#}gF=}%''k}mϞ=;֭[\޽z… SOQ@@YYY3?N_uMݏHz駟mc^z{znΐ99s 2 MR%]KJJ[n4p@~y[o%gGEEջݴiH.LT^^Nwܡ~d2k׮>'cƌi0#4cƌ:߹sƏO={$']U*=cE=)yW֖n޼i㴔rnu.m۶m$hǎyvOJJ y{{ȑ# 2g!;4݄ ?}ĉstU4h^{~mSϝ;G4eJKKl7o) F~~~4dȐ9 <++FMfff[o5ffddPvmݺBcЯJdnnNG> z;wj`@x~ʔ)bϾ)Sd|`\EO<d2z饗Zdq尥R)))L&'JL.}СC߾};R{?ŋ2`z?{RIK.%BAݺu***(##9"_SSkyR(_Rzz:Mݻw'33:6" r%իY[[ӪULjhdd$ۗhʕk\7FTgPSNtn/rvv6z;JO>.]u .7o.\Xoښ @R;ԭ[z/XMF}UWWD.hܹ?)~:r zTLf2x`ۿ hĉԥK*,,4:u/)Jdffi//|}},5t[ yoc$]՗4s[lP$;;;5jT뫸o\/u9lTRRRO>*TKKKq~Һ}~WSSCcƌi~{C'vϟ_k׮ԩS<7lHUUXiԩ&FޞHoߖ,OR:c0tB<YXXЦMt0ILO>o/:x Z ܦMZJ&lmmQ U~~>?Pzcn+ѽ O\NW^54j(ׯG[R;ϟO[l1xGm١C>nPN@#~)7:moooPvƴ'N x:vUm,%%_~ؓ@u&L O͘1^F+55Ue9>m巩}?|ΣG/^.]D4bĈӘaKk*~ ݻw%)}>;t!doo5-s-ZoiVwMSSטzoNCI.k\#¹?~i̘1S{%ssszg~Sm\7O]KꌙЕJL[n.|(|pttŋ 7bΜ9 CϞ=ѣZgСɩ8s΅7~7ܸqWرcѱcz~ N^zaժUX\Ç?d2AՒʝoTTʀ3.]?F9f[cʔ)>|A3gMi&̝;]Jƴ ,,ksǏoj:y퍏>ȠчjFK(h+K_}IC}Έu-..͛p&OBCCqa\t /{B9lIT***0~xXXXĉ :z m3Fw}Ř4iNׯJ¤IAP4k?uVZZrC6s>|893gHg^rSNżywB8tuSSKc0t%ɰb |Xh1c?JXx@DXbk%%%Xf ~f|Ñ;w.~V۹s':taÆ8-ܥW_ƍaoo駟Fii)9bc׮]Í7 ={6r9݋Ο?,?^]$%%!==n{?󚷷7 && KKK,Xɷş~)gHNyyy/,Z/6o KKFן NW~74a[O7m??? 2ԗ^zaÆ o pS~_*~3e˖ƍ7tz٨4u?!ܹ;h+6OOO<سgQm߾AAA0`トTTT`mڴI,S?R]]k׮a077W_}&!i`kk[5;;;ogӧOGII :dc5Uii)VZ_;w:Ѿ} 4O~O=Ǝ,!44Q-**ž={+_~}_GX8iJ=%"]VY|I=A%RIKKW_}+V Wm}ڵk ~\\m۶6lm>-- Ю]F U %33o&}YL bccyfL8ضmO???  T*V\ (++_|5;oJhC1"<&| oeN*7nСC6,u[L?駟}c:' ƬYN^7BΝm*="KmnX:in==x Zb8yxc)aKhk.XYYg::=-2ʱ]]]cc̆4}h~ͩѣG㡇7|Ө}yn^{ 111pюuVL<~~~F;n6%Msc֭ =隚 OOOE7n@ll,x 絝 l0 IDATٳw^:u*rss1sL\z.\ڵq|oocAjjaDzz:Jx+r^{ 7n:k HIIحURR|}}vG}NNNx"+mS@)%%SL={~f'''fq&<'lch~~~HLL4ʱիڵ+ܤE/N<_9瞻R}_~:kmnX8in=]z5fϞ-"2C ڵkRR/nGrhT.]AZ}Je)Jñj*bҤI(//׺]7u?ސJKK1j(t۶m6sC]tюyei i 9>|8{ҵHնqFVcJ QQQR(>|8oߎ7xJvjp;;;KP*XlVZw}WoːZ;5Gaa!z!XYܝ;wWН mU~~QO0uT[hƍZg9~?cǎO}ٵkW: FVzXMQTTR;u?ڔ`Μ9X~=^~e3XdAjJmJX>i猉#GLji- IY뇔Tr~+KI|Ấ>fy1eDFF^кСC3zO5554iyzhtn+ggg]WVVfn6.ur M']===UWWc۶m8}t)D$~zk#|.,^駟ЫW/xhܩYh8 /_.>t7EZZ moFEn݊;wٳ6m6Mcee+Wo63uu^1bD_`*$uzꫯ"""G|ppp-[ _} sիWcȐ!޽{i1$nCrhT u&$脙TVVΝ;7ڰat邍7j5xP({!ۡ!꽾,Xرc7ܹstnJ +r}xWbf ~T\\\`eeeDKJJjeN*{QٿtYYY1c&N( R?t1i$ǏѣGݻc׮]T*?[Ͼ їRO?m`kkKJo>ˡRsZT;vD׮]q9jfǎpssC=vvvؽ{7lmm_ysXl.]T﷓߾}~-&O,l~;?tY#S>o>XZZ6)(//wmyCݻvmOh֭DDtI@m6JMM O?,,,(44***4իdkkslqf̘vdff6׹s]~h4ÇӔ)S mٲu~С;?N[fRO>!>\իW M8Q~ Էo_RTZѥM={,YYYԩS)==rrrhP(СC /ϟ'te)T*ݛ{1C!"Pھ}{~~>҉'nAhΜ9>VcV~7[`6/Zx瞓:q_ e9l T***( Ν+u(DD$sssر#޽rssRSSiڵ@;wԺŋѱߺu+vi}7$sssz7TYYI)))a|JJJ_S.W333uVߴiV8{ƾpn*ٳ̈́ 6fma4իWL:Dt%"6lM6M3`: RINKҀ}P(ޞhʕuNbmmm5gԨQ ƧYF|}N?zkdcHmڵdggGeeez}ߖ^z޿.^EO?P(חJ|sQ@Ƀ>(>h "jZz3f 988 >N:?N/^Lݺu3ȑ#$h˖-ơ|Nv5W?׺_|X]tit|ߦ N\9}Is)ѽD~PP_j0,Z(%%EPaKi{ndp5 meS(|2͜9Ғ,,,LJ&MDO}vvvㅆ?|" .ЬYחޞ/UVV6knj<}ӖؑPK,!;;;1MF&Grl[u9(,,]Ґ!C>AϾ{,\nB``ߞ5B~~>/bٲeRc0СV\)U¤3uTܼysXL<vZ߶$!!/K}-]k׮CIccҥ_0i$ù/n[K_ƺu믿bرRØIl2l۶MrCc***Bxx8ĉ IX[Q\\ѣG#!!.\ߒ++̙3AAA-flʕ$K,|`/apv؁>HPZUV!)) _|ԡFxcܮ'|G}<'u8ҥK矷+K|g1c}Q|RØcٲe%I;RpܸqC83 4hpqݾPmC2~wCDž ҒV^-u(FQPP@&&T[SVVF{KJb 3gH ڵkI&ջƨ L&}-I !##&L@fffn:i4n[KER4n8JNN:$ƌF믿Jʊ-[F*6oL...Bj5]O?49;;ӝ;w yEnn.uЁFA555Rc4G!333Z~ԡIB{ԡjJ}Qruud}'B+VHJر\\\[ntEavEԡC믿Io9ZC/tBoj{'={vRlڴIR)F!v-***.^j8tx_}(--}܏nU?n\0p@ahh(6oTm38 :v(9P(W^%%%rԪIm~6R,X@hii#F KjÅ0667nFWXX(>ѭ[7P(ؾ};wIbE [ljZC[իW_۷zzz^jmZyfO B!T*xEZZܥ5Z-o.RbzdѵkWiqÆ yJӅB1*nܹ:u*N6"[o R)&N)k wC]N?N: '''^oFN<)t",,,7|Ӧn'`'zͲUPҎ9sӧyLT' ###ahh(^yqeKkrˣoTXX(;#;;;oǏ{;w)S333#F-ӪGoܸ!-Z$lllB +V`KFrr+ "DǎżyDTTTciCW]vΝ; KKK ~ ҥ033ׯf-11QM%yƊe˖~ B! / ~QVV֘'tB<1g%ߪnnخ^*b&nm&,,,X|9wRvv?h׮pttd{m턯_z52?ggg-f̘!ܹ#wYNTTTBo7|# \\\Tnߍ7ʕ+P*@CfԠũS˅ZZZW\R]bPYY)N:%ϟ/aii)޸qC۶m3f̐С>^Zl2O ]]]P(D޽ł yՐ!v!nݺ Xk׊$Klo8L)))'NVVV055F_~ cKRTT$N8!,Y"~i/'''1k,/JPUU%.^(-[& w.^}UeNB*v)fϞ-\]]#|IxbqiXB4'OᅬӧOwޘ={6Ə===KUee%vލիW%K0rHKkRSStR*f͚J%wiիyfƜ9s`dd$wi"""b l۶ ۷ĉ1m4xzz]ZVUUC!88w.f̘yq[񈊊p18p@bb"___rJM 1118s Ξ=g"11J{СCr"qho}bbbp=zǏG^^ лwoF.].ZX\pAzDGGCV~~~2d`cc#w-VYYΝ;'PTVVRׯLLL.{!,, 8}jvvvrj5$( 899'6t|KIIATT6#""Z +++)߿?`ll,wBWt_6mB||<0a9{n +** {֭[qUa1cu&wy^yy9oߎǎ1f]vrಲ~l۶ FiӦ1oN>M6a@=CbmCnn.N8wƝ;w쌿o2e z!wmFII .^gQUUSSS)uwwGϞ=:]6Irr2\rQQQ()).\\\ЫW/eQ\\K.… GTTbccQ^^mmm899 O<z8::c*''HHH@LL [nAD+-dPJ[RGGG8::ޞ-HHH@bb.###PTpssпrՅa˖-ضmRSSѩS' 6 ÇѩS'K|$}aHJJBǎ1fL0R6)==?3n݊/BOOO=g}-2@XX8}!,, 2d&LѣGsGTUUc׮] Abb" 0`aݻ7 .8v;+W@>} 00ٳe+,,իW.x111(..tNNNٳ'z=zH;۷+++ oFbb"]8)hw 5F,BGGG +CTT"""($%% `cc)upp@accÓML $%%ƍHHH5FMvڵEE6NWW]vBXM]Z2 ))Ij?QZZ pwwڨUC߿Ǚ3gPYY J#44T,66 ^^^>|8///if222~۷Bnn.O}гg񻓕h\t aaa Cbb"O?40hРfَnB$%%!>>񈍍~NJJfvvv=t{{{ؠsΰlv Aqq1222۷o#)) oߖnݒBotUyܣGg Dׯ_h~NNNvI}h XXXpC(//GVV&%%HJJBrr2RSSQ^^}&loV*''FWjY lmmkQKKKX[[~9w233}Vo5NRUo2~FѲB?+((sp9={ϟGaa!777i@ںQ; 눌Dtt4]ro߾RH3-ZFxxt3g 99йsg]^WXX(߼y#77  j|||x͛7*^|C3 ]tAΝacc++&-PQQt$''#%%nݒB8iSN۷۷5v?Û7o ?Q}VVV`aa333%QCnn.rsssrrpdee!-- wAff&QTT$_GG*J׺v*o8ruJKKq֭`I+P*RjaakkktQ111gKyyyϯgnn.p]K!kff&rssk|y [Ɔ*Ր۷o#%%oߖMMKKCee>,,,ЩS'XZZY6YAtBI377wAFF.5?y{fmm-ٶg[vgjZC󈌌۷QQQa涶ԩann:zzzM3ݓΘ 999FNNrrrK4â`kk+nnnpuu%uPZZ4Htt4"##W;wF7sss}) ***ήHIIqƮcǎpvv"jުpuIk.+̔с5:u$hB+333(7133Ƕ\sP_UU|TVVJ;ddd 33SOKK * NNNprr3zgggm$eeeHMMEFFܹS+pBzz: Ee]]]0116LLL׀?~?_QYYZU?,((@EEQ^^{eee(((@YY^M[ϖ-D #''{eeeI}&B^^:dӓBR_9055Rq<`ddT똴>JYIItܫi㗲2K}RQQ***+8jgjkkL 4aMs+92jZju˫q_]@V1)&oӫ1/ ??Oig/Ag )XϯkNjA kVVV̻jj]jIo߾,)0<4Wv011Um/[-JJJBjjj߹{5;UCyT*Ir>V&JMM~ﳲj4WV?ZACцfffJڂ!jPG5Z477V號 H;@; X666~۷oJfEonKKDGTGD+,,@V#77W:QWzߣ#whC$M ]hLHкgii5'4EEE5O9qQNkNo[~"F3Xz{<4gXFJDDDԜDDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 DDDDDDDDDD +QbJDDDDDDDDDԀ5 m """jK2bJΉ;88`׮]rIDD#i׮]׿Z-= K)J̜9eC`JDDDԄLMM˗/CQ㵘gBÇ7uyDDF?"jHTUUz-//Te#DDDDMl5FE &4QEDD?"j~SOAKK1tm5qAP$T*UQ[y0aB"JS ]dqI# wɱ?"jyIB`̘12VDЕHFG0( \E쏈mmm?:::҂?:v(wYhРA :2WDDDm#i񨨨@UU&M$w9Tr@DDDTUU!??(,,DYYEEEnPD~w^8::bCvj-o``}}}@ SSShiiĤq xCnn. kOeee5@KK 333 BίBԪ#77(--E^^Zaa!PTTRÇKKm FFFrOB """Sii)l!??G~~b)4Csإсa``ccc&&&ulff 顭sDD-QJJ 㑒d"%%)))B^^l}&&&033T*lll`ccJ{{{899C >~:RRR*T 77 >mmmְJJt'''5>fJDDDVNNRRRddddΝ;@VVS*BvZZZ055R)Ѿ}{Ϫ\]d >{ք*Jl+**PTT$-((30_kX+++XZZB:݈ieddҥKGll,'eAΝaggJKKKDԗU4?~B͕FjLOO$M_=۱cG8;; ݻ7z cccyIUU(!667nܐͥvٹsgؠCRԴO@cFvڵk}6^Inn.j˼puuЕZ;w !!}6Q=oߖ.333tܹVXN:cǎ VVV6999R]W 999ֿ 0[nptt; "jpN8K.!,, )))nݺgϞRٳgO899I>폪,`8::P*ѣ內~Zl?~gϞEXX\BE 45GuNU6KKKqu\vMj׮]CLL a``^z 󃵵c1t%""歰шGBBch׮]akk[c4RG{{ѥ#5'4۷oK9,--(=]]] Q$˗qa=zOFqq1Я_?xyyO>ӧ.RRR8,, Ɂ ???<֭ܥPRRGJWBPC:ЧOxxx@GGGrEV#&&Fۼr ???ߟ뇡+5HJJBtt4.]DGGڵk4[npqq+u.]H`|47nܨ񈎎F\\j5aggR68;;$ZsaصkaiiApuuFs >|ơC1(XEnn.>={ $$֭GK<0qY>}gΜ'PUU#((AAAܹe6w ] ! .HHC[[pww;`+//G||<"##GTTnݺ 73OD˗~ pwwG`` F OOO˓Eee%N8 %%ݺuÔ)S/N+//޽{BP9r$.Q999ػw/BBBp'Ĵi0vX^QV7DDDpi?^ YsssOOOx{{wpss+چ#** QQQx".\XjǀЯ_wQuظq#;\r={ԩS1vXt]!.^m۶aƍ{.yL>5x[N]{g1yd}0p@Kk2FQQq%\t N­[Ю];Hyzzr3wW_}(..ƈ#0c 2?Zcǎaݺuصklll0w\aGXr%lkkkL83gD׮].EW_!""?>mcJDDD ƍ }p[n~~~ԩeR ݼرcB0x``ĈСeՐ>6l)̙Yfy ͛7g!88FFF7oΝ KԩSp .y21:tp}y˒CW"""ztW^Ů]pcذa2dХKKVHH9rDwEE ѣGcѰL"jJKKcٲe077… K//+W9/__|n޼c2d-Z]Vr%|صky|pss,90t%""u6l؀͛7PT5j1x`αFMî] ̄}Ŕ)S0a(#&uA̜9w[oqf#JOOǢEߣeQ3SYYXl駟" @ZSN\_˗/okBDDDG%&McǢ_~UBFYY=m۶aP3f OwMII }]YƍΝ;]Vq̘1111O0k,n 7ɚ|86l؀4Z 󃣣#֮]2$V&11}Mi&O \'Ξ=x71rH]lDUU._y1pmBJ/2^ J\R GQ-YYYϰfcΜ96mT*ܥ=H]ヒW_}+cpF.]`ǎS8{,ƌ+++o ۨ˗c…7o/_ΰUfBX .o/߸ `ҥXj[oa֬Y0224+Vo)>#L>#7;4zjddBP#%%BBBj|Ej-s5ܽ{s(--UןS(uAuEL:]v1c`ڵ~zQ P(߿]?[=zxMԄ8s ^uzzzi&48JUVƍ7nf͚!C 11IODGxx8Ǝ1c $$AZbZZ'~ﻮs>𽏢k׮8s :v999 j/_5kn\|󃹹9 舉'"""z|C cΜ9fAQVTT$f̘! 5jHMMm\"QFwAoV֭[1~ߧqE@3gμϝ;':tPyZ-~m-y+JKKEFF8x>W{'-}qOLL#FXhiiwX@QRR"_.Ə/zO}Bo8҄xꩧY( f͚.O.ʕ+Ezzw8ypqqZZZb׮]|C۱cP*?oh)CW""6,%%Exzz;m۶V\С lR.\P֭}bG}Z*Jxzz ߮shubٲeBT ]ENNND(--}6r /Y cԨQI7>}ZBV׹Lffiii5O?!ăIIIBT mmm]B^x4Ha``PgFGff033gnorbƌc|cX|.0t%""jRSSpqqׯ_}B4Ljbb"/Jh߾\]kllP*O>\ٳgk':u]~z%GzC9r033Ç-&o8rHQO>Dz>WT8zh !G}$ڵk'n޼)[ Ը^z%akk+mCW IDATͽ]ޏP*}EO}TjZO 45^msA1btuuq1tM7h4EAAAug֭CUU܀ {US 57<$$$&&& PգqYkBD׻ヒ^x~~~S6lP6l/\'_һ Je˖] 5k׮_|Ѩ7k.CII ơ]q(JZ 'Ođ#Gu]r`JDD}qKKKˑŋի={_.IG={K/SH'9s#G~GKxyyaӦMذav)w9D̄իz2Pcʔ)P* A^^^.\;w`Ĉ5o~")) 066#}Fu7nD^`hh<زec̙3?? VjY6mڄΝ;#00QC}~}\76m$kJ ]ژ4^q{Zwi]fMWTbͰy.СCزe  ]&Mos#}.]  8ZZZصk.K'{ٺu+벱?JKKumذAk~0atttzj?wEpp0ܹPt'Nl;O0EEEؿ֭[1yd(sv W^qr]L<;vhu'D1 +]J-F_ouw۶mfΜk׮{G}ߟ/Yر#PYY7>gaѢE(++Cll,z OOO,YDjxwPK!fի4hP_rW?MVk'Յ',--ɓ'?w9}4~Gprr?~/.\+ѣ^뢦STT7n`РAM.1l0 <__~.ߐz)͛MЕ /tuu.hiijSҲOq=:w {n=*~'$$`̘15kǿ%EϞ=vZ9?qa˒xxxcǎ "jF`kkd=z4LMMqEDGGv Xq'>SRR /`׮]Xn]~Ǝ سgOGonuQ5ZBw l޼/|CV61055zj\FFFAuI9s / ** oFhFRẉcޯB֘~aȑ;*S3޽{e&33ZQۖۤ}>^|E188t OT*|޽;>F=emm M6M9rrrd]44}uS.+++J~/.&CW""6FR֭[rz!11 u^5sLhkk_~yP*T l޼gΜ5BKKjG "jFT*4?wSь۴iq9?2O7X`A}?{6Ս=SRRmoe4W6:s9s&ʰm6hkkK;88|cs***Z]dJDDHIIҽ{wϟGBBBl۶ IvCCC|W^ѣ/^y6..| ƍ={>ك;ǧL>7ߔP>o6&MTk۷ޟXۇ] 5#~z_~pqq;w0qD5 fff5i~"((8r:aӧOضmԺ{cqt)36667l͵]~ᇈݻRf&CW""6矇-]c/T*1|pܹ999PHKKW_}7x#|}__h,XX`Q^^T|wx߷aÆ:/YpssC~;w6-[࣏>­[PVV[naشilnVQQŋcPTrCDqA7zN  qC' .] X`+˗/_Gbb"JKKɓ'ҥK={6Vhh(RSS뢦bM.{_… о}(Z'|c Aݛl^&#ٱcP(b֭r" N:=/]$&M$t"􄮮AAA̙3ʪ>}g͚%:tpCCCɓ۷Veeeuz{{7oW׿^^!seu׋C.]]]]add$#-[&o|Madd$.;we˖&]ozzBVK?N?!D} /P3(+_PZZ*o.E݅011nٳg gg&[5oV&[gsk?_Ý;wNz}o,BR󟍾&T!c"""k޼yXv-v܉{NrKbؼyt "ƍ(CWWWr!ݺu Xt)͛'w9Э[7̜9˖-5kbccѭ[7iHsz""6>ĉ1z^FOTTT`֬YXx1+Dt_~)_] Ü9s`cc^{MRbɒ%+w9233h"[-pp+Q&+pB>-# 7rOX|90m4,]rF-={0o<$''^… ƔkbժU000~ӧCKKKЕNjj*8Gȑ#Ȁ) !C aݻw.]ɓ'qQ;wprr gyrJDT'N`8p<<N|'2RCհa!;;;KuRSSǏ+33SǎӱctQ]tI}ш#:AAA fQ\\ 6())INRTTx%&&jȐ!-_G@ƍ… 5mڴ}*))I7nT}}%&&jtnF۶mSrrRRR$I<.\ &|Jgrua߿_҉',iСRhhBBB4h q*++egg+++KǎS^^F5dEFF*&&FcƌСCecccpݻW>3]pAJLLw߭cTKTUU/ԶmgT5o}Tu̞UAA:Ni+ @ RPP'///yyy륹Yeee*++SaaUXX章@EEEjnnb588Tw!!!߿?W*;wNw6ѐ!C4rH9R#FlߩLǏÇu!:tH!C &Pjkkӑ#GLN...>|F#G*::Z±mmm:w233M˃R3fymu QQyyy sΩ޴|򒯯<==M?UrK{YP\ŋ; K.NvܬGj+ͪ2;m5]`0U666rvv6Gߞ{-P@/d1íT\^v|x'u.Z;~tsy9QOWPPw[v| HArUR2U7+رCw}: GZ$(](](](](](](](](](](](](](](](](](](](](](](](](](](](](](](]l,fR]]x555Ng!!!JNNDL?+ *9rDF}٦ M8F`,/p=f^hٳoP"d0~{*y{{3p@>}`&˙ p鮻͕WzՂ nl(fC `sU[[kii̙3op"B ` `0(::Z @*@ `NNN2elmm;m- 9PXȜ9si[[[MfD́B&N(VVV?~- E `!>}iyY8fϞmZb`0(11‰P4ay{{Kn[8nХKTSS6F=Z[lQhh I#yxx\-h4Z:@Oܬlٳ3UQQk>(88X0`"""4p@YY%&XN =СC믕mגsIDATLeggEVVV7򒧧,WWW  W^?ٱbS{YJC***JÇWll"""d0,R7#JWޮ}?WZZ߯zy{{+&&FQQQRddBCCegghmm_NǏWFF233GVU\\^(]A۷oWJJnݪ2+..NqqqUXXc^Qkkӵw^iϞ=*//WHH&O)S(..r﫪J1114i&O#FX:5iooѣG-[ԩSpBEEEY:"ЛPiڵ\EFFj={gxfwI_^6lPaabcctR%&&2(]ͫLo?Qף>zlooWjj?i ҥKh"988X:SQO]]VZ+WQ/c=&OOOKGZJ֭^y͝;G n.֭ӲeTWWgyFK.cuϟK/kjȐ!ZzƍgX@O PTTO .߯\秷~[ӄ Oz}\ٳGWcukڶm~zEEE)==ұZկ~ӧkΜ9JOOWllc(WVV4n8}ᇖt{6p=h֬Yڲey-Zґz,???}zꩧ4c jٲet[ikkӜ9scܹSǏtFoŋZ/- (]@k֭ھ};=jooג%K{ґn5]@f_^~бe0:BBBW]]e`0h̘1s}v9NA(屭zw5zhyxxM#Fի^o[x^~e=:xY 8v옖.]^xAs>^ttFi=^xA]suuhԔ)SbŊ.ڵk%IWvvVG$%$$h4h4I퓋/^g}cz!=Ê׉'3f'ԩS5o^xq9sjjj~|'34UW}}dmmm~W7n'+[:s|}}M$ooo=zTO?V\_JOOWLL駟v@ JJJ.I:snVȑ#D;wԁ4jԨ2tQRR=zWzl[LW+)55UY WIՠATPP/_^ WIڱcllloK6lؠk(___*##ô@1$_Әy*--5 +VP||&Lp]`IY*֮]z$-X@#GTddJJJm۶k%%ӶV'Oɓ'e04lذky'ԧOY(]@W[[T͛7ﺍ1oz92z:WWW걾V$SAA kъPii̙u'%%EۯxEI6nܨ{ڴiQjjvi~mIRSS5 o+Izd4%I? zKoJKKUQQw}Wﯧ~{>>pe3fhӦM?^{$j޽k={VFQ8q^|E[E6o|z售WXd6oެSNqn999кu4{lK,/ze˖T󎥣T~h>}+|}}c_VQQvڥ>@lll,6X^uuu5jk.Y[[[:RUVVh~-NX^NNNڴi8KZ:NU__iӦޞ+{`W5k,9::jŊԫ466*11QYYYڽ{\]]- v(]@3m4555ijnn믿RfPUUӧJMMհa, (]@4w\h…:q6n(777KN8544(55U111t[ z3g*--MǏרQw^KG֮]1cSp+FC)<<\&L/~ [:VPPP'֢E{nұnz>>>JIIѦM+,,Lo,[׊+4tPh׮]Zj- (]Mcڴiҽޫ>|n*hhBSS֬Yzgu1M0T5k(33SM4I#Gc^:)%%E[nչsYfi6l# +Ԥ/R7o֖-[t9999iر?~ƏZ:u!ٳG{ÇڪhM4ISLш#deuB pN<4iϞ=:w$԰a`W9ZZZTXXg̙3Vff222T^^.+++EDD(..NǏW\\7+*,,TFFӧ,I׀-yxxKӧ%I...Vss${YFUTT\Pqq *IrrrHEFF*::ZnnnyQPS{{tYٳJrUWWQ /]Y9;;Tv|||(88Xޖ|t3Z(](]l$}hKd"JVIENDB`chibicc-1.0.23.1/chibicc.h000077500000000000000000000663761505335450300151050ustar00rootroot00000000000000#define _POSIX_C_SOURCE 200809L #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SET_CTX(ctx) \ do { \ (ctx)->filename = __FILE__; \ (ctx)->funcname = __func__; \ (ctx)->line_no = __LINE__ + 1; \ } while (0) #define LIBDIR "/usr/local" #define ROUNDUP(X, K) (((X) + (K) - 1) & -(K)) #define ROUNDDOWN(X, K) ((X) & -(K)) #ifndef __has_attribute #define __has_attribute(x) __GCC4_has_attribute_##x #endif #define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #ifndef __GNUC__ #define __attribute__(x) #endif #define PRODUCT "chibicc" #define VERSION "1.0.23.1" #define MAXLEN 501 #define DEFAULT_TARGET_MACHINE "x86_64-linux-gnu" #define MAX_BUILTIN_ARGS 8 #define MAX_WEAK 20 #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) #define HELP PRODUCT " is a C compiler based on " PRODUCT " created by Rui Ueyama.\n \ See original project https://github.com/rui314/chibicc for more information\n \ this " PRODUCT " contains only some differences for now like new parameters\n" #define USAGE PRODUCT " usage :\n \ --help or -h print the help\n \ --version or -v print the version of " PRODUCT "\n \ -cc1 run the cc1 function needs -cc1-input (-cc1-output optional) parameter \n \ -fuse-ld to specify other linker than ld used by default \n \ -x Specify the language of the following input files.\n \ Permissible languages include: c assembler none\n \ 'none' means revert to the default behavior of\n \ guessing the language based on the file's extension.\n \ -S generate assembly file \n \ -o path to output executable if omitted a.out generated\n \ -c path to source to compile \n \ -Xlinker Pass on to the linker.\n \ -Wl, Pass comma-separated on to the linker.\n \ -z Pass on to the linker. \n \ -soname Pass -soname on to the linker. \n \ --version-script Pass --version-script to the linker.\n \ -I Pass path to the include directories \n \ -L Pass path to the lib directories \n \ -D define macro example -DM13 \n \ -U undefine macro example -UM13\n \ -s to strip all symbols during linkage phasis \n \ -M -MD -MP -MMD -MF -MT -MQ compiler write a list of input files to \n \ stdout in a format that \"make\" command can read. This feature is\n \ used to automate file dependency management\n \ -fpic or -fPIC Generate position-independent code (PIC)\n \ -fno-pic disables the generation of position-independent code with relative address references\n \ -pie Create a dynamically linked position independent \n \ -fpie Create a dynamically linked position independent\n \ -fPIE Create a dynamically linked position independent\n \ -fcommon is the default if not specified, it's mainly useful to enable legacy code to link without errors\n \ -fno-common specifies that the compiler places uninitialized global variables in the BSS section of the object file.\n \ -static pass to the linker to link a program statically\n \ -pthread pass to the linker to link with lpthread library \n \ -shared pass to the linker to produce a shared object which can then be linked with other objects to form an executable.\n \ -hashmap-test to test the hashmap function \n \ -idirafter apply to lookup for both the #include \"file\" and #include directives.\n \ -### to dump all commands executed by chibicc \n \ -debug to dump all commands executed by chibicc in a log file in /tmp/chibicc.log\n \ -E Stop after the preprocessing stage; do not run the compiler proper. \n \ The output is in the form of preprocessed source code, which is sent to the standard output.\n \ Input files that don’t require preprocessing are ignored.\n \ -rpath Add a directory to the runtime library search path this parameter is passed to the linker. \n \ This is used when linking an ELF executable with shared objects.\n \ All -rpath arguments are concatenated and passed to the runtime linker,\n \ which uses them to locate shared objects at runtime. \n \ The -rpath option is also used when locating shared objects \n \ which are needed by shared objects explicitly included in the link. \n \ -dumpmachine it's required by some projects returns x86_64-linux-gnu\n \ -dotfile generates a file with .dot extension that can be visualized using graphviz package \n \ -dM Print macro definitions in -E mode instead of normal output\n \ -print print all tokens in a log file in /tmp/chibicc.log \n \ -A print Abstract Syntax Tree in a log file in /tmp/chibicc.log \n \ -msse3 enabling sse3 support \n\ -msse4 enabling sse4 support \n \ -nostdlib Do not use the standard system startup files or libraries when linking \n \ -nostdinc Do not use the standard system header files when compiling \n \ -std=c99 generates an error on implicit function declaration (without -std only a warning is emitted) \n \ -std=c11 generates an error on implicit function declaration (without -std only a warning is emitted) \n \ -mmmx to allow mmx instructions and builtin functions linked to mmx like __builtin_packuswb... \n \ -print-search-dirs prints minimal information on install dir. \n \ chibicc [ -o ] \n" typedef struct Type Type; typedef struct Node Node; typedef struct Member Member; typedef struct Relocation Relocation; typedef struct Hideset Hideset; typedef struct { const char *filename; const char *funcname; int line_no; } Context; typedef Context Context; // // strings.c // typedef struct { char **data; int capacity; int len; } StringArray; void strarray_push(StringArray *arr, char *s); char *format(const char *fmt, ...) __attribute__((format(printf, 1, 2))); // // tokenize.c // // Token typedef enum { TK_IDENT, // Identifiers TK_PUNCT, // Punctuators TK_KEYWORD, // Keywords TK_STR, // String literals TK_NUM, // Numeric literals TK_PP_NUM, // Preprocessing numbers TK_EOF, // End-of-file markers } TokenKind; typedef struct { char *name; unsigned int file_no; char *contents; // For #line directive char *display_name; int line_delta; } File; // Token type typedef struct Token Token; struct Token { TokenKind kind; // Token kind Token *next; // Next token int64_t val; // If kind is TK_NUM, its value long double fval; // If kind is TK_NUM, its value char *loc; // Token location int len; // Token length Type *ty; // Used if TK_NUM or TK_STR char *str; // String literal contents including terminating '\0' File *file; // Source location char *filename; // Filename int line_no; // Line number int line_delta; // Line number bool at_bol; // True if this token is at beginning of line bool has_space; // True if this token follows a space character Hideset *hideset; // For macro expansion Token *origin; // If this is expanded from a macro, the original token }; noreturn void error(char *fmt, ...) __attribute__((format(printf, 1, 2))); noreturn void error_at(char *loc, char *fmt, ...) __attribute__((format(printf, 2, 3))); noreturn void error_tok(Token *tok, char *fmt, ...) __attribute__((format(printf, 2, 3))); void warn_tok(Token *tok, char *fmt, ...) __attribute__((format(printf, 2, 3))); bool equal(Token *tok, const char *op); Token *skip(Token *tok, char *op, Context *ctx); bool consume(Token **rest, Token *tok, char *str); void convert_pp_tokens(Token *tok); File **get_input_files(void); File *new_file(char *name, unsigned int file_no, char *contents); Token *tokenize_string_literal(Token *tok, Type *basety); Token *tokenize(File *file); Token *tokenize_file(char *filename); bool startswith(char *p, char *q); #define unreachable() \ error("internal error at %s:%d", __FILE__, __LINE__) // // preprocess.c // char *search_include_paths(char *filename); void init_macros(void); void define_macro(char *name, char *buf); void undef_macro(char *name); Token *preprocess(Token *tok, bool isReadLine); Token *preprocess3(Token *tok); void define_typedefs(void); void print_all_macros(void); // // parse.c // // This struct represents a variable initializer. Since initializers // can be nested (e.g. `int x[2][2] = {{1, 2}, {3, 4}}`), this struct // is a tree data structure. typedef struct Initializer Initializer; struct Initializer { Initializer *next; Type *ty; Token *tok; bool is_flexible; // If it's not an aggregate type and has an initializer, // `expr` has an initialization expression. Node *expr; // If it's an initializer for an aggregate type (e.g. array or struct), // `children` has initializers for its children. Initializer **children; // Only one member can be initialized for a union. // `mem` is used to clarify which member is initialized. Member *mem; }; // Variable or function typedef struct Obj Obj; struct Obj { Obj *next; char *name; // Variable name char *funcname; // function name char *alias_name; // alias name for function when weak attribute Type *ty; // Type Token *tok; // representative token bool is_local; // local or global/function bool is_compound_lit; //to handle compound literals int align; // alignment // Local variable int offset; int order; int nbparm; // Global variable or function bool is_function; bool is_definition; bool is_static; bool is_extern; // Global variable bool is_tentative; bool is_tls; char *init_data; Relocation *rel; // Function //from COSMOPOLITAN adding is_weak char *section; bool is_weak; bool is_externally_visible; char *visibility; char *asmname; bool is_inline; //from COSMOPOLITAN adding is_aligned, is_noreturn, is_destructor, is_constructor, is_ms_abi, is_no_instrument_function, is_force_align_arg_pointer, is_no_caller_saved_registers bool is_aligned; bool is_noreturn; bool is_constructor; bool is_destructor; int destructor_priority; int constructor_priority; bool is_ms_abi; bool is_no_instrument_function; bool is_force_align_arg_pointer; bool is_no_caller_saved_registers; Obj *params; Node *body; Obj *locals; Obj *va_area; Obj *alloca_bottom; int stack_size; int overflow_arg_area; bool pass_by_stack; // Static inline function bool is_live; bool is_root; StringArray refs; //for dwarf int file_no; // Index or number to identify the source file int line_no; // Line number where the variable or function is defined bool is_prototyped; // Whether the function is prototyped or not Initializer *init; bool is_address_used; }; // Global variable can be initialized either by a constant expression // or a pointer to another global variable. This struct represents the // latter. typedef struct Relocation Relocation; struct Relocation { Relocation *next; int offset; char **label; long addend; }; // AST node typedef enum { ND_NULL_EXPR, // Do nothing ND_ADD, // + ND_SUB, // - ND_MUL, // * ND_DIV, // / ND_NEG, // unary - ND_MOD, // % ND_BITAND, // & ND_BITOR, // | ND_BITXOR, // ^ ND_SHL, // << ND_SHR, // >> ND_EQ, // == ND_NE, // != ND_LT, // < ND_LE, // <= ND_ASSIGN, // = ND_COND, // ?: ND_COMMA, // , ND_MEMBER, // . (struct member access) ND_ADDR, // unary & ND_DEREF, // unary * ND_NOT, // ! ND_BITNOT, // ~ ND_LOGAND, // && ND_LOGOR, // || ND_RETURN, // "return" ND_IF, // "if" ND_FOR, // "for" or "while" ND_DO, // "do" ND_SWITCH, // "switch" ND_CASE, // "case" ND_BLOCK, // { ... } ND_GOTO, // "goto" ND_GOTO_EXPR, // "goto" labels-as-values ND_LABEL, // Labeled statement ND_LABEL_VAL, // [GNU] Labels-as-values ND_FUNCALL, // Function call ND_EXPR_STMT, // Expression statement ND_STMT_EXPR, // Statement expression ND_VAR, // Variable ND_VLA_PTR, // VLA designator ND_NUM, // Integer ND_CAST, // Type cast ND_MEMZERO, // Zero-clear a stack variable ND_ASM, // "asm" ND_CAS, // Atomic compare-and-swap ND_EXCH, // Atomic exchange ND_CAS_N, //atomic compare-and-swap with value ND_EXCH_N, // Atomic exchange with value ND_CMPEXCH, ND_CMPEXCH_N, ND_LOAD, // Atomic load to pointer ND_LOAD_N, // Atomic load to result ND_STORE, // Atomic store to pointer ND_STORE_N, // Atomic store to result ND_TESTANDSET, // Sync lock test and set ND_TESTANDSETA, // Atomic lock test and set ND_CLEAR, // Atomic clear ND_RELEASE, // Atomic lock release ND_FETCHADD, // Atomic fetch and add ND_FETCHSUB, // Atomic fetch and sub ND_FETCHXOR, // Atomic fetch and xor ND_FETCHAND, // Atomic fetch and and ND_FETCHOR, // Atomic fetch and or ND_SUBFETCH, // Atomic sub and fetch ND_SYNC, //atomic synchronize ND_BUILTIN_MEMCPY, //builtin memcpy ND_BUILTIN_MEMSET, //builtin memset ND_BUILTIN_CLZ, //builtin clz ND_BUILTIN_CLZL, //builtin clzl ND_BUILTIN_CLZLL, //builtin clzll ND_BUILTIN_CTZ, //builtin ctz ND_BUILTIN_CTZL, //builtin ctzl ND_BUILTIN_CTZLL, //builtin ctzll ND_POPCOUNT, //builtin popcount ND_EXPECT, //builtin expect ND_ABORT, //builtin abort ND_RETURN_ADDR, //builtin return address ND_BUILTIN_ADD_OVERFLOW, //builtin add overflow ND_BUILTIN_SUB_OVERFLOW, //builtin sub overflow ND_BUILTIN_MUL_OVERFLOW, //builtin mul overflow ND_UNREACHABLE, //builtin unreachable ND_ALLOC, //builtin alloca ND_BUILTIN_INFF, //builtin inff ND_BUILTIN_INF, //builtin inf ND_BUILTIN_NAN, //builtin nan ND_BUILTIN_NANF, //builtin nanf ND_BUILTIN_NANL, //builtin nanl ND_BUILTIN_ISNAN, //builtin isnan ND_BUILTIN_HUGE_VALL, //builtin huge vall ND_BUILTIN_HUGE_VALF, //builtin huge valf ND_BUILTIN_HUGE_VAL, //builtin huge val ND_BUILTIN_BSWAP16, //builtin bswap16 ND_BUILTIN_BSWAP32, //builtin bswap32 ND_BUILTIN_BSWAP64, //builtin bswap64, ND_BUILTIN_FRAME_ADDRESS, // builtin frame address ND_EMMS, ND_SFENCE, ND_LFENCE, ND_MFENCE, ND_PAUSE, ND_STMXCSR, ND_CVTPI2PS, ND_CVTPS2PI, ND_CLFLUSH, ND_VECINITV2SI, ND_VECEXTV2SI, ND_PACKSSWB, ND_PACKSSDW, ND_PACKUSWB, ND_PUNPCKHBW, ND_PUNPCKHWD, ND_PUNPCKHDQ, ND_PUNPCKLBW, ND_PUNPCKLWD, ND_PUNPCKLDQ, ND_PADDB, ND_PADDW, ND_PADDD, ND_PADDQ, ND_PADDSB, ND_PADDSW, ND_PADDUSB, ND_PADDUSW, ND_PSUBB, ND_PSUBW, ND_PSUBD, ND_PSUBQ, ND_PSUBSB, ND_PSUBSW, ND_PSUBUSB, ND_PSUBUSW, ND_PMADDWD, ND_PMULHW, ND_PMULLW, ND_PSLLW, ND_PSLLWI, ND_PSLLD, ND_PSLLDI, ND_PSLLQ, ND_PSLLQI, ND_PSRAW, ND_PSRAWI, ND_PSRAD, ND_PSRADI, ND_PSRLW, ND_PSRLWI, ND_PSRLD, ND_PSRLDI, ND_PSRLQ, ND_PSRLQI, ND_PAND, ND_PANDN, ND_POR, ND_PXOR, ND_PCMPEQB, ND_PCMPGTB, ND_PCMPEQW, ND_PCMPGTW, ND_PCMPEQD, ND_PCMPGTD, ND_VECINITV4HI, ND_VECINITV8QI, ND_ADDSS, ND_SUBSS, ND_MULSS, ND_DIVSS, ND_SQRTSS, ND_RCPSS, ND_RSQRTSS, ND_SQRTPS, ND_MINSS, ND_MAXSS, ND_RCPPS, ND_RSQRTPS, ND_MINPS, ND_MAXPS, ND_ANDPS, ND_ANDNPS, ND_ORPS, ND_XORPS, ND_CMPEQSS, ND_CMPLTSS, ND_CMPLESS, ND_MOVSS, ND_CMPNEQSS, ND_CMPNLTSS, ND_CMPNLESS, ND_CMPORDSS, ND_CMPUNORDSS, ND_CMPEQPS, ND_CMPLTPS, ND_CMPLEPS, ND_CMPGTPS, ND_CMPGEPS, ND_CMPNEQPS, ND_CMPNLTPS, ND_CMPNLEPS, ND_CMPNGTPS, ND_CMPNGEPS, ND_CMPORDPS, ND_CMPUNORDPS, ND_COMIEQ, ND_COMILT, ND_COMILE, ND_COMIGT, ND_COMIGE, ND_COMINEQ, ND_UCOMIEQ, ND_UCOMILT, ND_UCOMILE, ND_UCOMIGT, ND_UCOMIGE, ND_UCOMINEQ, ND_CVTSS2SI, ND_CVTSS2SI64, ND_CVTTSS2SI, ND_CVTTSS2SI64, ND_CVTTPS2PI, ND_CVTSI2SS, ND_CVTSI642SS, ND_MOVLHPS, ND_MOVHLPS, ND_UNPCKHPS, ND_UNPCKLPS, ND_LOADHPS, ND_STOREHPS, ND_LOADLPS, ND_STORELPS, ND_MOVMSKPS, ND_LDMXCSR, ND_SHUFPS, ND_SHUFFLE, ND_PMAXSW, ND_PMAXUB, ND_PMINSW, ND_PMINUB, ND_PMOVMSKB, ND_PMULHUW, ND_MASKMOVQ, ND_PAVGB, ND_PAVGW, ND_PSADBW, ND_MOVNTQ, ND_MOVNTPS, ND_SHUFPD, ND_VECEXTV4SI, ND_ADDSD, ND_SUBSD, ND_MULSD, ND_DIVSD, ND_SQRTPD, ND_MOVSD, ND_SQRTSD, ND_MINPD, ND_MINSD, ND_MAXPD, ND_MAXSD, ND_ANDPD, ND_ANDNPD, ND_ORPD, ND_XORPD, ND_CMPEQPD, ND_CMPLTPD, ND_CMPLEPD, ND_CMPGTPD, ND_CMPGEPD, ND_CMPNEQPD, ND_CMPNLTPD, ND_CMPNLEPD, ND_CMPNGTPD, ND_CMPNGEPD, ND_CMPORDPD, ND_CMPUNORDPD, ND_CMPEQSD, ND_CMPLTSD, ND_CMPLESD, ND_CMPNEQSD, ND_CMPNLTSD, ND_CMPNLESD, ND_CMPORDSD, ND_CMPUNORDSD, ND_COMISDEQ, ND_COMISDLT, ND_COMISDLE, ND_COMISDGT, ND_COMISDGE, ND_COMISDNEQ, ND_UCOMISDEQ, ND_UCOMISDLT, ND_UCOMISDLE, ND_UCOMISDGT, ND_UCOMISDGE, ND_UCOMISDNEQ, ND_MOVQ128, ND_CVTDQ2PD, ND_CVTDQ2PS, ND_CVTPD2DQ, ND_CVTPD2PI, ND_CVTPD2PS, ND_CVTTPD2DQ, ND_CVTTPD2PI, ND_CVTPI2PD, ND_CVTPS2DQ, ND_CVTTPS2DQ, ND_CVTPS2PD, ND_CVTSD2SI, ND_CVTSD2SI64, ND_CVTTSD2SI, ND_CVTTSD2SI64, ND_CVTSD2SS, ND_CVTSI2SD, ND_CVTSI642SD, ND_CVTSS2SD, ND_UNPCKHPD, ND_UNPCKLPD, ND_LOADHPD, ND_LOADLPD, ND_MOVMSKPD, ND_PACKSSWB128, ND_PACKSSDW128, ND_PACKUSWB128, ND_PUNPCKHBW128, ND_PUNPCKHWD128, ND_PUNPCKHDQ128, ND_PUNPCKHQDQ128, ND_PUNPCKLBW128, ND_PUNPCKLWD128, ND_PUNPCKLDQ128, ND_PUNPCKLQDQ128, ND_PADDSB128, ND_PADDSW128, ND_PADDUSB128, ND_PADDUSW128, ND_PSUBSB128, ND_PSUBSW128, ND_PSUBUSB128, ND_PSUBUSW128, ND_PMADDWD128, ND_PMULHW128, ND_PMULUDQ, ND_PMULUDQ128, ND_PSLLWI128, ND_PSLLDI128, ND_PSLLQI128, ND_PSRAWI128, ND_PSRADI128, ND_PSRLWI128, ND_PSRLDI128, ND_PSRLQI128, ND_PSLLW128, ND_PSLLD128, ND_PSLLQ128, ND_PSRAW128, ND_PSRAD128, ND_PSRLW128, ND_PSRLD128, ND_PSRLQ128, ND_PANDN128, ND_PMAXSW128, ND_PMAXUB128, ND_PMINSW128, ND_PMINUB128, ND_PMOVMSKB128, ND_PMULHUW128, ND_MASKMOVDQU, ND_PAVGB128, ND_PAVGW128, ND_PSADBW128, ND_MOVNTI, ND_MOVNTI64, ND_MOVNTDQ, ND_MOVNTPD, ND_POPCOUNTL, ND_POPCOUNTLL, ND_PARITY, ND_PARITYL, ND_PARITYLL, ND_UADD_OVERFLOW, ND_UADDL_OVERFLOW, ND_UADDLL_OVERFLOW, ND_UMUL_OVERFLOW, ND_UMULL_OVERFLOW, ND_UMULLL_OVERFLOW, ND_POS, } NodeKind; // AST node type struct Node { NodeKind kind; // Node kind Node *next; // Next node Type *ty; // Type, e.g. int or pointer to int Token *tok; // Representative token Node *lhs; // Left-hand side Node *rhs; // Right-hand side // "if" or "for" statement Node *cond; Node *then; Node *els; Node *init; Node *inc; // "break" and "continue" labels char *brk_label; char *cont_label; // Block or statement expression Node *body; // Struct member access Member *member; // Function call Type *func_ty; Node *args; bool pass_by_stack; bool realign_stack; Obj *ret_buffer; // Goto or labeled statement, or labels-as-values char *label; char *unique_label; Node *goto_next; // Switch Node *case_next; Node *default_case; // Case long begin; long end; // "asm" string literal char *asm_str; char memorder; // Atomic compare-and-swap Node *cas_addr; Node *cas_old; Node *cas_new; //compare and exchange Node *cas_ptr; Node *cas_expected; Node *cas_desired; Node *cas_weak; Node *cas_success; Node *cas_failure; //for builtin memcpy Node *builtin_dest; Node *builtin_src; Node *builtin_size; Node *builtin_val; Node *builtin_args[MAX_BUILTIN_ARGS]; int builtin_nargs; // Atomic op= operators Obj *atomic_addr; Node *atomic_expr; // Atomic fetch operation bool atomic_fetch; // Variable Obj *var; // Numeric literal int64_t val; long double fval; // for dot diagram int unique_number; bool is_scalar_promoted; }; typedef struct { Obj *var; Type *type_def; Type *enum_ty; int enum_val; } VarScope; Node *new_cast(Node *expr, Type *ty); int64_t const_expr(Token **rest, Token *tok); Obj *parse(Token *tok); VarScope *find_var(Token *tok); Obj *find_func(char *name); //from COSMOPOLITAN adding function ConsumeStringLiteral char *ConsumeStringLiteral(Token **rest, Token *tok) ; int64_t eval(Node *node); extern bool opt_fbuiltin; // // type.c // typedef enum { TY_VOID, TY_BOOL, TY_CHAR, TY_SHORT, TY_INT, TY_LONG, TY_FLOAT, TY_DOUBLE, TY_LDOUBLE, TY_ENUM, TY_PTR, TY_FUNC, TY_ARRAY, TY_VLA, // variable-length array TY_STRUCT, TY_UNION, TY_VECTOR, TY_INT128, TY_LLONG, } TypeKind; struct Type { TypeKind kind; int size; // sizeof() value int align; // alignment bool is_unsigned; // unsigned or signed bool is_atomic; // true if _Atomic //from COSMOPOLITAN adding is_const, is_restrict, is_volatile bool is_const; // const bool is_restrict; // restrict bool is_volatile; // volatile //from COSMOPOLITAN adding is_ms_abi, is_static bool is_ms_abi; // microsoft abi bool is_static; // for array parameter pointer bool is_pointer; // true if it's a pointer Type *pointertype; // store the pointer type int, char... Type *origin; // for type compatibility check Type *decl_next; // forward declarations // Pointer-to or array-of type. We intentionally use the same member // to represent pointer/array duality in C. // // In many contexts in which a pointer is expected, we examine this // member instead of "kind" member to determine whether a type is a // pointer or not. That means in many contexts "array of T" is // naturally handled as if it were "pointer to T", as required by // the C spec. Type *base; // Declaration Token *name; Token *name_pos; // Array int array_len; //from COSMOPOLITAN adding vector_size int vector_size; // Variable-length array Node *vla_len; // # of elements Obj *vla_size; // sizeof() value // Struct Member *members; bool is_flexible; bool is_packed; bool has_vla; //from COSMOPOLITAN adding is_aligned bool is_aligned; bool is_weak; char *visibility; bool is_inline; bool is_compound_lit; // Flag to indicate if this type is a compound literal // Function type Type *return_ty; Type *params; bool is_variadic; Type *next; char *alias_name; // alias name for function when weak attribute char *section; bool is_constructor; bool is_destructor; int destructor_priority; int constructor_priority; bool is_vector; }; // Struct member struct Member { Member *next; Type *ty; Token *tok; // for error message Token *name; int idx; int align; int offset; // Bitfield bool is_bitfield; int bit_offset; int bit_width; }; extern Type *ty_void; extern Type *ty_void_ptr; extern Type *ty_bool; extern Type *ty_char; extern Type *ty_short; extern Type *ty_int; extern Type *ty_long; extern Type *ty_llong; extern Type *ty_uchar; extern Type *ty_ushort; extern Type *ty_uint; extern Type *ty_ulong; extern Type *ty_ullong; extern Type *ty_float; extern Type *ty_double; extern Type *ty_ldouble; extern Type *ty_int128; extern Type *ty_uint128; bool is_integer(Type *ty); bool is_flonum(Type *ty); bool is_numeric(Type *ty); bool is_compatible(Type *t1, Type *t2); Type *copy_type(Type *ty); Type *pointer_to(Type *base); Type *func_type(Type *return_ty); Type *array_of(Type *base, int size); Type *vector_of(Type *base, int size); Type *vla_of(Type *base, Node *expr); Type *enum_type(void); Type *struct_type(void); void add_type(Node *node); bool is_bitfield(Node *node); bool is_array(Type *ty); Type *new_qualified_type(Type *ty); bool is_vector(Type *ty); bool is_int128(Type *ty); char *nodekind2str(NodeKind kind); // // printast.c // void print_ast(FILE *, Obj *); // // debug.c // char *tokenkind2str(TokenKind kind); void print_debug_tokens(char *currentfilename, char *function, Token *tok); // // codegen.c // void codegen(Obj *prog, FILE *out); int align_to(int n, int align); char *reg_ax(int sz); char *reg_bx(int sz); char *reg_cx(int sz); char *reg_dx(int sz); char *reg_di(int sz); char *reg_si(int sz); char *reg_r8w(int sz); char *reg_r9w(int sz); char *reg_r10w(int sz); char *reg_r11w(int sz); void assign_lvar_offsets(Obj *prog); int add_register_used(char *regist); void clear_register_used(); char *register32_to_64(char *regist); char *register16_to_64(char *regist); char *register8_to_64(char *regist); char *register_available(); char *specific_register_available(char *regist); bool check_register_used(char *regist); void check_register_in_template(char *template); void pushreg(const char *arg); // // unicode.c // int encode_utf8(char *buf, uint32_t c); uint32_t decode_utf8(char **new_pos, char *p); bool is_ident1(uint32_t c); bool is_ident2(uint32_t c); bool is_ident3(uint32_t c); // to fix issue #117 int display_width(char *p, int len); // // hashmap.c // typedef struct { char *key; int keylen; void *val; } HashEntry; typedef struct { HashEntry *buckets; int capacity; int used; } HashMap; void *hashmap_get(HashMap *map, char *key); void *hashmap_get2(HashMap *map, char *key, int keylen); void hashmap_put(HashMap *map, char *key, void *val); void hashmap_put2(HashMap *map, char *key, int keylen, void *val); void hashmap_delete(HashMap *map, char *key); void hashmap_delete2(HashMap *map, char *key, int keylen); void hashmap_test(void); // // main.c // bool file_exists(char *path); void dump_machine(void); void dump_version(void); bool startsWith(const char *restrict string, const char *restrict prefix); extern StringArray include_paths; extern bool opt_fpic; extern bool opt_fpie; extern bool opt_shared; extern bool opt_fcommon; extern char *base_file; extern char *dot_file; extern char *opt_o; extern char *replace_extn(char *tmpl, char *extn); extern FILE *dotf; extern FILE *f; extern bool isDotfile; extern bool isDebug; extern bool printTokens; extern bool isPrintMacro; extern char *extract_filename(char *tmpl); extern char *extract_path(char *tmpl); extern bool opt_sse; extern bool opt_sse2; extern bool opt_sse3; extern bool opt_sse4; extern bool opt_mmx; extern bool opt_g; extern FILE *open_file(char *path); extern FILE *ofile; extern bool opt_c99; extern bool opt_c11; extern bool opt_c17; extern char *weak_symbols[MAX_WEAK]; extern int weak_count; extern bool opt_implicit; // // extended_asm.c // char *extended_asm(Node *node, Token **rest, Token *tok, Obj *locals); void output_asm(Node *node, Token **rest, Token *tok, Obj *locals); void input_asm(Node *node, Token **rest, Token *tok, Obj *locals); char *subst_asm(char *template, char *output_str, char *input_str); char *string_replace(char *str, char *oldstr, char *newstr); char *generate_input_asm(char *input_str); bool check_template(char *template); int search_output_index(char c); char *int_to_string(int i); void update_offset(char *funcname, Obj *locals); char *load_variable(int order); char *generate_output_asm(char *output_str); char *opcode(int size); char *update_register_size(char *reg, int size); char *retrieve_output_index_str(char letter); int retrieve_output_index_from_letter(char letter); char *retrieveVariableNumber(int index); char *generate_input_for_output(void); char *generate_return_rax(Token *retval); chibicc-1.0.23.1/codegen.c000077500000000000000000004243301505335450300151040ustar00rootroot00000000000000#include "chibicc.h" #define CODEGEN_C "codegen.c" #define GP_MAX 6 #define FP_MAX 8 static FILE *output_file; static int depth; static char *argreg8[] = {"%dil", "%sil", "%dl", "%cl", "%r8b", "%r9b"}; static char *argreg16[] = {"%di", "%si", "%dx", "%cx", "%r8w", "%r9w"}; static char *argreg32[] = {"%edi", "%esi", "%edx", "%ecx", "%r8d", "%r9d"}; static char *argreg64[] = {"%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9"}; static char *newargreg8[] = {"%cl", "%bl", "%dl", "%al", "%sil", "%dil", "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"}; static char *newargreg16[] = {"%cx", "%bx", "%dx", "%ax", "%si", "%di", "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"}; static char *newargreg32[] = {"%ecx","%ebx","%edx","%eax","%esi","%edi","%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"}; static char *newargreg64[] = {"%rcx","%rbx","%rdx","%rax","%rsi","%rdi","%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"}; static char *registerUsed[] = {"free", "free", "free", "free", "free", "free", "free", "free", "free", "free", "free", "free", "free", "free"}; extern int64_t eval(Node *node); static Obj *current_fn; static void gen_expr(Node *node); static void gen_stmt(Node *node); static void print_offset(Obj *prog); static int cmp_ctor(const void *a, const void *b); static void emit_constructors(void); static void emit_destructors(void); static int last_loc_line = 0; typedef struct CtorFunc { char *name; int priority; } CtorFunc; static CtorFunc *constructors[256]; static int constructor_cnt = 0; static CtorFunc *destructors[256]; static int destructor_cnt = 0; __attribute__((format(printf, 1, 2))) static void println(char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(output_file, fmt, ap); va_end(ap); fprintf(output_file, "\n"); } static int count(void) { static int i = 1; return i++; } static void push(void) { println(" push %%rax"); depth++; } static void pop(char *arg) { println(" pop %s", arg); depth--; } static void pushf(void) { println(" sub $8, %%rsp"); println(" movsd %%xmm0, (%%rsp)"); depth++; } static void popf(int reg) { println(" movsd (%%rsp), %%xmm%d", reg); println(" add $8, %%rsp"); depth--; } static void pushv(void) { println(" sub $16, %%rsp"); println(" movdqu %%xmm0, (%%rsp)"); depth += 1; } static void popv(int reg) { println(" movdqu (%%rsp), %%xmm%d", reg); println(" add $16, %%rsp"); depth -= 1; } void pushx(void) { println(" push %%rdx"); println(" push %%rax"); depth++; depth++; } void popx(char *a, char *b) { println(" pop %s", a); println(" pop %s", b); depth--; depth--; } static void push_xmm(int x) { println(" sub $16, %%rsp"); println(" movdqu %%xmm%d, (%%rsp)", x); } static void pop_xmm(int x) { println(" movdqu (%%rsp), %%xmm%d", x); println(" add $16, %%rsp"); } // Round up `n` to the nearest multiple of `align`. For instance, // align_to(5, 8) returns 8 and align_to(11, 8) returns 16. int align_to(int n, int align) { return ((n + align - 1) / align) * align; } static void print_visibility(Obj *obj) { if (obj->visibility) { if (!strcmp(obj->visibility, "hidden")) { println(" .hidden\t%s", obj->name); } else if (!strcmp(obj->visibility, "protected")) { println(" .protected %s", obj->name); } } if (obj->is_static) { println(" .local\t%s", obj->name); } else { println(" .globl\t%s", obj->name); } if (obj->is_weak) { println(" .weak\t%s", obj->name); } } char *reg_dx(int sz) { switch (sz) { case 1: return "%dl"; case 2: return "%dx"; case 4: return "%edx"; case 8: return "%rdx"; case 16: return "%rdx"; } unreachable(); } char *reg_di(int sz) { switch (sz) { case 1: return "%dil"; case 2: return "%di"; case 4: return "%edi"; case 8: return "%rdi"; case 16: return "%rdi"; } unreachable(); } char *reg_si(int sz) { switch (sz) { case 1: return "%sil"; case 2: return "%si"; case 4: return "%esi"; case 8: return "%rsi"; case 16: return "%rsi"; } unreachable(); } char *reg_r8w(int sz) { switch (sz) { case 1: return "%r8b"; case 2: return "%r8w"; case 4: return "%r8d"; case 8: return "%r8"; case 16: return "%r8"; } unreachable(); } char *reg_r9w(int sz) { switch (sz) { case 1: return "%r9b"; case 2: return "%r9w"; case 4: return "%r9d"; case 8: return "%r9"; case 16: return "%r9"; } unreachable(); } char *reg_r10w(int sz) { switch (sz) { case 1: return "%r10b"; case 2: return "%r10w"; case 4: return "%r10d"; case 8: return "%r10"; case 16: return "%r10"; } unreachable(); } char *reg_r11w(int sz) { switch (sz) { case 1: return "%r11b"; case 2: return "%r11w"; case 4: return "%r11d"; case 8: return "%r11"; case 16: return "%r11"; } unreachable(); } char *reg_bx(int sz) { switch (sz) { case 1: return "%bl"; case 2: return "%bx"; case 4: return "%ebx"; case 8: return "%rbx"; case 16: return "%rbx"; } unreachable(); } char *reg_cx(int sz) { switch (sz) { case 1: return "%cl"; case 2: return "%cx"; case 4: return "%ecx"; case 8: return "%rcx"; case 16: return "%rcx"; } unreachable(); } char *reg_ax(int sz) { switch (sz) { case 1: return "%al"; case 2: return "%ax"; case 4: return "%eax"; case 8: return "%rax"; case 16: return "%rax"; } unreachable(); } // Compute the absolute address of a given node. // It's an error if a given node does not reside in memory. static void gen_addr(Node *node) { switch (node->kind) { case ND_VAR: // Variable-length array, which is always local. if (node->var->ty->kind == TY_VLA) { println(" mov %d(%%rbp), %%rax", node->var->offset); return; } // Local variable if (node->var->is_local) { println(" lea %d(%%rbp), %%rax", node->var->offset); return; } if (opt_fpic) { // Thread-local variable if (node->var->is_tls) { println(" data16 lea \"%s\"@tlsgd(%%rip), %%rdi", node->var->name); println(" .value 0x6666"); println(" rex64"); println(" call __tls_get_addr@PLT"); return; } // Function or global variable println(" mov \"%s\"@GOTPCREL(%%rip), %%rax", node->var->name); return; } // Thread-local variable if (node->var->is_tls) { println(" mov %%fs:0, %%rax"); if (node->var->is_definition) println(" add $\"%s\"@tpoff, %%rax", node->var->name); else println(" add %s@gottpoff(%%rip), %%rax", node->var->name); return; } // Here, we generate an absolute address of a function or a global // variable. Even though they exist at a certain address at runtime, // their addresses are not known at link-time for the following // two reasons. // // - Address randomization: Executables are loaded to memory as a // whole but it is not known what address they are loaded to. // Therefore, at link-time, relative address in the same // exectuable (i.e. the distance between two functions in the // same executable) is known, but the absolute address is not // known. // // - Dynamic linking: Dynamic shared objects (DSOs) or .so files // are loaded to memory alongside an executable at runtime and // linked by the runtime loader in memory. We know nothing // about addresses of global stuff that may be defined by DSOs // until the runtime relocation is complete. // // In order to deal with the former case, we use RIP-relative // addressing, denoted by `(%rip)`. For the latter, we obtain an // address of a stuff that may be in a shared object file from the // Global Offset Table using `@GOTPCREL(%rip)` notation. // Function if (node->ty->kind == TY_FUNC) { if (node->var->is_definition) println(" lea \"%s\"(%%rip), %%rax", node->var->name); else println(" mov \"%s\"@GOTPCREL(%%rip), %%rax", node->var->name); return; } // Global variable println(" lea \"%s\"(%%rip), %%rax", node->var->name); return; case ND_DEREF: gen_expr(node->lhs); return; case ND_COMMA: gen_expr(node->lhs); gen_addr(node->rhs); return; case ND_MEMBER: //fix from @fuhsnn on some issues with members switch(node->lhs->kind) { case ND_FUNCALL: if (!node->lhs->ret_buffer) break; case ND_ASSIGN: case ND_COND: case ND_STMT_EXPR: if (node->lhs->ty->kind != TY_STRUCT && node->lhs->ty->kind != TY_UNION) break; gen_expr(node->lhs); println(" add $%d, %%rax", node->member->offset); return; default: gen_addr(node->lhs); println(" add $%d, %%rax", node->member->offset); return; } case ND_FUNCALL: if (node->ret_buffer) { gen_expr(node); return; } break; case ND_ASSIGN: case ND_COND: if (node->ty->kind == TY_STRUCT || node->ty->kind == TY_UNION ) { gen_expr(node); return; } break; case ND_VLA_PTR: println(" lea %d(%%rbp), %%rax", node->var->offset); return; case ND_ADD: case ND_SUB: case ND_MUL: case ND_DIV: case ND_BITXOR: case ND_BITAND: case ND_BITOR: if (is_vector(node->lhs->ty) || (node->rhs && is_vector(node->rhs->ty))) { gen_expr(node->lhs); gen_expr(node->rhs); return; } return; case ND_CAST: if (is_vector(node->ty)) { gen_expr(node); return; } return; } error_tok(node->tok, "%s:%d not an lvalue %d", CODEGEN_C, __LINE__, node->kind); } // Copy n bytes from the source address in %rax to the destination in dst_reg. static void gen_mem_copy(const char *dst_reg, int n) { int i = 0; while (n >= 8) { println(" movq %d(%%rax), %%r8", i); println(" movq %%r8, %d(%s)", i, dst_reg); n -= 8; i += 8; } while (n >= 4) { println(" movl %d(%%rax), %%r8d", i); println(" movl %%r8d, %d(%s)", i, dst_reg); n -= 4; i += 4; } while (n >= 2) { println(" movw %d(%%rax), %%r8w", i); println(" movw %%r8w, %d(%s)", i, dst_reg); n -= 2; i += 2; } while (n >= 1) { println(" movb %d(%%rax), %%r8b", i); println(" movb %%r8b, %d(%s)", i, dst_reg); --n; ++i; } } // Zero n bytes starting from offset bytes off %rbp. static void gen_mem_zero(int offset, int n) { int i = offset; while (n >= 8) { println(" movq $0, %d(%%rbp)", i); n -= 8; i += 8; } while (n >= 4) { println(" movl $0, %d(%%rbp)", i); n -= 4; i += 4; } while (n >= 2) { println(" movw $0, %d(%%rbp)", i); n -= 2; i += 2; } while (n >= 1) { println(" movb $0, %d(%%rbp)", i); --n; ++i; } } // Load a value from where %rax is pointing to. static void load(Type *ty) { if (!ty) error("%s: %s:%d: error: in load : ty is null!", CODEGEN_C, __FILE__, __LINE__); switch (ty->kind) { case TY_VECTOR: { if (ty->base->kind == TY_FLOAT || ty->base->kind == TY_DOUBLE) { println(" movups (%%rax), %%xmm0"); } else if (is_integer(ty->base)) { println(" movdqu (%%rax), %%xmm0"); } else { error("%s: %s:%d: error: in load : unsupported vector base type %d", CODEGEN_C, __FILE__, __LINE__, ty->base->kind); } return; } case TY_ARRAY: case TY_STRUCT: case TY_UNION: case TY_FUNC: case TY_VLA: // If it is an array, do not attempt to load a value to the // register because in general we can't load an entire array to a // register. As a result, the result of an evaluation of an array // becomes not the array itself but the address of the array. // This is where "array is automatically converted to a pointer to // the first element of the array in C" occurs. return; case TY_FLOAT: println(" movss (%%rax), %%xmm0"); return; case TY_DOUBLE: println(" movsd (%%rax), %%xmm0"); return; case TY_LDOUBLE: println(" fldt (%%rax)"); return; case TY_INT128: println(" mov 8(%%rax), %%rdx"); // Load upper 64 bits into RDX println(" mov (%%rax), %%rax"); // Load lower 64 bits into RAX return; } char *insn = ty->is_unsigned ? "movz" : "movs"; // When we load a char or a short value to a register, we always // extend them to the size of int, so we can assume the lower half of // a register always contains a valid value. The upper half of a // register for char, short and int may contain garbage. When we load // a long value to a register, it simply occupies the entire register. if (ty->size == 1) println(" %sbl (%%rax), %%eax", insn); else if (ty->size == 2) println(" %swl (%%rax), %%eax", insn); else if (ty->size == 4) println(" movsxd (%%rax), %%rax"); else println(" mov (%%rax), %%rax"); } // Store %rax to an address that the stack top is pointing to. static void store(Type *ty) { if (!ty) error("%s %d: in store : ty is null!", CODEGEN_C, __LINE__); pop("%rdi"); switch (ty->kind) { case TY_VECTOR: if (ty->base->kind == TY_FLOAT || ty->base->kind == TY_DOUBLE) { println(" movups %%xmm0, (%%rdi)"); // store into rdi, not rax } else if (is_integer(ty->base)) { println(" movdqu %%xmm0, (%%rdi)"); } else { error("%s %d: in store : unsupported vector base type %d", CODEGEN_C, __LINE__, ty->base->kind); } return; case TY_STRUCT: case TY_UNION: gen_mem_copy("%rdi", ty->size); return; case TY_FLOAT: println(" movss %%xmm0, (%%rdi)"); return; case TY_DOUBLE: println(" movsd %%xmm0, (%%rdi)"); return; case TY_LDOUBLE: println(" fstpt (%%rdi)"); return; case TY_INT128: println(" mov %%rax, (%%rdi)"); println(" mov %%rdx, 8(%%rdi)"); return; } if (ty->size == 1) println(" mov %%al, (%%rdi)"); else if (ty->size == 2) println(" mov %%ax, (%%rdi)"); else if (ty->size == 4) println(" mov %%eax, (%%rdi)"); else println(" mov %%rax, (%%rdi)"); } static void cmp_zero(Type *ty) { if (!ty) error("%s %d: in cmp_zero : ty is null!", CODEGEN_C, __LINE__); switch (ty->kind) { case TY_FLOAT: println(" xorps %%xmm1, %%xmm1"); println(" ucomiss %%xmm1, %%xmm0"); return; case TY_DOUBLE: println(" xorpd %%xmm1, %%xmm1"); println(" ucomisd %%xmm1, %%xmm0"); return; case TY_LDOUBLE: println(" fldz"); println(" fucomip"); println(" fstp %%st(0)"); return; case TY_INT128: println(" mov %%rax, %%r11"); println(" or %%rdx, %%r11"); return; } if (is_integer(ty) && ty->size <= 4) println(" cmp $0, %%eax"); else println(" cmp $0, %%rax"); } #define REDZONE(X) \ "sub\t$16,%rsp\n" \ "\t" X "\n" \ "\tadd\t$16,%rsp" #define i8i128 "movsbq\t%al,%rax\n\tcqto" #define i16i128 "movswq\t%ax,%rax\n\tcqto" #define i32i128 "cltq\n\tcqto" #define i64i128 "cqto" #define u8i128 "movzbq\t%al,%rax\n\txor\t%edx,%edx" #define u16i128 "movzwq\t%ax,%rax\n\txor\t%edx,%edx" #define u32i128 "cltq\n\txor\t%edx,%edx" #define u64i128 "xor\t%edx,%edx" #define i128f32 "mov\t%rax,%rdi\n\tmov\t%rdx,%rsi\n\tcall\t__floattisf" #define i128f64 "mov\t%rax,%rdi\n\tmov\t%rdx,%rsi\n\tcall\t__floattidf" #define i128f80 "mov\t%rax,%rdi\n\tmov\t%rdx,%rsi\n\tcall\t__floattixf" #define u128f32 "mov\t%rax,%rdi\n\tmov\t%rdx,%rsi\n\tcall\t__floatuntisf" #define u128f64 "mov\t%rax,%rdi\n\tmov\t%rdx,%rsi\n\tcall\t__floatuntidf" #define u128f80 "mov\t%rax,%rdi\n\tmov\t%rdx,%rsi\n\tcall\t__floatuntixf" #define f32i128 "call\t__fixsfti" #define f64i128 "call\t__fixdfti" #define f80i128 REDZONE("fstpt\t(%rsp)\n\tcall\t__fixxfti") #define f32u128 "call\t__fixunssfti" #define f64u128 "call\t__fixunsdfti" #define f80u128 REDZONE("fstpt\t(%rsp)\n\tcall\t__fixunsxfti") enum { I8, I16, I32, I64, U8, U16, U32, U64, F32, F64, F80, I128, U128, }; static int getTypeId(Type *ty) { if (!ty) return I32; switch (ty->kind) { case TY_CHAR: return ty->is_unsigned ? U8 : I8; case TY_SHORT: return ty->is_unsigned ? U16 : I16; case TY_INT: return ty->is_unsigned ? U32 : I32; case TY_LONG: case TY_LLONG: return ty->is_unsigned ? U64 : I64; case TY_INT128: return ty->is_unsigned ? U128 : I128; case TY_FLOAT: return F32; case TY_DOUBLE: return F64; case TY_LDOUBLE: return F80; } return U64; } // The table for type casts static char i32i8[] = "movsbl %al, %eax"; static char i32u8[] = "movzbl %al, %eax"; static char i32i16[] = "movswl %ax, %eax"; static char i32u16[] = "movzwl %ax, %eax"; static char i32f32[] = "cvtsi2ssl %eax, %xmm0"; static char i32i64[] = "movslq %eax, %rax"; static char i32f64[] = "cvtsi2sdl %eax, %xmm0"; static char i32f80[] = "mov %eax, -4(%rsp); fildl -4(%rsp)"; static char u32f32[] = "mov %eax, %eax; cvtsi2ssq %rax, %xmm0"; static char u32i64[] = "mov %eax, %eax"; static char u32f64[] = "mov %eax, %eax; cvtsi2sdq %rax, %xmm0"; static char u32f80[] = "mov %eax, %eax; mov %rax, -8(%rsp); fildll -8(%rsp)"; static char i64f32[] = "cvtsi2ssq %rax, %xmm0"; static char i64f64[] = "cvtsi2sdq %rax, %xmm0"; static char i64f80[] = "movq %rax, -8(%rsp); fildll -8(%rsp)"; static char u64f32[] = "test %rax,%rax; js 1f; pxor %xmm0,%xmm0; cvtsi2ss %rax,%xmm0; jmp 2f; " "1: mov %rax,%rdi; and $1,%eax; pxor %xmm0,%xmm0; shr %rdi; " "or %rax,%rdi; cvtsi2ss %rdi,%xmm0; addss %xmm0,%xmm0; 2:"; static char u64f64[] = "test %rax,%rax; js 1f; pxor %xmm0,%xmm0; cvtsi2sd %rax,%xmm0; jmp 2f; " "1: mov %rax,%rdi; and $1,%eax; pxor %xmm0,%xmm0; shr %rdi; " "or %rax,%rdi; cvtsi2sd %rdi,%xmm0; addsd %xmm0,%xmm0; 2:"; static char u64f80[] = "mov %rax, -8(%rsp); fildq -8(%rsp); test %rax, %rax; jns 1f;" "mov $1602224128, %eax; mov %eax, -4(%rsp); fadds -4(%rsp); 1:"; static char f32i8[] = "cvttss2sil %xmm0, %eax; movsbl %al, %eax"; static char f32u8[] = "cvttss2sil %xmm0, %eax; movzbl %al, %eax"; static char f32i16[] = "cvttss2sil %xmm0, %eax; movswl %ax, %eax"; static char f32u16[] = "cvttss2sil %xmm0, %eax; movzwl %ax, %eax"; static char f32i32[] = "cvttss2sil %xmm0, %eax"; static char f32u32[] = "cvttss2siq %xmm0, %rax"; static char f32i64[] = "cvttss2siq %xmm0, %rax"; static char f32u64[] = "cvttss2siq %xmm0, %rcx; movq %rcx, %rdx; movl $0x5F000000, %eax; " "movd %eax, %xmm1; subss %xmm1, %xmm0; cvttss2siq %xmm0, %rax; " "sarq $63, %rdx; andq %rdx, %rax; orq %rcx, %rax;"; static char f32f64[] = "cvtss2sd %xmm0, %xmm0"; static char f32f80[] = "movss %xmm0, -4(%rsp); flds -4(%rsp)"; static char f64i8[] = "cvttsd2sil %xmm0, %eax; movsbl %al, %eax"; static char f64u8[] = "cvttsd2sil %xmm0, %eax; movzbl %al, %eax"; static char f64i16[] = "cvttsd2sil %xmm0, %eax; movswl %ax, %eax"; static char f64u16[] = "cvttsd2sil %xmm0, %eax; movzwl %ax, %eax"; static char f64i32[] = "cvttsd2sil %xmm0, %eax"; static char f64u32[] = "cvttsd2siq %xmm0, %rax"; static char f64i64[] = "cvttsd2siq %xmm0, %rax"; static char f64u64[] = "cvttsd2siq %xmm0, %rcx; movq %rcx, %rdx; mov $0x43e0000000000000, %rax; " "movq %rax, %xmm1; subsd %xmm1, %xmm0; cvttsd2siq %xmm0, %rax; " "sarq $63, %rdx; andq %rdx, %rax; orq %rcx, %rax"; static char f64f32[] = "cvtsd2ss %xmm0, %xmm0"; static char f64f80[] = "movsd %xmm0, -8(%rsp); fldl -8(%rsp)"; #define FROM_F80_1 \ "fnstcw -10(%rsp); movzwl -10(%rsp), %eax; or $12, %ah; " \ "mov %ax, -12(%rsp); fldcw -12(%rsp); " #define FROM_F80_2 " -24(%rsp); fldcw -10(%rsp); " static char f80i8[] = FROM_F80_1 "fistps" FROM_F80_2 "movsbl -24(%rsp), %eax"; static char f80u8[] = FROM_F80_1 "fistps" FROM_F80_2 "movzbl -24(%rsp), %eax"; static char f80i16[] = FROM_F80_1 "fistps" FROM_F80_2 "movzbl -24(%rsp), %eax"; static char f80u16[] = FROM_F80_1 "fistpl" FROM_F80_2 "movswl -24(%rsp), %eax"; static char f80i32[] = FROM_F80_1 "fistpl" FROM_F80_2 "mov -24(%rsp), %eax"; static char f80u32[] = FROM_F80_1 "fistpl" FROM_F80_2 "mov -24(%rsp), %eax"; static char f80i64[] = FROM_F80_1 "fistpq" FROM_F80_2 "mov -24(%rsp), %rax"; static char f80u64[] = "movl $0x5f000000, -4(%rsp); flds -4(%rsp); fucomi %st(1), %st; setbe %al;" "fldz; fcmovbe %st(1), %st; fstp %st(1); fsubrp %st, %st(1); fnstcw -12(%rsp);" "movzwl -12(%rsp), %ecx; orl $3072, %ecx; movw %cx, -10(%rsp); fldcw -10(%rsp);" "fistpll -8(%rsp); fldcw -12(%rsp); shlq $63, %rax; xorq -8(%rsp), %rax;"; static char f80f32[] = "fstps -8(%rsp); movss -8(%rsp), %xmm0"; static char f80f64[] = "fstpl -8(%rsp); movsd -8(%rsp), %xmm0"; static const char *const cast_table[13][13] = /* clang-format off */ { // i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 f80 i128 u128 {NULL, NULL, NULL, i32i64, i32u8, i32u16, NULL, i32i64, i32f32, i32f64, i32f80, i32i128, i32i128}, // i8 {i32i8, NULL, NULL, i32i64, i32u8, i32u16, NULL, i32i64, i32f32, i32f64, i32f80, i32i128, i32i128}, // i16 {i32i8, i32i16, NULL, i32i64, i32u8, i32u16, NULL, i32i64, i32f32, i32f64, i32f80, i32i128, i32i128}, // i32 {i32i8, i32i16, NULL, NULL, i32u8, i32u16, NULL, NULL, i64f32, i64f64, i64f80, i64i128, i64i128}, // i64 {i32i8, NULL, NULL, i32i64, NULL, NULL, NULL, i32i64, i32f32, i32f64, i32f80, i32i128, i32i128}, // u8 {i32i8, i32i16, NULL, i32i64, i32u8, NULL, NULL, i32i64, i32f32, i32f64, i32f80, i32i128, i32i128}, // u16 {i32i8, i32i16, NULL, u32i64, i32u8, i32u16, NULL, u32i64, u32f32, u32f64, u32f80, u32i128, i32i128}, // u32 {i32i8, i32i16, NULL, NULL, i32u8, i32u16, NULL, NULL, u64f32, u64f64, u64f80, u64i128, u64i128}, // u64 {f32i8, f32i16, f32i32, f32i64, f32u8, f32u16, f32u32, f32u64, NULL, f32f64, f32f80, f32i128, f32u128}, // f32 {f64i8, f64i16, f64i32, f64i64, f64u8, f64u16, f64u32, f64u64, f64f32, NULL, f64f80, f64i128, f64u128}, // f64 {f80i8, f80i16, f80i32, f80i64, f80u8, f80u16, f80u32, f80u64, f80f32, f80f64, NULL, f80i128, f80u128}, // f80 {i32i8, i32i16, NULL, NULL, i32u8, i32u16, NULL, NULL, i128f32, i128f64, i128f80, NULL, NULL }, // i128 {i32i8, i32i16, NULL, NULL, i32u8, i32u16, NULL, NULL, u128f32, u128f64, u128f80, NULL, NULL }, // u128 } /* clang-format on */; static void cast(Type *from, Type *to) { if (!to) error("%s %d: in cast : to type is null!", CODEGEN_C, __LINE__); if (!from) from = copy_type(to); if (to->kind == TY_VOID) return; if (to->kind == TY_BOOL) { cmp_zero(from); println(" setne %%al"); println(" movzx %%al, %%eax"); return; } if (is_vector(from) ||is_vector(to)) return; int t1 = getTypeId(from); int t2 = getTypeId(to); if (cast_table[t1][t2]) println(" %s", cast_table[t1][t2]); } // Returns true if 'ty' is or contains a pointer (recursively) static bool has_pointer(Type *ty) { if (!ty) return false; switch (ty->kind) { case TY_PTR: return true; case TY_VECTOR: case TY_ARRAY: return has_pointer(ty->base); case TY_STRUCT: case TY_UNION: { for (Member *mem = ty->members; mem; mem = mem->next) { if (has_pointer(mem->ty)) return true; } return false; } default: return false; } } // Structs or unions equal or smaller than 16 bytes are passed // using up to two registers. // // If the first 8 bytes contains only floating-point type members, // they are passed in an XMM register. Otherwise, they are passed // in a general-purpose register. // // If a struct/union is larger than 8 bytes, the same rule is // applied to the the next 8 byte chunk. // // This function returns true if `ty` has only floating-point // members in its byte range [lo, hi). static bool has_flonum(Type *ty, int lo, int hi, int offset) { if (ty->kind == TY_STRUCT || ty->kind == TY_UNION) { for (Member *mem = ty->members; mem; mem = mem->next) if (!has_flonum(mem->ty, lo, hi, offset + mem->offset)) return false; return true; } if (ty->kind == TY_ARRAY || ty->kind == TY_VECTOR) { for (int i = 0; i < ty->array_len; i++) if (!has_flonum(ty->base, lo, hi, offset + ty->base->size * i)) return false; return true; } return offset < lo || hi <= offset || ty->kind == TY_FLOAT || ty->kind == TY_DOUBLE ; } static bool has_flonum1(Type *ty) { return has_flonum(ty, 0, 8, 0); } static bool has_flonum2(Type *ty) { return has_flonum(ty, 8, 16, 0); } static bool has_longdouble(Type *ty) { if (!ty) return false; if (ty->kind == TY_LDOUBLE) return true; if (ty->kind != TY_STRUCT && ty->kind != TY_UNION) return false; for (Member *mem = ty->members; mem; mem = mem->next) { if (has_longdouble(mem->ty)) return true; } return false; } static bool pass_by_reg(Type *ty, int gp, int fp) { if (ty->size > 16) return false; if (has_longdouble(ty)) return false; int fp_inc = has_flonum1(ty) + (ty->size > 8 && has_flonum2(ty)); int gp_inc = !has_flonum1(ty) + (ty->size > 8 && !has_flonum2(ty)); if (fp_inc && (fp + fp_inc > FP_MAX)) return false; if (gp_inc && (gp + gp_inc > GP_MAX)) return false; if (ty->is_variadic && !has_flonum1(ty) && !has_pointer(ty)) return false; return true; } static void push_struct(Type *ty) { int sz = 0; if (has_longdouble(ty)) sz = align_to(ty->size, 16); else sz = align_to(ty->size, 8); println(" sub $%d, %%rsp", sz); depth += sz / 8; gen_mem_copy("%rsp", ty->size); } static void push_args2(Node *args, bool first_pass) { if (!args) return; push_args2(args->next, first_pass); // if ((first_pass && !args->pass_by_stack) || (!first_pass && args->pass_by_stack)) if (first_pass != args->pass_by_stack) return; gen_expr(args); switch (args->ty->kind) { case TY_STRUCT: case TY_UNION: if (args->ty->size == 0) return; push_struct(args->ty); break; case TY_VECTOR: pushv(); break; case TY_FLOAT: case TY_DOUBLE: pushf(); break; case TY_LDOUBLE: println(" sub $16, %%rsp"); println(" fstpt (%%rsp)"); depth += 2; break; case TY_INT128: pushx(); break; default: push(); } } // Load function call arguments. Arguments are already evaluated and // stored to the stack as local variables. What we need to do in this // function is to load them to registers or push them to the stack as // specified by the x86-64 psABI. Here is what the spec says: // // - Up to 6 arguments of integral type are passed using RDI, RSI, // RDX, RCX, R8 and R9. // // - Up to 8 arguments of floating-point type are passed using XMM0 to // XMM7. // // - If all registers of an appropriate type are already used, push an // argument to the stack in the right-to-left order. // // - Each argument passed on the stack takes 8 bytes, and the end of // the argument area must be aligned to a 16 byte boundary. // // - If a function is variadic, set the number of floating-point type // arguments to RAX. static int push_args(Node *node) { int stack = 0, gp = 0, fp = 0; // If the return type is a large struct/union, the caller passes // a pointer to a buffer as if it were the first argument. if (node->ret_buffer && node->ty->size > 16) gp++; // Load as many arguments to the registers as possible. for (Node *arg = node->args; arg; arg = arg->next) { Type *ty = arg->ty; if (!ty) error("%s %d: in push_args : type is null!", CODEGEN_C, __LINE__); switch (ty->kind) { case TY_STRUCT: case TY_UNION: if (ty->size == 0) continue; if (pass_by_reg(ty, gp, fp) ) { fp += has_flonum1(ty) + (ty->size > 8 && has_flonum2(ty)); gp += !has_flonum1(ty) + (ty->size > 8 && !has_flonum2(ty)); } else { arg->pass_by_stack = true; if (has_longdouble(ty)) stack += align_to(ty->size, 16) / 8; else stack += align_to(ty->size, 8) / 8; } break; case TY_VECTOR: case TY_FLOAT: case TY_DOUBLE: if (fp++ >= FP_MAX) { arg->pass_by_stack = true; stack++; } break; case TY_LDOUBLE: arg->pass_by_stack = true; stack += 2; break; case TY_INT128: if (gp + 1 >= GP_MAX) { arg->pass_by_stack = true; stack += 2; } else { gp += 2; } break; default: if (gp++ >= GP_MAX) { arg->pass_by_stack = true; stack++; } } } if ((depth + stack) % 2 == 1) { println(" sub $8, %%rsp"); depth++; stack++; } push_args2(node->args, true); push_args2(node->args, false); // If the return type is a large struct/union, the caller passes // a pointer to a buffer as if it were the first argument. if (node->ret_buffer && node->ty->size > 16) { println(" lea %d(%%rbp), %%rax", node->ret_buffer->offset); push(); } return stack; } static void copy_ret_buffer(Obj *var) { Type *ty = var->ty; if (!ty) error("%s %d: in copy_ret_buffer : type is null!", CODEGEN_C, __LINE__); int gp = 0, fp = 0; if (has_flonum1(ty)) { // Allow sizes 4, 8, 12, and 16 for floating-point types assert(ty->size == 4 || ty->size == 8 || ty->size == 12 || ty->size == 16); if (ty->size == 4) { println(" movss %%xmm0, %d(%%rbp)", var->offset); // Handle float (4 bytes) } else if (ty->size == 8) { println(" movsd %%xmm0, %d(%%rbp)", var->offset); // Handle double (8 bytes) } else if (ty->size == 12 || ty->size == 16) { // Split the 12 or 16 bytes into two parts, handle the first 8 bytes println(" movsd %%xmm0, %d(%%rbp)", var->offset); // Handle first 8 bytes // Handle the remaining bytes (4 or 8 bytes) if (ty->size == 12) { println(" movss %%xmm1, %d(%%rbp)", var->offset + 8); // Handle the remaining 4 bytes } else if (ty->size == 16) { println(" movsd %%xmm1, %d(%%rbp)", var->offset + 8); // Handle the remaining 8 bytes } } fp++; } else { // **Change 1: Handle the first 8 bytes for integer types (up to 64 bits)** for (int i = 0; i < MIN(8, ty->size); i++) { println(" mov %%al, %d(%%rbp)", var->offset + i); println(" shr $8, %%rax"); } gp++; } if (ty->size > 8) { if (has_flonum2(ty)) { assert(ty->size == 12 || ty->size == 16); if (ty->size == 12) println(" movss %%xmm%d, %d(%%rbp)", fp, var->offset + 8); else println(" movsd %%xmm%d, %d(%%rbp)", fp, var->offset + 8); } else { char *reg1 = (gp == 0) ? "%al" : "%dl"; char *reg2 = (gp == 0) ? "%rax" : "%rdx"; for (int i = 8; i < MIN(16, ty->size); i++) { println(" mov %s, %d(%%rbp)", reg1, var->offset + i); println(" shr $8, %s", reg2); } } } } static void copy_struct_reg(void) { Type *ty = current_fn->ty->return_ty; if (!ty) error("%s %d: in copy_struct_reg : type is null!", CODEGEN_C, __LINE__); int gp = 0, fp = 0; println(" mov %%rax, %%rdi"); if (has_flonum(ty, 0, 8, 0)) { assert(ty->size == 4 || 8 <= ty->size); if (ty->size == 4) println(" movss (%%rdi), %%xmm0"); else println(" movsd (%%rdi), %%xmm0"); fp++; } else { println(" mov $0, %%rax"); for (int i = MIN(8, ty->size) - 1; i >= 0; i--) { println(" shl $8, %%rax"); println(" mov %d(%%rdi), %%al", i); } gp++; } if (ty->size > 8) { if (has_flonum(ty, 8, 16, 0)) { assert(ty->size == 12 || ty->size == 16); if (ty->size == 12) println(" movss 8(%%rdi), %%xmm%d", fp); else println(" movsd 8(%%rdi), %%xmm%d", fp); } else { char *reg1 = (gp == 0) ? "%al" : "%dl"; char *reg2 = (gp == 0) ? "%rax" : "%rdx"; println(" mov $0, %s", reg2); for (int i = MIN(16, ty->size) - 1; i >= 8; i--) { println(" shl $8, %s", reg2); println(" mov %d(%%rdi), %s", i, reg1); } } } } static void copy_struct_mem(void) { Type *ty = current_fn->ty->return_ty; if (!ty) error("%s %d: in copy_struct_mem : type is null!", CODEGEN_C, __LINE__); Obj *var = current_fn->params; println(" mov %d(%%rbp), %%rdi", var->offset); gen_mem_copy("%rdi", ty->size); //from @fuhsnn Copy returned-by-stack aggregate's pointer to rax println(" mov %%rdi, %%rax"); } static void builtin_alloca(Node *node) { // Align size to 16 bytes. // println(" add $15, %%rdi"); // println(" and $0xfffffff0, %%edi"); int align = node->val > 16 ? node->val : 16; println(" add $%d, %%rdi", align - 1); println(" and $-%d, %%rdi", align); // Shift the temporary area by %rdi. println(" mov %d(%%rbp), %%rcx", current_fn->alloca_bottom->offset); println(" sub %%rsp, %%rcx"); println(" mov %%rsp, %%rax"); println(" sub %%rdi, %%rsp"); println(" mov %%rsp, %%rdx"); println("1:"); println(" cmp $0, %%rcx"); println(" je 2f"); println(" mov (%%rax), %%r8b"); println(" mov %%r8b, (%%rdx)"); println(" inc %%rdx"); println(" inc %%rax"); println(" dec %%rcx"); println(" jmp 1b"); println("2:"); // Move alloca_bottom pointer. println(" mov %d(%%rbp), %%rax", current_fn->alloca_bottom->offset); println(" sub %%rdi, %%rax"); println(" mov %%rax, %d(%%rbp)", current_fn->alloca_bottom->offset); } //from cosmopolitan static void HandleAtomicArithmetic(Node *node, const char *op) { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%r9"); println("\tmov\t%s,%s", reg_ax(node->ty->size), reg_si(node->ty->size)); println("\tmov\t(%%r9),%s", reg_ax(node->ty->size)); println("1:\tmov\t%s,%s", reg_ax(node->ty->size), reg_dx(node->ty->size)); println("\tmov\t%s,%s", reg_ax(node->ty->size), reg_di(node->ty->size)); println("\t%s\t%s,%s", op, reg_si(node->ty->size), reg_dx(node->ty->size)); println("\tlock cmpxchg\t%s,(%%r9)", reg_dx(node->ty->size)); println("\tjnz\t1b"); println("\tmov\t%s,%s", reg_di(node->ty->size), reg_ax(node->ty->size)); } static void gen_int128_op(Node *node) { if (node->rhs) { gen_expr(node->rhs); pushx(); } gen_expr(node->lhs); if (node->rhs) popx("%rdi", "%rsi"); switch (node->kind) { case ND_ADD: println(" add %%rdi, %%rax"); println(" adc %%rsi, %%rdx"); break; case ND_SUB: println(" sub %%rdi, %%rax"); println(" sbb %%rsi, %%rdx"); break; case ND_MUL: println(" imul %%rdi, %%rdx"); println(" imul %%rax, %%rsi"); println(" add %%rdx, %%rsi"); println(" mul %%rdi"); println(" add %%rsi, %%rdx"); break; case ND_DIV: case ND_MOD: println(" mov %%rsi, %%rcx"); println(" mov %%rdx, %%rsi"); println(" mov %%rdi, %%rdx"); println(" mov %%rax, %%rdi"); if (node->kind == ND_DIV) { if (node->ty->is_unsigned) { println(" call __udivti3"); } else { println(" call __divti3"); } } else { if (node->ty->is_unsigned) { println(" call __umodti3"); } else { println(" call __modti3"); } } break; case ND_NEG: println(" neg %%rax"); println(" adc $0, %%rdx"); println(" neg %%rdx"); break; case ND_BITNOT: println(" not %%rax"); println(" not %%rdx"); break; case ND_BITAND: println(" and %%rdi, %%rax"); println(" and %%rsi, %%rdx"); break; case ND_BITOR: println(" or %%rdi, %%rax"); println(" or %%rsi, %%rdx"); break; case ND_BITXOR: println(" xor %%rdi, %%rax"); println(" xor %%rsi, %%rdx"); break; case ND_EQ: println(" mov %%rax, %%r8"); // Move lower 64 bits of lhs to r8 println(" mov %%rdx, %%r9"); // Move upper 64 bits of lhs to r9 println(" xor %%r8, %%rdi"); // Compare lower 64 bits of lhs and rhs println(" xor %%r9, %%rsi"); // Compare upper 64 bits of lhs and rhs println(" or %%rsi, %%rdi"); // Combine the results println(" sete %%al"); // Set AL if the result is zero (equal) println(" movzx %%al, %%eax"); // Zero extend AL to EAX break; case ND_NE: println(" xor %%rax, %%rdi"); println(" xor %%rdx, %%rsi"); println(" or %%rsi, %%rdi"); println(" setne %%al"); println(" movzb %%al, %%rax"); // Zero-extend al to rax to ensure the whole rax is correctly set break; case ND_LT: if (node->lhs->ty->is_unsigned) { println(" cmp %%rdi, %%rax"); println(" mov %%rdx, %%rax"); println(" sbb %%rsi, %%rax"); println(" setc %%al"); println(" movzb %%al, %%rax"); // Zero-extend al to rax to ensure the whole rax is correctly set } else { println(" cmp %%rdi, %%rax"); println(" mov %%rdx, %%rax"); println(" sbb %%rsi, %%rax"); println(" setl %%al"); println(" movzb %%al, %%rax"); // Zero-extend al to rax to ensure the whole rax is correctly set } break; case ND_LE: if (node->lhs->ty->is_unsigned) { println(" cmp %%rax, %%rdi"); println(" sbb %%rdx, %%rsi"); println(" setnc %%al"); println(" movzb %%al, %%rax"); // Zero-extend al to rax to ensure the whole rax is correctly set } else { println(" cmp %%rax, %%rdi"); println(" sbb %%rdx, %%rsi"); println(" setge %%al"); println(" movzb %%al, %%rax"); // Zero-extend al to rax to ensure the whole rax is correctly set } break; case ND_SHL: println(" mov %%rdi, %%rcx"); println(" shld %%cl, %%rax, %%rdx"); println(" shl %%cl, %%rax"); println(" xor %%edi, %%edi"); println(" and $64, %%cl"); println(" cmovne %%rax, %%rdx"); println(" cmovne %%rdi, %%rax"); break; case ND_SHR: int c = count(); // Move shift amount to CL register println(" mov %%rdi, %%rcx"); if (node->lhs->ty->is_unsigned) { // Handle unsigned 128-bit shift right println(" cmp $64, %%rcx"); println(" ja .Lshift_gt64_unsigned_%d", c); // Common shift logic for shifts within 64 bits println(" shrd %%cl, %%rdx, %%rax"); // Shift right double println(" shr %%cl, %%rdx"); // Logical shift of upper 64 bits println(" jmp .Lshift_done_%d", c); // Handle shifts greater than 63 bits println(".Lshift_gt64_unsigned_%d:", c); println(" sub $64, %%rcx"); // Adjust shift amount println(" mov %%rdx, %%rax"); // Move high bits to low println(" shr %%cl, %%rax"); // Logical shift remaining bits in %%rax println(" xor %%rdx, %%rdx"); // Clear %%rdx (upper 64 bits) } else { // Handle signed 128-bit shift right (arithmetic) println(" cmp $64, %%rcx"); println(" ja .Lshift_gt64_signed_%d", c); // Common shift logic for shifts within 64 bits println(" shrd %%cl, %%rdx, %%rax"); // Shift right double println(" sar %%cl, %%rdx"); // Arithmetic shift of upper 64 bits println(" jmp .Lshift_done_%d", c); // Handle shifts greater than 63 bits println(".Lshift_gt64_signed_%d:", c); println(" sub $64, %%rcx"); // Adjust shift amount println(" mov %%rdx, %%rax"); // Move high bits to low println(" sar %%cl, %%rax"); // Arithmetic shift remaining bits in %%rax println(" sar $63, %%rdx"); // Sign extend %%rdx to fill with sign bit } println(".Lshift_done_%d:", c); break; default: error_tok(node->tok,"%s: %s:%d: error: in gen_int128_op : unsupported int128 operation %d", CODEGEN_C, __FILE__, __LINE__, node->kind); } } static void scalar_to_xmm(Type *vec_ty, const char *xmm_reg) { switch (vec_ty->base->kind) { case TY_INT: println(" movd %%eax, %s", xmm_reg); println(" pshufd $0x0, %s, %s", xmm_reg, xmm_reg); break; case TY_LLONG: case TY_LONG: println(" movq %%rax, %s", xmm_reg); println(" movddup %s, %s", xmm_reg, xmm_reg); break; case TY_FLOAT: println(" shufps $0x00, %s, %s", xmm_reg, xmm_reg); break; case TY_DOUBLE: println(" shufpd $0x00, %s, %s", xmm_reg, xmm_reg); break; default: error("%s: %s:%d: error: in scalar_to_xmm : unsupported vector base type for scalar promotion %d", CODEGEN_C, __FILE__, __LINE__, vec_ty->base->kind); } } static void gen_vector_op(Node *node) { if (node->rhs) { gen_expr(node->rhs); if (node->rhs->is_scalar_promoted) scalar_to_xmm(node->rhs->ty, "%xmm0"); push_xmm(0); } if (node->lhs) { gen_expr(node->lhs); if (node->lhs->is_scalar_promoted) scalar_to_xmm(node->lhs->ty, "%xmm0"); } if (node->rhs) pop_xmm(1); switch (node->kind) { case ND_ADD: case ND_SUB: case ND_MUL: break; case ND_BITXOR: case ND_BITAND: case ND_BITOR: case ND_BITNOT: break; case ND_DIV: if (is_integer(node->lhs->ty->base)) error_tok(node->tok, "%s: %s:%d: error: in gen_vector_op : integer vector division not supported", CODEGEN_C, __FILE__, __LINE__); break; case ND_NEG: //gen_expr(node->lhs); // materialize operand in %xmm0 break; default: error_tok(node->tok, "%s: %s:%d: error: in gen_vector_op : unsupported vector operation %d", CODEGEN_C, __FILE__, __LINE__, node->kind); } Type *vec_ty = node->lhs->ty; if (vec_ty->kind == TY_PTR && vec_ty->base->kind == TY_VECTOR) vec_ty = vec_ty->base; if (vec_ty->kind != TY_VECTOR) error_tok(node->tok, "%s: %s:%d: error: in gen_vector_op : lhs is not a vector", CODEGEN_C, __FILE__, __LINE__); // if (node->rhs) // load_vector_operand(node->rhs, "%xmm1"); // load_vector_operand(node->lhs, "%xmm0"); switch (vec_ty->base->kind) { case TY_FLOAT: switch (node->kind) { case ND_ADD: println(" addps %%xmm1, %%xmm0"); break; case ND_SUB: println(" subps %%xmm1, %%xmm0"); break; case ND_MUL: println(" mulps %%xmm1, %%xmm0"); break; case ND_DIV: println(" divps %%xmm1, %%xmm0"); break; case ND_BITXOR: println(" pxor %%xmm1, %%xmm0"); break; case ND_BITAND: println(" pand %%xmm1, %%xmm0"); break; case ND_BITOR: println(" por %%xmm1, %%xmm0"); break; case ND_NEG: println(" xorps %%xmm1, %%xmm1"); println(" subps %%xmm0, %%xmm1"); println(" movups %%xmm1, %%xmm0"); break; default: error_tok(node->tok, "%s: %s:%d: error: unsupported float vector operation", CODEGEN_C, __FILE__, __LINE__); } break; case TY_DOUBLE: switch (node->kind) { case ND_ADD: println(" addpd %%xmm1, %%xmm0"); break; case ND_SUB: println(" subpd %%xmm1, %%xmm0"); break; case ND_MUL: println(" mulpd %%xmm1, %%xmm0"); break; case ND_DIV: println(" divpd %%xmm1, %%xmm0"); break; case ND_BITXOR: println(" pxor %%xmm1, %%xmm0"); break; case ND_BITAND: println(" pand %%xmm1, %%xmm0"); break; case ND_BITOR: println(" por %%xmm1, %%xmm0"); break; case ND_NEG: println(" xorpd %%xmm1, %%xmm1"); println(" subpd %%xmm0, %%xmm1"); println(" movapd %%xmm1, %%xmm0"); break; default: error_tok(node->tok, "%s: %s:%d: error: unsupported double vector operation", CODEGEN_C, __FILE__, __LINE__); } break; case TY_LLONG: case TY_LONG: switch (node->kind) { case ND_ADD: println(" paddq %%xmm1, %%xmm0"); break; case ND_SUB: println(" psubq %%xmm1, %%xmm0"); break; case ND_MUL: println(" pmulld %%xmm1, %%xmm0"); // Note: no native 64-bit integer multiply in SSE2; might need scalar fallback break; case ND_BITXOR: println(" pxor %%xmm1, %%xmm0"); break; case ND_BITAND: println(" pand %%xmm1, %%xmm0"); break; case ND_BITOR: println(" por %%xmm1, %%xmm0"); break; case ND_NEG: println(" pxor %%xmm1, %%xmm1"); println(" psubq %%xmm0, %%xmm1"); println(" movdqa %%xmm1, %%xmm0"); break; case ND_BITNOT: println(" pcmpeqq %%xmm1, %%xmm1"); // SSE4.1; for SSE2 use two 32-bit pcmpeqd and pack println(" pxor %%xmm1, %%xmm0"); break; default: error_tok(node->tok, "%s: %s:%d: error: long vector operation not supported", CODEGEN_C, __FILE__, __LINE__); } break; case TY_INT: switch (node->kind) { case ND_ADD: println(" paddd %%xmm1, %%xmm0"); break; case ND_SUB: println(" psubd %%xmm1, %%xmm0"); break; case ND_MUL: println(" pmulld %%xmm1, %%xmm0"); break; case ND_BITXOR: println(" pxor %%xmm1, %%xmm0"); break; case ND_BITAND: println(" pand %%xmm1, %%xmm0"); break; case ND_BITOR: println(" por %%xmm1, %%xmm0"); break; case ND_NEG: println(" pxor %%xmm1, %%xmm1"); println(" psubd %%xmm0, %%xmm1"); println(" movdqa %%xmm1, %%xmm0"); break; case ND_BITNOT: println(" pcmpeqd %%xmm1, %%xmm1"); println(" pxor %%xmm1, %%xmm0"); break; default: error_tok(node->tok, "%s: %s:%d: error: integer vector operation not supported", CODEGEN_C, __FILE__, __LINE__); } break; } } static void gen_cmpxchg(Node *node) { gen_expr(node->cas_ptr); println(" mov %%rax, %%rdi"); gen_expr(node->cas_expected); println(" mov %%rax, %%rsi"); gen_expr(node->cas_desired); println(" mov %%rax, %%rcx"); if (node->ty->size == 1) { println(" movb (%%rcx), %%cl"); } else if (node->ty->size == 2) { println(" movw (%%rcx), %%cx"); } else if (node->ty->size == 4) { println(" movl (%%rcx), %%ecx"); } else if (node->ty->size == 8) { println(" movq (%%rcx), %%rcx"); } if (node->ty->size == 1) { println(" movb (%%rsi), %%al"); } else if (node->ty->size == 2) { println(" movw (%%rsi), %%ax"); } else if (node->ty->size == 4) { println(" movl (%%rsi), %%eax"); } else if (node->ty->size == 8) { println(" movq (%%rsi), %%rax"); } println(" lock cmpxchg %s, (%%rdi)", reg_cx(node->ty->size)); println(" mov %s, (%%rsi)", reg_ax(node->ty->size)); println(" sete %%al"); println(" movzbl %%al, %%eax"); if (node->cas_success || node->cas_failure) { println(" mfence"); } } static void gen_cmpxchgn(Node *node) { gen_expr(node->cas_ptr); println(" mov %%rax, %%rdi"); gen_expr(node->cas_expected); println(" mov %%rax, %%rsi"); gen_expr(node->cas_desired); println(" mov %%rax, %%rcx"); println(" movq (%%rsi), %%rax"); if (node->ty->size == 1) { println(" lock cmpxchg %%cl, (%%rdi)"); } else if (node->ty->size == 2) { println(" lock cmpxchg %%cx, (%%rdi)"); } else if (node->ty->size == 4) { println(" lock cmpxchg %%ecx, (%%rdi)"); } else if (node->ty->size == 8) { println(" lock cmpxchg %%rcx, (%%rdi)"); } println(" movq %%rax, (%%rsi)"); println(" sete %%al"); println(" movzbl %%al, %%eax"); if (node->cas_success || node->cas_failure) { println(" mfence"); } } static void gen_builtin(Node *node, const char *insn) { gen_expr(node->builtin_val); println(" %s %%rax, %%rax", insn); } static void gen_vec_init_v2si(Node *node) { gen_expr(node->lhs); println(" movl %%eax, %%edx"); gen_expr(node->rhs); println(" shl $32, %%rax"); println(" or %%rdx, %%rax"); println(" movq %%rax, %%xmm0"); } static void gen_vec_ext(Node *node) { gen_expr(node->lhs); gen_expr(node->rhs); println(" mov %%eax, %%ebx"); static int idx = 0; static int label_id = 0; int lbl_zero = label_id++; int lbl_done = label_id++; println(" cmpl $0, %%ebx"); println(" je .Lvec_ext_zero_%d", lbl_zero); println(" psrldq $%d, %%xmm0", 4 * idx); idx++; println(" movd %%xmm0, %%eax"); println(" jmp .Lvec_ext_done_%d", lbl_done); println(".Lvec_ext_zero_%d:", lbl_zero); println(" movd %%xmm0, %%eax"); println(".Lvec_ext_done_%d:", lbl_done); } static void gen_vec_init_binop(Node *node, const char *insn) { for (int i = 0; i < node->builtin_nargs; i++) { gen_expr(node->builtin_args[i]); // result in %eax if (i == 0) { println(" movd %%eax, %%xmm0"); } else { println(" %s $%d, %%eax, %%xmm0", insn, i); } } } static void gen_shuf_binop(Node *node, const char *insn) { gen_expr(node->rhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->lhs); println(" %s $%ld, %%xmm1, %%xmm0", insn, node->rhs->val); } static void gen_psll_binop(Node *node, const char *insn) { gen_expr(node->lhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->rhs); if (node->rhs->kind == ND_NUM) println(" %s $%ld, %%xmm1", insn, node->rhs->val); else { println(" movq %%rax, %%xmm0"); println(" %s %%xmm0, %%xmm1", insn); } println(" movups %%xmm1, %%xmm0"); } // Walk node to find a numeric constant. Works for ND_ASSIGN, ND_COMMA, ND_CAST etc. static int get_const_int_from_node(Node *node) { if (!node) error("%s: %s:%d: error: in get_const_int_from_node : expected constant node", CODEGEN_C, __FILE__, __LINE__); while (true) { if (node->kind == ND_NUM) return node->val; if (node->kind == ND_CAST) { node = node->lhs; continue; } if (node->kind == ND_COMMA) { node = node->rhs; continue; } if (node->kind == ND_ASSIGN) { node = node->rhs; continue; } break; } error_tok(node->tok, "%s: %s:%d: error: in get_const_int_from_node : not a compile-time integer constant", CODEGEN_C, __FILE__, __LINE__); } static Node *unwrap_casts(Node *node) { while (node && (node->kind == ND_CAST || node->kind == ND_COMMA)) node = node->lhs; return node; } // Fill vals[] with mask_node->var->ty->array_len ints (expect 4). static void get_mask_values(Node *mask_node, int *vals, int expected_len) { mask_node = unwrap_casts(mask_node); if (!mask_node->var || !mask_node->var->init) error_tok(mask_node->tok, "%s: %s:%d: error: in get_mask_values : shuffle mask must be a constant vector initializer! %d", CODEGEN_C, __FILE__, __LINE__, mask_node->kind); Initializer *init = mask_node->var->init; int len = mask_node->var->ty->array_len; for (int i = 0; i < len; i++) { Initializer *elem = init->children[i]; vals[i] = get_const_int_from_node(elem->expr); } } // Try to find imm1/imm2 (two shufps immediates) that produce mask[0..3]. // Returns true on success. static bool decompose_shuffle_mask_from_vals(int mask[4], int *out_imm1, int *out_imm2) { // mask entries must be 0..7 for (int i = 0; i < 4; i++) if (mask[i] < 0 || mask[i] > 7) return false; for (int comb = 0; comb < (1 << 4); comb++) { int idx[4]; int ia[2] = {-1,-1}, ib[2] = {-1,-1}; bool ok = true; for (int j = 0; j < 4; j++) { int bit = (comb >> j) & 1; if (mask[j] < 4) idx[j] = bit; // from a -> index 0/1 in intermediate else idx[j] = 2 + bit; // from b -> index 2/3 in intermediate if (idx[j] < 2) { if (ia[idx[j]] == -1) ia[idx[j]] = mask[j]; else if (ia[idx[j]] != mask[j]) { ok = false; break; } } else { int k = idx[j] - 2; if (ib[k] == -1) ib[k] = mask[j] - 4; else if (ib[k] != mask[j] - 4) { ok = false; break; } } } if (!ok) continue; for (int t = 0; t < 2; t++) { if (ia[t] == -1) ia[t] = 0; if (ib[t] == -1) ib[t] = 0; } int imm1 = (ia[0] & 3) | ((ia[1] & 3) << 2) | ((ib[0] & 3) << 4) | ((ib[1] & 3) << 6); int imm2 = (idx[0] & 3) | ((idx[1] & 3) << 2) | ((idx[2] & 3) << 4) | ((idx[3] & 3) << 6); // simulate int intermediate[4]; intermediate[0] = ia[0]; // reference a indices 0..3 treated as 0..3 intermediate[1] = ia[1]; intermediate[2] = ib[0] + 4; // convert back to 4..7 intermediate[3] = ib[1] + 4; int final[4]; for (int j = 0; j < 4; j++) final[j] = intermediate[(imm2 >> (2*j)) & 3]; bool match = true; for (int j = 0; j < 4; j++) if (final[j] != mask[j]) { match = false; break; } if (!match) continue; *out_imm1 = imm1; *out_imm2 = imm2; return true; } return false; } static void gen_shuffle(Node *node, const char *insn) { assert(node->builtin_nargs == 3); // Evaluate args so %xmm0 ends with lhs and %xmm1 ends with rhs as before: gen_expr(node->builtin_args[0]); // leaves a in %xmm0 println(" movups %%xmm0, %%xmm2"); // save a in xmm2 gen_expr(node->builtin_args[1]); // leaves b in %xmm0 println(" movups %%xmm0, %%xmm1"); // save b in xmm1 println(" movups %%xmm2, %%xmm0"); // restore a into xmm0 (dest) // read the 4 mask values int mask[4]; get_mask_values(node->builtin_args[2], mask, 4); // try to decompose into two shufps immediates int imm1, imm2; if (decompose_shuffle_mask_from_vals(mask, &imm1, &imm2)) { // emit exactly what GCC emits println(" %s $%d, %%xmm1, %%xmm0", insn, imm1); // shufps imm1, xmm1, xmm0 println(" %s $%d, %%xmm0, %%xmm0", insn, imm2); // shufps imm2, xmm0, xmm0 } else { // fallback: try a single shufps immediate (simple encode) or emit more general sequence // Build single-byte immediate where bits are (lane3<<6)|(lane2<<4)|(lane1<<2)|lane0 int single = ((mask[3] & 3) << 6) | ((mask[2] & 3) << 4) | ((mask[1] & 3) << 2) | (mask[0] & 3); println(" %s $%d, %%xmm1, %%xmm0", insn, single); } } static void gen_maskmovq(Node *node) { assert(node->builtin_nargs == 3); gen_expr(node->builtin_args[1]); println(" movq (%%rax), %%mm1"); gen_expr(node->builtin_args[0]); println(" movq (%%rax), %%mm0"); gen_addr(node->builtin_args[2]); println(" movq %%rax, %%rdi"); println(" maskmovq %%mm1, %%mm0"); println(" emms"); } static void gen_maskmovdqu(Node *node) { assert(node->builtin_nargs == 3); gen_expr(node->builtin_args[1]); println(" movdqu (%%rax), %%xmm1"); gen_expr(node->builtin_args[0]); println(" movdqu (%%rax), %%xmm0"); gen_addr(node->builtin_args[2]); println(" movq %%rax, %%rdi"); println(" maskmovdqu %%xmm1, %%xmm0"); } static void gen_cvtpi2ps(Node *node) { gen_expr(node->lhs); gen_addr(node->rhs); println(" movq (%%rax), %%mm0"); println(" cvtpi2ps %%mm0, %%xmm0"); println(" emms"); } static void gen_loadhps(Node *node) { gen_expr(node->lhs); println(" movups (%%rax), %%xmm0"); gen_expr(node->rhs); println(" movq (%%rax), %%xmm1"); println(" movlhps %%xmm1, %%xmm0"); } static void gen_packss128_binop(Node *node, const char *insn) { gen_expr(node->lhs); println(" movups (%%rax), %%xmm1"); gen_expr(node->rhs); println(" %s (%%rax), %%xmm1", insn); println(" movups %%xmm1, %%xmm0"); } static void gen_alloc(Node *node) { gen_expr(node->lhs); // Assume size to allocate is in RAX println(" mov %%rax, %%rdi"); // Move size to RDI (or appropriate register) println(" sub %%rdi, %%rsp"); // Allocate space on the stack println(" mov %%rsp, %%rax"); // Store the new stack pointer (allocated memory address) in RAX } static void gen_release(Node *node) { gen_expr(node->lhs); push(); pop("%rdi"); println(" xor %%eax, %%eax"); println(" mov %s, (%%rdi)", reg_ax(node->ty->size)); } static void gen_subfetch(Node *node) { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); push(); println(" neg %s", reg_ax(node->ty->size)); println(" xadd %s, (%%rdi)", reg_ax(node->ty->size)); pop("%rdi"); println(" sub %s, %s", reg_di(node->ty->size), reg_ax(node->ty->size)); } static void gen_fetchadd(Node *node) { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); println(" xadd %s, (%%rdi)", reg_ax(node->ty->size)); } static void gen_fetchsub(Node *node) { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); println(" neg %s", reg_ax(node->ty->size)); println(" xadd %s, (%%rdi)", reg_ax(node->ty->size)); } static void gen_store_binop(Node *node, const char *insn) { gen_expr(node->rhs); gen_expr(node->lhs); println(" %s %%xmm0, (%%rax)", insn); } static void gen_loadlps(Node *node) { gen_expr(node->lhs); gen_expr(node->rhs); println(" movlps (%%rax), %%xmm0"); } static void gen_stmxcsr(Node *node) { if (node->lhs) { gen_expr(node->lhs); println(" stmxcsr (%%rax)"); } else { println(" stmxcsr -8(%%rsp)"); println(" mov -8(%%rsp), %%eax"); } } static void gen_single_addr_binop(Node *node, const char *insn){ gen_addr(node->lhs); println(" %s (%%rax)", insn); } static void gen_add_overflow(Node *node) { int c = count(); // Unique label counter Type *ty = node->builtin_dest->ty; if (ty->base) ty = ty->base; gen_expr(node->lhs); push(); gen_expr(node->rhs); push(); gen_expr(node->builtin_dest); push(); pop("%rdx"); pop("%rsi"); pop("%rdi"); if (ty->size == 1) { println(" mov %%dil, %%al"); println(" add %%sil, %%al"); println(" mov %%al, (%%rdx)"); } else if (ty->size == 2) { println(" mov %%di, %%ax"); println(" add %%si, %%ax"); println(" mov %%ax, (%%rdx)"); } else if (ty->size == 4) { println(" mov %%edi, %%eax"); println(" add %%esi, %%eax"); println(" mov %%eax, (%%rdx)"); } else { println(" mov %%rdi, %%rax"); println(" add %%rsi, %%rax"); println(" mov %%rax, (%%rdx)"); } // Check for overflow println(" seto %%al"); // Set AL if overflow occurred println(" movzx %%al, %%eax"); // Zero-extend AL to EAX // Return 0 if no overflow, 1 if overflow println(" cmp $0, %%eax"); println(" jne .Loverflowa%d", c); println(" mov $0, %%eax"); println(" jmp .Lenda%d", c); println(".Loverflowa%d:", c); println(" mov $1, %%eax"); println(".Lenda%d:", c); } static void gen_umul_overflow(Node *node) { int c = count(); Type *ty = node->lhs->ty; if (ty->base) ty = ty->base; int size = ty->size; // Generate expressions gen_expr(node->lhs); push(); gen_expr(node->rhs); push(); gen_expr(node->builtin_dest); push(); // Pop arguments pop("%rdx"); // result pointer (can be NULL) pop("%rsi"); // rhs pop("%rdi"); // lhs println(" mov %%rdx, %%rcx"); // Multiply if (size == 1) { println(" movzbl %%di, %%eax"); println(" movzbl %%si, %%ebx"); println(" mul %%bl"); // AL * BL -> AX println(" jc .Loverflowm%d", c); } else if (size == 2) { println(" movzwl %%di, %%eax"); println(" movzwl %%si, %%ebx"); println(" mul %%bx"); // AX * BX -> DX:AX println(" jc .Loverflowm%d", c); } else if (size == 4) { println(" mov %%edi, %%eax"); println(" mul %%esi"); // EAX * ESI -> EDX:EAX println(" jc .Loverflowm%d", c); } else if (size >= 8) { println(" mov %%rdi, %%rax"); println(" mul %%rsi"); // RAX * RSI -> RDX:RAX println(" test %%rdx, %%rdx"); // overflow check println(" jnz .Loverflowm%d", c); } // Store result if destination pointer is not NULL println(" test %%rcx, %%rcx"); println(" jz .Ldonem%d", c); if (size == 1) println(" mov %%al, (%%rcx)"); else if (size == 2) println(" mov %%ax, (%%rcx)"); else if (size == 4) println(" mov %%eax, (%%rcx)"); else if (size == 8) println(" mov %%rax, (%%rcx)"); println(".Ldonem%d:", c); println(" mov $0, %%rax"); // return 0 for no overflow println(" jmp .Lend%d", c); // Overflow label println(".Loverflowm%d:", c); println(" test %%rcx, %%rcx"); // only store if pointer not NULL println(" jz .Loverflow_end%d", c); if (size == 1) println(" movb $0, (%%rcx)"); else if (size == 2) println(" movw $0, (%%rcx)"); else if (size == 4) println(" movl $0, (%%rcx)"); else if (size == 8) println(" movq $0, (%%rcx)"); println(".Loverflow_end%d:", c); println(" mov $1, %%rax"); // return 1 for overflow println(".Lend%d:", c); } static void gen_uadd_overflow(Node *node) { int c = count(); Type *ty = node->builtin_dest->ty; if (ty->base) ty = ty->base; gen_expr(node->lhs); push(); gen_expr(node->rhs); push(); gen_expr(node->builtin_dest); push(); pop("%rdx"); pop("%rsi"); pop("%rdi"); if (ty->size == 1) { println(" mov %%dil, %%al"); println(" add %%sil, %%al"); println(" mov %%al, (%%rdx)"); } else if (ty->size == 2) { println(" mov %%di, %%ax"); println(" add %%si, %%ax"); println(" mov %%ax, (%%rdx)"); } else if (ty->size == 4) { println(" mov %%edi, %%eax"); println(" add %%esi, %%eax"); println(" mov %%eax, (%%rdx)"); } else { println(" mov %%rdi, %%rax"); println(" add %%rsi, %%rax"); println(" mov %%rax, (%%rdx)"); } println(" setc %%al"); // carry flag = unsigned overflow println(" movzx %%al, %%eax"); // zero-extend AL to EAX // Return 0 if no overflow, 1 if overflow println(" cmp $0, %%eax"); println(" jne .Loverflowa%d", c); println(" mov $0, %%eax"); println(" jmp .Lenda%d", c); println(".Loverflowa%d:", c); println(" mov $1, %%eax"); println(".Lenda%d:", c); } static void gen_parity(Node *node) { gen_expr(node->lhs); if (node->lhs->kind == ND_NUM) { uint64_t x = node->lhs->val; x ^= x >> 32; x ^= x >> 16; x ^= x >> 8; x ^= x >> 4; x ^= x >> 2; x ^= x >> 1; int parity = x & 1; println(" mov $%d, %%eax", parity); } else { println(" mov %%rax, %%rcx"); // copy to rcx println(" shr $32, %%rcx"); println(" xor %%rcx, %%rax"); println(" mov %%rax, %%rcx"); println(" shr $16, %%rcx"); println(" xor %%rcx, %%rax"); println(" mov %%rax, %%rcx"); println(" shr $8, %%rcx"); println(" xor %%rcx, %%rax"); println(" mov %%rax, %%rcx"); println(" shr $4, %%rcx"); println(" xor %%rcx, %%rax"); println(" mov %%rax, %%rcx"); println(" shr $2, %%rcx"); println(" xor %%rcx, %%rax"); println(" mov %%rax, %%rcx"); println(" shr $1, %%rcx"); println(" xor %%rcx, %%rax"); println(" and $1, %%eax"); // final parity in eax } } static void gen_movq128(Node *node) { gen_expr(node->lhs); println(" movq %%xmm0, %%xmm1"); println(" pxor %%xmm0, %%xmm0"); println(" movq %%xmm1, %%xmm0"); } static void gen_movnti(Node *node) { gen_expr(node->rhs); if (node->rhs->kind == ND_NUM) println(" mov $%ld, %%ecx", node->rhs->val); else println(" movq (%%rax), %%rcx"); gen_expr(node->lhs); println(" movnti %%ecx, (%%rax)"); } static void gen_movnti64(Node *node) { gen_expr(node->rhs); if (node->rhs->kind == ND_NUM) println(" mov $%ld, %%rcx", node->rhs->val); else println(" movq (%%rax), %%rcx"); gen_expr(node->lhs); println(" movnti %%rcx, (%%rax)"); } static void gen_movnt_binop(Node *node, const char *insn) { gen_expr(node->rhs); gen_expr(node->lhs); println(" %s %%xmm0, (%%rax)", insn); } // Helper to emit MMX two-operand instruction static void gen_sse_binop1(Node *node, const char *insn, bool rhs_is_imm) { gen_expr(node->rhs); println(" movss %%xmm0, %%xmm1"); gen_expr(node->lhs); println(" %s %%xmm1, %%xmm0", insn); } static void gen_sse_binop2(Node *node, const char *insn, const char *reg, bool rhs_is_imm) { gen_expr(node->lhs); println(" %s %%xmm0, %%%s", insn, reg); } static void gen_sse_binop3(Node *node, const char *insn, bool rhs_is_imm) { gen_expr(node->rhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->lhs); println(" %s %%xmm1, %%xmm0", insn); } static void gen_sse_binop4(Node *node, const char *insn, const char *insn2) { gen_expr(node->lhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->rhs); println(" %s %%xmm0, %%xmm1", insn); println(" %s %%al", insn2); println(" movzx %%al, %%eax"); } static void gen_sse_binop5(Node *node, const char *insn, const char *insn2) { gen_expr(node->lhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->rhs); println(" %s %%xmm1, %%xmm0", insn); println(" %s %%al", insn2); println(" movzx %%al, %%eax"); } static void gen_sse_binop6(Node *node, const char *insn, const char *insn2) { gen_expr(node->lhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->rhs); println(" %s %%xmm0, %%xmm1", insn); println(" setnp %%dl"); println(" %s %%al", insn2); println(" and %%al, %%dl"); println(" movzx %%dl, %%eax"); } static void gen_sse_binop7(Node *node, const char *insn) { gen_expr(node->lhs); println(" movdqa %%xmm0, %%xmm1"); gen_expr(node->rhs); println(" %s %%xmm0, %%xmm1", insn); println(" movdqa %%xmm1, %%xmm0"); } static void gen_sse_binop8(Node *node, const char *insn, const char *reg) { gen_expr(node->lhs); println(" movq (%%rax), %%xmm0"); println(" %s %%xmm0, %%%s", insn, reg); } static void gen_sse_binop9(Node *node, const char *insn) { gen_expr(node->lhs); println(" movups %%xmm0, %%xmm1"); gen_expr(node->rhs); println(" %s %%xmm1, %%xmm0", insn); } static void gen_sse_binop10(Node *node, const char *insn, const char *reg) { gen_expr(node->lhs); println(" movq %%rax, %%rdi"); gen_expr(node->rhs); println(" %s %%%s, (%%rdi)", insn, reg); } static void gen_sse_binop11(Node *node, const char *insn, const char *reg) { gen_expr(node->lhs); println(" movq %%rax, %%rdi"); gen_expr(node->rhs); println(" %s %%%s, %%xmm0", insn, reg); } static void gen_cvt_mmx_binop(Node *node, const char *insn) { gen_addr(node->lhs); println(" movups (%%rax), %%xmm0"); println(" %s %%xmm0, %%mm0", insn); println(" movq %%mm0, %%rax"); println(" movq %%rax, %%xmm0"); println(" emms"); } static void gen_cvt_sse_binop2(Node *node, const char *insn, const char *reg, bool is_address) { gen_expr(node->lhs); gen_expr(node->rhs); if (is_address) println(" %s (%%%s), %%xmm0", insn, reg); else println(" %s %%%s, %%xmm0", insn, reg); } static void gen_cvt_mmx_binop3(Node *node, const char *insn) { gen_expr(node->lhs); println(" %s %%xmm0, %%mm0", insn); gen_addr(node->lhs); println(" movq %%mm0, %%rax"); println(" movq %%rax, %%xmm0"); println(" emms"); } static void gen_cvt_mmx_binop4(Node *node, const char *insn) { gen_expr(node->lhs); println(" movq (%%rax), %%mm0"); println(" %s %%mm0, %%xmm0", insn); println(" emms"); } // Helper to emit MMX two-operand instruction static void gen_mmx_binop(Node *node, const char *insn, bool rhs_is_imm) { gen_expr(node->lhs); println(" movq (%%rax), %%mm0"); if (rhs_is_imm) { if (node->rhs->kind == ND_NUM) { println(" %s $%ld, %%mm0", insn, node->rhs->val); } else { gen_expr(node->rhs); println(" movq %%rax, %%mm1"); println(" %s %%mm1, %%mm0", insn); } } else { gen_expr(node->rhs); println(" movq (%%rax), %%mm1"); println(" %s %%mm1, %%mm0", insn); } println(" movq %%mm0, %%rax"); println(" movq %%rax, %%xmm0"); println(" emms"); } static void gen_single_binop(const char *insn) { println(" %s", insn); } static void gen_cvt_binop(Node *node, const char *insn) { gen_addr(node->lhs); if (node->lhs->kind == ND_VAR || node->lhs->kind == ND_MEMBER) { println(" %s (%%rax), %%rax", insn); } else { println(" %s %%xmm0, %%rax", insn); } } // Generate code for a given node. static void gen_expr(Node *node) { if (!node) error("%s: %s:%d: error: in gen_expr : node is null!", CODEGEN_C, __FILE__, __LINE__); if (node->tok && node->tok->line_no != last_loc_line) { println(" .loc %d %u", node->tok->file->file_no, node->tok->line_no); last_loc_line = node->tok->line_no; } switch (node->kind) { case ND_NULL_EXPR: return; case ND_NUM: { switch (node->ty->kind) { case TY_FLOAT: { union { float f32; uint32_t u32; } u = {node->fval}; println(" mov $%u, %%eax # float %Lf", u.u32, node->fval); println(" movq %%rax, %%xmm0"); return; } case TY_DOUBLE: { union { double f64; uint64_t u64; } u = {node->fval}; println(" mov $%lu, %%rax # double %Lf", u.u64, node->fval); println(" movq %%rax, %%xmm0"); return; } case TY_LDOUBLE: { union { long double f80; uint64_t u64[2]; } u; memset(&u, 0, sizeof(u)); u.f80 = node->fval; println(" mov $%lu, %%rax # long double %Lf", u.u64[0], node->fval); println(" mov %%rax, -16(%%rsp)"); println(" mov $%lu, %%rax", u.u64[1]); println(" mov %%rax, -8(%%rsp)"); println(" fldt -16(%%rsp)"); return; } case TY_INT128: { // Extract the 128-bit integer value into high and low 64-bit parts __int128 val = node->val; uint64_t low = (uint64_t)val; uint64_t high = (uint64_t)(val >> 64); println(" mov $%lu, %%rax # low 64 bits", low); println(" mov $%lu, %%rdx # high 64 bits", high); return; } } println(" mov $%ld, %%rax", node->val); return; } case ND_POS: gen_expr(node->lhs); return; case ND_NEG: gen_expr(node->lhs); if (is_int128(node->ty)) { gen_int128_op(node); return; } if (is_vector(node->ty)) { gen_vector_op(node); return; } switch (node->ty->kind) { case TY_FLOAT: println(" mov $1, %%rax"); println(" shl $31, %%rax"); println(" movq %%rax, %%xmm1"); println(" xorps %%xmm1, %%xmm0"); return; case TY_DOUBLE: println(" mov $1, %%rax"); println(" shl $63, %%rax"); println(" movq %%rax, %%xmm1"); println(" xorpd %%xmm1, %%xmm0"); return; case TY_LDOUBLE: println(" fchs"); return; } println(" neg %%rax"); return; case ND_VAR: gen_addr(node); if (!node->ty) add_type(node); load(node->ty); return; case ND_MEMBER: { gen_addr(node); if (!node->ty) error("%s %d: in gen_expr : ND_MEMBER node type is null!", CODEGEN_C, __LINE__); load(node->ty); Member *mem = node->member; if (mem->is_bitfield) { //from @fuhsnn bitfield boolean returned -1 instead of 1 if (mem->ty->kind == TY_BOOL) { println(" shr $%d, %%rax", mem->bit_offset); println(" and $1, %%eax"); return; } println(" shl $%d, %%rax", 64 - mem->bit_width - mem->bit_offset); if (mem->ty->is_unsigned) println(" shr $%d, %%rax", 64 - mem->bit_width); else println(" sar $%d, %%rax", 64 - mem->bit_width); } return; } case ND_DEREF: gen_expr(node->lhs); if (!node->ty) error("%s %d: in gen_expr : ND_DEREF node type is null!", CODEGEN_C, __LINE__); load(node->ty); return; case ND_ADDR: gen_addr(node->lhs); return; case ND_ASSIGN: gen_addr(node->lhs); push(); gen_expr(node->rhs); if (node->lhs->kind == ND_MEMBER && node->lhs->member->is_bitfield) { println(" mov %%rax, %%r8"); // If the lhs is a bitfield, we need to read the current value // from memory and merge it with a new value. Member *mem = node->lhs->member; println(" mov %%rax, %%rdi"); if (mem->bit_width >= 32) { println(" mov $%ld, %%rax", (1L << mem->bit_width) - 1); println(" and %%rax, %%rdi"); } else { println(" and $%ld, %%rdi", (1L << mem->bit_width) - 1); } // println(" and $%ld, %%rdi", (1L << mem->bit_width) - 1); println(" shl $%d, %%rdi", mem->bit_offset); println(" mov (%%rsp), %%rax"); load(mem->ty); long mask = ((1L << mem->bit_width) - 1) << mem->bit_offset; println(" mov $%ld, %%r9", ~mask); println(" and %%r9, %%rax"); println(" or %%rdi, %%rax"); store(mem->ty); println(" mov %%r8, %%rax"); return; } store(node->ty); return; case ND_STMT_EXPR: for (Node *n = node->body; n; n = n->next) gen_stmt(n); return; case ND_COMMA: gen_expr(node->lhs); gen_expr(node->rhs); return; case ND_CAST: gen_expr(node->lhs); if (!node->ty) error("%s %d: in gen_expr : ND_CAST node type is null!", CODEGEN_C, __LINE__); cast(node->lhs->ty, node->ty); return; case ND_MEMZERO: gen_mem_zero(node->var->offset, node->var->ty->size); return; case ND_COND: { int c = count(); gen_expr(node->cond); cmp_zero(node->cond->ty); println(" je .L.else.%d", c); gen_expr(node->then); println(" jmp .L.end.%d", c); println(".L.else.%d:", c); gen_expr(node->els); println(".L.end.%d:", c); return; } case ND_NOT: gen_expr(node->lhs); cmp_zero(node->lhs->ty); println(" sete %%al"); println(" movzx %%al, %%rax"); return; case ND_BITNOT: if (is_int128(node->ty)) { gen_int128_op(node); return; } if (is_vector(node->ty)) { gen_vector_op(node); return; } gen_expr(node->lhs); println(" not %%rax"); return; case ND_LOGAND: if (is_int128(node->ty)) { gen_int128_op(node); return; } if (is_vector(node->ty)) { gen_vector_op(node); return; } { int c = count(); gen_expr(node->lhs); cmp_zero(node->lhs->ty); println(" je .L.false.%d", c); gen_expr(node->rhs); cmp_zero(node->rhs->ty); println(" je .L.false.%d", c); println(" mov $1, %%rax"); println(" jmp .L.end.%d", c); println(".L.false.%d:", c); println(" mov $0, %%rax"); println(".L.end.%d:", c); return; } case ND_LOGOR: if (is_int128(node->ty)) { gen_int128_op(node); return; } if (is_vector(node->ty)) { gen_vector_op(node); return; } { int c = count(); gen_expr(node->lhs); cmp_zero(node->lhs->ty); println(" jne .L.true.%d", c); gen_expr(node->rhs); cmp_zero(node->rhs->ty); println(" jne .L.true.%d", c); println(" mov $0, %%rax"); println(" jmp .L.end.%d", c); println(".L.true.%d:", c); println(" mov $1, %%rax"); println(".L.end.%d:", c); return; } case ND_FUNCALL: { if (node->lhs->kind == ND_VAR && (!strcmp(node->lhs->var->name, "alloca") || !strcmp(node->lhs->var->name, "__builtin_alloca"))) { gen_expr(node->args); println(" mov %%rax, %%rdi"); //builtin_alloca(); builtin_alloca(node); return; } int stack_args = push_args(node); gen_expr(node->lhs); int gp = 0, fp = 0; // If the return type is a large struct/union, the caller passes // a pointer to a buffer as if it were the first argument. if (node->ret_buffer && node->ty->size > 16) pop(argreg64[gp++]); for (Node *arg = node->args; arg; arg = arg->next) { Type *ty = arg->ty; if (!ty) error("%s %d: in gen_expr : type is null!", CODEGEN_C, __LINE__); switch (ty->kind) { case TY_STRUCT: case TY_UNION: if (ty->size == 0) continue; if (!pass_by_reg(ty, gp, fp)) continue; if (has_flonum1(ty)) popf(fp++); else pop(argreg64[gp++]); if (ty->size > 8) { if (has_flonum2(ty)) popf(fp++); else pop(argreg64[gp++]); } break; case TY_VECTOR: if (fp < FP_MAX) popv(fp++); break; case TY_FLOAT: case TY_DOUBLE: if (fp < FP_MAX) popf(fp++); break; case TY_LDOUBLE: break; case TY_INT128: if (gp + 2 <= GP_MAX) { int a = gp++; int b = gp++; popx(argreg64[a], argreg64[b]); } break; default: if (gp < GP_MAX) pop(argreg64[gp++]); break; } } // Function call println(" mov %%rax, %%r10"); //println(" mov $%d, %%rax", fp); println(" mov $%d, %%al", fp); println(" call *%%r10"); println(" add $%d, %%rsp", stack_args * 8); depth -= stack_args; // It looks like the most significant 48 or 56 bits in RAX may // contain garbage if a function return type is short or bool/char, // respectively. We clear the upper bits here. switch (node->ty->kind) { case TY_BOOL: println(" movzx %%al, %%eax"); return; case TY_CHAR: if (node->ty->is_unsigned) println(" movzbl %%al, %%eax"); else println(" movsbl %%al, %%eax"); return; case TY_SHORT: if (node->ty->is_unsigned) println(" movzwl %%ax, %%eax"); else println(" movswl %%ax, %%eax"); return; } // If the return type is a small struct, a value is returned // using up to two registers. if (node->ret_buffer && node->ty->size <= 16) { copy_ret_buffer(node->ret_buffer); println(" lea %d(%%rbp), %%rax", node->ret_buffer->offset); } return; } case ND_LABEL_VAL: println(" lea %s(%%rip), %%rax", node->unique_label); return; case ND_CAS: { gen_expr(node->cas_addr); push(); gen_expr(node->cas_new); push(); gen_expr(node->cas_old); println(" mov %%rax, %%r8"); if (!node->cas_old->ty->base) error("%s %d: in gen_expr : ND_CAS node base type is null!", CODEGEN_C, __LINE__); load(node->cas_old->ty->base); pop("%rdx"); // new pop("%rdi"); // addr int sz = node->cas_addr->ty->base->size; println(" lock cmpxchg %s, (%%rdi)", reg_dx(sz)); println(" sete %%cl"); println(" je 1f"); println(" mov %s, (%%r8)", reg_ax(sz)); println("1:"); println(" movzbl %%cl, %%eax"); return; } case ND_CAS_N: { gen_expr(node->cas_addr); push(); gen_expr(node->cas_new); push(); gen_expr(node->cas_old); // Move the old value to r8 to preserve it println(" mov %%rax, %%r8"); pop("%rdx"); pop("%rdi"); int sz = node->cas_addr->ty->base->size; // Perform the atomic compare-and-swap operation println(" lock cmpxchg %s, (%%rdi)", reg_dx(sz)); // After cmpxchg, rax contains the old value (before the swap) // Restore the preserved old value to rax println(" mov %%r8, %%rax"); return; } case ND_SYNC: { println(" mfence"); // x86-64 instruction for full memory barrier return; } case ND_BUILTIN_MEMCPY: { if (opt_fbuiltin) { gen_expr(node->builtin_dest); push(); println(" mov %%rax, %%rdi"); gen_expr(node->builtin_src); push(); println(" mov %%rax, %%rsi"); gen_expr(node->builtin_size); push(); println(" mov %%rax, %%rcx"); println(" rep movsb"); pop("%rcx"); pop("%rsi"); pop("%rdi"); } else { gen_expr(node->builtin_dest); push(); gen_expr(node->builtin_src); push(); gen_expr(node->builtin_size); push(); println(" call memcpy"); // Restore the stack pop("%rdx"); // size pop("%rsi"); // source pop("%rdi"); // destination } return; } case ND_BUILTIN_MEMSET: { gen_expr(node->builtin_dest); push(); gen_expr(node->builtin_val); push(); gen_expr(node->builtin_size); push(); pop("%rcx"); // size pop("%rsi"); // value pop("%rdi"); // destination println(" mov %%sil, %%al"); println(" rep stosb"); return; } case ND_BUILTIN_CLZ: { gen_expr(node->builtin_val); println(" bsr %%eax, %%eax"); println(" xor $31, %%eax"); return; } case ND_BUILTIN_CLZLL: case ND_BUILTIN_CLZL: { gen_expr(node->builtin_val); println(" bsr %%rax, %%rax"); println(" xor $63, %%eax"); return; } case ND_BUILTIN_CTZ: { gen_expr(node->builtin_val); println(" bsf %%eax, %%eax"); return; } case ND_BUILTIN_CTZLL: case ND_BUILTIN_CTZL: gen_builtin(node, "bsf"); return; // { // gen_expr(node->builtin_val); // println(" bsf %%rax, %%rax"); // return; // } case ND_BUILTIN_BSWAP16: { gen_expr(node->builtin_val); println(" mov %%ax, %%dx"); println(" rol $8, %%dx"); println(" mov %%dx, %%ax"); return; } case ND_BUILTIN_BSWAP32: { gen_expr(node->builtin_val); println(" bswap %%eax"); return; } case ND_BUILTIN_BSWAP64: { gen_expr(node->builtin_val); println(" bswap %%rax"); return; } case ND_BUILTIN_FRAME_ADDRESS: { int c = count(); // Unique label counter gen_expr(node->lhs); // level in %rax // Guard: limit frame walking to 64 levels println(" mov $64, %%rdi"); println(" cmp %%rax, %%rdi"); println(" ja .Lframe_address_ok%d", c); // if rax < 64, continue println(" jmp .Lframe_address_null%d", c); // else, bail out println(".Lframe_address_ok%d:", c); // Check if level == 0 println(" cmp $0, %%rax"); println(" je .Lframe_address_%d", c); // For level > 0, follow the frame pointer chain println(" mov %%rbp, %%rcx"); // rcx = current frame pointer //println(" sub $1, %%rax"); // rax = level - 1 println(".Lframe_address_loop%d:", c); println(" test %%rax, %%rax"); println(" jz .Lframe_address_done%d", c); println(" test %%rcx, %%rcx"); println(" jz .Lframe_address_null%d", c); println(" mov (%%rcx), %%rcx"); // rcx = *(rcx) (next frame) println(" sub $1, %%rax"); println(" jmp .Lframe_address_loop%d", c); println(".Lframe_address_done%d:", c); println(" mov %%rcx, %%rax"); // return result println(" jmp .Lframe_address_return%d", c); println(".Lframe_address_%d:", c); println(" mov %%rbp, %%rax"); // level 0: return current frame println(" jmp .Lframe_address_return%d", c); println(".Lframe_address_null%d:", c); println(" mov $0, %%rax"); // return NULL println(".Lframe_address_return%d:", c); return; } case ND_POPCOUNTL: case ND_POPCOUNTLL: case ND_POPCOUNT: gen_builtin(node, "popcnt"); return; case ND_EXPECT: { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); println(" cmp %%rax, %%rdi"); println(" mov %%rdi, %%rax"); return; } case ND_ABORT: { println(" call abort"); return; } case ND_RETURN_ADDR: { println(" mov %%rbp, %%rax"); int tmpdepth = eval(node->lhs); for (int i = 0; i < tmpdepth; i++) { println(" mov (%%rax), %%rax"); } println(" mov 8(%%rax), %%rax"); return; } case ND_UMULL_OVERFLOW: case ND_UMULLL_OVERFLOW: case ND_UMUL_OVERFLOW: gen_umul_overflow(node); return; case ND_UADDL_OVERFLOW: case ND_UADDLL_OVERFLOW: case ND_UADD_OVERFLOW: gen_uadd_overflow(node); return; case ND_BUILTIN_ADD_OVERFLOW: gen_add_overflow(node); return; case ND_BUILTIN_SUB_OVERFLOW: { int c = count(); Type *ty = node->builtin_dest->ty; if (ty->base) ty = ty->base; gen_expr(node->lhs); push(); gen_expr(node->rhs); push(); gen_expr(node->builtin_dest); push(); pop("%rdx"); pop("%rsi"); pop("%rdi"); if (ty->size == 1) { println(" mov %%dil, %%al"); println(" sub %%sil, %%al"); println(" mov %%al, (%%rdx)"); } else if (ty->size == 2) { println(" mov %%di, %%ax"); println(" sub %%si, %%ax"); println(" mov %%ax, (%%rdx)"); } else if (ty->size == 4) { println(" mov %%edi, %%eax"); println(" sub %%esi, %%eax"); println(" mov %%eax, (%%rdx)"); } else { println(" mov %%rdi, %%rax"); println(" sub %%rsi, %%rax"); println(" mov %%rax, (%%rdx)"); } // Check for overflow println(" seto %%al"); // Set AL if overflow occurred println(" movzx %%al, %%eax"); // Zero-extend AL to EAX // Return 0 if no overflow, 1 if overflow println(" cmp $0, %%eax"); println(" jne .Loverflows%d", c); println(" mov $0, %%eax"); println(" jmp .Lends%d", c); println(".Loverflows%d:", c); println(" mov $1, %%eax"); println(".Lends%d:", c); return; } case ND_BUILTIN_MUL_OVERFLOW: { int c = count(); // Unique label counter Type *ty = node->lhs->ty; // Get the type of the operands if (ty->base) ty = ty->base; int size = ty->size; // Evaluate left-hand side and right-hand side expressions gen_expr(node->lhs); push(); gen_expr(node->rhs); push(); gen_expr(node->builtin_dest); push(); // Load values into registers and perform multiplication pop("%rdx"); // Load address of result variable pop("%rsi"); // Load rhs pop("%rdi"); // Load lhs // Determine the suffix and size for the operations if (size == 1) { // For 8-bit values (char) println(" movzbl %%di, %%eax"); // Zero-extend to 32-bit println(" movzbl %%si, %%ebx"); // Zero-extend to 32-bit println(" imul %%ebx, %%eax"); // Perform 32-bit multiplication println(" jo .L.overflowm%d", c); // Jump if overflow println(" mov %%al, (%%rdx)"); // Store result (8-bit) println(" mov $0, %%al"); println(" jmp .L.donem%d", c); // Jump to done } else if (size == 2) { // For 16-bit values (short) println(" movzwl %%di, %%eax"); // Zero-extend to 32-bit println(" movzwl %%si, %%ebx"); // Zero-extend to 32-bit println(" imul %%ebx, %%eax"); // Perform 32-bit multiplication println(" jo .L.overflowm%d", c); // Jump if overflow println(" mov %%ax, (%%rdx)"); // Store result (16-bit) println(" mov $0, %%ax"); println(" jmp .L.donem%d", c); // Jump to done } else if (size == 4) { // For 32-bit values (int) println(" mov %%edi, %%eax"); // Move to 32-bit println(" imul %%esi, %%eax"); // Perform 32-bit multiplication println(" jo .L.overflowm%d", c); // Jump if overflow println(" mov %%eax, (%%rdx)"); // Store result (32-bit) println(" mov $0, %%eax"); println(" jmp .L.donem%d", c); // Jump to done } else if (size == 8) { // For 64-bit values (long long) println(" mov %%rdi, %%rax"); // Move to 64-bit println(" imul %%rsi, %%rax"); // Perform 64-bit multiplication println(" jo .L.overflowm%d", c); // Jump if overflow println(" mov %%rax, (%%rdx)"); // Store result (64-bit) println(" mov $0, %%rax"); println(" jmp .L.donem%d", c); // Jump to done } // Overflow handling println(".L.overflowm%d:", c); println(" mov %%al, (%%rdx)"); // Store result println(" mov $1, %%rax"); // Set return value to 1 (overflow detected) println(".L.donem%d:", c); return; } case ND_UNREACHABLE: println(" // __builtin_unreachable: no code generation needed"); return; case ND_BUILTIN_ISNAN: { gen_expr(node->builtin_val); // Generate code for the expression if (node->builtin_val->ty->kind == TY_FLOAT) { // Use movss to move the float value and then compare println(" movss %%xmm0, %%xmm1"); println(" ucomiss %%xmm1, %%xmm1"); } else { // Use ucomisd for double println(" ucomisd %%xmm0, %%xmm0"); } println(" setp %%al"); println(" movzx %%al, %%eax"); return; } case ND_EXCH: { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); int sz = node->lhs->ty->base->size; println(" xchg %s, (%%rdi)", reg_ax(sz)); return; } case ND_EXCH_N: case ND_TESTANDSET: { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); println(" xchg %s, (%%rdi)", reg_ax(node->ty->size)); return; } case ND_CMPEXCH: gen_cmpxchg(node); return; case ND_CMPEXCH_N: gen_cmpxchgn(node); return; case ND_TESTANDSETA: { gen_expr(node->lhs); push(); println(" mov $1, %%eax"); pop("%rdi"); println(" xchg %s, (%%rdi)", reg_ax(node->ty->size)); return; } case ND_LOAD: { gen_expr(node->rhs); push(); gen_expr(node->lhs); println(" mov (%%rax), %s", reg_ax(node->ty->size)); pop("%rdi"); println(" mov %s, (%%rdi)", reg_ax(node->ty->size)); return; } case ND_LOAD_N: { gen_expr(node->lhs); println(" mov (%%rax), %s", reg_ax(node->ty->size)); if (node->memorder) { println(" mfence"); } return; } case ND_STORE: { gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); println(" mov (%%rax),%s", reg_ax(node->ty->size)); println(" mov %s, (%%rdi)", reg_ax(node->ty->size)); if (node->memorder) { println(" mfence"); } return; } case ND_STORE_N: gen_expr(node->lhs); push(); gen_expr(node->rhs); pop("%rdi"); println(" mov %s, (%%rdi)", reg_ax(node->ty->size)); if (node->memorder) { println(" mfence"); } return; case ND_CLEAR: gen_expr(node->lhs); println(" mov %%rax, %%rdi"); println(" xor %%eax, %%eax"); println(" mov %s, (%%rdi)", reg_ax(node->ty->size)); if (node->memorder) { println(" mfence"); } return; case ND_FETCHADD: gen_fetchadd(node); return; case ND_FETCHSUB: gen_fetchsub(node); return; case ND_FETCHXOR: HandleAtomicArithmetic(node, "xor"); return; case ND_FETCHAND: HandleAtomicArithmetic(node, "and"); return; case ND_FETCHOR: HandleAtomicArithmetic(node, "or"); return; case ND_SUBFETCH: gen_subfetch(node); return; case ND_RELEASE: gen_release(node); return; case ND_ALLOC: gen_alloc(node); return; case ND_BUILTIN_NANF: case ND_BUILTIN_HUGE_VALF: case ND_BUILTIN_INFF: { union { float f; uint32_t i; } u; u.f = node->fval; println(" mov $%u, %%eax", u.i); println(" movd %%eax, %%xmm0"); return; } case ND_BUILTIN_NAN: case ND_BUILTIN_HUGE_VAL: case ND_BUILTIN_INF: { union { double d; uint64_t i; } u; u.d = node->fval; println(" movq $%lu, %%rax", u.i); println(" movq %%rax, %%xmm0"); return; } case ND_BUILTIN_NANL: case ND_BUILTIN_HUGE_VALL: { union { long double ld; uint8_t bytes[10]; } u; u.ld = node->fval; for (int i = 0; i < 10; i++) println(" movb $%d, -%d(%%rsp)", u.bytes[i], 10 - i); println(" fldt -10(%%rsp)"); return; } case ND_EMMS: gen_single_binop("emms"); return; case ND_SFENCE: gen_single_binop("sfence"); return; case ND_LFENCE: gen_single_binop("lfence"); return; case ND_MFENCE: gen_single_binop("mfence"); return; case ND_PAUSE: gen_single_binop("pause"); return; case ND_STMXCSR: gen_stmxcsr(node); return; case ND_LDMXCSR: gen_single_addr_binop(node, "ldmxcsr"); return; case ND_SHUFPS: gen_shuf_binop(node, "shufps"); return; case ND_SHUFPD: gen_shuf_binop(node, "shufpd"); return; case ND_SHUFFLE: gen_shuffle(node, "shufps"); return; case ND_CVTPI2PS: gen_cvtpi2ps(node); return; case ND_CVTPS2PI: gen_cvt_mmx_binop3(node, "cvtps2pi"); return; case ND_CVTSS2SI: gen_sse_binop2(node, "cvtss2si", "eax", false); return; case ND_CVTSS2SI64: gen_cvt_binop(node, "cvtss2siq"); return; case ND_CVTTSS2SI: gen_cvt_binop(node, "cvttss2si"); return; case ND_CVTTSS2SI64: gen_cvt_binop(node, "cvttss2siq"); return; case ND_CVTTPS2PI: gen_cvt_mmx_binop(node, "cvttps2pi"); return; case ND_CVTSI2SS: gen_cvt_sse_binop2(node, "cvtsi2ss", "eax", false); return; case ND_CVTSI642SS: gen_cvt_sse_binop2(node, "cvtsi2ss", "rax", false); return; case ND_MOVLHPS: gen_sse_binop3(node, "movlhps", false); return; case ND_MOVHLPS: gen_sse_binop3(node, "movhlps", false); return; case ND_UNPCKHPS: gen_sse_binop3(node, "unpckhps", false); return; case ND_UNPCKLPS: gen_sse_binop3(node, "unpcklps", false); return; case ND_LOADHPS: gen_loadhps(node); return; case ND_STOREHPS: gen_store_binop(node, "movhps"); return; case ND_LOADLPS: gen_loadlps(node); return; case ND_STORELPS: gen_store_binop(node, "movlps"); return; case ND_MOVMSKPS: gen_sse_binop2(node, "movmskps", "eax", false); return; case ND_CLFLUSH: gen_single_addr_binop(node, "clflush"); return; case ND_VECINITV2SI: gen_vec_init_v2si(node); return; case ND_VECEXTV2SI: gen_vec_ext(node); return; case ND_VECEXTV4SI: gen_vec_ext(node); return; case ND_PACKSSWB: gen_mmx_binop(node, "packsswb", false); return; case ND_PACKSSDW: gen_mmx_binop(node, "packssdw", false); return; case ND_PACKUSWB: gen_mmx_binop(node, "packuswb", false); return; case ND_PUNPCKHBW: gen_mmx_binop(node, "punpckhbw", false); return; case ND_PUNPCKHWD: gen_mmx_binop(node, "punpckhwd", false); return; case ND_PUNPCKHDQ: gen_mmx_binop(node, "punpckhdq", false); return; case ND_PUNPCKLBW: gen_mmx_binop(node, "punpcklbw", false); return; case ND_PUNPCKLWD: gen_mmx_binop(node, "punpcklwd", false); return; case ND_PUNPCKLDQ: gen_mmx_binop(node, "punpckldq", false); return; case ND_PADDB: gen_mmx_binop(node, "paddb", false); return; case ND_PADDW: gen_mmx_binop(node, "paddw", false); return; case ND_PADDD: gen_mmx_binop(node, "paddd", false); return; case ND_PADDQ: gen_mmx_binop(node, "paddq", false); return; case ND_PADDSB: gen_mmx_binop(node, "paddsb", false); return; case ND_PADDSW: gen_mmx_binop(node, "paddsw", false); return; case ND_PADDUSB: gen_mmx_binop(node, "paddusb", false); return; case ND_PADDUSW: gen_mmx_binop(node, "paddusw", false); return; case ND_PSUBB: gen_mmx_binop(node, "psubb", false); return; case ND_PSUBW: gen_mmx_binop(node, "psubw", false); return; case ND_PSUBD: gen_mmx_binop(node, "psubd", false); return; case ND_PSUBQ: gen_mmx_binop(node, "psubq", false); return; case ND_PSUBSB: gen_mmx_binop(node, "psubsb", false); return; case ND_PSUBSW: gen_mmx_binop(node, "psubsw", false); return; case ND_PSUBUSB: gen_mmx_binop(node, "psubusb", false); return; case ND_PSUBUSW: gen_mmx_binop(node, "psubusw", false); return; case ND_PMADDWD: gen_mmx_binop(node, "pmaddwd", false); return; case ND_PMULHW: gen_mmx_binop(node, "pmulhw", false); return; case ND_PMULLW: gen_mmx_binop(node, "pmullw", false); return; case ND_PSLLW: gen_mmx_binop(node, "psllw", false); return; case ND_PSLLWI: gen_mmx_binop(node, "psllw", true); return; case ND_PSLLD: gen_mmx_binop(node, "pslld", false); return; case ND_PSLLDI: gen_mmx_binop(node, "pslld", true); return; case ND_PSLLQ: gen_mmx_binop(node, "psllq", false); return; case ND_PSLLQI: gen_mmx_binop(node, "psllq", true); return; case ND_PSRAW: gen_mmx_binop(node, "psraw", false); return; case ND_PSRAWI: gen_mmx_binop(node, "psraw", true); return; case ND_PSRAD: gen_mmx_binop(node, "psrad", false); return; case ND_PSRADI: gen_mmx_binop(node, "psrad", true); return; case ND_PSRLW: gen_mmx_binop(node, "psrlw", false); return; case ND_PSRLWI: gen_mmx_binop(node, "psrlw", true); return; case ND_PSRLD: gen_mmx_binop(node, "psrld", false); return; case ND_PSRLDI: gen_mmx_binop(node, "psrld", true); return; case ND_PSRLQ: gen_mmx_binop(node, "psrlq", false); return; case ND_PSRLQI: gen_mmx_binop(node, "psrlq", true); return; case ND_PAND: gen_mmx_binop(node, "pand", false); return; case ND_PANDN: gen_mmx_binop(node, "pandn", false); return; case ND_POR: gen_mmx_binop(node, "por", false); return; case ND_PXOR: gen_mmx_binop(node, "pxor", false); return; case ND_PCMPEQB: gen_mmx_binop(node, "pcmpeqb", false); return; case ND_PCMPGTB: gen_mmx_binop(node, "pcmpgtb", false); return; case ND_PCMPEQW: gen_mmx_binop(node, "pcmpeqw", false); return; case ND_PCMPGTW: gen_mmx_binop(node, "pcmpgtw", false); return; case ND_PCMPEQD: gen_mmx_binop(node, "pcmpeqd", false); return; case ND_PCMPGTD: gen_mmx_binop(node, "pcmpgtd", false); return; case ND_VECINITV4HI: gen_vec_init_binop(node, "pinsrw"); return; case ND_VECINITV8QI: gen_vec_init_binop(node, "pinsrb"); return; case ND_ADDSS: gen_sse_binop1(node, "addss", false); return; case ND_SUBSS: gen_sse_binop1(node, "subss", false); return; case ND_MULSS: gen_sse_binop1(node, "mulss", false); return; case ND_DIVSS: gen_sse_binop1(node, "divss", false); return; case ND_SQRTSS: gen_sse_binop2(node, "sqrtss", "xmm0", false); return; case ND_RCPSS: gen_sse_binop2(node, "rcpss", "xmm0", false); return; case ND_RSQRTSS: gen_sse_binop2(node, "rsqrtss", "xmm0", false); return; case ND_MINSS: gen_sse_binop1(node, "minss", false); return; case ND_MAXSS: gen_sse_binop1(node, "maxss", false); return; case ND_SQRTPS: gen_sse_binop2(node, "sqrtps", "xmm0", false); return; case ND_RCPPS: gen_sse_binop2(node, "rcpps", "xmm0", false); return; case ND_RSQRTPS: gen_sse_binop2(node, "rsqrtps", "xmm0", false); return; case ND_MINPS: gen_sse_binop3(node, "minps", false); return; case ND_MAXPS: gen_sse_binop3(node, "maxps", false); return; case ND_ANDPS: gen_sse_binop3(node, "andps", false); return; case ND_ANDNPS: gen_sse_binop3(node, "andnps", false); return; case ND_ORPS: gen_sse_binop3(node, "orps", false); return; case ND_XORPS: gen_sse_binop3(node, "xorps", false); return; case ND_CMPEQSS: gen_sse_binop3(node, "cmpeqss", false); return; case ND_CMPLTSS: gen_sse_binop3(node, "cmpltss", false); return; case ND_CMPLESS: gen_sse_binop3(node, "cmpless", false); return; case ND_MOVSS: gen_sse_binop3(node, "movss", false); return; case ND_CMPNEQSS: gen_sse_binop3(node, "cmpneqss", false); return; case ND_CMPNLTSS: gen_sse_binop3(node, "cmpnltss", false); return; case ND_CMPNLESS: gen_sse_binop3(node, "cmpnless", false); return; case ND_CMPORDSS: gen_sse_binop3(node, "cmpordss", false); return; case ND_CMPUNORDSS: gen_sse_binop3(node, "cmpunordss", false); return; case ND_CMPEQPS: gen_sse_binop3(node, "cmpeqps", false); return; case ND_CMPLTPS: gen_sse_binop3(node, "cmpltps", false); return; case ND_CMPLEPS: gen_sse_binop3(node, "cmpleps", false); return; case ND_CMPGTPS: gen_sse_binop3(node, "cmpps $0x6,", false); return; case ND_CMPGEPS: gen_sse_binop3(node, "cmpps $0xD,", false); return; case ND_CMPNEQPS: gen_sse_binop3(node, "cmpps $4,", false); return; case ND_CMPNLTPS: gen_sse_binop3(node, "cmpps $5,", false); return; case ND_CMPNLEPS: gen_sse_binop3(node, "cmpps $6,", false); return; case ND_CMPNGTPS: gen_sse_binop3(node, "cmpps $2,", false); return; case ND_CMPNGEPS: gen_sse_binop3(node, "cmpps $1,", false); return; case ND_CMPORDPS: gen_sse_binop3(node, "cmpordps", false); return; case ND_CMPUNORDPS: gen_sse_binop3(node, "cmpunordps", false); return; case ND_COMIEQ: gen_sse_binop4(node, "comiss", "sete"); return; case ND_COMILT: gen_sse_binop4(node, "comiss", "setb"); return; case ND_COMILE: gen_sse_binop4(node, "comiss", "setbe"); return; case ND_COMIGT: gen_sse_binop4(node, "comiss", "seta"); return; case ND_COMIGE: gen_sse_binop5(node, "comiss", "setae"); return; case ND_COMINEQ: gen_sse_binop4(node, "comiss", "setne"); return; case ND_UCOMIEQ: gen_sse_binop6(node, "comiss", "sete"); return; case ND_UCOMILT: gen_sse_binop6(node, "comiss", "setb"); return; case ND_UCOMILE: gen_sse_binop6(node, "ucomiss", "setbe"); return; case ND_UCOMIGT: gen_sse_binop5(node, "ucomiss", "seta"); return; case ND_UCOMIGE: gen_sse_binop5(node, "ucomiss", "setae"); return; case ND_UCOMINEQ: gen_sse_binop4(node, "ucomiss", "setne"); return; case ND_PMAXSW: gen_sse_binop7(node, "pmaxsw"); return; case ND_PMAXUB: gen_sse_binop7(node, "pmaxub"); return; case ND_PMINSW: gen_sse_binop7(node, "pminsw"); return; case ND_PMINUB: gen_sse_binop7(node, "pminub"); return; case ND_PMOVMSKB: gen_sse_binop8(node, "pmovmskb", "eax"); return; case ND_PMULHUW: gen_sse_binop9(node, "pmulhuw"); return; case ND_MASKMOVQ: gen_maskmovq(node); return; case ND_PAVGB: gen_mmx_binop(node, "pavgb", false); return; case ND_PAVGW: gen_mmx_binop(node, "pavgw", false); return; case ND_PSADBW: gen_mmx_binop(node, "psadbw", false); return; case ND_MOVNTQ: gen_sse_binop10(node, "movnti", "rax"); return; case ND_MOVNTPS: gen_sse_binop10(node, "movups", "xmm0"); return; case ND_ADDSD: gen_sse_binop3(node, "addsd", false); return; case ND_SUBSD: gen_sse_binop3(node, "subsd", false); return; case ND_MULSD: gen_sse_binop3(node, "mulsd", false); return; case ND_DIVSD: gen_sse_binop3(node, "divsd", false); return; case ND_SQRTPD: gen_sse_binop2(node, "sqrtpd", "xmm0", false); return; case ND_MOVSD: gen_sse_binop3(node, "movsd", false); return; case ND_SQRTSD: gen_sse_binop2(node, "sqrtsd", "xmm0", false); return; case ND_MINPD: gen_sse_binop3(node, "minpd", false); return; case ND_MINSD: gen_sse_binop3(node, "minsd", false); return; case ND_MAXPD: gen_sse_binop3(node, "maxpd", false); return; case ND_MAXSD: gen_sse_binop3(node, "maxsd", false); return; case ND_ANDPD: gen_sse_binop3(node, "andpd", false); return; case ND_ANDNPD: gen_sse_binop3(node, "andnpd", false); return; case ND_ORPD: gen_sse_binop3(node, "orpd", false); return; case ND_XORPD: gen_sse_binop3(node, "xorpd", false); return; case ND_CMPEQPD: gen_sse_binop3(node, "cmpeqpd", false); return; case ND_CMPLTPD: gen_sse_binop3(node, "cmpltpd", false); return; case ND_CMPLEPD: gen_sse_binop3(node, "cmplepd", false); return; case ND_CMPGTPD: gen_sse_binop3(node, "cmpnlepd", false); return; case ND_CMPGEPD: gen_sse_binop3(node, "cmpnltpd", false); return; case ND_CMPNEQPD: gen_sse_binop3(node, "cmpneqpd", false); return; case ND_CMPNLTPD: gen_sse_binop3(node, "cmpnltpd", false); return; case ND_CMPNLEPD: gen_sse_binop3(node, "cmpnlepd", false); return; case ND_CMPNGTPD: gen_sse_binop3(node, "cmplepd", false); return; case ND_CMPNGEPD: gen_sse_binop3(node, "cmpltpd", false); return; case ND_CMPORDPD: gen_sse_binop3(node, "cmpordpd", false); return; case ND_CMPUNORDPD: gen_sse_binop3(node, "cmpunordpd", false); return; case ND_CMPEQSD: gen_sse_binop3(node, "cmpeqsd", false); return; case ND_CMPLTSD: gen_sse_binop3(node, "cmpltsd", false); return; case ND_CMPLESD: gen_sse_binop3(node, "cmplesd", false); return; case ND_CMPNEQSD: gen_sse_binop3(node, "cmpneqsd", false); return; case ND_CMPNLTSD: gen_sse_binop3(node, "cmpnltsd", false); return; case ND_CMPNLESD: gen_sse_binop3(node, "cmpnlesd", false); return; case ND_CMPORDSD: gen_sse_binop3(node, "cmpordsd", false); return; case ND_CMPUNORDSD: gen_sse_binop3(node, "cmpunordsd", false); return; case ND_COMISDEQ: gen_sse_binop4(node, "comisd", "sete"); return; case ND_COMISDLT: gen_sse_binop4(node, "comisd", "setb"); return; case ND_COMISDLE: gen_sse_binop4(node, "comisd", "setbe"); return; case ND_COMISDGT: gen_sse_binop4(node, "comisd", "seta"); return; case ND_COMISDGE: gen_sse_binop4(node, "comisd", "setae"); return; case ND_COMISDNEQ: gen_sse_binop4(node, "comisd", "setne"); return; case ND_UCOMISDEQ: gen_sse_binop4(node, "ucomisd", "sete"); return; case ND_UCOMISDLT: gen_sse_binop4(node, "ucomisd", "setb"); return; case ND_UCOMISDLE: gen_sse_binop4(node, "ucomisd", "setbe"); return; case ND_UCOMISDGT: gen_sse_binop4(node, "ucomisd", "seta"); return; case ND_UCOMISDGE: gen_sse_binop4(node, "ucomisd", "setae"); return; case ND_UCOMISDNEQ: gen_sse_binop4(node, "ucomisd", "setne"); return; case ND_MOVQ128: gen_movq128(node); return; case ND_CVTDQ2PD: gen_sse_binop2(node, "cvtdq2pd", "xmm0", false); return; case ND_CVTDQ2PS: gen_sse_binop2(node, "cvtdq2ps", "xmm0", false); return; case ND_CVTPD2DQ: gen_sse_binop2(node, "cvtpd2dq", "xmm0", false); return; case ND_CVTPD2PI: gen_cvt_mmx_binop3(node, "cvtpd2pi"); return; case ND_CVTPD2PS: gen_sse_binop2(node, "cvtpd2ps", "xmm0", false); return; case ND_CVTTPD2DQ: gen_sse_binop2(node, "cvttpd2dq", "xmm0", false); return; case ND_CVTTPD2PI: gen_cvt_mmx_binop3(node, "cvttpd2pi"); return; case ND_CVTPI2PD: gen_cvt_mmx_binop4(node, "cvtpi2pd"); return; case ND_CVTPS2DQ: gen_sse_binop2(node, "cvtps2dq", "xmm0", false); return; case ND_CVTTPS2DQ: gen_sse_binop2(node, "cvttps2dq", "xmm0", false); return; case ND_CVTPS2PD: gen_sse_binop2(node, "cvtps2pd", "xmm0", false); return; case ND_CVTSD2SI: gen_sse_binop2(node, "cvtsd2si", "eax", false); return; case ND_CVTSD2SI64: gen_sse_binop2(node, "cvtsd2siq", "rax", false); return; case ND_CVTTSD2SI: gen_sse_binop2(node, "cvttsd2si", "eax", false); return; case ND_CVTTSD2SI64: gen_sse_binop2(node, "cvttsd2siq", "rax", false); return; case ND_CVTSD2SS: gen_sse_binop3(node, "cvtsd2ss", false); return; case ND_CVTSI2SD: gen_sse_binop11(node, "cvtsi2sd", "rax"); return; case ND_CVTSI642SD: gen_sse_binop11(node, "cvtsi2sdq", "rax"); return; case ND_CVTSS2SD: gen_sse_binop3(node, "cvtss2sd", false); return; case ND_UNPCKHPD: gen_sse_binop3(node, "unpckhpd", false); return; case ND_UNPCKLPD: gen_sse_binop3(node, "unpcklpd", false); return; case ND_LOADHPD: gen_cvt_sse_binop2(node, "movhpd", "rax", true); return; case ND_LOADLPD: gen_cvt_sse_binop2(node, "movlpd", "rax", true); return; case ND_MOVMSKPD: gen_sse_binop2(node, "movmskpd", "rax", false); return; case ND_PACKSSWB128: gen_packss128_binop(node, "packsswb"); return; case ND_PACKSSDW128: gen_packss128_binop(node, "packssdw"); return; case ND_PACKUSWB128: gen_packss128_binop(node, "packuswb"); return; case ND_PUNPCKHBW128: gen_packss128_binop(node, "punpckhbw"); return; case ND_PUNPCKHWD128: gen_packss128_binop(node, "punpckhwd"); return; case ND_PUNPCKHDQ128: gen_packss128_binop(node, "punpckhdq"); return; case ND_PUNPCKHQDQ128: gen_packss128_binop(node, "punpckhqdq"); return; case ND_PUNPCKLBW128: gen_packss128_binop(node, "punpcklbw"); return; case ND_PUNPCKLWD128: gen_packss128_binop(node, "punpcklwd"); return; case ND_PUNPCKLDQ128: gen_packss128_binop(node, "punpckldq"); return; case ND_PUNPCKLQDQ128: gen_packss128_binop(node, "punpcklqdq"); return; case ND_PADDSB128: gen_sse_binop3(node, "paddsb", false); return; case ND_PADDSW128: gen_sse_binop3(node, "paddsw", false); return; case ND_PADDUSB128: gen_sse_binop3(node, "paddusb", false); return; case ND_PADDUSW128: gen_sse_binop3(node, "paddusw", false); return; case ND_PSUBSB128: gen_sse_binop3(node, "psubsb", false); return; case ND_PSUBSW128: gen_sse_binop3(node, "psubsw", false); return; case ND_PSUBUSB128: gen_sse_binop3(node, "psubusb", false); return; case ND_PSUBUSW128: gen_sse_binop3(node, "psubusw", false); return; case ND_PMADDWD128: gen_sse_binop3(node, "pmaddwd", false); return; case ND_PMULHW128: gen_sse_binop3(node, "pmulhw", false); return; case ND_PMULUDQ: case ND_PMULUDQ128: gen_sse_binop3(node, "pmuludq", false); return; case ND_PSLLWI128: gen_psll_binop(node, "psllw"); return; case ND_PSLLDI128: gen_psll_binop(node, "pslld"); return; case ND_PSLLQI128: gen_psll_binop(node, "psllq"); return; case ND_PSRAWI128: gen_psll_binop(node, "psraw"); return; case ND_PSRADI128: gen_psll_binop(node, "psrad"); return; case ND_PSRLWI128: gen_psll_binop(node, "psrlw"); return; case ND_PSRLDI128: gen_psll_binop(node, "psrld"); return; case ND_PSRLQI128: gen_psll_binop(node, "psrlq"); return; case ND_PSLLW128:gen_sse_binop3(node, "psllw", false); return; case ND_PSLLD128:gen_sse_binop3(node, "pslld", false); return; case ND_PSLLQ128:gen_sse_binop3(node, "psllq", false); return; case ND_PSRAW128:gen_sse_binop3(node, "psraw", false); return; case ND_PSRAD128:gen_sse_binop3(node, "psrad", false); return; case ND_PSRLW128:gen_sse_binop3(node, "psrlw", false); return; case ND_PSRLD128:gen_sse_binop3(node, "psrld", false); return; case ND_PSRLQ128:gen_sse_binop3(node, "psrlq", false); return; case ND_PANDN128:gen_sse_binop3(node, "pandn", false); return; case ND_PMAXSW128:gen_sse_binop3(node, "pmaxsw", false); return; case ND_PMAXUB128:gen_sse_binop3(node, "pmaxub", false); return; case ND_PMINSW128:gen_sse_binop3(node, "pminsw", false); return; case ND_PMINUB128:gen_sse_binop3(node, "pminub", false); return; case ND_PMOVMSKB128: gen_sse_binop2(node, "pmovmskb", "eax", false); return; case ND_PMULHUW128: gen_sse_binop9(node, "pmulhuw"); return; case ND_MASKMOVDQU: gen_maskmovdqu(node); return; case ND_PAVGB128:gen_sse_binop3(node, "pavgb", false); return; case ND_PAVGW128:gen_sse_binop3(node, "pavgw", false); return; case ND_PSADBW128:gen_sse_binop3(node, "psadbw", false); return; case ND_MOVNTI: gen_movnti(node); return; case ND_MOVNTI64: gen_movnti64(node); return; case ND_MOVNTDQ: gen_movnt_binop(node, "movntdq"); return; case ND_MOVNTPD: gen_movnt_binop(node, "movntpd"); return; case ND_PARITYL: case ND_PARITYLL: case ND_PARITY: gen_parity(node); return; } if (is_vector(node->lhs->ty) || (node->rhs && is_vector(node->rhs->ty))) { gen_vector_op(node); return; } //managing INT128 if (is_int128(node->lhs->ty)) { gen_int128_op(node); return; } switch (node->lhs->ty->kind) { case TY_FLOAT: case TY_DOUBLE: { gen_expr(node->rhs); pushf(); gen_expr(node->lhs); popf(1); char *sz = (node->lhs->ty->kind == TY_FLOAT) ? "ss" : "sd"; switch (node->kind) { case ND_ADD: println(" add%s %%xmm1, %%xmm0", sz); return; case ND_SUB: println(" sub%s %%xmm1, %%xmm0", sz); return; case ND_MUL: println(" mul%s %%xmm1, %%xmm0", sz); return; case ND_DIV: println(" div%s %%xmm1, %%xmm0", sz); return; case ND_EQ: case ND_NE: case ND_LT: case ND_LE: println(" ucomi%s %%xmm0, %%xmm1", sz); if (node->kind == ND_EQ) { println(" sete %%al"); println(" setnp %%dl"); println(" and %%dl, %%al"); } else if (node->kind == ND_NE) { println(" setne %%al"); println(" setp %%dl"); println(" or %%dl, %%al"); } else if (node->kind == ND_LT) { println(" seta %%al"); } else { println(" setae %%al"); } println(" and $1, %%al"); println(" movzb %%al, %%rax"); return; } error_tok(node->tok, "%s invalid expression", CODEGEN_C); } case TY_LDOUBLE: { gen_expr(node->lhs); gen_expr(node->rhs); switch (node->kind) { case ND_ADD: println(" faddp"); return; case ND_SUB: println(" fsubrp"); return; case ND_MUL: println(" fmulp"); return; case ND_DIV: println(" fdivrp"); return; case ND_EQ: case ND_NE: case ND_LT: case ND_LE: println(" fcomip"); println(" fstp %%st(0)"); if (node->kind == ND_EQ) println(" sete %%al"); else if (node->kind == ND_NE) println(" setne %%al"); else if (node->kind == ND_LT) println(" seta %%al"); else println(" setae %%al"); println(" movzb %%al, %%rax"); return; } error_tok(node->tok, "%s invalid expression", CODEGEN_C); } } if (!is_int128(node->rhs->ty)) { gen_expr(node->rhs); push(); gen_expr(node->lhs); pop("%rdi"); } char *ax, *di, *dx; if (node->lhs->ty->size == 8 || node->lhs->ty->base) { ax = "%rax"; di = "%rdi"; dx = "%rdx"; } else { ax = "%eax"; di = "%edi"; dx = "%edx"; } switch (node->kind) { case ND_ADD: if (node->lhs->ty->kind == TY_INT128) { println(" add %%rdi, %%rax"); println(" adc %%rsi, %%rdx"); } else { println(" add %s, %s", di, ax); } return; case ND_SUB: println(" sub %s, %s", di, ax); return; case ND_MUL: println(" imul %s, %s", di, ax); return; case ND_DIV: case ND_MOD: if (node->ty->is_unsigned) { println(" mov $0, %s", dx); println(" div %s", di); } else { if (node->lhs->ty->size == 8) println(" cqo"); else println(" cdq"); println(" idiv %s", di); } if (node->kind == ND_MOD) println(" mov %%rdx, %%rax"); return; case ND_BITAND: println(" and %s, %s", di, ax); return; case ND_BITOR: println(" or %s, %s", di, ax); return; case ND_BITXOR: println(" xor %s, %s", di, ax); return; case ND_EQ: case ND_NE: case ND_LT: case ND_LE: println(" cmp %s, %s", di, ax); if (node->kind == ND_EQ) { println(" sete %%al"); } else if (node->kind == ND_NE) { println(" setne %%al"); } else if (node->kind == ND_LT) { if (node->lhs->ty->is_unsigned) println(" setb %%al"); else println(" setl %%al"); } else if (node->kind == ND_LE) { if (node->lhs->ty->is_unsigned) println(" setbe %%al"); else println(" setle %%al"); } println(" movzb %%al, %%rax"); return; case ND_SHL: println(" mov %%rdi, %%rcx"); println(" shl %%cl, %s", ax); return; case ND_SHR: println(" mov %%rdi, %%rcx"); if (node->lhs->ty->is_unsigned) println(" shr %%cl, %s", ax); else println(" sar %%cl, %s", ax); return; } error_tok(node->tok, "%s invalid expression", CODEGEN_C); } static void gen_stmt(Node *node) { if (!node) error("%s: %s:%d: error: in gen_stmt : node is null!", CODEGEN_C, __FILE__, __LINE__); if (node->tok && node->tok->line_no != last_loc_line) { println(" .loc %d %u", node->tok->file->file_no, node->tok->line_no); last_loc_line = node->tok->line_no; } switch (node->kind) { case ND_IF: { int c = count(); gen_expr(node->cond); cmp_zero(node->cond->ty); println(" je .L.else.%d", c); gen_stmt(node->then); println(" jmp .L.end.%d", c); println(".L.else.%d:", c); if (node->els) gen_stmt(node->els); println(".L.end.%d:", c); return; } case ND_FOR: { int c = count(); if (node->init) gen_stmt(node->init); println(".L.begin.%d:", c); if (node->cond) { gen_expr(node->cond); cmp_zero(node->cond->ty); println(" je %s", node->brk_label); } gen_stmt(node->then); println("%s:", node->cont_label); if (node->inc) gen_expr(node->inc); println(" jmp .L.begin.%d", c); println("%s:", node->brk_label); return; } case ND_DO: { int c = count(); println(".L.begin.%d:", c); gen_stmt(node->then); println("%s:", node->cont_label); gen_expr(node->cond); cmp_zero(node->cond->ty); println(" jne .L.begin.%d", c); println("%s:", node->brk_label); return; } case ND_SWITCH: gen_expr(node->cond); for (Node *n = node->case_next; n; n = n->case_next) { char *ax, *di, *dx; if (node->cond->ty->size == 8) { ax = "%rax"; di = "%rdi"; dx = "%rdx"; } else { ax = "%eax"; di = "%edi"; dx = "%edx"; } if (n->begin == n->end) { println(" mov $%ld, %s", n->begin, dx); println(" cmp %s, %s", dx, ax); println(" je %s", n->label); continue; } // [GNU] Case ranges println(" mov %s, %s", ax, di); println(" mov $%ld, %s", n->begin, dx); println(" sub %s, %s", dx, di); println(" mov $%ld, %s", n->end - n->begin, dx); println(" cmp %s, %s", dx, di); println(" jbe %s", n->label); } if (node->default_case) println(" jmp %s", node->default_case->label); println(" jmp %s", node->brk_label); gen_stmt(node->then); println("%s:", node->brk_label); return; case ND_CASE: println("%s:", node->label); if (node->lhs) gen_stmt(node->lhs); return; case ND_BLOCK: for (Node *n = node->body; n; n = n->next) gen_stmt(n); return; case ND_GOTO: println(" jmp %s", node->unique_label); return; case ND_GOTO_EXPR: gen_expr(node->lhs); println(" jmp *%%rax"); return; case ND_LABEL: println("%s:", node->unique_label); if (node->lhs) gen_stmt(node->lhs); return; case ND_RETURN: if (node->lhs) { gen_expr(node->lhs); Type *ty = node->lhs->ty; switch (ty->kind) { case TY_STRUCT: case TY_UNION: if (ty->size <= 16) copy_struct_reg(); else copy_struct_mem(); break; } } println(" jmp .L.return.%s", current_fn->name); return; case ND_EXPR_STMT: gen_expr(node->lhs); return; case ND_ASM: println(" %s", node->asm_str); return; } error_tok(node->tok, "%s invalid statement", CODEGEN_C); } static void emit_data(Obj *prog) { for (Obj *var = prog; var; var = var->next) { //issue 35 about array not initialized completely. if (var->ty->size != 0) println(" .zero %d", abs(var->ty->size)); if (var->alias_name) println(" .set \"%s\", %s", var->name, var->alias_name); if (var->is_weak) println(" .weak \"%s\"", var->name); if (var->is_function || !var->is_definition) continue; print_visibility(var); // if (var->is_static) // println(" .local %s", var->name); // else if (var->ty->is_weak) // println(" .weak \"%s\"", var->name); // else // println(" .globl %s", var->name); int align = (var->ty->kind == TY_ARRAY && var->ty->size >= 16) ? MAX(16, var->align) : var->align; // Common symbol if (opt_fcommon && var->is_tentative && !var->is_tls && !var->section && !var->is_static) { //from @fuhsnn incomplete array assuming to have one element if (var->ty->kind == TY_ARRAY && var->ty->size < 0) var->ty->size = var->ty->base->size; println(" .comm %s, %d, %d", var->name, var->ty->size, align); continue; } // .data or .tdata if (var->init_data) { //from cosmopolitan if (var->section) { println(" .section %s,\"aw\",@progbits", var->section); } else if (var->is_tls) println(" .section .tdata,\"awT\",@progbits"); else println(" .section .data,\"aw\",@progbits"); println(" .type %s, @object", var->name); println(" .size %s, %d", var->name, abs(var->ty->size)); if (align > 1) println(" .align %d", align); println("%s:", var->name); Relocation *rel = var->rel; int unit_size = (var->ty->kind == TY_ARRAY) ? var->ty->base->size : var->ty->size; int pos = 0; while (pos < var->ty->size) { if (rel && rel->offset == pos) { if (var->is_function) { println(" .long %s - . + %ld", *rel->label, rel->addend); } else if (!var->is_extern) { println(" .quad %s%+ld", *rel->label, rel->addend); } rel = rel->next; pos += 8; } else { //from @enh (Elliott Hughes) Use .byte/.short/.long/.quad as appropriate. //println(" .byte %d", var->init_data[pos++]); if (unit_size == 8) { long v = *(long*) &var->init_data[pos]; println(" .quad %ld # %#lx", v, v); pos += 8; } else if (unit_size == 4) { int v = *(int*) &var->init_data[pos]; println(" .long %d # %#x", v, v); pos += 4; } else if (unit_size == 2) { int v = *(short*) &var->init_data[pos] & 0xffff; println(" .short %d # %#x", v, v); pos += 2; } else { int v = var->init_data[pos] & 0xff; println(" .byte %d # %#x", v, v); pos += 1; } } } println(" .size %s, %d", var->name, var->ty->size); continue; } if (var->section) { println(" .section %s,\"aw\",@nobits", var->section); } else if (var->is_tls) println(" .section .tbss,\"awT\",@nobits"); else println(" .section .bss,\"aw\",@nobits"); if (align > 1) println(" .align %d", align); println("%s:", var->name); if (var->ty->size != 0) println(" .zero %d", abs(var->ty->size)); } } static void store_fp(int r, int offset, int sz) { switch (sz) { case 0: // No operation for size 0 return; case 2: // movw is used for 2-byte (16-bit) words println(" movw %%xmm%d, %d(%%rbp)", r, offset); return; case 4: println(" movss %%xmm%d, %d(%%rbp)", r, offset); return; case 8: println(" movsd %%xmm%d, %d(%%rbp)", r, offset); return; case 16: println(" movups %%xmm%d, %d(%%rbp)", r, offset); // movaps for 16-byte (128-bit) vector return; } printf("===== r=%d offset=%d sz=%d\n", r, offset, sz); unreachable(); } static void store_gp(int r, int offset, int sz) { switch (sz) { case 0: // No operation for size 0 return; case 1: println(" mov %s, %d(%%rbp)", argreg8[r], offset); return; case 2: println(" mov %s, %d(%%rbp)", argreg16[r], offset); return; case 4: println(" mov %s, %d(%%rbp)", argreg32[r], offset); return; case 8: println(" mov %s, %d(%%rbp)", argreg64[r], offset); return; case 16: // Assuming we can use xmm registers to store 128 bits println(" movdqu %%xmm%d, %d(%%rbp)", r, offset); return; default: for (int i = 0; i < sz; i++) { println(" mov %s, %d(%%rbp)", argreg8[r], offset + i); println(" shr $8, %s", argreg64[r]); } return; } } static void emit_text(Obj *prog) { // First pass: collect constructor/destructor attributes for (Obj *fn = prog; fn; fn = fn->next) { if (!fn->is_function || !fn->is_definition) continue; if (fn->is_constructor || fn->ty->is_constructor) { int priority = fn->constructor_priority > fn->ty->constructor_priority ? fn->constructor_priority : fn->ty->constructor_priority; if (priority < 0 || priority > 65535) priority = 65535; CtorFunc *f = calloc(1, sizeof(CtorFunc)); f->name = fn->name; f->priority = priority; constructors[constructor_cnt++] = f; } // Combine destructor flags and pick max priority if (fn->is_destructor || fn->ty->is_destructor) { int priority = fn->destructor_priority > fn->ty->destructor_priority ? fn->destructor_priority : fn->ty->destructor_priority; if (priority < 0 || priority > 65535) priority = 65535; CtorFunc *f = calloc(1, sizeof(CtorFunc)); f->name = fn->name; f->priority = priority; destructors[destructor_cnt++] = f; } } for (Obj *fn = prog; fn; fn = fn->next) { // Emit alias if fn->alias_name is set if (fn->alias_name) { // Handle weak alias println(" .weak %s", fn->name); // Mark the function as weak println(" .set %s, %s", fn->name, fn->alias_name); // Define alias } if (!fn->is_function || !fn->is_definition) continue; // No code is emitted for "static inline" functions // if no one is referencing them. if (!fn->is_live) continue; if (fn->is_static) println(" .local %s", fn->name); else println(" .globl %s", fn->name); // Respect section attribute if set if (fn->section) println(" .section %s,\"ax\",@progbits", fn->section); else println(" .section .text,\"ax\",@progbits"); //println(" .text"); //println("\n .section .text,\"ax\",@progbits"); println(" .type %s, @function", fn->name); println("%s:", fn->name); current_fn = fn; // Prologue println(" push %%rbp"); println(" mov %%rsp, %%rbp"); println(" sub $%d, %%rsp", fn->stack_size); println(" mov %%rsp, %d(%%rbp)", fn->alloca_bottom->offset); // Save arg registers if function is variadic if (fn->va_area) { int gp = 0, fp = 0; for (Obj *var = fn->params; var; var = var->next) { Type *ty = var->ty; if (!ty) error("%s %d: in emit_text : type is null!", CODEGEN_C, __LINE__); switch (ty->kind) { case TY_STRUCT: case TY_UNION: if (ty->size == 0) continue; if (!pass_by_reg(ty, gp, fp)) continue; if (has_flonum1(ty)) fp++; else gp++; if (ty->size > 8) { if (has_flonum2(ty)) fp++; else gp++; } continue; case TY_VECTOR: case TY_FLOAT: case TY_DOUBLE: if (fp < FP_MAX) fp++; continue; case TY_LDOUBLE: continue; case TY_INT128: if (gp + 1 < FP_MAX) { gp++; gp++; } continue; default: if (gp < GP_MAX) gp++; } } int off = fn->va_area->offset; // va_elem println(" movl $%d, %d(%%rbp)", gp * 8, off); // gp_offset println(" movl $%d, %d(%%rbp)", fp * 16 + 48, off + 4); // fp_offset println(" movq %%rbp, %d(%%rbp)", off + 8); // overflow_arg_area //println(" addq $16, %d(%%rbp)", off + 8); println(" addq $%d, %d(%%rbp)", fn->overflow_arg_area, off + 8); println(" movq %%rbp, %d(%%rbp)", off + 16); // reg_save_area println(" addq $%d, %d(%%rbp)", off + 24, off + 16); // __reg_save_area__ println(" movq %%rdi, %d(%%rbp)", off + 24); println(" movq %%rsi, %d(%%rbp)", off + 32); println(" movq %%rdx, %d(%%rbp)", off + 40); println(" movq %%rcx, %d(%%rbp)", off + 48); println(" movq %%r8, %d(%%rbp)", off + 56); println(" movq %%r9, %d(%%rbp)", off + 64); println(" movsd %%xmm0, %d(%%rbp)", off + 72); println(" movsd %%xmm1, %d(%%rbp)", off + 88); println(" movsd %%xmm2, %d(%%rbp)", off + 104); println(" movsd %%xmm3, %d(%%rbp)", off + 120); println(" movsd %%xmm4, %d(%%rbp)", off + 136); println(" movsd %%xmm5, %d(%%rbp)", off + 152); println(" movsd %%xmm6, %d(%%rbp)", off + 168); println(" movsd %%xmm7, %d(%%rbp)", off + 184); } // Save passed-by-register arguments to the stack int gp = 0, fp = 0; for (Obj *var = fn->params; var; var = var->next) { // if (var->offset > 0) // continue; if (var->pass_by_stack) continue; Type *ty = var->ty; if (!ty) error("%s %d: in emit_text : type is null!", CODEGEN_C, __LINE__); switch (ty->kind) { case TY_VECTOR: if (ty->base->kind == TY_FLOAT || ty->base->kind == TY_DOUBLE) { store_fp(fp++, var->offset, ty->size); } else if (is_integer(ty->base)) { store_fp(fp++, var->offset, ty->size); } else { error("%s %d: in emit_text : Unsupported vector base type", CODEGEN_C, __LINE__); } break; case TY_STRUCT: case TY_UNION: assert(ty->size <= 16); if (has_flonum(ty, 0, 8, 0)) store_fp(fp++, var->offset, MIN(8, ty->size)); else store_gp(gp++, var->offset, MIN(8, ty->size)); if (ty->size > 8) { if (has_flonum(ty, 8, 16, 0)) store_fp(fp++, var->offset + 8, ty->size - 8); else store_gp(gp++, var->offset + 8, ty->size - 8); } break; case TY_FLOAT: case TY_DOUBLE: store_fp(fp++, var->offset, ty->size); break; case TY_INT128: store_gp(gp++, var->offset + 0, 8); store_gp(gp++, var->offset + 8, 8); break; default: store_gp(gp++, var->offset, ty->size); } } // Emit code gen_stmt(fn->body); assert(depth == 0); // [https://www.sigbus.info/n1570#5.1.2.2.3p1] The C spec defines // a special rule for the main function. Reaching the end of the // main function is equivalent to returning 0, even though the // behavior is undefined for the other functions. if (strcmp(fn->name, "main") == 0) { println(" mov $0, %%rax"); } // Epilogue println(".L.return.%s:", fn->name); println(" mov %%rbp, %%rsp"); println(" pop %%rbp"); println(" ret"); println(" .size %s, .-%s", fn->name, fn->name); } emit_constructors(); emit_destructors(); } void codegen(Obj *prog, FILE *out) { output_file = out; File **files = get_input_files(); for (int i = 0; files[i]; i++) println(" .file %d \"%s\"", files[i]->file_no, files[i]->name); assign_lvar_offsets(prog); emit_data(prog); emit_text(prog); println(" .section .note.GNU-stack,\"\",@progbits"); //print offset for each variable if (isDebug) print_offset(prog); } // Print offset. static void print_offset(Obj *prog) { for (Obj *fn = prog; fn; fn = fn->next) { for (Obj *var = fn->params; var; var = var->next) { printf("=====fn_name=%s var_name=%s offset=%d stack_size=%d\n", fn->name, var->name, var->offset, fn->stack_size ); } for (Obj *var = fn->locals; var; var = var->next) { printf("=====fn_name=%s var_name=%s offset=%d stack_size=%d\n", fn->name, var->name, var->offset, fn->stack_size ); //update the function name if it's missing if (!var->funcname) var->funcname = fn->name; } } } void assign_lvar_offsets(Obj *prog) { for (Obj *fn = prog; fn; fn = fn->next) { if (!fn->is_function) continue; // If a function has many parameters, some parameters are // inevitably passed by stack rather than by register. // The first passed-by-stack parameter resides at RBP+16. int top = 16; int bottom = 0; int max_align = 8; //trying to fix =====ISS-149 causing segmentation fault when having assembly instructions if (fn->alloca_bottom && fn->alloca_bottom->offset) bottom = abs(fn->alloca_bottom->offset); int gp = 0, fp = 0; bool is_variadic = fn->ty->is_variadic; // Assign offsets to pass-by-stack parameters. for (Obj *var = fn->params; var; var = var->next) { if (var->offset) { continue; } Type *ty = var->ty; if (!ty) error("%s %d: in assign_lvar_offsets : type is null!", CODEGEN_C, __LINE__); switch (ty->kind) { case TY_STRUCT: case TY_UNION: if (pass_by_reg(ty, gp, fp)) { fp += has_flonum1(ty) + (ty->size > 8 && has_flonum2(ty)); gp += !has_flonum1(ty) + (ty->size > 8 && !has_flonum2(ty)); continue; } break; case TY_VECTOR: case TY_FLOAT: case TY_DOUBLE: if (fp < FP_MAX) { fp++; continue; } break; case TY_LDOUBLE: break; case TY_INT128: if (gp + 1 < GP_MAX) { gp++; gp++; continue; } break; default: if (gp++ < GP_MAX) continue; } var->pass_by_stack = true; if (var->ty->align > max_align) max_align = var->ty->align; top = align_to(top, 8); var->offset = top; top += var->ty->size; } if (is_variadic) fn->overflow_arg_area = align_to(top, max_align); //fn->overflow_arg_area = align_to(top, 8); // Assign offsets to pass-by-register parameters and local variables. for (Obj *var = fn->locals; var; var = var->next) { int align = ((var->ty->kind == TY_ARRAY && var->ty->size >= 16) || is_vector(var->ty) || var->ty->kind == TY_INT128) ? MAX(16, var->align) : var->align; // if (isDebug) // printf("======bottom=%d kind=%d size=%d fn_bottom=%d fn_stack_size=%d name=%s funcname=%s\n", bottom, var->ty->kind, var->ty->size, fn->alloca_bottom->offset, fn->alloca_bottom->stack_size, var->name, var->funcname); //trying to fix ISS-154 Extended assembly compiled with chibicc failed with ASSERT and works fine without assert function //the bottom value need to take in account the size of parameters and local variables to avoid issue with extended assembly if (var->offset) { bottom += var->ty->size; bottom = align_to(bottom, align); continue; } // AMD64 System V ABI has a special alignment rule for an array of // length at least 16 bytes. We need to align such array to at least // 16-byte boundaries. See p.14 of // https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-draft.pdf. bottom += var->ty->size; bottom = align_to(bottom, align); var->offset = -bottom; } fn->stack_size = align_to(bottom, 16); } } //check if a register is available char *register_available() { int len = sizeof(newargreg64)/sizeof(newargreg64[0]); int i; for(i = 0; i < len; ++i) { //register already used bool isFound = check_register_used(newargreg64[i]); if (isFound) continue; else { add_register_used(newargreg64[i]); return newargreg64[i]; } } //no registry available error("%s: %s:%d: error: in register_available : no register available!", CODEGEN_C, __FILE__, __LINE__); } //check if a specific register is available in priority if not try to found a new available char *specific_register_available(char *regist) { int found = check_register_used(regist); if (!found) { add_register_used(regist); return regist; } return register_available(); } //convert register 8 to register 64 char *register8_to_64(char *regist) { int len = sizeof(newargreg8)/sizeof(newargreg8[0]); int i; for(i = 0; i < len; ++i) { if(!strncmp(newargreg8[i], regist, strlen(regist))) { return newargreg64[i]; } } error("%s: %s:%d: error: in register8_to_64 : unexpected error!", CODEGEN_C, __FILE__, __LINE__); } //convert register 16 to register 64 char *register16_to_64(char *regist) { int len = sizeof(newargreg16)/sizeof(newargreg16[0]); int i; for(i = 0; i < len; ++i) { if(!strncmp(newargreg16[i], regist, strlen(regist))) { return newargreg64[i]; } } error("%s: %s:%d: error: in register16_to_64 : unexpected error!", CODEGEN_C, __FILE__, __LINE__); } //convert register 32 to register 64 char *register32_to_64(char *regist) { int len = sizeof(newargreg32)/sizeof(newargreg32[0]); int i; for(i = 0; i < len; ++i) { if(!strncmp(newargreg32[i], regist, strlen(regist))) { return newargreg64[i]; } } error("%s: %s:%d: error: in register32_to_64 : unexpected error!", CODEGEN_C, __FILE__, __LINE__); } //add a register in the list of used registers int add_register_used(char *regist) { int len = sizeof(registerUsed)/sizeof(registerUsed[0]); int i; char *tmp = "free"; for(i = 0; i < len; ++i) { if (!strncmp(registerUsed[i], tmp, strlen(registerUsed[i]))) { registerUsed[i] = regist; return i; } } //no free location return -1; } //check if register used return 0 if not used bool check_register_used(char *regist) { int isFound = false; int len = sizeof(registerUsed)/sizeof(registerUsed[0]); int i; for(i = 0; i < len; ++i) { if(!strncmp(registerUsed[i], regist, strlen(regist))) { isFound = true; return isFound; } } //not found return isFound; } //clear the registerUseds void clear_register_used() { int len = sizeof(registerUsed)/sizeof(registerUsed[0]); int i; for(i = 0; i < len; ++i) { registerUsed[i] = "free"; } } //check if a register8 is used in a template //if yes retrieve the register64 and add it in the registerUsed array //if not check if a register 16 is found in a template void check_register_in_template(char *template) { int len = sizeof(newargreg64)/sizeof(newargreg64[0]); //check if register 64 found in template and mark it as used for(int i = 0; i < len; ++i) { if (strstr(template, newargreg64[i]) != NULL) add_register_used(newargreg64[i]); } //check if register 32 found in template and mark it as used len = sizeof(newargreg32)/sizeof(newargreg32[0]); for(int i = 0; i < len; ++i) { if (strstr(template, newargreg32[i]) != NULL) add_register_used(register32_to_64(newargreg32[i])); } //check if register 16 found in template and mark it as used len = sizeof(newargreg16)/sizeof(newargreg16[0]); for(int i = 0; i < len; ++i) { if (strstr(template, newargreg16[i]) != NULL) add_register_used(register16_to_64(newargreg16[i])); } //check if register 8 found in template and mark it as used len = sizeof(newargreg8)/sizeof(newargreg8[0]); for(int i = 0; i < len; ++i) { if (strstr(template, newargreg8[i]) != NULL) add_register_used(register8_to_64(newargreg8[i])); } } static int cmp_ctor(const void *a, const void *b) { return (*(CtorFunc **)a)->priority - (*(CtorFunc **)b)->priority; } static void emit_constructors(void) { if (constructor_cnt == 0) return; qsort(constructors, constructor_cnt, sizeof(CtorFunc *), cmp_ctor); println(" .section .init_array,\"aw\",@init_array"); println(" .p2align 3"); for (int i = 0; i < constructor_cnt; i++) { println(" .quad %s", constructors[i]->name); } println(" .text"); } static void emit_destructors(void) { if (destructor_cnt == 0) return; qsort(destructors, destructor_cnt, sizeof(CtorFunc *), cmp_ctor); println(" .section .fini_array,\"aw\",@fini_array"); println(" .p2align 3"); for (int i = 0; i < destructor_cnt; i++) { println(" .quad %s", destructors[i]->name); } println(" .text"); }chibicc-1.0.23.1/compare.txt000066400000000000000000000000001505335450300155000ustar00rootroot00000000000000chibicc-1.0.23.1/debug.c000077500000000000000000000034531505335450300145650ustar00rootroot00000000000000#include "chibicc.h" #define DEBUG_C "debug.c" // for debug needs char *tokenkind2str(TokenKind kind) { switch (kind) { case TK_IDENT: return "TK_IDENT"; case TK_PUNCT: return "TK_PUNCT"; case TK_KEYWORD: return "TK_KEYWORD"; case TK_STR: return "TK_STR"; case TK_NUM: return "TK_NUM"; case TK_PP_NUM: return "TK_PP_NUM"; case TK_EOF: return "TK_EOF"; default: return "UNREACHABLE"; } } // print all tokens received void print_debug_tokens(char *currentfilename, char *function, Token *tok) { fprintf(f, "=====================file : %s, function: %s\n", currentfilename, function); // for debug needs print all the tokens with values Token *t = tok; while (t->kind != TK_EOF) { if (t->len > 0) { char tokloc[t->len + 1]; memset(tokloc, 0, sizeof(tokloc)); char *ptokloc = &tokloc[0]; strncpy(ptokloc, t->loc, t->len); fprintf(f, "token->kind: %s, token->len: %d, token->val: %ld, token->fval:%Lf \n", tokenkind2str(t->kind), t->len, t->val, t->fval); fprintf(f, " token->str: %s, token->filename: %s, token->line_no: %d, token->at_bol:%d \n", t->str, t->filename, t->line_no, t->at_bol); fprintf(f, " token->loc: %s \n", ptokloc); } // TK_EOF not sure that it helps to have this information in the log! // else // { // fprintf(f, "token->kind: %s, token->len: %d, token->val: %ld, token->fval:%Lf \n", tokenkind2str(t->kind), t->len, t->val, t->fval); // fprintf(f, " token->str: %s, token->filename: %s, token->line_no: %d, token->at_bol:%d \n", t->str, t->filename, t->line_no, t->at_bol); // } t = t->next; } }chibicc-1.0.23.1/diagram/000077500000000000000000000000001505335450300147275ustar00rootroot00000000000000chibicc-1.0.23.1/diagram/README.md000066400000000000000000000000621505335450300162040ustar00rootroot00000000000000# needed to have the diagram folder empty into gitchibicc-1.0.23.1/extended_asm.c000066400000000000000000003231611505335450300161350ustar00rootroot00000000000000// This file manages extended assembly. // asm ( // "assembler template" // : outputs // : inputs // : clobbers // : labels) // references https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html and https://www.felixcloutier.com/documents/gcc-asm.html // // Special format strings // In addition to the tokens described by the input, output, and goto operands, these tokens have special meanings in the assembler template: // //‘%%’ // Outputs a single ‘%’ into the assembler code. // //‘%=’ // Outputs a number that is unique to each instance of the asm statement in the entire compilation. This option is useful when creating local labels and referring to them multiple times in a single template that generates multiple assembler instructions. // //‘%{’ //‘%|’ //‘%}’ // Outputs ‘{’, ‘|’, and ‘}’ characters (respectively) into the assembler code. // When unescaped, these characters have special meaning to indicate multiple assembler dialects. #include "chibicc.h" #define EXTASM_C "extended_asm.c" typedef struct { Token *input; // store the token corresponding to input char *variableNumber; //store the variable %0, %1... char *input_value; // store the immediate value char *reg; // store the register that corresponds to the variable size char *reg64; //store the register 64 bits char *regh; //store the high bits of a register like ah char *regl; //store the lower bits of a register like al char *regw; //store the word register char *operand_name; //store the operand name like [dst], [src] int index; // store the index char letter; // store the letter corresponding to input int offset; // store the offset int size; // store the size to determine the operation to do ex movl movb movw movq bool isVariable; // store true if it's a variable otherwise false for immediate value bool isAddress; // store true if it's an address pointer bool isArray; //true if it's an array variable bool isStruct; //true if it's a struct variable bool isToNegate; //true if the value should be negate int indexArray; //store the index element of array int offsetArray; //store the index of array int offsetStruct; //store the offset of the struct bool isq; //true if q: 8-bit registers (al, bl, cl, dl) bool isl; //true if l: 32-bit registers (eax, ebx, ecx, edx) bool is_pure_register; // true if the input is a pure register } AsmInput; typedef struct { Token *output; // store the token corresponding to input char *variableNumber; //store the variable %0, %1... char *prefix; //= or + char *reg; // store the register that corresponds to the variable size char *reg64; //store the register 64 bits char *regh; //store the high bits of a register like ah char *regl; //store the lower bits of a register like al char *regw; //store the word register char *operand_name; //store the operand name like [dst], [src] char letter; // to store a b r int index; // order in output int size; // store the size to determine the operation to do bool isRegister; // r bool isMemory; // m bool isAlpha; // if is not r neither m is considered Alpha int offset; // store the offset bool isVariable; // store true if it's a variable otherwise false for immediate value bool isAddress; // store true if it's an address pointer bool isArray; //true if it's an array variable bool isStruct; //true if it's a struct variable int indexArray; //store the index element of array int offsetArray; //store the index of array int offsetStruct; //store the offset of the struct bool inputToGenerate; //true if it's the corresponding input should be generated bool isq; //true if q: 8-bit registers (al, bl, cl, dl) bool isl; //true if l: 32-bit registers (eax, ebx, ecx, edx) bool is_pure_register; } AsmOutput; typedef struct { char *templatestr; //bool hasPercent; } AsmTemplate; typedef struct { char *clobber; } AsmClobber; typedef struct { AsmTemplate *template; AsmOutput *output[10]; AsmInput *input[10]; AsmClobber *clobber[10]; int nboutput; int nbinput; int nbclobber; int nblabel; } AsmExtended; typedef AsmExtended AsmExtended; typedef enum { AT_TEMPLATE, // assembler template AT_OUTPUT, // outputs AT_INPUT, // inputs AT_CLOBBER, // clobbers AT_LABEL, // labels } AsmType; // //+ means that the output is actually a read-write value. //=& means that the output is an early-clobber output. Its initial value is unspecified. //= means that the output is write-only. //=@ccCOND is a special case of = that allows you to query the result of a condition code at the end of your assembly statement. // typedef enum // { // CP_READWRITEREG = 1, // +r // CP_READWRITEMEM, // +m // CP_CLOBBEROUTPUTREG, // =&r // CP_WRITEONLYREG, // =r // CP_WRITEONLYMEM, // =m // CP_WRITEONLYOTH, // =a =b =c... // CP_COND, // =@ccCOND // } ConstraintPrefix; static AsmExtended *asmExt; static int nbInput = 0; static int nbOutput = 0; static int nbClobber = 0; static int nbLabel = 0; static int asmtype = 0; extern Context *ctx; static bool hasInput = false; static bool hasOutput = false; static bool isToNegate = false; static bool hasOperandName = false; static char *register_lower(char *reg); static char *register_higher(char *reg); static char *register_word(char *reg); char *extended_asm(Node *node, Token **rest, Token *tok, Obj *locals) { char *input_asm_str; char *output_loading; asmtype = 0; nbInput = 0; nbOutput = 0; nbClobber = 0; nbLabel = 0; hasInput = false; hasOutput = false; char *template = tok->str; char *asm_str = calloc(1, sizeof(char) * 10000); //case __asm__ volatile ("" ::: "memory") //case __asm__ __volatile__ ("rep; nop" ::: "memory"); //we generate a nop operation for each memory border defined //if (strlen(template) == 0 || !strncmp(template, "rep; nop", 9)) { if (strlen(template) == 0) { while (!equal(tok->next, ")")) { tok = tok->next; } *rest = tok->next; SET_CTX(ctx); *rest = skip(tok->next, ")", ctx); tok = *rest; asm_str = "\nnop;\n"; return asm_str; } if (isDebug) printf("template==%s\n", template); // allocate memory for all structs needed asmExt = calloc(1, sizeof(AsmExtended)); asmExt->template = calloc(1, sizeof(AsmTemplate)); for (int i = 0; i < 10; i++) asmExt->input[i] = calloc(1, sizeof(AsmInput)); for (int i = 0; i < 10; i++) asmExt->output[i] = calloc(1, sizeof(AsmOutput)); for (int i = 0; i < 10; i++) asmExt->clobber[i] = calloc(1, sizeof(AsmClobber)); //strncpy(asm_str, "", strlen(asm_str) + 1); char *output_asm_str = calloc(1, sizeof(char) * 2500); char *input_final = calloc(1, sizeof(char) * 2500); char *input_for_output = calloc(1, sizeof(char) * 4000); asmExt->template->templatestr = template; // asmExt->template->hasPercent = check_template(template); //clear the registerUsed array clear_register_used(); //mark the register used if found in template check_register_in_template(template); while (!equal(tok->next, ";") && !equal(tok, ";")) { switch (asmtype) { case AT_TEMPLATE: // assembler template break; case AT_OUTPUT: // outputs if (equal(tok, ":")) break; output_asm(node, rest, tok, locals); // generate output instruction for each output variable if (asmExt->output[nbOutput]->variableNumber) { hasOutput = true; output_loading = generate_output_asm(asmExt->output[nbOutput]->variableNumber); // replace %9 by the correct register if (!output_loading) error("%s : %s:%d: error: in extended_asm function extended_asm :output_loading is null!", EXTASM_C, __FILE__, __LINE__); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in extended_asm function extended_asm :asmExt->output[nbOutput]->reg is null!", EXTASM_C, __FILE__, __LINE__); output_loading = subst_asm(output_loading, asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->variableNumber); //generate the ouput instruction strncat(output_asm_str, output_loading, strlen(output_loading)); } else { //to manage the case of no output tok = tok->next; *rest = tok; } nbOutput++; tok = *rest; break; case AT_INPUT: // inputs // return %0, %1 or %x if (equal(tok, ":")) break; input_asm(node, rest, tok, locals); // generate input instruction to load the parameter into register if (asmExt->input[nbInput]->variableNumber) { hasInput = true; if (!hasOperandName) { input_asm_str = generate_input_asm(asmExt->input[nbInput]->variableNumber); //replace %9, by the correct if (!input_asm_str) error("%s %s:%d: error: in extended_asm function extended_asm :input_asm_str is null!", EXTASM_C, __FILE__, __LINE__); if (!asmExt->input[nbInput]->reg) error("%s %s:%d: error: in extended_asm function extended_asm :asmExt->input[nbInput]->reg is null!", EXTASM_C, __FILE__, __LINE__); if (asmExt->input[nbInput]->isAddress) input_asm_str = subst_asm(input_asm_str, asmExt->input[nbInput]->reg64, asmExt->input[nbInput]->variableNumber); else input_asm_str = subst_asm(input_asm_str, asmExt->input[nbInput]->reg, asmExt->input[nbInput]->variableNumber); // concatenate the input final strings to add to the assembly strncat(input_final, input_asm_str, strlen(input_asm_str)); } } else { //to manage the case of no input tok = tok->next; *rest = tok; } nbInput++; tok = *rest; break; case AT_CLOBBER: // clobbers if (equal(tok, ":")) break; asmExt->clobber[nbClobber]->clobber = tok->loc; tok = tok->next; // if (equal(tok, ",")) // tok = tok->next; *rest = tok; nbClobber++; //error_tok(tok, "%s : in extended_asm function : clobber not managed yet!", EXTASM_C); break; case AT_LABEL: // labels //nbLabel++; tok = tok->next; *rest = tok; //error_tok(tok, "%s : in extended_asm function : label not managed yet!", EXTASM_C); break; default: // error error_tok(tok, "%s : in extended_asm function : too much parameters or complex extended assembly not managed!", EXTASM_C); } if (equal(tok, ":")) asmtype += 1; tok = tok->next; } //case of no input need to generate input for output if (hasOutput && !hasInput){ input_for_output = generate_input_for_output(); if (input_for_output != NULL) { strncat(asm_str, input_for_output, strlen(input_for_output)); } } if (hasOutput) { // First, substitute named operands like %[dst] for (int i = 0; i < nbOutput; i++) { if (asmExt->output[i]->operand_name) { char pattern[32]; snprintf(pattern, sizeof(pattern), "%%[%s]", asmExt->output[i]->operand_name); template = subst_asm(template, asmExt->output[i]->reg, pattern); } } //replace each %9 by the correct output register char *tmp_asm = calloc(1, sizeof(char) * 300); for (int i = 0; i < nbOutput; i++) { if (asmExt->output[i]->isAddress) { char *tmp = calloc(1, sizeof(char) * 30); strncat(tmp, "(", 2); strncat(tmp, asmExt->output[i]->reg64, strlen(asmExt->output[i]->reg64) ); strncat(tmp, ")", 2); tmp_asm = subst_asm(template, tmp, asmExt->output[i]->variableNumber); free(tmp); }else { tmp_asm = subst_asm(template, asmExt->output[i]->reg, asmExt->output[i]->variableNumber); } } //special case %b0 %h0 for (int i = 0; i < nbOutput; i++) { // Replace %bN with regl if (asmExt->output[i]->regl) { char pattern[8]; snprintf(pattern, sizeof(pattern), "%%b%d", i); tmp_asm = subst_asm(template, asmExt->output[i]->regl, pattern); } // Replace %hN with regh if (asmExt->output[i]->regh) { char pattern[8]; snprintf(pattern, sizeof(pattern), "%%h%d", i); tmp_asm = subst_asm(template, asmExt->output[i]->regh, pattern); } // Replace %wN with regw if (asmExt->output[i]->regw) { char pattern[8]; snprintf(pattern, sizeof(pattern), "%%w%d", i); tmp_asm = subst_asm(template, asmExt->output[i]->regw, pattern); } } strncat(asm_str, tmp_asm, strlen(tmp_asm)); } if (hasInput) { if (hasOperandName) { // First, substitute named operands like %[src] for (int i = 0; i < nbInput; i++) { if (asmExt->input[i]->operand_name) { char pattern[32]; snprintf(pattern, sizeof(pattern), "%%[%s]", asmExt->input[i]->operand_name); template = subst_asm(template, asmExt->input[i]->reg, pattern); } } } //printf("template=%s\n", template); //replace each %9 by the correct input register for (int i = 0; i < nbInput; i++) { // Replace %bN with regl if (asmExt->input[i]->regl) { char pattern[8]; snprintf(pattern, sizeof(pattern), "%%b%d", asmExt->input[i]->index); asm_str = subst_asm(template, asmExt->input[i]->regl, pattern); } // Replace %hN with regh if (asmExt->input[i]->regh) { char pattern[8]; snprintf(pattern, sizeof(pattern), "%%h%d", asmExt->input[i]->index); asm_str = subst_asm(template, asmExt->input[i]->regh, pattern); } // Replace %wN with regw if (asmExt->input[i]->regw) { char pattern[8]; snprintf(pattern, sizeof(pattern), "%%w%d", asmExt->input[i]->index); asm_str = subst_asm(template, asmExt->input[i]->regw, pattern); } if (asmExt->input[i]->isAddress) { char *tmp = calloc(1, sizeof(char) * 30); strncat(tmp, "(", 2); strncat(tmp, asmExt->input[i]->reg64, strlen(asmExt->input[i]->reg64) ); strncat(tmp, ")", 2); asm_str = subst_asm(template, tmp, asmExt->input[i]->variableNumber); free(tmp); }else { asm_str = subst_asm(template, asmExt->input[i]->reg, asmExt->input[i]->variableNumber); } } //generate the input instructions before the output if (input_final != NULL) { if (nbOutput > 0) input_for_output = generate_input_for_output(); //input_for_output can be NULL if no input to generate for output //generate first the input for output and then the input for the rest of the template if (input_for_output != NULL && input_final != NULL) { strncat(input_for_output, input_final, strlen(input_final)); strncpy(input_final, input_for_output, strlen(input_for_output) + 1); strncat(input_final, asm_str, strlen(asm_str)); } else { strncat(input_final, asm_str, strlen(asm_str)); } asm_str = input_final; } } //generate the output instructions if (hasOutput && output_asm_str != NULL) { strncat(asm_str, output_asm_str, strlen(output_asm_str)); } //case __asm__ __volatile__ ("rep; nop" ::: "memory"); if (!hasOutput && !hasInput) { strncat(asm_str, template, strlen(template)); } //replace special characters // replace %% by % // replace ‘%{’ by '{', ‘%|’ by '|' and ‘%}’ by '}' asm_str = subst_asm(asm_str, " %", "%%"); asm_str = subst_asm(asm_str, " {", "%{"); asm_str = subst_asm(asm_str, " |", "%|"); asm_str = subst_asm(asm_str, " }", "%}"); if (isDebug) printf("=====template=%s\n====asm_str=%s\n====input_final==%s\n====output_asm_str===%s\n", template, asm_str, input_final, output_asm_str); tok = tok->next; //printf("tok=%s\n", tok->loc); *rest = tok; // free memory for (int i = 0; i < 10; i++) free(asmExt->input[i]); for (int i = 0; i < 10; i++) free(asmExt->output[i]); for (int i = 0; i < 10; i++) free(asmExt->clobber[i]); free(asmExt->template); // free(input_for_output); // free(output_asm_str); // free(input_final); free(asmExt); return asm_str; } void output_asm(Node *node, Token **rest, Token *tok, Obj *locals) { VarScope *sc; while (!equal(tok->next, ":") && !equal(tok->next, ";")) { //case of operand named if (equal(tok, "[") || equal(tok, "{")) { char closing = equal(tok, "[") ? ']' : '}'; tok = tok->next; //case of operand named [dst] or {src} if (tok->kind == TK_IDENT ) { char *name = calloc(tok->len + 1, 1); memcpy(name, tok->loc, tok->len); name[tok->len] = '\0'; asmExt->output[nbOutput]->operand_name = name; asmExt->output[nbOutput]->index = nbOutput; tok = tok->next; // Now consume the closing ] or } if (!equal(tok, (char[]){closing, 0})) { error_tok(tok, "%s : %s:%d: error: in output_asm function : expected closing %c after operand name", EXTASM_C, __FILE__, __LINE__, closing); } tok = tok->next; } } // register in write only mode // check if the register constraint is followed by a variable like "=r" (val) if (tok->kind == TK_STR) { if (!strncmp(tok->str, "=r", tok->len) || !strncmp(tok->str, "+r", tok->len)) { asmExt->output[nbOutput]->isRegister = true; if (!strncmp(tok->str, "=r", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rax"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'r'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } if (!strncmp(tok->str, "=&r", tok->len) ) { asmExt->output[nbOutput]->isRegister = true; asmExt->output[nbOutput]->prefix = "="; asmExt->output[nbOutput]->reg = specific_register_available("%r10"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'r'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=m", tok->len) || !strncmp(tok->str, "+m", tok->len)) { asmExt->output[nbOutput]->isMemory = true; if (!strncmp(tok->str, "=m", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rdi"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'm'; asmExt->output[nbOutput]->inputToGenerate = true; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=q", tok->len) || !strncmp(tok->str, "+q", tok->len)) { asmExt->output[nbOutput]->isMemory = true; asmExt->output[nbOutput]->isq = true; if (!strncmp(tok->str, "=q", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rdx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'q'; asmExt->output[nbOutput]->inputToGenerate = true; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=Q", tok->len) || !strncmp(tok->str, "+Q", tok->len)) { asmExt->output[nbOutput]->isMemory = true; asmExt->output[nbOutput]->isq = true; if (!strncmp(tok->str, "=Q", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rax"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'Q'; asmExt->output[nbOutput]->inputToGenerate = true; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=l", tok->len) || !strncmp(tok->str, "+l", tok->len)) { asmExt->output[nbOutput]->isMemory = true; asmExt->output[nbOutput]->isl = true; if (!strncmp(tok->str, "=l", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rdx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'l'; asmExt->output[nbOutput]->inputToGenerate = true; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } // assuming that it's =a =b ??? else if (!strncmp(tok->str, "=a", tok->len) || !strncmp(tok->str, "=b", tok->len) || !strncmp(tok->str, "=c", tok->len) || !strncmp(tok->str, "=d", tok->len) || !strncmp(tok->str, "=&a", tok->len) || !strncmp(tok->str, "=&b", tok->len) || !strncmp(tok->str, "=&c", tok->len) || !strncmp(tok->str, "=&d", tok->len)) { if (!strncmp(tok->str, "=a", tok->len) || !strncmp(tok->str, "=&a", tok->len)) { asmExt->output[nbOutput]->prefix = "="; asmExt->output[nbOutput]->reg = specific_register_available("%rax"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'a'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=b", tok->len) || !strncmp(tok->str, "=&b", tok->len)) { asmExt->output[nbOutput]->prefix = "="; asmExt->output[nbOutput]->reg = specific_register_available("%rbx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'b'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=c", tok->len) || !strncmp(tok->str, "=&c", tok->len)) { asmExt->output[nbOutput]->prefix = "="; asmExt->output[nbOutput]->reg = specific_register_available("%rcx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'c'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "=d", tok->len) || !strncmp(tok->str, "=&d", tok->len)) { asmExt->output[nbOutput]->prefix = "="; asmExt->output[nbOutput]->reg = specific_register_available("%rdx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'd'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else { tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } asmExt->output[nbOutput]->isAlpha = true; //asmExt->output[nbOutput]->prefix = "="; //asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "+a", tok->len) || !strncmp(tok->str, "+b", tok->len) || !strncmp(tok->str, "+c", tok->len) || !strncmp(tok->str, "+d", tok->len)) { if (!strncmp(tok->str, "+a", tok->len)) { asmExt->output[nbOutput]->prefix = "+"; asmExt->output[nbOutput]->reg = specific_register_available("%rax"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'a'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "+b", tok->len)) { asmExt->output[nbOutput]->prefix = "+"; asmExt->output[nbOutput]->reg = specific_register_available("%rbx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'b'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "+c", tok->len)) { asmExt->output[nbOutput]->prefix = "+"; asmExt->output[nbOutput]->reg = specific_register_available("%rcx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'c'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else if (!strncmp(tok->str, "+d", tok->len)) { asmExt->output[nbOutput]->prefix = "+"; asmExt->output[nbOutput]->reg = specific_register_available("%rdx"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'd'; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } else { tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } asmExt->output[nbOutput]->isAlpha = true; //asmExt->output[nbOutput]->prefix = "="; //asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); } //D for destination operand else if (!strncmp(tok->str, "=D", tok->len) || !strncmp(tok->str, "+D", tok->len)) { asmExt->output[nbOutput]->isMemory = true; if (!strncmp(tok->str, "=D", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rax"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'D'; asmExt->output[nbOutput]->inputToGenerate = true; } //S for source operand else if (!strncmp(tok->str, "=S", tok->len) || !strncmp(tok->str, "+S", tok->len)) { asmExt->output[nbOutput]->isMemory = true; if (!strncmp(tok->str, "=S", tok->len)) asmExt->output[nbOutput]->prefix = "="; else { asmExt->output[nbOutput]->prefix = "+"; } asmExt->output[nbOutput]->reg = specific_register_available("%rax"); if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg64 = asmExt->output[nbOutput]->reg; asmExt->output[nbOutput]->regh = register_higher(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regl = register_lower(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->regw = register_word(asmExt->output[nbOutput]->reg64); asmExt->output[nbOutput]->letter = 'S'; asmExt->output[nbOutput]->inputToGenerate = true; } asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); asmExt->output[nbOutput]->index = nbOutput; } // skip the comma else if (equal(tok, ",")) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } // manage the variable inside parenthesis else if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); // check if the variable is defined if (tok->kind == TK_IDENT) { //TODO potential issue if several variables with same name inside different functions. //need to check if the variable is in the correct function asmExt->output[nbOutput]->output = tok; sc = find_var(tok); if (!sc) error_tok(tok, "%s %d: in output_asm function : variable undefined", EXTASM_C, __LINE__); if (!sc->var->ty) error_tok(tok, "%s %d: in output_asm function : variable type unknown", EXTASM_C, __LINE__); // retrieve the size of the variable to determine the register to use here we use RAX variation asmExt->output[nbOutput]->size = sc->var->ty->size; if (!asmExt->output[nbOutput]->reg) error_tok(tok, "%s %d: in output_asm function : reg is null extended assembly not managed yet", EXTASM_C, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); asmExt->output[nbOutput]->isVariable = true; asmExt->output[nbOutput]->output = tok; asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->output[nbOutput]->offset = sc->var->offset; } else { asmExt->output[nbOutput]->offset = 0; } //managing specific case of arrays if (sc->var->ty->kind == TY_ARRAY) { SET_CTX(ctx); tok = skip(tok->next, "[", ctx); asmExt->output[nbOutput]->isArray = true; asmExt->output[nbOutput]->isAddress = false; asmExt->output[nbOutput]->indexArray = tok->val; asmExt->output[nbOutput]->size = sc->var->ty->base->size; if (!asmExt->output[nbOutput]->reg) error("%s : %s:%d: error: in output_asm function :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); //calculate the offset for each element from the bottom to the top r[0] has the lowest offset example -48, r[1] - 44, r[2] -40, r[3] - 36 asmExt->output[nbOutput]->offset = (sc->var->offset ) + (asmExt->output[nbOutput]->indexArray * asmExt->output[nbOutput]->size); asmExt->output[nbOutput]->offsetArray = sc->var->offset; tok = tok->next; SET_CTX(ctx); tok = skip(tok, "]", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } //special case of array pointer it means that the parameter received is an address. if (sc->var->ty->kind == TY_PTR && equal(tok->next, "[")) { SET_CTX(ctx); tok = skip(tok->next, "[", ctx); asmExt->output[nbOutput]->isArray = true; asmExt->output[nbOutput]->isAddress = true; asmExt->output[nbOutput]->indexArray = tok->val; asmExt->output[nbOutput]->size = sc->var->ty->base->size; if (!asmExt->output[nbOutput]->reg) error_tok(tok, "%s %d: in output_asm function : reg is null extended assembly not managed yet", EXTASM_C, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); //calculate the offset for each element from the bottom to the top r[0] has the lowest offset example -48, r[1] - 44, r[2] -40, r[3] - 36 asmExt->output[nbOutput]->offset = (asmExt->output[nbOutput]->indexArray * asmExt->output[nbOutput]->size); asmExt->output[nbOutput]->offsetArray = sc->var->offset; tok = tok->next; SET_CTX(ctx); tok = skip(tok, "]", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } //Trying to fix ISS-164 special case of ptr->value form (ptr to a struct) if (sc->var->ty->kind == TY_PTR && equal(tok->next, "->")) { if (!sc->var->ty->base) error_tok(tok, "%s %d: in output_asm function : expecting struct base but base is null!", EXTASM_C, __LINE__); asmExt->output[nbOutput]->output = tok; SET_CTX(ctx); tok = skip(tok->next, "->", ctx); Token * tokmbr = tok; // retrieve the size of the variable to determine the register to use here we use RAX variation asmExt->output[nbOutput]->isAddress = true; asmExt->output[nbOutput]->isStruct = true; asmExt->output[nbOutput]->size = sc->var->ty->size; if (!asmExt->output[nbOutput]->reg) error_tok(tok, "%s %d: in output_asm function : reg is null extended assembly not managed yet", EXTASM_C, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); if (!sc->var->ty->base->members) error_tok(tok, "%s %d: in output_asm function : expecting members but members is null", EXTASM_C, __LINE__); if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->output[nbOutput]->offset = sc->var->offset; asmExt->output[nbOutput]->offsetStruct = sc->var->ty->base->members->offset ; } else { asmExt->output[nbOutput]->offset = 0; } //need to update the specific struct field offset char *toktmp = calloc(1, sizeof(char) * 300); for (Member *mbr = sc->var->ty->base->members; mbr; mbr = mbr->next) { if (mbr->name->len > 59) error_tok(tok, "%s %d %d: in output_asm function : not enough size for toktmp", EXTASM_C, __LINE__, mbr->name->len); strncat(toktmp, mbr->name->loc, mbr->name->len); if (equal(tokmbr, toktmp)) { asmExt->output[nbOutput]->offsetStruct = mbr->offset ; asmExt->output[nbOutput]->size = mbr->ty->size ; if (!asmExt->output[nbOutput]->reg) error_tok(tok, "%s %d: in output_asm function : reg is null extended assembly not managed yet", EXTASM_C, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); } } tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } // skip the variable to go to next token that should be a ")" // tok = tok->next; tok = tok->next; if (!equal(tok, ")")) error_tok(tok, "%s %d: in output_asm function : extended assembly not managed yet", EXTASM_C, __LINE__); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } // pointer else if (equal(tok, "*")) { consume(&tok, tok, "*"); if (tok->kind == TK_IDENT) { asmExt->output[nbOutput]->isAddress = true; asmExt->output[nbOutput]->output = tok; sc = find_var(tok); if (!sc) error_tok(tok, "%s %d: in output_asm function : variable undefined2", EXTASM_C, __LINE__); if (!sc->var->ty) error_tok(tok, "%s %d: in output_asm function : variable type unknown2", EXTASM_C, __LINE__); // retrieve the size of the variable to determine the register to use here we use RAX variation // skip the variable to go to next token that should be a ")" asmExt->output[nbOutput]->size = sc->var->ty->pointertype->size; if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->output[nbOutput]->offset = sc->var->offset; } else { asmExt->output[nbOutput]->offset = 0; } if (!asmExt->output[nbOutput]->reg) error_tok(tok, "%s %d: in output_asm function : reg is null extended assembly not managed yet", EXTASM_C, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } else if (equal(tok, "(") && equal(tok->next, "(")) { // Skip '((' tok = tok->next->next; if (!equal(tok, "void")) error_tok(tok, "%s %d: in output_asm function : expected cast to (void **)", EXTASM_C, __LINE__); tok = tok->next; int pointer_depth = 0; while (equal(tok, "*")) { pointer_depth++; tok = tok->next; } if (!equal(tok, ")")) error_tok(tok, "%s %d: in output_asm function : expected ')' after cast type", EXTASM_C, __LINE__); tok = tok->next; if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: in output_asm function : expected identifier after cast", EXTASM_C, __LINE__); // At this point: we are at the identifier (like 'ofs') asmExt->output[nbOutput]->isAddress = true; asmExt->output[nbOutput]->output = tok; VarScope *sc = find_var(tok); if (!sc) error_tok(tok, "%s %d: in output_asm function : variable undefined after cast", EXTASM_C, __LINE__); if (!sc->var->ty) error_tok(tok, "%s %d: in output_asm function : variable type unknown after cast", EXTASM_C, __LINE__); asmExt->output[nbOutput]->size = sc->var->ty->size; if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->output[nbOutput]->offset = sc->var->offset; } else { asmExt->output[nbOutput]->offset = 0; } if (!asmExt->output[nbOutput]->reg) error_tok(tok, "%s %d: in output_asm function : reg is null", EXTASM_C, __LINE__); asmExt->output[nbOutput]->reg = update_register_size(asmExt->output[nbOutput]->reg, asmExt->output[nbOutput]->size); asmExt->output[nbOutput]->variableNumber = retrieveVariableNumber(nbOutput); tok = tok->next; if (!equal(tok, ")")) error_tok(tok, "%s %d: in output_asm function : expected ')' after cast type", EXTASM_C, __LINE__); tok = tok->next; //first parenthesis SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } else { error_tok(tok, "%s %d: in output_asm function : extended assembly not managed yet", EXTASM_C, __LINE__); } } } tok = tok->next; *rest = tok; } return; } void input_asm(Node *node, Token **rest, Token *tok, Obj *locals) { VarScope *sc; char *input_value = calloc(1, sizeof(char) * 300); asmExt->input[nbInput]->offset = 0; while (!equal(tok->next, ":") && !equal(tok->next, ";")) { //case of operand named if (equal(tok, "[") || equal(tok, "{")) { char closing = equal(tok, "[") ? ']' : '}'; tok = tok->next; // case of operand named [dst] or {src} if (tok->kind == TK_IDENT) { char *name = calloc(tok->len + 1, 1); memcpy(name, tok->loc, tok->len); name[tok->len] = '\0'; asmExt->input[nbInput]->operand_name = name; asmExt->input[nbInput]->index = nbInput; hasOperandName = true; tok = tok->next; // Now consume the closing ] or } if (!equal(tok, (char[]){closing, 0})) { error_tok(tok, "%s : %s:%d: error: in input_asm function : expected closing %c after operand name", EXTASM_C, __FILE__, __LINE__, closing); } tok = tok->next; } } // register in write only mode if (tok->kind == TK_STR && (!strncmp(tok->str, "0", tok->len) || !strncmp(tok->str, "%0", tok->len) )) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(0); asmExt->input[nbInput]->index = 0; asmExt->input[nbInput]->reg = asmExt->output[0]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[0]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } else if (tok->kind == TK_STR && (!strncmp(tok->str, "1", tok->len) || !strncmp(tok->str, "%1", tok->len))) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(1); asmExt->input[nbInput]->index = 1; asmExt->input[nbInput]->reg = asmExt->output[1]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[1]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } else if (tok->kind == TK_STR && (!strncmp(tok->str, "2", tok->len) || !strncmp(tok->str, "%2", tok->len))) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(2); asmExt->input[nbInput]->index = 2; asmExt->input[nbInput]->reg = asmExt->output[2]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[2]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } else if (tok->kind == TK_STR && (!strncmp(tok->str, "3", tok->len) || !strncmp(tok->str, "%3", tok->len))) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(3); asmExt->input[nbInput]->index = 3; asmExt->input[nbInput]->reg = asmExt->output[3]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[3]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } else if (tok->kind == TK_STR && !strncmp(tok->str, "a", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(retrieve_output_index_from_letter('a')); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->letter = 'a'; //=====ISS-156 case we have no output for the letter if (retrieve_output_index_from_letter('a') == -1) { asmExt->input[nbInput]->reg = specific_register_available("%rax"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); } else { asmExt->input[nbInput]->reg = asmExt->output[retrieve_output_index_from_letter('a')]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[retrieve_output_index_from_letter('a')]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } } else if (tok->kind == TK_STR && !strncmp(tok->str, "b", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(retrieve_output_index_from_letter('b')); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->letter = 'b'; //=====ISS-156 case we have no output for the letter if (retrieve_output_index_from_letter('b') == -1) { asmExt->input[nbInput]->reg = specific_register_available("%rbx"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); } else { asmExt->input[nbInput]->reg = asmExt->output[retrieve_output_index_from_letter('b')]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[retrieve_output_index_from_letter('b')]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } } else if (tok->kind == TK_STR && !strncmp(tok->str, "c", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(retrieve_output_index_from_letter('c')); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->letter = 'c'; //=====ISS-156 case we have no output for the letter if (retrieve_output_index_from_letter('c') == -1) { asmExt->input[nbInput]->reg = specific_register_available("%rcx"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); } else { asmExt->input[nbInput]->reg = asmExt->output[retrieve_output_index_from_letter('c')]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[retrieve_output_index_from_letter('c')]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } } else if (tok->kind == TK_STR && !strncmp(tok->str, "d", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(retrieve_output_index_from_letter('d')); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->letter = 'd'; //=====ISS-156 case we have no output for the letter if (retrieve_output_index_from_letter('d') == -1) { asmExt->input[nbInput]->reg = specific_register_available("%rdx"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); } else { asmExt->input[nbInput]->reg = asmExt->output[retrieve_output_index_from_letter('d')]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[retrieve_output_index_from_letter('d')]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } } else if (tok->kind == TK_STR && !strncmp(tok->str, "g", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(retrieve_output_index_from_letter('g')); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->letter = 'g'; //=====ISS-156 case we have no output for the letter if (retrieve_output_index_from_letter('g') == -1) { asmExt->input[nbInput]->reg = specific_register_available("%rdi"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); } else { asmExt->input[nbInput]->reg = asmExt->output[retrieve_output_index_from_letter('g')]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[retrieve_output_index_from_letter('g')]->reg64; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } } else if (tok->kind == TK_STR && !strncmp(tok->str, "Nd", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(retrieve_output_index_from_letter('d')); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->letter = 'N'; //=====ISS-156 case we have no output for the letter if (retrieve_output_index_from_letter('N') == -1) { asmExt->input[nbInput]->reg = specific_register_available("%rdx"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); } else { asmExt->input[nbInput]->reg = asmExt->output[retrieve_output_index_from_letter('N')]->reg; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->output[retrieve_output_index_from_letter('N')]->reg64; } asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); } else if (tok->kind == TK_STR && (!strncmp(tok->str, "m", tok->len) || !strncmp(tok->str, "rm", tok->len))) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%rdi"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'm'; } else if (tok->kind == TK_STR && !strncmp(tok->str, "q", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%r10"); asmExt->input[nbInput]->isq = true; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'q'; } else if (tok->kind == TK_STR && !strncmp(tok->str, "Q", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%rax"); asmExt->input[nbInput]->isq = true; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'Q'; } else if (tok->kind == TK_STR && !strncmp(tok->str, "l", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%r10"); asmExt->input[nbInput]->isl = true; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'l'; } else if ((tok->kind == TK_STR && !strncmp(tok->str, "r", tok->len)) || (tok->kind == TK_STR && !strncmp(tok->str, "rn", tok->len))) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%r8"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'r'; if (hasOperandName) { asmExt->input[nbInput]->size = 8; asmExt->input[nbInput]->is_pure_register = true; } } //D for destination operand else if (tok->kind == TK_STR && !strncmp(tok->str, "D", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%rdx"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'D'; } //S for source operand else if (tok->kind == TK_STR && !strncmp(tok->str, "S", tok->len)) { asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbOutput + nbInput); asmExt->input[nbInput]->index = nbOutput + nbInput; asmExt->input[nbInput]->reg = specific_register_available("%r11"); if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg64 = asmExt->input[nbInput]->reg; asmExt->input[nbInput]->regh = register_higher(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regl = register_lower(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->regw = register_word(asmExt->input[nbInput]->reg64); asmExt->input[nbInput]->letter = 'S'; } else if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); // check if the variable is defined if (equal(tok, "-")) { isToNegate = true; consume(&tok, tok, "-"); } if (tok->kind == TK_IDENT) { if (isToNegate) { asmExt->input[nbInput]->isToNegate = isToNegate; isToNegate = false; } sc = find_var(tok); if (!sc) error_tok(tok, "%s %d: in input_asm function : variable undefined", EXTASM_C, __LINE__); if (!sc->var->ty) error_tok(tok, "%s %d: in input_asm function : variable type unknown", EXTASM_C, __LINE__); asmExt->input[nbInput]->input = tok; asmExt->input[nbInput]->isVariable = true; asmExt->input[nbInput]->size = sc->var->ty->size; if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->input[nbInput]->offset = sc->var->offset; } if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null! %d", EXTASM_C, __FILE__, __LINE__, nbInput); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); //managing specific case of arrays if (sc->var->ty->kind == TY_ARRAY) { SET_CTX(ctx); tok = skip(tok->next, "[", ctx); asmExt->input[nbInput]->isArray = true; asmExt->input[nbInput]->indexArray = tok->val; asmExt->input[nbInput]->isAddress = false; asmExt->input[nbInput]->size = sc->var->ty->base->size; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); //calculate the offset for each element from the bottom to the top r[0] has the lowest offset example -48, r[1] - 44, r[2] -40, r[3] - 36 asmExt->input[nbInput]->offset = (sc->var->offset ) + (asmExt->input[nbInput]->indexArray * asmExt->input[nbInput]->size); asmExt->input[nbInput]->offsetArray = sc->var->offset; tok = tok->next; SET_CTX(ctx); tok = skip(tok, "]", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } else if (sc->var->ty->kind == TY_PTR && equal(tok->next, "[")) { SET_CTX(ctx); tok = skip(tok->next, "[", ctx); asmExt->input[nbInput]->isArray = true; asmExt->input[nbInput]->isAddress = true; asmExt->input[nbInput]->indexArray = tok->val; asmExt->input[nbInput]->size = sc->var->ty->base->size; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); //calculate the offset for each element from the bottom to the top r[0] has the lowest offset example -48, r[1] - 44, r[2] -40, r[3] - 36 asmExt->input[nbInput]->offset = (asmExt->input[nbInput]->indexArray * asmExt->input[nbInput]->size); asmExt->input[nbInput]->offsetArray = sc->var->offset; tok = tok->next; SET_CTX(ctx); tok = skip(tok, "]", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } //Trying to fix ISS-164 special case of ptr->value form (ptr to a struct) else if (sc->var->ty->kind == TY_PTR && equal(tok->next, "->")) { if (!sc->var->ty->base) error_tok(tok, "%s %d: in input_asm function : expecting struct base but base is null!", EXTASM_C, __LINE__); asmExt->input[nbInput]->input = tok; SET_CTX(ctx); tok = skip(tok->next, "->", ctx); Token * tokmbr = tok; // retrieve the size of the variable to determine the register to use here we use RAX variation asmExt->input[nbInput]->isAddress = true; asmExt->input[nbInput]->isStruct = true; asmExt->input[nbInput]->size = sc->var->ty->size; if (!asmExt->input[nbInput]->reg) error_tok(tok, "%s %d: in input_asm function : reg is null extended assembly not managed yet", EXTASM_C, __LINE__); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); //asmExt->input[nbInput]->variableNumber = retrieveVariableNumber(nbInput); if (!sc->var->ty->base->members) error_tok(tok, "%s %d: in input_asm function : expecting members but members is null", EXTASM_C, __LINE__); if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->input[nbInput]->offset = sc->var->offset; } else { asmExt->input[nbInput]->offset = 0; } //need to update the specific struct field offset char *toktmp = calloc(1, sizeof(char) * 300); for (Member *mbr = sc->var->ty->base->members; mbr; mbr = mbr->next) { if (mbr->name->len > 59) error_tok(tok, "%s %d %d: in input_asm function : not enough size for toktmp", EXTASM_C, __LINE__, mbr->name->len); strncat(toktmp, mbr->name->loc, mbr->name->len); if (equal(tokmbr, toktmp)) { asmExt->input[nbInput]->offsetStruct = mbr->offset ; asmExt->input[nbInput]->size = mbr->ty->size ; if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); } } tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } // immediate value else if (tok->kind == TK_NUM) { int length = snprintf(NULL, 0, "%ld", tok->val); if (tok->val == 0) strncat(input_value, "0 ", 3); else snprintf(input_value, length + 1, "%ld", tok->val); asmExt->input[nbInput]->input = tok; asmExt->input[nbInput]->isVariable = false; asmExt->input[nbInput]->isAddress = false; asmExt->input[nbInput]->input_value = input_value; asmExt->input[nbInput]->size = tok->ty->size; asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } // pointer else if (equal(tok, "*")) { consume(&tok, tok, "*"); if (tok->kind == TK_IDENT) { asmExt->input[nbInput]->input = tok; sc = find_var(tok); if (!sc) error_tok(tok, "%s %d: in input_asm function : variable undefined2", EXTASM_C, __LINE__); asmExt->input[nbInput]->input = tok; asmExt->input[nbInput]->isVariable = true; asmExt->input[nbInput]->isAddress = true; asmExt->input[nbInput]->size = sc->var->ty->size; if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->input[nbInput]->offset = sc->var->offset; } if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: error: in input_asm function input_asm :reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; // Handle casted input like *((void **)ptr) } else if (equal(tok, "(") && equal(tok->next, "(")) { // Skip '((' tok = tok->next->next; // Parse cast type — here just support 'void **' for now if (!equal(tok, "void")) error("%s : %s:%d: error: in input_asm function input_asm : expected cast to (void **)!", EXTASM_C, __FILE__, __LINE__); tok = tok->next; int pointer_depth = 0; while (equal(tok, "*")) { pointer_depth++; tok = tok->next; } if (!equal(tok, ")")) error_tok(tok, "expected ')' after cast type"); tok = tok->next; // skip first ')' // Now expect TK_IDENT if (tok->kind != TK_IDENT) error_tok(tok, "expected identifier after cast"); asmExt->input[nbInput]->input = tok; asmExt->input[nbInput]->isVariable = true; asmExt->input[nbInput]->isAddress = true; sc = find_var(tok); if (!sc) error_tok(tok, "%s %d: variable undefined in input_asm", EXTASM_C, __LINE__); if (!sc->var->ty) error_tok(tok, "%s %d: variable type undefined in input_asm", EXTASM_C, __LINE__); asmExt->input[nbInput]->size = sc->var->ty->size; if (sc->var->funcname) { update_offset(sc->var->funcname, locals); asmExt->input[nbInput]->offset = sc->var->offset; } if (!asmExt->input[nbInput]->reg) error("%s : %s:%d: input_asm: reg is null!", EXTASM_C, __FILE__, __LINE__); asmExt->input[nbInput]->reg = update_register_size(asmExt->input[nbInput]->reg, asmExt->input[nbInput]->size); tok = tok->next; if (!equal(tok, ")")) error_tok(tok, "%s %d: input_asm: expected ')' after cast", EXTASM_C, __LINE__); tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return; } } } else if (equal(tok, ",")) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } // else // error_tok(tok, "%s : in input_asm function : input complex constraint not managed yet!", EXTASM_C); tok = tok->next; *rest = tok; } return; } // do the susbtitution into the template char *subst_asm(char *template, char *output_str, char *input_str) { return string_replace(template, input_str, output_str); } // generic string replace function char *string_replace(char *str, char *oldstr, char *newstr) { char bstr[strlen(str)]; memset(bstr, 0, sizeof(bstr)); int i; for (i = 0; i < strlen(str); i++) { if (!strncmp(str + i, oldstr, strlen(oldstr))) { strcat(bstr, newstr); i += strlen(oldstr) - 1; } else { strncat(bstr, str + i, 1); } } strncpy(str, bstr, strlen(bstr) + 1); if (strlen(str)> 10000) error("%s: %s:%d: error: in string_replace : not enough memory!", EXTASM_C, __FILE__, __LINE__); return str; } // generate input assembly instruction char *generate_input_asm(char *input_str) { char *tmp = calloc(1, sizeof(char) * 100); //case variable if (asmExt->input[nbInput]->isVariable && asmExt->input[nbInput]->isToNegate) { strncat(tmp, "\n", 3); strncat(tmp, opcode(asmExt->input[nbInput]->size), strlen(opcode(asmExt->input[nbInput]->size))); strncat(tmp, load_variable(asmExt->input[nbInput]->offset), strlen(load_variable(asmExt->input[nbInput]->offset))); strncat(tmp, ", ", 3); strncat(tmp, asmExt->input[nbInput]->variableNumber, strlen(asmExt->input[nbInput]->variableNumber)); strncat(tmp, ";\n", 3); strncat(tmp, "neg ", 5); strncat(tmp, asmExt->input[nbInput]->variableNumber, strlen(asmExt->input[nbInput]->variableNumber)); strncat(tmp, ";\n", 3); return tmp; } else if (asmExt->input[nbInput]->isVariable && !asmExt->input[nbInput]->isAddress) { strncat(tmp, "\n", 3); strncat(tmp, opcode(asmExt->input[nbInput]->size), strlen(opcode(asmExt->input[nbInput]->size))); strncat(tmp, load_variable(asmExt->input[nbInput]->offset), strlen(load_variable(asmExt->input[nbInput]->offset))); strncat(tmp, ", ", 3); strncat(tmp, asmExt->input[nbInput]->variableNumber, strlen(asmExt->input[nbInput]->variableNumber)); strncat(tmp, ";\n", 3); return tmp; } else if (asmExt->input[nbInput]->isAddress) { strncat(tmp, "\n", 3); strncat(tmp, opcode(8), strlen(opcode(8))); strncat(tmp, load_variable(asmExt->input[nbInput]->offset), strlen(load_variable(asmExt->input[nbInput]->offset))); strncat(tmp, ", ", 3); strncat(tmp, asmExt->input[nbInput]->variableNumber, strlen(asmExt->input[nbInput]->variableNumber)); strncat(tmp, ";\n", 3); if (asmExt->input[nbInput]->letter != 'm') { strncat(tmp, opcode(8), 8); strncat(tmp, "(", 2); strncat(tmp, asmExt->input[nbInput]->reg64, strlen(asmExt->input[nbInput]->reg64)); strncat(tmp, ")", 2); strncat(tmp, ", ", 3); strncat(tmp, asmExt->input[nbInput]->reg64, strlen(asmExt->input[nbInput]->reg64)); strncat(tmp, "\n", 3); } return tmp; } //case immediate value else if (asmExt->input[nbInput]->input_value) { strncat(tmp, "\n", 3); strncat(tmp, opcode(asmExt->input[nbInput]->size), strlen(opcode(asmExt->input[nbInput]->size))); strncat(tmp, " $", 3); strncat(tmp, asmExt->input[nbInput]->input_value, strlen(asmExt->input[nbInput]->input_value)); strncat(tmp, ", ", 3); strncat(tmp, asmExt->input[nbInput]->variableNumber, strlen(asmExt->input[nbInput]->variableNumber)); strncat(tmp, ";\n", 3); return tmp; } error("%s : %s:%d: error: in extended_asm function generate_input_asm : unexpected error! %s", EXTASM_C, __FILE__, __LINE__, asmExt->template->templatestr); //return NULL; } // check if template contains % bool check_template(char *template) { return strchr(template, '%') != NULL; } // generate input assembly instruction char *generate_output_asm(char *output_str) { char *tmp = calloc(1, sizeof(char) * 300); //case variable and not an address if (asmExt->output[nbOutput]->isVariable && !asmExt->output[nbOutput]->isAddress) { strncat(tmp, "\n", 3); strncat(tmp, opcode(asmExt->output[nbOutput]->size), strlen(opcode(asmExt->output[nbOutput]->size))); strncat(tmp, asmExt->output[nbOutput]->variableNumber, strlen(asmExt->output[nbOutput]->variableNumber)); strncat(tmp, ", ", 3); strncat(tmp, load_variable(asmExt->output[nbOutput]->offset), strlen(load_variable(asmExt->output[nbOutput]->offset))); strncat(tmp, ";\n", 3); return tmp; } //case not an address it means that it's an immediate value should probably never exists else if (!asmExt->output[nbOutput]->isAddress) { strncat(tmp, opcode(asmExt->output[nbOutput]->size), strlen(opcode(asmExt->output[nbOutput]->size))); strncat(tmp, " $", 3); strncat(tmp, asmExt->input[nbInput]->input_value, strlen(asmExt->input[nbInput]->input_value)); strncat(tmp, ", ", 3); strncat(tmp, asmExt->input[nbInput]->variableNumber, strlen(asmExt->input[nbInput]->variableNumber)); strncat(tmp, ";\n", 3); return tmp; } //case it's an array with address we need to generate the correct output for the specified index else if (asmExt->output[nbOutput]->isAddress && asmExt->output[nbOutput]->isArray) { strncat(tmp, "\n", 3); strncat(tmp, " movq ", 8); strncat(tmp, load_variable(asmExt->output[nbOutput]->offsetArray), strlen(load_variable(asmExt->output[nbOutput]->offsetArray))); strncat(tmp, ", %rsi\n", 8); strncat(tmp, opcode(asmExt->output[nbOutput]->size), strlen(opcode(asmExt->output[nbOutput]->size))); strncat(tmp, asmExt->output[nbOutput]->variableNumber, strlen(asmExt->output[nbOutput]->variableNumber)); //if index 0 we move the value into address pointed by rsi, if index 1 the value will be stored at address pointed by rsi + size of one element //if index 2 the value will be stored at address pointed by rsi + (index * size of one element)... char *tmp2 = calloc(1, sizeof(char) * 100); if (asmExt->output[nbOutput]->indexArray == 0) strncat(tmp, ", (%rsi)\n", 11); else { strncat(tmp, ", ", 3); snprintf(tmp2, sizeof(asmExt->output[nbOutput]->offset), "%d", asmExt->output[nbOutput]->offset); strncat(tmp2, "(%rsi)\n", 9); //to have example 4(%rsi) for index 1, 8(%rsi) for index 2... strncat(tmp, tmp2, strlen(tmp2)); } return tmp; } //Trying to fix ======ISS-164 case it's a struct with address we need to generate the correct output for the specified struct member else if (asmExt->output[nbOutput]->isAddress && asmExt->output[nbOutput]->isStruct && strncmp(asmExt->output[nbOutput]->prefix, "=", 2)) { strncat(tmp, "\n", 3); strncat(tmp, " movq ", 8); strncat(tmp, load_variable(asmExt->output[nbOutput]->offset), strlen(load_variable(asmExt->output[nbOutput]->offset))); strncat(tmp, ", %rsi\n", 8); strncat(tmp, opcode(asmExt->output[nbOutput]->size), strlen(opcode(asmExt->output[nbOutput]->size))); strncat(tmp, asmExt->output[nbOutput]->variableNumber, strlen(asmExt->output[nbOutput]->variableNumber)); //if index 0 we move the value into address pointed by rsi, if index 1 the value will be stored at address pointed by rsi + size of one element //if index 2 the value will be stored at address pointed by rsi + (index * size of one element)... char *tmp2 = calloc(1, sizeof(char) * 100); if (asmExt->output[nbOutput]->offsetStruct == 0) strncat(tmp, ", (%rsi)\n", 11); else { strncat(tmp, ", ", 3); snprintf(tmp2, sizeof(asmExt->output[nbOutput]->offsetStruct), "%d", asmExt->output[nbOutput]->offsetStruct); strncat(tmp2, "(%rsi)\n", 9); //to have example 4(%rsi) for index 1, 8(%rsi) for index 2... strncat(tmp, tmp2, strlen(tmp2)); } return tmp; } //case it's an address else if (asmExt->output[nbOutput]->isAddress) { if (asmExt->output[nbOutput]->letter == 'm'|| asmExt->output[nbOutput]->letter == 'r' || asmExt->output[nbOutput]->letter == 'q') { strncat(tmp, "\n", 3); strncat(tmp, " movq ", 8); strncat(tmp, load_variable(asmExt->output[nbOutput]->offset), strlen(load_variable(asmExt->output[nbOutput]->offset))); strncat(tmp, ", %rsi\n", 8); strncat(tmp, opcode(asmExt->output[nbOutput]->size), strlen(opcode(asmExt->output[nbOutput]->size))); strncat(tmp, " (%rsi), ", 11); strncat(tmp, asmExt->output[nbOutput]->variableNumber, strlen(asmExt->output[nbOutput]->variableNumber)); strncat(tmp, "\n", 3); return tmp; } else { strncat(tmp, "\n", 3); strncat(tmp, " movq ", 8); strncat(tmp, load_variable(asmExt->output[nbOutput]->offset), strlen(load_variable(asmExt->output[nbOutput]->offset))); strncat(tmp, ", %rsi\n", 8); strncat(tmp, opcode(asmExt->output[nbOutput]->size), strlen(opcode(asmExt->output[nbOutput]->size))); strncat(tmp, asmExt->output[nbOutput]->variableNumber, strlen(asmExt->output[nbOutput]->variableNumber)); strncat(tmp, ", (%rsi)\n", 11); return tmp; } } error("%s : %s:%d: error: in extended_asm function generate_output_asm : unexpected error! %s", EXTASM_C, __FILE__, __LINE__, asmExt->template->templatestr); //return NULL; } //codegen.c generates correctly the offset but it's too late. //two possibilities: // - write some specific value example %nameofvaroffset% that will be at the end after codegen.c replaced in assembly file // by the correct value. // - or trying to do the same job as codegen.c but here. It's the goal of assign_lvar_offsets_assembly in update_offset function // need to test in several cases char *load_variable(int offset) { //generic solution to handle all values of offset // if (offset == 0) // error("%s %s %d : error: in load_variable : incorrect offset %d or not managed yet!", EXTASM_C, __FILE__, __LINE__, offset); char *targetaddr = calloc(20, sizeof(char)); int length = snprintf(targetaddr, sizeof(offset), "%d", offset); if (length < 0) error("%s %s %d : error:in load_variable : error during snprintf function! offset=%d length=%d", EXTASM_C, __FILE__, __LINE__, offset, length); strncat(targetaddr, "(%rbp)", 7); return targetaddr; } char *opcode(int size) { switch (size) { case 1: return "\n movb "; case 2: return "\n movw "; case 4: return "\n movl "; case 8: return "\n movq "; case 16: return "\n mov "; default: error("%s: %s:%d: error: in opcode : size %d unexpected!", EXTASM_C, __FILE__, __LINE__, size); } } // we need to update the offset to be able to use this information later for loading result into output variables. // TODO we can have an issue here if several functions with same name. Probably need to find in a better way to avoid this issue. void update_offset(char *funcname, Obj *locals) { //printf(" function %s \n", funcname); Obj *fn = find_func(funcname); if (fn) { //fixing ====ISS-161 issue with some locals missing in fn->locals //if (!fn->locals) fn->locals = locals; assign_lvar_offsets(fn); } } // update register following the size char *update_register_size(char *reg, int size) { if (!strncmp(reg, "%rax", strlen(reg)) || !strncmp(reg, "%eax", strlen(reg)) || !strncmp(reg, "%ax", strlen(reg)) || !strncmp(reg, "%ah", strlen(reg)) || !strncmp(reg, "%al", strlen(reg))) return reg_ax(size); else if (!strncmp(reg, "%rbx", strlen(reg)) || !strncmp(reg, "%ebx", strlen(reg)) || !strncmp(reg, "%bx", strlen(reg)) || !strncmp(reg, "%bh", strlen(reg)) || !strncmp(reg, "%bl", strlen(reg))) return reg_bx(size); else if (!strncmp(reg, "%rcx", strlen(reg)) || !strncmp(reg, "%ecx", strlen(reg)) || !strncmp(reg, "%cx", strlen(reg)) || !strncmp(reg, "%ch", strlen(reg)) || !strncmp(reg, "%cl", strlen(reg))) return reg_cx(size); else if (!strncmp(reg, "%rdx", strlen(reg)) || !strncmp(reg, "%edx", strlen(reg)) || !strncmp(reg, "%dx", strlen(reg)) || !strncmp(reg, "%dh", strlen(reg)) || !strncmp(reg, "%dl", strlen(reg))) return reg_dx(size); else if (!strncmp(reg, "%rdi", strlen(reg)) || !strncmp(reg, "%edi", strlen(reg)) || !strncmp(reg, "%di", strlen(reg)) || !strncmp(reg, "%dih", strlen(reg)) || !strncmp(reg, "%dil", strlen(reg))) return reg_di(size); else if (!strncmp(reg, "%rsi", strlen(reg)) || !strncmp(reg, "%esi", strlen(reg)) || !strncmp(reg, "%si", strlen(reg)) || !strncmp(reg, "%sih", strlen(reg)) || !strncmp(reg, "%sil", strlen(reg))) return reg_si(size); else if (!strncmp(reg, "%r8", strlen(reg)) || !strncmp(reg, "%r8d", strlen(reg)) || !strncmp(reg, "%r8w", strlen(reg)) || !strncmp(reg, "%r8h", strlen(reg)) || !strncmp(reg, "%r8b", strlen(reg))) return reg_si(size); else if (!strncmp(reg, "%r9", strlen(reg)) || !strncmp(reg, "%r9d", strlen(reg)) || !strncmp(reg, "%r9w", strlen(reg)) || !strncmp(reg, "%r9h", strlen(reg)) || !strncmp(reg, "%r9b", strlen(reg))) return reg_si(size); else return reg; } //returns the index corresponding to the letter received in parameter int retrieve_output_index_from_letter(char letter) { for (int i = 0; i < nbOutput; i++) { if (asmExt->output[i]->letter == letter) return asmExt->output[i]->index; } return -1; } //retrieve the variable number string like M0, %1, %2... char * retrieveVariableNumber(int index) { if (index > 8) error("%s: %s:%d: error: in retrieveVariableNumber : index %d not managed yet!", EXTASM_C, __FILE__, __LINE__, index); char *tmp; char *variableNumberStr = calloc(20, sizeof(char)); char *indexstr = calloc(20, sizeof(char)); strncat(variableNumberStr, "%", 2); int length = snprintf(indexstr, sizeof(index), "%d", index); if (length < 0) error("%s %s %d : error: in retrieveVariableNumber : error during snprintf function! index=%d length=%d", EXTASM_C, __FILE__, __LINE__, index, length); strncat(variableNumberStr, indexstr, strlen(indexstr)); tmp = variableNumberStr; return tmp; } //generate the input for the output when + is a prefix for output char *generate_input_for_output() { char *tmp = calloc(1, sizeof(char) * 500); for (int i = 0; i < nbOutput; i++) { //not sure yet about in which case exactly we need to generate the input for the output if ((asmExt->output[i]->offset != 0 && (!strncmp(asmExt->output[i]->prefix, "+", 2) || asmExt->output[i]->isAddress))) { if (asmExt->output[i]->isVariable && !asmExt->output[i]->isAddress) { strncat(tmp, "\n", 3); strncat(tmp, opcode(asmExt->output[i]->size), strlen(opcode(asmExt->output[i]->size))); strncat(tmp, load_variable(asmExt->output[i]->offset), strlen(load_variable(asmExt->output[i]->offset))); strncat(tmp, ", ", 3); strncat(tmp, asmExt->output[i]->reg, strlen(asmExt->output[i]->reg)); strncat(tmp, ";\n", 3); }else if (asmExt->output[i]->isAddress) { strncat(tmp, "\n", 3); strncat(tmp, opcode(8), 8); strncat(tmp, load_variable(asmExt->output[i]->offset), strlen(load_variable(asmExt->output[i]->offset))); strncat(tmp, ", ", 3); strncat(tmp, asmExt->output[i]->reg64, strlen(asmExt->output[i]->reg64)); strncat(tmp, ";\n", 3); } } } return tmp; } // Returns the high 8-bit register name for the given 64-bit register static char *register_higher(char *reg) { if (!reg) return NULL; if (!strncmp(reg, "%rax", 4) || !strncmp(reg, "%eax", 4) || !strncmp(reg, "%ax", 3)) return "%ah"; if (!strncmp(reg, "%rbx", 4) || !strncmp(reg, "%ebx", 4) || !strncmp(reg, "%bx", 3)) return "%bh"; if (!strncmp(reg, "%rcx", 4) || !strncmp(reg, "%ecx", 4) || !strncmp(reg, "%cx", 3)) return "%ch"; if (!strncmp(reg, "%rdx", 4) || !strncmp(reg, "%edx", 4) || !strncmp(reg, "%dx", 3)) return "%dh"; // %r8-%r9, %rdi, %rsi do not have high 8-bit registers in x86-64 if (!strncmp(reg, "%r8", 3) || !strncmp(reg, "%r9", 3) || !strncmp(reg, "%rdi", 4) || !strncmp(reg, "%rsi", 4)) return NULL; return NULL; } // Returns the low 8-bit register name for the given 64-bit register static char *register_lower(char *reg) { if (!reg) return NULL; if (!strncmp(reg, "%rax", 4) || !strncmp(reg, "%eax", 4) || !strncmp(reg, "%ax", 3)) return "%al"; if (!strncmp(reg, "%rbx", 4) || !strncmp(reg, "%ebx", 4) || !strncmp(reg, "%bx", 3)) return "%bl"; if (!strncmp(reg, "%rcx", 4) || !strncmp(reg, "%ecx", 4) || !strncmp(reg, "%cx", 3)) return "%cl"; if (!strncmp(reg, "%rdx", 4) || !strncmp(reg, "%edx", 4) || !strncmp(reg, "%dx", 3)) return "%dl"; if (!strncmp(reg, "%r8", 3)) return "%r8b"; if (!strncmp(reg, "%r9", 3)) return "%r9b"; if (!strncmp(reg, "%rdi", 4)) return "%dil"; if (!strncmp(reg, "%rsi", 4)) return "%sil"; return NULL; } // Returns the 16-bit register name for the given 64-bit register static char *register_word(char *reg) { if (!reg) return NULL; if (!strncmp(reg, "%rax", 4) || !strncmp(reg, "%eax", 4)) return "%ax"; if (!strncmp(reg, "%rbx", 4) || !strncmp(reg, "%ebx", 4)) return "%bx"; if (!strncmp(reg, "%rcx", 4) || !strncmp(reg, "%ecx", 4)) return "%cx"; if (!strncmp(reg, "%rdx", 4) || !strncmp(reg, "%edx", 4)) return "%dx"; if (!strncmp(reg, "%rsi", 5) || !strncmp(reg, "%esi", 4)) return "%si"; if (!strncmp(reg, "%rdi", 5) || !strncmp(reg, "%edi", 4)) return "%di"; if (!strncmp(reg, "%rbp", 5) || !strncmp(reg, "%ebp", 4)) return "%bp"; if (!strncmp(reg, "%rsp", 5) || !strncmp(reg, "%esp", 4)) return "%sp"; if (!strncmp(reg, "%r8", 3)) return "%r8w"; if (!strncmp(reg, "%r9", 3)) return "%r9w"; if (!strncmp(reg, "%r10", 4)) return "%r10w"; if (!strncmp(reg, "%r11", 4)) return "%r11w"; if (!strncmp(reg, "%r12", 4)) return "%r12w"; if (!strncmp(reg, "%r13", 4)) return "%r13w"; if (!strncmp(reg, "%r14", 4)) return "%r14w"; if (!strncmp(reg, "%r15", 4)) return "%r15w"; return NULL; } chibicc-1.0.23.1/hashmap.c000066400000000000000000000114321505335450300151110ustar00rootroot00000000000000// This is an implementation of the open-addressing hash table. #include "chibicc.h" #define HASHMAP_C "hashmap.c" // Initial hash bucket size #define INIT_SIZE 16 // Rehash if the usage exceeds 70%. #define HIGH_WATERMARK 70 // We'll keep the usage below 50% after rehashing. #define LOW_WATERMARK 50 // Represents a deleted hash entry #define TOMBSTONE ((void *)-1) static uint64_t fnv_hash(char *s, int len) { uint64_t hash = 0xcbf29ce484222325; for (int i = 0; i < len; i++) { hash *= 0x100000001b3; hash ^= (unsigned char)s[i]; } return hash; } // Make room for new entries in a given hashmap by removing // tombstones and possibly extending the bucket size. static void rehash(HashMap *map) { // Compute the size of the new hashmap. int nkeys = 0; for (int i = 0; i < map->capacity; i++) if (map->buckets[i].key && map->buckets[i].key != TOMBSTONE) nkeys++; int cap = map->capacity; while ((nkeys * 100) / cap >= LOW_WATERMARK) cap = cap * 2; assert(cap > 0); // Create a new hashmap and copy all key-values. HashMap map2 = {}; map2.buckets = calloc(cap, sizeof(HashEntry)); if (map2.buckets == NULL) error("%s: %s:%d: error: in rehash map2.buckets is null!", HASHMAP_C, __FILE__, __LINE__); map2.capacity = cap; for (int i = 0; i < map->capacity; i++) { HashEntry *ent = &map->buckets[i]; if (ent->key && ent->key != TOMBSTONE) hashmap_put2(&map2, ent->key, ent->keylen, ent->val); } assert(map2.used == nkeys); *map = map2; } static bool match(HashEntry *ent, char *key, int keylen) { return ent->key && ent->key != TOMBSTONE && ent->keylen == keylen && memcmp(ent->key, key, keylen) == 0; } static HashEntry *get_entry(HashMap *map, char *key, int keylen) { if (!map->buckets) return NULL; uint64_t hash = fnv_hash(key, keylen); for (int i = 0; i < map->capacity; i++) { HashEntry *ent = &map->buckets[(hash + i) % map->capacity]; if (match(ent, key, keylen)) return ent; if (ent->key == NULL) return NULL; } unreachable(); } static HashEntry *get_or_insert_entry(HashMap *map, char *key, int keylen) { if (!map->buckets) { map->buckets = calloc(INIT_SIZE, sizeof(HashEntry)); if (map->buckets == NULL) error("%s: %s:%d: error: in get_or_insert_entry map->buckets is null!", HASHMAP_C, __FILE__, __LINE__); map->capacity = INIT_SIZE; } else if ((map->used * 100) / map->capacity >= HIGH_WATERMARK) { rehash(map); } uint64_t hash = fnv_hash(key, keylen); for (int i = 0; i < map->capacity; i++) { HashEntry *ent = &map->buckets[(hash + i) % map->capacity]; if (match(ent, key, keylen)) return ent; // if (ent->key == TOMBSTONE) // { // ent->key = key; // ent->keylen = keylen; // return ent; // } if (ent->key == NULL) { ent->key = key; ent->keylen = keylen; map->used++; return ent; } } unreachable(); } void *hashmap_get(HashMap *map, char *key) { return hashmap_get2(map, key, strlen(key)); } void *hashmap_get2(HashMap *map, char *key, int keylen) { HashEntry *ent = get_entry(map, key, keylen); return ent ? ent->val : NULL; } void hashmap_put(HashMap *map, char *key, void *val) { hashmap_put2(map, key, strlen(key), val); } void hashmap_put2(HashMap *map, char *key, int keylen, void *val) { HashEntry *ent = get_or_insert_entry(map, key, keylen); ent->val = val; } void hashmap_delete(HashMap *map, char *key) { hashmap_delete2(map, key, strlen(key)); } void hashmap_delete2(HashMap *map, char *key, int keylen) { HashEntry *ent = get_entry(map, key, keylen); if (ent) ent->key = TOMBSTONE; } void hashmap_test(void) { HashMap *map = calloc(1, sizeof(HashMap)); for (int i = 0; i < 5000; i++) hashmap_put(map, format("key %d", i), (void *)(size_t)i); for (int i = 1000; i < 2000; i++) hashmap_delete(map, format("key %d", i)); for (int i = 1500; i < 1600; i++) hashmap_put(map, format("key %d", i), (void *)(size_t)i); for (int i = 6000; i < 7000; i++) hashmap_put(map, format("key %d", i), (void *)(size_t)i); for (int i = 0; i < 1000; i++) assert((size_t)hashmap_get(map, format("key %d", i)) == i); for (int i = 1000; i < 1500; i++) assert(hashmap_get(map, "no such key") == NULL); for (int i = 1500; i < 1600; i++) assert((size_t)hashmap_get(map, format("key %d", i)) == i); for (int i = 1600; i < 2000; i++) assert(hashmap_get(map, "no such key") == NULL); for (int i = 2000; i < 5000; i++) assert((size_t)hashmap_get(map, format("key %d", i)) == i); for (int i = 5000; i < 6000; i++) assert(hashmap_get(map, "no such key") == NULL); for (int i = 6000; i < 7000; i++) hashmap_put(map, format("key %d", i), (void *)(size_t)i); assert(hashmap_get(map, "no such key") == NULL); free(map); }chibicc-1.0.23.1/include/000077500000000000000000000000001505335450300147465ustar00rootroot00000000000000chibicc-1.0.23.1/include/cpuid.h000066400000000000000000000261031505335450300162250ustar00rootroot00000000000000/* * Copyright (C) 2007-2025 Free Software Foundation, Inc. * * This file is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 3, or (at your option) any * later version. * * This file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * Under Section 7 of GPL version 3, you are granted additional * permissions described in the GCC Runtime Library Exception, version * 3.1, as published by the Free Software Foundation. * * You should have received a copy of the GNU General Public License and * a copy of the GCC Runtime Library Exception along with this program; * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see * . */ #ifndef _CPUID_H_INCLUDED #define _CPUID_H_INCLUDED /* %ecx */ #define bit_SSE3 (1 << 0) #define bit_PCLMUL (1 << 1) #define bit_LZCNT (1 << 5) #define bit_SSSE3 (1 << 9) #define bit_FMA (1 << 12) #define bit_CMPXCHG16B (1 << 13) #define bit_SSE4_1 (1 << 19) #define bit_SSE4_2 (1 << 20) #define bit_MOVBE (1 << 22) #define bit_POPCNT (1 << 23) #define bit_AES (1 << 25) #define bit_XSAVE (1 << 26) #define bit_OSXSAVE (1 << 27) #define bit_AVX (1 << 28) #define bit_F16C (1 << 29) #define bit_RDRND (1 << 30) /* %edx */ #define bit_CMPXCHG8B (1 << 8) #define bit_CMOV (1 << 15) #define bit_MMX (1 << 23) #define bit_FXSAVE (1 << 24) #define bit_SSE (1 << 25) #define bit_SSE2 (1 << 26) /* Extended Features (%eax == 0x80000001) */ /* %ecx */ #define bit_LAHF_LM (1 << 0) #define bit_ABM (1 << 5) #define bit_SSE4a (1 << 6) #define bit_PRFCHW (1 << 8) #define bit_XOP (1 << 11) #define bit_LWP (1 << 15) #define bit_FMA4 (1 << 16) #define bit_TBM (1 << 21) #define bit_MWAITX (1 << 29) /* %edx */ #define bit_MMXEXT (1 << 22) #define bit_LM (1 << 29) #define bit_3DNOWP (1 << 30) #define bit_3DNOW (1u << 31) /* %ebx */ #define bit_CLZERO (1 << 0) #define bit_WBNOINVD (1 << 9) /* Extended Features Leaf (%eax == 7, %ecx == 0) */ /* %ebx */ #define bit_FSGSBASE (1 << 0) #define bit_SGX (1 << 2) #define bit_BMI (1 << 3) #define bit_HLE (1 << 4) #define bit_AVX2 (1 << 5) #define bit_BMI2 (1 << 8) #define bit_RTM (1 << 11) #define bit_AVX512F (1 << 16) #define bit_AVX512DQ (1 << 17) #define bit_RDSEED (1 << 18) #define bit_ADX (1 << 19) #define bit_AVX512IFMA (1 << 21) #define bit_CLFLUSHOPT (1 << 23) #define bit_CLWB (1 << 24) #define bit_AVX512CD (1 << 28) #define bit_SHA (1 << 29) #define bit_AVX512BW (1 << 30) #define bit_AVX512VL (1u << 31) /* %ecx */ #define bit_AVX512VBMI (1 << 1) #define bit_PKU (1 << 3) #define bit_OSPKE (1 << 4) #define bit_WAITPKG (1 << 5) #define bit_AVX512VBMI2 (1 << 6) #define bit_SHSTK (1 << 7) #define bit_GFNI (1 << 8) #define bit_VAES (1 << 9) #define bit_VPCLMULQDQ (1 << 10) #define bit_AVX512VNNI (1 << 11) #define bit_AVX512BITALG (1 << 12) #define bit_AVX512VPOPCNTDQ (1 << 14) #define bit_RDPID (1 << 22) #define bit_KL (1 << 23) #define bit_CLDEMOTE (1 << 25) #define bit_MOVDIRI (1 << 27) #define bit_MOVDIR64B (1 << 28) #define bit_ENQCMD (1 << 29) /* %edx */ #define bit_UINTR (1 << 5) #define bit_AVX512VP2INTERSECT (1 << 8) #define bit_SERIALIZE (1 << 14) #define bit_TSXLDTRK (1 << 16) #define bit_PCONFIG (1 << 18) #define bit_IBT (1 << 20) #define bit_AMX_BF16 (1 << 22) #define bit_AVX512FP16 (1 << 23) #define bit_AMX_TILE (1 << 24) #define bit_AMX_INT8 (1 << 25) /* Extended Features Sub-leaf (%eax == 7, %ecx == 1) */ /* %eax */ #define bit_SHA512 (1 << 0) #define bit_SM3 (1 << 1) #define bit_SM4 (1 << 2) #define bit_RAOINT (1 << 3) #define bit_AVXVNNI (1 << 4) #define bit_AVX512BF16 (1 << 5) #define bit_CMPCCXADD (1 << 7) #define bit_AMX_COMPLEX (1 << 8) #define bit_AMX_FP16 (1 << 21) #define bit_HRESET (1 << 22) #define bit_AVXIFMA (1 << 23) #define bit_MOVRS (1 << 31) /* %edx */ #define bit_AVXVNNIINT8 (1 << 4) #define bit_AVXNECONVERT (1 << 5) #define bit_AVXVNNIINT16 (1 << 10) #define bit_PREFETCHI (1 << 14) #define bit_USER_MSR (1 << 15) #define bit_AVX10 (1 << 19) #define bit_APX_F (1 << 21) /* Extended State Enumeration Sub-leaf (%eax == 0xd, %ecx == 1) */ #define bit_XSAVEOPT (1 << 0) #define bit_XSAVEC (1 << 1) #define bit_XSAVES (1 << 3) /* PT sub leaf (%eax == 0x14, %ecx == 0) */ /* %ebx */ #define bit_PTWRITE (1 << 4) /* Keylocker leaf (%eax == 0x19) */ /* %ebx */ #define bit_AESKLE ( 1<<0 ) #define bit_WIDEKL ( 1<<2 ) /* AMX sub leaf (%eax == 0x1e, %ecx == 1) */ /* %eax */ #define bit_AMX_FP8 (1 << 4) #define bit_AMX_TRANSPOSE (1 << 5) #define bit_AMX_TF32 (1 << 6) #define bit_AMX_AVX512 (1 << 7) #define bit_AMX_MOVRS (1 << 8) /* Signatures for different CPU implementations as returned in uses of cpuid with level 0. */ #define signature_AMD_ebx 0x68747541 #define signature_AMD_ecx 0x444d4163 #define signature_AMD_edx 0x69746e65 #define signature_CENTAUR_ebx 0x746e6543 #define signature_CENTAUR_ecx 0x736c7561 #define signature_CENTAUR_edx 0x48727561 #define signature_CYRIX_ebx 0x69727943 #define signature_CYRIX_ecx 0x64616574 #define signature_CYRIX_edx 0x736e4978 #define signature_INTEL_ebx 0x756e6547 #define signature_INTEL_ecx 0x6c65746e #define signature_INTEL_edx 0x49656e69 #define signature_TM1_ebx 0x6e617254 #define signature_TM1_ecx 0x55504361 #define signature_TM1_edx 0x74656d73 #define signature_TM2_ebx 0x756e6547 #define signature_TM2_ecx 0x3638784d #define signature_TM2_edx 0x54656e69 #define signature_NSC_ebx 0x646f6547 #define signature_NSC_ecx 0x43534e20 #define signature_NSC_edx 0x79622065 #define signature_NEXGEN_ebx 0x4778654e #define signature_NEXGEN_ecx 0x6e657669 #define signature_NEXGEN_edx 0x72446e65 #define signature_RISE_ebx 0x65736952 #define signature_RISE_ecx 0x65736952 #define signature_RISE_edx 0x65736952 #define signature_SIS_ebx 0x20536953 #define signature_SIS_ecx 0x20536953 #define signature_SIS_edx 0x20536953 #define signature_UMC_ebx 0x20434d55 #define signature_UMC_ecx 0x20434d55 #define signature_UMC_edx 0x20434d55 #define signature_VIA_ebx 0x20414956 #define signature_VIA_ecx 0x20414956 #define signature_VIA_edx 0x20414956 #define signature_VORTEX_ebx 0x74726f56 #define signature_VORTEX_ecx 0x436f5320 #define signature_VORTEX_edx 0x36387865 #define signature_SHANGHAI_ebx 0x68532020 #define signature_SHANGHAI_ecx 0x20206961 #define signature_SHANGHAI_edx 0x68676e61 #ifndef __x86_64__ /* At least one cpu (Winchip 2) does not set %ebx and %ecx for cpuid leaf 1. Forcibly zero the two registers before calling cpuid as a precaution. */ #define __cpuid(level, a, b, c, d) \ do { \ if (__builtin_constant_p (level) && (level) != 1) \ __asm__ __volatile__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level)); \ else \ __asm__ __volatile__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level), "1" (0), "2" (0)); \ } while (0) #else #define __cpuid(level, a, b, c, d) \ __asm__ __volatile__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level)) #endif // #define __cpuid_count(level, count, a, b, c, d) \ // __asm__ __volatile__ ("cpuid\n\t" \ // : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ // : "0" (level), "2" (count)) static inline void __cpuid_count(int info, int subinfo, int eax, int ebx, int ecx, int edx) { int *peax = &eax; int *pebx = &ebx; int *pecx = &ecx; int *pedx = &edx; __asm__ __volatile__ ( "cpuid" : "=a" (*peax), "=b" (*pebx), "=c" (*pecx), "=d" (*pedx) : "0" (info), "2" (subinfo) ); } /* Return highest supported input value for cpuid instruction. ext can be either 0x0 or 0x80000000 to return highest supported value for basic or extended cpuid information. Function returns 0 if cpuid is not supported or whatever cpuid returns in eax register. If sig pointer is non-null, then first four bytes of the signature (as found in ebx register) are returned in location pointed by sig. */ static __inline unsigned int __get_cpuid_max (unsigned int __ext, unsigned int *__sig) { unsigned int __eax, __ebx, __ecx, __edx; #ifndef __x86_64__ /* See if we can use cpuid. On AMD64 we always can. */ #if __GNUC__ >= 3 __asm__ ("pushf{l|d}\n\t" "pushf{l|d}\n\t" "pop{l}\t%0\n\t" "mov{l}\t{%0, %1|%1, %0}\n\t" "xor{l}\t{%2, %0|%0, %2}\n\t" "push{l}\t%0\n\t" "popf{l|d}\n\t" "pushf{l|d}\n\t" "pop{l}\t%0\n\t" "popf{l|d}\n\t" : "=&r" (__eax), "=&r" (__ebx) : "i" (0x00200000)); #else /* Host GCCs older than 3.0 weren't supporting Intel asm syntax nor alternatives in i386 code. */ __asm__ ("pushfl\n\t" "pushfl\n\t" "popl\t%0\n\t" "movl\t%0, %1\n\t" "xorl\t%2, %0\n\t" "pushl\t%0\n\t" "popfl\n\t" "pushfl\n\t" "popl\t%0\n\t" "popfl\n\t" : "=&r" (__eax), "=&r" (__ebx) : "i" (0x00200000)); #endif if (__builtin_expect (!((__eax ^ __ebx) & 0x00200000), 0)) return 0; #endif /* Host supports cpuid. Return highest supported cpuid input value. */ __cpuid (__ext, __eax, __ebx, __ecx, __edx); if (__sig) *__sig = __ebx; return __eax; } /* Return cpuid data for requested cpuid leaf, as found in returned eax, ebx, ecx and edx registers. The function checks if cpuid is supported and returns 1 for valid cpuid information or 0 for unsupported cpuid leaf. All pointers are required to be non-null. */ static __inline int __get_cpuid (unsigned int __leaf, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx) { unsigned int __ext = __leaf & 0x80000000; unsigned int __maxlevel = __get_cpuid_max (__ext, 0); if (__maxlevel == 0 || __maxlevel < __leaf) return 0; __cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx); return 1; } /* Same as above, but sub-leaf can be specified. */ static __inline int __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx) { unsigned int __ext = __leaf & 0x80000000; unsigned int __maxlevel = __get_cpuid_max (__ext, 0); if (__builtin_expect (__maxlevel == 0, 0) || __maxlevel < __leaf) return 0; __cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx); return 1; } static __inline void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf) { __cpuid_count (__leaf, __subleaf, __cpuid_info[0], __cpuid_info[1], __cpuid_info[2], __cpuid_info[3]); } #endif /* _CPUID_H_INCLUDED */chibicc-1.0.23.1/include/float.h000077500000000000000000000020231505335450300162240ustar00rootroot00000000000000#ifndef __STDFLOAT_H #define __STDFLOAT_H #define DECIMAL_DIG 21 #define FLT_EVAL_METHOD 0 // C11 5.2.4.2.2p9 #define FLT_RADIX 2 #define FLT_ROUNDS 1 // C11 5.2.4.2.2p8: to nearest #define FLT_DIG 6 #define FLT_EPSILON 0x1p-23 #define FLT_MANT_DIG 24 #define FLT_MAX 0x1.fffffep+127 #define FLT_MAX_10_EXP 38 #define FLT_MAX_EXP 128 #define FLT_MIN 0x1p-126 #define FLT_MIN_10_EXP -37 #define FLT_MIN_EXP -125 #define FLT_TRUE_MIN 0x1p-149 #define DBL_DIG 15 #define DBL_EPSILON 0x1p-52 #define DBL_MANT_DIG 53 #define DBL_MAX 0x1.fffffffffffffp+1023 #define DBL_MAX_10_EXP 308 #define DBL_MAX_EXP 1024 #define DBL_MIN 0x1p-1022 #define DBL_MIN_10_EXP -307 #define DBL_MIN_EXP -1021 #define DBL_TRUE_MIN 0x0.0000000000001p-1022 #define LDBL_DIG 15 #define LDBL_EPSILON 0x1p-52 #define LDBL_MANT_DIG 53 #define LDBL_MAX 0x1.fffffffffffffp+1023 #define LDBL_MAX_10_EXP 308 #define LDBL_MAX_EXP 1024 #define LDBL_MIN 0x1p-1022 #define LDBL_MIN_10_EXP -307 #define LDBL_MIN_EXP -1021 #define LDBL_TRUE_MIN 0x0.0000000000001p-1022 #endifchibicc-1.0.23.1/include/limits.h000066400000000000000000000160551505335450300164270ustar00rootroot00000000000000/* Copyright (C) 1991-2022 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see . */ /* * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types */ #ifndef _LIBC_LIMITS_H_ #define _LIBC_LIMITS_H_ 1 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION #include /* Maximum length of any multibyte character in any locale. We define this value here since the gcc header does not define the correct value. */ #define MB_LEN_MAX 16 /* Limits of integral types */ #define CHAR_BIT 8 /* Number of bits in a char */ #define SCHAR_MIN (-128) /* Minimum value of a signed char */ #define SCHAR_MAX 127 /* Maximum value of a signed char */ #define UCHAR_MAX 255 /* Maximum value of an unsigned char */ #define CHAR_MIN SCHAR_MIN /* Minimum value of a char */ #define CHAR_MAX SCHAR_MAX /* Maximum value of a char */ #define SHRT_MIN (-32768) /* Minimum value of a short int */ #define SHRT_MAX 32767 /* Maximum value of a short int */ #define USHRT_MAX 65535 /* Maximum value of an unsigned short int */ #define INT_MIN (-2147483648) /* Minimum value of an int */ #define INT_MAX 2147483647 /* Maximum value of an int */ #define UINT_MAX 4294967295U /* Maximum value of an unsigned int */ #define LONG_MIN (-9223372036854775808L) /* Minimum value of a long int */ #define LONG_MAX 9223372036854775807L /* Maximum value of a long int */ #define ULONG_MAX 18446744073709551615UL /* Maximum value of an unsigned long int */ /* Limits of other types */ #define LLONG_MIN (-9223372036854775808LL) /* Minimum value of a long long int */ #define LLONG_MAX 9223372036854775807LL /* Maximum value of a long long int */ #define ULLONG_MAX 18446744073709551615ULL /* Maximum value of an unsigned long long int */ /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 /* We only protect from multiple inclusion here, because all the other #include's protect themselves, and in GCC 2 we may #include_next through multiple copies of this file before we get to GCC's. */ # ifndef _LIMITS_H # define _LIMITS_H 1 #include /* We don't have #include_next. Define ANSI for standard 32-bit words. */ /* These assume 8-bit `char's, 16-bit `short int's, and 32-bit `int's and `long int's. */ /* Number of bits in a `char'. */ # define CHAR_BIT 8 /* Minimum and maximum values a `signed char' can hold. */ # define SCHAR_MIN (-128) # define SCHAR_MAX 127 /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */ # define UCHAR_MAX 255 /* Minimum and maximum values a `char' can hold. */ # ifdef __CHAR_UNSIGNED__ # define CHAR_MIN 0 # define CHAR_MAX UCHAR_MAX # else # define CHAR_MIN SCHAR_MIN # define CHAR_MAX SCHAR_MAX # endif /* Minimum and maximum values a `signed short int' can hold. */ # define SHRT_MIN (-32768) # define SHRT_MAX 32767 /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ # define USHRT_MAX 65535 /* Minimum and maximum values a `signed int' can hold. */ # define INT_MIN (-INT_MAX - 1) # define INT_MAX 2147483647 /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */ # define UINT_MAX 4294967295U /* Minimum and maximum values a `signed long int' can hold. */ # if __WORDSIZE == 64 # define LONG_MAX 9223372036854775807L # else # define LONG_MAX 2147483647L # endif # define LONG_MIN (-LONG_MAX - 1L) /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ # if __WORDSIZE == 64 # define ULONG_MAX 18446744073709551615UL # else # define ULONG_MAX 4294967295UL # endif # ifdef __USE_ISOC99 /* Minimum and maximum values a `signed long long int' can hold. */ # define LLONG_MAX 9223372036854775807LL # define LLONG_MIN (-LLONG_MAX - 1LL) /* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ # define ULLONG_MAX 18446744073709551615ULL # endif /* ISO C99 */ # endif /* limits.h */ #endif /* GCC 2. */ #endif /* !_LIBC_LIMITS_H_ */ /* Get the compiler's limits.h, which defines almost all the ISO constants. We put this #include_next outside the double inclusion check because it should be possible to include this file more than once and still get the definitions from gcc's header. */ // #if defined __GNUC__ && !defined _GCC_LIMITS_H_ // /* `_GCC_LIMITS_H_' is what GCC's file defines. */ // # include_next // #endif /* The files in some gcc versions don't define LLONG_MIN, LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for ages are available. */ #if defined __USE_ISOC99 && defined __GNUC__ # ifndef LLONG_MIN # define LLONG_MIN (-LLONG_MAX-1) # endif # ifndef LLONG_MAX # define LLONG_MAX __LONG_LONG_MAX__ # endif # ifndef ULLONG_MAX # define ULLONG_MAX (LLONG_MAX * 2ULL + 1) # endif #endif /* The integer width macros are not defined by GCC's before GCC 7, or if _GNU_SOURCE rather than __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. */ #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) # ifndef CHAR_WIDTH # define CHAR_WIDTH 8 # endif # ifndef SCHAR_WIDTH # define SCHAR_WIDTH 8 # endif # ifndef UCHAR_WIDTH # define UCHAR_WIDTH 8 # endif # ifndef SHRT_WIDTH # define SHRT_WIDTH 16 # endif # ifndef USHRT_WIDTH # define USHRT_WIDTH 16 # endif # ifndef INT_WIDTH # define INT_WIDTH 32 # endif # ifndef UINT_WIDTH # define UINT_WIDTH 32 # endif # ifndef LONG_WIDTH # define LONG_WIDTH __WORDSIZE # endif # ifndef ULONG_WIDTH # define ULONG_WIDTH __WORDSIZE # endif # ifndef LLONG_WIDTH # define LLONG_WIDTH 64 # endif # ifndef ULLONG_WIDTH # define ULLONG_WIDTH 64 # endif #endif /* Use IEC_60559_BFP_EXT. */ /* The macros for _Bool are not defined by GCC's before GCC 11, or if _GNU_SOURCE is defined rather than enabling C2x support with -std. */ #if __GLIBC_USE (ISOC2X) # ifndef BOOL_MAX # define BOOL_MAX 1 # endif # ifndef BOOL_WIDTH # define BOOL_WIDTH 1 # endif #endif #ifdef __USE_POSIX /* POSIX adds things to . */ # include #endif #ifdef __USE_POSIX2 # include #endif #ifdef __USE_XOPEN # include #endifchibicc-1.0.23.1/include/math.h000066400000000000000000000130161505335450300160510ustar00rootroot00000000000000#ifndef CHIBICC_MATH_H #define CHIBICC_MATH_H // Trigonometric functions double sin(double x); double cos(double x); double tan(double x); double asin(double x); double acos(double x); double atan(double x); double atan2(double y, double x); // Hyperbolic functions double sinh(double x); double cosh(double x); double tanh(double x); // Exponential and logarithmic functions double exp(double x); double frexp(double x, int *exp); double ldexp(double x, int exp); double log(double x); double log10(double x); double modf(double x, double *iptr); float expf(float); long double expl(long double); extern float powf(float x, float y); extern double pow(double x, double y); extern long double powl(long double x, long double y); extern float log10f(float x); extern double log10(double x); extern long double log10l(long double x); extern long lroundf(float x); extern long lround(double x); extern long lroundl(long double x); // Power and absolute-value functions double pow(double x, double y); double sqrt(double x); double fabs(double x); double fmod(double x, double y); float sqrtf(float); long double sqrtl(long double); float fabsf(float x); long double fabsl(long double x); double cbrt(double x); float cbrtf(float x); long double cbrtl(long double x); double asinh(double x); float asinhf(float x); long double asinhl(long double x); double acosh(double x); float acoshf(float x); long double acoshl(long double x); double atanh(double x); float atanhf(float x); long double atanhl(long double x); double erf(double x); float erff(float x); long double erfl(long double x); double erfc(double x); float erfcf(float x); long double erfcl(long double x); double tgamma(double x); float tgammaf(float x); long double tgammal(long double x); double lgamma(double x); float lgammaf(float x); long double lgammal(long double x); double log1p(double); float log1pf(float); long double log1pl(long double); extern float fmodf(float x, float y); extern long double fmodl(long double x, long double y); extern long long llroundl(long double x); extern long long llround(double x); extern long long llroundf(float x); extern float roundf(float x); extern double round(double x); extern long double roundl(long double x); static inline int isless(double x, double y) { return x < y; } static inline int isgreater(double x, double y){ return x > y; } static inline int islessequal(double x, double y) { return x <= y; } static inline int isgreaterequal(double x, double y) { return x >= y; } static inline int islessf(float x, float y) { return x < y; } static inline int isgreaterf(float x, float y){ return x > y; } static inline int islessequalf(float x, float y) { return x <= y; } static inline int isgreaterequalf(float x, float y) { return x >= y; } extern float sinf(float x); extern float cosf(float x); extern float tanf(float x); extern float asinf(float x); extern float acosf(float x); extern float atanf(float x); extern float atan2f(float y, float x); float floorf(float); float ldexpf(float x, int exp); // Rounding and remainder double floor(double x); double ceil(double x); double trunc(double x); double round(double x); double nearbyint(double x); double rint(double x); long double floorl(long double); long double ceill(long double); double fma(double x, double y, double z); // fused multiply-add (optional, used in numerics) double copysign(double x, double y); // result has magnitude of x and sign of y double hypot(double x, double y); // sqrt(x*x + y*y) double log2(double x); // base-2 log double exp2(double x); // base-2 exponent double fmax(double x, double y); float fmaxf(float x, float y); long double fmaxl(long double x, long double y); double fmin(double x, double y); float fminf(float x, float y); long double fminl(long double x, long double y); double nextafter(double x, double y); float nextafterf(float x, float y); long double nextafterl(long double x, long double y); float nanf(const char *tagp); double expm1(double x); float expm1f(float x); long double expm1l(long double x); int isnormal(double x); // non-zero and not subnormal #define isnormal(x) ((fpclassify(x) == FP_NORMAL)) #define signbit(x) __builtin_signbit(x) #define __builtin_signbit(x) ((x) < 0.0 ? 1 : 0) // Classification extern int __fpclassify(double __value); extern int __isnan(double __value); extern int __isinf(double __value); extern int __finite(double __value); // Add missing standard macros #define isnan(x) __isnan(x) #define isinf(x) __isinf(x) #define isfinite(x) __finite(x) #define fpclassify(x) __fpclassify(x) // Constants #define HUGE_VAL (__builtin_huge_val()) #define HUGE_VALF (__builtin_huge_valf()) #define HUGE_VALL (__builtin_huge_vall()) #define NAN (__builtin_nan("")) #define INFINITY (__builtin_inff()) #define M_E 2.71828182845904523536 #define M_LOG2E 1.44269504088896340736 #define M_LOG10E 0.43429448190325182765 #define M_LN2 0.69314718055994530942 #define M_LN10 2.30258509299404568402 #define M_PI 3.14159265358979323846 #define M_PI_2 1.57079632679489661923 #define M_PI_4 0.78539816339744830962 #define M_1_PI 0.31830988618379067154 #define M_2_PI 0.63661977236758134308 #define M_2_SQRTPI 1.12837916709551257390 #define M_SQRT2 1.41421356237309504880 #define M_SQRT1_2 0.70710678118654752440 #define FP_INFINITE 1 #define FP_NAN 2 #define FP_NORMAL 3 #define FP_SUBNORMAL 4 #define FP_ZERO 5 typedef float float_t; typedef double double_t; #endif // CHIBICC_MATH_H chibicc-1.0.23.1/include/mm_malloc.h000066400000000000000000000033661505335450300170670ustar00rootroot00000000000000/* Copyright (C) 2004-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifndef _MM_MALLOC_H_INCLUDED #define _MM_MALLOC_H_INCLUDED #include /* We can't depend on since the prototype of posix_memalign may not be visible. */ #ifndef __cplusplus extern int posix_memalign (void **, size_t, size_t); #else extern "C" int posix_memalign (void **, size_t, size_t) throw (); #endif static __inline void * _mm_malloc (size_t __size, size_t __alignment) { void *__ptr; if (__alignment == 1) return malloc (__size); if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4)) __alignment = sizeof (void *); if (posix_memalign (&__ptr, __alignment, __size) == 0) return __ptr; else return NULL; } static __inline void _mm_free (void *__ptr) { free (__ptr); } #endif /* _MM_MALLOC_H_INCLUDED */ chibicc-1.0.23.1/include/stdalign.h000077500000000000000000000002431505335450300167260ustar00rootroot00000000000000#ifndef __STDALIGN_H #define __STDALIGN_H #define alignas _Alignas #define alignof _Alignof #define __alignas_is_defined 1 #define __alignof_is_defined 1 #endif chibicc-1.0.23.1/include/stdarg.h000077500000000000000000000036311505335450300164110ustar00rootroot00000000000000#ifndef __STDARG_H #define __STDARG_H typedef struct { unsigned int gp_offset; unsigned int fp_offset; void *overflow_arg_area; void *reg_save_area; } __va_elem; typedef __va_elem va_list[1]; typedef unsigned long uintptr_t; extern int printf(const char *fmt, ...); #define va_start(ap, last) \ do { *(ap) = *(__va_elem *)__va_area__; } while (0) #define va_end(ap) //for now alignment is not correctly managed by chibicc when we have variadic functions. //we store into the stack by substracting directly the sz of the component (aligned to 8 or 16) //but we need a more robust way to manage alignment and activate here the correct alignment. static void *__va_arg_mem(__va_elem *ap, int sz, int align) { void *p = ap->overflow_arg_area; // if (align > 16) { // p = (void *)(((uintptr_t)p + align - 1) & ~(align - 1)); // } ap->overflow_arg_area = (void *)(((unsigned long)p + sz + 7) / 8 * 8); return p; } static void *__va_arg_gp(__va_elem *ap, int sz, int align) { if (ap->gp_offset >= 48) return __va_arg_mem(ap, sz, align); void *r = ap->reg_save_area + ap->gp_offset; ap->gp_offset += 8; return r; } static void *__va_arg_fp(__va_elem *ap, int sz, int align) { if (ap->fp_offset >= 176) return __va_arg_mem(ap, sz, align); void *r = ap->reg_save_area + ap->fp_offset; ap->fp_offset += 16; return r; } #define va_arg(ap, ty) \ ({ \ int klass = __builtin_reg_class(ty); \ *(ty *)(klass == 0 ? __va_arg_gp(ap, sizeof(ty), _Alignof(ty)) : \ klass == 1 ? __va_arg_fp(ap, sizeof(ty), _Alignof(ty)) : \ __va_arg_mem(ap, sizeof(ty), _Alignof(ty))); \ }) #define va_copy(dest, src) ((dest)[0] = (src)[0]) #define __GNUC_VA_LIST 1 typedef va_list __gnuc_va_list; #endifchibicc-1.0.23.1/include/stdatomic.h000077500000000000000000000151051505335450300171130ustar00rootroot00000000000000#ifndef __STDATOMIC_H #define __STDATOMIC_H #define __ATOMIC_RELAXED 0 #define __ATOMIC_CONSUME 1 #define __ATOMIC_ACQUIRE 2 #define __ATOMIC_RELEASE 3 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_SEQ_CST 5 #define ATOMIC_BOOL_LOCK_FREE 1 #define ATOMIC_CHAR_LOCK_FREE 1 #define ATOMIC_CHAR16_T_LOCK_FREE 1 #define ATOMIC_CHAR32_T_LOCK_FREE 1 #define ATOMIC_WCHAR_T_LOCK_FREE 1 #define ATOMIC_SHORT_LOCK_FREE 1 #define ATOMIC_INT_LOCK_FREE 1 #define ATOMIC_LONG_LOCK_FREE 1 #define ATOMIC_LLONG_LOCK_FREE 1 #define ATOMIC_POINTER_LOCK_FREE 1 #define ATOMIC_VAR_INIT(value) (value) typedef enum { memory_order_relaxed, memory_order_consume, memory_order_acquire, memory_order_release, memory_order_acq_rel, memory_order_seq_cst, } memory_order; #define true 1 #define false 0 //#define ATOMIC_FLAG_INIT(x) (x) #define ATOMIC_FLAG_INIT { 0 } #define atomic_init(addr, val) (*(addr) = (val)) #define kill_dependency(x) (x) #define atomic_thread_fence(order) #define atomic_signal_fence(order) #define atomic_is_lock_free(x) 1 // #define atomic_load(addr) (*(addr)) // #define atomic_store(addr, val) (*(addr) = (val)) // #define atomic_load_explicit(addr, order) (*(addr)) // #define atomic_store_explicit(addr, val, order) (*(addr) = (val)) // #define atomic_fetch_add(obj, val) (*(obj) += (val)) // #define atomic_fetch_sub(obj, val) (*(obj) -= (val)) // #define atomic_fetch_or(obj, val) (*(obj) |= (val)) // #define atomic_fetch_xor(obj, val) (*(obj) ^= (val)) // #define atomic_fetch_and(obj, val) (*(obj) &= (val)) #define atomic_fetch_add(obj, val) __builtin_atomic_fetch_op(obj, val, 0) #define atomic_fetch_sub(obj, val) __builtin_atomic_fetch_op(obj, val, 1) #define atomic_fetch_or(obj, val) __builtin_atomic_fetch_op(obj, val, 2) #define atomic_fetch_xor(obj, val) __builtin_atomic_fetch_op(obj, val, 3) #define atomic_fetch_and(obj, val) __builtin_atomic_fetch_op(obj, val, 4) // #define atomic_fetch_add_explicit(obj, val, order) (*(obj) += (val)) // #define atomic_fetch_sub_explicit(obj, val, order) (*(obj) -= (val)) // #define atomic_fetch_or_explicit(obj, val, order) (*(obj) |= (val)) // #define atomic_fetch_xor_explicit(obj, val, order) (*(obj) ^= (val)) // #define atomic_fetch_and_explicit(obj, val, order) (*(obj) &= (val)) #define atomic_fetch_add_explicit(obj, val, order) atomic_fetch_add(obj, val) #define atomic_fetch_sub_explicit(obj, val, order) atomic_fetch_sub(obj, val) #define atomic_fetch_or_explicit(obj, val, order) atomic_fetch_or(obj, val) #define atomic_fetch_xor_explicit(obj, val, order) atomic_fetch_xor(obj, val) #define atomic_fetch_and_explicit(obj, val, order) atomic_fetch_and(obj, val) #define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ __atomic_compare_exchange_n((obj), (expected), (desired), true, (succ), (fail)) #define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ __atomic_compare_exchange_n((obj), (expected), (desired), false, (succ), (fail)) // #define atomic_compare_exchange_strong_explicit(object, expected, desired, \ // success, failure) false // #define atomic_compare_exchange_weak_explicit(object, expected, desired, \ // success, failure) false #define atomic_compare_exchange_weak(p, old, new) \ __builtin_compare_and_swap((p), (old), (new)) #define atomic_compare_exchange_strong(p, old, new) \ __builtin_compare_and_swap((p), (old), (new)) #define atomic_exchange(obj, val) __builtin_atomic_exchange((obj), (val)) #define atomic_exchange_explicit(obj, val, order) __builtin_atomic_exchange((obj), (val)) // #define atomic_flag_test_and_set(obj) atomic_exchange((obj), 1) // #define atomic_flag_test_and_set_explicit(obj, order) atomic_exchange((obj), 1) // #define atomic_flag_clear(obj) (*(obj) = 0) // #define atomic_flag_clear_explicit(obj, order) (*(obj) = 0) // Other atomic operation macros #define atomic_load(obj) __builtin_atomic_load_n((obj)) #define atomic_load_explicit(obj, order) __builtin_atomic_load_n((obj), (order)) #define atomic_store(obj, val) __builtin_atomic_store_n((obj), (val)) #define atomic_store_explicit(obj, val, order) __builtin_atomic_store_n((obj), (val), (order)) #define atomic_test_and_set(obj) __builtin_atomic_test_and_set((obj)) #define atomic_test_and_set_explicit(obj, order) __builtin_atomic_test_and_set((obj), (order)) #define atomic_flag_test_and_set(obj) __sync_lock_test_and_set(obj, 1) #define atomic_flag_test_and_set_explicit(obj, order) __sync_lock_test_and_set(obj, 1) //#define atomic_flag_clear_explicit(obj, order) __sync_lock_release(obj) //#define atomic_flag_clear(obj) __sync_lock_release(obj) #define atomic_flag_clear(obj) atomic_clear(obj) #define atomic_flag_clear_explicit(obj, order) atomic_clear_explicit(obj, order) #define atomic_clear(obj) __builtin_atomic_clear((obj)) #define atomic_clear_explicit(obj, order) __builtin_atomic_clear((obj), (order)) typedef _Atomic _Bool atomic_flag; typedef _Atomic _Bool atomic_bool; typedef _Atomic char atomic_char; typedef _Atomic signed char atomic_schar; typedef _Atomic unsigned char atomic_uchar; typedef _Atomic short atomic_short; typedef _Atomic unsigned short atomic_ushort; typedef _Atomic int atomic_int; typedef _Atomic unsigned int atomic_uint; typedef _Atomic long atomic_long; typedef _Atomic unsigned long atomic_ulong; typedef _Atomic long long atomic_llong; typedef _Atomic unsigned long long atomic_ullong; typedef _Atomic unsigned short atomic_char16_t; typedef _Atomic unsigned atomic_char32_t; typedef _Atomic unsigned atomic_wchar_t; typedef _Atomic signed char atomic_int_least8_t; typedef _Atomic unsigned char atomic_uint_least8_t; typedef _Atomic short atomic_int_least16_t; typedef _Atomic unsigned short atomic_uint_least16_t; typedef _Atomic int atomic_int_least32_t; typedef _Atomic unsigned int atomic_uint_least32_t; typedef _Atomic long atomic_int_least64_t; typedef _Atomic unsigned long atomic_uint_least64_t; typedef _Atomic signed char atomic_int_fast8_t; typedef _Atomic unsigned char atomic_uint_fast8_t; typedef _Atomic short atomic_int_fast16_t; typedef _Atomic unsigned short atomic_uint_fast16_t; typedef _Atomic int atomic_int_fast32_t; typedef _Atomic unsigned int atomic_uint_fast32_t; typedef _Atomic long atomic_int_fast64_t; typedef _Atomic unsigned long atomic_uint_fast64_t; typedef _Atomic long atomic_intptr_t; typedef _Atomic unsigned long atomic_uintptr_t; typedef _Atomic unsigned long atomic_size_t; typedef _Atomic long atomic_ptrdiff_t; typedef _Atomic long atomic_intmax_t; typedef _Atomic unsigned long atomic_uintmax_t; #endif chibicc-1.0.23.1/include/stdbool.h000077500000000000000000000002131505335450300165640ustar00rootroot00000000000000#ifndef __STDBOOL_H #define __STDBOOL_H #define bool _Bool #define true 1 #define false 0 #define __bool_true_false_are_defined 1 #endif chibicc-1.0.23.1/include/stddef.h000077500000000000000000000027541505335450300164030ustar00rootroot00000000000000#ifndef __STDDEF_H #define __STDDEF_H #define NULL ((void *)0) // Define sizes of various types #define SIZEOF_CHAR 1 #define SIZEOF_SHORT 2 #define SIZEOF_INT 4 // Ensure this is set to 4 #define SIZEOF_LONG 8 #define SIZEOF_LONG_LONG 8 #define SIZEOF_POINTER 8 #define LONG_MAX 9223372036854775807 #define INT_MIN -2147483648 #define INT_MAX 2147483647 typedef unsigned long size_t; typedef long ptrdiff_t; typedef unsigned int wchar_t; typedef long max_align_t; #ifndef __has_attribute #define __has_attribute(x) 1 #endif #define _Pragma(message) #define __builtin_choose_expr(cond, true_expr, false_expr) (cond ? true_expr : false_expr) #define offsetof(type, member) ((size_t)&(((type *)0)->member)) //#define static_assert(x, msg) extern char STATIC_MSG(msg, __LINE__) [(x)?1:-1] // #ifndef _Static_assert #define CONCAT_(prefix, suffix) prefix##suffix /// Concatenate `prefix, suffix` into `prefixsuffix` #define CONCAT(prefix, suffix) CONCAT_(prefix, suffix) #define MAKE_UNIQUE_VARIABLE_NAME(prefix) CONCAT(prefix##_, __LINE__) //#define static_assert(x, msg) extern char STATIC_MSG(msg, __LINE__) [(x)?1:-1] //#define _Static_assert static_assert #define _Static_assert STATIC_ASSERT #define StaticAssertDecl STATIC_ASSERT #define Assert STATIC_ASSERT #define STATIC_ASSERT(COND,MSG) static int MAKE_UNIQUE_VARIABLE_NAME(prefix)[(COND)?1:-1] #define STATIC_ASSERT(COND) static int MAKE_UNIQUE_VARIABLE_NAME(prefix)[(COND)?1:-1] #define STATIC_ASSERT(...) // #endif /* _Static_assert */ #endif chibicc-1.0.23.1/include/stdnoreturn.h000077500000000000000000000001241505335450300175060ustar00rootroot00000000000000#ifndef __STDNORETURN_H #define __STDNORETURN_H #define noreturn _Noreturn #endif chibicc-1.0.23.1/issues/000077500000000000000000000000001505335450300146365ustar00rootroot00000000000000chibicc-1.0.23.1/issues/arch-x86.h000066400000000000000000000162651505335450300163610ustar00rootroot00000000000000/*------------------------------------------------------------------------- * * arch-x86.h * Atomic operations considerations specific to intel x86 * * Note that we actually require a 486 upwards because the 386 doesn't have * support for xadd and cmpxchg. Given that the 386 isn't supported anywhere * anymore that's not much of a restriction luckily. * * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * NOTES: * * src/include/port/atomics/arch-x86.h * *------------------------------------------------------------------------- */ /* * Both 32 and 64 bit x86 do not allow loads to be reordered with other loads, * or stores to be reordered with other stores, but a load can be performed * before a subsequent store. * * Technically, some x86-ish chips support uncached memory access and/or * special instructions that are weakly ordered. In those cases we'd need * the read and write barriers to be lfence and sfence. But since we don't * do those things, a compiler barrier should be enough. * * "lock; addl" has worked for longer than "mfence". It's also rumored to be * faster in many scenarios. */ #if defined(__GNUC__) || defined(__INTEL_COMPILER) #if defined(__i386__) || defined(__i386) #define pg_memory_barrier_impl() \ __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory", "cc") #elif defined(__x86_64__) #define pg_memory_barrier_impl() \ __asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory", "cc") #endif #endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */ #define pg_read_barrier_impl() pg_compiler_barrier_impl() #define pg_write_barrier_impl() pg_compiler_barrier_impl() /* * Provide implementation for atomics using inline assembly on x86 gcc. It's * nice to support older gcc's and the compare/exchange implementation here is * actually more efficient than the * __sync variant. */ #if defined(HAVE_ATOMICS) #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define PG_HAVE_ATOMIC_FLAG_SUPPORT typedef struct pg_atomic_flag { volatile char value; } pg_atomic_flag; #define PG_HAVE_ATOMIC_U32_SUPPORT typedef struct pg_atomic_uint32 { volatile uint32 value; } pg_atomic_uint32; /* * It's too complicated to write inline asm for 64bit types on 32bit and the * 486 can't do it anyway. */ #ifdef __x86_64__ #define PG_HAVE_ATOMIC_U64_SUPPORT typedef struct pg_atomic_uint64 { /* alignment guaranteed due to being on a 64bit platform */ volatile uint64 value; } pg_atomic_uint64; #endif /* __x86_64__ */ #endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */ #endif /* defined(HAVE_ATOMICS) */ #if !defined(PG_HAVE_SPIN_DELAY) /* * This sequence is equivalent to the PAUSE instruction ("rep" is * ignored by old IA32 processors if the following instruction is * not a string operation); the IA-32 Architecture Software * Developer's Manual, Vol. 3, Section 7.7.2 describes why using * PAUSE in the inner loop of a spin lock is necessary for good * performance: * * The PAUSE instruction improves the performance of IA-32 * processors supporting Hyper-Threading Technology when * executing spin-wait loops and other routines where one * thread is accessing a shared lock or semaphore in a tight * polling loop. When executing a spin-wait loop, the * processor can suffer a severe performance penalty when * exiting the loop because it detects a possible memory order * violation and flushes the core processor's pipeline. The * PAUSE instruction provides a hint to the processor that the * code sequence is a spin-wait loop. The processor uses this * hint to avoid the memory order violation and prevent the * pipeline flush. In addition, the PAUSE instruction * de-pipelines the spin-wait loop to prevent it from * consuming execution resources excessively. */ #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define PG_HAVE_SPIN_DELAY static __inline__ void pg_spin_delay_impl(void) { __asm__ __volatile__(" rep; nop \n"); } #elif defined(_MSC_VER) && defined(__x86_64__) #define PG_HAVE_SPIN_DELAY static __forceinline void pg_spin_delay_impl(void) { _mm_pause(); } #elif defined(_MSC_VER) #define PG_HAVE_SPIN_DELAY static __forceinline void pg_spin_delay_impl(void) { /* See comment for gcc code. Same code, MASM syntax */ __asm rep nop; } #endif #endif /* !defined(PG_HAVE_SPIN_DELAY) */ #if defined(HAVE_ATOMICS) #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define PG_HAVE_ATOMIC_TEST_SET_FLAG static inline bool pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr) { char _res = 1; __asm__ __volatile__( " lock \n" " xchgb %0,%1 \n" : "+q"(_res), "+m"(ptr->value) : : "memory"); return _res == 0; } #define PG_HAVE_ATOMIC_CLEAR_FLAG static inline void pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr) { /* * On a TSO architecture like x86 it's sufficient to use a compiler * barrier to achieve release semantics. */ __asm__ __volatile__("" ::: "memory"); ptr->value = 0; } #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32 static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { char ret; /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgl %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); return (bool) ret; } #define PG_HAVE_ATOMIC_FETCH_ADD_U32 static inline uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_) { uint32 res; __asm__ __volatile__( " lock \n" " xaddl %0,%1 \n" : "=q"(res), "=m"(ptr->value) : "0" (add_), "m"(ptr->value) : "memory", "cc"); return res; } #ifdef __x86_64__ #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64 static inline bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval) { char ret; /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgq %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); return (bool) ret; } #define PG_HAVE_ATOMIC_FETCH_ADD_U64 static inline uint64 pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_) { uint64 res; __asm__ __volatile__( " lock \n" " xaddq %0,%1 \n" : "=q"(res), "=m"(ptr->value) : "0" (add_), "m"(ptr->value) : "memory", "cc"); return res; } #endif /* __x86_64__ */ #endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */ /* * 8 byte reads / writes have single-copy atomicity on 32 bit x86 platforms * since at least the 586. As well as on all x86-64 cpus. */ #if defined(__i568__) || defined(__i668__) || /* gcc i586+ */ \ (defined(_M_IX86) && _M_IX86 >= 500) || /* msvc i586+ */ \ defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) /* gcc, sunpro, msvc */ #define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY #endif /* 8 byte single-copy atomicity */ #endif /* HAVE_ATOMICS */ chibicc-1.0.23.1/issues/array2.c000066400000000000000000000014311505335450300162010ustar00rootroot00000000000000#include void add_arrays(float *a, float *b, float *result, int n) { for (int i = 0; i < n; i++) result[i] = a[i] + b[i]; } #include int *get_array() { static int arr[4] = {1, 2, 3, 4}; // Static allows it to live after function ends return arr; // Returning array decays to pointer to first element } int main() { float a[4] = {1.0, 2.0, 3.0, 4.0}; float b[4] = {10.0, 20.0, 30.0, 40.0}; float result[4]; add_arrays(a, b, result, 4); for (int i = 0; i < 4; i++) printf("result[%d] = %.1f\n", i, result[i]); int *a1 = get_array(); printf("a[0]=%d\n", a1[0]); printf("a[1]=%d\n", a1[1]); printf("a[2]=%d\n", a1[2]); printf("a[3]=%d\n", a1[3]); return 0; } chibicc-1.0.23.1/issues/asm1.c000077500000000000000000000533701505335450300156560ustar00rootroot00000000000000ELF>@N@8@ @@@PPP%%000((p=pMpM=MMppp00DDp=pMpMStdppp00Ptd000||QtdRtdp=pMpM/lib64/ld-linux-x86-64.so.2 GNUGNUWn:72du-GNUem1E 'tmf " 9W"putssiglongjmp__stack_chk_failexitsigactionputchar__sigsetjmp__libc_start_main__cxa_finalizememsetprintfgetuidlibc.so.6GLIBC_2.4GLIBC_2.34GLIBC_2.2.5_ITM_deregisterTMCloneTable__gmon_start___ITM_registerTMCloneTable{ii ui pM`xM PP PPOOO O OOOOOOOO O O OHH?HtH5R?%T?@hfhfhfhfhfhfhfhrfhbfh Rf%?fD%>fD%>fD%>fD%>fD%~>fD%v>fD%n>fD%f>fD%^>fD%V>fD1I^HHPTE11H=F3>f.H=q>Hj>H9tH>Ht H=A>H5:>H)HH?HHHtH=HtfD=>u+UH==Ht H==d=]wUHH }HuHUH=HUHSH}HuHUHMؾhXMV XVH}7HuHEHE؉H]UHSHXdH%(HE1DžDžDžDž@މAHHǸHH‰οeHjH‰οGHPH‰ο)H6H‰ο މAHHǸHH‰ο @HH‰οMicr}HH‰οosof_HlH‰οt HvADž-t HS;H[t HHH"HDž8HPHHƿ tHHjZHHHHHAH/HǸNHUdH+%(tH]UHH}uHUE;Eu UHEHHHǸ+MUHEHHHǸUHH H}HuHUHEH;Eu!HUHEHHHǸ-HMHUHEHHHǸ^UHH0HHHHEHUHEHUHEHUHEHEHEHUH1HEHEHUHHdHǸUHH0HIHHLHuH}HUHMLELMHEHUHHH3EH3UH tpHM؋UHEHHHǸzHUHEHHHHǸSHUHEHH \UH]UH}E]UH}E]UH]UH]UH]UH]UH]UH]UH]UH]UHHHXH`HhLpLxt )E)M)U)])e)m)u)}dH%(HH1Dž0Dž40HEH8HPH@Dž(Dž,O0/w#H@0HЋ00H8HPH8(,,;|(HHdH+%(t7UHEMEXE]UHEMEXE]UH}uUMDEDMUE‹E‹E‹E‹E‹E‹E‹E ‹E(]UHEMU]emu}EXEXEXEXEXEXEXEXEXE]UHEMU]emu}EXEXEXEXEXEXEXEXEXE]UHHUHME}t}}t}tEEEE]UHHfH~HEHUu}t}tEE, E,]UHH}uEHD]UH}}t}t HE HEHE ]UHE EfEE(HEMH]UHSHHH!H HȹAH HƉH HHZHHHHHfHnH]UHHdH%(HE1E EEUfH UHH%H HUdH+%(t&UHH0dH%(HE1E EEE(E2E %d %s => %d expected but got %d %s => %lld %s => %lld expected but got %lld (%lld, %llu)%s:%d: %s => want but got >@;|.P$H1pv7FV0fPup0P p)G]0P p5aX4\T`tzp4zRx &D$4FJ w?9*3$"\ t+EC  QEC AG $EC H  kEC b rEC i 4VhEC _ TEC  t?EC F .EC G EC G EC F EC F EC F 4EC F TEC F tEC F EC F EC F -EC $ EC U EC U 4NEC E TdEC [ tdEC [ EKEC B pDEC { EC U +EC b ,EC c  4WEC AM XdEC [ x dEC [ dEC  EC  EC  EC  EC  8\XEC O XEC  xEC  TEC K 1EC ( ` {  -pMxMo pO oooo|oM0@P`pPPGCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0   3 I@PUxM|`pM`Pi+(Q$8M0pO*%X9MU-]rf . PE*T(PhQ-ed)<FFPTK0 Zm6vP-KP,dP@'N!,P9CkJ YPf0u(+1&0Q2&@PJ!clr(} P+xD1W&(P2d@ Z,idv" Scrt1.o__abi_tagcrtstuff.cderegister_tm_clones__do_global_dtors_auxcompleted.0__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entryasm1.csegv_handler_envsegv_handlercommonstatic_fncommon_local__FRAME_END___DYNAMIC__GNU_EH_FRAME_HDR_GLOBAL_OFFSET_TABLE_struct_test141putchar@GLIBC_2.2.5ext_fn1add_alluchar_fn__libc_start_main@GLIBC_2.34_ITM_deregisterTMCloneTabletrue_fnputs@GLIBC_2.2.5sigaction@GLIBC_2.2.5struct_test171_edataprint_i128vmware_bdoor_fini__stack_chk_fail@GLIBC_2.4add10_floatgetuid@GLIBC_2.2.5assert128ext3struct_test121printf@GLIBC_2.2.5false_fncommon_ext2struct_test6struct_test4ext1siglongjmp@GLIBC_2.2.5memset@GLIBC_2.2.5struct_test24sshort_fnstruct_test26struct_test28struct_test151add10_intschar_fnextern_tls__data_startadd_floatassert__gmon_start____dso_handle_IO_stdin_usedstruct_test101struct_test181ext_fn2add_double_end__bss_startstruct_test131mainassert64struct_test161ushort_fnstruct_test7struct_test5struct_test25exit@GLIBC_2.2.5__TMC_END__struct_test27_ITM_registerTMCloneTablestruct_test111add10_double__sigsetjmp@GLIBC_2.2.5__cxa_finalize@GLIBC_2.2.5_init.symtab.strtab.shstrtab.interp.note.gnu.property.note.gnu.build-id.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.got.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.tbss.init_array.fini_array.dynamic.data.bss.commentPP#pp06$I Wo$a iqo|| ~o@B  -- 0000|P2P2pMp=pMp=xMx=M=pOp? P@(@P(@ 0(@+X@ (IM chibicc-1.0.23.1/issues/bitfield2.c000066400000000000000000000075731505335450300166620ustar00rootroot00000000000000#include "test.h" struct M { int : 0; int f2 : 12; }; int bitextract(void){ struct Fields { _Bool a :1; long long :3; unsigned b :4; _Bool c :1; unsigned d :3; unsigned e :2; long :2; }; struct Fields s1 = {11,22,33,44,55,66,77}; struct Fields s2 = {77,66,55,44,33,22,11}; ASSERT(4, sizeof(struct Fields)); ASSERT(4, _Alignof(struct Fields)); ASSERT(0, memcmp(&(int){14689}, &s1, 2)); ASSERT(0, memcmp(&(int){6433}, &s2, 2)); ASSERT(1, s1.a); ASSERT(6, s1.b); ASSERT(1, s1.c); ASSERT(4, s1.d); ASSERT(3, s1.e); ASSERT(1, s2.a); ASSERT(2, s2.b); ASSERT(1, s2.c); ASSERT(4, s2.d); ASSERT(1, s2.e); } int struct_init(void) { struct M m = {11,22}; ASSERT(11, ({ m.f2; })); ASSERT(11, ({ struct { int :1,a,:1,b,:1,:1,c,:1; } s = {11,22,33}; s.a; })); ASSERT(22, ({ struct { int :1,a,:1,b,:1,:1,c,:1; } s = {11,22,33}; s.b; })); ASSERT(33, ({ struct { int :1,a,:1,b,:1,:1,c,:1; } s = {11,22,33}; s.c; })); ASSERT(11, ({ struct { int a,:1,b,:1,:1,c,:1; } s = {.a=11,22,33}; s.a; })); ASSERT(22, ({ struct { int a,:1,b,:1,:1,c,:1; } s = {.a=11,22,33}; s.b; })); ASSERT(33, ({ struct { int a,:1,b,:1,:1,c,:1; } s = {.a=11,22,33}; s.c; })); ASSERT(11, ({ struct { struct { int a,:1,b,:1,:1,c,:1; }; } s = {.a=11,22,33}; s.a; })); ASSERT(22, ({ struct { struct { int a,:1,b; int;int :1,c,:1; }; } s = {.a=11,22,33}; s.b; })); ASSERT(33, ({ struct { struct { int a,:1,b,:1,:1,c,:1; }; } s = {.a=11,22,33}; s.c; })); ASSERT(22, ({ struct { struct { int a; int; int b; int; int; int c; int; }; } s = {.a=11,22,33}; s.b; })); ASSERT(33, ({ struct { int a; struct {int:1,:1;}; int b; } s = {11,{},33}; s.b; })); ASSERT(33, ({ struct { int a; struct {int:1,:1;}; int b; } s = {.a=11,{},33}; s.b; })); ASSERT(22, ({ struct { struct { }; int a; } s = {{},22,33}; s.a; })); ASSERT(22, ({ struct { struct { int :1,:1; }; int a; } s = {{},22,33}; s.a; })); ASSERT(22, ({ struct { int :1; int a; int :1; struct { int :1; int b; int:1; int c; }; } s = {11,22,33}; s.b; })); ASSERT(33, ({ struct { int :1; int a; int :1; struct { int :1; int b; int:1; int c; }; } s = {11,22,33}; s.c; })); } void union_init(void) { ASSERT(33, ({ union { int :1,:1; int a; } s = {33}; s.a; })); ASSERT(33, ({ struct { union { int :1,:1; }; int a;} s = {{23},33}; s.a;})); ASSERT(33, ({ struct { union { int :1,:1; }; int a;} s = {{23},33}; s.a;})); ASSERT(11, ({ struct { int a; union { int :1,:7; }; int b; } s = {11,{},33}; s.a; })); ASSERT(33, ({ struct { int a; union { int :1,:7; }; int b; } s = {11,{},33}; s.b; })); ASSERT(11, ({ union { struct { int a,:1,b,:1,:1,c,:1; }; } s = {.a=11,22,33}; s.a; })); ASSERT(22, ({ union { struct { int a,:1,b,:1,:1,c,:1; }; } s = {.a=11,22,33}; s.b; })); ASSERT(33, ({ union { struct { int a,:1,b,:1,:1,c,:1; }; } s = {.a=11,22,33}; s.c; })); ASSERT(22, ({ union { struct { int a, :1; int b, :1, :1; int c, :1; }; } s = {.a=11,22,33}; s.b; })); ASSERT(0, ({ union { union { }; int a; } s = {{}}; s.a; })); ASSERT(0, ({ union { struct { int :1,:1; }; int a; } s = {{}}; s.a; })); ASSERT(22, ({ struct { int a; union { int:1; int b; }; } s = {11,22}; s.b; })); } int assign_expr(void) { struct { int i : 2; _Bool b : 1; unsigned j : 2; } s = {.b = 1}; int x = s.i = -5; int y = s.j = 5; ASSERT(-1, x); ASSERT(1, y); x = s.i += -5; y = s.j += 5; int z = s.b >>= 1; ASSERT(-2, x); ASSERT(2, y); ASSERT(0, (s.b >>= 1)); } int large_field(void) { ASSERT(1, ({ struct { unsigned long long i: 56; } s = {.i = 0xFFFFFFFFFFFFFFFF }; s.i == 0xFFFFFFFFFFFFFF; }) ); } struct { int b :3; int i, j; } s = {.i = 2, 3}; int uninit_global(void) { ASSERT(2, s.i); ASSERT(3, s.j); } int main(void) { bitextract(); struct_init(); union_init(); assign_expr(); large_field(); uninit_global(); printf("OK\n"); return 0; }chibicc-1.0.23.1/issues/builtin_cvtpi2ps2.c000066400000000000000000000014411505335450300203640ustar00rootroot00000000000000#include #include "test.h" int main() { __m128 a = (__m128){100.0f, 200.0f, 300.0f, 400.0f}; // upper 2 will be kept __m64 b = (__m64){1, 2}; // lower 2 will be converted to float printf("a = %f %f %f %f\n", a[0], a[1], a[2], a[3]); ASSERT(100, a[0]); ASSERT(200, a[1]); ASSERT(300, a[2]); ASSERT(400, a[3]); int *p = (int *)&b; printf("b = %d %d\n", p[0], p[1]); // Correct: 1 2 ASSERT(1, p[0]); ASSERT(2, p[1]); float *p2 = (float *)&a; __m128 result = __builtin_ia32_cvtpi2ps(a, b); float *f = (float *)&result; printf("%f %f %f %f\n", f[0], f[1], f[2], f[3]); ASSERT(1, f[0]); ASSERT(2, f[1]); ASSERT(300, f[2]); ASSERT(400, f[3]); return 0; } chibicc-1.0.23.1/issues/builtin_types_compatibility.c000066400000000000000000000003161505335450300226250ustar00rootroot00000000000000#include int main() { if (__builtin_types_compatible_p(int, int)) { printf("Types are compatible\n"); } else { printf("Types are not compatible\n"); } return 0; } chibicc-1.0.23.1/issues/c.h000066400000000000000000001344411505335450300152400ustar00rootroot00000000000000/*------------------------------------------------------------------------- * * c.h * Fundamental C definitions. This is included by every .c file in * PostgreSQL (via either postgres.h or postgres_fe.h, as appropriate). * * Note that the definitions here are not intended to be exposed to clients * of the frontend interface libraries --- so we don't worry much about * polluting the namespace with lots of stuff... * * * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/c.h * *------------------------------------------------------------------------- */ /* *---------------------------------------------------------------- * TABLE OF CONTENTS * * When adding stuff to this file, please try to put stuff * into the relevant section, or add new sections as appropriate. * * section description * ------- ------------------------------------------------ * 0) pg_config.h and standard system headers * 1) compiler characteristics * 2) bool, true, false * 3) standard system types * 4) IsValid macros for system types * 5) lengthof, alignment * 6) assertions * 7) widely useful macros * 8) random stuff * 9) system-specific hacks * * NOTE: since this file is included by both frontend and backend modules, * it's usually wrong to put an "extern" declaration here, unless it's * ifdef'd so that it's seen in only one case or the other. * typedefs and macros are the kind of thing that might go here. * *---------------------------------------------------------------- */ #ifndef C_H #define C_H //#include "postgres_ext.h" typedef unsigned int Oid; #ifdef __cplusplus #define InvalidOid (Oid(0)) #else #define InvalidOid ((Oid) 0) #endif #define PG_IO_ALIGN_SIZE 4096 #define OID_MAX UINT_MAX /* you will need to include to use the above #define */ #define atooid(x) ((Oid) strtoul((x), NULL, 10)) /* the above needs */ #define PG_INT64_TYPE long int /* Define a signed 64-bit integer type for use in client API declarations. */ typedef PG_INT64_TYPE pg_int64; typedef uintptr_t Datum; #define DatumGetChar(d) ((char) (d)) #define DatumGetInt16(d) ((int16) (d)) #define DatumGetInt32(d) ((int32_t) (d)) /* * Identifiers of error message fields. Kept here to keep common * between frontend and backend, and also to export them to libpq * applications. */ #define PG_DIAG_SEVERITY 'S' #define PG_DIAG_SEVERITY_NONLOCALIZED 'V' #define PG_DIAG_SQLSTATE 'C' #define PG_DIAG_MESSAGE_PRIMARY 'M' #define PG_DIAG_MESSAGE_DETAIL 'D' #define PG_DIAG_MESSAGE_HINT 'H' #define PG_DIAG_STATEMENT_POSITION 'P' #define PG_DIAG_INTERNAL_POSITION 'p' #define PG_DIAG_INTERNAL_QUERY 'q' #define PG_DIAG_CONTEXT 'W' #define PG_DIAG_SCHEMA_NAME 's' #define PG_DIAG_TABLE_NAME 't' #define PG_DIAG_COLUMN_NAME 'c' #define PG_DIAG_DATATYPE_NAME 'd' #define PG_DIAG_CONSTRAINT_NAME 'n' #define PG_DIAG_SOURCE_FILE 'F' #define PG_DIAG_SOURCE_LINE 'L' #define PG_DIAG_SOURCE_FUNCTION 'R' /* Must undef pg_config_ext.h symbols before including pg_config.h */ #undef PG_INT64_TYPE //#include "pg_config.h" //#include "pg_config_manual.h" /* must be after pg_config.h */ //#include "pg_config_os.h" /* must be before any system header files */ /* System header files that should be available everywhere in Postgres */ #include #include #include #include #include #ifdef HAVE_STRINGS_H #include #endif #include #include #include #if defined(WIN32) || defined(__CYGWIN__) #include /* ensure O_BINARY is available */ #endif #include #ifdef ENABLE_NLS #include #endif /* Define before including zlib.h to add const decorations to zlib API. */ #ifdef HAVE_LIBZ #define ZLIB_CONST #endif /* ---------------------------------------------------------------- * Section 1: compiler characteristics * * type prefixes (const, signed, volatile, inline) are handled in pg_config.h. * ---------------------------------------------------------------- */ /* * Disable "inline" if PG_FORCE_DISABLE_INLINE is defined. * This is used to work around compiler bugs and might also be useful for * investigatory purposes. */ #ifdef PG_FORCE_DISABLE_INLINE #undef inline #define inline #endif /* * Attribute macros * * GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html * GCC: https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html * Clang: https://clang.llvm.org/docs/AttributeReference.html * Sunpro: https://docs.oracle.com/cd/E18659_01/html/821-1384/gjzke.html */ /* * For compilers which don't support __has_attribute, we just define * __has_attribute(x) to 0 so that we can define macros for various * __attribute__s more easily below. */ #ifndef __has_attribute #define __has_attribute(attribute) 0 #endif /* only GCC supports the unused attribute */ #ifdef __GNUC__ #define pg_attribute_unused() __attribute__((unused)) #else #define pg_attribute_unused() #endif /* * pg_nodiscard means the compiler should warn if the result of a function * call is ignored. The name "nodiscard" is chosen in alignment with * (possibly future) C and C++ standards. For maximum compatibility, use it * as a function declaration specifier, so it goes before the return type. */ #ifdef __GNUC__ #define pg_nodiscard __attribute__((warn_unused_result)) #else #define pg_nodiscard #endif /* * This macro will disable address safety instrumentation for a function * when running with "-fsanitize=address". Think twice before using this! */ #if defined(__clang__) || __GNUC__ >= 8 #define pg_attribute_no_sanitize_address() __attribute__((no_sanitize("address"))) #elif __has_attribute(no_sanitize_address) /* This would work for clang, but it's deprecated. */ #define pg_attribute_no_sanitize_address() __attribute__((no_sanitize_address)) #else #define pg_attribute_no_sanitize_address() #endif /* * Place this macro before functions that should be allowed to make misaligned * accesses. Think twice before using it on non-x86-specific code! * Testing can be done with "-fsanitize=alignment -fsanitize-trap=alignment" * on clang, or "-fsanitize=alignment -fno-sanitize-recover=alignment" on gcc. */ #if __clang_major__ >= 7 || __GNUC__ >= 8 #define pg_attribute_no_sanitize_alignment() __attribute__((no_sanitize("alignment"))) #else #define pg_attribute_no_sanitize_alignment() #endif /* * pg_attribute_nonnull means the compiler should warn if the function is * called with the listed arguments set to NULL. If no arguments are * listed, the compiler should warn if any pointer arguments are set to NULL. */ #if __has_attribute (nonnull) #define pg_attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__))) #else #define pg_attribute_nonnull(...) #endif /* * Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only * used in assert-enabled builds, to avoid compiler warnings about unused * variables in assert-disabled builds. */ #ifdef USE_ASSERT_CHECKING #define PG_USED_FOR_ASSERTS_ONLY #else #define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused() #endif /* GCC supports format attributes */ #if defined(__GNUC__) #define pg_attribute_format_arg(a) __attribute__((format_arg(a))) #define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a))) #else #define pg_attribute_format_arg(a) #define pg_attribute_printf(f,a) #endif /* GCC and Sunpro support aligned, packed and noreturn */ #if defined(__GNUC__) || defined(__SUNPRO_C) #define pg_attribute_aligned(a) __attribute__((aligned(a))) #define pg_attribute_noreturn() __attribute__((noreturn)) #define pg_attribute_packed() __attribute__((packed)) #define HAVE_PG_ATTRIBUTE_NORETURN 1 #elif defined(_MSC_VER) /* * MSVC supports aligned. noreturn is also possible but in MSVC it is * declared before the definition while pg_attribute_noreturn() macro * is currently used after the definition. * * Packing is also possible but only by wrapping the entire struct definition * which doesn't fit into our current macro declarations. */ #define pg_attribute_aligned(a) __declspec(align(a)) #define pg_attribute_noreturn() #else /* * NB: aligned and packed are not given default definitions because they * affect code functionality; they *must* be implemented by the compiler * if they are to be used. */ #define pg_attribute_noreturn() #endif /* * Use "pg_attribute_always_inline" in place of "inline" for functions that * we wish to force inlining of, even when the compiler's heuristics would * choose not to. But, if possible, don't force inlining in unoptimized * debug builds. */ #if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) /* GCC > 3 and Sunpro support always_inline via __attribute__ */ #define pg_attribute_always_inline __attribute__((always_inline)) inline #elif defined(_MSC_VER) /* MSVC has a special keyword for this */ #define pg_attribute_always_inline __forceinline #else /* Otherwise, the best we can do is to say "inline" */ #define pg_attribute_always_inline inline #endif /* * Forcing a function not to be inlined can be useful if it's the slow path of * a performance-critical function, or should be visible in profiles to allow * for proper cost attribution. Note that unlike the pg_attribute_XXX macros * above, this should be placed before the function's return type and name. */ /* GCC and Sunpro support noinline via __attribute__ */ #if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C) #define pg_noinline __attribute__((noinline)) /* msvc via declspec */ #elif defined(_MSC_VER) #define pg_noinline __declspec(noinline) #else #define pg_noinline #endif /* * For now, just define pg_attribute_cold and pg_attribute_hot to be empty * macros on minGW 8.1. There appears to be a compiler bug that results in * compilation failure. At this time, we still have at least one buildfarm * animal running that compiler, so this should make that green again. It's * likely this compiler is not popular enough to warrant keeping this code * around forever, so let's just remove it once the last buildfarm animal * upgrades. */ #if defined(__MINGW64__) && __GNUC__ == 8 && __GNUC_MINOR__ == 1 #define pg_attribute_cold #define pg_attribute_hot #else /* * Marking certain functions as "hot" or "cold" can be useful to assist the * compiler in arranging the assembly code in a more efficient way. */ #if __has_attribute (cold) #define pg_attribute_cold __attribute__((cold)) #else #define pg_attribute_cold #endif #if __has_attribute (hot) #define pg_attribute_hot __attribute__((hot)) #else #define pg_attribute_hot #endif #endif /* defined(__MINGW64__) && __GNUC__ == 8 && * __GNUC_MINOR__ == 1 */ /* * Mark a point as unreachable in a portable fashion. This should preferably * be something that the compiler understands, to aid code generation. * In assert-enabled builds, we prefer abort() for debugging reasons. */ #if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING) #define pg_unreachable() __builtin_unreachable() #elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING) #define pg_unreachable() __assume(0) #else #define pg_unreachable() abort() #endif /* * Hints to the compiler about the likelihood of a branch. Both likely() and * unlikely() return the boolean value of the contained expression. * * These should only be used sparingly, in very hot code paths. It's very easy * to mis-estimate likelihoods. */ #if __GNUC__ >= 3 #define likely(x) __builtin_expect((x) != 0, 1) #define unlikely(x) __builtin_expect((x) != 0, 0) #else #define likely(x) ((x) != 0) #define unlikely(x) ((x) != 0) #endif /* * CppAsString * Convert the argument to a string, using the C preprocessor. * CppAsString2 * Convert the argument to a string, after one round of macro expansion. * CppConcat * Concatenate two arguments together, using the C preprocessor. * * Note: There used to be support here for pre-ANSI C compilers that didn't * support # and ##. Nowadays, these macros are just for clarity and/or * backward compatibility with existing PostgreSQL code. */ #define CppAsString(identifier) #identifier #define CppAsString2(x) CppAsString(x) #define CppConcat(x, y) x##y /* * VA_ARGS_NARGS * Returns the number of macro arguments it is passed. * * An empty argument still counts as an argument, so effectively, this is * "one more than the number of commas in the argument list". * * This works for up to 63 arguments. Internally, VA_ARGS_NARGS_() is passed * 64+N arguments, and the C99 standard only requires macros to allow up to * 127 arguments, so we can't portably go higher. The implementation is * pretty trivial: VA_ARGS_NARGS_() returns its 64th argument, and we set up * the call so that that is the appropriate one of the list of constants. * This idea is due to Laurent Deniau. * * MSVC has an implementation of __VA_ARGS__ that doesn't conform to the * standard unless you use the /Zc:preprocessor compiler flag, but that * isn't available before Visual Studio 2019. For now, use a different * definition that also works on older compilers. */ #ifdef _MSC_VER #define EXPAND(args) args #define VA_ARGS_NARGS(...) \ VA_ARGS_NARGS_ EXPAND((__VA_ARGS__, \ 63,62,61,60, \ 59,58,57,56,55,54,53,52,51,50, \ 49,48,47,46,45,44,43,42,41,40, \ 39,38,37,36,35,34,33,32,31,30, \ 29,28,27,26,25,24,23,22,21,20, \ 19,18,17,16,15,14,13,12,11,10, \ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) #else #define VA_ARGS_NARGS(...) \ VA_ARGS_NARGS_(__VA_ARGS__, \ 63,62,61,60, \ 59,58,57,56,55,54,53,52,51,50, \ 49,48,47,46,45,44,43,42,41,40, \ 39,38,37,36,35,34,33,32,31,30, \ 29,28,27,26,25,24,23,22,21,20, \ 19,18,17,16,15,14,13,12,11,10, \ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) #endif #define VA_ARGS_NARGS_( \ _01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \ _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ _61,_62,_63, N, ...) \ (N) /* * Generic function pointer. This can be used in the rare cases where it's * necessary to cast a function pointer to a seemingly incompatible function * pointer type while avoiding gcc's -Wcast-function-type warnings. */ typedef void (*pg_funcptr_t) (void); /* * We require C99, hence the compiler should understand flexible array * members. However, for documentation purposes we still consider it to be * project style to write "field[FLEXIBLE_ARRAY_MEMBER]" not just "field[]". * When computing the size of such an object, use "offsetof(struct s, f)" * for portability. Don't use "offsetof(struct s, f[0])", as this doesn't * work with MSVC and with C++ compilers. */ #define FLEXIBLE_ARRAY_MEMBER /* empty */ /* * Does the compiler support #pragma GCC system_header? We optionally use it * to avoid warnings that we can't fix (e.g. in the perl headers). * See https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html * * Headers for which we do not want to show compiler warnings can, * conditionally, use #pragma GCC system_header to avoid warnings. Obviously * this should only be used for external headers over which we do not have * control. * * Support for the pragma is tested here, instead of during configure, as gcc * also warns about the pragma being used in a .c file. It's surprisingly hard * to get autoconf to use .h as the file-ending. Looks like gcc has * implemented the pragma since the 2000, so this test should suffice. * * * Alternatively, we could add the include paths for problematic headers with * -isystem, but that is a larger hammer and is harder to search for. * * A more granular alternative would be to use #pragma GCC diagnostic * push/ignored/pop, but gcc warns about unknown warnings being ignored, so * every to-be-ignored-temporarily compiler warning would require its own * pg_config.h symbol and #ifdef. */ #ifdef __GNUC__ #define HAVE_PRAGMA_GCC_SYSTEM_HEADER 1 #endif /* ---------------------------------------------------------------- * Section 2: bool, true, false * ---------------------------------------------------------------- */ /* * bool * Boolean value, either true or false. * * We use stdbool.h if available and its bool has size 1. That's useful for * better compiler and debugger output and for compatibility with third-party * libraries. But PostgreSQL currently cannot deal with bool of other sizes; * there are static assertions around the code to prevent that. * * For C++ compilers, we assume the compiler has a compatible built-in * definition of bool. * * See also the version of this code in src/interfaces/ecpg/include/ecpglib.h. */ #ifndef __cplusplus #ifdef PG_USE_STDBOOL #include #else #ifndef bool typedef unsigned char bool; #endif #ifndef true #define true ((bool) 1) #endif #ifndef false #define false ((bool) 0) #endif #endif /* not PG_USE_STDBOOL */ #endif /* not C++ */ /* ---------------------------------------------------------------- * Section 3: standard system types * ---------------------------------------------------------------- */ /* * Pointer * Variable holding address of any memory resident object. * * XXX Pointer arithmetic is done with this, so it can't be void * * under "true" ANSI compilers. */ typedef char *Pointer; /* * intN * Signed integer, EXACTLY N BITS IN SIZE, * used for numerical computations and the * frontend/backend protocol. */ #ifndef HAVE_INT8 typedef signed char int8; /* == 8 bits */ typedef int16_t int16; /* == 16 bits */ typedef signed int int32; /* == 32 bits */ #endif /* not HAVE_INT8 */ /* * uintN * Unsigned integer, EXACTLY N BITS IN SIZE, * used for numerical computations and the * frontend/backend protocol. */ #ifndef HAVE_UINT8 typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ #endif /* not HAVE_UINT8 */ /* * bitsN * Unit of bitwise operation, AT LEAST N BITS IN SIZE. */ typedef uint8 bits8; /* >= 8 bits */ typedef uint16 bits16; /* >= 16 bits */ typedef uint32 bits32; /* >= 32 bits */ /* * 64-bit integers */ #ifdef HAVE_LONG_INT_64 /* Plain "long int" fits, use it */ #ifndef HAVE_INT64 typedef long int int64; #endif #ifndef HAVE_UINT64 typedef unsigned long int uint64; #endif #define INT64CONST(x) (x##L) #define UINT64CONST(x) (x##UL) #elif defined(HAVE_LONG_LONG_INT_64) /* We have working support for "long long int", use that */ #ifndef HAVE_INT64 typedef long long int int64; #endif #ifndef HAVE_UINT64 typedef unsigned long long int uint64; #endif #define INT64CONST(x) (x##LL) #define UINT64CONST(x) (x##ULL) #else /* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */ #error must have a working 64-bit integer datatype #endif /* snprintf format strings to use for 64-bit integers */ #define INT64_FORMAT "%" INT64_MODIFIER "d" #define UINT64_FORMAT "%" INT64_MODIFIER "u" /* * 128-bit signed and unsigned integers * There currently is only limited support for such types. * E.g. 128bit literals and snprintf are not supported; but math is. * Also, because we exclude such types when choosing MAXIMUM_ALIGNOF, * it must be possible to coerce the compiler to allocate them on no * more than MAXALIGN boundaries. */ #if defined(PG_INT128_TYPE) #if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF #define HAVE_INT128 1 typedef PG_INT128_TYPE int128 #if defined(pg_attribute_aligned) pg_attribute_aligned(MAXIMUM_ALIGNOF) #endif ; typedef unsigned PG_INT128_TYPE uint128 #if defined(pg_attribute_aligned) pg_attribute_aligned(MAXIMUM_ALIGNOF) #endif ; #endif #endif /* * stdint.h limits aren't guaranteed to have compatible types with our fixed * width types. So just define our own. */ #define PG_INT8_MIN (-0x7F-1) #define PG_INT8_MAX (0x7F) #define PG_UINT8_MAX (0xFF) #define PG_INT16_MIN (-0x7FFF-1) #define PG_INT16_MAX (0x7FFF) #define PG_UINT16_MAX (0xFFFF) #define PG_INT32_MIN (-0x7FFFFFFF-1) #define PG_INT32_MAX (0x7FFFFFFF) #define PG_UINT32_MAX (0xFFFFFFFFU) #define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1) #define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF) #define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF) /* * We now always use int64 timestamps, but keep this symbol defined for the * benefit of external code that might test it. */ #define HAVE_INT64_TIMESTAMP /* * Size * Size of any memory resident object, as returned by sizeof. */ typedef size_t Size; /* * Index * Index into any memory resident array. * * Note: * Indices are non negative. */ typedef unsigned int Index; /* * Offset * Offset into any memory resident array. * * Note: * This differs from an Index in that an Index is always * non negative, whereas Offset may be negative. */ typedef signed int Offset; /* * Common Postgres datatype names (as used in the catalogs) */ typedef float float4; typedef double float8; #ifdef USE_FLOAT8_BYVAL #define FLOAT8PASSBYVAL true #else #define FLOAT8PASSBYVAL false #endif /* * Oid, RegProcedure, TransactionId, SubTransactionId, MultiXactId, * CommandId */ /* typedef Oid is in postgres_ext.h */ /* * regproc is the type name used in the include/catalog headers, but * RegProcedure is the preferred name in C code. */ typedef Oid regproc; typedef regproc RegProcedure; typedef uint32 TransactionId; typedef uint32 LocalTransactionId; typedef uint32 SubTransactionId; #define InvalidSubTransactionId ((SubTransactionId) 0) #define TopSubTransactionId ((SubTransactionId) 1) /* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */ typedef TransactionId MultiXactId; typedef uint32 MultiXactOffset; typedef uint32 CommandId; #define FirstCommandId ((CommandId) 0) #define InvalidCommandId (~(CommandId)0) /* ---------------- * Variable-length datatypes all share the 'struct varlena' header. * * NOTE: for TOASTable types, this is an oversimplification, since the value * may be compressed or moved out-of-line. However datatype-specific routines * are mostly content to deal with de-TOASTed values only, and of course * client-side routines should never see a TOASTed value. But even in a * de-TOASTed value, beware of touching vl_len_ directly, as its * representation is no longer convenient. It's recommended that code always * use macros VARDATA_ANY, VARSIZE_ANY, VARSIZE_ANY_EXHDR, VARDATA, VARSIZE, * and SET_VARSIZE instead of relying on direct mentions of the struct fields. * See postgres.h for details of the TOASTed form. * ---------------- */ struct varlena { char vl_len_[4]; /* Do not touch this field directly! */ char vl_dat[FLEXIBLE_ARRAY_MEMBER]; /* Data content is here */ }; #define VARHDRSZ ((int32) sizeof(int32)) /* * These widely-used datatypes are just a varlena header and the data bytes. * There is no terminating null or anything like that --- the data length is * always VARSIZE_ANY_EXHDR(ptr). */ typedef struct varlena bytea; typedef struct varlena text; typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */ typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */ /* * Specialized array types. These are physically laid out just the same * as regular arrays (so that the regular array subscripting code works * with them). They exist as distinct types mostly for historical reasons: * they have nonstandard I/O behavior which we don't want to change for fear * of breaking applications that look at the system catalogs. There is also * an implementation issue for oidvector: it's part of the primary key for * pg_proc, and we can't use the normal btree array support routines for that * without circularity. */ typedef struct { int32 vl_len_; /* these fields must match ArrayType! */ int ndim; /* always 1 for int2vector */ int32 dataoffset; /* always 0 for int2vector */ Oid elemtype; int dim1; int lbound1; int16 values[FLEXIBLE_ARRAY_MEMBER]; } int2vector; typedef struct { int32 vl_len_; /* these fields must match ArrayType! */ int ndim; /* always 1 for oidvector */ int32 dataoffset; /* always 0 for oidvector */ Oid elemtype; int dim1; int lbound1; Oid values[FLEXIBLE_ARRAY_MEMBER]; } oidvector; /* * Representation of a Name: effectively just a C string, but null-padded to * exactly NAMEDATALEN bytes. The use of a struct is historical. */ typedef struct nameData { char data[NAMEDATALEN]; } NameData; typedef NameData *Name; #define NameStr(name) ((name).data) /* ---------------------------------------------------------------- * Section 4: IsValid macros for system types * ---------------------------------------------------------------- */ /* * BoolIsValid * True iff bool is valid. */ #define BoolIsValid(boolean) ((boolean) == false || (boolean) == true) /* * PointerIsValid * True iff pointer is valid. */ #define PointerIsValid(pointer) ((const void*)(pointer) != NULL) /* * PointerIsAligned * True iff pointer is properly aligned to point to the given type. */ #define PointerIsAligned(pointer, type) \ (((uintptr_t)(pointer) % (sizeof (type))) == 0) #define OffsetToPointer(base, offset) \ ((void *)((char *) base + offset)) #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid)) #define RegProcedureIsValid(p) OidIsValid(p) /* ---------------------------------------------------------------- * Section 5: lengthof, alignment * ---------------------------------------------------------------- */ /* * lengthof * Number of elements in an array. */ #define lengthof(array) (sizeof (array) / sizeof ((array)[0])) /* ---------------- * Alignment macros: align a length or address appropriately for a given type. * The fooALIGN() macros round up to a multiple of the required alignment, * while the fooALIGN_DOWN() macros round down. The latter are more useful * for problems like "how many X-sized structures will fit in a page?". * * NOTE: TYPEALIGN[_DOWN] will not work if ALIGNVAL is not a power of 2. * That case seems extremely unlikely to be needed in practice, however. * * NOTE: MAXIMUM_ALIGNOF, and hence MAXALIGN(), intentionally exclude any * larger-than-8-byte types the compiler might have. * ---------------- */ #define TYPEALIGN(ALIGNVAL,LEN) \ (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1))) #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) #define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN)) #define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN)) /* MAXALIGN covers only built-in types, not buffers */ #define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN)) #define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN)) #define TYPEALIGN_DOWN(ALIGNVAL,LEN) \ (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1))) #define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN)) #define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN)) #define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN)) #define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN)) #define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN)) /* * The above macros will not work with types wider than uintptr_t, like with * uint64 on 32-bit platforms. That's not problem for the usual use where a * pointer or a length is aligned, but for the odd case that you need to * align something (potentially) wider, use TYPEALIGN64. */ #define TYPEALIGN64(ALIGNVAL,LEN) \ (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1))) /* we don't currently need wider versions of the other ALIGN macros */ #define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN)) /* ---------------------------------------------------------------- * Section 6: assertions * ---------------------------------------------------------------- */ /* * USE_ASSERT_CHECKING, if defined, turns on all the assertions. * - plai 9/5/90 * * It should _NOT_ be defined in releases or in benchmark copies */ /* * Assert() can be used in both frontend and backend code. In frontend code it * just calls the standard assert, if it's available. If use of assertions is * not configured, it does nothing. */ #ifndef USE_ASSERT_CHECKING #define Assert(condition) ((void)true) #define AssertMacro(condition) ((void)true) #elif defined(FRONTEND) #include #define Assert(p) assert(p) #define AssertMacro(p) ((void) assert(p)) #else /* USE_ASSERT_CHECKING && !FRONTEND */ /* * Assert * Generates a fatal exception if the given condition is false. */ #define Assert(condition) \ do { \ if (!(condition)) \ ExceptionalCondition(#condition, __FILE__, __LINE__); \ } while (0) /* * AssertMacro is the same as Assert but it's suitable for use in * expression-like macros, for example: * * #define foo(x) (AssertMacro(x != 0), bar(x)) */ #define AssertMacro(condition) \ ((void) ((condition) || \ (ExceptionalCondition(#condition, __FILE__, __LINE__), 0))) #endif /* USE_ASSERT_CHECKING && !FRONTEND */ /* * Check that `ptr' is `bndr' aligned. */ #define AssertPointerAlignment(ptr, bndr) \ Assert(TYPEALIGN(bndr, (uintptr_t)(ptr)) == (uintptr_t)(ptr)) /* * ExceptionalCondition is compiled into the backend whether or not * USE_ASSERT_CHECKING is defined, so as to support use of extensions * that are built with that #define with a backend that isn't. Hence, * we should declare it as long as !FRONTEND. */ #ifndef FRONTEND extern void ExceptionalCondition(const char *conditionName, const char *fileName, int lineNumber) pg_attribute_noreturn(); #endif /* * Macros to support compile-time assertion checks. * * If the "condition" (a compile-time-constant expression) evaluates to false, * throw a compile error using the "errmessage" (a string literal). * * C11 has _Static_assert(), and most C99 compilers already support that. For * portability, we wrap it into StaticAssertDecl(). _Static_assert() is a * "declaration", and so it must be placed where for example a variable * declaration would be valid. As long as we compile with * -Wno-declaration-after-statement, that also means it cannot be placed after * statements in a function. Macros StaticAssertStmt() and StaticAssertExpr() * make it safe to use as a statement or in an expression, respectively. * * For compilers without _Static_assert(), we fall back on a kluge that * assumes the compiler will complain about a negative width for a struct * bit-field. This will not include a helpful error message, but it beats not * getting an error at all. */ #ifndef __cplusplus #ifdef HAVE__STATIC_ASSERT #define StaticAssertDecl(condition, errmessage) \ _Static_assert(condition, errmessage) #define StaticAssertStmt(condition, errmessage) \ do { _Static_assert(condition, errmessage); } while(0) #define StaticAssertExpr(condition, errmessage) \ ((void) ({ StaticAssertStmt(condition, errmessage); true; })) #else /* !HAVE__STATIC_ASSERT */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) #define StaticAssertStmt(condition, errmessage) \ ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; })) #define StaticAssertExpr(condition, errmessage) \ StaticAssertStmt(condition, errmessage) #endif /* HAVE__STATIC_ASSERT */ #else /* C++ */ #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 #define StaticAssertDecl(condition, errmessage) \ static_assert(condition, errmessage) #define StaticAssertStmt(condition, errmessage) \ static_assert(condition, errmessage) #define StaticAssertExpr(condition, errmessage) \ ({ static_assert(condition, errmessage); }) #else /* !__cpp_static_assert */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) #define StaticAssertStmt(condition, errmessage) \ do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0) #define StaticAssertExpr(condition, errmessage) \ ((void) ({ StaticAssertStmt(condition, errmessage); })) #endif /* __cpp_static_assert */ #endif /* C++ */ /* * Compile-time checks that a variable (or expression) has the specified type. * * AssertVariableIsOfType() can be used as a statement. * AssertVariableIsOfTypeMacro() is intended for use in macros, eg * #define foo(x) (AssertVariableIsOfTypeMacro(x, int), bar(x)) * * If we don't have __builtin_types_compatible_p, we can still assert that * the types have the same size. This is far from ideal (especially on 32-bit * platforms) but it provides at least some coverage. */ #ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P #define AssertVariableIsOfType(varname, typename) \ StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \ CppAsString(varname) " does not have type " CppAsString(typename)) #define AssertVariableIsOfTypeMacro(varname, typename) \ (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \ CppAsString(varname) " does not have type " CppAsString(typename))) #else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */ #define AssertVariableIsOfType(varname, typename) \ StaticAssertStmt(sizeof(varname) == sizeof(typename), \ CppAsString(varname) " does not have type " CppAsString(typename)) #define AssertVariableIsOfTypeMacro(varname, typename) \ (StaticAssertExpr(sizeof(varname) == sizeof(typename), \ CppAsString(varname) " does not have type " CppAsString(typename))) #endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */ /* ---------------------------------------------------------------- * Section 7: widely useful macros * ---------------------------------------------------------------- */ /* * Max * Return the maximum of two numbers. */ #define Max(x, y) ((x) > (y) ? (x) : (y)) /* * Min * Return the minimum of two numbers. */ #define Min(x, y) ((x) < (y) ? (x) : (y)) /* Get a bit mask of the bits set in non-long aligned addresses */ #define LONG_ALIGN_MASK (sizeof(long) - 1) /* * MemSet * Exactly the same as standard library function memset(), but considerably * faster for zeroing small word-aligned structures (such as parsetree nodes). * This has to be a macro because the main point is to avoid function-call * overhead. However, we have also found that the loop is faster than * native libc memset() on some platforms, even those with assembler * memset() functions. More research needs to be done, perhaps with * MEMSET_LOOP_LIMIT tests in configure. */ #define MemSet(start, val, len) \ do \ { \ /* must be void* because we don't know if it is integer aligned yet */ \ void *_vstart = (void *) (start); \ int _val = (val); \ Size _len = (len); \ \ if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \ (_len & LONG_ALIGN_MASK) == 0 && \ _val == 0 && \ _len <= MEMSET_LOOP_LIMIT && \ /* \ * If MEMSET_LOOP_LIMIT == 0, optimizer should find \ * the whole "if" false at compile time. \ */ \ MEMSET_LOOP_LIMIT != 0) \ { \ long *_start = (long *) _vstart; \ long *_stop = (long *) ((char *) _start + _len); \ while (_start < _stop) \ *_start++ = 0; \ } \ else \ memset(_vstart, _val, _len); \ } while (0) /* * MemSetAligned is the same as MemSet except it omits the test to see if * "start" is word-aligned. This is okay to use if the caller knows a-priori * that the pointer is suitably aligned (typically, because he just got it * from palloc(), which always delivers a max-aligned pointer). */ #define MemSetAligned(start, val, len) \ do \ { \ long *_start = (long *) (start); \ int _val = (val); \ Size _len = (len); \ \ if ((_len & LONG_ALIGN_MASK) == 0 && \ _val == 0 && \ _len <= MEMSET_LOOP_LIMIT && \ MEMSET_LOOP_LIMIT != 0) \ { \ long *_stop = (long *) ((char *) _start + _len); \ while (_start < _stop) \ *_start++ = 0; \ } \ else \ memset(_start, _val, _len); \ } while (0) /* * Macros for range-checking float values before converting to integer. * We must be careful here that the boundary values are expressed exactly * in the float domain. PG_INTnn_MIN is an exact power of 2, so it will * be represented exactly; but PG_INTnn_MAX isn't, and might get rounded * off, so avoid using that. * The input must be rounded to an integer beforehand, typically with rint(), * else we might draw the wrong conclusion about close-to-the-limit values. * These macros will do the right thing for Inf, but not necessarily for NaN, * so check isnan(num) first if that's a possibility. */ #define FLOAT4_FITS_IN_INT16(num) \ ((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN)) #define FLOAT4_FITS_IN_INT32(num) \ ((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN)) #define FLOAT4_FITS_IN_INT64(num) \ ((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN)) #define FLOAT8_FITS_IN_INT16(num) \ ((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN)) #define FLOAT8_FITS_IN_INT32(num) \ ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN)) #define FLOAT8_FITS_IN_INT64(num) \ ((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN)) /* ---------------------------------------------------------------- * Section 8: random stuff * ---------------------------------------------------------------- */ /* * Invert the sign of a qsort-style comparison result, ie, exchange negative * and positive integer values, being careful not to get the wrong answer * for INT_MIN. The argument should be an integral variable. */ #define INVERT_COMPARE_RESULT(var) \ ((var) = ((var) < 0) ? 1 : -(var)) /* * Use this, not "char buf[BLCKSZ]", to declare a field or local variable * holding a page buffer, if that page might be accessed as a page. Otherwise * the variable might be under-aligned, causing problems on alignment-picky * hardware. We include both "double" and "int64" in the union to ensure that * the compiler knows the value must be MAXALIGN'ed (cf. configure's * computation of MAXIMUM_ALIGNOF). */ typedef union PGAlignedBlock { char data[BLCKSZ]; double force_align_d; int64 force_align_i64; } PGAlignedBlock; /* * Use this to declare a field or local variable holding a page buffer, if that * page might be accessed as a page or passed to an SMgr I/O function. If * allocating using the MemoryContext API, the aligned allocation functions * should be used with PG_IO_ALIGN_SIZE. This alignment may be more efficient * for I/O in general, but may be strictly required on some platforms when * using direct I/O. */ typedef union PGIOAlignedBlock { #ifdef pg_attribute_aligned pg_attribute_aligned(PG_IO_ALIGN_SIZE) #endif char data[BLCKSZ]; double force_align_d; int64 force_align_i64; } PGIOAlignedBlock; /* Same, but for an XLOG_BLCKSZ-sized buffer */ typedef union PGAlignedXLogBlock { #ifdef pg_attribute_aligned pg_attribute_aligned(PG_IO_ALIGN_SIZE) #endif char data[XLOG_BLCKSZ]; double force_align_d; int64 force_align_i64; } PGAlignedXLogBlock; /* msb for char */ #define HIGHBIT (0x80) #define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT) /* * Support macros for escaping strings. escape_backslash should be true * if generating a non-standard-conforming string. Prefixing a string * with ESCAPE_STRING_SYNTAX guarantees it is non-standard-conforming. * Beware of multiple evaluation of the "ch" argument! */ #define SQL_STR_DOUBLE(ch, escape_backslash) \ ((ch) == '\'' || ((ch) == '\\' && (escape_backslash))) #define ESCAPE_STRING_SYNTAX 'E' #define STATUS_OK (0) #define STATUS_ERROR (-1) #define STATUS_EOF (-2) /* * gettext support */ #ifndef ENABLE_NLS /* stuff we'd otherwise get from */ #define gettext(x) (x) #define dgettext(d,x) (x) #define ngettext(s,p,n) ((n) == 1 ? (s) : (p)) #define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p)) #endif #define _(x) gettext(x) /* * Use this to mark string constants as needing translation at some later * time, rather than immediately. This is useful for cases where you need * access to the original string and translated string, and for cases where * immediate translation is not possible, like when initializing global * variables. * * https://www.gnu.org/software/gettext/manual/html_node/Special-cases.html */ #define gettext_noop(x) (x) /* * To better support parallel installations of major PostgreSQL * versions as well as parallel installations of major library soname * versions, we mangle the gettext domain name by appending those * version numbers. The coding rule ought to be that wherever the * domain name is mentioned as a literal, it must be wrapped into * PG_TEXTDOMAIN(). The macros below do not work on non-literals; but * that is somewhat intentional because it avoids having to worry * about multiple states of premangling and postmangling as the values * are being passed around. * * Make sure this matches the installation rules in nls-global.mk. */ #ifdef SO_MAJOR_VERSION #define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION) #else #define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION) #endif /* * Macro that allows to cast constness and volatile away from an expression, but doesn't * allow changing the underlying type. Enforcement of the latter * currently only works for gcc like compilers. * * Please note IT IS NOT SAFE to cast constness away if the result will ever * be modified (it would be undefined behaviour). Doing so anyway can cause * compiler misoptimizations or runtime crashes (modifying readonly memory). * It is only safe to use when the result will not be modified, but API * design or language restrictions prevent you from declaring that * (e.g. because a function returns both const and non-const variables). * * Note that this only works in function scope, not for global variables (it'd * be nice, but not trivial, to improve that). */ #if defined(__cplusplus) #define unconstify(underlying_type, expr) const_cast(expr) #define unvolatize(underlying_type, expr) const_cast(expr) #elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P) #define unconstify(underlying_type, expr) \ (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \ "wrong cast"), \ (underlying_type) (expr)) #define unvolatize(underlying_type, expr) \ (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \ "wrong cast"), \ (underlying_type) (expr)) #else #define unconstify(underlying_type, expr) \ ((underlying_type) (expr)) #define unvolatize(underlying_type, expr) \ ((underlying_type) (expr)) #endif /* ---------------------------------------------------------------- * Section 9: system-specific hacks * * This should be limited to things that absolutely have to be * included in every source file. The port-specific header file * is usually a better place for this sort of thing. * ---------------------------------------------------------------- */ /* * NOTE: this is also used for opening text files. * WIN32 treats Control-Z as EOF in files opened in text mode. * Therefore, we open files in binary mode on Win32 so we can read * literal control-Z. The other affect is that we see CRLF, but * that is OK because we can already handle those cleanly. */ #if defined(WIN32) || defined(__CYGWIN__) #define PG_BINARY O_BINARY #define PG_BINARY_A "ab" #define PG_BINARY_R "rb" #define PG_BINARY_W "wb" #else #define PG_BINARY 0 #define PG_BINARY_A "a" #define PG_BINARY_R "r" #define PG_BINARY_W "w" #endif /* * Provide prototypes for routines not present in a particular machine's * standard C library. */ #if !HAVE_DECL_FDATASYNC extern int fdatasync(int fildes); #endif /* * Thin wrappers that convert strings to exactly 64-bit integers, matching our * definition of int64. (For the naming, compare that POSIX has * strtoimax()/strtoumax() which return intmax_t/uintmax_t.) */ #ifdef HAVE_LONG_INT_64 #define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base)) #define strtou64(str, endptr, base) ((uint64) strtoul(str, endptr, base)) #else #define strtoi64(str, endptr, base) ((int64) strtoll(str, endptr, base)) #define strtou64(str, endptr, base) ((uint64) strtoull(str, endptr, base)) #endif /* * Similarly, wrappers around labs()/llabs() matching our int64. */ #ifdef HAVE_LONG_INT_64 #define i64abs(i) labs(i) #else #define i64abs(i) llabs(i) #endif /* * Use "extern PGDLLIMPORT ..." to declare variables that are defined * in the core backend and need to be accessible by loadable modules. * No special marking is required on most ports. */ #ifndef PGDLLIMPORT #define PGDLLIMPORT #endif /* * Use "extern PGDLLEXPORT ..." to declare functions that are defined in * loadable modules and need to be callable by the core backend or other * loadable modules. * If the compiler knows __attribute__((visibility("*"))), we use that, * unless we already have a platform-specific definition. Otherwise, * no special marking is required. */ #ifndef PGDLLEXPORT #ifdef HAVE_VISIBILITY_ATTRIBUTE #define PGDLLEXPORT __attribute__((visibility("default"))) #else #define PGDLLEXPORT #endif #endif /* * The following is used as the arg list for signal handlers. Any ports * that take something other than an int argument should override this in * their pg_config_os.h file. Note that variable names are required * because it is used in both the prototypes as well as the definitions. * Note also the long name. We expect that this won't collide with * other names causing compiler warnings. */ #ifndef SIGNAL_ARGS #define SIGNAL_ARGS int postgres_signal_arg #endif /* * When there is no sigsetjmp, its functionality is provided by plain * setjmp. We now support the case only on Windows. However, it seems * that MinGW-64 has some longstanding issues in its setjmp support, * so on that toolchain we cheat and use gcc's builtins. */ #ifdef WIN32 #ifdef __MINGW64__ typedef intptr_t sigjmp_buf[5]; #define sigsetjmp(x,y) __builtin_setjmp(x) #define siglongjmp __builtin_longjmp #else /* !__MINGW64__ */ #define sigjmp_buf jmp_buf #define sigsetjmp(x,y) setjmp(x) #define siglongjmp longjmp #endif /* __MINGW64__ */ #endif /* WIN32 */ /* /port compatibility functions */ //#include "port.h" #endif /* C_H */ chibicc-1.0.23.1/issues/complex_asm.c000066400000000000000000000006661505335450300173210ustar00rootroot00000000000000#include "test.h" int main() { int a = 10, b = 20; int result; // Extended assembly with named operand and expression inside parentheses __asm__ volatile ( "add %[src], %[dst]\n" : [dst] "=r" (result) // output operand name [dst] : [src] "r" (a + b) // input operand name [src], expression in parentheses ); printf("Result = %d\n", result); return 0; } chibicc-1.0.23.1/issues/constexpr2.c000066400000000000000000000056261505335450300171220ustar00rootroot00000000000000#include "test.h" #include #if !1u - 1 > 0 #error #endif extern int extarr[55]; int garr[11]; static int sgarr[33]; //_Bool str_lit_bool_init = "abc" ? "foo" && "bar" : 0; void array_cast_to_bool(int j) { static int slarr[5]; int larr[7]; char vla[j]; DASSERT((_Bool)extarr && (_Bool)garr && (_Bool)sgarr && (_Bool)slarr && (_Bool)larr && (_Bool)vla); // ASSERT(1, str_lit_bool_init); } int extarr[55]; extern int ext_var; extern void ext_fn(void); SASSERT(2 == ((_Bool)&ext_var + (_Bool)ext_fn)); #ifdef NOTGCC SASSERT(3 == ((_Bool)(long long)&ext_var + (_Bool)(_Bool)ext_fn + (_Bool)(long long)(_Bool)ext_fn)); #endif int main(void) { array_cast_to_bool(11); DASSERT((_Bool)0.1f == 1); DASSERT((_Bool)2 == 1); DASSERT((_Bool)(0.0f + 0.1f) == 1); DASSERT((_Bool)(2 * 3) == 1); DASSERT( -1 < 0 ); DASSERT( 3U << 31 >> 31 == 1); DASSERT( 1 << 31 >> 31 == -1); DASSERT(0.2 > 0.1); DASSERT(0.1 < 0.2); DASSERT(0.2 != 0.1); DASSERT(!(0.2 <= 0.1)); DASSERT(!(0.1 >= 0.2)); DASSERT(!(0.1 == 0.2)); DASSERT(!!0.1); DASSERT(0.1 ? 1 : 0); DASSERT((long)-0x1U == 4294967295); DASSERT((long)-0x1 == -1); DASSERT((long)-0xFFFFFFF0U == 16); DASSERT((long)-0xFFFFFFF0 == 16); DASSERT((long)~0x1U == 4294967294); DASSERT((long)~0x1 == -2); DASSERT((long)~0xFFFFFFF0U == 15); DASSERT((long)~0xFFFFFFF0 == 15); DASSERT((long)(0x80000000U << 1) == 0); DASSERT((long)(0xFFFFFFFFU + 1) == 0); DASSERT((long)(0U - 1) == 0xFFFFFFFFU); DASSERT((long)(25989 * 2972383464U) == 4287027336); // static_assert(INT32_MIN / -1 == INT32_MIN); // static_assert(INT64_MIN / -1 == INT64_MIN); // static_assert(INT32_MIN % -1 == 0); // static_assert(INT64_MIN % -1 == 0); DASSERT(13835058055282163712.0 == (double)13835058055282163712ULL); DASSERT(13835058055282163712.0f == (float) 13835058055282163712ULL); DASSERT(13835058055282163712ULL == (unsigned long long) 13835058055282163712.0f); DASSERT(13835058055282163712ULL == (unsigned long long) 13835058055282163712.0); DASSERT(13835058055282163711ULL == (unsigned long long) 13835058055282163711.0L); DASSERT(13835058055282163711.0L == (long double) 13835058055282163711ULL); DASSERT( 16777217.0 != (float)16777217.0 ); DASSERT( 9007199254740993.0L != (double)9007199254740993.0L || sizeof(double) == sizeof(long double) ); #ifdef NOTCLANG DASSERT( 127 == (unsigned char)511.0 >> 1 ); #endif DASSERT( (long long)(0.1f * 1e12f) == 99999997952LL ); ASSERT(1, ({ int i = 2; char arr[ (i++,3) ]; i == sizeof arr; }) ); { char (*arr_ptr)[UINT32_MAX + 1ULL]; DASSERT( sizeof(*arr_ptr) == (UINT32_MAX + 1ULL)); } { char arr[3]; DASSERT(8 == sizeof((0 ? arr:arr))); DASSERT(8 == sizeof((0 ? 0:arr))); DASSERT(8 == sizeof((0 ? arr:0))); DASSERT(8 == sizeof(({arr;}))); DASSERT(8 == sizeof((0,arr))); DASSERT(3 == sizeof( (typeof(arr)){0} )); } printf("OK\n"); return 0; }chibicc-1.0.23.1/issues/cpython.c000066400000000000000000000036171505335450300164750ustar00rootroot00000000000000#include #include #include #include #include #include #define NB_SMALL_SIZE_CLASSES 32 #define OBMALLOC_USED_POOLS_SIZE (2 * ((NB_SMALL_SIZE_CLASSES + 7) / 8) * 8) #define MAX_POOLS_IN_ARENA 8 #define INITIAL_ARENA_OBJECTS 16 typedef void* poolp; struct arena_object { int dummy; }; struct _obmalloc_pools { poolp used[OBMALLOC_USED_POOLS_SIZE]; }; struct _obmalloc_mgmt { struct arena_object* arenas; uint maxarenas; struct arena_object* unused_arena_objects; struct arena_object* usable_arenas; struct arena_object* nfp2lasta[MAX_POOLS_IN_ARENA + 1]; size_t narenas_currently_allocated; size_t ntimes_arena_allocated; size_t narenas_highwater; size_t raw_allocated_blocks; }; typedef struct _obmalloc_state { struct _obmalloc_pools pools; struct _obmalloc_mgmt mgmt; } OMState; // Simulate the interpreter state static OMState obmalloc_state_main; static OMState* get_state(void) { return &obmalloc_state_main; } // Simulated allocation void* _PyObject_Malloc(size_t nbytes) { OMState *state = get_state(); void* ptr = malloc(nbytes); if (ptr) state->mgmt.raw_allocated_blocks++; return ptr; } int main(void) { OMState *state = get_state(); printf("State address: %p\n", state); printf("Pools address: %p\n", &state->pools); printf("Mgmt address: %p\n", &state->mgmt); // Initialize pools for (int i = 0; i < OBMALLOC_USED_POOLS_SIZE; i++) state->pools.used[i] = (poolp)(uintptr_t)(0x1000 + i); // Allocate multiple objects void* objs[10]; for (int i = 0; i < 10; i++) { objs[i] = _PyObject_Malloc(64); printf("Allocated object[%d]: %p\n", i, objs[i]); } printf("Raw allocated blocks: %zu\n", state->mgmt.raw_allocated_blocks); return 0; } chibicc-1.0.23.1/issues/cpython_blake.c000066400000000000000000000035141505335450300176270ustar00rootroot00000000000000#define PY_SSIZE_T_CLEAN #include #include #include #define _Py_HACL_CAN_COMPILE_VEC128 0 #define _Py_HACL_CAN_COMPILE_VEC256 0 static void __cpuid_count(int info, int subinfo, int *eax, int *ebx, int *ecx, int *edx) { #if defined(__x86_64__) __asm__ volatile( "cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "a"(info), "c"(subinfo) ); #else *eax = *ebx = *ecx = *edx = 0; #endif } typedef struct { PyTypeObject *blake2b_type; PyTypeObject *blake2s_type; bool can_run_simd128; bool can_run_simd256; } Blake2State; static void blake2module_init_cpu_features(Blake2State *state) { int eax1 = 0, ebx1 = 0, ecx1 = 0, edx1 = 0; int eax7 = 0, ebx7 = 0, ecx7 = 0, edx7 = 0; __cpuid_count(1, 0, &eax1, &ebx1, &ecx1, &edx1); __cpuid_count(7, 0, &eax7, &ebx7, &ecx7, &edx7); bool avx = (ecx1 & (1 << 28)) != 0; bool avx2 = (ebx7 & (1 << 5)) != 0; bool sse = (edx1 & (1 << 25)) != 0; bool sse2 = (edx1 & (1 << 26)) != 0; bool cmov = (edx1 & (1 << 15)) != 0; bool sse3 = (ecx1 & (1 << 0)) != 0; bool sse41 = (ecx1 & (1 << 19)) != 0; bool sse42 = (ecx1 & (1 << 20)) != 0; state->can_run_simd128 = false; state->can_run_simd256 = false; } int main(void) { Blake2State st = {0}; blake2module_init_cpu_features(&st); printf("CPU feature detection result:\n"); printf(" can_run_simd128 = %s\n", st.can_run_simd128 ? "true" : "false"); printf(" can_run_simd256 = %s\n", st.can_run_simd256 ? "true" : "false"); if (st.can_run_simd256 && !st.can_run_simd128) { fprintf(stderr, "Invariant violated: SIMD256 requires SIMD128!\n"); return 1; } return 0; } chibicc-1.0.23.1/issues/curl557.c000066400000000000000000000002411505335450300162050ustar00rootroot00000000000000#include int main() { switch (0) { case 0: case (sizeof(int) == 8): ; // Duplicate case — should trigger error } return 0; } chibicc-1.0.23.1/issues/example.c000077500000000000000000000416521505335450300164500ustar00rootroot00000000000000/* example.c -- usage example of the zlib compression library * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zlib.h" #include #include typedef unsigned char Byte; /* 8 bits */ #ifdef STDC #include #include #endif #if defined(VMS) || defined(RISCOS) #define TESTFILE "foo-gz" #else #define TESTFILE "foo.gz" #endif #define CHECK_ERR(err, msg) \ { \ if (err != Z_OK) \ { \ fprintf(stderr, "%s error: %d\n", msg, err); \ exit(1); \ } \ } static z_const char hello[] = "hello, hello!"; /* "hello world" would be more standard, but the repeated "hello" * stresses the compression code better, sorry... */ static const char dictionary[] = "hello"; static uLong dictId; /* Adler32 value of the dictionary */ void test_deflate OF((Byte * compr, uLong comprLen)); void test_inflate OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_large_deflate OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_large_inflate OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_flush OF((Byte * compr, uLong *comprLen)); void test_sync OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_dict_deflate OF((Byte * compr, uLong comprLen)); void test_dict_inflate OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); int main OF((int argc, char *argv[])); #ifdef Z_SOLO void *myalloc OF((void *, unsigned, unsigned)); void myfree OF((void *, void *)); void *myalloc(q, n, m) void *q; unsigned n, m; { (void)q; return calloc(n, m); } void myfree(void *q, void *p) { (void)q; free(p); } static alloc_func zalloc = myalloc; static free_func zfree = myfree; #else /* !Z_SOLO */ static alloc_func zalloc = (alloc_func)0; static free_func zfree = (free_func)0; void test_compress OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_gzio OF((const char *fname, Byte *uncompr, uLong uncomprLen)); /* =========================================================================== * Test compress() and uncompress() */ void test_compress(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; uLong len = (uLong)strlen(hello) + 1; err = compress(compr, &comprLen, (const Bytef *)hello, len); CHECK_ERR(err, "compress"); strcpy((char *)uncompr, "garbage"); err = uncompress(uncompr, &uncomprLen, compr, comprLen); CHECK_ERR(err, "uncompress"); if (strcmp((char *)uncompr, hello)) { fprintf(stderr, "bad uncompress\n"); exit(1); } else { printf("uncompress(): %s\n", (char *)uncompr); } } /* =========================================================================== * Test read/write of .gz files */ void test_gzio(fname, uncompr, uncomprLen) const char *fname; /* compressed file name */ Byte *uncompr; uLong uncomprLen; { #ifdef NO_GZCOMPRESS fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); #else int err; int len = (int)strlen(hello) + 1; gzFile file; z_off_t pos; file = gzopen(fname, "wb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } gzputc(file, 'h'); if (gzputs(file, "ello") != 4) { fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); exit(1); } if (gzprintf(file, ", %s!", "hello") != 8) { fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); exit(1); } gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ gzclose(file); file = gzopen(fname, "rb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } strcpy((char *)uncompr, "garbage"); if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); exit(1); } if (strcmp((char *)uncompr, hello)) { fprintf(stderr, "bad gzread: %s\n", (char *)uncompr); exit(1); } else { printf("gzread(): %s\n", (char *)uncompr); } pos = gzseek(file, -8L, SEEK_CUR); if (pos != 6 || gztell(file) != pos) { fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", (long)pos, (long)gztell(file)); exit(1); } if (gzgetc(file) != ' ') { fprintf(stderr, "gzgetc error\n"); exit(1); } if (gzungetc(' ', file) != ' ') { fprintf(stderr, "gzungetc error\n"); exit(1); } gzgets(file, (char *)uncompr, (int)uncomprLen); if (strlen((char *)uncompr) != 7) { /* " hello!" */ fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); exit(1); } if (strcmp((char *)uncompr, hello + 6)) { fprintf(stderr, "bad gzgets after gzseek\n"); exit(1); } else { printf("gzgets() after gzseek: %s\n", (char *)uncompr); } gzclose(file); #endif } #endif /* Z_SOLO */ /* =========================================================================== * Test deflate() with small buffers */ void test_deflate(compr, comprLen) Byte *compr; uLong comprLen; { z_stream c_stream; /* compression stream */ int err; uLong len = (uLong)strlen(hello) + 1; c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); c_stream.next_in = (z_const unsigned char *)hello; c_stream.next_out = compr; while (c_stream.total_in != len && c_stream.total_out < comprLen) { c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); } /* Finish the stream, still forcing small buffers: */ for (;;) { c_stream.avail_out = 1; err = deflate(&c_stream, Z_FINISH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "deflate"); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with small buffers */ void test_inflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char *)uncompr, "garbage"); d_stream.zalloc = zalloc; d_stream.zfree = zfree; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = 0; d_stream.next_out = uncompr; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "inflate"); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); if (strcmp((char *)uncompr, hello)) { fprintf(stderr, "bad inflate\n"); exit(1); } else { printf("inflate(): %s\n", (char *)uncompr); } } /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { z_stream c_stream; /* compression stream */ int err; c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_BEST_SPEED); CHECK_ERR(err, "deflateInit"); c_stream.next_out = compr; c_stream.avail_out = (uInt)comprLen; /* At this point, uncompr is still mostly zeroes, so it should compress * very well: */ c_stream.next_in = uncompr; c_stream.avail_in = (uInt)uncomprLen; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); if (c_stream.avail_in != 0) { fprintf(stderr, "deflate not greedy\n"); exit(1); } /* Feed in already compressed data and switch to no compression: */ deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); c_stream.next_in = compr; c_stream.avail_in = (uInt)comprLen / 2; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); /* Switch back to compressing mode: */ deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); c_stream.next_in = uncompr; c_stream.avail_in = (uInt)uncomprLen; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with large buffers */ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char *)uncompr, "garbage"); d_stream.zalloc = zalloc; d_stream.zfree = zfree; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = (uInt)comprLen; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); for (;;) { d_stream.next_out = uncompr; /* discard the output */ d_stream.avail_out = (uInt)uncomprLen; err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "large inflate"); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); if (d_stream.total_out != 2 * uncomprLen + comprLen / 2) { fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); exit(1); } else { printf("large_inflate(): OK\n"); } } /* =========================================================================== * Test deflate() with full flush */ void test_flush(compr, comprLen) Byte *compr; uLong *comprLen; { z_stream c_stream; /* compression stream */ int err; uInt len = (uInt)strlen(hello) + 1; c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); c_stream.next_in = (z_const unsigned char *)hello; c_stream.next_out = compr; c_stream.avail_in = 3; c_stream.avail_out = (uInt)*comprLen; err = deflate(&c_stream, Z_FULL_FLUSH); CHECK_ERR(err, "deflate"); compr[3]++; /* force an error in first compressed block */ c_stream.avail_in = len - 3; err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { CHECK_ERR(err, "deflate"); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); *comprLen = c_stream.total_out; } /* =========================================================================== * Test inflateSync() */ void test_sync(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char *)uncompr, "garbage"); d_stream.zalloc = zalloc; d_stream.zfree = zfree; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = 2; /* just read the zlib header */ err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; d_stream.avail_out = (uInt)uncomprLen; err = inflate(&d_stream, Z_NO_FLUSH); CHECK_ERR(err, "inflate"); d_stream.avail_in = (uInt)comprLen - 2; /* read all compressed data */ err = inflateSync(&d_stream); /* but skip the damaged part */ CHECK_ERR(err, "inflateSync"); err = inflate(&d_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "inflate should report Z_STREAM_END\n"); exit(1); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); printf("after inflateSync(): hel%s\n", (char *)uncompr); } /* =========================================================================== * Test deflate() with preset dictionary */ void test_dict_deflate(compr, comprLen) Byte *compr; uLong comprLen; { z_stream c_stream; /* compression stream */ int err; c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_BEST_COMPRESSION); CHECK_ERR(err, "deflateInit"); err = deflateSetDictionary(&c_stream, (const Bytef *)dictionary, (int)sizeof(dictionary)); CHECK_ERR(err, "deflateSetDictionary"); dictId = c_stream.adler; c_stream.next_out = compr; c_stream.avail_out = (uInt)comprLen; c_stream.next_in = (z_const unsigned char *)hello; c_stream.avail_in = (uInt)strlen(hello) + 1; err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with a preset dictionary */ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char *)uncompr, "garbage"); d_stream.zalloc = zalloc; d_stream.zfree = zfree; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = (uInt)comprLen; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; d_stream.avail_out = (uInt)uncomprLen; for (;;) { err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; if (err == Z_NEED_DICT) { if (d_stream.adler != dictId) { fprintf(stderr, "unexpected dictionary"); exit(1); } err = inflateSetDictionary(&d_stream, (const Bytef *)dictionary, (int)sizeof(dictionary)); } CHECK_ERR(err, "inflate with dict"); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); if (strcmp((char *)uncompr, hello)) { fprintf(stderr, "bad inflate with dict\n"); exit(1); } else { printf("inflate with dictionary: %s\n", (char *)uncompr); } } /* =========================================================================== * Usage: example [output.gz [input.gz]] */ int main(argc, argv) int argc; char *argv[]; { Byte *compr, *uncompr; uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; static const char *myVersion = ZLIB_VERSION; if (zlibVersion()[0] != myVersion[0]) { fprintf(stderr, "incompatible zlib version\n"); exit(1); } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { fprintf(stderr, "warning: different zlib version\n"); } printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); compr = (Byte *)calloc((uInt)comprLen, 1); uncompr = (Byte *)calloc((uInt)uncomprLen, 1); /* compr and uncompr are cleared to avoid reading uninitialized * data and to ensure that uncompr compresses well. */ if (compr == Z_NULL || uncompr == Z_NULL) { printf("out of memory\n"); exit(1); } #ifdef Z_SOLO (void)argc; (void)argv; #else test_compress(compr, comprLen, uncompr, uncomprLen); test_gzio((argc > 1 ? argv[1] : TESTFILE), uncompr, uncomprLen); #endif test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); test_large_deflate(compr, comprLen, uncompr, uncomprLen); test_large_inflate(compr, comprLen, uncompr, uncomprLen); test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); comprLen = uncomprLen; test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); free(compr); free(uncompr); return 0; } chibicc-1.0.23.1/issues/expr.h000066400000000000000000000250361505335450300157730ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (C) 2002 Roman Zippel */ #ifndef EXPR_H #define EXPR_H #ifdef __cplusplus extern "C" { #endif #include #include #include "list.h" #ifndef __cplusplus #include #endif struct file { struct file *next; struct file *parent; const char *name; int lineno; }; typedef enum tristate { no, mod, yes } tristate; enum expr_type { E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LTH, E_LEQ, E_GTH, E_GEQ, E_LIST, E_SYMBOL, E_RANGE }; union expr_data { struct expr *expr; struct symbol *sym; }; struct expr { enum expr_type type; union expr_data left, right; }; #define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) #define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) #define EXPR_NOT(dep) (2-(dep)) #define expr_list_for_each_sym(l, e, s) \ for (e = (l); e && (s = e->right.sym); e = e->left.expr) struct expr_value { struct expr *expr; tristate tri; }; struct symbol_value { void *val; tristate tri; }; enum symbol_type { S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING }; /* enum values are used as index to symbol.def[] */ enum { S_DEF_USER, /* main user value */ S_DEF_AUTO, /* values read from auto.conf */ S_DEF_DEF3, /* Reserved for UI usage */ S_DEF_DEF4, /* Reserved for UI usage */ S_DEF_COUNT }; /* * Represents a configuration symbol. * * Choices are represented as a special kind of symbol and have the * SYMBOL_CHOICE bit set in 'flags'. */ struct symbol { /* The next symbol in the same bucket in the symbol hash table */ struct symbol *next; /* The name of the symbol, e.g. "FOO" for 'config FOO' */ char *name; /* S_BOOLEAN, S_TRISTATE, ... */ enum symbol_type type; /* * The calculated value of the symbol. The SYMBOL_VALID bit is set in * 'flags' when this is up to date. Note that this value might differ * from the user value set in e.g. a .config file, due to visibility. */ struct symbol_value curr; /* * Values for the symbol provided from outside. def[S_DEF_USER] holds * the .config value. */ struct symbol_value def[S_DEF_COUNT]; /* * An upper bound on the tristate value the user can set for the symbol * if it is a boolean or tristate. Calculated from prompt dependencies, * which also inherit dependencies from enclosing menus, choices, and * ifs. If 'n', the user value will be ignored. * * Symbols lacking prompts always have visibility 'n'. */ tristate visible; /* SYMBOL_* flags */ int flags; /* List of properties. See prop_type. */ struct property *prop; /* Dependencies from enclosing menus, choices, and ifs */ struct expr_value dir_dep; /* Reverse dependencies through being selected by other symbols */ struct expr_value rev_dep; /* * "Weak" reverse dependencies through being implied by other symbols */ struct expr_value implied; }; #define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) #define SYMBOL_CONST 0x0001 /* symbol is const */ #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400 /* ? */ #define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */ #define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ #define SYMBOL_WARNED 0x8000 /* warning has been issued */ /* Set when symbol.def[] is used */ #define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ #define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ #define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ /* choice values need to be set before calculating this symbol value */ #define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 #define SYMBOL_MAXLENGTH 256 #define SYMBOL_HASHSIZE 9973 /* A property represent the config options that can be associated * with a config "symbol". * Sample: * config FOO * default y * prompt "foo prompt" * select BAR * config BAZ * int "BAZ Value" * range 1..255 * * Please, also check parser.y:print_symbol() when modifying the * list of property types! */ enum prop_type { P_UNKNOWN, P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ P_COMMENT, /* text associated with a comment */ P_MENU, /* prompt associated with a menu or menuconfig symbol */ P_DEFAULT, /* default y */ P_CHOICE, /* choice value */ P_SELECT, /* select BAR */ P_IMPLY, /* imply BAR */ P_RANGE, /* range 7..100 (for a symbol) */ P_SYMBOL, /* where a symbol is defined */ P_RESET, /* reset to defaults condition */ }; struct property { struct property *next; /* next property - null if last */ enum prop_type type; /* type of property */ const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ struct expr_value visible; struct expr *expr; /* the optional conditional part of the property */ struct menu *menu; /* the menu the property are associated with * valid for: P_SELECT, P_RANGE, P_CHOICE, * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ struct file *file; /* what file was this property defined */ int lineno; /* what lineno was this property defined */ }; #define for_all_properties(sym, st, tok) \ for (st = sym->prop; st; st = st->next) \ if (st->type == (tok)) #define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) #define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) #define for_all_prompts(sym, st) \ for (st = sym->prop; st; st = st->next) \ if (st->text) /* * Represents a node in the menu tree, as seen in e.g. menuconfig (though used * for all front ends). Each symbol, menu, etc. defined in the Kconfig files * gets a node. A symbol defined in multiple locations gets one node at each * location. */ struct menu { /* The next menu node at the same level */ struct menu *next; /* The parent menu node, corresponding to e.g. a menu or choice */ struct menu *parent; /* The first child menu node, for e.g. menus and choices */ struct menu *list; /* * The symbol associated with the menu node. Choices are implemented as * a special kind of symbol. NULL for menus, comments, and ifs. */ struct symbol *sym; /* * The prompt associated with the node. This holds the prompt for a * symbol as well as the text for a menu or comment, along with the * type (P_PROMPT, P_MENU, etc.) */ struct property *prompt; /* * 'visible if' dependencies. If more than one is given, they will be * ANDed together. */ struct expr *visibility; /* * Ordinary dependencies from e.g. 'depends on' and 'if', ANDed * together */ struct expr *dep; /* MENU_* flags */ unsigned int flags; /* Any help text associated with the node */ char *help; /* The location where the menu node appears in the Kconfig files */ struct file *file; int lineno; /* For use by front ends that need to store auxiliary data */ void *data; }; /* * Set on a menu node when the corresponding symbol changes state in some way. * Can be checked by front ends. */ #define MENU_CHANGED 0x0001 #define MENU_ROOT 0x0002 struct jump_key { struct list_head entries; size_t offset; struct menu *target; int index; }; extern struct file *file_list; extern struct file *current_file; struct file *lookup_file(const char *name); extern struct symbol symbol_yes, symbol_no, symbol_mod; extern struct symbol *modules_sym; extern int cdebug; struct expr *expr_alloc_symbol(struct symbol *sym); struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); struct expr *expr_copy(const struct expr *org); void expr_free(struct expr *e); void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); int expr_eq(struct expr *e1, struct expr *e2); tristate expr_calc_value(struct expr *e); struct expr *expr_trans_bool(struct expr *e); struct expr *expr_eliminate_dups(struct expr *e); struct expr *expr_transform(struct expr *e); int expr_contains_symbol(struct expr *dep, struct symbol *sym); bool expr_depends_symbol(struct expr *dep, struct symbol *sym); struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ void expr_gstr_print(struct expr *e, struct gstr *gs); void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, tristate pr_type, const char *title); static inline int expr_is_yes(struct expr *e) { return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); } static inline int expr_is_no(struct expr *e) { return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); } #ifdef __cplusplus } #endif #endif /* EXPR_H */chibicc-1.0.23.1/issues/function2.c000066400000000000000000000073211505335450300167140ustar00rootroot00000000000000#include "test.h" #include typedef struct { char g; } G; typedef struct { float f; } F; typedef struct { char l; float d; } A; extern float struct_test101( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ); float struct_test100( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } extern float struct_test111( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ); float struct_test110( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } extern float struct_test121( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1); float struct_test120( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1) { return reg0.l + reg0.d + reg1.l + reg1.d + reg2.l + reg2.d + reg3.l + reg3.d + reg4.l + reg4.d + reg5.l + reg5.d + s0.l + s0.d + s1.l + s1.d + f6.f + f7.f; } typedef struct { char _Alignas(1024) c; } Aligned1024; //extern int struct_test131(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5,int i0,int i1,...); int struct_test130(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5,int i0,int i1,...) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, int); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, long double); va_end(ap); return ret; } int main(void) { G g[] = {10,11,12,13,14,15}; F f[] = {20,21,22,23,24,25,26,27}; G gs[] = {30,31}; F fs[] = {40,41}; ASSERT(405, struct_test100( g[0], g[1], g[2], g[3], g[4], g[5], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test101( g[0], g[1], g[2], g[3], g[4], g[5], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test110( f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], g[0], g[1], g[2], g[3], g[4], g[5], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test111( f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], g[0], g[1], g[2], g[3], g[4], g[5], gs[0], fs[0], gs[1], fs[1])); A reg[] = {10,11,20,21,30,31,40,41,50,51,60,61}; A as[] = {70,71,80,81}; ASSERT(781, struct_test120( reg[0], reg[1], reg[2], reg[3], reg[4], reg[5], as[0], f[6], f[7], as[1])); ASSERT(781, struct_test121( reg[0], reg[1], reg[2], reg[3], reg[4], reg[5], as[0], f[6], f[7], as[1])); Aligned1024 s = {.c = 77}; // ASSERT(257, struct_test131( // g[0], g[1], g[2], g[3], g[4], // f[0], f[1], f[2], f[3], f[4], f[5], // (int) 11, // (int) 22, // (long double) 2.3, // (Aligned1024) s, // (int) 33, // (double) 4.5, // (double) 5.6, // (double) 6.7, // (double) 7.8, // (Aligned1024) s, // (long double) 11.1)); // ASSERT(257, struct_test130( // g[0], g[1], g[2], g[3], g[4], // f[0], f[1], f[2], f[3], f[4], f[5], // (int) 11, // (int) 22, // (long double) 2.3, // (Aligned1024) s, // (int) 33, // (double) 4.5, // (double) 5.6, // (double) 6.7, // (double) 7.8, // (Aligned1024) s, // (long double) 11.1)); printf("OK\n"); }chibicc-1.0.23.1/issues/function2b.c000066400000000000000000000161341505335450300170600ustar00rootroot00000000000000#include "test.h" #include typedef struct { char g; } G; typedef struct { float f; } F; typedef struct { char l; float d; } A; extern float struct_test101( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ); float struct_test100( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } extern float struct_test111( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ); float struct_test110( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } extern float struct_test121( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1); float struct_test120( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1) { return reg0.l + reg0.d + reg1.l + reg1.d + reg2.l + reg2.d + reg3.l + reg3.d + reg4.l + reg4.d + reg5.l + reg5.d + s0.l + s0.d + s1.l + s1.d + f6.f + f7.f; } typedef struct { char _Alignas(1024) c; } Aligned1024; extern int struct_test131(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5,int i0,int i1,...); int struct_test130(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5,int i0,int i1,...) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, int); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, long double); va_end(ap); return ret; } typedef struct { long i,j; } DI; int struct_test141(int cnt,...); int struct_test140(int cnt,...) { va_list ap; va_start(ap, cnt); long ret = 0; for (int i = 0; i < cnt; i++) { DI s = va_arg(ap, DI); ret += s.i + s.j; } va_end(ap); return ret; } typedef struct { double d,f; } DD; int struct_test151(int cnt,...); int struct_test150(int cnt,...) { va_list ap; va_start(ap, cnt); double ret = 0; for (int i = 0; i < cnt; i++) { DD s = va_arg(ap, DD); ret += s.d + s.f; } va_end(ap); return ret; } typedef struct { long i; double d; } DM; int struct_test161(int cnt,...); int struct_test160(int cnt,...) { va_list ap; va_start(ap, cnt); double ret = 0; for (int i = 0; i < cnt; i++) { DM s = va_arg(ap, DM); ret += s.d + s.i; } va_end(ap); return ret; } typedef struct { union { long double ld[1]; long double ld2; } u[1]; } struct170; struct170 struct_test171(struct170 t1,...); struct170 struct_test170(struct170 t1,...) { va_list ap; va_start(ap, t1); struct170 t = t1; t.u[0].ld2 += va_arg(ap, struct170).u[0].ld[0]; va_end(ap); return t; } typedef union { long double ld; long i; } struct180; struct180 struct_test181(struct180 t1,...); struct180 struct_test180(struct180 t1,...) { va_list ap; va_start(ap, t1); struct180 t = t1; t.ld += va_arg(ap, struct180).ld; va_end(ap); return t; } static int add_all2(int n, ...) { va_list ap; va_start(ap, n); int sum = 0; for (int i = 0; i < n; i++) sum += ({ va_arg(ap, int); }); va_end(ap); return sum; } int main(void) { G g[] = {10,11,12,13,14,15}; F f[] = {20,21,22,23,24,25,26,27}; G gs[] = {30,31}; F fs[] = {40,41}; ASSERT(405, struct_test100( g[0], g[1], g[2], g[3], g[4], g[5], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test101( g[0], g[1], g[2], g[3], g[4], g[5], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test110( f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], g[0], g[1], g[2], g[3], g[4], g[5], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test111( f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], g[0], g[1], g[2], g[3], g[4], g[5], gs[0], fs[0], gs[1], fs[1])); A reg[] = {10,11,20,21,30,31,40,41,50,51,60,61}; A as[] = {70,71,80,81}; ASSERT(781, struct_test120( reg[0], reg[1], reg[2], reg[3], reg[4], reg[5], as[0], f[6], f[7], as[1])); ASSERT(781, struct_test121( reg[0], reg[1], reg[2], reg[3], reg[4], reg[5], as[0], f[6], f[7], as[1])); Aligned1024 s = {.c = 77}; ASSERT(257, struct_test131( g[0], g[1], g[2], g[3], g[4], f[0], f[1], f[2], f[3], f[4], f[5], (int) 11, (int) 22, (long double) 2.3, s, // (Aligned1024) (int) 33, (double) 4.5, (double) 5.6, (double) 6.7, (double) 7.8, s, // (Aligned1024) (long double) 11.1)); ASSERT(257, struct_test130( g[0], g[1], g[2], g[3], g[4], f[0], f[1], f[2], f[3], f[4], f[5], (int) 11, (int) 22, (long double) 2.3, s, // (Aligned1024) (int) 33, (double) 4.5, (double) 5.6, (double) 6.7, (double) 7.8, s, // (Aligned1024) (long double) 11.1)); { DI s0 = {2,3}; DI s1 = {5,7}; DI s2 = {11,13}; DI s3 = {17,19}; DI s4 = {23,29}; DI s5 = {31,37}; DI s6 = {41,43}; DI s7 = {47,53}; DI s8 = {59,61}; DI s9 = {67,71}; ASSERT(639, struct_test140(10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9)); ASSERT(639, struct_test141(10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9)); } { DD s0 = {2,3}; DD s1 = {5,7}; DD s2 = {11,13}; DD s3 = {17,19}; DD s4 = {23,29}; DD s5 = {31,37}; DD s6 = {41,43}; DD s7 = {47,53}; DD s8 = {59,61}; DD s9 = {67,71}; ASSERT(639, struct_test150(10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9)); ASSERT(639, struct_test151(10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9)); } { DM s0 = {2,3}; DM s1 = {5,7}; DM s2 = {11,13}; DM s3 = {17,19}; DM s4 = {23,29}; DM s5 = {31,37}; DM s6 = {41,43}; DM s7 = {47,53}; DM s8 = {59,61}; DM s9 = {67,71}; ASSERT(639, struct_test160(10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9)); ASSERT(639, struct_test161(10, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9)); } ASSERT(6, add_all2(3,1,2,3)); ASSERT(5, add_all2(4,1,2,3,-1)); { struct170 t1 = {13}; struct170 t2 = {24}; ASSERT(37, struct_test170(t1, t2).u[0].ld[0]); ASSERT(37, struct_test171(t1, t2).u[0].ld[0]); } { struct180 t1 = {31}; struct180 t2 = {42}; ASSERT(73, struct_test180(t1, t2).ld); ASSERT(73, struct_test181(t1, t2).ld); } //ASSERT(sizeof(void*), sizeof (main + 1) ); ASSERT(sizeof(void*), sizeof ({ main; }) ); ASSERT(sizeof(void*), sizeof (0 ? main : main) ); ASSERT(sizeof(void*), sizeof (0, main) ); //ASSERT(1, sizeof * (main + 1) ); ASSERT(1, sizeof * ({ main; }) ); ASSERT(1, sizeof * (0 ? main : main) ); ASSERT(1, sizeof * (0, main) ); printf("OK\n"); }chibicc-1.0.23.1/issues/function3.c000066400000000000000000000032031505335450300167100ustar00rootroot00000000000000#include "test.h" #include typedef struct { char g; } G; typedef struct { float f; } F; typedef struct { char l; float d; } A; typedef struct { char _Alignas(1024) c; } Aligned1024; //extern int struct_test131(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5,int i0,int i1,...); int struct_test130(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5,int i0,int i1,...) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); //ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, int); //ret += va_arg(ap, double); //ret += va_arg(ap, double); //ret += va_arg(ap, double); //ret += va_arg(ap, double); //ret += va_arg(ap, Aligned1024).c; //ret += va_arg(ap, long double); va_end(ap); return ret; } int main(void) { G g[] = {10,11,12,13,14,15}; F f[] = {20,21,22,23,24,25,26,27}; G gs[] = {30,31}; F fs[] = {40,41}; Aligned1024 s = {.c = 77}; ASSERT(43, struct_test130( g[0], g[1], g[2], g[3], g[4], f[0], f[1], f[2], f[3], f[4], f[5], (int) 11, (int) 22, (long double) 2.3, //(Aligned1024) s, (int) 33 //(double) 4.5, //(double) 5.6, //(double) 6.7, //(double) 7.8 //(Aligned1024) s //(long double) 11.1 ) ); // ASSERT(257, struct_test131( // g[0], g[1], g[2], g[3], g[4], // f[0], f[1], f[2], f[3], f[4], f[5], // (int) 11, // (int) 22, // //(long double) 2.3, // //(Aligned1024) s, // (int) 33, // (double) 4.5, // (double) 5.6, // (double) 6.7, // (double) 7.8 // //(Aligned1024) s // //(long double) 11.1 // )); printf("OK\n"); }chibicc-1.0.23.1/issues/function6.c000066400000000000000000000024561505335450300167240ustar00rootroot00000000000000#include #include typedef int G; // Dummy placeholder for G type typedef double F; // Dummy placeholder for F type typedef struct { char c; // no special alignment here } Aligned1024; // name kept, but no _Alignas int struct_test130( G g0, G g1, G g2, G g3, G g4, F f0, F f1, F f2, F f3, F f4, F f5, int i0, int i1, ... ) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); // read a long double from variadic args ret += va_arg(ap, int); // read int ret += va_arg(ap, Aligned1024).c; // read struct (just its char) // you can uncomment and add more va_arg calls here as needed va_end(ap); return ret; } int main() { G g_vals[5] = {1,2,3,4,5}; F f_vals[6] = {1,2,3,4,5,6}; Aligned1024 s = {7}; // Call with variadic args: long double, int, Aligned1024 long double ld = 10.5L; int i = 20; long double result = struct_test130( g_vals[0], g_vals[1], g_vals[2], g_vals[3], g_vals[4], f_vals[0], f_vals[1], f_vals[2], f_vals[3], f_vals[4], f_vals[5], 100, 200, ld, // variadic long double i, // variadic int s // variadic struct ); printf("Result = %.2Lf\n", result); // Expected: 100 + 200 + 10.5 + 20 + 7 = 337.5 return 0; } chibicc-1.0.23.1/issues/initializer2.c000066400000000000000000000025731505335450300174160ustar00rootroot00000000000000#include "test.h" long double ld = 0.0L; const int arr[2][2] = {{1,2},{3,4}}; int *const p1 = arr[1]; int g1 = ((int){77}); int g2 = arr[1][1]; const struct { int *a, *b, *c; } relo = {.a = &g1, .c = &g2}; int *p2 = relo.c; int *p1p = p1; struct S { int i, j, k; }; struct S const s1 = {99, 88, 77}; struct S s2 = (struct S){33,44,55}; struct S s3 = s1; #ifdef NOTGCC int g3 = (struct S){55,66,77}.j; int g4 = (const int[]){11,22,33,44}[2]; #endif static long long obar = 2 + (long long)"foobar"; _Bool b = 2; _Bool ba[] = {3,3,3}; struct { _Bool b; } bs = {4}; int main(void) { ASSERT(3, *p1); ASSERT(77, g1); ASSERT(4, g2); ASSERT(1, p2 == &g2); ASSERT(1, p1p == p1); ASSERT(33, s2.i); ASSERT(44, s2.j); ASSERT(55, s2.k); ASSERT(99, s3.i); ASSERT(88, s3.j); ASSERT(77, s3.k); #ifdef NOTGCC ASSERT(66, g3); ASSERT(33, g4); #endif ASSERT(1, b); ASSERT(1, ba[2]); ASSERT(1, bs.b); ASSERT(0, strcmp("obar", (char *)obar)); { int i[2][4] = {[0][0 ... 1] = 4, 2, 3, 7, [1][1 ... 2] = 1, 9}; int ans[] = {4,4,2,3,7,1,1,9}; ASSERT(0, memcmp(&i, &ans, sizeof(ans))); } { struct Sub { int i; }; struct S { struct Sub b; int j; }; struct Sub b = {3}; struct S s[] = {b, 6, 7}; ASSERT(3, s[0].b.i); ASSERT(6, s[0].j); ASSERT(7, s[1].b.i); ASSERT(0, s[1].j); } printf("OK\n"); }chibicc-1.0.23.1/issues/int128_test.c000066400000000000000000000001771505335450300170730ustar00rootroot00000000000000//#include "test.h" int main() { __int128 a = 8 ; __int128 b = 7; __int128 c = 0; c = a + b; return c; }chibicc-1.0.23.1/issues/isl.c000066400000000000000000000000721505335450300155700ustar00rootroot00000000000000 #include int main() { return 0; }chibicc-1.0.23.1/issues/issue108b.c000077500000000000000000000306241505335450300165350ustar00rootroot00000000000000/***************************************************************************** * vlc_charset.h: Unicode UTF-8 wrappers function ***************************************************************************** * Copyright (C) 2003-2005 VLC authors and VideoLAN * Copyright © 2005-2010 Rémi Denis-Courmont * * Author: Rémi Denis-Courmont * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include #include #include "vlc_common.h" #ifndef VLC_CHARSET_H #define VLC_CHARSET_H 1 /** * \file vlc_charset.h * \ingroup charset * \defgroup charset Character sets * \ingroup strings * @{ */ /** * Decodes a code point from UTF-8. * * Converts the first character in a UTF-8 sequence into a Unicode code point. * * \param str an UTF-8 bytes sequence [IN] * \param pwc address of a location to store the code point [OUT] * * \return the number of bytes occupied by the decoded code point * * \retval (size_t)-1 not a valid UTF-8 sequence * \retval 0 null character (i.e. str points to an empty string) * \retval 1 (non-null) ASCII character * \retval 2-4 non-ASCII character */ VLC_API size_t vlc_towc(const char *str, uint32_t *restrict pwc); /** * Checks UTF-8 validity. * * Checks whether a null-terminated string is a valid UTF-8 bytes sequence. * * \param str string to check * * \retval str the string is a valid null-terminated UTF-8 sequence * \retval NULL the string is not an UTF-8 sequence */ VLC_USED static inline const char *IsUTF8(const char *str) { size_t n; uint32_t cp; while ((n = vlc_towc(str, &cp)) != 0) if (likely(n != (size_t)-1)) str += n; else return NULL; return str; } /** * Checks ASCII validity. * * Checks whether a null-terminated string is a valid ASCII bytes sequence * (non-printable ASCII characters 1-31 are permitted). * * \param str string to check * * \retval str the string is a valid null-terminated ASCII sequence * \retval NULL the string is not an ASCII sequence */ VLC_USED static inline const char *IsASCII(const char *str) { unsigned char c; for (const char *p = str; (c = *p) != '\0'; p++) if (c >= 0x80) return NULL; return str; } /** * Removes non-UTF-8 sequences. * * Replaces invalid or over-long UTF-8 bytes sequences within a * null-terminated string with question marks. This is so that the string can * be printed at least partially. * * \warning Do not use this were correctness is critical. use IsUTF8() and * handle the error case instead. This function is mainly for display or debug. * * \note Converting from Latin-1 to UTF-8 in place is not possible (the string * size would be increased). So it is not attempted even if it would otherwise * be less disruptive. * * \retval str the string is a valid null-terminated UTF-8 sequence * (i.e. no changes were made) * \retval NULL the string is not an UTF-8 sequence */ static inline char *EnsureUTF8(char *str) { char *ret = str; size_t n; uint32_t cp; while ((n = vlc_towc(str, &cp)) != 0) if (likely(n != (size_t)-1)) str += n; else { *str++ = '?'; ret = NULL; } return ret; } /** * \defgroup iconv iconv wrappers * * (defined in src/extras/libc.c) * @{ */ #define VLC_ICONV_ERR ((size_t) -1) typedef void *vlc_iconv_t; VLC_API vlc_iconv_t vlc_iconv_open( const char *, const char * ) VLC_USED; VLC_API size_t vlc_iconv( vlc_iconv_t, const char **, size_t *, char **, size_t * ) VLC_USED; VLC_API int vlc_iconv_close( vlc_iconv_t ); /** @} */ #include VLC_API int utf8_vfprintf( FILE *stream, const char *fmt, va_list ap ); VLC_API int utf8_fprintf( FILE *, const char *, ... ) VLC_FORMAT( 2, 3 ); VLC_API char * vlc_strcasestr(const char *, const char *) VLC_USED; VLC_API char * FromCharset( const char *charset, const void *data, size_t data_size ) VLC_USED; VLC_API void * ToCharset( const char *charset, const char *in, size_t *outsize ) VLC_USED; #ifdef __APPLE__ # include /* Obtains a copy of the contents of a CFString in specified encoding. * Returns char* (must be freed by caller) or NULL on failure. */ VLC_USED static inline char *FromCFString(const CFStringRef cfString, const CFStringEncoding cfStringEncoding) { // Try the quick way to obtain the buffer const char *tmpBuffer = CFStringGetCStringPtr(cfString, cfStringEncoding); if (tmpBuffer != NULL) { return strdup(tmpBuffer); } // The quick way did not work, try the long way CFIndex length = CFStringGetLength(cfString); CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, cfStringEncoding); // If result would exceed LONG_MAX, kCFNotFound is returned if (unlikely(maxSize == kCFNotFound)) { return NULL; } // Account for the null terminator maxSize++; char *buffer = (char *)malloc(maxSize); if (unlikely(buffer == NULL)) { return NULL; } // Copy CFString in requested encoding to buffer Boolean success = CFStringGetCString(cfString, buffer, maxSize, cfStringEncoding); if (!success) FREENULL(buffer); return buffer; } #endif #ifdef _WIN32 VLC_USED static inline char *FromWide (const wchar_t *wide) { size_t len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL); if (len == 0) return NULL; char *out = (char *)malloc (len); if (likely(out)) WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL); return out; } VLC_USED static inline wchar_t *ToWide (const char *utf8) { int len = MultiByteToWideChar (CP_UTF8, 0, utf8, -1, NULL, 0); if (len == 0) return NULL; wchar_t *out = (wchar_t *)malloc (len * sizeof (wchar_t)); if (likely(out)) MultiByteToWideChar (CP_UTF8, 0, utf8, -1, out, len); return out; } VLC_USED VLC_MALLOC static inline char *ToCodePage (unsigned cp, const char *utf8) { wchar_t *wide = ToWide (utf8); if (wide == NULL) return NULL; size_t len = WideCharToMultiByte (cp, 0, wide, -1, NULL, 0, NULL, NULL); if (len == 0) { free(wide); return NULL; } char *out = (char *)malloc (len); if (likely(out != NULL)) WideCharToMultiByte (cp, 0, wide, -1, out, len, NULL, NULL); free (wide); return out; } VLC_USED VLC_MALLOC static inline char *FromCodePage (unsigned cp, const char *mb) { int len = MultiByteToWideChar (cp, 0, mb, -1, NULL, 0); if (len == 0) return NULL; wchar_t *wide = (wchar_t *)malloc (len * sizeof (wchar_t)); if (unlikely(wide == NULL)) return NULL; MultiByteToWideChar (cp, 0, mb, -1, wide, len); char *utf8 = FromWide (wide); free (wide); return utf8; } VLC_USED VLC_MALLOC static inline char *FromANSI (const char *ansi) { return FromCodePage (GetACP (), ansi); } VLC_USED VLC_MALLOC static inline char *ToANSI (const char *utf8) { return ToCodePage (GetACP (), utf8); } # define FromLocale FromANSI # define ToLocale ToANSI # define LocaleFree(s) free((char *)(s)) # define FromLocaleDup FromANSI # define ToLocaleDup ToANSI #elif defined(__OS2__) VLC_USED static inline char *FromLocale (const char *locale) { return locale ? FromCharset ((char *)"", locale, strlen(locale)) : NULL; } VLC_USED static inline char *ToLocale (const char *utf8) { size_t outsize; return utf8 ? (char *)ToCharset ("", utf8, &outsize) : NULL; } VLC_USED static inline void LocaleFree (const char *str) { free ((char *)str); } VLC_USED static inline char *FromLocaleDup (const char *locale) { return FromCharset ("", locale, strlen(locale)); } VLC_USED static inline char *ToLocaleDup (const char *utf8) { size_t outsize; return (char *)ToCharset ("", utf8, &outsize); } #else # define FromLocale(l) (l) # define ToLocale(u) (u) # define LocaleFree(s) ((void)(s)) # define FromLocaleDup strdup # define ToLocaleDup strdup #endif /** * Converts a nul-terminated string from ISO-8859-1 to UTF-8. */ static inline char *FromLatin1 (const char *latin) { char *str = (char *)malloc (2 * strlen (latin) + 1), *utf8 = str; unsigned char c; if (str == NULL) return NULL; while ((c = *(latin++)) != '\0') { if (c >= 0x80) { *(utf8++) = 0xC0 | (c >> 6); *(utf8++) = 0x80 | (c & 0x3F); } else *(utf8++) = c; } *(utf8++) = '\0'; utf8 = (char *)realloc (str, utf8 - str); return utf8 ? utf8 : str; } /** * \defgroup c_locale C/POSIX locale functions * @{ */ /** * Parses a double in C locale. * * This function parses a double-precision floating point number from a string * just like the standard strtod() but it uses the C locale. In other words, it * expects the POSIX/C/American decimal format regardless of the current * numeric locale. * * \param str nul-terminated string to parse * \param[out] end storage space for a pointer to the first unparsed byte * (or NULL to discard it) * \return the parsed double value (zero if no character could be parsed) */ VLC_API double vlc_strtod_c(const char *restrict str, char **restrict end) VLC_USED; /** * Parses a float in C locale. * * This function parses a single-precision floating point number from a string * just like the standard strtof() but it uses the C locale. In other words, it * expects the POSIX/C/American decimal format regardless of the current * numeric locale. * * \param str nul-terminated string to parse * \param[out] end storage space for a pointer to the first unparsed byte * (or NULL to discard it) * \return the parsed double value (zero if no character could be parsed) */ VLC_API float vlc_strtof_c(const char * restrict str, char ** restrict end) VLC_USED; /** * Parses a double in C locale. * * This function parses a double-precision floating point number from a string * just like the standard atof() but it uses the C locale. In other words, it * expects the POSIX/C/American decimal format regardless of the current * numeric locale. * * \param str nul-terminated string to parse * \return the parsed double value (zero if no character could be parsed) */ VLC_USED static inline double vlc_atof_c(const char *str) { return vlc_strtod_c(str, NULL); } /** * Formats a string using the C locale. * * This function formats a string from a format string and a variable argument * list, just like the standard vasprintf() but using the C locale for the * formatting of numerals. * * \param[out] p storage space for a pointer to the heap-allocated formatted * string (undefined on error) * \param fmt format string * \param ap variable argument list * \return number of bytes formatted (excluding the nul terminator) * or -1 on error */ VLC_API int vlc_vasprintf_c(char ** restrict p, const char * restrict fmt, va_list ap) VLC_USED; /** * Formats a string using the C locale. * * This function formats a string from a format string and a variable argument * list, just like the standard vasprintf() but using the C locale for the * formatting of numerals. * * \param[out] p storage space for a pointer to the heap-allocated formatted * string (undefined on error) * \param fmt format string * \return number of bytes formatted (excluding the nul terminator) * or -1 on error */ VLC_API int vlc_asprintf_c( char **, const char *, ... ) VLC_USED; int vlc_vsscanf_c(const char *, const char *, va_list) VLC_USED; int vlc_sscanf_c(const char*, const char*, ...) VLC_USED #ifdef __GNUC__ __attribute__((format(scanf, 2, 3))) #endif ; /** @} */ /** @} */ #endif int main(void) { return 0; }chibicc-1.0.23.1/issues/issue112.c000077500000000000000000000003741505335450300163650ustar00rootroot00000000000000#include "vlc_common.h" #include static VLC_UNUSED_FUNC VLC_WARN_CALL("thread name too big") const char * vlc_thread_name_too_big( const char * thread_name ) { return thread_name; } int main(void) { printf("ok\n"); return 0; } chibicc-1.0.23.1/issues/issue112b.c000077500000000000000000000002121505335450300165160ustar00rootroot00000000000000#include "vlc_common.h" #include "vlc_tick.h" VLC_USED VLC_MALLOC int myfunc2(int x) { return x; } int main(void) { return 0; }chibicc-1.0.23.1/issues/issue114.c000077500000000000000000001052271505335450300163720ustar00rootroot00000000000000/***************************************************************************** * vlc_common.h: common definitions * Collection of useful common types and macros definitions ***************************************************************************** * Copyright (C) 1998-2011 VLC authors and VideoLAN * * Authors: Samuel Hocevar * Vincent Seguin * Gildas Bazin * Rémi Denis-Courmont * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ // # define VLC_MALLOC // # define VLC_USED // # define VLC_EXTERN // # define VLC_API // # define VLC_DEPRECATED #ifndef VLC_COMMON_H # define VLC_COMMON_H 1 // # define VLC_USED // # define VLC_MALLOC // # define VLC_DEPRECATED // # define VLC_NOINLINE_FUNC // # define VLC_UNUSED_FUNC /** * \defgroup vlc VLC plug-in programming interface * \file * \ingroup vlc * This file is a collection of common definitions and types */ /***************************************************************************** * Required vlc headers *****************************************************************************/ //#include "vlc_config.h" /***************************************************************************** * Required system headers *****************************************************************************/ #include #include #include #include #include #include #include #ifndef __cplusplus # include #endif /** * \defgroup cext C programming language extensions * \ingroup vlc * * This section defines a number of macros and inline functions extending the * C language. Most extensions are implemented by GCC and LLVM/Clang, and have * unoptimized fallbacks for other C11/C++11 conforming compilers. * @{ */ #ifdef __GNUC__ # define VLC_GCC_VERSION(maj,min) \ ((__GNUC__ > (maj)) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min))) #else /** GCC version check */ # define VLC_GCC_VERSION(maj,min) (0) #endif /* Try to fix format strings for all versions of mingw and mingw64 */ #if defined( _WIN32 ) && defined( __USE_MINGW_ANSI_STDIO ) #undef PRId64 #define PRId64 "lld" #undef PRIi64 #define PRIi64 "lli" #undef PRIu64 #define PRIu64 "llu" #undef PRIo64 #define PRIo64 "llo" #undef PRIx64 #define PRIx64 "llx" #define snprintf __mingw_snprintf #define vsnprintf __mingw_vsnprintf #define swprintf _snwprintf #endif /* Function attributes for compiler warnings */ #if defined __has_attribute # if __has_attribute(warning) # define VLC_WARN_CALL(w) VLC_NOINLINE_FUNC __attribute__((warning((w)))) # else # define VLC_WARN_CALL(w) # endif # if __has_attribute(error) # define VLC_ERROR_CALL(e) VLC_NOINLINE_FUNC __attribute__((error((e)))) # else # define VLC_ERROR_CALL(e) # endif # if __has_attribute(unused) # define VLC_UNUSED_FUNC __attribute__((unused)) # else # define VLC_UNUSED_FUNC # endif # if __has_attribute(noinline) # define VLC_NOINLINE_FUNC __attribute__((noinline)) # else # define VLC_NOINLINE_FUNC # endif # if __has_attribute(deprecated) # define VLC_DEPRECATED __attribute__((deprecated)) # else /** * Deprecated functions or compound members annotation * * Use this macro in front of a function declaration or compound member * within a compound type declaration. * The compiler may emit a warning every time the function or member is used. * * Use \ref VLC_DEPRECATED_ENUM instead for enumeration members. */ # define VLC_DEPRECATED # endif # if __has_attribute(malloc) # define VLC_MALLOC __attribute__((malloc)) # else /** * Heap allocated result function annotation * * Use this macro to annotate a function that returns a pointer to memory that * cannot alias any other valid pointer. * * This is primarily used for functions that return a pointer to heap-allocated * memory, but it can be used for other applicable purposes. * * \warning Do not use this annotation if the returned pointer can in any way * alias a valid pointer at the time the function exits. This could lead to * very weird memory corruption bugs. */ # define VLC_MALLOC # endif # if __has_attribute(warn_unused_result) # define VLC_USED __attribute__((warn_unused_result)) # else /** * Used result function annotation * * Use this macro to annotate a function whose result must be used. * * There are several cases where this is useful: * - If a function has no side effects (or no useful side effects), such that * the only useful purpose of calling said function is to obtain its * return value. * - If ignoring the function return value would lead to a resource leak * (including but not limited to a memory leak). * - If a function cannot be used correctly without checking its return value. * For instance, if the function can fail at any time. * * The compiler may warn if the return value of a function call is ignored. */ # define VLC_USED # endif #endif #ifdef __GNUC__ # if VLC_GCC_VERSION(6,0) # define VLC_DEPRECATED_ENUM __attribute__((deprecated)) # else # define VLC_DEPRECATED_ENUM # endif # if defined( _WIN32 ) && !defined( __clang__ ) # define VLC_FORMAT(x,y) __attribute__ ((format(gnu_printf,x,y))) # else # define VLC_FORMAT(x,y) __attribute__ ((format(printf,x,y))) # endif # define VLC_FORMAT_ARG(x) __attribute__ ((format_arg(x))) #else /** * Deprecated enum member annotation * * Use this macro after an enumerated type member declaration. * The compiler may emit a warning every time the enumeration member is used. * * See also \ref VLC_DEPRECATED. */ # define VLC_DEPRECATED_ENUM /** * String format function annotation * * Use this macro after a function prototype/declaration if the function * expects a standard C format string. This helps compiler diagnostics. * * @param x the position (starting from 1) of the format string argument * @param y the first position (also starting from 1) of the variable arguments * following the format string (usually but not always \p x+1). */ # define VLC_FORMAT(x,y) /** * Format string translation function annotation * * Use this macro after a function prototype/declaration if the function * expects a format string as input and returns another format string as output * to another function. * * This is primarily intended for localization functions such as gettext(). */ # define VLC_FORMAT_ARG(x) #endif #if defined (__ELF__) || defined (__MACH__) || defined (__wasm__) # define VLC_WEAK __attribute__((weak)) #else /** * Weak symbol annotation * * Use this macro before an external identifier \b definition to mark it as a * weak symbol. A weak symbol can be overridden by another symbol of the same * name at the link time. */ # define VLC_WEAK #endif /* Branch prediction */ #if defined (__GNUC__) || defined (__clang__) # define likely(p) __builtin_expect(!!(p), 1) # define unlikely(p) __builtin_expect(!!(p), 0) # define unreachable() __builtin_unreachable() #elif defined(_MSC_VER) # define likely(p) (!!(p)) # define unlikely(p) (!!(p)) # define unreachable() (__assume(0)) #else /** * Predicted true condition * * This macro indicates that the condition is expected most often true. * The compiler may optimize the code assuming that this condition is usually * met. */ # define likely(p) (!!(p)) /** * Predicted false condition * * This macro indicates that the condition is expected most often false. * The compiler may optimize the code assuming that this condition is rarely * met. */ # define unlikely(p) (!!(p)) /** * Impossible branch * * This macro indicates that the branch cannot be reached at run-time, and * represents undefined behaviour. * The compiler may optimize the code assuming that the call flow will never * logically reach the point where this macro is expanded. * * See also \ref vlc_assert_unreachable. */ # define unreachable() ((void)0) #endif /** * Impossible branch assertion * * This macro asserts that the branch cannot be reached at run-time. * * If the branch is reached in a debug build, it will trigger an assertion * failure and abnormal program termination. * * If the branch is reached in a non-debug build, this macro is equivalent to * \ref unreachable and the behaviour is undefined. */ #define vlc_assert_unreachable() (vlc_assert(!"unreachable"), unreachable()) /** * Run-time assertion * * This macro performs a run-time assertion if C assertions are enabled * and the following preprocessor symbol is defined: * @verbatim __LIBVLC__ @endverbatim * That restriction ensures that assertions in public header files are not * unwittingly leaked to externally-compiled plug-ins * including those header files. * * Within the LibVLC code base, this is exactly the same as assert(), which can * and probably should be used directly instead. */ #ifdef __LIBVLC__ # define vlc_assert(pred) assert(pred) #else # define vlc_assert(pred) ((void)0) #endif /* Linkage */ #ifdef __cplusplus # define VLC_EXTERN extern "C" #else # define VLC_EXTERN #endif #if defined (_WIN32) && defined (DLL_EXPORT) # define VLC_EXPORT __declspec(dllexport) #elif defined (__GNUC__) # define VLC_EXPORT __attribute__((visibility("default"))) #else # define VLC_EXPORT #endif /** * Exported API call annotation * * This macro is placed before a function declaration to indicate that the * function is an API call of the LibVLC plugin API. */ #define VLC_API VLC_EXTERN VLC_EXPORT /** @} */ /***************************************************************************** * Basic types definitions *****************************************************************************/ /** * The vlc_fourcc_t type. * * See http://www.webartz.com/fourcc/ for a very detailed list. */ typedef uint32_t vlc_fourcc_t; #ifdef WORDS_BIGENDIAN # define VLC_FOURCC( a, b, c, d ) \ ( ((uint32_t)d) | ( ((uint32_t)c) << 8 ) \ | ( ((uint32_t)b) << 16 ) | ( ((uint32_t)a) << 24 ) ) # define VLC_TWOCC( a, b ) \ ( (uint16_t)(b) | ( (uint16_t)(a) << 8 ) ) #else # define VLC_FOURCC( a, b, c, d ) \ ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \ | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) ) # define VLC_TWOCC( a, b ) \ ( (uint16_t)(a) | ( (uint16_t)(b) << 8 ) ) #endif /** * Translate a vlc_fourcc into its string representation. This function * assumes there is enough room in psz_fourcc to store 4 characters in. * * \param fcc a vlc_fourcc_t * \param psz_fourcc string to store string representation of vlc_fourcc in */ static inline void vlc_fourcc_to_char( vlc_fourcc_t fcc, char *psz_fourcc ) { memcpy( psz_fourcc, &fcc, 4 ); } /***************************************************************************** * Classes declaration *****************************************************************************/ /* Internal types */ typedef struct vlc_object_t vlc_object_t; typedef struct libvlc_int_t libvlc_int_t; typedef struct date_t date_t; /* Playlist */ typedef struct services_discovery_t services_discovery_t; typedef struct vlc_renderer_discovery_t vlc_renderer_discovery_t; typedef struct vlc_renderer_item_t vlc_renderer_item_t; /* Modules */ typedef struct module_t module_t; typedef struct module_config_t module_config_t; typedef struct config_category_t config_category_t; /* Input */ typedef struct input_item_t input_item_t; typedef struct input_item_node_t input_item_node_t; typedef struct input_source_t input_source_t; typedef struct stream_t stream_t; typedef struct stream_t demux_t; typedef struct es_out_t es_out_t; typedef struct es_out_id_t es_out_id_t; typedef struct seekpoint_t seekpoint_t; typedef struct info_t info_t; typedef struct info_category_t info_category_t; typedef struct input_attachment_t input_attachment_t; /* Format */ typedef struct audio_format_t audio_format_t; typedef struct video_format_t video_format_t; typedef struct subs_format_t subs_format_t; typedef struct es_format_t es_format_t; typedef struct video_palette_t video_palette_t; typedef struct vlc_es_id_t vlc_es_id_t; /* Audio */ typedef struct audio_output audio_output_t; typedef audio_format_t audio_sample_format_t; /* Video */ typedef struct vout_thread_t vout_thread_t; typedef struct vlc_viewpoint_t vlc_viewpoint_t; typedef video_format_t video_frame_format_t; typedef struct picture_t picture_t; /* Subpictures */ typedef struct spu_t spu_t; typedef struct subpicture_t subpicture_t; typedef struct subpicture_region_t subpicture_region_t; typedef struct image_handler_t image_handler_t; /* Stream output */ typedef struct sout_input_t sout_input_t; typedef struct sout_packetizer_input_t sout_packetizer_input_t; typedef struct sout_access_out_t sout_access_out_t; typedef struct sout_mux_t sout_mux_t; typedef struct sout_stream_t sout_stream_t; typedef struct config_chain_t config_chain_t; typedef struct session_descriptor_t session_descriptor_t; /* Decoders */ typedef struct decoder_t decoder_t; /* Encoders */ typedef struct encoder_t encoder_t; /* Filters */ typedef struct filter_t filter_t; /* Network */ typedef struct vlc_url_t vlc_url_t; /* Misc */ typedef struct iso639_lang_t iso639_lang_t; /* block */ typedef struct vlc_frame_t block_t; typedef struct vlc_fifo_t vlc_fifo_t; typedef struct vlc_fifo_t block_fifo_t; /* Hashing */ typedef struct vlc_hash_md5_ctx vlc_hash_md5_t; /* XML */ typedef struct xml_t xml_t; typedef struct xml_reader_t xml_reader_t; /* vod server */ typedef struct vod_t vod_t; typedef struct vod_media_t vod_media_t; /* VLM */ typedef struct vlm_t vlm_t; typedef struct vlm_message_t vlm_message_t; /* misc */ typedef struct vlc_meta_t vlc_meta_t; typedef struct input_stats_t input_stats_t; typedef struct addon_entry_t addon_entry_t; /* Update */ typedef struct update_t update_t; /** * VLC value structure */ typedef union { int64_t i_int; bool b_bool; float f_float; char * psz_string; void * p_address; struct { int32_t x; int32_t y; } coords; } vlc_value_t; /** * \defgroup errors Error codes * \ingroup cext * @{ */ /** No error */ #define VLC_SUCCESS 0 /** Unspecified error */ #define VLC_EGENERIC (-2 * (1 << (sizeof (int) * 8 - 2))) /* INT_MIN */ /** Not enough memory */ #define VLC_ENOMEM (-ENOMEM) /** Timeout */ #define VLC_ETIMEOUT (-ETIMEDOUT) /** Not found */ #define VLC_ENOENT (-ENOENT) /** Bad variable value */ #define VLC_EINVAL (-EINVAL) /** Operation forbidden */ #define VLC_EACCES (-EACCES) /** Operation not supported */ #define VLC_ENOTSUP (-ENOTSUP) /** @} */ /***************************************************************************** * Variable callbacks: called when the value is modified *****************************************************************************/ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */ char const *, /* variable name */ vlc_value_t, /* old value */ vlc_value_t, /* new value */ void * ); /* callback data */ /***************************************************************************** * List callbacks: called when elements are added/removed from the list *****************************************************************************/ typedef int ( * vlc_list_callback_t ) ( vlc_object_t *, /* variable's object */ char const *, /* variable name */ int, /* VLC_VAR_* action */ vlc_value_t *, /* new/deleted value */ void *); /* callback data */ /***************************************************************************** * OS-specific headers and thread types *****************************************************************************/ #if defined( _WIN32 ) # include # ifndef PATH_MAX # define PATH_MAX MAX_PATH # endif # include #endif #ifdef __APPLE__ #include #include #endif #ifdef __OS2__ # define OS2EMX_PLAIN_CHAR # define INCL_BASE # define INCL_PM # include # include #endif // #include "vlc_tick.h" // #include "vlc_threads.h" /** * \defgroup intops Integer operations * \ingroup cext * * Common integer functions. * @{ */ /* __MAX and __MIN: self explanatory */ #ifndef __MAX # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) ) #endif #ifndef __MIN # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) #endif /* clip v in [min, max] */ #define VLC_CLIP(v, min, max) __MIN(__MAX((v), (min)), (max)) /** * Make integer v a multiple of align * * \note align must be a power of 2 */ VLC_USED static inline size_t vlc_align(size_t v, size_t align) { return (v + (align - 1)) & ~(align - 1); } #if defined(__clang__) && __has_attribute(diagnose_if) static inline size_t vlc_align(size_t v, size_t align) __attribute__((diagnose_if(((align & (align - 1)) || (align == 0)), "align must be power of 2", "error"))); #endif /** Greatest common divisor */ VLC_USED static inline int64_t GCD ( int64_t a, int64_t b ) { while( b ) { int64_t c = a % b; a = b; b = c; } return a; } /* function imported from libavutil/common.h */ VLC_USED static inline uint8_t clip_uint8_vlc( int32_t a ) { if( a&(~255) ) return (-a)>>31; else return a; } /** * \defgroup bitops Bit operations * @{ */ #define VLC_INT_FUNC(basename) \ VLC_INT_FUNC_TYPE(basename, unsigned, ) \ VLC_INT_FUNC_TYPE(basename, unsigned long, l) \ VLC_INT_FUNC_TYPE(basename, unsigned long long, ll) #if defined (__GNUC__) || defined (__clang__) # define VLC_INT_FUNC_TYPE(basename,type,suffix) \ VLC_USED static inline int vlc_##basename##suffix(type x) \ { \ return __builtin_##basename##suffix(x); \ } VLC_INT_FUNC(clz) #else VLC_USED static inline int vlc_clzll(unsigned long long x) { int i = sizeof (x) * 8; while (x) { x >>= 1; i--; } return i; } VLC_USED static inline int vlc_clzl(unsigned long x) { return vlc_clzll(x) - ((sizeof (long long) - sizeof (long)) * 8); } VLC_USED static inline int vlc_clz(unsigned x) { return vlc_clzll(x) - ((sizeof (long long) - sizeof (int)) * 8); } VLC_USED static inline int vlc_ctz_generic(unsigned long long x) { unsigned i = sizeof (x) * 8; while (x) { x <<= 1; i--; } return i; } VLC_USED static inline int vlc_parity_generic(unsigned long long x) { for (unsigned i = 4 * sizeof (x); i > 0; i /= 2) x ^= x >> i; return x & 1; } VLC_USED static inline int vlc_popcount_generic(unsigned long long x) { int count = 0; while (x) { count += x & 1; x = x >> 1; } return count; } # define VLC_INT_FUNC_TYPE(basename,type,suffix) \ VLC_USED static inline int vlc_##basename##suffix(type x) \ { \ return vlc_##basename##_generic(x); \ } #endif VLC_INT_FUNC(ctz) VLC_INT_FUNC(parity) VLC_INT_FUNC(popcount) #ifndef __cplusplus # define VLC_INT_GENERIC(func,x) \ _Generic((x), \ unsigned char: func(x), \ signed char: func(x), \ unsigned short: func(x), \ signed short: func(x), \ unsigned int: func(x), \ signed int: func(x), \ unsigned long: func##l(x), \ signed long: func##l(x), \ unsigned long long: func##ll(x), \ signed long long: func##ll(x)) /** * Count leading zeroes * * This function counts the number of consecutive zero (clear) bits * down from the highest order bit in an unsigned integer. * * \param x a non-zero integer * \note This macro assumes that CHAR_BIT equals 8. * \warning By definition, the result depends on the (width of the) type of x. * \return The number of leading zero bits in x. */ # define clz(x) \ _Generic((x), \ unsigned char: (vlc_clz(x) - (sizeof (unsigned) - 1) * 8), \ unsigned short: (vlc_clz(x) \ - (sizeof (unsigned) - sizeof (unsigned short)) * 8), \ unsigned: vlc_clz(x), \ unsigned long: vlc_clzl(x), \ unsigned long long: vlc_clzll(x)) /** * Count trailing zeroes * * This function counts the number of consecutive zero bits * up from the lowest order bit in an unsigned integer. * * \param x a non-zero integer * \note This function assumes that CHAR_BIT equals 8. * \return The number of trailing zero bits in x. */ # define ctz(x) VLC_INT_GENERIC(vlc_ctz, x) /** * Parity * * This function determines the parity of an integer. * \retval 0 if x has an even number of set bits. * \retval 1 if x has an odd number of set bits. */ # define parity(x) VLC_INT_GENERIC(vlc_parity, x) /** * Bit weight / population count * * This function counts the number of non-zero bits in an integer. * * \return The count of non-zero bits. */ # define vlc_popcount(x) \ _Generic((x), \ signed char: vlc_popcount((unsigned char)(x)), \ signed short: vlc_popcount((unsigned short)(x)), \ default: VLC_INT_GENERIC(vlc_popcount ,x)) #else VLC_USED static inline int vlc_popcount(unsigned char x) { return vlc_popcount((unsigned)x); } VLC_USED static inline int vlc_popcount(unsigned short x) { return vlc_popcount((unsigned)x); } VLC_USED static inline int vlc_popcount(unsigned long x) { return vlc_popcountl(x); } VLC_USED static inline int vlc_popcount(unsigned long long x) { return vlc_popcountll(x); } #endif /** Byte swap (16 bits) */ VLC_USED static inline uint16_t vlc_bswap16(uint16_t x) { return (x << 8) | (x >> 8); } /** Byte swap (32 bits) */ VLC_USED static inline uint32_t vlc_bswap32(uint32_t x) { #if defined (__GNUC__) || defined(__clang__) return __builtin_bswap32 (x); #else return ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24); #endif } /** Byte swap (64 bits) */ VLC_USED static inline uint64_t vlc_bswap64(uint64_t x) { #if defined (__GNUC__) || defined(__clang__) return __builtin_bswap64 (x); #elif !defined (__cplusplus) return ((x & 0x00000000000000FF) << 56) | ((x & 0x000000000000FF00) << 40) | ((x & 0x0000000000FF0000) << 24) | ((x & 0x00000000FF000000) << 8) | ((x & 0x000000FF00000000) >> 8) | ((x & 0x0000FF0000000000) >> 24) | ((x & 0x00FF000000000000) >> 40) | ((x & 0xFF00000000000000) >> 56); #else return ((x & 0x00000000000000FFULL) << 56) | ((x & 0x000000000000FF00ULL) << 40) | ((x & 0x0000000000FF0000ULL) << 24) | ((x & 0x00000000FF000000ULL) << 8) | ((x & 0x000000FF00000000ULL) >> 8) | ((x & 0x0000FF0000000000ULL) >> 24) | ((x & 0x00FF000000000000ULL) >> 40) | ((x & 0xFF00000000000000ULL) >> 56); #endif } /** @} */ /** * \defgroup overflow Overflowing arithmetic * @{ */ static inline bool uadd_overflow(unsigned a, unsigned b, unsigned *res) { #if VLC_GCC_VERSION(5,0) || defined(__clang__) return __builtin_uadd_overflow(a, b, res); #else *res = a + b; return (a + b) < a; #endif } static inline bool uaddl_overflow(unsigned long a, unsigned long b, unsigned long *res) { #if VLC_GCC_VERSION(5,0) || defined(__clang__) return __builtin_uaddl_overflow(a, b, res); #else *res = a + b; return (a + b) < a; #endif } static inline bool uaddll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { #if VLC_GCC_VERSION(5,0) || defined(__clang__) return __builtin_uaddll_overflow(a, b, res); #else *res = a + b; return (a + b) < a; #endif } #ifndef __cplusplus /** * Overflowing addition * * Converts \p a and \p b to the type of \p *r. * Then computes the sum of both conversions while checking for overflow. * Finally stores the result in \p *r. * * \param a an integer * \param b an integer * \param r a pointer to an integer [OUT] * \retval false The sum did not overflow. * \retval true The sum overflowed. */ # define add_overflow(a,b,r) \ _Generic(*(r), \ unsigned: uadd_overflow(a, b, (unsigned *)(r)), \ unsigned long: uaddl_overflow(a, b, (unsigned long *)(r)), \ unsigned long long: uaddll_overflow(a, b, (unsigned long long *)(r))) #else static inline bool add_overflow(unsigned a, unsigned b, unsigned *res) { return uadd_overflow(a, b, res); } static inline bool add_overflow(unsigned long a, unsigned long b, unsigned long *res) { return uaddl_overflow(a, b, res); } static inline bool add_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { return uaddll_overflow(a, b, res); } #endif #if !(VLC_GCC_VERSION(5,0) || defined(__clang__)) # include #endif static inline bool umul_overflow(unsigned a, unsigned b, unsigned *res) { #if VLC_GCC_VERSION(5,0) || defined(__clang__) return __builtin_umul_overflow(a, b, res); #else *res = a * b; return b > 0 && a > (UINT_MAX / b); #endif } static inline bool umull_overflow(unsigned long a, unsigned long b, unsigned long *res) { #if VLC_GCC_VERSION(5,0) || defined(__clang__) return __builtin_umull_overflow(a, b, res); #else *res = a * b; return b > 0 && a > (ULONG_MAX / b); #endif } static inline bool umulll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { #if VLC_GCC_VERSION(5,0) || defined(__clang__) return __builtin_umulll_overflow(a, b, res); #else *res = a * b; return b > 0 && a > (ULLONG_MAX / b); #endif } #ifndef __cplusplus /** * Overflowing multiplication * * Converts \p a and \p b to the type of \p *r. * Then computes the product of both conversions while checking for overflow. * Finally stores the result in \p *r. * * \param a an integer * \param b an integer * \param r a pointer to an integer [OUT] * \retval false The product did not overflow. * \retval true The product overflowed. */ #define mul_overflow(a,b,r) \ _Generic(*(r), \ unsigned: umul_overflow(a, b, (unsigned *)(r)), \ unsigned long: umull_overflow(a, b, (unsigned long *)(r)), \ unsigned long long: umulll_overflow(a, b, (unsigned long long *)(r))) #else static inline bool mul_overflow(unsigned a, unsigned b, unsigned *res) { return umul_overflow(a, b, res); } static inline bool mul_overflow(unsigned long a, unsigned long b, unsigned long *res) { return umull_overflow(a, b, res); } static inline bool mul_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { return umulll_overflow(a, b, res); } #endif /** @} */ /** @} */ /* Free and set set the variable to NULL */ #define FREENULL(a) do { free( a ); a = NULL; } while(0) #define EMPTY_STR(str) (!str || !*str) // #include /* MSB (big endian)/LSB (little endian) conversions - network order is always * MSB, and should be used for both network communications and files. */ #ifdef WORDS_BIGENDIAN # define hton16(i) ((uint16_t)(i)) # define hton32(i) ((uint32_t)(i)) # define hton64(i) ((uint64_t)(i)) #else # define hton16(i) vlc_bswap16(i) # define hton32(i) vlc_bswap32(i) # define hton64(i) vlc_bswap64(i) #endif #define ntoh16(i) hton16(i) #define ntoh32(i) hton32(i) #define ntoh64(i) hton64(i) /** Reads 16 bits in network byte order */ VLC_USED static inline uint16_t U16_AT (const void *p) { uint16_t x; memcpy (&x, p, sizeof (x)); return ntoh16 (x); } /** Reads 32 bits in network byte order */ VLC_USED static inline uint32_t U32_AT (const void *p) { uint32_t x; memcpy (&x, p, sizeof (x)); return ntoh32 (x); } /** Reads 64 bits in network byte order */ VLC_USED static inline uint64_t U64_AT (const void *p) { uint64_t x; memcpy (&x, p, sizeof (x)); return ntoh64 (x); } #define GetWBE(p) U16_AT(p) #define GetDWBE(p) U32_AT(p) #define GetQWBE(p) U64_AT(p) /** Reads 16 bits in little-endian order */ VLC_USED static inline uint16_t GetWLE (const void *p) { uint16_t x; memcpy (&x, p, sizeof (x)); #ifdef WORDS_BIGENDIAN x = vlc_bswap16 (x); #endif return x; } /** Reads 32 bits in little-endian order */ VLC_USED static inline uint32_t GetDWLE (const void *p) { uint32_t x; memcpy (&x, p, sizeof (x)); #ifdef WORDS_BIGENDIAN x = vlc_bswap32 (x); #endif return x; } /** Reads 64 bits in little-endian order */ VLC_USED static inline uint64_t GetQWLE (const void *p) { uint64_t x; memcpy (&x, p, sizeof (x)); #ifdef WORDS_BIGENDIAN x = vlc_bswap64 (x); #endif return x; } /** Writes 16 bits in network byte order */ static inline void SetWBE (void *p, uint16_t w) { w = hton16 (w); memcpy (p, &w, sizeof (w)); } /** Writes 32 bits in network byte order */ static inline void SetDWBE (void *p, uint32_t dw) { dw = hton32 (dw); memcpy (p, &dw, sizeof (dw)); } /** Writes 64 bits in network byte order */ static inline void SetQWBE (void *p, uint64_t qw) { qw = hton64 (qw); memcpy (p, &qw, sizeof (qw)); } /** Writes 16 bits in little endian order */ static inline void SetWLE (void *p, uint16_t w) { #ifdef WORDS_BIGENDIAN w = vlc_bswap16 (w); #endif memcpy (p, &w, sizeof (w)); } /** Writes 32 bits in little endian order */ static inline void SetDWLE (void *p, uint32_t dw) { #ifdef WORDS_BIGENDIAN dw = vlc_bswap32 (dw); #endif memcpy (p, &dw, sizeof (dw)); } /** Writes 64 bits in little endian order */ static inline void SetQWLE (void *p, uint64_t qw) { #ifdef WORDS_BIGENDIAN qw = vlc_bswap64 (qw); #endif memcpy (p, &qw, sizeof (qw)); } /* */ #define VLC_UNUSED(x) (void)(x) /* Stuff defined in src/extras/libc.c */ #if defined(_WIN32) /* several type definitions */ # if defined( __MINGW32__ ) # if !defined( _OFF_T_ ) typedef long long _off_t; typedef _off_t off_t; # define _OFF_T_ # else # ifdef off_t # undef off_t # endif # define off_t long long # endif # endif # ifndef O_NONBLOCK # define O_NONBLOCK 0 # endif /* the mingw32 swab() and win32 _swab() prototypes expect a char* instead of a const void* */ # define swab(a,b,c) swab((char*) (a), (char*) (b), (c)) #endif /* _WIN32 */ typedef struct { unsigned num, den; } vlc_rational_t; VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t ); #define container_of(ptr, type, member) \ ((type *)(((char *)(ptr)) - offsetof(type, member))) VLC_USED VLC_MALLOC static inline void *vlc_alloc(size_t count, size_t size) { return mul_overflow(count, size, &size) ? NULL : malloc(size); } VLC_USED static inline void *vlc_reallocarray(void *ptr, size_t count, size_t size) { return mul_overflow(count, size, &size) ? NULL : realloc(ptr, size); } /***************************************************************************** * I18n stuff *****************************************************************************/ VLC_API const char *vlc_gettext(const char *msgid) VLC_FORMAT_ARG(1); VLC_API const char *vlc_ngettext(const char *s, const char *p, unsigned long n) VLC_FORMAT_ARG(1) VLC_FORMAT_ARG(2); #define vlc_pgettext( ctx, id ) \ vlc_pgettext_aux( ctx "\004" id, id ) VLC_FORMAT_ARG(2) static inline const char *vlc_pgettext_aux( const char *ctx, const char *id ) { const char *tr = vlc_gettext( ctx ); return (tr == ctx) ? id : tr; } /***************************************************************************** * Loosy memory allocation functions. Do not use in new code. *****************************************************************************/ static inline void *xmalloc(size_t len) { void *ptr = malloc(len); if (unlikely(ptr == NULL && len > 0)) abort(); return ptr; } static inline void *xrealloc(void *ptr, size_t len) { void *nptr = realloc(ptr, len); if (unlikely(nptr == NULL && len > 0)) abort(); return nptr; } static inline char *xstrdup (const char *str) { char *ptr = strdup (str); if (unlikely(ptr == NULL)) abort (); return ptr; } /***************************************************************************** * libvlc features *****************************************************************************/ VLC_API const char * VLC_CompileBy( void ) VLC_USED; VLC_API const char * VLC_CompileHost( void ) VLC_USED; VLC_API const char * VLC_Compiler( void ) VLC_USED; /***************************************************************************** * Additional vlc stuff *****************************************************************************/ // #include "vlc_messages.h" // #include "vlc_objects.h" // #include "vlc_variables.h" // #include "vlc_configuration.h" #if defined( _WIN32 ) || defined( __OS2__ ) # define DIR_SEP_CHAR '\\' # define DIR_SEP "\\" # define PATH_SEP_CHAR ';' # define PATH_SEP ";" #else # define DIR_SEP_CHAR '/' # define DIR_SEP "/" # define PATH_SEP_CHAR ':' # define PATH_SEP ":" #endif #define LICENSE_MSG \ _("This program comes with NO WARRANTY, to the extent permitted by " \ "law.\nYou may redistribute it under the terms of the GNU General " \ "Public License;\nsee the file named COPYING for details.\n" \ "Written by the VideoLAN team; see the AUTHORS file.\n") #if defined(__cplusplus) || defined(_MSC_VER) #define ARRAY_STATIC_SIZE #else #define ARRAY_STATIC_SIZE static #endif #endif /* !VLC_COMMON_H */ # define VLC_OBJECT(x) \ _Generic((x)->obj, \ struct vlc_object_marker *: (x), \ default: (&((x)->obj)) \ ) int myfuncl(unsigned int x) { return x; } int myfuncll(unsigned int x) { return x; } int myfunc(unsigned int x) { return x; } int main(void) { int x = 10; VLC_INT_GENERIC(myfunc,x); return 0; }chibicc-1.0.23.1/issues/issue126.c000066400000000000000000000012341505335450300163630ustar00rootroot00000000000000#include size_t strlcpy(dst, src, siz) char *dst; const char *src; size_t siz; { register char *d = dst; register const char *s = src; register size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return (s - src - 1); /* count does not include NUL */ } int main(void) { return 0; }chibicc-1.0.23.1/issues/issue137.c000066400000000000000000000006641505335450300163730ustar00rootroot00000000000000#include #include static const char hello[] = "hello, hello!"; void test_compress(compr, comprLen, uncompr, uncomprLen) char *compr, *uncompr; long comprLen, uncomprLen; { int err; long len = (long)strlen(hello) + 1; //strncpy(uncompr, "garbage", 8); printf("uncompress(): %s\n", (char *)uncompr); } int main(int argc, char **argv) { test_compress(&hello, 14, &hello, 14); return 0; } chibicc-1.0.23.1/issues/issue146.c000066400000000000000000000001561505335450300163670ustar00rootroot00000000000000#include int main (void) { if (sizeof (union semun)) return 0; ; return 0; } chibicc-1.0.23.1/issues/issue152.c000066400000000000000000000020411505335450300163570ustar00rootroot00000000000000#include "vlc_common.h" /** Player capability: can seek */ #define VLC_PLAYER_CAP_SEEK (1<<0) VLC_API int vlc_player_GetCapabilities(char *player); /** * Helper to get the seek capability */ static inline bool vlc_player_CanSeek(char *player) { return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_SEEK; } #ifndef __cplusplus #define vlc_hash_FinishHex(ctx, output) \ do { \ char out_tmp[_Generic((ctx), \ vlc_hash_md5_t *: VLC_HASH_MD5_DIGEST_SIZE)]; \ _Generic((ctx), \ vlc_hash_md5_t *: vlc_hash_md5_Finish) \ (ctx, out_tmp, sizeof(out_tmp)); \ vlc_hex_encode_binary(out_tmp, sizeof(out_tmp), output); \ } while (0) #endif VLC_API void vlc_hash_md5_Finish(vlc_hash_md5_t *ctx, void *output, size_t size); int main() { vlc_hash_md5_t md5; return 0; }chibicc-1.0.23.1/issues/issue153.c000066400000000000000000000007421505335450300163660ustar00rootroot00000000000000#include #include #include #include typedef __UINTPTR_TYPE__ omp_uintptr_t; int main(int argc, char **argv) { int num_threads,tid; #pragma omp parallel //parallel execution begin { tid = omp_get_thread_num(); printf("Thread id: %d\n", tid); if (tid == 0) { num_threads = omp_get_num_threads(); printf("Number of threads: %d\n", num_threads); } } return 0; }chibicc-1.0.23.1/issues/issue170.c000066400000000000000000000006571505335450300163720ustar00rootroot00000000000000 #include #include #include #include struct named_init_test { int a; int b; }; extern void structfunc(struct named_init_test); int main(int argc, char **argv) { struct named_init_test nit = { .a = 3, .b = 5, }; for (int loop_var = 0; loop_var < 3; loop_var++) { nit.a += nit.b; } structfunc((struct named_init_test){1, 0}); return nit.a != 0; } chibicc-1.0.23.1/issues/issue188.c000066400000000000000000000015211505335450300163720ustar00rootroot00000000000000#include #include typedef struct internal_state { int x; int y; int w_size; int hash_size; char *head[10]; char *prev[10]; } FAR deflate_state; void slide_hash(s) deflate_state *s; { unsigned n, m; char *p; uint64_t wsize = s->w_size; n = s->hash_size; p = &s->head[n]; do { m = *--p; *p = (char *)(m >= wsize ? m - wsize : NULL); } while (--n); n = wsize; #ifndef FASTEST p = &s->prev[n]; do { m = *--p; *p = (char *)(m >= wsize ? m - wsize : NULL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } while (--n); #endif } int main() { deflate_state s; s.x = 42; s.y = 17; printf("s.x = %d, s.y = %d\n", s.x, s.y); return 0; } chibicc-1.0.23.1/issues/issue28.c000077500000000000000000000001071505335450300163050ustar00rootroot00000000000000struct a { int; double d:10; }A; int main() { return 0; }chibicc-1.0.23.1/issues/issue35.c000077500000000000000000000007341505335450300163110ustar00rootroot00000000000000#include #include "test.h" #define SIZE 10 int myarr[SIZE]; int myarr[] = {11, 34, }; int main(void) { for(int i = 0; i < SIZE; i++) { printf("%d: %d\n", i, myarr[i]); } ASSERT(11, myarr[0]); ASSERT(34, myarr[1]); ASSERT(0, myarr[2]); ASSERT(0, myarr[3]); ASSERT(0, myarr[4]); ASSERT(0, myarr[5]); ASSERT(0, myarr[6]); ASSERT(0, myarr[7]); ASSERT(0, myarr[8]); ASSERT(0, myarr[9]); return 0; }chibicc-1.0.23.1/issues/issue40a.c000077500000000000000000000001671505335450300164460ustar00rootroot00000000000000// fails silently (pointer to VLA) int x = 10; void fun(char (*a)[x]) { sizeof *a; } int main(void) { return 0; }chibicc-1.0.23.1/issues/issue41a.c000077500000000000000000000000611505335450300164400ustar00rootroot00000000000000void foo() { } void bar() { int x = foo(); } chibicc-1.0.23.1/issues/issue41b.c000077500000000000000000000000271505335450300164430ustar00rootroot00000000000000int bar() { return; }chibicc-1.0.23.1/issues/issue41c.c000077500000000000000000000000541505335450300164440ustar00rootroot00000000000000void foo() {} int bar() { return foo(); }chibicc-1.0.23.1/issues/issue41d.c000077500000000000000000000000321505335450300164410ustar00rootroot00000000000000void foo() { return 1; }chibicc-1.0.23.1/issues/issue42.c000077500000000000000000000001251505335450300163010ustar00rootroot00000000000000#include int main() { return;} void foo() { } void bar() { 1 + foo(); }chibicc-1.0.23.1/issues/issue72.c000077500000000000000000000000621505335450300163040ustar00rootroot00000000000000long f1[] = "a"; int main(void) { return 0; }chibicc-1.0.23.1/issues/issue94.c000066400000000000000000000000741505335450300163100ustar00rootroot00000000000000#if !1u - 1 > 0 #error #endif int main() { return 0; }chibicc-1.0.23.1/issues/issue_cast.c000066400000000000000000000006131505335450300171440ustar00rootroot00000000000000#include "test.h" int test_return_cast(void) { return (int){42}; } float test_return_cast_float(void) { return (float){3.14f}; } int main(void) { int i = test_return_cast(); float f = test_return_cast_float(); printf("i = %d\n", i); printf("f = %f\n", f); ASSERT(42, i); ASSERT(3, (int)f); // simple cast to int for test return 0; } chibicc-1.0.23.1/issues/issue_cmake.c000066400000000000000000000002551505335450300172740ustar00rootroot00000000000000 #if defined(__CLASSIC_C__) int main(argc, argv) int argc; char* argv[]; #else int main(int argc, char* argv[]) #endif { (void)argv; return argc-1;}chibicc-1.0.23.1/issues/issue_cvtss2si.c000066400000000000000000000010601505335450300177670ustar00rootroot00000000000000#include "test.h" // Declare the builtin manually (so we don't need xmmintrin.h) int __builtin_ia32_cvtss2si(__attribute__((vector_size(16))) float v); int main(void) { // Create a vector of 4 floats (matches __v4sf) __attribute__((vector_size(16))) float vec = { 42.5f, 2.0f, -3.0f, 99.0f }; // Convert the lowest element to int int result = __builtin_ia32_cvtss2si(vec); printf("Input[0] = %.2f -> int = %d\n", vec[0], result); ASSERT(42, vec[0]); ASSERT(42, result); printf("OK\n"); return 0; } chibicc-1.0.23.1/issues/issue_vlcasm.c000066400000000000000000000042611505335450300175020ustar00rootroot00000000000000#include #include #include #define COPY16_SHIFTR(x) \ "psrlw "x", %%xmm1\n" #define COPY16_SHIFTL(x) \ "psllw "x", %%xmm1\n" #define COPY16_S(dstp, srcp, load, store, shiftstr) \ asm volatile ( \ load " 0(%[src]), %%xmm1\n" \ shiftstr \ store " %%xmm1, 0(%[dst])\n" \ : : [dst]"r"(dstp), [src]"r"(srcp) : "memory", "xmm1") #define COPY16(dstp, srcp, load, store) COPY16_S(dstp, srcp, load, store, "") #define COPY64_SHIFTR(x) \ "psrlw "x", %%xmm1\n" \ "psrlw "x", %%xmm2\n" \ "psrlw "x", %%xmm3\n" \ "psrlw "x", %%xmm4\n" #define COPY64_SHIFTL(x) \ "psllw "x", %%xmm1\n" \ "psllw "x", %%xmm2\n" \ "psllw "x", %%xmm3\n" \ "psllw "x", %%xmm4\n" #define COPY64_S(dstp, srcp, load, store, shiftstr) \ asm volatile ( \ load " 0(%[src]), %%xmm1\n" \ load " 16(%[src]), %%xmm2\n" \ load " 32(%[src]), %%xmm3\n" \ load " 48(%[src]), %%xmm4\n" \ shiftstr \ store " %%xmm1, 0(%[dst])\n" \ store " %%xmm2, 16(%[dst])\n" \ store " %%xmm3, 32(%[dst])\n" \ store " %%xmm4, 48(%[dst])\n" \ : : [dst]"r"(dstp), [src]"r"(srcp) : "memory", "xmm1", "xmm2", "xmm3", "xmm4") #define COPY64(dstp, srcp, load, store) \ COPY64_S(dstp, srcp, load, store, "") static void Copy2d(uint8_t *dst, size_t dst_pitch, const uint8_t *src, size_t src_pitch, unsigned width, unsigned height) { assert(((intptr_t)src & 0x0f) == 0 && (src_pitch & 0x0f) == 0); for (unsigned y = 0; y < height; y++) { unsigned x = 0; bool unaligned = ((intptr_t)dst & 0x0f) != 0; if (!unaligned) { for (; x+63 < width; x += 64) COPY64(&dst[x], &src[x], "movdqa", "movntdq"); } else { for (; x+63 < width; x += 64) COPY64(&dst[x], &src[x], "movdqa", "movdqu"); } for (; x < width; x++) dst[x] = src[x]; src += src_pitch; dst += dst_pitch; } } int main() { return 0; }chibicc-1.0.23.1/issues/issuephp5.c000066400000000000000000000044511505335450300167330ustar00rootroot00000000000000typedef struct { int dummy; } HashTable; // Static global variable should not be visible externally static HashTable classes; /* {{{ prop handler tables */ static HashTable dom_document_prop_handlers; static HashTable dom_xml_document_prop_handlers; static HashTable dom_abstract_base_document_prop_handlers; static HashTable dom_documentfragment_prop_handlers; static HashTable dom_modern_documentfragment_prop_handlers; static HashTable dom_node_prop_handlers; static HashTable dom_modern_node_prop_handlers; static HashTable dom_entity_reference_prop_handlers; static HashTable dom_modern_entity_reference_prop_handlers; static HashTable dom_nodelist_prop_handlers; static HashTable dom_namednodemap_prop_handlers; static HashTable dom_characterdata_prop_handlers; static HashTable dom_modern_characterdata_prop_handlers; static HashTable dom_attr_prop_handlers; static HashTable dom_modern_attr_prop_handlers; static HashTable dom_element_prop_handlers; static HashTable dom_modern_element_prop_handlers; static HashTable dom_modern_element_prop_handlers; static HashTable dom_text_prop_handlers; static HashTable dom_modern_text_prop_handlers; static HashTable dom_documenttype_prop_handlers; static HashTable dom_modern_documenttype_prop_handlers; static HashTable dom_notation_prop_handlers; static HashTable dom_modern_notation_prop_handlers; static HashTable dom_entity_prop_handlers; static HashTable dom_modern_entity_prop_handlers; static HashTable dom_processinginstruction_prop_handlers; static HashTable dom_modern_processinginstruction_prop_handlers; static HashTable dom_namespace_node_prop_handlers; static HashTable dom_token_list_prop_handlers; // Make sure the variable is used so it doesn't get optimized out HashTable *get_dom_handlers(void) { return &dom_document_prop_handlers; } // Mock zend_extension struct, simplified typedef struct { const char *name; const char *version; const char *author; const char *url; const char *copyright; } zend_extension; // Tentative definition: no initializer static zend_extension opcache_extension_entry; // Full initialized definition static zend_extension opcache_extension_entry = { "OPcache", "8.0.0", "Zend Technologies", "http://www.zend.com/", "Copyright (c)" };chibicc-1.0.23.1/issues/limits.c000066400000000000000000000002731505335450300163050ustar00rootroot00000000000000#include #include int main() { printf("INT_MAX: %d\n", INT_MAX); printf("INT_MIN: %d\n", INT_MIN); printf("LONG_MAX: %ld\n", LONG_MAX); return 0; } chibicc-1.0.23.1/issues/list.h000066400000000000000000000100151505335450300157570ustar00rootroot00000000000000/* SPDX-License-Identifier: GPL-2.0-only */ #ifndef LIST_H #define LIST_H /* * Copied from include/linux/... */ #undef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) /** * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member. * @type: the type of the container struct this is embedded in. * @member: the name of the member within the struct. * */ #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) struct list_head { struct list_head *next, *prev; }; #define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) /** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. * @member: the name of the list_head within the struct. */ #define list_entry(ptr, type, member) \ container_of(ptr, type, member) /** * list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the list_head within the struct. */ #define list_for_each_entry(pos, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop cursor. * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_head within the struct. */ #define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) /** * list_empty - tests whether a list is empty * @head: the list to test. */ static inline int list_empty(const struct list_head *head) { return head->next == head; } /* * Insert a new entry between two known consecutive entries. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static inline void __list_add(struct list_head *_new, struct list_head *prev, struct list_head *next) { next->prev = _new; _new->next = next; _new->prev = prev; prev->next = _new; } /** * list_add_tail - add a new entry * @new: new entry to be added * @head: list head to add it before * * Insert a new entry before the specified head. * This is useful for implementing queues. */ static inline void list_add_tail(struct list_head *_new, struct list_head *head) { __list_add(_new, head->prev, head); } /* * Delete a list entry by making the prev/next entries * point to each other. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static inline void __list_del(struct list_head *prev, struct list_head *next) { next->prev = prev; prev->next = next; } #define LIST_POISON1 ((void *) 0x00100100) #define LIST_POISON2 ((void *) 0x00200200) /** * list_del - deletes entry from list. * @entry: the element to delete from the list. * Note: list_empty() on entry does not return true after this, the entry is * in an undefined state. */ static inline void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); entry->next = (struct list_head*)LIST_POISON1; entry->prev = (struct list_head*)LIST_POISON2; } #endifchibicc-1.0.23.1/issues/lj_arch.h000066400000000000000000000454731505335450300164260ustar00rootroot00000000000000/* ** Target architecture selection. ** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_ARCH_H #define _LJ_ARCH_H #include "lua.h" /* -- Target definitions -------------------------------------------------- */ /* Target endianess. */ #define LUAJIT_LE 0 #define LUAJIT_BE 1 /* Target architectures. */ #define LUAJIT_ARCH_X86 1 #define LUAJIT_ARCH_x86 1 #define LUAJIT_ARCH_X64 2 #define LUAJIT_ARCH_x64 2 #define LUAJIT_ARCH_ARM 3 #define LUAJIT_ARCH_arm 3 #define LUAJIT_ARCH_ARM64 4 #define LUAJIT_ARCH_arm64 4 #define LUAJIT_ARCH_PPC 5 #define LUAJIT_ARCH_ppc 5 #define LUAJIT_ARCH_MIPS 6 #define LUAJIT_ARCH_mips 6 #define LUAJIT_ARCH_MIPS32 6 #define LUAJIT_ARCH_mips32 6 #define LUAJIT_ARCH_MIPS64 7 #define LUAJIT_ARCH_mips64 7 /* Target OS. */ #define LUAJIT_OS_OTHER 0 #define LUAJIT_OS_WINDOWS 1 #define LUAJIT_OS_LINUX 2 #define LUAJIT_OS_OSX 3 #define LUAJIT_OS_BSD 4 #define LUAJIT_OS_POSIX 5 /* Number mode. */ #define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ #define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */ #define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */ #define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */ /* -- Target detection ---------------------------------------------------- */ /* Select native target if no target defined. */ #ifndef LUAJIT_TARGET #if defined(__i386) || defined(__i386__) || defined(_M_IX86) #define LUAJIT_TARGET LUAJIT_ARCH_X86 #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) #define LUAJIT_TARGET LUAJIT_ARCH_X64 #elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM) #define LUAJIT_TARGET LUAJIT_ARCH_ARM #elif defined(__aarch64__) || defined(_M_ARM64) #define LUAJIT_TARGET LUAJIT_ARCH_ARM64 #elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) #define LUAJIT_TARGET LUAJIT_ARCH_PPC #elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64) #define LUAJIT_TARGET LUAJIT_ARCH_MIPS64 #elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS) #define LUAJIT_TARGET LUAJIT_ARCH_MIPS32 #else #error "Architecture not supported (in this version), see: https://luajit.org/status.html#architectures" #endif #endif /* Select native OS if no target OS defined. */ #ifndef LUAJIT_OS #if defined(_WIN32) && !defined(_XBOX_VER) #define LUAJIT_OS LUAJIT_OS_WINDOWS #elif defined(__linux__) #define LUAJIT_OS LUAJIT_OS_LINUX #elif defined(__MACH__) && defined(__APPLE__) #include "TargetConditionals.h" #define LUAJIT_OS LUAJIT_OS_OSX #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__NetBSD__) || defined(__OpenBSD__) || \ defined(__DragonFly__)) && !defined(__ORBIS__) && !defined(__PROSPERO__) #define LUAJIT_OS LUAJIT_OS_BSD #elif (defined(__sun__) && defined(__svr4__)) #define LJ_TARGET_SOLARIS 1 #define LUAJIT_OS LUAJIT_OS_POSIX #elif defined(__HAIKU__) #define LUAJIT_OS LUAJIT_OS_POSIX #elif defined(__CYGWIN__) #define LJ_TARGET_CYGWIN 1 #define LUAJIT_OS LUAJIT_OS_POSIX #elif defined(__QNX__) #define LJ_TARGET_QNX 1 #define LUAJIT_OS LUAJIT_OS_POSIX #else #define LUAJIT_OS LUAJIT_OS_OTHER #endif #endif /* Set target OS properties. */ #if LUAJIT_OS == LUAJIT_OS_WINDOWS #define LJ_OS_NAME "Windows" #elif LUAJIT_OS == LUAJIT_OS_LINUX #define LJ_OS_NAME "Linux" #elif LUAJIT_OS == LUAJIT_OS_OSX #define LJ_OS_NAME "OSX" #elif LUAJIT_OS == LUAJIT_OS_BSD #define LJ_OS_NAME "BSD" #elif LUAJIT_OS == LUAJIT_OS_POSIX #define LJ_OS_NAME "POSIX" #else #define LJ_OS_NAME "Other" #endif #define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS) #define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX) #define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX) #define LJ_TARGET_BSD (LUAJIT_OS == LUAJIT_OS_BSD) #define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) #define LJ_TARGET_DLOPEN LJ_TARGET_POSIX #if TARGET_OS_IPHONE #define LJ_TARGET_IOS 1 #else #define LJ_TARGET_IOS 0 #endif #ifdef __CELLOS_LV2__ #define LJ_TARGET_PS3 1 #define LJ_TARGET_CONSOLE 1 #endif #ifdef __ORBIS__ #define LJ_TARGET_PS4 1 #define LJ_TARGET_CONSOLE 1 #undef NULL #define NULL ((void*)0) #endif #ifdef __PROSPERO__ #define LJ_TARGET_PS5 1 #define LJ_TARGET_CONSOLE 1 #undef NULL #define NULL ((void*)0) #endif #ifdef __psp2__ #define LJ_TARGET_PSVITA 1 #define LJ_TARGET_CONSOLE 1 #endif #if _XBOX_VER >= 200 #define LJ_TARGET_XBOX360 1 #define LJ_TARGET_CONSOLE 1 #endif #ifdef _DURANGO #define LJ_TARGET_XBOXONE 1 #define LJ_TARGET_CONSOLE 1 #define LJ_TARGET_GC64 1 #endif #ifdef __NX__ #define LJ_TARGET_NX 1 #define LJ_TARGET_CONSOLE 1 #undef NULL #define NULL ((void*)0) #endif #ifdef _UWP #define LJ_TARGET_UWP 1 #if LUAJIT_TARGET == LUAJIT_ARCH_X64 #define LJ_TARGET_GC64 1 #endif #endif /* -- Arch-specific settings ---------------------------------------------- */ /* Set target architecture properties. */ #if LUAJIT_TARGET == LUAJIT_ARCH_X86 #define LJ_ARCH_NAME "x86" #define LJ_ARCH_BITS 32 #define LJ_ARCH_ENDIAN LUAJIT_LE #define LJ_TARGET_X86 1 #define LJ_TARGET_X86ORX64 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_EHRAREG 8 #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNALIGNED 1 #define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL #elif LUAJIT_TARGET == LUAJIT_ARCH_X64 #define LJ_ARCH_NAME "x64" #define LJ_ARCH_BITS 64 #define LJ_ARCH_ENDIAN LUAJIT_LE #define LJ_TARGET_X64 1 #define LJ_TARGET_X86ORX64 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_EHRAREG 16 #define LJ_TARGET_JUMPRANGE 31 /* +-2^31 = +-2GB */ #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNALIGNED 1 #define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL #ifndef LUAJIT_DISABLE_GC64 #define LJ_TARGET_GC64 1 #elif LJ_TARGET_OSX #error "macOS requires GC64 -- don't disable it" #endif #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM #define LJ_ARCH_NAME "arm" #define LJ_ARCH_BITS 32 #define LJ_ARCH_ENDIAN LUAJIT_LE #if !defined(LJ_ARCH_HASFPU) && __SOFTFP__ #define LJ_ARCH_HASFPU 0 #endif #if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP #define LJ_ABI_SOFTFP 1 #endif #define LJ_ABI_EABI 1 #define LJ_TARGET_ARM 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_EHRAREG 14 #define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ #define LJ_TARGET_MASKSHIFT 0 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #if __ARM_ARCH >= 8 || __ARM_ARCH_8__ || __ARM_ARCH_8A__ #define LJ_ARCH_VERSION 80 #elif __ARM_ARCH == 7 || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ || __ARM_ARCH_7VE__ #define LJ_ARCH_VERSION 70 #elif __ARM_ARCH_6T2__ #define LJ_ARCH_VERSION 61 #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ #define LJ_ARCH_VERSION 60 #else #define LJ_ARCH_VERSION 50 #endif #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM64 #define LJ_ARCH_BITS 64 #if defined(__AARCH64EB__) #define LJ_ARCH_NAME "arm64be" #define LJ_ARCH_ENDIAN LUAJIT_BE #else #define LJ_ARCH_NAME "arm64" #define LJ_ARCH_ENDIAN LUAJIT_LE #endif #if !defined(LJ_ABI_PAUTH) && defined(__arm64e__) #define LJ_ABI_PAUTH 1 #endif #define LJ_TARGET_ARM64 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_EHRAREG 30 #define LJ_TARGET_JUMPRANGE 27 /* +-2^27 = +-128MB */ #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_TARGET_GC64 1 #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #define LJ_ARCH_VERSION 80 #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC #ifndef LJ_ARCH_ENDIAN #if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ #define LJ_ARCH_ENDIAN LUAJIT_LE #else #define LJ_ARCH_ENDIAN LUAJIT_BE #endif #endif #if _LP64 #define LJ_ARCH_BITS 64 #if LJ_ARCH_ENDIAN == LUAJIT_LE #define LJ_ARCH_NAME "ppc64le" #else #define LJ_ARCH_NAME "ppc64" #endif #else #define LJ_ARCH_BITS 32 #define LJ_ARCH_NAME "ppc" #if !defined(LJ_ARCH_HASFPU) #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) #define LJ_ARCH_HASFPU 0 #else #define LJ_ARCH_HASFPU 1 #endif #endif #if !defined(LJ_ABI_SOFTFP) #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) #define LJ_ABI_SOFTFP 1 #else #define LJ_ABI_SOFTFP 0 #endif #endif #endif #if LJ_ABI_SOFTFP #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #else #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE #endif #define LJ_TARGET_PPC 1 #define LJ_TARGET_EHRETREG 3 #define LJ_TARGET_EHRAREG 65 #define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ #define LJ_TARGET_MASKSHIFT 0 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ #if LJ_TARGET_CONSOLE #define LJ_ARCH_PPC32ON64 1 #define LJ_ARCH_NOFFI 1 #elif LJ_ARCH_BITS == 64 #error "No support for PPC64" #undef LJ_TARGET_PPC #endif #if _ARCH_PWR7 #define LJ_ARCH_VERSION 70 #elif _ARCH_PWR6 #define LJ_ARCH_VERSION 60 #elif _ARCH_PWR5X #define LJ_ARCH_VERSION 51 #elif _ARCH_PWR5 #define LJ_ARCH_VERSION 50 #elif _ARCH_PWR4 #define LJ_ARCH_VERSION 40 #else #define LJ_ARCH_VERSION 0 #endif #if _ARCH_PPCSQ #define LJ_ARCH_SQRT 1 #endif #if _ARCH_PWR5X #define LJ_ARCH_ROUND 1 #endif #if __PPU__ #define LJ_ARCH_CELL 1 #endif #if LJ_TARGET_XBOX360 #define LJ_ARCH_XENON 1 #endif #elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS32 || LUAJIT_TARGET == LUAJIT_ARCH_MIPS64 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) #if __mips_isa_rev >= 6 #define LJ_TARGET_MIPSR6 1 #define LJ_TARGET_UNALIGNED 1 #endif #if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32 #if LJ_TARGET_MIPSR6 #define LJ_ARCH_NAME "mips32r6el" #else #define LJ_ARCH_NAME "mipsel" #endif #else #if LJ_TARGET_MIPSR6 #define LJ_ARCH_NAME "mips64r6el" #else #define LJ_ARCH_NAME "mips64el" #endif #endif #define LJ_ARCH_ENDIAN LUAJIT_LE #else #if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32 #if LJ_TARGET_MIPSR6 #define LJ_ARCH_NAME "mips32r6" #else #define LJ_ARCH_NAME "mips" #endif #else #if LJ_TARGET_MIPSR6 #define LJ_ARCH_NAME "mips64r6" #else #define LJ_ARCH_NAME "mips64" #endif #endif #define LJ_ARCH_ENDIAN LUAJIT_BE #endif #if !defined(LJ_ARCH_HASFPU) #ifdef __mips_soft_float #define LJ_ARCH_HASFPU 0 #else #define LJ_ARCH_HASFPU 1 #endif #endif #if !defined(LJ_ABI_SOFTFP) #ifdef __mips_soft_float #define LJ_ABI_SOFTFP 1 #else #define LJ_ABI_SOFTFP 0 #endif #endif #if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32 #define LJ_ARCH_BITS 32 #define LJ_TARGET_MIPS32 1 #else #define LJ_ARCH_BITS 64 #define LJ_TARGET_MIPS64 1 #define LJ_TARGET_GC64 1 #endif #define LJ_TARGET_MIPS 1 #define LJ_TARGET_EHRETREG 4 #define LJ_TARGET_EHRAREG 31 #define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */ #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #if LJ_TARGET_MIPSR6 #define LJ_ARCH_VERSION 60 #elif _MIPS_ARCH_MIPS32R2 || _MIPS_ARCH_MIPS64R2 #define LJ_ARCH_VERSION 20 #else #define LJ_ARCH_VERSION 10 #endif #else #error "No target architecture defined" #endif /* -- Checks for requirements --------------------------------------------- */ /* Check for minimum required compiler versions. */ #if defined(__GNUC__) #if LJ_TARGET_X86 #if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4) #error "Need at least GCC 3.4 or newer" #endif #elif LJ_TARGET_X64 #if __GNUC__ < 4 #error "Need at least GCC 4.0 or newer" #endif #elif LJ_TARGET_ARM #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) #error "Need at least GCC 4.2 or newer" #endif #elif LJ_TARGET_ARM64 #if __clang__ #if ((__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5)) && !defined(__NX_TOOLCHAIN_MAJOR__) #error "Need at least Clang 3.5 or newer" #endif #else #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 8) #error "Need at least GCC 4.8 or newer" #endif #endif #elif !LJ_TARGET_PS3 #if __clang__ #if ((__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5)) #error "Need at least Clang 3.5 or newer" #endif #else #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) #error "Need at least GCC 4.3 or newer" #endif #endif #endif #endif /* Check target-specific constraints. */ #ifndef _BUILDVM_H #if LJ_TARGET_X64 #if __USING_SJLJ_EXCEPTIONS__ #error "Need a C compiler with native exception handling on x64" #endif #elif LJ_TARGET_ARM #if defined(__ARMEB__) #error "No support for big-endian ARM" #undef LJ_TARGET_ARM #endif #if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ #error "No support for Cortex-M CPUs" #undef LJ_TARGET_ARM #endif #if !(__ARM_EABI__ || LJ_TARGET_IOS) #error "Only ARM EABI or iOS 3.0+ ABI is supported" #undef LJ_TARGET_ARM #endif #elif LJ_TARGET_ARM64 #if defined(_ILP32) #error "No support for ILP32 model on ARM64" #undef LJ_TARGET_ARM64 #endif #elif LJ_TARGET_PPC #if defined(_LITTLE_ENDIAN) && (!defined(_BYTE_ORDER) || (_BYTE_ORDER == _LITTLE_ENDIAN)) #error "No support for little-endian PPC32" #undef LJ_TARGET_PPC #endif #if defined(__NO_FPRS__) && !defined(_SOFT_FLOAT) #error "No support for PPC/e500, use LuaJIT 2.0" #undef LJ_TARGET_PPC #endif #elif LJ_TARGET_MIPS32 #if !((defined(_MIPS_SIM_ABI32) && _MIPS_SIM == _MIPS_SIM_ABI32) || (defined(_ABIO32) && _MIPS_SIM == _ABIO32)) #error "Only o32 ABI supported for MIPS32" #undef LJ_TARGET_MIPS #endif #if LJ_TARGET_MIPSR6 /* Not that useful, since most available r6 CPUs are 64 bit. */ #error "No support for MIPS32R6" #undef LJ_TARGET_MIPS #endif #elif LJ_TARGET_MIPS64 #if !((defined(_MIPS_SIM_ABI64) && _MIPS_SIM == _MIPS_SIM_ABI64) || (defined(_ABI64) && _MIPS_SIM == _ABI64)) /* MIPS32ON64 aka n32 ABI support might be desirable, but difficult. */ #error "Only n64 ABI supported for MIPS64" #undef LJ_TARGET_MIPS #endif #endif #endif /* -- Derived defines ----------------------------------------------------- */ /* Enable or disable the dual-number mode for the VM. */ #if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \ (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1) #error "No support for this number mode on this architecture" #endif #if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \ (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \ (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2) #define LJ_DUALNUM 1 #else #define LJ_DUALNUM 0 #endif #if LJ_TARGET_IOS || LJ_TARGET_CONSOLE /* Runtime code generation is restricted on iOS. Complain to Apple, not me. */ /* Ditto for the consoles. Complain to Sony or MS, not me. */ #ifndef LUAJIT_ENABLE_JIT #define LJ_OS_NOJIT 1 #endif #endif /* 64 bit GC references. */ #if LJ_TARGET_GC64 #define LJ_GC64 1 #else #define LJ_GC64 0 #endif /* 2-slot frame info. */ #if LJ_GC64 #define LJ_FR2 1 #else #define LJ_FR2 0 #endif /* Disable or enable the JIT compiler. */ #if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT) #define LJ_HASJIT 0 #else #define LJ_HASJIT 1 #endif /* Disable or enable the FFI extension. */ #if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI) #define LJ_HASFFI 0 #else #define LJ_HASFFI 1 #endif /* Disable or enable the string buffer extension. */ #if defined(LUAJIT_DISABLE_BUFFER) #define LJ_HASBUFFER 0 #else #define LJ_HASBUFFER 1 #endif #if defined(LUAJIT_DISABLE_PROFILE) #define LJ_HASPROFILE 0 #elif LJ_TARGET_POSIX #define LJ_HASPROFILE 1 #define LJ_PROFILE_SIGPROF 1 #elif LJ_TARGET_PS3 #define LJ_HASPROFILE 1 #define LJ_PROFILE_PTHREAD 1 #elif LJ_TARGET_WINDOWS || LJ_TARGET_XBOX360 #define LJ_HASPROFILE 1 #define LJ_PROFILE_WTHREAD 1 #else #define LJ_HASPROFILE 0 #endif #ifndef LJ_ARCH_HASFPU #define LJ_ARCH_HASFPU 1 #endif #ifndef LJ_ABI_SOFTFP #define LJ_ABI_SOFTFP 0 #endif #define LJ_SOFTFP (!LJ_ARCH_HASFPU) #define LJ_SOFTFP32 (LJ_SOFTFP && LJ_32) #ifndef LJ_ABI_PAUTH #define LJ_ABI_PAUTH 0 #endif #if LJ_ARCH_ENDIAN == LUAJIT_BE #define LJ_LE 0 #define LJ_BE 1 #define LJ_ENDIAN_SELECT(le, be) be #define LJ_ENDIAN_LOHI(lo, hi) hi lo #else #define LJ_LE 1 #define LJ_BE 0 #define LJ_ENDIAN_SELECT(le, be) le #define LJ_ENDIAN_LOHI(lo, hi) lo hi #endif #if LJ_ARCH_BITS == 32 #define LJ_32 1 #define LJ_64 0 #else #define LJ_32 0 #define LJ_64 1 #endif #ifndef LJ_TARGET_UNALIGNED #define LJ_TARGET_UNALIGNED 0 #endif #ifndef LJ_PAGESIZE #define LJ_PAGESIZE 4096 #endif /* Various workarounds for embedded operating systems or weak C runtimes. */ #if defined(__ANDROID__) || defined(__symbian__) || LJ_TARGET_XBOX360 || LJ_TARGET_WINDOWS #define LUAJIT_NO_LOG2 #endif #if LJ_TARGET_CONSOLE || (LJ_TARGET_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0) #define LJ_NO_SYSTEM 1 #endif #if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN #define LJ_ABI_WIN 1 #else #define LJ_ABI_WIN 0 #endif #if LJ_TARGET_WINDOWS #if LJ_TARGET_UWP #define LJ_WIN_VALLOC VirtualAllocFromApp #define LJ_WIN_VPROTECT VirtualProtectFromApp extern void *LJ_WIN_LOADLIBA(const char *path); #else #define LJ_WIN_VALLOC VirtualAlloc #define LJ_WIN_VPROTECT VirtualProtect #define LJ_WIN_LOADLIBA(path) LoadLibraryExA((path), NULL, 0) #endif #endif #if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 #define LJ_NO_UNWIND 1 #endif #if !LJ_NO_UNWIND && !defined(LUAJIT_UNWIND_INTERNAL) && (LJ_ABI_WIN || (defined(LUAJIT_UNWIND_EXTERNAL) && (defined(__GNUC__) || defined(__clang__)))) #define LJ_UNWIND_EXT 1 #else #define LJ_UNWIND_EXT 0 #endif #if LJ_UNWIND_EXT && LJ_HASJIT && !LJ_TARGET_ARM && !(LJ_ABI_WIN && LJ_TARGET_X86) #define LJ_UNWIND_JIT 1 #else #define LJ_UNWIND_JIT 0 #endif /* Compatibility with Lua 5.1 vs. 5.2. */ #ifdef LUAJIT_ENABLE_LUA52COMPAT #define LJ_52 1 #else #define LJ_52 0 #endif /* -- VM security --------------------------------------------------------- */ /* Don't make any changes here. Instead build with: ** make "XCFLAGS=-DLUAJIT_SECURITY_flag=value" ** ** Important note to distro maintainers: DO NOT change the defaults for a ** regular distro build -- neither upwards, nor downwards! ** These build-time configurable security flags are intended for embedders ** who may have specific needs wrt. security vs. performance. */ /* Security defaults. */ #ifndef LUAJIT_SECURITY_PRNG /* PRNG init: 0 = fixed/insecure, 1 = secure from OS. */ #define LUAJIT_SECURITY_PRNG 1 #endif #ifndef LUAJIT_SECURITY_STRHASH /* String hash: 0 = sparse only, 1 = sparse + dense. */ #define LUAJIT_SECURITY_STRHASH 1 #endif #ifndef LUAJIT_SECURITY_STRID /* String IDs: 0 = linear, 1 = reseed < 255, 2 = reseed < 15, 3 = random. */ #define LUAJIT_SECURITY_STRID 1 #endif #ifndef LUAJIT_SECURITY_MCODE /* Machine code page protection: 0 = insecure RWX, 1 = secure RW^X. */ #define LUAJIT_SECURITY_MCODE 1 #endif #define LJ_SECURITY_MODE \ ( 0u \ | ((LUAJIT_SECURITY_PRNG & 3) << 0) \ | ((LUAJIT_SECURITY_STRHASH & 3) << 2) \ | ((LUAJIT_SECURITY_STRID & 3) << 4) \ | ((LUAJIT_SECURITY_MCODE & 3) << 6) \ ) #define LJ_SECURITY_MODESTRING \ "\004prng\007strhash\005strid\005mcode" #endif chibicc-1.0.23.1/issues/loongarch.c000066400000000000000000000004751505335450300167640ustar00rootroot00000000000000//#include int main () { unsigned int crc = 0; crc = __crc32cb(crc, 0); crc = __crc32ch(crc, 0); crc = __crc32cw(crc, 0); crc = __crc32cd(crc, 0); /* return computed value, to prevent the above being optimized away */ return crc == 0; ; return undeclared_func(123); }chibicc-1.0.23.1/issues/lua.h000066400000000000000000000300441505335450300155710ustar00rootroot00000000000000/* ** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (https://www.lua.org) ** See Copyright Notice at the end of this file */ #ifndef lua_h #define lua_h #include #include #include "luaconf.h" #define LUA_VERSION "Lua 5.1" #define LUA_RELEASE "Lua 5.1.4" #define LUA_VERSION_NUM 501 #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" /* mark for precompiled code (`Lua') */ #define LUA_SIGNATURE "\033Lua" /* option for multiple returns in `lua_pcall' and `lua_call' */ #define LUA_MULTRET (-1) /* ** pseudo-indices */ #define LUA_REGISTRYINDEX (-10000) #define LUA_ENVIRONINDEX (-10001) #define LUA_GLOBALSINDEX (-10002) #define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) /* thread status */ #define LUA_OK 0 #define LUA_YIELD 1 #define LUA_ERRRUN 2 #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 #define LUA_ERRERR 5 typedef struct lua_State lua_State; typedef int (*lua_CFunction) (lua_State *L); /* ** functions that read/write blocks when loading/dumping Lua chunks */ typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); /* ** prototype for memory-allocation functions */ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); /* ** basic types */ #define LUA_TNONE (-1) #define LUA_TNIL 0 #define LUA_TBOOLEAN 1 #define LUA_TLIGHTUSERDATA 2 #define LUA_TNUMBER 3 #define LUA_TSTRING 4 #define LUA_TTABLE 5 #define LUA_TFUNCTION 6 #define LUA_TUSERDATA 7 #define LUA_TTHREAD 8 /* minimum Lua stack available to a C function */ #define LUA_MINSTACK 20 /* ** generic extra include file */ #if defined(LUA_USER_H) #include LUA_USER_H #endif /* type of numbers in Lua */ typedef LUA_NUMBER lua_Number; /* type for integer functions */ typedef LUA_INTEGER lua_Integer; /* ** state manipulation */ LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); LUA_API void (lua_close) (lua_State *L); LUA_API lua_State *(lua_newthread) (lua_State *L); LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); /* ** basic stack manipulation */ LUA_API int (lua_gettop) (lua_State *L); LUA_API void (lua_settop) (lua_State *L, int idx); LUA_API void (lua_pushvalue) (lua_State *L, int idx); LUA_API void (lua_remove) (lua_State *L, int idx); LUA_API void (lua_insert) (lua_State *L, int idx); LUA_API void (lua_replace) (lua_State *L, int idx); LUA_API int (lua_checkstack) (lua_State *L, int sz); LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); /* ** access functions (stack -> C) */ LUA_API int (lua_isnumber) (lua_State *L, int idx); LUA_API int (lua_isstring) (lua_State *L, int idx); LUA_API int (lua_iscfunction) (lua_State *L, int idx); LUA_API int (lua_isuserdata) (lua_State *L, int idx); LUA_API int (lua_type) (lua_State *L, int idx); LUA_API const char *(lua_typename) (lua_State *L, int tp); LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); LUA_API int (lua_toboolean) (lua_State *L, int idx); LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); LUA_API size_t (lua_objlen) (lua_State *L, int idx); LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); LUA_API void *(lua_touserdata) (lua_State *L, int idx); LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); LUA_API const void *(lua_topointer) (lua_State *L, int idx); /* ** push functions (C -> stack) */ LUA_API void (lua_pushnil) (lua_State *L); LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); LUA_API void (lua_pushstring) (lua_State *L, const char *s); LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, va_list argp); LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); LUA_API void (lua_pushboolean) (lua_State *L, int b); LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); LUA_API int (lua_pushthread) (lua_State *L); /* ** get functions (Lua -> stack) */ LUA_API void (lua_gettable) (lua_State *L, int idx); LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); LUA_API void (lua_rawget) (lua_State *L, int idx); LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); LUA_API int (lua_getmetatable) (lua_State *L, int objindex); LUA_API void (lua_getfenv) (lua_State *L, int idx); /* ** set functions (stack -> Lua) */ LUA_API void (lua_settable) (lua_State *L, int idx); LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); LUA_API void (lua_rawset) (lua_State *L, int idx); LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); LUA_API int (lua_setmetatable) (lua_State *L, int objindex); LUA_API int (lua_setfenv) (lua_State *L, int idx); /* ** `load' and `call' functions (load and run Lua code) */ LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, const char *chunkname); LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); /* ** coroutine functions */ LUA_API int (lua_yield) (lua_State *L, int nresults); LUA_API int (lua_resume) (lua_State *L, int narg); LUA_API int (lua_status) (lua_State *L); /* ** garbage-collection function and options */ #define LUA_GCSTOP 0 #define LUA_GCRESTART 1 #define LUA_GCCOLLECT 2 #define LUA_GCCOUNT 3 #define LUA_GCCOUNTB 4 #define LUA_GCSTEP 5 #define LUA_GCSETPAUSE 6 #define LUA_GCSETSTEPMUL 7 #define LUA_GCISRUNNING 9 LUA_API int (lua_gc) (lua_State *L, int what, int data); /* ** miscellaneous functions */ LUA_API int (lua_error) (lua_State *L); LUA_API int (lua_next) (lua_State *L, int idx); LUA_API void (lua_concat) (lua_State *L, int n); LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); /* ** =============================================================== ** some useful macros ** =============================================================== */ #define lua_pop(L,n) lua_settop(L, -(n)-1) #define lua_newtable(L) lua_createtable(L, 0, 0) #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) #define lua_strlen(L,i) lua_objlen(L, (i)) #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) #define lua_pushliteral(L, s) \ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) /* ** compatibility macros and functions */ #define lua_open() luaL_newstate() #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) #define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) #define lua_Chunkreader lua_Reader #define lua_Chunkwriter lua_Writer /* hack */ LUA_API void lua_setlevel (lua_State *from, lua_State *to); /* ** {====================================================================== ** Debug API ** ======================================================================= */ /* ** Event codes */ #define LUA_HOOKCALL 0 #define LUA_HOOKRET 1 #define LUA_HOOKLINE 2 #define LUA_HOOKCOUNT 3 #define LUA_HOOKTAILRET 4 /* ** Event masks */ #define LUA_MASKCALL (1 << LUA_HOOKCALL) #define LUA_MASKRET (1 << LUA_HOOKRET) #define LUA_MASKLINE (1 << LUA_HOOKLINE) #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) typedef struct lua_Debug lua_Debug; /* activation record */ /* Functions to be called by the debuger in specific events */ typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); LUA_API lua_Hook lua_gethook (lua_State *L); LUA_API int lua_gethookmask (lua_State *L); LUA_API int lua_gethookcount (lua_State *L); /* From Lua 5.2. */ LUA_API void *lua_upvalueid (lua_State *L, int idx, int n); LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2); LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode); LUA_API const lua_Number *lua_version (lua_State *L); LUA_API void lua_copy (lua_State *L, int fromidx, int toidx); LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum); LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum); /* From Lua 5.3. */ LUA_API int lua_isyieldable (lua_State *L); struct lua_Debug { int event; const char *name; /* (n) */ const char *namewhat; /* (n) `global', `local', `field', `method' */ const char *what; /* (S) `Lua', `C', `main', `tail' */ const char *source; /* (S) */ int currentline; /* (l) */ int nups; /* (u) number of upvalues */ int linedefined; /* (S) */ int lastlinedefined; /* (S) */ char short_src[LUA_IDSIZE]; /* (S) */ /* private part */ int i_ci; /* active function */ }; /* }====================================================================== */ /****************************************************************************** * Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ #endif chibicc-1.0.23.1/issues/luaconf.h000066400000000000000000000107511505335450300164420ustar00rootroot00000000000000/* ** Configuration header. ** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h */ #ifndef luaconf_h #define luaconf_h #ifndef WINVER #define WINVER 0x0501 #endif #include #include /* Default path for loading Lua and C modules with require(). */ #if defined(_WIN32) /* ** In Windows, any exclamation mark ('!') in the path is replaced by the ** path of the directory of the executable file of the current process. */ #define LUA_LDIR "!\\lua\\" #define LUA_CDIR "!\\" #define LUA_PATH_DEFAULT \ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" #define LUA_CPATH_DEFAULT \ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else /* ** Note to distribution maintainers: do NOT patch the following lines! ** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. */ #ifndef LUA_MULTILIB #define LUA_MULTILIB "lib" #endif #ifndef LUA_LMULTILIB #define LUA_LMULTILIB "lib" #endif #define LUA_LROOT "/usr/local" #define LUA_LUADIR "/lua/5.1/" #define LUA_LJDIR "/luajit-2.1/" #ifdef LUA_ROOT #define LUA_JROOT LUA_ROOT #define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR #define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR #define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua" #define LUA_RCPATH ";" LUA_RCDIR "?.so" #else #define LUA_JROOT LUA_LROOT #define LUA_RLPATH #define LUA_RCPATH #endif #define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua" #define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR #define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR #define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua" #define LUA_LCPATH1 ";" LUA_LCDIR "?.so" #define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so" #define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH #define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2 #endif /* Environment variable names for path overrides and initialization code. */ #define LUA_PATH "LUA_PATH" #define LUA_CPATH "LUA_CPATH" #define LUA_INIT "LUA_INIT" /* Special file system characters. */ #if defined(_WIN32) #define LUA_DIRSEP "\\" #else #define LUA_DIRSEP "/" #endif #define LUA_PATHSEP ";" #define LUA_PATH_MARK "?" #define LUA_EXECDIR "!" #define LUA_IGMARK "-" #define LUA_PATH_CONFIG \ LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ LUA_EXECDIR "\n" LUA_IGMARK "\n" /* Quoting in error messages. */ #define LUA_QL(x) "'" x "'" #define LUA_QS LUA_QL("%s") /* Various tunables. */ #define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ #define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ #define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ #define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ #define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ /* Configuration for the frontend (the luajit executable). */ #if defined(luajit_c) #define LUA_PROGNAME "luajit" /* Fallback frontend name. */ #define LUA_PROMPT "> " /* Interactive prompt. */ #define LUA_PROMPT2 ">> " /* Continuation prompt. */ #define LUA_MAXINPUT 512 /* Max. input line length. */ #endif /* Note: changing the following defines breaks the Lua 5.1 ABI. */ #define LUA_INTEGER ptrdiff_t #define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ /* ** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using ** unreasonable amounts of stack space, but still retain ABI compatibility. ** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. */ #define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) /* The following defines are here only for compatibility with luaconf.h ** from the standard Lua distribution. They must not be changed for LuaJIT. */ #define LUA_NUMBER_DOUBLE #define LUA_NUMBER double #define LUAI_UACNUMBER double #define LUA_NUMBER_SCAN "%lf" #define LUA_NUMBER_FMT "%.14g" #define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) #define LUAI_MAXNUMBER2STR 32 #define LUA_INTFRMLEN "l" #define LUA_INTFRM_T long /* Linkage of public API functions. */ #if defined(LUA_BUILD_AS_DLL) #if defined(LUA_CORE) || defined(LUA_LIB) #define LUA_API __declspec(dllexport) #else #define LUA_API __declspec(dllimport) #endif #else #define LUA_API extern #endif #define LUALIB_API LUA_API /* Compatibility support for assertions. */ #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) #include #endif #ifdef LUA_USE_ASSERT #define lua_assert(x) assert(x) #endif #ifdef LUA_USE_APICHECK #define luai_apicheck(L, o) { (void)L; assert(o); } #else #define luai_apicheck(L, o) { (void)L; } #endif #endif chibicc-1.0.23.1/issues/macro2.c000066400000000000000000000013561505335450300161720ustar00rootroot00000000000000#include "test.h" int main(void) { #define H(x) #x #define STR(x) H(x) #define M1(X) H(X) H(X) ASSERT(0, strcmp("00", M1(__COUNTER__)) ); #define M2(A,B,...) H(__VA_OPT__(A##B)) ASSERT(0, strcmp("XY", M2(X,Y,z)) ); #define M3(A,B,...) #__VA_OPT__(A##B) ASSERT(0, strcmp("XY", M3(X,Y,z)) ); #define EXPAND_PASTE(x,y) x + x##y #define i 5 ASSERT(107, ({ int i3=100; EXPAND_PASTE(1+i,3); })); #undef i #define M4(A,...) H((A,##__VA_ARGS__)) ASSERT(0, strcmp("(X,)", M4(X,) )); #define M5(x,...) b ## __VA_OPT__(x) ASSERT(0, strcmp("bbz", STR(M5(M5(z,a),b)) )); #define hash_hash # ## # #define mkstr(a) # a #define in_between(a) mkstr(a) #define join(c, d) in_between(c hash_hash d) ASSERT(0, strcmp("x ## y", join(x,y) )); printf("OK\n"); }chibicc-1.0.23.1/issues/macro_1.c000066400000000000000000000001031505335450300163150ustar00rootroot00000000000000#define hash # hash include int main() { return 0; }chibicc-1.0.23.1/issues/memcpy_issue.c000066400000000000000000000014041505335450300175030ustar00rootroot00000000000000#include #include // Function pointers void (*keycopy)(void *, const void *, size_t); void (*keymset)(void *, int, size_t); int main() { // Initialize function pointers keycopy = memcpy; keymset = memset; // Example data char src[50] = "This is a source string."; char dest[50]; char buffer[50]; // Use keycopy to copy data from src to dest keycopy(dest, src, strlen(src) + 1); // +1 to include the null terminator printf("After keycopy: dest = \"%s\"\n", dest); // Use keymset to set all elements in buffer to 'A' keymset(buffer, 'A', sizeof(buffer) - 1); buffer[sizeof(buffer) - 1] = '\0'; // Null-terminate the buffer printf("After keymset: buffer = \"%s\"\n", buffer); return 0; } chibicc-1.0.23.1/issues/mulq.c000066400000000000000000000456341505335450300157740ustar00rootroot00000000000000/* * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include #if !(defined(__GNUC__) && __GNUC__>=2) # include "../bn_asm.c" /* kind of dirty hack for Sun Studio */ #else /*- * x86_64 BIGNUM accelerator version 0.1, December 2002. * * Implemented by Andy Polyakov for the OpenSSL * project. * * Rights for redistribution and usage in source and binary forms are * granted according to the License. Warranty of any kind is disclaimed. * * Q. Version 0.1? It doesn't sound like Andy, he used to assign real * versions, like 1.0... * A. Well, that's because this code is basically a quick-n-dirty * proof-of-concept hack. As you can see it's implemented with * inline assembler, which means that you're bound to GCC and that * there might be enough room for further improvement. * * Q. Why inline assembler? * A. x86_64 features own ABI which I'm not familiar with. This is * why I decided to let the compiler take care of subroutine * prologue/epilogue as well as register allocation. For reference. * Win64 implements different ABI for AMD64, different from Linux. * * Q. How much faster does it get? * A. 'apps/openssl speed rsa dsa' output with no-asm: * * sign verify sign/s verify/s * rsa 512 bits 0.0006s 0.0001s 1683.8 18456.2 * rsa 1024 bits 0.0028s 0.0002s 356.0 6407.0 * rsa 2048 bits 0.0172s 0.0005s 58.0 1957.8 * rsa 4096 bits 0.1155s 0.0018s 8.7 555.6 * sign verify sign/s verify/s * dsa 512 bits 0.0005s 0.0006s 2100.8 1768.3 * dsa 1024 bits 0.0014s 0.0018s 692.3 559.2 * dsa 2048 bits 0.0049s 0.0061s 204.7 165.0 * * 'apps/openssl speed rsa dsa' output with this module: * * sign verify sign/s verify/s * rsa 512 bits 0.0004s 0.0000s 2767.1 33297.9 * rsa 1024 bits 0.0012s 0.0001s 867.4 14674.7 * rsa 2048 bits 0.0061s 0.0002s 164.0 5270.0 * rsa 4096 bits 0.0384s 0.0006s 26.1 1650.8 * sign verify sign/s verify/s * dsa 512 bits 0.0002s 0.0003s 4442.2 3786.3 * dsa 1024 bits 0.0005s 0.0007s 1835.1 1497.4 * dsa 2048 bits 0.0016s 0.0020s 620.4 504.6 * * For the reference. IA-32 assembler implementation performs * very much like 64-bit code compiled with no-asm on the same * machine. */ # undef mul # undef mul_add /*- * "m"(a), "+m"(r) is the way to favor DirectPath µ-code; * "g"(0) let the compiler to decide where does it * want to keep the value of zero; */ # define mul_add(r,a,word,carry) do { \ register unsigned long high,low; \ asm ("mulq %3" \ : "=a"(low),"=d"(high) \ : "a"(word),"m"(a) \ : "cc"); \ asm ("addq %2,%0; adcq %3,%1" \ : "+r"(carry),"+d"(high)\ : "a"(low),"g"(0) \ : "cc"); \ asm ("addq %2,%0; adcq %3,%1" \ : "+m"(r),"+d"(high) \ : "r"(carry),"g"(0) \ : "cc"); \ carry=high; \ } while (0) # define mul(r,a,word,carry) do { \ register unsigned long high,low; \ asm ("mulq %3" \ : "=a"(low),"=d"(high) \ : "a"(word),"g"(a) \ : "cc"); \ asm ("addq %2,%0; adcq %3,%1" \ : "+r"(carry),"+d"(high)\ : "a"(low),"g"(0) \ : "cc"); \ (r)=carry, carry=high; \ } while (0) # undef sqr # define sqr(r0,r1,a) \ asm ("mulq %2" \ : "=a"(r0),"=d"(r1) \ : "a"(a) \ : "cc"); unsigned long bn_mul_add_words(unsigned long *rp, const unsigned long *ap, int num, unsigned long w) { unsigned long c1 = 0; if (num <= 0) return c1; while (num & ~3) { mul_add(rp[0], ap[0], w, c1); mul_add(rp[1], ap[1], w, c1); mul_add(rp[2], ap[2], w, c1); mul_add(rp[3], ap[3], w, c1); ap += 4; rp += 4; num -= 4; } if (num) { mul_add(rp[0], ap[0], w, c1); if (--num == 0) return c1; mul_add(rp[1], ap[1], w, c1); if (--num == 0) return c1; mul_add(rp[2], ap[2], w, c1); return c1; } return c1; } unsigned long bn_mul_words(unsigned long *rp, const unsigned long *ap, int num, unsigned long w) { unsigned long c1 = 0; if (num <= 0) return c1; while (num & ~3) { mul(rp[0], ap[0], w, c1); mul(rp[1], ap[1], w, c1); mul(rp[2], ap[2], w, c1); mul(rp[3], ap[3], w, c1); ap += 4; rp += 4; num -= 4; } if (num) { mul(rp[0], ap[0], w, c1); if (--num == 0) return c1; mul(rp[1], ap[1], w, c1); if (--num == 0) return c1; mul(rp[2], ap[2], w, c1); } return c1; } void bn_sqr_words(unsigned long *r, const unsigned long *a, int n) { if (n <= 0) return; while (n & ~3) { sqr(r[0], r[1], a[0]); sqr(r[2], r[3], a[1]); sqr(r[4], r[5], a[2]); sqr(r[6], r[7], a[3]); a += 4; r += 8; n -= 4; } if (n) { sqr(r[0], r[1], a[0]); if (--n == 0) return; sqr(r[2], r[3], a[1]); if (--n == 0) return; sqr(r[4], r[5], a[2]); } } unsigned long bn_div_words(unsigned long h, unsigned long l, unsigned long d) { unsigned long ret, waste; asm("divq %4":"=a"(ret), "=d"(waste) : "a"(l), "d"(h), "r"(d) : "cc"); return ret; } unsigned long bn_add_words(unsigned long *rp, const unsigned long *ap, const unsigned long *bp, int n) { unsigned long ret; size_t i = 0; if (n <= 0) return 0; asm volatile (" subq %0,%0 \n" /* clear carry */ " jmp 1f \n" ".p2align 4 \n" "1: movq (%4,%2,8),%0 \n" " adcq (%5,%2,8),%0 \n" " movq %0,(%3,%2,8) \n" " lea 1(%2),%2 \n" " dec %1 \n" " jnz 1b \n" " sbbq %0,%0 \n" :"=&r" (ret), "+c"(n), "+r"(i) :"r"(rp), "r"(ap), "r"(bp) :"cc", "memory"); return ret & 1; } # ifndef SIMICS unsigned long bn_sub_words(unsigned long *rp, const unsigned long *ap, const unsigned long *bp, int n) { unsigned long ret; size_t i = 0; if (n <= 0) return 0; asm volatile (" subq %0,%0 \n" /* clear borrow */ " jmp 1f \n" ".p2align 4 \n" "1: movq (%4,%2,8),%0 \n" " sbbq (%5,%2,8),%0 \n" " movq %0,(%3,%2,8) \n" " lea 1(%2),%2 \n" " dec %1 \n" " jnz 1b \n" " sbbq %0,%0 \n" :"=&r" (ret), "+c"(n), "+r"(i) :"r"(rp), "r"(ap), "r"(bp) :"cc", "memory"); return ret & 1; } # else /* Simics 1.4<7 has buggy sbbq:-( */ # define BN_MASK2 0xffffffffffffffffL unsigned long bn_sub_words(unsigned long *r, unsigned long *a, unsigned long *b, int n) { unsigned long t1, t2; int c = 0; if (n <= 0) return (unsigned long)0; for (;;) { t1 = a[0]; t2 = b[0]; r[0] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); if (--n <= 0) break; t1 = a[1]; t2 = b[1]; r[1] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); if (--n <= 0) break; t1 = a[2]; t2 = b[2]; r[2] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); if (--n <= 0) break; t1 = a[3]; t2 = b[3]; r[3] = (t1 - t2 - c) & BN_MASK2; if (t1 != t2) c = (t1 < t2); if (--n <= 0) break; a += 4; b += 4; r += 4; } return c; } # endif /* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */ /* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */ /* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */ /* * sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number * c=(c2,c1,c0) */ /* * Keep in mind that carrying into high part of multiplication result * can not overflow, because it cannot be all-ones. */ # if 0 /* original macros are kept for reference purposes */ # define mul_add_c(a,b,c0,c1,c2) do { \ unsigned long ta = (a), tb = (b); \ unsigned long lo, hi; \ BN_UMULT_LOHI(lo,hi,ta,tb); \ c0 += lo; hi += (c0 #include typedef void (*FuncPtr)(void); typedef struct { int a; FuncPtr func; double b; } MyStruct; void myFunction(void) { printf("Function called!\n"); } int main() { printf("Offset of a: %zu\n", offsetof(MyStruct, a)); // Should be 0 printf("Offset of func: %zu\n", offsetof(MyStruct, func)); // Should be sizeof(int) printf("Offset of b: %zu\n", offsetof(MyStruct, b)); // Should be sizeof(int) + sizeof(FuncPtr) // Example usage MyStruct s; s.func = myFunction; s.func(); // Should print "Function called!" return 0; } chibicc-1.0.23.1/issues/offsetof2.c000066400000000000000000000020041505335450300166730ustar00rootroot00000000000000#include #include typedef void (*Func1)(void); typedef void (*Func2)(int); typedef int (*Func3)(int); typedef struct { Func1 func1; Func2 func2; Func3 func3; } FunctionStruct; void myFunc1(void) { printf("Func1 called!\n"); } void myFunc2(int x) { printf("Func2 called with %d!\n", x); } int myFunc3(int x) { return x * 2; } int main() { printf("Offset of func1: %zu\n", offsetof(FunctionStruct, func1)); // Should be 0 printf("Offset of func2: %zu\n", offsetof(FunctionStruct, func2)); // Should be sizeof(Func1) printf("Offset of func3: %zu\n", offsetof(FunctionStruct, func3)); // Should be sizeof(Func1) + sizeof(Func2) // Example usage FunctionStruct fs; fs.func1 = myFunc1; fs.func2 = myFunc2; fs.func3 = myFunc3; fs.func1(); // Should print "Func1 called!" fs.func2(10); // Should print "Func2 called with 10!" printf("Func3 result: %d\n", fs.func3(5)); // Should print "Func3 result: 10" return 0; } chibicc-1.0.23.1/issues/offsetof3.c000066400000000000000000000014471505335450300167060ustar00rootroot00000000000000#include #include typedef void (*Callback)(int); typedef struct { int a; char b; Callback callback; double c; } ComplexStruct; void myCallback(int x) { printf("Callback called with %d\n", x); } int main() { printf("Offset of a: %zu\n", offsetof(ComplexStruct, a)); // Should be 0 printf("Offset of b: %zu\n", offsetof(ComplexStruct, b)); // Should be sizeof(int) printf("Offset of callback: %zu\n", offsetof(ComplexStruct, callback)); // Should be sizeof(int) + sizeof(char) printf("Offset of c: %zu\n", offsetof(ComplexStruct, c)); // Should be sizeof(int) + sizeof(char) + sizeof(Callback) // Example usage ComplexStruct cs; cs.callback = myCallback; cs.callback(42); // Should print "Callback called with 42" return 0; } chibicc-1.0.23.1/issues/paramgcc1.c000066400000000000000000000003711505335450300166410ustar00rootroot00000000000000 extern int i; int i; int foo2(char * p) __attribute__((nonnull(1))); int foo( void ) { switch (0) { case 1: __attribute__((fallthrough)); case 2: break; } return 0; }; chibicc-1.0.23.1/issues/postgres_asm.c000066400000000000000000000431161505335450300175150ustar00rootroot00000000000000 #include #include #include "test.h" typedef uint64_t uint64; typedef uint32_t uint32; typedef uint16_t uint16; typedef int64_t int64; typedef int32_t int32; typedef int16_t int16; typedef uint8_t uint8; typedef int8_t int8; typedef uint8 bits8; /* >= 8 bits */ typedef uint16 bits16; /* >= 16 bits */ typedef uint32 bits32; /* >= 32 bits */ const uint8 pg_rightmost_one_pos[256] = { 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; const uint8 pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; const uint8 pg_number_of_ones[256] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; #define INT64CONST(x) (x##L) #define UINT64CONST(x) (x##UL) #define PG_INT8_MIN (-0x7F-1) #define PG_INT8_MAX (0x7F) #define PG_UINT8_MAX (0xFF) #define PG_INT16_MIN (-0x7FFF-1) #define PG_INT16_MAX (0x7FFF) #define PG_UINT16_MAX (0xFFFF) #define PG_INT32_MIN (-0x7FFFFFFF-1) #define PG_INT32_MAX (0x7FFFFFFF) #define PG_UINT32_MAX (0xFFFFFFFFU) #define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1) #define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF) #define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF) #define TYPEALIGN(ALIGNVAL,LEN) \ (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1))) #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) #define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN)) #define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN)) /* MAXALIGN covers only built-in types, not buffers */ #define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN)) #define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN)) #define TYPEALIGN_DOWN(ALIGNVAL,LEN) \ (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1))) #define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN)) #define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN)) #define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN)) #define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN)) #define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN)) /*------------------------------------------------------------------------- * * pg_bitutils.h * Miscellaneous functions for bit-wise operations. * * * Copyright (c) 2019-2024, PostgreSQL Global Development Group * * src/include/port/pg_bitutils.h * *------------------------------------------------------------------------- */ #ifndef PG_BITUTILS_H #define PG_BITUTILS_H #ifdef _MSC_VER #include #define HAVE_BITSCAN_FORWARD #define HAVE_BITSCAN_REVERSE #else #if defined(HAVE__BUILTIN_CTZ) #define HAVE_BITSCAN_FORWARD #endif #if defined(HAVE__BUILTIN_CLZ) #define HAVE_BITSCAN_REVERSE #endif #endif /* _MSC_VER */ /* * pg_leftmost_one_pos32 * Returns the position of the most significant set bit in "word", * measured from the least significant bit. word must not be 0. */ static inline int pg_leftmost_one_pos32(uint32 word) { #ifdef HAVE__BUILTIN_CLZ //Assert(word != 0); return 31 - __builtin_clz(word); #elif defined(_MSC_VER) unsigned long result; bool non_zero; //Assert(word != 0); non_zero = _BitScanReverse(&result, word); return (int) result; #else int shift = 32 - 8; //Assert(word != 0); while ((word >> shift) == 0) shift -= 8; return shift + pg_leftmost_one_pos[(word >> shift) & 255]; #endif /* HAVE__BUILTIN_CLZ */ } /* * pg_leftmost_one_pos64 * As above, but for a 64-bit word. */ static inline int pg_leftmost_one_pos64(uint64 word) { #ifdef HAVE__BUILTIN_CLZ //Assert(word != 0); #if defined(HAVE_LONG_INT_64) return 63 - __builtin_clzl(word); #elif defined(HAVE_LONG_LONG_INT_64) return 63 - __builtin_clzll(word); #else #error must have a working 64-bit integer datatype #endif /* HAVE_LONG_INT_64 */ #elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64)) unsigned long result; bool non_zero; //Assert(word != 0); non_zero = _BitScanReverse64(&result, word); return (int) result; #else int shift = 64 - 8; //Assert(word != 0); while ((word >> shift) == 0) shift -= 8; return shift + pg_leftmost_one_pos[(word >> shift) & 255]; #endif /* HAVE__BUILTIN_CLZ */ } /* * pg_rightmost_one_pos32 * Returns the position of the least significant set bit in "word", * measured from the least significant bit. word must not be 0. */ static inline int pg_rightmost_one_pos32(uint32 word) { #ifdef HAVE__BUILTIN_CTZ //Assert(word != 0); return __builtin_ctz(word); #elif defined(_MSC_VER) unsigned long result; bool non_zero; //Assert(word != 0); non_zero = _BitScanForward(&result, word); return (int) result; #else int result = 0; //Assert(word != 0); while ((word & 255) == 0) { word >>= 8; result += 8; } result += pg_rightmost_one_pos[word & 255]; return result; #endif /* HAVE__BUILTIN_CTZ */ } /* * pg_rightmost_one_pos64 * As above, but for a 64-bit word. */ static inline int pg_rightmost_one_pos64(uint64 word) { #ifdef HAVE__BUILTIN_CTZ //Assert(word != 0); #if defined(HAVE_LONG_INT_64) return __builtin_ctzl(word); #elif defined(HAVE_LONG_LONG_INT_64) return __builtin_ctzll(word); #else #error must have a working 64-bit integer datatype #endif /* HAVE_LONG_INT_64 */ #elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64)) unsigned long result; bool non_zero; //Assert(word != 0); non_zero = _BitScanForward64(&result, word); return (int) result; #else int result = 0; //Assert(word != 0); while ((word & 255) == 0) { word >>= 8; result += 8; } result += pg_rightmost_one_pos[word & 255]; return result; #endif /* HAVE__BUILTIN_CTZ */ } /* * pg_nextpower2_32 * Returns the next higher power of 2 above 'num', or 'num' if it's * already a power of 2. * * 'num' mustn't be 0 or be above PG_UINT32_MAX / 2 + 1. */ static inline uint32 pg_nextpower2_32(uint32 num) { //Assert(num > 0 && num <= PG_UINT32_MAX / 2 + 1); /* * A power 2 number has only 1 bit set. Subtracting 1 from such a number * will turn on all previous bits resulting in no common bits being set * between num and num-1. */ if ((num & (num - 1)) == 0) return num; /* already power 2 */ return ((uint32) 1) << (pg_leftmost_one_pos32(num) + 1); } /* * pg_nextpower2_64 * Returns the next higher power of 2 above 'num', or 'num' if it's * already a power of 2. * * 'num' mustn't be 0 or be above PG_UINT64_MAX / 2 + 1. */ static inline uint64 pg_nextpower2_64(uint64 num) { //Assert(num > 0 && num <= PG_UINT64_MAX / 2 + 1); /* * A power 2 number has only 1 bit set. Subtracting 1 from such a number * will turn on all previous bits resulting in no common bits being set * between num and num-1. */ if ((num & (num - 1)) == 0) return num; /* already power 2 */ return ((uint64) 1) << (pg_leftmost_one_pos64(num) + 1); } /* * pg_prevpower2_32 * Returns the next lower power of 2 below 'num', or 'num' if it's * already a power of 2. * * 'num' mustn't be 0. */ static inline uint32 pg_prevpower2_32(uint32 num) { return ((uint32) 1) << pg_leftmost_one_pos32(num); } /* * pg_prevpower2_64 * Returns the next lower power of 2 below 'num', or 'num' if it's * already a power of 2. * * 'num' mustn't be 0. */ static inline uint64 pg_prevpower2_64(uint64 num) { return ((uint64) 1) << pg_leftmost_one_pos64(num); } /* * pg_ceil_log2_32 * Returns equivalent of ceil(log2(num)) */ static inline uint32 pg_ceil_log2_32(uint32 num) { if (num < 2) return 0; else return pg_leftmost_one_pos32(num - 1) + 1; } /* * pg_ceil_log2_64 * Returns equivalent of ceil(log2(num)) */ static inline uint64 pg_ceil_log2_64(uint64 num) { if (num < 2) return 0; else return pg_leftmost_one_pos64(num - 1) + 1; } /* * With MSVC on x86_64 builds, try using native popcnt instructions via the * __popcnt and __popcnt64 intrinsics. These don't work the same as GCC's * __builtin_popcount* intrinsic functions as they always emit popcnt * instructions. */ #if defined(_MSC_VER) && defined(_M_AMD64) #define HAVE_X86_64_POPCNTQ #endif /* * On x86_64, we can use the hardware popcount instruction, but only if * we can verify that the CPU supports it via the cpuid instruction. * * Otherwise, we fall back to a hand-rolled implementation. */ #ifdef HAVE_X86_64_POPCNTQ #if defined(HAVE__GET_CPUID) || defined(HAVE__CPUID) #define TRY_POPCNT_FAST 1 #endif #endif #ifdef TRY_POPCNT_FAST /* Attempt to use the POPCNT instruction, but perform a runtime check first */ extern PGDLLIMPORT int (*pg_popcount32) (uint32 word); extern PGDLLIMPORT int (*pg_popcount64) (uint64 word); extern PGDLLIMPORT uint64 (*pg_popcount_optimized) (const char *buf, int bytes); extern PGDLLIMPORT uint64 (*pg_popcount_masked_optimized) (const char *buf, int bytes, bits8 mask); /* * We can also try to use the AVX-512 popcount instruction on some systems. * The implementation of that is located in its own file because it may * require special compiler flags that we don't want to apply to any other * files. */ #ifdef USE_AVX512_POPCNT_WITH_RUNTIME_CHECK extern bool pg_popcount_avx512_available(void); extern uint64 pg_popcount_avx512(const char *buf, int bytes); extern uint64 pg_popcount_masked_avx512(const char *buf, int bytes, bits8 mask); #endif #else /* Use a portable implementation -- no need for a function pointer. */ static inline int pg_popcount32_slow(uint32 word) { #ifdef HAVE__BUILTIN_POPCOUNT return __builtin_popcount(word); #else /* !HAVE__BUILTIN_POPCOUNT */ int result = 0; while (word != 0) { result += pg_number_of_ones[word & 255]; word >>= 8; } return result; #endif /* HAVE__BUILTIN_POPCOUNT */ } /* * pg_popcount64_slow * Return the number of 1 bits set in word */ static inline int pg_popcount64_slow(uint64 word) { #ifdef HAVE__BUILTIN_POPCOUNT #if defined(HAVE_LONG_INT_64) return __builtin_popcountl(word); #elif defined(HAVE_LONG_LONG_INT_64) return __builtin_popcountll(word); #else #error must have a working 64-bit integer datatype #endif #else /* !HAVE__BUILTIN_POPCOUNT */ int result = 0; while (word != 0) { result += pg_number_of_ones[word & 255]; word >>= 8; } return result; #endif /* HAVE__BUILTIN_POPCOUNT */ } /* * pg_popcount_slow * Returns the number of 1-bits in buf */ static uint64 pg_popcount_slow(const char *buf, int bytes) { uint64 popcnt = 0; #if SIZEOF_VOID_P >= 8 /* Process in 64-bit chunks if the buffer is aligned. */ if (buf == (const char *) TYPEALIGN(8, buf)) { const uint64 *words = (const uint64 *) buf; while (bytes >= 8) { popcnt += pg_popcount64_slow(*words++); bytes -= 8; } buf = (const char *) words; } #else /* Process in 32-bit chunks if the buffer is aligned. */ if (buf == (const char *) TYPEALIGN(4, buf)) { const uint32 *words = (const uint32 *) buf; while (bytes >= 4) { popcnt += pg_popcount32_slow(*words++); bytes -= 4; } buf = (const char *) words; } #endif /* Process any remaining bytes */ while (bytes--) popcnt += pg_number_of_ones[(unsigned char) *buf++]; return popcnt; } /* * pg_popcount_masked_slow * Returns the number of 1-bits in buf after applying the mask to each byte */ static uint64 pg_popcount_masked_slow(const char *buf, int bytes, bits8 mask) { uint64 popcnt = 0; #if SIZEOF_VOID_P >= 8 /* Process in 64-bit chunks if the buffer is aligned */ uint64 maskv = ~UINT64CONST(0) / 0xFF * mask; if (buf == (const char *) TYPEALIGN(8, buf)) { const uint64 *words = (const uint64 *) buf; while (bytes >= 8) { popcnt += pg_popcount64_slow(*words++ & maskv); bytes -= 8; } buf = (const char *) words; } #else /* Process in 32-bit chunks if the buffer is aligned. */ uint32 maskv = ~((uint32) 0) / 0xFF * mask; if (buf == (const char *) TYPEALIGN(4, buf)) { const uint32 *words = (const uint32 *) buf; while (bytes >= 4) { popcnt += pg_popcount32_slow(*words++ & maskv); bytes -= 4; } buf = (const char *) words; } #endif /* Process any remaining bytes */ while (bytes--) popcnt += pg_number_of_ones[(unsigned char) *buf++ & mask]; return popcnt; } int pg_popcount32(uint32 word) { return pg_popcount32_slow(word); } int pg_popcount64(uint64 word) { return pg_popcount64_slow(word); } /* * pg_popcount_optimized * Returns the number of 1-bits in buf */ uint64 pg_popcount_optimized(const char *buf, int bytes) { return pg_popcount_slow(buf, bytes); } /* * pg_popcount_masked_optimized * Returns the number of 1-bits in buf after applying the mask to each byte */ uint64 pg_popcount_masked_optimized(const char *buf, int bytes, bits8 mask) { return pg_popcount_masked_slow(buf, bytes, mask); } extern uint64 pg_popcount_optimized(const char *buf, int bytes); extern uint64 pg_popcount_masked_optimized(const char *buf, int bytes, bits8 mask); #endif /* TRY_POPCNT_FAST */ /* * Returns the number of 1-bits in buf. * * If there aren't many bytes to process, the function call overhead of the * optimized versions isn't worth taking, so we inline a loop that consults * pg_number_of_ones in that case. If there are many bytes to process, we * accept the function call overhead because the optimized versions are likely * to be faster. */ static inline uint64 pg_popcount(const char *buf, int bytes) { /* * We set the threshold to the point at which we'll first use special * instructions in the optimized version. */ #if SIZEOF_VOID_P >= 8 int threshold = 8; #else int threshold = 4; #endif if (bytes < threshold) { uint64 popcnt = 0; while (bytes--) popcnt += pg_number_of_ones[(unsigned char) *buf++]; return popcnt; } return pg_popcount_optimized(buf, bytes); } /* * Returns the number of 1-bits in buf after applying the mask to each byte. * * Similar to pg_popcount(), we only take on the function pointer overhead when * it's likely to be faster. */ static inline uint64 pg_popcount_masked(const char *buf, int bytes, bits8 mask) { /* * We set the threshold to the point at which we'll first use special * instructions in the optimized version. */ #if SIZEOF_VOID_P >= 8 int threshold = 8; #else int threshold = 4; #endif if (bytes < threshold) { uint64 popcnt = 0; while (bytes--) popcnt += pg_number_of_ones[(unsigned char) *buf++ & mask]; return popcnt; } return pg_popcount_masked_optimized(buf, bytes, mask); } /* * Rotate the bits of "word" to the right/left by n bits. */ static inline uint32 pg_rotate_right32(uint32 word, int n) { return (word >> n) | (word << (32 - n)); } static inline uint32 pg_rotate_left32(uint32 word, int n) { return (word << n) | (word >> (32 - n)); } /* size_t variants of the above, as required */ #if SIZEOF_SIZE_T == 4 #define pg_leftmost_one_pos_size_t pg_leftmost_one_pos32 #define pg_nextpower2_size_t pg_nextpower2_32 #define pg_prevpower2_size_t pg_prevpower2_32 #else #define pg_leftmost_one_pos_size_t pg_leftmost_one_pos64 #define pg_nextpower2_size_t pg_nextpower2_64 #define pg_prevpower2_size_t pg_prevpower2_64 #endif #endif /* PG_BITUTILS_H */ void test_pg_popcount32() { uint32_t test_value = 0b11010110; // binary: 11010110, expected popcount: 5 int expected = 5; int result = pg_popcount32(test_value); if (result == expected) { printf("Test passed: pg_popcount32(%u) = %d\n", test_value, result); Assert(5, result); } else { printf("Test failed: pg_popcount32(%u) = %d, expected %d\n", test_value, result, expected); } } int main() { test_pg_popcount32(); return 0; } chibicc-1.0.23.1/issues/postgres_issue4.c000066400000000000000000000244261505335450300201540ustar00rootroot00000000000000#include #include #include #include #include // Required for offsetof #define PGSTAT_KIND_MIN 1 #define PGSTAT_KIND_MAX 256 /* Maximum ID allowed */ #define PGSTAT_KIND_CUSTOM_MIN 128 #define PGSTAT_KIND_CUSTOM_MAX PGSTAT_KIND_MAX #define PGSTAT_KIND_CUSTOM_SIZE (PGSTAT_KIND_CUSTOM_MAX - PGSTAT_KIND_CUSTOM_MIN + 1) #define PGSTAT_KIND_BUILTIN_SIZE 10 // Size based on the number of elements in pgstat_kind_builtin_infos // Define the dummy callback functions void pgstat_archiver_init_shmem_cb(void *stats) { printf("Archiver init_shmem_cb called with %p\n", stats); } void pgstat_bgwriter_init_shmem_cb(void *stats) { printf("BgWriter init_shmem_cb called with %p\n", stats); } void pgstat_checkpointer_init_shmem_cb(void *stats) { printf("Checkpointer init_shmem_cb called with %p\n", stats); } void pgstat_io_init_shmem_cb(void *stats) { printf("IO init_shmem_cb called with %p\n", stats); } void pgstat_slru_init_shmem_cb(void *stats) { printf("SLRU init_shmem_cb called with %p\n", stats); } void pgstat_wal_init_shmem_cb(void *stats) { printf("WAL init_shmem_cb called with %p\n", stats); } void pgstat_database_flush_cb(void) {} void pgstat_database_reset_timestamp_cb(void) {} void pgstat_relation_flush_cb(void) {} void pgstat_relation_delete_pending_cb(void) {} void pgstat_function_flush_cb(void) {} void pgstat_subscription_flush_cb(void) {} void pgstat_subscription_reset_timestamp_cb(void) {} void pgstat_replslot_reset_timestamp_cb(void) {} void pgstat_replslot_to_serialized_name_cb(void) {} void pgstat_replslot_from_serialized_name_cb(void) {} typedef int PgStat_Kind; typedef int TimestampTz; typedef struct PgStat_EntryRef PgStat_EntryRef; typedef struct PgStat_ShmemControl PgStat_ShmemControl; typedef struct PgStat_HashKey PgStat_HashKey; typedef struct PgStatShared_Common PgStatShared_Common; typedef struct NameData NameData; // Define some dummy structures to satisfy the offsetof macro usage typedef struct PgStatShared_Database { int stats; } PgStatShared_Database; typedef struct PgStatShared_Relation { int stats; } PgStatShared_Relation; typedef struct PgStatShared_Function { int stats; } PgStatShared_Function; typedef struct PgStatShared_ReplSlot { int stats; } PgStatShared_ReplSlot; typedef struct PgStatShared_Subscription { int stats; } PgStatShared_Subscription; typedef struct PgStatShared_Archiver { int stats; } PgStatShared_Archiver; typedef struct PgStatShared_BgWriter { int stats; } PgStatShared_BgWriter; typedef struct PgStatShared_Checkpointer { int stats; } PgStatShared_Checkpointer; typedef struct PgStatShared_IO { int stats; } PgStatShared_IO; typedef struct PgStatShared_SLRU { int stats; } PgStatShared_SLRU; typedef struct PgStatShared_Wal { int stats; } PgStatShared_Wal; typedef struct PgStat_Snapshot { PgStatShared_Archiver archiver; PgStatShared_BgWriter bgwriter; PgStatShared_Checkpointer checkpointer; PgStatShared_IO io; PgStatShared_SLRU slru; PgStatShared_Wal wal; } PgStat_Snapshot; typedef struct PgStat_KindInfo { bool fixed_amount : 1; bool accessed_across_databases : 1; uint32_t shared_size; uint32_t snapshot_ctl_off; uint32_t shared_ctl_off; uint32_t shared_data_off; uint32_t shared_data_len; uint32_t pending_size; bool (*flush_pending_cb)(PgStat_EntryRef *sr, bool nowait); void (*delete_pending_cb)(PgStat_EntryRef *sr); void (*reset_timestamp_cb)(PgStatShared_Common *header, TimestampTz ts); void (*to_serialized_name)(const PgStat_HashKey *key, const PgStatShared_Common *header, NameData *name); bool (*from_serialized_name)(const NameData *name, PgStat_HashKey *key); void (*init_shmem_cb)(void *stats); void (*reset_all_cb)(TimestampTz ts); void (*snapshot_cb)(void); const char *const name; } PgStat_KindInfo; typedef struct PgStat_ShmemControl { void *custom_data[PGSTAT_KIND_CUSTOM_MAX - PGSTAT_KIND_CUSTOM_MIN + 1]; // Added dummy members for fixed amounts PgStatShared_Archiver archiver; PgStatShared_BgWriter bgwriter; PgStatShared_Checkpointer checkpointer; PgStatShared_IO io; PgStatShared_SLRU slru; PgStatShared_Wal wal; } PgStat_ShmemControl; // Updated PgStat_KindInfo array with missing elements static const PgStat_KindInfo pgstat_kind_builtin_infos[PGSTAT_KIND_BUILTIN_SIZE] = { [0] = {0}, // Placeholder for index 0 [1] = { .name = "database", .fixed_amount = false, .accessed_across_databases = true, .shared_size = sizeof(PgStatShared_Database), .shared_data_off = offsetof(PgStatShared_Database, stats), .shared_data_len = sizeof(((PgStatShared_Database *) 0)->stats), .flush_pending_cb = pgstat_database_flush_cb, .reset_timestamp_cb = pgstat_database_reset_timestamp_cb, }, [2] = { .name = "relation", .fixed_amount = false, .shared_size = sizeof(PgStatShared_Relation), .shared_data_off = offsetof(PgStatShared_Relation, stats), .shared_data_len = sizeof(((PgStatShared_Relation *) 0)->stats), .flush_pending_cb = pgstat_relation_flush_cb, .delete_pending_cb = pgstat_relation_delete_pending_cb, }, [3] = { .name = "function", .fixed_amount = false, .shared_size = sizeof(PgStatShared_Function), .shared_data_off = offsetof(PgStatShared_Function, stats), .shared_data_len = sizeof(((PgStatShared_Function *) 0)->stats), .flush_pending_cb = pgstat_function_flush_cb, }, [4] = { .name = "replslot", .fixed_amount = false, .accessed_across_databases = true, .shared_size = sizeof(PgStatShared_ReplSlot), .shared_data_off = offsetof(PgStatShared_ReplSlot, stats), .shared_data_len = sizeof(((PgStatShared_ReplSlot *) 0)->stats), .reset_timestamp_cb = pgstat_replslot_reset_timestamp_cb, .to_serialized_name = pgstat_replslot_to_serialized_name_cb, .from_serialized_name = pgstat_replslot_from_serialized_name_cb, }, [5] = { .name = "subscription", .fixed_amount = false, .accessed_across_databases = true, .shared_size = sizeof(PgStatShared_Subscription), .shared_data_off = offsetof(PgStatShared_Subscription, stats), .shared_data_len = sizeof(((PgStatShared_Subscription *) 0)->stats), .flush_pending_cb = pgstat_subscription_flush_cb, .reset_timestamp_cb = pgstat_subscription_reset_timestamp_cb, }, [6] = { .name = "archiver", .fixed_amount = true, .snapshot_ctl_off = offsetof(PgStat_Snapshot, archiver), .shared_ctl_off = offsetof(PgStat_ShmemControl, archiver), .shared_data_off = offsetof(PgStatShared_Archiver, stats), .shared_data_len = sizeof(((PgStatShared_Archiver *) 0)->stats), .init_shmem_cb = pgstat_archiver_init_shmem_cb, .reset_all_cb = NULL, .snapshot_cb = NULL, }, [7] = { .name = "bgwriter", .fixed_amount = true, .snapshot_ctl_off = offsetof(PgStat_Snapshot, bgwriter), .shared_ctl_off = offsetof(PgStat_ShmemControl, bgwriter), .shared_data_off = offsetof(PgStatShared_BgWriter, stats), .shared_data_len = sizeof(((PgStatShared_BgWriter *) 0)->stats), .init_shmem_cb = pgstat_bgwriter_init_shmem_cb, .reset_all_cb = NULL, .snapshot_cb = NULL, }, [8] = { .name = "checkpointer", .fixed_amount = true, .snapshot_ctl_off = offsetof(PgStat_Snapshot, checkpointer), .shared_ctl_off = offsetof(PgStat_ShmemControl, checkpointer), .shared_data_off = offsetof(PgStatShared_Checkpointer, stats), .shared_data_len = sizeof(((PgStatShared_Checkpointer *) 0)->stats), .init_shmem_cb = pgstat_checkpointer_init_shmem_cb, .reset_all_cb = NULL, .snapshot_cb = NULL, }, [9] = { .name = "io", .fixed_amount = true, .snapshot_ctl_off = offsetof(PgStat_Snapshot, io), .shared_ctl_off = offsetof(PgStat_ShmemControl, io), .shared_data_off = offsetof(PgStatShared_IO, stats), .shared_data_len = sizeof(((PgStatShared_IO *) 0)->stats), .init_shmem_cb = pgstat_io_init_shmem_cb, .reset_all_cb = NULL, .snapshot_cb = NULL, }, }; const PgStat_KindInfo* pgstat_get_kind_info(PgStat_Kind kind) { if (kind >= PGSTAT_KIND_MIN && kind <= PGSTAT_KIND_MAX) return &pgstat_kind_builtin_infos[kind]; return NULL; } bool pgstat_is_kind_builtin(PgStat_Kind kind) { return kind < PGSTAT_KIND_CUSTOM_MIN; } void* ShmemAlloc(size_t size) { return malloc(size); } /* Dummy init_shmem_cb implementation */ void my_init_shmem_cb(void *stats) { printf("Shared memory initialized with size: %p\n", stats); } int main(void) { PgStat_ShmemControl *ctl = malloc(sizeof(PgStat_ShmemControl)); if (ctl == NULL) { perror("Failed to allocate memory for PgStat_ShmemControl"); return EXIT_FAILURE; } printf("======sizeof=%ld\n", sizeof(PgStatShared_Archiver)); for (PgStat_Kind kind = PGSTAT_KIND_MIN; kind <= PGSTAT_KIND_MAX; kind++) { const PgStat_KindInfo *kind_info = pgstat_get_kind_info(kind); char *ptr = NULL; if (kind_info == NULL) { printf("No kind info found for kind %d\n", kind); continue; } if (kind_info->fixed_amount) { if (pgstat_is_kind_builtin(kind)) { ptr = ((char *)ctl) + kind_info->shared_ctl_off; } else { int idx = kind - PGSTAT_KIND_CUSTOM_MIN; ctl->custom_data[idx] = ShmemAlloc(kind_info->shared_size); if (ctl->custom_data[idx] == NULL) { perror("Failed to allocate memory for custom_data"); continue; } ptr = ctl->custom_data[idx]; } printf("Kind %d - Offset: %zu, Pointer: %p\n", kind, kind_info->shared_ctl_off, ptr); if (kind_info->init_shmem_cb) { kind_info->init_shmem_cb(ptr); } else { printf("init_shmem_cb is NULL for kind %d %ld\n", kind, kind_info->shared_size); } } } printf("Initialization complete\n"); free(ctl); return 0; } chibicc-1.0.23.1/issues/postgres_struct_func1.c000066400000000000000000000007551505335450300213570ustar00rootroot00000000000000#include #include struct MyStruct { void (*myFunc)(void *, const void *, size_t); }; // Initialize the struct with memcpy assigned to the function pointer struct MyStruct myStruct = { .myFunc = memcpy }; int main() { // Use the function pointer char src[20] = "Hello, World!"; char dest[20]; myStruct.myFunc(dest, src, strlen(src) + 1); printf("Copied string: %s\n", dest); // Should print: "Copied string: Hello, World!" return 0; } chibicc-1.0.23.1/issues/postgres_struct_func2.c000066400000000000000000000007551505335450300213600ustar00rootroot00000000000000#include #include struct MyStruct { void (*myFunc)(void *, const void *, size_t); }; // Initialize the struct with memcpy assigned to the function pointer struct MyStruct myStruct = { .myFunc = memcpy }; int main() { // Use the function pointer char src[20] = "Hello, World!"; char dest[20]; myStruct.myFunc(dest, src, strlen(src) + 1); printf("Copied string: %s\n", dest); // Should print: "Copied string: Hello, World!" return 0; } chibicc-1.0.23.1/issues/postgres_struct_func3.c000066400000000000000000000032141505335450300213520ustar00rootroot00000000000000#include #include // Define the functions with the required signatures void pgstat_archiver_init_shmem_cb(void *stats) { printf("Archiver init_shmem_cb called with %p\n", stats); } // Define a struct with two function pointers struct MyStruct { void (*copy_func)(void *dest, const void *src, size_t n); // Function like memcpy void (*init_shmem_cb)(void *stats); // Function for initializing shared memory }; // Initialize a static const array of MyStruct with two elements static const struct MyStruct myArray[2] = { [0] = { .copy_func = memcpy, // Only initialize the first function // init_shmem_cb is not initialized }, [1] = { // copy_func is not initialized .init_shmem_cb = pgstat_archiver_init_shmem_cb, // Only initialize the second function } }; int main() { char src[] = "Hello, world!"; char dest[50]; void *dummyStats = (void *)0x1234; // Some dummy stats pointer // Loop through the array and call the appropriate function for (int i = 0; i < 2; i++) { if (myArray[i].copy_func) { // Call the first function if it's initialized myArray[i].copy_func(dest, src, sizeof(src)); printf("Array element %d - Copy result: %s\n", i + 1, dest); } else if (myArray[i].init_shmem_cb) { // Call the second function if it's initialized myArray[i].init_shmem_cb(dummyStats); printf("Array element %d - Called init_shmem_cb\n", i + 1); } else { printf("Array element %d - No function initialized\n", i + 1); } } return 0; } chibicc-1.0.23.1/issues/promote.c000066400000000000000000000026461505335450300164770ustar00rootroot00000000000000#include #include #include // Your storebuffer function as provided static int storebuffer(int output, FILE *data) { char **buffer = (char **)data; unsigned char outc = (unsigned char)output; **buffer = outc; (*buffer)++; return outc; // act like fputc() } // Dummy dprintf_formatf replacement for testing (just calls vsnprintf internally) int dprintf_formatf(char **buffer_ptr, int (*output_func)(int, FILE *), const char *fmt, va_list ap) { // We'll just format into a temp buffer, then call output_func per char: char tmp[1024]; int len = vsnprintf(tmp, sizeof(tmp), fmt, ap); if (len < 0) return len; for (int i = 0; i < len; i++) { output_func(tmp[i], (FILE *)buffer_ptr); } return len; } int curl_msprintf(char *buffer, const char *format, ...) { va_list ap_save; int retcode; va_start(ap_save, format); retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); va_end(ap_save); *buffer = 0; // Null-terminate the string return retcode; } int main(void) { char buf[256]; unsigned short val = 65535; int len = curl_msprintf(buf, "Value: %hu", val); printf("Formatted length: %d\n", len); printf("Formatted string: '%s'\n", buf); if (len > 0 && strcmp(buf, "Value: 65535") == 0) { printf("Test passed!\n"); } else { printf("Test failed!\n"); } return 0; } chibicc-1.0.23.1/issues/redirect.c000066400000000000000000000012351505335450300166040ustar00rootroot00000000000000#include #include # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) # define __ASMNAME2(prefix, cname) __STRING (prefix) cname #define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) // extern int __REDIRECT (fscanf, (FILE *__restrict __stream, // const char *__restrict __format, ...), // __isoc99_fscanf) __wur; #define TEST 10 #define TEST2 10 int toto(int a, int b) { return a + b; } // main function - // where the execution of program begins int main() { static_assert(TEST == 10, "TEST is not 10"); // prints hello world //printf("Hello World\n"); return 0; }chibicc-1.0.23.1/issues/segfault.c000066400000000000000000000035641505335450300166240ustar00rootroot00000000000000#include #include #include #include #include #include #include void enable_core_dump() { struct rlimit rl; rl.rlim_cur = RLIM_INFINITY; rl.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) == -1) { perror("setrlimit"); exit(EXIT_FAILURE); } } void segfault_handler(int signum) { printf("Segmentation fault (signal %d)\n", signum); abort(); // Generate a core dump } void setup_signal_handlers() { signal(SIGSEGV, segfault_handler); } int main() { enable_core_dump(); setup_signal_handlers(); pid_t pid = fork(); if (pid == -1) { perror("fork"); exit(EXIT_FAILURE); } if (pid == 0) { // Child process code char *path = "~/postgres/tmp_install/usr/local/pgsql/bin:~/postgres:$PATH"; char *ld_library_path = "~/postgres/tmp_install/usr/local/pgsql/lib:$LD_LIBRARY_PATH"; char *initdb_template = "~/postgres/tmp_install/initdb-template"; char *argv[] = { "initdb", "-A", "trust", "-N", "--no-instructions", "--no-locale", initdb_template, NULL }; char *envp[] = { path, ld_library_path, NULL }; execvp(argv[0], argv); perror("execvp"); // execvp only returns on error exit(EXIT_FAILURE); } else { waitpid(pid, NULL, 0); // Wait for the child process to stop // Attach gdb to the child process char cmd[256]; snprintf(cmd, sizeof(cmd), "gdb -ex 'attach %d' -ex 'set pagination off'-ex 'set confirm off' -ex 'continue' -ex 'detach' -ex 'quit'", pid); system(cmd); waitpid(pid, NULL, 0); // Wait for the child process to finish } return 0; } chibicc-1.0.23.1/issues/segfault2.c000066400000000000000000000036121505335450300167000ustar00rootroot00000000000000#include #include #include #include #include #include #include void enable_core_dump() { struct rlimit rl; rl.rlim_cur = RLIM_INFINITY; rl.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) == -1) { perror("setrlimit"); exit(EXIT_FAILURE); } } void segfault_handler(int signum) { printf("Segmentation fault (signal %d)\n", signum); abort(); // Generate a core dump } void setup_signal_handlers() { signal(SIGSEGV, segfault_handler); } int main() { enable_core_dump(); setup_signal_handlers(); pid_t pid = fork(); if (pid == -1) { perror("fork"); exit(EXIT_FAILURE); } if (pid == 0) { ptrace(PTRACE_TRACEME, 0, NULL, NULL); kill(getpid(), SIGSTOP); // Child process code char *path = "~/postgres/tmp_install/usr/local/pgsql/bin:~/postgres:$PATH"; char *ld_library_path = "~/postgres/tmp_install/usr/local/pgsql/lib:$LD_LIBRARY_PATH"; char *initdb_template = "~/postgres/tmp_install/initdb-template"; char *argv[] = { "initdb", "-A", "trust", "-N", "--no-instructions", "--no-locale", initdb_template, NULL }; char *envp[] = { path, ld_library_path, NULL }; execvp(argv[0], argv); perror("execvp"); // execvp only returns on error exit(EXIT_FAILURE); } else { waitpid(pid, NULL, 0); // Wait for the child process to stop char cmd[256]; snprintf(cmd, sizeof(cmd), "gdb -p %d -ex 'set pagination off'-ex 'set confirm off' -ex 'continue' -ex 'detach' -ex 'quit'", pid); system(cmd); ptrace(PTRACE_CONT, pid, NULL, NULL); // Continue the child process } return 0; } chibicc-1.0.23.1/issues/setjmp.c000066400000000000000000000006751505335450300163140ustar00rootroot00000000000000#include "test.h" #include #include jmp_buf my_jump_buffer; noreturn void foo(int status) { printf("foo(%d) called\n", status); longjmp(my_jump_buffer, status + 1); // will return status+1 out of setjmp } int main(void) { volatile int count = 0; // modified local vars in setjmp scope must be volatile if (setjmp(my_jump_buffer) != 5) // compare against constant in an if foo(++count); }chibicc-1.0.23.1/issues/sizeof_vla.c000066400000000000000000000002651505335450300171460ustar00rootroot00000000000000#include #include "test.h" struct { char c; char arr[]; } s = {1,2,3}; int main(void) { printf("%zu\n", sizeof(s)); ASSERT(1, sizeof(s)); return 0; }chibicc-1.0.23.1/issues/struct5.c000066400000000000000000000046331505335450300164210ustar00rootroot00000000000000// This program is designed to test some arm64-specific things, such as the // calling convention, but should give the same results on any architecture. #include #include #include struct hfa21 { double a; } hfa21 = { 21.1 }; struct hfa22 { double a, b; } hfa22 = { 22.1, 22.2 }; struct hfa23 { double a, b, c; } hfa23 = { 23.1, 23.2, 23.3 }; struct hfa24 { double a, b, c, d; } hfa24 = { 24.1, 24.2, 24.3, 24.4 }; struct hfa31 { long double a; } hfa31 = { 31.1 }; struct hfa32 { long double a, b; } hfa32 = { 32.1, 32.2 }; struct hfa33 { long double a, b, c; } hfa33 = { 33.1, 33.2, 33.3 }; struct hfa34 { long double a, b, c, d; } hfa34 = { 34.1, 34.2, 34.3, 34.4 }; int match(const char **s, const char *f) { const char *p = *s; for (p = *s; *f && *f == *p; f++, p++) ; if (!*f) { *s = p - 1; return 1; } return 0; } void myprintf(const char *format, ...) { const char *s; va_list ap; va_start(ap, format); for (s = format; *s; s++) { if (match(&s, "%hfa21")) { struct hfa21 x = va_arg(ap, struct hfa21); printf("%.1f,%.1f", x.a, x.a); } else if (match(&s, "%hfa22")) { struct hfa22 x = va_arg(ap, struct hfa22); printf("%.1f,%.1f", x.a, x.b); } else if (match(&s, "%hfa23")) { struct hfa23 x = va_arg(ap, struct hfa23); printf("%.1f,%.1f", x.a, x.c); } else if (match(&s, "%hfa24")) { struct hfa24 x = va_arg(ap, struct hfa24); printf("%.1f,%.1f", x.a, x.d); } else if (match(&s, "%hfa31")) { struct hfa31 x = va_arg(ap, struct hfa31); printf("%.1Lf,%.1Lf", x.a, x.a); } else if (match(&s, "%hfa32")) { struct hfa32 x = va_arg(ap, struct hfa32); printf("%.1Lf,%.1Lf", x.a, x.b); } else if (match(&s, "%hfa33")) { struct hfa33 x = va_arg(ap, struct hfa33); printf("%.1Lf,%.1Lf", x.a, x.c); } else if (match(&s, "%hfa34")) { struct hfa34 x = va_arg(ap, struct hfa34); printf("%.1Lf,%.1Lf", x.a, x.d); } else putchar(*s); } putchar('\n'); } int main() { printf("stdarg:\n"); myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21", hfa24, hfa22, hfa21, hfa21, hfa21, hfa21); return 0; }chibicc-1.0.23.1/issues/switch2.c000066400000000000000000000027661505335450300164000ustar00rootroot00000000000000#include #include #include #include "c.h" static inline void store_att_byval(void *T, Datum newdatum, int attlen) { switch (attlen) { case sizeof(char): *(char *) T = DatumGetChar(newdatum); break; case sizeof(int16): *(int16 *) T = DatumGetInt16(newdatum); break; case sizeof(int32): *(int32 *) T = DatumGetInt32(newdatum); break; #if SIZEOF_DATUM == 8 case sizeof(Datum): *(Datum *) T = newdatum; break; #endif default: printf("unsupported byval length: %d", attlen); } } int main() { char c = 0; int16 i16 = 0; int32_t i32 = 0; Datum d = 0; Datum val_char = (Datum) 'A'; Datum val_i16 = (Datum) 12345; Datum val_i32 = (Datum) 67890; Datum val_d = (Datum) 0x123456789ABCDEF0; store_att_byval(&c, val_char, sizeof(char)); assert(c == 'A'); printf("char stored ok: %c\n", c); store_att_byval(&i16, val_i16, sizeof(int16)); assert(i16 == 12345); printf("int16 stored ok: %d\n", i16); store_att_byval(&i32, val_i32, sizeof(int32_t)); assert(i32 == 67890); printf("int32 stored ok: %d\n", i32); #if SIZEOF_DATUM == 8 store_att_byval(&d, val_d, sizeof(Datum)); assert(d == val_d); printf("Datum stored ok: 0x%lx\n", (unsigned long) d); #endif printf("All store_att_byval tests passed.\n"); printf("sizeof(char) = %zu\n", sizeof(char)); printf("sizeof(short) = %zu\n", sizeof(short)); printf("sizeof(int16_t) = %zu\n", sizeof(int16_t)); printf("sizeof(int16) = %zu\n", sizeof(int16)); return 0; } chibicc-1.0.23.1/issues/testctx.c000066400000000000000000000000131505335450300164720ustar00rootroot00000000000000int zz = 10chibicc-1.0.23.1/issues/vfork.c000066400000000000000000000010471505335450300161330ustar00rootroot00000000000000#include #include #include int main(void) { pid_t pid = 0; int errpipe = 0; // simulate parent stack variable for error reporting pid = vfork(); if (pid < 0) { perror("vfork"); return 1; } if (pid == 0) { // child // // safe write to parent stack variable errpipe = 123; return 0; // child exits safely } // parent reads updated value printf("errpipe = %d\n", errpipe); printf("OK\n"); return 0; } chibicc-1.0.23.1/issues/vla_fail.c000066400000000000000000000003271505335450300165610ustar00rootroot00000000000000#include int main(void) { unsigned int k = sizeof("z"); union { char b[k]; } w = { .b = "z" }; assert(w.b[0] == 'z' && w.b[1] == '\0'); return 0; }chibicc-1.0.23.1/issues/vlc_arrays.h000066400000000000000000000522131505335450300171570ustar00rootroot00000000000000/***************************************************************************** * vlc_arrays.h : Arrays and data structures handling ***************************************************************************** * Copyright (C) 1999-2004 VLC authors and VideoLAN * * Authors: Samuel Hocevar * Clément Stenac * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_ARRAYS_H_ #define VLC_ARRAYS_H_ /** * \file * This file defines functions, structures and macros for handling arrays in vlc */ /* realloc() that never fails *if* downsizing */ static inline void *realloc_down( void *ptr, size_t size ) { void *ret = realloc( ptr, size ); return ret ? ret : ptr; } /** * This wrapper around realloc() will free the input pointer when * realloc() returns NULL. The use case ptr = realloc(ptr, newsize) will * cause a memory leak when ptr pointed to a heap allocation before, * leaving the buffer allocated but unreferenced. vlc_realloc() is a * drop-in replacement for that use case (and only that use case). */ static inline void *realloc_or_free( void *p, size_t sz ) { void *n = realloc(p,sz); if( !n ) free(p); return n; } #define TAB_INIT( count, tab ) \ do { \ (count) = 0; \ (tab) = NULL; \ } while(0) #define TAB_CLEAN( count, tab ) \ do { \ free( tab ); \ (count)= 0; \ (tab)= NULL; \ } while(0) #define TAB_APPEND_CAST( cast, count, tab, p ) \ do { \ if( (count) > 0 ) \ (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \ else \ (tab) = cast malloc( sizeof( *(tab) ) ); \ if( !(tab) ) abort(); \ (tab)[count] = (p); \ (count)++; \ } while(0) #define TAB_APPEND( count, tab, p ) \ TAB_APPEND_CAST( , count, tab, p ) #define TAB_FIND( count, tab, p, idx ) \ do { \ for( (idx) = 0; (idx) < (count); (idx)++ ) \ if( (tab)[(idx)] == (p) ) \ break; \ if( (idx) >= (count) ) \ (idx) = -1; \ } while(0) #define TAB_ERASE( count, tab, index ) \ do { \ if( (count) > 1 ) \ memmove( (tab) + (index), \ (tab) + (index) + 1, \ ((count) - (index) - 1 ) * sizeof( *(tab) ) );\ (count)--; \ if( (count) == 0 ) \ { \ free( tab ); \ (tab) = NULL; \ } \ } while(0) #define TAB_REMOVE( count, tab, p ) \ do { \ int i_index; \ TAB_FIND( count, tab, p, i_index ); \ if( i_index >= 0 ) \ TAB_ERASE( count, tab, i_index ); \ } while(0) #define TAB_INSERT_CAST( cast, count, tab, p, index ) do { \ if( (count) > 0 ) \ (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \ else \ (tab) = cast malloc( sizeof( *(tab) ) ); \ if( !(tab) ) abort(); \ if( (count) - (index) > 0 ) \ memmove( (tab) + (index) + 1, \ (tab) + (index), \ ((count) - (index)) * sizeof( *(tab) ) );\ (tab)[(index)] = (p); \ (count)++; \ } while(0) #define TAB_INSERT( count, tab, p, index ) \ TAB_INSERT_CAST( , count, tab, p, index ) /** * Binary search in a sorted array. The key must be comparable by < and > * \param entries array of entries * \param count number of entries * \param elem key to check within an entry (like .id, or ->i_id) * \param zetype type of the key * \param key value of the key * \param answer index of answer within the array. -1 if not found */ #define BSEARCH( entries, count, elem, zetype, key, answer ) \ do { \ int low = 0, high = count - 1; \ answer = -1; \ while( low <= high ) {\ int mid = ((unsigned int)low + (unsigned int)high) >> 1;\ zetype mid_val = entries[mid] elem;\ if( mid_val < key ) \ low = mid + 1; \ else if ( mid_val > key ) \ high = mid -1; \ else \ { \ answer = mid; break; \ }\ } \ } while(0) /************************************************************************ * Dynamic arrays with progressive allocation ************************************************************************/ /* Internal functions */ #define _ARRAY_ALLOC(array, newsize) { \ (array).i_alloc = newsize; \ (array).p_elems = realloc( (array).p_elems, (array).i_alloc * \ sizeof(*(array).p_elems) ); \ if( !(array).p_elems ) abort(); \ } #define _ARRAY_GROW1(array) { \ if( (array).i_alloc < 10 ) \ _ARRAY_ALLOC(array, 10 ) \ else if( (array).i_alloc == (array).i_size ) \ _ARRAY_ALLOC(array, (int)((array).i_alloc * 1.5) ) \ } #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* API */ #define DECL_ARRAY(type) struct { \ int i_alloc; \ int i_size; \ type *p_elems; \ } #define TYPEDEF_ARRAY(type, name) typedef DECL_ARRAY(type) name; #define ARRAY_INIT(array) \ do { \ (array).i_alloc = 0; \ (array).i_size = 0; \ (array).p_elems = NULL; \ } while(0) #define ARRAY_RESET(array) \ do { \ (array).i_alloc = 0; \ (array).i_size = 0; \ free( (array).p_elems ); (array).p_elems = NULL; \ } while(0) #define ARRAY_APPEND(array, elem) \ do { \ _ARRAY_GROW1(array); \ (array).p_elems[(array).i_size] = elem; \ (array).i_size++; \ } while(0) #define ARRAY_INSERT(array,elem,pos) \ do { \ _ARRAY_GROW1(array); \ if( (array).i_size - (pos) ) { \ memmove( (array).p_elems + (pos) + 1, (array).p_elems + (pos), \ ((array).i_size-(pos)) * sizeof(*(array).p_elems) ); \ } \ (array).p_elems[pos] = elem; \ (array).i_size++; \ } while(0) #define _ARRAY_SHRINK(array) { \ if( (array).i_size > 10 && (array).i_size < (int)((array).i_alloc / 1.5) ) { \ _ARRAY_ALLOC(array, (array).i_size + 5); \ } \ } #define ARRAY_FIND(array, p, idx) \ TAB_FIND((array).i_size, (array).p_elems, p, idx) #define ARRAY_REMOVE(array,pos) \ do { \ if( (array).i_size - (pos) - 1 ) \ { \ memmove( (array).p_elems + (pos), (array).p_elems + (pos) + 1, \ ( (array).i_size - (pos) - 1 ) *sizeof(*(array).p_elems) );\ } \ (array).i_size--; \ _ARRAY_SHRINK(array); \ } while(0) #define ARRAY_VAL(array, pos) array.p_elems[pos] #define ARRAY_BSEARCH(array, elem, zetype, key, answer) \ BSEARCH( (array).p_elems, (array).i_size, elem, zetype, key, answer) /* append ##item to index variable name to avoid variable shadowing warnings for * nested loops */ #define ARRAY_FOREACH(item, array) \ for (int array_index_##item = 0; \ array_index_##item < (array).i_size && \ ((item) = (array).p_elems[array_index_##item], 1); \ ++array_index_##item) /************************************************************************ * Dynamic arrays with progressive allocation (Preferred API) ************************************************************************/ typedef struct vlc_array_t { size_t i_count; void ** pp_elems; } vlc_array_t; static inline void vlc_array_init( vlc_array_t * p_array ) { p_array->i_count = 0; p_array->pp_elems = NULL; } static inline void vlc_array_clear( vlc_array_t * p_array ) { free( p_array->pp_elems ); vlc_array_init( p_array ); } /* Read */ static inline size_t vlc_array_count( vlc_array_t * p_array ) { return p_array->i_count; } #ifndef __cplusplus # define vlc_array_item_at_index(ar, idx) \ _Generic((ar), \ const vlc_array_t *: ((ar)->pp_elems[idx]), \ vlc_array_t *: ((ar)->pp_elems[idx])) #else static inline void *vlc_array_item_at_index( vlc_array_t *ar, size_t idx ) { return ar->pp_elems[idx]; } static inline const void *vlc_array_item_at_index( const vlc_array_t *ar, size_t idx ) { return ar->pp_elems[idx]; } #endif static inline ssize_t vlc_array_index_of_item( const vlc_array_t *ar, const void *elem ) { for( size_t i = 0; i < ar->i_count; i++ ) { if( ar->pp_elems[i] == elem ) return i; } return -1; } /* Write */ static inline int vlc_array_insert( vlc_array_t *ar, void *elem, int idx ) { void **pp = (void **)realloc( ar->pp_elems, sizeof( void * ) * (ar->i_count + 1) ); if( unlikely(pp == NULL) ) return -1; size_t tail = ar->i_count - idx; if( tail > 0 ) memmove( pp + idx + 1, pp + idx, sizeof( void * ) * tail ); pp[idx] = elem; ar->i_count++; ar->pp_elems = pp; return 0; } static inline void vlc_array_insert_or_abort( vlc_array_t *ar, void *elem, int idx ) { if( vlc_array_insert( ar, elem, idx ) ) abort(); } static inline int vlc_array_append( vlc_array_t *ar, void *elem ) { void **pp = (void **)realloc( ar->pp_elems, sizeof( void * ) * (ar->i_count + 1) ); if( unlikely(pp == NULL) ) return -1; pp[ar->i_count++] = elem; ar->pp_elems = pp; return 0; } static inline void vlc_array_append_or_abort( vlc_array_t *ar, void *elem ) { if( vlc_array_append( ar, elem ) != 0 ) abort(); } static inline void vlc_array_remove( vlc_array_t *ar, size_t idx ) { void **pp = ar->pp_elems; size_t tail = ar->i_count - idx - 1; if( tail > 0 ) memmove( pp + idx, pp + idx + 1, sizeof( void * ) * tail ); ar->i_count--; if( ar->i_count > 0 ) { pp = (void **)realloc( pp, sizeof( void * ) * ar->i_count ); if( likely(pp != NULL) ) ar->pp_elems = pp; } else { free( pp ); ar->pp_elems = NULL; } } /************************************************************************ * Dictionaries ************************************************************************/ /* This function is not intended to be crypto-secure, we only want it to be * fast and not suck too much. This one is pretty fast and did 0 collisions * in wenglish's dictionary. */ static inline uint64_t DictHash( const char *psz_string, int hashsize ) { uint64_t i_hash = 0; if( psz_string ) { while( *psz_string ) { i_hash += *psz_string++; i_hash += i_hash << 10; i_hash ^= i_hash >> 8; } } return i_hash % hashsize; } typedef struct vlc_dictionary_entry_t { char * psz_key; void * p_value; struct vlc_dictionary_entry_t * p_next; } vlc_dictionary_entry_t; typedef struct vlc_dictionary_t { int i_size; vlc_dictionary_entry_t ** p_entries; } vlc_dictionary_t; static void * const kVLCDictionaryNotFound = NULL; static inline void vlc_dictionary_init( vlc_dictionary_t * p_dict, int i_size ) { p_dict->p_entries = NULL; if( i_size > 0 ) { p_dict->p_entries = (vlc_dictionary_entry_t **)calloc( i_size, sizeof(*p_dict->p_entries) ); if( !p_dict->p_entries ) i_size = 0; } p_dict->i_size = i_size; } static inline void vlc_dictionary_clear( vlc_dictionary_t * p_dict, void ( * pf_free )( void * p_data, void * p_obj ), void * p_obj ) { if( p_dict->p_entries ) { for( int i = 0; i < p_dict->i_size; i++ ) { vlc_dictionary_entry_t * p_current, * p_next; p_current = p_dict->p_entries[i]; while( p_current ) { p_next = p_current->p_next; if( pf_free != NULL ) ( * pf_free )( p_current->p_value, p_obj ); free( p_current->psz_key ); free( p_current ); p_current = p_next; } } free( p_dict->p_entries ); p_dict->p_entries = NULL; } p_dict->i_size = 0; } static inline int vlc_dictionary_has_key( const vlc_dictionary_t * p_dict, const char * psz_key ) { if( !p_dict->p_entries ) return 0; int i_pos = DictHash( psz_key, p_dict->i_size ); const vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos]; for( ; p_entry != NULL; p_entry = p_entry->p_next ) { if( !strcmp( psz_key, p_entry->psz_key ) ) break; } return p_entry != NULL; } static inline void * vlc_dictionary_value_for_key( const vlc_dictionary_t * p_dict, const char * psz_key ) { if( !p_dict->p_entries ) return kVLCDictionaryNotFound; int i_pos = DictHash( psz_key, p_dict->i_size ); vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos]; if( !p_entry ) return kVLCDictionaryNotFound; /* Make sure we return the right item. (Hash collision) */ do { if( !strcmp( psz_key, p_entry->psz_key ) ) return p_entry->p_value; p_entry = p_entry->p_next; } while( p_entry ); return kVLCDictionaryNotFound; } static inline int vlc_dictionary_keys_count( const vlc_dictionary_t * p_dict ) { vlc_dictionary_entry_t * p_entry; int i, count = 0; if( !p_dict->p_entries ) return 0; for( i = 0; i < p_dict->i_size; i++ ) { for( p_entry = p_dict->p_entries[i]; p_entry; p_entry = p_entry->p_next ) count++; } return count; } static inline bool vlc_dictionary_is_empty( const vlc_dictionary_t * p_dict ) { if( p_dict->p_entries ) for( int i = 0; i < p_dict->i_size; i++ ) if( p_dict->p_entries[i] ) return false; return true; } static inline char ** vlc_dictionary_all_keys( const vlc_dictionary_t * p_dict ) { vlc_dictionary_entry_t * p_entry; char ** ppsz_ret; int i, count = vlc_dictionary_keys_count( p_dict ); ppsz_ret = (char**)malloc(sizeof(char *) * (count + 1)); if( unlikely(!ppsz_ret) ) return NULL; count = 0; for( i = 0; i < p_dict->i_size; i++ ) { for( p_entry = p_dict->p_entries[i]; p_entry; p_entry = p_entry->p_next ) ppsz_ret[count++] = strdup( p_entry->psz_key ); } ppsz_ret[count] = NULL; return ppsz_ret; } static inline void vlc_dictionary_insert_impl_( vlc_dictionary_t * p_dict, const char * psz_key, void * p_value, bool rebuild ) { if( !p_dict->p_entries ) vlc_dictionary_init( p_dict, 1 ); int i_pos = DictHash( psz_key, p_dict->i_size ); vlc_dictionary_entry_t * p_entry; p_entry = (vlc_dictionary_entry_t *)malloc(sizeof(*p_entry)); p_entry->psz_key = strdup( psz_key ); p_entry->p_value = p_value; p_entry->p_next = p_dict->p_entries[i_pos]; p_dict->p_entries[i_pos] = p_entry; if( rebuild ) { /* Count how many items there was */ int count; for( count = 1; p_entry->p_next; count++ ) p_entry = p_entry->p_next; if( count > 3 ) /* XXX: this need tuning */ { /* Here it starts to be not good, rebuild a bigger dictionary */ struct vlc_dictionary_t new_dict; int i_new_size = ( (p_dict->i_size+2) * 3) / 2; /* XXX: this need tuning */ int i; vlc_dictionary_init( &new_dict, i_new_size ); for( i = 0; i < p_dict->i_size; i++ ) { p_entry = p_dict->p_entries[i]; while( p_entry ) { vlc_dictionary_insert_impl_( &new_dict, p_entry->psz_key, p_entry->p_value, false /* To avoid multiple rebuild loop */); p_entry = p_entry->p_next; } } vlc_dictionary_clear( p_dict, NULL, NULL ); p_dict->i_size = new_dict.i_size; p_dict->p_entries = new_dict.p_entries; } } } static inline void vlc_dictionary_insert( vlc_dictionary_t * p_dict, const char * psz_key, void * p_value ) { vlc_dictionary_insert_impl_( p_dict, psz_key, p_value, true ); } static inline void vlc_dictionary_remove_value_for_key( const vlc_dictionary_t * p_dict, const char * psz_key, void ( * pf_free )( void * p_data, void * p_obj ), void * p_obj ) { if( !p_dict->p_entries ) return; int i_pos = DictHash( psz_key, p_dict->i_size ); vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos]; vlc_dictionary_entry_t * p_prev; if( !p_entry ) return; /* Not found, nothing to do */ /* Hash collision */ p_prev = NULL; do { if( !strcmp( psz_key, p_entry->psz_key ) ) { if( pf_free != NULL ) ( * pf_free )( p_entry->p_value, p_obj ); if( !p_prev ) p_dict->p_entries[i_pos] = p_entry->p_next; else p_prev->p_next = p_entry->p_next; free( p_entry->psz_key ); free( p_entry ); return; } p_prev = p_entry; p_entry = p_entry->p_next; } while( p_entry ); /* No key was found */ } #ifdef __cplusplus // C++ helpers template void vlc_delete_all( T &container ) { typename T::iterator it = container.begin(); while ( it != container.end() ) { delete *it; ++it; } container.clear(); } #endif #endif chibicc-1.0.23.1/issues/vlc_common.h000077500000000000000000000752121505335450300171550ustar00rootroot00000000000000/***************************************************************************** * vlc_common.h: common definitions * Collection of useful common types and macros definitions ***************************************************************************** * Copyright (C) 1998-2011 VLC authors and VideoLAN * * Authors: Samuel Hocevar * Vincent Seguin * Gildas Bazin * Rémi Denis-Courmont * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_COMMON_H # define VLC_COMMON_H 1 /** * \defgroup vlc VLC plug-in programming interface * \file * \ingroup vlc * This file is a collection of common definitions and types */ /***************************************************************************** * Required vlc headers *****************************************************************************/ #include "vlc_config.h" /***************************************************************************** * Required system headers *****************************************************************************/ #include #include #include #include #include #include #include #ifndef __cplusplus # include #endif /** * \defgroup cext C programming language extensions * \ingroup vlc * * This section defines a number of macros and inline functions extending the * C language. Most extensions are implemented by GCC and LLVM/Clang, and have * unoptimized fallbacks for other C11/C++11 conforming compilers. * @{ */ /* Function attributes for compiler warnings */ #if defined __has_attribute # if __has_attribute(warning) # define VLC_WARN_CALL(w) VLC_NOINLINE_FUNC __attribute__((warning((w)))) # else # define VLC_WARN_CALL(w) # endif # if __has_attribute(error) # define VLC_ERROR_CALL(e) VLC_NOINLINE_FUNC __attribute__((error((e)))) # else # define VLC_ERROR_CALL(e) # endif # if __has_attribute(unused) # define VLC_UNUSED_FUNC __attribute__((unused)) # else # define VLC_UNUSED_FUNC # endif # if __has_attribute(noinline) # define VLC_NOINLINE_FUNC __attribute__((noinline)) # else # define VLC_NOINLINE_FUNC # endif # if __has_attribute(deprecated) # define VLC_DEPRECATED __attribute__((deprecated)) # else /** * Deprecated functions or compound members annotation * * Use this macro in front of a function declaration or compound member * within a compound type declaration. * The compiler may emit a warning every time the function or member is used. * * Use \ref VLC_DEPRECATED_ENUM instead for enumeration members. */ # define VLC_DEPRECATED # endif # if __has_attribute(malloc) # define VLC_MALLOC __attribute__((malloc)) # else /** * Heap allocated result function annotation * * Use this macro to annotate a function that returns a pointer to memory that * cannot alias any other valid pointer. * * This is primarily used for functions that return a pointer to heap-allocated * memory, but it can be used for other applicable purposes. * * \warning Do not use this annotation if the returned pointer can in any way * alias a valid pointer at the time the function exits. This could lead to * very weird memory corruption bugs. */ # define VLC_MALLOC # endif # if __has_attribute(warn_unused_result) # define VLC_USED __attribute__((warn_unused_result)) # else /** * Used result function annotation * * Use this macro to annotate a function whose result must be used. * * There are several cases where this is useful: * - If a function has no side effects (or no useful side effects), such that * the only useful purpose of calling said function is to obtain its * return value. * - If ignoring the function return value would lead to a resource leak * (including but not limited to a memory leak). * - If a function cannot be used correctly without checking its return value. * For instance, if the function can fail at any time. * * The compiler may warn if the return value of a function call is ignored. */ # define VLC_USED # endif #elif defined(_MSC_VER) # define VLC_USED _Check_return_ // # define VLC_MALLOC __declspec(allocator) # define VLC_MALLOC // # define VLC_DEPRECATED __declspec(deprecated) # define VLC_DEPRECATED #else // !GCC && !MSVC # define VLC_USED # define VLC_MALLOC # define VLC_DEPRECATED #endif #ifdef __GNUC__ # define VLC_DEPRECATED_ENUM __attribute__((deprecated)) # if defined( _WIN32 ) && !defined( __clang__ ) # define VLC_FORMAT(x,y) __attribute__ ((format(gnu_printf,x,y))) # else # define VLC_FORMAT(x,y) __attribute__ ((format(printf,x,y))) # endif # define VLC_FORMAT_ARG(x) __attribute__ ((format_arg(x))) #else /** * Deprecated enum member annotation * * Use this macro after an enumerated type member declaration. * The compiler may emit a warning every time the enumeration member is used. * * See also \ref VLC_DEPRECATED. */ # define VLC_DEPRECATED_ENUM /** * String format function annotation * * Use this macro after a function prototype/declaration if the function * expects a standard C format string. This helps compiler diagnostics. * * @param x the position (starting from 1) of the format string argument * @param y the first position (also starting from 1) of the variable arguments * following the format string (usually but not always \p x+1). */ # define VLC_FORMAT(x,y) /** * Format string translation function annotation * * Use this macro after a function prototype/declaration if the function * expects a format string as input and returns another format string as output * to another function. * * This is primarily intended for localization functions such as gettext(). */ # define VLC_FORMAT_ARG(x) #endif #if defined (__ELF__) || defined (__MACH__) || defined (__wasm__) # define VLC_WEAK __attribute__((weak)) #else /** * Weak symbol annotation * * Use this macro before an external identifier \b definition to mark it as a * weak symbol. A weak symbol can be overridden by another symbol of the same * name at the link time. */ # define VLC_WEAK #endif /* Branch prediction */ #if defined (__GNUC__) || defined (__clang__) # define likely(p) __builtin_expect(!!(p), 1) # define unlikely(p) __builtin_expect(!!(p), 0) # if !defined(unreachable) # define unreachable() __builtin_unreachable() # endif #elif defined(_MSC_VER) # define likely(p) (!!(p)) # define unlikely(p) (!!(p)) # define unreachable() (__assume(0)) #else /** * Predicted true condition * * This macro indicates that the condition is expected most often true. * The compiler may optimize the code assuming that this condition is usually * met. */ # define likely(p) (!!(p)) /** * Predicted false condition * * This macro indicates that the condition is expected most often false. * The compiler may optimize the code assuming that this condition is rarely * met. */ # define unlikely(p) (!!(p)) /** * Impossible branch * * This macro indicates that the branch cannot be reached at run-time, and * represents undefined behaviour. * The compiler may optimize the code assuming that the call flow will never * logically reach the point where this macro is expanded. * * See also \ref vlc_assert_unreachable. */ # define unreachable() ((void)0) #endif /** * Impossible branch assertion * * This macro asserts that the branch cannot be reached at run-time. * * If the branch is reached in a debug build, it will trigger an assertion * failure and abnormal program termination. * * If the branch is reached in a non-debug build, this macro is equivalent to * \ref unreachable and the behaviour is undefined. */ #define vlc_assert_unreachable() (vlc_assert(!"unreachable"), unreachable()) /** * Run-time assertion * * This macro performs a run-time assertion if C assertions are enabled * and the following preprocessor symbol is defined: * @verbatim LIBVLC_INTERNAL_ @endverbatim * That restriction ensures that assertions in public header files are not * unwittingly leaked to externally-compiled plug-ins * including those header files. * * Within the LibVLC code base, this is exactly the same as assert(), which can * and probably should be used directly instead. */ #ifdef LIBVLC_INTERNAL_ # define vlc_assert(pred) assert(pred) #else # define vlc_assert(pred) ((void)0) #endif /* Linkage */ #ifdef __cplusplus # define VLC_EXTERN extern "C" #else # define VLC_EXTERN #endif #if defined (_WIN32) && defined (VLC_DLL_EXPORT) # define VLC_EXPORT __declspec(dllexport) #elif defined (__GNUC__) # define VLC_EXPORT __attribute__((visibility("default"))) #else # define VLC_EXPORT #endif /** * Exported API call annotation * * This macro is placed before a function declaration to indicate that the * function is an API call of the LibVLC plugin API. */ #define VLC_API VLC_EXTERN VLC_EXPORT /** @} */ /***************************************************************************** * Basic types definitions *****************************************************************************/ /** * The vlc_fourcc_t type. * * See http://www.webartz.com/fourcc/ for a very detailed list. */ typedef uint32_t vlc_fourcc_t; #ifdef WORDS_BIGENDIAN # define VLC_FOURCC( a, b, c, d ) \ ( ((uint32_t)d) | ( ((uint32_t)c) << 8 ) \ | ( ((uint32_t)b) << 16 ) | ( ((uint32_t)a) << 24 ) ) # define VLC_TWOCC( a, b ) \ ( (uint16_t)(b) | ( (uint16_t)(a) << 8 ) ) #else # define VLC_FOURCC( a, b, c, d ) \ ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \ | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) ) # define VLC_TWOCC( a, b ) \ ( (uint16_t)(a) | ( (uint16_t)(b) << 8 ) ) #endif /** * Translate a vlc_fourcc into its string representation. This function * assumes there is enough room in psz_fourcc to store 4 characters in. * * \param fcc a vlc_fourcc_t * \param psz_fourcc string to store string representation of vlc_fourcc in */ static inline void vlc_fourcc_to_char( vlc_fourcc_t fcc, char *psz_fourcc ) { memcpy( psz_fourcc, &fcc, 4 ); } /***************************************************************************** * Classes declaration *****************************************************************************/ /* Internal types */ typedef struct vlc_object_t vlc_object_t; typedef struct libvlc_int_t libvlc_int_t; typedef struct date_t date_t; /* Playlist */ typedef struct services_discovery_t services_discovery_t; typedef struct vlc_renderer_discovery_t vlc_renderer_discovery_t; typedef struct vlc_renderer_item_t vlc_renderer_item_t; /* Modules */ typedef struct module_t module_t; typedef struct module_config_t module_config_t; typedef struct config_category_t config_category_t; /* Input */ typedef struct input_item_t input_item_t; typedef struct input_item_node_t input_item_node_t; typedef struct input_source_t input_source_t; typedef struct stream_t stream_t; typedef struct stream_t demux_t; typedef struct es_out_t es_out_t; typedef struct es_out_id_t es_out_id_t; typedef struct seekpoint_t seekpoint_t; typedef struct info_t info_t; typedef struct info_category_t info_category_t; typedef struct input_attachment_t input_attachment_t; /* Format */ typedef struct audio_format_t audio_format_t; typedef struct video_format_t video_format_t; typedef struct subs_format_t subs_format_t; typedef struct es_format_t es_format_t; typedef struct video_palette_t video_palette_t; typedef struct vlc_es_id_t vlc_es_id_t; /* Audio */ typedef struct audio_output audio_output_t; typedef audio_format_t audio_sample_format_t; /* Video */ typedef struct vout_thread_t vout_thread_t; typedef struct vlc_viewpoint_t vlc_viewpoint_t; typedef video_format_t video_frame_format_t; typedef struct picture_t picture_t; /* Subpictures */ typedef struct spu_t spu_t; typedef struct subpicture_t subpicture_t; typedef struct subpicture_region_t subpicture_region_t; typedef struct image_handler_t image_handler_t; /* Stream output */ typedef struct sout_input_t sout_input_t; typedef struct sout_packetizer_input_t sout_packetizer_input_t; typedef struct sout_access_out_t sout_access_out_t; typedef struct sout_mux_t sout_mux_t; typedef struct sout_stream_t sout_stream_t; typedef struct config_chain_t config_chain_t; typedef struct session_descriptor_t session_descriptor_t; /* Decoders */ typedef struct decoder_t decoder_t; /* Encoders */ typedef struct encoder_t encoder_t; /* Filters */ typedef struct filter_t filter_t; /* Network */ typedef struct vlc_url_t vlc_url_t; /* Misc */ typedef struct iso639_lang_t iso639_lang_t; /* block */ typedef struct vlc_frame_t block_t; typedef struct vlc_fifo_t vlc_fifo_t; typedef struct vlc_fifo_t block_fifo_t; /* Hashing */ typedef struct vlc_hash_md5_ctx vlc_hash_md5_t; /* XML */ typedef struct xml_t xml_t; typedef struct xml_reader_t xml_reader_t; /* vod server */ typedef struct vod_t vod_t; typedef struct vod_media_t vod_media_t; /* VLM */ typedef struct vlm_t vlm_t; typedef struct vlm_message_t vlm_message_t; /* misc */ typedef struct vlc_meta_t vlc_meta_t; typedef struct input_stats_t input_stats_t; typedef struct addon_entry_t addon_entry_t; /* Update */ typedef struct update_t update_t; /** * \defgroup errors Error codes * \ingroup cext * @{ */ /** No error */ #define VLC_SUCCESS 0 /** Unspecified error */ #define VLC_EGENERIC (-2 * (1 << (sizeof (int) * 8 - 2))) /* INT_MIN */ /** Not enough memory */ #define VLC_ENOMEM (-ENOMEM) /** Timeout */ #define VLC_ETIMEOUT (-ETIMEDOUT) /** Not found */ #define VLC_ENOENT (-ENOENT) /** Bad variable value */ #define VLC_EINVAL (-EINVAL) /** Operation forbidden */ #define VLC_EACCES (-EACCES) /** Operation not supported */ #define VLC_ENOTSUP (-ENOTSUP) /** @} */ /***************************************************************************** * OS-specific headers and thread types *****************************************************************************/ #if defined( _WIN32 ) # include #endif #ifdef __APPLE__ #include #include #endif #ifdef __OS2__ # define OS2EMX_PLAIN_CHAR # define INCL_BASE # define INCL_PM # include # include #endif /** * \defgroup intops Integer operations * \ingroup cext * * Common integer functions. * @{ */ /* __MAX and __MIN: self explanatory */ #ifndef __MAX # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) ) #endif #ifndef __MIN # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) #endif /* clip v in [min, max] */ #define VLC_CLIP(v, min, max) __MIN(__MAX((v), (min)), (max)) /** * Make integer v a multiple of align * * \note align must be a power of 2 */ VLC_USED static inline size_t vlc_align(size_t v, size_t align) { return (v + (align - 1)) & ~(align - 1); } #if defined __has_attribute # if __has_attribute(diagnose_if) static inline size_t vlc_align(size_t v, size_t align) __attribute__((diagnose_if(((align & (align - 1)) || (align == 0)), "align must be power of 2", "error"))); # endif #endif /** Greatest common divisor */ VLC_USED static inline int64_t GCD ( int64_t a, int64_t b ) { while( b ) { int64_t c = a % b; a = b; b = c; } return a; } /* function imported from libavutil/common.h */ VLC_USED static inline uint8_t clip_uint8_vlc( int32_t a ) { if( a&(~255) ) return (-a)>>31; else return a; } /** * \defgroup bitops Bit operations * @{ */ #define VLC_INT_FUNC(basename) \ VLC_INT_FUNC_TYPE(basename, unsigned, ) \ VLC_INT_FUNC_TYPE(basename, unsigned long, l) \ VLC_INT_FUNC_TYPE(basename, unsigned long long, ll) #if defined (__GNUC__) || defined (__clang__) # define VLC_INT_FUNC_TYPE(basename,type,suffix) \ VLC_USED static inline int vlc_##basename##suffix(type x) \ { \ return __builtin_##basename##suffix(x); \ } #else VLC_USED static inline int vlc_ctz_generic(unsigned long long x) { unsigned i = sizeof (x) * 8; while (x) { x <<= 1; i--; } return i; } VLC_USED static inline int vlc_parity_generic(unsigned long long x) { for (unsigned i = 4 * sizeof (x); i > 0; i /= 2) x ^= x >> i; return x & 1; } VLC_USED static inline int vlc_popcount_generic(unsigned long long x) { int count = 0; while (x) { count += x & 1; x = x >> 1; } return count; } # define VLC_INT_FUNC_TYPE(basename,type,suffix) \ VLC_USED static inline int vlc_##basename##suffix(type x) \ { \ return vlc_##basename##_generic(x); \ } #endif VLC_INT_FUNC(ctz) VLC_INT_FUNC(parity) VLC_INT_FUNC(popcount) #ifndef __cplusplus # define VLC_INT_GENERIC(func,x) \ _Generic((x), \ unsigned char: func(x), \ signed char: func(x), \ unsigned short: func(x), \ signed short: func(x), \ unsigned int: func(x), \ signed int: func(x), \ unsigned long: func##l(x), \ signed long: func##l(x), \ unsigned long long: func##ll(x), \ signed long long: func##ll(x)) /** * Count trailing zeroes * * This function counts the number of consecutive zero bits * up from the lowest order bit in an unsigned integer. * * \param x a non-zero integer * \note This function assumes that CHAR_BIT equals 8. * \return The number of trailing zero bits in x. */ # define ctz(x) VLC_INT_GENERIC(vlc_ctz, x) /** * Parity * * This function determines the parity of an integer. * \retval 0 if x has an even number of set bits. * \retval 1 if x has an odd number of set bits. */ # define parity(x) VLC_INT_GENERIC(vlc_parity, x) /** * Bit weight / population count * * This function counts the number of non-zero bits in an integer. * * \return The count of non-zero bits. */ # define vlc_popcount(x) \ _Generic((x), \ signed char: vlc_popcount((unsigned char)(x)), \ signed short: vlc_popcount((unsigned short)(x)), \ default: VLC_INT_GENERIC(vlc_popcount ,x)) #else VLC_USED static inline int vlc_popcount(unsigned char x) { return vlc_popcount((unsigned)x); } VLC_USED static inline int vlc_popcount(unsigned short x) { return vlc_popcount((unsigned)x); } VLC_USED static inline int vlc_popcount(unsigned long x) { return vlc_popcountl(x); } VLC_USED static inline int vlc_popcount(unsigned long long x) { return vlc_popcountll(x); } #endif /** Byte swap (16 bits) */ VLC_USED static inline uint16_t vlc_bswap16(uint16_t x) { return (x << 8) | (x >> 8); } /** Byte swap (32 bits) */ VLC_USED static inline uint32_t vlc_bswap32(uint32_t x) { #if defined (__GNUC__) || defined(__clang__) return __builtin_bswap32 (x); #else return ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24); #endif } /** Byte swap (64 bits) */ VLC_USED static inline uint64_t vlc_bswap64(uint64_t x) { #if defined (__GNUC__) || defined(__clang__) return __builtin_bswap64 (x); #elif !defined (__cplusplus) return ((x & 0x00000000000000FF) << 56) | ((x & 0x000000000000FF00) << 40) | ((x & 0x0000000000FF0000) << 24) | ((x & 0x00000000FF000000) << 8) | ((x & 0x000000FF00000000) >> 8) | ((x & 0x0000FF0000000000) >> 24) | ((x & 0x00FF000000000000) >> 40) | ((x & 0xFF00000000000000) >> 56); #else return ((x & 0x00000000000000FFULL) << 56) | ((x & 0x000000000000FF00ULL) << 40) | ((x & 0x0000000000FF0000ULL) << 24) | ((x & 0x00000000FF000000ULL) << 8) | ((x & 0x000000FF00000000ULL) >> 8) | ((x & 0x0000FF0000000000ULL) >> 24) | ((x & 0x00FF000000000000ULL) >> 40) | ((x & 0xFF00000000000000ULL) >> 56); #endif } /** @} */ /** * \defgroup overflow Overflowing arithmetic * @{ */ static inline bool uadd_overflow(unsigned a, unsigned b, unsigned *res) { #if defined(__GNUC__) || defined(__clang__) return __builtin_uadd_overflow(a, b, res); #else *res = a + b; return (a + b) < a; #endif } static inline bool uaddl_overflow(unsigned long a, unsigned long b, unsigned long *res) { #if defined(__GNUC__) || defined(__clang__) return __builtin_uaddl_overflow(a, b, res); #else *res = a + b; return (a + b) < a; #endif } static inline bool uaddll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { #if defined(__GNUC__) || defined(__clang__) return __builtin_uaddll_overflow(a, b, res); #else *res = a + b; return (a + b) < a; #endif } #ifndef __cplusplus /** * Overflowing addition * * Converts \p a and \p b to the type of \p *r. * Then computes the sum of both conversions while checking for overflow. * Finally stores the result in \p *r. * * \param a an integer * \param b an integer * \param r a pointer to an integer [OUT] * \retval false The sum did not overflow. * \retval true The sum overflowed. */ # define add_overflow(a,b,r) \ _Generic(*(r), \ unsigned: uadd_overflow(a, b, (unsigned *)(r)), \ unsigned long: uaddl_overflow(a, b, (unsigned long *)(r)), \ unsigned long long: uaddll_overflow(a, b, (unsigned long long *)(r))) #else static inline bool add_overflow(unsigned a, unsigned b, unsigned *res) { return uadd_overflow(a, b, res); } static inline bool add_overflow(unsigned long a, unsigned long b, unsigned long *res) { return uaddl_overflow(a, b, res); } static inline bool add_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { return uaddll_overflow(a, b, res); } #endif #if !(defined(__GNUC__) || defined(__clang__)) # include #endif static inline bool umul_overflow(unsigned a, unsigned b, unsigned *res) { #if defined(__GNUC__) || defined(__clang__) return __builtin_umul_overflow(a, b, res); #else *res = a * b; return b > 0 && a > (UINT_MAX / b); #endif } static inline bool umull_overflow(unsigned long a, unsigned long b, unsigned long *res) { #if defined(__GNUC__) || defined(__clang__) return __builtin_umull_overflow(a, b, res); #else *res = a * b; return b > 0 && a > (ULONG_MAX / b); #endif } static inline bool umulll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { #if defined(__GNUC__) || defined(__clang__) return __builtin_umulll_overflow(a, b, res); #else *res = a * b; return b > 0 && a > (ULLONG_MAX / b); #endif } #ifndef __cplusplus /** * Overflowing multiplication * * Converts \p a and \p b to the type of \p *r. * Then computes the product of both conversions while checking for overflow. * Finally stores the result in \p *r. * * \param a an integer * \param b an integer * \param r a pointer to an integer [OUT] * \retval false The product did not overflow. * \retval true The product overflowed. */ #define mul_overflow(a,b,r) \ _Generic(*(r), \ unsigned: umul_overflow(a, b, (unsigned *)(r)), \ unsigned long: umull_overflow(a, b, (unsigned long *)(r)), \ unsigned long long: umulll_overflow(a, b, (unsigned long long *)(r))) #else static inline bool mul_overflow(unsigned a, unsigned b, unsigned *res) { return umul_overflow(a, b, res); } static inline bool mul_overflow(unsigned long a, unsigned long b, unsigned long *res) { return umull_overflow(a, b, res); } static inline bool mul_overflow(unsigned long long a, unsigned long long b, unsigned long long *res) { return umulll_overflow(a, b, res); } #endif /** @} */ /** @} */ /* Free and set set the variable to NULL */ #define FREENULL(a) do { free( a ); a = NULL; } while(0) #define EMPTY_STR(str) (!str || !*str) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* MSB (big endian)/LSB (little endian) conversions - network order is always * MSB, and should be used for both network communications and files. */ #ifdef WORDS_BIGENDIAN # define hton16(i) ((uint16_t)(i)) # define hton32(i) ((uint32_t)(i)) # define hton64(i) ((uint64_t)(i)) #else # define hton16(i) vlc_bswap16(i) # define hton32(i) vlc_bswap32(i) # define hton64(i) vlc_bswap64(i) #endif #define ntoh16(i) hton16(i) #define ntoh32(i) hton32(i) #define ntoh64(i) hton64(i) /** Reads 16 bits in network byte order */ VLC_USED static inline uint16_t U16_AT (const void *p) { uint16_t x; memcpy (&x, p, sizeof (x)); return ntoh16 (x); } /** Reads 32 bits in network byte order */ VLC_USED static inline uint32_t U32_AT (const void *p) { uint32_t x; memcpy (&x, p, sizeof (x)); return ntoh32 (x); } /** Reads 64 bits in network byte order */ VLC_USED static inline uint64_t U64_AT (const void *p) { uint64_t x; memcpy (&x, p, sizeof (x)); return ntoh64 (x); } #define GetWBE(p) U16_AT(p) #define GetDWBE(p) U32_AT(p) #define GetQWBE(p) U64_AT(p) /** Reads 16 bits in little-endian order */ VLC_USED static inline uint16_t GetWLE (const void *p) { uint16_t x; memcpy (&x, p, sizeof (x)); #ifdef WORDS_BIGENDIAN x = vlc_bswap16 (x); #endif return x; } /** Reads 32 bits in little-endian order */ VLC_USED static inline uint32_t GetDWLE (const void *p) { uint32_t x; memcpy (&x, p, sizeof (x)); #ifdef WORDS_BIGENDIAN x = vlc_bswap32 (x); #endif return x; } /** Reads 64 bits in little-endian order */ VLC_USED static inline uint64_t GetQWLE (const void *p) { uint64_t x; memcpy (&x, p, sizeof (x)); #ifdef WORDS_BIGENDIAN x = vlc_bswap64 (x); #endif return x; } /** Writes 16 bits in network byte order */ static inline void SetWBE (void *p, uint16_t w) { w = hton16 (w); memcpy (p, &w, sizeof (w)); } /** Writes 32 bits in network byte order */ static inline void SetDWBE (void *p, uint32_t dw) { dw = hton32 (dw); memcpy (p, &dw, sizeof (dw)); } /** Writes 64 bits in network byte order */ static inline void SetQWBE (void *p, uint64_t qw) { qw = hton64 (qw); memcpy (p, &qw, sizeof (qw)); } /** Writes 16 bits in little endian order */ static inline void SetWLE (void *p, uint16_t w) { #ifdef WORDS_BIGENDIAN w = vlc_bswap16 (w); #endif memcpy (p, &w, sizeof (w)); } /** Writes 32 bits in little endian order */ static inline void SetDWLE (void *p, uint32_t dw) { #ifdef WORDS_BIGENDIAN dw = vlc_bswap32 (dw); #endif memcpy (p, &dw, sizeof (dw)); } /** Writes 64 bits in little endian order */ static inline void SetQWLE (void *p, uint64_t qw) { #ifdef WORDS_BIGENDIAN qw = vlc_bswap64 (qw); #endif memcpy (p, &qw, sizeof (qw)); } /* */ #define VLC_UNUSED(x) (void)(x) /* Stuff defined in src/extras/libc.c */ #if defined(_WIN32) /* several type definitions */ # ifndef O_NONBLOCK # define O_NONBLOCK 0 # endif /* the mingw32 swab() and win32 _swab() prototypes expect a char* instead of a const void* */ # define swab(a,b,c) _swab((char*) (a), (char*) (b), (c)) #endif /* _WIN32 */ typedef struct { unsigned num, den; } vlc_rational_t; VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t ); #define container_of(ptr, type, member) \ ((type *)(((char *)(ptr)) - offsetof(type, member))) VLC_USED VLC_MALLOC static inline void *vlc_alloc(size_t count, size_t size) { return mul_overflow(count, size, &size) ? NULL : malloc(size); } VLC_USED static inline void *vlc_reallocarray(void *ptr, size_t count, size_t size) { return mul_overflow(count, size, &size) ? NULL : realloc(ptr, size); } /***************************************************************************** * I18n stuff *****************************************************************************/ VLC_API const char *vlc_gettext(const char *msgid) VLC_FORMAT_ARG(1); VLC_API const char *vlc_ngettext(const char *s, const char *p, unsigned long n) VLC_FORMAT_ARG(1) VLC_FORMAT_ARG(2); #define vlc_pgettext( ctx, id ) \ vlc_pgettext_aux( ctx "\004" id, id ) VLC_FORMAT_ARG(2) static inline const char *vlc_pgettext_aux( const char *ctx, const char *id ) { const char *tr = vlc_gettext( ctx ); return (tr == ctx) ? id : tr; } /***************************************************************************** * Loosy memory allocation functions. Do not use in new code. *****************************************************************************/ static inline void *xmalloc(size_t len) { void *ptr = malloc(len); if (unlikely(ptr == NULL && len > 0)) abort(); return ptr; } static inline void *xrealloc(void *ptr, size_t len) { void *nptr = realloc(ptr, len); if (unlikely(nptr == NULL && len > 0)) abort(); return nptr; } static inline char *xstrdup (const char *str) { char *ptr = strdup (str); if (unlikely(ptr == NULL)) abort (); return ptr; } /***************************************************************************** * libvlc features *****************************************************************************/ VLC_API const char * VLC_CompileBy( void ) VLC_USED; VLC_API const char * VLC_CompileHost( void ) VLC_USED; VLC_API const char * VLC_Compiler( void ) VLC_USED; /***************************************************************************** * Additional vlc stuff *****************************************************************************/ #include "vlc_messages.h" #include "vlc_objects.h" #include "vlc_variables.h" #if defined( _WIN32 ) || defined( __OS2__ ) # define DIR_SEP_CHAR '\\' # define DIR_SEP "\\" # define PATH_SEP_CHAR ';' # define PATH_SEP ";" #else # define DIR_SEP_CHAR '/' # define DIR_SEP "/" # define PATH_SEP_CHAR ':' # define PATH_SEP ":" #endif #define LICENSE_MSG \ _("This program comes with NO WARRANTY, to the extent permitted by " \ "law.\nYou may redistribute it under the terms of the GNU General " \ "Public License;\nsee the file named COPYING for details.\n" \ "Written by the VideoLAN team; see the AUTHORS file.\n") #if defined(__cplusplus) || defined(_MSC_VER) #define ARRAY_STATIC_SIZE #else #define ARRAY_STATIC_SIZE static #endif #endif /* !VLC_COMMON_H */ chibicc-1.0.23.1/issues/vlc_config.h000066400000000000000000000074501505335450300171260ustar00rootroot00000000000000/***************************************************************************** * vlc_config.h: limits and configuration * Defines all compilation-time configuration constants and size limits ***************************************************************************** * Copyright (C) 1999-2003 VLC authors and VideoLAN * * Authors: Vincent Seguin * Samuel Hocevar * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /** * \file * This file defines of values used in interface, vout, aout and vlc core functions. */ /* Conventions regarding names of symbols and variables * ---------------------------------------------------- * * - Symbols should begin with a prefix indicating in which module they are * used, such as INTF_, VOUT_ or AOUT_. */ /***************************************************************************** * General configuration *****************************************************************************/ /* All timestamp below or equal to this define are invalid/unset * XXX the numerical value is 0 because of historical reason and will change.*/ #define VLC_TICK_INVALID INT64_C(0) #define VLC_TICK_0 INT64_C(1) #define CLOCK_FREQ INT64_C(1000000) /***************************************************************************** * Interface configuration *****************************************************************************/ /* Base delay in micro second for interface sleeps */ #define INTF_IDLE_SLEEP VLC_TICK_FROM_MS(50) /***************************************************************************** * Input thread configuration *****************************************************************************/ /* Used in ErrorThread */ #define INPUT_IDLE_SLEEP VLC_TICK_FROM_MS(100) /* * General limitations */ /* Duration between the time we receive the data packet, and the time we will * mark it to be presented */ #define DEFAULT_PTS_DELAY VLC_TICK_FROM_MS(300) /***************************************************************************** * Video configuration *****************************************************************************/ /* * Default settings for video output threads */ /* Multiplier value for aspect ratio calculation (2^7 * 3^3 * 5^3) */ #define VOUT_ASPECT_FACTOR 432000 /* Maximum width of a scaled source picture - this should be relatively high, * since higher stream values will result in no display at all. */ #define VOUT_MAX_WIDTH 4096 /* Number of planes in a picture */ #define VOUT_MAX_PLANES 5 /* * Time settings */ /* Time to sleep when waiting for a buffer (from vout or the video fifo). * It should be approximately the time needed to perform a complete picture * loop. Since it only happens when the video heap is full, it does not need * to be too low, even if it blocks the decoder. */ #define VOUT_OUTMEM_SLEEP VLC_TICK_FROM_MS(20) /* The default video output window title */ #define VOUT_TITLE "VLC" chibicc-1.0.23.1/issues/vlc_configuration.h000066400000000000000000000336221505335450300205300ustar00rootroot00000000000000/***************************************************************************** * vlc_configuration.h : configuration management module * This file describes the programming interface for the configuration module. * It includes functions allowing to declare, get or set configuration options. ***************************************************************************** * Copyright (C) 1999-2006 VLC authors and VideoLAN * * Authors: Gildas Bazin * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_CONFIGURATION_H #define VLC_CONFIGURATION_H 1 /** * \defgroup config User settings * \ingroup interface * VLC provides a simple name-value dictionary for user settings. * * Those settings are per-user per-system - they are shared by all LibVLC * instances in a single process, and potentially other processes as well. * * Each name-value pair is called a configuration item. * @{ */ /** * \file * This file describes the programming interface for the configuration module. * It includes functions allowing to declare, get or set configuration options. */ #include /* for ssize_t */ # ifdef __cplusplus extern "C" { # endif typedef union { char *psz; int64_t i; float f; } module_value_t; typedef int (*vlc_string_list_cb)(const char *, char ***, char ***); typedef int (*vlc_integer_list_cb)(const char *, int64_t **, char ***); /** * Configuration item * * This is the internal reprensation of a configuration item. * See also config_FindConfig(). */ struct module_config_t { uint8_t i_type; /**< Configuration type */ const char *psz_type; /**< Configuration subtype */ const char *psz_name; /**< Option name */ const char *psz_text; /**< Short comment on the configuration option */ const char *psz_longtext; /**< Long comment on the configuration option */ module_value_t value; /**< Current value */ module_value_t orig; /**< Default value */ module_value_t min; /**< Minimum value (for scalars only) */ module_value_t max; /**< Maximum value (for scalars only) */ /* Values list */ uint16_t list_count; /**< Choices count */ union { const char **psz; /**< Table of possible string choices */ const int *i; /**< Table of possible integer choices */ } list; /**< Possible choices */ const char **list_text; /**< Human-readable names for list values */ }; /** * Gets a configuration item type * * This function checks the type of configuration item by name. * \param name Configuration item name * \return The configuration item type or 0 if not found. */ VLC_API int config_GetType(const char *name) VLC_USED; /** * Gets an integer configuration item's value. * * This function retrieves the current value of a configuration item of * integral type (\ref CONFIG_ITEM_INTEGER and \ref CONFIG_ITEM_BOOL). * * \warning The behaviour is undefined if the configuration item exists but is * not of integer or boolean type. * * \param name Configuration item name * \return The configuration item value or -1 if not found. * \bug A legitimate integer value of -1 cannot be distinguished from an error. */ VLC_API int64_t config_GetInt(const char *name) VLC_USED; /** * Sets an integer configuration item's value. * * This function changes the current value of a configuration item of * integral type (\ref CONFIG_ITEM_INTEGER and \ref CONFIG_ITEM_BOOL). * * \warning The behaviour is undefined if the configuration item exists but is * not of integer or boolean type. * * \note If no configuration item by the specified exist, the function has no * effects. * * \param name Configuration item name * \param val New value */ VLC_API void config_PutInt(const char *name, int64_t val); /** * Gets a floating point configuration item's value. * * This function retrieves the current value of a configuration item of * floating point type (\ref CONFIG_ITEM_FLOAT). * * \warning The behaviour is undefined if the configuration item exists but is * not of floating point type. * * \param name Configuration item name * \return The configuration item value or -1 if not found. * \bug A legitimate floating point value of -1 cannot be distinguished from an * error. */ VLC_API float config_GetFloat(const char *name) VLC_USED; /** * Sets a floating point configuration item's value. * * This function changes the current value of a configuration item of * floating point type (\ref CONFIG_ITEM_FLOAT). * * \warning The behaviour is undefined if the configuration item exists but is * not of floating point type. * * \note If no configuration item by the specified exist, the function has no * effects. * * \param name Configuration item name * \param val New value */ VLC_API void config_PutFloat(const char *name, float val); /** * Gets a string configuration item's value. * * This function retrieves the current value of a configuration item of * string type (\ref CONFIG_ITEM_STRING). * * \note The caller must free() the returned pointer (if non-NULL), which is a * duplicate of the current value. It is not safe to return a pointer to the * current value internally as it can be modified at any time by any other * thread. * * \warning The behaviour is undefined if the configuration item exists but is * not of string type. * * \param name Configuration item name * \return Normally, a heap-allocated copy of the configuration item value. * If the value is the empty string, if the configuration does not exist, * or if an error occurs, NULL is returned. * \bug The empty string value cannot be distinguished from an error. */ VLC_API char *config_GetPsz(const char *name) VLC_USED VLC_MALLOC; /** * Sets a string configuration item's value. * * This function changes the current value of a configuration item of * string type (e.g. \ref CONFIG_ITEM_STRING). * * \warning The behaviour is undefined if the configuration item exists but is * not of a string type. * * \note If no configuration item by the specified exist, the function has no * effects. * * \param name Configuration item name * \param val New value (will be copied) * \bug This function allocates memory but errors cannot be detected. */ VLC_API void config_PutPsz(const char *name, const char *val); /** * Enumerates integer configuration choices. * * Determines a list of suggested values for an integer configuration item. * \param values pointer to a table of integer values [OUT] * \param texts pointer to a table of descriptions strings [OUT] * \return number of choices, or -1 on error * \note the caller is responsible for calling free() on all descriptions and * on both tables. In case of error, both pointers are set to NULL. */ VLC_API ssize_t config_GetIntChoices(const char *, int64_t **values, char ***texts) VLC_USED; /** * Determines a list of suggested values for a string configuration item. * \param values pointer to a table of value strings [OUT] * \param texts pointer to a table of descriptions strings [OUT] * \return number of choices, or -1 on error * \note the caller is responsible for calling free() on all values, on all * descriptions and on both tables. * In case of error, both pointers are set to NULL. */ VLC_API ssize_t config_GetPszChoices(const char *, char ***values, char ***texts) VLC_USED; VLC_API int config_SaveConfigFile( libvlc_int_t * ); #define config_SaveConfigFile(a) config_SaveConfigFile(vlc_object_instance(a)) /** * Resets the configuration. * * This function resets all configuration items to their respective * compile-time default value. */ VLC_API void config_ResetAll(void); /** * Looks up a configuration item. * * This function looks for the internal representation of a configuration item. * Where possible, this should be avoided in favor of more specific function * calls. * * \param name Configuration item name * \return The internal structure, or NULL if not found. */ VLC_API module_config_t *config_FindConfig(const char *name) VLC_USED; /** * System directory identifiers */ typedef enum vlc_system_dir { VLC_PKG_DATA_DIR, /**< Package-specific architecture-independent read-only data directory (e.g. /usr/local/data/vlc). */ VLC_PKG_LIB_DIR, /**< Package-specific architecture-dependent read-only data directory (e.g. /usr/local/lib/vlc). */ VLC_PKG_LIBEXEC_DIR, /**< Package-specific executable read-only directory (e.g. /usr/local/libexec/vlc). */ VLC_PKG_INCLUDE_DIR_RESERVED, VLC_SYSDATA_DIR, /**< Global architecture-independent read-only data directory (e.g. /usr/local/data). Available only on some platforms. */ VLC_LIB_DIR, /**< Global architecture-dependent read-only directory (e.g. /usr/local/lib). */ VLC_LIBEXEC_DIR, /**< Global executable read-only directory (e.g. /usr/local/libexec). */ VLC_INCLUDE_DIR_RESERVED, VLC_LOCALE_DIR, /**< Base directory for package read-only locale data. */ } vlc_sysdir_t; /** * Gets an installation directory. * * This function determines one of the installation directory. * * @param dir identifier of the directory (see \ref vlc_sysdir_t) * @param filename name of a file or other object within the directory * (or NULL to obtain the plain directory) * * @return a heap-allocated string (use free() to release it), or NULL on error */ VLC_API char *config_GetSysPath(vlc_sysdir_t dir, const char *filename) VLC_USED VLC_MALLOC; typedef enum vlc_user_dir { VLC_HOME_DIR, /* User's home */ VLC_CONFIG_DIR, /* VLC-specific configuration directory */ VLC_USERDATA_DIR, /* VLC-specific data directory */ VLC_CACHE_DIR, /* VLC-specific user cached data directory */ /* Generic directories (same as XDG) */ VLC_DESKTOP_DIR=0x80, VLC_DOWNLOAD_DIR, VLC_TEMPLATES_DIR, VLC_PUBLICSHARE_DIR, VLC_DOCUMENTS_DIR, VLC_MUSIC_DIR, VLC_PICTURES_DIR, VLC_VIDEOS_DIR, } vlc_userdir_t; VLC_API char * config_GetUserDir( vlc_userdir_t ) VLC_USED VLC_MALLOC; VLC_API void config_AddIntf(const char *); VLC_API void config_RemoveIntf(const char *); VLC_API bool config_ExistIntf(const char *) VLC_USED; /**************************************************************************** * config_chain_t: ****************************************************************************/ struct config_chain_t { config_chain_t *p_next; /**< Pointer on the next config_chain_t element */ char *psz_name; /**< Option name */ char *psz_value; /**< Option value */ }; /** * This function will * - create all options in the array ppsz_options (var_Create). * - parse the given linked list of config_chain_t and set the value (var_Set). * * The option names will be created by adding the psz_prefix prefix. */ VLC_API void config_ChainParse( vlc_object_t *, const char *psz_prefix, const char *const *ppsz_options, const config_chain_t * ); #define config_ChainParse( a, b, c, d ) config_ChainParse( VLC_OBJECT(a), b, c, d ) /** * This function will parse a configuration string (psz_opts) and * - set all options for this module in a chained list (*pp_cfg) * - returns a pointer on the next module if any. * * The string format is * module{option=*,option=*} * * The options values are unescaped using config_StringUnescape. */ VLC_API const char *config_ChainParseOptions( config_chain_t **pp_cfg, const char *ppsz_opts ); /** * This function will parse a configuration string (psz_string) and * - set the module name (*ppsz_name) * - set all options for this module in a chained list (*pp_cfg) * - returns a pointer on the next module if any. * * The string format is * module{option=*,option=*}[:modulenext{option=*,...}] * * The options values are unescaped using config_StringUnescape. */ VLC_API char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg, const char *psz_string ) VLC_USED VLC_MALLOC; /** * This function will release a linked list of config_chain_t * (Including the head) */ VLC_API void config_ChainDestroy( config_chain_t * ); /** * This function will duplicate a linked list of config_chain_t */ VLC_API config_chain_t * config_ChainDuplicate( const config_chain_t * ) VLC_USED VLC_MALLOC; /** * This function will unescape a string in place and will return a pointer on * the given string. * No memory is allocated by it (unlike config_StringEscape). * If NULL is given as parameter nothing will be done (NULL will be returned). * * The following sequences will be unescaped (only one time): * \\ \' and \" */ VLC_API char * config_StringUnescape( char *psz_string ); /** * This function will escape a string that can be unescaped by * config_StringUnescape. * The returned value is allocated by it. You have to free it once you * do not need it anymore (unlike config_StringUnescape). * If NULL is given as parameter nothing will be done (NULL will be returned). * * The escaped characters are ' " and \ */ VLC_API char * config_StringEscape( const char *psz_string ) VLC_USED VLC_MALLOC; # ifdef __cplusplus } # endif /** @} */ #endif /* _VLC_CONFIGURATION_H */ chibicc-1.0.23.1/issues/vlc_messages.h000066400000000000000000000143601505335450300174660ustar00rootroot00000000000000/***************************************************************************** * vlc_messages.h: messages interface * This library provides basic functions for threads to interact with user * interface, such as message output. ***************************************************************************** * Copyright (C) 1999, 2000, 2001, 2002 VLC authors and VideoLAN * * Authors: Vincent Seguin * Samuel Hocevar * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_MESSAGES_H_ #define VLC_MESSAGES_H_ #include /** * \defgroup messages Logging * \ingroup os * \brief Message logs * * Functions for modules to emit log messages. * * @{ * \file * Logging functions */ /** Message types */ enum vlc_log_type { VLC_MSG_INFO=0, /**< Important information */ VLC_MSG_ERR, /**< Error */ VLC_MSG_WARN, /**< Warning */ VLC_MSG_DBG, /**< Debug */ }; /** * Log message */ typedef struct vlc_log_t { uintptr_t i_object_id; /**< Emitter (temporarily) unique object ID or 0 */ const char *psz_object_type; /**< Emitter object type name */ const char *psz_module; /**< Emitter module (source code) */ const char *psz_header; /**< Additional header (used by VLM media) */ const char *file; /**< Source code file name or NULL */ int line; /**< Source code file line number or -1 */ const char *func; /**< Source code calling function name or NULL */ unsigned long tid; /**< Emitter thread ID */ } vlc_log_t; /** * Emit a log message. * * \param obj VLC object emitting the message or NULL * \param type VLC_MSG_* message type (info, error, warning or debug) * \param module name of module from which the message come * (normally vlc_module_name) * \param file source module file name (normally __FILE__) or NULL * \param line function call source line number (normally __LINE__) or 0 * \param func calling function name (normally __func__) or NULL * \param format printf-like message format */ VLC_API void vlc_object_Log(vlc_object_t *obj, int type, const char *module, const char *file, unsigned line, const char *func, const char *format, ...) VLC_FORMAT(7, 8); /** * Emit a log message. * * This function is the variable argument list equivalent to vlc_object_Log(). */ VLC_API void vlc_object_vaLog(vlc_object_t *obj, int prio, const char *module, const char *file, unsigned line, const char *func, const char *format, va_list ap); #define msg_GenericVa(o, p, fmt, ap) \ vlc_object_vaLog(VLC_OBJECT(o), p, vlc_module_name, __FILE__, __LINE__, \ __func__, fmt, ap) #define msg_Generic(o, p, ...) \ vlc_object_Log(VLC_OBJECT(o), p, vlc_module_name, __FILE__, __LINE__, \ __func__, __VA_ARGS__) #define msg_Info(p_this, ...) \ msg_Generic(p_this, VLC_MSG_INFO, __VA_ARGS__) #define msg_Err(p_this, ...) \ msg_Generic(p_this, VLC_MSG_ERR, __VA_ARGS__) #define msg_Warn(p_this, ...) \ msg_Generic(p_this, VLC_MSG_WARN, __VA_ARGS__) #define msg_Dbg(p_this, ...) \ msg_Generic(p_this, VLC_MSG_DBG, __VA_ARGS__) #ifndef __cplusplus extern const char vlc_module_name[]; #else extern "C" const char vlc_module_name[]; #endif VLC_API const char *vlc_strerror(int); VLC_API const char *vlc_strerror_c(int); /** * \defgroup logger Logger * \brief Message log back-end. * * @{ */ struct vlc_logger; VLC_API void vlc_Log(struct vlc_logger *const *logger, int prio, const char *type, const char *module, const char *file, unsigned line, const char *func, const char *format, ...) VLC_FORMAT(8, 9); VLC_API void vlc_vaLog(struct vlc_logger *const *logger, int prio, const char *type, const char *module, const char *file, unsigned line, const char *func, const char *format, va_list ap); #define vlc_log_gen(logger, prio, ...) \ vlc_Log(&(logger), prio, "generic", vlc_module_name, \ __FILE__, __LINE__, __func__, __VA_ARGS__) #define vlc_info(logger, ...) vlc_log_gen(logger, VLC_MSG_INFO, __VA_ARGS__) #define vlc_error(logger, ...) vlc_log_gen(logger, VLC_MSG_ERR, __VA_ARGS__) #define vlc_warning(logger, ...) vlc_log_gen(logger, VLC_MSG_WARN, __VA_ARGS__) #define vlc_debug(logger, ...) vlc_log_gen(logger, VLC_MSG_DBG, __VA_ARGS__) /** * Message logging callback signature. * \param data data pointer as provided to vlc_LogSet(). * \param type message type (VLC_MSG_* values from enum vlc_log_type) * \param item meta information * \param fmt format string * \param args format string arguments */ typedef void (*vlc_log_cb) (void *data, int type, const vlc_log_t *item, const char *fmt, va_list args); struct vlc_logger_operations { vlc_log_cb log; void (*destroy)(void *data); }; /** * Creates a prefixed message log. * * This creates a message log that prefixes all its messages and forwards them * in another log. * \param parent message log to inject into * \param str nul-terminated prefix (a.k.a. "header") * \return a new message log on success or @c NULL on error */ VLC_API struct vlc_logger *vlc_LogHeaderCreate(struct vlc_logger *parent, const char *str) VLC_USED; /** * Destroys a message log. */ VLC_API void vlc_LogDestroy(struct vlc_logger *); /** * @} */ /** * @} */ #endif chibicc-1.0.23.1/issues/vlc_objects.h000066400000000000000000000222421505335450300173060ustar00rootroot00000000000000/***************************************************************************** * vlc_objects.h: vlc_object_t definition and manipulation methods ***************************************************************************** * Copyright (C) 2002-2008 VLC authors and VideoLAN * * Authors: Samuel Hocevar * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /** * \defgroup vlc_object VLC objects * \ingroup vlc * @{ * \file * Common VLC object definitions */ struct vlc_logger; struct vlc_tracer; struct vlc_object_internals; struct vlc_object_marker; /** * VLC object common members * * Common public properties for all VLC objects. * Object also have private properties maintained by the core, see * \ref vlc_object_internals_t */ struct vlc_object_t { struct vlc_logger *logger; union { struct vlc_object_internals *priv; struct vlc_object_marker *obj; }; bool no_interact; /** Module probe flag * * A boolean during module probing when the probe is "forced". * See \ref module_need(). */ bool force; }; /** * Type-safe vlc_object_t cast * * This macro attempts to cast a pointer to a compound type to a * \ref vlc_object_t pointer in a type-safe manner. * It checks if the compound type actually starts with an embedded * \ref vlc_object_t structure. */ #if !defined(__cplusplus) # define VLC_OBJECT(x) \ _Generic((x)->obj, \ struct vlc_object_marker *: (x), \ default: (&((x)->obj)) \ ) #else static inline vlc_object_t *VLC_OBJECT(vlc_object_t *o) { return o; } template static inline vlc_object_t *VLC_OBJECT(T *d) { return &d->obj; } #endif #ifdef __cplusplus extern "C" { #endif /* The root object */ struct libvlc_int_t { struct vlc_object_t obj; }; /** * Allocates and initializes a vlc object. * * @param i_size object byte size * * @return the new object, or NULL on error. */ VLC_API void *vlc_object_create( vlc_object_t *, size_t i_size) VLC_MALLOC VLC_USED; /** * Drops the strong reference to an object. * * This removes the initial strong reference to a given object. This must be * called exactly once per allocated object after it is no longer needed, * matching vlc_object_create() or vlc_custom_create(). */ VLC_API void vlc_object_delete(vlc_object_t *obj); #define vlc_object_delete(obj) vlc_object_delete(VLC_OBJECT(obj)) VLC_API size_t vlc_list_children(vlc_object_t *, vlc_object_t **, size_t) VLC_USED; /** * Returns the object type name. * * This returns a nul-terminated string identifying the object type. * The string is valid for at least as long as the object reference. * * \param obj object whose type name to get */ VLC_API const char *vlc_object_typename(const vlc_object_t *obj) VLC_USED; /** * Gets the parent of an object. * * \return the parent object (NULL if none) * * \note The returned parent object pointer is valid as long as the child is. */ VLC_API vlc_object_t *vlc_object_parent(vlc_object_t *obj) VLC_USED; #define vlc_object_parent(o) vlc_object_parent(VLC_OBJECT(o)) static inline struct vlc_logger *vlc_object_logger(vlc_object_t *obj) { return obj->logger; } #define vlc_object_logger(o) vlc_object_logger(VLC_OBJECT(o)) /** * Get tracer of a vlc instance from an object. * * \return the tracer of a vlc instance from an object (NULL if none). */ VLC_API struct vlc_tracer *vlc_object_get_tracer(vlc_object_t *obj); /** * Tries to get the name of module bound to an object. * * \warning This function is intrinsically race-prone, as a module may be * bound or unbound asynchronously by another thread. * Do not trust the result for any purpose other than debugging/tracing. * * \return Normally, this returns a heap-allocated nul-terminated string * which is the name of the module. If no module are bound to the object, it * returns NULL. It also returns NULL on error. */ #define vlc_object_get_name(obj) var_GetString(obj, "module-name") #define vlc_object_create(a,b) vlc_object_create( VLC_OBJECT(a), b ) #define vlc_object_find_name(a,b) \ vlc_object_find_name( VLC_OBJECT(a),b) VLC_USED static inline libvlc_int_t *vlc_object_instance(vlc_object_t *obj) { vlc_object_t *parent; do parent = obj; while ((obj = vlc_object_parent(obj)) != NULL); return (libvlc_int_t *)parent; } #define vlc_object_instance(o) vlc_object_instance(VLC_OBJECT(o)) /* Here for backward compatibility. TODO: Move to ! */ VLC_API vout_thread_t *vout_Hold(vout_thread_t *vout); VLC_API void vout_Release(vout_thread_t *vout); /* Here for backward compatibility. TODO: Move to ! */ VLC_API audio_output_t *aout_Hold(audio_output_t *aout); VLC_API void aout_Release(audio_output_t *aout); /* TODO: remove vlc_object_hold/_release() for GUIs, remove this */ VLC_DEPRECATED static inline void *vlc_object_hold(vlc_object_t *o) { const char *tn = vlc_object_typename(o); if (!strcmp(tn, "audio output")) aout_Hold((audio_output_t *)o); if (!strcmp(tn, "video output")) vout_Hold((vout_thread_t *)o); return o; } static inline void vlc_object_release(vlc_object_t *o) { const char *tn = vlc_object_typename(o); if (!strcmp(tn, "audio output")) aout_Release((audio_output_t *)o); if (!strcmp(tn, "video output")) vout_Release((vout_thread_t *)o); } #define vlc_object_release(o) vlc_object_release(VLC_OBJECT(o)) /** * @defgroup objres Object resources * * The object resource functions tie resource allocation to an instance of * a module through a VLC object. * Such resource will be automatically freed, in first in last out order, * when the module instance associated with the VLC object is terminated. * * Specifically, if the module instance activation/probe function fails, the * resource will be freed immediately after the failure. If the activation * succeeds, the resource will be freed when the module instance is terminated. * * This is a convenience mechanism to save explicit clean-up function calls * in modules. * * @{ */ /** * Allocates memory for a module. * * This function allocates memory from the heap for a module instance. * The memory is uninitialized. * * @param obj VLC object to tie the memory allocation to * @param size byte size of the memory allocation * * @return a pointer to the allocated memory, or NULL on error (errno is set). */ VLC_API VLC_MALLOC void *vlc_obj_malloc(vlc_object_t *obj, size_t size); #define vlc_obj_malloc(o, s) vlc_obj_malloc(VLC_OBJECT(o), s) /** * Allocates a zero-initialized table for a module. * * This function allocates a table from the heap for a module instance. * The memory is initialized to all zeroes. * * @param obj VLC object to tie the memory allocation to * @param nmemb number of table entries * @param size byte size of a table entry * * @return a pointer to the allocated memory, or NULL on error (errno is set). */ VLC_API VLC_MALLOC void *vlc_obj_calloc(vlc_object_t *obj, size_t nmemb, size_t size); #define vlc_obj_calloc(o, n, s) vlc_obj_calloc(VLC_OBJECT(o), n, s) /** * Duplicates a string for a module. * * This function allocates a copy of a nul-terminated string for a module * instance. * * @param obj VLC object to tie the memory allocation to * @param str string to copy * * @return a pointer to the copy, or NULL on error (errno is set). */ VLC_API VLC_MALLOC char *vlc_obj_strdup(vlc_object_t *obj, const char *str); #define vlc_obj_strdup(o, s) vlc_obj_strdup(VLC_OBJECT(o), s) /** * Manually frees module memory. * * This function manually frees a resource allocated with vlc_obj_malloc(), * vlc_obj_calloc() or vlc_obj_strdup() before the module instance is * terminated. This is seldom necessary. * * @param obj VLC object that the allocation was tied to * @param ptr pointer to the allocated resource */ VLC_API void vlc_obj_free(vlc_object_t *obj, void *ptr); #define vlc_obj_free(o, p) vlc_obj_free(VLC_OBJECT(o), p) #ifdef __cplusplus } /* extern "C" */ #undef vlc_object_create template VLC_MALLOC VLC_USED static inline void* vlc_object_create(O *obj, size_t size) { return vlc_object_create(VLC_OBJECT(obj), size); } template VLC_MALLOC VLC_USED static inline T* vlc_object_create(O *obj) { static_assert(std::is_pointer::value == false, "vlc_object_create can only create objects"); return static_cast(vlc_object_create(VLC_OBJECT(obj), sizeof(T))); } #endif /** @} */ /** @} */ chibicc-1.0.23.1/issues/vlc_threads.h000066400000000000000000001012661505335450300173130ustar00rootroot00000000000000/***************************************************************************** * vlc_threads.h : threads implementation for the VideoLAN client * This header provides portable declarations for mutexes & conditions ***************************************************************************** * Copyright (C) 1999, 2002 VLC authors and VideoLAN * Copyright © 2007-2016 Rémi Denis-Courmont * * Authors: Jean-Marc Dressler * Samuel Hocevar * Gildas Bazin * Christophe Massiot * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_THREADS_H_ #define VLC_THREADS_H_ #ifndef __cplusplus #include #endif /** * \ingroup os * \defgroup thread Threads and synchronization primitives * @{ * \file * Thread primitive declarations */ /** * Issues an explicit deferred cancellation point. * * This has no effects if thread cancellation is disabled. * This can be called when there is a rather slow non-sleeping operation. * This is also used to force a cancellation point in a function that would * otherwise not always be one (block_FifoGet() is an example). */ VLC_API void vlc_testcancel(void); #if defined (_WIN32) # include # ifndef ETIMEDOUT # define ETIMEDOUT 10060 /* This is the value in winsock.h. */ # endif typedef struct vlc_thread *vlc_thread_t; # define VLC_THREAD_CANCELED ((void*) UINTPTR_MAX) typedef struct vlc_threadvar *vlc_threadvar_t; typedef struct vlc_timer *vlc_timer_t; static inline int vlc_poll(struct pollfd *fds, unsigned nfds, int timeout) { int val; vlc_testcancel(); val = poll(fds, nfds, timeout); if (val < 0) vlc_testcancel(); return val; } # define poll(u,n,t) vlc_poll(u, n, t) #elif defined (__OS2__) # include typedef struct vlc_thread *vlc_thread_t; #define VLC_THREAD_CANCELED ((void*) UINTPTR_MAX) typedef struct vlc_threadvar *vlc_threadvar_t; typedef struct vlc_timer *vlc_timer_t; # define pthread_sigmask sigprocmask static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) { static int (*vlc_poll_os2)(struct pollfd *, unsigned, int) = NULL; if (!vlc_poll_os2) { HMODULE hmod; CHAR szFailed[CCHMAXPATH]; if (DosLoadModule(szFailed, sizeof(szFailed), "vlccore", &hmod)) return -1; if (DosQueryProcAddr(hmod, 0, "_vlc_poll_os2", (PFN *)&vlc_poll_os2)) return -1; } return (*vlc_poll_os2)(fds, nfds, timeout); } # define poll(u,n,t) vlc_poll(u, n, t) #elif defined (__ANDROID__) /* pthreads subset without pthread_cancel() */ # include # include # include # define LIBVLC_USE_PTHREAD_CLEANUP 1 typedef struct vlc_thread *vlc_thread_t; #define VLC_THREAD_CANCELED ((void*) UINTPTR_MAX) typedef pthread_key_t vlc_threadvar_t; typedef struct vlc_timer *vlc_timer_t; static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) { int val; do { int ugly_timeout = ((unsigned)timeout >= 50) ? 50 : timeout; if (timeout >= 0) timeout -= ugly_timeout; vlc_testcancel (); val = poll (fds, nfds, ugly_timeout); } while (val == 0 && timeout != 0); return val; } # define poll(u,n,t) vlc_poll(u, n, t) #else /* POSIX threads */ # include /* _POSIX_SPIN_LOCKS */ # include /** * Whether LibVLC threads are based on POSIX threads. */ # define LIBVLC_USE_PTHREAD 1 /** * Whether LibVLC thread cancellation is based on POSIX threads. */ # define LIBVLC_USE_PTHREAD_CLEANUP 1 /** * Thread handle. */ typedef struct { pthread_t handle; } vlc_thread_t; /** * Return value of a canceled thread. */ #define VLC_THREAD_CANCELED PTHREAD_CANCELED /** * Thread-local key handle. * * \ingroup threadvar */ typedef pthread_key_t vlc_threadvar_t; /** * Threaded timer handle. * * \ingroup timer */ typedef struct vlc_timer *vlc_timer_t; #endif /** * \defgroup mutex Mutual exclusion locks * @{ */ /** * Mutex. * * Storage space for a mutual exclusion lock. */ typedef struct { union { #ifndef __cplusplus struct { atomic_uint value; atomic_uint recursion; atomic_ulong owner; }; #endif struct { unsigned int value; unsigned int recursion; unsigned long owner; } dummy; }; } vlc_mutex_t; /** * Static initializer for (static) mutex. * * \note This only works in C code. * In C++, consider using a global \ref vlc::threads::mutex instance instead. */ #define VLC_STATIC_MUTEX { \ .value = ATOMIC_VAR_INIT(0), \ .recursion = ATOMIC_VAR_INIT(0), \ .owner = ATOMIC_VAR_INIT(0), \ } /** * Initializes a fast mutex. * * Recursive locking of a fast mutex is undefined behaviour. (In debug builds, * recursive locking will cause an assertion failure.) */ VLC_API void vlc_mutex_init(vlc_mutex_t *); /** * Initializes a recursive mutex. * \warning This is strongly discouraged. Please use normal mutexes. */ VLC_API void vlc_mutex_init_recursive(vlc_mutex_t *); /** * Acquires a mutex. * * If needed, this waits for any other thread to release it. * * \warning Beware of deadlocks when locking multiple mutexes at the same time, * or when using mutexes from callbacks. * * \note This function is not a cancellation point. */ VLC_API void vlc_mutex_lock(vlc_mutex_t *); /** * Tries to acquire a mutex. * * This function acquires the mutex if and only if it is not currently held by * another thread. This function never sleeps and can be used in delay-critical * code paths. * * \note This function is not a cancellation point. * * \warning If this function fails, then the mutex is held... by another * thread. The calling thread must deal with the error appropriately. That * typically implies postponing the operations that would have required the * mutex. If the thread cannot defer those operations, then it must use * vlc_mutex_lock(). If in doubt, use vlc_mutex_lock() instead. * * @return 0 if the mutex could be acquired, an error code otherwise. */ VLC_API int vlc_mutex_trylock( vlc_mutex_t * ) VLC_USED; /** * Releases a mutex. * * If the mutex is not held by the calling thread, the behaviour is undefined. * * \note This function is not a cancellation point. */ VLC_API void vlc_mutex_unlock(vlc_mutex_t *); /** * Checks if a mutex is locked. * * This function checks if the calling thread holds a given mutual exclusion * lock. It has no side effects and is essentially intended for run-time * debugging. * * @note To assert that the calling thread holds a lock, the helper macro * vlc_mutex_assert() should be used instead of this function. * * @note While it is nominally possible to implement recursive lock semantics * with this function, vlc_mutex_init_recursive() should be used instead to * create a recursive mutex explicitly.. * * @retval false the mutex is not locked by the calling thread * @retval true the mutex is locked by the calling thread */ VLC_API bool vlc_mutex_held(const vlc_mutex_t *) VLC_USED; /** * Asserts that a mutex is locked by the calling thread. */ #define vlc_mutex_assert(m) assert(vlc_mutex_held(m)) /** @} */ /** * \defgroup condvar Condition variables * * The condition variable is the most common and generic mean for threads to * wait for events triggered by other threads. * * See also POSIX @c pthread_cond_t . * @{ */ struct vlc_cond_waiter; /** * Condition variable. * * Storage space for a thread condition variable. */ typedef struct { struct vlc_cond_waiter *head; vlc_mutex_t lock; } vlc_cond_t; /** * Static initializer for (static) condition variable. */ #define VLC_STATIC_COND { NULL, VLC_STATIC_MUTEX } /** * Initializes a condition variable. */ VLC_API void vlc_cond_init(vlc_cond_t *); /** * Wakes up one thread waiting on a condition variable. * * If any thread is currently waiting on the condition variable, at least one * of those threads will be woken up. Otherwise, this function has no effects. * * \note This function is not a cancellation point. */ VLC_API void vlc_cond_signal(vlc_cond_t *); /** * Wakes up all threads waiting on a condition variable. * * \note This function is not a cancellation point. */ VLC_API void vlc_cond_broadcast(vlc_cond_t *); /** * Waits on a condition variable. * * The calling thread will be suspended until another thread calls * vlc_cond_signal() or vlc_cond_broadcast() on the same condition variable, * the thread is cancelled with vlc_cancel(), or the system causes a * spurious unsolicited wake-up. * * A mutex is needed to wait on a condition variable. It must not be * a recursive mutex. Although it is possible to use the same mutex for * multiple condition, it is not valid to use different mutexes for the same * condition variable at the same time from different threads. * * The canonical way to use a condition variable to wait for event foobar is: @code vlc_mutex_lock(&lock); while (!foobar) vlc_cond_wait(&wait, &lock); // -- foobar is now true, do something about it here -- vlc_mutex_unlock(&lock); @endcode * * \param cond condition variable to wait on * \param mutex mutex which is unlocked while waiting, * then locked again when waking up. */ VLC_API void vlc_cond_wait(vlc_cond_t *cond, vlc_mutex_t *mutex); /** * Waits on a condition variable up to a certain date. * * This works like vlc_cond_wait() but with an additional time-out. * The time-out is expressed as an absolute timestamp using the same arbitrary * time reference as the vlc_tick_now() and vlc_tick_wait() functions. * * \param cond condition variable to wait on * \param mutex mutex which is unlocked while waiting, * then locked again when waking up * \param deadline absolute timeout * * \return 0 if the condition was signaled, an error code in case of timeout. */ VLC_API int vlc_cond_timedwait(vlc_cond_t *cond, vlc_mutex_t *mutex, vlc_tick_t deadline); int vlc_cond_timedwait_daytime(vlc_cond_t *, vlc_mutex_t *, time_t); /** @} */ /** * \defgroup semaphore Semaphores * * The semaphore is the simplest thread synchronization primitive, consisting * of a simple counter. * * See also POSIX @c sem_t . * * @{ */ /** * Semaphore. * * Storage space for a thread-safe semaphore. */ typedef struct { union { #ifndef __cplusplus atomic_uint value; #endif int dummy; }; } vlc_sem_t; /** * Initializes a semaphore. * * @param count initial semaphore value (typically 0) */ VLC_API void vlc_sem_init(vlc_sem_t *, unsigned count); /** * Increments the value of a semaphore. * * \note This function is not a cancellation point. * * \return 0 on success, EOVERFLOW in case of integer overflow. */ VLC_API int vlc_sem_post(vlc_sem_t *); /** * Waits on a semaphore. * * This function atomically waits for the semaphore to become non-zero then * decrements it, and returns. If the semaphore is non-zero on entry, it is * immediately decremented. * * \note This function may be a point of cancellation. */ VLC_API void vlc_sem_wait(vlc_sem_t *); /** * Tries to decrement a semaphore. * * This function decrements the semaphore if its value is not zero. * * \param sem semaphore to decrement * * \retval 0 the semaphore was decremented * \retval EAGAIN the semaphore was zero and could not be decremented */ VLC_API int vlc_sem_trywait(vlc_sem_t *sem) VLC_USED; /** * Waits on a semaphore within a deadline. * * This function waits for the semaphore just like vlc_sem_wait(), but only * up to a given deadline. * * \param sem semaphore to wait for * \param deadline deadline to wait until * * \retval 0 the semaphore was decremented * \retval ETIMEDOUT the deadline was reached */ VLC_API int vlc_sem_timedwait(vlc_sem_t *sem, vlc_tick_t deadline) VLC_USED; /** @} */ #ifndef __cplusplus /** * \defgroup latch Latches * * The latch is a downward counter used to synchronise threads. * * @{ */ /** * Latch. * * Storage space for a thread-safe latch. */ typedef struct { atomic_size_t value; atomic_uint ready; } vlc_latch_t; /** * Initializes a latch. * * @param value initial latch value (typically 1) */ VLC_API void vlc_latch_init(vlc_latch_t *, size_t value); /** * Decrements the value of a latch. * * This function atomically decrements the value of a latch by the given * quantity. If the result is zero, then any thread waiting on the latch is * woken up. * * \warning If the result is (arithmetically) strictly negative, the behaviour * is undefined. * * \param n quantity to subtract from the latch value (typically 1) * * \note This function is not a cancellation point. */ VLC_API void vlc_latch_count_down(vlc_latch_t *, size_t n); /** * Decrements the value of a latch and waits on it. * * This function atomically decrements the value of a latch by the given * quantity. Then, if the result of the subtraction is strictly positive, * it waits until the value reaches zero. * * This function is equivalent to the succession of vlc_latch_count_down() * then vlc_latch_wait(), and is only an optimisation to combine the two. * * \warning If the result is strictly negative, the behaviour is undefined. * * @param n number of times to decrement the value (typically 1) * * \note This function may be a cancellation point. */ VLC_API void vlc_latch_count_down_and_wait(vlc_latch_t *, size_t n); /** * Checks if a latch is ready. * * This function compares the value of a latch with zero. * * \retval false if the latch value is non-zero * \retval true if the latch value equals zero */ VLC_API bool vlc_latch_is_ready(const vlc_latch_t *latch) VLC_USED; /** * Waits on a latch. * * This function waits until the value of the latch reaches zero. * * \note This function may be a point of cancellation. */ VLC_API void vlc_latch_wait(vlc_latch_t *); /** @} */ /* * Queued mutex * * A queued mutex is a type of thread-safe mutual exclusion lock that is * acquired in strict FIFO order. * * In most cases, a regular mutex (\ref vlc_mutex_t) should be used instead. * There are important differences: * - A queued mutex is generally slower, especially on the fast path. * - A queued mutex cannot be combined with a condition variable. * Indeed, the scheduling policy of the condition variable would typically * conflict with that of the queued mutex, leading to a dead lock. * - The try-lock operation is not implemented. */ typedef struct { atomic_uint head; atomic_uint tail; atomic_ulong owner; } vlc_queuedmutex_t; #define VLC_STATIC_QUEUEDMUTEX { ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0) } void vlc_queuedmutex_init(vlc_queuedmutex_t *m); void vlc_queuedmutex_lock(vlc_queuedmutex_t *m); void vlc_queuedmutex_unlock(vlc_queuedmutex_t *m); /** * Checks if a queued mutex is locked. * * This function checks if the calling thread holds a given queued mutual * exclusion lock. It has no side effects and is essentially intended for * run-time debugging. * * @note To assert that the calling thread holds a lock, the helper macro * vlc_queuedmutex_assert() should be used instead of this function. * * @retval false the mutex is not locked by the calling thread * @retval true the mutex is locked by the calling thread */ bool vlc_queuedmutex_held(vlc_queuedmutex_t *m); #define vlc_queuedmutex_assert(m) assert(vlc_queuedmutex_held(m)) /** * One-time initialization. * * A one-time initialization object must always be initialized assigned to * \ref VLC_STATIC_ONCE before use. */ typedef struct { atomic_uint value; } vlc_once_t; /** * Static initializer for one-time initialization. */ #define VLC_STATIC_ONCE { ATOMIC_VAR_INIT(0) } /** * Begins a one-time initialization. * * This function checks if a one-time initialization has completed: * - If this is the first time the function is called for the given one-time * initialization object, it marks the beginning of the initialization and * returns true. vlc_once_complete() must be called to mark the completion * of the initialisation. * - Otherwise, it waits until the initialization completes and returns false. * - In particular, if the initialization has already completed, the function * returns false immediately without actually waiting. * * The specified one-time initialization object must have been initialized * with @ref VLC_STATIC_ONCE, which is a constant expression suitable as a * static initializer. * * \warning If this function is called twice without an intervening call to * vlc_once_complete(), a dead lock will occur. * * \param once one-time initialisation object * \retval false on the first call (for the given object) * \retval true on subsequent calls (for the given object) */ VLC_API bool vlc_once_begin(vlc_once_t *restrict once); static inline bool vlc_once_begin_inline(vlc_once_t *restrict once) { /* Fast path: check if already initialized */ if (unlikely(atomic_load_explicit(&once->value, memory_order_acquire) < 3)) return vlc_once_begin(once); return true; } #define vlc_once_begin(once) vlc_once_begin_inline(once) /** * Completes a one-time initialization. * * This function marks the end of an ongoing one-time initialization. * If any thread is waiting for the completion of that initialization, its * execution will be resumed. * * \warning The behavior is undefined if the one-time initialization object * is uninitialized, if one-time initialization has not started, or * if one-time initialization has already completed. * * \param once one-time initialisation object */ VLC_API void vlc_once_complete(vlc_once_t *restrict once); /** * Executes a function one time. * * The first time this function is called with a given one-time initialization * object, it executes the provided callback with the provided data pointer as * sole parameter. Any further call with the same object will be a no-op. * * In the corner case that the first time execution is ongoing in another * thread, then the function will wait for completion on the other thread * (and then synchronize memory) before it returns. * This ensures that, no matter what, the callback has been executed exactly * once and its side effects are visible after the function returns. * * \param once a one-time initialization object * \param cb callback to execute (the first time) * \param opaque data pointer for the callback */ static inline void vlc_once(vlc_once_t *restrict once, void (*cb)(void *), void *opaque) { if (unlikely(!vlc_once_begin(once))) { cb(opaque); vlc_once_complete(once); } } #endif /** * \defgroup threadvar Thread-specific variables * @{ */ /** * Allocates a thread-specific variable. * * @param key where to store the thread-specific variable handle * @param destr a destruction callback. It is called whenever a thread exits * and the thread-specific variable has a non-NULL value. * * @return 0 on success, a system error code otherwise. * This function can actually fail: on most systems, there is a fixed limit to * the number of thread-specific variables in a given process. */ VLC_API int vlc_threadvar_create(vlc_threadvar_t *key, void (*destr) (void *)); /** * Deallocates a thread-specific variable. */ VLC_API void vlc_threadvar_delete(vlc_threadvar_t *); /** * Sets a thread-specific variable. * \param key thread-local variable key (created with vlc_threadvar_create()) * \param value new value for the variable for the calling thread * \return 0 on success, a system error code otherwise. */ VLC_API int vlc_threadvar_set(vlc_threadvar_t key, void *value); /** * Gets the value of a thread-local variable for the calling thread. * This function cannot fail. * * \return the value associated with the given variable for the calling * or NULL if no value was set. */ VLC_API void *vlc_threadvar_get(vlc_threadvar_t); /** @} */ /** * Creates and starts a new thread. * * The thread must be joined with vlc_join() to reclaim resources * when it is not needed anymore. * * @param th storage space for the handle of the new thread (cannot be NULL) * [OUT] * @param entry entry point for the thread * @param data data parameter given to the entry point * @return 0 on success, a standard error code on error. * @note In case of error, the value of *th is undefined. */ VLC_API int vlc_clone(vlc_thread_t *th, void *(*entry)(void *), void *data) VLC_USED; #if defined(__GNUC__) static VLC_UNUSED_FUNC VLC_WARN_CALL("thread name too big") const char * vlc_thread_name_too_big( const char * thread_name ) { return thread_name; } # define check_name_length( thread_name ) \ ((__builtin_constant_p(__builtin_strlen(thread_name) > 15) && \ __builtin_strlen(thread_name) > 15) \ ? vlc_thread_name_too_big(thread_name): thread_name) #endif /** * Set the thread name of the current thread. * * \param name the string to use as the thread name * * \note On Linux the name can be up to 16-byte long, including the terminating * nul character. If larger, the name will be truncated. */ VLC_API void vlc_thread_set_name(const char *name); #if defined(check_name_length) # define vlc_thread_set_name(name) vlc_thread_set_name(check_name_length(name)) #endif /** * Marks a thread as cancelled. * * Next time the target thread reaches a cancellation point (while not having * disabled cancellation), it will run its cancellation cleanup handler, the * thread variable destructors, and terminate. * * vlc_join() must be used regardless of a thread being cancelled or not, to * avoid leaking resources. */ VLC_API void vlc_cancel(vlc_thread_t); /** * Waits for a thread to complete (if needed), then destroys it. * * \note This is a cancellation point. In case of cancellation, the thread is * not joined. * \warning A thread cannot join itself (normally VLC will abort if this is * attempted). * * @param th thread handle * @param result [OUT] pointer to write the thread return value or NULL */ VLC_API void vlc_join(vlc_thread_t th, void **result); /** * Disables thread cancellation. * * This functions saves the current cancellation state (enabled or disabled), * then disables cancellation for the calling thread. It must be called before * entering a piece of code that is not cancellation-safe, unless it can be * proven that the calling thread will not be cancelled. * * \note This function is not a cancellation point. * * \return Previous cancellation state (opaque value for vlc_restorecancel()). */ VLC_API int vlc_savecancel(void); /** * Restores the cancellation state. * * This function restores the cancellation state of the calling thread to * a state previously saved by vlc_savecancel(). * * \note This function is not a cancellation point. * * \param state previous state as returned by vlc_savecancel(). */ VLC_API void vlc_restorecancel(int state); typedef struct vlc_cleanup_t vlc_cleanup_t; /** * Internal handler for thread cancellation. * * Do not call this function directly. Use wrapper macros instead: * vlc_cleanup_push(), vlc_cleanup_pop(). */ VLC_API void vlc_control_cancel(vlc_cleanup_t *); /** * Thread identifier. * * This function returns a non-zero unique identifier of the calling thread. * The identifier cannot change for the entire lifetime of the thread, and two * concurrent threads cannot have the same identifier. * * The thread identifier has no defined semantics other than uniqueness, * and no particular purposes within LibVLC. * It is provided mainly for tracing and debugging. * * On some but not all supported platforms, the thread identifier is in fact * the OS/kernel thread identifier (a.k.a. task PID), and is temporally unique * not only within the process but across the entire system. * * \note * The `main()` thread identifier is typically identical to the process * identifier, but this is not portable. * * \return the thread identifier (cannot fail) */ VLC_API unsigned long vlc_thread_id(void) VLC_USED; /** * Precision monotonic clock. * * In principles, the clock has a precision of 1 MHz. But the actual resolution * may be much lower, especially when it comes to sleeping with vlc_tick_wait() or * vlc_tick_sleep(). Most general-purpose operating systems provide a resolution of * only 100 to 1000 Hz. * * \warning The origin date (time value "zero") is not specified. It is * typically the time the kernel started, but this is platform-dependent. * If you need wall clock time, use gettimeofday() instead. * * \return a timestamp in microseconds. */ VLC_API vlc_tick_t vlc_tick_now(void); /** * Waits until a deadline. * * \param deadline timestamp to wait for (\ref vlc_tick_now()) * * \note The deadline may be exceeded due to OS scheduling. * \note This function is a cancellation point. */ VLC_API void vlc_tick_wait(vlc_tick_t deadline); /** * Waits for an interval of time. * * \param delay how long to wait (in microseconds) * * \note The delay may be exceeded due to OS scheduling. * \note This function is a cancellation point. */ VLC_API void vlc_tick_sleep(vlc_tick_t delay); #define VLC_HARD_MIN_SLEEP VLC_TICK_FROM_MS(10) /* 10 milliseconds = 1 tick at 100Hz */ #define VLC_SOFT_MIN_SLEEP VLC_TICK_FROM_SEC(9) /* 9 seconds */ #if defined(__GNUC__) /* Linux has 100, 250, 300 or 1000Hz * * HZ=100 by default on FreeBSD, but some architectures use a 1000Hz timer */ static VLC_UNUSED_FUNC VLC_ERROR_CALL("sorry, cannot sleep for such short a time") vlc_tick_t impossible_delay( vlc_tick_t delay ) { (void) delay; return VLC_HARD_MIN_SLEEP; } static VLC_UNUSED_FUNC VLC_WARN_CALL("use proper event handling instead of short delay") vlc_tick_t harmful_delay( vlc_tick_t delay ) { return delay; } # define check_delay( d ) \ ((__builtin_constant_p(d < VLC_HARD_MIN_SLEEP) \ && (d < VLC_HARD_MIN_SLEEP)) \ ? impossible_delay(d) \ : ((__builtin_constant_p(d < VLC_SOFT_MIN_SLEEP) \ && (d < VLC_SOFT_MIN_SLEEP)) \ ? harmful_delay(d) \ : d)) static VLC_UNUSED_FUNC VLC_ERROR_CALL("deadlines can not be constant") vlc_tick_t impossible_deadline( vlc_tick_t deadline ) { return deadline; } # define check_deadline( d ) \ (__builtin_constant_p(d) ? impossible_deadline(d) : d) #endif #if defined(check_delay) #define vlc_tick_sleep(d) vlc_tick_sleep(check_delay(d)) #endif #if defined(check_deadline) #define vlc_tick_wait(d) vlc_tick_wait(check_deadline(d)) #endif /** * \defgroup timer Asynchronous/threaded timers * @{ */ /** * Initializes an asynchronous timer. * * \param id pointer to timer to be initialized * \param func function that the timer will call * \param data parameter for the timer function * \return 0 on success, a system error code otherwise. * * \warning Asynchronous timers are processed from an unspecified thread. * \note Multiple occurrences of a single interval timer are serialized: * they cannot run concurrently. */ VLC_API int vlc_timer_create(vlc_timer_t *id, void (*func)(void *), void *data) VLC_USED; /** * Destroys an initialized timer. * * If needed, the timer is first disarmed. Behaviour is undefined if the * specified timer is not initialized. * * \warning This function must be called before the timer data can be * freed and before the timer callback function can be unmapped/unloaded. * * \param timer timer to destroy */ VLC_API void vlc_timer_destroy(vlc_timer_t timer); #define VLC_TIMER_DISARM (0) #define VLC_TIMER_FIRE_ONCE (0) /** * Arms or disarms an initialized timer. * * This functions overrides any previous call to itself. * * \note A timer can fire later than requested due to system scheduling * limitations. An interval timer can fail to trigger sometimes, either because * the system is busy or suspended, or because a previous iteration of the * timer is still running. See also vlc_timer_getoverrun(). * * \param timer initialized timer * \param absolute the timer value origin is the same as vlc_tick_now() if true, * the timer value is relative to now if false. * \param value zero to disarm the timer, otherwise the initial time to wait * before firing the timer. * \param interval zero to fire the timer just once, otherwise the timer * repetition interval. */ VLC_API void vlc_timer_schedule(vlc_timer_t timer, bool absolute, vlc_tick_t value, vlc_tick_t interval); static inline void vlc_timer_disarm(vlc_timer_t timer) { vlc_timer_schedule( timer, false, VLC_TIMER_DISARM, 0 ); } static inline void vlc_timer_schedule_asap(vlc_timer_t timer, vlc_tick_t interval) { vlc_timer_schedule(timer, false, 1, interval); } /** * Fetches and resets the overrun counter for a timer. * * This functions returns the number of times that the interval timer should * have fired, but the callback was not invoked due to scheduling problems. * The call resets the counter to zero. * * \param timer initialized timer * \return the timer overrun counter (typically zero) */ VLC_API unsigned vlc_timer_getoverrun(vlc_timer_t timer) VLC_USED; /** @} */ /** * Count CPUs. * * \return number of available (logical) CPUs. */ VLC_API unsigned vlc_GetCPUCount(void); #if defined (LIBVLC_USE_PTHREAD_CLEANUP) /** * Registers a thread cancellation handler. * * This pushes a function to run if the thread is cancelled (or otherwise * exits prematurely). * * If multiple procedures are registered, * they are handled in last-in first-out order. * * \note Any call to vlc_cleanup_push() must paired with a call to * vlc_cleanup_pop(). * \warning Branching into or out of the block between these two function calls * is not allowed (read: it will likely crash the whole process). * * \param routine procedure to call if the thread ends * \param arg argument for the procedure */ # define vlc_cleanup_push( routine, arg ) pthread_cleanup_push (routine, arg) /** * Unregisters the last cancellation handler. * * This pops the cancellation handler that was last pushed with * vlc_cleanup_push() in the calling thread. */ # define vlc_cleanup_pop( ) pthread_cleanup_pop (0) #else /* !LIBVLC_USE_PTHREAD_CLEANUP */ struct vlc_cleanup_t { vlc_cleanup_t *next; void (*proc) (void *); void *data; }; # ifndef __cplusplus /* This macros opens a code block on purpose: It reduces the chance of * not pairing the push and pop. It also matches the POSIX Thread internals. * That way, Win32 developers will not accidentally break other platforms. */ # define vlc_cleanup_push( routine, arg ) \ do { \ vlc_control_cancel(&(vlc_cleanup_t){ NULL, routine, arg }) # define vlc_cleanup_pop( ) \ vlc_control_cancel (NULL); \ } while (0) # else # define vlc_cleanup_push(routine, arg) \ static_assert(false, "don't use vlc_cleanup_push in portable C++ code") # define vlc_cleanup_pop() \ static_assert(false, "don't use vlc_cleanup_pop in portable C++ code") # endif #endif /* !LIBVLC_USE_PTHREAD_CLEANUP */ #ifdef __cplusplus /** * Helper C++ class to lock a mutex. * * The mutex is locked when the object is created, and unlocked when the object * is destroyed. */ class vlc_mutex_locker { private: vlc_mutex_t *lock; public: vlc_mutex_locker (vlc_mutex_t *m) : lock (m) { vlc_mutex_lock (lock); } ~vlc_mutex_locker (void) { vlc_mutex_unlock (lock); } }; #endif enum { VLC_AVCODEC_MUTEX = 0, VLC_GCRYPT_MUTEX, VLC_XLIB_MUTEX, VLC_MOSAIC_MUTEX, #ifdef _WIN32 VLC_MTA_MUTEX, #endif /* Insert new entry HERE */ VLC_MAX_MUTEX }; /** * Internal handler for global mutexes. * * Do not use this function directly. Use helper macros instead: * vlc_global_lock(), vlc_global_unlock(). */ VLC_API void vlc_global_mutex(unsigned, bool); /** * Acquires a global mutex. */ #define vlc_global_lock( n ) vlc_global_mutex(n, true) /** * Releases a global mutex. */ #define vlc_global_unlock( n ) vlc_global_mutex(n, false) /** @} */ #endif /* !_VLC_THREADS_H */ chibicc-1.0.23.1/issues/vlc_tick.h000077500000000000000000000223511505335450300166130ustar00rootroot00000000000000/***************************************************************************** * vlc_tick.h: high resolution time management functions ***************************************************************************** * This header provides portable high precision time management functions, * which should be the only ones used in other segments of the program, since * functions like gettimeofday() and ftime() are not always supported. * Most functions are declared as inline or as macros since they are only * interfaces to system calls and have to be called frequently. ***************************************************************************** * Copyright (C) 1996, 1997, 1998, 1999, 2000 VLC authors and VideoLAN * * Authors: Vincent Seguin * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef __VLC_MTIME_H # define __VLC_MTIME_H 1 struct timespec; /** * High precision date or time interval * * Store a high precision date or time interval. The maximum precision is the * microsecond, and a 64 bits integer is used to avoid overflows (maximum * time interval is then 292271 years, which should be long enough for any * video). Dates are stored as microseconds since a common date (usually the * epoch). Note that date and time intervals can be manipulated using regular * arithmetic operators, and that no special functions are required. */ typedef int64_t vlc_tick_t; #define VLC_TICK_MIN INT64_MIN #define VLC_TICK_MAX INT64_MAX #ifdef __cplusplus #else /* !__cplusplus */ #endif /* !__cplusplus */ /* seconds in floating point from vlc_tick_t */ static inline double secf_from_vlc_tick(vlc_tick_t vtk) { return (double)vtk; } static inline vlc_tick_t vlc_tick_rate_duration(float frame_rate) { return frame_rate; } /* * samples<>vlc_tick_t */ static inline vlc_tick_t vlc_tick_from_samples(int64_t samples, int samp_rate) { return samp_rate; } static inline int64_t samples_from_vlc_tick(vlc_tick_t t, int samp_rate) { return t * samp_rate ; } static inline uint64_t vlc_tick_from_frac(uint64_t num, uint64_t den) { lldiv_t d = lldiv (num, den); return den; } /* * vlc_tick_t <> milliseconds (ms) conversions */ #if (CLOCK_FREQ % 1000) == 0 #define VLC_TICK_FROM_MS(ms) ((CLOCK_FREQ / INT64_C(1000)) * (ms)) #define MS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000))) #elif (1000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_MS(ms) ((ms) / (INT64_C(1000) / CLOCK_FREQ)) #define MS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_MS(ms) (CLOCK_FREQ * (ms) / 1000) #define MS_FROM_VLC_TICK(vtk) ((vtk) * 1000 / CLOCK_FREQ) #endif /* CLOCK_FREQ / 1000 */ /* * vlc_tick_t <> microseconds (us) conversions */ #if (CLOCK_FREQ % 1000000) == 0 #define VLC_TICK_FROM_US(us) ((CLOCK_FREQ / INT64_C(1000000)) * (us)) #define US_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000000))) #elif (1000000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_US(us) ((us) / (INT64_C(1000000) / CLOCK_FREQ)) #define US_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_US(us) (CLOCK_FREQ * (us) / INT64_C(1000000)) #define US_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(1000000) / CLOCK_FREQ) #endif /* CLOCK_FREQ / 1000000 */ /* * vlc_tick_t <> nanoseconds (ns) conversions */ #if (CLOCK_FREQ % 1000000000) == 0 #define VLC_TICK_FROM_NS(ns) ((ns) * (CLOCK_FREQ / (INT64_C(1000000000)))) #define NS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / (INT64_C(1000000000)))) #elif (1000000000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_NS(ns) ((ns) / (INT64_C(1000000000) / CLOCK_FREQ)) #define NS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000000000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_NS(ns) (CLOCK_FREQ * (ns) / INT64_C(1000000000)) #define NS_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(1000000000) / CLOCK_FREQ) #endif /* CLOCK_FREQ / 1000000000 */ /* * msftime_t is a time with 100ns resolutions, typically used by Microsoft */ typedef int64_t msftime_t; #define MSFTIME_FROM_SEC(sec) (INT64_C(10000000) * (sec)) /* seconds in msftime_t */ #define MSFTIME_FROM_MS(sec) (INT64_C(10000) * (sec)) /* milliseconds in msftime_t */ #if (CLOCK_FREQ % 10000000) == 0 #define VLC_TICK_FROM_MSFTIME(msft) ((msft) * (CLOCK_FREQ / INT64_C(10000000)) #define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(10000000)) #elif (10000000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_MSFTIME(msft) ((msft) / (INT64_C(10000000) / CLOCK_FREQ)) #define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(10000000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_MSFTIME(msft) (CLOCK_FREQ * (msft) / INT64_C(10000000)) #define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(10000000) / CLOCK_FREQ) #endif /* CLOCK_FREQ / 10000000 */ #define vlc_tick_from_timeval(tv) \ (vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_US( (tv)->tv_usec )) #define vlc_tick_from_timespec(tv) \ (vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_NS( (tv)->tv_nsec )) /** * Converts a VLC tick to a POSIX time specification. * * \param ts [out] storage space for the time specification * \param tick VLC tick * \return @c ts */ VLC_API struct timespec *vlc_tick_to_timespec(struct timespec *restrict ts, vlc_tick_t tick); /***************************************************************************** * MSTRTIME_MAX_SIZE: maximum possible size of vlc_tick_to_str ***************************************************************************** * This values is the maximal possible size of the string returned by the * vlc_tick_to_str() function, including '-' and the final '\0'. It should be * used to allocate the buffer. *****************************************************************************/ #define MSTRTIME_MAX_SIZE 22 /***************************************************************************** * Prototypes *****************************************************************************/ /** * Convert seconds to a time in the format h:mm:ss. * * This function is provided for any interface function which need to print a * time string in the format h:mm:ss * date. * \param ticks the time to be converted * \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters * \return psz_buffer is returned so this can be used as printf parameter. */ VLC_API char * vlc_tick_to_str( char *psz_buffer, vlc_tick_t ticks ); /** * \defgroup date Timestamps, error-free * These functions support generating timestamps without long term rounding * errors due to sample rate conversions. * \ingroup input * @{ */ /** * Timestamps without long-term rounding errors */ struct date_t { vlc_tick_t date; uint32_t i_divider_num; uint32_t i_divider_den; uint32_t i_remainder; }; /** * Initializes a date_t. * * \param date date to initialize [OUT] * \param num divider (sample rate) numerator * \param den divider (sample rate) denominator */ VLC_API void date_Init(date_t *restrict date, uint32_t num, uint32_t den); /** * Changes the rate of a date_t. * * \param date date to change * \param num divider (sample rate) numerator * \param den divider (sample rate) denominator */ VLC_API void date_Change(date_t *restrict date, uint32_t num, uint32_t den); /** * Sets the exact timestamp of a date_t. * * \param date date to set the timestamp into * \param value date value */ static inline void date_Set(date_t *restrict date, vlc_tick_t value) { date->date = value; date->i_remainder = 0; } /** * Gets the current timestamp from a date_t. * * \param date date to fetch the timestamp from * \return date value */ VLC_USED static inline vlc_tick_t date_Get(const date_t *restrict date) { return date->date; } /** * Increments a date. * * Moves the date_t timestamp forward by a given number of samples. * * \param date date to move forward * \param count number of samples * \return timestamp value after incrementing */ VLC_API vlc_tick_t date_Increment(date_t *restrict date, uint32_t count); /** * Decrements a date. * * Moves the date_t timestamp backward by a given number of samples. * * \param date date to move backward * \param count number of samples * \return date value */ VLC_API vlc_tick_t date_Decrement(date_t *restrict date, uint32_t count); /** @} */ /** * @return NTP 64-bits timestamp in host byte order. */ VLC_API uint64_t NTPtime64( void ); #endif /* !__VLC_MTIME_ */ chibicc-1.0.23.1/issues/vlc_undefine2.c000066400000000000000000000017361505335450300175340ustar00rootroot00000000000000// test3.c #include #include #include // external function (not defined in this TU) void extfn(void) { return; } static inline void playlist_bookmark_Set(const char *name) { extfn(); // reference to an external symbol } static inline void playlist_bookmark_Play(const char *name) { puts(name); // reference to libc } // simulate VLC macro calling inline functions #define INTF_ACTION_HANDLER(name) \ void action_handler_##name(int action_id) { \ char bookmark_name[32]; \ snprintf(bookmark_name, sizeof(bookmark_name), "bookmark%i", action_id); \ if (action_id % 2) \ playlist_bookmark_Set(bookmark_name); \ else \ playlist_bookmark_Play(bookmark_name); \ } // instantiate the macro INTF_ACTION_HANDLER(PlaylistBookmark) int main(void) { // action_handler_PlaylistBookmark(1); //action_handler_PlaylistBookmark(2); return 0; } chibicc-1.0.23.1/issues/vlc_variables.h000066400000000000000000000650711505335450300176340ustar00rootroot00000000000000/***************************************************************************** * vlc_variables.h: variables handling ***************************************************************************** * Copyright (C) 2002-2004 VLC authors and VideoLAN * * Authors: Samuel Hocevar * Gildas Bazin * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_VARIABLES_H #define VLC_VARIABLES_H 1 /** * \defgroup variables Variables * \ingroup vlc_object * * VLC object variables and callbacks * * @{ * \file * VLC object variables and callbacks interface */ #define VLC_VAR_TYPE 0x00ff #define VLC_VAR_CLASS 0x00f0 #define VLC_VAR_FLAGS 0xff00 /** * \defgroup var_type Variable types * These are the different types a vlc variable can have. * @{ */ #define VLC_VAR_VOID 0x0010 #define VLC_VAR_BOOL 0x0020 #define VLC_VAR_INTEGER 0x0030 #define VLC_VAR_STRING 0x0040 #define VLC_VAR_FLOAT 0x0050 #define VLC_VAR_ADDRESS 0x0070 #define VLC_VAR_COORDS 0x00A0 /**@}*/ typedef union { int64_t i_int; bool b_bool; float f_float; char * psz_string; void * p_address; struct { int32_t x; int32_t y; } coords; } vlc_value_t; typedef struct vlc_callback_t vlc_callback_t; typedef struct vlc_list_callback_t vlc_list_callback_t; struct vlc_callback_t { int a; }; struct vlc_list_callback_t { int a; }; /** \defgroup var_flags Additive flags * These flags are added to the type field of the variable. Most as a result of * a var_Change() call, but some may be added at creation time * @{ */ #define VLC_VAR_HASCHOICE 0x0100 #define VLC_VAR_ISCOMMAND 0x2000 /** Creation flag */ /* If the variable is not found on the current module search all parents and finally module config until found */ #define VLC_VAR_DOINHERIT 0x8000 /**@}*/ /** * \defgroup var_action Variable actions * These are the different actions that can be used with var_Change(). * The parameters given are the meaning of the two last parameters of * var_Change() when this action is being used. * @{ */ #define VLC_VAR_SETSTEP 0x0012 /** * Set the value of this variable without triggering any callbacks * \param p_val The new value * \param p_val2 Unused */ #define VLC_VAR_SETVALUE 0x0013 #define VLC_VAR_SETTEXT 0x0014 #define VLC_VAR_GETTEXT 0x0015 #define VLC_VAR_GETMIN 0x0016 #define VLC_VAR_GETMAX 0x0017 #define VLC_VAR_GETSTEP 0x0018 #define VLC_VAR_ADDCHOICE 0x0020 #define VLC_VAR_DELCHOICE 0x0021 #define VLC_VAR_CLEARCHOICES 0x0022 #define VLC_VAR_GETCHOICES 0x0024 #define VLC_VAR_CHOICESCOUNT 0x0026 #define VLC_VAR_SETMINMAX 0x0027 /**@}*/ /** * Variable actions. * * These are the different actions that can be used with var_GetAndSet(). */ enum vlc_var_atomic_op { VLC_VAR_BOOL_TOGGLE, /**< Invert a boolean value (param ignored) */ VLC_VAR_INTEGER_ADD, /**< Add parameter to an integer value */ VLC_VAR_INTEGER_OR, /**< Binary OR over an integer bits field */ VLC_VAR_INTEGER_NAND,/**< Binary NAND over an integer bits field */ }; /** * Creates a VLC object variable. * * This function creates a named variable within a VLC object. * If a variable already exists with the same name within the same object, its * reference count is incremented instead. * * \param obj Object to hold the variable * \param name Variable name * \param type Variable type. Must be one of \ref var_type combined with * zero or more \ref var_flags */ VLC_API int var_Create(vlc_object_t *obj, const char *name, int type); /** * Destroys a VLC object variable. * * This function decrements the reference count of a named variable within a * VLC object. If the reference count reaches zero, the variable is destroyed. * * \param obj Object holding the variable * \param name Variable name */ VLC_API void var_Destroy(vlc_object_t *obj, const char *name); /** * Performs a special action on a variable. * * \param obj Object holding the variable * \param name Variable name * \param action Action to perform. Must be one of \ref var_action */ VLC_API int var_Change(vlc_object_t *obj, const char *name, int action, ...); /** * Get the type of a variable. * * \see var_type * * \return The variable type if it exists * or 0 if the variable could not be found. */ VLC_API int var_Type(vlc_object_t *obj, const char *name) VLC_USED; /** * Sets a variable value. * * \param obj Object holding the variable * \param name Variable name * \param val Variable value to set */ VLC_API int var_Set(vlc_object_t *obj, const char *name, vlc_value_t val); /** * Gets a variable value. * * \param obj Object holding the variable * \param name Variable name * \param valp Pointer to a \ref vlc_value_t object to hold the value [OUT] */ VLC_API int var_Get(vlc_object_t *obj, const char *name, vlc_value_t *valp); VLC_API int var_SetChecked( vlc_object_t *, const char *, int, vlc_value_t ); VLC_API int var_GetChecked( vlc_object_t *, const char *, int, vlc_value_t * ); /** * Perform an atomic read-modify-write of a variable. * * \param obj object holding the variable * \param name variable name * \param op read-modify-write operation to perform * (see \ref vlc_var_atomic_op) * \param value value of the variable after the modification * \retval VLC_SUCCESS Operation successful * \retval VLC_ENOENT Variable not found * * \bug The modified value is returned rather than the original value. * As such, the original value cannot be known in the case of non-reversible * operation such as \ref VLC_VAR_INTEGER_OR and \ref VLC_VAR_INTEGER_NAND. */ VLC_API int var_GetAndSet(vlc_object_t *obj, const char *name, int op, vlc_value_t *value); /** * Finds the value of a variable. * * If the specified object does not hold a variable with the specified name, * try the parent object, and iterate until the top of the objects tree. If no * match is found, the value is read from the configuration. */ VLC_API int var_Inherit( vlc_object_t *, const char *, int, vlc_value_t * ); /***************************************************************************** * Variable callbacks ***************************************************************************** * int MyCallback( vlc_object_t *p_this, * char const *psz_variable, * vlc_value_t oldvalue, * vlc_value_t newvalue, * void *p_data); *****************************************************************************/ /** * Registers a callback for a variable. * * We store a function pointer that will be called upon variable * modification. * * \param obj Object holding the variable * \param name Variable name * \param callback Callback function pointer * \param opaque Opaque data pointer for use by the callback. * * \warning The callback function is run in the thread that calls var_Set() on * the variable. Use proper locking. This thread may not have much * time to spare, so keep callback functions short. * * \bug It is not possible to atomically retrieve the current value and * register a callback. As a consequence, extreme care must be taken to ensure * that the variable value cannot change before the callback is registered. * Failure to do so will result in intractable race conditions. */ VLC_API void var_AddCallback(vlc_object_t *obj, const char *name, vlc_callback_t callback, void *opaque); /** * Deregisters a callback from a variable. * * The callback and opaque pointer must be supplied again, as the same callback * function might have been registered more than once. */ VLC_API void var_DelCallback(vlc_object_t *obj, const char *name, vlc_callback_t callback, void *opaque); /** * Triggers callbacks on a variable. * * This triggers any callbacks registered on the named variable without * actually modifying the variable value. This is primarily useful for * variables with \ref VLC_VAR_VOID type (which do not have a value). * * \param obj Object holding the variable * \param name Variable name */ VLC_API void var_TriggerCallback(vlc_object_t *obj, const char *name); /** * Register a callback for a list variable * * The callback is triggered when an element is added/removed from the * list or when the list is cleared. * * See var_AddCallback(). */ VLC_API void var_AddListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * ); /** * Remove a callback from a list variable * * See var_DelCallback(). */ VLC_API void var_DelListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * ); /***************************************************************************** * helpers functions *****************************************************************************/ /** * Set the value of an integer variable * * \param p_obj The object that holds the variable * \param psz_name The name of the variable * \param i The new integer value of this variable */ static inline int var_SetInteger( vlc_object_t *p_obj, const char *psz_name, int64_t i ) { vlc_value_t val; val.i_int = i; return var_SetChecked( p_obj, psz_name, VLC_VAR_INTEGER, val ); } /** * Set the value of an boolean variable * * \param p_obj The object that holds the variable * \param psz_name The name of the variable * \param b The new boolean value of this variable */ static inline int var_SetBool( vlc_object_t *p_obj, const char *psz_name, bool b ) { vlc_value_t val; val.b_bool = b; return var_SetChecked( p_obj, psz_name, VLC_VAR_BOOL, val ); } static inline int var_SetCoords( vlc_object_t *obj, const char *name, int32_t x, int32_t y ) { vlc_value_t val; val.coords.x = x; val.coords.y = y; return var_SetChecked (obj, name, VLC_VAR_COORDS, val); } /** * Set the value of a float variable * * \param p_obj The object that holds the variable * \param psz_name The name of the variable * \param f The new float value of this variable */ static inline int var_SetFloat( vlc_object_t *p_obj, const char *psz_name, float f ) { vlc_value_t val; val.f_float = f; return var_SetChecked( p_obj, psz_name, VLC_VAR_FLOAT, val ); } /** * Set the value of a string variable * * \param p_obj The object that holds the variable * \param psz_name The name of the variable * \param psz_string The new string value of this variable */ static inline int var_SetString( vlc_object_t *p_obj, const char *psz_name, const char *psz_string ) { vlc_value_t val; val.psz_string = (char *)psz_string; return var_SetChecked( p_obj, psz_name, VLC_VAR_STRING, val ); } /** * Set the value of a pointer variable * * \param p_obj The object that holds the variable * \param psz_name The name of the variable * \param ptr The new pointer value of this variable */ static inline int var_SetAddress( vlc_object_t *p_obj, const char *psz_name, void *ptr ) { vlc_value_t val; val.p_address = ptr; return var_SetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, val ); } /** * Get an integer value * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline int64_t var_GetInteger( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; if( !var_GetChecked( p_obj, psz_name, VLC_VAR_INTEGER, &val ) ) return val.i_int; else return 0; } /** * Get a boolean value * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline bool var_GetBool( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; val.b_bool = false; if( !var_GetChecked( p_obj, psz_name, VLC_VAR_BOOL, &val ) ) return val.b_bool; else return false; } static inline void var_GetCoords( vlc_object_t *obj, const char *name, int32_t *px, int32_t *py ) { vlc_value_t val; if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val))) { *px = val.coords.x; *py = val.coords.y; } else *px = *py = 0; } /** * Get a float value * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline float var_GetFloat( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; val.f_float = 0.0; if( !var_GetChecked( p_obj, psz_name, VLC_VAR_FLOAT, &val ) ) return val.f_float; else return 0.0; } /** * Get a string value * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED VLC_MALLOC static inline char *var_GetString( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; val.psz_string = NULL; if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) ) return NULL; else return val.psz_string; } VLC_USED VLC_MALLOC static inline char *var_GetNonEmptyString( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) ) return NULL; if( val.psz_string && *val.psz_string ) return val.psz_string; free( val.psz_string ); return NULL; } VLC_USED static inline void *var_GetAddress( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; if( var_GetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, &val ) ) return NULL; else return val.p_address; } /** * Increment an integer variable * \param p_obj the object that holds the variable * \param psz_name the name of the variable */ static inline int64_t var_IncInteger( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; val.i_int = 1; if( var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val ) ) return 0; return val.i_int; } /** * Decrement an integer variable * \param p_obj the object that holds the variable * \param psz_name the name of the variable */ static inline int64_t var_DecInteger( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; val.i_int = -1; if( var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val ) ) return 0; return val.i_int; } static inline uint64_t var_OrInteger( vlc_object_t *obj, const char *name, unsigned v ) { vlc_value_t val; val.i_int = v; if( var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val ) ) return 0; return val.i_int; } static inline uint64_t var_NAndInteger( vlc_object_t *obj, const char *name, unsigned v ) { vlc_value_t val; val.i_int = v; if( var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val ) ) return 0; return val.i_int; } /** * Create a integer variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline int64_t var_CreateGetInteger( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); return var_GetInteger( p_obj, psz_name ); } /** * Create a boolean variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline bool var_CreateGetBool( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); return var_GetBool( p_obj, psz_name ); } /** * Create a float variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline float var_CreateGetFloat( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); return var_GetFloat( p_obj, psz_name ); } /** * Create a string variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED VLC_MALLOC static inline char *var_CreateGetString( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT ); return var_GetString( p_obj, psz_name ); } VLC_USED VLC_MALLOC static inline char *var_CreateGetNonEmptyString( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT ); return var_GetNonEmptyString( p_obj, psz_name ); } /** * Create an address variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline void *var_CreateGetAddress( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT ); return var_GetAddress( p_obj, psz_name ); } /** * Create a integer command variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline int64_t var_CreateGetIntegerCommand( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); return var_GetInteger( p_obj, psz_name ); } /** * Create a boolean command variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline bool var_CreateGetBoolCommand( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); return var_GetBool( p_obj, psz_name ); } /** * Create a float command variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED static inline float var_CreateGetFloatCommand( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); return var_GetFloat( p_obj, psz_name ); } /** * Create a string command variable with inherit and get its value. * * \param p_obj The object that holds the variable * \param psz_name The name of the variable */ VLC_USED VLC_MALLOC static inline char *var_CreateGetStringCommand( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); return var_GetString( p_obj, psz_name ); } VLC_USED VLC_MALLOC static inline char *var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj, const char *psz_name ) { var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); return var_GetNonEmptyString( p_obj, psz_name ); } VLC_USED static inline size_t var_CountChoices( vlc_object_t *p_obj, const char *psz_name ) { size_t count; if( var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count ) ) return 0; return count; } static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name ) { vlc_value_t val; if( var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val ) ) return false; return val.b_bool; } VLC_USED static inline bool var_InheritBool( vlc_object_t *obj, const char *name ) { vlc_value_t val; if( var_Inherit( obj, name, VLC_VAR_BOOL, &val ) ) val.b_bool = false; return val.b_bool; } VLC_USED static inline int64_t var_InheritInteger( vlc_object_t *obj, const char *name ) { vlc_value_t val; if( var_Inherit( obj, name, VLC_VAR_INTEGER, &val ) ) val.i_int = 0; return val.i_int; } VLC_USED static inline float var_InheritFloat( vlc_object_t *obj, const char *name ) { vlc_value_t val; if( var_Inherit( obj, name, VLC_VAR_FLOAT, &val ) ) val.f_float = 0.; return val.f_float; } VLC_USED VLC_MALLOC static inline char *var_InheritString( vlc_object_t *obj, const char *name ) { vlc_value_t val; if( var_Inherit( obj, name, VLC_VAR_STRING, &val ) ) val.psz_string = NULL; else if( val.psz_string && !*val.psz_string ) { free( val.psz_string ); val.psz_string = NULL; } return val.psz_string; } VLC_USED static inline void *var_InheritAddress( vlc_object_t *obj, const char *name ) { vlc_value_t val; if( var_Inherit( obj, name, VLC_VAR_ADDRESS, &val ) ) val.p_address = NULL; return val.p_address; } /** * Inherit a string as a fractional value. * * This function inherits a string, and interprets it as an unsigned rational * number, i.e. a fraction. It also accepts a normally formatted floating point * number. * * \warning The caller shall perform any and all necessary boundary checks. * * \note The rational number is always reduced, * i.e. the returned numerator and denominator are always co-prime numbers. * * \note Fraction with zero as denominator are considered valid, * including the undefined form zero-by-zero. * * \return Zero on success, an error if parsing fails. */ VLC_API int var_InheritURational(vlc_object_t *obj, unsigned *num, unsigned *den, const char *name); /** * Parses a string with multiple options. * * Parses a set of colon-separated or semicolon-separated * name=value pairs. * Some access (or access_demux) plugins uses this scheme * in media resource location. * @note Only trusted/safe variables are allowed. This is intended. * * @warning Only use this for plugins implementing VLC-specific resource * location schemes. This would not make any sense for standardized ones. * * @param obj VLC object on which to set variables (and emit error messages) * @param mrl string to parse * @param prefix prefix to prepend to option names in the string * * @return VLC_ENOMEM on error, VLC_SUCCESS on success. */ VLC_API int var_LocationParse(vlc_object_t *obj, const char *mrl, const char *prefix); #ifndef DOC #define var_Create(a,b,c) var_Create(VLC_OBJECT(a), b, c) #define var_Destroy(a,b) var_Destroy(VLC_OBJECT(a), b) #define var_Change(a,b,...) var_Change(VLC_OBJECT(a), b, __VA_ARGS__) #define var_Type(a,b) var_Type(VLC_OBJECT(a), b) #define var_Set(a,b,c) var_Set(VLC_OBJECT(a), b, c) #define var_Get(a,b,c) var_Get(VLC_OBJECT(a), b, c) #define var_SetChecked(o,n,t,v) var_SetChecked(VLC_OBJECT(o), n, t, v) #define var_GetChecked(o,n,t,v) var_GetChecked(VLC_OBJECT(o), n, t, v) #define var_AddCallback(a,b,c,d) var_AddCallback(VLC_OBJECT(a), b, c, d) #define var_DelCallback(a,b,c,d) var_DelCallback(VLC_OBJECT(a), b, c, d) #define var_TriggerCallback(a,b) var_TriggerCallback(VLC_OBJECT(a), b) #define var_AddListCallback(a,b,c,d) \ var_AddListCallback(VLC_OBJECT(a), b, c, d) #define var_DelListCallback(a,b,c,d) \ var_DelListCallback(VLC_OBJECT(a), b, c, d) #define var_SetInteger(a,b,c) var_SetInteger(VLC_OBJECT(a), b, c) #define var_SetBool(a,b,c) var_SetBool(VLC_OBJECT(a), b, c) #define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o), n, x, y) #define var_SetFloat(a,b,c) var_SetFloat(VLC_OBJECT(a), b, c) #define var_SetString(a,b,c) var_SetString(VLC_OBJECT(a), b, c) #define var_SetAddress(o, n, p) var_SetAddress(VLC_OBJECT(o), n, p) #define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o), n, x, y) #define var_IncInteger(a,b) var_IncInteger(VLC_OBJECT(a), b) #define var_DecInteger(a,b) var_DecInteger(VLC_OBJECT(a), b) #define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a), b, c) #define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a), b, c) #define var_CreateGetInteger(a,b) var_CreateGetInteger(VLC_OBJECT(a), b) #define var_CreateGetBool(a,b) var_CreateGetBool(VLC_OBJECT(a), b) #define var_CreateGetFloat(a,b) var_CreateGetFloat(VLC_OBJECT(a), b) #define var_CreateGetString(a,b) var_CreateGetString(VLC_OBJECT(a), b) #define var_CreateGetNonEmptyString(a,b) \ var_CreateGetNonEmptyString(VLC_OBJECT(a), b) #define var_CreateGetAddress(a,b) var_CreateGetAddress( VLC_OBJECT(a), b) #define var_CreateGetIntegerCommand(a,b) var_CreateGetIntegerCommand( VLC_OBJECT(a),b) #define var_CreateGetBoolCommand(a,b) var_CreateGetBoolCommand( VLC_OBJECT(a),b) #define var_CreateGetFloatCommand(a,b) var_CreateGetFloatCommand( VLC_OBJECT(a),b) #define var_CreateGetStringCommand(a,b) var_CreateGetStringCommand( VLC_OBJECT(a),b) #define var_CreateGetNonEmptyStringCommand(a,b) var_CreateGetNonEmptyStringCommand( VLC_OBJECT(a),b) #define var_CountChoices(a,b) var_CountChoices(VLC_OBJECT(a),b) #define var_ToggleBool(a,b) var_ToggleBool(VLC_OBJECT(a),b ) #define var_InheritBool(o, n) var_InheritBool(VLC_OBJECT(o), n) #define var_InheritInteger(o, n) var_InheritInteger(VLC_OBJECT(o), n) #define var_InheritFloat(o, n) var_InheritFloat(VLC_OBJECT(o), n) #define var_InheritString(o, n) var_InheritString(VLC_OBJECT(o), n) #define var_InheritAddress(o, n) var_InheritAddress(VLC_OBJECT(o), n) #define var_InheritURational(a,b,c,d) var_InheritURational(VLC_OBJECT(a), b, c, d) #define var_GetInteger(a,b) var_GetInteger(VLC_OBJECT(a),b) #define var_GetBool(a,b) var_GetBool(VLC_OBJECT(a),b) #define var_GetFloat(a,b) var_GetFloat(VLC_OBJECT(a),b) #define var_GetString(a,b) var_GetString(VLC_OBJECT(a),b) #define var_GetNonEmptyString(a,b) var_GetNonEmptyString( VLC_OBJECT(a),b) #define var_GetAddress(a,b) var_GetAddress(VLC_OBJECT(a),b) #define var_LocationParse(o, m, p) var_LocationParse(VLC_OBJECT(o), m, p) #endif /** * @} */ #endif /* _VLC_VARIABLES_H */ chibicc-1.0.23.1/issues/weak2.c000066400000000000000000000014071505335450300160150ustar00rootroot00000000000000// weak2.c #include typedef void (*vlc_plugin_cb)(void); // Simulate VLC_WEAK macro #define VLC_WEAK __attribute__((weak)) // Weak symbol declaration VLC_WEAK extern const vlc_plugin_cb vlc_static_modules[]; // Function using the weak symbol void init_plugins(void) { // if (!vlc_static_modules) { // printf("vlc_static_modules not defined\n"); // return; // } // for (unsigned i = 0; vlc_static_modules[i]; i++) { // printf("Plugin %u initialized\n", i); // vlc_static_modules[i](); //} } // Dummy plugin void plugin1(void) { printf("Plugin1 executed\n"); } // Uncomment to define the weak array for testing // const vlc_plugin_cb vlc_static_modules[] = { plugin1, NULL }; chibicc-1.0.23.1/issues/weak2.so000077500000000000000000000365001505335450300162210ustar00rootroot00000000000000ELF>@5@8 @ 44-==(0.>> $$Std PtdH H H 44QtdRtd-==GNUGNU<g&HyZj( [WЦ uzb  , F"U9t__gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizeinit_pluginsvlc_static_modulesputsprintfplugin1libc.so.6GLIBC_2.2.5ui =0=@@?????@@HH/HtH5/%/@hfhf%/fD%/fD%/fDH=/H/H9tH&/Ht H=a/H5Z/H)HH?HHHtH.HtfD=/u+UH=.Ht H=.9d.]wUHHH|.HuHHIE-EHHǸH=.UHЃEH).UHHuUHHzH]HHvlc_static_modules not definedPlugin %u initialized Plugin1 executed;4PxezRx $0FJ w?9*3$"D\ tAtEC k EC Q 0  ==o ?0 oooo>0@@GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 !7@C=j0v=0!@>H @?  /B9tO b qy "crtstuff.cderegister_tm_clones__do_global_dtors_auxcompleted.0__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entryweak2.c__FRAME_END___fini__dso_handle_DYNAMIC__GNU_EH_FRAME_HDR__TMC_END___GLOBAL_OFFSET_TABLE__init_ITM_deregisterTMCloneTableputs@GLIBC_2.2.5printf@GLIBC_2.2.5init_pluginsvlc_static_modules__gmon_start__plugin1_ITM_registerTMCloneTable__cxa_finalize@GLIBC_2.2.5.symtab.strtab.shstrtab.note.gnu.property.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.got.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.init_array.fini_array.dynamic.got.plt.data.bss.comment .$Ao(K S[oho wB0  0PP`` G  GH H 4 =-=->.?/(?/(@0@000+H0 34 chibicc-1.0.23.1/issues/weak2b.c000066400000000000000000000001341505335450300161530ustar00rootroot00000000000000// main.c void init_plugins(void); int main() { init_plugins(); return 0; } chibicc-1.0.23.1/issues/xgetbv.c000066400000000000000000000015571505335450300163110ustar00rootroot00000000000000#include "test.h" #include // direct wrapper for xgetbv static inline uint64_t xgetbv(uint32_t xcr) { uint32_t eax, edx; __asm__ volatile ( ".byte 0x0f, 0x01, 0xd0" // xgetbv opcode : "=a"(eax), "=d"(edx) // outputs in eax, edx : "c"(xcr) // input: xcr in ecx ); return ((uint64_t)edx << 32) | eax; } static inline void cpuid(uint32_t leaf, uint32_t subleaf, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) { __asm__ volatile("cpuid" : "=a"(*a), "=b"(*b), "=c"(*c), "=d"(*d) : "a"(leaf), "c"(subleaf)); } int main(void) { printf("Calling xgetbv(0)...\n"); uint64_t val = xgetbv(0); printf("xgetbv(0) = 0x%llx\n", (unsigned long long)val); return 0; } chibicc-1.0.23.1/main.c000077500000000000000000001161041505335450300144210ustar00rootroot00000000000000#include "chibicc.h" #define MAIN_C "main.c" typedef enum { FILE_NONE, FILE_C, FILE_ASM, FILE_OBJ, FILE_AR, FILE_DSO, FILE_RSP, } FileType; StringArray include_paths; bool opt_fcommon = true; bool opt_fbuiltin = true; bool opt_fpic; bool opt_fpie; bool opt_shared; bool opt_sse; bool opt_sse2; bool opt_sse3; bool opt_sse4; bool opt_mmx; bool opt_g; bool opt_c99; bool opt_c11; bool opt_c17; bool opt_implicit; static FileType opt_x; static StringArray opt_include; bool opt_E; static bool opt_A; static bool opt_M; static bool opt_MD; static bool opt_MMD; static bool opt_MP; static bool opt_S; static bool opt_c; static bool opt_cc1; static bool opt_hash_hash_hash; static bool opt_static; static bool isCc1input = false; static bool isCc1output = false; static char *opt_MF; static char *opt_MT; char *opt_o; static char *opt_linker; // static char *symbolic_name; static char *r_path; static bool opt_nostdinc; static bool opt_nostdlib; static bool opt_v; static bool opt_fstack_protector; static StringArray ld_extra_args; static StringArray std_include_paths; char *base_file; static char *output_file; FILE *f; FILE *ofile; // for dot diagrams FILE *dotf; char *dot_file; bool isDotfile = false; bool isDebug = false; bool isPrintMacro = false; bool printTokens = false; char *previousfile = " "; Context *ctx; char *weak_symbols[MAX_WEAK]; int weak_count = 0; static char logFile[] = "/tmp/chibicc.log"; static StringArray input_paths; static StringArray tmpfiles; static void enable_core_dump() { struct rlimit rl; rl.rlim_cur = RLIM_INFINITY; rl.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) == -1) { perror("setrlimit"); exit(EXIT_FAILURE); } } static void segfault_handler(int signum) { printf("Segmentation fault (signal %d)\n", signum); abort(); // Generate a core dump } static void setup_signal_handlers() { signal(SIGSEGV, segfault_handler); } static void print_string_array(StringArray *arr) { for (int i = 0; i < arr->len; i++) { printf("=====ld_extra_args[%d]: %s\n", i, arr->data[i]); } } static void print_include_directories() { strarray_push(&include_paths, "./include"); // Add standard include paths. strarray_push(&include_paths, "/usr/local/include/x86_64-linux-gnu/chibicc"); strarray_push(&include_paths, "/usr/include/x86_64-linux-gnu"); strarray_push(&include_paths, "/usr/local/include"); strarray_push(&include_paths, "/usr/include"); strarray_push(&include_paths, "/usr/lib/gcc/x86_64-linux-gnu/13/include"); //strarray_push(&include_paths, "/usr/include/chibicc/include"); #if defined(__APPLE__) && defined(__MACH__) strarray_push(&include_paths, "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"); define_macro("__GNUC__", "5"); // for MacOS SDK compatibility #endif // Keep a copy of the standard include paths for -MMD option. for (int i = 0; i < include_paths.len; i++) { strarray_push(&std_include_paths, include_paths.data[i]); } printf("#include \"...\" search starts here:\n"); printf("#include <...> search starts here:\n"); for (int i = 0; i < std_include_paths.len; i++) { char *dir = std_include_paths.data[i]; printf(" %s\n", dir); } printf("End of search list.\n"); } static void usage(int status) { fprintf(stdout, HELP); fprintf(stdout, USAGE); exit(status); } // print the version of the command static void printVersion() { printf("%s version : %s\n", PRODUCT, VERSION); } // check the length and validity of parameter to avoid non valid input values static void check_parms_length(char *arg) { if (strlen(arg) > MAXLEN) { error("%s : %s:%d: error: in check_parms_length maximum length parameter overpassed", MAIN_C, __FILE__, __LINE__); exit(EXIT_FAILURE); } } static bool take_arg(char *arg) { char *x[] = { "-o", "-I", "-idirafter", "-include", "-x", "-MF", "-MT", "-MQ", "-Xlinker", "-cc1-input", "-cc1-output", "-fuse-ld", "-soname", "-rpath", "--version-script"}; for (int i = 0; i < sizeof(x) / sizeof(*x); i++) { if (!strcmp(arg, x[i])) return true; } return false; } static void add_default_include_paths(char *argv0) { if (opt_nostdinc) return; // We expect that chibicc-specific include files are installed // to ./include relative to argv[0]. strarray_push(&include_paths, format("%s/include", dirname(strdup(argv0)))); // Add standard include paths. strarray_push(&include_paths, "/usr/local/include/x86_64-linux-gnu/chibicc"); strarray_push(&include_paths, "/usr/include"); strarray_push(&include_paths, "/usr/local/include"); strarray_push(&include_paths, "/usr/include/x86_64-linux-gnu"); strarray_push(&include_paths, "/usr/lib/gcc/x86_64-linux-gnu/13/include"); //strarray_push(&include_paths, "/usr/include/chibicc/include"); #if defined(__APPLE__) && defined(__MACH__) strarray_push(&include_paths, "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"); define_macro("__GNUC__", "5"); // for MacOS SDK compatibility #endif // Keep a copy of the standard include paths for -MMD option. for (int i = 0; i < include_paths.len; i++) { strarray_push(&std_include_paths, include_paths.data[i]); } } static void define(char *str) { char *eq = strchr(str, '='); if (eq) define_macro(strndup(str, eq - str), eq + 1); else define_macro(str, "1"); } static FileType parse_opt_x(char *s) { if (!strcmp(s, "c")) return FILE_C; if (!strcmp(s, "assembler")) return FILE_ASM; if (!strcmp(s, "assembler-with-cpp")) return FILE_ASM; if (!strcmp(s, "none")) return FILE_NONE; error("%s : %s:%d: error: in parse_opt_x : unknown argument for -x: %s", MAIN_C, __FILE__, __LINE__, s); } static char *quote_makefile(char *s) { char *buf = calloc(1, strlen(s) * 2 + 1); if (buf == NULL) { error("%s : %s:%d: error: in quote_makefile buf pointer is null!", MAIN_C, __FILE__, __LINE__); } for (int i = 0, j = 0; s[i]; i++) { switch (s[i]) { case '$': buf[j++] = '$'; buf[j++] = '$'; break; case '#': buf[j++] = '\\'; buf[j++] = '#'; break; case ' ': case '\t': for (int k = i - 1; k >= 0 && s[k] == '\\'; k--) buf[j++] = '\\'; buf[j++] = '\\'; buf[j++] = s[i]; break; default: buf[j++] = s[i]; break; } } return buf; } static void parse_args(int argc, char **argv) { // Make sure that all command line options that take an argument // have an argument. for (int i = 1; i < argc; i++) if (take_arg(argv[i])) if (!argv[++i]) { printf("parameter without value! the following parameters need to be followed by a value :\n"); printf("-o, -I, -idirafter, -include, -x, -MF, -MQ, -MT, -Xlinker, -cc1-input, -cc1-output, -fuse-ld, -soname, -rpath, --version-script \n"); usage(1); } StringArray idirafter = {}; for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-###")) { opt_hash_hash_hash = true; continue; } if (!strcmp(argv[i], "-cc1")) { opt_cc1 = true; continue; } if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { usage(0); continue; } if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v") || !strcmp(argv[i], "-V") || !strcmp(argv[i], "-version")) { printVersion(); print_include_directories(); opt_v = true; //exit(0); continue; } if (!strcmp(argv[i], "-fuse-ld")) { opt_linker = argv[++i]; check_parms_length(opt_linker); continue; } if (startsWith(argv[i], "-march=")) { continue; } if (!strcmp(argv[i], "-mno-sse")) { opt_sse = false; continue; } if (!strcmp(argv[i], "-mno-sse2")) { opt_sse2 = false; continue; } if (!strcmp(argv[i], "-mno-sse3")) { opt_sse3 = false; continue; } if (startsWith(argv[i], "-mno-sse4")) { opt_sse4 = false; continue; } if (!strcmp(argv[i], "-mno-mmx")) { opt_mmx = false; continue; } if (!strcmp(argv[i], "-msse")) { opt_sse = true; continue; } if (!strcmp(argv[i], "-msse2")) { opt_sse2 = true; continue; } if (!strcmp(argv[i], "-msse3")) { opt_sse3 = true; continue; } if (startsWith(argv[i], "-msse4")) { opt_sse4 = true; continue; } if (!strcmp(argv[i], "-mmmx")) { opt_mmx = true; continue; } if (startsWith(argv[i], "-flto")) { continue; } if (startsWith(argv[i], "-mtune=")) { continue; } if (!strcmp(argv[i], "-o")) { opt_o = argv[++i]; check_parms_length(opt_o); continue; } if (!strncmp(argv[i], "-o", 2)) { opt_o = argv[i] + 2; continue; } if (!strcmp(argv[i], "-S")) { opt_S = true; continue; } if (!strcmp(argv[i], "-debug")) { isDebug = true; continue; } //to print all tokens if (!strcmp(argv[i], "-print")) { printTokens = true; continue; } if (!strcmp(argv[i], "-dM")) { isPrintMacro = true; continue; } if (!strcmp(argv[i], "-dotfile")) { isDotfile = true; continue; } if (!strcmp(argv[i], "-fcommon")) { opt_fcommon = true; continue; } if (!strcmp(argv[i], "-fno-common")) { opt_fcommon = false; continue; } if (!strcmp(argv[i], "-fno-builtin")) { opt_fbuiltin = false; continue; } if (!strcmp(argv[i], "-c")) { opt_c = true; continue; } if (!strcmp(argv[i], "-E")) { opt_E = true; continue; } // sometimes we can have -I dir or -Idir if (!strncmp(argv[i], "-I", 2)) { if (strlen(argv[i]) == 2) strarray_push(&include_paths, argv[++i]); else strarray_push(&include_paths, argv[i] + 2); continue; } // seems to be used to define macros ? if (!strcmp(argv[i], "-D")) { char *tmp = argv[++i]; // define(argv[++i]); check_parms_length(tmp); define(tmp); continue; } if (!strncmp(argv[i], "-D", 2)) { char *tmp = argv[i] + 2; check_parms_length(tmp); define(tmp); // define(argv[i] + 2); continue; } if (!strcmp(argv[i], "-U")) { char *tmp = argv[++i]; check_parms_length(tmp); undef_macro(tmp); // undef_macro(argv[++i]); continue; } if (!strncmp(argv[i], "-U", 2)) { char *tmp = argv[i] + 2; check_parms_length(tmp); undef_macro(tmp); // undef_macro(argv[i] + 2); continue; } if (!strcmp(argv[i], "-include")) { char *tmp = argv[++i]; check_parms_length(tmp); strarray_push(&opt_include, tmp); // strarray_push(&opt_include, argv[++i]); continue; } if (!strcmp(argv[i], "-x")) { char *tmp = argv[++i]; check_parms_length(tmp); opt_x = parse_opt_x(tmp); continue; } if (!strncmp(argv[i], "-x", 2)) { char *tmp = argv[i] + 2; check_parms_length(tmp); opt_x = parse_opt_x(tmp); continue; } if (!strncmp(argv[i], "-l", 2)) { strarray_push(&input_paths, argv[i]); continue; } if (!strncmp(argv[i], "-Wl,", 4)) { char *opt = argv[i] + 4; if (!strncmp(opt, "-z,", 3)) { strarray_push(&input_paths, argv[i]); continue; } if (!strncmp(opt, "-U,", 3)) { char *ptr = opt + 3; while (*ptr && weak_count < MAX_WEAK) { char *comma = strchr(ptr, ','); if (comma) *comma = '\0'; weak_symbols[weak_count] = strdup(ptr); weak_count++; strarray_push(&ld_extra_args, "-U"); strarray_push(&ld_extra_args, ptr); if (!comma) break; ptr = comma + 1; } continue; } strarray_push(&input_paths, argv[i]); continue; } if (!strcmp(argv[i], "-Xlinker")) { char *tmp = argv[++i]; check_parms_length(tmp); strarray_push(&ld_extra_args, tmp); // strarray_push(&ld_extra_args, argv[++i]); continue; } // not sure why the --version-script is interpreted as -version-script ? if (!strcmp(argv[i], "-version-script") || !strcmp(argv[i], "--version-script")) { char *tmp = argv[++i]; check_parms_length(tmp); strarray_push(&ld_extra_args, "--version-script"); strarray_push(&ld_extra_args, tmp); // strarray_push(&ld_extra_args, argv[++i]); continue; } if (!strcmp(argv[i], "-x")) { char *tmp = argv[++i]; check_parms_length(tmp); strarray_push(&ld_extra_args, tmp); // strarray_push(&ld_extra_args, argv[++i]); continue; } if (!strcmp(argv[i], "-s")) { strarray_push(&ld_extra_args, "-s"); continue; } if (!strcmp(argv[i], "-M")) { opt_M = true; continue; } if (!strcmp(argv[i], "-MF")) { opt_MF = argv[++i]; check_parms_length(opt_MF); continue; } if (!strcmp(argv[i], "-MP")) { opt_MP = true; continue; } if (!strcmp(argv[i], "-MT")) { if (opt_MT == NULL) opt_MT = argv[++i]; else opt_MT = format("%s %s", opt_MT, argv[++i]); check_parms_length(opt_MT); continue; } if (!strcmp(argv[i], "-MD")) { opt_MD = true; continue; } if (!strcmp(argv[i], "-MQ")) { if (opt_MT == NULL) opt_MT = quote_makefile(argv[++i]); else opt_MT = format("%s %s", opt_MT, quote_makefile(argv[++i])); check_parms_length(opt_MT); continue; } if (!strcmp(argv[i], "-MMD")) { opt_MD = opt_MMD = true; continue; } if (!strcmp(argv[i], "-fpic") || !strcmp(argv[i], "-fPIC")) { opt_fpic = true; continue; } //trying to fix -fpie parameter =====ISS-156 forcing shared if -pie is received if (!strcmp(argv[i], "-fpie") || !strcmp(argv[i], "-fPIE") || !strcmp(argv[i], "-pie")) { opt_fpie = true; strarray_push(&ld_extra_args, "-pie"); continue; } if (!strcmp(argv[i], "-fno-pic")) { opt_fpic = false; continue; } if (!strcmp(argv[i], "-cc1-input")) { base_file = argv[++i]; check_parms_length(base_file); isCc1input = true; continue; } if (!strcmp(argv[i], "-cc1-output")) { isCc1output = true; output_file = argv[++i]; check_parms_length(output_file); continue; } if (!strcmp(argv[i], "-idirafter")) { char *tmp = argv[i++]; check_parms_length(tmp); strarray_push(&idirafter, tmp); // strarray_push(&idirafter, argv[i++]); continue; } if (!strcmp(argv[i], "-static")) { opt_static = true; strarray_push(&ld_extra_args, "-static"); continue; } if (!strcmp(argv[i], "-shared")) { opt_shared = true; //opt_fpic = true; strarray_push(&ld_extra_args, "-shared"); continue; } if (!strcmp(argv[i], "-pthread")) { strarray_push(&ld_extra_args, "-lpthread"); continue; } if (!strncmp(argv[i], "-L", 2)) { //strarray_push(&ld_extra_args, "-L"); char *tmp = argv[i]; check_parms_length(tmp); strarray_push(&ld_extra_args, tmp); continue; } if (!strcmp(argv[i], "-L")) { strarray_push(&ld_extra_args, "-L"); char *tmp = argv[++i]; check_parms_length(tmp); strarray_push(&ld_extra_args, tmp); // strarray_push(&ld_extra_args, argv[++i]); continue; } if (!strncmp(argv[i], "-L", 2)) { strarray_push(&ld_extra_args, "-L"); char *tmp = argv[i] + 2; check_parms_length(tmp); strarray_push(&ld_extra_args, tmp); // strarray_push(&ld_extra_args, argv[i] + 2); continue; } if (!strcmp(argv[i], "-hashmap-test")) { hashmap_test(); exit(0); } if (!strcmp(argv[i], "-dumpmachine")) { dump_machine(); exit(0); } if (!strcmp(argv[i], "-dumpversion")) { dump_version(); exit(0); } //-soname create a symbolic link before calling the linker like in gcc -Wl,-soname,libcurl.so.4 -o libcurl.so.4.8.0 if (!strcmp(argv[i], "-soname")) { char *tmp = argv[++i]; check_parms_length(tmp); strarray_push(&ld_extra_args, "-soname"); strarray_push(&ld_extra_args, tmp); // symbolic_name = tmp; continue; } if (!strcmp(argv[i], "Wl,-rpath,") || !strcmp(argv[i], "-rpath")) { char *tmp = argv[++i]; check_parms_length(tmp); r_path = tmp; strarray_push(&ld_extra_args, "-rpath"); strarray_push(&ld_extra_args, r_path); continue; } //for printing AST if (!strcmp(argv[i], "-A")) { opt_A = true; continue; } //-Werror-implicit-function-declaration //for printing AST if (!strcmp(argv[i], "-Werror-implicit-function-declaration")) { opt_implicit = true; continue; } //other options -Axxx ignored if (startsWith(argv[i], "-A")) { continue; } if (!strcmp(argv[i], "-rdynamic")) { strarray_push(&input_paths, "-Wl,--export-dynamic"); continue; } if (!strncmp(argv[i], "-g", 2)) { if (argv[i][2] == '0') opt_g = false; else opt_g = true; continue; } if (!strcmp(argv[i], "-nostdinc")) { opt_nostdinc = true; continue; } if (!strcmp(argv[i], "-nostdlib")) { opt_nostdlib = true; continue; } if (!strcmp(argv[i], "-fstack-protector") || !strcmp(argv[i], "-fstack-protector-strong") || !strcmp(argv[i], "-fstack-clash-protection") ) { opt_fstack_protector = true; continue; } if (!strcmp(argv[i], "-print-search-dirs")) { printf("install: %s/bin\n", LIBDIR); printf("programs: =%s/bin\n", LIBDIR); printf("libraries: =%s/lib\n", LIBDIR); exit(0); } if (!strcmp(argv[i], "-fp-model")) { i++; continue; } // These options are ignored for now. if (startsWith(argv[i], "-O") || !strcmp(argv[i], "-P") || !strcmp(argv[i], "-Wall") || !strcmp(argv[i], "-Wextra") || !strcmp(argv[i], "-Wno-switch") || !strcmp(argv[i], "-Wno-unused-variable") || !strcmp(argv[i], "-Wno-format-y2k") || !strcmp(argv[i], "-Wmissing-prototypes") || !strcmp(argv[i], "-Wno-uninitialized") || !strcmp(argv[i], "-Wmissing-declarations") || !strcmp(argv[i], "-Wredundant-decls") || !strcmp(argv[i], "-Winit-self") || !strcmp(argv[i], "-fno-math-errno") || !strcmp(argv[i], "-fno-rounding-math") || !strcmp(argv[i], "-fno-signaling-nans") || !strcmp(argv[i], "-fcx-limited-range") || !strcmp(argv[i], "-funsafe-math-optimizations") || !strcmp(argv[i], "-funroll-loops") || !strcmp(argv[i], "-ffreestanding") || !strcmp(argv[i], "-fno-omit-frame-pointer") || !strcmp(argv[i], "-fomit-frame-pointer") || !strcmp(argv[i], "-funwind-tables") || !strcmp(argv[i], "-fno-stack-protector") || !strcmp(argv[i], "-fno-strict-aliasing") || !strcmp(argv[i], "-m64") || !strcmp(argv[i], "-m32") || !strcmp(argv[i], "--whole-archive") || !strcmp(argv[i], "--no-whole-archive") || !strcmp(argv[i], "-fsigned-char") || !strcmp(argv[i], "-Bsymbolic") || !strcmp(argv[i], "-pedantic") || !strcmp(argv[i], "-mno-red-zone") || !strcmp(argv[i], "-fvisibility=default") || !strcmp(argv[i], "-fvisibility=hidden") || !strcmp(argv[i], "-Wsign-compare") || !strcmp(argv[i], "-Wundef") || !strcmp(argv[i], "-Wpointer-arith") || !strcmp(argv[i], "-Wvolatile-register-var") || !strcmp(argv[i], "-Wformat") || !strcmp(argv[i], "-Wformat-security") || !strcmp(argv[i], "-Wduplicated-branches") || !strcmp(argv[i], "-Wduplicated-cond") || !strcmp(argv[i], "-Wbad-function-cast") || !strcmp(argv[i], "-Wwrite-strings") || !strcmp(argv[i], "-Wlogical-op") || !strcmp(argv[i], "-Wshadow=local") || !strcmp(argv[i], "-Wmultistatement-macros") || !strcmp(argv[i], "-fdiagnostics-show-option") || !strcmp(argv[i], "-fasynchronous-unwind-tables") || !strcmp(argv[i], "-fexceptions") || !strcmp(argv[i], "-fdiagnostics-show-option") || !strcmp(argv[i], "-Xc") || !strcmp(argv[i], "-Aa") || !strcmp(argv[i], "-w") || !strcmp(argv[i], "-w2") || !strcmp(argv[i], "--param=ssp-buffer-size=4") || !strcmp(argv[i], "-fno-lto") || !strcmp(argv[i], "-fdiagnostics-color=always") || !strcmp(argv[i], "-mfpmath=sse") || !strcmp(argv[i], "-ffunction-sections") || !strcmp(argv[i], "-fdata-sections") || !strcmp(argv[i], "-fprofile-arcs") || !strcmp(argv[i], "-ftest-coverage") || !strcmp(argv[i], "-ansi_alias") || !strcmp(argv[i], "-ffat-lto-objects") || !strcmp(argv[i], "-static-libstdc++") || !strcmp(argv[i], "-static-libgcc") || !strcmp(argv[i], "-pipe") || !strcmp(argv[i], "-mindirect-branch-register") ) continue; if (startsWith(argv[i], "-std")) { char *stdver = argv[i] + 5; if (!strcmp(stdver, "c99") || !strcmp(stdver, "gnu99")) { opt_c99 = true; } else if (!strcmp(stdver, "c11") || !strcmp(stdver, "gnu11")) { opt_c11 = true; } else if (!strcmp(stdver, "c17") || !strcmp(stdver, "gnu17")) { opt_c17 = true; } else { error("%s : %s:%d: error: in parse_args : unsupported -std option: %s", MAIN_C, __FILE__, __LINE__, stdver); exit(1); } continue; } if (argv[i][0] == '-' && argv[i][1] != '\0') error("%s : %s:%d: error: in parse_args unknown argument: %s", MAIN_C, __FILE__, __LINE__, argv[i]); strarray_push(&input_paths, argv[i]); } for (int i = 0; i < idirafter.len; i++) strarray_push(&include_paths, idirafter.data[i]); if (input_paths.len == 0) { if (!opt_v) error("%s : %s:%d: error: in parse_args no input files", MAIN_C, __FILE__, __LINE__); exit(0); } // -E implies that the input is the C macro language. if (opt_E) opt_x = FILE_C; } FILE *open_file(char *path) { if (!path || strcmp(path, "-") == 0) return stdout; FILE *out = fopen(path, "w"); if (!out) error("%s : %s:%d: error: in open_file cannot open output file: %s: %s", MAIN_C, __FILE__, __LINE__, path, strerror(errno)); return out; } static bool endswith(char *p, char *q) { int len1 = strlen(p); int len2 = strlen(q); return (len1 >= len2) && !strcmp(p + len1 - len2, q); } // returns filename example ./test/hello.c returns hello.c char *extract_filename(char *tmpl) { char *filename = basename(strdup(tmpl)); return format("%s", filename); } char * extract_path(char* tmpl) { char* parent = calloc(1, sizeof(char) * 300); int parentLen; char* last = strrchr(tmpl, '/'); if (last != NULL) { parentLen = strlen(tmpl) - strlen(last + 1); if (parentLen > 300) error("%s : %s:%d: error: no enough size for parent in getParent function %d expected ", MAIN_C, __FILE__, __LINE__, parentLen); strncpy(parent, tmpl, parentLen); } return parent; } // Replace file extension char *replace_extn(char *tmpl, char *extn) { char *filename = extract_filename(tmpl); char *dot = strrchr(filename, '.'); if (dot) *dot = '\0'; return format("%s%s", filename, extn); } static void cleanup(void) { if (!isDebug) { for (int i = 0; i < tmpfiles.len; i++) unlink(tmpfiles.data[i]); } if ((isDebug && f != NULL) || (printTokens && f != NULL)) fclose(f); // for dot diagrams if (isDotfile && dotf != NULL) { fprintf(dotf, "}\n"); fclose(dotf); } } static char *create_tmpfile(void) { char *path = strdup("/tmp/chibicc-XXXXXX"); if (path == NULL) error("%s : in create_tmpfile path path is null", MAIN_C); int fd = mkstemp(path); if (fd == -1) error("%s : %s:%d: error: in create_tmpfile mkstemp failed: %s", MAIN_C, __FILE__, __LINE__, strerror(errno)); close(fd); strarray_push(&tmpfiles, path); return path; } static void run_subprocess(char **argv) { // If -### or -debug is given, dump the subprocess's command line. if (opt_hash_hash_hash) { fprintf(stdout, "%s", argv[0]); for (int i = 1; argv[i]; i++) fprintf(stdout, " %s", argv[i]); fprintf(stdout, "\n"); } if (isDebug && f != NULL) { fprintf(f, "%s", argv[0]); for (int i = 1; argv[i]; i++) fprintf(f, " %s", argv[i]); fprintf(f, "\n"); } if (fork() == 0) { execvp(argv[0], argv); fprintf(stderr, "%s : %s:%d: error: in run_subprocess exec failed: %s: %s\n", MAIN_C, __FILE__, __LINE__, argv[0], strerror(errno)); _exit(1); } // Wait for the child process to finish. int status; while (wait(&status) > 0) ; if (status != 0) exit(1); } static void run_cc1(int argc, char **argv, char *input, char *output) { char **args = calloc(argc + 10, sizeof(char *)); if (args == NULL) error("%s : %s:%d: error: in run_cc1 args is null", MAIN_C, __FILE__, __LINE__); memcpy(args, argv, argc * sizeof(char *)); args[argc++] = "-cc1"; if (input) { args[argc++] = "-cc1-input"; args[argc++] = input; } if (output) { args[argc++] = "-cc1-output"; args[argc++] = output; } run_subprocess(args); free(args); } // Print tokens to stdout. Used for -E. static void print_tokens(Token *tok) { FILE *out = open_file(opt_o ? opt_o : "-"); int line = 1; for (; tok->kind != TK_EOF; tok = tok->next) { if (line > 1 && tok->at_bol) fprintf(out, "\n"); if (tok->has_space && !tok->at_bol) fprintf(out, " "); fprintf(out, "%.*s", tok->len, tok->loc); line++; } fprintf(out, "\n"); } static bool in_std_include_path(char *path) { for (int i = 0; i < std_include_paths.len; i++) { char *dir = std_include_paths.data[i]; int len = strlen(dir); if (strncmp(dir, path, len) == 0 && path[len] == '/') return true; } return false; } // If -M options is given, the compiler write a list of input files to // stdout in a format that "make" command can read. This feature is // used to automate file dependency management. static void print_dependencies(void) { char *path; if (opt_MF) path = opt_MF; else if (opt_MD) { // fixing the issue with file.d created in the current directory if no -o parameter or in the output directory define by -o parameter path = replace_extn(opt_o ? opt_o : base_file, ".d"); if (opt_o != NULL) { char *fullpath; //char *filename; //filename = extract_filename(opt_o); fullpath = extract_path(opt_o); strncat(fullpath, path, strlen(path)); path = fullpath; } } else if (opt_o) path = opt_o; else path = "-"; FILE *out = open_file(path); if (opt_MT) fprintf(out, "%s:", opt_MT); else fprintf(out, "%s:", quote_makefile(replace_extn(base_file, ".o"))); File **files = get_input_files(); for (int i = 0; files[i]; i++) { if (opt_MMD && in_std_include_path(files[i]->name)) continue; fprintf(out, " \\\n %s", files[i]->name); } fprintf(out, "\n\n"); if (opt_MP) { for (int i = 1; files[i]; i++) { if (opt_MMD && in_std_include_path(files[i]->name)) continue; fprintf(out, "%s:\n\n", quote_makefile(files[i]->name)); } } } static Token *must_tokenize_file(char *path) { Token *tok = tokenize_file(path); if (!tok) error("%s : %s:%d: error: in must_tokenize_file %s: %s", MAIN_C, __FILE__, __LINE__, path, strerror(errno)); return tok; } static Token *append_tokens(Token *tok1, Token *tok2) { if (!tok1 || tok1->kind == TK_EOF) return tok2; Token *t = tok1; while (t->next->kind != TK_EOF) t = t->next; t->next = tok2; return tok1; } static void cc1(void) { Token *tok = NULL; // Process -include option for (int i = 0; i < opt_include.len; i++) { char *incl = opt_include.data[i]; char *path; if (file_exists(incl)) { path = incl; } else { path = search_include_paths(incl); if (!path) error("%s : %s:%d: error: in cc1 -include: %s: %s", MAIN_C, __FILE__, __LINE__, incl, strerror(errno)); } Token *tok2 = must_tokenize_file(path); tok = append_tokens(tok, tok2); } // Tokenize and parse. Token *tok2 = must_tokenize_file(base_file); bool isReadLine = false; tok = append_tokens(tok, tok2); tok = preprocess(tok, isReadLine); // If -M or -MD are given, print file dependencies. if (opt_M || opt_MD) { print_dependencies(); if (opt_M) return; } if (isPrintMacro) { print_all_macros(); if (ofile) fclose(ofile); return; } // If -E is given, print out preprocessed C code as a result. if (opt_E) { print_tokens(tok); return; } Obj *prog = parse(tok); if (opt_A) { print_ast(f, prog); return; } // Open a temporary output buffer. char *buf; size_t buflen; FILE *output_buf = open_memstream(&buf, &buflen); // Traverse the AST to emit assembly. codegen(prog, output_buf); fclose(output_buf); // Write the asembly text to a file. FILE *out = open_file(output_file); fwrite(buf, buflen, 1, out); fclose(out); } static void assemble(char *input, char *output) { if (endswith(input, ".S")) { char *cmd[] = {"gcc", "-c", "-masm=intel", input, "-o", output, NULL}; run_subprocess(cmd); } else { char *cmd[] = {"as", "-c", input, "-o", output, NULL}; run_subprocess(cmd); } } // static void symbolic_link(char *input, char *output) { // char *cmd[] = {"ln", "-s", "-f", output, input, NULL}; // run_subprocess(cmd); // } void dump_machine(void) { fprintf(stdout, DEFAULT_TARGET_MACHINE "\n"); } void dump_version(void) { fprintf(stdout, VERSION "\n"); } static char *find_file(char *pattern) { char *path = NULL; glob_t buf = {}; glob(pattern, 0, NULL, &buf); if (buf.gl_pathc > 0) path = strdup(buf.gl_pathv[buf.gl_pathc - 1]); globfree(&buf); return path; } // Returns true if a given file exists. bool file_exists(char *path) { struct stat st; return !stat(path, &st); } static char *find_libpath(void) { if (file_exists("/usr/lib/x86_64-linux-gnu/crti.o")) return "/usr/lib/x86_64-linux-gnu"; if (file_exists("/usr/lib64/crti.o")) return "/usr/lib64"; error("%s : %s:%d: error: in find_libpath library path is not found", MAIN_C, __FILE__, __LINE__); } static char *find_gcc_libpath(void) { char *paths[] = { "/usr/lib/gcc/x86_64-linux-gnu/*/crtbegin.o", "/usr/lib/gcc/x86_64-*/*/crtbegin.o", "/usr/lib/gcc/x86_64-pc-linux-gnu/*/crtbegin.o", // For Gentoo "/usr/lib/gcc/x86_64-redhat-linux/*/crtbegin.o", // For Fedora }; for (int i = 0; i < sizeof(paths) / sizeof(*paths); i++) { char *path = find_file(paths[i]); if (path) return dirname(path); } error("%s : %s:%d: error: in find_gcc_libpath gcc library path is not found", MAIN_C, __FILE__, __LINE__); } static void run_linker(StringArray *inputs, char *output) { StringArray arr = {}; if (opt_linker != NULL) { strarray_push(&arr, opt_linker); } else { strarray_push(&arr, "ld"); } strarray_push(&arr, "-o"); strarray_push(&arr, output); strarray_push(&arr, "-m"); strarray_push(&arr, "elf_x86_64"); strarray_push(&arr, "--allow-multiple-definition"); //for some projects like POSTGRES it seems that the specific path for the project //should be defined first for (int i = 0; i < ld_extra_args.len; i++) { //printf("====%s\n", ld_extra_args.data[i]); strarray_push(&arr, ld_extra_args.data[i]); } if (opt_shared) { opt_nostdlib = false; } else if (opt_fstack_protector) { opt_nostdlib = false; } //enabling verbose mode for linker in case of debug if (isDebug) strarray_push(&arr, "--verbose=1"); char *libpath = find_libpath(); char *gcc_libpath = find_gcc_libpath(); if (opt_shared && !opt_fpic) strarray_push(&ld_extra_args, "-fPIC"); // Only add startup files if not using -nostdlib if (!opt_nostdlib) { if (opt_shared) { strarray_push(&arr, format("%s/crti.o", libpath)); strarray_push(&arr, format("%s/crtbeginS.o", gcc_libpath)); } //trying to fix ====ISS-156 fpie parameter else if (opt_fpie) { strarray_push(&arr, format("%s/Scrt1.o", libpath)); strarray_push(&arr, format("%s/crti.o", libpath)); strarray_push(&arr, format("%s/crtbeginS.o", gcc_libpath)); //strarray_push(&arr, format("%s/crtendS.o", gcc_libpath)); } else { strarray_push(&arr, format("%s/crt1.o", libpath)); strarray_push(&arr, format("%s/crti.o", libpath)); strarray_push(&arr, format("%s/crtbegin.o", gcc_libpath)); } } strarray_push(&arr, format("-L%s", gcc_libpath)); strarray_push(&arr, "-L/usr/lib/x86_64-linux-gnu"); strarray_push(&arr, "-L/usr/lib64"); strarray_push(&arr, "-L/lib64"); strarray_push(&arr, "-L/usr/lib/x86_64-linux-gnu"); strarray_push(&arr, "-L/lib/x86_64-linux-gnu"); strarray_push(&arr, "-L/usr/lib/x86_64-pc-linux-gnu"); strarray_push(&arr, "-L/usr/lib/x86_64-redhat-linux"); strarray_push(&arr, "-L/usr/lib"); strarray_push(&arr, "-L/lib"); strarray_push(&arr, "-L."); if (!opt_static) { strarray_push(&arr, "-dynamic-linker"); strarray_push(&arr, "/lib64/ld-linux-x86-64.so.2"); } for (int i = 0; i < inputs->len; i++) { //printf("====%s\n", inputs->data[i]); strarray_push(&arr, inputs->data[i]); } if (opt_static) { strarray_push(&arr, "--start-group"); strarray_push(&arr, "-lgcc"); strarray_push(&arr, "-lgcc_eh"); strarray_push(&arr, "-lc"); strarray_push(&arr, "--end-group"); } else { strarray_push(&arr, "-lc"); strarray_push(&arr, "-lgcc"); strarray_push(&arr, "--as-needed"); strarray_push(&arr, "-lgcc_s"); //strarray_push(&arr, "--no-as-needed"); } if (!opt_nostdlib) { strarray_push(&arr, "-lm"); } // Add the ending object file if not using -nostdlib if (!opt_nostdlib) { if (opt_shared || opt_fpie) strarray_push(&arr, format("%s/crtendS.o", gcc_libpath)); else if(!opt_fpie) strarray_push(&arr, format("%s/crtend.o", gcc_libpath)); } strarray_push(&arr, format("%s/crtn.o", libpath)); strarray_push(&arr, NULL); if (isDebug) print_string_array(&arr); run_subprocess(arr.data); } static FileType get_file_type(char *filename) { if (endswith(filename, ".a")) return FILE_AR; if (endswith(filename, ".so") || strstr(filename, ".so.")) return FILE_DSO; if (endswith(filename, ".lo")) return FILE_DSO; if (endswith(filename, ".o")) return FILE_OBJ; if (endswith(filename, ".c") ) return FILE_C; if (endswith(filename, ".s") || (endswith(filename, ".S")) || endswith(filename, ".asm")) return FILE_ASM; if (endswith(filename, ".so.4")) return FILE_DSO; if (endswith(filename, ".rsp")) return FILE_RSP; if (opt_x != FILE_NONE) return opt_x; error("%s : %s:%d: error: in get_file_type : unknown file extension: %s", MAIN_C, __FILE__, __LINE__, filename); } int main(int argc, char **argv) { int file_count = 0; // Enable core dumps and set up signal handlers enable_core_dump(); setup_signal_handlers(); atexit(cleanup); ctx = calloc(1, sizeof(Context)); parse_args(argc, argv); // the parsing need to be done before trying to open the log file if ((isDebug && f == NULL) || (printTokens && f == NULL) || opt_A) { f = fopen(logFile, "w"); if (f == NULL) { error("%s : %s:%d: error: in main Issue with -debug or -printparameter, file not opened!", MAIN_C, __FILE__, __LINE__); exit(1); } } //print macro in preprocess.c if (isPrintMacro) { ofile = open_file(opt_o); } // init_macros can call tokenize functions moving here to be able to print debug values init_macros(); if (opt_cc1 && !isCc1input) { error("%s : %s:%d: error: in main with -cc1 parameter -cc1-input is mandatory!", MAIN_C, __FILE__, __LINE__); usage(-1); } //from @fuhsnn fix if (input_paths.len > 1 && opt_o && (opt_c || opt_S || opt_E)) if (++file_count > 1) error("%s : %s:%d: error: in main cannot specify '-o' with '-c,' '-S' or '-E' with multiple files", MAIN_C, __FILE__, __LINE__); StringArray ld_args = {}; for (int i = 0; i < input_paths.len; i++) { char *input = input_paths.data[i]; if (!strncmp(input, "-l", 2)) { strarray_push(&ld_args, input); continue; } if (!strncmp(input, "-Wl,", 4)) { char *s = strdup(input + 4); char *arg = strtok(s, ","); while (arg) { strarray_push(&ld_args, arg); arg = strtok(NULL, ","); } continue; } char *output; if (opt_o) output = opt_o; else if (opt_S) output = replace_extn(input, ".s"); else output = replace_extn(input, ".o"); FileType type = get_file_type(input); // Handle .o or .a if (type == FILE_OBJ || type == FILE_AR || type == FILE_DSO) { strarray_push(&ld_args, input); continue; } // Handle .s, -S, .asm if (type == FILE_ASM) { if (!opt_S) assemble(input, output); continue; } if (type == FILE_RSP) { continue; } if (opt_cc1) { add_default_include_paths(argv[0]); cc1(); return 0; } assert(type == FILE_C); // Just preprocess if (opt_E || opt_M) { run_cc1(argc, argv, input, NULL); continue; } // Compile if (opt_S) { run_cc1(argc, argv, input, output); continue; } if (opt_A) { run_cc1(argc, argv, input, NULL); continue; } // Compile and assemble if (opt_c) { char *tmp = create_tmpfile(); run_cc1(argc, argv, input, tmp); assemble(tmp, output); continue; } // Compile, assemble and link char *tmp1 = create_tmpfile(); char *tmp2 = create_tmpfile(); run_cc1(argc, argv, input, tmp1); assemble(tmp1, tmp2); strarray_push(&ld_args, tmp2); continue; } if (ld_args.len > 0) { // if (symbolic_name) // symbolic_link(symbolic_name, opt_o); run_linker(&ld_args, opt_o ? opt_o : "a.out"); } //free(opt_MT); return 0; } bool startsWith(const char *restrict string, const char *restrict prefix) { while(*prefix) { if(*prefix++ != *string++) return 0; } return 1; }chibicc-1.0.23.1/parse.c000066400000000000000000007273131505335450300146160ustar00rootroot00000000000000// This file contains a recursive descent parser for C. // // Most functions in this file are named after the symbols they are // supposed to read from an input token list. For example, stmt() is // responsible for reading a statement from a token list. The function // then construct an AST node representing a statement. // // Each function conceptually returns two values, an AST node and // remaining part of the input tokens. Since C doesn't support // multiple return values, the remaining tokens are returned to the // caller via a pointer argument. // // Input tokens are represented by a linked list. Unlike many recursive // descent parsers, we don't have the notion of the "input token stream". // Most parsing functions don't change the global state of the parser. // So it is very easy to lookahead arbitrary number of tokens in this // parser. #include "chibicc.h" #define PARSE_C "parse.c" // Scope for local variables, global variables, typedefs // or enum constants // Represents a block scope. typedef struct Scope Scope; struct Scope { Scope *next; // C has two block scopes; one is for variables/typedefs and // the other is for struct/union/enum tags. HashMap vars; HashMap tags; }; typedef struct VarAttr VarAttr; // Variable attributes such as typedef or extern. struct VarAttr { bool is_typedef; bool is_static; bool is_extern; bool is_inline; bool is_tls; int align; //from COSMOPOLITAN adding some attributes bool is_weak; bool is_ms_abi; bool is_aligned; bool is_noreturn; bool is_destructor; bool is_constructor; bool is_externally_visible; bool is_no_instrument_function; bool is_force_align_arg_pointer; bool is_no_caller_saved_registers; char *section; char *visibility; char *alias_name; //to store alias name for function when weak attribute int destructor_priority; int constructor_priority; bool is_packed; }; // For local variable initializer. typedef struct InitDesg InitDesg; struct InitDesg { InitDesg *next; int idx; Member *member; Obj *var; }; typedef struct { const char *name; int node_kind; } BuiltinEntry; static int nbFunc = 0; static Type* ArrayType[50][50]; static Token* ArrayToken[50][50]; static Token* ArrayTokenOrder[50][50]; static int order = 0; static bool is_old_style = false; static Type * current_type; static VarAttr * current_attr; // All local variable instances created during parsing are // accumulated to this list. static Obj *locals; static char* current_section; // Likewise, global variables are accumulated to this list. static Obj *globals; static Scope *scope = &(Scope){}; // Points to the function object the parser is currently parsing. static Obj *current_fn; // Lists of all goto statements and labels in the curent function. static Node *gotos; static Node *labels; // Current "goto" and "continue" jump targets. static char *brk_label; static char *cont_label; // Points to a node representing a switch if we are parsing // a switch statement. Otherwise, NULL. static Node *current_switch; static Obj *builtin_alloca; extern Context *ctx; static bool is_typename(Token *tok); static Type *declspec(Token **rest, Token *tok, VarAttr *attr); static Type *typename(Token **rest, Token *tok); static Type *enum_specifier(Token **rest, Token *tok); static Type *typeof_specifier(Token **rest, Token *tok); static Type *type_suffix(Token **rest, Token *tok, Type *ty); static Type *declarator(Token **rest, Token *tok, Type *ty); static Node *declaration(Token **rest, Token *tok, Type *basety, VarAttr *attr); static void array_initializer2(Token **rest, Token *tok, Initializer *init, int i); static void struct_initializer2(Token **rest, Token *tok, Initializer *init, Member *mem, bool post_desig); static void initializer2(Token **rest, Token *tok, Initializer *init); static Initializer *initializer(Token **rest, Token *tok, Type *ty, Type **new_ty); static Node *lvar_initializer(Token **rest, Token *tok, Obj *var); static void gvar_initializer(Token **rest, Token *tok, Obj *var); static Node *compound_stmt(Token **rest, Token *tok, Node **last); static Node *stmt(Token **rest, Token *tok, bool chained); static Node *expr_stmt(Token **rest, Token *tok); static Node *expr(Token **rest, Token *tok); //static int64_t eval(Node *node); static int64_t eval2(Node *node, char ***label); static int64_t eval_rval(Node *node, char ***label); static bool is_const_expr(Node *node); static Node *assign(Token **rest, Token *tok); static Node *logor(Token **rest, Token *tok); static double eval_double(Node *node); static Node *conditional(Token **rest, Token *tok); static Node *logand(Token **rest, Token *tok); static Node * bitor (Token * *rest, Token *tok); static Node *bitxor(Token **rest, Token *tok); static Node *bitand(Token **rest, Token *tok); static Node *equality(Token **rest, Token *tok); static Node *relational(Token **rest, Token *tok); static Node *shift(Token **rest, Token *tok); static Node *add(Token **rest, Token *tok); static Node *new_add(Node *lhs, Node *rhs, Token *tok, bool is_op); static Node *new_sub(Node *lhs, Node *rhs, Token *tok, bool is_op); static Node *mul(Token **rest, Token *tok); static Node *cast(Token **rest, Token *tok); static Member *get_struct_member(Type *ty, Token *tok); static Type *struct_decl(Token **rest, Token *tok); static Type *union_decl(Token **rest, Token *tok); static Node *postfix(Token **rest, Token *tok); static Node *funcall(Token **rest, Token *tok, Node *node); static Node *unary(Token **rest, Token *tok); static Node *primary(Token **rest, Token *tok); static Node *parse_typedef(Token **rest, Token *tok, Type *basety); static bool is_function(Token *tok); static Token *function(Token *tok, Type *basety, VarAttr *attr); static Token *global_variable(Token *tok, Type *basety, VarAttr *attr); //static void initializer3(Token **rest, Token *tok, Initializer *init); //from COSMOPOLITAN adding attribute for variable static Token *thing_attributes(Token *tok, void *arg); static Token *attribute_list(Token *tok, void *arg, Token *(*f)(Token *, void *)); static Token *type_attributes(Token *tok, void *arg); static Token *static_assertion(Token *tok); //managing old C style function definition static bool check_old_style(Token **rest, Token *tok); //from cosmopolitan managing builtin functions static Node *ParseAtomic2(NodeKind kind, Token *tok, Token **rest); static Node *ParseAtomic3(NodeKind kind, Token *tok, Token **rest); static Node *ParseAtomicCompareExchangeN(NodeKind kind, Token *tok, Token **rest); //for builtin functions static Node *parse_memcpy(Token *tok, Token **rest); static Node *parse_memset(Token *tok, Token **rest); static Node *ParseBuiltin(NodeKind kind, Token *tok, Token **rest); static Node *parse_overflow(NodeKind kind, Token *tok, Token **rest); static Node *parse_huge_val(double fval, Token *tok, Token **rest); static Token * old_style_params(Token **rest, Token *tok, Type *ty); static Type *old_params(Type *ty, int nbparms); //from @fuhsnn static int64_t eval_sign_extend(Type *ty, uint64_t val); static bool is_const_var(Obj *var); static int64_t eval_rval(Node *node, char ***label); static Obj *eval_var(Node *expr, bool allow_local); static bool is_const_var(Obj *var) ; static bool is_str_tok(Token **rest, Token *tok, Token **str_tok); static Node *compound_stmt2(Token **rest, Token *tok); static int builtin_enum(Token *tok); static Node *scalar_to_vector(Node *scalar, Type *vec_ty); static void promote_scalar_to_vector(Node *node); static int align_down(int n, int align) { return (n / align) * align; } static void enter_scope(void) { Scope *sc = calloc(1, sizeof(Scope)); if (sc == NULL) error("%s %s:%d: in enter_scope : sc pointer is null!", PARSE_C, __FILE__, __LINE__ ); sc->next = scope; scope = sc; } static void leave_scope(void) { scope = scope->next; } // Find a variable by name. VarScope *find_var(Token *tok) { for (Scope *sc = scope; sc; sc = sc->next) { VarScope *sc2 = hashmap_get2(&sc->vars, tok->loc, tok->len); if (sc2) return sc2; } return NULL; } static Type *find_tag(Token *tok) { for (Scope *sc = scope; sc; sc = sc->next) { Type *ty = hashmap_get2(&sc->tags, tok->loc, tok->len); if (ty) return ty; } return NULL; } static Node *new_node(NodeKind kind, Token *tok) { static int count = 0; Node *node = calloc(1, sizeof(Node)); if (node == NULL) error("%s:%s:%d: error: in new_node : node is null", PARSE_C, __FILE__, __LINE__); node->kind = kind; node->unique_number = count++; node->tok = tok; return node; } static Node *new_binary(NodeKind kind, Node *lhs, Node *rhs, Token *tok) { Node *node = new_node(kind, tok); if (isDotfile && dotf != NULL) { fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(rhs->kind), rhs->unique_number); fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(lhs->kind), lhs->unique_number); } node->lhs = lhs; node->rhs = rhs; add_type(node->rhs); if (kind == ND_ASSIGN && node->rhs->ty->kind == TY_VOID ) { error_tok(node->rhs->tok, "%s %d: in new_binary : Cannot assign void type expression", PARSE_C, __LINE__); } // TODO type check other binary expressions, e.g., ND_ADD return node; } static Node *new_unary(NodeKind kind, Node *expr, Token *tok) { Node *node = new_node(kind, tok); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(expr->kind), expr->unique_number); node->lhs = expr; add_type(node->lhs); return node; } static Node *new_double(double fval, Token *tok) { Node *node = new_node(ND_NUM, tok); node->fval = fval; node->ty = ty_double; return node; } static Node *new_num(int64_t val, Token *tok) { Node *node = new_node(ND_NUM, tok); node->val = val; return node; } static Node *new_long(int64_t val, Token *tok) { Node *node = new_node(ND_NUM, tok); node->val = val; node->ty = ty_long; return node; } static Node *new_ulong(long val, Token *tok) { Node *node = new_node(ND_NUM, tok); node->val = val; node->ty = ty_ulong; return node; } static Node *new_boolean(bool val, Token *tok) { Node *node = new_node(ND_NUM, tok); node->val = val; node->ty = ty_bool; return node; } static Node *new_var_node(Obj *var, Token *tok) { Node *node = new_node(ND_VAR, tok); node->var = var; return node; } static Node *new_vla_ptr(Obj *var, Token *tok) { Node *node = new_node(ND_VLA_PTR, tok); node->var = var; return node; } Node *new_cast(Node *expr, Type *ty) { //fix for case when cast has __attribute__ add_type(expr); Node *node = calloc(1, sizeof(Node)); if (node == NULL) error("%s: %s:%d: error: in new_cast : node is null", PARSE_C, __FILE__, __LINE__); node->kind = ND_CAST; node->tok = expr->tok; node->lhs = expr; if (!ty) error("%s: %s:%d: error: in new_cast : type is null", PARSE_C, __FILE__, __LINE__); node->ty = copy_type(ty); return node; } static void apply_cv_qualifier(Node *node, Type *ty2) { add_type(node); Type *ty = node->ty; if (ty->is_const < ty2->is_const || ty->is_volatile < ty2->is_volatile) { node->ty = new_qualified_type(ty); node->ty->is_const = ty->is_const | ty2->is_const; node->ty->is_volatile = ty->is_volatile | ty2->is_volatile; } } static VarScope *push_scope(char *name) { VarScope *sc = calloc(1, sizeof(VarScope)); if (sc == NULL) error("%s: %s:%d: error: in push_scope : sc is null!", PARSE_C, __FILE__, __LINE__); hashmap_put(&scope->vars, name, sc); return sc; } static Initializer *new_initializer(Type *ty, bool is_flexible) { Initializer *init = calloc(1, sizeof(Initializer)); if (init == NULL) error("%s: %s:%d: error: in new_initializer : init is null", PARSE_C, __FILE__, __LINE__); init->ty = ty; if (ty->kind == TY_ARRAY) { if (is_flexible && (ty->size < 0 || ty->array_len < 0)) { init->is_flexible = true; return init; } init->children = calloc(ty->array_len, sizeof(Initializer *)); if (init->children == NULL) error("%s: %s:%d: error: in new_initializer : init->children is null %d %d", PARSE_C, __FILE__, __LINE__, ty->array_len, ty->size); for (int i = 0; i < ty->array_len; i++) init->children[i] = new_initializer(ty->base, false); return init; } if (ty->kind == TY_VECTOR) { init->children = calloc(ty->array_len, sizeof(Initializer *)); if (init->children == NULL) error("%s: %s:%d: error: in new_initializer : init->children is null %d %d", PARSE_C, __FILE__, __LINE__, ty->array_len, ty->size); for (int i = 0; i < ty->array_len; i++) init->children[i] = new_initializer(ty->base, false); return init; } if (ty->kind == TY_STRUCT || ty->kind == TY_UNION) { // Count the number of struct members. int len = 0; for (Member *mem = ty->members; mem; mem = mem->next) mem->idx = len++; init->children = calloc(len, sizeof(Initializer *)); if (init->children == NULL) error("%s: %s:%d: error: in new_initializer : init->children is null (bis)", PARSE_C, __FILE__, __LINE__); for (Member *mem = ty->members; mem; mem = mem->next) { if (is_flexible && ty->is_flexible && !mem->next) { Initializer *child = calloc(1, sizeof(Initializer)); if (child == NULL) error("%s: %s:%d: error: in new_initializer : child is null", PARSE_C, __FILE__, __LINE__); child->ty = mem->ty; child->is_flexible = true; init->children[mem->idx] = child; } else { init->children[mem->idx] = new_initializer(mem->ty, false); } } return init; } return init; } static Obj *new_var(char *name, Type *ty) { Obj *var = calloc(1, sizeof(Obj)); if (var == NULL) error("%s: %s:%d: error: in new_var : var is null", PARSE_C, __FILE__, __LINE__); var->name = name; var->ty = ty; var->align = ty->align; push_scope(name)->var = var; return var; } static Obj *new_lvar(char *name, Type *ty, char *funcname) { Obj *var = new_var(name, ty); var->is_local = true; var->next = locals; var->order = order; var->is_weak = ty->is_weak; if (!funcname) funcname = current_fn->funcname; var->funcname = funcname; if (var->ty->kind == TY_PTR) { var->ty->is_pointer = true; var->ty->pointertype = ty->base; var->ty->size = ty->size; } locals = var; return var; } static Obj *new_gvar(char *name, Type *ty) { Obj *var = new_var(name, ty); var->next = globals; var->is_static = true; var->is_definition = true; globals = var; return var; } static char *new_unique_name(void) { static int id = 0; return format(".L..%d", id++); } static Obj *new_anon_gvar(Type *ty) { return new_gvar(new_unique_name(), ty); } static Obj *new_string_literal(char *p, Type *ty) { Obj *var = new_anon_gvar(ty); var->init_data = p; return var; } static char *get_ident(Token *tok) { if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: in get_ident : expected an identifier", PARSE_C, __LINE__); return strndup(tok->loc, tok->len); } static Type *find_typedef(Token *tok) { if (tok->kind == TK_IDENT) { VarScope *sc = find_var(tok); if (sc) { if (sc->type_def) return sc->type_def; } } return NULL; } static void push_tag_scope(Token *tok, Type *ty) { hashmap_put2(&scope->tags, tok->loc, tok->len, ty); } // declspec = ("void" | "_Bool" | "char" | "short" | "int" | "long" | "double" // | "typedef" | "static" | "extern" | "inline" // | "_Thread_local" | "__thread" // | "signed" | "unsigned" // | struct-decl | union-decl | typedef-name // | enum-specifier | typeof-specifier // | "const" | "volatile" | "auto" | "register" | "restrict" // | "__restrict" | "__restrict__" | "_Noreturn" | )+ // The order of typenames in a type-specifier doesn't matter. For // example, `int long static` means the same as `static long int`. // That can also be written as `static long` because you can omit // `int` if `long` or `short` are specified. However, something like // `char int` is not a valid type specifier. We have to accept only a // limited combinations of the typenames. // // In this function, we count the number of occurrences of each typename // while keeping the "current" type object that the typenames up // until that point represent. When we reach a non-typename token, // we returns the current type object. static Type *declspec(Token **rest, Token *tok, VarAttr *attr) { // We use a single integer as counters for all typenames. // For example, bits 0 and 1 represents how many times we saw the // keyword "void" so far. With this, we can use a switch statement // as you can see below. enum { VOID = 1 << 0, BOOL = 1 << 2, CHAR = 1 << 4, SHORT = 1 << 6, INT = 1 << 8, LONG = 1 << 10, FLOAT = 1 << 12, DOUBLE = 1 << 14, OTHER = 1 << 16, SIGNED = 1 << 17, UNSIGNED = 1 << 18, INT128 = 1 << 19, }; Type *ty = ty_int; int counter = 0; bool is_atomic = false; while (is_typename(tok)) { tok = attribute_list(tok, ty, type_attributes); //fixing =====ISS-155 __label__ out; if (equal(tok, "__label__")) { consume(&tok, tok, "__label__"); //skip the label identifier tok = tok->next; SET_CTX(ctx); tok = skip(tok, ";", ctx); } // Handle storage class specifiers. if (equal(tok, "typedef") || equal(tok, "static") || equal(tok, "extern") || equal(tok, "__inline") || equal(tok, "inline") || equal(tok, "_Thread_local") || equal(tok, "__thread")) { if (!attr) error_tok(tok, "%s %d: in declspec : storage class specifier is not allowed in this context", PARSE_C, __LINE__); if (equal(tok, "typedef")) attr->is_typedef = true; else if (equal(tok, "static")) attr->is_static = true; else if (equal(tok, "extern")) attr->is_extern = true; else if (equal(tok, "inline") || equal(tok, "__inline")) attr->is_inline = true; else if (equal(tok, "_Thread_local") || equal(tok, "__thread")) attr->is_tls = true; else error_tok(tok, "%s %d: in declspec : unknown storage class specifier", PARSE_C, __LINE__); //fixing check for typedef specifier/attribute not strict enough #142 suggested by @samkho if (attr->is_typedef && attr->is_static + attr->is_extern + attr->is_inline + attr->is_tls >= 1) error_tok(tok, "%s %d: in declspec : typedef may not be used together with static," " extern, inline, __thread or _Thread_local", PARSE_C, __LINE__); tok = tok->next; //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, attr, thing_attributes); continue; } // These keywords are recognized but ignored. // fixing issue #119 _Complex if (consume(&tok, tok, "const") || consume(&tok, tok, "volatile") || consume(&tok, tok, "auto") || consume(&tok, tok, "register") || consume(&tok, tok, "_Complex") || consume(&tok, tok, "restrict") || consume(&tok, tok, "__restrict") || consume(&tok, tok, "__restrict__") || consume(&tok, tok, "_Noreturn")) continue; if (equal(tok, "_Atomic")) { tok = tok->next; if (equal(tok, "(")) { ty = typename(&tok, tok->next); SET_CTX(ctx); tok = skip(tok, ")", ctx); } is_atomic = true; continue; } if (equal(tok, "_Alignas")) { if (!attr) error_tok(tok, "%s %d: in declspec : _Alignas is not allowed in this context", PARSE_C, __LINE__); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); int align; if (is_typename(tok)) align = typename(&tok, tok)->align; else align = const_expr(&tok, tok); attr->align = MAX(attr->align, align); // if (attr->align > ty->align) { // ty->align = attr->align; // } if (attr->align > ty->align) { ty = copy_type(ty); ty->align = attr->align; } SET_CTX(ctx); tok = skip(tok, ")", ctx); continue; } if (attr && attr->is_typedef) { tok = attribute_list(tok, ty, type_attributes); } else if (attr) { tok = attribute_list(tok, attr, thing_attributes); } // Handle user-defined types. Type *ty2 = find_typedef(tok); tok = attribute_list(tok, ty2, type_attributes); if (equal(tok, "struct") || equal(tok, "union") || equal(tok, "enum") || equal(tok, "typeof") || equal(tok, "__typeof") || ty2) { if (counter) break; if (equal(tok, "struct")) { ty = struct_decl(&tok, tok->next); } else if (equal(tok, "union")) { ty = union_decl(&tok, tok->next); } else if (equal(tok, "enum")) { ty = enum_specifier(&tok, tok->next); } else if (equal(tok, "typeof") || equal(tok, "__typeof")) { ty = typeof_specifier(&tok, tok->next); } else { ty = ty2; tok = tok->next; } counter += OTHER; continue; } // Handle built-in types. if (equal(tok, "void")) counter += VOID; else if (equal(tok, "_Bool")) counter += BOOL; else if (equal(tok, "char")) counter += CHAR; else if (equal(tok, "short")) counter += SHORT; else if (equal(tok, "int")) counter += INT; else if (equal(tok, "long")) counter += LONG; else if (equal(tok, "float")) counter += FLOAT; else if (equal(tok, "double")) counter += DOUBLE; else if (equal(tok, "__int128")) counter += INT128; else if (equal(tok, "signed")) counter |= SIGNED; else if (equal(tok, "unsigned")) counter |= UNSIGNED; else unreachable(); switch (counter) { case VOID: ty = ty_void; break; case BOOL: ty = ty_bool; break; case CHAR: case SIGNED + CHAR: ty = ty_char; break; case UNSIGNED + CHAR: ty = ty_uchar; break; case SHORT: case SHORT + INT: case SIGNED + SHORT: case SIGNED + SHORT + INT: ty = ty_short; break; case UNSIGNED + SHORT: case UNSIGNED + SHORT + INT: ty = ty_ushort; break; case INT: case SIGNED: case SIGNED + INT: ty = ty_int; break; case INT128: case SIGNED + INT128: ty = copy_type(ty_int128); break; case UNSIGNED: case UNSIGNED + INT: ty = ty_uint; break; case LONG: case LONG + INT: case SIGNED + LONG: case SIGNED + LONG + INT: ty = ty_long; break; case LONG + LONG: case LONG + LONG + INT: case SIGNED + LONG + LONG: case SIGNED + LONG + LONG + INT: ty = ty_llong; break; case UNSIGNED + LONG: case UNSIGNED + LONG + INT: ty = ty_ulong; break; case UNSIGNED + LONG + LONG: case UNSIGNED + LONG + LONG + INT: ty = ty_ullong; break; case UNSIGNED + INT128: ty = copy_type(ty_uint128); break; case FLOAT: ty = ty_float; break; case DOUBLE: ty = ty_double; break; case LONG + DOUBLE: ty = ty_ldouble; break; default: error_tok(tok, "%s %d: in declspec : invalid type", PARSE_C, __LINE__); } tok = tok->next; //to fix attributes after or before the identifier // if (attr && !attr->is_typedef) { // tok = attribute_list(tok, attr, thing_attributes); // tok->next = attribute_list(tok->next, attr, thing_attributes); // } else { // tok = attribute_list(tok, ty, type_attributes); // tok->next = attribute_list(tok->next, ty, type_attributes); // } } if (is_atomic) { ty = copy_type(ty); ty->is_atomic = true; } *rest = tok; if (!ty) error_tok(tok, "%s %d: in declspec : ty is null!", PARSE_C, __LINE__); return ty; } // func-params = ("void" | param ("," param)* ("," "...")?)? ")" // param = declspec declarator static Type *func_params(Token **rest, Token *tok, Type *ty) { //tok = attribute_list(tok, ty, type_attributes); if (equal(tok, "void") && equal(tok->next, ")")) { *rest = tok->next->next; return func_type(ty); } Type head = {}; Type *cur = &head; bool is_variadic = false; int nbparms = 0; while (!equal(tok, ")") && !equal(tok->next, "{")) { tok = attribute_list(tok, ty, type_attributes); if (cur != &head) { if (equal(tok, ";")) { SET_CTX(ctx); tok = skip(tok, ";", ctx); } //fix for Static assert declaration ISS-165/ISS-166 else if (!equal(tok, ",")) { Node *node = expr(&tok, tok); if (eval(node->lhs) == 0) { error("%s: %s:%d: tatic assert error : %s", PARSE_C, __FILE__, __LINE__, node->rhs->tok->loc); } while(!equal(tok->next, ";")) tok = tok->next; break; } else { SET_CTX(ctx); tok = skip(tok, ",", ctx); } } tok = attribute_list(tok, ty, type_attributes); if (equal(tok, "...")) { is_variadic = true; tok = tok->next; SET_CTX(ctx); skip(tok, ")", ctx); break; } Type *ty2 = declspec(&tok, tok, NULL); tok = attribute_list(tok, ty2, type_attributes); //Type *backup = ty2; if (is_old_style) { Token *backup = tok; while(equal(tok, "*")) { tok = tok->next; } if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: in func_params : expected identifier old source code not managed yet", PARSE_C, __LINE__); ArrayToken[nbFunc][nbparms] = tok; tok = backup; } ty2 = declarator(&tok, tok, ty2); tok = attribute_list(tok, ty2, type_attributes); if (!ty2) error_tok(tok, "%s %d: in func_params : ty2 is null", PARSE_C, __LINE__); // if (ty2->kind == TY_PTR) // { // ty2->is_pointer = true; // ty2->pointertype = backup; // } Token *name = ty2->name; if (is_array(ty2)) { // "array of T" is converted to "pointer to T" only in the parameter // context. For example, *argv[] is converted to **argv by this. ty2 = pointer_to(ty2->base); ty2->name = name; } else if (ty2->kind == TY_FUNC) { // Likewise, a function is converted to a pointer to a function // only in the parameter context. ty2 = pointer_to(ty2); ty2->name = name; } if (is_old_style) { ArrayType[nbFunc][nbparms] = ty2; nbparms++; } cur = cur->next = copy_type(ty2); } if (cur == &head) is_variadic = true; ty = func_type(ty); tok = attribute_list(tok, ty, type_attributes); //the goal here is to rearrange the correct parameter order type following the parameter order for old C style //example // void test_compress(compr, comprLen, uncompr, uncomprLen) char *compr, // *uncompr; // long comprLen, uncomprLen; // the order of parameters inside parenthesis doesn't correspond to the declaration of each parameter. if (is_old_style) { ty->params = old_params(head.next, nbparms); } else ty->params = head.next; ty->is_variadic = is_variadic; *rest = tok->next; if (!ty) error_tok(tok, "%s %d: in func_params : ty is null!", PARSE_C, __LINE__); return ty; } // array-dimensions = ("static" | "restrict")* const-expr? "]" type-suffix static Type *array_dimensions(Token **rest, Token *tok, Type *ty) { while (equal(tok, "static") || equal(tok, "restrict") || equal(tok, "__restrict") || equal(tok, "__restrict__") || equal(tok, "const") || equal(tok, "volatile")) tok = tok->next; // trying to fix issue with regex //=======if the params contains a variable int __nmatch and the next parameter used this variable it fails with undefined variable if (tok->kind == TK_IDENT && equal(tok->next, "]")) { VarScope *sc = find_var(tok); if (sc == NULL) tok = tok->next; } if (consume(&tok, tok, "]") || (equal(tok, "*") && consume(&tok, tok->next, "]"))) { if (equal(tok, "[")) ty = array_dimensions(&tok, tok->next, ty); *rest = tok; return array_of(ty, -1); } Node *expr = assign(&tok, tok); add_type(expr); SET_CTX(ctx); tok = skip(tok, "]", ctx); if (equal(tok, "[")) ty = array_dimensions(&tok, tok->next, ty); *rest = tok; if (ty->kind != TY_VLA && is_const_expr(expr) ) return array_of(ty, eval(expr)); return vla_of(ty, expr); } // type-suffix = "(" func-params // | "[" array-dimensions // | ε static Type *type_suffix(Token **rest, Token *tok, Type *ty) { //tok->next = attribute_list(tok->next, ty, type_attributes); if (equal(tok, "(")) { //in case of old style K&R we omit the parameters inside parenthesis and we parse the parameters that //follow the old c style example // void test_compress(compr, comprLen, uncompr, uncomprLen) char *compr, // *uncompr; // long comprLen, uncomprLen; if (is_old_style) { nbFunc++; tok = old_style_params(rest, tok->next, ty); *rest = tok; return func_params(rest, tok, ty); } return func_params(rest, tok->next, ty); } if (equal(tok, "[")) return array_dimensions(rest, tok->next, ty); *rest = tok; if (!ty) error_tok(tok, "%s %d: in type_suffix : ty is null!", PARSE_C, __LINE__); return ty; } // pointers = ("*" ("const" | "volatile" | "restrict" | "_Complex" )*)* static Type *pointers(Token **rest, Token *tok, Type *ty) { while (consume(&tok, tok, "*")) { ty = pointer_to(ty); for (;;) { tok = attribute_list(tok, ty, type_attributes); if (equal(tok, "const")) { ty->is_const = true; tok = tok->next; } else if (equal(tok, "volatile")) { ty->is_volatile = true; tok = tok->next; } else if (equal(tok, "restrict") || equal(tok, "__restrict") || equal(tok, "__restrict__")) { ty->is_restrict = true; tok = tok->next; } else if (equal(tok, "_Atomic")) { ty->is_atomic = true; tok = tok->next; } else if (equal(tok, "_Complex")) { tok = tok->next; } else { break; } } } tok = attribute_list(tok, ty, type_attributes); *rest = tok; if (!ty) error_tok(tok, "%s %d: in pointers : ty is null!", PARSE_C, __LINE__); return ty; } // declarator = pointers ("(" ident ")" | "(" declarator ")" | ident) type-suffix static Type *declarator(Token **rest, Token *tok, Type *ty) { tok = attribute_list(tok, ty, type_attributes); ty = pointers(&tok, tok, ty); tok->next = attribute_list(tok->next, ty, type_attributes); if (equal(tok, "(") && !is_typename(tok->next) && !equal(tok->next, ")")) { Token *start = tok; Type dummy = {}; declarator(&tok, start->next, &dummy); if (equal(tok, ")")) { SET_CTX(ctx); tok = skip(tok, ")", ctx); } ty = type_suffix(rest, tok, ty); if (!ty) error_tok(tok, "%s %d: in declarator : ty is null", PARSE_C, __LINE__); return declarator(&tok, start->next, ty); } tok = attribute_list(tok, ty, type_attributes); Token *name = NULL; Token *name_pos = tok; if (tok->kind == TK_IDENT) { name = tok; tok = tok->next; } ty = type_suffix(rest, tok, ty); if (!ty) error_tok(tok, "%s %d: in declarator : ty is null", PARSE_C, __LINE__); ty->name = name; ty->name_pos = name_pos; tok = attribute_list(tok, ty, type_attributes); if (!ty) error_tok(tok, "%s %d: in declarator : ty is null!", PARSE_C, __LINE__); return ty; } // abstract-declarator = pointers ("(" abstract-declarator ")")? type-suffix static Type *abstract_declarator(Token **rest, Token *tok, Type *ty) { tok = attribute_list(tok, ty, type_attributes); ty = pointers(&tok, tok, ty); if (equal(tok, "(")) { Token *start = tok; Type dummy = {}; abstract_declarator(&tok, start->next, &dummy); SET_CTX(ctx); tok = skip(tok, ")", ctx); ty = type_suffix(rest, tok, ty); if (!ty) error_tok(tok, "%s %d: in declarator : ty is null", PARSE_C, __LINE__); return abstract_declarator(&tok, start->next, ty); } tok = attribute_list(tok, ty, type_attributes); return type_suffix(rest, tok, ty); } // type-name = declspec abstract-declarator static Type *typename(Token **rest, Token *tok) { Type *ty = declspec(&tok, tok, NULL); tok = attribute_list(tok, ty, type_attributes); return abstract_declarator(rest, tok, ty); } static bool is_end(Token *tok) { return equal(tok, "}") || (equal(tok, ",") && equal(tok->next, "}")) || equal(tok, ";"); } static bool consume_end(Token **rest, Token *tok) { if (equal(tok, "}")) { *rest = tok->next; return true; } if (equal(tok, ",") && equal(tok->next, "}")) { *rest = tok->next->next; return true; } return false; } // enum-specifier = ident? "{" enum-list? "}" // | ident ("{" enum-list? "}")? // // enum-list = ident ("=" num)? ("," ident ("=" num)?)* ","? static Type *enum_specifier(Token **rest, Token *tok) { Type *ty = enum_type(); // Read a struct tag. Token *tag = NULL; if (tok->kind == TK_IDENT) { tag = tok; tok = tok->next; } tok = attribute_list(tok, ty, type_attributes); if (tag && !equal(tok, "{")) { Type *ty2 = find_tag(tag); if (!ty2) warn_tok(tag, "%s %d: in enum_specifier : unknown enum type", PARSE_C, __LINE__); if (ty2 && ty2->kind != TY_ENUM) error_tok(tag, "%s %d: in enum_specifier : not an enum tag", PARSE_C, __LINE__); *rest = tok; if (ty2) return ty2; if (!ty) error_tok(tok, "%s %d: in enum_specifier : ty is null!", PARSE_C, __LINE__); return ty; } SET_CTX(ctx); tok = skip(tok, "{", ctx); // Read an enum-list. int i = 0; int val = 0; while (!consume_end(rest, tok)) { tok->next = attribute_list(tok->next, ty, type_attributes); if (i++ > 0) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } char *name = get_ident(tok); tok = tok->next; tok = attribute_list(tok, ty, type_attributes); if (equal(tok, "=")) val = const_expr(&tok, tok->next); tok = attribute_list(tok, ty, type_attributes); VarScope *sc = push_scope(name); sc->enum_ty = ty; sc->enum_val = val++; } if (tag) push_tag_scope(tag, ty); if (!ty) error_tok(tok, "%s %d: in enum_specifier : ty is null!", PARSE_C, __LINE__); return ty; } // typeof-specifier = "(" (expr | typename) ")" static Type *typeof_specifier(Token **rest, Token *tok) { SET_CTX(ctx); tok = skip(tok, "(", ctx); Type *ty; if (is_typename(tok)) { ty = typename(&tok, tok); } else { Node *node = expr(&tok, tok); add_type(node); ty = node->ty; } SET_CTX(ctx); *rest = skip(tok, ")", ctx); if (!ty) error_tok(tok, "%s %d: in typeof_specifier : ty is null!", PARSE_C, __LINE__); return ty; } // Generate code for computing a VLA size. static Node *compute_vla_size(Type *ty, Token *tok) { Node *node = new_node(ND_NULL_EXPR, tok); if (ty->vla_size) return node; if (ty == ty->base) return node; if (ty->base) { node = new_binary(ND_COMMA, node, compute_vla_size(ty->base, tok), tok); } if (ty->kind != TY_VLA && !ty->has_vla) return node; if ((ty->kind == TY_STRUCT || ty->kind == TY_UNION) && ty->has_vla == false) return node; if ((ty->kind == TY_STRUCT || ty->kind == TY_UNION) && ty->has_vla) { // Allocate temporary variable to hold size ty->vla_size = new_lvar("", ty_ulong, NULL); Node *sz = new_num(0, tok); for (Member *mem = ty->members; mem; mem = mem->next) { Node *member_size; if (mem->ty->kind == TY_VLA || mem->ty->has_vla) { node = new_binary(ND_COMMA, node, compute_vla_size(mem->ty, tok), tok); member_size = new_var_node(mem->ty->vla_size, tok); } else { member_size = new_num(mem->ty->size, tok); } // Simply add size, no alignment sz = new_binary(ND_ADD, sz, member_size, tok); } Node *expr = new_binary(ND_ASSIGN, new_var_node(ty->vla_size, tok), sz, tok); return new_binary(ND_COMMA, node, expr, tok); } Node *base_sz; if (ty->base->kind == TY_VLA) base_sz = new_var_node(ty->base->vla_size, tok); else base_sz = new_num(ty->base->size, tok); ty->vla_size = new_lvar("", ty_ulong, NULL); if (!ty->vla_len) error_tok(tok, "%s %d: in compute_vla_size : vla_len is null", PARSE_C, __LINE__); //ty->vla_len = new_var_node(ty->vla_size, tok); Node *expr = new_binary(ND_ASSIGN, new_var_node(ty->vla_size, tok), new_binary(ND_MUL, ty->vla_len, base_sz, tok), tok); return new_binary(ND_COMMA, node, expr, tok); } static Node *new_alloca(Node *sz) { if (!builtin_alloca) { // Fallback implementation for alloca Node *node = new_node(ND_ALLOC, sz->tok); node->ty = pointer_to(ty_void); // Adjust the type as necessary node->lhs = sz; // `sz` is the size to allocate add_type(sz); return node; } Node *node = new_unary(ND_FUNCALL, new_var_node(builtin_alloca, sz->tok), sz->tok); node->func_ty = builtin_alloca->ty; node->ty = builtin_alloca->ty->return_ty; node->args = sz; add_type(sz); return node; } // declaration = declspec (declarator ("=" expr)? ("," declarator ("=" expr)?)*)? ";" static Node *declaration(Token **rest, Token *tok, Type *basety, VarAttr *attr) { Node head = {}; Node *cur = &head; int i = 0; while (!equal(tok, ";")) { if (i++ > 0) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } int alt_align = attr ? attr->align : 0; Type *ty = declarator(&tok, tok, basety); if (!ty) error_tok(tok, "%s %d: in declaration : ty is null", PARSE_C, __LINE__); if (ty->kind == TY_VOID) error_tok(tok, "%s %d: in declaration : variable declared void", PARSE_C, __LINE__); if (!ty->name) error_tok(ty->name_pos, "%s %d: in declaration : variable name omitted", PARSE_C, __LINE__); tok = attribute_list(tok, attr, thing_attributes); if (attr && attr->is_static) { // static local variable if (ty->kind == TY_VLA) error_tok(tok, "%s %d: in declaration: variable length arrays cannot be 'static'", PARSE_C, __LINE__); Obj *var = new_anon_gvar(ty); //from @fuhsnn fix Handle local static _Thread_local var->is_tls = attr->is_tls; if (alt_align) var->align = alt_align; push_scope(get_ident(ty->name))->var = var; if (equal(tok, "=")) gvar_initializer(&tok, tok->next, var); continue; } // Generate code for computing a VLA size. We need to do this // even if ty is not VLA because ty may be a pointer to VLA // (e.g. int (*foo)[n][m] where n and m are variables.) cur = cur->next = new_unary(ND_EXPR_STMT, compute_vla_size(ty, tok), tok); //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, attr, thing_attributes); if (ty->kind == TY_VLA) { if (equal(tok, "=")) error_tok(tok, "%s %d: in declaration: variable-sized object may not be initialized", PARSE_C, __LINE__); // Variable length arrays (VLAs) are translated to alloca() calls. // For example, `int x[n+2]` is translated to `tmp = n + 2, // x = alloca(tmp)`. Obj *var = new_lvar(get_ident(ty->name), ty, NULL); Token *tok = ty->name; tok = attribute_list(tok, ty, type_attributes); Node *expr = new_binary(ND_ASSIGN, new_vla_ptr(var, tok), new_alloca(new_var_node(ty->vla_size, tok)), tok); cur = cur->next = new_unary(ND_EXPR_STMT, expr, tok); continue; } Obj *var = new_lvar(get_ident(ty->name), ty, NULL); if (alt_align) var->align = alt_align; // if (attr && attr->align) // var->align = attr->align; // if (equal(tok, "=")) // { // Node *expr = lvar_initializer(&tok, tok->next, var); // cur = cur->next = new_unary(ND_EXPR_STMT, expr, tok); // } if (equal(tok, "=")) { tok = tok->next; Node *expr; expr = lvar_initializer(&tok, tok, var); if (expr->lhs && expr->lhs->var && expr->lhs->var->name) { cur = cur->next = new_unary(ND_EXPR_STMT, expr, tok); } } //ISS-146 if (var->ty->size < 0) error_tok(ty->name, "%s %d: in declaration : variable has incomplete type", PARSE_C, __LINE__); if (var->ty->kind == TY_VOID) error_tok(ty->name, "%s %d: in declaration : variable declared void", PARSE_C, __LINE__); } Node *node = new_node(ND_BLOCK, tok); node->body = head.next; *rest = tok->next; return node; } static Token *skip_excess_element(Token *tok) { if (equal(tok, "{")) { tok = skip_excess_element(tok->next); SET_CTX(ctx); return skip(tok, "}", ctx); } assign(&tok, tok); return tok; } // string-initializer = string-literal static void string_initializer(Token **rest, Token *tok, Initializer *init) { if (init->is_flexible) *init = *new_initializer(array_of(init->ty->base, tok->ty->array_len), false); int len = MIN(init->ty->array_len, tok->ty->array_len); switch (init->ty->base->size) { case 1: { char *str = tok->str; for (int i = 0; i < len; i++) init->children[i]->expr = new_num(str[i], tok); break; } case 2: { uint16_t *str = (uint16_t *)tok->str; for (int i = 0; i < len; i++) init->children[i]->expr = new_num(str[i], tok); break; } case 4: { uint32_t *str = (uint32_t *)tok->str; for (int i = 0; i < len; i++) init->children[i]->expr = new_num(str[i], tok); break; } case 8: { // Initialize array of 64-bit integers for (int i = 0; i < len; i++) { // We need to ensure that we are accessing the string in a manner suitable for 64-bit integers. // For simplicity, let's fill the 64-bit integer with repeated characters from the string. uint64_t value = 0; for (int j = 0; j < 8 && i * 8 + j < len; j++) { value |= (uint64_t)(unsigned char) tok->str[i * 8 + j] << (j * 8); } init->children[i]->expr = new_num(value, tok); } break; case 16: { // Initialize array of 128-bit integers for (int i = 0; i < len; i++) { __int128 value = 0; for (int j = 0; j < 16 && i * 16 + j < len; j++) { value |= (__int128)(unsigned char)tok->str[i * 16 + j] << (j * 8); } init->children[i]->expr = new_num(value, tok); } } break; } default: error_tok(tok, "%s %d: in string_initializer : array of inappropriate type initialized from string constant", PARSE_C, __LINE__); // unreachable(); } *rest = tok->next; } // array-designator = "[" const-expr "]" // // C99 added the designated initializer to the language, which allows // programmers to move the "cursor" of an initializer to any element. // The syntax looks like this: // // int x[10] = { 1, 2, [5]=3, 4, 5, 6, 7 }; // // `[5]` moves the cursor to the 5th element, so the 5th element of x // is set to 3. Initialization then continues forward in order, so // 6th, 7th, 8th and 9th elements are initialized with 4, 5, 6 and 7, // respectively. Unspecified elements (in this case, 3rd and 4th // elements) are initialized with zero. // // Nesting is allowed, so the following initializer is valid: // // int x[5][10] = { [5][8]=1, 2, 3 }; // // It sets x[5][8], x[5][9] and x[6][0] to 1, 2 and 3, respectively. // // Use `.fieldname` to move the cursor for a struct initializer. E.g. // // struct { int a, b, c; } x = { .c=5 }; // // The above initializer sets x.c to 5. static void array_designator(Token **rest, Token *tok, Type *ty, int *begin, int *end) { *begin = const_expr(&tok, tok->next); if (*begin >= ty->array_len) error_tok(tok, "%s %d: in array_designator : array designator index exceeds array bounds", PARSE_C, __LINE__); if (equal(tok, "...")) { *end = const_expr(&tok, tok->next); if (*end >= ty->array_len) error_tok(tok, "%s %d: in array designator : index exceeds array bounds", PARSE_C, __LINE__); if (*end < *begin) error_tok(tok, "%s %d: in array designator : range [%d, %d] is empty", PARSE_C, __LINE__, *begin, *end); } else { *end = *begin; } SET_CTX(ctx); *rest = skip(tok, "]", ctx); } // struct-designator = "." ident static Member *struct_designator(Token **rest, Token *tok, Type *ty) { Token *start = tok; if (equal(tok, ".")) { SET_CTX(ctx); tok = skip(tok, ".", ctx); } if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: in struct_designator : expected a field designator", PARSE_C, __LINE__); for (Member *mem = ty->members; mem; mem = mem->next) { // Anonymous struct member if (!mem->name) { if (mem->ty->kind == TY_STRUCT || mem->ty->kind == TY_UNION) { tok = attribute_list(tok, ty, type_attributes); if (get_struct_member(mem->ty, tok)) { *rest = start; return mem; } } continue; } // Regular struct member if (mem->name->len == tok->len && !strncmp(mem->name->loc, tok->loc, tok->len)) { *rest = tok->next; return mem; } } error_tok(tok, "%s %d: in struct_designator : struct has no such member", PARSE_C, __LINE__); } // designation = ("[" const-expr "]" | "." ident)* "="? initializer static void designation(Token **rest, Token *tok, Initializer *init) { tok = attribute_list(tok, init->ty, type_attributes); if (equal(tok, "[")) { if (init->ty->kind != TY_ARRAY) error_tok(tok, "%s %d: in designation : array index in non-array initializer", PARSE_C, __LINE__); int begin, end; array_designator(&tok, tok, init->ty, &begin, &end); Token *tok2; for (int i = begin; i <= end; i++) designation(&tok2, tok, init->children[i]); //fix from @fuhsnn Fix array initializer post-designation offset //array_initializer2(rest, tok2, init, begin + 1); array_initializer2(rest, tok2, init, end + 1); return; } if (equal(tok, ".") && init->ty->kind == TY_STRUCT) { Member *mem = struct_designator(&tok, tok, init->ty); designation(&tok, tok, init->children[mem->idx]); init->expr = NULL; struct_initializer2(rest, tok, init, mem->next, true); return; } if (equal(tok, ".") && init->ty->kind == TY_UNION) { Member *mem = struct_designator(&tok, tok, init->ty); init->mem = mem; designation(rest, tok, init->children[mem->idx]); return; } if (equal(tok, ".")) error_tok(tok, "%s %d: in designation: field name not in struct or union initializer", PARSE_C, __LINE__); if (equal(tok, "=")) { SET_CTX(ctx); tok = skip(tok, "=", ctx); } // tok = tok->next; initializer2(rest, tok, init); } // An array length can be omitted if an array has an initializer // (e.g. `int x[] = {1,2,3}`). If it's omitted, count the number // of initializer elements. static int count_array_init_elements(Token *tok, Type *ty) { bool first = true; Initializer *dummy = new_initializer(ty->base, true); int i = 0, max = 0; while (!consume_end(&tok, tok)) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; if (equal(tok, "[")) { i = const_expr(&tok, tok->next); if (equal(tok, "...")) i = const_expr(&tok, tok->next); SET_CTX(ctx); tok = skip(tok, "]", ctx); designation(&tok, tok, dummy); } else { initializer2(&tok, tok, dummy); } i++; max = MAX(max, i); } return max; } // array-initializer1 = "{" initializer ("," initializer)* ","? "}" static void array_initializer1(Token **rest, Token *tok, Initializer *init) { SET_CTX(ctx); tok = skip(tok, "{", ctx); // if (init->is_flexible) // { // int len = count_array_init_elements(tok, init->ty); // *init = *new_initializer(array_of(init->ty->base, len), false); // } bool first = true; if (init->is_flexible) { int len = count_array_init_elements(tok, init->ty); *init = *new_initializer(array_of(init->ty->base, len), false); } for (int i = 0; !consume_end(rest, tok); i++) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; if (equal(tok, "[")) { int begin, end; array_designator(&tok, tok, init->ty, &begin, &end); Token *tok2; for (int j = begin; j <= end; j++) designation(&tok2, tok, init->children[j]); tok = tok2; i = end; continue; } if (i < init->ty->array_len) initializer2(&tok, tok, init->children[i]); else tok = skip_excess_element(tok); } } // array-initializer2 = initializer ("," initializer)* static void array_initializer2(Token **rest, Token *tok, Initializer *init, int i) { if (init->is_flexible) { int len = count_array_init_elements(tok, init->ty); *init = *new_initializer(array_of(init->ty->base, len), false); } for (; i < init->ty->array_len && !is_end(tok); i++) { Token *start = tok; if (i > 0) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } if (equal(tok, "[") || equal(tok, ".")) { *rest = start; return; } initializer2(&tok, tok, init->children[i]); } *rest = tok; } // struct-initializer1 = "{" initializer ("," initializer)* ","? "}" static void struct_initializer1(Token **rest, Token *tok, Initializer *init) { SET_CTX(ctx); tok = skip(tok, "{", ctx); Member *mem = init->ty->members; bool first = true; while (!consume_end(rest, tok)) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; if (equal(tok, ".")) { mem = struct_designator(&tok, tok, init->ty); designation(&tok, tok, init->children[mem->idx]); mem = mem->next; continue; } if (mem) { initializer2(&tok, tok, init->children[mem->idx]); mem = mem->next; } else { tok = skip_excess_element(tok); } } } // struct-initializer2 = initializer ("," initializer)* static void struct_initializer2(Token **rest, Token *tok, Initializer *init, Member *mem, bool post_desig) { bool first = true; for (; mem && !is_end(tok); mem = mem->next) { Token *start = tok; if (!first || post_desig) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; if (equal(tok, "[") || equal(tok, ".")) { *rest = start; return; } //fixing c-Testsuite 205. //initializer2(&tok, tok, init->children[mem->idx]); // Arrays and vectors inside structs need to handle their elements with braces if (mem->ty->kind == TY_ARRAY) { array_initializer2(&tok, tok, init->children[mem->idx], 0); } else { // For scalar members, just assign directly initializer2(&tok, tok, init->children[mem->idx]); } } *rest = tok; } static void union_initializer(Token **rest, Token *tok, Initializer *init) { SET_CTX(ctx); tok = skip(tok, "{", ctx); bool first = true; for (; !consume_end(rest, tok); first = false) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } if (equal(tok, ".")) { init->mem = struct_designator(&tok, tok, init->ty); designation(&tok, tok, init->children[init->mem->idx]); continue; } if (first && init->ty->members) { init->mem = init->ty->members; initializer2(&tok, tok, init->children[0]); } else { tok = skip_excess_element(tok); } } } static void vector_initializer1(Token **rest, Token *tok, Initializer *init) { SET_CTX(ctx); tok = skip(tok, "{", ctx); for (int i = 0; i < init->ty->array_len && !equal(tok, "}"); i++) { init->children[i] = calloc(1, sizeof(Initializer)); init->children[i]->ty = init->ty->base; initializer2(&tok, tok, init->children[i]); if (equal(tok, ",")) tok = tok->next; } SET_CTX(ctx); *rest = skip(tok, "}", ctx); } // initializer = string-initializer | array-initializer // | struct-initializer | union-initializer // | assign static void initializer2(Token **rest, Token *tok, Initializer *init) { // trying to fix issue #62 if (equal(tok, ",")) return; if (!init) error("%s: %s:%d: error: in initializer2 : init is null %s", PARSE_C, __FILE__, __LINE__, tok->loc); if (init->ty->kind == TY_ARRAY && is_integer(init->ty->base)) { Token *start = tok; Token *str_tok; if (equal(tok, "{") && is_str_tok(&tok, tok->next, &str_tok)) { if (consume(rest, tok, "}")) { string_initializer(&tok, str_tok, init); return; } tok = start; } if (is_str_tok(rest, tok, &str_tok)) { string_initializer(&tok, str_tok, init); return; } } if (is_vector(init->ty)) { if (equal(tok, "{")) { vector_initializer1(rest, tok, init); return; } } if (init->ty->kind == TY_ARRAY) { if (equal(tok, "{")) array_initializer1(rest, tok, init); else array_initializer2(rest, tok, init, 0); return; } if (init->ty->kind == TY_STRUCT) { if (equal(tok, "{")) { struct_initializer1(rest, tok, init); return; } // A struct can be initialized with another struct. E.g. // `struct T x = y;` where y is a variable of type `struct T`. // Handle that case first. Node *expr = assign(rest, tok); add_type(expr); if (expr->ty->kind == TY_STRUCT) { init->expr = expr; return; } if (!init->ty->members) error_tok(tok, "%s: %s:%d: error: in initializer2 : initializer for empty aggregate requires explicit braces", PARSE_C, __FILE__, __LINE__); struct_initializer2(rest, tok, init, init->ty->members, false); return; } if (init->ty->kind == TY_UNION) { if (equal(tok, "{")) { union_initializer(rest, tok, init); return; } Node *expr = assign(rest, tok); add_type(expr); if (expr->ty->kind == TY_UNION) { init->expr = expr; return; } if (!init->ty->members) error_tok(tok, "%s: %s:%d: error: in initializer2 : initializer for empty aggregate requires explicit braces", PARSE_C, __FILE__, __LINE__); init->mem = init->ty->members; initializer2(rest, tok, init->children[0]); return; } if (equal(tok, "{")) { // An initializer for a scalar variable can be surrounded by // braces. E.g. `int x = {3};`. Handle that case. while (!equal(tok, "}")) { initializer2(&tok, tok->next, init); } SET_CTX(ctx); *rest = skip(tok, "}", ctx); return; } init->expr = assign(rest, tok); add_type(init->expr); if (init->expr->kind == ND_VAR && init->expr->var && init->expr->var->is_function && init->ty->kind == TY_PTR) { init->expr->var->is_address_used = true; } } static Type *copy_struct_type(Type *ty) { ty = copy_type(ty); Member head = {}; Member *cur = &head; for (Member *mem = ty->members; mem; mem = mem->next) { Member *m = calloc(1, sizeof(Member)); if (m == NULL) error("%s: %s:%d: error: in copy_struct_type : m is null", PARSE_C, __FILE__, __LINE__); *m = *mem; cur = cur->next = m; } ty->members = head.next; if (!ty) error("%s %d: in copy_struct_type : ty is null!", PARSE_C, __LINE__); return ty; } static Initializer *initializer(Token **rest, Token *tok, Type *ty, Type **new_ty) { Initializer *init = new_initializer(ty, true); initializer2(rest, tok, init); if ((ty->kind == TY_STRUCT || ty->kind == TY_UNION) && ty->is_flexible) { ty = copy_struct_type(ty); Member *mem = ty->members; while (mem->next) mem = mem->next; mem->ty = init->children[mem->idx]->ty; ty->size += mem->ty->size; *new_ty = ty; return init; } *new_ty = init->ty; return init; } static Node *init_desg_expr(InitDesg *desg, Token *tok) { if (desg->var) return new_var_node(desg->var, tok); if (desg->member) { Node *node = new_unary(ND_MEMBER, init_desg_expr(desg->next, tok), tok); node->member = desg->member; return node; } Node *lhs = init_desg_expr(desg->next, tok); Node *rhs = new_num(desg->idx, tok); return new_unary(ND_DEREF, new_add(lhs, rhs, tok, false), tok); } static Node *create_lvar_init(Initializer *init, Type *ty, InitDesg *desg, Token *tok) { if (ty->kind == TY_ARRAY) { Node *node = new_node(ND_NULL_EXPR, tok); for (int i = 0; i < ty->array_len; i++) { InitDesg desg2 = {desg, i}; Node *rhs = create_lvar_init(init->children[i], ty->base, &desg2, tok); node = new_binary(ND_COMMA, node, rhs, tok); } return node; } //case of vectors two kinds of initialization possible : direct like {1.0f, 2.0f...} or from expressions like function call if (is_vector(ty)) { if (init->expr) { Node *lhs = init_desg_expr(desg, tok); return new_binary(ND_ASSIGN, lhs, init->expr, tok); } Node *node = new_node(ND_NULL_EXPR, tok); for (int i = 0; i < ty->array_len; i++) { InitDesg desg2 = {desg, i}; Node *rhs = create_lvar_init(init->children[i], ty->base, &desg2, tok); node = new_binary(ND_COMMA, node, rhs, tok); } return node; } if (init->expr) { Node *lhs = init_desg_expr(desg, tok); return new_binary(ND_ASSIGN, lhs, init->expr, tok); } if (ty->kind == TY_STRUCT && !init->expr) { Node *node = new_node(ND_NULL_EXPR, tok); for (Member *mem = ty->members; mem; mem = mem->next) { InitDesg desg2 = {desg, 0, mem}; Node *rhs = create_lvar_init(init->children[mem->idx], mem->ty, &desg2, tok); node = new_binary(ND_COMMA, node, rhs, tok); } return node; } if (ty->kind == TY_UNION) { if (!init->mem) return new_node(ND_NULL_EXPR, tok); Member *mem = init->mem ? init->mem : ty->members; InitDesg desg2 = {desg, 0, mem}; return create_lvar_init(init->children[mem->idx], mem->ty, &desg2, tok); } if (!init->expr) return new_node(ND_NULL_EXPR, tok); Node *lhs = init_desg_expr(desg, tok); return new_binary(ND_ASSIGN, lhs, init->expr, tok); } // A variable definition with an initializer is a shorthand notation // for a variable definition followed by assignments. This function // generates assignment expressions for an initializer. For example, // `int x[2][2] = {{6, 7}, {8, 9}}` is converted to the following // expressions: // // x[0][0] = 6; // x[0][1] = 7; // x[1][0] = 8; // x[1][1] = 9; static Node *lvar_initializer(Token **rest, Token *tok, Obj *var) { Initializer *init = initializer(rest, tok, var->ty, &var->ty); InitDesg desg = {NULL, 0, NULL, var}; // If a partial initializer list is given, the standard requires // that unspecified elements are set to 0. Here, we simply // zero-initialize the entire memory region of a variable before // initializing it with user-supplied values. Node *lhs = new_node(ND_MEMZERO, tok); lhs->var = var; lhs->var->init = init; Node *rhs = create_lvar_init(init, var->ty, &desg, tok); return new_binary(ND_COMMA, lhs, rhs, tok); } static uint64_t read_buf(char *buf, int sz) { if (sz == 1) return *buf; if (sz == 2) return *(uint16_t *)buf; if (sz == 4) return *(uint32_t *)buf; if (sz == 8) return *(uint64_t *)buf; if (sz == 16) return *(long double *)buf; unreachable(); } static void write_buf(char *buf, uint64_t val, int sz) { if (sz == 1) *buf = val; else if (sz == 2) *(uint16_t *)buf = val; else if (sz == 4) *(uint32_t *)buf = val; else if (sz == 8) *(uint64_t *)buf = val; else if (sz == 16) *(long double *)buf = val; else unreachable(); } static Relocation * write_gvar_data(Relocation *cur, Initializer *init, Type *ty, char *buf, int offset) { if (ty->kind == TY_ARRAY) { int elem_size = ty->base->size; memset(buf + offset, 0, elem_size * ty->array_len); if (init->expr) error_tok(init->expr->tok, "%s %d: in write_gvar_data : array initializer must be an initializer list", PARSE_C, __LINE__); int sz = ty->base->size; for (int i = 0; i < ty->array_len; i++) cur = write_gvar_data(cur, init->children[i], ty->base, buf, offset + sz * i); return cur; } if (is_vector(ty)) { int sz = ty->base->size; memset(buf + offset, 0, sz * ty->array_len); for (int i = 0; i < ty->array_len; i++) cur = write_gvar_data(cur, init->children[i], ty->base, buf, offset + sz * i); return cur; } if (!init->expr) { if (ty->kind == TY_STRUCT) { // Zero the whole struct first memset(buf + offset, 0, ty->size); for (Member *mem = ty->members; mem; mem = mem->next) { if (mem->is_bitfield) { Node *expr = init->children[mem->idx]->expr; if (!expr) continue; add_type(expr); char *loc = buf + offset + mem->offset; uint64_t oldval = read_buf(loc, mem->ty->size); uint64_t newval = eval(expr); uint64_t mask = (1L << mem->bit_width) - 1; uint64_t combined = oldval | ((newval & mask) << mem->bit_offset); write_buf(loc, combined, mem->ty->size); } else { cur = write_gvar_data(cur, init->children[mem->idx], mem->ty, buf, offset + mem->offset); } } return cur; } if (ty->kind == TY_UNION) { memset(buf + offset, 0, ty->size); if (!init->mem) return cur; return write_gvar_data(cur, init->children[init->mem->idx], init->mem->ty, buf, offset); } if (!init->expr) return cur; } add_type(init->expr); // Check if the initializer is a compound literal if (is_compatible(ty, init->expr->ty)) { int sofs = 0; Obj *var = eval_var(init->expr, false); if (var && var->init_data && !var->is_weak && (is_const_var(var) || var->is_compound_lit)) { Relocation *srel = var->rel; while (srel && srel->offset < sofs) srel = srel->next; for (int pos = 0; pos < ty->size && (pos + sofs) < var->ty->size;) { if (srel && srel->offset == (pos + sofs)) { // Create new relocation cur = cur->next = calloc(1, sizeof(Relocation)); cur->offset = (pos + offset); cur->label = srel->label; cur->addend = srel->addend; srel = srel->next; pos += 8; } else { // Copy initialization data from compound literal buf[(pos + offset)] = var->init_data[(pos + sofs)]; pos++; } } return cur; } } if (ty->kind == TY_FLOAT) { *(float *)(buf + offset) = eval_double(init->expr); return cur; } if (ty->kind == TY_DOUBLE) { *(double *)(buf + offset) = eval_double(init->expr); return cur; } if (ty->kind == TY_LDOUBLE) { *(long double *)(buf + offset) = eval_double(init->expr); return cur; } char **label = NULL; uint64_t val = eval2(init->expr, &label); if (!label) { write_buf(buf + offset, val, ty->size); return cur; } Relocation *rel = calloc(1, sizeof(Relocation)); if (rel == NULL) error("%s: %s:%d: error: in write_gvar_data : rel is null", PARSE_C, __FILE__, __LINE__); rel->offset = offset; rel->label = label; rel->addend = val; cur->next = rel; return cur->next; } // Initializers for global variables are evaluated at compile-time and // embedded to .data section. This function serializes Initializer // objects to a flat byte array. It is a compile error if an // initializer list contains a non-constant expression. static void gvar_initializer(Token **rest, Token *tok, Obj *var) { Initializer *init = initializer(rest, tok, var->ty, &var->ty); Relocation head = {}; char *buf = calloc(1, var->ty->size); if (buf == NULL) error("%s: %s:%d: error: in gvar_initializer : buf is null!", PARSE_C, __FILE__, __LINE__); write_gvar_data(&head, init, var->ty, buf, 0); var->init_data = buf; var->rel = head.next; } // Returns true if a given token represents a type. static bool is_typename(Token *tok) { static HashMap map; if (map.capacity == 0) { static char *kw[] = { "void", "_Bool", "char", "short", "int", "long", "struct", "union", "typedef", "enum", "static", "extern", "_Alignas", "signed", "unsigned", "const", "volatile", "auto", "register", "restrict", "__restrict", "__restrict__", "_Noreturn", "float", "double", "typeof", "inline", "__inline", "_Thread_local", "__thread", "_Atomic", "_Complex", "__label__", "__typeof", "__int128"}; for (int i = 0; i < sizeof(kw) / sizeof(*kw); i++) hashmap_put(&map, kw[i], (void *)1); } return hashmap_get2(&map, tok->loc, tok->len) || find_typedef(tok); } // asm-stmt = "asm" ("volatile" | "inline")* "(" string-literal ")" static Node *asm_stmt(Token **rest, Token *tok) { Node *node = new_node(ND_ASM, tok); tok = tok->next; while (equal(tok, "volatile") || equal(tok, "inline") || equal(tok, "__inline")) tok = tok->next; SET_CTX(ctx); tok = skip(tok, "(", ctx); if (tok->kind != TK_STR || tok->ty->base->kind != TY_CHAR) error_tok(tok, "%s %d: in asm_stmt : expected string literal", PARSE_C, __LINE__); // extended assembly like asm ( assembler_template: output operands (optional) : input operands (optional) : list of clobbered registers (optional)) if (equal(tok->next, ":")) { node->asm_str = extended_asm(node, rest, tok, locals); if (!node->asm_str) error_tok(tok, "%s %d: in asm_stmt : error during extended_asm function null returned!", PARSE_C, __LINE__); return node; } node->asm_str = tok->str; SET_CTX(ctx); *rest = skip(tok->next, ")", ctx); return node; } // stmt = "return" expr? ";" // | "if" "(" expr ")" stmt ("else" stmt)? // | "switch" "(" expr ")" stmt // | "case" const-expr ("..." const-expr)? ":" stmt // | "default" ":" stmt // | "for" "(" expr-stmt expr? ";" expr? ")" stmt // | "while" "(" expr ")" stmt // | "do" stmt "while" "(" expr ")" ";" // | "asm" asm-stmt // | "goto" (ident | "*" expr) ";" // | "break" ";" // | "continue" ";" // | ident ":" stmt // | "{" compound-stmt // | expr-stmt static Node *stmt(Token **rest, Token *tok, bool chained) { if (equal(tok, "return")) { Type *ret_ty = current_fn->ty->return_ty; Node *node = new_node(ND_RETURN, tok); if (consume(rest, tok->next, ";")) { if (ret_ty->kind != TY_VOID) { error_tok(tok, "%s %d: in stmt : Non-void function must return something", PARSE_C, __LINE__); } return node; } Node *exp = expr(&tok, tok->next); SET_CTX(ctx); *rest = skip(tok, ";", ctx); add_type(exp); // Type *ty = current_fn->ty->return_ty; // if (ty->kind != TY_STRUCT && ty->kind != TY_UNION) // exp = new_cast(exp, current_fn->ty->return_ty); if (!exp->ty) error_tok(exp->tok, "%s %d: in stmt : exp->ty is null", PARSE_C, __LINE__); if (ret_ty->kind == TY_VOID && exp->ty->kind != TY_VOID) { error_tok(exp->tok, "%s %d: in stmt : Void function must return void type expression", PARSE_C, __LINE__); } if (ret_ty->kind != TY_VOID && exp->ty->kind == TY_VOID) { error_tok(exp->tok, "%s %d: in stmt : Non-void function cannot return void type expression", PARSE_C, __LINE__); } if (ret_ty->kind != TY_STRUCT && ret_ty->kind != TY_UNION) exp = new_cast(exp, ret_ty); node->lhs = exp; return node; } if (equal(tok, "if")) { Node *node = new_node(ND_IF, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->cond = expr(&tok, tok); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->cond->kind), node->cond->unique_number); SET_CTX(ctx); tok = skip(tok, ")", ctx); node->then = stmt(&tok, tok, true); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->then->kind), node->then->unique_number); if (equal(tok, "else")) { node->els = stmt(&tok, tok->next, true); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->els->kind), node->els->unique_number); } *rest = tok; return node; } //from COSMOPOLITAN adding function static_assertion if (equal(tok, "_Static_assert")) { Token *start = tok; *rest = static_assertion(tok); return new_node(ND_BLOCK, start); } if (equal(tok, "switch")) { Node *node = new_node(ND_SWITCH, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->cond = expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); Node *sw = current_switch; current_switch = node; char *brk = brk_label; brk_label = node->brk_label = new_unique_name(); node->then = stmt(rest, tok, true); current_switch = sw; brk_label = brk; return node; } if (equal(tok, "case")) { if (!current_switch) error_tok(tok, "%s %d: in stmt : stray case", PARSE_C, __LINE__); Node *node = new_node(ND_CASE, tok); int64_t begin = const_expr(&tok, tok->next); int64_t end; add_type(current_switch->cond); if (equal(tok, "...")) { // [GNU] Case ranges, e.g. "case 1 ... 5:" end = const_expr(&tok, tok->next); // if (end < begin) // error_tok(tok, "%s %d: in stmt : empty case range specified", PARSE_C, __LINE__); } else { end = begin; } if (current_switch->cond->ty->size == 4) { if (!current_switch->cond->ty->is_unsigned) { begin = (int32_t) begin; end = (int32_t) end; } else { begin = (uint32_t) begin; end = (uint32_t) end; } } if ((!current_switch->cond->ty->is_unsigned && (end < begin)) || ((current_switch->cond->ty->is_unsigned && ((uint64_t)end < begin)))) error_tok(tok, "%s %d: in stmt : empty case range specified", PARSE_C, __LINE__); SET_CTX(ctx); tok = skip(tok, ":", ctx); VarAttr attr = {}; tok = attribute_list(tok, &attr, thing_attributes); node->label = new_unique_name(); if (chained) { if (is_typename(tok)) { node->lhs = compound_stmt2(rest, tok); } else { node->lhs = stmt(rest, tok, true); } } else *rest = tok; //duplicate case value detection for (Node *c = current_switch->case_next; c; c = c->case_next) { if (!(end < c->begin || begin > c->end)) error_tok(tok, "%s %d: in stmt : duplicated case value or overlapping range %ld", PARSE_C, __LINE__, begin); } node->begin = begin; node->end = end; node->case_next = current_switch->case_next; current_switch->case_next = node; return node; } if (equal(tok, "default")) { if (!current_switch) error_tok(tok, "%s %d: in stmt : stray default", PARSE_C, __LINE__); Node *node = new_node(ND_CASE, tok); SET_CTX(ctx); tok = skip(tok->next, ":", ctx); node->label = new_unique_name(); if (chained) { if (is_typename(tok)) { node->lhs = compound_stmt2(rest, tok); } else { node->lhs = stmt(rest, tok, true); } } else *rest = tok; current_switch->default_case = node; return node; } if (equal(tok, "for")) { Node *node = new_node(ND_FOR, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); enter_scope(); char *brk = brk_label; char *cont = cont_label; brk_label = node->brk_label = new_unique_name(); cont_label = node->cont_label = new_unique_name(); if (is_typename(tok)) { Type *basety = declspec(&tok, tok, NULL); node->init = declaration(&tok, tok, basety, NULL); } else { node->init = expr_stmt(&tok, tok); } if (!equal(tok, ";")) { node->cond = expr(&tok, tok); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->cond->kind), node->cond->unique_number); } SET_CTX(ctx); tok = skip(tok, ";", ctx); if (!equal(tok, ")")) { node->inc = expr(&tok, tok); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->inc->kind), node->inc->unique_number); } SET_CTX(ctx); tok = skip(tok, ")", ctx); node->then = stmt(rest, tok, true); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->then->kind), node->then->unique_number); leave_scope(); brk_label = brk; cont_label = cont; return node; } if (equal(tok, "while")) { Node *node = new_node(ND_FOR, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->cond = expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); char *brk = brk_label; char *cont = cont_label; brk_label = node->brk_label = new_unique_name(); cont_label = node->cont_label = new_unique_name(); node->then = stmt(rest, tok, true); brk_label = brk; cont_label = cont; return node; } if (equal(tok, "do")) { Node *node = new_node(ND_DO, tok); char *brk = brk_label; char *cont = cont_label; brk_label = node->brk_label = new_unique_name(); cont_label = node->cont_label = new_unique_name(); node->then = stmt(&tok, tok->next, true); brk_label = brk; cont_label = cont; SET_CTX(ctx); tok = skip(tok, "while", ctx); SET_CTX(ctx); tok = skip(tok, "(", ctx); node->cond = expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); SET_CTX(ctx); *rest = skip(tok, ";", ctx); return node; } if (equal(tok, "asm") || equal(tok, "__asm__")) return asm_stmt(rest, tok); if (equal(tok, "goto")) { if (equal(tok->next, "*")) { // [GNU] `goto *ptr` jumps to the address specified by `ptr`. Node *node = new_node(ND_GOTO_EXPR, tok); node->lhs = expr(&tok, tok->next->next); SET_CTX(ctx); *rest = skip(tok, ";", ctx); return node; } Node *node = new_node(ND_GOTO, tok); node->label = get_ident(tok->next); node->goto_next = gotos; gotos = node; SET_CTX(ctx); *rest = skip(tok->next->next, ";", ctx); return node; } if (equal(tok, "break")) { if (!brk_label) error_tok(tok, "%s %d: in stmt : stray break", PARSE_C, __LINE__); Node *node = new_node(ND_GOTO, tok); node->unique_label = brk_label; SET_CTX(ctx); *rest = skip(tok->next, ";", ctx); return node; } if (equal(tok, "continue")) { if (!cont_label) error_tok(tok, "%s %d: in stmt : stray continue", PARSE_C, __LINE__); Node *node = new_node(ND_GOTO, tok); node->unique_label = cont_label; SET_CTX(ctx); *rest = skip(tok->next, ";", ctx); return node; } if ((tok->kind == TK_IDENT && equal(tok->next, ":"))) { Node *node = new_node(ND_LABEL, tok); node->label = strndup(tok->loc, tok->len); node->unique_label = new_unique_name(); //node->lhs = stmt(rest, tok->next->next); tok = tok->next->next; if (chained) node->lhs = stmt(rest, tok, true); else *rest = tok; node->goto_next = labels; labels = node; return node; } if (equal(tok, "{")) return compound_stmt(rest, tok->next, NULL); return expr_stmt(rest, tok); } // compound-stmt = (typedef | declaration | stmt)* "}" static Node *compound_stmt(Token **rest, Token *tok, Node **last) { Node *node = new_node(ND_BLOCK, tok); Node head = {0}; Node *cur = &head; enter_scope(); //while (!equal(tok, "}")) for (; !equal(tok, "}"); add_type(cur)) { VarAttr attr = {}; tok = attribute_list(tok, &attr, thing_attributes); if (is_typename(tok) && !equal(tok->next, ":")) { //VarAttr attr = {}; Type *basety = declspec(&tok, tok, &attr); if (attr.is_typedef) { Node *vla_calc = parse_typedef(&tok, tok, basety); cur = cur->next = new_unary(ND_EXPR_STMT, vla_calc, tok); add_type(cur); continue; } if (is_function(tok)) { tok = function(tok, basety, &attr); continue; } if (attr.is_extern) { tok = global_variable(tok, basety, &attr); continue; } cur = cur->next = declaration(&tok, tok, basety, &attr); } else { //case specific of fallthrough //VarAttr attr= {}; tok = attribute_list(tok, &attr, thing_attributes); cur = cur->next = stmt(&tok, tok, false); } add_type(cur); } if (last) *last = cur; leave_scope(); node->body = head.next; if (isDotfile && dotf != NULL) { if (node->body != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->body->kind), node->body->unique_number); } *rest = tok->next; return node; } // compound-stmt = (typedef | declaration | stmt)* //case of missing braces for compound statement static Node *compound_stmt2(Token **rest, Token *tok) { Node *node = new_node(ND_BLOCK, tok); Node head = {}; Node *cur = &head; enter_scope(); while (!equal(tok, "}") && !equal(tok, "case") && !equal(tok, "default")) { VarAttr attr = {}; tok = attribute_list(tok, &attr, thing_attributes); if (is_typename(tok) && !equal(tok->next, ":")) { //VarAttr attr = {}; Type *basety = declspec(&tok, tok, &attr); if (attr.is_typedef) { Node *vla_calc = parse_typedef(&tok, tok, basety); cur = cur->next = new_unary(ND_EXPR_STMT, vla_calc, tok); add_type(cur); continue; } if (is_function(tok)) { tok = function(tok, basety, &attr); continue; } if (attr.is_extern) { tok = global_variable(tok, basety, &attr); continue; } //cur = cur->next = declaration(&tok, tok, basety, &attr); Node *expr = declaration(&tok, tok, basety, &attr); if (expr) cur = cur->next = new_unary(ND_EXPR_STMT, expr, tok); continue; } else { //case specific of fallthrough //VarAttr attr= {}; tok = attribute_list(tok, &attr, thing_attributes); cur = cur->next = stmt(&tok, tok, false); } //add_type(cur); } leave_scope(); node->body = head.next; if (isDotfile && dotf != NULL) { if (node->body != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->body->kind), node->body->unique_number); } *rest = tok; return node; } // expr-stmt = expr? ";" static Node *expr_stmt(Token **rest, Token *tok) { if (equal(tok, ";")) { *rest = tok->next; return new_node(ND_BLOCK, tok); } Node *node = new_node(ND_EXPR_STMT, tok); node->lhs = expr(&tok, tok); if (isDotfile && dotf != NULL) fprintf(dotf, "%s%d -> %s%d\n", nodekind2str(node->kind), node->unique_number, nodekind2str(node->lhs->kind), node->lhs->unique_number); SET_CTX(ctx); *rest = skip(tok, ";", ctx); return node; } // expr = assign ("," expr)? static Node *expr(Token **rest, Token *tok) { Node *node = assign(&tok, tok); if (equal(tok, ",")) return new_binary(ND_COMMA, node, expr(rest, tok->next), tok); *rest = tok; return node; } int64_t eval(Node *node) { return eval2(node, NULL); } // Evaluate a given node as a constant expression. // // A constant expression is either just a number or ptr+n where ptr // is a pointer to a global variable and n is a postiive/negative // number. The latter form is accepted only as an initialization // expression for a global variable. static int64_t eval2(Node *node, char ***label) { add_type(node); if (is_flonum(node->ty)) return eval_double(node); switch (node->kind) { case ND_ADD: return eval2(node->lhs, label) + eval(node->rhs); case ND_SUB: return eval2(node->lhs, label) - eval(node->rhs); case ND_MUL: return eval(node->lhs) * eval(node->rhs); case ND_DIV: // Check for division overflow if (eval(node->lhs) == LLONG_MIN && eval(node->rhs) == -1) { warn_tok(node->tok, "in eval2: %s %d: integer overflow!", PARSE_C, __LINE__); return 0; // Return 0 or any other value you think is appropriate } if (eval(node->rhs) == 0) error_tok(node->tok, "%s %d: in eval2 : eval(node->rhs) caused a division by zero!", PARSE_C, __LINE__ ); if (node->ty && node->ty->is_unsigned) return (uint64_t)eval(node->lhs) / (uint64_t)eval(node->rhs); return eval(node->lhs) / eval(node->rhs); case ND_POS: return eval(node->lhs); case ND_NEG: return -eval(node->lhs); case ND_MOD: // Check for division overflow if (eval(node->lhs) == LLONG_MIN && eval(node->rhs) == -1) { warn_tok(node->tok, "in eval2: %s %d: integer overflow!", PARSE_C, __LINE__); return 0; } if (eval(node->rhs) == 0) error_tok(node->tok, "%s %d: in eval2 : eval(node->rhs) caused a division by zero!", PARSE_C, __LINE__ ); if (node->ty && node->ty->is_unsigned) return (uint64_t)eval(node->lhs) % eval(node->rhs); return eval(node->lhs) % eval(node->rhs); case ND_BITAND: return eval(node->lhs) & eval(node->rhs); case ND_BITOR: return eval(node->lhs) | eval(node->rhs); case ND_BITXOR: return eval(node->lhs) ^ eval(node->rhs); case ND_SHL: return eval(node->lhs) << eval(node->rhs); case ND_SHR: if (node->ty->is_unsigned && node->ty->size == 8) return (uint64_t)eval(node->lhs) >> eval(node->rhs); return eval(node->lhs) >> eval(node->rhs); case ND_EQ: //from @fuhsnn fixing when lhs is a float if (is_flonum(node->lhs->ty)) return eval_double(node->lhs) == eval_double(node->rhs); return eval(node->lhs) == eval(node->rhs); case ND_NE: //from @fuhsnn fixing when lhs is a float if (is_flonum(node->lhs->ty)) return eval_double(node->lhs) != eval_double(node->rhs); return eval(node->lhs) != eval(node->rhs); case ND_LT: //from @fuhsnn fixing when lhs is a float if (is_flonum(node->lhs->ty)) return eval_double(node->lhs) < eval_double(node->rhs); if (node->lhs->ty->is_unsigned) return (uint64_t)eval(node->lhs) < eval(node->rhs); return eval(node->lhs) < eval(node->rhs); case ND_LE: //from @fuhsnn fixing when lhs is a float if (is_flonum(node->lhs->ty)) return eval_double(node->lhs) <= eval_double(node->rhs); if (node->lhs->ty->is_unsigned) return (uint64_t)eval(node->lhs) <= eval(node->rhs); return eval(node->lhs) <= eval(node->rhs); case ND_COND: return eval(node->cond) ? eval2(node->then, label) : eval2(node->els, label); case ND_COMMA: return eval2(node->rhs, label); case ND_NOT: //from @fuhsnn fixing when lhs is a float if (is_flonum(node->lhs->ty)) return !eval_double(node->lhs); return !eval(node->lhs); case ND_BITNOT: return ~eval(node->lhs); case ND_LOGAND: return eval(node->lhs) && eval(node->rhs); case ND_LOGOR: return eval(node->lhs) || eval(node->rhs); case ND_CAST: { if (is_flonum(node->lhs->ty)) { if (node->ty->kind == TY_BOOL) return !!eval_double(node->lhs); if (node->ty->size == 8 && node->ty->is_unsigned) return (uint64_t)eval_double(node->lhs); return eval_sign_extend(node->ty, eval_double(node->lhs)); } if (node->ty->kind == TY_BOOL) { if (node->lhs->kind == ND_VAR && is_array(node->lhs->ty)) return 1; return !!eval2(node->lhs, label); } int64_t val = eval2(node->lhs, label); if (is_integer(node->ty)) return eval_sign_extend(node->ty, val); return val; } case ND_ADDR: return eval_rval(node->lhs, label); case ND_LABEL_VAL: *label = &node->unique_label; return 0; // fixing issue #115 // case ND_DEREF: // return eval2(node->lhs, label); //from @fuhsnn eval2():Evaluate ND_DEREF for TY_ARRAY case ND_DEREF: if (node->ty->kind != TY_ARRAY && !is_vector(node->ty)) error_tok(node->tok, "%s:%d: in eval2 : not a compile-time constant node->ty->kind=%d", PARSE_C, __LINE__, node->ty->kind); return eval2(node->lhs, label); case ND_MEMBER: if (!label) { error_tok(node->tok, "%s:%d: in eval2 : not a compile-time constant", PARSE_C, __LINE__ ); } if (node->ty->kind != TY_ARRAY) { error_tok(node->tok, "%s %d: in eval2 : invalid initializer", PARSE_C, __LINE__); } return eval_rval(node->lhs, label) + node->member->offset; case ND_VAR: if (is_vector(node->var->ty)) return 0; if (!label) { error_tok(node->tok, "%s %d : in eval2 : not a compile-time constant %d", PARSE_C, __LINE__, node->var->ty->kind); } //trying to fix ======ISS-145 compiling util-linux failed with invalid initalizer2 if (node->var->ty->kind != TY_ARRAY && node->var->ty->kind != TY_FUNC && node->var->ty->kind != TY_INT) { error_tok(node->tok, "%s %d: in eval2 : invalid initializer2 %d", PARSE_C, __LINE__, node->var->ty->kind); } //trying to fix ======ISS-145 compiling util-linux failed with invalid initalizer2 if (node->var->ty->kind == TY_INT) return 0; *label = &node->var->name; return 0; case ND_NUM: return node->val; } error_tok(node->tok, "%s %d: in eval2 : not a compile-time constant3", PARSE_C, __LINE__); } static int64_t eval_rval(Node *node, char ***label) { switch (node->kind) { case ND_VAR: if (node->var->is_local) error_tok(node->tok, "%s %d: in eval2 : not a compile-time constant4", PARSE_C, __LINE__); *label = &node->var->name; return 0; case ND_DEREF: return eval2(node->lhs, label); case ND_MEMBER: return eval_rval(node->lhs, label) + node->member->offset; } error_tok(node->tok, "%s %d: in eval2 : invalid initializer3", PARSE_C, __LINE__); } static bool is_const_expr(Node *node) { add_type(node); switch (node->kind) { case ND_ADD: case ND_SUB: case ND_MUL: case ND_DIV: case ND_MOD: case ND_BITAND: case ND_BITOR: case ND_BITXOR: case ND_SHL: case ND_SHR: case ND_EQ: case ND_NE: case ND_LT: case ND_LE: case ND_LOGAND: case ND_LOGOR: return is_const_expr(node->lhs) && is_const_expr(node->rhs); case ND_COND: if (!is_const_expr(node->cond)) return false; return is_const_expr(eval(node->cond) ? node->then : node->els); case ND_COMMA: return is_const_expr(node->rhs); case ND_POS: case ND_NEG: case ND_NOT: case ND_BITNOT: case ND_CAST: return is_const_expr(node->lhs); case ND_NUM: return true; case ND_MEMBER: case ND_ADDR: case ND_DEREF: return is_const_expr(node->lhs); } return false; } int64_t const_expr(Token **rest, Token *tok) { Node *node = conditional(rest, tok); return eval(node); } static double eval_double(Node *node) { add_type(node); if (is_integer(node->ty)) { if (node->ty->is_unsigned) return (unsigned long)eval(node); return eval(node); } switch (node->kind) { case ND_ADD: return eval_double(node->lhs) + eval_double(node->rhs); case ND_SUB: return eval_double(node->lhs) - eval_double(node->rhs); case ND_MUL: return eval_double(node->lhs) * eval_double(node->rhs); case ND_DIV: return eval_double(node->lhs) / eval_double(node->rhs); case ND_POS: return eval_double(node->lhs); case ND_NEG: return -eval_double(node->lhs); case ND_COND: return eval_double(node->cond) ? eval_double(node->then) : eval_double(node->els); case ND_COMMA: return eval_double(node->rhs); case ND_CAST: // if (is_flonum(node->lhs->ty)) // return eval_double(node->lhs); if (is_flonum(node->lhs->ty)) return eval_double(node->lhs); if (node->lhs->ty->size == 8 && node->lhs->ty->is_unsigned) return (uint64_t)eval(node->lhs); return eval(node->lhs); case ND_NUM: return node->fval; } error_tok(node->tok, "%s %d: in eval_double : not a compile-time constant", PARSE_C, __LINE__); } // Convert op= operators to expressions containing an assignment. // // In general, `A op= C` is converted to ``tmp = &A, *tmp = *tmp op B`. // However, if a given expression is of form `A.x op= C`, the input is // converted to `tmp = &A, (*tmp).x = (*tmp).x op C` to handle assignments // to bitfields. static Node *to_assign(Node *binary) { add_type(binary->lhs); add_type(binary->rhs); Token *tok = binary->tok; // Convert `A.x op= C` to `tmp = &A, (*tmp).x = (*tmp).x op C`. if (binary->lhs->kind == ND_MEMBER) { Obj *var = new_lvar("", pointer_to(binary->lhs->lhs->ty), NULL); Node *expr1 = new_binary(ND_ASSIGN, new_var_node(var, tok), new_unary(ND_ADDR, binary->lhs->lhs, tok), tok); Node *expr2 = new_unary(ND_MEMBER, new_unary(ND_DEREF, new_var_node(var, tok), tok), tok); expr2->member = binary->lhs->member; Node *expr3 = new_unary(ND_MEMBER, new_unary(ND_DEREF, new_var_node(var, tok), tok), tok); expr3->member = binary->lhs->member; Node *expr4 = new_binary(ND_ASSIGN, expr2, new_binary(binary->kind, expr3, binary->rhs, tok), tok); return new_binary(ND_COMMA, expr1, expr4, tok); } // If A is an atomic type, Convert `A op= B` to // // ({ // T1 *addr = &A; T2 val = (B); T1 old = *addr; T1 new; // do { // new = old op val; // } while (!atomic_compare_exchange_strong(addr, &old, new)); // new; // }) if (binary->lhs->ty->is_atomic || binary->atomic_fetch) { Node head = {}; Node *cur = &head; Obj *addr = new_lvar("", pointer_to(binary->lhs->ty), NULL); Obj *val = new_lvar("", binary->rhs->ty, NULL); Obj *old = new_lvar("", binary->lhs->ty, NULL); Obj *new = new_lvar("", binary->lhs->ty, NULL); Obj *ret = binary->atomic_fetch ? old : new; cur = cur->next = new_unary(ND_EXPR_STMT, new_binary(ND_ASSIGN, new_var_node(addr, tok), new_unary(ND_ADDR, binary->lhs, tok), tok), tok); cur = cur->next = new_unary(ND_EXPR_STMT, new_binary(ND_ASSIGN, new_var_node(val, tok), binary->rhs, tok), tok); cur = cur->next = new_unary(ND_EXPR_STMT, new_binary(ND_ASSIGN, new_var_node(old, tok), new_unary(ND_DEREF, new_var_node(addr, tok), tok), tok), tok); Node *loop = new_node(ND_DO, tok); loop->brk_label = new_unique_name(); loop->cont_label = new_unique_name(); Node *body = new_binary(ND_ASSIGN, new_var_node(new, tok), new_binary(binary->kind, new_var_node(old, tok), new_var_node(val, tok), tok), tok); loop->then = new_node(ND_BLOCK, tok); loop->then->body = new_unary(ND_EXPR_STMT, body, tok); Node *cas = new_node(ND_CAS, tok); cas->cas_addr = new_var_node(addr, tok); cas->cas_old = new_unary(ND_ADDR, new_var_node(old, tok), tok); cas->cas_new = new_var_node(new, tok); loop->cond = new_unary(ND_NOT, cas, tok); cur = cur->next = loop; // cur = cur->next = new_unary(ND_EXPR_STMT, new_var_node(new, tok), tok); cur = cur->next = new_unary(ND_EXPR_STMT, new_var_node(ret, tok), tok); Node *node = new_node(ND_STMT_EXPR, tok); node->body = head.next; return node; } // Convert `A op= B` to ``tmp = &A, *tmp = *tmp op B`. Obj *var = new_lvar("", pointer_to(binary->lhs->ty), NULL); Node *expr1 = new_binary(ND_ASSIGN, new_var_node(var, tok), new_unary(ND_ADDR, binary->lhs, tok), tok); Node *expr2 = new_binary(ND_ASSIGN, new_unary(ND_DEREF, new_var_node(var, tok), tok), new_binary(binary->kind, new_unary(ND_DEREF, new_var_node(var, tok), tok), binary->rhs, tok), tok); return new_binary(ND_COMMA, expr1, expr2, tok); } // assign = conditional (assign-op assign)? // assign-op = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "&=" | "|=" | "^=" // | "<<=" | ">>=" static Node *assign(Token **rest, Token *tok) { Node *node = conditional(&tok, tok); if (equal(tok, "=")) return new_binary(ND_ASSIGN, node, assign(rest, tok->next), tok); if (equal(tok, "+=")) return to_assign(new_add(node, assign(rest, tok->next), tok, false)); if (equal(tok, "-=")) return to_assign(new_sub(node, assign(rest, tok->next), tok, false)); if (equal(tok, "*=")) return to_assign(new_binary(ND_MUL, node, assign(rest, tok->next), tok)); if (equal(tok, "/=")) return to_assign(new_binary(ND_DIV, node, assign(rest, tok->next), tok)); if (equal(tok, "%=")) return to_assign(new_binary(ND_MOD, node, assign(rest, tok->next), tok)); if (equal(tok, "&=")) return to_assign(new_binary(ND_BITAND, node, assign(rest, tok->next), tok)); if (equal(tok, "|=")) return to_assign(new_binary(ND_BITOR, node, assign(rest, tok->next), tok)); if (equal(tok, "^=")) return to_assign(new_binary(ND_BITXOR, node, assign(rest, tok->next), tok)); if (equal(tok, "<<=")) return to_assign(new_binary(ND_SHL, node, assign(rest, tok->next), tok)); if (equal(tok, ">>=")) return to_assign(new_binary(ND_SHR, node, assign(rest, tok->next), tok)); *rest = tok; return node; } // conditional = logor ("?" expr? ":" conditional)? static Node *conditional(Token **rest, Token *tok) { Node *cond = logor(&tok, tok); if (!equal(tok, "?")) { *rest = tok; return cond; } if (equal(tok->next, ":") || equal(tok, ",")) { // [GNU] Compile `a ?: b` as `tmp = a, tmp ? tmp : b`. add_type(cond); Obj *var = new_lvar("", cond->ty, NULL); Node *lhs = new_binary(ND_ASSIGN, new_var_node(var, tok), cond, tok); Node *rhs = new_node(ND_COND, tok); rhs->cond = new_var_node(var, tok); rhs->then = new_var_node(var, tok); rhs->els = conditional(rest, tok->next->next); return new_binary(ND_COMMA, lhs, rhs, tok); } Node *node = new_node(ND_COND, tok); node->cond = cond; node->then = expr(&tok, tok->next); SET_CTX(ctx); tok = skip(tok, ":", ctx); node->els = conditional(rest, tok); return node; } // logor = logand ("||" logand)* static Node *logor(Token **rest, Token *tok) { Node *node = logand(&tok, tok); while (equal(tok, "||")) { Token *start = tok; node = new_binary(ND_LOGOR, node, logand(&tok, tok->next), start); } *rest = tok; return node; } // logand = bitor ("&&" bitor)* static Node *logand(Token **rest, Token *tok) { Node *node = bitor (&tok, tok); while (equal(tok, "&&")) { Token *start = tok; node = new_binary(ND_LOGAND, node, bitor (&tok, tok->next), start); } *rest = tok; return node; } // bitor = bitxor ("|" bitxor)* static Node * bitor (Token * *rest, Token *tok) { Node *node = bitxor(&tok, tok); while (equal(tok, "|")) { Token *start = tok; node = new_binary(ND_BITOR, node, bitxor(&tok, tok->next), start); promote_scalar_to_vector(node); } *rest = tok; return node; } // bitxor = bitand ("^" bitand)* static Node *bitxor(Token **rest, Token *tok) { Node *node = bitand(&tok, tok); while (equal(tok, "^")) { Token *start = tok; node = new_binary(ND_BITXOR, node, bitand(&tok, tok->next), start); promote_scalar_to_vector(node); } *rest = tok; return node; } // bitand = equality ("&" equality)* static Node *bitand(Token **rest, Token *tok) { Node *node = equality(&tok, tok); while (equal(tok, "&")) { Token *start = tok; node = new_binary(ND_BITAND, node, equality(&tok, tok->next), start); promote_scalar_to_vector(node); } *rest = tok; return node; } // equality = relational ("==" relational | "!=" relational)* static Node *equality(Token **rest, Token *tok) { Node *node = relational(&tok, tok); for (;;) { Token *start = tok; if (equal(tok, "==")) { node = new_binary(ND_EQ, node, relational(&tok, tok->next), start); continue; } if (equal(tok, "!=")) { node = new_binary(ND_NE, node, relational(&tok, tok->next), start); continue; } *rest = tok; return node; } } // relational = shift ("<" shift | "<=" shift | ">" shift | ">=" shift)* static Node *relational(Token **rest, Token *tok) { Node *node = shift(&tok, tok); for (;;) { Token *start = tok; if (equal(tok, "<")) { node = new_binary(ND_LT, node, shift(&tok, tok->next), start); continue; } if (equal(tok, "<=")) { node = new_binary(ND_LE, node, shift(&tok, tok->next), start); continue; } if (equal(tok, ">")) { node = new_binary(ND_LT, shift(&tok, tok->next), node, start); continue; } if (equal(tok, ">=")) { node = new_binary(ND_LE, shift(&tok, tok->next), node, start); continue; } *rest = tok; return node; } } // shift = add ("<<" add | ">>" add)* static Node *shift(Token **rest, Token *tok) { Node *node = add(&tok, tok); for (;;) { Token *start = tok; if (equal(tok, "<<")) { node = new_binary(ND_SHL, node, add(&tok, tok->next), start); continue; } if (equal(tok, ">>")) { node = new_binary(ND_SHR, node, add(&tok, tok->next), start); continue; } *rest = tok; return node; } } // In C, `+` operator is overloaded to perform the pointer arithmetic. // If p is a pointer, p+n adds not n but sizeof(*p)*n to the value of p, // so that p+n points to the location n elements (not bytes) ahead of p. // In other words, we need to scale an integer value before adding to a // pointer value. This function takes care of the scaling. static Node *new_add(Node *lhs, Node *rhs, Token *tok, bool is_op) { add_type(lhs); add_type(rhs); //case of vectors + sclaras if (is_op && (is_vector(lhs->ty) || is_vector(rhs->ty))) { if (is_vector(lhs->ty) && !is_vector(rhs->ty)) { rhs = scalar_to_vector(rhs, lhs->ty); rhs->ty = lhs->ty; } else if (is_vector(rhs->ty) && !is_vector(lhs->ty)) { lhs = scalar_to_vector(lhs, rhs->ty); lhs->ty = rhs->ty; } } // case of vectors if (is_vector(lhs->ty) && is_vector(rhs->ty)) { if (lhs->ty->array_len != rhs->ty->array_len) error_tok(tok, "%s %d: in new_add: incompatible vector types", PARSE_C, __LINE__); Node *node = new_binary(ND_ADD, lhs, rhs, tok); node->ty = lhs->ty; return node; } // num + num if (is_numeric(lhs->ty) && is_numeric(rhs->ty)) return new_binary(ND_ADD, lhs, rhs, tok); if ((lhs->ty->base == NULL && rhs->ty->base == NULL) || (lhs->ty->base != NULL && rhs->ty->base != NULL)) { error_tok(tok, "%s %d: in new_add : invalid operands", PARSE_C, __LINE__); } // Canonicalize `num + ptr` to `ptr + num`. if (!lhs->ty->base && rhs->ty->base) { Node *tmp = lhs; lhs = rhs; rhs = tmp; } // VLA + num if (lhs->ty->base->kind == TY_VLA) { rhs = new_binary(ND_MUL, rhs, new_var_node(lhs->ty->base->vla_size, tok), tok); return new_binary(ND_ADD, lhs, rhs, tok); } // ptr + num rhs = new_binary(ND_MUL, rhs, new_long(lhs->ty->base->size, tok), tok); return new_binary(ND_ADD, lhs, rhs, tok); } // Like `+`, `-` is overloaded for the pointer type. static Node *new_sub(Node *lhs, Node *rhs, Token *tok, bool is_op) { add_type(lhs); add_type(rhs); //case of vectors + scalars if (is_op && (is_vector(lhs->ty) || is_vector(rhs->ty))) { if (is_vector(lhs->ty) && !is_vector(rhs->ty)) { rhs = scalar_to_vector(rhs, lhs->ty); rhs->ty = lhs->ty; } else if (is_vector(rhs->ty) && !is_vector(lhs->ty)) { lhs = scalar_to_vector(lhs, rhs->ty); lhs->ty = rhs->ty; } } // case of vectors if (is_vector(lhs->ty) && is_vector(rhs->ty)) { if (lhs->ty->array_len != rhs->ty->array_len || lhs->ty->base->kind != rhs->ty->base->kind) error_tok(tok, "%s %d: in new_sub : incompatible vector types", PARSE_C, __LINE__); Node *node = new_binary(ND_SUB, lhs, rhs, tok); node->ty = lhs->ty; return node; } // num - num if (is_numeric(lhs->ty) && is_numeric(rhs->ty)) return new_binary(ND_SUB, lhs, rhs, tok); // VLA + num if (lhs->ty->base && lhs->ty->base->kind == TY_VLA) { rhs = new_binary(ND_MUL, rhs, new_var_node(lhs->ty->base->vla_size, tok), tok); add_type(rhs); Node *node = new_binary(ND_SUB, lhs, rhs, tok); node->ty = lhs->ty; return node; } // ptr - num if (lhs->ty->base && is_integer(rhs->ty)) { rhs = new_binary(ND_MUL, rhs, new_long(lhs->ty->base->size, tok), tok); add_type(rhs); Node *node = new_binary(ND_SUB, lhs, rhs, tok); node->ty = lhs->ty; return node; } // ptr - ptr, which returns how many elements are between the two. if (lhs->ty->base && rhs->ty->base) { Node *node = new_binary(ND_SUB, lhs, rhs, tok); node->ty = ty_long; return new_binary(ND_DIV, node, new_num(lhs->ty->base->size, tok), tok); } error_tok(tok, "%s %d: in new_sub : invalid operands", PARSE_C, __LINE__); } // add = mul ("+" mul | "-" mul)* static Node *add(Token **rest, Token *tok) { Node *node = mul(&tok, tok); for (;;) { Token *start = tok; if (equal(tok, "+")) { node = new_add(node, mul(&tok, tok->next), start, true); continue; } if (equal(tok, "-")) { node = new_sub(node, mul(&tok, tok->next), start, true); continue; } *rest = tok; return node; } } // mul = cast ("*" cast | "/" cast | "%" cast)* static Node *mul(Token **rest, Token *tok) { Node *node = cast(&tok, tok); for (;;) { Token *start = tok; if (equal(tok, "*")) { node = new_binary(ND_MUL, node, cast(&tok, tok->next), start); promote_scalar_to_vector(node); continue; } if (equal(tok, "/")) { node = new_binary(ND_DIV, node, cast(&tok, tok->next), start); promote_scalar_to_vector(node); continue; } if (equal(tok, "%")) { node = new_binary(ND_MOD, node, cast(&tok, tok->next), start); promote_scalar_to_vector(node); continue; } *rest = tok; return node; } } // cast = "(" type-name ")" cast | unary static Node *cast(Token **rest, Token *tok) { Token *start = tok; //fix for the following cast case : //(__attribute__((__vector_size__ (16))) int) if (equal(tok, "(") && equal(tok->next, "__attribute__")) { while(tok->kind != TK_KEYWORD) tok = tok->next; Type *tmp = typename(&tok, tok); tok = attribute_list(start->next, tmp, type_attributes); start->next = tok; Type *ty = typename(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); // compound literal if (equal(tok, "{")) return unary(rest, start); // type cast Node *node = new_cast(cast(rest, tok), ty); node->tok = start; return node; } if (equal(tok, "(") && is_typename(tok->next)) { //Token *start = tok; Type *ty = typename(&tok, tok->next); SET_CTX(ctx); tok = skip(tok, ")", ctx); // compound literal if (equal(tok, "{")) return unary(rest, start); // type cast Node *node = new_cast(cast(rest, tok), ty); node->tok = start; return node; } return unary(rest, tok); } // unary = ("+" | "-" | "*" | "&" | "!" | "~") cast // | ("++" | "--") unary // | "&&" ident // | postfix static Node *unary(Token **rest, Token *tok) { if (equal(tok, "+")) return new_unary(ND_POS, cast(rest, tok->next), tok); //return cast(rest, tok->next); if (equal(tok, "-")) return new_unary(ND_NEG, cast(rest, tok->next), tok); if (equal(tok, "&")) { Node *lhs = cast(rest, tok->next); add_type(lhs); //if (lhs->kind == ND_MEMBER && lhs->member->is_bitfield) if (is_bitfield(lhs)) error_tok(tok, "%s %d: in unary : cannot take address of bitfield", PARSE_C, __LINE__); if (lhs->kind == ND_VAR && lhs->var && lhs->var->is_function) { lhs->var->is_address_used = true; } return new_unary(ND_ADDR, lhs, tok); } if (equal(tok, "*")) { // [https://www.sigbus.info/n1570#6.5.3.2p4] This is an oddity // in the C spec, but dereferencing a function shouldn't do // anything. If foo is a function, `*foo`, `**foo` or `*****foo` // are all equivalent to just `foo`. Node *node = cast(rest, tok->next); add_type(node); if (node->ty->kind == TY_FUNC) return node; Type *ty = node->ty; node = new_unary(ND_DEREF, node, tok); if (is_array(ty)) apply_cv_qualifier(node, ty); return node; //return new_unary(ND_DEREF, node, tok); } if (equal(tok, "!")) return new_unary(ND_NOT, cast(rest, tok->next), tok); if (equal(tok, "~")) return new_unary(ND_BITNOT, cast(rest, tok->next), tok); // Read ++i as i+=1 if (equal(tok, "++")) return to_assign(new_add(unary(rest, tok->next), new_num(1, tok), tok, false)); // Read --i as i-=1 if (equal(tok, "--")) return to_assign(new_sub(unary(rest, tok->next), new_num(1, tok), tok, false)); // [GNU] labels-as-values if (equal(tok, "&&")) { Node *node = new_node(ND_LABEL_VAL, tok); node->label = get_ident(tok->next); node->goto_next = gotos; gotos = node; *rest = tok->next->next; return node; } return postfix(rest, tok); } // struct-members = (declspec declarator ("," declarator)* ";")* static void struct_members(Token **rest, Token *tok, Type *ty) { Member head = {}; Member *cur = &head; //int idx = 0; while (!equal(tok, "}")) { VarAttr attr = {}; Type *basety = declspec(&tok, tok, &attr); bool first = true; // Anonymous struct member if ((basety->kind == TY_STRUCT || basety->kind == TY_UNION) && consume(&tok, tok, ";")) { Member *mem = calloc(1, sizeof(Member)); if (mem == NULL) error("%s: %s:%d: error: in struct_members : mem is null", PARSE_C, __FILE__, __LINE__); mem->ty = basety; //mem->idx = idx++; mem->align = attr.align ? attr.align : mem->ty->align; cur = cur->next = mem; continue; } // Regular struct members while (!consume(&tok, tok, ";")) { tok = attribute_list(tok, ty, type_attributes); if (equal(tok, ";")) break; if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; Member *mem = calloc(1, sizeof(Member)); if (mem == NULL) error("%s: %s:%d: error: in struct_members : mem is null", PARSE_C, __FILE__, __LINE__); if (tok->kind == TK_KEYWORD) basety = declspec(&tok, tok, &attr); mem->ty = declarator(&tok, tok, basety); mem->name = mem->ty->name; //mem->idx = idx++; mem->align = attr.align ? attr.align : mem->ty->align; if (consume(&tok, tok, ":")) { if (!is_integer(mem->ty)) { error_tok(tok, "%s %d: in struct_members : only integers can be bitfields", PARSE_C, __LINE__); } mem->is_bitfield = true; mem->bit_width = const_expr(&tok, tok); if (mem->bit_width < 0) { error_tok(tok, "%s %d: in struct_members : bitfield width must be positive", PARSE_C, __LINE__); } } cur = cur->next = mem; } } // If the last element is an array of incomplete type, it's // called a "flexible array member". It should behave as if // if were a zero-sized array. if (cur != &head && cur->ty->kind == TY_ARRAY && cur->ty->array_len < 0) { cur->ty = array_of(cur->ty->base, 0); ty->is_flexible = true; cur->ty->is_flexible = true; } //Check for VLA-containing members for (Member *mem = head.next; mem; mem = mem->next) { if (mem->ty->has_vla) { ty->has_vla = true; break; } } *rest = tok->next; ty->members = head.next; } //from COSMOPOLITAN adding attribute management static Token *attribute_list(Token *tok, void *arg, Token *(*f)(Token *, void *)) { while (consume(&tok, tok, "__attribute__") || consume(&tok, tok, "__attribute")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); SET_CTX(ctx); tok = skip(tok, "(", ctx); bool first = true; while (!consume(&tok, tok, ")")) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; tok = f(tok, arg); } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } // attribute = ("__attribute__" "(" "(" "packed" ")" ")")* static Token *type_attributes(Token *tok, void *arg) { Type *ty = arg; if (!ty) { warn_tok(tok, "in type_attributes: %s %d: ty is null", PARSE_C, __LINE__); return tok; } if (consume(&tok, tok, "packed") || consume(&tok, tok, "__packed__")) { ty->is_packed = true; return tok; } // if ((equal(tok->next, ")") && consume(&tok, tok, "__aligned__")) || (equal(tok->next, ")") && consume(&tok, tok, "aligned")) ) // { // ty->is_aligned = true; // return tok; // } if (consume(&tok, tok, "aligned") || consume(&tok, tok, "__aligned__")) { ty->is_aligned = true; if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); //from COSMOPOLITAN adding is_aligned ty->align = const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } //from COSMOPOLITAN adding ms_abi if (consume(&tok, tok, "ms_abi") || consume(&tok, tok, "__ms_abi__")) { ty->is_ms_abi = true; return tok; } if (consume(&tok, tok, "constructor") || consume(&tok, tok, "__constructor__")) { ty->is_constructor = true; ty->constructor_priority = 65535; // Default GCC priority if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(",ctx); // Parse the priority integer constant if present if (tok->kind == TK_NUM) { ty->constructor_priority = tok->val; tok = tok->next; } else { warn_tok(tok, "in type_attributes: %s %d: expected integer priority in constructor attribute", PARSE_C, __LINE__); } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } // if (consume(&tok, tok, "destructor") || consume(&tok, tok, "__destructor__")) { // ty->is_destructor = true; // return tok; // } if (consume(&tok, tok, "destructor") || consume(&tok, tok, "__destructor__")) { ty->is_destructor = true; ty->destructor_priority = 65535; // Default GCC priority if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(",ctx); // Parse the priority integer constant if present if (tok->kind == TK_NUM) { ty->destructor_priority = tok->val; tok = tok->next; } else { warn_tok(tok, "in type_attributes: %s %d: expected integer priority in destructor attribute", PARSE_C, __LINE__); } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "vector_size") || consume(&tok, tok, "__vector_size__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); int vs = const_expr(&tok, tok); if (vs != 2 && vs != 4 && vs != 8 && vs != 16) { error_tok(tok, "%s %d: unsupported vector_size %d; only 2, 4, 8 and 16 are supported", PARSE_C, __LINE__, vs); } if (vs != ty->vector_size) { //ty->size = vs; ty->vector_size = vs; if (!ty->is_aligned) ty->align = vs; } int base_size = ty->size; if (base_size == 0) { error_tok(tok, "%s %d: in types_attributes: incorrect base size %d;", PARSE_C, __LINE__, base_size); } int n = vs / base_size; ty->is_vector = true; ty = vector_of(ty, n); SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } //from COSMOPOLITAN adding warn_if_not_aligned if (consume(&tok, tok, "warn_if_not_aligned") || consume(&tok, tok, "__warn_if_not_aligned__") ) { SET_CTX(ctx); tok = skip(tok, "(", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } if (equal(tok->next, "(") && (consume(&tok, tok, "__deprecated__") || consume(&tok, tok, "deprecated"))) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "__target__") || consume(&tok, tok, "target")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "section") || consume(&tok, tok, "__section__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ty->section = ConsumeStringLiteral(&tok, tok); current_section = ty->section; SET_CTX(ctx); return skip(tok, ")", ctx); } //from COSMOPOLITAN adding deprecated, may_alias, unused if (consume(&tok, tok, "deprecated") || consume(&tok, tok, "__deprecated__") || consume(&tok, tok, "may_alias") || consume(&tok, tok, "__may_alias__") || consume(&tok, tok, "__transparent_union__") || consume(&tok, tok, "transparent_union")) { return tok; } // Handle __cleanup__ attribute if (consume(&tok, tok, "cleanup") || consume(&tok, tok, "__cleanup__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: in type_attributes: expected identifier in __cleanup__", PARSE_C, __LINE__); // Store the cleanup function name current_type = copy_type(ty); tok = tok->next; SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } if (consume(&tok, tok, "cold") || consume(&tok, tok, "__cold__")) { return tok; } if (consume(&tok, tok, "hot") || consume(&tok, tok, "__hot__")) { return tok; } if (consume(&tok, tok, "malloc") || consume(&tok, tok, "__malloc__")) { // Check for optional parameters: e.g., __malloc__(rpl_free, 1) if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); // Parse the deallocator function name (e.g., rpl_free) if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: expected identifier in __malloc__ attribute", PARSE_C, __LINE__); tok = tok->next; // Optionally consume comma and size argument if (equal(tok, ",")) { tok = tok->next; const_expr(&tok, tok); // size index (e.g., 1) } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "null_terminated_string_arg")) { // GCC syntax: __attribute__((null_terminated_string_arg(index))) if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "noinline") || consume(&tok, tok, "__noinline__") || consume(&tok, tok, "const") || consume(&tok, tok, "__const__") || consume(&tok, tok, "pure") || consume(&tok, tok, "__pure__") || consume(&tok, tok, "dontclone") || consume(&tok, tok, "__dontclone__") || consume(&tok, tok, "may_alias") || consume(&tok, tok, "__may_alias__") || consume(&tok, tok, "warn_unused_result") || consume(&tok, tok, "__warn_unused_result__") || consume(&tok, tok, "flatten") || consume(&tok, tok, "__flatten__") || consume(&tok, tok, "leaf") || consume(&tok, tok, "__leaf__") || consume(&tok, tok, "no_reorder") || consume(&tok, tok, "__no_reorder__") || consume(&tok, tok, "dontthrow") || consume(&tok, tok, "__dontthrow__") || consume(&tok, tok, "optnone") || consume(&tok, tok, "__optnone__") || consume(&tok, tok, "returns_twice") || consume(&tok, tok, "__returns_twice__") || consume(&tok, tok, "nodebug") || consume(&tok, tok, "__nodebug__") || consume(&tok, tok, "artificial") || consume(&tok, tok, "__artificial__") || consume(&tok, tok, "returns_nonnull") || consume(&tok, tok, "__returns_nonnull__") || consume(&tok, tok, "deprecated") || consume(&tok, tok, "__deprecated__") || consume(&tok, tok, "__transparent_union__") || consume(&tok, tok, "transparent_union") || consume(&tok, tok, "gnu_inline") || consume(&tok, tok, "__gnu_inline__") || consume(&tok, tok, "used") || consume(&tok, tok, "__used__") || consume(&tok, tok, "unused") || consume(&tok, tok, "__unused__") || consume(&tok, tok, "no_icf") || consume(&tok, tok, "__no_icf__") || consume(&tok, tok, "noipa") || consume(&tok, tok, "__noipa__") || consume(&tok, tok, "noplt") || consume(&tok, tok, "__noplt__") || consume(&tok, tok, "stack_protect") || consume(&tok, tok, "__stack_protect__") || consume(&tok, tok, "no_sanitize_address") || consume(&tok, tok, "__no_sanitize_address__") || consume(&tok, tok, "no_sanitize_thread") || consume(&tok, tok, "__no_sanitize_thread__") || consume(&tok, tok, "no_split_stack") || consume(&tok, tok, "__no_split_stack__") || consume(&tok, tok, "no_stack_limit") || consume(&tok, tok, "__no_stack_limit__") || consume(&tok, tok, "no_sanitize_undefined") || consume(&tok, tok, "__no_sanitize_undefined__") || consume(&tok, tok, "__nonstring__") || consume(&tok, tok, "nonstring") || consume(&tok, tok, "no_profile_instrument_function") || consume(&tok, tok, "stdcall") || consume(&tok, tok, "ms_struct") || consume(&tok, tok, "__stub__") || consume(&tok, tok, "__retain__") || consume(&tok, tok, "transaction_pure") || consume(&tok, tok, "transaction_may_cancel_outer") || consume(&tok, tok, "transaction_callable") || consume(&tok, tok, "tainted_args") || consume(&tok, tok, "__designated_init__") || consume(&tok, tok, "__no_profile_instrument_function__")) { return tok; } //fallthrough is the last instruction in case: followed by a semicolon if (consume(&tok, tok, "fallthrough") || consume(&tok, tok, "__fallthrough__") ) { return tok; } if (consume(&tok, tok, "format") || consume(&tok, tok, "__format__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); consume(&tok, tok, "printf") ; consume(&tok, tok, "__printf__"); consume(&tok, tok, "scanf"); consume(&tok, tok, "__scanf__"); consume(&tok, tok, "strftime"); consume(&tok, tok, "__strftime__"); consume(&tok, tok, "strfmon"); consume(&tok, tok, "__strfmon__"); consume(&tok, tok, "gnu_printf"); consume(&tok, tok, "__gnu_printf__"); consume(&tok, tok, "gnu_scanf"); consume(&tok, tok, "__gnu_scanf__"); consume(&tok, tok, "gnu_strftime"); consume(&tok, tok, "__gnu_strftime__"); SET_CTX(ctx); tok = skip(tok, ",", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } if (consume(&tok, tok, "format_arg") || consume(&tok, tok, "__format_arg__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok =skip(tok, ")", ctx); return tok; } if (consume(&tok, tok, "mode") || consume(&tok, tok, "__mode__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); if (consume(&tok, tok, "__QI__") || consume(&tok, tok, "__HI__") || consume(&tok, tok, "__SI__") || consume(&tok, tok, "__DI__") || consume(&tok, tok, "__TI__") || consume(&tok, tok, "__SF__") || consume(&tok, tok, "__DF__") || consume(&tok, tok, "__XF__") || consume(&tok, tok, "__TF__") || consume(&tok, tok, "__SQ__") || consume(&tok, tok, "__HQ__") || consume(&tok, tok, "__SA__") || consume(&tok, tok, "__DA__") || consume(&tok, tok, "__TQ__") || consume(&tok, tok, "__V2SI__") || consume(&tok, tok, "__V4SI__") || consume(&tok, tok, "__V8HI__") || consume(&tok, tok, "__V16QI__") || consume(&tok, tok, "__word__") || consume(&tok, tok, "__pointer__") || consume(&tok, tok, "__CQI__") || consume(&tok, tok, "__CHI__") || consume(&tok, tok, "__CDF__") || consume(&tok, tok, "__TC__") ||consume(&tok, tok, "__BI__")) { SET_CTX(ctx); return skip(tok, ")", ctx); } SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "nothrow") || consume(&tok, tok, "__nothrow__")) { return tok; } if (consume(&tok, tok, "noreturn") || consume(&tok, tok, "__noreturn__")) { return tok; } if (consume(&tok, tok, "const") || consume(&tok, tok, "__const__")) { ty->is_const = true; return tok; } if (consume(&tok, tok, "always_inline") || consume(&tok, tok, "__always_inline__")) { ty->is_inline = true; return tok; } if (consume(&tok, tok, "nonnull") || consume(&tok, tok, "__nonnull__")) { if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(",ctx); // Optional parameter list while (!equal(tok, ")")) { if (tok->kind != TK_NUM) { error_tok(tok, "%s %d: expected parameter index in __nonnull__", PARSE_C, __LINE__); } // You can store the info if you want (e.g., attr->nonnull_params = ...) tok = tok->next; if (equal(tok, ",")) tok = tok->next; else break; } SET_CTX(ctx); tok = skip(tok, ")",ctx); } return tok; } if (consume(&tok, tok, "sentinel") || consume(&tok, tok, "__sentinel__") || consume(&tok, tok, "optimize") || consume(&tok, tok, "__optimize__") || consume(&tok, tok, "assume_aligned") || consume(&tok, tok, "__assume_aligned__") || consume(&tok, tok, "alloc_size") || consume(&tok, tok, "__alloc_size__") || consume(&tok, tok, "attribute_alloc_size") || consume(&tok, tok, "__attribute_alloc_size__") || consume(&tok, tok, "alloc_align") || consume(&tok, tok, "__alloc_align__")) { if (consume(&tok, tok, "(")) { for (;;) { const_expr(&tok, tok); if (consume(&tok, tok, ")")) break; SET_CTX(ctx); tok = skip(tok, ",", ctx); } } return tok; } if (consume(&tok, tok, "error") || consume(&tok, tok, "__error__") || consume(&tok, tok, "warning") || consume(&tok, tok, "__warning__") || consume(&tok, tok, "__access__") ) { bool two_parent= false; SET_CTX(ctx); tok = skip(tok, "(", ctx); if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); two_parent = true; } ConsumeStringLiteral(&tok, tok); if (two_parent) { SET_CTX(ctx); tok = skip(tok, ")", ctx); } SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "no_sanitize")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "weak") || consume(&tok, tok, "__weak__")) { //int __attribute__((weak, alias("lxc_attach_main"))) main(int argc, char *argv[]); ty->is_weak = true; consume(&tok, tok, ","); if (consume(&tok, tok, "alias")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ty->alias_name = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "alias")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ty->alias_name = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } if (consume(&tok, tok, "visibility") || consume(&tok, tok, "__visibility__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ty->visibility = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } return tok; } //from COSMOPOLITAN adding attribute for variable static Token *thing_attributes(Token *tok, void *arg) { VarAttr *attr = arg; if (!attr) { warn_tok(tok, "in thing_attributes: %s %d: attr is null", PARSE_C, __LINE__); return tok; } if (consume(&tok, tok, "packed") || consume(&tok, tok, "__packed__")) { attr->is_packed = true; return tok; } if (consume(&tok, tok, "weak") || consume(&tok, tok, "__weak__")) { //int __attribute__((weak, alias("lxc_attach_main"))) main(int argc, char *argv[]); attr->is_weak = true; consume(&tok, tok, ","); if (consume(&tok, tok, "alias")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); attr->alias_name = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "alias")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); attr->alias_name = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } if (consume(&tok, tok, "hot") || consume(&tok, tok, "__hot__")) { attr->section = ".text.likely"; return tok; } if (consume(&tok, tok, "cold") || consume(&tok, tok, "__cold__")) { attr->section = ".text.unlikely"; return tok; } if (consume(&tok, tok, "__target__") || consume(&tok, tok, "target")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "section") || consume(&tok, tok, "__section__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); attr->section = ConsumeStringLiteral(&tok, tok); current_section = attr->section; SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "noreturn") || consume(&tok, tok, "__noreturn__")) { attr->is_noreturn = true; return tok; } if (consume(&tok, tok, "nothrow") || consume(&tok, tok, "__nothrow__")) { return tok; } if (consume(&tok, tok, "always_inline") || consume(&tok, tok, "__always_inline__")) { attr->is_inline = true; return tok; } if (consume(&tok, tok, "const") || consume(&tok, tok, "__const__")) { return tok; } if (consume(&tok, tok, "visibility") || consume(&tok, tok, "__visibility__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); attr->visibility = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "externally_visible") || consume(&tok, tok, "__externally_visible__")) { attr->is_externally_visible = true; return tok; } if (consume(&tok, tok, "no_instrument_function") || consume(&tok, tok, "__no_instrument_function__")) { attr->is_no_instrument_function = true; return tok; } if (consume(&tok, tok, "force_align_arg_pointer") || consume(&tok, tok, "__force_align_arg_pointer__")) { attr->is_force_align_arg_pointer = true; return tok; } if (consume(&tok, tok, "no_caller_saved_registers") || consume(&tok, tok, "__no_caller_saved_registers__")) { attr->is_no_caller_saved_registers = true; return tok; } if (consume(&tok, tok, "ms_abi")) { attr->is_ms_abi = true; return tok; } if (consume(&tok, tok, "constructor") || consume(&tok, tok, "__constructor__")) { attr->is_constructor = true; attr->constructor_priority = 65535; // Default GCC priority if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(",ctx); // Parse the priority integer constant if present if (tok->kind == TK_NUM) { attr->constructor_priority = tok->val; tok = tok->next; } else { warn_tok(tok, "in thing_attributes: %s %d: expected integer priority in constructor attribute", PARSE_C, __LINE__); } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "destructor") || consume(&tok, tok, "__destructor__")) { attr->is_destructor = true; attr->destructor_priority = 65535; // Default GCC priority if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(",ctx); // Parse the priority integer constant if present if (tok->kind == TK_NUM) { attr->destructor_priority = tok->val; tok = tok->next; } else { warn_tok(tok, "in thing_attributes: %s %d: expected integer priority in destructor attribute", PARSE_C, __LINE__); } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "aligned") || consume(&tok, tok, "__aligned__")) { attr->is_aligned = true; if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); //from COSMOPOLITAN adding is_aligned attr->align = const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "warn_if_not_aligned") || consume(&tok, tok, "__warn_if_not_aligned__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); const_expr(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "error") || consume(&tok, tok, "__error__") || consume(&tok, tok, "warning") || consume(&tok, tok, "__warning__") || consume(&tok, tok, "__access__") ) { bool two_parent= false; SET_CTX(ctx); tok = skip(tok, "(", ctx); if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); two_parent = true; } ConsumeStringLiteral(&tok, tok); if (two_parent) { SET_CTX(ctx); tok = skip(tok, ")", ctx); } SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "mode") || consume(&tok, tok, "__mode__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); if (consume(&tok, tok, "__QI__") || consume(&tok, tok, "__HI__") || consume(&tok, tok, "__SI__") || consume(&tok, tok, "__DI__") || consume(&tok, tok, "__TI__") || consume(&tok, tok, "__SF__") || consume(&tok, tok, "__DF__") || consume(&tok, tok, "__XF__") || consume(&tok, tok, "__TF__") || consume(&tok, tok, "__SQ__") || consume(&tok, tok, "__HQ__") || consume(&tok, tok, "__SA__") || consume(&tok, tok, "__DA__") || consume(&tok, tok, "__TQ__") || consume(&tok, tok, "__V2SI__") || consume(&tok, tok, "__V4SI__") || consume(&tok, tok, "__V8HI__") || consume(&tok, tok, "__V16QI__") || consume(&tok, tok, "__word__") || consume(&tok, tok, "__pointer__") || consume(&tok, tok, "__CQI__") || consume(&tok, tok, "__CHI__") || consume(&tok, tok, "__CDF__") || consume(&tok, tok, "__TC__") || consume(&tok, tok, "__BI__")) { SET_CTX(ctx); return skip(tok, ")", ctx); } SET_CTX(ctx); return skip(tok, ")", ctx); } if (equal(tok->next, "(") && (consume(&tok, tok, "__deprecated__") || consume(&tok, tok, "deprecated"))) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } // Handle __cleanup__ attribute if (consume(&tok, tok, "cleanup") || consume(&tok, tok, "__cleanup__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: expected identifier in __cleanup__", PARSE_C, __LINE__); // Store the cleanup function name current_attr = attr; tok = tok->next; SET_CTX(ctx); tok = skip(tok, ")", ctx); return tok; } if (consume(&tok, tok, "malloc") || consume(&tok, tok, "__malloc__")) { // Check for optional parameters: e.g., __malloc__(rpl_free, 1) if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); // Parse the deallocator function name (e.g., rpl_free) if (tok->kind != TK_IDENT) error_tok(tok, "%s %d: expected identifier in __malloc__ attribute", PARSE_C, __LINE__); tok = tok->next; // Optionally consume comma and size argument if (equal(tok, ",")) { tok = tok->next; const_expr(&tok, tok); // size index (e.g., 1) } SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "null_terminated_string_arg")) { // GCC syntax: __attribute__((null_terminated_string_arg(index))) if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } return tok; } if (consume(&tok, tok, "noinline") || consume(&tok, tok, "__noinline__") || consume(&tok, tok, "const") || consume(&tok, tok, "__const__") || consume(&tok, tok, "pure") || consume(&tok, tok, "__pure__") || consume(&tok, tok, "dontclone") || consume(&tok, tok, "__dontclone__") || consume(&tok, tok, "may_alias") || consume(&tok, tok, "__may_alias__") || consume(&tok, tok, "warn_unused_result") || consume(&tok, tok, "__warn_unused_result__") || consume(&tok, tok, "flatten") || consume(&tok, tok, "__flatten__") || consume(&tok, tok, "leaf") || consume(&tok, tok, "__leaf__") || consume(&tok, tok, "no_reorder") || consume(&tok, tok, "__no_reorder__") || consume(&tok, tok, "dontthrow") || consume(&tok, tok, "__dontthrow__") || consume(&tok, tok, "optnone") || consume(&tok, tok, "__optnone__") || consume(&tok, tok, "returns_twice") || consume(&tok, tok, "__returns_twice__") || consume(&tok, tok, "nodebug") || consume(&tok, tok, "__nodebug__") || consume(&tok, tok, "artificial") || consume(&tok, tok, "__artificial__") || consume(&tok, tok, "returns_nonnull") || consume(&tok, tok, "__returns_nonnull__") || consume(&tok, tok, "deprecated") || consume(&tok, tok, "__deprecated__") || consume(&tok, tok, "__transparent_union__") || consume(&tok, tok, "transparent_union") || consume(&tok, tok, "gnu_inline") || consume(&tok, tok, "__gnu_inline__") || consume(&tok, tok, "used") || consume(&tok, tok, "__used__") || consume(&tok, tok, "unused") || consume(&tok, tok, "__unused__") || consume(&tok, tok, "no_icf") || consume(&tok, tok, "__no_icf__") || consume(&tok, tok, "noipa") || consume(&tok, tok, "__noipa__") || consume(&tok, tok, "noplt") || consume(&tok, tok, "__noplt__") || consume(&tok, tok, "stack_protect") || consume(&tok, tok, "__stack_protect__") || consume(&tok, tok, "no_sanitize_address") || consume(&tok, tok, "__no_sanitize_address__") || consume(&tok, tok, "no_sanitize_thread") || consume(&tok, tok, "__no_sanitize_thread__") || consume(&tok, tok, "no_split_stack") || consume(&tok, tok, "__no_split_stack__") || consume(&tok, tok, "no_stack_limit") || consume(&tok, tok, "__no_stack_limit__") || consume(&tok, tok, "no_sanitize_undefined") || consume(&tok, tok, "__no_sanitize_undefined__") || consume(&tok, tok, "__nonstring__") || consume(&tok, tok, "nonstring") || consume(&tok, tok, "no_profile_instrument_function") || consume(&tok, tok, "stdcall") || consume(&tok, tok, "__stub__") || consume(&tok, tok, "__retain__") || consume(&tok, tok, "transaction_pure") || consume(&tok, tok, "transaction_may_cancel_outer") || consume(&tok, tok, "transaction_callable") || consume(&tok, tok, "tainted_args") || consume(&tok, tok, "__designated_init__") || consume(&tok, tok, "__no_profile_instrument_function__")) { return tok; } if (consume(&tok, tok, "always_inline") || consume(&tok, tok, "__always_inline__")) { attr->is_inline = true; return tok; } //fallthrough is the last instruction in case: followed by a semicolon if (consume(&tok, tok, "fallthrough") || consume(&tok, tok, "__fallthrough__") ) { return tok; } if (consume(&tok, tok, "nonnull") || consume(&tok, tok, "__nonnull__")) { if (equal(tok, "(")) { SET_CTX(ctx); tok = skip(tok, "(",ctx); // Optional parameter list while (!equal(tok, ")")) { if (tok->kind != TK_NUM) { error_tok(tok, "%s %d: expected parameter index in __nonnull__", PARSE_C, __LINE__); } // You can store the info if you want (e.g., attr->nonnull_params = ...) tok = tok->next; if (equal(tok, ",")) tok = tok->next; else break; } SET_CTX(ctx); tok = skip(tok, ")",ctx); } return tok; } if (consume(&tok, tok, "sentinel") || consume(&tok, tok, "__sentinel__") || consume(&tok, tok, "optimize") || consume(&tok, tok, "__optimize__") || consume(&tok, tok, "assume_aligned") || consume(&tok, tok, "__assume_aligned__") || consume(&tok, tok, "alloc_size") || consume(&tok, tok, "__alloc_size__") || consume(&tok, tok, "attribute_alloc_size") || consume(&tok, tok, "__attribute_alloc_size__") || consume(&tok, tok, "alloc_align") || consume(&tok, tok, "__alloc_align__")) { if (consume(&tok, tok, "(")) { for (;;) { const_expr(&tok, tok); if (consume(&tok, tok, ")")) break; SET_CTX(ctx); tok = skip(tok, ",", ctx); } } return tok; } if (consume(&tok, tok, "format") || consume(&tok, tok, "__format__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); consume(&tok, tok, "printf"); consume(&tok, tok, "__printf__"); consume(&tok, tok, "scanf"); consume(&tok, tok, "__scanf__"); consume(&tok, tok, "strftime"); consume(&tok, tok, "__strftime__"); consume(&tok, tok, "strfmon"); consume(&tok, tok, "__strfmon__"); consume(&tok, tok, "gnu_printf"); consume(&tok, tok, "__gnu_printf__"); consume(&tok, tok, "gnu_scanf"); consume(&tok, tok, "__gnu_scanf__"); consume(&tok, tok, "gnu_strftime"); consume(&tok, tok, "__gnu_strftime__"); SET_CTX(ctx); tok = skip(tok, ",", ctx); const_expr(&tok, tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); const_expr(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "format_arg") || consume(&tok, tok, "__format_arg__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); const_expr(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } if (consume(&tok, tok, "no_sanitize")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); return skip(tok, ")", ctx); } return tok; } // struct-union-decl = attribute? ident? ("{" struct-members)? static Type *struct_union_decl(Token **rest, Token *tok, bool *no_list) { Type *ty = struct_type(); tok = attribute_list(tok, ty, type_attributes); // Read a tag. Token *tag = NULL; if (tok->kind == TK_IDENT) { tag = tok; ty->name = tag; tok = tok->next; } if (tag && !equal(tok, "{")) { *rest = tok; *no_list = true; Type *ty2 = find_tag(tag); if (ty2) return ty2; ty->size = -1; push_tag_scope(tag, ty); if (!ty) error_tok(tok, "%s %d: in struct_union_decl : ty is null!", PARSE_C, __LINE__); return ty; } SET_CTX(ctx); tok = skip(tok, "{", ctx); // Construct a struct object. struct_members(&tok, tok, ty); *rest = attribute_list(tok, ty, type_attributes); if (tag) { // If this is a redefinition, overwrite a previous type. // Otherwise, register the struct type. Type *ty2 = hashmap_get2(&scope->tags, tag->loc, tag->len); if (ty2) { for (Type *t = ty2; t; t = t->decl_next) { t->size = ty->size; t->align = MAX(t->align, ty->align); t->members = ty->members; t->is_flexible = ty->is_flexible; t->is_packed = ty->is_packed; t->origin = ty; } return ty2; } push_tag_scope(tag, ty); } if (!ty) error_tok(tok, "%s %d: in struct_union_decl : ty is null!", PARSE_C, __LINE__); return ty; } // struct-decl = struct-union-decl static Type *struct_decl(Token **rest, Token *tok) { bool no_list = false; Type *ty = struct_union_decl(rest, tok, &no_list); tok = attribute_list(tok, ty, type_attributes); ty->kind = TY_STRUCT; if (no_list) return ty; //ty->size = MAX(ty->size, 0); // Assign offsets within the struct to members. int bits = 0; Member head = {0}; Member *cur = &head; for (Member *mem = ty->members; mem; mem = mem->next) { if (mem->is_bitfield && mem->bit_width == 0) { // Zero-width anonymous bitfield has a special meaning. // It affects only alignment. bits = align_to(bits, mem->ty->size * 8); } else if (mem->is_bitfield) { int sz = mem->ty->size; if (bits / (sz * 8) != (bits + mem->bit_width - 1) / (sz * 8)) bits = align_to(bits, sz * 8); mem->offset = align_down(bits / 8, sz); mem->bit_offset = bits % (sz * 8); bits += mem->bit_width; } else { if (!ty->is_packed) bits = align_to(bits, mem->align * 8); mem->offset = bits / 8; bits += mem->ty->size * 8; } if (!mem->name && mem->is_bitfield ) { cur->next = NULL; continue; } //from COSMOPOLITAN adding is_aligned if (!ty->is_packed && !ty->is_aligned && ty->align < mem->align) ty->align = mem->align; cur = cur->next = mem; } ty->members = head.next; ty->size = align_to(bits, ty->align * 8) / 8; if (!ty) error_tok(tok, "%s %d: in struct_decl : ty is null!", PARSE_C, __LINE__); return ty; } // union-decl = struct-union-decl static Type *union_decl(Token **rest, Token *tok) { bool no_list = false; Type *ty = struct_union_decl(rest, tok, &no_list); tok = attribute_list(tok, ty, type_attributes); ty->kind = TY_UNION; if (no_list) return ty; Member head = {0}; Member *cur = &head; for (Member *mem = ty->members; mem; mem = mem->next) { int sz; if (mem->is_bitfield) sz = align_to(mem->bit_width, 8) / 8; else sz = mem->ty->size; ty->size = MAX(ty->size, sz); if (!mem->name && mem->is_bitfield) { cur->next = NULL; continue; } if (ty->align < mem->align) ty->align = mem->align; cur = cur->next = mem; } ty->members = head.next; ty->size = align_to(ty->size, ty->align); if (!ty) error_tok(tok, "%s %d: in union_decl : ty is null!", PARSE_C, __LINE__); return ty; } // Find a struct member by name. static Member *get_struct_member(Type *ty, Token *tok) { for (Member *mem = ty->members; mem; mem = mem->next) { // Anonymous struct member if (!mem->name) { //if (mem->ty->kind == TY_STRUCT || mem->ty->kind == TY_UNION) if (get_struct_member(mem->ty, tok)) return mem; continue; } // Regular struct member if (mem->name->len == tok->len && !strncmp(mem->name->loc, tok->loc, tok->len)) return mem; } return NULL; } // Create a node representing a struct member access, such as foo.bar // where foo is a struct and bar is a member name. // // C has a feature called "anonymous struct" which allows a struct to // have another unnamed struct as a member like this: // // struct { struct { int a; }; int b; } x; // // The members of an anonymous struct belong to the outer struct's // member namespace. Therefore, in the above example, you can access // member "a" of the anonymous struct as "x.a". // // This function takes care of anonymous structs. static Node *struct_ref(Node *node, Token *tok) { add_type(node); if (node->ty->kind != TY_STRUCT && node->ty->kind != TY_UNION) error_tok(node->tok, "%s %d: in struct_ref : not a struct nor a union", PARSE_C, __LINE__); Type *ty = node->ty; for (;;) { Member *mem = get_struct_member(ty, tok); if (!mem) error_tok(tok, "%s %d: in struct_ref : no such member", PARSE_C, __LINE__); node = new_unary(ND_MEMBER, node, tok); node->member = mem; if (mem->name) break; ty = mem->ty; } return node; } // Convert A++ to `(typeof A)((A += 1) - 1)` static Node *new_inc_dec(Node *node, Token *tok, int addend) { add_type(node); return new_cast(new_add(to_assign(new_add(node, new_num(addend, tok), tok, false)), new_num(-addend, tok), tok, false), node->ty); } // postfix = "(" type-name ")" "{" initializer-list "}" postfix-tail* // = ident "(" func-args ")" postfix-tail* // | primary postfix-tail* // // postfix-tail = "[" expr "]" // | "(" func-args ")" // | "." ident // | "->" ident // | "++" // | "--" static Node *postfix(Token **rest, Token *tok) { Node *node; if (equal(tok, "(") && is_typename(tok->next)) { // Compound literal Token *start = tok; Type *ty = typename(&tok, tok->next); tok = attribute_list(tok, ty, type_attributes); if (ty->kind == TY_VLA) error_tok(tok, "%s %d: in postfix : compound literals cannot be VLA", PARSE_C, __LINE__); SET_CTX(ctx); tok = skip(tok, ")", ctx); if (scope->next == NULL) { Obj *var = new_anon_gvar(ty); var->is_compound_lit = true; gvar_initializer(&tok, tok, var); node = new_var_node(var, start); } else { Obj *var = new_lvar("", ty, NULL); var->is_compound_lit = true; Node *lhs = lvar_initializer(&tok, tok, var); Node *rhs = new_var_node(var, tok); node = new_binary(ND_COMMA, lhs, rhs, start); } } else { node = primary(&tok, tok); } // Node *node = primary(&tok, tok); for (;;) { if (equal(tok, "(")) { node = funcall(&tok, tok->next, node); continue; } if (equal(tok, "[")) { // x[y] is short for *(x+y) Token *start = tok; Node *idx = expr(&tok, tok->next); SET_CTX(ctx); tok = skip(tok, "]", ctx); add_type(node); Type *ty = node->ty; node = new_unary(ND_DEREF, new_add(node, idx, start, false), start); if (is_array(ty)) apply_cv_qualifier(node, ty); continue; } if (equal(tok, ".")) { node = struct_ref(node, tok->next); tok = tok->next->next; continue; } if (equal(tok, "->")) { // x->y is short for (*x).y add_type(node); Type *ty = node->ty; node = new_unary(ND_DEREF, node, tok); node = struct_ref(node, tok->next); if (is_array(ty)) apply_cv_qualifier(node, ty); tok = tok->next->next; continue; } if (equal(tok, "++")) { node = new_inc_dec(node, tok, 1); tok = tok->next; continue; } if (equal(tok, "--")) { node = new_inc_dec(node, tok, -1); tok = tok->next; continue; } *rest = tok; return node; } } static char *token_to_string(Token *tok) { char *buf = calloc(tok->len + 1, 1); // allocate and zero-initialize memcpy(buf, tok->loc, tok->len); return buf; } // funcall = (assign ("," assign)*)? ")" static Node *funcall(Token **rest, Token *tok, Node *fn) { add_type(fn); if (fn->ty->kind != TY_FUNC && (fn->ty->kind != TY_PTR || fn->ty->base->kind != TY_FUNC)) error_tok(fn->tok, "%s %d: in funcall : not a function %d %s", PARSE_C, __LINE__, fn->ty->kind, tok->loc); Type *ty = (fn->ty->kind == TY_FUNC) ? fn->ty : fn->ty->base; Type *param_ty = ty->params; Node head = {}; Node *cur = &head; while (!equal(tok, ")")) { if (cur != &head) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } Node *arg = assign(&tok, tok); add_type(arg); if (!param_ty && !ty->is_variadic) error_tok(tok, "%s %d: in funcall : too many arguments", PARSE_C, __LINE__); //can't be done later because param_ty will be set to the next value //if param_ty is null it means that it's a variadic argument. if (!param_ty){ arg->ty->is_variadic = true; } if (param_ty) { if (param_ty->kind != TY_STRUCT && param_ty->kind != TY_UNION) arg = new_cast(arg, param_ty); param_ty = param_ty->next; } else if (arg->ty->kind == TY_FLOAT) { // If parameter type is omitted (e.g. in "..."), float // arguments are promoted to double. arg = new_cast(arg, ty_double); } else if (is_array(arg->ty)) arg = new_cast(arg, pointer_to(arg->ty->base)); else if (arg->ty->kind == TY_FUNC) arg = new_cast(arg, pointer_to(arg->ty)); cur = cur->next = arg; } if (param_ty) error_tok(tok, "%s %d: in funcall : too few arguments", PARSE_C, __LINE__); SET_CTX(ctx); *rest = skip(tok, ")", ctx); Node *node = new_unary(ND_FUNCALL, fn, tok); node->func_ty = ty; node->ty = ty->return_ty; node->args = head.next; // If a function returns a struct, it is caller's responsibility // to allocate a space for the return value. if (node->ty->kind == TY_STRUCT || node->ty->kind == TY_UNION) node->ret_buffer = new_lvar("", node->ty, NULL); return node; } // generic-selection = "(" assign "," generic-assoc ("," generic-assoc)* ")" // // generic-assoc = type-name ":" assign // | "default" ":" assign static Node *generic_selection(Token **rest, Token *tok) { // Token *start = tok; SET_CTX(ctx); tok = skip(tok, "(", ctx); Node *ctrl = assign(&tok, tok); add_type(ctrl); Type *t1 = ctrl->ty; if (t1->kind == TY_FUNC) t1 = pointer_to(t1); else if (t1->kind == TY_ARRAY) t1 = pointer_to(t1->base); // try to fix issue with VLC Node *ret = NULL; while (!consume(rest, tok, ")")) { SET_CTX(ctx); tok = skip(tok, ",", ctx); if (equal(tok, "default")) { SET_CTX(ctx); tok = skip(tok->next, ":", ctx); Node *node = assign(&tok, tok); if (!ret) ret = node; continue; } Type *t2 = typename(&tok, tok); SET_CTX(ctx); tok = skip(tok, ":", ctx); Node *node = assign(&tok, tok); if (is_compatible(t1, t2)) ret = node; } if (!ret) { ret = ctrl; // error_tok(start, "controlling expression type not compatible with" // " any generic association type"); } return ret; } // primary = "(" "{" stmt+ "}" ")" // | "(" expr ")" // | "sizeof" "(" type-name ")" // | "sizeof" unary // | "_Alignof" "(" type-name ")" // | "_Alignof" unary // | "_Generic" generic-selection // | "__builtin_types_compatible_p" "(" type-name, type-name, ")" // | "__builtin_reg_class" "(" type-name ")" // | ident // | str // | num static Node *primary(Token **rest, Token *tok) { Token *start = tok; if ((equal(tok, "(") && equal(tok->next, "{"))) { // This is a GNU statement expresssion. // Node *node = new_node(ND_STMT_EXPR, tok); // node->body = compound_stmt(&tok, tok->next->next)->body; Node *stmt = NULL; Node *node = compound_stmt(&tok, tok->next->next, &stmt); node->kind = ND_STMT_EXPR; if (stmt && stmt->kind == ND_EXPR_STMT) { Node *expr = stmt->lhs; if (expr->ty->kind == TY_STRUCT || expr->ty->kind == TY_UNION) { Obj *var = new_lvar("", expr->ty, NULL); expr = new_binary(ND_ASSIGN, new_var_node(var, tok), expr, tok); add_type(expr); stmt->lhs = expr; } else if (is_array(expr->ty)) { stmt->lhs = new_cast(expr, pointer_to(expr->ty->base)); } } SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "(")) { Node *node = expr(&tok, tok->next); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "sizeof")) { Type *ty; if (equal(tok->next, "(") && is_typename(tok->next->next)) { ty = typename(&tok, tok->next->next); SET_CTX(ctx); *rest = skip(tok, ")", ctx); if ((ty->kind == TY_STRUCT || ty->kind == TY_UNION) && ty->has_vla) { if (!ty->vla_size) { Node *lhs = compute_vla_size(ty, tok); Node *rhs = new_var_node(ty->vla_size, tok); return new_binary(ND_COMMA, lhs, rhs, tok); } return new_var_node(ty->vla_size, tok); } if (ty->kind == TY_STRUCT && ty->is_flexible) { Member *mem = ty->members; while (mem->next) mem = mem->next; if (mem->ty->kind == TY_ARRAY) return new_ulong((ty->size - mem->ty->size), tok); } if ((ty->kind == TY_UNION || ty->kind == TY_STRUCT) && ty->size < 0) error_tok(tok, "%s %d: in primary : incomplete type for sizeof", PARSE_C, __LINE__); if (ty->kind == TY_VLA) { if (ty->vla_size) return new_var_node(ty->vla_size, tok); return compute_vla_size(ty, tok); } return new_ulong(ty->size, start); } else { Node *node = unary(rest, tok->next); add_type(node); // Check if the type is incomplete if ((node->ty->kind == TY_UNION || node->ty->kind == TY_STRUCT) && node->ty->size < 0) error_tok(tok, "%s %d: in primary : incomplete type for sizeof", PARSE_C, __LINE__); //trying to fix =====ISS-166 segmentation fault if (node->ty->kind == TY_VLA) { if (node->ty->vla_size) return new_var_node(node->ty->vla_size, tok); return compute_vla_size(node->ty, tok); } if (node->ty->size < 0) error_tok(tok, "%s %d: in primary : incomplete type for sizeof", PARSE_C, __LINE__); if ((node->ty->kind == TY_STRUCT || node->ty->kind == TY_UNION) && node->ty->has_vla) { if (!node->ty->vla_size) { Node *lhs = compute_vla_size(node->ty, tok); // defines ty->vla_size Node *rhs = new_var_node(node->ty->vla_size, tok); return new_binary(ND_COMMA, lhs, rhs, tok); } return new_var_node(node->ty->vla_size, tok); } if (node->ty->kind == TY_STRUCT && node->ty->is_flexible) { Member *mem = node->ty->members; while (mem->next) mem = mem->next; if (mem->ty->kind == TY_ARRAY) return new_ulong((node->ty->size - mem->ty->size), tok); } if (node->ty->kind == TY_PTR) { return new_ulong(8, tok); } return new_ulong(node->ty->size, start); } } //from @fuhsnn merging alignof if (equal(tok, "_Alignof") || equal(tok, "alignof") || equal(tok, "__alignof__")) { Token *start = tok; Type *ty; if (equal(tok->next, "(") && is_typename(tok->next->next)) { ty = typename(&tok, tok->next->next); SET_CTX(ctx); *rest = skip(tok, ")", ctx); } else { Node *node = unary(rest, tok->next); switch (node->kind) { case ND_MEMBER: return new_ulong(MAX(node->member->ty->align, node->member->align), start); case ND_VAR: return new_ulong(node->var->align, start); } add_type(node); ty = node->ty; } while (is_array(ty)) ty = ty->base; return new_ulong(ty->align, start); } if (equal(tok, "_Generic")) return generic_selection(rest, tok->next); if (equal(tok, "__builtin_types_compatible_p")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Type *t1 = typename(&tok, tok); if (equal(tok, ",")) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } Type *t2 = typename(&tok, tok); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return new_num(is_compatible(t1, t2), start); } if (equal(tok, "__builtin_constant_p")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *expr = assign(&tok, tok); SET_CTX(ctx); *rest = skip(tok, ")", ctx); bool is_constant = false; if (expr->tok->kind == TK_NUM || expr->tok->kind == TK_STR || is_const_expr(expr)) { // Consider numeric and character literals as constants is_constant = true; } return new_num(is_constant ? 1 : 0, start); } // if (equal(tok, "__builtin_offsetof")) { // SET_CTX(ctx); // tok = skip(tok->next, "(", ctx); // Token *stok = tok; // Type *tstruct = typename(&tok, tok); // if (tstruct->kind != TY_STRUCT && tstruct->kind != TY_UNION) { // error_tok(stok, "%s %d: in primary : not a structure or union type", PARSE_C, __LINE__); // } // SET_CTX(ctx); // tok = skip(tok, ",", ctx); // Token *member = tok; // tok = tok->next; // SET_CTX(ctx); // *rest = skip(tok, ")", ctx); // for (Member *m = tstruct->members; m; m = m->next) { // if (m->name->len == member->len && // !memcmp(m->name->loc, member->loc, m->name->len)) { // return new_ulong(m->offset, start); // } // } // error_tok(member, "%s %d: in primary : no such member", PARSE_C, __LINE__); // } //trying to fix ===== some builtin functions linked to mmx/emms if (equal(tok, "__builtin_ia32_emms") || equal(tok, "__builtin_ia32_sfence") || equal(tok, "__builtin_ia32_pause") || equal(tok, "__builtin_ia32_lfence") || equal(tok, "__builtin_ia32_mfence")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_stmxcsr")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); if (!equal(tok, ")")) { node->lhs = assign(&tok, tok); add_type(node->lhs); } SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_cvtss2si") || equal(tok, "__builtin_ia32_cvttss2si") || equal(tok, "__builtin_ia32_cvttss2si64") || equal(tok, "__builtin_ia32_movmskps") || equal(tok, "__builtin_ia32_ldmxcsr") || equal(tok, "__builtin_ia32_sqrtpd") || equal(tok, "__builtin_ia32_sqrtsd") || equal(tok, "__builtin_ia32_movq128") || equal(tok, "__builtin_ia32_cvtdq2pd") || equal(tok, "__builtin_ia32_cvtdq2ps") || equal(tok, "__builtin_ia32_cvtpd2dq") || equal(tok, "__builtin_ia32_cvtpd2ps") || equal(tok, "__builtin_ia32_cvttpd2dq") || equal(tok, "__builtin_ia32_cvtps2dq") || equal(tok, "__builtin_ia32_cvttps2dq") || equal(tok, "__builtin_ia32_cvtps2pd") || equal(tok, "__builtin_ia32_cvtsd2si") || equal(tok, "__builtin_ia32_cvtsd2si64") || equal(tok, "__builtin_ia32_cvttsd2si") || equal(tok, "__builtin_ia32_cvttsd2si64") || equal(tok, "__builtin_ia32_movmskpd") || equal(tok, "__builtin_ia32_pmovmskb128") || equal(tok, "__builtin_ia32_cvtss2si64") || equal(tok, "__builtin_ia32_cvtps2pi") || equal(tok, "__builtin_ia32_cvttps2pi") || equal(tok, "__builtin_ia32_cvttpd2pi") || equal(tok, "__builtin_ia32_cvtpi2pd") || equal(tok, "__builtin_ia32_cvtpd2pi") || equal(tok, "__builtin_ia32_sqrtss") || equal(tok, "__builtin_ia32_rcpss") || equal(tok, "__builtin_ia32_rcpps") || equal(tok, "__builtin_ia32_rsqrtps") || equal(tok, "__builtin_ia32_clflush") || equal(tok, "_mm_clflush") || equal(tok, "__builtin_ia32_pmovmskb") || equal(tok, "__builtin_ia32_sqrtps") || equal(tok, "__builtin_parity") || equal(tok, "__builtin_parityl") || equal(tok, "__builtin_parityll") || equal(tok, "__builtin_ia32_rsqrtss")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_shuffle")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_args[0] = assign(&tok, tok); add_type(node->builtin_args[0]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[1] = assign(&tok, tok); add_type(node->builtin_args[1]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[2] = assign(&tok, tok); add_type(node->builtin_args[2]); node->builtin_nargs = 3; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_maskmovq")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_args[0] = assign(&tok, tok); add_type(node->builtin_args[0]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[1] = assign(&tok, tok); add_type(node->builtin_args[1]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[2] = assign(&tok, tok); add_type(node->builtin_args[2]); node->builtin_nargs = 3; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_maskmovdqu")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_args[0] = assign(&tok, tok); add_type(node->builtin_args[0]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[1] = assign(&tok, tok); add_type(node->builtin_args[1]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[2] = assign(&tok, tok); add_type(node->builtin_args[2]); node->builtin_nargs = 3; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_vec_init_v4hi")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_args[0] = assign(&tok, tok); add_type(node->builtin_args[0]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[1] = assign(&tok, tok); add_type(node->builtin_args[1]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[2] = assign(&tok, tok); add_type(node->builtin_args[2]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[3] = assign(&tok, tok); add_type(node->builtin_args[3]); node->builtin_nargs = 4; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_shufps") || equal(tok, "__builtin_ia32_shufpd")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs->val = const_expr(&tok, tok); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } if (equal(tok, "__builtin_ia32_vec_init_v8qi")) { int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_args[0] = assign(&tok, tok); add_type(node->builtin_args[0]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[1] = assign(&tok, tok); add_type(node->builtin_args[1]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[2] = assign(&tok, tok); add_type(node->builtin_args[2]); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_args[3] = assign(&tok, tok); add_type(node->builtin_args[3]); tok = skip(tok, ",", ctx); node->builtin_args[4] = assign(&tok, tok); add_type(node->builtin_args[4]); tok = skip(tok, ",", ctx); node->builtin_args[5] = assign(&tok, tok); add_type(node->builtin_args[5]); tok = skip(tok, ",", ctx); node->builtin_args[6] = assign(&tok, tok); add_type(node->builtin_args[6]); tok = skip(tok, ",", ctx); node->builtin_args[7] = assign(&tok, tok); add_type(node->builtin_args[7]); node->builtin_nargs = 8; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } } //managing lots of builtin_ia32 that needs two args // defined in builtin_table[] int builtin = builtin_enum(tok); if (builtin != -1) { Node *node = new_node(builtin, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_reg_class")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Type *ty = typename(&tok, tok); SET_CTX(ctx); *rest = skip(tok, ")", ctx); if (is_integer(ty) || ty->kind == TY_PTR) return new_num(0, start); if (ty->kind == TY_FLOAT || ty->kind == TY_DOUBLE) return new_num(1, start); return new_num(2, start); } if (equal(tok, "__builtin_compare_and_swap")) { Node *node = new_node(ND_CAS, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->cas_addr = assign(&tok, tok); add_type(node->cas_addr); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->cas_old = assign(&tok, tok); add_type(node->cas_old); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->cas_new = assign(&tok, tok); add_type(node->cas_new); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_atomic_exchange")) { Node *node = new_node(ND_EXCH, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__sync_val_compare_and_swap")) { Node *node = new_node(ND_CAS_N, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->cas_addr = assign(&tok, tok); add_type(node->cas_addr); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->cas_old = assign(&tok, tok); add_type(node->cas_old); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->cas_new = assign(&tok, tok); add_type(node->cas_new); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } // Extend the parser to recognize __sync_synchronize() if (equal(tok, "__sync_synchronize")) { Node *node = new_node(ND_SYNC, tok); SET_CTX(ctx); *rest = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(*rest, ")", ctx); return node; } if (equal(tok, "__builtin_memcpy")) { return parse_memcpy(tok, rest); } if (equal(tok, "__builtin_memset")) { return parse_memset(tok, rest); } if (equal(tok, "__builtin_huge_valf")) { Node *node = new_node(ND_BUILTIN_HUGE_VALF, tok); node->ty = ty_float; node->fval = INFINITY; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_inf")) { Node *node = new_node(ND_BUILTIN_INF, tok); node->ty = ty_double; node->fval = INFINITY; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_huge_val")) { Node *node = new_node(ND_BUILTIN_HUGE_VAL, tok); node->ty = ty_double; node->fval = INFINITY; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_huge_vall")) { Node *node = new_node(ND_BUILTIN_HUGE_VALL, tok); node->ty = ty_ldouble; node->fval = INFINITY; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_inff")) { Node *node = new_node(ND_BUILTIN_INFF, tok); node->ty = ty_float; node->fval = INFINITY; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_nan")) { Node *node = new_node(ND_BUILTIN_NAN, tok); node->ty = ty_double; node->fval = NAN; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); if (tok->kind == TK_STR) tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_nanf")) { Node *node = new_node(ND_BUILTIN_NANF, tok); node->ty = ty_float; node->fval = NAN; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); if (tok->kind == TK_STR) tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_nanl")) { Node *node = new_node(ND_BUILTIN_NANL, tok); node->ty = ty_ldouble; node->fval = NAN; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); if (tok->kind == TK_STR) tok = tok->next; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_isnan")) { return ParseBuiltin(ND_BUILTIN_ISNAN, tok, rest); } if (equal(tok, "__builtin_clz")) { return ParseBuiltin(ND_BUILTIN_CLZ, tok, rest); } if (equal(tok, "__builtin_clzl")) { return ParseBuiltin(ND_BUILTIN_CLZL, tok, rest); } if (equal(tok, "__builtin_clzll")) { return ParseBuiltin(ND_BUILTIN_CLZLL, tok, rest); } if (equal(tok, "__builtin_ctz")) { return ParseBuiltin(ND_BUILTIN_CTZ, tok, rest); } if (equal(tok, "__builtin_ctzl")) { return ParseBuiltin(ND_BUILTIN_CTZL, tok, rest); } if (equal(tok, "__builtin_ctzll")) { return ParseBuiltin(ND_BUILTIN_CTZLL, tok, rest); } if (equal(tok, "__builtin_bswap16")) { return ParseBuiltin(ND_BUILTIN_BSWAP16, tok, rest); } if (equal(tok, "__builtin_bswap32")) { return ParseBuiltin(ND_BUILTIN_BSWAP32, tok, rest); } if (equal(tok, "__builtin_bswap64")) { return ParseBuiltin(ND_BUILTIN_BSWAP64, tok, rest); } if (equal(tok, "__builtin_popcount")) { return ParseBuiltin(ND_POPCOUNT, tok, rest); } if (equal(tok, "__builtin_popcountl")) { return ParseBuiltin(ND_POPCOUNTL, tok, rest); } if (equal(tok, "__builtin_popcountll")) { return ParseBuiltin(ND_POPCOUNTLL, tok, rest); } if (equal(tok, "__builtin_expect")) { Node *node = new_node(ND_EXPECT, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_abort")) { Node *node = new_node(ND_ABORT, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_return_address")) { Node *node = new_node(ND_RETURN_ADDR, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_frame_address")) { Node *node = new_node(ND_BUILTIN_FRAME_ADDRESS, tok); add_type(node); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_add_overflow")) { return parse_overflow(ND_BUILTIN_ADD_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_uadd_overflow")) { return parse_overflow(ND_UADD_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_uaddll_overflow")) { return parse_overflow(ND_UADDLL_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_uaddl_overflow")) { return parse_overflow(ND_UADDL_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_umul_overflow")) { return parse_overflow(ND_UMUL_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_umulll_overflow")) { return parse_overflow(ND_UMULLL_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_umull_overflow")) { return parse_overflow(ND_UMULL_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_sub_overflow")) { return parse_overflow(ND_BUILTIN_SUB_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_mul_overflow")) { return parse_overflow(ND_BUILTIN_MUL_OVERFLOW, tok, rest); } if (equal(tok, "__builtin_unreachable")) { Node *node = new_node(ND_UNREACHABLE, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__builtin_atomic_exchange_n") || equal(tok, "__atomic_exchange_n")) { return ParseAtomic3(ND_EXCH_N, tok, rest); } if (equal(tok, "__builtin_atomic_compare_exchange") || equal(tok, "__atomic_compare_exchange")) { return ParseAtomicCompareExchangeN(ND_CMPEXCH, tok, rest); } if (equal(tok, "__builtin_atomic_compare_exchange_n") || equal(tok, "__atomic_compare_exchange_n")) { return ParseAtomicCompareExchangeN(ND_CMPEXCH_N, tok, rest); } if (equal(tok, "__builtin_atomic_load")) { return ParseAtomic3(ND_LOAD, tok, rest); } if (equal(tok, "__builtin_atomic_store")) { return ParseAtomic3(ND_STORE, tok, rest); } if (equal(tok, "__builtin_atomic_load_n") || equal(tok, "__atomic_load_n")) { return ParseAtomic2(ND_LOAD_N, tok, rest); } if (equal(tok, "__builtin_atomic_store_n") || equal(tok, "__atomic_store_n")) { return ParseAtomic3(ND_STORE_N, tok, rest); } if (equal(tok, "__builtin_atomic_fetch_add")) { return ParseAtomic3(ND_FETCHADD, tok, rest); } if (equal(tok, "__builtin_atomic_fetch_sub")) { return ParseAtomic3(ND_FETCHSUB, tok, rest); } if (equal(tok, "__builtin_atomic_fetch_xor")) { return ParseAtomic3(ND_FETCHXOR, tok, rest); } if (equal(tok, "__builtin_atomic_fetch_and") ) { return ParseAtomic3(ND_FETCHAND, tok, rest); } if (equal(tok, "__builtin_atomic_fetch_or") ) { return ParseAtomic3(ND_FETCHOR, tok, rest); } if (equal(tok, "__builtin_atomic_test_and_set")) { return ParseAtomic2(ND_TESTANDSETA, tok, rest); } if (equal(tok, "__builtin_atomic_clear")) { return ParseAtomic2(ND_CLEAR, tok, rest); } if (equal(tok, "__sync_lock_test_and_set")) { Node *node = new_node(ND_TESTANDSET, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); node->ty = node->lhs->ty->base; SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__sync_lock_release")) { Node *node = new_node(ND_RELEASE, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); node->ty = node->lhs->ty->base; SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } if (equal(tok, "__sync_fetch_and_add")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *obj = new_unary(ND_DEREF, assign(&tok, tok), tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *val = assign(&tok, tok); add_type(val); Node *node; node = new_add(obj, val, tok, false); node->atomic_fetch = true; *rest = tok->next; return to_assign(node); } if (equal(tok, "__sync_fetch_and_sub")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *obj = new_unary(ND_DEREF, assign(&tok, tok), tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *val = assign(&tok, tok); add_type(val); Node *node; node = new_sub(obj, val, tok, false); node->atomic_fetch = true; *rest = tok->next; return to_assign(node); } if (equal(tok, "__sync_fetch_and_or")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *obj = new_unary(ND_DEREF, assign(&tok, tok), tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *val = assign(&tok, tok); add_type(val); Node *node = new_binary(ND_BITOR, obj, val, tok); node->atomic_fetch = true; *rest = tok->next; return to_assign(node); } if (equal(tok, "__sync_fetch_and_xor")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *obj = new_unary(ND_DEREF, assign(&tok, tok), tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *val = assign(&tok, tok); add_type(val); Node *node = new_binary(ND_BITXOR, obj, val, tok); node->atomic_fetch = true; *rest = tok->next; return to_assign(node); } if (equal(tok, "__sync_fetch_and_and")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *obj = new_unary(ND_DEREF, assign(&tok, tok), tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *val = assign(&tok, tok); add_type(val); Node *node = new_binary(ND_BITAND, obj, val, tok); node->atomic_fetch = true; *rest = tok->next; return to_assign(node); } if (equal(tok, "__builtin_atomic_fetch_op")) { SET_CTX(ctx); tok = skip(tok->next, "(", ctx); Node *obj = new_unary(ND_DEREF, assign(&tok, tok), tok); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *val = assign(&tok, tok); add_type(val); SET_CTX(ctx); tok = skip(tok, ",", ctx); Node *node; if (equal(tok, "0")) node = new_add(obj, val, tok, false); else if (equal(tok, "1")) node = new_sub(obj, val, tok, false); else if (equal(tok, "2")) node = new_binary(ND_BITOR, obj, val, tok); else if (equal(tok, "3")) node = new_binary(ND_BITXOR, obj, val, tok); else if (equal(tok, "4")) node = new_binary(ND_BITAND, obj, val, tok); else error_tok(tok, "%s %d: in primary : invalid fetch operator", PARSE_C, __LINE__); node->atomic_fetch = true; SET_CTX(ctx); *rest = skip(tok->next, ")", ctx); return to_assign(node); } // Handle __builtin_huge_valf if (equal(tok, "__builtin_huge_valf")) { return parse_huge_val(HUGE_VALF, tok, rest); } // Handle __builtin_huge_vall if (equal(tok, "__builtin_huge_vall")) { return parse_huge_val(HUGE_VALL, tok, rest); } // Handle __builtin_huge_val if (equal(tok, "__builtin_huge_val")) { return parse_huge_val(HUGE_VAL, tok, rest); } if (tok->kind == TK_IDENT) { // Variable or enum constant VarScope *sc = find_var(tok); *rest = tok->next; // For "static inline" function if (sc && sc->var && sc->var->is_function) { if (current_fn) strarray_push(¤t_fn->refs, sc->var->name); else { sc->var->is_root = true; } if (sc->var->is_address_used) { sc->var->is_root = true; } } if (sc) { if (sc->var) return new_var_node(sc->var, tok); if (sc->enum_ty) return new_num(sc->enum_val, tok); } if (equal(tok->next, "(")) { Obj *fn = find_func(token_to_string(tok)); if (!fn && (opt_c99 || opt_c11 || opt_c17 || opt_implicit)) { error_tok(tok, "%s %d: in primary : implicit declaration of function", PARSE_C, __LINE__); } if (!fn) { warn_tok(tok, "%s %d: in primary : implicit declaration of function", PARSE_C, __LINE__); Type *ty = func_type(ty_int); ty->is_variadic = true; fn = new_gvar(token_to_string(tok), ty); fn->name = token_to_string(tok); fn->is_function = true; fn->is_definition = false; fn->is_tentative = true; fn->is_static = false; fn->is_extern = true; } Node *node = unary(rest, tok->next); return node; // error_tok(tok, "%s %d: in primary : implicit declaration of a function", PARSE_C, __LINE__); } //printf("=======%s %d\n", tok->loc, __LINE__); error_tok(tok, "%s %d: in primary : error: undefined variable %s", PARSE_C, __LINE__, tok->loc); } if (tok->kind == TK_STR) { Obj *var = new_string_literal(tok->str, tok->ty); *rest = tok->next; return new_var_node(var, tok); } if (equal(tok, "false")) { *rest = tok->next; return new_boolean(0, tok); } if (equal(tok, "true")) { *rest = tok->next; return new_boolean(1, tok); } if (tok->kind == TK_NUM) { Node *node; if (is_flonum(tok->ty)) { node = new_node(ND_NUM, tok); node->fval = tok->fval; } else { node = new_num(tok->val, tok); } node->ty = tok->ty; *rest = tok->next; return node; } error_tok(tok, "%s %d: in primary : expected an expression %s", PARSE_C, __LINE__, tok->loc); } static Node *parse_typedef(Token **rest, Token *tok, Type *basety) { bool first = true; Node *node = new_node(ND_NULL_EXPR, tok); while (!consume(rest, tok, ";")) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; Type *ty = declarator(&tok, tok, basety); if (!ty) error_tok(tok, "%s %d: in parse_typedef : ty is null", PARSE_C, __LINE__); if (!ty->name) error_tok(ty->name_pos, "%s %d: in parse_typedef : typedef name omitted", PARSE_C, __LINE__); //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, ty, type_attributes); if (ty->is_vector && !is_vector(ty)) { int len = ty->vector_size / ty->size; Token *name = ty->name; ty = vector_of(ty, len); ty->name = name; } push_scope(get_ident(ty->name))->type_def = ty; node = new_binary(ND_COMMA, node, compute_vla_size(ty, tok), tok); } return node; } static void create_param_lvars(Type *param, char *funcname) { if (!param) return; // from @fuhsnn Adjust ABI with unnamed function parameter #2 create_param_lvars(param->next, funcname); //if (!param->name) // return; // error_tok(param->name_pos, "parameter name omitted"); //new_lvar(get_ident(param->name), param, funcname); if (!param->name) new_lvar("", param, funcname); else new_lvar(get_ident(param->name), param, funcname); order++; } // This function matches gotos or labels-as-values with labels. // // We cannot resolve gotos as we parse a function because gotos // can refer a label that appears later in the function. // So, we need to do this after we parse the entire function. static void resolve_goto_labels(void) { for (Node *x = gotos; x; x = x->goto_next) { for (Node *y = labels; y; y = y->goto_next) { if (!strcmp(x->label, y->label)) { x->unique_label = y->unique_label; break; } } if (x->unique_label == NULL) error_tok(x->tok->next, "%s %d: in resolve_goto_labels : use of undeclared label", PARSE_C, __LINE__); } gotos = labels = NULL; } Obj *find_func(char *name) { Scope *sc = scope; while (sc->next) sc = sc->next; VarScope *sc2 = hashmap_get(&sc->vars, name); if (sc2 && sc2->var && sc2->var->is_function) return sc2->var; return NULL; } static void mark_live(Obj *var) { if (!var->is_function || var->is_live) return; var->is_live = true; for (int i = 0; i < var->refs.len; i++) { Obj *fn = find_func(var->refs.data[i]); if (fn) mark_live(fn); } } static Token *function(Token *tok, Type *basety, VarAttr *attr) { Type *ty = declarator(&tok, tok, basety); tok = attribute_list(tok, attr, thing_attributes); if (!ty) error_tok(tok, "%s %d: in function : ty is null", PARSE_C, __LINE__); if (!ty->name) error_tok(ty->name_pos, "%s %d: in function : function name omitted", PARSE_C, __LINE__); char *name_str = get_ident(ty->name); Obj *fn = find_func(name_str); if (fn) { // Redeclaration if (!fn->is_function) error_tok(tok, "%s %d: in function : redeclared as a different kind of symbol", PARSE_C, __LINE__); if (fn->is_definition && equal(tok, "{")) error_tok(tok, "%s %d: in function : redefinition of %s", PARSE_C, __LINE__, name_str); if (!fn->is_static && attr->is_static) error_tok(tok, "%s %d: in function : static declaration follows a non-static declaration", PARSE_C, __LINE__); fn->is_definition = fn->is_definition || equal(tok, "{"); } else { fn = new_gvar(name_str, ty); fn->funcname = name_str; fn->is_function = true; fn->is_definition = equal(tok, "{"); fn->is_static = attr->is_static || (attr->is_inline && !attr->is_extern); fn->is_inline = attr->is_inline; } //from COSMOPOLITAN adding other GNUC attributes fn->alias_name = attr->alias_name; fn->is_extern |= attr->is_extern; fn->is_weak |= attr->is_weak; fn->section = attr->section; fn->is_ms_abi |= attr->is_ms_abi; fn->visibility = fn->visibility ?: attr->visibility; fn->is_aligned |= attr->is_aligned; fn->is_noreturn |= attr->is_noreturn; fn->is_destructor |= attr->is_destructor; fn->is_constructor |= attr->is_constructor; if (attr->destructor_priority > 0) fn->destructor_priority = attr->destructor_priority; if (attr->constructor_priority > 0) fn->constructor_priority = attr->constructor_priority; fn->is_externally_visible |= attr->is_externally_visible; fn->is_no_instrument_function |= attr->is_no_instrument_function; fn->is_force_align_arg_pointer |= attr->is_force_align_arg_pointer; fn->is_no_caller_saved_registers |= attr->is_no_caller_saved_registers; fn->file_no = tok->file->file_no; fn->line_no = tok->line_no; fn->is_root = !(fn->is_static && fn->is_inline); if (consume(&tok, tok, "asm") || consume(&tok, tok, "__asm__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); fn->asmname = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, attr, thing_attributes); if (consume(&tok, tok, ";") || consume(&tok, tok, ",")) return tok; current_fn = fn; locals = NULL; enter_scope(); // if it's a pointer we don't know the size of the type of pointer int ? char ? create_param_lvars(ty->params, name_str); // store the number of function parameters to be used for extended assembly fn->nbparm = order; // A buffer for a struct/union return value is passed // as the hidden first parameter. Type *rty = ty->return_ty; if ((rty->kind == TY_STRUCT || rty->kind == TY_UNION) && rty->size > 16) new_lvar("", pointer_to(rty), name_str); fn->params = locals; if (ty->is_variadic) fn->va_area = new_lvar("__va_area__", array_of(ty_char, 200), name_str); fn->alloca_bottom = new_lvar("__alloca_size__", pointer_to(ty_char), name_str); //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, ty, type_attributes); if (consume(&tok, tok, ";") || consume(&tok, tok, ",")) return tok; SET_CTX(ctx); tok = skip(tok, "{", ctx); is_old_style = false; // [https://www.sigbus.info/n1570#6.4.2.2p1] "__func__" is // automatically defined as a local variable containing the // current function name. tok = attribute_list(tok, ty, type_attributes); push_scope("__func__")->var = new_string_literal(fn->name, array_of(ty_char, strlen(fn->name) + 1)); //in assert.h __PRETTY_FUNCTION__ is an alias for __func__ for the current function push_scope("__PRETTY_FUNCTION__")->var = new_string_literal(fn->name, array_of(ty_char, strlen(fn->name) + 1)); // [GNU] __FUNCTION__ is yet another name of __func__. push_scope("__FUNCTION__")->var = new_string_literal(fn->name, array_of(ty_char, strlen(fn->name) + 1)); fn->body = compound_stmt(&tok, tok, NULL); fn->locals = locals; order = 0; leave_scope(); resolve_goto_labels(); return tok; } static Token *global_variable(Token *tok, Type *basety, VarAttr *attr) { bool first = true; while (!consume(&tok, tok, ";")) { if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; Type *ty = declarator(&tok, tok, basety); if (!ty) error_tok(tok, "%s %d: in global_variable : ty is null", PARSE_C, __LINE__); if (!ty->name) error_tok(ty->name_pos, "%s %d: in global_variable : variable name omitted", PARSE_C, __LINE__); Obj *var = new_gvar(get_ident(ty->name), ty); //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, attr, thing_attributes); //tok = attribute_list(tok, ty, type_attributes); if (consume(&tok, tok, "asm") || consume(&tok, tok, "__asm__")) { SET_CTX(ctx); tok = skip(tok, "(", ctx); var->asmname = ConsumeStringLiteral(&tok, tok); SET_CTX(ctx); tok = skip(tok, ")", ctx); } var->is_weak = attr->is_weak; var->alias_name = attr->alias_name; var->section = attr->section; if (!attr->section && current_section) { var->section = current_section; } var->visibility = attr->visibility; var->is_aligned = var->is_aligned | attr->is_aligned; var->is_externally_visible = attr->is_externally_visible; var->is_definition = !attr->is_extern; var->is_static = attr->is_static; var->is_tls = attr->is_tls; if (attr->align) var->align = MAX(var->align, attr->align); if (equal(tok, "=")) gvar_initializer(&tok, tok->next, var); else if (!attr->is_extern && !attr->is_tls) var->is_tentative = true; current_section=NULL; } return tok; } // Lookahead tokens and returns true if a given token is a start // of a function definition or declaration. static bool is_function(Token *tok) { if (equal(tok, ";")) return false; Type dummy = {}; Type *ty = declarator(&tok, tok, &dummy); if (!ty) error_tok(tok, "%s %d: in is_function : ty is null", PARSE_C, __LINE__); return ty->kind == TY_FUNC; } static bool var_in_array(const char *str, Obj *varArr[], size_t count) { for (size_t i = 0; i < count ; i++) { if (varArr[i] && varArr[i]->name && strcmp(str, varArr[i]->name) == 0) { return true; } } return false; } static bool var_in_array2(const char *str, Obj *varArr[], size_t count) { for (size_t i = 0; i < count ; i++) { if (varArr[i] && varArr[i]->name && strcmp(str, varArr[i]->name) == 0) { return true; } } return false; } // Remove redundant tentative definitions. // works fine when we have tentative and definition but didn't work when we have multiple tentatives. // that's why here we're doing two passes and managed the case of duplicate tentatives. static void scan_globals(void) { Obj head; Obj *cur = &head; Obj *varArr[50000]; int i = 0; //the first pass skipped the duplicated tentative and stores in an Array of objects duplicated tentative for (Obj *var = globals; var; var = var->next) { if (!var->is_tentative) { cur = cur->next = var; continue; } // Find another definition of the same identifier. Obj *var2 = globals; for (; var2; var2 = var2->next) { if (var != var2 && var2->is_definition && !strcmp(var->name, var2->name)) { //warn_tok(var->tok, "%s %d: in scan_globals : duplicated tentative definition", PARSE_C, __LINE__); if (var2->is_tentative && !var_in_array(var->name, varArr, i + 1 ) && (i + 1) < 50000) { varArr[i++] = var; } break; } } // If there's another definition, the tentative definition // is redundant if (!var2) cur = cur->next = var; } //here now we have globals without duplicated tentative, we start from de-duplicated tentatives //and we add after all the remaining globals. cur = &head; head.next = NULL; for (int j = 0; j < i; j++) { if (varArr[j]) { cur = cur->next = varArr[j]; } } for (Obj *var = globals; var; var = var->next) { cur = cur->next = var; } cur->next = NULL; globals = head.next; } static void scan_globals2(void) { Obj head; Obj *cur = &head; Obj *varArr[50000]; int i = 0; //the first pass skipped the duplicated tentative and stores in an Array of objects duplicated tentative for (Obj *var = globals; var; var = var->next) { if (!var->is_definition) { cur = cur->next = var; continue; } // Find another definition of the same identifier. Obj *var2 = globals; for (; var2; var2 = var2->next) { if (var != var2 && var2->is_definition && !strcmp(var->name, var2->name)) { //warn_tok(var->tok, "%s %d: in scan_globals : duplicated tentative definition", PARSE_C, __LINE__); if (var2->is_definition && !var_in_array2(var->name, varArr, i + 1 ) && (i + 1) < 50000) { varArr[i++] = var; } break; } } // If there's another definition, the tentative definition // is redundant if (!var2) cur = cur->next = var; } //here now we have globals without duplicated tentative, we start from de-duplicated tentatives //and we add after all the remaining globals. cur = &head; head.next = NULL; for (int j = 0; j < i; j++) { if (varArr[j]) { cur = cur->next = varArr[j]; } } for (Obj *var = globals; var; var = var->next) { cur = cur->next = var; } cur->next = NULL; globals = head.next; } static void declare_builtin_functions(void) { Type *ty = func_type(pointer_to(ty_void)); ty->params = copy_type(ty_int); builtin_alloca = new_gvar("alloca", ty); builtin_alloca->is_definition = false; Obj *builtin = new_gvar("__builtin_alloca", ty); builtin->is_definition = false; } // program = (typedef | function-definition | global-variable)* Obj *parse(Token *tok) { char *path; char *fullpath = calloc(1, sizeof(char) * 400);; //char *filename; if (isDotfile && dotf == NULL) { if (base_file == NULL && opt_o == NULL) { fprintf(stderr, "%s: in parse base_file and opt_o are null!\n", PARSE_C); exit(1); } path = replace_extn(opt_o ? opt_o : base_file, ".dot"); if (opt_o != NULL) { //filename = extract_filename(opt_o); fullpath = extract_path(opt_o); strncat(fullpath, path, strlen(path)); } //printf("%s %s %s\n", fullpath, filename, path); dotf = fopen(fullpath, "w"); if (dotf == NULL) { fprintf(stderr, "%s: in parse dot file cannot be opend\n", PARSE_C); exit(1); } fprintf(dotf, "digraph A { \n"); } if (opt_fbuiltin) declare_builtin_functions(); globals = NULL; while (tok->kind != TK_EOF) { if (equal(tok, "_Static_assert")) { tok = static_assertion(tok); continue; } //fixing ISS-192 found during php-src compile if (equal(tok, "asm") || equal(tok, "__asm__")) { Node *node = asm_stmt(&tok, tok); add_type(node); continue; } VarAttr attr = {}; //from COSMOPOLITAN adding other GNUC attributes tok = attribute_list(tok, &attr, thing_attributes); Type *basety = declspec(&tok, tok, &attr); tok = attribute_list(tok, &attr, thing_attributes); // Typedef if (attr.is_typedef) { //checking if the typedef has attributes set at the end; Token *start = tok; while (!equal(tok, ";")) { tok = attribute_list(tok, basety, type_attributes); tok = tok->next; } tok = start; parse_typedef(&tok, tok, basety); continue; } // Function if (is_function(tok)) { if (check_old_style(&tok, tok)) { is_old_style = true; tok = function(tok, basety, &attr); continue; //error_tok(tok, "%s: in function : old C style function definition is not supported", PARSE_C); } is_old_style = false; tok = function(tok, basety, &attr); continue; } // Global variable tok = global_variable(tok, basety, &attr); } for (Obj *var = globals; var; var = var->next) if (var->is_root) mark_live(var); // Remove redundant tentative definitions. scan_globals(); // Remove redundant declaration; scan_globals2(); return globals; } // for dot diagram char *nodekind2str(NodeKind kind) { switch (kind) { case ND_NULL_EXPR: return "NULL_EXPR"; case ND_ADD: return "ADD"; case ND_SUB: return "SUB"; case ND_MUL: return "MUL"; case ND_DIV: return "DIV"; case ND_POS: return "POS"; case ND_NEG: return "NEG"; case ND_MOD: return "MOD"; case ND_BITAND: return "BITAND"; case ND_BITOR: return "BITOR"; case ND_BITXOR: return "BITXOR"; case ND_SHL: return "SHL"; case ND_SHR: return "SHR"; case ND_EQ: return "EQ"; case ND_NE: return "NE"; case ND_LT: return "LT"; case ND_LE: return "LE"; case ND_ASSIGN: return "ASSIGN"; case ND_COND: return "COND"; case ND_COMMA: return "COMMA"; case ND_MEMBER: return "MEMBER"; case ND_ADDR: return "ADDR"; case ND_DEREF: return "DEREF"; case ND_NOT: return "NOT"; case ND_BITNOT: return "BITNOT"; case ND_LOGAND: return "LOGAND"; case ND_LOGOR: return "LOGOR"; case ND_RETURN: return "RETURN"; case ND_IF: return "IF"; case ND_FOR: return "FOR"; case ND_DO: return "DO"; case ND_SWITCH: return "SWITCH"; case ND_CASE: return "CASE"; case ND_BLOCK: return "BLOCK"; case ND_GOTO: return "GOTO"; case ND_GOTO_EXPR: return "GOTO_EXPR"; case ND_LABEL: return "LABEL"; case ND_LABEL_VAL: return "LABEL_VAL"; case ND_FUNCALL: return "FUNCCALL"; case ND_EXPR_STMT: return "EXPRSTMR"; case ND_STMT_EXPR: return "STMTEXPR"; case ND_VAR: return "VAR"; case ND_VLA_PTR: return "VLAPTR"; case ND_NUM: return "NUM"; case ND_CAST: return "CAST"; case ND_MEMZERO: return "MEMZERO"; case ND_ASM: return "ASM"; case ND_CAS: return "CAS"; case ND_CAS_N: return "CAS_N"; case ND_EXCH: return "EXCHANGE"; case ND_EXCH_N: return "EXCHANGE_N"; case ND_CMPEXCH: return "COMPARE_EXCHANGE"; case ND_CMPEXCH_N: return "COMPARE_EXCHANGE_N"; case ND_LOAD: return "LOAD"; case ND_LOAD_N: return "LOAD_N"; case ND_STORE: return "STORE"; case ND_STORE_N: return "STORE_N"; case ND_TESTANDSET: return "TESTANDSET"; case ND_TESTANDSETA: return "TESTANDSETA"; case ND_CLEAR: return "CLEAR"; case ND_RELEASE: return "RELEASE"; case ND_FETCHADD: return "FETCHADD"; case ND_FETCHSUB: return "FETCHSUB"; case ND_FETCHXOR: return "FETCHXOR"; case ND_FETCHAND: return "FETCHAND"; case ND_FETCHOR: return "FETCHOR"; case ND_SUBFETCH: return "SUBFETCH"; case ND_SYNC: return "SYNC"; case ND_BUILTIN_MEMCPY: return "MEMCPY"; case ND_BUILTIN_MEMSET: return "MEMSET"; case ND_BUILTIN_CLZ: return "CLZ"; case ND_BUILTIN_CLZL: return "CLZL"; case ND_BUILTIN_CLZLL: return "CLZLL"; case ND_BUILTIN_CTZ: return "CTZ"; case ND_BUILTIN_CTZL: return "CTZL"; case ND_BUILTIN_CTZLL: return "CTZLL"; case ND_BUILTIN_INFF: return "INFF"; case ND_BUILTIN_INF: return "INFF"; case ND_BUILTIN_NAN: return "NAN"; case ND_BUILTIN_NANF: return "NANF"; case ND_BUILTIN_NANL: return "NANL"; case ND_BUILTIN_ISNAN: return "ISNAN"; case ND_BUILTIN_HUGE_VAL: return "ISNAN"; case ND_BUILTIN_HUGE_VALF: return "ISNAN"; case ND_BUILTIN_HUGE_VALL: return "ISNAN"; case ND_POPCOUNT: return "POPCOUNT"; case ND_POPCOUNTL: return "POPCOUNTL"; case ND_POPCOUNTLL: return "POPCOUNTLL"; case ND_RETURN_ADDR: return "RETURN_ADDRESS"; case ND_BUILTIN_FRAME_ADDRESS: return "FRAME_ADDRESS"; case ND_BUILTIN_ADD_OVERFLOW: return "ADD_OVERFLOW"; case ND_BUILTIN_SUB_OVERFLOW: return "SUB_OVERFLOW"; case ND_BUILTIN_MUL_OVERFLOW: return "MUL_OVERFLOW"; case ND_UADD_OVERFLOW: return "UADD_OVERFLOW"; case ND_UADDL_OVERFLOW: return "UADDL_OVERFLOW"; case ND_UADDLL_OVERFLOW: return "UADDLL_OVERFLOW"; case ND_UMUL_OVERFLOW: return "UMUL_OVERFLOW"; case ND_UMULL_OVERFLOW: return "UMULL_OVERFLOW"; case ND_UMULLL_OVERFLOW: return "UMULLL_OVERFLOW"; case ND_BUILTIN_BSWAP16: return "BSWAP16"; case ND_BUILTIN_BSWAP32: return "BSWAP32"; case ND_BUILTIN_BSWAP64: return "BSWAP64"; case ND_ALLOC: return "ALLOCA"; case ND_ABORT: return "ABORT"; case ND_EXPECT: return "EXPECT"; case ND_EMMS: return "EMMS"; case ND_LFENCE: return "LFENCE"; case ND_MFENCE: return "MFENCE"; case ND_SFENCE: return "SFENCE"; case ND_PAUSE: return "PAUSE"; case ND_STMXCSR: return "STMXCSR"; case ND_LDMXCSR: return "LDMXCSR"; case ND_CVTPI2PS: return "CVTPI2PS"; case ND_CVTPS2PI: return "CVTPS2PI"; case ND_CLFLUSH: return "CLFLUSH"; case ND_VECINITV2SI: return "VEC_INIT_V2SI"; case ND_VECEXTV2SI: return "VEC_EXT_V2SI"; case ND_VECEXTV4SI: return "VEC_EXT_V4SI"; case ND_VECINITV8QI: return "VEC_INIT_V8QI"; case ND_VECINITV4HI: return "VEC_INIT_V4HI"; case ND_PACKSSWB: return "PACKSSWB"; case ND_PACKSSDW: return "PACKSSDW"; case ND_PACKUSWB: return "PACKUSWB"; case ND_PUNPCKHBW: return "PUNPCKHBW"; case ND_PUNPCKHWD: return "PUNPCKHWD"; case ND_PUNPCKHDQ: return "PUNPCKHDQ"; case ND_PUNPCKLBW: return "PUNPCKLBW"; case ND_PUNPCKLWD: return "PUNPCKLWD"; case ND_PUNPCKLDQ: return "PUNPCKLDQ"; case ND_PADDB: return "PADDB"; case ND_PADDW: return "PADDW"; case ND_PADDD: return "PADDD"; case ND_PADDQ: return "PADDQ"; case ND_PADDSB: return "PADDSB"; case ND_PADDSW: return "PADDSW"; case ND_PADDUSB: return "PADDUSB"; case ND_PADDUSW: return "PADDUSW"; case ND_PSUBB: return "PSUBB"; case ND_PSUBW: return "PSUBW"; case ND_PSUBD: return "PSUBD"; case ND_PSUBQ: return "PSUBQ"; case ND_PSUBSB: return "PSUBSB"; case ND_PSUBSW: return "PSUBSW"; case ND_PSUBUSB: return "PSUBUSB"; case ND_PSUBUSW: return "PSUBUSW"; case ND_PMADDWD: return "PMADDWD"; case ND_PMULHW: return "PMULHW"; case ND_PMULLW: return "PMULLW"; case ND_PSLLW: return "PSLLW"; case ND_PSLLWI: return "PSLLWI"; case ND_PSLLD: return "PSLLD"; case ND_PSLLDI: return "PSLLDI"; case ND_PSLLQ: return "PSLLQ"; case ND_PSLLQI: return "PSLLQI"; case ND_PSRAW: return "PSRAW"; case ND_PSRAWI: return "PSRAWI"; case ND_PSRAD: return "PSRAD"; case ND_PSRADI: return "PSRADI"; case ND_PSRLW: return "PSRLW"; case ND_PSRLWI: return "PSRLWI"; case ND_PSRLD: return "PSRLD"; case ND_PSRLDI: return "PSRLDI"; case ND_PSRLQ: return "PSRLQ"; case ND_PSRLQI: return "PSRLQI"; case ND_PAND: return "PAND"; case ND_PANDN: return "PANDN"; case ND_POR: return "POR"; case ND_PXOR: return "PXOR"; case ND_PCMPEQB: return "PCMPEQB"; case ND_PCMPGTB: return "PCMPGTB"; case ND_PCMPEQW: return "PCMPEQW"; case ND_PCMPEQD: return "PCMPEQD"; case ND_PCMPGTW: return "PCMPGTW"; case ND_PCMPGTD: return "PCMPGTD"; case ND_ADDSS: return "ADDSS"; case ND_SUBSS: return "SUBSS"; case ND_MULSS: return "MULSS"; case ND_DIVSS: return "DIVSS"; case ND_SQRTSS: return "SQRTSS"; case ND_SQRTPS: return "SQRTPS"; case ND_RSQRTSS: return "RSQRTSS"; case ND_RSQRTPS: return "RSQRTPS"; case ND_RCPSS: return "RCPSS"; case ND_RCPPS: return "RCPPS"; case ND_MINSS: return "MINSS"; case ND_MINPS: return "MINPS"; case ND_MAXPS: return "MAXPS"; case ND_MAXSS: return "MAXSS"; case ND_ANDPS: return "ANDPS"; case ND_ANDNPS: return "ANDNPS"; case ND_ORPS: return "ORPS"; case ND_XORPS: return "XORPS"; case ND_CMPEQSS: return "CMPEQSS"; case ND_CMPLTSS: return "CMPLTSS"; case ND_CMPLESS: return "CMPLESS"; case ND_MOVSS: return "MOVSS"; case ND_CMPNEQSS: return "CMPNEQSS"; case ND_CMPNLTSS: return "CMPNLTSS"; case ND_CMPNLESS: return "CMPNLESS"; case ND_CMPORDSS: return "CMPORDSS"; case ND_CMPUNORDSS: return "CMPUNORDSS"; case ND_CMPEQPS: return "CMPEQPS"; case ND_CMPLTPS: return "CMPLTPS"; case ND_CMPLEPS: return "CMPLEPS"; case ND_CMPGTPS: return "CMPGTPS"; case ND_CMPGEPS: return "CMPGEPS"; case ND_CMPNEQPS: return "CMPNEQPS"; case ND_CMPNLTPS: return "CMPNLTPS"; case ND_CMPNLEPS: return "CMPNLEPS"; case ND_CMPNGTPS: return "CMPNGTPS"; case ND_CMPNGEPS: return "CMPNGEPS"; case ND_CMPORDPS: return "CMPORDPS"; case ND_CMPUNORDPS: return "CMPUNORDPS"; case ND_COMIEQ: return "COMIEQ"; case ND_COMILT: return "COMILT"; case ND_COMILE: return "COMILE"; case ND_COMIGT: return "COMIGT"; case ND_COMIGE: return "COMIGE"; case ND_COMINEQ: return "COMINEQ"; case ND_UCOMIEQ: return "UCOMIEQ"; case ND_UCOMILT: return "UCOMILT"; case ND_UCOMILE: return "UCOMILE"; case ND_UCOMIGT: return "UCOMIGT"; case ND_UCOMIGE: return "UCOMIGE"; case ND_UCOMINEQ: return "UCOMINEQ"; case ND_CVTSS2SI: return "CVTSS2SI"; case ND_CVTSS2SI64: return "CVTSS2SI64"; case ND_CVTTSS2SI: return "CVTTSS2SI"; case ND_CVTTSS2SI64: return "CVTTSS2SI64"; case ND_CVTTPS2PI: return "CVTTPS2PI"; case ND_CVTSI2SS: return "CVTSI2SS"; case ND_CVTSI642SS: return "CVTSI642SS"; case ND_MOVLHPS: return "MOVLHPS"; case ND_MOVHLPS: return "MOVHLPS"; case ND_UNPCKHPS: return "UNPCKHPS"; case ND_UNPCKLPS: return "UNPCKLPS"; case ND_LOADHPS: return "LOADHPS"; case ND_STOREHPS: return "STOREHPS"; case ND_LOADLPS: return "LOADLPS"; case ND_STORELPS: return "STORELPS"; case ND_MOVMSKPS: return "MOVMSKPS"; case ND_SHUFPS: return "SHUFPS"; case ND_SHUFFLE: return "SHUFFLE"; case ND_PMAXSW: return "PMAXSW"; case ND_PMAXUB: return "PMAXUB"; case ND_PMINSW: return "PMINSW"; case ND_PMINUB: return "PMINUB"; case ND_PMOVMSKB: return "PMOVMSKB"; case ND_PMULHUW: return "PMULHUW"; case ND_MASKMOVQ: return "MASKMOVQ"; case ND_PAVGB: return "PAVGB"; case ND_PAVGW: return "PAVGW"; case ND_PSADBW: return "PSADBW"; case ND_MOVNTQ: return "MOVNTQ"; case ND_MOVNTPS: return "MOVNTPS"; case ND_SHUFPD: return "SHUFPD"; case ND_ADDSD: return "ADDSD"; case ND_SUBSD: return "SUBSD"; case ND_MULSD: return "MULSD"; case ND_DIVSD: return "DIVSD"; case ND_SQRTPD: return "SQRTPD"; case ND_SQRTSD: return "SQRTSD"; case ND_MOVSD: return "MOVSD"; case ND_MINPD: return "MINPD"; case ND_MINSD: return "MINSD"; case ND_MAXPD: return "MAXPD"; case ND_MAXSD: return "MAXSD"; case ND_ANDPD: return "ANDPD"; case ND_ANDNPD: return "ANDNPD"; case ND_ORPD: return "ORPD"; case ND_XORPD: return "XORPD"; case ND_CMPEQPD: return "CMPEQPD"; case ND_CMPLTPD: return "CMPLTPD"; case ND_CMPLEPD: return "CMPLEPD"; case ND_CMPGTPD: return "CMPGTPD"; case ND_CMPGEPD: return "CMPGEPD"; case ND_CMPNEQPD: return "CMPNEQPD"; case ND_CMPNLTPD: return "CMPNLTPD"; case ND_CMPNLEPD: return "CMPNLEPD"; case ND_CMPNGTPD: return "CMPNGTPD"; case ND_CMPNGEPD: return "CMPNGEPD"; case ND_CMPORDPD: return "CMPORDPD"; case ND_CMPUNORDPD: return "CMPUNORDPD"; case ND_CMPEQSD: return "CMPEQSD"; case ND_CMPLTSD: return "CMPLTSD"; case ND_CMPLESD: return "CMPLESD"; case ND_CMPNEQSD: return "CMPNEQSD"; case ND_CMPNLTSD: return "CMPNLTSD"; case ND_CMPNLESD: return "CMPNLESD"; case ND_CMPORDSD: return "CMPORDSD"; case ND_CMPUNORDSD: return "CMPUNORDSD"; case ND_COMISDEQ: return "COMISDEQ"; case ND_COMISDLT: return "COMISDLT"; case ND_COMISDLE: return "COMISDLE"; case ND_COMISDGT: return "COMISDGT"; case ND_COMISDGE: return "COMISDGE"; case ND_COMISDNEQ: return "COMISDNEQ"; case ND_UCOMISDEQ: return "UCOMISDEQ"; case ND_UCOMISDLT: return "UCOMISDLT"; case ND_UCOMISDLE: return "UCOMISDLE"; case ND_UCOMISDGT: return "UCOMISDGT"; case ND_UCOMISDGE: return "UCOMISDGE"; case ND_UCOMISDNEQ: return "UCOMISDNEQ"; case ND_MOVQ128: return "MOVQ128"; case ND_CVTDQ2PD: return "CVTDQ2PD"; case ND_CVTDQ2PS: return "CVTDQ2PS"; case ND_CVTPD2DQ: return "CVTPD2DQ"; case ND_CVTPD2PI: return "CVTPD2PI"; case ND_CVTPD2PS: return "CVTPD2PS"; case ND_CVTTPD2DQ: return "CVTTPD2DQ"; case ND_CVTTPD2PI: return "CVTTPD2PI"; case ND_CVTPI2PD: return "CVTPI2PD"; case ND_CVTPS2DQ: return "CVTPS2DQ"; case ND_CVTTPS2DQ: return "CVTTPS2DQ"; case ND_CVTPS2PD: return "CVTPS2PD"; case ND_CVTSD2SI: return "CVTSD2SI"; case ND_CVTSD2SI64: return "CVTSD2SI64"; case ND_CVTTSD2SI: return "CVTTSD2SI"; case ND_CVTTSD2SI64: return "CVTTSD2SI64"; case ND_CVTSD2SS: return "CVTSD2SS"; case ND_CVTSI2SD: return "CVTSI2SD"; case ND_CVTSI642SD: return "CVTSI642SD"; case ND_CVTSS2SD: return "CVTSS2SD"; case ND_UNPCKHPD: return "UNPCKHPD"; case ND_UNPCKLPD: return "UNPCKLPD"; case ND_LOADHPD: return "LOADHPD"; case ND_LOADLPD: return "LOADLPD"; case ND_MOVMSKPD: return "MOVMSKPD"; case ND_PACKSSWB128: return "PACKSSWB128"; case ND_PACKSSDW128: return "PACKSSDW128"; case ND_PACKUSWB128: return "PACKUSWB128"; case ND_PUNPCKHBW128: return "PUNPCKHB128"; case ND_PUNPCKHWD128: return "PUNPCKHWD128"; case ND_PUNPCKHDQ128: return "PUNPCKHDQ128"; case ND_PUNPCKHQDQ128: return "PUNPCKHQDQ128"; case ND_PUNPCKLBW128: return "PUNPCKLBW128"; case ND_PUNPCKLWD128: return "PUNPCKLWD128"; case ND_PUNPCKLDQ128: return "PUNPCKLDQ128"; case ND_PUNPCKLQDQ128: return "PUNPCKLQDQ128"; case ND_PADDSB128: return "PADDSB128"; case ND_PADDSW128: return "PADDSW128"; case ND_PADDUSB128: return "PADDUSB128"; case ND_PADDUSW128: return "PADDUSW128"; case ND_PSUBSB128: return "PSUBSB128"; case ND_PSUBSW128: return "PSUBSW128"; case ND_PSUBUSB128: return "PSUBUSB128"; case ND_PSUBUSW128: return "PSUBUSW128"; case ND_PMADDWD128: return "PMADDWD128"; case ND_PMULHW128: return "PMULHW128"; case ND_PMULUDQ: return "PMULUDQ"; case ND_PMULUDQ128: return "PMULUDQ128"; case ND_PSLLWI128: return "PSLLWI128"; case ND_PSLLDI128: return "PSLLDI128"; case ND_PSLLQI128: return "PSLLQI128"; case ND_PSRAWI128: return "PSRAWI128"; case ND_PSRADI128: return "PSRADI128"; case ND_PSRLWI128: return "PSRLWI128"; case ND_PSRLDI128: return "PSRLDI128"; case ND_PSRLQI128: return "PSRLQI128"; case ND_PSLLW128: return "PSLLW128"; case ND_PSLLD128: return "PSLLD128"; case ND_PSLLQ128: return "PSLLQ128"; case ND_PSRAW128: return "PSRAW128"; case ND_PSRAD128: return "PSRAD128"; case ND_PSRLW128: return "PSRLW128"; case ND_PSRLD128: return "PSRLD128"; case ND_PSRLQ128: return "PSRLQ128"; case ND_PANDN128: return "PANDN128"; case ND_PMAXSW128: return "PMAXSW128"; case ND_PMAXUB128: return "PMAXUB128"; case ND_PMINSW128: return "PMINSW128"; case ND_PMINUB128: return "PMINUB128"; case ND_PMOVMSKB128: return "PMOVMSKB128"; case ND_PMULHUW128: return "PMULHUW128"; case ND_MASKMOVDQU: return "MASKMOVDQU"; case ND_PAVGB128: return "PAVGB128"; case ND_PAVGW128: return "PAVGW128"; case ND_PSADBW128: return "PSADBW128"; case ND_MOVNTI: return "MOVNTI"; case ND_MOVNTI64: return "MOVNTI64"; case ND_MOVNTDQ: return "MOVNTDQ"; case ND_MOVNTPD: return "MOVNTPD"; case ND_PARITY: return "PARITY"; case ND_PARITYL: return "PARITYL"; case ND_PARITYLL: return "PARITYLL"; default: return "UNREACHABLE"; } } //from COSMOPOLITAN adding function ConsumeStringLiteral char *ConsumeStringLiteral(Token **rest, Token *tok) { char *s; if (tok->kind != TK_STR || tok->ty->base->kind != TY_CHAR) { error_tok(tok, "%s %d: in ConsumeStringLiteral : expected string literal but got tok->kind %d", PARSE_C, __LINE__, tok->kind); } s = tok->str; *rest = tok->next; return s; } //from COSMOPOLITAN adding function static_assertion static Token *static_assertion(Token *tok) { char *msg; Token *start = tok; Token *errmsg = tok; SET_CTX(ctx); tok = skip(tok->next, "(", ctx); int64_t cond = const_expr(&tok, tok); if (consume(&tok, tok, ",")) { errmsg = tok; msg = ConsumeStringLiteral(&tok, tok); } else { msg = "static assertion failed"; } SET_CTX(ctx); tok = skip(tok, ")", ctx); SET_CTX(ctx); tok = skip(tok, ";", ctx); if (!cond) { error_tok(start, "%s %d: in static_assertion : %s %s", PARSE_C, __LINE__, msg, errmsg->loc); } return tok; } // this function checks if we have an old C style function declaration static bool check_old_style(Token **rest, Token *tok) { Token *start = tok; is_old_style = false; while (tok->kind != TK_EOF && !equal(tok, "{")) { //found a function body if (equal(tok, ";") && equal(tok->next, "{")) { tok = start; return true; } //if function declaration ending with ";" exit if (equal(tok, ")") && equal(tok->next, ";")) { break; } // //if function not followed by a Keyword exit // if (equal(tok, ")") && tok->next &&tok->next->kind != TK_KEYWORD) // { // break; // } if (equal(tok, "}")) { break; } tok = tok->next; } tok = start; return false; } static Token * old_style_params(Token **rest, Token *tok, Type *ty) { int nbparms = 0; bool first = true; while(!equal(tok, ")")) { //first count the number of parameters if (!first) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } first = false; ArrayTokenOrder[nbFunc][nbparms] = tok; nbparms++; tok = tok->next; } tok = tok->next; return tok; } static Node *ParseBuiltin(NodeKind kind, Token *tok, Token **rest) { Node *node = new_node(kind, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_val = assign(&tok, tok); add_type(node->builtin_val); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } //from cosmopolitan managing builtin atomics static Node *ParseAtomic2(NodeKind kind, Token *tok, Token **rest) { Node *node = new_node(kind, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); node->ty = node->lhs->ty->base; if (equal(tok, ",")) { SET_CTX(ctx); tok = skip(tok, ",", ctx); node->memorder = const_expr(&tok, tok); } SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } static Node *ParseAtomic3(NodeKind kind, Token *tok, Token **rest) { Node *node = new_node(kind, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); node->ty = node->lhs->ty->base; SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); // Check if there's a comma, indicating a memory order argument if (equal(tok, ",")) { SET_CTX(ctx); tok = skip(tok, ",", ctx); node->memorder = const_expr(&tok, tok); } SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } static Node *ParseAtomicCompareExchangeN(NodeKind kind, Token *tok, Token **rest) { Node *node = new_node(kind, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->cas_ptr = assign(&tok, tok); add_type(node->cas_ptr); tok = skip(tok, ",", ctx); node->cas_expected = assign(&tok, tok); add_type(node->cas_expected); tok = skip(tok, ",", ctx); node->cas_desired = assign(&tok, tok); add_type(node->cas_desired); tok = skip(tok, ",", ctx); node->cas_weak = assign(&tok, tok); add_type(node->cas_weak); tok = skip(tok, ",", ctx); node->cas_success = assign(&tok, tok); add_type(node->cas_success); tok = skip(tok, ",", ctx); node->cas_failure = assign(&tok, tok); add_type(node->cas_failure); *rest = skip(tok, ")", ctx); node->ty = ty_bool; return node; } //builtin function memcpy static Node *parse_memcpy(Token *tok, Token **rest) { Node *node = new_node(ND_BUILTIN_MEMCPY, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_dest = assign(&tok, tok); add_type(node->builtin_dest); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_src = assign(&tok, tok); add_type(node->builtin_src); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_size = assign(&tok, tok); add_type(node->builtin_size); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } static Node *parse_memset(Token *tok, Token **rest) { Node *node = new_node(ND_BUILTIN_MEMSET, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->builtin_dest = assign(&tok, tok); add_type(node->builtin_dest); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_val = assign(&tok, tok); add_type(node->builtin_val); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_size = assign(&tok, tok); add_type(node->builtin_size); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } static Node *parse_overflow(NodeKind kind, Token *tok, Token **rest) { // Parse the arguments for __builtin_add_overflow Node *node = new_node(kind, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); node->lhs = assign(&tok, tok); add_type(node->lhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->rhs = assign(&tok, tok); add_type(node->rhs); SET_CTX(ctx); tok = skip(tok, ",", ctx); node->builtin_dest = assign(&tok, tok); add_type(node->builtin_dest); SET_CTX(ctx); *rest = skip(tok, ")", ctx); return node; } // //the goal of this function is to put the correct type for the correct parameter order in case of old C style K&R // // example : // // void test_compress(compr, comprLen, uncompr, uncomprLen) char *compr, // // *uncompr; // // long comprLen, uncomprLen; // // the order of parameters inside parenthesis doesn't correspond to the declaration of each parameter. // // that's why this function found the parameter order and update the type for this order and returns new ty->params following // // the expected order and not the declaration order. It's quite complex and probably we can find an easiest way to do it static Type *old_params(Type *ty, int nbparms) { Type head = {}; Type *cur = &head; bool isOrdered = true; // Check if parameters are already in order for (int i = 0; i < nbparms; i++) { if (strncmp(ArrayTokenOrder[nbFunc][i]->loc, ArrayToken[nbFunc][i]->loc, ArrayToken[nbFunc][i]->len) != 0) { isOrdered = false; break; } } // If parameters are already in order, return the original type list if (isOrdered) { return ty; } // If not in order, create a new Type list with parameters in correct order for (int i = 0; i < nbparms; i++) { for (int j = 0; j < nbparms; j++) { if (strncmp(ArrayTokenOrder[nbFunc][i]->loc, ArrayToken[nbFunc][j]->loc, ArrayTokenOrder[nbFunc][i]->len) == 0) { cur = cur->next = copy_type(ArrayType[nbFunc][j]); break; } } } return head.next; } static Node *parse_huge_val(double fval, Token *tok, Token **rest) { Node *node = new_double(fval, tok); SET_CTX(ctx); tok = skip(tok->next, "(", ctx); SET_CTX(ctx); tok = skip(tok, ")", ctx); *rest = tok; return node; } static int64_t eval_sign_extend(Type *ty, uint64_t val) { switch (ty->size) { case 1: return ty->is_unsigned ? (uint8_t)val : (int64_t)(int8_t)val; case 2: return ty->is_unsigned ? (uint16_t)val : (int64_t)(int16_t)val; case 4: return ty->is_unsigned ? (uint32_t)val : (int64_t)(int32_t)val; case 8: return val; case 16: return ty->is_unsigned ? (uint64_t)val : (int64_t)val; } printf("====FATAL ERROR %d\n", ty->size ); unreachable(); } static bool is_const_var(Obj *var) { Type *ty = var->ty; for (; ty && ty->kind == TY_ARRAY; ty = ty->base) if (ty->is_const) return true; return ty->is_const; } static Obj *eval_var(Node *expr, bool allow_local) { if (expr->kind != ND_VAR) return NULL; Obj *var = expr->var; if (!var) return NULL; if (var->is_compound_lit) return var; return NULL; } static bool is_str_tok(Token **rest, Token *tok, Token **str_tok) { if (equal(tok, "(") && is_str_tok(&tok, tok->next, str_tok) && consume(rest, tok, ")")) return true; if (tok->kind == TK_STR) { *str_tok = tok; *rest = tok->next; return true; } return false; } static BuiltinEntry builtin_table[] = { { "__builtin_ia32_packssdw", ND_PACKSSDW }, { "__builtin_ia32_packsswb", ND_PACKSSWB }, { "__builtin_ia32_packuswb", ND_PACKUSWB }, { "__builtin_ia32_punpckhbw", ND_PUNPCKHBW }, { "__builtin_ia32_punpckhwd", ND_PUNPCKHWD }, { "__builtin_ia32_punpckhdq", ND_PUNPCKHDQ }, { "__builtin_ia32_punpcklbw", ND_PUNPCKLBW }, { "__builtin_ia32_punpcklwd", ND_PUNPCKLWD }, { "__builtin_ia32_punpckldq", ND_PUNPCKLDQ }, { "__builtin_ia32_paddb", ND_PADDB }, { "__builtin_ia32_paddw", ND_PADDW }, { "__builtin_ia32_paddd", ND_PADDD }, { "__builtin_ia32_paddq", ND_PADDQ }, { "__builtin_ia32_paddsb", ND_PADDSB }, { "__builtin_ia32_paddsw", ND_PADDSW }, { "__builtin_ia32_paddusb", ND_PADDUSB }, { "__builtin_ia32_paddusw", ND_PADDUSW }, { "__builtin_ia32_psubb", ND_PSUBB }, { "__builtin_ia32_psubw", ND_PSUBW }, { "__builtin_ia32_psubd", ND_PSUBD }, { "__builtin_ia32_psubq", ND_PSUBQ }, { "__builtin_ia32_psubsb", ND_PSUBSB }, { "__builtin_ia32_psubsw", ND_PSUBSW }, { "__builtin_ia32_psubusb", ND_PSUBUSB }, { "__builtin_ia32_psubusw", ND_PSUBUSW }, { "__builtin_ia32_pmaddwd", ND_PMADDWD }, { "__builtin_ia32_pmulhw", ND_PMULHW }, { "__builtin_ia32_pmullw", ND_PMULLW }, { "__builtin_ia32_psllw", ND_PSLLW }, { "__builtin_ia32_psllwi", ND_PSLLWI }, { "__builtin_ia32_pslld", ND_PSLLD }, { "__builtin_ia32_pslldi", ND_PSLLDI }, { "__builtin_ia32_psllq", ND_PSLLQ }, { "__builtin_ia32_psllqi", ND_PSLLQI }, { "__builtin_ia32_psraw", ND_PSRAW }, { "__builtin_ia32_psrawi", ND_PSRAWI }, { "__builtin_ia32_psrad", ND_PSRAD }, { "__builtin_ia32_psradi", ND_PSRADI }, { "__builtin_ia32_psrlw", ND_PSRLW }, { "__builtin_ia32_psrlwi", ND_PSRLWI }, { "__builtin_ia32_psrld", ND_PSRLD }, { "__builtin_ia32_psrldi", ND_PSRLDI }, { "__builtin_ia32_psrlq", ND_PSRLQ }, { "__builtin_ia32_psrlqi", ND_PSRLQI }, { "__builtin_ia32_pand", ND_PAND }, { "__builtin_ia32_pandn", ND_PANDN }, { "__builtin_ia32_por", ND_POR }, { "__builtin_ia32_pxor", ND_PXOR }, { "__builtin_ia32_pcmpeqb", ND_PCMPEQB }, { "__builtin_ia32_pcmpgtb", ND_PCMPGTB }, { "__builtin_ia32_pcmpeqw", ND_PCMPEQW }, { "__builtin_ia32_pcmpgtw", ND_PCMPGTW }, { "__builtin_ia32_pcmpeqd", ND_PCMPEQD }, { "__builtin_ia32_pcmpgtd", ND_PCMPGTD }, { "__builtin_ia32_vec_init_v4hi", ND_VECINITV4HI }, { "__builtin_ia32_vec_init_v8qi", ND_VECINITV8QI }, { "__builtin_ia32_vec_init_v2si", ND_VECINITV2SI }, { "__builtin_ia32_vec_ext_v2si", ND_VECEXTV2SI }, { "__builtin_ia32_vec_ext_v4si", ND_VECEXTV4SI }, { "__builtin_ia32_emms", ND_EMMS }, { "__builtin_ia32_sfence", ND_SFENCE }, { "__builtin_ia32_lfence", ND_LFENCE }, { "__builtin_ia32_mfence", ND_MFENCE }, { "__builtin_ia32_pause", ND_PAUSE }, { "__builtin_ia32_stmxcsr", ND_STMXCSR }, { "__builtin_ia32_ldmxcsr", ND_LDMXCSR }, { "__builtin_ia32_cvtpi2ps", ND_CVTPI2PS }, { "__builtin_ia32_cvtps2pi", ND_CVTPS2PI }, { "__builtin_ia32_addss", ND_ADDSS }, { "__builtin_ia32_subss", ND_SUBSS }, { "__builtin_ia32_mulss", ND_MULSS }, { "__builtin_ia32_divss", ND_DIVSS }, { "__builtin_ia32_sqrtss", ND_SQRTSS }, { "__builtin_ia32_sqrtps", ND_SQRTPS }, { "__builtin_ia32_rcpss", ND_RCPSS }, { "__builtin_ia32_rsqrtss", ND_RSQRTSS }, { "__builtin_ia32_rsqrtps", ND_RSQRTPS }, { "__builtin_ia32_minss", ND_MINSS }, { "__builtin_ia32_minps", ND_MINPS }, { "__builtin_ia32_maxss", ND_MAXSS }, { "__builtin_ia32_maxps", ND_MAXPS }, { "__builtin_ia32_rcpps", ND_RCPPS }, { "__builtin_ia32_andps", ND_ANDPS }, { "__builtin_ia32_andnps", ND_ANDNPS }, { "__builtin_ia32_orps", ND_ORPS }, { "__builtin_ia32_xorps", ND_XORPS }, { "__builtin_ia32_cmpeqss", ND_CMPEQSS }, { "__builtin_ia32_cmpltss", ND_CMPLTSS }, { "__builtin_ia32_cmpless", ND_CMPLESS }, { "__builtin_ia32_movss", ND_MOVSS }, { "__builtin_ia32_cmpneqss", ND_CMPNEQSS }, { "__builtin_ia32_cmpnltss", ND_CMPNLTSS }, { "__builtin_ia32_cmpnless", ND_CMPNLESS }, { "__builtin_ia32_cmpordss", ND_CMPORDSS }, { "__builtin_ia32_cmpunordss", ND_CMPUNORDSS }, { "__builtin_ia32_cmpeqps", ND_CMPEQPS }, { "__builtin_ia32_cmpltps", ND_CMPLTPS }, { "__builtin_ia32_cmpleps", ND_CMPLEPS }, { "__builtin_ia32_cmpgtps", ND_CMPGTPS }, { "__builtin_ia32_cmpgeps", ND_CMPGEPS }, { "__builtin_ia32_cmpneqps", ND_CMPNEQPS }, { "__builtin_ia32_cmpnltps", ND_CMPNLTPS }, { "__builtin_ia32_cmpnleps", ND_CMPNLEPS }, { "__builtin_ia32_cmpngtps", ND_CMPNGTPS }, { "__builtin_ia32_cmpngeps", ND_CMPNGEPS }, { "__builtin_ia32_cmpordps", ND_CMPORDPS }, { "__builtin_ia32_cmpunordps", ND_CMPUNORDPS }, { "__builtin_ia32_comieq", ND_COMIEQ }, { "__builtin_ia32_comilt", ND_COMILT }, { "__builtin_ia32_comile", ND_COMILE }, { "__builtin_ia32_comigt", ND_COMIGT }, { "__builtin_ia32_comige", ND_COMIGE }, { "__builtin_ia32_comineq", ND_COMINEQ }, { "__builtin_ia32_ucomieq", ND_UCOMIEQ }, { "__builtin_ia32_ucomilt", ND_UCOMILT }, { "__builtin_ia32_ucomile", ND_UCOMILE }, { "__builtin_ia32_ucomigt", ND_UCOMIGT }, { "__builtin_ia32_ucomige", ND_UCOMIGE }, { "__builtin_ia32_ucomineq", ND_UCOMINEQ }, { "__builtin_ia32_cvtss2si", ND_CVTSS2SI }, { "__builtin_ia32_cvtss2si64", ND_CVTSS2SI64 }, { "__builtin_ia32_cvttss2si", ND_CVTTSS2SI }, { "__builtin_ia32_cvttss2si64", ND_CVTTSS2SI64 }, { "__builtin_ia32_cvttps2pi", ND_CVTTPS2PI }, { "__builtin_ia32_cvtsi2ss", ND_CVTSI2SS }, { "__builtin_ia32_cvtsi642ss", ND_CVTSI642SS }, { "__builtin_ia32_movlhps", ND_MOVLHPS }, { "__builtin_ia32_movhlps", ND_MOVHLPS }, { "__builtin_ia32_unpckhps", ND_UNPCKHPS }, { "__builtin_ia32_unpcklps", ND_UNPCKLPS }, { "__builtin_ia32_loadhps", ND_LOADHPS }, { "__builtin_ia32_storehps", ND_STOREHPS }, { "__builtin_ia32_loadlps", ND_LOADLPS }, { "__builtin_ia32_storelps", ND_STORELPS }, { "__builtin_ia32_movmskps", ND_MOVMSKPS }, { "__builtin_ia32_shufps", ND_SHUFPS }, { "__builtin_shuffle", ND_SHUFFLE }, { "__builtin_ia32_pmaxsw", ND_PMAXSW }, { "__builtin_ia32_pmaxub", ND_PMAXUB }, { "__builtin_ia32_pminsw", ND_PMINSW }, { "__builtin_ia32_pminub", ND_PMINUB }, { "__builtin_ia32_clflush", ND_CLFLUSH }, { "_mm_clflush", ND_CLFLUSH }, { "__builtin_ia32_pmovmskb", ND_PMOVMSKB }, { "__builtin_ia32_pmulhuw", ND_PMULHUW }, { "__builtin_ia32_maskmovq", ND_MASKMOVQ }, { "__builtin_ia32_pavgb", ND_PAVGB }, { "__builtin_ia32_pavgw", ND_PAVGW }, { "__builtin_ia32_psadbw", ND_PSADBW }, { "__builtin_ia32_movntq", ND_MOVNTQ }, { "__builtin_ia32_movntps", ND_MOVNTPS }, { "__builtin_ia32_shufpd", ND_SHUFPD }, { "__builtin_ia32_addsd", ND_ADDSD }, { "__builtin_ia32_subsd", ND_SUBSD }, { "__builtin_ia32_mulsd", ND_MULSD }, { "__builtin_ia32_divsd", ND_DIVSD }, { "__builtin_ia32_sqrtpd", ND_SQRTPD }, { "__builtin_ia32_movsd", ND_MOVSD }, { "__builtin_ia32_sqrtsd", ND_SQRTSD }, { "__builtin_ia32_minpd", ND_MINPD }, { "__builtin_ia32_minsd", ND_MINSD }, { "__builtin_ia32_maxpd", ND_MAXPD }, { "__builtin_ia32_maxsd", ND_MAXSD }, { "__builtin_ia32_andpd", ND_ANDPD }, { "__builtin_ia32_andnpd", ND_ANDNPD }, { "__builtin_ia32_orpd", ND_ORPD }, { "__builtin_ia32_xorpd", ND_XORPD }, { "__builtin_ia32_cmpeqpd", ND_CMPEQPD }, { "__builtin_ia32_cmpltpd", ND_CMPLTPD }, { "__builtin_ia32_cmplepd", ND_CMPLEPD }, { "__builtin_ia32_cmpgtpd", ND_CMPGTPD }, { "__builtin_ia32_cmpgepd", ND_CMPGEPD }, { "__builtin_ia32_cmpneqpd", ND_CMPNEQPD }, { "__builtin_ia32_cmpnltpd", ND_CMPNLTPD }, { "__builtin_ia32_cmpnlepd", ND_CMPNLEPD }, { "__builtin_ia32_cmpngtpd", ND_CMPNGTPD }, { "__builtin_ia32_cmpngepd", ND_CMPNGEPD }, { "__builtin_ia32_cmpordpd", ND_CMPORDPD }, { "__builtin_ia32_cmpunordpd", ND_CMPUNORDPD }, { "__builtin_ia32_cmpeqsd", ND_CMPEQSD }, { "__builtin_ia32_cmpltsd", ND_CMPLTSD }, { "__builtin_ia32_cmplesd", ND_CMPLESD }, { "__builtin_ia32_cmpneqsd", ND_CMPNEQSD }, { "__builtin_ia32_cmpnltsd", ND_CMPNLTSD }, { "__builtin_ia32_cmpnlesd", ND_CMPNLESD }, { "__builtin_ia32_cmpordsd", ND_CMPORDSD }, { "__builtin_ia32_cmpunordsd", ND_CMPUNORDSD }, { "__builtin_ia32_comisdeq", ND_COMISDEQ }, { "__builtin_ia32_comisdlt", ND_COMISDLT}, { "__builtin_ia32_comisdle", ND_COMISDLE}, { "__builtin_ia32_comisdgt", ND_COMISDGT}, { "__builtin_ia32_comisdge", ND_COMISDGE}, { "__builtin_ia32_comisdneq", ND_COMISDNEQ}, { "__builtin_ia32_ucomisdeq", ND_UCOMISDEQ }, { "__builtin_ia32_ucomisdlt", ND_UCOMISDLT}, { "__builtin_ia32_ucomisdle", ND_UCOMISDLE}, { "__builtin_ia32_ucomisdgt", ND_UCOMISDGT}, { "__builtin_ia32_ucomisdge", ND_UCOMISDGE}, { "__builtin_ia32_ucomisdneq", ND_UCOMISDNEQ}, { "__builtin_ia32_movq128", ND_MOVQ128}, { "__builtin_ia32_cvtdq2pd", ND_CVTDQ2PD}, { "__builtin_ia32_cvtdq2ps", ND_CVTDQ2PS}, { "__builtin_ia32_cvtpd2dq", ND_CVTPD2DQ}, { "__builtin_ia32_cvtpd2pi", ND_CVTPD2PI}, { "__builtin_ia32_cvtpd2ps", ND_CVTPD2PS}, { "__builtin_ia32_cvttpd2dq", ND_CVTTPD2DQ}, { "__builtin_ia32_cvttpd2pi", ND_CVTTPD2PI}, { "__builtin_ia32_cvtpi2pd", ND_CVTPI2PD}, { "__builtin_ia32_cvtps2dq", ND_CVTPS2DQ}, { "__builtin_ia32_cvttps2dq", ND_CVTTPS2DQ}, { "__builtin_ia32_cvtps2pd", ND_CVTPS2PD}, { "__builtin_ia32_cvtsd2si", ND_CVTSD2SI}, { "__builtin_ia32_cvtsd2si64", ND_CVTSD2SI64}, { "__builtin_ia32_cvttsd2si", ND_CVTTSD2SI}, { "__builtin_ia32_cvttsd2si64", ND_CVTTSD2SI64}, { "__builtin_ia32_cvtsd2ss", ND_CVTSD2SS}, { "__builtin_ia32_cvtsi2sd", ND_CVTSI2SD}, { "__builtin_ia32_cvtsi642sd", ND_CVTSI642SD}, { "__builtin_ia32_cvtss2sd", ND_CVTSS2SD}, { "__builtin_ia32_unpckhpd", ND_UNPCKHPD}, { "__builtin_ia32_unpcklpd", ND_UNPCKLPD}, { "__builtin_ia32_loadhpd", ND_LOADHPD }, { "__builtin_ia32_loadlpd", ND_LOADLPD }, { "__builtin_ia32_movmskpd", ND_MOVMSKPD }, { "__builtin_ia32_packsswb128", ND_PACKSSWB128 }, { "__builtin_ia32_packssdw128", ND_PACKSSDW128 }, { "__builtin_ia32_packuswb128", ND_PACKUSWB128 }, { "__builtin_ia32_punpckhbw128", ND_PUNPCKHBW128 }, { "__builtin_ia32_punpckhwd128", ND_PUNPCKHWD128 }, { "__builtin_ia32_punpckhdq128", ND_PUNPCKHDQ128 }, { "__builtin_ia32_punpckhqdq128", ND_PUNPCKHQDQ128 }, { "__builtin_ia32_punpcklbw128", ND_PUNPCKLBW128 }, { "__builtin_ia32_punpcklwd128", ND_PUNPCKLWD128 }, { "__builtin_ia32_punpckldq128", ND_PUNPCKLDQ128 }, { "__builtin_ia32_punpcklqdq128", ND_PUNPCKLQDQ128 }, { "__builtin_ia32_paddsb128", ND_PADDSB128 }, { "__builtin_ia32_paddsw128", ND_PADDSW128 }, { "__builtin_ia32_paddusb128", ND_PADDUSB128 }, { "__builtin_ia32_paddusw128", ND_PADDUSW128 }, { "__builtin_ia32_psubsb128", ND_PSUBSB128 }, { "__builtin_ia32_psubsw128", ND_PSUBSW128 }, { "__builtin_ia32_psubusb128", ND_PSUBUSB128 }, { "__builtin_ia32_psubusw128", ND_PSUBUSW128 }, { "__builtin_ia32_pmaddwd128", ND_PMADDWD128 }, { "__builtin_ia32_pmulhw128", ND_PMULHW128 }, { "__builtin_ia32_pmuludq", ND_PMULUDQ }, { "__builtin_ia32_pmuludq128", ND_PMULUDQ128 }, { "__builtin_ia32_psllwi128", ND_PSLLWI128 }, { "__builtin_ia32_pslldi128", ND_PSLLDI128 }, { "__builtin_ia32_psllqi128", ND_PSLLQI128 }, { "__builtin_ia32_psrawi128", ND_PSRAWI128 }, { "__builtin_ia32_psradi128", ND_PSRADI128 }, { "__builtin_ia32_psrlwi128", ND_PSRLWI128 }, { "__builtin_ia32_psrldi128", ND_PSRLDI128 }, { "__builtin_ia32_psrlqi128", ND_PSRLQI128 }, { "__builtin_ia32_psllw128", ND_PSLLW128 }, { "__builtin_ia32_pslld128", ND_PSLLD128 }, { "__builtin_ia32_psllq128", ND_PSLLQ128 }, { "__builtin_ia32_psraw128", ND_PSRAW128 }, { "__builtin_ia32_psrad128", ND_PSRAD128 }, { "__builtin_ia32_psrlw128", ND_PSRLW128 }, { "__builtin_ia32_psrld128", ND_PSRLD128 }, { "__builtin_ia32_psrlq128", ND_PSRLQ128 }, { "__builtin_ia32_pandn128", ND_PANDN128 }, { "__builtin_ia32_pmaxsw128", ND_PMAXSW128 }, { "__builtin_ia32_pmaxub128", ND_PMAXUB128 }, { "__builtin_ia32_pminsw128", ND_PMINSW128 }, { "__builtin_ia32_pminub128", ND_PMINUB128 }, { "__builtin_ia32_pmovmskb128", ND_PMOVMSKB128 }, { "__builtin_ia32_pmulhuw128", ND_PMULHUW128 }, { "__builtin_ia32_maskmovdqu", ND_MASKMOVDQU }, { "__builtin_ia32_pavgb128", ND_PAVGB128 }, { "__builtin_ia32_pavgw128", ND_PAVGW128 }, { "__builtin_ia32_psadbw128", ND_PSADBW128 }, { "__builtin_ia32_movnti", ND_MOVNTI }, { "__builtin_ia32_movnti64", ND_MOVNTI64 }, { "__builtin_ia32_movntdq", ND_MOVNTDQ }, { "__builtin_ia32_movntpd", ND_MOVNTPD }, { "__builtin_parity", ND_PARITY }, { "__builtin_parityl", ND_PARITYL }, { "__builtin_parityll", ND_PARITYLL }, }; static int builtin_enum(Token *tok) { for (size_t i = 0; i < sizeof(builtin_table) / sizeof(builtin_table[0]); i++) { if (equal(tok, builtin_table[i].name)) return builtin_table[i].node_kind; } return -1; // not found } // scalar_to_vector now marks the node as a scalar promotion static Node *scalar_to_vector(Node *scalar, Type *vec_ty) { Node *n = new_unary(ND_CAST, scalar, scalar->tok); n->ty = vec_ty; // target vector type n->is_scalar_promoted = true; // renamed flag for clarity return n; } // Promote scalars to vectors for a binary operation static void promote_scalar_to_vector(Node *node) { add_type(node->lhs); add_type(node->rhs); if (is_vector(node->rhs->ty) && !is_vector(node->lhs->ty)) { node->lhs = scalar_to_vector(node->lhs, node->rhs->ty); node->lhs->is_scalar_promoted = true; } if (is_vector(node->lhs->ty) && !is_vector(node->rhs->ty)) { node->rhs = scalar_to_vector(node->rhs, node->lhs->ty); node->rhs->is_scalar_promoted = true; } } chibicc-1.0.23.1/preprocess.c000077500000000000000000001353111505335450300156630ustar00rootroot00000000000000// This file implements the C preprocessor. // // The preprocessor takes a list of tokens as an input and returns a // new list of tokens as an output. // // The preprocessing language is designed in such a way that that's // guaranteed to stop even if there is a recursive macro. // Informally speaking, a macro is applied only once for each token. // That is, if a macro token T appears in a result of direct or // indirect macro expansion of T, T won't be expanded any further. // For example, if T is defined as U, and U is defined as T, then // token T is expanded to U and then to T and the macro expansion // stops at that point. // // To achieve the above behavior, we attach for each token a set of // macro names from which the token is expanded. The set is called // "hideset". Hideset is initially empty, and every time we expand a // macro, the macro name is added to the resulting tokens' hidesets. // // The above macro expansion algorithm is explained in this document // written by Dave Prossor, which is used as a basis for the // standard's wording: // https://github.com/rui314/chibicc/wiki/cpp.algo.pdf #include "chibicc.h" #define PREPROCESS_C "preprocess.c" typedef struct MacroParam MacroParam; struct MacroParam { MacroParam *next; char *name; }; typedef struct MacroArg MacroArg; struct MacroArg { MacroArg *next; char *name; bool is_va_args; Token *tok; }; typedef Token *macro_handler_fn(Token *); typedef struct Macro Macro; struct Macro { char *name; bool is_objlike; // Object-like or function-like or attribut-like MacroParam *params; char *va_args_name; Token *body; macro_handler_fn *handler; }; // `#if` can be nested, so we use a stack to manage nested `#if`s. typedef struct CondIncl CondIncl; struct CondIncl { CondIncl *next; enum { IN_THEN, IN_ELIF, IN_ELSE } ctx; Token *tok; bool included; }; typedef struct Hideset Hideset; struct Hideset { Hideset *next; char *name; }; static HashMap macros; static CondIncl *cond_incl; static HashMap pragma_once; static int include_next_idx; //ISS-142 extern bool opt_E; extern bool opt_fbuiltin; extern Context *ctx; static Token *preprocess2(Token *tok); static Macro *find_macro(Token *tok); static void join_adjacent_string_literals(Token *tok); static Token *paste(Token *lhs, Token *rhs); static bool file_exists_in_include_path(const char *filename); //begin static bool is_hash(Token *tok) // [https://www.sigbus.info/n1570#6.10.3.4p3] tok->origin is checked here // because "#" can appear in object-like macro, and after expansion of that // macro, it's not a preprocessing directive even it resembles one. // For example: // 1. #define H # // 2. #define I include // 3. // 4. H I // Line 4 produces these tokens: // {#} {include} {} // which are not treated as preprocessing directive. { return tok->at_bol && equal(tok, "#") && !tok->origin; } // Some preprocessor directives such as #include allow extraneous // tokens before newline. This function skips such tokens. static Token *skip_line(Token *tok) { if (tok->at_bol) return tok; warn_tok(tok, "extra token"); while (!tok->at_bol) tok = tok->next; return tok; } static Token *copy_token(Token *tok) { Token *t = calloc(1, sizeof(Token)); if (t == NULL) error("%s: %s:%d: error: in copy_token : t is null", PREPROCESS_C, __FILE__, __LINE__); *t = *tok; t->next = NULL; return t; } static Token *new_eof(Token *tok) { Token *t = copy_token(tok); t->at_bol = true; t->kind = TK_EOF; t->len = 0; return t; } static Hideset *new_hideset(char *name) { Hideset *hs = calloc(1, sizeof(Hideset)); if (hs == NULL) error("%s: %s:%d: error: in new_hideset : hs is null", PREPROCESS_C, __FILE__, __LINE__); hs->name = name; return hs; } static Hideset *hideset_union(Hideset *hs1, Hideset *hs2) { Hideset head = {}; Hideset *cur = &head; for (; hs1; hs1 = hs1->next) cur = cur->next = new_hideset(hs1->name); cur->next = hs2; return head.next; } static bool hideset_contains(Hideset *hs, char *s, int len) { for (; hs; hs = hs->next) if (strlen(hs->name) == len && !strncmp(hs->name, s, len)) return true; return false; } static Hideset *hideset_intersection(Hideset *hs1, Hideset *hs2) { Hideset head = {}; Hideset *cur = &head; for (; hs1; hs1 = hs1->next) if (hideset_contains(hs2, hs1->name, strlen(hs1->name))) cur = cur->next = new_hideset(hs1->name); return head.next; } static Token *add_hideset(Token *tok, Hideset *hs) { Token head = {}; Token *cur = &head; for (; tok; tok = tok->next) { Token *t = copy_token(tok); t->hideset = hideset_union(t->hideset, hs); cur = cur->next = t; } return head.next; } // Append tok2 to the end of tok1. static Token *append(Token *tok1, Token *tok2) { if (tok1->kind == TK_EOF) return tok2; Token head = {}; Token *cur = &head; for (; tok1->kind != TK_EOF; tok1 = tok1->next) cur = cur->next = copy_token(tok1); cur->next = tok2; return head.next; } static Token *skip_cond_incl2(Token *tok) { while (tok->kind != TK_EOF) { if (is_hash(tok) && (equal(tok->next, "if") || equal(tok->next, "ifdef") || equal(tok->next, "ifndef"))) { tok = skip_cond_incl2(tok->next->next); continue; } if (is_hash(tok) && equal(tok->next, "endif")) return tok->next->next; tok = tok->next; } return tok; } // Skip until next `#else`, `#elif` or `#endif`. // Nested `#if` and `#endif` are skipped. static Token *skip_cond_incl(Token *tok) { while (tok->kind != TK_EOF) { if (is_hash(tok) && (equal(tok->next, "if") || equal(tok->next, "ifdef") || equal(tok->next, "ifndef"))) { tok = skip_cond_incl2(tok->next->next); continue; } if (is_hash(tok) && (equal(tok->next, "elif") || equal(tok->next, "else") || equal(tok->next, "endif"))) break; tok = tok->next; } return tok; } // Double-quote a given string and returns it. static char *quote_string(char *str) { int bufsize = 3; for (int i = 0; str[i]; i++) { if (str[i] == '\\' || str[i] == '"') bufsize++; bufsize++; } char *buf = calloc(1, bufsize); if (buf == NULL) error("%s: %s:%d: error: in quote_string : buf is null", PREPROCESS_C, __FILE__, __LINE__); char *p = buf; *p++ = '"'; for (int i = 0; str[i]; i++) { if (str[i] == '\\' || str[i] == '"') *p++ = '\\'; *p++ = str[i]; } *p++ = '"'; *p++ = '\0'; return buf; } static Token *new_str_token(char *str, Token *tmpl) { char *buf = quote_string(str); return tokenize(new_file(tmpl->file->name, tmpl->file->file_no, buf)); } // Copy all tokens until the next newline, terminate them with // an EOF token and then returns them. This function is used to // create a new list of tokens for `#if` arguments. static Token *copy_line(Token **rest, Token *tok) { Token head = {}; Token *cur = &head; for (; !tok->at_bol; tok = tok->next) cur = cur->next = copy_token(tok); cur->next = new_eof(tok); *rest = tok; return head.next; } static Token *new_num_token(int val, Token *tmpl) { char *buf = format("%d\n", val); if (!buf) error_tok(tmpl, "%s: in new_num_token : buf is null", PREPROCESS_C); return tokenize(new_file(tmpl->file->name, tmpl->file->file_no, buf)); } static Token *read_const_expr(Token **rest, Token *tok) { tok = copy_line(rest, tok); Token head = {}; Token *cur = &head; while (tok->kind != TK_EOF) { // "defined(foo)" or "defined foo" becomes "1" if macro "foo" // is defined. Otherwise "0". if (equal(tok, "defined") || equal(tok, "__has_attribute")) { Token *start = tok; bool has_paren = consume(&tok, tok->next, "("); if (tok->kind != TK_IDENT) error_tok(start, "%s: in read_const_expr : macro name must be an identifier", PREPROCESS_C); Macro *m = find_macro(tok); tok = tok->next; if (has_paren) { SET_CTX(ctx); tok = skip(tok, ")", ctx); } cur = cur->next = new_num_token(m ? 1 : 0, start); continue; } else if (equal(tok, "__has_include")) { Token *start = tok; bool has_paren = consume(&tok, tok->next, "("); if (tok->kind != TK_STR && !equal(tok, "<")) error_tok(start, "%s: in read_const_expr : __has_include expects a filename", PREPROCESS_C); char filename[PATH_MAX]; if (tok->kind == TK_STR) { // __has_include("header.h") snprintf(filename, sizeof(filename), "%s", tok->str); filename[tok->len] = '\0'; tok = tok->next; } else { // __has_include() tok = tok->next; const char *start_str = tok->str; int len = 0; while (!equal(tok, ">") && tok->kind != TK_EOF) { len += tok->len; tok = tok->next; } if (!equal(tok, ">")) error_tok(start, "%s: in read_const_expr : expected closing > in __has_include", PREPROCESS_C); snprintf(filename, sizeof(filename), "%.*s", len, start_str); tok = tok->next; // consume '>' } if (has_paren) { SET_CTX(ctx); tok = skip(tok, ")", ctx); } bool found = file_exists_in_include_path(filename); cur = cur->next = new_num_token(found ? 1 : 0, start); continue; } cur = cur->next = tok; tok = tok->next; } cur->next = tok; return head.next; } // Read and evaluate a constant expression. static long eval_const_expr(Token **rest, Token *tok) { Token *start = tok; Token *expr = read_const_expr(rest, tok->next); expr = preprocess2(expr); if (expr->kind == TK_EOF) error_tok(start, "%s: in eval_const_expr : no expression", PREPROCESS_C); // [https://www.sigbus.info/n1570#6.10.1p4] The standard requires // we replace remaining non-macro identifiers with "0" before // evaluating a constant expression. For example, `#if foo` is // equivalent to `#if 0` if foo is not defined. for (Token *t = expr; t->kind != TK_EOF; t = t->next) { if (t->kind == TK_IDENT) { Token *next = t->next; *t = *new_num_token(0, t); t->next = next; } } // Convert pp-numbers to regular numbers convert_pp_tokens(expr); if (expr->ty && is_flonum(expr->ty)) error_tok(expr, "%s: in eval_const_expr : floating constant in preprocessor expression", PREPROCESS_C); Token *rest2; long val = const_expr(&rest2, expr); if (rest2->kind != TK_EOF) error_tok(rest2, "%s: in eval_const_expr : extra token", PREPROCESS_C); return val; } static CondIncl *push_cond_incl(Token *tok, bool included) { CondIncl *ci = calloc(1, sizeof(CondIncl)); if (ci == NULL) error("%s: %s:%d: error: in push_cond_incl : ci is null", PREPROCESS_C, __FILE__, __LINE__); ci->next = cond_incl; ci->ctx = IN_THEN; ci->tok = tok; ci->included = included; cond_incl = ci; return ci; } static Macro *find_macro(Token *tok) { if (tok->kind != TK_IDENT) return NULL; return hashmap_get2(¯os, tok->loc, tok->len); } static Macro *add_macro(char *name, bool is_objlike, Token *body) { Macro *m = calloc(1, sizeof(Macro)); if (m == NULL) error("%s: %s:%d: error: in add_macro : m is null", PREPROCESS_C, __FILE__, __LINE__); m->name = name; m->is_objlike = is_objlike; m->body = body; hashmap_put(¯os, name, m); return m; } static MacroParam *read_macro_params(Token **rest, Token *tok, char **va_args_name) { MacroParam head = {}; MacroParam *cur = &head; while (!equal(tok, ")")) { if (cur != &head) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } if (equal(tok, "...")) { *va_args_name = "__VA_ARGS__"; SET_CTX(ctx); *rest = skip(tok->next, ")", ctx); return head.next; } if (tok->kind != TK_IDENT) error_tok(tok, "%s in read_macro_params : expected an identifier", PREPROCESS_C); if (equal(tok->next, "...")) { *va_args_name = strndup(tok->loc, tok->len); SET_CTX(ctx); *rest = skip(tok->next->next, ")", ctx); return head.next; } MacroParam *m = calloc(1, sizeof(MacroParam)); if (m == NULL) error("%s: %s:%d: error: in read_macro_params : m is null", PREPROCESS_C, __FILE__, __LINE__); m->name = strndup(tok->loc, tok->len); cur = cur->next = m; tok = tok->next; } *rest = tok->next; return head.next; } static void read_macro_definition(Token **rest, Token *tok) { Token head = {}; Token *cur = &head; if (tok->kind != TK_IDENT) error_tok(tok, "%s: in read_macro_definition : macro name must be an identifier", PREPROCESS_C); char *name = strndup(tok->loc, tok->len); tok = tok->next; if (!tok->has_space && equal(tok, "(")) { // Function-like macro char *va_args_name = NULL; MacroParam *params = read_macro_params(&tok, tok->next, &va_args_name); //Macro *m = add_macro(name, false, copy_line(rest, tok)); while (!tok->at_bol) { if (equal(tok, "##")) { if (cur == &head) error_tok(tok, "%s: in read_macro_definition : '##' cannot appear at start of replacement list", PREPROCESS_C); if (tok->next->at_bol) error_tok(tok, "%s : in read_macro_definition : '##' cannot appear at end of replacement list", PREPROCESS_C); cur = cur->next = copy_token(tok); // ## cur = cur->next = copy_token(tok->next); // rhs tok = tok->next->next; continue; } cur = cur->next = copy_token(tok); tok = tok->next; } cur->next = new_eof(tok); *rest = tok; Macro *m = add_macro(name, false, head.next); m->params = params; m->va_args_name = va_args_name; } else { // Object-like macro while (!tok->at_bol) { if (equal(tok, "##")) { if (cur == &head) error_tok(tok, "%s: in read_macro_definition : '##' cannot appear at start of replacement list", PREPROCESS_C); if (tok->next->at_bol) error_tok(tok, "%s: in read_macro_definition : '##' cannot appear at end of replacement list", PREPROCESS_C); *cur = *paste(cur, tok->next); tok = tok->next->next; continue; } cur = cur->next = copy_token(tok); tok = tok->next; } cur->next = new_eof(tok); *rest = tok; add_macro(name, true, head.next); //add_macro(name, true, copy_line(rest, tok)); } } static MacroArg *read_macro_arg_one(Token **rest, Token *tok, bool read_rest) { Token head = {}; Token *cur = &head; int level = 0; for (;;) { if (level == 0 && equal(tok, ")")) break; if (level == 0 && !read_rest && equal(tok, ",")) break; if (tok->kind == TK_EOF) error_tok(tok, "%s: in read_macro_arg_one : premature end of input", PREPROCESS_C); if (equal(tok, "(")) level++; else if (equal(tok, ")")) level--; cur = cur->next = copy_token(tok); tok = tok->next; } cur->next = new_eof(tok); MacroArg *arg = calloc(1, sizeof(MacroArg)); if (arg == NULL) error("%s: %s:%d: error: in read_macro_arg_one : arg is null", PREPROCESS_C, __FILE__, __LINE__); arg->tok = head.next; *rest = tok; return arg; } static MacroArg * read_macro_args(Token **rest, Token *tok, MacroParam *params, char *va_args_name) { Token *start = tok; tok = tok->next->next; MacroArg head = {}; MacroArg *cur = &head; MacroParam *pp = params; for (; pp; pp = pp->next) { if (cur != &head) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } cur = cur->next = read_macro_arg_one(&tok, tok, false); cur->name = pp->name; } if (va_args_name) { MacroArg *arg; if (equal(tok, ")")) { arg = calloc(1, sizeof(MacroArg)); if (arg == NULL) error("%s: %s:%d: error: in read_macro_args : arg is null", PREPROCESS_C, __FILE__, __LINE__); arg->tok = new_eof(tok); } else { if (pp != params) { SET_CTX(ctx); tok = skip(tok, ",", ctx); } arg = read_macro_arg_one(&tok, tok, true); } arg->name = va_args_name; ; arg->is_va_args = true; cur = cur->next = arg; } else if (pp) { error_tok(start, "%s: in read_macro_args : too many arguments", PREPROCESS_C); } SET_CTX(ctx); skip(tok, ")",ctx); *rest = tok; return head.next; } static MacroArg *find_arg(MacroArg *args, Token *tok) { for (MacroArg *ap = args; ap; ap = ap->next) if (tok->len == strlen(ap->name) && !strncmp(tok->loc, ap->name, tok->len)) return ap; return NULL; } // Concatenates all tokens in `tok` and returns a new string. static char *join_tokens(Token *tok, Token *end) { // Compute the length of the resulting token. int len = 1; for (Token *t = tok; t != end && t->kind != TK_EOF; t = t->next) { if (t != tok && t->has_space) len++; len += t->len; } char *buf = calloc(1, len); if (buf == NULL) error("%s: %s:%d: error: in join_tokens : buf is null", PREPROCESS_C, __FILE__, __LINE__); // Copy token texts. int pos = 0; for (Token *t = tok; t != end && t->kind != TK_EOF; t = t->next) { if (t != tok && t->has_space) buf[pos++] = ' '; strncpy(buf + pos, t->loc, t->len); pos += t->len; } buf[pos] = '\0'; return buf; } // Concatenates all tokens in `arg` and returns a new string token. // This function is used for the stringizing operator (#). static Token *stringize(Token *hash, Token *arg) { // Create a new string token. We need to set some value to its // source location for error reporting function, so we use a macro // name token as a template. char *s = join_tokens(arg, NULL); return new_str_token(s, hash); } // Concatenate two tokens to create a new token. static Token *paste(Token *lhs, Token *rhs) { // Paste the two tokens. char *buf = format("%.*s%.*s", lhs->len, lhs->loc, rhs->len, rhs->loc); // Tokenize the resulting string. Token *tok = tokenize(new_file(lhs->file->name, lhs->file->file_no, buf)); // if (tok->next->kind != TK_EOF) // error_tok(lhs, "%s: in paste : pasting forms '%s', an invalid token", PREPROCESS_C, buf); if (tok->kind == TK_EOF || tok->next->kind != TK_EOF) { error_tok(lhs, "%s: in paste : invalid preprocessing token '%s' produced by pasting " "'%.*s' and '%.*s'", PREPROCESS_C, buf, lhs->len, lhs->loc, rhs->len, rhs->loc); } return tok; } static bool has_varargs(MacroArg *args) { for (MacroArg *ap = args; ap; ap = ap->next) if (!strcmp(ap->name, "__VA_ARGS__")) return ap->tok->kind != TK_EOF; return false; } // Replace func-like macro parameters with given arguments. static Token *subst(Macro *m, MacroArg *args) { Token head = {}; Token *cur = &head; Token *tok = m->body; while (tok->kind != TK_EOF) { // "#" followed by a parameter is replaced with stringized actuals. if (equal(tok, "#")) { MacroArg *arg = find_arg(args, tok->next); if (!arg) error_tok(tok->next, "%s: in subst : '#' is not followed by a macro parameter", PREPROCESS_C); cur = cur->next = stringize(tok, arg->tok); tok = tok->next->next; continue; } // [GNU] If __VA_ARG__ is empty, `,##__VA_ARGS__` is expanded // to the empty token list. Otherwise, its expaned to `,` and // __VA_ARGS__. if (equal(tok, ",") && equal(tok->next, "##")) { MacroArg *arg = find_arg(args, tok->next->next); if (arg && arg->is_va_args) { if (arg->tok->kind == TK_EOF) { tok = tok->next->next->next; } else { cur = cur->next = copy_token(tok); tok = tok->next->next; } continue; } } if (equal(tok, "##")) { // if (cur == &head) // error_tok(tok, "%s: in subst : '##' cannot appear at start of macro expansion", PREPROCESS_C); // if (tok->next->kind == TK_EOF) // error_tok(tok, "%s: in subst : '##' cannot appear at end of macro expansion", PREPROCESS_C); MacroArg *arg = find_arg(args, tok->next); if (arg) { if (arg->tok->kind != TK_EOF) { //*cur = *paste(cur, arg->tok); if (cur == &head) cur = cur->next = copy_token(arg->tok); else *cur = *paste(cur, arg->tok); for (Token *t = arg->tok->next; t->kind != TK_EOF; t = t->next) cur = cur->next = copy_token(t); } tok = tok->next->next; continue; } *cur = *paste(cur, tok->next); tok = tok->next->next; continue; } MacroArg *arg = find_arg(args, tok); if (arg && equal(tok->next, "##")) { Token *rhs = tok->next->next; if (arg->tok->kind == TK_EOF) { MacroArg *arg2 = find_arg(args, rhs); if (arg2) { for (Token *t = arg2->tok; t->kind != TK_EOF; t = t->next) cur = cur->next = copy_token(t); } else { cur = cur->next = copy_token(rhs); } tok = rhs->next; continue; } for (Token *t = arg->tok; t->kind != TK_EOF; t = t->next) cur = cur->next = copy_token(t); tok = tok->next; continue; } // If __VA_ARG__ is empty, __VA_OPT__(x) is expanded to the // empty token list. Otherwise, __VA_OPT__(x) is expanded to x. if (equal(tok, "__VA_OPT__") && equal(tok->next, "(")) { MacroArg *arg = read_macro_arg_one(&tok, tok->next->next, true); if (has_varargs(args)) for (Token *t = arg->tok; t->kind != TK_EOF; t = t->next) cur = cur->next = t; SET_CTX(ctx); tok = skip(tok, ")", ctx); continue; } // Handle a macro token. Macro arguments are completely macro-expanded // before they are substituted into a macro body. if (arg) { Token *t = preprocess2(arg->tok); // t->at_bol = tok->at_bol; t->has_space = tok->has_space; for (; t->kind != TK_EOF; t = t->next) cur = cur->next = copy_token(t); tok = tok->next; continue; } // Handle a non-macro token. cur = cur->next = copy_token(tok); tok = tok->next; continue; } cur->next = tok; return head.next; } // If tok is a macro, expand it and return true. // Otherwise, do nothing and return false. static bool expand_macro(Token **rest, Token *tok) { if (hideset_contains(tok->hideset, tok->loc, tok->len)) return false; Macro *m = find_macro(tok); if (!m) return false; // Built-in dynamic macro application such as __LINE__ if (m->handler) { *rest = m->handler(tok); (*rest)->next = tok->next; return true; } // Object-like macro application if (m->is_objlike) { Hideset *hs = hideset_union(tok->hideset, new_hideset(m->name)); Token *body = add_hideset(m->body, hs); for (Token *t = body; t->kind != TK_EOF; t = t->next) { t->origin = tok; } *rest = append(body, tok->next); //(*rest)->at_bol = tok->at_bol; (*rest)->has_space = tok->has_space; return true; } // If a funclike macro token is not followed by an argument list, // treat it as a normal identifier. if (!equal(tok->next, "(")) return false; // Function-like macro application Token *macro_token = tok; MacroArg *args = read_macro_args(&tok, tok, m->params, m->va_args_name); Token *rparen = tok; // Tokens that consist a func-like macro invocation may have different // hidesets, and if that's the case, it's not clear what the hideset // for the new tokens should be. We take the interesection of the // macro token and the closing parenthesis and use it as a new hideset // as explained in the Dave Prossor's algorithm. Hideset *hs = hideset_intersection(macro_token->hideset, rparen->hideset); hs = hideset_union(hs, new_hideset(m->name)); // Token *body = subst(m->body, args); // body = add_hideset(body, hs); // for (Token *t = body; t->kind != TK_EOF; t = t->next) // { // t->origin = macro_token; // } // *rest = append(body, tok->next); // //#issue 108 not sure why but this corrupts some tokens "#" that are not recognized starting at beginning of the line. // // (*rest)->at_bol = macro_token->at_bol; // (*rest)->has_space = macro_token->has_space; if (m->body->kind != TK_EOF) { // If replacement list is not empty Token *body = subst(m, args); body = add_hideset(body, hs); for (Token *t = body; t->kind != TK_EOF; t = t->next) { t->origin = macro_token; } *rest = append(body, tok->next); (*rest)->at_bol = macro_token->at_bol; (*rest)->has_space = macro_token->has_space; } else { *rest = tok->next; } return true; } char *search_include_paths(char *filename) { if (filename[0] == '/') return filename; static HashMap cache; char *cached = hashmap_get(&cache, filename); if (cached) return cached; // Search a file from the include paths. for (int i = 0; i < include_paths.len; i++) { char *path = format("%s/%s", include_paths.data[i], filename); // printf("%s\n", path); if (!file_exists(path)) continue; hashmap_put(&cache, filename, path); include_next_idx = i + 1; return path; } return NULL; } static char *search_include_next(char *filename) { for (; include_next_idx < include_paths.len; include_next_idx++) { char *path = format("%s/%s", include_paths.data[include_next_idx], filename); if (file_exists(path)) return path; } return NULL; } // Read an #include argument. static char *read_include_filename(Token **rest, Token *tok, bool *is_dquote) { // Pattern 1: #include "foo.h" if (tok->kind == TK_STR) { // A double-quoted filename for #include is a special kind of // token, and we don't want to interpret any escape sequences in it. // For example, "\f" in "C:\foo" is not a formfeed character but // just two non-control characters, backslash and f. // So we don't want to use token->str. *is_dquote = true; *rest = skip_line(tok->next); return strndup(tok->loc + 1, tok->len - 2); } // Pattern 2: #include if (equal(tok, "<")) { // Reconstruct a filename from a sequence of tokens between // "<" and ">". Token *start = tok; // Find closing ">". for (; !equal(tok, ">"); tok = tok->next) if (tok->at_bol || tok->kind == TK_EOF) { error_tok(tok, "%s: in read_include_filename : expected '>' %s", PREPROCESS_C, start->loc ); } *is_dquote = false; *rest = skip_line(tok->next); return join_tokens(start->next, tok); } // Pattern 3: #include FOO // In this case FOO must be macro-expanded to either // a single string token or a sequence of "<" ... ">". if (tok->kind == TK_IDENT) { Token *tok2 = preprocess2(copy_line(rest, tok)); return read_include_filename(&tok2, tok2, is_dquote); } error_tok(tok, "%s: in read_include_filename : expected a filename", PREPROCESS_C); } // Detect the following "include guard" pattern. // // #ifndef FOO_H // #define FOO_H // ... // #endif static char *detect_include_guard(Token *tok) { // Detect the first two lines. if (!is_hash(tok) || !equal(tok->next, "ifndef")) return NULL; tok = tok->next->next; if (tok->kind != TK_IDENT) return NULL; char *macro = strndup(tok->loc, tok->len); tok = tok->next; if (!is_hash(tok) || !equal(tok->next, "define") || !equal(tok->next->next, macro)) return NULL; // Read until the end of the file. while (tok->kind != TK_EOF) { if (!is_hash(tok)) { tok = tok->next; continue; } if (equal(tok->next, "endif") && tok->next->next->kind == TK_EOF) return macro; if (equal(tok, "if") || equal(tok, "ifdef") || equal(tok, "ifndef")) tok = skip_cond_incl(tok->next); else tok = tok->next; } return NULL; } static Token *include_file(Token *tok, char *path, Token *filename_tok) { // Check for "#pragma once" if (hashmap_get(&pragma_once, path)) return tok; // If we read the same file before, and if the file was guarded // by the usual #ifndef ... #endif pattern, we may be able to // skip the file without opening it. static HashMap include_guards; char *guard_name = hashmap_get(&include_guards, path); if (guard_name && hashmap_get(¯os, guard_name)) return tok; Token *tok2 = tokenize_file(path); if (!tok2) error_tok(filename_tok, "%s: in include_file : %s: cannot open file: %s", PREPROCESS_C, path, strerror(errno)); guard_name = detect_include_guard(tok2); if (guard_name) hashmap_put(&include_guards, path, guard_name); return append(tok2, tok); } static void print_macro(Macro *m) { FILE *out = ofile ? ofile : stdout; fprintf(out, "#define %s", m->name); if (!m->is_objlike) { fprintf(out, "("); MacroParam *p = m->params; bool first = true; while (p) { if (!first) fprintf(out, ","); fprintf(out, "%s", p->name); first = false; p = p->next; } if (m->va_args_name) { if (!first) fprintf(out, ","); fprintf(out, "..."); } fprintf(out, ")"); } Token *tok = m->body; if (tok && tok->kind != TK_EOF) fprintf(out, " "); for (; tok && tok->kind != TK_EOF; tok = tok->next) { // Add space between tokens fprintf(out, "%.*s", tok->len, tok->loc); if (tok->next && tok->next->kind != TK_EOF) fprintf(out, " "); } fprintf(out, "\n"); } // Read #line arguments static void read_line_marker(Token **rest, Token *tok) { Token *start = tok; bool isReadLine = true; tok = preprocess(copy_line(rest, tok), isReadLine); // if (isDebug && f != NULL) // print_debug_tokens(PREPROCESS_C, "read_line_marker", tok); if (tok->kind != TK_NUM && tok->ty->kind != TY_INT) error_tok(tok, "%s: in read_line_marker : invalid line marker", PREPROCESS_C); // fix issue with negative number that cause Assembler less number than one //start->file->line_delta = tok->val - start->line_no; // fix from @fuhsnn Line control off by one start->file->line_delta = tok->val - start->line_no - 1; tok = tok->next; if (tok->kind == TK_EOF) return; if (tok->kind != TK_STR) error_tok(tok, "%s: in read_line_marker : filename expected", PREPROCESS_C); start->file->display_name = tok->str; } // Visit all tokens in `tok` while evaluating preprocessing // macros and directives. static Token *preprocess2(Token *tok) { Token head = {}; Token *cur = &head; while (tok->kind != TK_EOF) { // // // If it is a macro, expand it. //if (expand_macro(&tok, tok)) if (tok->kind == TK_IDENT && !equal(tok, "__attribute__") && expand_macro(&tok, tok)) continue; // Pass through if it is not a "#". if (!is_hash(tok)) { tok->line_delta = tok->file->line_delta; tok->filename = tok->file->display_name; cur = cur->next = tok; tok = tok->next; continue; } Token *start = tok; tok = tok->next; if (equal(tok, "include")) { bool is_dquote; char *filename = read_include_filename(&tok, tok->next, &is_dquote); if (isDebug) printf("=====includes===%s\n", filename); if (filename[0] != '/' && is_dquote) { char *path = format("%s/%s", dirname(strdup(start->file->name)), filename); if (file_exists(path)) { tok = include_file(tok, path, start->next->next); continue; } } char *path = search_include_paths(filename); tok = include_file(tok, path ? path : filename, start->next->next); continue; } if (equal(tok, "include_next")) { bool ignore; char *filename = read_include_filename(&tok, tok->next, &ignore); char *path = search_include_next(filename); tok = include_file(tok, path ? path : filename, start->next->next); continue; } if (equal(tok, "define")) { read_macro_definition(&tok, tok->next); continue; } if (equal(tok, "undef")) { tok = tok->next; if (tok->kind != TK_IDENT) error_tok(tok, "%s: in preprocess2 : macro name must be an identifier", PREPROCESS_C); Macro *m = find_macro(tok); if (m) undef_macro(m->name); //undef_macro(strndup(tok->loc, tok->len)); tok = skip_line(tok->next); continue; } if (equal(tok, "if")) { long val = eval_const_expr(&tok, tok); push_cond_incl(start, val); if (!val) tok = skip_cond_incl(tok); continue; } if (equal(tok, "ifdef")) { if (tok->next->kind != TK_IDENT) error_tok(tok->next, "%s: in preprocess2 : no macro name given in #ifdef directive", PREPROCESS_C); // bool defined = find_macro(tok->next); // push_cond_incl(tok, defined); Macro *defined = find_macro(tok->next); push_cond_incl(tok, !!defined); tok = skip_line(tok->next->next); if (!defined) tok = skip_cond_incl(tok); continue; } if (equal(tok, "ifndef")) { //bool defined = find_macro(tok->next); if (tok->next->kind != TK_IDENT) error_tok(tok->next, "%s: in preprocess2 : no macro name given in #ifndef directive", PREPROCESS_C); Macro *defined = find_macro(tok->next); push_cond_incl(tok, !defined); tok = skip_line(tok->next->next); if (defined) tok = skip_cond_incl(tok); continue; } if (equal(tok, "elif")) { if (!cond_incl || cond_incl->ctx == IN_ELSE) error_tok(start, "%s: in preprocess2 : stray #elif", PREPROCESS_C); cond_incl->ctx = IN_ELIF; if (!cond_incl->included && eval_const_expr(&tok, tok)) cond_incl->included = true; else tok = skip_cond_incl(tok); continue; } if (equal(tok, "else")) { if (!cond_incl || cond_incl->ctx == IN_ELSE) error_tok(start, "%s: in preprocess2 : stray #else", PREPROCESS_C); cond_incl->ctx = IN_ELSE; tok = skip_line(tok->next); if (cond_incl->included) tok = skip_cond_incl(tok); continue; } if (equal(tok, "endif")) { if (!cond_incl) error_tok(start, "%s: in preprocess2 : stray #endif", PREPROCESS_C); cond_incl = cond_incl->next; tok = skip_line(tok->next); continue; } if (equal(tok, "line")) { read_line_marker(&tok, tok->next); // tok = skip_line(tok->next->next->next); continue; } if (tok->kind == TK_PP_NUM) { read_line_marker(&tok, tok); continue; } if (equal(tok, "pragma") && equal(tok->next, "once")) { hashmap_put(&pragma_once, tok->file->name, (void *)1); tok = skip_line(tok->next->next); continue; } if (equal(tok, "pragma")) { do { tok = tok->next; } while (!tok->at_bol); continue; } if (equal(tok, "error")) error_tok(tok, "%s: in preprocess2 : error", PREPROCESS_C); // `#`-only line is legal. It's called a null directive. if (tok->at_bol) continue; //from @fuhsnn warning management if (equal(tok, "warning")) { warn_tok(tok, "warning"); do { tok = tok->next; }while (!tok->at_bol); continue; } error_tok(tok, "%s: in preprocess2 : invalid preprocessor directive", PREPROCESS_C); } cur->next = tok; return head.next; } void define_macro(char *name, char *buf) { if (strncmp(name, "__has_attribute", 15)) { Token *tok = tokenize(new_file("", 1, buf)); add_macro(name, true, tok); } } void undef_macro(char *name) { hashmap_delete(¯os, name); } static Macro *add_builtin(char *name, macro_handler_fn *fn) { Macro *m = add_macro(name, true, NULL); m->handler = fn; return m; } static Token *file_macro(Token *tmpl) { while (tmpl->origin) tmpl = tmpl->origin; return new_str_token(tmpl->file->display_name, tmpl); } static Token *line_macro(Token *tmpl) { while (tmpl->origin) tmpl = tmpl->origin; int i = tmpl->line_no + tmpl->file->line_delta; return new_num_token(i, tmpl); } // __COUNTER__ is expanded to serial values starting from 0. static Token *counter_macro(Token *tmpl) { static int i = 0; return new_num_token(i++, tmpl); } // __TIMESTAMP__ is expanded to a string describing the last // modification time of the current file. E.g. // "Fri Jul 24 01:32:50 2020" static Token *timestamp_macro(Token *tmpl) { struct stat st; if (stat(tmpl->file->name, &st) != 0) return new_str_token("??? ??? ?? ??:??:?? ????", tmpl); char buf[30]; ctime_r(&st.st_mtime, buf); buf[24] = '\0'; return new_str_token(buf, tmpl); } static Token *builtin_atomics(Token *tmpl) { char *buf = "#include <\"stdatomic.h\""; return new_str_token(buf, tmpl); } static Token *base_file_macro(Token *tmpl) { return new_str_token(base_file, tmpl); } // __DATE__ is expanded to the current date, e.g. "May 17 2020". static char *format_date(struct tm *tm) { static char mon[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", }; return format("\"%s %2d %d\"", mon[tm->tm_mon], tm->tm_mday, tm->tm_year + 1900); } // __TIME__ is expanded to the current time, e.g. "13:34:03". static char *format_time(struct tm *tm) { return format("\"%02d:%02d:%02d\"", tm->tm_hour, tm->tm_min, tm->tm_sec); } void init_macros(void) { // Define predefined macros define_macro("__VERSION__", "\"" VERSION "\""); define_macro("__builtin_offsetof", "offsetof"); define_macro("_LP64", "1"); define_macro("__C99_MACRO_WITH_VA_ARGS", "1"); define_macro("__ELF__", "1"); define_macro("__LP64__", "1"); define_macro("__SIZEOF_DOUBLE__", "8"); define_macro("__SIZEOF_FLOAT__", "4"); define_macro("__UINTPTR_TYPE__", "unsigned long"); define_macro("__INT32_TYPE__", "int"); define_macro("__SIZEOF_INT__", "4"); define_macro("SIZEOF_INT", "4"); define_macro("__SIZEOF_LONG_DOUBLE__", "16"); define_macro("__SIZEOF_LONG_LONG__", "8"); define_macro("__SIZEOF_LONG__", "8"); define_macro("SIZEOF_LONG", "8"); define_macro("__SIZEOF_POINTER__", "8"); define_macro("__SIZEOF_PTRDIFF_T__", "8"); define_macro("__SIZEOF_SHORT__", "2"); define_macro("__SIZEOF_SIZE_T__", "8"); define_macro("__SIZEOF_WCHAR_T__", "4"); define_macro("__WCHAR_TYPE__", "int"); define_macro("__WINT_TYPE__", "unsigned int"); define_macro("__SIZE_TYPE__", "unsigned long"); define_macro("__STDC_HOSTED__", "1"); define_macro("__STDC_NO_COMPLEX__", "1"); define_macro("__STDC_UTF_16__", "1"); define_macro("__STDC_UTF_32__", "1"); define_macro("__STDC_VERSION__", "201112L"); define_macro("__STDC__", "1"); // define_macro("__STDC_IEC_559__" , "1"); // define_macro("__STDC_ISO_10646__" , "201706L"); // define_macro("__STDC_IEC_559_COMPLEX__" , "1"); // define_macro("__STDC_IEC_60559_COMPLEX__" , "201404L"); // define_macro("__STDC_IEC_60559_BFP__" , "201404L"); define_macro("__GNUC_STDC_INLINE__", "1"); define_macro("__USER_LABEL_PREFIX__", ""); define_macro("__alignof__", "_Alignof"); define_macro("__amd64", "1"); define_macro("__amd64__", "1"); define_macro("__CHIBICC__", "1"); define_macro("__chibicc__", "1"); define_macro("__const__", "const"); define_macro("__gnu_linux__", "1"); define_macro("__inline__", "inline"); define_macro("__linux", "1"); define_macro("__linux__", "1"); define_macro("__signed__", "signed"); define_macro("__typeof__", "typeof"); define_macro("__unix", "1"); define_macro("__unix__", "1"); define_macro("__volatile__", "volatile"); define_macro("__x86_64", "1"); define_macro("__x86_64__", "1"); define_macro("_GNU_SOURCE", "1"); define_macro("_DEFAULT_SOURCE", "1"); //define_macro("__INTEL_COMPILER", "1"); //define_macro("__GNUC__", "9"); define_macro("__GNUC__", "2"); //define_macro("__GNUC_MINOR__", "1"); //define_macro("__GNUC_PATCHLEVEL__ ", "1"); //define_macro("HAVE_ATTRIBUTE_PACKED", "1"); define_macro("linux", "1"); define_macro("unix", "1"); define_macro("HAVE_RECV", "1"); define_macro("HAVE_SEND", "1"); define_macro("HAVE_SYS_IO_H", "1"); define_macro("__extension__", ""); define_macro("HAVE_TEST_AND_SET", "1"); define_macro("HAVE_LONG_LONG_INT_64", "1"); define_macro("__ATOMIC_RELAXED", "0"); define_macro("__ATOMIC_CONSUME", "1"); define_macro("__ATOMIC_ACQUIRE", "2"); define_macro("__ATOMIC_RELEASE", "3"); define_macro("__ATOMIC_ACQ_REL", "4"); define_macro("__ATOMIC_SEQ_CST", "5"); define_macro("__builtin_choose_expr(cond, true_expr, false_expr)", "(cond ? true_expr : false_expr)"); define_macro("__SHRT_MAX__", "32767"); define_macro("__INT_MAX__", "2147483647"); define_macro("__LONG_MAX__", "9223372036854775807L"); define_macro("__LONG_LONG_MAX__", "9223372036854775807LL"); define_macro("__SCHAR_MAX__", "127"); define_macro("__WCHAR_MAX__", "2147483647"); define_macro("__CHAR_BIT__", "8"); define_macro("__SCHAR_MAX__", "127"); define_macro("__SHRT_MAX__", "32767"); define_macro("__INT_MAX__", "2147483647"); define_macro("__LONG_MAX__", "9223372036854775807L"); define_macro("__LONG_LONG_MAX__", "9223372036854775807LL"); define_macro("__SCHAR_WIDTH__", "8"); define_macro("__SHRT_WIDTH__", "16"); define_macro("__INT_WIDTH__", "32"); define_macro("__LONG_WIDTH__", "64"); define_macro("__LONG_LONG_WIDTH__", "64"); define_macro("__SCHAR_MIN__", "-128"); define_macro("__SHRT_MIN__", "-32768"); define_macro("__INT_MIN__", "-2147483648"); define_macro("__LONG_MIN__", "-9223372036854775808L"); define_macro("__LONG_LONG_MIN__", "-9223372036854775808LL"); define_macro("HAVE_ATTRIBUTE_PACKED", "1"); define_macro("linux", "1"); define_macro("unix", "1"); define_macro("__extension__", ""); define_macro("__has_attribute(x)", "1"); define_macro("__builtin_strlen", "strlen"); //define_macro("nonnull", "1"); //====fixing ISS-147 defining the two macros for the linux platform define_macro("__ORDER_LITTLE_ENDIAN__", "1234"); define_macro("__ORDER_BIG_ENDIAN__", "4321"); define_macro("__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__"); define_macro("USE_BUILTINS", "1"); define_macro("_Pragma(message) ", ""); // if (opt_fbuiltin) { // define_macro("memcpy", "__builtin_memcpy"); // define_macro("memset", "__builtin_memset"); // } add_builtin("__FILE__", file_macro); add_builtin("__LINE__", line_macro); add_builtin("__COUNTER__", counter_macro); add_builtin("__TIMESTAMP__", timestamp_macro); add_builtin("__BASE_FILE__", base_file_macro); add_builtin("__BUILTIN_ATOMICS__", builtin_atomics); time_t now = time(NULL); struct tm *tm = localtime(&now); define_macro("__DATE__", format_date(tm)); define_macro("__TIME__", format_time(tm)); } typedef enum { STR_NONE, STR_UTF8, STR_UTF16, STR_UTF32, STR_WIDE, } StringKind; static StringKind getStringKind(Token *tok) { if (!strcmp(tok->loc, "u8")) return STR_UTF8; switch (tok->loc[0]) { case '"': return STR_NONE; case 'u': return STR_UTF16; case 'U': return STR_UTF32; case 'L': return STR_WIDE; } unreachable(); } // Concatenate adjacent string literals into a single string literal // as per the C spec. static void join_adjacent_string_literals(Token *tok) { // First pass: If regular string literals are adjacent to wide // string literals, regular string literals are converted to a wide // type before concatenation. In this pass, we do the conversion. for (Token *tok1 = tok; tok1->kind != TK_EOF;) { if (tok1->kind != TK_STR || tok1->next->kind != TK_STR) { tok1 = tok1->next; continue; } StringKind kind = getStringKind(tok1); if (!tok1->ty){ error("%s: %s:%d: error: in join_adjacent_string_literals : tok1->ty is null", PREPROCESS_C, __FILE__, __LINE__); } Type *basety = tok1->ty->base; for (Token *t = tok1->next; t->kind == TK_STR; t = t->next) { StringKind k = getStringKind(t); if (kind == STR_NONE) { kind = k; basety = t->ty->base; } else if (k != STR_NONE && kind != k) { error_tok(t, "%s: in join_adjacent_string_literals : unsupported non-standard concatenation of string literals", PREPROCESS_C); } } if (basety->size > 1) for (Token *t = tok1; t->kind == TK_STR; t = t->next) if (t->ty->base->size == 1) *t = *tokenize_string_literal(t, basety); while (tok1->kind == TK_STR) tok1 = tok1->next; } // Second pass: concatenate adjacent string literals. for (Token *tok1 = tok; tok1->kind != TK_EOF;) { if (tok1->kind != TK_STR || tok1->next->kind != TK_STR) { tok1 = tok1->next; continue; } if (!tok1->ty){ error("%s: %s:%d: error: in join_adjacent_string_literals : tok1->ty is null", PREPROCESS_C, __FILE__, __LINE__); } Token *tok2 = tok1->next; while (tok2->kind == TK_STR) tok2 = tok2->next; int len = tok1->ty->array_len; for (Token *t = tok1->next; t != tok2; t = t->next) len = len + t->ty->array_len - 1; char *buf = calloc(tok1->ty->base->size, len); if (buf == NULL) error("%s: %s:%d: error: in join_adjacent_string_literals : buf is null", PREPROCESS_C, __FILE__, __LINE__); int i = 0; for (Token *t = tok1; t != tok2; t = t->next) { memcpy(buf + i, t->str, t->ty->size); i = i + t->ty->size - t->ty->base->size; } *tok1 = *copy_token(tok1); tok1->ty = array_of(tok1->ty->base, len); tok1->str = buf; tok1->next = tok2; tok1 = tok2; } } // Entry point function of the preprocessor. Token *preprocess(Token *tok, bool isReadLine) { tok = preprocess2(tok); // to manage issue with macro used before its definition. gcc allows it tok = preprocess3(tok); if (cond_incl && !isReadLine) error_tok(cond_incl->tok, "%s: in preprocess : unterminated conditional directive", PREPROCESS_C); convert_pp_tokens(tok); //ISS-142 temp fix if (!opt_E) { join_adjacent_string_literals(tok); } for (Token *t = tok; t; t = t->next) t->line_no += abs(t->line_delta); // fixing issue with negative number that caused assembly issue return tok; } // a temp fix to manage the fact that gcc allows that a macro was defined after their use. See issue124.c for more details Token *preprocess3(Token *tok) { Token head = {}; Token *cur = &head; // Token *start = tok; while (tok->kind != TK_EOF) { Macro *m = find_macro(tok); if (m != NULL && m->body->len == 0) { //if (expand_macro(&tok, tok)) if (tok->kind == TK_IDENT && !equal(tok, "__attribute__") && expand_macro(&tok, tok)) continue; } cur = cur->next = tok; tok = tok->next; } cur->next = tok; return head.next; } static bool file_exists_in_include_path(const char *filename) { for (int i = 0; i < include_paths.len; i++) { char path[PATH_MAX]; snprintf(path, sizeof(path), "%s/%s", include_paths.data[i], filename); if (access(path, R_OK) == 0) return true; } return false; } void print_all_macros(void) { for (int i = 0; i < macros.capacity; i++) { HashEntry *e = ¯os.buckets[i]; if (e->key) { Macro *m = (Macro *)e->val; print_macro(m); } } } chibicc-1.0.23.1/printast.c000066400000000000000000000273671505335450300153520ustar00rootroot00000000000000/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "chibicc.h" #define HASH_TABLE_SIZE 256 // Simple hash table entry typedef struct HashTableEntry { Type *type; struct HashTableEntry *next; } HashTableEntry; // Simple hash table HashTableEntry *hashTable[HASH_TABLE_SIZE]; // Hash function for Type pointer unsigned int hash(Type *ty) { return ((unsigned long)ty) % HASH_TABLE_SIZE; } // Insert Type into hash table bool insertType(Type *ty) { unsigned int index = hash(ty); HashTableEntry *entry = hashTable[index]; while (entry) { if (entry->type == ty) { return false; // Type already exists, cycle detected } entry = entry->next; } // Insert new entry HashTableEntry *newEntry = malloc(sizeof(HashTableEntry)); newEntry->type = ty; newEntry->next = hashTable[index]; hashTable[index] = newEntry; return true; } static const char kBoolStr[2][6] = {"false", "true"}; static const char kTypeKindStr[17][8] = { "VOID", "BOOL", "CHAR", "SHORT", "INT", "LONG", "INT128", "FLOAT", "DOUBLE", "LDOUBLE", "ENUM", "PTR", "FUNC", "ARRAY", "VLA", "STRUCT", "UNION", }; static const char kNodeKindStr[76][21] = { "NULL_EXPR", "ADD", "SUB", "MUL", "DIV", "NEG", "MOD", "BITAND", "BITOR", "BITXOR", "SHL", "SHR", "EQ", "NE", "LT", "LE", "ASSIGN", "COND", "COMMA", "MEMBER", "ADDR", "DEREF", "NOT", "BITNOT", "LOGAND", "LOGOR", "RETURN", "IF", "FOR", "DO", "SWITCH", "CASE", "BLOCK", "GOTO", "GOTO_EXPR", "LABEL", "LABEL_VAL", "FUNCALL", "EXPR_STMT", "STMT_EXPR", "VAR", "VLA_PTR", "NUM", "CAST", "MEMZERO", "ASM", "CAS", "EXCH", "CAS_N", "EXCH_N", "LOAD", "LOAD_N", "STORE", "STORE_N", "TESTANDSET", "TESTANDSETA", "CLEAR", "RELEASE", "FETCHADD", "FETCHSUB", "FETCHXOR", "FETCHAND", "FETCHOR", "SUBFETCH", "SYNC", "BUILTIN_MEMCPY", "BUILTIN_MEMSET", "BUILTIN_CLZ", "BUILTIN_CTZ", "POPCOUNT", "EXPECT", "RETURN_ADDR", "BUILTIN_ADD_OVERFLOW", "BUILTIN_SUB_OVERFLOW", "BUILTIN_MUL_OVERFLOW", "UNREACHABLE", }; static struct Visited { size_t i, n; intptr_t *p; } g_visited; static void PrintObj(FILE *, int, const char *, Obj *); static void PrintNode(FILE *, int, const char *, Node *); static void PrintType(FILE *, int, const char *, Type *); static void PrintAsm(FILE *f, int l, const char *s, char *a); static bool Visit(void *ptr) { size_t i; intptr_t addr = (intptr_t)ptr; for (i = 0; i < g_visited.i; ++i) { if (addr == g_visited.p[i]) { return false; } } // APPEND(&g_visited.p, &g_visited.i, &g_visited.n, &addr); return true; } static void PrintLine(FILE *f, int l, char *fmt, ...) { int i; va_list ap; for (i = 0; i < l; ++i) fputc(' ', f); va_start(ap, fmt); vfprintf(f, fmt, ap); va_end(ap); fputc('\n', f); } static void PrintBool(FILE *f, int l, const char *s, bool b) { if (!b) return; PrintLine(f, l, "%s%s", s, kBoolStr[b]); } static void PrintInt(FILE *f, int l, const char *s, long x) { if (!x) return; PrintLine(f, l, "%s%ld", s, x); } static void PrintStr(FILE *f, int l, const char *s, const char *t) { if (!t || !*t) return; PrintLine(f, l, "%s%`'s", s, t); } static void PrintTokStr(FILE *f, int l, const char *s, Token *t) { if (!t) return; PrintLine(f, l, "%s%`'.*s", s, t->len, t->loc); } static void PrintMember(FILE *f, int l, const char *s, Member *m) { if (!m) return; PrintLine(f, l, "%sMember { # %p", s, m); PrintTokStr(f, l + 2, "name: ", m->name); PrintInt(f, l + 2, "idx: ", m->idx); PrintInt(f, l + 2, "align: ", m->align); PrintInt(f, l + 2, "offset: ", m->offset); PrintBool(f, l + 2, "is_bitfield: ", m->is_bitfield); PrintInt(f, l + 2, "bit_offset: ", m->bit_offset); PrintInt(f, l + 2, "bit_width: ", m->bit_width); PrintType(f, l + 2, "ty: ", m->ty); PrintLine(f, l, "}"); } static void PrintMembers(FILE *f, int l, const char *s, Member *m) { for (; m; m = m->next) { PrintMember(f, l, s, m); } } static void PrintType(FILE *f, int l, const char *s, Type *t) { for (; t; t = t->next) { if (!insertType(t)) { //printf("Detected cycle at address: %p\n", (void *)t); break; // Exit to avoid infinite loop } if (Visit(t)) { PrintLine(f, l, "%sType { # %p", s, t); PrintLine(f, l + 2, "kind: TY_%s", kTypeKindStr[t->kind]); PrintInt(f, l + 2, "size: ", t->size); PrintInt(f, l + 2, "align: ", t->align); PrintBool(f, l + 2, "is_unsigned: ", t->is_unsigned); PrintBool(f, l + 2, "is_atomic: ", t->is_atomic); PrintType(f, l + 2, "base: ", t->base); PrintTokStr(f, l + 2, "name: ", t->name); PrintTokStr(f, l + 2, "name_pos: ", t->name_pos); PrintInt(f, l + 2, "array_len: ", t->array_len); PrintInt(f, l + 2, "vector_size: ", t->vector_size); PrintNode(f, l + 2, "vla_len: ", t->vla_len); PrintObj(f, l + 2, "vla_size: ", t->vla_size); PrintMembers(f, l + 2, "members: ", t->members); PrintBool(f, l + 2, "is_flexible: ", t->is_flexible); PrintBool(f, l + 2, "is_packed: ", t->is_packed); PrintBool(f, l + 2, "is_aligned: ", t->is_aligned); PrintBool(f, l + 2, "is_const: ", t->is_const); PrintBool(f, l + 2, "is_static: ", t->is_static); PrintType(f, l + 2, "return_ty: ", t->return_ty); PrintType(f, l + 2, "params: ", t->params); PrintBool(f, l + 2, "is_variadic: ", t->is_variadic); PrintLine(f, l, "}"); } else if (t->name) { PrintLine(f, l, "%sTY_%s %.*s # %p", s, kTypeKindStr[t->kind], t->name->len, t->name->loc, t); } else { PrintLine(f, l, "%sTY_%s # %p", s, kTypeKindStr[t->kind], t); } } } static void PrintAsm(FILE *f, int l, const char *s, char * a) { if (!a) return; PrintLine(f, l, "%sAsm { # %p", s, a); PrintStr(f, l + 2, "str: ", a); } static void PrintNode(FILE *f, int l, const char *s, Node *n) { for (; n; n = n->next) { PrintLine(f, l, "%sNode { # %p", s, n); PrintLine(f, l + 2, "kind: ND_%s", kNodeKindStr[n->kind]); PrintType(f, l + 2, "ty: ", n->ty); PrintNode(f, l + 2, "lhs: ", n->lhs); PrintNode(f, l + 2, "rhs: ", n->rhs); PrintNode(f, l + 2, "cond: ", n->cond); PrintNode(f, l + 2, "then: ", n->then); PrintNode(f, l + 2, "els: ", n->els); PrintNode(f, l + 2, "init: ", n->init); PrintNode(f, l + 2, "inc: ", n->inc); PrintNode(f, l + 2, "body: ", n->body); PrintType(f, l + 2, "func_ty: ", n->func_ty); PrintNode(f, l + 2, "args: ", n->args); PrintObj(f, l + 2, "ret_buffer: ", n->ret_buffer); PrintBool(f, l + 2, "pass_by_stack: ", n->pass_by_stack); PrintBool(f, l + 2, "realign_stack: ", n->realign_stack); PrintNode(f, l + 2, "case_next: ", n->case_next); PrintNode(f, l + 2, "default_case: ", n->default_case); PrintStr(f, l + 2, "label: ", n->label); PrintStr(f, l + 2, "unique_label: ", n->unique_label); PrintNode(f, l + 2, "goto_next: ", n->goto_next); PrintStr(f, l + 2, "brk_label: ", n->brk_label); PrintStr(f, l + 2, "cont_label: ", n->cont_label); PrintInt(f, l + 2, "begin: ", n->begin); PrintAsm(f, l + 2, "asm: ", n->asm_str); PrintInt(f, l + 2, "end: ", n->end); PrintMember(f, l + 2, "member: ", n->member); PrintObj(f, l + 2, "var: ", n->var); PrintInt(f, l + 2, "val: ", n->val); if (n->fval) PrintLine(f, l + 2, "fval: %Lf", n->fval); PrintLine(f, l, "}"); } } static void PrintRelo(FILE *f, int l, const char *s, Relocation *r) { for (; r; r = r->next) { PrintLine(f, l, "%sRelocation { # %p", s, r); PrintInt(f, l + 2, "offset: ", r->offset); if (r->label) PrintStr(f, l + 2, "label: ", *r->label); PrintInt(f, l + 2, "addend: ", r->addend); PrintLine(f, l, "}"); } } static void PrintObj(FILE *f, int l, const char *s, Obj *o) { if (!o) return; PrintLine(f, l, "%sObj { # %p", s, o); PrintStr(f, l + 2, "name: ", o->name); PrintType(f, l + 2, "ty: ", o->ty); PrintBool(f, l + 2, "is_local: ", o->is_local); PrintInt(f, l + 2, "align: ", o->align); PrintInt(f, l + 2, "offset: ", o->offset); PrintBool(f, l + 2, "is_function: ", o->is_function); PrintBool(f, l + 2, "is_definition: ", o->is_definition); PrintBool(f, l + 2, "is_static: ", o->is_static); PrintBool(f, l + 2, "is_weak: ", o->is_weak); PrintBool(f, l + 2, "is_externally_visible: ", o->is_externally_visible); PrintStr(f, l + 2, "asmname: ", o->asmname); PrintStr(f, l + 2, "section: ", o->section); PrintStr(f, l + 2, "visibility: ", o->visibility); PrintBool(f, l + 2, "is_tentative: ", o->is_tentative); //PrintBool(f, l + 2, "is_string_literal: ", o->is_string_literal); PrintBool(f, l + 2, "is_tls: ", o->is_tls); PrintStr(f, l + 2, "init_data: ", o->init_data); PrintRelo(f, l + 2, "rel: ", o->rel); PrintBool(f, l + 2, "is_inline: ", o->is_inline); PrintBool(f, l + 2, "is_aligned: ", o->is_aligned); PrintBool(f, l + 2, "is_noreturn: ", o->is_noreturn); PrintBool(f, l + 2, "is_destructor: ", o->is_destructor); PrintBool(f, l + 2, "is_constructor: ", o->is_constructor); PrintBool(f, l + 2, "is_externally_visible: ", o->is_externally_visible); PrintBool(f, l + 2, "is_no_instrument_function: ", o->is_no_instrument_function); PrintBool(f, l + 2, "is_force_align_arg_pointer: ", o->is_force_align_arg_pointer); PrintBool(f, l + 2, "is_no_caller_saved_registers: ", o->is_no_caller_saved_registers); PrintInt(f, l + 2, "stack_size: ", o->stack_size); PrintObj(f, l + 2, "params: ", o->params); PrintNode(f, l + 2, "body: ", o->body); PrintObj(f, l + 2, "locals: ", o->locals); PrintObj(f, l + 2, "va_area: ", o->va_area); PrintObj(f, l + 2, "alloca_bottom: ", o->alloca_bottom); PrintBool(f, l + 2, "is_live: ", o->is_live); PrintBool(f, l + 2, "is_root: ", o->is_root); PrintLine(f, l, "}"); } void print_ast(FILE *f, Obj *o) { for (; o ; o = o->next) { PrintObj(f, 0, "", o); } }chibicc-1.0.23.1/pvs.sh000077500000000000000000000002621505335450300144720ustar00rootroot00000000000000pvs-studio-analyzer trace -- make pvs-studio-analyzer analyze -f ./strace_out plog-converter -a GA:1,2 -t tasklist -o report.tasks ./PVS-Studio.log rm strace_out PVS-Studio.log chibicc-1.0.23.1/report.tasks000077500000000000000000000050331505335450300157110ustar00rootroot00000000000000pvs-studio.com/en/docs/warnings/ 1 err Help: The documentation for all analyzer warnings is available here: https://pvs-studio.com/en/docs/warnings/. /home/stormalf/tests_c/chibicc/main.c 44 warn V707 Giving short names to global variables is considered to be bad practice. It is suggested to rename 'f' variable. /home/stormalf/tests_c/chibicc/main.c 86 warn V575 The potential null pointer is passed into 'dirname' function. Inspect the first argument. Check lines: 86, 86. /home/stormalf/tests_c/chibicc/parse.c 843 warn V1004 The 'ty->base' pointer was used unsafely after it was verified against nullptr. Check lines: 836, 843. /home/stormalf/tests_c/chibicc/parse.c 1574 warn V773 The return value of function 'write_gvar_data' is required to be utilized. A memory leak is possible. /home/stormalf/tests_c/chibicc/parse.c 2014 warn V1070 Signed value is converted to an unsigned one with subsequent expansion to a larger type in ternary operator. /home/stormalf/tests_c/chibicc/parse.c 2015 warn V1070 Signed value is converted to an unsigned one with subsequent expansion to a larger type in ternary operator. /home/stormalf/tests_c/chibicc/parse.c 2016 warn V1070 Signed value is converted to an unsigned one with subsequent expansion to a larger type in ternary operator. /home/stormalf/tests_c/chibicc/parse.c 2505 err V595 The 'lhs->ty->base' pointer was utilized before it was verified against nullptr. Check lines: 2505, 2513. /home/stormalf/tests_c/chibicc/parse.c 3395 warn V576 Incorrect format. Consider checking the third actual argument of the 'error_tok' function. Under certain conditions the pointer can be null. /home/stormalf/tests_c/chibicc/chibicc.h 159 warn V1071 Consider inspecting the 'skip' function. The return value is not always used. Total calls: 96, discarded results: 1. /home/stormalf/tests_c/chibicc/parse.c 132 warn V1071 Consider inspecting the 'assign' function. The return value is not always used. Total calls: 26, discarded results: 1. /home/stormalf/tests_c/chibicc/preprocess.c 470 warn V547 Expression 'pp' is always false. /home/stormalf/tests_c/chibicc/preprocess.c 894 warn V575 The potential null pointer is passed into 'dirname' function. Inspect the first argument. Check lines: 894, 894. /home/stormalf/tests_c/chibicc/tokenize.c 812 warn V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'input_files' is lost. Consider assigning realloc() to a temporary pointer. /home/stormalf/tests_c/chibicc/type.c 199 warn V1037 Two or more case-branches perform the same actions. Check lines: 199, 238 chibicc-1.0.23.1/strings.c000077500000000000000000000030041505335450300151600ustar00rootroot00000000000000#include "chibicc.h" #define STRINGS_C "strings.c" // void strarray_push(StringArray *arr, char *s) { // if (!arr->data) { // arr->data = calloc(8, sizeof(char *)); // arr->capacity = 8; // } // if (arr->capacity == arr->len) { // char **tmp; // tmp = realloc(arr->data, sizeof(char *) * arr->capacity * 2); // if (tmp == NULL) // error("%s: %s:%d: error: in strarray_push reallocation of arr->data failed!", STRINGS_C, __FILE__, __LINE__); // arr->data = tmp; // arr->capacity *= 2; // for (int i = arr->len; i < arr->capacity; i++) { // arr->data[i] = NULL; // } // } // arr->data[arr->len++] = s; // } void strarray_push(StringArray *arr, char *s) { if (!arr->data) { arr->data = calloc(8, sizeof(char *)); arr->capacity = 8; } if (arr->capacity == arr->len) { char **tmp = realloc(arr->data, sizeof(char *) * arr->capacity * 2); if (tmp == NULL) error("%s: %s:%d: error: in strarray_push reallocation of arr->data failed!", STRINGS_C, __FILE__, __LINE__); arr->data = tmp; arr->capacity *= 2; } arr->data[arr->len++] = s; } // Takes a printf-style format string and returns a formatted string. char *format(const char *fmt, ...) { char *buf; size_t buflen; FILE *out = open_memstream(&buf, &buflen); if (out == NULL) error("%s: %s:%d: error: in strarray_push out is null", STRINGS_C, __FILE__, __LINE__); va_list ap; va_start(ap, fmt); vfprintf(out, fmt, ap); va_end(ap); fclose(out); return buf; } chibicc-1.0.23.1/test.log000066400000000000000000006343351505335450300150230ustar00rootroot00000000000000test/int128.c:42: error: __int128 end, __int128 got, const char *gotcode, bool isfatal) { ^ parse.c 6574: in primary : error: undefined variable isfatal) { } void testLang128(void) { lotsOfArgs(__FILE__, __LINE__, __FUNCTION__, 0, 0, 0, "", false); ASSERT(16, sizeof(__int128)); ASSERT(16, sizeof(unsigned __int128)); ASSERT(16, _Alignof(__int128)); ASSERT(16, ({ struct T { __int128 x; }; _Alignof(struct T); })); ASSERT(2, ({ struct __attribute__((__aligned__(2))) T { __int128 x; }; _Alignof(struct T); })); ASSERT128(7, ({ __int128 i = 2; i += 5; i; })); ASSERT128(I128(0xffffffffffffffff, 0xffffffffffffffff), ({ __int128 i = 0; add128(i, -1); })); ASSERT128(I128(0x3a8eaaa2e9af03f5, 0xd7ed730a55920176), sub128x5(I128(0x0db9cd085ab6ba38, 0xdaf9c05f15896b5f), I128(0xb6429ba7b5b38454, 0x4061839d268a0a78), I128(0x19a0da005190a5ac, 0x755fa06484419e38), I128(0xafc6e44400b9eadd, 0x05e5afdb2e66cdb8), I128(0x5380c8796909a165, 0x47657977e6c4f381))); ASSERT128(I128(0x1f1b109234418f84, 0x21f9f24c8535e4f0), sub128x6(0x5ab6ba38, I128(0x0db9cd085ab6ba38, 0xdaf9c05f15896b5f), I128(0xb6429ba7b5b38454, 0x4061839d268a0a78), I128(0x19a0da005190a5ac, 0x755fa06484419e38), I128(0xafc6e44400b9eadd, 0x05e5afdb2e66cdb8), I128(0x5380c8796909a165, 0x47657977e6c4f381))); } void testCompare128(void) { __int128 x = 1, y = 2; ASSERT(0, x == y); ASSERT(1, x != y); ASSERT(1, x < y); ASSERT(1, x <= y); ASSERT(0, x > y); ASSERT(0, x >= y); ASSERT(1, x >= x); x = I128(-1ul, 2); y = I128(0xfffffffffffffff0, 2); ASSERT(0, x == y); } void testCastDblInt128(void) { int k; double f; __int128 i, w; k = 110; i = 1; i <<= k; f = i; f /= 2; i = f; w = 1; w <<= k - 1; ASSERT128(w, i); } void testCastDblUint128(void) { double f; unsigned __int128 i; i = 0x0000ffffffffffff; ++i; f = i; --f; i = f; --i; ASSERT128(0x0000fffffffffffe, i); } void testCastLdblInt128(void) { int k; __int128 i, w; long double f; k = 110; i = 1; i <<= k; f = i; f /= 2; i = f; w = 1; w <<= k - 1; ASSERT128(w, i); } void testCastLdblUint128(void) { long double f; unsigned __int128 i; i = 0xffffffffffffffff; ++i; f = i; --f; i = f; --i; ASSERT128(0xfffffffffffffffe, i); } void testAdd128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x + y); x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 2), x + y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, BANE), x + y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x + y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x + y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x + y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x + y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x + y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x + y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x + y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x + y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x + y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x + y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x + y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x + y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(0, 2); y = I128(0, 0); ASSERT128(I128(0, 2), x + y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 4), x + y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, BANE2), x + y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(1, 1), x + y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x + y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(2, 4), x + y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x + y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(3, 1), x + y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x + y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 4), x + y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x + y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 1), x + y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x + y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 4), x + y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x + y); x = I128(0, BANE); y = I128(0, 0); ASSERT128(I128(0, BANE), x + y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, BANE2), x + y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(1, 0), x + y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(1, IMAX), x + y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x + y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x + y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(3, 0), x + y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(3, IMAX), x + y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x + y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x + y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE1, 0), x + y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x + y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x + y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, IMAX), x + y); x = I128(0, -1ul); y = I128(0, 0); ASSERT128(I128(0, -1ul), x + y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(1, 1), x + y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(1, IMAX), x + y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x + y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x + y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(3, 1), x + y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(3, IMAX), x + y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(3, 0xfffffffffffffffe), x + y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x + y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE1, 1), x + y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x + y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x + y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x + y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x + y); x = I128(2, 0); y = I128(0, 0); ASSERT128(I128(2, 0), x + y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(2, 2), x + y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(2, BANE), x + y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x + y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(4, 0), x + y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(4, 2), x + y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(4, BANE), x + y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(4, -1ul), x + y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x + y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x + y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x + y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x + y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(1, 2), x + y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(1, BANE), x + y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(1, -1ul), x + y); x = I128(2, 2); y = I128(0, 0); ASSERT128(I128(2, 2), x + y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 4), x + y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(2, BANE2), x + y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(3, 1), x + y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(4, 2), x + y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(4, 4), x + y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(4, BANE2), x + y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(5, 1), x + y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x + y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 4), x + y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(1, 2), x + y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(1, 4), x + y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(1, BANE2), x + y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 1), x + y); x = I128(2, BANE); y = I128(0, 0); ASSERT128(I128(2, BANE), x + y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, BANE2), x + y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(3, 0), x + y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(3, IMAX), x + y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(4, BANE), x + y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(4, BANE2), x + y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(5, 0), x + y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(5, IMAX), x + y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x + y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x8000000000000003, 0), x + y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(1, BANE), x + y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(1, BANE2), x + y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x + y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, IMAX), x + y); x = I128(2, -1ul); y = I128(0, 0); ASSERT128(I128(2, -1ul), x + y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(3, 1), x + y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(3, IMAX), x + y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(3, 0xfffffffffffffffe), x + y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(4, -1ul), x + y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(5, 1), x + y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(5, IMAX), x + y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(5, 0xfffffffffffffffe), x + y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0x8000000000000003, 0xfffffffffffffffe), x + y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, -1ul), x + y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 1), x + y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(2, IMAX), x + y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x + y); x = I128(BANE, 0); y = I128(0, 0); ASSERT128(I128(BANE, 0), x + y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(BANE, 2), x + y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x + y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x + y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(BANE2, 0), x + y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x + y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x + y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x + y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 2), x + y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x + y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x + y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 0), x + y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 2), x + y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE), x + y); x = I128(BANE, 0); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(BANE, 2); y = I128(0, 0); ASSERT128(I128(BANE, 2), x + y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 4), x + y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(BANE, BANE2), x + y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE1, 1), x + y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(BANE2, 2), x + y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(BANE2, 4), x + y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x + y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 4), x + y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, BANE2), x + y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(1, 1), x + y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 2), x + y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 4), x + y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 1), x + y); x = I128(BANE, BANE); y = I128(0, 0); ASSERT128(I128(BANE, BANE), x + y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, BANE2), x + y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE1, 0), x + y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(BANE2, BANE), x + y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0x8000000000000003, 0), x + y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x + y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE2), x + y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x + y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(1, IMAX), x + y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(IMAX, BANE), x + y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x + y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, IMAX), x + y); x = I128(BANE, -1ul); y = I128(0, 0); ASSERT128(I128(BANE, -1ul), x + y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE1, 1), x + y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x + y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000003, 0xfffffffffffffffe), x + y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x + y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(1, 1), x + y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(1, IMAX), x + y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x + y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE, 1), x + y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, IMAX), x + y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 0xfffffffffffffffe), x + y); x = I128(-1ul, 0); y = I128(0, 0); ASSERT128(I128(-1ul, 0), x + y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x + y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x + y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(1, 0), x + y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(1, 2), x + y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(1, BANE), x + y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(1, -1ul), x + y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x + y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(IMAX, 2), x + y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x + y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x + y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 2), x + y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE), x + y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0xfffffffffffffffe, -1ul), x + y); x = I128(-1ul, 2); y = I128(0, 0); ASSERT128(I128(-1ul, 2), x + y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 4), x + y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 1), x + y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(1, 2), x + y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(1, 4), x + y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(1, BANE2), x + y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(2, 1), x + y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x + y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 4), x + y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 1), x + y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 2), x + y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x + y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE2), x + y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x + y); x = I128(-1ul, BANE); y = I128(0, 0); ASSERT128(I128(-1ul, BANE), x + y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x + y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, IMAX), x + y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(1, BANE), x + y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(1, BANE2), x + y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(2, 0), x + y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(2, IMAX), x + y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x + y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x + y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, IMAX), x + y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, BANE), x + y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, BANE2), x + y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x + y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(0, 0); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x + y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x + y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(1, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(2, 1), x + y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(2, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x + y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, 1), x + y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0xfffffffffffffffe), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 1), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x + y); } void testSub128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x - y); x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), x - y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 1), x - y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x - y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x - y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 1), x - y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x - y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x - y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x - y); x = I128(0, 2); y = I128(0, 0); ASSERT128(I128(0, 2), x - y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x - y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 2), x - y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE2), x - y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 3), x - y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x - y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x - y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE2), x - y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 3), x - y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(1, 2), x - y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(1, 0), x - y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE2), x - y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 3), x - y); x = I128(0, BANE); y = I128(0, 0); ASSERT128(I128(0, BANE), x - y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x - y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, BANE), x - y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(IMAX2, BANE1), x - y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x - y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x - y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, BANE1), x - y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(1, BANE), x - y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(1, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(1, 0), x - y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE1), x - y); x = I128(0, -1ul); y = I128(0, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x - y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, -1ul), x - y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, IMAX2), x - y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffe, IMAX), x - y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x - y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, IMAX2), x - y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, IMAX), x - y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x - y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, -1ul), x - y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(1, IMAX2), x - y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(1, IMAX), x - y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(1, 0), x - y); x = I128(2, 0); y = I128(0, 0); ASSERT128(I128(2, 0), x - y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(1, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(1, BANE), x - y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(1, 1), x - y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x - y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE1, BANE), x - y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 1), x - y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(3, 0), x - y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(2, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x - y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(2, 1), x - y); x = I128(2, 2); y = I128(0, 0); ASSERT128(I128(2, 2), x - y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 0), x - y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(1, BANE2), x - y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(1, 3), x - y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x - y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x - y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x - y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE1, BANE2), x - y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 3), x - y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(3, 2), x - y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(3, 0), x - y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE2), x - y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 3), x - y); x = I128(2, BANE); y = I128(0, 0); ASSERT128(I128(2, BANE), x - y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(2, 0), x - y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(1, BANE1), x - y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x - y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x - y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x - y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, BANE1), x - y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(3, BANE), x - y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(3, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(3, 0), x - y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, BANE1), x - y); x = I128(2, -1ul); y = I128(0, 0); ASSERT128(I128(2, -1ul), x - y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(2, IMAX2), x - y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(2, IMAX), x - y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(2, 0), x - y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x - y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x - y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE2, IMAX2), x - y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE2, IMAX), x - y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(3, -1ul), x - y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(3, IMAX2), x - y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(3, IMAX), x - y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(3, 0), x - y); x = I128(BANE, 0); y = I128(0, 0); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x - y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(IMAX, 1), x - y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffd, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x - y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, 1), x - y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x - y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(BANE1, 0), x - y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x - y); x = I128(BANE, 0); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 1), x - y); x = I128(BANE, 2); y = I128(0, 0); ASSERT128(I128(BANE, 2), x - y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE2), x - y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(IMAX, 3), x - y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, 2), x - y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE2), x - y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, 3), x - y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x - y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x - y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(BANE1, 2), x - y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0), x - y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE2), x - y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 3), x - y); x = I128(BANE, BANE); y = I128(0, 0); ASSERT128(I128(BANE, BANE), x - y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(IMAX, BANE1), x - y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, BANE), x - y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffe, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE1), x - y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x - y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x - y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE1, BANE), x - y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE1, 0), x - y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, BANE1), x - y); x = I128(BANE, -1ul); y = I128(0, 0); ASSERT128(I128(BANE, -1ul), x - y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE, IMAX), x - y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, -1ul), x - y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffe, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffe, IMAX), x - y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x - y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(BANE1, -1ul), x - y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE1, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE1, IMAX), x - y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE1, 0), x - y); x = I128(-1ul, 0); y = I128(0, 0); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0xfffffffffffffffe, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE), x - y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 1), x - y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffc, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffc, BANE), x - y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, 1), x - y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0x7ffffffffffffffe, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE), x - y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x - y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x - y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(-1ul, 2); y = I128(0, 0); ASSERT128(I128(-1ul, 2), x - y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE2), x - y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 3), x - y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(IMAX2, 2), x - y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffc, BANE2), x - y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, 3), x - y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x - y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE2), x - y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 3), x - y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x - y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x - y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(-1ul, BANE); y = I128(0, 0); ASSERT128(I128(-1ul, BANE), x - y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, BANE1), x - y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(IMAX2, BANE), x - y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(IMAX2, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, BANE1), x - y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x - y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, BANE1), x - y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x - y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x - y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(-1ul, -1ul); y = I128(0, 0); ASSERT128(I128(-1ul, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(IMAX2, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(IMAX2, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x - y); } void testMul128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 4), x * y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x * y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(4, 4), x * y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(5, 0), x * y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(5, 0xfffffffffffffffe), x * y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 4), x * y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x * y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x * y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(0, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(1, 0), x * y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(1, 0), x * y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(1, 0), x * y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0), x * y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(0, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 1), x * y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, 1), x * y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x * y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x * y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x * y); x = I128(2, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(4, 4), x * y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x * y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0x0000000000000008, 4), x * y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(5, 0), x * y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(3, 0xfffffffffffffffe), x * y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(4, 4), x * y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x * y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(2, 4), x * y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x * y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x * y); x = I128(2, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(5, 0), x * y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(5, 0), x * y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(5, 0), x * y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(0x8000000000000005, 0), x * y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, BANE), x * y); x = I128(2, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(5, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffc, 1), x * y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(3, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffa, 1), x * y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0x8000000000000005, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffc, 1), x * y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0x0000000000000006, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x * y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 1), x * y); x = I128(BANE, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 4), x * y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x * y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(4, 4), x * y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(5, 0), x * y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000005, 0xfffffffffffffffe), x * y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 4), x * y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x * y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x * y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x * y); x = I128(BANE, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(1, 0), x * y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(1, 0), x * y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(1, 0), x * y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0), x * y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(BANE, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x * y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffc, 1), x * y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0xfffffffffffffffe, 1), x * y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x * y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 1), x * y); x = I128(-1ul, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(BANE1, 0), x * y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(2, 4), x * y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0x8000000000000005, 0), x * y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0x0000000000000006, 0xfffffffffffffffe), x * y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE1, 0), x * y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffc, 4), x * y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, 0), x * y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x * y); x = I128(-1ul, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, 0), x * y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE, BANE), x * y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, 0), x * y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(BANE, BANE), x * y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0), x * y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x * y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 0), x * y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x * y); x = I128(-1ul, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, 1), x * y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), x * y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 1), x * y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 1), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x * y); } void testDiv128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 1), x / y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x / y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(1, 0), x / y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffc), x / y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x / y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(1, 1), x / y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffc), x / y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x / y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(1, 0x4000000000000000), x / y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffb), x / y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, BANE), x / y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(1, IMAX), x / y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 3), x / y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, IMAX2), x / y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffb), x / y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 1), x / y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, 0), x / y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, 0), x / y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000000), x / y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xcccccccccccccccd), x / y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(1, 0), x / y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, 1), x / y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, 1), x / y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xcccccccccccccccd), x / y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, -1ul), x / y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x / y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, 1), x / y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xcccccccccccccccd), x / y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, -1ul), x / y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, BANE), x / y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, BANE), x / y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, 2), x / y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE1), x / y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xccccccccccccccce), x / y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0xfffffffffffffffe), x / y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 1), x / y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, BANE), x / y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x / y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, BANE1), x / y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x / y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, 0xc000000000000000), x / y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x / y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x / y); } void testDivu128(void) { unsigned __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 1), x / y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(1, 0), x / y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(1, 1), x / y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(1, 0x4000000000000000), x / y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(1, IMAX), x / y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 3), x / y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, 0), x / y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(1, 0), x / y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0, 0x3fffffffffffffff), x / y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x / y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, 1), x / y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x / y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0, 0x3fffffffffffffff), x / y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x / y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(1, 1), x / y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x / y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, IMAX), x / y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(1, 1), x / y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaab), x / y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(IMAX, BANE), x / y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(1, 0xfffffffffffffffe), x / y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(IMAX, BANE1), x / y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(1, 0xfffffffffffffffe), x / y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(IMAX, 0xc000000000000000), x / y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(1, -1ul), x / y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(IMAX, -1ul), x / y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(1, -1ul), x / y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(1, 1), x / y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x / y); } void testRem128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x % y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 4), x % y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 4), x % y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0x0000000000000006), x % y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE2), x % y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0x8000000000000004), x % y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 5), x % y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0x7ffffffffffffffe), x % y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0xd555555555555556), x % y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x % y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 1), x % y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x % y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 2), x % y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, BANE), x % y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0xd555555555555558), x % y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 3), x % y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, BANE), x % y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0xfffffffffffffffe), x % y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0x5555555555555556), x % y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE1), x % y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, -1ul), x % y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0x7ffffffffffffffd), x % y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, -1ul), x % y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0xd555555555555555), x % y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x % y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); } void testRemu128(void) { unsigned __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 4), x % y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE2), x % y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(2, -1ul), x % y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(1, BANE2), x % y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0x2aaaaaaaaaaaaaaa), x % y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(0, BANE2), x % y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(1, 0x8000000000000004), x % y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0, BANE2), x % y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(2, 0x2aaaaaaaaaaaaaac), x % y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x % y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 1), x % y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(1, 0), x % y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(2, 0xaaaaaaaaaaaaaaaa), x % y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX), x % y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(1, IMAX), x % y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x % y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, -1ul), x % y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(1, 0), x % y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x % y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0x7ffffffffffffffe, 0xfffffffffffffffe), x % y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE), x % y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x % y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(1, 2), x % y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(0, 4), x % y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555557), x % y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE2), x % y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 3), x % y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(1, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE2), x % y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0xd555555555555555), x % y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0x7ffffffffffffffe), x % y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, BANE1), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(1, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(1, 1), x % y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(1, 0x5555555555555554), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), x % y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), x % y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); } void testShr128(void) { unsigned __int128 x; x = I128(0, 0); x >>= 0; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 1; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 0; ASSERT128(I128(0, 2), x); x = I128(0, 2); x >>= 1; ASSERT128(I128(0, 1), x); x = I128(0, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 0; ASSERT128(I128(0, BANE), x); x = I128(0, BANE); x >>= 1; ASSERT128(I128(0, 0x4000000000000000), x); x = I128(0, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 0; ASSERT128(I128(0, -1ul), x); x = I128(0, -1ul); x >>= 1; ASSERT128(I128(0, IMAX), x); x = I128(0, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 0; ASSERT128(I128(2, 0), x); x = I128(2, 0); x >>= 1; ASSERT128(I128(1, 0), x); x = I128(2, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 0; ASSERT128(I128(2, 2), x); x = I128(2, 2); x >>= 1; ASSERT128(I128(1, 1), x); x = I128(2, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 0; ASSERT128(I128(2, BANE), x); x = I128(2, BANE); x >>= 1; ASSERT128(I128(1, 0x4000000000000000), x); x = I128(2, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 0; ASSERT128(I128(2, -1ul), x); x = I128(2, -1ul); x >>= 1; ASSERT128(I128(1, IMAX), x); x = I128(2, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x >>= 0; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x >>= 1; ASSERT128(I128(0x4000000000000000, 0), x); x = I128(BANE, 0); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, 0); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(BANE, 2); x >>= 0; ASSERT128(I128(BANE, 2), x); x = I128(BANE, 2); x >>= 1; ASSERT128(I128(0x4000000000000000, 1), x); x = I128(BANE, 2); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, 2); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(BANE, BANE); x >>= 0; ASSERT128(I128(BANE, BANE), x); x = I128(BANE, BANE); x >>= 1; ASSERT128(I128(0x4000000000000000, 0x4000000000000000), x); x = I128(BANE, BANE); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, BANE); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(BANE, -1ul); x >>= 0; ASSERT128(I128(BANE, -1ul), x); x = I128(BANE, -1ul); x >>= 1; ASSERT128(I128(0x4000000000000000, IMAX), x); x = I128(BANE, -1ul); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, -1ul); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, 0); x >>= 0; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, 0); x >>= 1; ASSERT128(I128(IMAX, BANE), x); x = I128(-1ul, 0); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, 0); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, 2); x >>= 0; ASSERT128(I128(-1ul, 2), x); x = I128(-1ul, 2); x >>= 1; ASSERT128(I128(IMAX, BANE1), x); x = I128(-1ul, 2); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, 2); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, BANE); x >>= 0; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, BANE); x >>= 1; ASSERT128(I128(IMAX, 0xc000000000000000), x); x = I128(-1ul, BANE); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, BANE); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, -1ul); x >>= 0; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 1; ASSERT128(I128(IMAX, -1ul), x); x = I128(-1ul, -1ul); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, -1ul); x >>= 127; ASSERT128(I128(0, 1), x); } void testSar128(void) { __int128 x; x = I128(0, 0); x >>= 0; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 1; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 0; ASSERT128(I128(0, 2), x); x = I128(0, 2); x >>= 1; ASSERT128(I128(0, 1), x); x = I128(0, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 0; ASSERT128(I128(0, BANE), x); x = I128(0, BANE); x >>= 1; ASSERT128(I128(0, 0x4000000000000000), x); x = I128(0, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 0; ASSERT128(I128(0, -1ul), x); x = I128(0, -1ul); x >>= 1; ASSERT128(I128(0, IMAX), x); x = I128(0, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 0; ASSERT128(I128(2, 0), x); x = I128(2, 0); x >>= 1; ASSERT128(I128(1, 0), x); x = I128(2, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 0; ASSERT128(I128(2, 2), x); x = I128(2, 2); x >>= 1; ASSERT128(I128(1, 1), x); x = I128(2, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 0; ASSERT128(I128(2, BANE), x); x = I128(2, BANE); x >>= 1; ASSERT128(I128(1, 0x4000000000000000), x); x = I128(2, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 0; ASSERT128(I128(2, -1ul), x); x = I128(2, -1ul); x >>= 1; ASSERT128(I128(1, IMAX), x); x = I128(2, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x >>= 0; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x >>= 1; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(BANE, 0); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, 0); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(BANE, 2); x >>= 0; ASSERT128(I128(BANE, 2), x); x = I128(BANE, 2); x >>= 1; ASSERT128(I128(0xc000000000000000, 1), x); x = I128(BANE, 2); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, 2); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(BANE, BANE); x >>= 0; ASSERT128(I128(BANE, BANE), x); x = I128(BANE, BANE); x >>= 1; ASSERT128(I128(0xc000000000000000, 0x4000000000000000), x); x = I128(BANE, BANE); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, BANE); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(BANE, -1ul); x >>= 0; ASSERT128(I128(BANE, -1ul), x); x = I128(BANE, -1ul); x >>= 1; ASSERT128(I128(0xc000000000000000, IMAX), x); x = I128(BANE, -1ul); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, -1ul); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 0); x >>= 0; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, 0); x >>= 1; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, 0); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 0); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 2); x >>= 0; ASSERT128(I128(-1ul, 2), x); x = I128(-1ul, 2); x >>= 1; ASSERT128(I128(-1ul, BANE1), x); x = I128(-1ul, 2); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 2); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, BANE); x >>= 0; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, BANE); x >>= 1; ASSERT128(I128(-1ul, 0xc000000000000000), x); x = I128(-1ul, BANE); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, BANE); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 0; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 1; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); } void testShl128(void) { __int128 x; x = I128(0, 0); x <<= 0; ASSERT128(I128(0, 0), x); x = I128(0, 0); x <<= 1; ASSERT128(I128(0, 0), x); x = I128(0, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(0, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(0, 2); x <<= 0; ASSERT128(I128(0, 2), x); x = I128(0, 2); x <<= 1; ASSERT128(I128(0, 4), x); x = I128(0, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(0, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x <<= 0; ASSERT128(I128(0, BANE), x); x = I128(0, BANE); x <<= 1; ASSERT128(I128(1, 0), x); x = I128(0, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x <<= 0; ASSERT128(I128(0, -1ul), x); x = I128(0, -1ul); x <<= 1; ASSERT128(I128(1, 0xfffffffffffffffe), x); x = I128(0, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(0, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); x = I128(2, 0); x <<= 0; ASSERT128(I128(2, 0), x); x = I128(2, 0); x <<= 1; ASSERT128(I128(4, 0), x); x = I128(2, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(2, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(2, 2); x <<= 0; ASSERT128(I128(2, 2), x); x = I128(2, 2); x <<= 1; ASSERT128(I128(4, 4), x); x = I128(2, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(2, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x <<= 0; ASSERT128(I128(2, BANE), x); x = I128(2, BANE); x <<= 1; ASSERT128(I128(5, 0), x); x = I128(2, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x <<= 0; ASSERT128(I128(2, -1ul), x); x = I128(2, -1ul); x <<= 1; ASSERT128(I128(5, 0xfffffffffffffffe), x); x = I128(2, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(2, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x <<= 0; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x <<= 1; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, 2); x <<= 0; ASSERT128(I128(BANE, 2), x); x = I128(BANE, 2); x <<= 1; ASSERT128(I128(0, 4), x); x = I128(BANE, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, BANE); x <<= 0; ASSERT128(I128(BANE, BANE), x); x = I128(BANE, BANE); x <<= 1; ASSERT128(I128(1, 0), x); x = I128(BANE, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(BANE, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, -1ul); x <<= 0; ASSERT128(I128(BANE, -1ul), x); x = I128(BANE, -1ul); x <<= 1; ASSERT128(I128(1, 0xfffffffffffffffe), x); x = I128(BANE, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(BANE, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); x = I128(-1ul, 0); x <<= 0; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, 0); x <<= 1; ASSERT128(I128(0xfffffffffffffffe, 0), x); x = I128(-1ul, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(-1ul, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(-1ul, 2); x <<= 0; ASSERT128(I128(-1ul, 2), x); x = I128(-1ul, 2); x <<= 1; ASSERT128(I128(0xfffffffffffffffe, 4), x); x = I128(-1ul, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(-1ul, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(-1ul, BANE); x <<= 0; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, BANE); x <<= 1; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(-1ul, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(-1ul, -1ul); x <<= 0; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x <<= 1; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(-1ul, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(-1ul, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); } void testNeg128(void) { __int128 x; x = I128(0, 0); ASSERT128(I128(0, 0), -x); x = I128(0, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), -x); x = I128(0, BANE); ASSERT128(I128(-1ul, BANE), -x); x = I128(0, -1ul); ASSERT128(I128(-1ul, 1), -x); x = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), -x); x = I128(2, 2); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), -x); x = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), -x); x = I128(2, -1ul); ASSERT128(I128(IMAX2, 1), -x); x = I128(BANE, 0); ASSERT128(I128(BANE, 0), -x); x = I128(BANE, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), -x); x = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), -x); x = I128(BANE, -1ul); ASSERT128(I128(IMAX, 1), -x); x = I128(-1ul, 0); ASSERT128(I128(1, 0), -x); x = I128(-1ul, 2); ASSERT128(I128(0, 0xfffffffffffffffe), -x); x = I128(-1ul, BANE); ASSERT128(I128(0, BANE), -x); x = I128(-1ul, -1ul); ASSERT128(I128(0, 1), -x); } void testXor128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x ^ y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x ^ y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x ^ y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x ^ y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x ^ y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x ^ y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x ^ y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x ^ y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x ^ y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x ^ y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x ^ y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(2, 0), x ^ y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x ^ y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x ^ y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x ^ y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x ^ y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x ^ y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(2, 0), x ^ y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(2, IMAX), x ^ y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x ^ y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x ^ y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x ^ y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x ^ y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(2, IMAX), x ^ y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, 0), x ^ y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x ^ y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x ^ y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(2, 2), x ^ y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(2, BANE), x ^ y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x ^ y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x ^ y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 0), x ^ y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(2, BANE2), x ^ y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x ^ y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, BANE2), x ^ y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(2, 0), x ^ y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(2, IMAX), x ^ y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x ^ y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(2, 0), x ^ y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x ^ y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x ^ y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(BANE, 2), x ^ y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x ^ y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x ^ y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 0), x ^ y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x ^ y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE, 0), x ^ y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x ^ y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE, 0), x ^ y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(IMAX, -1ul), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x ^ y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x ^ y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x ^ y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, -1ul), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x ^ y); } void testAnd128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x & y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 2), x & y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x & y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, BANE), x & y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x & y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(2, -1ul), x & y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x & y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, -1ul), x & y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x & y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 2), x & y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x & y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 2), x & y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x & y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x & y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x & y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x & y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x & y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x & y); } void testOr128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 2), x | y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, BANE), x | y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x | y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x | y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x | y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, BANE2), x | y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x | y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x | y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x | y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x | y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, BANE2), x | y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x | y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x | y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x | y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x | y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x | y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, -1ul), x | y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, -1ul), x | y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x | y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x | y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(2, BANE2), x | y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x | y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x | y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x | y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, BANE2), x | y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x | y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x | y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x | y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(BANE2, 0), x | y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x | y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(BANE2, 2), x | y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(BANE2, BANE), x | y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); } void testNot128(void) { __int128 x; x = I128(0, 0); ASSERT128(I128(-1ul, -1ul), ~x); x = I128(0, 2); ASSERT128(I128(-1ul, IMAX2), ~x); x = I128(0, BANE); ASSERT128(I128(-1ul, IMAX), ~x); x = I128(0, -1ul); ASSERT128(I128(-1ul, 0), ~x); x = I128(2, 0); ASSERT128(I128(IMAX2, -1ul), ~x); x = I128(2, 2); ASSERT128(I128(IMAX2, IMAX2), ~x); x = I128(2, BANE); ASSERT128(I128(IMAX2, IMAX), ~x); x = I128(2, -1ul); ASSERT128(I128(IMAX2, 0), ~x); x = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), ~x); x = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), ~x); x = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), ~x); x = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), ~x); x = I128(-1ul, 0); ASSERT128(I128(0, -1ul), ~x); x = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), ~x); x = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), ~x); x = I128(-1ul, -1ul); ASSERT128(I128(0, 0), ~x); } void testAbi(void) { ASSERT(0, ({ char buf[200]; sprintf(buf, "%d %d %d %d %032jjx %032jjx", 1, 2, 3, 4, I128(0x1ffffffff, 0x2ffffffff), I128(0x3eeeeeeee, 0x4eeeeeeee)); strcmp("1 2 3 4 00000001ffffffff00000002ffffffff " "00000003eeeeeeee00000004eeeeeeee", buf); })); ASSERT(0, ({ char buf[200]; sprintf(buf, "%d %d %d %d %d %032jjx %032jjx", 1, 2, 3, 4, 5, I128(0x1ffffffff, 0x2ffffffff), I128(0x3eeeeeeee, 0x4eeeeeeee)); strcmp("1 2 3 4 5 00000001ffffffff00000002ffffffff " "00000003eeeeeeee00000004eeeeeeee", buf); })); } int main(void) { testLang128(); testCompare128(); testAdd128(); testSub128(); testMul128(); testDiv128(); testDivu128(); testRem128(); testRemu128(); testShr128(); testSar128(); testShl128(); testNeg128(); testXor128(); testAnd128(); testOr128(); testNot128(); testCastDblInt128(); testCastDblUint128(); testCastLdblInt128(); testCastLdblUint128(); testAbi(); return 0; } chibicc-1.0.23.1/test/000077500000000000000000000000001505335450300143025ustar00rootroot00000000000000chibicc-1.0.23.1/test/align2.c000066400000000000000000000025131505335450300156230ustar00rootroot00000000000000//#include #include #include "test.h" struct __attribute__((aligned(128))) big128 { char buf[128]; }; struct __attribute__((aligned(1024))) big1024 { char buf[1024]; }; void test_big_align(int named_int, struct big128 s128, struct big1024 s1024, int count, ...) { printf("named int = %d\n", named_int); ASSERT(42, named_int); printf("struct big128 align = %zu size = %zu\n", __alignof__(s128), sizeof(s128)); ASSERT(128, sizeof(s128) ); printf("struct big1024 align = %zu size = %zu\n", __alignof__(s1024), sizeof(s1024)); ASSERT(1024, sizeof(s1024)); va_list ap; va_start(ap, count); for (int i = 0; i < count - 1 ; i++) { double val = va_arg(ap, double); printf("variadic double[%d] = %f\n", i, val); ASSERT(i+1, val); } struct big1024 s1024b = va_arg(ap, struct big1024); printf("struct big1024 align = %zu size = %zu\n", __alignof__(s1024b), sizeof(s1024b)); ASSERT(1024, sizeof(s1024b)); va_end(ap); } int main() { struct big128 s128 = {0}; struct big1024 s1024 = {0}; test_big_align( 42, // named int s128, // struct with align 128 s1024, // struct with align 1024 6, // count // variadic doubles 1.1, 2.2, 3.3, 4.4, 5.5, s1024 ); return 0; } chibicc-1.0.23.1/test/alignof.c000077500000000000000000000030171505335450300160710ustar00rootroot00000000000000#include "test.h" int _Alignas(512) g1; int _Alignas(512) g2; char g3; int g4; long g5; char g6; int main() { ASSERT(1, _Alignof(char)); ASSERT(2, _Alignof(short)); ASSERT(4, _Alignof(int)); ASSERT(8, _Alignof(long)); ASSERT(8, _Alignof(long long)); ASSERT(1, _Alignof(char[3])); ASSERT(4, _Alignof(int[3])); ASSERT(1, _Alignof(struct {char a; char b;}[2])); ASSERT(8, _Alignof(struct {char a; long b;}[2])); char x, y; printf("%ld\n", &y - &x); ASSERT(1, ({ _Alignas(char) char x, y; &y-&x; })); ASSERT(8, ({ _Alignas(long) char x, y; &y-&x; })); ASSERT(32, ({ _Alignas(32) char x, y; &y-&x; })); ASSERT(32, ({ _Alignas(32) int *x, *y; ((char *)&y)-((char *)&x); })); ASSERT(16, ({ struct { _Alignas(16) char x, y; } a; &a.y-&a.x; })); ASSERT(8, ({ struct T { _Alignas(8) char a; }; _Alignof(struct T); })); ASSERT(0, (long)(char *)&g1 % 512); ASSERT(0, (long)(char *)&g2 % 512); ASSERT(0, (long)(char *)&g4 % 4); ASSERT(0, (long)(char *)&g5 % 8); ASSERT(1, ({ char x; _Alignof(x); })); ASSERT(4, ({ int x; _Alignof(x); })); ASSERT(1, ({ char x; _Alignof x; })); ASSERT(4, ({ int x; _Alignof x; })); ASSERT(1, _Alignof(char) << 31 >> 31); ASSERT(1, _Alignof(char) << 63 >> 63); ASSERT(1, ({ char x; _Alignof(x) << 63 >> 63; })); ASSERT(0, ({ char x[16]; (unsigned long)&x % 16; })); ASSERT(0, ({ char x[17]; (unsigned long)&x % 16; })); ASSERT(0, ({ char x[100]; (unsigned long)&x % 16; })); ASSERT(0, ({ char x[101]; (unsigned long)&x % 16; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/alloca.c000077500000000000000000000010671505335450300157100ustar00rootroot00000000000000#include "test.h" void *fn(int x, void *p, int y) { return p; } int main() { int i = 0; char *p1 = alloca(16); char *p2 = alloca(16); char *p3 = 1 + (char *)alloca(3) + 1; p3 -= 2; char *p4 = fn(1, alloca(16), 3); ASSERT(16, p1 - p2); ASSERT(16, p2 - p3); ASSERT(16, p3 - p4); memcpy(p1, "0123456789abcdef", 16); memcpy(p2, "ghijklmnopqrstuv", 16); memcpy(p3, "wxy", 3); ASSERT(0, memcmp(p1, "0123456789abcdef", 16)); ASSERT(0, memcmp(p2, "ghijklmnopqrstuv", 16)); ASSERT(0, memcmp(p3, "wxy", 3)); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/alloca_builtin.c000066400000000000000000000002101505335450300174200ustar00rootroot00000000000000 void example() { int *p = alloca(10 * sizeof(int)); // Use the allocated memory... } int main() { example(); return 0; }chibicc-1.0.23.1/test/arith.c000077500000000000000000000075351505335450300155720ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(0, 0); ASSERT(42, 42); ASSERT(21, 5+20-4); ASSERT(41, 12 + 34 - 5 ); ASSERT(47, 5+6*7); ASSERT(15, 5*(9-6)); ASSERT(4, (3+5)/2); ASSERT(10, -10+20); ASSERT(10, - -10); ASSERT(10, - - +10); ASSERT(0, 0==1); ASSERT(1, 42==42); ASSERT(1, 0!=1); ASSERT(0, 42!=42); ASSERT(1, 0<1); ASSERT(0, 1<1); ASSERT(0, 2<1); ASSERT(1, 0<=1); ASSERT(1, 1<=1); ASSERT(0, 2<=1); ASSERT(1, 1>0); ASSERT(0, 1>1); ASSERT(0, 1>2); ASSERT(1, 1>=0); ASSERT(1, 1>=1); ASSERT(0, 1>=2); ASSERT(0, 1073741824 * 100 / 100); ASSERT(7, ({ int i=2; i+=5; i; })); ASSERT(7, ({ int i=2; i+=5; })); ASSERT(3, ({ int i=5; i-=2; i; })); ASSERT(3, ({ int i=5; i-=2; })); ASSERT(6, ({ int i=3; i*=2; i; })); ASSERT(6, ({ int i=3; i*=2; })); ASSERT(3, ({ int i=6; i/=2; i; })); ASSERT(3, ({ int i=6; i/=2; })); ASSERT(3, ({ int i=2; ++i; })); ASSERT(2, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; ++*p; })); ASSERT(0, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; --*p; })); ASSERT(2, ({ int i=2; i++; })); ASSERT(2, ({ int i=2; i--; })); ASSERT(3, ({ int i=2; i++; i; })); ASSERT(1, ({ int i=2; i--; i; })); ASSERT(1, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; *p++; })); ASSERT(1, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; *p--; })); ASSERT(0, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p++)--; a[0]; })); ASSERT(0, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*(p--))--; a[1]; })); ASSERT(2, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p)--; a[2]; })); ASSERT(2, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p)--; p++; *p; })); ASSERT(0, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p++)--; a[0]; })); ASSERT(0, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p++)--; a[1]; })); ASSERT(2, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p++)--; a[2]; })); ASSERT(2, ({ int a[3]; a[0]=0; a[1]=1; a[2]=2; int *p=a+1; (*p++)--; *p; })); ASSERT(0, !1); ASSERT(0, !2); ASSERT(1, !0); ASSERT(1, !(char)0); ASSERT(0, !(long)3); ASSERT(4, sizeof(!(char)0)); ASSERT(4, sizeof(!(long)0)); ASSERT(-1, ~0); ASSERT(0, ~-1); ASSERT(5, 17%6); ASSERT(5, ((long)17)%6); ASSERT(2, ({ int i=10; i%=4; i; })); ASSERT(2, ({ long i=10; i%=4; i; })); ASSERT(0, 0&1); ASSERT(1, 3&1); ASSERT(3, 7&3); ASSERT(10, -1&10); ASSERT(1, 0|1); ASSERT(0b10011, 0b10000|0b00011); ASSERT(0, 0^0); ASSERT(0, 0b1111^0b1111); ASSERT(0b110100, 0b111000^0b001100); ASSERT(2, ({ int i=6; i&=3; i; })); ASSERT(7, ({ int i=6; i|=3; i; })); ASSERT(10, ({ int i=15; i^=5; i; })); ASSERT(1, 1<<0); ASSERT(8, 1<<3); ASSERT(10, 5<<1); ASSERT(2, 5>>1); ASSERT(-1, -1>>1); ASSERT(1, ({ int i=1; i<<=0; i; })); ASSERT(8, ({ int i=1; i<<=3; i; })); ASSERT(10, ({ int i=5; i<<=1; i; })); ASSERT(2, ({ int i=5; i>>=1; i; })); ASSERT(-1, -1); ASSERT(-1, ({ int i=-1; i; })); ASSERT(-1, ({ int i=-1; i>>=1; i; })); ASSERT(2, 0?1:2); ASSERT(1, 1?1:2); ASSERT(-1, 0?-2:-1); ASSERT(-2, 1?-2:-1); ASSERT(4, sizeof(0?1:2)); ASSERT(8, sizeof(0?(long)1:(long)2)); ASSERT(-1, 0?(long)-2:-1); ASSERT(-1, 0?-2:(long)-1); ASSERT(-2, 1?(long)-2:-1); ASSERT(-2, 1?-2:(long)-1); 1 ? -2 : (void)-1; ASSERT(20, ({ int x; int *p=&x; p+20-p; })); ASSERT(1, ({ int x; int *p=&x; p+20-p>0; })); ASSERT(-20, ({ int x; int *p=&x; p-20-p; })); ASSERT(1, ({ int x; int *p=&x; p-20-p<0; })); ASSERT(15, (char *)0xffffffffffffffff - (char *)0xfffffffffffffff0); ASSERT(-15, (char *)0xfffffffffffffff0 - (char *)0xffffffffffffffff); ASSERT(1, (void *)0xffffffffffffffff > (void *)0); ASSERT(3, 3?:5); ASSERT(5, 0?:5); ASSERT(4, ({ int i = 3; ++i?:10; })); ASSERT(3, (long double)3); ASSERT(5, (long double)3+2); ASSERT(6, (long double)3*2); ASSERT(5, (long double)3+2.0); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/array_initializer.c000066400000000000000000000005251505335450300201710ustar00rootroot00000000000000#include "test.h" #define SIZE 10 int main() { int myarr[SIZE] = { 11, 34, 0, 0, 0, 0, 0, 0, 0, 0}; int myarr2[SIZE] = { 11, 34,}; for (int i = 0; i < SIZE; ++i) printf("%d: %d\n", i, myarr[i]); for (int i = 0; i < SIZE; ++i) printf("%d: %d\n", i, myarr2[i]); ASSERT(0, myarr2[9]); return 0; }chibicc-1.0.23.1/test/asm.c000077500000000000000000000006251505335450300152340ustar00rootroot00000000000000#include "test.h" char *asm_fn1(void) { asm("mov $50, %rax\n\t" "mov %rbp, %rsp\n\t" "pop %rbp\n\t" "ret"); } char *asm_fn2(void) { asm inline volatile("mov $55, %rax\n\t" "mov %rbp, %rsp\n\t" "pop %rbp\n\t" "ret"); } int main() { ASSERT(50, asm_fn1()); ASSERT(55, asm_fn2()); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/asm1.c000066400000000000000000000037151505335450300153150ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include // #include #include // #include #include "test.h" static jmp_buf segv_handler_env; static void segv_handler(__attribute__((__unused__)) int sig, __attribute__((__unused__)) siginfo_t *info, __attribute__((__unused__)) void *ignored) { siglongjmp(segv_handler_env, 1); } #define HYPERVISOR_INFO_LEAF 0x40000000 #define VMWARE_BDOOR_MAGIC 0x564D5868 #define VMWARE_BDOOR_PORT 0x5658 #define VMWARE_BDOOR_CMD_GETVERSION 10 static inline void cpuid(unsigned int op, unsigned int *teax, unsigned int *tebx, unsigned int *tecx, unsigned int *tedx) { __asm__( "cpuid;" : "=b"(*tebx), "=a"(*teax), "=c"(*tecx), "=d"(*tedx) : "1"(op), "c"(0)); } void vmware_bdoor(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { __asm__( "inl (%%dx), %%eax;" : "=b"(*ebx), "=a"(*eax), "=c"(*ecx), "=d"(*edx) : "0"(VMWARE_BDOOR_MAGIC), "1"(VMWARE_BDOOR_CMD_GETVERSION), "2"(VMWARE_BDOOR_PORT), "3"(0) : "memory"); } int main(void) { unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; struct sigaction act, oact; cpuid(HYPERVISOR_INFO_LEAF, &eax, &ebx, &ecx, &edx); printf("%d %d %d %d\n", eax, ebx, ecx, edx); ASSERT(1073741835, eax); ASSERT(1919117645, ebx); ASSERT(1718580079, ecx); ASSERT(1984438388, edx); eax = 0; ebx = 0; ecx = 0; edx = 0; if (getuid() != 0) return 0; if (sigsetjmp(segv_handler_env, 1)) return 0; memset(&act, 0, sizeof(act)); act.sa_sigaction = segv_handler; act.sa_flags = SA_SIGINFO; if (sigaction(SIGSEGV, &act, &oact)) { printf("cannot set signal handler\n"); return -1; } vmware_bdoor(&eax, &ebx, &ecx, &edx); printf("%d %d %d %d\n", eax, ebx, ecx, edx); return 0; }chibicc-1.0.23.1/test/asm2a.c000066400000000000000000000017551505335450300154610ustar00rootroot00000000000000 #include "test.h" void someasm(void) { /* Add 10 and 20 and store result into register %eax */ int eax=0; int a = 0; __asm__ ( "xor %eax, %eax;" "movl $10, %ebx;" "movl $20, %ebx;" "addl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); a = eax; printf("a = %d\n", a); ASSERT(20, a); /* Subtract 20 from 10 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "subl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); ASSERT(-10, eax); /* Multiply 10 and 20 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "imull %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); ASSERT(200, eax); } int main() { someasm(); return 0 ; }chibicc-1.0.23.1/test/asm2b.c000066400000000000000000000017261505335450300154600ustar00rootroot00000000000000#include "test.h" void someasm(void) { /* Add 10 and 20 and store result into register %eax */ int eax=0, ebx = 0; __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "addl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); ASSERT(30, eax); /* Subtract 20 from 10 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "subl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); ASSERT(-10, eax); /* Multiply 10 and 20 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "imull %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); ASSERT(200, eax); } int main() { someasm(); return 0 ; }chibicc-1.0.23.1/test/asm2c.c000066400000000000000000000016601505335450300154560ustar00rootroot00000000000000#include "test.h" int main() { /* Add 10 and 20 and store result into register %eax */ int teax=0, tebx = 0, tecx = 0; __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "addl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( teax )); ASSERT(30, teax); printf("eax = %d\n", teax); /* Subtract 20 from 10 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "subl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( teax )); ASSERT(-10, teax); printf("eax = %d\n", teax); /* Multiply 10 and 20 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "imull %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( teax )); ASSERT(200, teax); printf("eax = %d\n", teax); return 0 ; }chibicc-1.0.23.1/test/asm2d.c000066400000000000000000000004361505335450300154570ustar00rootroot00000000000000 #include "test.h" int main() { int src = 1; int dst = 0; __asm__ ("mov %1, %0\n\t" "add $1, %0" : "=r" (dst) : "r" (src)); printf("%d\n", dst); printf("%ld %ld\n", sizeof(src), sizeof(dst)); ASSERT(2, dst); ASSERT(4, sizeof(src)); ASSERT(4, sizeof(dst)); return 0 ; }chibicc-1.0.23.1/test/asm3.c000066400000000000000000000004041505335450300153070ustar00rootroot00000000000000 #include "test.h" int main() { int src = 1; int dst; asm ("mov %1, %0\n\t" "add $1, %0" : "=r" (dst) : "r" (src)); printf("%d\n", dst); printf("%d\n", src); ASSERT(2, dst); ASSERT(1, src); return 0; }chibicc-1.0.23.1/test/asm4.c000066400000000000000000000013721505335450300153150ustar00rootroot00000000000000#include #include "test.h" int main() { uint64_t msr; asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. "shl $32, %%rdx\n\t" // Shift the upper bits left. "or %%rdx, %0" // 'Or' in the lower bits. : "=a" (msr) : : "rdx"); printf("msr: %lx\n", msr); ASSERT(1, msr != 0); // Do other work... // Reprint the timestamp asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. "shl $32, %%rdx\n\t" // Shift the upper bits left. "or %%rdx, %0" // 'Or' in the lower bits. : "=a" (msr) : : "rdx"); printf("msr: %lx\n", msr); ASSERT(1, msr != 0); return 0; }chibicc-1.0.23.1/test/asm5.c000066400000000000000000000013211505335450300153100ustar00rootroot00000000000000#include #include "test.h" void DoCheck(uint32_t dwSomeValue) { uint32_t dwRes; // Assumes dwSomeValue is not zero. asm ("bsfl %1 , %0 ;" : "=r" (dwRes) : "r" (dwSomeValue) : "cc"); printf("%u: %u %u\n", 0, dwSomeValue, dwRes); ASSERT(0, dwRes); ASSERT(5, dwSomeValue); //assert(dwRes > 3); } void do_print(uint32_t dwSomeValue) { uint32_t dwRes; for (uint32_t x=0; x < 5; x++) { // Assumes dwSomeValue is not zero. asm ("bsfl %1 , %0 ;" : "=r" (dwRes) : "r" (dwSomeValue) : "cc"); printf("%u: %u %u\n", x, dwSomeValue, dwRes); } } int main() { uint32_t a = 5; DoCheck(a); do_print(a); return 0; }chibicc-1.0.23.1/test/asm6.c000066400000000000000000000020651505335450300153170ustar00rootroot00000000000000#include "test.h" void someasm(void) { /* Add 10 and 20 and store result into register %eax */ int eax=0, ebx = 0; __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "addl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); ASSERT(30, eax); printf("eax = %d\n", eax); printf("eax = %d\n", eax); /* Subtract 20 from 10 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "subl %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); printf("eax = %d\n", eax); ASSERT(-10, eax); /* Multiply 10 and 20 and store result into register %eax */ __asm__ ( "movl $10, %eax;" "movl $20, %ebx;" "imull %ebx, %eax;" ); __asm__ ("movl %%eax, %0;" : "=r" ( eax )); printf("eax = %d\n", eax); printf("eax = %d\n", eax); ASSERT(200, eax); } int main() { someasm(); return 0 ; }chibicc-1.0.23.1/test/asm7.c000066400000000000000000000004041505335450300153130ustar00rootroot00000000000000#include "test.h" int add(int a, int b) { asm ("add %1, %0\n\t" : "+r" (a) : "r" (b) : "cc" ); return a; } int main(void) { int result = add(10, 21); printf("%d\n", result); ASSERT(31, result); return 0; } chibicc-1.0.23.1/test/asm8.c000066400000000000000000000011621505335450300153160ustar00rootroot00000000000000 #include "test.h" void add_and_subtract(int a, int b, int *sum, int *diff) { asm ( "add %3, %2\n\t" "mov %2, %0\n\t" "sub %3, %2\n\t" "mov %2, %1\n\t" "" : "=r" (*sum), "=r" (*diff) // Output operands : "r" (a), "r" (b) // Input operands : "cc" // Clobbered registers ); } int main(void) { int a = 10, b = 5; int sum = 0, diff = 0; add_and_subtract(a, b, &sum, &diff); printf("Sum: %d\n", sum); printf("Difference: %d\n", diff); ASSERT(15, sum); ASSERT(10, diff); return 0; } chibicc-1.0.23.1/test/asm9.c000066400000000000000000000034571505335450300153300ustar00rootroot00000000000000#include #include #include #include "test.h" void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h) { __asm__ volatile( "movq (%1), %%mm0 \n\t" "movq %%mm0, (%0) \n\t" : // No output operands : "r"(block), "r"(pixels) // Input operands : "memory" // Clobbered registers ); } int atomic_add(int *ptr, int val) { int result; __asm__ volatile("lock; xaddl %0, %1" : "=r"(result), "+m"(*ptr) : "0"(val) : "memory"); return result; } static inline long syscall(long n, long a1, long a2, long a3, long a4, long a5, long a6) { long ret; __asm__ volatile ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(a4), "r"(a5), "r"(a6) : "rcx", "r11", "memory"); return ret; } void *memcpy(void *dest, const void *src, size_t n) { __asm__ volatile( "rep movsb" : "+D"(dest), "+S"(src), "+c"(n) : : "memory"); return dest; } int main(int argc, char **argv) { uint8_t block[8] = {1, 2, 3, 4, 5, 6, 7, 8}; uint8_t pixels[8] = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8}; ff_put_pixels8_mmx(block, pixels, 8, 1); printf("%d\n", block[0]); printf("%d\n", block[7]); printf("%d\n", pixels[0]); printf("%d\n", pixels[7]); ASSERT(1, block[0]); ASSERT(8, block[7]); ASSERT(1, pixels[0]); ASSERT(8, pixels[7]); int i = 8; int j = 0; int *ptr = &i; j = atomic_add(ptr, 1); printf("i=%d, j=%d\n", i, j); ASSERT(9, i); ASSERT(8, j); // long tid = syscall(SYS_gettid, 0, 0, 0, 0, 0, 0); // printf("Thread ID: %ld\n", tid); return 0; }chibicc-1.0.23.1/test/assert1.c000066400000000000000000000001071505335450300160260ustar00rootroot00000000000000 #include int main() { static_assert( 3 < 4, "hello"); }chibicc-1.0.23.1/test/assoc.h000066400000000000000000000010641505335450300155640ustar00rootroot00000000000000/* associative array */ void assoc_init(const int hashpower_init); item *assoc_find(const char *key, const size_t nkey, const uint32_t hv); int assoc_insert(item *item, const uint32_t hv); void assoc_delete(const char *key, const size_t nkey, const uint32_t hv); int start_assoc_maintenance_thread(void); void stop_assoc_maintenance_thread(void); void assoc_start_expand(uint64_t curr_items); /* walk functions */ void *assoc_get_iterator(void); bool assoc_iterate(void *iterp, item **it); void assoc_iterate_final(void *iterp); extern unsigned int hashpower; chibicc-1.0.23.1/test/atomic.c000077500000000000000000000031741505335450300157320ustar00rootroot00000000000000#include "test.h" #include #include static int incr(_Atomic int *p) { int oldval = *p; int newval; do { newval = oldval + 1; } while (!atomic_compare_exchange_weak(p, &oldval, newval)); return newval; } static int add1(void *arg) { _Atomic int *x = arg; for (int i = 0; i < 1000*1000; i++) incr(x); return 0; } static int add2(void *arg) { _Atomic int *x = arg; for (int i = 0; i < 1000*1000; i++) (*x)++; return 0; } static int add3(void *arg) { _Atomic int *x = arg; for (int i = 0; i < 1000*1000; i++) *x += 5; return 0; } static int add_millions(void) { _Atomic int x = 0; pthread_t thr1; pthread_t thr2; pthread_t thr3; pthread_create(&thr1, NULL, add1, &x); pthread_create(&thr2, NULL, add2, &x); pthread_create(&thr3, NULL, add3, &x); for (int i = 0; i < 1000*1000; i++) x--; pthread_join(thr1, NULL); pthread_join(thr2, NULL); pthread_join(thr3, NULL); return x; } static void fetch_ops(void) { _Atomic int x = 0; ASSERT(0, atomic_fetch_add(&x, 17)); ASSERT(17, atomic_fetch_add(&x, 10)); ASSERT(27, atomic_fetch_add(&x, 3)); ASSERT(30, atomic_fetch_sub(&x, 17)); ASSERT(13, atomic_fetch_sub(&x, 13)); ASSERT(0, atomic_fetch_or(&x, 0xf0)); ASSERT(0xf0, atomic_fetch_or(&x, 0x0f)); ASSERT(0xff, atomic_fetch_and(&x, 0x0f)); ASSERT(0x0f, atomic_fetch_xor(&x, 0xff)); ASSERT(0xf0, atomic_fetch_add(&x, 0)); } int main() { ASSERT(6*1000*1000, add_millions()); ASSERT(3, ({ int x=3; atomic_exchange(&x, 5); })); ASSERT(5, ({ int x=3; atomic_exchange(&x, 5); x; })); fetch_ops(); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/atomic2.c000066400000000000000000000105271505335450300160110ustar00rootroot00000000000000 #include #include "test.h" int main() { int value = 5; int expected = 5; int new_value = 10; if (atomic_compare_exchange_weak(&value, &expected, new_value)) { printf("Value was exchanged.\n"); } else { printf("Value was not exchanged. Expected: %d, Value: %d\n", expected, value); } printf("Final Value: %d\n", value); ASSERT(10, value); if (atomic_compare_exchange_strong(&value, &expected, new_value)) { printf("Value was exchanged.\n"); } else { printf("Value was not exchanged. Expected: %d, Value: %d\n", expected, value); } printf("Final Value: %d\n", value); ASSERT(10, value); value = 5; int old_value = atomic_fetch_add(&value, 3); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(8, value); value = 5; old_value = atomic_fetch_sub(&value, 3); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(2, value); value = 5; // 0101 in binary old_value = atomic_fetch_or(&value, 2); // 0010 in binary printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(7, value); value = 5; // 0101 in binary old_value = atomic_fetch_xor(&value, 3); // 0011 in binary printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(6, value); value = 5; // 0101 in binary old_value = atomic_fetch_and(&value, 3); // 0011 in binary printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(1, value); value = 5; old_value = atomic_exchange(&value, 10); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(10, value); value = 5; old_value = atomic_exchange_explicit(&value, 10, memory_order_seq_cst); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(10, value); value = 5; int loaded_value = atomic_load(&value); printf("Loaded Value: %d\n", loaded_value); ASSERT(5, value); ASSERT(5, loaded_value); value = 5; loaded_value = atomic_load_explicit(&value, memory_order_acquire); printf("Loaded Value: %d\n", loaded_value); ASSERT(5, value); ASSERT(5, loaded_value); atomic_store(&value, 11); printf("Stored Value: %d\n", value); ASSERT(11, value); atomic_store_explicit(&value, 12, memory_order_release); printf("Stored Value: %d\n", value); ASSERT(12, value); atomic_flag flag = ATOMIC_FLAG_INIT; if (!atomic_flag_test_and_set(&flag)) { printf("Flag was clear and is now set.\n"); } else { printf("Flag was already set.\n"); } atomic_flag flag2 = ATOMIC_FLAG_INIT; if (!atomic_flag_test_and_set_explicit(&flag2, memory_order_acquire)) { printf("Flag2 was clear and is now set.\n"); } else { printf("Flag2 was already set.\n"); } atomic_flag flag3 = ATOMIC_FLAG_INIT; atomic_flag_test_and_set(&flag3); atomic_flag_clear(&flag3); printf("Flag3 is now clear.\n"); atomic_flag flag4 = ATOMIC_FLAG_INIT; atomic_flag_test_and_set(&flag4); atomic_flag_clear_explicit(&flag4, memory_order_release); printf("Flag4 is now clear.\n"); value = 5; old_value = __sync_val_compare_and_swap(&value, 5, 10); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(10, value); value = 5; old_value = __sync_fetch_and_add(&value, 3); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(8, value); value = 5; old_value = __sync_fetch_and_sub(&value, 3); printf("Old Value: %d, New Value: %d\n", old_value, value); ASSERT(5, old_value); ASSERT(2, value); value = 5; old_value = __sync_val_compare_and_swap(&value, 5, 10); printf("Old value: %d, New value: %d\n", old_value, value); // Expected: Old value: 5, New value: 10 ASSERT(5, old_value); ASSERT(10, value); value = 5; old_value = __sync_val_compare_and_swap(&value, 5, 20); printf("Old value: %d, New value: %d\n", old_value, value); // Expected: Old value: 5, New value: 20 ASSERT(5, old_value); ASSERT(20, value); return 0; } chibicc-1.0.23.1/test/atomic3.c000066400000000000000000000016441505335450300160120ustar00rootroot00000000000000#include "test.h" #include #include int main(void) { int x = 0; int y = 42; // Atomic store using __atomic_store_n __atomic_store_n(&x, y, __ATOMIC_SEQ_CST); // Atomic load using __atomic_load_n int z = __atomic_load_n(&x, __ATOMIC_SEQ_CST); printf("x = %d, y = %d, z = %d\n", x, y, z); ASSERT(42, x); ASSERT(42, y); ASSERT(42, z); // Modify x using store_n again __atomic_store_n(&x, 99, __ATOMIC_SEQ_CST); int w = __atomic_load_n(&x, __ATOMIC_SEQ_CST); printf("x = %d, w = %d\n", x, w); ASSERT(99, x); ASSERT(99, w); // Test with uint8_t uint8_t a = 5, b = 200; __atomic_store_n(&a, b, __ATOMIC_SEQ_CST); uint8_t c = __atomic_load_n(&a, __ATOMIC_SEQ_CST); printf("a = %u, b = %u, c = %u\n", a, b, c); ASSERT(200, a); ASSERT(200, b); ASSERT(200, c); return 0; } chibicc-1.0.23.1/test/atomic4.c000066400000000000000000000033411505335450300160070ustar00rootroot00000000000000#include #include // Test for __atomic_compare_exchange_n void test_compare_exchange_n() { int x = 42; int expected = 42; int desired = 100; // Should succeed, since *x == expected bool success = __atomic_compare_exchange_n(&x, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("=== __atomic_compare_exchange_n ===\n"); printf("success=%d, x=%d, expected=%d\n", success, x, expected); // Reset for failure case x = 200; expected = 42; desired = 300; success = __atomic_compare_exchange_n(&x, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("failure case: success=%d, x=%d, expected=%d\n", success, x, expected); } // Test for __atomic_compare_exchange void test_compare_exchange() { int x = 42; int expected = 42; int desired = 100; // Same semantics but explicit expected as a pointer bool success = __atomic_compare_exchange(&x, &expected, &desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("=== __atomic_compare_exchange ===\n"); printf("success=%d, x=%d, expected=%d\n", success, x, expected); // Reset for failure case x = 200; expected = 42; desired = 300; success = __atomic_compare_exchange(&x, &expected, &desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("failure case: success=%d, x=%d, expected=%d\n", success, x, expected); } int main() { test_compare_exchange_n(); test_compare_exchange(); return 0; } chibicc-1.0.23.1/test/atomic_clear_flag.c000066400000000000000000000006311505335450300200610ustar00rootroot00000000000000#include "test.h" typedef struct pg_atomic_flag { volatile char value; } pg_atomic_flag; static inline void pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr) { __asm__ __volatile__("" ::: "memory"); ptr->value = 0; } int main() { pg_atomic_flag flag = {1}; pg_atomic_clear_flag_impl(&flag); printf("Flag cleared: %d\n", flag.value); ASSERT(0, flag.value); return 0; } chibicc-1.0.23.1/test/atomic_compare_exchange.c000066400000000000000000000015661505335450300213020ustar00rootroot00000000000000 #include #include "test.h" typedef struct pg_atomic_uint32 { volatile unsigned int value; } pg_atomic_uint32; static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, unsigned int *expected, unsigned int newval) { char ret; __asm__ __volatile__( "lock\n" "cmpxchgl %4,%5\n" "setz %2\n" : "=a" (*expected), "=m" (ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m" (ptr->value) : "memory", "cc"); return (bool) ret; } int main() { pg_atomic_uint32 val = {10}; unsigned int expected = 10; bool result = pg_atomic_compare_exchange_u32_impl(&val, &expected, 20); printf("Compare and Exchange: %d, New Value: %u\n", result, val.value); ASSERT(1, result); ASSERT(20, val.value); return 0; } chibicc-1.0.23.1/test/atomic_compare_exchange_u64.c000066400000000000000000000016561505335450300220000ustar00rootroot00000000000000#ifdef __x86_64__ #include #include "test.h" typedef struct pg_atomic_uint64 { volatile unsigned long long value; } pg_atomic_uint64; static inline bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, unsigned long long *expected, unsigned long long newval) { char ret; __asm__ __volatile__( "lock\n" "cmpxchgq %4,%5\n" "setz %2\n" : "=a" (*expected), "=m" (ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m" (ptr->value) : "memory", "cc"); return (bool) ret; } int main() { pg_atomic_uint64 val = {10}; unsigned long long expected = 10; bool result = pg_atomic_compare_exchange_u64_impl(&val, &expected, 20); printf("Compare and Exchange U64: %d, New Value: %llu\n", result, val.value); ASSERT(1, result); ASSERT(20, val.value); return 0; } #endif chibicc-1.0.23.1/test/atomic_fetch_add.c000066400000000000000000000012471505335450300177070ustar00rootroot00000000000000 #include "test.h" typedef struct pg_atomic_uint32 { volatile unsigned int value; } pg_atomic_uint32; static inline unsigned int pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int add_) { unsigned int res; __asm__ __volatile__( "lock\n" "xaddl %0,%1\n" : "=q"(res), "=m"(ptr->value) : "0" (add_), "m"(ptr->value) : "memory", "cc"); return res; } int main() { pg_atomic_uint32 val = {10}; unsigned int old_val = pg_atomic_fetch_add_u32_impl(&val, 5); printf("Fetch and Add: Old Value: %u, New Value: %u\n", old_val, val.value); ASSERT(10, old_val); ASSERT(15, val.value); return 0; } chibicc-1.0.23.1/test/atomic_sync_bool_compare_and_swap.c000077500000000000000000000010741505335450300233600ustar00rootroot00000000000000 #include "test.h" static inline int __sync_bool_compare_and_swap(int *ptr, int oldval, int newval) { char result; __asm__ __volatile__( "lock; cmpxchgl %2, %1\n\t" "sete %0" : "=q" (result), "+m" (*ptr), "+a" (oldval) : "r" (newval) : "memory"); return result; } int main() { int value = 5; int result = __sync_bool_compare_and_swap(&value, 5, 10); printf("Compare and swap result: %d, New value: %d\n", result, value); // Result: 1, value: 5 ASSERT(1, result); ASSERT(5, value); return 0; } chibicc-1.0.23.1/test/atomic_sync_fetch_and_add.c000066400000000000000000000010371505335450300215620ustar00rootroot00000000000000 #include "test.h" // static inline int __sync_fetch_and_add(int *ptr, int value) { // int old_value; // __asm__ __volatile__( // "lock; xaddl %0, %1" // : "=r" (old_value), "+m" (*ptr) // : "0" (value) // : "memory" // ); // return old_value; // } int main() { int value = 5; int old_value = __sync_fetch_and_add(&value, 3); printf("Old value: %d, New value: %d\n", old_value, value); // Old value: 5, New value: 8 ASSERT(5, old_value); ASSERT(8, value); return 0; } chibicc-1.0.23.1/test/atomic_sync_fetch_and_sub.c000066400000000000000000000010411505335450300216160ustar00rootroot00000000000000 #include "test.h" // static inline int __sync_fetch_and_sub(int *ptr, int value) { // int old_value; // __asm__ __volatile__( // "lock; xaddl %0, %1" // : "=r" (old_value), "+m" (*ptr) // : "0" (-value) // : "memory" // ); // return old_value; // } int main() { int value = 5; int old_value = __sync_fetch_and_sub(&value, 2); printf("Old value: %d, New value: %d\n", old_value, value); // Old value: 5, New value: 3 ASSERT(5, old_value); ASSERT(3, value); return 0; } chibicc-1.0.23.1/test/atomic_sync_lock_and_set.c000066400000000000000000000004121505335450300214600ustar00rootroot00000000000000 #include "test.h" int main() { int value = 0; int old_value = __sync_lock_test_and_set(&value, 1); printf("Old value: %d, New value: %d\n", old_value, value); // Old value: 0, New value: 1 ASSERT(0, old_value); ASSERT(1, value); return 0; } chibicc-1.0.23.1/test/atomic_sync_synchronize.c000066400000000000000000000007161505335450300214150ustar00rootroot00000000000000 #include #include "test.h" int shared_value = 0; void *thread_func(void *arg) { __sync_synchronize(); // Memory barrier shared_value = 42; __sync_synchronize(); // Memory barrier return NULL; } int main() { pthread_t thread; pthread_create(&thread, NULL, thread_func, NULL); pthread_join(thread, NULL); printf("Shared value: %d\n", shared_value); // Shared value: 42 ASSERT(42, shared_value); return 0; } chibicc-1.0.23.1/test/atomic_sync_val_and_swap.c000066400000000000000000000011411505335450300214710ustar00rootroot00000000000000 #include #include "test.h" // static inline int __sync_val_compare_and_swap(int *ptr, int oldval, int newval) { // int result; // __asm__ __volatile__( // "lock; cmpxchgl %2, %1" // : "=a" (result), "+m" (*ptr) // : "r" (newval), "0" (oldval) // : "memory" // ); // return result; // } int main() { int value = 5; int old_value = __sync_val_compare_and_swap(&value, 5, 10); printf("Old value: %d, New value: %d\n", old_value, value); // Old value: 5, New value: 10 ASSERT(5, old_value); ASSERT(10, value); return 0; } chibicc-1.0.23.1/test/atomic_test_and_set2.c000066400000000000000000000010651505335450300205420ustar00rootroot00000000000000 #include #include "test.h" typedef struct pg_atomic_flag { volatile char value; } pg_atomic_flag; static inline bool pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr) { char _res = 1; __asm__ __volatile__( "lock\n" "xchgb %0,%1\n" : "+q" (_res), "+m" (ptr->value) : : "memory"); return _res == 0; } int main() { pg_atomic_flag flag = {0}; bool result = pg_atomic_test_set_flag_impl(&flag); printf("Test and Set Flag: %d\n", result); ASSERT(1, result); return 0; } chibicc-1.0.23.1/test/attribute.c000077500000000000000000000071131505335450300164560ustar00rootroot00000000000000#include "test.h" #include "stddef.h" int main() { ASSERT(5, ({ struct { char a; int b; } __attribute__((packed)) x; sizeof(x); })); ASSERT(0, offsetof(struct __attribute__((packed)) { char a; int b; }, a)); ASSERT(1, offsetof(struct __attribute__((packed)) { char a; int b; }, b)); ASSERT(5, ({ struct __attribute__((packed)) { char a; int b; } x; sizeof(x); })); ASSERT(0, offsetof(struct { char a; int b; } __attribute__((packed)), a)); ASSERT(1, offsetof(struct { char a; int b; } __attribute__((packed)), b)); ASSERT(9, ({ typedef struct { char a; int b[2]; } __attribute__((packed)) T; sizeof(T); })); ASSERT(9, ({ typedef struct __attribute__((packed)) { char a; int b[2]; } T; sizeof(T); })); ASSERT(1, offsetof(struct __attribute__((packed)) T { char a; int b[2]; }, b)); ASSERT(1, _Alignof(struct __attribute__((packed)) { char a; int b[2]; })); ASSERT(8, ({ struct __attribute__((aligned(8))) { int a; } x; _Alignof(x); })); ASSERT(8, ({ struct { int a; } __attribute__((aligned(8))) x; _Alignof(x); })); ASSERT(8, ({ struct __attribute__((aligned(8), packed)) { char a; int b; } x; _Alignof(x); })); ASSERT(8, ({ struct { char a; int b; } __attribute__((aligned(8), packed)) x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((aligned(8), packed)) { char a; int b; }, b)); ASSERT(1, offsetof(struct { char a; int b; } __attribute__((aligned(8), packed)), b)); ASSERT(8, ({ struct __attribute__((aligned(8))) __attribute__((packed)) { char a; int b; } x; _Alignof(x); })); ASSERT(8, ({ struct { char a; int b; } __attribute__((aligned(8))) __attribute__((packed)) x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((aligned(8))) __attribute__((packed)) { char a; int b; }, b)); ASSERT(1, offsetof(struct { char a; int b; } __attribute__((aligned(8))) __attribute__((packed)), b)); ASSERT(8, ({ struct __attribute__((aligned(8))) { char a; int b; } __attribute__((packed)) x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((aligned(8))) { char a; int b; } __attribute__((packed)), b)); ASSERT(16, ({ struct __attribute__((aligned(8+8))) { char a; int b; } x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((packed)) T { char a; int b[2]; }, b)); ASSERT(1, _Alignof(struct __attribute__((packed)) { char a; int b[2]; })); ASSERT(8, ({ struct __attribute__((aligned(8))) { int a; } x; _Alignof(x); })); ASSERT(8, ({ struct { int a; } __attribute__((aligned(8))) x; _Alignof(x); })); ASSERT(8, ({ struct __attribute__((aligned(8), packed)) { char a; int b; } x; _Alignof(x); })); ASSERT(8, ({ struct { char a; int b; } __attribute__((aligned(8), packed)) x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((aligned(8), packed)) { char a; int b; }, b)); ASSERT(1, offsetof(struct { char a; int b; } __attribute__((aligned(8), packed)), b)); ASSERT(8, ({ struct __attribute__((aligned(8))) __attribute__((packed)) { char a; int b; } x; _Alignof(x); })); ASSERT(8, ({ struct { char a; int b; } __attribute__((aligned(8))) __attribute__((packed)) x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((aligned(8))) __attribute__((packed)) { char a; int b; }, b)); ASSERT(1, offsetof(struct { char a; int b; } __attribute__((aligned(8))) __attribute__((packed)), b)); ASSERT(8, ({ struct __attribute__((aligned(8))) { char a; int b; } __attribute__((packed)) x; _Alignof(x); })); ASSERT(1, offsetof(struct __attribute__((aligned(8))) { char a; int b; } __attribute__((packed)), b)); ASSERT(16, ({ struct __attribute__((aligned(8+8))) { char a; int b; } x; _Alignof(x); })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/bipbuffer.h000066400000000000000000000041061505335450300164200ustar00rootroot00000000000000#ifndef BIPBUFFER_H #define BIPBUFFER_H typedef struct { unsigned long int size; /* region A */ unsigned int a_start, a_end; /* region B */ unsigned int b_end; /* is B inuse? */ int b_inuse; unsigned char data[]; } bipbuf_t; /** * Create a new bip buffer. * * malloc()s space * * @param[in] size The size of the buffer */ bipbuf_t *bipbuf_new(const unsigned int size); /** * Initialise a bip buffer. Use memory provided by user. * * No malloc()s are performed. * * @param[in] size The size of the array */ void bipbuf_init(bipbuf_t* me, const unsigned int size); /** * Free the bip buffer */ void bipbuf_free(bipbuf_t *me); /* TODO: DOCUMENTATION */ unsigned char *bipbuf_request(bipbuf_t* me, const int size); int bipbuf_push(bipbuf_t* me, const int size); /** * @param[in] data The data to be offered to the buffer * @param[in] size The size of the data to be offered * @return number of bytes offered */ int bipbuf_offer(bipbuf_t *me, const unsigned char *data, const int size); /** * Look at data. Don't move cursor * * @param[in] len The length of the data to be peeked * @return data on success, NULL if we can't peek at this much data */ unsigned char *bipbuf_peek(const bipbuf_t* me, const unsigned int len); /** * Look at data. Don't move cursor * * @param[in] len The length of the data returned * @return data on success, NULL if nothing available */ unsigned char *bipbuf_peek_all(const bipbuf_t* me, unsigned int *len); /** * Get pointer to data to read. Move the cursor on. * * @param[in] len The length of the data to be polled * @return pointer to data, NULL if we can't poll this much data */ unsigned char *bipbuf_poll(bipbuf_t* me, const unsigned int size); /** * @return the size of the bipbuffer */ int bipbuf_size(const bipbuf_t* me); /** * @return 1 if buffer is empty; 0 otherwise */ int bipbuf_is_empty(const bipbuf_t* me); /** * @return how much space we have assigned */ int bipbuf_used(const bipbuf_t* cb); /** * @return bytes of unused space */ int bipbuf_unused(const bipbuf_t* me); #endif /* BIPBUFFER_H */ chibicc-1.0.23.1/test/bitfield.c000077500000000000000000000024171505335450300162370ustar00rootroot00000000000000#include "test.h" struct { char a; int b : 5; int c : 10; } g45 = {1, 2, 3}, g46={}; int main() { ASSERT(4, sizeof(struct {int x:1; })); ASSERT(8, sizeof(struct {long x:1; })); struct bit1 { short a; char b; int c : 2; int d : 3; int e : 3; }; ASSERT(4, sizeof(struct bit1)); ASSERT(1, ({ struct bit1 x; x.a=1; x.b=2; x.c=3; x.d=4; x.e=5; x.a; })); ASSERT(1, ({ struct bit1 x={1,2,3,4,5}; x.a; })); ASSERT(2, ({ struct bit1 x={1,2,3,4,5}; x.b; })); ASSERT(-1, ({ struct bit1 x={1,2,3,4,5}; x.c; })); ASSERT(-4, ({ struct bit1 x={1,2,3,4,5}; x.d; })); ASSERT(-3, ({ struct bit1 x={1,2,3,4,5}; x.e; })); ASSERT(1, g45.a); ASSERT(2, g45.b); ASSERT(3, g45.c); ASSERT(0, g46.a); ASSERT(0, g46.b); ASSERT(0, g46.c); typedef struct { int a : 10; int b : 10; int c : 10; } T3; ASSERT(1, ({ T3 x={1,2,3}; x.a++; })); ASSERT(2, ({ T3 x={1,2,3}; x.b++; })); ASSERT(3, ({ T3 x={1,2,3}; x.c++; })); ASSERT(2, ({ T3 x={1,2,3}; ++x.a; })); ASSERT(3, ({ T3 x={1,2,3}; ++x.b; })); ASSERT(4, ({ T3 x={1,2,3}; ++x.c; })); ASSERT(4, sizeof(struct {int a:3; int c:1; int c:5;})); ASSERT(8, sizeof(struct {int a:3; int:0; int c:5;})); ASSERT(4, sizeof(struct {int a:3; int:0;})); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/bitwise.c000066400000000000000000000031641505335450300161200ustar00rootroot00000000000000 #include #include "test.h" const uint8_t pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; void test_bitwise_operations() { uint64_t num = 9223372036854775807; uint64_t word = num - 1; int shift = 64 - 8; printf("Testing num: %lu\n", num); printf("Initial word: %lu\n", word); ASSERT(9223372036854775807, num); ASSERT(9223372036854775806, word); while ((word >> shift) == 0) { shift -= 8; printf("Shift: %d, word: %lu\n", shift, word >> shift); } printf("Final shift: %d\n", shift); ASSERT(56, shift); int pos = shift + pg_leftmost_one_pos[(word >> shift) & 255]; printf("Computed pos: %d\n", pos); ASSERT(62, pos); printf("Computed log2: %d\n", pos + 1); ASSERT(63, pos + 1); } int main() { test_bitwise_operations(); return 0; } chibicc-1.0.23.1/test/bitwise2.c000066400000000000000000000043721505335450300162040ustar00rootroot00000000000000 #include #include #include "test.h" const uint8_t pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; static inline int pg_leftmost_one_pos64(uint64_t word) { int shift = 64 - 8; while ((word >> shift) == 0) { shift -= 8; } int pos = shift + pg_leftmost_one_pos[(word >> shift) & 255]; return pos; } static inline int pg_ceil_log2_64(uint64_t num) { if (num < 2) return 0; else return pg_leftmost_one_pos64(num - 1) + 1; } static int my_log2(long num) { if (num > LONG_MAX / 2) num = LONG_MAX / 2; // Assuming SIZEOF_LONG >= 8 return pg_ceil_log2_64(num); } static int next_pow2_int(long num) { if (num > INT_MAX / 2) num = INT_MAX / 2; int log2 = my_log2(num); return 1 << log2; } int main() { long test_values[] = {1, 2, 3, 536870912, LONG_MAX}; for (int i = 0; i < sizeof(test_values) / sizeof(test_values[0]); ++i) { printf("Input: %ld, next_pow2_int: %d\n", test_values[i], next_pow2_int(test_values[i])); if (i == 0) ASSERT(1, next_pow2_int(test_values[i]) ); else if (i == 1) ASSERT(2, next_pow2_int(test_values[i]) ); else if (i == 2) ASSERT(4, next_pow2_int(test_values[i]) ); else if (i == 3) ASSERT(536870912, next_pow2_int(test_values[i]) ); else if (i == 4) ASSERT(1073741824, next_pow2_int(test_values[i]) ); } return 0; } chibicc-1.0.23.1/test/builtin.c000077500000000000000000000032701505335450300161210ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(1, __builtin_types_compatible_p(int, int)); ASSERT(1, __builtin_types_compatible_p(double, double)); ASSERT(0, __builtin_types_compatible_p(int, long)); ASSERT(0, __builtin_types_compatible_p(long, float)); ASSERT(1, __builtin_types_compatible_p(int *, int *)); ASSERT(0, __builtin_types_compatible_p(short *, int *)); ASSERT(0, __builtin_types_compatible_p(int **, int *)); ASSERT(1, __builtin_types_compatible_p(const int, int)); ASSERT(0, __builtin_types_compatible_p(unsigned, int)); ASSERT(1, __builtin_types_compatible_p(signed, int)); ASSERT(0, __builtin_types_compatible_p(struct {int a;}, struct {int a;})); ASSERT(1, __builtin_types_compatible_p(int (*)(void), int (*)(void))); ASSERT(1, __builtin_types_compatible_p(void (*)(int), void (*)(int))); ASSERT(1, __builtin_types_compatible_p(void (*)(int, double), void (*)(int, double))); ASSERT(1, __builtin_types_compatible_p(int (*)(float, double), int (*)(float, double))); ASSERT(0, __builtin_types_compatible_p(int (*)(float, double), int)); ASSERT(0, __builtin_types_compatible_p(int (*)(float, double), int (*)(float))); ASSERT(0, __builtin_types_compatible_p(int (*)(float, double), int (*)(float, double, int))); ASSERT(1, __builtin_types_compatible_p(double (*)(...), double (*)(...))); ASSERT(0, __builtin_types_compatible_p(double (*)(...), double (*)(void))); ASSERT(1, ({ typedef struct {int a;} T; __builtin_types_compatible_p(T, T); })); ASSERT(1, ({ typedef struct {int a;} T; __builtin_types_compatible_p(T, const T); })); ASSERT(1, ({ struct {int a; int b;} x; __builtin_types_compatible_p(typeof(x.a), typeof(x.b)); })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_add_overflow.c000066400000000000000000000007311505335450300206500ustar00rootroot00000000000000 #include "test.h" int main() { int result; if (__builtin_add_overflow(54, 1, &result)) { printf("Overflow detected!\n"); } else { printf("Overflow not detected!\n"); } ASSERT(0, __builtin_add_overflow(54, 1, &result)); printf("second test\n"); if (__builtin_add_overflow(2147483647, 1, &result)) { printf("Overflow detected!\n"); } ASSERT(1, __builtin_add_overflow(2147483647, 1, &result)); return 0; } chibicc-1.0.23.1/test/builtin_addsd.c000066400000000000000000000005301505335450300172510ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); int main() { double2 a = {1.0, 2.0}; double2 b = {3.0, 4.0}; double2 c = __builtin_ia32_addsd(a, b); printf("%.1f %.1f\n", c[0], c[1]); // Expected: 4.0 2.0 ASSERT(4, c[0]); ASSERT(2, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_addss.c000066400000000000000000000011411505335450300172670ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { // Initialize full 4-float vectors v4sf va = {1.5f, 3.3f, 4.4f, 5.5f}; v4sf vb = {2.5f, 6.7f, 3.6f, 7.5f}; // Perform scalar single-float addition on lowest elements v4sf vc = __builtin_ia32_addss(va, vb); // Extract the scalar result (lowest float) float result = ((float*)&vc)[0]; printf("result = %f\n", result); // Should print 4.0 ASSERT(4, vc[0]); ASSERT(3, vc[1]); ASSERT(4, vc[2]); ASSERT(5, vc[3]); ASSERT(4, result); return 0; } chibicc-1.0.23.1/test/builtin_andnpd.c000066400000000000000000000007131505335450300174410ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_andnpd(a, b); // Print the raw bits as unsigned long long to see AND effect unsigned long long *p = (unsigned long long *)&c; printf("andpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_andnps.c000066400000000000000000000007741505335450300174670ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0x55555555}; v4sf b = {0x0F0F0F0F, 0xF0F0F0F0, 0xAAAAAAAA, 0xFFFFFFFF}; v4sf c = __builtin_ia32_andnps(a, b); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08X\n", i, *(unsigned int*)&c[i]); } ASSERT(0, c[0]); ASSERT(-2147483648, c[1]); ASSERT(0, c[2]); ASSERT(0, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_andpd.c000066400000000000000000000007751505335450300172730ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); extern v2df __builtin_ia32_andpd(v2df a, v2df b); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_andpd(a, b); // Print the raw bits as unsigned long long to see AND effect unsigned long long *p = (unsigned long long *)&c; printf("andpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_andps.c000066400000000000000000000010141505335450300172750ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {0xFFFFFFFF, 0x00000000, 0xAAAAAAAA, 0x55555555}; v4sf b = {0x0F0F0F0F, 0xF0F0F0F0, 0xAAAAAAAA, 0xFFFFFFFF}; v4sf c = __builtin_ia32_andps(a, b); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08X\n", i, *(unsigned int*)&c[i]); } ASSERT(134217728, c[0]); ASSERT(0, c[1]); ASSERT(-2147483648, c[2]); ASSERT(1073741824, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_bswap.c000066400000000000000000000017521505335450300173150ustar00rootroot00000000000000 #include #include // For PRIx macros #include "test.h" int main() { // Example values uint16_t value16 = 0x1234; uint32_t value32 = 0x12345678; uint64_t value64 = 0x123456789ABCDEF0; // Perform byte-swapping using built-in functions uint16_t swapped16 = __builtin_bswap16(value16); uint32_t swapped32 = __builtin_bswap32(value32); uint64_t swapped64 = __builtin_bswap64(value64); // Print original and swapped values printf("Original 16-bit value: 0x%04" PRIx16 "\n", value16); printf("Swapped 16-bit value: 0x%04" PRIx16 "\n", swapped16); ASSERT(0x3412, swapped16); printf("Original 32-bit value: 0x%08" PRIx32 "\n", value32); printf("Swapped 32-bit value: 0x%08" PRIx32 "\n", swapped32); ASSERT(0x78563412, swapped32); printf("Original 64-bit value: 0x%016" PRIx64 "\n", value64); printf("Swapped 64-bit value: 0x%016" PRIx64 "\n", swapped64); ASSERT(0xf0debc9a78563412, swapped64); return 0; } chibicc-1.0.23.1/test/builtin_choose_expr.c000066400000000000000000000004651505335450300205170ustar00rootroot00000000000000 #include #include "test.h" #define ARRAY_SIZE(x) (__builtin_choose_expr(!__builtin_types_compatible_p(typeof(x), typeof(&*(x))), sizeof(x) / sizeof((x)[0]), (void)0)) int main() { int arr[10]; printf("Array size: %lu\n", ARRAY_SIZE(arr)); ASSERT(10, ARRAY_SIZE(arr)); return 0; } chibicc-1.0.23.1/test/builtin_clflush.c000066400000000000000000000010761505335450300176400ustar00rootroot00000000000000#include // For _mm_clflush #include "test.h" // Simple test function void test_flush(void *p) { // GCC/Clang builtin form __builtin_ia32_clflush(p); // SSE2 intrinsic form _mm_clflush(p); } int main(void) { char buf[64]; // Write something so it’s in cache for (int i = 0; i < sizeof(buf); i++) buf[i] = (char)i; // Call flush test_flush(buf); // Do something else buf[0] = 42; printf("%d\n", buf[0]); ASSERT(42, buf[0]); ASSERT(1, buf[1]); return 0; } chibicc-1.0.23.1/test/builtin_clz.c000066400000000000000000000003561505335450300167700ustar00rootroot00000000000000 #include "test.h" int main() { int leading_zeros = __builtin_clz(8); // 8 is 1000 in binary, so leading_zeros is 28 on a 32-bit system printf("Leading zeros: %d\n", leading_zeros); ASSERT(28, leading_zeros); return 0; } chibicc-1.0.23.1/test/builtin_clzl.c000066400000000000000000000026131505335450300171420ustar00rootroot00000000000000 #include #include "test.h" void print_value(long value) { printf("Value in RAX: %ld\n", value); } // Function prototype for the test function unsigned int my_clzl(long x); int main() { // Test values long test_values[] = { 0, // Should return 63 (all bits are zeros) 1, // Should return 63 (1 << 63 has one leading zero) 0xFFFFFFFFFFFFFFFE, // Should return 0 (64-bit value with a single bit set) 0x8000000000000000, // Should return 0 (64-bit value with the highest bit set) 0x7FFFFFFFFFFFFFFF, // Should return 1 (all bits except the highest are set) 0xFFFFFFFFFFFFFFFF // Should return 0 (all bits are set) }; // Test the `__builtin_clzl` function for (int i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) { long value = test_values[i]; unsigned int result = my_clzl(value); printf("my_clzl(%ld) = %u\n", value, result); if (i == 0 || i == 1) ASSERT(63, result ); else if (i == 2 || i == 3 || i == 5) ASSERT(0, result); else if (i == 4) ASSERT(1, result ); } return 0; } // Dummy implementation of `__builtin_clzl` for demonstration // In your real code, this would be replaced by the actual built-in function unsigned int my_clzl(long x) { return __builtin_clzl(x); } chibicc-1.0.23.1/test/builtin_cmpeqpd.c000066400000000000000000000007171505335450300176320ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df c = __builtin_ia32_cmpeqpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpeqpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpeqps.c000066400000000000000000000011341505335450300176430ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 5.0f, 3.0f, 7.0f}; v4sf res = __builtin_ia32_cmpeqps(a, b); unsigned int *p = (unsigned int*)&res; // Each lane will be 0xffffffff if equal, else 0 printf("cmpeqps results:\n"); for (int i = 0; i < 4; i++) { printf("lane %d: 0x%x\n", i, p[i]); } ASSERT(-2147483648, res[0]); ASSERT(0, res[1]); ASSERT(-2147483648, res[2]); ASSERT(0, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpeqsd.c000066400000000000000000000007371505335450300176370ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); v2df my_cmpeqsd(v2df a, v2df b) { return __builtin_ia32_cmpeqsd(a, b); } int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = my_cmpeqsd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(-2147483648, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpeqss.c000066400000000000000000000007751505335450300176600ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 0.0f, 0.0f, 0.0f}; v4sf c = __builtin_ia32_cmpeqss(a, b); printf("c[0] = 0x%X\n", *(unsigned int*)&c[0]); printf("c[1] = %f\n", c[1]); printf("c[2] = %f\n", c[2]); printf("c[3] = %f\n", c[3]); ASSERT(-2147483648, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpgepd.c000066400000000000000000000012251505335450300176130ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 3.5 }; v2df c = __builtin_ia32_cmpgepd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpgepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); c = __builtin_ia32_cmpgepd(d, a); p = (unsigned long long *)&c; printf("cmpgepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpgeps.c000066400000000000000000000014451505335450300176360ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 4.0f, 3.0f, 7.0f}; v4sf b = {1.0f, 2.0f, 3.5f, 5.0f}; // cmpgeps: compare a >= b for each element, result is mask (all bits set or zero) v4sf c = __builtin_ia32_cmpgeps(a, b); // Print results as integers to see the mask bits (0xFFFFFFFF or 0) uint32_t* mask = (uint32_t*)&c; printf("cmpgeps results:\n"); for (int i = 0; i < 4; i++) { printf("a[%d] >= b[%d] : %s (mask=0x%08x)\n", i, i, mask[i] == 0xFFFFFFFF ? "true" : "false", mask[i]); } ASSERT(-2147483648, c[0]); ASSERT(-2147483648, c[1]); ASSERT(0, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpgtpd.c000066400000000000000000000012241505335450300176310ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 3.5 }; v2df c = __builtin_ia32_cmpgtpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpgtpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(-1, p[1]); c = __builtin_ia32_cmpgtpd(d, a); p = (unsigned long long *)&c; printf("cmpgtpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpgtps.c000066400000000000000000000011241505335450300176470ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 3.0f, 5.0f, 7.0f}; v4sf b = {2.0f, 3.0f, 4.0f, 8.0f}; v4sf res = __builtin_ia32_cmpgtps(a, b); unsigned int *p = (unsigned int*)&res; // Each lane will be 0xffffffff if a[i] > b[i], else 0 printf("cmpgtps results:\n"); for (int i = 0; i < 4; i++) { printf("lane %d: 0x%x\n", i, p[i]); } ASSERT(0, res[0]); ASSERT(0, res[1]); ASSERT(-2147483648, res[2]); ASSERT(0, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmplepd.c000066400000000000000000000012261505335450300176210ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 1.5 }; v2df c = __builtin_ia32_cmplepd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmplepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(0, p[1]); c = __builtin_ia32_cmplepd(d, a); p = (unsigned long long *)&c; printf("cmplepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpleps.c000066400000000000000000000011551505335450300176410ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 3.0f, 5.0f, 7.0f}; v4sf b = {2.0f, 3.0f, 4.0f, 8.0f}; v4sf res = __builtin_ia32_cmpleps(a, b); unsigned int *p = (unsigned int*)&res; // Each lane will be 0xffffffff if a[i] <= b[i], else 0 printf("cmpleps results:\n"); for (int i = 0; i < 4; i++) { printf("lane %d: 0x%x\n", i, p[i]); } ASSERT(-2147483648, res[0]); ASSERT(-2147483648, res[1]); ASSERT(0, res[2]); ASSERT(-2147483648, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmplesd.c000066400000000000000000000006311505335450300176230ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmplesd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(-2147483648, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpless.c000066400000000000000000000011551505335450300176440ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.5f, 2.5f, 3.5f, 4.5f}; v4sf b = {1.5f, 2.0f, 4.0f, 5.0f}; v4sf c = __builtin_ia32_cmpless(a, b); printf("c[0] = 0x%X\n", *(unsigned int*)&c[0]); // expect 0xFFFFFFFF because 1.5 <= 1.5 printf("c[1] = %f\n", c[1]); // expect 2.5 (copied from a) printf("c[2] = %f\n", c[2]); // expect 3.5 printf("c[3] = %f\n", c[3]); // expect 4.5 ASSERT(-2147483648, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpltpd.c000066400000000000000000000012251505335450300176370ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 1.5 }; v2df c = __builtin_ia32_cmpltpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpltpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); c = __builtin_ia32_cmpltpd(d, a); p = (unsigned long long *)&c; printf("cmpltpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpltps.c000066400000000000000000000011421505335450300176540ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 3.0f, 5.0f, 7.0f}; v4sf b = {2.0f, 3.0f, 4.0f, 8.0f}; v4sf res = __builtin_ia32_cmpltps(a, b); unsigned int *p = (unsigned int*)&res; // Each lane will be 0xffffffff if a[i] < b[i], else 0 printf("cmpltps results:\n"); for (int i = 0; i < 4; i++) { printf("lane %d: 0x%x\n", i, p[i]); } ASSERT(-2147483648, res[0]); ASSERT(0, res[1]); ASSERT(0, res[2]); ASSERT(-2147483648, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpltsd.c000066400000000000000000000006171505335450300176460ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmpltsd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(0, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpltss.c000066400000000000000000000011501505335450300176560ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {2.0f, 2.0f, 2.0f, 2.0f}; v4sf c = __builtin_ia32_cmpltss(a, b); printf("c[0] = 0x%X\n", *(unsigned int*)&c[0]); // expect 0xFFFFFFFF because 1.0 < 2.0 printf("c[1] = %f\n", c[1]); // expect 2.0 (copied from a) printf("c[2] = %f\n", c[2]); // expect 3.0 printf("c[3] = %f\n", c[3]); // expect 4.0 ASSERT(-2147483648, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpneqpd.c000066400000000000000000000007211505335450300200030ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df c = __builtin_ia32_cmpneqpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpneqpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(-1, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpneqps.c000066400000000000000000000011631505335450300200230ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 0.0f, 3.0f, 5.0f}; // Perform vector comparison: not equal (cmpneqps) v4sf c = __builtin_ia32_cmpneqps(a, b); // Print results as int masks (0xffffffff for true, 0 for false) unsigned int *res = (unsigned int*)&c; for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x\n", i, res[i]); } ASSERT(0, c[0]); ASSERT(-2147483648, c[1]); ASSERT(0, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpneqsd.c000066400000000000000000000006201505335450300200040ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmpneqsd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(0, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpneqss.c000066400000000000000000000011071505335450300200240ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {2.0f, 2.0f, 3.0f, 4.0f}; v4sf c = __builtin_ia32_cmpneqss(a, b); printf("cmpneqss result: %x %x %x %x\n", ((unsigned int*)&c)[0], ((unsigned int*)&c)[1], ((unsigned int*)&c)[2], ((unsigned int*)&c)[3]); // Expected: lowest uint is 0xFFFFFFFF (true), rest are 0 ASSERT(-2147483648, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpngepd.c000066400000000000000000000012311505335450300177660ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 3.5 }; v2df c = __builtin_ia32_cmpngepd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpngepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); c = __builtin_ia32_cmpngepd(d, a); p = (unsigned long long *)&c; printf("cmpngepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpngeps.c000066400000000000000000000010741505335450300200120ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 5.0f, 3.0f, 7.0f}; v4sf b = {2.0f, 4.0f, 3.0f, 8.0f}; // cmpngeps: !(a[i] >= b[i]) v4sf c = __builtin_ia32_cmpngeps(a, b); unsigned int *r = (unsigned int *)&c; printf("cmpngeps results:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x\n", i, r[i]); } ASSERT(-2147483648, c[0]); ASSERT(0, c[1]); ASSERT(0, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpngtpd.c000066400000000000000000000012321505335450300200060ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 3.5 }; v2df c = __builtin_ia32_cmpngtpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpngtpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(0, p[1]); c = __builtin_ia32_cmpngtpd(d, a); p = (unsigned long long *)&c; printf("cmpngtpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpngtps.c000066400000000000000000000010461505335450300200300ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 5.0f, 3.0f, 7.0f}; v4sf b = {2.0f, 4.0f, 3.0f, 8.0f}; v4sf c = __builtin_ia32_cmpngtps(a, b); unsigned int *r = (unsigned int *)&c; printf("cmpngtps results:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x\n", i, r[i]); } ASSERT(-2147483648, c[0]); ASSERT(0, c[1]); ASSERT(-2147483648, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnlepd.c000066400000000000000000000012301505335450300177720ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 3.5 }; v2df c = __builtin_ia32_cmpnlepd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpnlepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(-1, p[1]); c = __builtin_ia32_cmpnlepd(d, a); p = (unsigned long long *)&c; printf("cmpnlepd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnleps.c000066400000000000000000000013331505335450300200150ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 1.5f, 3.5f, 4.0f}; // __builtin_ia32_cmpnleps returns a mask vector where // each element is 0xFFFFFFFF if !(a[i] <= b[i]) (i.e. a[i] > b[i]), // else 0x0. v4sf c = __builtin_ia32_cmpnleps(a, b); uint32_t *res = (uint32_t *)&c; printf("cmpnleps results:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x => %s\n", i, res[i], res[i] ? "true" : "false"); } ASSERT(0, c[0]); ASSERT(-2147483648, c[1]); ASSERT(0, c[2]); ASSERT(0, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnlesd.c000066400000000000000000000006201505335450300177770ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmpnlesd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(0, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnless.c000066400000000000000000000011501505335450300200150ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {3.0f, 3.0f, 4.0f, 5.0f}; v4sf b = {2.0f, 3.0f, 4.0f, 5.0f}; v4sf c = __builtin_ia32_cmpnless(a, b); printf("cmpnlessss result: %x %x %x %x\n", ((unsigned int*)&c)[0], ((unsigned int*)&c)[1], ((unsigned int*)&c)[2], ((unsigned int*)&c)[3]); // Expected lowest uint is 0xFFFFFFFF (true because 3.0 > 2.0) ASSERT(-2147483648, c[0]); ASSERT(3, c[1]); ASSERT(4, c[2]); ASSERT(5, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnltpd.c000066400000000000000000000012311505335450300200120ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df d = { 0.8, 3.5 }; v2df c = __builtin_ia32_cmpnltpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpnltpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); c = __builtin_ia32_cmpnltpd(d, a); p = (unsigned long long *)&c; printf("cmpnltpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnltps.c000066400000000000000000000007671505335450300200460ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 4.0f, 3.0f, 6.0f}; v4sf b = {2.0f, 3.0f, 3.0f, 7.0f}; v4sf c = __builtin_ia32_cmpnltps(a, b); unsigned int *res = (unsigned int*)&c; for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x\n", i, res[i]); } ASSERT(0, c[0]); ASSERT(-2147483648, c[1]); ASSERT(-2147483648, c[2]); ASSERT(0, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnltsd.c000066400000000000000000000006321505335450300200210ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmpnltsd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(-2147483648, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpnltss.c000066400000000000000000000010711505335450300200360ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {2.0f, 3.0f, 4.0f, 5.0f}; v4sf b = {1.0f, 3.0f, 4.0f, 5.0f}; v4sf c = __builtin_ia32_cmpnltss(a, b); printf("cmpnltss result: %x %x %x %x\n", ((unsigned int*)&c)[0], ((unsigned int*)&c)[1], ((unsigned int*)&c)[2], ((unsigned int*)&c)[3]); // Expected lowest uint is 0xFFFFFFFF (true because 2.0 >= 1.0) ASSERT(-2147483648, c[0]); ASSERT(3, c[1]); ASSERT(4, c[2]); ASSERT(5, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpordpd.c000066400000000000000000000007221505335450300200050ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df c = __builtin_ia32_cmpordpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpordpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(-1, p[0]); ASSERT(-1, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpordps.c000066400000000000000000000012071505335450300200230ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, NAN, 3.0f, 4.0f}; v4sf b = {2.0f, 5.0f, NAN, 4.0f}; // cmpordps returns true (all bits set) if neither element is NaN, false (0) otherwise v4sf c = __builtin_ia32_cmpordps(a, b); unsigned int *r = (unsigned int *)&c; printf("cmpordps results:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x\n", i, r[i]); } ASSERT(-2147483648, c[0]); ASSERT(0, c[1]); ASSERT(0, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpordsd.c000066400000000000000000000006321505335450300200100ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmpordsd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(-2147483648, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpordss.c000066400000000000000000000013101505335450300200210ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {0.0f / 0.0f, 5.0f, 6.0f, 7.0f}; // b[0] = NaN // cmpordss returns all bits set in lowest float if both are ordered (not NaN) v4sf res = __builtin_ia32_cmpordss(a, b); unsigned int *p = (unsigned int*)&res; printf("cmpordss result (lowest float mask): 0x%x\n", p[0]); // Expected: // p[0] == 0 if unordered (because b[0] is NaN) // Other lanes are undefined (only lowest lane is relevant) ASSERT(0, res[0]); ASSERT(2, res[1]); ASSERT(3, res[2]); ASSERT(4, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpunordpd.c000066400000000000000000000007241505335450300203520ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 1.0, 2.0 }; v2df c = __builtin_ia32_cmpunordpd(a, b); // Cast to unsigned long long to see raw comparison result bits unsigned long long *p = (unsigned long long *)&c; printf("cmpunordpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpunordps.c000066400000000000000000000012141505335450300203640ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, NAN, 3.0f, 4.0f}; v4sf b = {2.0f, 5.0f, NAN, 4.0f}; // cmpunordps returns true (all bits set) if either element is NaN, false (0) otherwise v4sf c = __builtin_ia32_cmpunordps(a, b); unsigned int *r = (unsigned int *)&c; printf("cmpunordps results:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08x\n", i, r[i]); } ASSERT(0, c[0]); ASSERT(-2147483648, c[1]); ASSERT(-2147483648, c[2]); ASSERT(0, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpunordsd.c000066400000000000000000000006221505335450300203520ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df a = {1.0, 99.0}; v2df b = {1.0, 77.0}; v2df r = __builtin_ia32_cmpunordsd(a, b); printf("Result: [%llx, %llx]\n", ((unsigned long long*)&r)[0], ((unsigned long long*)&r)[1]); ASSERT(0, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cmpunordss.c000066400000000000000000000013201505335450300203650ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {0.0f / 0.0f, 5.0f, 6.0f, 7.0f}; // b[0] = NaN // cmpunordss returns all bits set in lowest float if unordered (NaN involved) v4sf res = __builtin_ia32_cmpunordss(a, b); unsigned int *p = (unsigned int*)&res; printf("cmpunordss result (lowest float mask): 0x%x\n", p[0]); // Expected: // p[0] == 0xffffffff since b[0] is NaN // Other lanes are undefined (only lowest lane is relevant) ASSERT(-2147483648, res[0]); ASSERT(2, res[1]); ASSERT(3, res[2]); ASSERT(4, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comieq.c000066400000000000000000000007061505335450300174540ustar00rootroot00000000000000 #include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main(void) { __v4sf a = {4.0f, 3.0f, 2.0f, 1.0f}; __v4sf b = {4.0f, 3.0f, 2.0f, 1.0f}; // Compare the lowest float elements of a and b for equality int result = __builtin_ia32_comieq((__v4sf)a, (__v4sf)b); printf("Lowest elements are equal? %s\n", result ? "Yes" : "No"); ASSERT(1, result); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comige.c000066400000000000000000000005561505335450300174450ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4sf a = {7.0f, 1.0f, 2.0f, 1.0f}; __v4sf b = {7.0f, 4.0f, 2.0f, 0.0f}; // Compare: returns int (from low float) int res = __builtin_ia32_comige(a, b); printf("Result: %d\n", res); ASSERT(1, res); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comigt.c000066400000000000000000000005561505335450300174640ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4sf a = {5.0f, 1.0f, 2.0f, 1.0f}; __v4sf b = {7.0f, 4.0f, 2.0f, 0.0f}; // Compare: returns int (from low float) int res = __builtin_ia32_comigt(a, b); printf("Result: %d\n", res); ASSERT(0, res); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comile.c000066400000000000000000000005561505335450300174520ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4sf a = {7.0f, 5.0f, 3.0f, 1.0f}; __v4sf b = {7.0f, 4.0f, 2.0f, 0.0f}; // Compare: returns int (from low float) int res = __builtin_ia32_comile(a, b); printf("Result: %d\n", res); ASSERT(1, res); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comilt.c000066400000000000000000000005561505335450300174710ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4sf a = {8.0f, 5.0f, 3.0f, 1.0f}; __v4sf b = {7.0f, 4.0f, 2.0f, 0.0f}; // Compare: returns int (from low float) int res = __builtin_ia32_comilt(a, b); printf("Result: %d\n", res); ASSERT(0, res); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comineq.c000066400000000000000000000015711505335450300176330ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 3.0f, 3.0f, 5.0f}; v4sf c = {0.0f, 2.0f, 0.0f, 4.0f}; // Compare a and b: expect 0 for equal (index 0 and 2), 1 for not equal (index 1 and 3) int res1 = __builtin_ia32_comineq(a, b); printf("comineq(a, b) = %d (expected non-zero because a != b)\n", res1); // Compare a and c: expect non-zero because many elements differ int res2 = __builtin_ia32_comineq(a, c); printf("comineq(a, c) = %d (expected non-zero)\n", res2); // Compare a and a: expect zero because they are equal int res3 = __builtin_ia32_comineq(a, a); printf("comineq(a, a) = %d (expected zero)\n", res3); ASSERT(0, res1); ASSERT(1, res2); ASSERT(0, res3); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comisdeq.c000066400000000000000000000023151505335450300200010ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element int result = __builtin_ia32_comisdeq(v1, v2); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdeq(v1, v3); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdeq(vnan, v1); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdeq(v1, vnan); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdeq(vnan, vnan); printf("result = %d\n", result); ASSERT(1, result); // Only low element (index 0) is compared! // test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); // test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); // test_case(vnan, v1, "NaN vs normal"); // test_case(v1, vnan, "Normal vs NaN"); // test_case(vnan, vnan, "NaN vs NaN"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comisdge.c000066400000000000000000000023131505335450300177650ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element int result = __builtin_ia32_comisdge(v1, v2); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdge(v1, v3); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdge(vnan, v1); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdge(v1, vnan); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdge(vnan, vnan); printf("result = %d\n", result); ASSERT(1, result); // Only low element (index 0) is compared! // test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); // test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); // test_case(vnan, v1, "NaN vs normal"); // test_case(v1, vnan, "Normal vs NaN"); // test_case(vnan, vnan, "NaN vs NaN"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comisdgt.c000066400000000000000000000023131505335450300200040ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element int result = __builtin_ia32_comisdgt(v1, v2); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdgt(v1, v3); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdgt(vnan, v1); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdgt(v1, vnan); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdgt(vnan, vnan); printf("result = %d\n", result); ASSERT(0, result); // Only low element (index 0) is compared! // test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); // test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); // test_case(vnan, v1, "NaN vs normal"); // test_case(v1, vnan, "Normal vs NaN"); // test_case(vnan, vnan, "NaN vs NaN"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comisdle.c000066400000000000000000000023131505335450300177720ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element int result = __builtin_ia32_comisdle(v1, v2); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdle(v1, v3); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdle(vnan, v1); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdle(v1, vnan); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdle(vnan, vnan); printf("result = %d\n", result); ASSERT(1, result); // Only low element (index 0) is compared! // test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); // test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); // test_case(vnan, v1, "NaN vs normal"); // test_case(v1, vnan, "Normal vs NaN"); // test_case(vnan, vnan, "NaN vs NaN"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comisdlt.c000066400000000000000000000023131505335450300200110ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element int result = __builtin_ia32_comisdlt(v1, v2); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdlt(v1, v3); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdlt(vnan, v1); printf("result = %d\n", result); ASSERT(0, result); result = __builtin_ia32_comisdlt(v1, vnan); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdlt(vnan, vnan); printf("result = %d\n", result); ASSERT(0, result); // Only low element (index 0) is compared! // test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); // test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); // test_case(vnan, v1, "NaN vs normal"); // test_case(v1, vnan, "Normal vs NaN"); // test_case(vnan, vnan, "NaN vs NaN"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comisdneq.c000066400000000000000000000023201505335450300201530ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element int result = __builtin_ia32_comisdneq(v1, v2); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdneq(v1, v3); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdneq(vnan, v1); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdneq(v1, vnan); printf("result = %d\n", result); ASSERT(1, result); result = __builtin_ia32_comisdneq(vnan, vnan); printf("result = %d\n", result); ASSERT(0, result); // Only low element (index 0) is compared! // test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); // test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); // test_case(vnan, v1, "NaN vs normal"); // test_case(v1, vnan, "Normal vs NaN"); // test_case(vnan, vnan, "NaN vs NaN"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_comixx.c000066400000000000000000000045131505335450300175060ustar00rootroot00000000000000#include "test.h" // If you want to avoid xmmintrin.h, define the builtins manually: typedef float v4sf __attribute__((vector_size(16))); static inline int test_comieq(v4sf A, v4sf B) { return __builtin_ia32_comieq((v4sf)A, (v4sf)B); } static inline int test_comineq(v4sf A, v4sf B) { return __builtin_ia32_comineq((v4sf)A, (v4sf)B); } static inline int test_comile(v4sf A, v4sf B) { return __builtin_ia32_comile((v4sf)A, (v4sf)B); } static inline int test_comigt(v4sf A, v4sf B) { return __builtin_ia32_comigt((v4sf)A, (v4sf)B); } static inline int test_comilt(v4sf A, v4sf B) { return __builtin_ia32_comilt((v4sf)A, (v4sf)B); } int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 3.0f, 2.0f, 4.0f}; v4sf c = {1.0f/0.0f, 2.0f, 3.0f, 4.0f}; // c[0] = +inf to test NaN/unordered behavior printf("comieq (a, b): %d\n", test_comieq(a, b)); // expect 0 (not equal) ASSERT(1, test_comieq(a, b)); printf("comieq (a, a): %d\n", test_comieq(a, a)); // expect 1 (equal) ASSERT(1, test_comieq(a, a)); printf("comineq (a, b): %d\n", test_comineq(a, b)); // expect 1 (not equal) ASSERT(0, test_comineq(a, b)); printf("comineq (a, a): %d\n", test_comineq(a, a)); // expect 0 (equal) ASSERT(0, test_comineq(a, a)); printf("comile (a, b): %d\n", test_comile(a, b)); // expect 1 (1 <= 1) ASSERT(1, test_comile(a, b)); printf("comile (b, a): %d\n", test_comile(b, a)); // expect 0 (3 <= 1 false) ASSERT(1, test_comile(b, a)); printf("comile (a, c): %d\n", test_comile(a, c)); // behavior with +inf ASSERT(1, test_comile(a, c)); printf("comigt (a, b): %d\n", test_comigt(a, b)); // expect 0 (1 > 1 false) ASSERT(0, test_comigt(a, b)); printf("comigt (b, a): %d\n", test_comigt(b, a)); // expect 1 (3 > 1) ASSERT(0, test_comigt(b, a)); printf("comigt (a, c): %d\n", test_comigt(a, c)); // behavior with +inf printf("comilt (a, b): %d\n", test_comilt(a, b)); // expect 0 (1 < 1 false) ASSERT(0, test_comilt(a, b)); printf("comilt (b, a): %d\n", test_comilt(b, a)); // expect 0 (3 < 1 false) ASSERT(0, test_comilt(b, a)); printf("comilt (a, c): %d\n", test_comilt(a, c)); // behavior with +inf ASSERT(1, test_comilt(a, c)); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_ctz.c000066400000000000000000000003411505335450300167720ustar00rootroot00000000000000 #include "test.h" int main() { int trailing_zeros = __builtin_ctz(16); // 16 is 10000 in binary, so trailing_zeros is 4 printf("Trailing zeros: %d\n", trailing_zeros); ASSERT(4, trailing_zeros); return 0; } chibicc-1.0.23.1/test/builtin_cvtdq2pd.c000066400000000000000000000007431505335450300177270ustar00rootroot00000000000000 #include "test.h" typedef int __v4si __attribute__((vector_size(16))); typedef double __v2df __attribute__((vector_size(16))); int main() { __v4si src = { 42, -100 , 80, -200}; // actually only low 64 bits used here __v2df result = __builtin_ia32_cvtdq2pd((__v4si)src); printf("result[0] = %f\n", result[0]); printf("result[1] = %f\n", result[1]); ASSERT(42, result[0]); ASSERT(-100, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtdq2ps.c000066400000000000000000000011741505335450300177450ustar00rootroot00000000000000 #include "test.h" typedef int __v4si __attribute__((vector_size(16))); typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4si src = { 42, -100 , 80, -200}; // actually only low 64 bits used here __v4sf result = __builtin_ia32_cvtdq2ps((__v4si)src); printf("result[0] = %f\n", result[0]); printf("result[1] = %f\n", result[1]); printf("result[2] = %f\n", result[2]); printf("result[3] = %f\n", result[3]); ASSERT(42, result[0]); ASSERT(-100, result[1]); ASSERT(80, result[2]); ASSERT(-200, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtp2ips.c000066400000000000000000000017441505335450300177540ustar00rootroot00000000000000//#include #include "test.h" typedef int __m64 __attribute__((vector_size(8))); typedef float __m128 __attribute__((vector_size(16))); int main() { __m128 a = (__m128){100.0f, 200.0f, 300.0f, 400.0f}; // upper 2 will be kept __m64 b = (__m64){1, 2}; // lower 2 will be converted to float printf("a = %lld %lld\n", ((__int64_t *)&a)[0], ((__int64_t *)&a)[1]); int *p = (int *)&b; printf("b = %d %d\n", p[0], p[1]); // Correct: 1 2 ASSERT(1, p[0]); ASSERT(2, p[1]); float *p2 = (float *)&a; printf("a = %f %f %f %f\n", a[0], a[1], a[2], a[3]); ASSERT(100, a[0]); ASSERT(200, a[1]); ASSERT(300, a[2]); ASSERT(400, a[3]); __m128 result = __builtin_ia32_cvtpi2ps(a, b); float *f = (float *)&result; printf("%f %f %f %f\n", f[0], f[1], f[2], f[3]); ASSERT(1, f[0]); ASSERT(2, f[1]); ASSERT(300, f[2]); ASSERT(400, f[3]); return 0; } chibicc-1.0.23.1/test/builtin_cvtpd2dq.c000066400000000000000000000010761505335450300177270ustar00rootroot00000000000000 #include "test.h" typedef double v2df __attribute__((vector_size(16))); typedef int v4si __attribute__((vector_size(16))); v4si convert_double_to_int(v2df a) { return (v4si)__builtin_ia32_cvtpd2dq(a); } int main(void) { v2df a = { 1.5, -2.9 }; v4si b = convert_double_to_int(a); // Only first 2 elements contain results; rest are undefined/zero printf("Converted: %d %d %d %d\n", b[0], b[1], b[2], b[3]); ASSERT(2, b[0]); ASSERT(-3, b[1]); ASSERT(0, b[2]); ASSERT(0, b[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtpd2pi.c000066400000000000000000000007411505335450300177310ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); typedef int v2si __attribute__((vector_size(8))); // 2×32-bit ints in 64-bit MMX register v2si convert_double_to_mmx(v2df a) { return (v2si)__builtin_ia32_cvtpd2pi(a); } int main(void) { v2df a = { 3.8, -4.2 }; v2si b = convert_double_to_mmx(a); printf("Converted: %d %d\n", b[0], b[1]); ASSERT(4, b[0]); ASSERT(-4, b[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtpd2ps.c000066400000000000000000000010061505335450300177360ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); typedef double __v2df __attribute__((vector_size(16))); __v4sf test_cvtpd2ps(__v2df a) { return (__v4sf)__builtin_ia32_cvtpd2ps(a); } #include int main() { __v2df a = { 1.5, -2.25 }; __v4sf r = test_cvtpd2ps(a); printf("%f %f\n", r[0], r[1]); // upper 2 floats are undefined ASSERT(1, r[0]); ASSERT(-2, r[1]); ASSERT(0, r[2]); ASSERT(0, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtpi2pd.c000066400000000000000000000007541505335450300177350ustar00rootroot00000000000000#include "test.h" typedef int mm64 __attribute__((vector_size(8))); // MMX 64-bit typedef double v2df __attribute__((vector_size(16))); // 2 doubles v2df test_cvtpi2pd(mm64 a) { return __builtin_ia32_cvtpi2pd(a); } int main(void) { mm64 input = { 3, -2 }; // two 32-bit integers v2df output = test_cvtpi2pd(input); printf("%.1f %.1f\n", output[0], output[1]); ASSERT(3, output[0]); ASSERT(-2, output[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtps2dq.c000066400000000000000000000010441505335450300177410ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); typedef int int4 __attribute__((vector_size(16))); int main(void) { float4 a = {1.2f, 2.8f, -3.5f, 4.7f}; // Convert float4 to int4 (truncate) int4 b = __builtin_ia32_cvtps2dq(a); printf("a = {%.1f, %.1f, %.1f, %.1f}\n", a[0], a[1], a[2], a[3]); printf("b = {%d, %d, %d, %d}\n", b[0], b[1], b[2], b[3]); ASSERT(1, b[0]); ASSERT(3, b[1]); ASSERT(-4, b[2]); ASSERT(5, b[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtps2pd.c000066400000000000000000000007601505335450300177440ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); typedef double double2 __attribute__((vector_size(16))); int main(void) { float4 a = {1.5f, -2.25f, 5.4f, 7.8f}; // Convert two floats to two doubles double2 b = __builtin_ia32_cvtps2pd(a); printf("a = {%.2f, %.2f, %.2f, %.2f}\n", a[0], a[1], a[2], a[3]); printf("b = {%.2lf, %.2lf}\n", b[0], b[1]); ASSERT(1, b[0]); ASSERT(-2, b[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtps2pi.c000066400000000000000000000012121505335450300177420ustar00rootroot00000000000000#include "test.h" typedef float __m128 __attribute__((vector_size(16))); typedef int __m64 __attribute__((vector_size(8))); __m64 my_cvtps2pi(__m128 a) { return __builtin_ia32_cvtps2pi(a); } int main() { __m128 floats = {1.5f, 2.5f, 3.5f, 4.5f}; __m64 ints = my_cvtps2pi(floats); printf("floats =%f %f %f %f\n", floats[0], floats[1], floats[2], floats[3]); ASSERT(1, floats[0]); ASSERT(2, floats[1]); ASSERT(3, floats[2]); ASSERT(4, floats[3]); printf("Converted ints: %d %d\n", (int)ints[0], (int)ints[1]); ASSERT(2, (int)ints[0]); ASSERT(2, (int)ints[1]); return 0; } chibicc-1.0.23.1/test/builtin_cvtsd2si.c000066400000000000000000000006421505335450300177370ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d a = {42.75f, 37.8f}; // Convert double to int int b = __builtin_ia32_cvtsd2si(a); printf("a[0] = %.2lf, a[1] = %.2lf\n", a[0], a[1]); ASSERT(42, a[0]); ASSERT(37, a[1]); printf("b = %d\n", b); // Expected: 43 ASSERT(43, b); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtsd2si64.c000066400000000000000000000006541505335450300201140ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d a = {42.75f, 37.8f}; // Convert double to int long long b = __builtin_ia32_cvtsd2si64(a); printf("a[0] = %.2lf, a[1] = %.2lf\n", a[0], a[1]); ASSERT(42, a[0]); ASSERT(37, a[1]); printf("b = %lld\n", b); // Expected: 43 ASSERT(43, b); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtsd2ss.c000066400000000000000000000013401505335450300177450ustar00rootroot00000000000000#include "test.h" typedef double float2 __attribute__((vector_size(16))); typedef float float4 __attribute__((vector_size(16))); int main(void) { float2 src = {3.14159, 2.71828}; // 2 doubles float4 dst = {0.0f, 1.0f, 2.0f, 3.0f}; // 4 floats // Convert lowest double of src to float in lowest element of dst dst = __builtin_ia32_cvtsd2ss(dst, src); printf("dst = {%.6f, %.6f, %.6f, %.6f}\n", dst[0], dst[1], dst[2], dst[3]); // Expected output: // dst[0] = 3.141590 (converted from src[0]) // dst[1..3] unchanged: 1.0, 2.0, 3.0 ASSERT(3, dst[0]); ASSERT(1, dst[1]); ASSERT(2, dst[2]); ASSERT(3, dst[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtsi2sd.c000066400000000000000000000007661505335450300177460ustar00rootroot00000000000000#include "test.h" typedef double float2 __attribute__((vector_size(16))); int main(void) { float2 v = {0.0, 1.0}; // 2 doubles int x = 42; // Convert int x to double and store in the lowest element of v v = __builtin_ia32_cvtsi2sd(v, x); printf("v = {%.1f, %.1f}\n", v[0], v[1]); // Expected output: // v[0] = 42.0 (converted from x) // v[1] = 1.0 (unchanged) ASSERT(42, v[0]); ASSERT(1, v[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtsi642sd.c000066400000000000000000000007701505335450300201130ustar00rootroot00000000000000#include "test.h" typedef double float2 __attribute__((vector_size(16))); int main(void) { float2 v = {0.0, 1.0}; // 2 doubles int x = 42; // Convert int x to double and store in the lowest element of v v = __builtin_ia32_cvtsi642sd(v, x); printf("v = {%.1f, %.1f}\n", v[0], v[1]); // Expected output: // v[0] = 42.0 (converted from x) // v[1] = 1.0 (unchanged) ASSERT(42, v[0]); ASSERT(1, v[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtsi642ss.c000066400000000000000000000010351505335450300201250ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; int64_t b = 42; v4sf c = __builtin_ia32_cvtsi642ss(a, b); printf("c[0] = %f\n", c[0]); // should print 42.0 printf("c[1] = %f\n", c[1]); // should print 2.0 (unchanged) printf("c[2] = %f\n", c[2]); printf("c[3] = %f\n", c[3]); ASSERT(42, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtss2iss.c000066400000000000000000000014111505335450300201340ustar00rootroot00000000000000#include "test.h" // Manually declare the builtin (no xmmintrin.h included) typedef float __v4sf __attribute__((vector_size(16))); __v4sf __builtin_ia32_cvtsi2ss(__v4sf a, int b); int main(void) { __v4sf vec = { 1.0f, 2.0f, 3.0f, 4.0f }; int val = 123; __v4sf result = __builtin_ia32_cvtsi2ss(vec, val); printf("Original vector first element: %.2f\n", vec[0]); printf("Inserted int as float: %.2f\n", result[0]); printf("Other elements unchanged: %.2f, %.2f, %.2f\n", result[1], result[2], result[3]); ASSERT(123, result[0]); ASSERT(1, vec[0]); if ((int)result[0] == val && result[1] == vec[1]) { puts("PASS"); return 0; } else { puts("FAIL"); return 1; } } chibicc-1.0.23.1/test/builtin_cvtss2sd.c000066400000000000000000000011041505335450300177430ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); // 4 floats typedef double v2df __attribute__((vector_size(16))); // 2 doubles int main(void) { v4sf a = { 3.5f, 99.0f, 0.0f, 0.0f }; // source float vector v2df b = { 1.25, 2.5 }; // destination double vector // Convert low float in `a` to double, replacing low double in `b` v2df res = __builtin_ia32_cvtss2sd(b, a); printf("result: %.10f %.10f\n", res[0], res[1]); ASSERT(3, res[0]); ASSERT(2, res[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtss2si.c000066400000000000000000000007741505335450300177640ustar00rootroot00000000000000#include "test.h" // Declare the builtin manually (so we don't need xmmintrin.h) typedef float v4si __attribute__((vector_size(16))); int main(void) { // Create a vector of 4 floats (matches __v4sf) v4si vec = { 42.5f, 2.0f, -3.0f, 99.0f }; // Convert the lowest element to int int result = __builtin_ia32_cvtss2si(vec); printf("Input[0] = %.2f -> int = %d\n", vec[0], result); ASSERT(42, vec[0]); ASSERT(42, result); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvtss2si64.c000066400000000000000000000011371505335450300201300ustar00rootroot00000000000000#include "test.h" // Declare the builtin manually without any headers typedef long long __m128; typedef float __v4sf __attribute__((vector_size(16))); int main(void) { // Create a vector of 4 floats (like __v4sf) __v4sf vec = { 123.456f, 2.0f, -3.0f, 99.0f }; // Convert the lowest float to 64-bit int __m128 result = __builtin_ia32_cvtss2si64(vec); printf("Input[0] = %.3f -> int64 = %lld\n", vec[0], result); if (result == 123) printf("PASS\n"); else printf("FAIL\n"); ASSERT(123, result); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttpd2dq.c000066400000000000000000000011261505335450300201070ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); // 2 doubles typedef int v4si __attribute__((vector_size(16))); // 4 ints v4si test_truncate(v2df a) { return __builtin_ia32_cvttpd2dq(a); } #include int main(void) { v2df input = { 3.9, -2.7 }; // will truncate to {3, -2} v4si output = test_truncate(input); printf("%d %d %d %d\n", output[0], output[1], output[2], output[3]); ASSERT(3, output[0]); ASSERT(-2, output[1]); ASSERT(0, output[2]); ASSERT(0, output[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttpd2pi.c000066400000000000000000000007611505335450300201170ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); // 2 doubles typedef int mm64 __attribute__((vector_size(8))); // MMX 64-bit mm64 test_cvttpd2pi(v2df a) { return __builtin_ia32_cvttpd2pi(a); } int main(void) { v2df input = { 3.9, -2.7 }; mm64 output = test_cvttpd2pi(input); int *p = (int*)&output; printf("%d %d\n", p[0], p[1]); // truncated values ASSERT(3, p[0]); ASSERT(-2, p[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttps2dq.c000066400000000000000000000010451505335450300201260ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); typedef int int4 __attribute__((vector_size(16))); int main(void) { float4 a = {1.2f, 2.8f, -3.5f, 4.7f}; // Convert float4 to int4 (truncate) int4 b = __builtin_ia32_cvttps2dq(a); printf("a = {%.1f, %.1f, %.1f, %.1f}\n", a[0], a[1], a[2], a[3]); printf("b = {%d, %d, %d, %d}\n", b[0], b[1], b[2], b[3]); ASSERT(1, b[0]); ASSERT(2, b[1]); ASSERT(-3, b[2]); ASSERT(4, b[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttps2pi.c000066400000000000000000000023761505335450300201420ustar00rootroot00000000000000#include "test.h" // Define __m64 as a 64-bit integer type to hold MMX registers typedef long long __m64; typedef float __v4sf __attribute__((vector_size(16))); typedef int __v2si __attribute__((vector_size(8))); int main(void) { // Create a vector of 4 floats (like __v4sf) __v4sf vec = { 123.9f, 456.7f, -789.5f, 0.0f }; // Convert the lowest two floats to packed 16-bit ints in MMX register __v2si result = __builtin_ia32_cvttps2pi(vec); // Since we cannot directly print __m64, cast it to unsigned 64-bit for printing unsigned long long packed = (unsigned long long)result; printf("Input floats: %.1f, %.1f\n", vec[0], vec[1]); printf("Packed 16-bit ints: 0x%016llx\n", packed); // Extract low and high 16-bit parts to check correctness short low = (short)(packed & 0xFFFF); short high = (short)((packed >> 16) & 0xFFFF); printf("Extracted 16-bit ints: %d, %d\n", low, high); int *res_ints = (int *)&result; printf("Extracted 32-bit ints: %d, %d\n", res_ints[0], res_ints[1]); ASSERT(123, res_ints[0]); ASSERT(456, res_ints[1]); printf("OK\n"); if (res_ints[0] == 123 && res_ints[1] == 456) { puts("PASS"); return 0; } else { puts("FAIL"); return 1; } } chibicc-1.0.23.1/test/builtin_cvttsd2si.c000066400000000000000000000006431505335450300201240ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d a = {42.75f, 37.8f}; // Convert double to int int b = __builtin_ia32_cvttsd2si(a); printf("a[0] = %.2lf, a[1] = %.2lf\n", a[0], a[1]); ASSERT(42, a[0]); ASSERT(37, a[1]); printf("b = %d\n", b); // Expected: 42 ASSERT(42, b); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttsd2si64.c000066400000000000000000000006551505335450300203010ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); int main(void) { __m128d a = {42.75f, 37.8f}; // Convert double to int long long b = __builtin_ia32_cvttsd2si64(a); printf("a[0] = %.2lf, a[1] = %.2lf\n", a[0], a[1]); ASSERT(42, a[0]); ASSERT(37, a[1]); printf("b = %lld\n", b); // Expected: 42 ASSERT(42, b); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttss2si.c000066400000000000000000000016551505335450300201470ustar00rootroot00000000000000#include "test.h" // Declare the builtin manually without any headers typedef long long __m128; typedef float __v4sf __attribute__((vector_size(16))); // A struct with a float member struct S { float f; }; int main(void) { // Create a vector of 4 floats (like __v4sf) __v4sf vec = { 123.456f, 2.0f, -3.0f, 99.0f }; // Convert the lowest float to 64-bit int __m128 result = __builtin_ia32_cvttss2si(vec); printf("Input[0] = %.3f -> int64 = %lld\n", vec[0], result); if (result == 123) printf("PASS\n"); else printf("FAIL\n"); ASSERT(123, result); struct S s = { 456.25f }; __v4sf member_vec = { s.f, 0.0f, 0.0f, 0.0f }; int result_member = __builtin_ia32_cvttss2si(member_vec); printf("Struct member float: %.2f -> int: %d\n", member_vec[0], result_member); ASSERT(456, result_member); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_cvttss2si64.c000066400000000000000000000016611505335450300203160ustar00rootroot00000000000000#include "test.h" // Declare the builtin manually without any headers typedef long long __m128; typedef float __v4sf __attribute__((vector_size(16))); // A struct with a float member struct S { float f; }; int main(void) { // Create a vector of 4 floats (like __v4sf) __v4sf vec = { 123.456f, 2.0f, -3.0f, 99.0f }; // Convert the lowest float to 64-bit int __m128 result = __builtin_ia32_cvttss2si64(vec); printf("Input[0] = %.3f -> int64 = %lld\n", vec[0], result); if (result == 123) printf("PASS\n"); else printf("FAIL\n"); ASSERT(123, result); struct S s = { 456.25f }; __v4sf member_vec = { s.f, 0.0f, 0.0f, 0.0f }; int result_member = __builtin_ia32_cvttss2si64(member_vec); printf("Struct member float: %.2f -> int: %d\n", member_vec[0], result_member); ASSERT(456, result_member); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_divss.c000066400000000000000000000011201505335450300173160ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf va = {6.0f, 3.3f, 4.4f, 5.5f}; v4sf vb = {2.0f, 6.7f, 2.6f, 7.5f}; v4sf vc = __builtin_ia32_divss(va, vb); float result = ((float*)&vc)[0]; printf("result = %f\n", result); // Expected: 6.0 / 2.0 = 3.0 // Check lowest element is correct (scalar div) ASSERT(3, result); // The other elements should be copied from the first vector (va) ASSERT(3, vc[0]); ASSERT(3, vc[1]); ASSERT(4, vc[2]); ASSERT(5, vc[3]); return 0; } chibicc-1.0.23.1/test/builtin_expect.c000066400000000000000000000006641505335450300174720ustar00rootroot00000000000000 #include "test.h" int main() { int x = 10; if (__builtin_expect(x == 10, 1)) { printf("Expected branch\n"); } else { printf("Unexpected branch\n"); ASSERT(0, 1); // This should not happen } if (__builtin_expect(x == 5, 1)) { printf("Expected branch 2\n"); ASSERT(0, 1); // This should not happen } else { printf("Unexpected branch 2\n"); } return 0; } chibicc-1.0.23.1/test/builtin_frame_address.c000066400000000000000000000012621505335450300207740ustar00rootroot00000000000000#include "test.h" #include int main() { void *f0 = __builtin_frame_address(0); printf("%p\n", f0); void *f1 = __builtin_frame_address(1); printf("%p\n", f1); void *f2 = __builtin_frame_address(2); printf("%p\n", f2); void *f3 = __builtin_frame_address(3); printf("%p\n", f3); bool x = false; printf("Frame address (level 0): %p\n", f0); x = f0; ASSERT(1, x); printf("Frame address (level 1): %p\n", f1); x = f1; ASSERT(1, x); printf("Frame address (level 2): %p\n", f2); x = f2; ASSERT(1, x); printf("Frame address (level 3): %p\n", f3); x = f3; ASSERT(0, x); }chibicc-1.0.23.1/test/builtin_frame_address2.c000066400000000000000000000012631505335450300210570ustar00rootroot00000000000000#include "test.h" #include void test0() { bool x = false; printf("frame_address(0) = %p\n", __builtin_frame_address(0)); x = __builtin_frame_address(0); ASSERT(1, x);} void test1() { bool x = false; printf("frame_address(1) = %p\n", __builtin_frame_address(1)); x = __builtin_frame_address(1); ASSERT(1, x);} void test2() { bool x = false; printf("frame_address(2) = %p\n", __builtin_frame_address(2)); x = __builtin_frame_address(2); ASSERT(1, x);} void test3() { bool x = false; printf("frame_address(3) = %p\n", __builtin_frame_address(3)); x = __builtin_frame_address(3); ASSERT(1, x);} int main() { test0(); test1(); test2(); test3(); return 0; }chibicc-1.0.23.1/test/builtin_frame_address3.c000066400000000000000000000013701505335450300210570ustar00rootroot00000000000000#include "test.h" #include void print_frame_addresses(const char *label) { void *f0 = __builtin_frame_address(0); void *f1 = __builtin_frame_address(1); void *f2 = __builtin_frame_address(2); bool x = false; printf("%s f0 = %p\n", label, f0); x = f0; ASSERT(1, x); printf("%s f1 = %p\n", label, f1); x = f1; ASSERT(1, x); printf("%s f2 = %p\n", label, f2); x = f2; ASSERT(1, x); } void inner() { print_frame_addresses("inner"); } void outer() { print_frame_addresses("outer-before"); inner(); print_frame_addresses("outer-after"); } int main() { print_frame_addresses("main-before"); outer(); print_frame_addresses("main-after"); }chibicc-1.0.23.1/test/builtin_ia32.c000066400000000000000000000003661505335450300167370ustar00rootroot00000000000000#include "test.h" void test(void) { __builtin_ia32_pause(); __builtin_ia32_lfence(); __builtin_ia32_mfence(); __builtin_ia32_sfence(); __builtin_ia32_emms(); } int main() { test(); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/builtin_isnan.c000066400000000000000000000021251505335450300173040ustar00rootroot00000000000000 #include #include "test.h" int main() { // Test with NaN (Not a Number) double nan_value = 0.0 / 0.0; float nan_value_f = 0.0f / 0.0f; int a = 0, b = 0, c = 0, d = 0; if (__builtin_isnan(nan_value)) { printf("nan_value is NaN (double)\n"); a = 1; } else { printf("nan_value is NOT NaN (double)\n"); } if (__builtin_isnan(nan_value_f)) { printf("nan_value_f is NaN (float)\n"); b = 1; } else { printf("nan_value_f is NOT NaN (float)\n"); } // Test with a regular number double regular_value = 123.456; float regular_value_f = 123.456f; if (__builtin_isnan(regular_value)) { printf("regular_value is NaN (double)\n"); } else { printf("regular_value is NOT NaN (double)\n"); c = 1; } if (__builtin_isnan(regular_value_f)) { printf("regular_value_f is NaN (float)\n"); } else { printf("regular_value_f is NOT NaN (float)\n"); d = 1; } ASSERT(1, a); ASSERT(1, b); ASSERT(1, c); ASSERT(1, d); return 0; } chibicc-1.0.23.1/test/builtin_ldmxcsr.c000066400000000000000000000013511505335450300176500ustar00rootroot00000000000000#include "test.h" #include int main(void) { // Read the current MXCSR uint32_t mxcsr = __builtin_ia32_stmxcsr(); printf("Initial MXCSR: 0x%08x\n", mxcsr); // Prepare a new MXCSR value (example: mask all exceptions) uint32_t new_mxcsr = mxcsr | (1 << 15); // Load the new value __builtin_ia32_ldmxcsr(new_mxcsr); // Read back uint32_t mxcsr_after = __builtin_ia32_stmxcsr(); printf("After load MXCSR: 0x%08x\n", mxcsr_after); //restore back // Load the new value __builtin_ia32_ldmxcsr(mxcsr); printf("Restored MXCSR: 0x%08x\n", mxcsr); ASSERT(0x00001f80, mxcsr); ASSERT(0x00009f80, mxcsr_after); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_loadhpd.c000066400000000000000000000006751505335450300176170ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); // 2 doubles int main(void) { double2 a = {1.0, 2.0}; // xmm0: low=1.0, high=2.0 double b = 99.0; double2 r = __builtin_ia32_loadhpd(a, &b); printf("r[0] = %.1f\n", r[0]); // from low of a (1.0) printf("r[1] = %.1f\n", r[1]); // from low of b (3.0) ASSERT(1, r[0]); ASSERT(99, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_loadhps.c000066400000000000000000000011501505335450300176230ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); typedef float v2sf __attribute__((vector_size(8))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v2sf p = {5.0f, 6.0f}; v4sf c = __builtin_ia32_loadhps(a, &p); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&c)[i]); } // Expected: // c[0] = 1.0 // c[1] = 2.0 // c[2] = 5.0 // c[3] = 6.0 ASSERT(1, c[0]); ASSERT(2, c[1]); ASSERT(5, c[2]); ASSERT(6, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_loadlpd.c000066400000000000000000000006751505335450300176230ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); // 2 doubles int main(void) { double2 a = {1.0, 2.0}; // xmm0: low=1.0, high=2.0 double b = 99.0; double2 r = __builtin_ia32_loadlpd(a, &b); printf("r[0] = %.1f\n", r[0]); // from low of a (1.0) printf("r[1] = %.1f\n", r[1]); // from low of b (3.0) ASSERT(99, r[0]); ASSERT(2, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_loadlps.c000066400000000000000000000011501505335450300176270ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); typedef float v2sf __attribute__((vector_size(8))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v2sf p = {5.0f, 6.0f}; v4sf c = __builtin_ia32_loadlps(a, &p); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&c)[i]); } // Expected: // c[0] = 1.0 // c[1] = 2.0 // c[2] = 5.0 // c[3] = 6.0 ASSERT(5, c[0]); ASSERT(6, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_maskmovdqu.c000066400000000000000000000014511505335450300203640ustar00rootroot00000000000000#include "test.h" #include typedef unsigned char uchar16 __attribute__((vector_size(16))); typedef char char16 __attribute__((vector_size(16))); int main() { char16 src = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'}; char16 mask = {0x80,0,0x80,0,0x80,0,0x80,0,0x80,0,0x80,0,0x80,0,0x80,0}; unsigned char dest[16]; memset(dest, '.', sizeof(dest)); __builtin_ia32_maskmovdqu(src, mask, dest); for (int i = 0; i < 16; i++) putchar(dest[i]); putchar('\n'); ASSERT('A', dest[0]); ASSERT('C', dest[2]); ASSERT('E', dest[4]); ASSERT('G', dest[6]); ASSERT('I', dest[8]); ASSERT('K', dest[10]); ASSERT('M', dest[12]); ASSERT('O', dest[14]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_maskmovq.c000066400000000000000000000010551505335450300200330ustar00rootroot00000000000000#include "test.h" // test/builtin_maskmovq.c typedef char __m64 __attribute__((__vector_size__(8))); __m64 a = { 1, 2 , 3, 4, 5, 6, 7, 8}; __m64 m = { -1, 0 , -1, 0, -1, 0, -1, 0}; char dst[8]; int main() { __builtin_ia32_maskmovq(a, m, dst); for (int i = 0; i < 8; i++) printf("%d ", dst[i]); ASSERT(1, dst[0]); ASSERT(0, dst[1]); ASSERT(3, dst[2]); ASSERT(0, dst[3]); ASSERT(5, dst[4]); ASSERT(0, dst[5]); ASSERT(7, dst[6]); ASSERT(0, dst[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_maxpd.c000066400000000000000000000005051505335450300173050ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_maxpd(a, b); printf("min: %f %f\n", c[0], c[1]); ASSERT(3, c[0]); ASSERT(4, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_maxps.c000066400000000000000000000006721505335450300173310ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main(void) { __v4sf a= {1.5f, 2.0f, 3.0f, 4.0f}; __v4sf b = {3.5f, 1.0f, 5.0f, 6.0f}; __v4sf out = __builtin_ia32_maxps(a, b); printf("Result: %f %f %f %f\n", out[0], out[1], out[2], out[3]); ASSERT(3, out[0]); ASSERT(2, out[1]); ASSERT(5, out[2]); ASSERT(6, out[3]); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/builtin_maxsd.c000066400000000000000000000005051505335450300173100ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_maxsd(a, b); printf("max: %f %f\n", c[0], c[1]); ASSERT(3, c[0]); ASSERT(4, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_maxss.c000066400000000000000000000006721505335450300173340ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main(void) { __v4sf a= {1.5f, 2.0f, 3.0f, 4.0f}; __v4sf b = {3.5f, 1.0f, 5.0f, 6.0f}; __v4sf out = __builtin_ia32_maxss(a, b); printf("Result: %f %f %f %f\n", out[0], out[1], out[2], out[3]); ASSERT(3, out[0]); ASSERT(2, out[1]); ASSERT(3, out[2]); ASSERT(4, out[3]); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/builtin_memcpy.c000066400000000000000000000004401505335450300174640ustar00rootroot00000000000000 #include #include "test.h" int main() { char src[] = "Hello, world!"; char dest[20]; memcpy(dest, src, strlen(src)); // Use memcpy instead of __builtin_memcpy printf("Copied string: %s\n", dest); ASSERT(0, !strcmp(dest, "Hello, world!")); return 0; } chibicc-1.0.23.1/test/builtin_memset.c000066400000000000000000000003571505335450300174730ustar00rootroot00000000000000#include "test.h" int main() { char buffer[10]; __builtin_memset(buffer, 'A', sizeof(buffer)); for (int i = 0; i < 10; i++) { putchar(buffer[i]); ASSERT('A', buffer[i]); } putchar('\n'); return 0; } chibicc-1.0.23.1/test/builtin_minpd.c000066400000000000000000000005261505335450300173060ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_minpd(a, b); printf("min: %f %f\n", c[0], c[1]); // expect 1.0 2.0 ASSERT(1, c[0]); ASSERT(2, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_minps.c000066400000000000000000000007511505335450300173250ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4sf a = {3.0f, 100.0f, 200.0f, 300.0f}; __v4sf b = {5.0f, 400.0f, 500.0f, 600.0f}; __v4sf res = __builtin_ia32_minps(a, b); float *f = (float *)&res; for (int i = 0; i < 4; i++) printf("res[%d] = %f\n", i, f[i]); ASSERT(3, res[0]); ASSERT(100, res[1]); ASSERT(200, res[2]); ASSERT(300, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_minsd.c000066400000000000000000000005261505335450300173110ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_minsd(a, b); printf("min: %f %f\n", c[0], c[1]); // expect 1.0 2.0 ASSERT(1, c[0]); ASSERT(4, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_minss.c000066400000000000000000000007511505335450300173300ustar00rootroot00000000000000#include "test.h" typedef float __v4sf __attribute__((vector_size(16))); int main() { __v4sf a = {3.0f, 100.0f, 200.0f, 300.0f}; __v4sf b = {5.0f, 400.0f, 500.0f, 600.0f}; __v4sf res = __builtin_ia32_minss(a, b); float *f = (float *)&res; for (int i = 0; i < 4; i++) printf("res[%d] = %f\n", i, f[i]); ASSERT(3, res[0]); ASSERT(100, res[1]); ASSERT(200, res[2]); ASSERT(300, res[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movhlps.c000066400000000000000000000013151505335450300176640ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {5.0f, 6.0f, 7.0f, 8.0f}; // movhlps moves the upper half of b into the upper half of a v4sf c = __builtin_ia32_movhlps(a, b); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&c)[i]); } // Expected output: // c[0] = 1.0 (from a[0]) // c[1] = 2.0 (from a[1]) // c[2] = 7.0 (from b[2]) // c[3] = 8.0 (from b[3]) ASSERT(7, c[0]); ASSERT(8, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movlhps.c000066400000000000000000000012301505335450300176600ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {5.0f, 6.0f, 7.0f, 8.0f}; // movlhps moves low 64 bits (2 floats) from b into high 64 bits of a v4sf c = __builtin_ia32_movlhps(a, b); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, c[i]); } // Expected: // c[0] = a[0] = 1.0 // c[1] = a[1] = 2.0 // c[2] = b[0] = 5.0 // c[3] = b[1] = 6.0 ASSERT(1, c[0]); ASSERT(2, c[1]); ASSERT(5, c[2]); ASSERT(6, c[3]); return 0; } chibicc-1.0.23.1/test/builtin_movmskpd.c000066400000000000000000000010201505335450300200250ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); // 2 doubles typedef float v4sf __attribute__((vector_size(16))); int main(void) { v4sf vec = { 1.0f, -2.0f, 3.0f, -4.0f }; // movmskps should produce a 4-bit mask of sign bits // bit0 = sign of vec[0], bit1 = sign of vec[1], etc. double mask = __builtin_ia32_movmskps(vec); printf("vec[0] = %.1f\n", vec[0]); printf("vec[1] = %.1f\n", vec[1]); ASSERT(10, mask); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movmskps.c000066400000000000000000000015061505335450300200550ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); // Declare the builtin directly int __builtin_ia32_movmskps(v4sf a); int main(void) { v4sf vec = { 1.0f, -2.0f, 3.0f, -4.0f }; // movmskps should produce a 4-bit mask of sign bits // bit0 = sign of vec[0], bit1 = sign of vec[1], etc. int mask = __builtin_ia32_movmskps(vec); printf("Vector: %f %f %f %f\n", vec[0], vec[1], vec[2], vec[3]); printf("Mask: %d (binary %04b)\n", mask, mask); // Expected: // vec[0] > 0 => bit0 = 0 // vec[1] < 0 => bit1 = 1 // vec[2] > 0 => bit2 = 0 // vec[3] < 0 => bit3 = 1 // So mask = 0b1010 = 10 ASSERT(10, mask); ASSERT(1, vec[0]); ASSERT(-2, vec[1]); ASSERT(3, vec[2]); ASSERT(-4, vec[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movntdq.c000066400000000000000000000007041505335450300176650ustar00rootroot00000000000000#include "test.h" #include typedef long long v2di __attribute__((vector_size(16))); int main() { v2di value = {0x1122334455667788LL, 0x99AABBCCDDEEFF00LL}; v2di mem; __builtin_ia32_movntdq(&mem, value); printf("mem[0] = 0x%llX\n", mem[0]); printf("mem[1] = 0x%llX\n", mem[1]); LASSERT(0x1122334455667788, mem[0]); LASSERT(0x99AABBCCDDEEFF00, mem[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movnti.c000066400000000000000000000004161505335450300175110ustar00rootroot00000000000000#include "test.h" #include int main() { int x = 0; // Non-temporal store 12345 into &x __builtin_ia32_movnti(&x, 12345); printf("x = %d\n", x); // Should print 12345 ASSERT(12345, x); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movnti64.c000066400000000000000000000004301505335450300176570ustar00rootroot00000000000000#include "test.h" #include int main() { long long x = 0; __builtin_ia32_movnti64(&x, 0x1122334455667788LL); printf("x = 0x%llX\n", x); // Should print 1122334455667788 LASSERT(0x1122334455667788, x); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movntpd.c000066400000000000000000000006411505335450300176640ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main() { v2df val = { 1.25, -2.5 }; double dst[2] = {0.0, 0.0}; // Non-temporal store 128-bit packed doubles to dst __builtin_ia32_movntpd(dst, val); printf("%.2f %.2f\n", dst[0], dst[1]); // expect: 1.25 -2.50 ASSERT(1, dst[0]); ASSERT(-2, dst[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movntps.c000066400000000000000000000011631505335450300177030ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); int main(void) { float4 v = {1.0f, 2.0f, 3.0f, 4.0f}; float4 dst = {0.0f, 0.0f, 0.0f, 0.0f}; // Non-temporal store equivalent: store vector into memory float4 *p = &dst; // Normally you'd use __builtin_ia32_movntps(p, v) // Here we just assign via pointer for testing *p = v; printf("dst = {%.1f, %.1f, %.1f, %.1f}\n", dst[0], dst[1], dst[2], dst[3]); ASSERT(1, dst[0]); ASSERT(2, dst[1]); ASSERT(3, dst[2]); ASSERT(4, dst[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movntq.c000066400000000000000000000003741505335450300175240ustar00rootroot00000000000000#include "test.h" typedef unsigned long long u64; int main() { u64 x = 0; __builtin_ia32_movntq(&x, 0x1122334455667788ULL); printf("x = 0x%llx\n", x); LASSERT(0x1122334455667788ULL, x); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movq128.c000066400000000000000000000005331505335450300174120ustar00rootroot00000000000000#include "test.h" typedef long long int int2 __attribute__((vector_size(16))); int main(void) { int2 a = {1, 2}; int2 b; // Move 128-bit vector a into b b = __builtin_ia32_movq128(a); printf("b = {%lld, %lld}\n", b[0], b[1]); ASSERT(1, b[0]); ASSERT(0, b[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movsd.c000066400000000000000000000010531505335450300173230ustar00rootroot00000000000000#include "test.h" // compile with: chibicc -o test test.c typedef double v2df __attribute__((vector_size(16))); extern v2df __builtin_ia32_movsd(v2df, v2df); int main(void) { v2df a = { 1.5, 2.5 }; v2df b = { 9.0, 8.0 }; v2df c = __builtin_ia32_movsd(a, b); // movsd should copy only the lower element from 'a', keeping the upper from 'b' printf("c[0] = %f\n", c[0]); // expect 1.5 printf("c[1] = %f\n", c[1]); // expect 8.0 ASSERT(9, c[0]); ASSERT(2, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_movss.c000066400000000000000000000006571505335450300173530ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {5.5f, 6.5f, 7.5f, 8.5f}; v4sf c = __builtin_ia32_movss(a, b); printf("c = %f %f %f %f\n", c[0], c[1], c[2], c[3]); // Should print: 5.5 2.0 3.0 4.0 ASSERT(5, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_mul_div.c000066400000000000000000000007141505335450300176350ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); int main() { double2 a = {10.0, 7.0}; double2 b = {5.0, 4.0}; double2 c = __builtin_ia32_mulsd(a, b); double2 d = __builtin_ia32_divsd(a, b); printf("%.1f %.1f\n", c[0], c[1]); printf("%.1f %.1f\n", d[0], d[1]); ASSERT(50, c[0]); ASSERT(7, c[1]); ASSERT(2, d[0]); ASSERT(7, d[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_mul_overflow.c000066400000000000000000000006601505335450300207160ustar00rootroot00000000000000 #include "test.h" int main() { int result; if (__builtin_mul_overflow(2147483647, 2, &result)) { printf("Overflow detected!\n"); } ASSERT(1, __builtin_mul_overflow(2147483647, 2, &result)); if (__builtin_mul_overflow(55, 2, &result)) { printf("Overflow detected!\n"); } else printf("Overflow not detected!\n"); ASSERT(0, __builtin_mul_overflow(55, 2, &result)); return 0; } chibicc-1.0.23.1/test/builtin_mulss.c000066400000000000000000000011501505335450300173340ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf va = {1.5f, 3.3f, 4.4f, 5.5f}; v4sf vb = {2.5f, 6.7f, 2.6f, 7.5f}; v4sf vc = __builtin_ia32_mulss(va, vb); float result = ((float*)&vc)[0]; printf("result = %f\n", result); // Expected: 1.5 * 2.5 = 3.75 // Check lowest element is correct (scalar mul) ASSERT(3, result); // The other elements should be copied from the first vector (va) ASSERT(3, vc[0]); ASSERT(3, vc[1]); ASSERT(4, vc[2]); ASSERT(5, vc[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_orpd.c000066400000000000000000000011251505335450300171370ustar00rootroot00000000000000#include "test.h" typedef double v2df __attribute__((vector_size(16))); int main(void) { v2df a = { 1.0, 4.0 }; v2df b = { 3.0, 2.0 }; v2df c = __builtin_ia32_orpd(a, b); // Print the raw bits as unsigned long long to see AND effect unsigned long long *p = (unsigned long long *)&c; printf("orpd: 0x%llx 0x%llx\n", p[0], p[1]); ASSERT(0, p[0]); ASSERT(0, p[1]); v2df d = __builtin_ia32_orpd(a, b); unsigned long long *q = (unsigned long long *)&d; ASSERT(0, q[0]); ASSERT(0, q[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_orps.c000066400000000000000000000010321505335450300171530ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {0x00000000, 0x0F0F0F0F, 0xAAAAAAAA, 0x55555555}; v4sf b = {0xFFFFFFFF, 0xF0F0F0F0, 0x55555555, 0xAAAAAAAA}; v4sf c = __builtin_ia32_orps(a, b); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08X\n", i, *(unsigned int*)&c[i]); } ASSERT(-2147483648, c[0]); ASSERT(-2147483648, c[1]); ASSERT(-2147483648, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_overflow.c000066400000000000000000000026571505335450300200510ustar00rootroot00000000000000#include "test.h" #include int main(void) { // ---------- 32-bit unsigned addition ---------- unsigned int a32 = 0xFFFFFFFF; unsigned int b32 = 1; unsigned int res32; int overflow32 = __builtin_uadd_overflow(a32, b32, &res32); printf("uadd_overflow(0x%X + 0x%X) = %u, overflow = %d\n", a32, b32, res32, overflow32); // 32-bit constant addition unsigned int res32_const; int overflow32_const = __builtin_uadd_overflow(100u, 200u, &res32_const); printf("uadd_overflow(100 + 200) = %u, overflow = %d\n", res32_const, overflow32_const); // ---------- 64-bit unsigned long addition ---------- unsigned long a64 = 0xFFFFFFFFFFFFFFFFUL; unsigned long b64 = 1; unsigned long res64; int overflow64 = __builtin_uaddl_overflow(a64, b64, &res64); printf("uaddl_overflow(0x%lX + 0x%lX) = %lu, overflow = %d\n", a64, b64, res64, overflow64); // 64-bit constant addition unsigned long res64_const; int overflow64_const = __builtin_uaddl_overflow(100UL, 200UL, &res64_const); printf("uaddl_overflow(100 + 200) = %lu, overflow = %d\n", res64_const, overflow64_const); // 64-bit constant addition unsigned long long resl64_const; int overflowl64_const = __builtin_uaddll_overflow(100ULL, 200ULL, &resl64_const); printf("uaddll_overflow(100 + 200) = %lu, overflow = %d\n", resl64_const, overflowl64_const); return 0; } chibicc-1.0.23.1/test/builtin_packssdw.c000066400000000000000000000011431505335450300200120ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); typedef short v4hi __attribute__((vector_size(8))); int main() { v2si a = {30000, -30000}; v2si b = {1000, -1000}; ASSERT(30000, a[0]); ASSERT(-30000, a[1]); ASSERT(1000, b[0]); ASSERT(-1000, b[1]); v4hi result = (v4hi) __builtin_ia32_packssdw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", (int)result[i]); } ASSERT(30000, result[0]); ASSERT(-30000, result[1]); ASSERT(1000, result[2]); ASSERT(-1000, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_packssdw128.c000066400000000000000000000013351505335450300202500ustar00rootroot00000000000000#include "test.h" typedef int __v4si __attribute__((vector_size(16))); typedef short __v8hi __attribute__((vector_size(16))); __v8hi test_packssdw128(__v4si a, __v4si b) { return __builtin_ia32_packssdw128(a, b); } int main(void) { __v4si a = { 1000, 40000, -40000, -1000 }; __v4si b = { 2000, -50000, 50000, -2000 }; __v8hi r = test_packssdw128(a, b); for (int i = 0; i < 8; i++) { printf("%d ", r[i]); } printf("\n"); ASSERT(1000, r[0]); ASSERT(32767, r[1]); ASSERT(-32768, r[2]); ASSERT(-1000, r[3]); ASSERT(2000, r[4]); ASSERT(-32768, r[5]); ASSERT(32767, r[6]); ASSERT(-2000, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_packsswb.c000066400000000000000000000016751505335450300200220ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); // 4 × 16-bit = 8 bytes typedef signed char v8qi __attribute__((vector_size(8))); // 8 × 8-bit = 8 bytes int main(void) { v4hi a = {30000, -30000, 100, -100}; v4hi b = {32767, -32768, 200, -200}; // MMX builtin returns an 8-byte vector of signed char v8qi result = (v8qi)__builtin_ia32_packsswb(a, b); ASSERT(30000, a[0]); ASSERT(-30000, a[1]); ASSERT(100, a[2]); ASSERT(-100, a[3]); ASSERT(32767, b[0]); ASSERT(-32768, b[1]); ASSERT(200, b[2]); ASSERT(-200, b[3]); for (int i = 0; i < 8; i++) printf("%d ", (int)result[i]); printf("\n"); ASSERT(127, result[0]); ASSERT(-128, result[1]); ASSERT(100, result[2]); ASSERT(-100, result[3]); ASSERT(127, result[4]); ASSERT(-128, result[5]); ASSERT(127, result[6]); ASSERT(-128, result[7]); return 0; } chibicc-1.0.23.1/test/builtin_packsswb128.c000066400000000000000000000022611505335450300202450ustar00rootroot00000000000000// test_packsswb128.c #include "test.h" typedef short __v8hi __attribute__((vector_size(16))); typedef char __v16qi __attribute__((vector_size(16))); typedef __v16qi __m128i; // Declare the builtin explicitly so Chibicc knows it extern __v16qi __builtin_ia32_packsswb128(__v8hi, __v8hi); __m128i test_packsswb128(__v8hi a, __v8hi b) { return (__m128i)__builtin_ia32_packsswb128(a, b); } int main(void) { __v8hi a = { 100, 200, 30000, -30000, -200, -150, 127, -128 }; __v8hi b = { 50, -50, 40000, -40000, 200, 150, -127, 128 }; __m128i r = test_packsswb128(a, b); char *bytes = (char *)&r; printf("Result bytes:\n"); for (int i = 0; i < 16; i++) { printf("%d ", bytes[i]); } printf("\n"); ASSERT(100, r[0]); ASSERT(127, r[1]); ASSERT(127, r[2]); ASSERT(-128, r[3]); ASSERT(-128, r[4]); ASSERT(-128, r[5]); ASSERT(127, r[6]); ASSERT(-128, r[7]); ASSERT(50, r[8]); ASSERT(-50, r[9]); ASSERT(-128, r[10]); ASSERT(127, r[11]); ASSERT(127, r[12]); ASSERT(127, r[13]); ASSERT(-127, r[14]); ASSERT(127, r[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_packuswb.c000066400000000000000000000021241505335450300200120ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); typedef unsigned char v8qi __attribute__((vector_size(8))); int main() { v4hi a = {300, -30, 1000, -1000}; v4hi b = {100, 200, 40000, -40000}; ASSERT(300, a[0]); ASSERT(-30, a[1]); ASSERT(1000, a[2]); ASSERT(-1000, a[3]); ASSERT(100, b[0]); ASSERT(-25536, b[2]); //40000 is changed to -25536 warning: overflow in conversion from ‘int’ to ‘short int’ changes value from ‘-40000’ to ‘25536’ [-Woverflow] ASSERT(25536, b[3]); // warning: overflow in conversion from ‘int’ to ‘short int’ changes value from ‘-40000’ to ‘25536’ [-Woverflow] v8qi result = (v8qi)__builtin_ia32_packuswb(a, b); for (int i = 0; i < 8; i++) { printf("%u ", (unsigned int)result[i]); } ASSERT(255, result[0]); ASSERT(0, result[1]); ASSERT(255, result[2]); ASSERT(0, result[3]); ASSERT(100, result[4]); ASSERT(200, result[5]); ASSERT(0, result[6]); ASSERT(255, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_packuswb128.c000066400000000000000000000017441505335450300202540ustar00rootroot00000000000000#include "test.h" typedef short __v8hi __attribute__((vector_size(16))); typedef unsigned char __v16qu __attribute__((vector_size(16))); typedef char __v16qi __attribute__((vector_size(16))); __v16qi test_packuswb128(__v8hi a, __v8hi b) { return __builtin_ia32_packuswb128(a, b); } int main(void) { __v8hi a = { 100, 200, 300, -100, -200, 127, 255, 400 }; __v8hi b = { 0, -1, 500, 128, 300, -500, 255, -255 }; __v16qu r = (__v16qu)test_packuswb128(a, b); for (int i = 0; i < 16; i++) printf("%u ", r[i]); printf("\n"); ASSERT(100, r[0]); ASSERT(200, r[1]); ASSERT(255, r[2]); ASSERT(0, r[3]); ASSERT(0, r[4]); ASSERT(127, r[5]); ASSERT(255, r[6]); ASSERT(255, r[7]); ASSERT(0, r[8]); ASSERT(0, r[9]); ASSERT(255, r[10]); ASSERT(128, r[11]); ASSERT(255, r[12]); ASSERT(0, r[13]); ASSERT(255, r[14]); ASSERT(0, r[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddb.c000066400000000000000000000014471505335450300172540ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); int main() { v8qi a = {1, 2, 3, 4, 5, 6, 7, 8}; v8qi b = {10, 20, 30, 40, 50, 60, 70, 80}; v8qi result = __builtin_ia32_paddb(a, b); for (int i = 0; i < 8; i++) { printf("%d ", (int)result[i]); } for (int i = 0; i < 8; i++) { printf("%d ", (int)a[i]); ASSERT(i + 1, a[i]); } for (int i = 0; i < 8; i++) { printf("%d ", (int)b[i]); ASSERT((i + 1) * 10 , b[i]); } ASSERT(11, result[0]); ASSERT(22, result[1]); ASSERT(33, result[2]); ASSERT(44, result[3]); ASSERT(55, result[4]); ASSERT(66, result[5]); ASSERT(77, result[6]); ASSERT(88, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddd.c000066400000000000000000000011451505335450300172510ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = {100000, 200000}; v2si b = {10, 20}; v2si result = __builtin_ia32_paddd(a, b); for (int i = 0; i < 2; i++) { printf("%d ", a[i]); ASSERT((i+1) * 100000, a[i]); } for (int i = 0; i < 2; i++) { printf("%d ", b[i]); ASSERT((i+1) * 10, b[i]); } for (int i = 0; i < 2; i++) { printf("%d ", result[i]); } ASSERT(100010, result[0]); ASSERT(200020, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddq.c000066400000000000000000000006171505335450300172710ustar00rootroot00000000000000#include "test.h" typedef long long v1di __attribute__((vector_size(8))); int main() { v1di a = {1000000000LL}; v1di b = {1234567890LL}; v1di result = __builtin_ia32_paddq(a, b); printf("%lld\n", result[0]); LASSERT(1000000000LL, a[0]); LASSERT(1234567890LL, b[0]); LASSERT(2234567890LL, (long long) result[0]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddsb.c000066400000000000000000000017401505335450300174330ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); int main() { v8qi a = {120, -120, 100, -100, 50, -50, 127, -128}; v8qi b = {10, -10, 50, -50, 100, -100, 1, -1}; v8qi result = (v8qi) __builtin_ia32_paddsb(a, b); for (int i = 0; i < 8; i++) printf("%d ", result[i]); ASSERT(120, a[0]); ASSERT(-120, a[1]); ASSERT(100, a[2]); ASSERT(-100, a[3]); ASSERT(50, a[4]); ASSERT(-50, a[5]); ASSERT(127, a[6]); ASSERT(-128, a[7]); ASSERT(10, b[0]); ASSERT(-10, b[1]); ASSERT(50, b[2]); ASSERT(-50, b[3]); ASSERT(100, b[4]); ASSERT(-100, b[5]); ASSERT(1, b[6]); ASSERT(-1, b[7]); ASSERT(127, result[0]); ASSERT(-128, result[1]); ASSERT(127, result[2]); ASSERT(-128, result[3]); ASSERT(127, result[4]); ASSERT(-128, result[5]); ASSERT(127, result[6]); ASSERT(-128, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddsb128.c000066400000000000000000000021061505335450300176630ustar00rootroot00000000000000#include "test.h" #include typedef char __v16qi __attribute__((__vector_size__(16))); __v16qi paddsb128(__v16qi a, __v16qi b) { return __builtin_ia32_paddsb128(a, b); } int main() { // Signed 8-bit integers: will saturate at 127 and -128 __v16qi a = {120, -125, 60, -60, 100, -100, 50, -50, 127, -128, 10, -10, 30, -30, 80, -80}; __v16qi b = {10, -10, 70, -70, 50, -50, 100, -100, 1, -1, 120, -120, -50, 50, 60, -60}; __v16qi r = paddsb128(a, b); int8_t *vals = (int8_t *)&r; for (int i = 0; i < 16; i++) printf("%d ", vals[i]); printf("\n"); ASSERT(127, r[0]); ASSERT(-128, r[1]); ASSERT(127, r[2]); ASSERT(-128, r[3]); ASSERT(127, r[4]); ASSERT(-128, r[5]); ASSERT(127, r[6]); ASSERT(-128, r[7]); ASSERT(127, r[8]); ASSERT(-128, r[9]); ASSERT(127, r[10]); ASSERT(-128, r[11]); ASSERT(-20, r[12]); ASSERT(20, r[13]); ASSERT(127, r[14]); ASSERT(-128, r[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddsw.c000066400000000000000000000012431505335450300174560ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {30000, -30000, 20000, -20000}; v4hi b = {10000, 10000, -10000, -10000}; v4hi result = (v4hi) __builtin_ia32_paddsw(a, b); for (int i = 0; i < 4; i++) printf("%d ", result[i]); ASSERT(30000, a[0]); ASSERT(-30000, a[1]); ASSERT(20000, a[2]); ASSERT(-20000, a[3]); ASSERT(10000, b[0]); ASSERT(10000, b[1]); ASSERT(-10000, b[2]); ASSERT(-10000, b[3]); ASSERT(32767, result[0]); ASSERT(-20000, result[1]); ASSERT(10000, result[2]); ASSERT(-30000, result[3]); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_paddsw128.c000066400000000000000000000012721505335450300177130ustar00rootroot00000000000000#include "test.h" typedef short v8hi __attribute__((vector_size(16))); v8hi paddsw128_test(v8hi a, v8hi b) { return __builtin_ia32_paddsw128(a, b); } int main() { v8hi a = { 32000, -32000, 20000, -20000, 15000, -15000, 10000, -10000 }; v8hi b = { 1000, 1000, 20000, 20000, -20000, -20000, 5000, 5000 }; v8hi r = paddsw128_test(a, b); for (int i = 0; i < 8; i++) printf("%d ", r[i]); printf("\n"); ASSERT(32767, r[0]); ASSERT(-31000, r[1]); ASSERT(32767, r[2]); ASSERT(0, r[3]); ASSERT(-5000, r[4]); ASSERT(-32768, r[5]); ASSERT(15000, r[6]); ASSERT(-5000, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddusb.c000066400000000000000000000013111505335450300176120ustar00rootroot00000000000000#include "test.h" typedef unsigned char v8qu __attribute__((vector_size(8))); typedef char v8qi __attribute__((vector_size(8))); int main(void) { v8qu a = {120u, 200u, 100u, 250u, 10u, 30u, 255u, 1u}; v8qu b = {10u, 100u, 200u, 10u, 250u, 240u, 10u, 5u}; v8qu result = (v8qu) __builtin_ia32_paddusb((v8qi)a, (v8qi)b); for (int i = 0; i < 8; i++) { printf("%u ", result[i]); } printf("\n"); ASSERT(130, result[0]); ASSERT(255, result[1]); ASSERT(255, result[2]); ASSERT(255, result[3]); ASSERT(255, result[4]); ASSERT(255, result[5]); ASSERT(255, result[6]); ASSERT(6, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddusb128.c000066400000000000000000000012271505335450300200530ustar00rootroot00000000000000#include "test.h" typedef char v16hi __attribute__((vector_size(16))); typedef unsigned char v16hu __attribute__((vector_size(16))); int main() { v16hi a_vals = { 250, 10, 200, 255, 100, 0, 50, 240, 128, 64, 255, 1, 20, 30, 40, 50 }; v16hi b_vals = { 10, 250, 100, 10, 200, 255, 250, 20, 128, 200, 1, 255, 240, 230, 220, 210 }; v16hu result = (v16hu)__builtin_ia32_paddusb128(a_vals, b_vals); for (int i = 0; i < 16; i++) { printf("Result: %3u\n", result[i]); ASSERT(255, result[i]); } printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddusw.c000066400000000000000000000013451505335450300176460ustar00rootroot00000000000000 #include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main(void) { v4hi a = {30000, 100, 65000, 500}; v4hi b = {10000, 200, 1000, 200}; v4hi result = (v4hi)__builtin_ia32_paddusw(a, b); for (int i = 0; i < 4; i++) printf("%u ", (unsigned short)result[i]); ASSERT(30000, a[0]); ASSERT(100, a[1]); ASSERT(65000, (unsigned short)a[2]); ASSERT(500, a[3]); ASSERT(10000, b[0]); ASSERT(200, b[1]); ASSERT(1000, b[2]); ASSERT(200, b[3]); ASSERT(40000, (unsigned short) result[0]); ASSERT(300, result[1]); ASSERT(65535, (unsigned short) result[2]); ASSERT(700, result[3]); printf("\n"); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_paddusw128.c000066400000000000000000000014651505335450300201040ustar00rootroot00000000000000#include "test.h" #include typedef short v8hi __attribute__((vector_size(16))); typedef unsigned short v8hu __attribute__((vector_size(16))); v8hi paddusw128_test(v8hi a, v8hi b) { return __builtin_ia32_paddusw128(a, b); } int main() { v8hi a = {65535, 1000, 50000, 65530, 40000, 200, 65535, 60000}; v8hi b = {1, 60000, 20000, 10, 30000, 700, 100, 10000}; v8hu result = (v8hu)paddusw128_test(a, b); for (int i = 0; i < 8; i++) printf("%u ", result[i]); printf("\n"); ASSERT(65535, result[0]); ASSERT(61000, result[1]); ASSERT(65535, result[2]); ASSERT(65535, result[3]); ASSERT(65535, result[4]); ASSERT(900, result[5]); ASSERT(65535, result[6]); ASSERT(65535, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_paddw.c000066400000000000000000000012511505335450300172720ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {1000, 2000, 3000, 4000}; v4hi b = {10, 20, 30, 40}; v4hi result = __builtin_ia32_paddw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", a[i]); ASSERT((i+1) * 1000, a[i]); } for (int i = 0; i < 4; i++) { printf("%d ", b[i]); ASSERT((i+1) * 10, b[i]); } for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } ASSERT(1010, result[0]); ASSERT(2020, result[1]); ASSERT(3030, result[2]); ASSERT(4040, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pand.c000066400000000000000000000015541505335450300171230ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); typedef v2si __m64; int main() { __m64 a = {0xF0F0F0F0, 0xF0F0F0F0}; __m64 b = {0x0F0F0F0F, 0x0F0F0F0F}; __m64 result = __builtin_ia32_pand(a, b); printf("a[0] = 0x%x\n", a[0]); printf("a[1] = 0x%x\n", a[1]); printf("b[0] = 0x%x\n", b[0]); printf("b[1] = 0x%x\n", b[1]); printf("result[0] = 0x%x\n", result[0]); printf("result[1] = 0x%x\n", result[1]); if (result[0] == 0 && result[1] == 0) { printf("Test passed.\n"); } else { printf("Test failed.\n"); return 1; } ASSERT(0xf0f0f0f0, a[0]); ASSERT(0xf0f0f0f0, a[1]); ASSERT(0xf0f0f0f, b[0]); ASSERT(0xf0f0f0f, b[1]); ASSERT(0x0, result[0]); ASSERT(0x0, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pandn.c000066400000000000000000000013361505335450300172770ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); typedef v2si __m64; int main() { __m64 a = {0xFFFF0000, 0xAAAA5555}; __m64 b = {0x0F0F0F0F, 0x12345678}; __m64 result = __builtin_ia32_pandn(a, b); printf("a[0] = 0x%x\n", a[0]); printf("a[1] = 0x%x\n", a[1]); printf("b[0] = 0x%x\n", b[0]); printf("b[1] = 0x%x\n", b[1]); printf("result[0] = 0x%x\n", result[0]); printf("result[1] = 0x%x\n", result[1]); ASSERT(0xffff0000, a[0]); ASSERT(0xaaaa5555, a[1]); ASSERT(0xf0f0f0f, b[0]); ASSERT(0x12345678, b[1]); ASSERT(0xf0f, result[0]); ASSERT(0x10140228, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pandn128.c000066400000000000000000000006641505335450300175350ustar00rootroot00000000000000#include "test.h" typedef long long int int4 __attribute__((vector_size(16))); int main() { int4 a = {0xF0F0F0F0, 0xAAAAAAAA}; int4 b = {0x0F0F0F0F, 0x55555555}; int4 c = __builtin_ia32_pandn128(a, b); // ~a & b for(int i = 0; i < 2; i++) { printf("%llX ", c[i]); } printf("\n"); ASSERT(0xF0F0F0F, c[0]); ASSERT(0x55555555, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_parity.c000066400000000000000000000007711505335450300175110ustar00rootroot00000000000000#include "test.h" int main(void) { // Immediate constant int p1 = __builtin_parity(0x12345678); printf("parity(0x12345678) = %d\n", p1); // Variable / runtime value unsigned int x = 0xDEADBEEF; int p2 = __builtin_parity(x); printf("parity(0xDEADBEEF) = %d\n", p2); // Another constant int p3 = __builtin_parity(0xFFFFFFFF); printf("parity(0xFFFFFFFF) = %d\n", p3); ASSERT(1, p1); ASSERT(0, p2); ASSERT(0, p3); return 0; } chibicc-1.0.23.1/test/builtin_pavgb.c000066400000000000000000000012271505335450300172750ustar00rootroot00000000000000#include "test.h" // Define the vector type manually typedef char v8qi __attribute__((vector_size(8))); typedef unsigned char v8qu __attribute__((vector_size(8))); #include int main() { v8qi a = {10, 20, 30, 40, 50, 60, 70, 80}; v8qi b = {5, 15, 25, 35, 45, 55, 65, 75}; v8qu r = (v8qu)__builtin_ia32_pavgb(a, b); for (int i = 0; i < 8; i++) printf("%u ", r[i]); printf("\n"); ASSERT(8, r[0]); ASSERT(18, r[1]); ASSERT(28, r[2]); ASSERT(38, r[3]); ASSERT(48, r[4]); ASSERT(58, r[5]); ASSERT(68, r[6]); ASSERT(78, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pavgb128.c000066400000000000000000000016721505335450300175340ustar00rootroot00000000000000#include "test.h" typedef unsigned char uchar16 __attribute__((vector_size(16))); typedef char char16 __attribute__((vector_size(16))); int main() { char16 a = {100, 200, 255, 0, 1, 50, 128, 64, 5, 250, 100, 30, 200, 100, 1, 255}; char16 b = {100, 55, 10, 0, 255, 200, 127, 192, 250, 10, 100, 30, 100, 200, 254, 255}; uchar16 c = (uchar16)__builtin_ia32_pavgb128(a, b); for (int i = 0; i < 16; i++) printf("%u ", c[i]); printf("\n"); ASSERT(100, c[0]); ASSERT(128, c[1]); ASSERT(133, c[2]); ASSERT(0, c[3]); ASSERT(128, c[4]); ASSERT(125, c[5]); ASSERT(128, c[6]); ASSERT(128, c[7]); ASSERT(128, c[8]); ASSERT(130, c[9]); ASSERT(100, c[10]); ASSERT(30, c[11]); ASSERT(150, c[12]); ASSERT(150, c[13]); ASSERT(128, c[14]); ASSERT(255, c[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pavgw.c000066400000000000000000000015231505335450300173210ustar00rootroot00000000000000#include "test.h" // Define the vector type manually typedef short v4si __attribute__((vector_size(8))); typedef unsigned short v4qu __attribute__((vector_size(8))); #include int main() { v4si a = {10, 20, 30, 40}; v4si b = {5, 15, 25, 35}; v4qu r = (v4qu)__builtin_ia32_pavgw(a, b); for (int i = 0; i < 4; i++) printf("%u ", r[i]); printf("\n"); ASSERT(8, r[0]); ASSERT(18, r[1]); ASSERT(28, r[2]); ASSERT(38, r[3]); v4si c = {100, 200, 300, 400}; v4si d = {50, 150, 250, 350}; v4qu r2 = (v4qu)__builtin_ia32_pavgw(c, d); for (int i = 0; i < 4; i++) printf("%u ", r2[i]); printf("\n"); ASSERT(75, r2[0]); ASSERT(175, r2[1]); ASSERT(275, r2[2]); ASSERT(375, r2[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pavgw128.c000066400000000000000000000012351505335450300175540ustar00rootroot00000000000000#include "test.h" typedef unsigned short ushort8 __attribute__((vector_size(16))); typedef short short8 __attribute__((vector_size(16))); int main() { short8 a = {1000, 2000, 65535, 0, 1, 5000, 32000, 100}; short8 b = {1000, 555, 10, 0, 65535, 6000, 32767, 65535}; ushort8 c = (ushort8)__builtin_ia32_pavgw128(a, b); for (int i = 0; i < 8; i++) printf("%u ", c[i]); printf("\n"); ASSERT(1000, c[0]); ASSERT(1278, c[1]); ASSERT(32773, c[2]); ASSERT(0, c[3]); ASSERT(32768, c[4]); ASSERT(5500, c[5]); ASSERT(32384, c[6]); ASSERT(32818, c[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pcmpeqb.c000066400000000000000000000014311505335450300176220ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); typedef unsigned char v8qu __attribute__((vector_size(8))); int main() { v8qi a = {1, 2, 3, 4, 5, 6, 7, 8}; v8qi b = {1, 0, 3, 0, 5, 0, 7, 0}; // Compare each byte for equality, returns 0xFF in each byte if equal, else 0x00 v8qu c = (v8qu)__builtin_ia32_pcmpeqb(a, b); // Print bytes as unsigned integers for (int i = 0; i < 8; i++) { printf("%u ", (unsigned char)c[i]); } printf("\n"); // Expected output: 255 0 255 0 255 0 255 0 ASSERT(255, c[0]); ASSERT(0, c[1]); ASSERT(255, c[2]); ASSERT(0, c[3]); ASSERT(255, c[4]); ASSERT(0, c[5]); ASSERT(255, c[6]); ASSERT(0, c[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pcmpeqd.c000066400000000000000000000007621505335450300176320ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = {10, 20}; v2si b = {10, 30}; // Compare elements: result is 0xFFFFFFFF (-1) if equal, else 0x00000000 v2si c = __builtin_ia32_pcmpeqd(a, b); for (int i = 0; i < 2; i++) { printf("%d ", c[i]); // -1 for true, 0 for false } printf("\n"); // Expected output: -1 0 ASSERT(-1, c[0]); ASSERT(0, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pcmpeqw.c000066400000000000000000000010761505335450300176540ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {1, 2, 3, 4}; v4hi b = {1, 0, 3, 5}; // Compare words for equality: each element is 0xFFFF (-1) if equal, else 0x0000 v4hi c = __builtin_ia32_pcmpeqw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", (short)c[i]); // prints -1 if equal else 0 } printf("\n"); // Expected output: -1 0 -1 0 ASSERT(-1, c[0]); ASSERT(0, c[1]); ASSERT(-1, c[2]); ASSERT(0, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pcmpgtb.c000066400000000000000000000012721505335450300176320ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); int main() { v8qi a = {1, 5, -3, 4, 127, -128, 7, -1}; v8qi b = {1, 2, -5, 4, 126, -128, 8, 0}; // Compare bytes, returns 0xFF if a[i] > b[i], else 0x00 v8qi c = __builtin_ia32_pcmpgtb(a, b); for (int i = 0; i < 8; i++) { printf("%d ", (signed char)c[i]); // Will print either 0 or -1 (0xFF) } printf("\n"); // Expected output: 0 -1 -1 0 -1 0 0 -1 ASSERT(0, c[0]); ASSERT(-1, c[1]); ASSERT(-1, c[2]); ASSERT(0, c[3]); ASSERT(-1, c[4]); ASSERT(0, c[5]); ASSERT(0, c[6]); ASSERT(0, c[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pcmpgtd.c000066400000000000000000000007571505335450300176430ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = {10, 40}; v2si b = {20, 30}; // Compare elements: result is 0xFFFFFFFF (-1) if a[i] > b[i], else 0 v2si c = __builtin_ia32_pcmpgtd(a, b); for (int i = 0; i < 2; i++) { printf("%d ", c[i]); // -1 for true, 0 for false } printf("\n"); // Expected output: 0 -1 ASSERT(0, c[0]); ASSERT(-1, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pcmpgtw.c000066400000000000000000000010651505335450300176570ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {5, 2, 7, 1}; v4hi b = {3, 4, 7, 0}; // Compare elements: result is 0xFFFF (-1) if a[i] > b[i], else 0x0000 v4hi c = __builtin_ia32_pcmpgtw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", (short)c[i]); // -1 for true, 0 for false } printf("\n"); // Expected output: -1 0 0 -1 ASSERT(-1, c[0]); ASSERT(0, c[1]); ASSERT(0, c[2]); ASSERT(-1, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmaddwd.c000066400000000000000000000011471505335450300176170ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {1, 2, 3, 4}; v4hi b = {5, 6, 7, 8}; v4hi result = (v4hi)__builtin_ia32_pmaddwd(a, b); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } ASSERT(1, a[0]); ASSERT(2, a[1]); ASSERT(3, a[2]); ASSERT(4, a[3]); ASSERT(5, b[0]); ASSERT(6, b[1]); ASSERT(7, b[2]); ASSERT(8, b[3]); ASSERT(17, result[0]); ASSERT(0, result[1]); ASSERT(53, result[2]); ASSERT(0, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmaddwd128.c000066400000000000000000000014441505335450300200520ustar00rootroot00000000000000#include "test.h" #include typedef short v8hi __attribute__((vector_size(16))); typedef int v4si __attribute__((vector_size(16))); v4si pmaddwd128_test(v8hi a, v8hi b) { return __builtin_ia32_pmaddwd128(a, b); } int main() { v8hi a = {1, 2, 3, 4, -5, -6, 7, 8}; v8hi b = {10, 20, 30, 40, 50, 60, -70, -80}; v4si res = pmaddwd128_test(a, b); printf("%d %d %d %d\n", res[0], res[1], res[2], res[3]); // Expected: // res[0] = (1*10 + 2*20) = 10 + 40 = 50 // res[1] = (3*30 + 4*40) = 90 + 160 = 250 // res[2] = (-5*50 + -6*60) = -250 + -360 = -610 // res[3] = (7*-70 + 8*-80) = -490 + -640 = -1130 ASSERT(50, res[0]); ASSERT(250, res[1]); ASSERT(-610, res[2]); ASSERT(-1130, res[3]); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_pmaxsw.c000066400000000000000000000007561505335450300175230ustar00rootroot00000000000000#include "test.h" // Define a 4-element short vector type (like __v4hi) typedef short v4hi __attribute__((vector_size(8))); int main(void) { v4hi a = {10, 20, 30, 40}; v4hi b = {15, 15, 35, 35}; v4hi c = __builtin_ia32_pmaxsw(a, b); printf("Result: %hd %hd %hd %hd\n", c[0], c[1], c[2], c[3]); // Expected output: 15 20 35 40 ASSERT(15, c[0]); ASSERT(20, c[1]); ASSERT(35, c[2]); ASSERT(40, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmaxsw128.c000066400000000000000000000011771505335450300177540ustar00rootroot00000000000000#include "test.h" typedef short short8 __attribute__((vector_size(16))); int main() { short8 a = {1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000}; short8 b = {-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000}; short8 c = __builtin_ia32_pmaxsw128(a, b); // signed max per lane for(int i = 0; i < 8; i++) { printf("%d ", c[i]); } printf("\n"); ASSERT(1000, c[0]); ASSERT(2000, c[1]); ASSERT(3000, c[2]); ASSERT(4000, c[3]); ASSERT(5000, c[4]); ASSERT(6000, c[5]); ASSERT(7000, c[6]); ASSERT(8000, c[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmaxub.c000066400000000000000000000013131505335450300174660ustar00rootroot00000000000000#include "test.h" typedef unsigned char v8qu __attribute__((vector_size(8))); typedef char v8qi __attribute__((vector_size(8))); int main(void) { v8qu a = {1, 200, 3, 250, 5, 10, 7, 100}; v8qu b = {100, 100, 200, 200, 0, 20, 10, 90}; v8qi c = __builtin_ia32_pmaxub((v8qi)a, (v8qi)b); v8qu d = (v8qu)c; for (int i = 0; i < 8; i++) { printf("%u ", (unsigned)c[i]); } printf("\n"); // Expected output: 100 200 200 250 5 20 10 100 ASSERT(100, d[0]); ASSERT(200, d[1]); ASSERT(200, d[2]); ASSERT(250, d[3]); ASSERT(5, d[4]); ASSERT(20, d[5]); ASSERT(10, d[6]); ASSERT(100, d[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmaxub128.c000066400000000000000000000016431505335450300177270ustar00rootroot00000000000000#include "test.h" typedef unsigned char uchar16 __attribute__((vector_size(16))); typedef char char16 __attribute__((vector_size(16))); int main() { char16 a = {1, 200, 3, 150, 5, 250, 7, 100, 9, 50, 11, 25, 13, 75, 15, 0}; char16 b = {100, 50, 200, 100, 150, 0, 50, 200, 250, 25, 5, 255, 0, 100, 20, 10}; uchar16 c = (uchar16)__builtin_ia32_pmaxub128(a, b); // unsigned max per 8-bit lane for(int i = 0; i < 16; i++) { printf("%u ", c[i]); } printf("\n"); ASSERT(100, c[0]); ASSERT(200, c[1]); ASSERT(200, c[2]); ASSERT(150, c[3]); ASSERT(150, c[4]); ASSERT(250, c[5]); ASSERT(50, c[6]); ASSERT(200, c[7]); ASSERT(250, c[8]); ASSERT(50, c[9]); ASSERT(11, c[10]); ASSERT(255, c[11]); ASSERT(13, c[12]); ASSERT(100, c[13]); ASSERT(20, c[14]); ASSERT(10, c[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pminsw.c000066400000000000000000000010601505335450300175060ustar00rootroot00000000000000#include "test.h" typedef short __v4hi __attribute__((vector_size(8))); int main(void) { __v4hi a = {-1900, -2000, 3000, -4000}; __v4hi b = {-1000, -2500, -3000, 4000}; // Compute pairwise signed minimum using the builtin intrinsic __v4hi r = __builtin_ia32_pminsw(a, b); // Print results for (int i = 0; i < 4; i++) { printf("r[%d] = %d\n", i, r[i]); } ASSERT(-1900, r[0]); ASSERT(-2500, r[1]); ASSERT(-3000, r[2]); ASSERT(-4000, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pminsw128.c000066400000000000000000000012071505335450300177440ustar00rootroot00000000000000#include "test.h" typedef short short8 __attribute__((vector_size(16))); int main() { short8 a = {1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000}; short8 b = {-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000}; short8 c = __builtin_ia32_pminsw128(a, b); // signed min per lane for(int i = 0; i < 8; i++) { printf("%d ", c[i]); } printf("\n"); ASSERT(-1000, c[0]); ASSERT(-2000, c[1]); ASSERT(-3000, c[2]); ASSERT(-4000, c[3]); ASSERT(-5000, c[4]); ASSERT(-6000, c[5]); ASSERT(-7000, c[6]); ASSERT(-8000, c[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pminub.c000066400000000000000000000013561505335450300174730ustar00rootroot00000000000000#include "test.h" typedef char __v8qi __attribute__((vector_size(8))); typedef unsigned char __v8qu __attribute__((vector_size(8))); int main(void) { __v8qi a = {100, 250, 30, 40, 200, 60, 70, 80}; __v8qi b = {150, 200, 50, 20, 180, 70, 60, 90}; __v8qi r = __builtin_ia32_pminub(a, b); __v8qu r2 = (__v8qu) r; for (int i = 0; i < 8; i++) { printf("r[%d] = %u\n", i, r[i]); } for (int i = 0; i < 8; i++) { printf("r2[%d] = %u\n", i, r2[i]); } ASSERT(100, r2[0]); ASSERT(200, r2[1]); ASSERT(30, r2[2]); ASSERT(20, r2[3]); ASSERT(180, r2[4]); ASSERT(60, r2[5]); ASSERT(60, r2[6]); ASSERT(80, r2[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pminub128.c000066400000000000000000000016261505335450300177260ustar00rootroot00000000000000#include "test.h" typedef unsigned char uchar16 __attribute__((vector_size(16))); typedef char char16 __attribute__((vector_size(16))); int main() { char16 a = {1, 200, 3, 150, 5, 250, 7, 100, 9, 50, 11, 25, 13, 75, 15, 0}; char16 b = {100, 50, 200, 100, 150, 0, 50, 200, 250, 25, 5, 255, 0, 100, 20, 10}; uchar16 c = (uchar16)__builtin_ia32_pminub128(a, b); // unsigned min per 8-bit lane for(int i = 0; i < 16; i++) { printf("%u ", c[i]); } printf("\n"); ASSERT(1, c[0]); ASSERT(50, c[1]); ASSERT(3, c[2]); ASSERT(100, c[3]); ASSERT(5, c[4]); ASSERT(0, c[5]); ASSERT(7, c[6]); ASSERT(100, c[7]); ASSERT(9, c[8]); ASSERT(25, c[9]); ASSERT(5, c[10]); ASSERT(25, c[11]); ASSERT(0, c[12]); ASSERT(75, c[13]); ASSERT(15, c[14]); ASSERT(0, c[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmovmskb.c000066400000000000000000000005751505335450300200410ustar00rootroot00000000000000#include "test.h" typedef char __v8qi __attribute__((vector_size(8))); int main(void) { __v8qi a = {0x80, 0x00, 0xFF, 0x01, 0x00, 0x80, 0x7F, 0x00}; // Extract MSB of each byte into a mask unsigned int mask = (unsigned int)__builtin_ia32_pmovmskb(a); printf("mask = 0x%x\n", mask); ASSERT(0x25, mask); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmovmskb128.c000066400000000000000000000007721505335450300202730ustar00rootroot00000000000000#include "test.h" typedef char char16 __attribute__((vector_size(16))); typedef unsigned char uchar16 __attribute__((vector_size(16))); int main() { // Only the MSB of each byte matters char16 a = { 0x80, 0x7F, 0xFF, 0x01, 0x00, 0xC0, 0x20, 0xF0, 0x10, 0x08, 0x04, 0x02, 0x81, 0x82, 0x83, 0x84 }; int mask = __builtin_ia32_pmovmskb128(a); printf("%04X\n", mask); ASSERT(0xF0A5, mask); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmulhuw.c000066400000000000000000000020271505335450300176760ustar00rootroot00000000000000#include "test.h" // 64-bit vectors typedef unsigned short v4hu __attribute__((vector_size(8))); typedef short v4hi __attribute__((vector_size(8))); static unsigned short hi16_mul(unsigned int a, unsigned int b) { // high 16 bits of the 32-bit product (unsigned) unsigned int prod = a * b; // 32-bit return (unsigned short)(prod >> 16); } int main(void) { v4hu A = {1000, 2000, 3000, 4000}; v4hu B = {5000, 6000, 7000, 8000}; // builtin takes signed 16-bit vectors; cast is fine (lane-wise bits identical) v4hu R = (v4hu)__builtin_ia32_pmulhuw((v4hi)A, (v4hi)B); unsigned short *r = (unsigned short*)&R; unsigned short exp0 = hi16_mul(A[0], B[0]); unsigned short exp1 = hi16_mul(A[1], B[1]); unsigned short exp2 = hi16_mul(A[2], B[2]); unsigned short exp3 = hi16_mul(A[3], B[3]); printf("R = {%hu, %hu, %hu, %hu}\n", r[0], r[1], r[2], r[3]); ASSERT(exp0, r[0]); ASSERT(exp1, r[1]); ASSERT(exp2, r[2]); ASSERT(exp3, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmulhuw128.c000066400000000000000000000015271505335450300201350ustar00rootroot00000000000000#include "test.h" typedef unsigned short ushort8 __attribute__((vector_size(16))); typedef short short8 __attribute__((vector_size(16))); int main() { // Choose pairs with easy-to-verify products short8 a = {0xFFFF, 0x8000, 0x1234, 0xAAAA, 0x00FF, 0x0F0F, 0x7FFF, 0x4000}; short8 b = {0xFFFF, 0x0002, 0x0010, 0x0002, 0x00FF, 0x1010, 0x0002, 0x4000}; ushort8 c = (ushort8)__builtin_ia32_pmulhuw128(a, b); // Print high 16 bits of each lane product in hex (zero-padded) for (int i = 0; i < 8; i++) { printf("%04X ", c[i]); } printf("\n"); ASSERT(0xFFFE, c[0]); ASSERT(0x0001, c[1]); ASSERT(0x0001, c[2]); ASSERT(0x0001, c[3]); ASSERT(0x0000, c[4]); ASSERT(0x00F1, c[5]); ASSERT(0x0000, c[6]); ASSERT(0x1000, c[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmulhw.c000066400000000000000000000012211505335450300175040ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {30000, -30000, 100, -100}; v4hi b = {2, 3, 4, 5}; v4hi result = __builtin_ia32_pmulhw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(30000, a[0]); ASSERT(-30000, a[1]); ASSERT(100, a[2]); ASSERT(-100, a[3]); ASSERT(2, b[0]); ASSERT(3, b[1]); ASSERT(4, b[2]); ASSERT(5, b[3]); ASSERT(0, result[0]); ASSERT(-2, result[1]); ASSERT(0, result[2]); ASSERT(-1, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmulhw128.c000066400000000000000000000013651505335450300177500ustar00rootroot00000000000000#include "test.h" typedef short v8hi __attribute__((vector_size(16))); int main() { // Two sets of signed 16-bit integers (8 elements in 128 bits) v8hi a = {3000, -3000, 10000, -10000, 12345, -12345, 20000, -20000}; v8hi b = {2, 3, -2, -3, 4, -4, 5, -5}; // Multiply and keep the high 16 bits v8hi vc = __builtin_ia32_pmulhw128(a, b); // intrinsic for PMULHW // Print results printf("Result: "); for (int i = 0; i < 8; i++) printf("%d ", vc[i]); printf("\n"); ASSERT(0, vc[0]); ASSERT(-1, vc[1]); ASSERT(-1, vc[2]); ASSERT(0, vc[3]); ASSERT(0, vc[4]); ASSERT(0, vc[5]); ASSERT(1, vc[6]); ASSERT(1, vc[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmullw.c000066400000000000000000000012331505335450300175130ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {30000, -30000, 100, -100}; v4hi b = {2, 3, 4, 5}; v4hi result = __builtin_ia32_pmullw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(30000, a[0]); ASSERT(-30000, a[1]); ASSERT(100, a[2]); ASSERT(-100, a[3]); ASSERT(2, b[0]); ASSERT(3, b[1]); ASSERT(4, b[2]); ASSERT(5, b[3]); ASSERT(-5536, result[0]); ASSERT(-24464, result[1]); ASSERT(400, result[2]); ASSERT(-500, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmuludq.c000066400000000000000000000007271505335450300176710ustar00rootroot00000000000000#include "test.h" #include typedef int v4li __attribute__((vector_size(8))); typedef unsigned long long v4lu __attribute__((vector_size(8))); int main() { v4li a = { 2, 4}; v4li b = { 10, 20}; // Multiply and keep the high 16 bits v4lu vc = (v4lu)__builtin_ia32_pmuludq(a, b); // intrinsic for PMULHW printf("Result: %llu\n", (unsigned long long)vc[0]); ASSERT(20, vc[0]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pmuludq128.c000066400000000000000000000010241505335450300201130ustar00rootroot00000000000000#include "test.h" typedef long long __v2di __attribute__((vector_size(16))); typedef int __v4si __attribute__((vector_size(16))); int main(void) { __v4si a = { 2, 0, 3, 0 }; // Only even-indexed elements are used for pmuludq __v4si b = { 5, 0, 7, 0 }; __v2di r = (__v2di)__builtin_ia32_pmuludq128(a, b); long long *res = (long long*)&r; printf("%lld %lld\n", res[0], res[1]); // Expected: 10 21 ASSERT(10, res[0]); ASSERT(21, res[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_popcount.c000066400000000000000000000003031505335450300200370ustar00rootroot00000000000000 #include "test.h" int main() { int count = __builtin_popcount(15); // 15 is 1111 in binary, so count is 4 printf("Number of 1-bits: %d\n", count); ASSERT(4, count); return 0; } chibicc-1.0.23.1/test/builtin_popcountll.c000066400000000000000000000007351505335450300204000ustar00rootroot00000000000000#include "test.h" #include uint32_t a32 = 0xF0F0F0F0; uint64_t a64 = 0xF0F0F0F0F0F0F0F0; int main() { unsigned int c1 = __builtin_popcount(a32); // emits popcnt eax, eax unsigned int c2 = __builtin_popcountl(a64); // emits popcnt rax, rax unsigned int c3 = __builtin_popcountll(a64); // emits popcnt rax, rax printf("c1=%0x\n", c1); printf("c2=%0x\n", c2); printf("c3=%0x\n", c3); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/builtin_por.c000066400000000000000000000016621505335450300170010ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); typedef v2si __m64; int main() { __m64 a = {0xF0F0F0F0, 0xAAAA5555}; __m64 b = {0x0F0F0F0F, 0x12345678}; __m64 result = __builtin_ia32_por(a, b); printf("a[0] = 0x%x\n", a[0]); printf("a[1] = 0x%x\n", a[1]); printf("b[0] = 0x%x\n", b[0]); printf("b[1] = 0x%x\n", b[1]); printf("result[0] = 0x%x\n", result[0]); printf("result[1] = 0x%x\n", result[1]); // result[i] = a[i] | b[i] if (result[0] == (a[0] | b[0]) && result[1] == (a[1] | b[1])) { printf("Test passed.\n"); } else { printf("Test failed.\n"); return 1; } ASSERT(0xf0f0f0f0, a[0]); ASSERT(0xaaaa5555, a[1]); ASSERT(0xf0f0f0f, b[0]); ASSERT(0x12345678, b[1]); ASSERT(0xffffffff, result[0]); ASSERT(0xbabe577d, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psadbw.c000066400000000000000000000006371505335450300174620ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); typedef unsigned long v1du __attribute__((vector_size(8))); #include int main() { v8qi a = {10, 20, 30, 40, 50, 60, 70, 80}; v8qi b = {15, 25, 35, 45, 55, 65, 75, 85}; v1du r = (v1du)__builtin_ia32_psadbw(a, b); printf("%lu\n", r[0]); ASSERT(40, r[0]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psadbw128.c000066400000000000000000000011651505335450300177120ustar00rootroot00000000000000#include "test.h" typedef char char16 __attribute__((vector_size(16))); typedef unsigned long long ull2 __attribute__((vector_size(16))); int main() { char16 a = { 10, 20, 30, 40, 50, 60, 70, 80, 90,100,110,120,130,140,150,160 }; char16 b = { 15, 25, 35, 45, 55, 65, 75, 85, 85, 95,105,115,125,135,145,155 }; ull2 result = (ull2)__builtin_ia32_psadbw128(a, b); printf("Low 8-byte sum: %llu\n", result[0]); printf("High 8-byte sum: %llu\n", result[1]); ASSERT(40, result[0]); ASSERT(40, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pslld.c000066400000000000000000000010601505335450300173070ustar00rootroot00000000000000#include "test.h" // Define a 2-element vector of int (32-bit) typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = {1, 2}; v2si count = {1, 2}; // Perform packed shift left logical on 2x 32-bit integers v2si result = __builtin_ia32_pslld(a, count); printf("%d %d\n", result[0], result[1]); // Expect: 2 8 ASSERT(1, a[0]); ASSERT(2, a[1]); ASSERT(1, count[0]); ASSERT(2, count[1]); ASSERT(0, result[0]); ASSERT(0, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pslld128.c000066400000000000000000000006561505335450300175540ustar00rootroot00000000000000#include "test.h" typedef int __m128i __attribute__((vector_size(16))); int main() { __m128i a = {1, 2, 3, 4}; __m128i b = {1, 0, 0, 0}; __m128i c = __builtin_ia32_pslld128(a, b); // shift left each 32-bit element by 1 printf("%d %d %d %d\n", c[0], c[1], c[2], c[3]); ASSERT(2, c[0]); ASSERT(4, c[1]); ASSERT(6, c[2]); ASSERT(8, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pslldi.c000066400000000000000000000011101505335450300174540ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = {1, 2}; // Shift left each 32-bit element by 1 bit (immediate) v2si result = __builtin_ia32_pslldi(a, 1); for (int i = 0; i < 2; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(1, a[0]); ASSERT(2, a[1]); ASSERT(2, result[0]); ASSERT(4, result[1]); int count = 1; result = __builtin_ia32_pslldi(a, count); ASSERT(2, result[0]); ASSERT(4, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pslldi128.c000066400000000000000000000014221505335450300177150ustar00rootroot00000000000000#include "test.h" #include // Declare the builtin typedef int __m128i __attribute__((__vector_size__(16), __may_alias__)); int main() { __m128i v = { 1, 2, 3, 4 }; // Four 32-bit integers in the 128-bit vector int shift = 2; // Shift left by 2 bits __m128i result = __builtin_ia32_pslldi128(v, shift); uint32_t *vals = (uint32_t *)&result; printf("Result: %u %u %u %u\n", vals[0], vals[1], vals[2], vals[3]); ASSERT(4, result[0]); ASSERT(8, result[1]); ASSERT(12, result[2]); ASSERT(16, result[3]); result = __builtin_ia32_pslldi128(v, 2); ASSERT(4, result[0]); ASSERT(8, result[1]); ASSERT(12, result[2]); ASSERT(16, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllq.c000066400000000000000000000006401505335450300173270ustar00rootroot00000000000000#include "test.h" typedef long long __m64 __attribute__((vector_size(8))); int main() { __m64 a = (__m64){0x1000LL}; __m64 count = (__m64){4}; // shift left by 4 bits __m64 result = __builtin_ia32_psllq(a, count); printf("0x%llx\n", (unsigned long long)result[0]); // Expected output: 0x10000 (0x1000 << 4) ASSERT(0x10000, result[0]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllq128.c000066400000000000000000000007001505335450300175570ustar00rootroot00000000000000#include "test.h" #include typedef long long v8hi __attribute__((vector_size(16))); int main() { v8hi a = { 1, 2 }; v8hi b = {1,0}; v8hi r = __builtin_ia32_psllq128((v8hi)a, (v8hi)b); long long *res = (long long *)&r; for (int i = 0; i < 2; i++) { printf("%lld ", res[i]); } printf("\n"); ASSERT(2, r[0]); ASSERT(4, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllqi.c000066400000000000000000000014351505335450300175030ustar00rootroot00000000000000#include "test.h" typedef long long __m64 __attribute__((vector_size(8))); typedef int __v1di __attribute__((vector_size(8))); // Forward declaration of the intrinsic (usually built-in by compiler) __m64 __builtin_ia32_psllqi(__m64 a, int count); int main() { __m64 a = (__m64){0x123456789abcdef0LL}; // sample 64-bit value packed in __m64 int count = 1; // shift left by 1 bit __m64 result = __builtin_ia32_psllqi(a, count); // Print result as 64-bit integer (cast vector to long long) long long *p = (long long*)&result; printf("Result after psllqi by %d: 0x%llx\n", count, p[0]); ASSERT(897170912, result[0]); __m64 result = __builtin_ia32_psllqi(a, 1); ASSERT(897170912, result[0]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllqi128.c000066400000000000000000000007171505335450300177400ustar00rootroot00000000000000#include "test.h" #include typedef long long v2di __attribute__((vector_size(16))); v2di test_psllq_i128(v2di a) { // Equivalent to: return __builtin_ia32_psllqi128(a, 2); return __builtin_ia32_psllqi128(a, 2); } int main() { v2di a = {1, 2}; // Two 64-bit integers v2di b = test_psllq_i128(a); printf("%lld %lld\n", b[0], b[1]); ASSERT(4, b[0]); ASSERT(8, b[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllw.c000066400000000000000000000013171505335450300173370ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = (v4hi){1, 2, 3, 4}; // v4hi v4hi count = (v4hi){1, 1, 1, 1}; // shift each by 1 bit v4hi result = __builtin_ia32_psllw(a, count); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); for (int i = 0; i < 4; i++) { printf("%d ", a[i]); ASSERT(i + 1, a[i]); } for (int i = 0; i < 4; i++) { printf("%d ", count[i]); ASSERT(1, count[i]); } ASSERT(0, result[0]); ASSERT(0, result[1]); ASSERT(0, result[2]); ASSERT(0, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllw128.c000066400000000000000000000006761505335450300176010ustar00rootroot00000000000000#include "test.h" #include typedef short v8hi __attribute__((vector_size(16))); int main() { v8hi a = { 1, 2, 3, 4, 5, 6, 7, 8 }; v8hi b = {1,0,2,3,1,0,2,3}; v8hi r = __builtin_ia32_psllw128((v8hi)a, (v8hi)b); short *res = (short *)&r; for (int i = 0; i < 8; i++) { printf("%d ", res[i]); ASSERT(0, r[i]); } printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psllwi.c000066400000000000000000000017501505335450300175110ustar00rootroot00000000000000#include "test.h" typedef long long __m64; // minimal __m64 definition typedef short v4hi __attribute__((vector_size(8))); int main(void) { v4hi a = {1, 2, 3, 4}; // reinterpret v4hi as __m64 for builtin __m64 am = (__m64)a; // shift each 16-bit element left by 1 (immediate form) __m64 rm = (__m64)__builtin_ia32_psllwi(a, 1); // reinterpret back to vector for printing v4hi result = (v4hi)rm; for (int i = 0; i < 4; i++) { printf("%d ", a[i]); ASSERT(i+1, a[i]); } for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(2, result[0]); ASSERT(4, result[1]); ASSERT(6, result[2]); ASSERT(8, result[3]); int count = 1; result = (v4hi)__builtin_ia32_psllwi(a, count); ASSERT(2, result[0]); ASSERT(4, result[1]); ASSERT(6, result[2]); ASSERT(8, result[3]); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/builtin_psllwi128.c000066400000000000000000000016741505335450300177510ustar00rootroot00000000000000#include "test.h" #include typedef short v8si __attribute__((vector_size(16))); int main() { // Prepare test data: 8 x 16-bit words in a 128-bit vector v8si v = {1, 2, 3, 4, 0x8000, 0x4000, 0x1234, 0xFFFF}; v8si r = __builtin_ia32_psllwi128(v, 1); for (int i = 0; i < 8; i++) { printf("%04x ", r[i]); } printf("\n"); ASSERT(2, r[0]); ASSERT(4, r[1]); ASSERT(6, r[2]); ASSERT(8, r[3]); ASSERT(0, r[4]); ASSERT(-32768, r[5]); ASSERT(9320, r[6]); ASSERT(-2, r[7]); int count = 1; r = __builtin_ia32_psllwi128(v, count); for (int i = 0; i < 8; i++) { printf("%04x ", r[i]); } printf("\n"); ASSERT(2, r[0]); ASSERT(4, r[1]); ASSERT(6, r[2]); ASSERT(8, r[3]); ASSERT(0, r[4]); ASSERT(-32768, r[5]); ASSERT(9320, r[6]); ASSERT(-2, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrad.c000066400000000000000000000007631505335450300173130ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = (v2si){-1024, 2048}; v2si count = (v2si){2, 3}; // shift each lane by respective value v2si result = __builtin_ia32_psrad(a, count); printf("%d %d\n", result[0], result[1]); ASSERT(-1024, a[0]); ASSERT(2048, a[1]); ASSERT(2, count[0]); ASSERT(3, count[1]); ASSERT(-1, result[0]); ASSERT(0, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrad128.c000066400000000000000000000010541505335450300175400ustar00rootroot00000000000000#include "test.h" #include typedef int v4si __attribute__((vector_size(16))); int main() { v4si a = { 100000, -100000, 2147483647, -2147483648 }; v4si b = { 2, 2, 2, 2 }; // Shift right arithmetic by 2 bits v4si r = __builtin_ia32_psrad128((v4si)a,(v4si)b); int *res = (int *)&r; for (int i = 0; i < 4; i++) { printf("%d ", res[i]); } printf("\n"); ASSERT(0, r[0]); ASSERT(-1, r[1]); ASSERT(0, r[2]); ASSERT(-1, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psradi.c000066400000000000000000000011071505335450300174550ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); int main() { v2si a = (v2si){-1024, 2048}; // Shift both lanes right by an immediate value of 2 v2si result = __builtin_ia32_psradi(a, 2); printf("%d %d\n", result[0], result[1]); // Expect -256 and 512 ASSERT(-1024, a[0]); ASSERT(2048, a[1]); ASSERT(-256, result[0]); ASSERT(512, result[1]); int count = 2; result = __builtin_ia32_psradi(a, count); ASSERT(-256, result[0]); ASSERT(512, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psradi128.c000066400000000000000000000015201505335450300177070ustar00rootroot00000000000000#include "test.h" #include typedef int v4si __attribute__((vector_size(16))); int main() { v4si a = { 100000, -100000, 2147483647, -2147483648 }; // Shift right arithmetic by 2 bits v4si r = __builtin_ia32_psradi128((v4si)a, 2); int *res = (int *)&r; for (int i = 0; i < 4; i++) { printf("%d ", res[i]); } printf("\n"); ASSERT(25000, r[0]); ASSERT(-25000, r[1]); ASSERT(536870911, r[2]); ASSERT(-536870912, r[3]); int count = 2; r = __builtin_ia32_psradi128((v4si)a, 2); res = (int *)&r; for (int i = 0; i < 4; i++) { printf("%d ", res[i]); } printf("\n"); ASSERT(25000, r[0]); ASSERT(-25000, r[1]); ASSERT(536870911, r[2]); ASSERT(-536870912, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psraw.c000066400000000000000000000006671505335450300173410ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = (v4hi){-2, -4, 8, 16}; v4hi count = (v4hi){1, 1, 1, 1}; v4hi result = __builtin_ia32_psraw(a, count); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(-1, result[0]); ASSERT(-1, result[1]); ASSERT(0, result[2]); ASSERT(0, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psraw128.c000066400000000000000000000010251505335450300175610ustar00rootroot00000000000000 #include "test.h" typedef short short16 __attribute__((vector_size(16))); int main() { short16 a = {1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000}; short16 b = {1, 0, 1, 0, 2, 0, 2, 0}; short16 c = __builtin_ia32_psraw128(a, b); // shift each 16-bit element right by 2 for(int i=0; i<8; i++) { printf("%d ", c[i]); if (i % 2 == 0) ASSERT(0, c[i]); else ASSERT(-1, c[i]); } printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrawi.c000066400000000000000000000010641505335450300175020ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = (v4hi){-4, -8, 16, 32}; int count = 2; v4hi result = __builtin_ia32_psrawi(a, count); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(-1, result[0]); ASSERT(-2, result[1]); ASSERT(4, result[2]); ASSERT(8, result[3]); result = __builtin_ia32_psrawi(a, 2); ASSERT(-1, result[0]); ASSERT(-2, result[1]); ASSERT(4, result[2]); ASSERT(8, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrawi128.c000066400000000000000000000020161505335450300177330ustar00rootroot00000000000000#include "test.h" #include typedef short v8hi __attribute__((vector_size(16))); int main() { v8hi a = { 1000, -1000, 32767, -32768, 1234, -1234, 500, -500 }; // Shift right arithmetic by 2 bits v8hi r = __builtin_ia32_psrawi128((v8hi)a, 2); short *res = (short *)&r; for (int i = 0; i < 8; i++) { printf("%d ", res[i]); } printf("\n"); ASSERT(250, r[0]); ASSERT(-250, r[1]); ASSERT(8191, r[2]); ASSERT(-8192, r[3]); ASSERT(308, r[4]); ASSERT(-309, r[5]); ASSERT(125, r[6]); ASSERT(-125, r[7]); int count = 2; r = __builtin_ia32_psrawi128((v8hi)a, 2); res = (short *)&r; for (int i = 0; i < 8; i++) { printf("%d ", res[i]); } printf("\n"); ASSERT(250, r[0]); ASSERT(-250, r[1]); ASSERT(8191, r[2]); ASSERT(-8192, r[3]); ASSERT(308, r[4]); ASSERT(-309, r[5]); ASSERT(125, r[6]); ASSERT(-125, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrld.c000066400000000000000000000007401505335450300173210ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); // 2 x 32-bit ints int main() { v2si a = {4, -4}; // second value has sign bit set // Logical shift right by vector count v2si count_vec = {1, 1}; v2si r1 = __builtin_ia32_psrld(a, count_vec); printf("psrld variable count: %u %u\n", (unsigned)r1[0], (unsigned)r1[1]); ASSERT(0, (unsigned)r1[0]); ASSERT(0, (unsigned)r1[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrld128.c000066400000000000000000000007051505335450300175550ustar00rootroot00000000000000#include "test.h" typedef int int4 __attribute__((vector_size(16))); int main() { int4 a = {1, 2, 3, 4}; int4 b = {1, 0, 1, 0}; int4 c = __builtin_ia32_psrld128(a, b); // shift each 32-bit element right by 1 for(int i = 0; i < 4; i++) { printf("%d ", c[i]); } printf("\n"); ASSERT(0, c[0]); ASSERT(1, c[1]); ASSERT(1, c[2]); ASSERT(2, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrldi.c000066400000000000000000000013101505335450300174640ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); // 2 x 32-bit ints int main() { v2si a = {4, -4}; // second value has sign bit set // Logical shift right by vector count v2si count_vec = {1, 1}; // Logical shift right by immediate count v2si r2 = __builtin_ia32_psrldi(a, 1); printf("psrldi immediate count: %u %u\n", (unsigned)r2[0], (unsigned)r2[1]); int count = 1; r2 = __builtin_ia32_psrldi(a, count); printf("psrldi immediate count: %u %u\n", (unsigned)r2[0], (unsigned)r2[1]); // psrldi : 2 2147483646 ASSERT(2, (unsigned)r2[0]); ASSERT(2147483646, (unsigned)r2[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrldi128.c000066400000000000000000000016311505335450300177250ustar00rootroot00000000000000#include "test.h" #include typedef int v4si __attribute__((vector_size(16))); int main() { v4si a = { 0xFFFFFFFF, 0x80000000, 0x12345678, 0x00000001 }; // Shift right logical by 1 v4si r = __builtin_ia32_psrldi128((v4si)a, 1); unsigned int *res = (unsigned int *)&r; for (int i = 0; i < 4; i++) { printf("%08x ", res[i]); } printf("\n"); ASSERT(0x7fffffff, r[0]); ASSERT(0x40000000, r[1]); ASSERT(0x091a2b3c, r[2]); ASSERT(0x00000000, r[3]); int count = 1; r = __builtin_ia32_psrldi128((v4si)a, count); res = (unsigned int *)&r; for (int i = 0; i < 4; i++) { printf("%08x ", res[i]); } printf("\n"); ASSERT(0x7fffffff, r[0]); ASSERT(0x40000000, r[1]); ASSERT(0x091a2b3c, r[2]); ASSERT(0x00000000, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlq.c000066400000000000000000000012461505335450300173400ustar00rootroot00000000000000#include "test.h" typedef long long v1di __attribute__((vector_size(8))); #include int main() { v1di a = {0x123456789abcdef0LL}; v1di count = {4}; v1di result_var = __builtin_ia32_psrlq(a, count); v1di result_imm = __builtin_ia32_psrlqi(a, 4); printf("result_var: 0x%llx\n", result_var[0]); printf("result_imm: 0x%llx\n", result_imm[0]); LASSERT(0x123456789abcdefLL, (long long)result_var[0]); LASSERT(0x123456789abcdefLL, (long long)result_imm[0]); int c = 4; result_imm = __builtin_ia32_psrlqi(a, c); LASSERT(0x123456789abcdefLL, (long long)result_imm[0]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlq128.c000066400000000000000000000006271505335450300175750ustar00rootroot00000000000000#include "test.h" typedef long long v2li __attribute__((vector_size(16))); int main() { v2li a = {1, 2,}; v2li b = {1, 0}; v2li c = __builtin_ia32_psrlq128(a, b); // shift each 32-bit element right by 1 for(int i = 0; i < 2; i++) { printf("%lld ", c[i]); } printf("\n"); ASSERT(0, c[0]); ASSERT(1, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlqi128.c000066400000000000000000000014201505335450300177360ustar00rootroot00000000000000#include "test.h" #include typedef long long v2di __attribute__((vector_size(16))); int main() { v2di a = { 0xFFFFFFFFFFFFFFFF, 0x8000000000000000 }; // Shift right logical by 1 v2di r = __builtin_ia32_psrlqi128((v2di)a, 1); unsigned long long *res = (unsigned long long *)&r; for (int i = 0; i < 2; i++) { printf("%016llx ", res[i]); } printf("\n"); LASSERT(0x7fffffffffffffff, r[0]); LASSERT(0x4000000000000000, r[1]); int count = 1; // Shift right logical by 1 r = __builtin_ia32_psrlqi128((v2di)a, count); res = (unsigned long long *)&r; for (int i = 0; i < 2; i++) { printf("%016llx ", res[i]); } printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlw.c000066400000000000000000000014451505335450300173470ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = (v4hi){4, 8, -4, -8}; // v4hi with signed values v4hi count = (v4hi){1, 1, 1, 1}; // shift right by 1 bit each // Logical shift right on packed 16-bit integers (ignores sign) v4hi result = __builtin_ia32_psrlw(a, count); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); ASSERT(4, a[0]); ASSERT(8, a[1]); ASSERT(-4, a[2]); ASSERT(-8, a[3]); ASSERT(1, count[0]); ASSERT(1, count[1]); ASSERT(1, count[2]); ASSERT(1, count[3]); ASSERT(0, result[0]); ASSERT(0, result[1]); ASSERT(0, result[2]); ASSERT(0, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlw128.c000066400000000000000000000007031505335450300175760ustar00rootroot00000000000000#include "test.h" typedef short short16 __attribute__((vector_size(16))); int main() { short16 a = {1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000}; short16 b = {1, 0, 1, 0, 1, 0, 1, 0}; short16 c = __builtin_ia32_psrlw128(a, b); // shift each 16-bit element right by 3 for(int i = 0; i < 8; i++) { printf("%d ", c[i]); ASSERT(0, c[i]); } printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlwi.c000066400000000000000000000013761505335450300175230ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = (v4hi){4, 8, -4, -8}; // v4hi with signed values // Logical shift right by immediate 1 bit v4hi result = __builtin_ia32_psrlwi(a, 1); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } printf("\n"); // Expect: 2 4 32766 32764 (logical shift right ignores sign bit) ASSERT(2, result[0]); ASSERT(4, result[1]); ASSERT(32766, result[2]); ASSERT(32764, result[3]); int count = 1; result = __builtin_ia32_psrlwi(a, count); ASSERT(2, result[0]); ASSERT(4, result[1]); ASSERT(32766, result[2]); ASSERT(32764, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psrlwi128.c000066400000000000000000000021271505335450300177510ustar00rootroot00000000000000#include "test.h" #include typedef short v8hi __attribute__((vector_size(16))); int main() { v8hi a = { 0xFFFF, 0x8000, 0x1234, 0x0001, 0x7FFF, 0x4000, 0xAAAA, 0x5555 }; // Shift right logical by 1 v8hi r = __builtin_ia32_psrlwi128((v8hi)a, 1); unsigned short *res = (unsigned short *)&r; for (int i = 0; i < 8; i++) { printf("%04x ", res[i]); } printf("\n"); ASSERT(0x7fff, r[0]); ASSERT(0x4000, r[1]); ASSERT(0x091a, r[2]); ASSERT(0x0000, r[3]); ASSERT(0x3fff, r[4]); ASSERT(0x2000, r[5]); ASSERT(0x5555, r[6]); ASSERT(0x2aaa, r[7]); int count = 1; r = __builtin_ia32_psrlwi128((v8hi)a, count); res = (unsigned short *)&r; for (int i = 0; i < 8; i++) { printf("%04x ", res[i]); } printf("\n"); ASSERT(0x7fff, r[0]); ASSERT(0x4000, r[1]); ASSERT(0x091a, r[2]); ASSERT(0x0000, r[3]); ASSERT(0x3fff, r[4]); ASSERT(0x2000, r[5]); ASSERT(0x5555, r[6]); ASSERT(0x2aaa, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubb.c000066400000000000000000000017011505335450300173060ustar00rootroot00000000000000 #include "test.h" typedef char v8qi __attribute__((vector_size(8))); int main(void) { v8qi a = {100, -50, 30, -128, 10, 20, 30, 40}; v8qi b = {50, 50, -30, 1, 5, 5, 5, 5}; v8qi result = (v8qi)__builtin_ia32_psubb(a, b); for (int i = 0; i < 8; i++) printf("%d ", result[i]); ASSERT(100, a[0]); ASSERT(-50, a[1]); ASSERT(30, a[2]); ASSERT(-128, a[3]); ASSERT(10, a[4]); ASSERT(20, a[5]); ASSERT(30, a[6]); ASSERT(40, a[7]); ASSERT(50, b[0]); ASSERT(50, b[1]); ASSERT(-30, b[2]); ASSERT(1, b[3]); ASSERT(5, b[4]); ASSERT(5, b[5]); ASSERT(5, b[6]); ASSERT(5, b[7]); ASSERT(50, result[0]); ASSERT(-100, result[1]); ASSERT(60, result[2]); ASSERT(127, result[3]); ASSERT(5, result[4]); ASSERT(15, result[5]); ASSERT(25, result[6]); ASSERT(35, result[7]); printf("\n"); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_psubd.c000066400000000000000000000007621505335450300173160ustar00rootroot00000000000000 #include "test.h" typedef int v2si __attribute__((vector_size(8))); int main(void) { v2si a = {100000, -200000}; v2si b = {50000, 100000}; v2si result = (v2si)__builtin_ia32_psubd(a, b); for (int i = 0; i < 2; i++) printf("%d ", result[i]); printf("\n"); ASSERT(100000, a[0]); ASSERT(-200000, a[1]); ASSERT(50000, b[0]); ASSERT(100000, b[1]); ASSERT(50000, result[0]); ASSERT(-300000, result[1]); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_psubq.c000066400000000000000000000005171505335450300173310ustar00rootroot00000000000000 #include "test.h" typedef long long v1di __attribute__((vector_size(8))); int main(void) { v1di a = {10000000000LL}; v1di b = {5000000000LL}; v1di result = (v1di)__builtin_ia32_psubq(a, b); printf("%lld\n", (long long)result[0]); LASSERT(5000000000, (long long)result[0]); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_psubsb.c000066400000000000000000000020301505335450300174650ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); int main() { v8qi a = {100, 50, -100, -50, 127, -128, 10, -10}; v8qi b = {50, 100, -50, -100, 1, 1, 20, 20}; v8qi result = __builtin_ia32_psubsb(a, b); for (int i = 0; i < 8; i++) { printf("%d ", (int)result[i]); } printf("\n"); ASSERT(100, a[0]); ASSERT(50, a[1]); ASSERT(-100, a[2]); ASSERT(-50, a[3]); ASSERT(127, a[4]); ASSERT(-128, a[5]); ASSERT(10, a[6]); ASSERT(-10, a[7]); ASSERT(50, b[0]); ASSERT(100, b[1]); ASSERT(-50, b[2]); ASSERT(-100, b[3]); ASSERT(1, b[4]); ASSERT(1, b[5]); ASSERT(20, b[6]); ASSERT(20, b[7]); ASSERT(50, (int) result[0]); ASSERT(-50, (int) result[1]); ASSERT(-50, (int) result[2]); ASSERT(50, (int) result[3]); ASSERT(126, (int) result[4]); ASSERT(-128, (int) result[5]); ASSERT(-10, (int) result[6]); ASSERT(-30, (int) result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubsb128.c000066400000000000000000000021711505335450300177260ustar00rootroot00000000000000#include "test.h" #include typedef char v16qi __attribute__((vector_size(16))); v16qi do_psubsb(v16qi a, v16qi b) { // Saturated subtraction of packed signed 8-bit integers return __builtin_ia32_psubsb128(a, b); } int main() { v16qi a = { 120, 100, -120, -100, 50, -50, 127, -127, 10, 20, -30, 40, 90, -90, 60, -60 }; v16qi b = { 10, 50, -50, 100, -100, -100, -1, 1, -10, 30, 40, -50, -90, 90, -70, 70 }; v16qi result = do_psubsb(a, b); printf("Result: "); for (int i = 0; i < 16; i++) printf("%d ", result[i]); ASSERT(110, result[0]); ASSERT(50, result[1]); ASSERT(-70, result[2]); ASSERT(-128, result[3]); ASSERT(127, result[4]); ASSERT(50, result[5]); ASSERT(127, result[6]); ASSERT(-128, result[7]); ASSERT(20, result[8]); ASSERT(-10, result[9]); ASSERT(-70, result[10]); ASSERT(90, result[11]); ASSERT(127, result[12]); ASSERT(-128, result[13]); ASSERT(127, result[14]); ASSERT(-128, result[15]); printf("\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubsw.c000066400000000000000000000013111505335450300175130ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {30000, -30000, 100, -100}; v4hi b = {1000, 1000, 500, 500}; v4hi result = __builtin_ia32_psubsw(a, b); for (int i = 0; i < 4; i++) { printf("%d ", (int)result[i]); } ASSERT(30000, a[0]); ASSERT(-30000, a[1]); ASSERT(100, a[2]); ASSERT(-100, a[3]); ASSERT(1000, b[0]); ASSERT(1000, b[1]); ASSERT(500, b[2]); ASSERT(500, b[3]); ASSERT(29000, (int) result[0]); ASSERT(-31000, (int) result[1]); ASSERT(-400, (int) result[2]); ASSERT(-600, (int) result[3]); printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubsw128.c000066400000000000000000000013761505335450300177610ustar00rootroot00000000000000#include "test.h" #include typedef long long __v2di __attribute__((__vector_size__(16))); typedef short __v8hi __attribute__((__vector_size__(16))); int main() { __v8hi a = {30000, -20000, 15000, -32768, 1000, -1000, 20000, -15000}; __v8hi b = {10000, -20000, 20000, 1000, 5000, -4000, -30000, 20000}; __v8hi res = __builtin_ia32_psubsw128(a, b); short *vals = (short*)&res; for (int i = 0; i < 8; i++) printf("%d ", vals[i]); printf("\n"); ASSERT(20000, res[0]); ASSERT(0, res[1]); ASSERT(-5000, res[2]); ASSERT(-32768, res[3]); ASSERT(-4000, res[4]); ASSERT(3000, res[5]); ASSERT(32767, res[6]); ASSERT(-32768, res[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubusb.c000066400000000000000000000021751505335450300176640ustar00rootroot00000000000000#include "test.h" typedef unsigned char v8qu __attribute__((vector_size(8))); typedef char v8qi __attribute__((vector_size(8))); int main() { v8qu a = {255, 200, 100, 50, 25, 10, 5, 0}; v8qu b = {1, 50, 50, 25, 10, 5, 5, 0}; v8qu result =(v8qu) __builtin_ia32_psubusb((v8qi)a, (v8qi)b); for (int i = 0; i < 8; i++) { printf("%u ", (unsigned)result[i]); } printf("\n"); ASSERT(255, a[0]); ASSERT(200, a[1]); ASSERT(100, a[2]); ASSERT(50, a[3]); ASSERT(25, a[4]); ASSERT(10, a[5]); ASSERT(5, a[6]); ASSERT(0, a[7]); ASSERT(1, b[0]); ASSERT(50, b[1]); ASSERT(50, b[2]); ASSERT(25, b[3]); ASSERT(10, b[4]); ASSERT(5, b[5]); ASSERT(5, b[6]); ASSERT(0, b[7]); ASSERT(254, (unsigned) result[0]); ASSERT(150, (unsigned) result[1]); ASSERT(50, (unsigned) result[2]); ASSERT(25, (unsigned) result[3]); ASSERT(15, (unsigned) result[4]); ASSERT(5, (unsigned) result[5]); ASSERT(0, (unsigned) result[6]); ASSERT(0, (unsigned) result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubusb128.c000066400000000000000000000026161505335450300201170ustar00rootroot00000000000000#include "test.h" #include typedef char __m128i __attribute__((__vector_size__(16), __may_alias__)); typedef unsigned char __m128u __attribute__((__vector_size__(16), __may_alias__)); __m128i test_psubusb128(__m128i a, __m128i b) { return __builtin_ia32_psubusb128(a, b); } int main() { // Initialize with unsigned bytes __m128i a = (__m128i){ 200, 255, 0, 50, 100, 5, 255, 10, 200, 255, 0, 50, 100, 5, 255, 10 }; __m128i b = (__m128i){ 100, 100, 100, 100, 200, 200, 5, 20, 100, 100, 100, 100, 200, 200, 5, 20 }; __m128u result = (__m128u)test_psubusb128(a, b); unsigned char *res = (unsigned char *)&result; printf("Result: "); for (int i = 0; i < 16; i++) printf("%u ", res[i]); printf("\n"); // Expected (saturated at 0) // 100, 155, 0, 0, 0, 0, 250, 0, // 100, 155, 0, 0, 0, 0, 250, 0 ASSERT(100, result[0]); ASSERT(155, result[1]); ASSERT(0, result[2]); ASSERT(0, result[3]); ASSERT(0, result[4]); ASSERT(0, result[5]); ASSERT(250, result[6]); ASSERT(0, result[7]); ASSERT(100, result[8]); ASSERT(155, result[9]); ASSERT(0, result[10]); ASSERT(0, result[11]); ASSERT(0, result[12]); ASSERT(0, result[13]); ASSERT(250, result[14]); ASSERT(0, result[15]); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_psubusw.c000066400000000000000000000014611505335450300177060ustar00rootroot00000000000000#include "test.h" typedef unsigned short v4hu __attribute__((vector_size(8))); typedef short v4hi __attribute__((vector_size(8))); int main() { v4hu a = {65535, 40000, 30000, 10000}; v4hu b = {1, 1000, 40000, 5000}; v4hu result = (v4hu)__builtin_ia32_psubusw((v4hi)a, (v4hi)b); for (int i = 0; i < 4; i++) { printf("%u ", (unsigned)result[i]); } printf("\n"); ASSERT(65535, a[0]); ASSERT(40000, a[1]); ASSERT(30000, a[2]); ASSERT(10000, a[3]); ASSERT(1, b[0]); ASSERT(1000, b[1]); ASSERT(40000, b[2]); ASSERT(5000, b[3]); ASSERT(65534, (unsigned) result[0]); ASSERT(39000, (unsigned) result[1]); ASSERT(0, (unsigned) result[2]); ASSERT(5000, (unsigned) result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubusw128.c000066400000000000000000000015301505335450300201360ustar00rootroot00000000000000#include "test.h" #include typedef short __m128i __attribute__((__vector_size__(16), __may_alias__)); typedef unsigned short __m128u __attribute__((__vector_size__(16), __may_alias__)); int main() { // Test vectors __m128i a = (__m128i){ 500, 1000, 30000, 40000, 50, 60, 65535, 0 }; __m128i b = (__m128i){ 100, 2000, 40000, 500, 100, 50, 65535, 1 }; __m128u result = (__m128u)__builtin_ia32_psubusw128(a, b); uint16_t *res = (uint16_t *)&result; for (int i = 0; i < 8; i++) { printf("%u ", res[i]); } printf("\n"); ASSERT(400, result[0]); ASSERT(0, result[1]); ASSERT(0, result[2]); ASSERT(39500, result[3]); ASSERT(0, result[4]); ASSERT(10, result[5]); ASSERT(0, result[6]); ASSERT(0, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_psubw.c000066400000000000000000000012351505335450300173350ustar00rootroot00000000000000 #include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main(void) { v4hi a = {1000, -2000, 3000, -32768}; v4hi b = {500, 500, -3000, 1}; v4hi result = (v4hi)__builtin_ia32_psubw(a, b); for (int i = 0; i < 4; i++) printf("%d ", result[i]); ASSERT(1000, a[0]); ASSERT(-2000, a[1]); ASSERT(3000, a[2]); ASSERT(-32768, a[3]); ASSERT(500, b[0]); ASSERT(500, b[1]); ASSERT(-3000, b[2]); ASSERT(1, b[3]); ASSERT(500, result[0]); ASSERT(-2500, result[1]); ASSERT(6000, result[2]); ASSERT(32767, result[3]); printf("\n"); printf("OK\n"); } chibicc-1.0.23.1/test/builtin_punpckhbw.c000066400000000000000000000016541505335450300202030ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); int main() { v8qi a = {0,1,2,3,4,5,6,7}; v8qi b = {10,11,12,13,14,15,16,17}; v8qi result = (v8qi)__builtin_ia32_punpckhbw(a, b); for (int i = 0; i < 8; i++) { printf("%u ", (unsigned int)result[i]); } ASSERT(0, a[0]); ASSERT(1, a[1]); ASSERT(2, a[2]); ASSERT(3, a[3]); ASSERT(4, a[4]); ASSERT(5, a[5]); ASSERT(6, a[6]); ASSERT(7, a[7]); ASSERT(10, b[0]); ASSERT(11, b[1]); ASSERT(12, b[2]); ASSERT(13, b[3]); ASSERT(14, b[4]); ASSERT(15, b[5]); ASSERT(16, b[6]); ASSERT(17, b[7]); ASSERT(4, result[0]); ASSERT(14, result[1]); ASSERT(5, result[2]); ASSERT(15, result[3]); ASSERT(6, result[4]); ASSERT(16, result[5]); ASSERT(7, result[6]); ASSERT(17, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckhbw128.c000066400000000000000000000020061505335450300204260ustar00rootroot00000000000000#include "test.h" typedef unsigned char __v16qu __attribute__((vector_size(16))); typedef char __v16qi __attribute__((vector_size(16))); __v16qi test_punpckhbw(__v16qi a, __v16qi b) { return __builtin_ia32_punpckhbw128(a, b); } int main(void) { __v16qi a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; __v16qi b = {100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115 }; __v16qu r = (__v16qu)test_punpckhbw(a, b); for (int i = 0; i < 16; i++) printf("%u ", r[i]); printf("\n"); ASSERT(8, r[0]); ASSERT(108, r[1]); ASSERT(9, r[2]); ASSERT(109, r[3]); ASSERT(10, r[4]); ASSERT(110, r[5]); ASSERT(11, r[6]); ASSERT(111, r[7]); ASSERT(12, r[8]); ASSERT(112, r[9]); ASSERT(13, r[10]); ASSERT(113, r[11]); ASSERT(14, r[12]); ASSERT(114, r[13]); ASSERT(15, r[14]); ASSERT(115, r[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckhdq.c000066400000000000000000000007601505335450300201740ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); // 2 ints, 64 bits (MMX size) int main() { v2si a = {1000, 2000}; v2si b = {10, 20}; ASSERT(1000, a[0]); ASSERT(2000, a[1]); ASSERT(10, b[0]); ASSERT(20, b[1]); v2si result = __builtin_ia32_punpckhdq(a, b); for (int i = 0; i < 2; i++) { printf("%d ", result[i]); } ASSERT(2000, result[0]); ASSERT(20, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckhdq128.c000066400000000000000000000010171505335450300204230ustar00rootroot00000000000000#include "test.h" typedef int __v4si __attribute__((vector_size(16))); __v4si test_punpckhdq128(__v4si a, __v4si b) { return __builtin_ia32_punpckhdq128(a, b); } int main(void) { __v4si a = { 0, 1, 2, 3 }; __v4si b = {100,101,102,103 }; __v4si r = test_punpckhdq128(a, b); for (int i = 0; i < 4; i++) printf("%d ", r[i]); printf("\n"); ASSERT(2, r[0]); ASSERT(102, r[1]); ASSERT(3, r[2]); ASSERT(103, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckhqdq128.c000066400000000000000000000010171505335450300206040ustar00rootroot00000000000000#include "test.h" typedef int __v4si __attribute__((vector_size(16))); __v4si test_punpckhdq128(__v4si a, __v4si b) { return __builtin_ia32_punpckhdq128(a, b); } int main(void) { __v4si a = { 0, 1, 2, 3 }; __v4si b = {100,101,102,103 }; __v4si r = test_punpckhdq128(a, b); for (int i = 0; i < 4; i++) printf("%d ", r[i]); printf("\n"); ASSERT(2, r[0]); ASSERT(102, r[1]); ASSERT(3, r[2]); ASSERT(103, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckhwd.c000066400000000000000000000011751505335450300202030ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi a = {100, 200, 300, 400}; v4hi b = {10, 20, 30, 40}; v4hi result = (v4hi)__builtin_ia32_punpckhwd(a, b); for (int i = 0; i < 8; i++) { printf("%d ", result[i]); } ASSERT(100, a[0]); ASSERT(200, a[1]); ASSERT(300, a[2]); ASSERT(400, a[3]); ASSERT(10, b[0]); ASSERT(20, b[1]); ASSERT(30, b[2]); ASSERT(40, b[3]); ASSERT(300, result[0]); ASSERT(30, result[1]); ASSERT(400, result[2]); ASSERT(40, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckhwd128.c000066400000000000000000000012231505335450300204300ustar00rootroot00000000000000#include "test.h" typedef short __v8hi __attribute__((vector_size(16))); __v8hi test_punpckhwd128(__v8hi a, __v8hi b) { return __builtin_ia32_punpckhwd128(a, b); } int main(void) { __v8hi a = { 0, 1, 2, 3, 4, 5, 6, 7 }; __v8hi b = {100,101,102,103,104,105,106,107 }; __v8hi r = test_punpckhwd128(a, b); for (int i = 0; i < 8; i++) printf("%d ", r[i]); printf("\n"); ASSERT(4, r[0]); ASSERT(104, r[1]); ASSERT(5, r[2]); ASSERT(105, r[3]); ASSERT(6, r[4]); ASSERT(106, r[5]); ASSERT(7, r[6]); ASSERT(107, r[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpcklbw.c000066400000000000000000000016571505335450300202120ustar00rootroot00000000000000#include "test.h" typedef char v8qi __attribute__((vector_size(8))); // 8 bytes vector int main() { v8qi a = {1,2,3,4,5,6,7,8}; v8qi b = {10,20,30,40,50,60,70,80}; v8qi result = __builtin_ia32_punpcklbw(a, b); for (int i = 0; i < 8; i++) { printf("%d ", (int)result[i]); } ASSERT(1, a[0]); ASSERT(2, a[1]); ASSERT(3, a[2]); ASSERT(4, a[3]); ASSERT(5, a[4]); ASSERT(6, a[5]); ASSERT(7, a[6]); ASSERT(8, a[7]); ASSERT(10, b[0]); ASSERT(20, b[1]); ASSERT(30, b[2]); ASSERT(40, b[3]); ASSERT(50, b[4]); ASSERT(60, b[5]); ASSERT(70, b[6]); ASSERT(80, b[7]); ASSERT(1, result[0]); ASSERT(10, result[1]); ASSERT(2, result[2]); ASSERT(20, result[3]); ASSERT(3, result[4]); ASSERT(30, result[5]); ASSERT(4, result[6]); ASSERT(40, result[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpcklbw128.c000066400000000000000000000017131505335450300204360ustar00rootroot00000000000000#include "test.h" #include typedef unsigned char v16u8 __attribute__((vector_size(16))); typedef char v16i8 __attribute__((vector_size(16))); int main() { v16i8 a = {1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16}; v16i8 b = {100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115}; v16u8 result = (v16u8)__builtin_ia32_punpcklbw128(a, b); unsigned char *p = (unsigned char *)&result; for (int i = 0; i < 16; i++) printf("%d ", p[i]); printf("\n"); ASSERT(1, p[0]); ASSERT(100, p[1]); ASSERT(2, p[2]); ASSERT(101, p[3]); ASSERT(3, p[4]); ASSERT(102, p[5]); ASSERT(4, p[6]); ASSERT(103, p[7]); ASSERT(5, p[8]); ASSERT(104, p[9]); ASSERT(6, p[10]); ASSERT(105, p[11]); ASSERT(7, p[12]); ASSERT(106, p[13]); ASSERT(8, p[14]); ASSERT(107, p[15]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckldq.c000066400000000000000000000007661505335450300202060ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); // 2 ints, 64-bit vector (MMX) int main() { v2si a = {1000, 2000}; v2si b = {10, 20}; v2si result = __builtin_ia32_punpckldq(a, b); for (int i = 0; i < 2; i++) { printf("%d ", result[i]); } ASSERT(1000, a[0]); ASSERT(2000, a[1]); ASSERT(10, b[0]); ASSERT(20, b[1]); ASSERT(1000, result[0]); ASSERT(10, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpckldq128.c000066400000000000000000000012051505335450300204260ustar00rootroot00000000000000#include "test.h" typedef int __m128i __attribute__((vector_size(16))); int main() { __m128i a = {40, 30, 20, 10}; // [40, 30, 20, 10] __m128i b = {400, 300, 200, 100}; // [400, 300, 200, 100] __m128i r = __builtin_ia32_punpckldq128(a, b); // Expected: Interleave low 2 dwords from a and b: // a low part: 20, 10 // b low part: 200, 100 // => 20, 200, 10, 100 (in reverse order for little-endian print) printf("%d %d %d %d\n", r[0], r[1], r[2], r[3]); ASSERT(40, r[0]); ASSERT(400, r[1]); ASSERT(30, r[2]); ASSERT(300, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpcklqdq128.c000066400000000000000000000007441505335450300206160ustar00rootroot00000000000000#include "test.h" typedef long long __m128i __attribute__((vector_size(16))); int main() { __m128i a = {4, 1}; // { low=1, high=4 } __m128i b = {8, 2}; // { low=2, high=8 } __m128i r = __builtin_ia32_punpcklqdq128(a, b); unsigned long long *vals = (unsigned long long *)&r; printf("%llu %llu\n", vals[0], vals[1]); // Expected: low64(a)=1, low64(b)=2 => {1, 2} ASSERT(4, r[0]); ASSERT(8, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpcklwd.c000066400000000000000000000012241505335450300202020ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); // 4 shorts, 64-bit vector int main() { v4hi a = {100, 200, 300, 400}; v4hi b = {10, 20, 30, 40}; v4hi result = __builtin_ia32_punpcklwd(a, b); for (int i = 0; i < 4; i++) { printf("%d ", result[i]); } ASSERT(100, a[0]); ASSERT(200, a[1]); ASSERT(300, a[2]); ASSERT(400, a[3]); ASSERT(10, b[0]); ASSERT(20, b[1]); ASSERT(30, b[2]); ASSERT(40, b[3]); ASSERT(100, result[0]); ASSERT(10, result[1]); ASSERT(200, result[2]); ASSERT(20, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_punpcklwd128.c000066400000000000000000000012171505335450300204370ustar00rootroot00000000000000#include "test.h" typedef short __v8hi __attribute__((vector_size(16))); int main() { __v8hi a = {16, 15, 14, 13, 12, 11, 10, 9}; __v8hi b = {26, 25, 24, 23, 22, 21, 20, 19}; __v8hi res = (__v8hi)__builtin_ia32_punpcklwd128( (__v8hi)a, (__v8hi)b ); short *vals = (short *)&res; for (int i = 0; i < 8; i++) printf("%d ", vals[i]); printf("\n"); ASSERT(16, vals[0]); ASSERT(26, vals[1]); ASSERT(15, vals[2]); ASSERT(25, vals[3]); ASSERT(14, vals[4]); ASSERT(24, vals[5]); ASSERT(13, vals[6]); ASSERT(23, vals[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_pxor.c000066400000000000000000000016571505335450300171750ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); typedef v2si __m64; int main() { __m64 a = {0xFF00FF00, 0x00FF00FF}; __m64 b = {0x0F0F0F0F, 0xF0F0F0F0}; __m64 result = __builtin_ia32_pxor(a, b); printf("a[0] = 0x%x\n", a[0]); printf("a[1] = 0x%x\n", a[1]); printf("b[0] = 0x%x\n", b[0]); printf("b[1] = 0x%x\n", b[1]); printf("result[0] = 0x%x\n", result[0]); printf("result[1] = 0x%x\n", result[1]); // Expected: bitwise XOR if (result[0] == (a[0] ^ b[0]) && result[1] == (a[1] ^ b[1])) { printf("Test passed.\n"); } else { printf("Test failed.\n"); return 1; } ASSERT(0xff00ff00, a[0]); ASSERT(0xff00ff, a[1]); ASSERT(0xf0f0f0f, b[0]); ASSERT(0xf0f0f0f0, b[1]); ASSERT(0xf00ff00f, result[0]); ASSERT(0xf00ff00f, result[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_rcpps.c000066400000000000000000000006071505335450300173260ustar00rootroot00000000000000#include "test.h" typedef float __m128 __attribute__((vector_size(16))); int main(void) { __m128 a = { 1.0f, 2.0f, 4.0f, 8.0f }; __m128 out = __builtin_ia32_rcpps(a); printf("rcp: %f %f %f %f\n", out[0], out[1], out[2], out[3]); ASSERT(0, out[0]); ASSERT(0, out[1]); ASSERT(0, out[2]); ASSERT(0, out[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_rcpss.c000066400000000000000000000007751505335450300173370ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); v4sf __builtin_ia32_rcpss(v4sf a); int main() { v4sf a = {4.0f, 0, 0, 0}; v4sf r = __builtin_ia32_rcpss(a); float approx_reciprocal = ((float*)&r)[0]; // The reciprocal of 4.0f is 0.25, approximate result will be close. printf("approx reciprocal: %f\n", approx_reciprocal); ASSERT(0, r[0]); ASSERT(0, r[1]); ASSERT(0, r[2]); ASSERT(0, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_return_address.c000066400000000000000000000006301505335450300212170ustar00rootroot00000000000000#include "test.h" #include void *get_return_address() { return __builtin_return_address(0); } void *dummy_function() { return __builtin_return_address(0); } int main() { printf("Return address: %p\n", get_return_address()); printf("Return function : %p\n", dummy_function()); ASSERT(1, get_return_address() != NULL); ASSERT(1, dummy_function() != NULL); return 0; } chibicc-1.0.23.1/test/builtin_rsqrtps.c000066400000000000000000000007671505335450300177240ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {4.0f, 9.0f, 16.0f, 25.0f}; // Compute approximate reciprocal square root of each element v4sf r = __builtin_ia32_rsqrtps(a); printf("Reciprocal square roots:\n"); for (int i = 0; i < 4; i++) { printf("r[%d] = %f\n", i, r[i]); } ASSERT(0, r[0]); ASSERT(0, r[1]); ASSERT(0, r[2]); ASSERT(0, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_rsqrtss.c000066400000000000000000000010551505335450300177160ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); extern v4sf __builtin_ia32_rsqrtss(v4sf); int main(void) { v4sf a = { 4.0f, 9.0f, 16.0f, 25.0f }; v4sf result = __builtin_ia32_rsqrtss(a); printf("Input: %.6f %.6f %.6f %.6f\n", a[0], a[1], a[2], a[3]); printf("Output: %.6f %.6f %.6f %.6f\n", result[0], result[1], result[2], result[3]); ASSERT(0, result[0]); ASSERT(9, result[1]); ASSERT(16, result[2]); ASSERT(25, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_shuffle.c000066400000000000000000000010151505335450300176250ustar00rootroot00000000000000#include "test.h" typedef float __m128 __attribute__((vector_size(16))); typedef int __v2si __attribute__((vector_size(16))); int main(void) { __m128 a = {1.0f, 2.0f, 3.0f, 4.0f}; __m128 b = {5.0f, 6.0f, 7.0f, 8.0f}; __v2si mask = {0,4,2,7}; __m128 r = __builtin_shuffle(a, b, mask); float *f = (float*)&r; printf("%f %f %f %f\n", f[0], f[1], f[2], f[3]); ASSERT(1, f[0]); ASSERT(5, f[1]); ASSERT(3, f[2]); ASSERT(8, f[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_shuffle2.c000066400000000000000000000024351505335450300177160ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); typedef int __v4si __attribute__((vector_size(16))); #define TEST_SHUFFLE(a, b, mask) do { \ float4 res = __builtin_shuffle(a, b, mask); \ printf("mask = {%d,%d,%d,%d} => ", mask[0], mask[1], mask[2], mask[3]); \ printf("{%.1f, %.1f, %.1f, %.1f}\n", res[0], res[1], res[2], res[3]); \ } while (0) int main(void) { float4 a = {1.0, 2.0, 3.0, 4.0}; float4 b = {5.0, 6.0, 7.0, 8.0}; // Masks: 0–3 pull from 'a', 4–7 pull from 'b' __v4si mask1 = {0, 1, 2, 3}; // identity from a __v4si mask2 = {4, 5, 6, 7}; // identity from b __v4si mask3 = {0, 4, 1, 5}; // interleave a,b __v4si mask4 = {2, 7, 0, 5}; // mixed arbitrary __v4si mask5 = {7, 6, 5, 4}; // reverse b __v4si mask6 = {3, 2, 1, 0}; // reverse a __v4si mask7 = {0, 7, 4, 3}; // cross edges __v4si mask8 = {1, 4, 6, 2}; // mixed mid __v4si mask9 = {0, 4, 2, 7}; // your example TEST_SHUFFLE(a, b, mask1); TEST_SHUFFLE(a, b, mask2); TEST_SHUFFLE(a, b, mask3); TEST_SHUFFLE(a, b, mask4); TEST_SHUFFLE(a, b, mask5); TEST_SHUFFLE(a, b, mask6); TEST_SHUFFLE(a, b, mask7); TEST_SHUFFLE(a, b, mask8); TEST_SHUFFLE(a, b, mask9); return 0; } chibicc-1.0.23.1/test/builtin_shufpd.c000066400000000000000000000010471505335450300174670ustar00rootroot00000000000000#include "test.h" #define _MM_SHUFFLE(z, y, x, w) \ (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) typedef double __m128 __attribute__((vector_size(16))); int main(void) { __m128 a = {1.0f, 2.0f}; __m128 b = {5.0f, 6.0f}; __m128 r = __builtin_ia32_shufpd(a, b, _MM_SHUFFLE(0,1,2,3)); float *f = (float*)&r; printf("%f %f\n", f[0], f[1]); ASSERT(0, f[0]); ASSERT(2, f[1]); r = __builtin_ia32_shufpd(a, b, 27); ASSERT(0, f[0]); ASSERT(2, f[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_shufps.c000066400000000000000000000012441505335450300175050ustar00rootroot00000000000000#include "test.h" #define _MM_SHUFFLE(z, y, x, w) \ (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) typedef float __m128 __attribute__((vector_size(16))); int main(void) { __m128 a = {1.0f, 2.0f, 3.0f, 4.0f}; __m128 b = {5.0f, 6.0f, 7.0f, 8.0f}; __m128 r = __builtin_ia32_shufps(a, b, _MM_SHUFFLE(0,1,2,3)); float *f = (float*)&r; printf("%f %f %f %f\n", f[0], f[1], f[2], f[3]); ASSERT(4, f[0]); ASSERT(3, f[1]); ASSERT(6, f[2]); ASSERT(5, f[3]); r = __builtin_ia32_shufps(a, b, 27); ASSERT(4, f[0]); ASSERT(3, f[1]); ASSERT(6, f[2]); ASSERT(5, f[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_sqrtpd.c000066400000000000000000000005011505335450300175050ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); int main() { double2 a = {4.0, 9.0}; double2 b = __builtin_ia32_sqrtpd(a); printf("sqrtpd: %.1f %.1f\n", b[0], b[1]); // Expected: 2.0 3.0 ASSERT(2, b[0]); ASSERT(3, b[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_sqrtps.c000066400000000000000000000006601505335450300175320ustar00rootroot00000000000000#include "test.h" typedef float __m128 __attribute__((vector_size(16))); int main(void) { __m128 vec = {4.0f, 9.0f, 16.0f, 25.0f}; __m128 result = __builtin_ia32_sqrtps(vec); printf("sqrt results: %f %f %f %f\n", result[0], result[1], result[2], result[3]); ASSERT(2, result[0]); ASSERT(3, result[1]); ASSERT(4, result[2]); ASSERT(5, result[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_sqrtsd.c000066400000000000000000000005011505335450300175100ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); int main() { double2 a = {4.0, 9.0}; double2 b = __builtin_ia32_sqrtsd(a); printf("sqrtsd: %.1f %.1f\n", b[0], b[1]); // Expected: 2.0 3.0 ASSERT(2, b[0]); ASSERT(9, b[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_sqrtss.c000066400000000000000000000010761505335450300175370ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf va = {16.0f, 3.3f, 4.4f, 5.5f}; v4sf vc = __builtin_ia32_sqrtss(va); float result = ((float*)&vc)[0]; printf("result = %f\n", result); // Expected: sqrt(16.0) = 4.0 // Check lowest element is correct (scalar sqrt) ASSERT(4, result); // The other elements should be copied from the input vector (va) ASSERT(4, vc[0]); ASSERT(3, vc[1]); ASSERT(4, vc[2]); ASSERT(5, vc[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_stmxcsr.c000066400000000000000000000006201505335450300176750ustar00rootroot00000000000000#include #include "test.h" int main() { uint32_t mxcsr = 0; __builtin_ia32_stmxcsr(&mxcsr); printf("MXCSR = 0x%x\n", mxcsr); ASSERT(0x1f80, mxcsr); // Optionally: test known bit (e.g., flush-to-zero) if (mxcsr & (1 << 15)) printf("Flush-to-zero is enabled\n"); else printf("Flush-to-zero is disabled\n"); return 0; } chibicc-1.0.23.1/test/builtin_stmxcsr2.c000066400000000000000000000003161505335450300177610ustar00rootroot00000000000000#include "test.h" #include int main() { unsigned int mxcsr = __builtin_ia32_stmxcsr(); printf("MXCSR register value: 0x%x\n", mxcsr); ASSERT(0x1f80, mxcsr); return 0; } chibicc-1.0.23.1/test/builtin_storehps.c000066400000000000000000000015451505335450300200500ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); typedef float v2sf __attribute__((vector_size(8))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v2sf p = {5.0f, 6.0f}; __builtin_ia32_storehps(&p, a); printf("Result vector:\n"); for (int i = 0; i < 2; i++) { printf("c[%d] = %f\n", i, ((float*)&p)[i]); } // Expected: // c[0] = 3.0 // c[1] = 4.0 ASSERT(3, p[0]); ASSERT(4, p[1]); v4sf c = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf d = {5.0f, 6.0f, 7.0f, 8.0f}; __builtin_ia32_storehps(&d, c); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&d)[i]); } ASSERT(3, d[0]); ASSERT(4, d[1]); ASSERT(7, d[2]); ASSERT(8, d[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_storelps.c000066400000000000000000000015451505335450300200540ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); typedef float v2sf __attribute__((vector_size(8))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v2sf p = {5.0f, 6.0f}; __builtin_ia32_storelps(&p, a); printf("Result vector:\n"); for (int i = 0; i < 2; i++) { printf("c[%d] = %f\n", i, ((float*)&p)[i]); } // Expected: // c[0] = 3.0 // c[1] = 4.0 ASSERT(1, p[0]); ASSERT(2, p[1]); v4sf c = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf d = {5.0f, 6.0f, 7.0f, 8.0f}; __builtin_ia32_storelps(&d, c); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&d)[i]); } ASSERT(1, d[0]); ASSERT(2, d[1]); ASSERT(7, d[2]); ASSERT(8, d[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_sub_overflow.c000066400000000000000000000006771505335450300207220ustar00rootroot00000000000000 #include "test.h" int main() { int result; if (__builtin_sub_overflow(-1, 1, &result)) { printf("Overflow detected!\n"); } else { printf("Overflow not detected!\n"); } ASSERT(0, __builtin_sub_overflow(-1, 1, &result)); if (__builtin_sub_overflow(-2147483648, 1, &result)) { printf("Overflow detected!\n"); } ASSERT(1, __builtin_sub_overflow(-2147483648, 1, &result)); return 0; } chibicc-1.0.23.1/test/builtin_subsd.c000066400000000000000000000005321505335450300173140ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); int main() { double2 a = {5.0, 7.0}; double2 b = {2.0, 4.0}; double2 c = __builtin_ia32_subsd(a, b); printf("%.1f %.1f\n", c[0], c[1]); // Expected: 3.0 7.0 ASSERT(3, c[0]); ASSERT(7, c[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_subss.c000066400000000000000000000006561505335450300173420ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); v4sf subss_test(v4sf a, v4sf b) { return __builtin_ia32_subss(a, b); } int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {0.5f, 1.5f, 2.5f, 3.5f}; v4sf c = subss_test(a, b); (int)c[0]; ASSERT(0, c[0]); ASSERT(2, c[1]); ASSERT(3, c[2]); ASSERT(4, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_ucomieq.c000066400000000000000000000005541505335450300176420ustar00rootroot00000000000000 #include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 5.0f, 3.0f, 0.0f}; int res = __builtin_ia32_ucomieq(a, b); printf("ucomieq result: %d\n", res); // Should print 1 if lowest floats are equal ASSERT(1, res); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_ucomisdeq.c000066400000000000000000000006221505335450300201650ustar00rootroot00000000000000 #include "test.h" typedef double __v2df __attribute__((vector_size(16))); int main(void) { __v2df a = { 3.14, 2.71 }; __v2df b = { 3.14, 5.0 }; // Compare the low double elements of a and b (unordered compare equal) int res = __builtin_ia32_ucomisdeq(a, b); printf("Result = %d\n", res); // Expected 1 because 3.14 == 3.14 ASSERT(1, res); return 0; } chibicc-1.0.23.1/test/builtin_ucomisdge.c000066400000000000000000000006221505335450300201530ustar00rootroot00000000000000 #include "test.h" typedef double __v2df __attribute__((vector_size(16))); int main(void) { __v2df a = { 3.14, 2.71 }; __v2df b = { 3.14, 5.0 }; // Compare the low double elements of a and b (unordered compare equal) int res = __builtin_ia32_ucomisdge(a, b); printf("Result = %d\n", res); // Expected 1 because 3.14 == 3.14 ASSERT(1, res); return 0; } chibicc-1.0.23.1/test/builtin_ucomisdgt.c000066400000000000000000000006221505335450300201720ustar00rootroot00000000000000 #include "test.h" typedef double __v2df __attribute__((vector_size(16))); int main(void) { __v2df a = { 3.14, 2.71 }; __v2df b = { 3.14, 5.0 }; // Compare the low double elements of a and b (unordered compare equal) int res = __builtin_ia32_ucomisdgt(a, b); printf("Result = %d\n", res); // Expected 1 because 3.14 == 3.14 ASSERT(0, res); return 0; } chibicc-1.0.23.1/test/builtin_ucomisdle.c000066400000000000000000000006221505335450300201600ustar00rootroot00000000000000 #include "test.h" typedef double __v2df __attribute__((vector_size(16))); int main(void) { __v2df a = { 3.14, 2.71 }; __v2df b = { 3.14, 5.0 }; // Compare the low double elements of a and b (unordered compare equal) int res = __builtin_ia32_ucomisdle(a, b); printf("Result = %d\n", res); // Expected 1 because 3.14 == 3.14 ASSERT(1, res); return 0; } chibicc-1.0.23.1/test/builtin_ucomisdlt.c000066400000000000000000000006221505335450300201770ustar00rootroot00000000000000 #include "test.h" typedef double __v2df __attribute__((vector_size(16))); int main(void) { __v2df a = { 3.14, 2.71 }; __v2df b = { 3.14, 5.0 }; // Compare the low double elements of a and b (unordered compare equal) int res = __builtin_ia32_ucomisdlt(a, b); printf("Result = %d\n", res); // Expected 1 because 3.14 == 3.14 ASSERT(0, res); return 0; } chibicc-1.0.23.1/test/builtin_ucomisdneq.c000066400000000000000000000006231505335450300203440ustar00rootroot00000000000000 #include "test.h" typedef double __v2df __attribute__((vector_size(16))); int main(void) { __v2df a = { 3.14, 2.71 }; __v2df b = { 3.14, 5.0 }; // Compare the low double elements of a and b (unordered compare equal) int res = __builtin_ia32_ucomisdneq(a, b); printf("Result = %d\n", res); // Expected 1 because 3.14 == 3.14 ASSERT(0, res); return 0; } chibicc-1.0.23.1/test/builtin_ucomixx.c000066400000000000000000000040231505335450300176670ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {1.0f, 5.0f, 3.5f, 4.0f}; v4sf c = {0.0f/0.0f, 5.0f, 3.5f, 4.0f}; // NaN in lowest element int res; // __builtin_ia32_ucomieq: unordered compare equal res = __builtin_ia32_ucomieq(a, b); printf("ucomieq (a,b): %d\n", res); ASSERT(1, res); // a[0]==b[0] => true res = __builtin_ia32_ucomieq(a, c); printf("ucomieq (a,c): %d\n", res); ASSERT(0, res); // unordered because c[0] is NaN // __builtin_ia32_ucomigt: unordered compare greater than res = __builtin_ia32_ucomigt(b, a); printf("ucomigt (b,a): %d\n", res); ASSERT(0, res); // b[0] > a[0] res = __builtin_ia32_ucomigt(a, c); printf("ucomigt (a,c): %d\n", res); ASSERT(0, res); // unordered => false // __builtin_ia32_ucomige: unordered compare greater or equal res = __builtin_ia32_ucomige(a, b); printf("ucomige (a,b): %d\n", res); ASSERT(1, res); // 1.0 >= 1.0 => true res = __builtin_ia32_ucomige(b, a); printf("ucomige (b,a): %d\n", res); ASSERT(1, res); // b[0] >= a[0] => false res = __builtin_ia32_ucomige(a, c); printf("ucomige (a,c): %d\n", res); ASSERT(0, res); // unordered => false // __builtin_ia32_ucomilt: unordered compare less than res = __builtin_ia32_ucomilt(a, b); printf("ucomilt (a,b): %d\n", res); ASSERT(0, res); // 1.0 < 1.0 false, 2.0 < 5.0 true but only lowest float counts res = __builtin_ia32_ucomilt(a, c); printf("ucomilt (a,c): %d\n", res); ASSERT(0, res); // unordered => false // __builtin_ia32_ucomile: unordered compare less or equal res = __builtin_ia32_ucomile(a, b); printf("ucomile (a,b): %d\n", res); ASSERT(1, res); // 1.0 <= 1.0 => true res = __builtin_ia32_ucomile(a, c); printf("ucomile (a,c): %d\n", res); ASSERT(0, res); // unordered => false printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_unpckhpd.c000066400000000000000000000007411505335450300200120ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); // 2 doubles int main(void) { double2 a = {1.0, 2.0}; // xmm0: low=1.0, high=2.0 double2 b = {3.0, 4.0}; // xmm1: low=3.0, high=4.0 double2 r = __builtin_ia32_unpckhpd(a, b); printf("r[0] = %.1f\n", r[0]); // from high of a (2.0) printf("r[1] = %.1f\n", r[1]); // from high of b (4.0) ASSERT(2, r[0]); ASSERT(4, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_unpckhps.c000066400000000000000000000011551505335450300200310ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {5.0f, 6.0f, 7.0f, 8.0f}; v4sf c = __builtin_ia32_unpckhps(a, b); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&c)[i]); } // Expected output: // c[0] = 3.0 (a2) // c[1] = 7.0 (b2) // c[2] = 4.0 (a3) // c[3] = 8.0 (b3) ASSERT(3, c[0]); ASSERT(7, c[1]); ASSERT(4, c[2]); ASSERT(8, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_unpcklpd.c000066400000000000000000000007371505335450300200230ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); // 2 doubles int main(void) { double2 a = {1.0, 2.0}; // xmm0: low=1.0, high=2.0 double2 b = {3.0, 4.0}; // xmm1: low=3.0, high=4.0 double2 r = __builtin_ia32_unpcklpd(a, b); printf("r[0] = %.1f\n", r[0]); // from low of a (1.0) printf("r[1] = %.1f\n", r[1]); // from low of b (3.0) ASSERT(1, r[0]); ASSERT(3, r[1]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_unpcklps.c000066400000000000000000000011551505335450300200350ustar00rootroot00000000000000#include "test.h" #include typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {1.0f, 2.0f, 3.0f, 4.0f}; v4sf b = {5.0f, 6.0f, 7.0f, 8.0f}; v4sf c = __builtin_ia32_unpcklps(a, b); printf("Result vector:\n"); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, ((float*)&c)[i]); } // Expected output: // c[0] = 3.0 (a2) // c[1] = 7.0 (b2) // c[2] = 4.0 (a3) // c[3] = 8.0 (b3) ASSERT(1, c[0]); ASSERT(5, c[1]); ASSERT(2, c[2]); ASSERT(6, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_unreacheable.c000066400000000000000000000003001505335450300206030ustar00rootroot00000000000000 #include "test.h" int main() { int x = 0; if (x == 0) { printf("x is zero\n"); ASSERT(0, x); } else { __builtin_unreachable(); } return 0; } chibicc-1.0.23.1/test/builtin_vec_ext_v2si.c000066400000000000000000000012071505335450300205740ustar00rootroot00000000000000#include "test.h" // Define a 2-element int vector type (like __v2si) typedef int v2si __attribute__((vector_size(8))); // Prototype for the builtin so the compiler accepts it int __builtin_ia32_vec_ext_v2si(v2si vec, int index); int main(void) { // Create a vector with two ints: 123456 and 789012 v2si v = {123456, 789012}; // Extract elements using the builtin int elem0 = __builtin_ia32_vec_ext_v2si(v, 0); int elem1 = __builtin_ia32_vec_ext_v2si(v, 1); printf("elem0 = %d\n", elem0); printf("elem1 = %d\n", elem1); ASSERT(123456, elem0); ASSERT(789012, elem1); return 0; } chibicc-1.0.23.1/test/builtin_vec_ext_v4si.c000066400000000000000000000006361505335450300206030ustar00rootroot00000000000000#include "test.h" typedef int int4 __attribute__((vector_size(16))); int main(void) { int4 v = {10, 20, 30, 40}; int a0 = __builtin_ia32_vec_ext_v4si(v, 0); int a1 = __builtin_ia32_vec_ext_v4si(v, 1); int a2 = __builtin_ia32_vec_ext_v4si(v, 2); int a3 = __builtin_ia32_vec_ext_v4si(v, 3); printf("%d %d %d %d\n", a0, a1, a2, a3); // Expected: 10 20 30 40 return 0; } chibicc-1.0.23.1/test/builtin_vec_init_v2si.c000066400000000000000000000006301505335450300207360ustar00rootroot00000000000000#include "test.h" typedef int v2si __attribute__((vector_size(8))); // 2 × 4 bytes = 8 bytes // Prototype for the builtin so the compiler doesn't warn v2si __builtin_ia32_vec_init_v2si(int, int); int main(void) { v2si v = __builtin_ia32_vec_init_v2si(123456, 0); int *p = (int *)&v; printf("%d %d\n", p[0], p[1]); ASSERT(123456, p[0]); ASSERT(0, p[1]); return 0; } chibicc-1.0.23.1/test/builtin_vec_init_v4hi.c000066400000000000000000000004621505335450300207300ustar00rootroot00000000000000#include "test.h" typedef short v4hi __attribute__((vector_size(8))); int main() { v4hi v = __builtin_ia32_vec_init_v4hi(1, 2, 3, 4); for (int i = 0; i < 4; i++) { printf("%d ", v[i]); ASSERT(i+1, v[i]); } printf("\n"); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_vec_init_v8qi.c000066400000000000000000000021651505335450300207470ustar00rootroot00000000000000#include "test.h" #include typedef char v8qi __attribute__((vector_size(8))); int main() { // Test with immediate values v8qi v = (v8qi)__builtin_ia32_vec_init_v8qi( 1, 2, 3, 4, -1, -2, -3, -4 ); printf("Immediate init:\n"); for (int i = 0; i < 8; i++) { printf("%d ", v[i]); } printf("\n"); ASSERT(1, v[0]); ASSERT(2, v[1]); ASSERT(3, v[2]); ASSERT(4, v[3]); ASSERT(-1, v[4]); ASSERT(-2, v[5]); ASSERT(-3, v[6]); ASSERT(-4, v[7]); // Test with variables char a0 = 10, a1 = 20, a2 = 30, a3 = 40; char a4 = -10, a5 = -20, a6 = -30, a7 = -40; v8qi v2 = (v8qi)__builtin_ia32_vec_init_v8qi( a0, a1, a2, a3, a4, a5, a6, a7 ); printf("Variable init:\n"); for (int i = 0; i < 8; i++) { printf("%d ", v2[i]); } printf("\n"); ASSERT(10, v2[0]); ASSERT(20, v2[1]); ASSERT(30, v2[2]); ASSERT(40, v2[3]); ASSERT(-10, v2[4]); ASSERT(-20, v2[5]); ASSERT(-30, v2[6]); ASSERT(-40, v2[7]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/builtin_xorps.c000066400000000000000000000010301505335450300173410ustar00rootroot00000000000000#include "test.h" typedef float v4sf __attribute__((vector_size(16))); int main() { v4sf a = {0x00000000, 0x0F0F0F0F, 0xAAAAAAAA, 0x55555555}; v4sf b = {0xFFFFFFFF, 0xF0F0F0F0, 0x55555555, 0xAAAAAAAA}; v4sf c = __builtin_ia32_orps(a, b); for (int i = 0; i < 4; i++) { printf("c[%d] = 0x%08X\n", i, *(unsigned int*)&c[i]); } ASSERT(-2147483648, c[0]); ASSERT(-2147483648, c[1]); ASSERT(-2147483648, c[2]); ASSERT(-2147483648, c[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/c99.c000066400000000000000000000057631505335450300150650ustar00rootroot00000000000000 #include #include #include #include #include #include "test.h" // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); ASSERT(1234, x); ASSERT(5678, y); printf("\n"); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } chibicc-1.0.23.1/test/cache.h000066400000000000000000000066271505335450300155310ustar00rootroot00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #ifndef CACHE_H #define CACHE_H #include #include "queue.h" #ifndef NDEBUG /* may be used for debug purposes */ extern int cache_error; #endif struct cache_free_s { STAILQ_ENTRY(cache_free_s) c_next; }; //typedef STAILQ_HEAD(cache_head_s, cache_free_s) cache_head_t; /** * Definition of the structure to keep track of the internal details of * the cache allocator. Touching any of these variables results in * undefined behavior. */ typedef struct { /** Mutex to protect access to the structure */ pthread_mutex_t mutex; /** Name of the cache objects in this cache (provided by the caller) */ char *name; /** freelist of available buffers */ STAILQ_HEAD(cache_head, cache_free_s) head; /** The size of each element in this cache */ size_t bufsize; /** The capacity of the list of elements */ int freetotal; /** Total malloc'ed objects */ int total; /** The current number of free elements */ int freecurr; /** A limit on the total number of elements */ int limit; } cache_t; /** * Create an object cache. * * The object cache will let you allocate objects of the same size. It is fully * MT safe, so you may allocate objects from multiple threads without having to * do any synchronization in the application code. * * @param name the name of the object cache. This name may be used for debug purposes * and may help you track down what kind of object you have problems with * (buffer overruns, leakage etc) * @param bufsize the size of each object in the cache * @param align the alignment requirements of the objects in the cache. * @param constructor the function to be called to initialize memory when we need * to allocate more memory from the os. * @param destructor the function to be called before we release the memory back * to the os. * @return a handle to an object cache if successful, NULL otherwise. */ cache_t* cache_create(const char* name, size_t bufsize, size_t align); /** * Destroy an object cache. * * Destroy and invalidate an object cache. You should return all buffers allocated * with cache_alloc by using cache_free before calling this function. Not doing * so results in undefined behavior (the buffers may or may not be invalidated) * * @param handle the handle to the object cache to destroy. */ void cache_destroy(cache_t* handle); /** * Allocate an object from the cache. * * @param handle the handle to the object cache to allocate from * @return a pointer to an initialized object from the cache, or NULL if * the allocation cannot be satisfied. */ void* cache_alloc(cache_t* handle); void* do_cache_alloc(cache_t* handle); /** * Return an object back to the cache. * * The caller should return the object in an initialized state so that * the object may be returned in an expected state from cache_alloc. * * @param handle handle to the object cache to return the object to * @param ptr pointer to the object to return. */ void cache_free(cache_t* handle, void* ptr); void do_cache_free(cache_t* handle, void* ptr); /** * Set or adjust a limit for the number of objects to malloc * * @param handle handle to the object cache to adjust * @param limit the number of objects to cache before returning NULL */ void cache_set_limit(cache_t* handle, int limit); #endif chibicc-1.0.23.1/test/cast.c000077500000000000000000000032021505335450300154000ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(131585, (int)8590066177); ASSERT(513, (short)8590066177); ASSERT(1, (char)8590066177); ASSERT(1, (long)1); ASSERT(0, (long)&*(int *)0); ASSERT(513, ({ int x=512; *(char *)&x=1; x; })); ASSERT(5, ({ int x=5; long y=(long)&x; *(int*)y; })); (void)1; ASSERT(-1, (char)255); ASSERT(-1, (signed char)255); ASSERT(255, (unsigned char)255); ASSERT(-1, (short)65535); ASSERT(65535, (unsigned short)65535); ASSERT(-1, (int)0xffffffff); ASSERT(0xffffffff, (unsigned)0xffffffff); ASSERT(1, -1<1); ASSERT(0, -1<(unsigned)1); ASSERT(254, (char)127+(char)127); ASSERT(65534, (short)32767+(short)32767); ASSERT(-1, -1>>1); ASSERT(-1, (unsigned long)-1); ASSERT(2147483647, ((unsigned)-1)>>1); ASSERT(-50, (-100)/2); ASSERT(2147483598, ((unsigned)-100)/2); ASSERT(9223372036854775758, ((unsigned long)-100)/2); ASSERT(0, ((long)-1)/(unsigned)100); ASSERT(-2, (-100)%7); ASSERT(2, ((unsigned)-100)%7); ASSERT(6, ((unsigned long)-100)%9); ASSERT(65535, (int)(unsigned short)65535); ASSERT(65535, ({ unsigned short x = 65535; x; })); ASSERT(65535, ({ unsigned short x = 65535; (int)x; })); ASSERT(-1, ({ typedef short T; T x = 65535; (int)x; })); ASSERT(65535, ({ typedef unsigned short T; T x = 65535; (int)x; })); ASSERT(0, (_Bool)0.0); ASSERT(1, (_Bool)0.1); ASSERT(3, (char)3.0); ASSERT(1000, (short)1000.3); ASSERT(3, (int)3.99); ASSERT(2000000000000000, (long)2e15); ASSERT(3, (float)3.5); ASSERT(5, (double)(float)5.5); ASSERT(3, (float)3); ASSERT(3, (double)3); ASSERT(3, (float)3L); ASSERT(3, (double)3L); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/common000077500000000000000000000140211505335450300155160ustar00rootroot00000000000000#include #include #include void assert(int expected, int actual, char *code) { if (expected == actual) { printf("%s => %d\n", code, actual); } else { printf("%s => %d expected but got %d\n", code, expected, actual); exit(1); } } void assert64(long long expected, long long actual, char *code) { if (expected == actual) { printf("%s => %lld\n", code, actual); } else { printf("%s => %lld expected but got %lld\n", code, expected, actual); exit(1); } } typedef unsigned long long uint64_t; void print_i128(__int128 v) { unsigned __int128 uv = v; // for bit shifts uint64_t lo = (uint64_t)uv; uint64_t hi = (uint64_t)(uv >> 64); printf("(%lld, %llu)", (long long)hi, (unsigned long long)lo); } void assert128(__int128 k, __int128 x, char *code, char *func, int line) { if (k != x) { printf("%s:%d: %s => want ", func, line, code); print_i128(k); printf(" but got "); print_i128(x); printf("\n"); exit(1); } } static int static_fn() { return 5; } int ext1 = 5; int *ext2 = &ext1; int ext3 = 7; int ext_fn1(int x) { return x; } int ext_fn2(int x) { return x; } int common_ext2 = 3; static int common_local; _Thread_local int extern_tls; int false_fn() { return 512; } int true_fn() { return 513; } int char_fn() { return (2<<8)+3; } int short_fn() { return (2<<16)+5; } int uchar_fn() { return (2<<10)-1-4; } int ushort_fn() { return (2<<20)-1-7; } int schar_fn() { return (2<<10)-1-4; } int sshort_fn() { return (2<<20)-1-7; } int add_all(int n, ...) { va_list ap; va_start(ap, n); int sum = 0; for (int i = 0; i < n; i++) sum += va_arg(ap, int); return sum; } float add_float(float x, float y) { return x + y; } double add_double(double x, double y) { return x + y; } int add10_int(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10) { return x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10; } float add10_float(float x1, float x2, float x3, float x4, float x5, float x6, float x7, float x8, float x9, float x10) { return x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10; } double add10_double(double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9, double x10) { return x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10; } typedef struct { int a,b; short c; char d; } Ty4; typedef struct { int a; float b; double c; } Ty5; typedef struct { unsigned char a[3]; } Ty6; typedef struct { long a, b, c; } Ty7; int struct_test4(Ty4 x, int n) { switch (n) { case 0: return x.a; case 1: return x.b; case 2: return x.c; default: return x.d; } } int struct_test5(Ty5 x, int n) { switch (n) { case 0: return x.a; case 1: return x.b; default: return x.c; } } int struct_test6(Ty6 x, int n) { return x.a[n]; } int struct_test7(Ty7 x, int n) { switch (n) { case 0: return x.a; case 1: return x.b; default: return x.c; } } Ty4 struct_test24(void) { return (Ty4){10, 20, 30, 40}; } Ty5 struct_test25(void) { return (Ty5){10, 20, 30}; } Ty6 struct_test26(void) { return (Ty6){10, 20, 30}; } typedef struct { unsigned char a[10]; } Ty20; typedef struct { unsigned char a[20]; } Ty21; Ty20 struct_test27(void) { return (Ty20){10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; } Ty21 struct_test28(void) { return (Ty21){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; } typedef struct { char g; } G; typedef struct { float f; } F; typedef struct { char l; float d; } A; float struct_test101( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } float struct_test111( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } float struct_test121( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1) { return reg0.l + reg0.d + reg1.l + reg1.d + reg2.l + reg2.d + reg3.l + reg3.d + reg4.l + reg4.d + reg5.l + reg5.d + s0.l + s0.d + s1.l + s1.d + f6.f + f7.f; } typedef struct { char _Alignas(1024) c; } Aligned1024; int struct_test131(G g0,G g1,G g2,G g3,G g4,F f0,F f1,F f2,F f3,F f4,F f5, int i0, int i1, ... ) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, int); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, double); ret += va_arg(ap, Aligned1024).c; ret += va_arg(ap, long double); va_end(ap); return ret; } typedef struct { long i,j; } DI; int struct_test141(int cnt,...) { va_list ap; va_start(ap, cnt); long ret = 0; for (int i = 0; i < cnt; i++) { DI s = va_arg(ap, DI); ret += s.i + s.j; } va_end(ap); return ret; } typedef struct { double d,f; } DD; int struct_test151(int cnt,...) { va_list ap; va_start(ap, cnt); double ret = 0; for (int i = 0; i < cnt; i++) { DD s = va_arg(ap, DD); ret += s.d + s.f; } va_end(ap); return ret; } typedef struct { long i; double d; } DM; int struct_test161(int cnt,...) { va_list ap; va_start(ap, cnt); double ret = 0; for (int i = 0; i < cnt; i++) { DM s = va_arg(ap, DM); ret += s.d + s.i; } va_end(ap); return ret; } typedef struct { union { long double ld[1]; long double ld2; } u[1]; } struct170; struct170 struct_test171(struct170 t1,...) { va_list ap; va_start(ap, t1); struct170 t = t1; t.u[0].ld2 += va_arg(ap, struct170).u[0].ld[0]; va_end(ap); return t; } typedef union { long double ld; long i; } struct180; struct180 struct_test181(struct180 t1,...) { va_list ap; va_start(ap, t1); struct180 t = t1; t.ld += va_arg(ap, struct180).ld; va_end(ap); return t; }chibicc-1.0.23.1/test/commonsym.c000077500000000000000000000003651505335450300164760ustar00rootroot00000000000000#include "test.h" int x; int x = 5; int y = 7; int y; int common_ext1; int common_ext2; static int common_local; int main() { ASSERT(5, x); ASSERT(7, y); ASSERT(0, common_ext1); ASSERT(3, common_ext2); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/compare_exchange.c000066400000000000000000000034511505335450300177410ustar00rootroot00000000000000#include "test.h" #include #include int main() { int x = 42; int expected; int desired; bool result; printf("=== Testing __atomic_compare_exchange_n ===\n"); // Example 1: successful CAS x = 42; expected = 42; desired = 100; result = __atomic_compare_exchange_n(&x, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("CAS_N success? %d, x=%d, expected=%d\n", result, x, expected); ASSERT(42, expected); ASSERT(100, x); ASSERT(1, result); // Example 2: failed CAS x = 50; expected = 42; desired = 200; result = __atomic_compare_exchange_n(&x, &expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("CAS_N success? %d, x=%d, expected=%d\n", result, x, expected); printf("\n=== Testing __atomic_compare_exchange ===\n"); ASSERT(50, expected); ASSERT(50, x); ASSERT(0, result); // Using __atomic_compare_exchange (strong variant) x = 42; expected = 50; desired = 123; result = __atomic_compare_exchange(&x, &expected, &desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("CAS success? %d, x=%d, expected=%d\n", result, x, expected); ASSERT(42, expected); ASSERT(42, x); ASSERT(0, result); // Failed CAS x = 50; expected = 42; desired = 999; result = __atomic_compare_exchange(&x, &expected, &desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); printf("CAS success? %d, x=%d, expected=%d\n", result, x, expected); ASSERT(50, expected); ASSERT(50, x); ASSERT(0, result); return 0; } chibicc-1.0.23.1/test/compat.c000077500000000000000000000005711505335450300157370ustar00rootroot00000000000000#include "test.h" _Noreturn noreturn_fn(int restrict x) { exit(0); } void funcy_type(int arg[restrict static 3]) {} int main() { { volatile x; } { int volatile x; } { volatile int x; } { volatile int volatile volatile x; } { int volatile * volatile volatile x; } { auto ** restrict __restrict __restrict__ const volatile *x; } printf("OK\n"); return 0; } chibicc-1.0.23.1/test/complit.c000077500000000000000000000010341505335450300161160ustar00rootroot00000000000000#include "test.h" typedef struct Tree { int val; struct Tree *lhs; struct Tree *rhs; } Tree; Tree *tree = &(Tree){ 1, &(Tree){ 2, &(Tree){ 3, 0, 0 }, &(Tree){ 4, 0, 0 } }, 0 }; int main() { ASSERT(1, (int){1}); ASSERT(2, ((int[]){0,1,2})[2]); ASSERT('a', ((struct {char a; int b;}){'a', 3}).a); ASSERT(3, ({ int x=3; (int){x}; })); (int){3} = 5; ASSERT(1, tree->val); ASSERT(2, tree->lhs->val); ASSERT(3, tree->lhs->lhs->val); ASSERT(4, tree->lhs->rhs->val); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/complit2.c000066400000000000000000000014171505335450300162020ustar00rootroot00000000000000#include "test.h" static int arr[4] = {1,2,3,4}; int sum(int a, int b){ return a + b; } int* getarr(int idx) { return &arr[idx]; } struct s { int i,j,k; } s0 = {1,2,3}; int main() { ASSERT(1, ({ (int[2]){1,2}[0]; })); ASSERT(2, ({ (int[2]){1,2}[1]; })); ASSERT(1, ({ (int*){&arr}[0]; })); ASSERT(3, ({ (int*){&arr[1]}[1]; })); ASSERT(4, ({ (int(*)[2]){&arr}[1][1]; })); ASSERT(0, ({ (struct s){.j=2}.i; })); ASSERT(2, ({ (struct s){.j=2}.j; })); ASSERT(0, ({ (struct s){.j=2}.k; })); ASSERT(3, ({ (struct s*){&s0}->k; })); ASSERT(3, ({ int a=(int){3}++; a; })); ASSERT(1, ({ int *p=(int*){&arr[0]}++; *p; })); ASSERT(10, ({ (int(*)(int,int)){sum}(7,3); })); ASSERT(3, ({ (int*(*)(int)){&getarr}(1)[1]; })); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/config.h000066400000000000000000000132441505335450300157240ustar00rootroot00000000000000/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ /* Set to nonzero if you want to compile using ASAN */ /* #undef ASAN */ /* Set to nonzero if you want to disable unix domain socket */ /* #undef DISABLE_UNIX_SOCKET */ /* Set to nonzero if you want to include DTRACE */ /* #undef ENABLE_DTRACE */ /* Set to nonzero if you want to include SASL */ /* #undef ENABLE_SASL */ /* Set to nonzero if you want to enable a SASL pwdb */ /* #undef ENABLE_SASL_PWDB */ /* machine is bigendian */ /* #undef ENDIAN_BIG */ /* machine is littleendian */ #define ENDIAN_LITTLE 1 /* Set to nonzero if you want to enable extstore */ #define EXTSTORE 1 /* Define to 1 if support accept4 */ #define HAVE_ACCEPT4 1 /* Define to 1 if you have the `cap_enter' function. */ /* #undef HAVE_CAP_ENTER */ /* Define to 1 if you have the `clock_gettime' function. */ #define HAVE_CLOCK_GETTIME 1 /* Define this if you have an implementation of drop_privileges() */ /* #undef HAVE_DROP_PRIVILEGES */ /* Define this if you have an implementation of drop_worker_privileges() */ /* #undef HAVE_DROP_WORKER_PRIVILEGES */ /* Define to 1 if you have the `eventfd' function. */ #define HAVE_EVENTFD 1 /* GCC 64bit Atomics available */ #define HAVE_GCC_64ATOMICS 1 /* GCC Atomics available */ #define HAVE_GCC_ATOMICS 1 /* Define to 1 if support getopt_long */ #define HAVE_GETOPT_LONG 1 /* Define to 1 if you have the `getpagesizes' function. */ /* #undef HAVE_GETPAGESIZES */ /* Have ntohll */ #define HAVE_HTONLL 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* linked to libevent */ #define HAVE_LIBEVENT_NEW 1 /* Set to nonzero if you want to enable proxy uring handling */ /* #undef HAVE_LIBURING */ /* Define to 1 if you have the `memcntl' function. */ /* #undef HAVE_MEMCNTL */ /* Define to 1 if you have the `mlockall' function. */ #define HAVE_MLOCKALL 1 /* Define to 1 if you have the `pledge' function. */ /* #undef HAVE_PLEDGE */ /* Define to 1 if you have the `pread' function. */ #define HAVE_PREAD 1 /* Define to 1 if you have the `preadv' function. */ #define HAVE_PREADV 1 /* Define to 1 if you have the `sandbox_init' function. */ /* #undef HAVE_SANDBOX_INIT */ /* we have sasl_callback_ft */ /* #undef HAVE_SASL_CALLBACK_FT */ /* Set to nonzero if your SASL implementation supports SASL_CB_GETCONF */ /* #undef HAVE_SASL_CB_GETCONF */ /* Set to nonzero if your SASL implementation supports SASL_CB_GETCONFPATH */ /* #undef HAVE_SASL_CB_GETCONFPATH */ /* Define to 1 if you have the header file. */ /* #undef HAVE_SASL_SASL_H */ /* Define to 1 if you have the `setppriv' function. */ /* #undef HAVE_SETPPRIV */ /* Define to 1 if stdbool.h conforms to C99. */ #define HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDIO_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `sysconf' function. */ #define HAVE_SYSCONF 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_AUXV_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if the system has the type `_Bool'. */ #define HAVE__BOOL 1 /* Machine need alignment */ /* #undef NEED_ALIGN */ /* Name of package */ #define PACKAGE "memcached" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "memcached@googlegroups.com" /* Define to the full name of this package. */ #define PACKAGE_NAME "memcached" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "memcached 1.6.21" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "memcached" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "1.6.21" /* Set to nonzero if you want to enable proxy code */ /* #undef PROXY */ /* The size of `void *', as computed by sizeof. */ #define SIZEOF_VOID_P 8 /* Set to nonzero if you want to compile a statically linked binary */ /* #undef STATIC */ /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ #define STDC_HEADERS 1 /* Set to nonzero if you want to enable TLS */ /* #undef TLS */ /* Version number of package */ #define VERSION "1.6.21" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN /* # undef WORDS_BIGENDIAN */ # endif #endif /* make sure IOV_MAX is defined */ /* #undef _GNU_SOURCE */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* define to int if socklen_t not available */ /* #undef socklen_t */ #if HAVE_STDBOOL_H #include #else #define bool char #define false 0 #define true 1 #endif #ifdef HAVE_INTTYPES_H #include #endif chibicc-1.0.23.1/test/const.c000077500000000000000000000004441505335450300156010ustar00rootroot00000000000000#include "test.h" int main() { { const x; } { int const x; } { const int x; } { const int const const x; } ASSERT(5, ({ const x = 5; x; })); ASSERT(8, ({ const x = 8; int *const y=&x; *y; })); ASSERT(6, ({ const x = 6; *(const * const)&x; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/constexpr.c000077500000000000000000000044631505335450300165050ustar00rootroot00000000000000#include "test.h" float g40 = 1.5; double g41 = 0.0 ? 55 : (0, 1 + 1 * 5.0 / 2 * (double)2 * (int)2.0); int main() { ASSERT(10, ({ enum { ten=1+2+3+4 }; ten; })); ASSERT(1, ({ int i=0; switch(3) { case 5-2+0*3: i++; } i; })); ASSERT(8, ({ int x[1+1]; sizeof(x); })); ASSERT(6, ({ char x[8-2]; sizeof(x); })); ASSERT(6, ({ char x[2*3]; sizeof(x); })); ASSERT(3, ({ char x[12/4]; sizeof(x); })); ASSERT(2, ({ char x[12%10]; sizeof(x); })); ASSERT(0b100, ({ char x[0b110&0b101]; sizeof(x); })); ASSERT(0b111, ({ char x[0b110|0b101]; sizeof(x); })); ASSERT(0b110, ({ char x[0b111^0b001]; sizeof(x); })); ASSERT(4, ({ char x[1<<2]; sizeof(x); })); ASSERT(2, ({ char x[4>>1]; sizeof(x); })); ASSERT(2, ({ char x[(1==1)+1]; sizeof(x); })); ASSERT(1, ({ char x[(1!=1)+1]; sizeof(x); })); ASSERT(1, ({ char x[(1<1)+1]; sizeof(x); })); ASSERT(2, ({ char x[(1<=1)+1]; sizeof(x); })); ASSERT(2, ({ char x[1?2:3]; sizeof(x); })); ASSERT(3, ({ char x[0?2:3]; sizeof(x); })); ASSERT(3, ({ char x[(1,3)]; sizeof(x); })); ASSERT(2, ({ char x[!0+1]; sizeof(x); })); ASSERT(1, ({ char x[!1+1]; sizeof(x); })); ASSERT(2, ({ char x[~-3]; sizeof(x); })); ASSERT(2, ({ char x[(5||6)+1]; sizeof(x); })); ASSERT(1, ({ char x[(0||0)+1]; sizeof(x); })); ASSERT(2, ({ char x[(1&&1)+1]; sizeof(x); })); ASSERT(1, ({ char x[(1&&0)+1]; sizeof(x); })); ASSERT(3, ({ char x[(int)3]; sizeof(x); })); ASSERT(15, ({ char x[(char)0xffffff0f]; sizeof(x); })); ASSERT(0x10f, ({ char x[(short)0xffff010f]; sizeof(x); })); ASSERT(4, ({ char x[(int)0xfffffffffff+5]; sizeof(x); })); ASSERT(8, ({ char x[(int*)0+2]; sizeof(x); })); ASSERT(12, ({ char x[(int*)16-1]; sizeof(x); })); ASSERT(3, ({ char x[(int*)16-(int*)4]; sizeof(x); })); ASSERT(4, ({ char x[(-1>>31)+5]; sizeof(x); })); ASSERT(255, ({ char x[(unsigned char)0xffffffff]; sizeof(x); })); ASSERT(0x800f, ({ char x[(unsigned short)0xffff800f]; sizeof(x); })); ASSERT(1, ({ char x[(unsigned int)0xfffffffffff>>31]; sizeof(x); })); ASSERT(1, ({ char x[(long)-1/((long)1<<62)+1]; sizeof(x); })); ASSERT(4, ({ char x[(unsigned long)-1/((long)1<<62)+1]; sizeof(x); })); ASSERT(1, ({ char x[(unsigned)1<-1]; sizeof(x); })); ASSERT(1, ({ char x[(unsigned)1<=-1]; sizeof(x); })); ASSERT(1, g40==1.5); ASSERT(1, g41==11); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/constructor_destructor.c000066400000000000000000000034451505335450300213170ustar00rootroot00000000000000 #include "test.h" // Attributes defined BEFORE declarations __attribute__((constructor(200))) void ctor2(); __attribute__((constructor(100))) void ctor1(); __attribute__((destructor(200))) void dtor2(); __attribute__((destructor(100))) void dtor1(); int step = 0; void before_main_low () __attribute__((constructor(500))) ; void before_main_high() __attribute__((constructor(400))) ; void after_main_low() __attribute__((destructor(500))) ; void after_main_high() __attribute__((destructor(400))) ; // Attributes defined AFTER declarations void ctor3() __attribute__((constructor(300))); void dtor3() __attribute__((destructor(300))); void ctor1() { printf("Constructor 100 (first)\n"); step += 100; ASSERT(100, step); } void ctor2() { printf("Constructor 200 (second)\n"); step += 100; ASSERT(200, step); } void ctor3() { printf("Constructor 300 (third)\n"); step += 100; ASSERT(300, step); } void dtor1() { printf("Destructor 100 (first)\n"); step -= 100; ASSERT(0, step); } void dtor2() { printf("Destructor 200 (second)\n"); step -= 100; ASSERT(100, step); } void dtor3() { printf("Destructor 300 (last)\n"); step -= 100; ASSERT(200, step); } void before_main_low(void) { printf("Constructor with priority 500 (runs fifth)\n"); step += 100; ASSERT(500, step); } void before_main_high(void) { printf("Constructor with priority 400 (runs fourth)\n"); step += 100; ASSERT(400, step); } void after_main_low(void) { printf("Destructor with priority 500 (runs fifth)\n"); step -= 100; ASSERT(400, step); } void after_main_high(void) { printf("Destructor with priority 400 (runs fourth)\n"); step -= 100; ASSERT(300, step); } int main(void) { printf("Inside main()\n"); return 0; } chibicc-1.0.23.1/test/constructor_destructor2.c000066400000000000000000000035421505335450300213770ustar00rootroot00000000000000 #include "test.h" // Attributes defined BEFORE declarations __attribute__((constructor(200))) void ctor2(void); __attribute__((constructor(100))) void ctor1(void); __attribute__((destructor(200))) void dtor2(void); __attribute__((destructor(100))) void dtor1(void); int step = 0; void before_main_low(void) __attribute__((constructor(500))); void before_main_high(void) __attribute__((constructor(400))); void after_main_low(void) __attribute__((destructor(500))); void after_main_high(void) __attribute__((destructor(400))); // Attributes defined AFTER declarations void ctor3(void) __attribute__((constructor(300))); void dtor3(void) __attribute__((destructor(300))); void ctor1(void) { printf("Constructor 100 (first)\n"); step += 100; ASSERT(100, step); } void ctor2(void) { printf("Constructor 200 (second)\n"); step +=100; ASSERT(200, step); } void ctor3(void) { printf("Constructor 300 (third)\n"); step += 100; ASSERT(300, step); } void dtor1(void) { printf("Destructor 100 (first)\n"); step -= 100; ASSERT(0, step); } void dtor2(void) { printf("Destructor 200 (second)\n"); step -= 100; ASSERT(100, step); } void dtor3(void) { printf("Destructor 300 (last)\n"); step -= 100; ASSERT(200, step); } void before_main_low(void) { printf("Constructor with priority 500 (runs fifth)\n"); step += 100; ASSERT(500, step); } void before_main_high(void) { printf("Constructor with priority 400 (runs fourth)\n"); step += 100; ASSERT(400, step); } void after_main_low(void) { printf("Destructor with priority 500 (runs fifth)\n"); step -= 100; ASSERT(400, step); } void after_main_high(void) { printf("Destructor with priority 400 (runs fourth)\n"); step -= 100; ASSERT(300, step); } int main(void) { printf("Inside main()\n"); return 0; } chibicc-1.0.23.1/test/control.c000077500000000000000000000106251505335450300161350ustar00rootroot00000000000000#include "test.h" /* * This is a block comment. */ int main() { ASSERT(3, ({ int x; if (0) x=2; else x=3; x; })); ASSERT(3, ({ int x; if (1-1) x=2; else x=3; x; })); ASSERT(2, ({ int x; if (1) x=2; else x=3; x; })); ASSERT(2, ({ int x; if (2-1) x=2; else x=3; x; })); ASSERT(55, ({ int i=0; int j=0; for (i=0; i<=10; i=i+1) j=i+j; j; })); ASSERT(10, ({ int i=0; while(i<10) i=i+1; i; })); ASSERT(3, ({ 1; {2;} 3; })); ASSERT(5, ({ ;;; 5; })); ASSERT(10, ({ int i=0; while(i<10) i=i+1; i; })); ASSERT(55, ({ int i=0; int j=0; while(i<=10) {j=i+j; i=i+1;} j; })); ASSERT(3, (1,2,3)); ASSERT(5, ({ int i=2, j=3; (i=5,j)=6; i; })); ASSERT(6, ({ int i=2, j=3; (i=5,j)=6; j; })); ASSERT(55, ({ int j=0; for (int i=0; i<=10; i=i+1) j=j+i; j; })); ASSERT(3, ({ int i=3; int j=0; for (int i=0; i<=10; i=i+1) j=j+i; i; })); ASSERT(1, 0||1); ASSERT(1, 0||(2-2)||5); ASSERT(0, 0||0); ASSERT(0, 0||(2-2)); ASSERT(0, 0&&1); ASSERT(0, (2-2)&&5); ASSERT(1, 1&&5); ASSERT(3, ({ int i=0; goto a; a: i++; b: i++; c: i++; i; })); ASSERT(2, ({ int i=0; goto e; d: i++; e: i++; f: i++; i; })); ASSERT(1, ({ int i=0; goto i; g: i++; h: i++; i: i++; i; })); ASSERT(1, ({ typedef int foo; goto foo; foo:; 1; })); ASSERT(3, ({ int i=0; for(;i<10;i++) { if (i == 3) break; } i; })); ASSERT(4, ({ int i=0; while (1) { if (i++ == 3) break; } i; })); ASSERT(3, ({ int i=0; for(;i<10;i++) { for (;;) break; if (i == 3) break; } i; })); ASSERT(4, ({ int i=0; while (1) { while(1) break; if (i++ == 3) break; } i; })); ASSERT(10, ({ int i=0; int j=0; for (;i<10;i++) { if (i>5) continue; j++; } i; })); ASSERT(6, ({ int i=0; int j=0; for (;i<10;i++) { if (i>5) continue; j++; } j; })); ASSERT(10, ({ int i=0; int j=0; for(;!i;) { for (;j!=10;j++) continue; break; } j; })); ASSERT(11, ({ int i=0; int j=0; while (i++<10) { if (i>5) continue; j++; } i; })); ASSERT(5, ({ int i=0; int j=0; while (i++<10) { if (i>5) continue; j++; } j; })); ASSERT(11, ({ int i=0; int j=0; while(!i) { while (j++!=10) continue; break; } j; })); ASSERT(5, ({ int i=0; switch(0) { case 0:i=5;break; case 1:i=6;break; case 2:i=7;break; } i; })); ASSERT(6, ({ int i=0; switch(1) { case 0:i=5;break; case 1:i=6;break; case 2:i=7;break; } i; })); ASSERT(7, ({ int i=0; switch(2) { case 0:i=5;break; case 1:i=6;break; case 2:i=7;break; } i; })); ASSERT(0, ({ int i=0; switch(3) { case 0:i=5;break; case 1:i=6;break; case 2:i=7;break; } i; })); ASSERT(5, ({ int i=0; switch(0) { case 0:i=5;break; default:i=7; } i; })); ASSERT(7, ({ int i=0; switch(1) { case 0:i=5;break; default:i=7; } i; })); ASSERT(2, ({ int i=0; switch(1) { case 0: 0; case 1: 0; case 2: 0; i=2; } i; })); ASSERT(0, ({ int i=0; switch(3) { case 0: 0; case 1: 0; case 2: 0; i=2; } i; })); ASSERT(3, ({ int i=0; switch(-1) { case 0xffffffff: i=3; break; } i; })); ASSERT(7, ({ int i=0; int j=0; do { j++; } while (i++ < 6); j; })); ASSERT(4, ({ int i=0; int j=0; int k=0; do { if (++j > 3) break; continue; k++; } while (1); j; })); ASSERT(0, 0.0 && 0.0); ASSERT(0, 0.0 && 0.1); ASSERT(0, 0.3 && 0.0); ASSERT(1, 0.3 && 0.5); ASSERT(0, 0.0 || 0.0); ASSERT(1, 0.0 || 0.1); ASSERT(1, 0.3 || 0.0); ASSERT(1, 0.3 || 0.5); ASSERT(5, ({ int x; if (0.0) x=3; else x=5; x; })); ASSERT(3, ({ int x; if (0.1) x=3; else x=5; x; })); ASSERT(5, ({ int x=5; if (0.0) x=3; x; })); ASSERT(3, ({ int x=5; if (0.1) x=3; x; })); ASSERT(10, ({ double i=10.0; int j=0; for (; i; i--, j++); j; })); ASSERT(10, ({ double i=10.0; int j=0; do j++; while(--i); j; })); ASSERT(2, ({ int i=0; switch(7) { case 0 ... 5: i=1; break; case 6 ... 20: i=2; break; } i; })); ASSERT(1, ({ int i=0; switch(7) { case 0 ... 7: i=1; break; case 8 ... 10: i=2; break; } i; })); ASSERT(1, ({ int i=0; switch(7) { case 0: i=1; break; case 7 ... 7: i=1; break; } i; })); ASSERT(3, ({ void *p = &&v11; int i=0; goto *p; v11:i++; v12:i++; v13:i++; i; })); ASSERT(2, ({ void *p = &&v22; int i=0; goto *p; v21:i++; v22:i++; v23:i++; i; })); ASSERT(1, ({ void *p = &&v33; int i=0; goto *p; v31:i++; v32:i++; v33:i++; i; })); ASSERT(3, ({ static void *p[]={&&v41,&&v42,&&v43}; int i=0; goto *p[0]; v41:i++; v42:i++; v43:i++; i; })); ASSERT(2, ({ static void *p[]={&&v52,&&v52,&&v53}; int i=0; goto *p[1]; v51:i++; v52:i++; v53:i++; i; })); ASSERT(1, ({ static void *p[]={&&v62,&&v62,&&v63}; int i=0; goto *p[2]; v61:i++; v62:i++; v63:i++; i; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/control2.c000066400000000000000000000016431505335450300162140ustar00rootroot00000000000000#include "test.h" #include char c23_label(void) { { int i = 0; if (i != 0) lab3: i = 1; ASSERT(0, i); } switch (1) { default: case 2: } if (0) { { lab1: } { lab2: int j; } return 77; } goto lab1; } int main(void){ ASSERT(2, ({ uint32_t i=0; switch(i){case 0 ...0xFFFFFFFF: i=2;} i; })); ASSERT(2, ({ int32_t i=0; switch(i){case 0x80000000 ...0x7FFFFFFF: i=2;} i; })); ASSERT(2, ({ uint64_t i=0; switch(i){case 0 ...0xFFFFFFFFFFFFFFFF: i=2;} i; })); ASSERT(2, ({ int64_t i=0; switch(i){case 0x8000000000000000 ...0x7FFFFFFFFFFFFFFF: i=2;} i; })); ASSERT(2, ({ uint32_t i=0; switch(i){case 0 ...0x100000000: i=2;} i; })); ASSERT(2, ({ int32_t i=-1; switch(i){case -1 ...(int64_t)-1: i=2;} i; })); ASSERT(2, ({ int64_t i=0; switch(0x123456789){case 0x123456789: i=2;} i; })); ASSERT(77, c23_label()); printf("OK\n"); }chibicc-1.0.23.1/test/cpuid.c000066400000000000000000000015561505335450300155610ustar00rootroot00000000000000#include "test.h" #include #include // Simple cpuid wrapper function void cpuid(uint32_t eax_in, uint32_t ecx_in, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { __asm__ volatile ( "cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (eax_in), "c" (ecx_in) ); } int main(void) { uint32_t eax, ebx, ecx, edx; // Get vendor ID (cpuid leaf 0) cpuid(0, 0, &eax, &ebx, &ecx, &edx); char vendor[13]; *(uint32_t*)&vendor[0] = ebx; *(uint32_t*)&vendor[4] = edx; *(uint32_t*)&vendor[8] = ecx; vendor[12] = '\0'; printf("CPUID vendor: %s\n", vendor); printf("Max cpuid leaf: %u\n", eax); //assert(0 == !strncmp("GenuineIntel", vendor, 12)); assert(13 == eax || eax == 20); return 0; } chibicc-1.0.23.1/test/cpython_ms_struct.c000066400000000000000000000020421505335450300202330ustar00rootroot00000000000000#include "test.h" #include // Normal struct struct Normal { char c; int i; short s; }; // MS struct struct __attribute__((ms_struct)) Ms { char c; int i; short s; }; int main(void) { printf("sizeof(Normal) = %zu\n", sizeof(struct Normal)); printf(" offsets: c=%zu i=%zu s=%zu\n", offsetof(struct Normal, c), offsetof(struct Normal, i), offsetof(struct Normal, s)); printf("sizeof(Ms) = %zu\n", sizeof(struct Ms)); printf(" offsets: c=%zu i=%zu s=%zu\n", offsetof(struct Ms, c), offsetof(struct Ms, i), offsetof(struct Ms, s)); ASSERT(12, sizeof(struct Normal)); ASSERT(0, offsetof(struct Normal, c)); ASSERT(4, offsetof(struct Normal, i)); ASSERT(8, offsetof(struct Normal, s)); ASSERT(12, sizeof(struct Ms)); ASSERT(0, offsetof(struct Ms, c)); ASSERT(4, offsetof(struct Ms, i)); ASSERT(8, offsetof(struct Ms, s)); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/crawler.h000066400000000000000000000024511505335450300161140ustar00rootroot00000000000000#ifndef CRAWLER_H #define CRAWLER_H #define LRU_CRAWLER_CAP_REMAINING -1 typedef struct { uint64_t histo[61]; uint64_t ttl_hourplus; uint64_t noexp; uint64_t reclaimed; uint64_t seen; rel_time_t start_time; rel_time_t end_time; bool run_complete; } crawlerstats_t; struct crawler_expired_data { pthread_mutex_t lock; crawlerstats_t crawlerstats[POWER_LARGEST]; /* redundant with crawlerstats_t so we can get overall start/stop/done */ rel_time_t start_time; rel_time_t end_time; bool crawl_complete; bool is_external; /* whether this was an alloc local or remote to the module. */ }; enum crawler_result_type { CRAWLER_OK=0, CRAWLER_RUNNING, CRAWLER_BADCLASS, CRAWLER_NOTSTARTED, CRAWLER_ERROR }; int start_item_crawler_thread(void); #define CRAWLER_WAIT true #define CRAWLER_NOWAIT false int stop_item_crawler_thread(bool wait); int init_lru_crawler(void *arg); enum crawler_result_type lru_crawler_crawl(char *slabs, enum crawler_run_type, void *c, const int sfd, unsigned int remaining); int lru_crawler_start(uint8_t *ids, uint32_t remaining, const enum crawler_run_type type, void *data, void *c, const int sfd); void lru_crawler_pause(void); void lru_crawler_resume(void); #endif chibicc-1.0.23.1/test/crc32.c000077500000000000000000000765111505335450300153770ustar00rootroot00000000000000/* crc32.c -- compute the CRC-32 of a data stream * Copyright (C) 1995-2022 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * This interleaved implementation of a CRC makes use of pipelined multiple * arithmetic-logic units, commonly found in modern CPU cores. It is due to * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution. */ /* @(#) $Id$ */ /* Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection on the static variables used to control the first-use generation of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). MAKECRCH can be #defined to write out crc32.h. A main() routine is also produced, so that this one source file can be compiled to an executable. */ #include "test.h" #ifdef MAKECRCH #include #ifndef DYNAMIC_CRC_TABLE #define DYNAMIC_CRC_TABLE #endif /* !DYNAMIC_CRC_TABLE */ #endif /* MAKECRCH */ #include "zutil.h" /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */ /* A CRC of a message is computed on N braids of words in the message, where each word consists of W bytes (4 or 8). If N is 3, for example, then three running sparse CRCs are calculated respectively on each braid, at these indices in the array of words: 0, 3, 6, ..., 1, 4, 7, ..., and 2, 5, 8, ... This is done starting at a word boundary, and continues until as many blocks of N * W bytes as are available have been processed. The results are combined into a single CRC at the end. For this code, N must be in the range 1..6 and W must be 4 or 8. The upper limit on N can be increased if desired by adding more #if blocks, extending the patterns apparent in the code. In addition, crc32.h would need to be regenerated, if the maximum N value is increased. N and W are chosen empirically by benchmarking the execution time on a given processor. The choices for N and W below were based on testing on Intel Kaby Lake i7, AMD Ryzen 7, ARM Cortex-A57, Sparc64-VII, PowerPC POWER9, and MIPS64 Octeon II processors. The Intel, AMD, and ARM processors were all fastest with N=5, W=8. The Sparc, PowerPC, and MIPS64 were all fastest at N=5, W=4. They were all tested with either gcc or clang, all using the -O3 optimization level. Your mileage may vary. */ /* Define N */ #ifdef Z_TESTN #define N Z_TESTN #else #define N 5 #endif #if N < 1 || N > 6 #error N must be in 1..6 #endif /* z_crc_t must be at least 32 bits. z_word_t must be at least as long as z_crc_t. It is assumed here that z_word_t is either 32 bits or 64 bits, and that bytes are eight bits. */ /* Define W and the associated z_word_t type. If W is not defined, then a braided calculation is not used, and the associated tables and code are not compiled. */ #ifdef Z_TESTW #if Z_TESTW - 1 != -1 #define W Z_TESTW #endif #else #ifdef MAKECRCH #define W 8 /* required for MAKECRCH */ #else #if defined(__x86_64__) || defined(__aarch64__) #define W 8 #else #define W 4 #endif #endif #endif #ifdef W #if W == 8 && defined(Z_U8) typedef Z_U8 z_word_t; #elif defined(Z_U4) #undef W #define W 4 typedef Z_U4 z_word_t; #else #undef W #endif #endif /* Local functions. */ local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); /* If available, use the ARM processor CRC32 instruction. */ #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 #define ARMCRC32 #endif #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) /* Swap the bytes in a z_word_t to convert between little and big endian. Any self-respecting compiler will optimize this to a single machine byte-swap instruction, if one is available. This assumes that word_t is either 32 bits or 64 bits. */ local z_word_t byte_swap(word) z_word_t word; { #if W == 8 return (word & 0xff00000000000000) >> 56 | (word & 0xff000000000000) >> 40 | (word & 0xff0000000000) >> 24 | (word & 0xff00000000) >> 8 | (word & 0xff000000) << 8 | (word & 0xff0000) << 24 | (word & 0xff00) << 40 | (word & 0xff) << 56; #else /* W == 4 */ return (word & 0xff000000) >> 24 | (word & 0xff0000) >> 8 | (word & 0xff00) << 8 | (word & 0xff) << 24; #endif } #endif /* CRC polynomial. */ #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ #ifdef DYNAMIC_CRC_TABLE local z_crc_t FAR crc_table[256]; local z_crc_t FAR x2n_table[32]; local void make_crc_table OF((void)); #ifdef W local z_word_t FAR crc_big_table[256]; local z_crc_t FAR crc_braid_table[W][256]; local z_word_t FAR crc_braid_big_table[W][256]; local void braid OF((z_crc_t[][256], z_word_t[][256], int, int)); #endif #ifdef MAKECRCH local void write_table OF((FILE *, const z_crc_t FAR *, int)); local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); local void write_table64 OF((FILE *, const z_word_t FAR *, int)); #endif /* MAKECRCH */ /* Define a once() function depending on the availability of atomics. If this is compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in multiple threads, and if atomics are not available, then get_crc_table() must be called to initialize the tables and must return before any threads are allowed to compute or combine CRCs. */ /* Definition of once functionality. */ typedef struct once_s once_t; local void once OF((once_t *, void (*)(void))); /* Check for the availability of atomics. */ #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ !defined(__STDC_NO_ATOMICS__) #include /* Structure for once(), which must be initialized with ONCE_INIT. */ struct once_s { atomic_flag begun; atomic_int done; }; #define ONCE_INIT \ { \ ATOMIC_FLAG_INIT, 0 \ } /* Run the provided init() function exactly once, even if multiple threads invoke once() at the same time. The state must be a once_t initialized with ONCE_INIT. */ local void once(state, init) once_t *state; void (*init)(void); { if (!atomic_load(&state->done)) { if (atomic_flag_test_and_set(&state->begun)) while (!atomic_load(&state->done)) ; else { init(); atomic_store(&state->done, 1); } } } #else /* no atomics */ /* Structure for once(), which must be initialized with ONCE_INIT. */ struct once_s { volatile int begun; volatile int done; }; #define ONCE_INIT \ { \ 0, 0 \ } /* Test and set. Alas, not atomic, but tries to minimize the period of vulnerability. */ local int test_and_set OF((int volatile *)); local int test_and_set(flag) int volatile *flag; { int was; was = *flag; *flag = 1; return was; } /* Run the provided init() function once. This is not thread-safe. */ local void once(state, init) once_t *state; void (*init)(void); { if (!state->done) { if (test_and_set(&state->begun)) while (!state->done) ; else { init(); state->done = 1; } } } #endif /* State for once(). */ local once_t made = ONCE_INIT; /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the byte 0xb1 is the polynomial x^7+x^3+x^2+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b. This calculation is done using the shift-register method of multiplying and taking the remainder. The register is initialized to zero, and for each incoming bit, x^32 is added mod p to the register if the bit is a one (where x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x (which is shifting right by one and adding x^32 mod p if the bit shifted out is a one). We start with the highest power (least significant bit) of q and repeat for all eight bits of q. The table is simply the CRC of all possible eight bit values. This is all the information needed to generate CRCs on data a byte at a time for all combinations of CRC register values and incoming bytes. */ local void make_crc_table() { unsigned i, j, n; z_crc_t p; /* initialize the CRC of bytes tables */ for (i = 0; i < 256; i++) { p = i; for (j = 0; j < 8; j++) p = p & 1 ? (p >> 1) ^ POLY : p >> 1; crc_table[i] = p; #ifdef W crc_big_table[i] = byte_swap(p); #endif } /* initialize the x^2^n mod p(x) table */ p = (z_crc_t)1 << 30; /* x^1 */ x2n_table[0] = p; for (n = 1; n < 32; n++) x2n_table[n] = p = multmodp(p, p); #ifdef W /* initialize the braiding tables -- needs x2n_table[] */ braid(crc_braid_table, crc_braid_big_table, N, W); #endif #ifdef MAKECRCH { /* The crc32.h header file contains tables for both 32-bit and 64-bit z_word_t's, and so requires a 64-bit type be available. In that case, z_word_t must be defined to be 64-bits. This code then also generates and writes out the tables for the case that z_word_t is 32 bits. */ #if !defined(W) || W != 8 #error Need a 64-bit integer type in order to generate crc32.h. #endif FILE *out; int k, n; z_crc_t ltl[8][256]; z_word_t big[8][256]; out = fopen("crc32.h", "w"); if (out == NULL) return; /* write out little-endian CRC table to crc32.h */ fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n" " * Generated automatically by crc32.c\n */\n" "\n" "local const z_crc_t FAR crc_table[] = {\n" " "); write_table(out, crc_table, 256); fprintf(out, "};\n"); /* write out big-endian CRC table for 64-bit z_word_t to crc32.h */ fprintf(out, "\n" "#ifdef W\n" "\n" "#if W == 8\n" "\n" "local const z_word_t FAR crc_big_table[] = {\n" " "); write_table64(out, crc_big_table, 256); fprintf(out, "};\n"); /* write out big-endian CRC table for 32-bit z_word_t to crc32.h */ fprintf(out, "\n" "#else /* W == 4 */\n" "\n" "local const z_word_t FAR crc_big_table[] = {\n" " "); write_table32hi(out, crc_big_table, 256); fprintf(out, "};\n" "\n" "#endif\n"); /* write out braid tables for each value of N */ for (n = 1; n <= 6; n++) { fprintf(out, "\n" "#if N == %d\n", n); /* compute braid tables for this N and 64-bit word_t */ braid(ltl, big, n, 8); /* write out braid tables for 64-bit z_word_t to crc32.h */ fprintf(out, "\n" "#if W == 8\n" "\n" "local const z_crc_t FAR crc_braid_table[][256] = {\n"); for (k = 0; k < 8; k++) { fprintf(out, " {"); write_table(out, ltl[k], 256); fprintf(out, "}%s", k < 7 ? ",\n" : ""); } fprintf(out, "};\n" "\n" "local const z_word_t FAR crc_braid_big_table[][256] = {\n"); for (k = 0; k < 8; k++) { fprintf(out, " {"); write_table64(out, big[k], 256); fprintf(out, "}%s", k < 7 ? ",\n" : ""); } fprintf(out, "};\n"); /* compute braid tables for this N and 32-bit word_t */ braid(ltl, big, n, 4); /* write out braid tables for 32-bit z_word_t to crc32.h */ fprintf(out, "\n" "#else /* W == 4 */\n" "\n" "local const z_crc_t FAR crc_braid_table[][256] = {\n"); for (k = 0; k < 4; k++) { fprintf(out, " {"); write_table(out, ltl[k], 256); fprintf(out, "}%s", k < 3 ? ",\n" : ""); } fprintf(out, "};\n" "\n" "local const z_word_t FAR crc_braid_big_table[][256] = {\n"); for (k = 0; k < 4; k++) { fprintf(out, " {"); write_table32hi(out, big[k], 256); fprintf(out, "}%s", k < 3 ? ",\n" : ""); } fprintf(out, "};\n" "\n" "#endif\n" "\n" "#endif\n"); } fprintf(out, "\n" "#endif\n"); /* write out zeros operator table to crc32.h */ fprintf(out, "\n" "local const z_crc_t FAR x2n_table[] = {\n" " "); write_table(out, x2n_table, 32); fprintf(out, "};\n"); fclose(out); } #endif /* MAKECRCH */ } #ifdef MAKECRCH /* Write the 32-bit values in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ local void write_table(out, table, k) FILE *out; const z_crc_t FAR *table; int k; { int n; for (n = 0; n < k; n++) fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", (unsigned long)(table[n]), n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); } /* Write the high 32-bits of each value in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ local void write_table32hi(out, table, k) FILE *out; const z_word_t FAR *table; int k; { int n; for (n = 0; n < k; n++) fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", (unsigned long)(table[n] >> 32), n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); } /* Write the 64-bit values in table[0..k-1] to out, three per line in hexadecimal separated by commas. This assumes that if there is a 64-bit type, then there is also a long long integer type, and it is at least 64 bits. If not, then the type cast and format string can be adjusted accordingly. */ local void write_table64(out, table, k) FILE *out; const z_word_t FAR *table; int k; { int n; for (n = 0; n < k; n++) fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", (unsigned long long)(table[n]), n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); } /* Actually do the deed. */ int main() { make_crc_table(); return 0; } #endif /* MAKECRCH */ #ifdef W /* Generate the little and big-endian braid tables for the given n and z_word_t size w. Each array must have room for w blocks of 256 elements. */ local void braid(ltl, big, n, w) z_crc_t ltl[][256]; z_word_t big[][256]; int n; int w; { int k; z_crc_t i, p, q; for (k = 0; k < w; k++) { p = x2nmodp((n * w + 3 - k) << 3, 0); ltl[k][0] = 0; big[w - 1 - k][0] = 0; for (i = 1; i < 256; i++) { ltl[k][i] = q = multmodp(i << 24, p); big[w - 1 - k][i] = byte_swap(q); } } } #endif #else /* !DYNAMIC_CRC_TABLE */ /* * Tables for byte-wise and braided CRC-32 calculations, and a table of powers * of x for combining CRC-32s, all made by make_crc_table(). */ #include "crc32.h" #endif /* DYNAMIC_CRC_TABLE */ /* * Routines used for CRC calculation. Some are also required for the table * generation above. */ /* Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, reflected. For speed, this requires that a not be zero. */ local z_crc_t multmodp(a, b) z_crc_t a; z_crc_t b; { z_crc_t m, p; m = (z_crc_t)1 << 31; p = 0; for (;;) { if (a & m) { p ^= b; if ((a & (m - 1)) == 0) break; } m >>= 1; b = b & 1 ? (b >> 1) ^ POLY : b >> 1; } return p; } /* Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been initialized. */ local z_crc_t x2nmodp(n, k) z_off64_t n; unsigned k; { z_crc_t p; p = (z_crc_t)1 << 31; /* x^0 == 1 */ while (n) { if (n & 1) p = multmodp(x2n_table[k & 31], p); n >>= 1; k++; } return p; } /* * This function can be used by asm versions of crc32(), and to force the * generation of the CRC tables in a threaded application. */ const z_crc_t FAR *ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return (const z_crc_t FAR *)crc_table; } /* * Use ARM machine instructions if available. This will compute the CRC about * ten times faster than the braided calculation. This code does not check for * the presence of the CRC instruction at run time. __ARM_FEATURE_CRC32 will * only be defined if the compilation specifies an ARM processor architecture * that has the instructions. For example, compiling with -march=armv8.1-a or * -march=armv8-a+crc, or -march=native if the compile machine has the crc32 * instructions. */ #ifdef ARMCRC32 /* Constants empirically determined to maximize speed. These values are from measurements on a Cortex-A57. Your mileage may vary. */ #define Z_BATCH 3990 /* number of words in a batch */ #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ #define Z_BATCH_MIN 800 /* fewest words in a final batch */ unsigned long ZEXPORT crc32_z(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; z_size_t len; { z_crc_t val; z_word_t crc1, crc2; const z_word_t *word; z_word_t val0, val1, val2; z_size_t last, last2, i; z_size_t num; /* Return initial CRC, if requested. */ if (buf == Z_NULL) return 0; #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ /* Pre-condition the CRC */ crc ^= 0xffffffff; /* Compute the CRC up to a word boundary. */ while (len && ((z_size_t)buf & 7) != 0) { len--; val = *buf++; __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); } /* Prepare to compute the CRC on full 64-bit words word[0..num-1]. */ word = (z_word_t const *)buf; num = len >> 3; len &= 7; /* Do three interleaved CRCs to realize the throughput of one crc32x instruction per cycle. Each CRC is calcuated on Z_BATCH words. The three CRCs are combined into a single CRC after each set of batches. */ while (num >= 3 * Z_BATCH) { crc1 = 0; crc2 = 0; for (i = 0; i < Z_BATCH; i++) { val0 = word[i]; val1 = word[i + Z_BATCH]; val2 = word[i + 2 * Z_BATCH]; __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1)); __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2)); } word += 3 * Z_BATCH; num -= 3 * Z_BATCH; crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc1; crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc2; } /* Do one last smaller batch with the remaining words, if there are enough to pay for the combination of CRCs. */ last = num / 3; if (last >= Z_BATCH_MIN) { last2 = last << 1; crc1 = 0; crc2 = 0; for (i = 0; i < last; i++) { val0 = word[i]; val1 = word[i + last]; val2 = word[i + last2]; __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1)); __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2)); } word += 3 * last; num -= 3 * last; val = x2nmodp(last, 6); crc = multmodp(val, crc) ^ crc1; crc = multmodp(val, crc) ^ crc2; } /* Compute the CRC on any remaining words. */ for (i = 0; i < num; i++) { val0 = word[i]; __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); } word += num; /* Complete the CRC on any remaining bytes. */ buf = (const unsigned char FAR *)word; while (len) { len--; val = *buf++; __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); } /* Return the CRC, post-conditioned. */ return crc ^ 0xffffffff; } #else #ifdef W /* Return the CRC of the W bytes in the word_t data, taking the least-significant byte of the word as the first byte of data, without any pre or post conditioning. This is used to combine the CRCs of each braid. */ local z_crc_t crc_word(data) z_word_t data; { int k; for (k = 0; k < W; k++) data = (data >> 8) ^ crc_table[data & 0xff]; return (z_crc_t)data; } local z_word_t crc_word_big(data) z_word_t data; { int k; for (k = 0; k < W; k++) data = (data << 8) ^ crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; return data; } #endif unsigned long ZEXPORT crc32_z(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; z_size_t len; { /* Return initial CRC, if requested. */ if (buf == Z_NULL) return 0; #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ /* Pre-condition the CRC */ crc ^= 0xffffffff; #ifdef W /* If provided enough bytes, do a braided CRC calculation. */ if (len >= N * W + W - 1) { z_size_t blks; z_word_t const *words; unsigned endian; int k; /* Compute the CRC up to a z_word_t boundary. */ while (len && ((z_size_t)buf & (W - 1)) != 0) { len--; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } /* Compute the CRC on as many N z_word_t blocks as are available. */ blks = len / (N * W); len -= blks * N * W; words = (z_word_t const *)buf; /* Do endian check at execution time instead of compile time, since ARM processors can change the endianess at execution time. If the compiler knows what the endianess will be, it can optimize out the check and the unused branch. */ endian = 1; if (*(unsigned char *)&endian) { /* Little endian. */ z_crc_t crc0; z_word_t word0; #if N > 1 z_crc_t crc1; z_word_t word1; #if N > 2 z_crc_t crc2; z_word_t word2; #if N > 3 z_crc_t crc3; z_word_t word3; #if N > 4 z_crc_t crc4; z_word_t word4; #if N > 5 z_crc_t crc5; z_word_t word5; #endif #endif #endif #endif #endif /* Initialize the CRC for each braid. */ crc0 = crc; #if N > 1 crc1 = 0; #if N > 2 crc2 = 0; #if N > 3 crc3 = 0; #if N > 4 crc4 = 0; #if N > 5 crc5 = 0; #endif #endif #endif #endif #endif /* Process the first blks-1 blocks, computing the CRCs on each braid independently. */ while (--blks) { /* Load the word for each braid into registers. */ word0 = crc0 ^ words[0]; #if N > 1 word1 = crc1 ^ words[1]; #if N > 2 word2 = crc2 ^ words[2]; #if N > 3 word3 = crc3 ^ words[3]; #if N > 4 word4 = crc4 ^ words[4]; #if N > 5 word5 = crc5 ^ words[5]; #endif #endif #endif #endif #endif words += N; /* Compute and update the CRC for each word. The loop should get unrolled. */ crc0 = crc_braid_table[0][word0 & 0xff]; #if N > 1 crc1 = crc_braid_table[0][word1 & 0xff]; #if N > 2 crc2 = crc_braid_table[0][word2 & 0xff]; #if N > 3 crc3 = crc_braid_table[0][word3 & 0xff]; #if N > 4 crc4 = crc_braid_table[0][word4 & 0xff]; #if N > 5 crc5 = crc_braid_table[0][word5 & 0xff]; #endif #endif #endif #endif #endif for (k = 1; k < W; k++) { crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff]; #if N > 1 crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff]; #if N > 2 crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff]; #if N > 3 crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff]; #if N > 4 crc4 ^= crc_braid_table[k][(word4 >> (k << 3)) & 0xff]; #if N > 5 crc5 ^= crc_braid_table[k][(word5 >> (k << 3)) & 0xff]; #endif #endif #endif #endif #endif } } /* Process the last block, combining the CRCs of the N braids at the same time. */ crc = crc_word(crc0 ^ words[0]); #if N > 1 crc = crc_word(crc1 ^ words[1] ^ crc); #if N > 2 crc = crc_word(crc2 ^ words[2] ^ crc); #if N > 3 crc = crc_word(crc3 ^ words[3] ^ crc); #if N > 4 crc = crc_word(crc4 ^ words[4] ^ crc); #if N > 5 crc = crc_word(crc5 ^ words[5] ^ crc); #endif #endif #endif #endif #endif words += N; } else { /* Big endian. */ z_word_t crc0, word0, comb; #if N > 1 z_word_t crc1, word1; #if N > 2 z_word_t crc2, word2; #if N > 3 z_word_t crc3, word3; #if N > 4 z_word_t crc4, word4; #if N > 5 z_word_t crc5, word5; #endif #endif #endif #endif #endif /* Initialize the CRC for each braid. */ crc0 = byte_swap(crc); #if N > 1 crc1 = 0; #if N > 2 crc2 = 0; #if N > 3 crc3 = 0; #if N > 4 crc4 = 0; #if N > 5 crc5 = 0; #endif #endif #endif #endif #endif /* Process the first blks-1 blocks, computing the CRCs on each braid independently. */ while (--blks) { /* Load the word for each braid into registers. */ word0 = crc0 ^ words[0]; #if N > 1 word1 = crc1 ^ words[1]; #if N > 2 word2 = crc2 ^ words[2]; #if N > 3 word3 = crc3 ^ words[3]; #if N > 4 word4 = crc4 ^ words[4]; #if N > 5 word5 = crc5 ^ words[5]; #endif #endif #endif #endif #endif words += N; /* Compute and update the CRC for each word. The loop should get unrolled. */ crc0 = crc_braid_big_table[0][word0 & 0xff]; #if N > 1 crc1 = crc_braid_big_table[0][word1 & 0xff]; #if N > 2 crc2 = crc_braid_big_table[0][word2 & 0xff]; #if N > 3 crc3 = crc_braid_big_table[0][word3 & 0xff]; #if N > 4 crc4 = crc_braid_big_table[0][word4 & 0xff]; #if N > 5 crc5 = crc_braid_big_table[0][word5 & 0xff]; #endif #endif #endif #endif #endif for (k = 1; k < W; k++) { crc0 ^= crc_braid_big_table[k][(word0 >> (k << 3)) & 0xff]; #if N > 1 crc1 ^= crc_braid_big_table[k][(word1 >> (k << 3)) & 0xff]; #if N > 2 crc2 ^= crc_braid_big_table[k][(word2 >> (k << 3)) & 0xff]; #if N > 3 crc3 ^= crc_braid_big_table[k][(word3 >> (k << 3)) & 0xff]; #if N > 4 crc4 ^= crc_braid_big_table[k][(word4 >> (k << 3)) & 0xff]; #if N > 5 crc5 ^= crc_braid_big_table[k][(word5 >> (k << 3)) & 0xff]; #endif #endif #endif #endif #endif } } /* Process the last block, combining the CRCs of the N braids at the same time. */ comb = crc_word_big(crc0 ^ words[0]); #if N > 1 comb = crc_word_big(crc1 ^ words[1] ^ comb); #if N > 2 comb = crc_word_big(crc2 ^ words[2] ^ comb); #if N > 3 comb = crc_word_big(crc3 ^ words[3] ^ comb); #if N > 4 comb = crc_word_big(crc4 ^ words[4] ^ comb); #if N > 5 comb = crc_word_big(crc5 ^ words[5] ^ comb); #endif #endif #endif #endif #endif words += N; crc = byte_swap(comb); } /* Update the pointer to the remaining bytes to process. */ buf = (unsigned char const *)words; } #endif /* W */ /* Complete the computation of the CRC on any remaining bytes. */ while (len >= 8) { len -= 8; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } while (len) { len--; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } /* Return the CRC, post-conditioned. */ return crc ^ 0xffffffff; } #endif unsigned long ZEXPORT crc32(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; uInt len; { return crc32_z(crc, buf, len); } uLong ZEXPORT crc32_combine64(crc1, crc2, len2) uLong crc1; uLong crc2; z_off64_t len2; { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return multmodp(x2nmodp(len2, 3), crc1) ^ crc2; } uLong ZEXPORT crc32_combine(crc1, crc2, len2) uLong crc1; uLong crc2; z_off_t len2; { return crc32_combine64(crc1, crc2, len2); } uLong ZEXPORT crc32_combine_gen64(len2) z_off64_t len2; { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return x2nmodp(len2, 3); } uLong ZEXPORT crc32_combine_gen(len2) z_off_t len2; { return crc32_combine_gen64(len2); } uLong crc32_combine_op(crc1, crc2, op) uLong crc1; uLong crc2; uLong op; { return multmodp(op, crc1) ^ crc2; } int main() { uLong a = 12, b = 17, c = 15, d = 0; d = crc32_combine_op(a, b, c); printf("d=%ld\n", d); ASSERT(686661317, d); return 0; }chibicc-1.0.23.1/test/crc32.h000077500000000000000000022036051505335450300154020ustar00rootroot00000000000000/* crc32.h -- tables for rapid CRC calculation * Generated automatically by crc32.c */ local const z_crc_t FAR crc_table[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; #ifdef W #if W == 8 local const z_word_t FAR crc_big_table[] = { 0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, 0x8def022d00000000}; #else /* W == 4 */ local const z_word_t FAR crc_big_table[] = { 0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, 0x8def022d}; #endif #if N == 1 #if W == 8 local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, 0x264b06e6}, {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, 0x92364a30}, {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, 0xe4c4abcc}, {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, 0xca64c78c}, {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1}, {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed}, {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72}, {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, 0x8def022d00000000}, {0x0000000000000000, 0x41311b1900000000, 0x8262363200000000, 0xc3532d2b00000000, 0x04c56c6400000000, 0x45f4777d00000000, 0x86a75a5600000000, 0xc796414f00000000, 0x088ad9c800000000, 0x49bbc2d100000000, 0x8ae8effa00000000, 0xcbd9f4e300000000, 0x0c4fb5ac00000000, 0x4d7eaeb500000000, 0x8e2d839e00000000, 0xcf1c988700000000, 0x5112c24a00000000, 0x1023d95300000000, 0xd370f47800000000, 0x9241ef6100000000, 0x55d7ae2e00000000, 0x14e6b53700000000, 0xd7b5981c00000000, 0x9684830500000000, 0x59981b8200000000, 0x18a9009b00000000, 0xdbfa2db000000000, 0x9acb36a900000000, 0x5d5d77e600000000, 0x1c6c6cff00000000, 0xdf3f41d400000000, 0x9e0e5acd00000000, 0xa224849500000000, 0xe3159f8c00000000, 0x2046b2a700000000, 0x6177a9be00000000, 0xa6e1e8f100000000, 0xe7d0f3e800000000, 0x2483dec300000000, 0x65b2c5da00000000, 0xaaae5d5d00000000, 0xeb9f464400000000, 0x28cc6b6f00000000, 0x69fd707600000000, 0xae6b313900000000, 0xef5a2a2000000000, 0x2c09070b00000000, 0x6d381c1200000000, 0xf33646df00000000, 0xb2075dc600000000, 0x715470ed00000000, 0x30656bf400000000, 0xf7f32abb00000000, 0xb6c231a200000000, 0x75911c8900000000, 0x34a0079000000000, 0xfbbc9f1700000000, 0xba8d840e00000000, 0x79dea92500000000, 0x38efb23c00000000, 0xff79f37300000000, 0xbe48e86a00000000, 0x7d1bc54100000000, 0x3c2ade5800000000, 0x054f79f000000000, 0x447e62e900000000, 0x872d4fc200000000, 0xc61c54db00000000, 0x018a159400000000, 0x40bb0e8d00000000, 0x83e823a600000000, 0xc2d938bf00000000, 0x0dc5a03800000000, 0x4cf4bb2100000000, 0x8fa7960a00000000, 0xce968d1300000000, 0x0900cc5c00000000, 0x4831d74500000000, 0x8b62fa6e00000000, 0xca53e17700000000, 0x545dbbba00000000, 0x156ca0a300000000, 0xd63f8d8800000000, 0x970e969100000000, 0x5098d7de00000000, 0x11a9ccc700000000, 0xd2fae1ec00000000, 0x93cbfaf500000000, 0x5cd7627200000000, 0x1de6796b00000000, 0xdeb5544000000000, 0x9f844f5900000000, 0x58120e1600000000, 0x1923150f00000000, 0xda70382400000000, 0x9b41233d00000000, 0xa76bfd6500000000, 0xe65ae67c00000000, 0x2509cb5700000000, 0x6438d04e00000000, 0xa3ae910100000000, 0xe29f8a1800000000, 0x21cca73300000000, 0x60fdbc2a00000000, 0xafe124ad00000000, 0xeed03fb400000000, 0x2d83129f00000000, 0x6cb2098600000000, 0xab2448c900000000, 0xea1553d000000000, 0x29467efb00000000, 0x687765e200000000, 0xf6793f2f00000000, 0xb748243600000000, 0x741b091d00000000, 0x352a120400000000, 0xf2bc534b00000000, 0xb38d485200000000, 0x70de657900000000, 0x31ef7e6000000000, 0xfef3e6e700000000, 0xbfc2fdfe00000000, 0x7c91d0d500000000, 0x3da0cbcc00000000, 0xfa368a8300000000, 0xbb07919a00000000, 0x7854bcb100000000, 0x3965a7a800000000, 0x4b98833b00000000, 0x0aa9982200000000, 0xc9fab50900000000, 0x88cbae1000000000, 0x4f5def5f00000000, 0x0e6cf44600000000, 0xcd3fd96d00000000, 0x8c0ec27400000000, 0x43125af300000000, 0x022341ea00000000, 0xc1706cc100000000, 0x804177d800000000, 0x47d7369700000000, 0x06e62d8e00000000, 0xc5b500a500000000, 0x84841bbc00000000, 0x1a8a417100000000, 0x5bbb5a6800000000, 0x98e8774300000000, 0xd9d96c5a00000000, 0x1e4f2d1500000000, 0x5f7e360c00000000, 0x9c2d1b2700000000, 0xdd1c003e00000000, 0x120098b900000000, 0x533183a000000000, 0x9062ae8b00000000, 0xd153b59200000000, 0x16c5f4dd00000000, 0x57f4efc400000000, 0x94a7c2ef00000000, 0xd596d9f600000000, 0xe9bc07ae00000000, 0xa88d1cb700000000, 0x6bde319c00000000, 0x2aef2a8500000000, 0xed796bca00000000, 0xac4870d300000000, 0x6f1b5df800000000, 0x2e2a46e100000000, 0xe136de6600000000, 0xa007c57f00000000, 0x6354e85400000000, 0x2265f34d00000000, 0xe5f3b20200000000, 0xa4c2a91b00000000, 0x6791843000000000, 0x26a09f2900000000, 0xb8aec5e400000000, 0xf99fdefd00000000, 0x3accf3d600000000, 0x7bfde8cf00000000, 0xbc6ba98000000000, 0xfd5ab29900000000, 0x3e099fb200000000, 0x7f3884ab00000000, 0xb0241c2c00000000, 0xf115073500000000, 0x32462a1e00000000, 0x7377310700000000, 0xb4e1704800000000, 0xf5d06b5100000000, 0x3683467a00000000, 0x77b25d6300000000, 0x4ed7facb00000000, 0x0fe6e1d200000000, 0xccb5ccf900000000, 0x8d84d7e000000000, 0x4a1296af00000000, 0x0b238db600000000, 0xc870a09d00000000, 0x8941bb8400000000, 0x465d230300000000, 0x076c381a00000000, 0xc43f153100000000, 0x850e0e2800000000, 0x42984f6700000000, 0x03a9547e00000000, 0xc0fa795500000000, 0x81cb624c00000000, 0x1fc5388100000000, 0x5ef4239800000000, 0x9da70eb300000000, 0xdc9615aa00000000, 0x1b0054e500000000, 0x5a314ffc00000000, 0x996262d700000000, 0xd85379ce00000000, 0x174fe14900000000, 0x567efa5000000000, 0x952dd77b00000000, 0xd41ccc6200000000, 0x138a8d2d00000000, 0x52bb963400000000, 0x91e8bb1f00000000, 0xd0d9a00600000000, 0xecf37e5e00000000, 0xadc2654700000000, 0x6e91486c00000000, 0x2fa0537500000000, 0xe836123a00000000, 0xa907092300000000, 0x6a54240800000000, 0x2b653f1100000000, 0xe479a79600000000, 0xa548bc8f00000000, 0x661b91a400000000, 0x272a8abd00000000, 0xe0bccbf200000000, 0xa18dd0eb00000000, 0x62defdc000000000, 0x23efe6d900000000, 0xbde1bc1400000000, 0xfcd0a70d00000000, 0x3f838a2600000000, 0x7eb2913f00000000, 0xb924d07000000000, 0xf815cb6900000000, 0x3b46e64200000000, 0x7a77fd5b00000000, 0xb56b65dc00000000, 0xf45a7ec500000000, 0x370953ee00000000, 0x763848f700000000, 0xb1ae09b800000000, 0xf09f12a100000000, 0x33cc3f8a00000000, 0x72fd249300000000}, {0x0000000000000000, 0x376ac20100000000, 0x6ed4840300000000, 0x59be460200000000, 0xdca8090700000000, 0xebc2cb0600000000, 0xb27c8d0400000000, 0x85164f0500000000, 0xb851130e00000000, 0x8f3bd10f00000000, 0xd685970d00000000, 0xe1ef550c00000000, 0x64f91a0900000000, 0x5393d80800000000, 0x0a2d9e0a00000000, 0x3d475c0b00000000, 0x70a3261c00000000, 0x47c9e41d00000000, 0x1e77a21f00000000, 0x291d601e00000000, 0xac0b2f1b00000000, 0x9b61ed1a00000000, 0xc2dfab1800000000, 0xf5b5691900000000, 0xc8f2351200000000, 0xff98f71300000000, 0xa626b11100000000, 0x914c731000000000, 0x145a3c1500000000, 0x2330fe1400000000, 0x7a8eb81600000000, 0x4de47a1700000000, 0xe0464d3800000000, 0xd72c8f3900000000, 0x8e92c93b00000000, 0xb9f80b3a00000000, 0x3cee443f00000000, 0x0b84863e00000000, 0x523ac03c00000000, 0x6550023d00000000, 0x58175e3600000000, 0x6f7d9c3700000000, 0x36c3da3500000000, 0x01a9183400000000, 0x84bf573100000000, 0xb3d5953000000000, 0xea6bd33200000000, 0xdd01113300000000, 0x90e56b2400000000, 0xa78fa92500000000, 0xfe31ef2700000000, 0xc95b2d2600000000, 0x4c4d622300000000, 0x7b27a02200000000, 0x2299e62000000000, 0x15f3242100000000, 0x28b4782a00000000, 0x1fdeba2b00000000, 0x4660fc2900000000, 0x710a3e2800000000, 0xf41c712d00000000, 0xc376b32c00000000, 0x9ac8f52e00000000, 0xada2372f00000000, 0xc08d9a7000000000, 0xf7e7587100000000, 0xae591e7300000000, 0x9933dc7200000000, 0x1c25937700000000, 0x2b4f517600000000, 0x72f1177400000000, 0x459bd57500000000, 0x78dc897e00000000, 0x4fb64b7f00000000, 0x16080d7d00000000, 0x2162cf7c00000000, 0xa474807900000000, 0x931e427800000000, 0xcaa0047a00000000, 0xfdcac67b00000000, 0xb02ebc6c00000000, 0x87447e6d00000000, 0xdefa386f00000000, 0xe990fa6e00000000, 0x6c86b56b00000000, 0x5bec776a00000000, 0x0252316800000000, 0x3538f36900000000, 0x087faf6200000000, 0x3f156d6300000000, 0x66ab2b6100000000, 0x51c1e96000000000, 0xd4d7a66500000000, 0xe3bd646400000000, 0xba03226600000000, 0x8d69e06700000000, 0x20cbd74800000000, 0x17a1154900000000, 0x4e1f534b00000000, 0x7975914a00000000, 0xfc63de4f00000000, 0xcb091c4e00000000, 0x92b75a4c00000000, 0xa5dd984d00000000, 0x989ac44600000000, 0xaff0064700000000, 0xf64e404500000000, 0xc124824400000000, 0x4432cd4100000000, 0x73580f4000000000, 0x2ae6494200000000, 0x1d8c8b4300000000, 0x5068f15400000000, 0x6702335500000000, 0x3ebc755700000000, 0x09d6b75600000000, 0x8cc0f85300000000, 0xbbaa3a5200000000, 0xe2147c5000000000, 0xd57ebe5100000000, 0xe839e25a00000000, 0xdf53205b00000000, 0x86ed665900000000, 0xb187a45800000000, 0x3491eb5d00000000, 0x03fb295c00000000, 0x5a456f5e00000000, 0x6d2fad5f00000000, 0x801b35e100000000, 0xb771f7e000000000, 0xeecfb1e200000000, 0xd9a573e300000000, 0x5cb33ce600000000, 0x6bd9fee700000000, 0x3267b8e500000000, 0x050d7ae400000000, 0x384a26ef00000000, 0x0f20e4ee00000000, 0x569ea2ec00000000, 0x61f460ed00000000, 0xe4e22fe800000000, 0xd388ede900000000, 0x8a36abeb00000000, 0xbd5c69ea00000000, 0xf0b813fd00000000, 0xc7d2d1fc00000000, 0x9e6c97fe00000000, 0xa90655ff00000000, 0x2c101afa00000000, 0x1b7ad8fb00000000, 0x42c49ef900000000, 0x75ae5cf800000000, 0x48e900f300000000, 0x7f83c2f200000000, 0x263d84f000000000, 0x115746f100000000, 0x944109f400000000, 0xa32bcbf500000000, 0xfa958df700000000, 0xcdff4ff600000000, 0x605d78d900000000, 0x5737bad800000000, 0x0e89fcda00000000, 0x39e33edb00000000, 0xbcf571de00000000, 0x8b9fb3df00000000, 0xd221f5dd00000000, 0xe54b37dc00000000, 0xd80c6bd700000000, 0xef66a9d600000000, 0xb6d8efd400000000, 0x81b22dd500000000, 0x04a462d000000000, 0x33cea0d100000000, 0x6a70e6d300000000, 0x5d1a24d200000000, 0x10fe5ec500000000, 0x27949cc400000000, 0x7e2adac600000000, 0x494018c700000000, 0xcc5657c200000000, 0xfb3c95c300000000, 0xa282d3c100000000, 0x95e811c000000000, 0xa8af4dcb00000000, 0x9fc58fca00000000, 0xc67bc9c800000000, 0xf1110bc900000000, 0x740744cc00000000, 0x436d86cd00000000, 0x1ad3c0cf00000000, 0x2db902ce00000000, 0x4096af9100000000, 0x77fc6d9000000000, 0x2e422b9200000000, 0x1928e99300000000, 0x9c3ea69600000000, 0xab54649700000000, 0xf2ea229500000000, 0xc580e09400000000, 0xf8c7bc9f00000000, 0xcfad7e9e00000000, 0x9613389c00000000, 0xa179fa9d00000000, 0x246fb59800000000, 0x1305779900000000, 0x4abb319b00000000, 0x7dd1f39a00000000, 0x3035898d00000000, 0x075f4b8c00000000, 0x5ee10d8e00000000, 0x698bcf8f00000000, 0xec9d808a00000000, 0xdbf7428b00000000, 0x8249048900000000, 0xb523c68800000000, 0x88649a8300000000, 0xbf0e588200000000, 0xe6b01e8000000000, 0xd1dadc8100000000, 0x54cc938400000000, 0x63a6518500000000, 0x3a18178700000000, 0x0d72d58600000000, 0xa0d0e2a900000000, 0x97ba20a800000000, 0xce0466aa00000000, 0xf96ea4ab00000000, 0x7c78ebae00000000, 0x4b1229af00000000, 0x12ac6fad00000000, 0x25c6adac00000000, 0x1881f1a700000000, 0x2feb33a600000000, 0x765575a400000000, 0x413fb7a500000000, 0xc429f8a000000000, 0xf3433aa100000000, 0xaafd7ca300000000, 0x9d97bea200000000, 0xd073c4b500000000, 0xe71906b400000000, 0xbea740b600000000, 0x89cd82b700000000, 0x0cdbcdb200000000, 0x3bb10fb300000000, 0x620f49b100000000, 0x55658bb000000000, 0x6822d7bb00000000, 0x5f4815ba00000000, 0x06f653b800000000, 0x319c91b900000000, 0xb48adebc00000000, 0x83e01cbd00000000, 0xda5e5abf00000000, 0xed3498be00000000}, {0x0000000000000000, 0x6567bcb800000000, 0x8bc809aa00000000, 0xeeafb51200000000, 0x5797628f00000000, 0x32f0de3700000000, 0xdc5f6b2500000000, 0xb938d79d00000000, 0xef28b4c500000000, 0x8a4f087d00000000, 0x64e0bd6f00000000, 0x018701d700000000, 0xb8bfd64a00000000, 0xddd86af200000000, 0x3377dfe000000000, 0x5610635800000000, 0x9f57195000000000, 0xfa30a5e800000000, 0x149f10fa00000000, 0x71f8ac4200000000, 0xc8c07bdf00000000, 0xada7c76700000000, 0x4308727500000000, 0x266fcecd00000000, 0x707fad9500000000, 0x1518112d00000000, 0xfbb7a43f00000000, 0x9ed0188700000000, 0x27e8cf1a00000000, 0x428f73a200000000, 0xac20c6b000000000, 0xc9477a0800000000, 0x3eaf32a000000000, 0x5bc88e1800000000, 0xb5673b0a00000000, 0xd00087b200000000, 0x6938502f00000000, 0x0c5fec9700000000, 0xe2f0598500000000, 0x8797e53d00000000, 0xd187866500000000, 0xb4e03add00000000, 0x5a4f8fcf00000000, 0x3f28337700000000, 0x8610e4ea00000000, 0xe377585200000000, 0x0dd8ed4000000000, 0x68bf51f800000000, 0xa1f82bf000000000, 0xc49f974800000000, 0x2a30225a00000000, 0x4f579ee200000000, 0xf66f497f00000000, 0x9308f5c700000000, 0x7da740d500000000, 0x18c0fc6d00000000, 0x4ed09f3500000000, 0x2bb7238d00000000, 0xc518969f00000000, 0xa07f2a2700000000, 0x1947fdba00000000, 0x7c20410200000000, 0x928ff41000000000, 0xf7e848a800000000, 0x3d58149b00000000, 0x583fa82300000000, 0xb6901d3100000000, 0xd3f7a18900000000, 0x6acf761400000000, 0x0fa8caac00000000, 0xe1077fbe00000000, 0x8460c30600000000, 0xd270a05e00000000, 0xb7171ce600000000, 0x59b8a9f400000000, 0x3cdf154c00000000, 0x85e7c2d100000000, 0xe0807e6900000000, 0x0e2fcb7b00000000, 0x6b4877c300000000, 0xa20f0dcb00000000, 0xc768b17300000000, 0x29c7046100000000, 0x4ca0b8d900000000, 0xf5986f4400000000, 0x90ffd3fc00000000, 0x7e5066ee00000000, 0x1b37da5600000000, 0x4d27b90e00000000, 0x284005b600000000, 0xc6efb0a400000000, 0xa3880c1c00000000, 0x1ab0db8100000000, 0x7fd7673900000000, 0x9178d22b00000000, 0xf41f6e9300000000, 0x03f7263b00000000, 0x66909a8300000000, 0x883f2f9100000000, 0xed58932900000000, 0x546044b400000000, 0x3107f80c00000000, 0xdfa84d1e00000000, 0xbacff1a600000000, 0xecdf92fe00000000, 0x89b82e4600000000, 0x67179b5400000000, 0x027027ec00000000, 0xbb48f07100000000, 0xde2f4cc900000000, 0x3080f9db00000000, 0x55e7456300000000, 0x9ca03f6b00000000, 0xf9c783d300000000, 0x176836c100000000, 0x720f8a7900000000, 0xcb375de400000000, 0xae50e15c00000000, 0x40ff544e00000000, 0x2598e8f600000000, 0x73888bae00000000, 0x16ef371600000000, 0xf840820400000000, 0x9d273ebc00000000, 0x241fe92100000000, 0x4178559900000000, 0xafd7e08b00000000, 0xcab05c3300000000, 0x3bb659ed00000000, 0x5ed1e55500000000, 0xb07e504700000000, 0xd519ecff00000000, 0x6c213b6200000000, 0x094687da00000000, 0xe7e932c800000000, 0x828e8e7000000000, 0xd49eed2800000000, 0xb1f9519000000000, 0x5f56e48200000000, 0x3a31583a00000000, 0x83098fa700000000, 0xe66e331f00000000, 0x08c1860d00000000, 0x6da63ab500000000, 0xa4e140bd00000000, 0xc186fc0500000000, 0x2f29491700000000, 0x4a4ef5af00000000, 0xf376223200000000, 0x96119e8a00000000, 0x78be2b9800000000, 0x1dd9972000000000, 0x4bc9f47800000000, 0x2eae48c000000000, 0xc001fdd200000000, 0xa566416a00000000, 0x1c5e96f700000000, 0x79392a4f00000000, 0x97969f5d00000000, 0xf2f123e500000000, 0x05196b4d00000000, 0x607ed7f500000000, 0x8ed162e700000000, 0xebb6de5f00000000, 0x528e09c200000000, 0x37e9b57a00000000, 0xd946006800000000, 0xbc21bcd000000000, 0xea31df8800000000, 0x8f56633000000000, 0x61f9d62200000000, 0x049e6a9a00000000, 0xbda6bd0700000000, 0xd8c101bf00000000, 0x366eb4ad00000000, 0x5309081500000000, 0x9a4e721d00000000, 0xff29cea500000000, 0x11867bb700000000, 0x74e1c70f00000000, 0xcdd9109200000000, 0xa8beac2a00000000, 0x4611193800000000, 0x2376a58000000000, 0x7566c6d800000000, 0x10017a6000000000, 0xfeaecf7200000000, 0x9bc973ca00000000, 0x22f1a45700000000, 0x479618ef00000000, 0xa939adfd00000000, 0xcc5e114500000000, 0x06ee4d7600000000, 0x6389f1ce00000000, 0x8d2644dc00000000, 0xe841f86400000000, 0x51792ff900000000, 0x341e934100000000, 0xdab1265300000000, 0xbfd69aeb00000000, 0xe9c6f9b300000000, 0x8ca1450b00000000, 0x620ef01900000000, 0x07694ca100000000, 0xbe519b3c00000000, 0xdb36278400000000, 0x3599929600000000, 0x50fe2e2e00000000, 0x99b9542600000000, 0xfcdee89e00000000, 0x12715d8c00000000, 0x7716e13400000000, 0xce2e36a900000000, 0xab498a1100000000, 0x45e63f0300000000, 0x208183bb00000000, 0x7691e0e300000000, 0x13f65c5b00000000, 0xfd59e94900000000, 0x983e55f100000000, 0x2106826c00000000, 0x44613ed400000000, 0xaace8bc600000000, 0xcfa9377e00000000, 0x38417fd600000000, 0x5d26c36e00000000, 0xb389767c00000000, 0xd6eecac400000000, 0x6fd61d5900000000, 0x0ab1a1e100000000, 0xe41e14f300000000, 0x8179a84b00000000, 0xd769cb1300000000, 0xb20e77ab00000000, 0x5ca1c2b900000000, 0x39c67e0100000000, 0x80fea99c00000000, 0xe599152400000000, 0x0b36a03600000000, 0x6e511c8e00000000, 0xa716668600000000, 0xc271da3e00000000, 0x2cde6f2c00000000, 0x49b9d39400000000, 0xf081040900000000, 0x95e6b8b100000000, 0x7b490da300000000, 0x1e2eb11b00000000, 0x483ed24300000000, 0x2d596efb00000000, 0xc3f6dbe900000000, 0xa691675100000000, 0x1fa9b0cc00000000, 0x7ace0c7400000000, 0x9461b96600000000, 0xf10605de00000000}, {0x0000000000000000, 0xb029603d00000000, 0x6053c07a00000000, 0xd07aa04700000000, 0xc0a680f500000000, 0x708fe0c800000000, 0xa0f5408f00000000, 0x10dc20b200000000, 0xc14b703000000000, 0x7162100d00000000, 0xa118b04a00000000, 0x1131d07700000000, 0x01edf0c500000000, 0xb1c490f800000000, 0x61be30bf00000000, 0xd197508200000000, 0x8297e06000000000, 0x32be805d00000000, 0xe2c4201a00000000, 0x52ed402700000000, 0x4231609500000000, 0xf21800a800000000, 0x2262a0ef00000000, 0x924bc0d200000000, 0x43dc905000000000, 0xf3f5f06d00000000, 0x238f502a00000000, 0x93a6301700000000, 0x837a10a500000000, 0x3353709800000000, 0xe329d0df00000000, 0x5300b0e200000000, 0x042fc1c100000000, 0xb406a1fc00000000, 0x647c01bb00000000, 0xd455618600000000, 0xc489413400000000, 0x74a0210900000000, 0xa4da814e00000000, 0x14f3e17300000000, 0xc564b1f100000000, 0x754dd1cc00000000, 0xa537718b00000000, 0x151e11b600000000, 0x05c2310400000000, 0xb5eb513900000000, 0x6591f17e00000000, 0xd5b8914300000000, 0x86b821a100000000, 0x3691419c00000000, 0xe6ebe1db00000000, 0x56c281e600000000, 0x461ea15400000000, 0xf637c16900000000, 0x264d612e00000000, 0x9664011300000000, 0x47f3519100000000, 0xf7da31ac00000000, 0x27a091eb00000000, 0x9789f1d600000000, 0x8755d16400000000, 0x377cb15900000000, 0xe706111e00000000, 0x572f712300000000, 0x4958f35800000000, 0xf971936500000000, 0x290b332200000000, 0x9922531f00000000, 0x89fe73ad00000000, 0x39d7139000000000, 0xe9adb3d700000000, 0x5984d3ea00000000, 0x8813836800000000, 0x383ae35500000000, 0xe840431200000000, 0x5869232f00000000, 0x48b5039d00000000, 0xf89c63a000000000, 0x28e6c3e700000000, 0x98cfa3da00000000, 0xcbcf133800000000, 0x7be6730500000000, 0xab9cd34200000000, 0x1bb5b37f00000000, 0x0b6993cd00000000, 0xbb40f3f000000000, 0x6b3a53b700000000, 0xdb13338a00000000, 0x0a84630800000000, 0xbaad033500000000, 0x6ad7a37200000000, 0xdafec34f00000000, 0xca22e3fd00000000, 0x7a0b83c000000000, 0xaa71238700000000, 0x1a5843ba00000000, 0x4d77329900000000, 0xfd5e52a400000000, 0x2d24f2e300000000, 0x9d0d92de00000000, 0x8dd1b26c00000000, 0x3df8d25100000000, 0xed82721600000000, 0x5dab122b00000000, 0x8c3c42a900000000, 0x3c15229400000000, 0xec6f82d300000000, 0x5c46e2ee00000000, 0x4c9ac25c00000000, 0xfcb3a26100000000, 0x2cc9022600000000, 0x9ce0621b00000000, 0xcfe0d2f900000000, 0x7fc9b2c400000000, 0xafb3128300000000, 0x1f9a72be00000000, 0x0f46520c00000000, 0xbf6f323100000000, 0x6f15927600000000, 0xdf3cf24b00000000, 0x0eaba2c900000000, 0xbe82c2f400000000, 0x6ef862b300000000, 0xded1028e00000000, 0xce0d223c00000000, 0x7e24420100000000, 0xae5ee24600000000, 0x1e77827b00000000, 0x92b0e6b100000000, 0x2299868c00000000, 0xf2e326cb00000000, 0x42ca46f600000000, 0x5216664400000000, 0xe23f067900000000, 0x3245a63e00000000, 0x826cc60300000000, 0x53fb968100000000, 0xe3d2f6bc00000000, 0x33a856fb00000000, 0x838136c600000000, 0x935d167400000000, 0x2374764900000000, 0xf30ed60e00000000, 0x4327b63300000000, 0x102706d100000000, 0xa00e66ec00000000, 0x7074c6ab00000000, 0xc05da69600000000, 0xd081862400000000, 0x60a8e61900000000, 0xb0d2465e00000000, 0x00fb266300000000, 0xd16c76e100000000, 0x614516dc00000000, 0xb13fb69b00000000, 0x0116d6a600000000, 0x11caf61400000000, 0xa1e3962900000000, 0x7199366e00000000, 0xc1b0565300000000, 0x969f277000000000, 0x26b6474d00000000, 0xf6cce70a00000000, 0x46e5873700000000, 0x5639a78500000000, 0xe610c7b800000000, 0x366a67ff00000000, 0x864307c200000000, 0x57d4574000000000, 0xe7fd377d00000000, 0x3787973a00000000, 0x87aef70700000000, 0x9772d7b500000000, 0x275bb78800000000, 0xf72117cf00000000, 0x470877f200000000, 0x1408c71000000000, 0xa421a72d00000000, 0x745b076a00000000, 0xc472675700000000, 0xd4ae47e500000000, 0x648727d800000000, 0xb4fd879f00000000, 0x04d4e7a200000000, 0xd543b72000000000, 0x656ad71d00000000, 0xb510775a00000000, 0x0539176700000000, 0x15e537d500000000, 0xa5cc57e800000000, 0x75b6f7af00000000, 0xc59f979200000000, 0xdbe815e900000000, 0x6bc175d400000000, 0xbbbbd59300000000, 0x0b92b5ae00000000, 0x1b4e951c00000000, 0xab67f52100000000, 0x7b1d556600000000, 0xcb34355b00000000, 0x1aa365d900000000, 0xaa8a05e400000000, 0x7af0a5a300000000, 0xcad9c59e00000000, 0xda05e52c00000000, 0x6a2c851100000000, 0xba56255600000000, 0x0a7f456b00000000, 0x597ff58900000000, 0xe95695b400000000, 0x392c35f300000000, 0x890555ce00000000, 0x99d9757c00000000, 0x29f0154100000000, 0xf98ab50600000000, 0x49a3d53b00000000, 0x983485b900000000, 0x281de58400000000, 0xf86745c300000000, 0x484e25fe00000000, 0x5892054c00000000, 0xe8bb657100000000, 0x38c1c53600000000, 0x88e8a50b00000000, 0xdfc7d42800000000, 0x6feeb41500000000, 0xbf94145200000000, 0x0fbd746f00000000, 0x1f6154dd00000000, 0xaf4834e000000000, 0x7f3294a700000000, 0xcf1bf49a00000000, 0x1e8ca41800000000, 0xaea5c42500000000, 0x7edf646200000000, 0xcef6045f00000000, 0xde2a24ed00000000, 0x6e0344d000000000, 0xbe79e49700000000, 0x0e5084aa00000000, 0x5d50344800000000, 0xed79547500000000, 0x3d03f43200000000, 0x8d2a940f00000000, 0x9df6b4bd00000000, 0x2ddfd48000000000, 0xfda574c700000000, 0x4d8c14fa00000000, 0x9c1b447800000000, 0x2c32244500000000, 0xfc48840200000000, 0x4c61e43f00000000, 0x5cbdc48d00000000, 0xec94a4b000000000, 0x3cee04f700000000, 0x8cc764ca00000000}, {0x0000000000000000, 0xa5d35ccb00000000, 0x0ba1c84d00000000, 0xae72948600000000, 0x1642919b00000000, 0xb391cd5000000000, 0x1de359d600000000, 0xb830051d00000000, 0x6d8253ec00000000, 0xc8510f2700000000, 0x66239ba100000000, 0xc3f0c76a00000000, 0x7bc0c27700000000, 0xde139ebc00000000, 0x70610a3a00000000, 0xd5b256f100000000, 0x9b02d60300000000, 0x3ed18ac800000000, 0x90a31e4e00000000, 0x3570428500000000, 0x8d40479800000000, 0x28931b5300000000, 0x86e18fd500000000, 0x2332d31e00000000, 0xf68085ef00000000, 0x5353d92400000000, 0xfd214da200000000, 0x58f2116900000000, 0xe0c2147400000000, 0x451148bf00000000, 0xeb63dc3900000000, 0x4eb080f200000000, 0x3605ac0700000000, 0x93d6f0cc00000000, 0x3da4644a00000000, 0x9877388100000000, 0x20473d9c00000000, 0x8594615700000000, 0x2be6f5d100000000, 0x8e35a91a00000000, 0x5b87ffeb00000000, 0xfe54a32000000000, 0x502637a600000000, 0xf5f56b6d00000000, 0x4dc56e7000000000, 0xe81632bb00000000, 0x4664a63d00000000, 0xe3b7faf600000000, 0xad077a0400000000, 0x08d426cf00000000, 0xa6a6b24900000000, 0x0375ee8200000000, 0xbb45eb9f00000000, 0x1e96b75400000000, 0xb0e423d200000000, 0x15377f1900000000, 0xc08529e800000000, 0x6556752300000000, 0xcb24e1a500000000, 0x6ef7bd6e00000000, 0xd6c7b87300000000, 0x7314e4b800000000, 0xdd66703e00000000, 0x78b52cf500000000, 0x6c0a580f00000000, 0xc9d904c400000000, 0x67ab904200000000, 0xc278cc8900000000, 0x7a48c99400000000, 0xdf9b955f00000000, 0x71e901d900000000, 0xd43a5d1200000000, 0x01880be300000000, 0xa45b572800000000, 0x0a29c3ae00000000, 0xaffa9f6500000000, 0x17ca9a7800000000, 0xb219c6b300000000, 0x1c6b523500000000, 0xb9b80efe00000000, 0xf7088e0c00000000, 0x52dbd2c700000000, 0xfca9464100000000, 0x597a1a8a00000000, 0xe14a1f9700000000, 0x4499435c00000000, 0xeaebd7da00000000, 0x4f388b1100000000, 0x9a8adde000000000, 0x3f59812b00000000, 0x912b15ad00000000, 0x34f8496600000000, 0x8cc84c7b00000000, 0x291b10b000000000, 0x8769843600000000, 0x22bad8fd00000000, 0x5a0ff40800000000, 0xffdca8c300000000, 0x51ae3c4500000000, 0xf47d608e00000000, 0x4c4d659300000000, 0xe99e395800000000, 0x47ecadde00000000, 0xe23ff11500000000, 0x378da7e400000000, 0x925efb2f00000000, 0x3c2c6fa900000000, 0x99ff336200000000, 0x21cf367f00000000, 0x841c6ab400000000, 0x2a6efe3200000000, 0x8fbda2f900000000, 0xc10d220b00000000, 0x64de7ec000000000, 0xcaacea4600000000, 0x6f7fb68d00000000, 0xd74fb39000000000, 0x729cef5b00000000, 0xdcee7bdd00000000, 0x793d271600000000, 0xac8f71e700000000, 0x095c2d2c00000000, 0xa72eb9aa00000000, 0x02fde56100000000, 0xbacde07c00000000, 0x1f1ebcb700000000, 0xb16c283100000000, 0x14bf74fa00000000, 0xd814b01e00000000, 0x7dc7ecd500000000, 0xd3b5785300000000, 0x7666249800000000, 0xce56218500000000, 0x6b857d4e00000000, 0xc5f7e9c800000000, 0x6024b50300000000, 0xb596e3f200000000, 0x1045bf3900000000, 0xbe372bbf00000000, 0x1be4777400000000, 0xa3d4726900000000, 0x06072ea200000000, 0xa875ba2400000000, 0x0da6e6ef00000000, 0x4316661d00000000, 0xe6c53ad600000000, 0x48b7ae5000000000, 0xed64f29b00000000, 0x5554f78600000000, 0xf087ab4d00000000, 0x5ef53fcb00000000, 0xfb26630000000000, 0x2e9435f100000000, 0x8b47693a00000000, 0x2535fdbc00000000, 0x80e6a17700000000, 0x38d6a46a00000000, 0x9d05f8a100000000, 0x33776c2700000000, 0x96a430ec00000000, 0xee111c1900000000, 0x4bc240d200000000, 0xe5b0d45400000000, 0x4063889f00000000, 0xf8538d8200000000, 0x5d80d14900000000, 0xf3f245cf00000000, 0x5621190400000000, 0x83934ff500000000, 0x2640133e00000000, 0x883287b800000000, 0x2de1db7300000000, 0x95d1de6e00000000, 0x300282a500000000, 0x9e70162300000000, 0x3ba34ae800000000, 0x7513ca1a00000000, 0xd0c096d100000000, 0x7eb2025700000000, 0xdb615e9c00000000, 0x63515b8100000000, 0xc682074a00000000, 0x68f093cc00000000, 0xcd23cf0700000000, 0x189199f600000000, 0xbd42c53d00000000, 0x133051bb00000000, 0xb6e30d7000000000, 0x0ed3086d00000000, 0xab0054a600000000, 0x0572c02000000000, 0xa0a19ceb00000000, 0xb41ee81100000000, 0x11cdb4da00000000, 0xbfbf205c00000000, 0x1a6c7c9700000000, 0xa25c798a00000000, 0x078f254100000000, 0xa9fdb1c700000000, 0x0c2eed0c00000000, 0xd99cbbfd00000000, 0x7c4fe73600000000, 0xd23d73b000000000, 0x77ee2f7b00000000, 0xcfde2a6600000000, 0x6a0d76ad00000000, 0xc47fe22b00000000, 0x61acbee000000000, 0x2f1c3e1200000000, 0x8acf62d900000000, 0x24bdf65f00000000, 0x816eaa9400000000, 0x395eaf8900000000, 0x9c8df34200000000, 0x32ff67c400000000, 0x972c3b0f00000000, 0x429e6dfe00000000, 0xe74d313500000000, 0x493fa5b300000000, 0xececf97800000000, 0x54dcfc6500000000, 0xf10fa0ae00000000, 0x5f7d342800000000, 0xfaae68e300000000, 0x821b441600000000, 0x27c818dd00000000, 0x89ba8c5b00000000, 0x2c69d09000000000, 0x9459d58d00000000, 0x318a894600000000, 0x9ff81dc000000000, 0x3a2b410b00000000, 0xef9917fa00000000, 0x4a4a4b3100000000, 0xe438dfb700000000, 0x41eb837c00000000, 0xf9db866100000000, 0x5c08daaa00000000, 0xf27a4e2c00000000, 0x57a912e700000000, 0x1919921500000000, 0xbccacede00000000, 0x12b85a5800000000, 0xb76b069300000000, 0x0f5b038e00000000, 0xaa885f4500000000, 0x04facbc300000000, 0xa129970800000000, 0x749bc1f900000000, 0xd1489d3200000000, 0x7f3a09b400000000, 0xdae9557f00000000, 0x62d9506200000000, 0xc70a0ca900000000, 0x6978982f00000000, 0xccabc4e400000000}, {0x0000000000000000, 0xb40b77a600000000, 0x29119f9700000000, 0x9d1ae83100000000, 0x13244ff400000000, 0xa72f385200000000, 0x3a35d06300000000, 0x8e3ea7c500000000, 0x674eef3300000000, 0xd345989500000000, 0x4e5f70a400000000, 0xfa54070200000000, 0x746aa0c700000000, 0xc061d76100000000, 0x5d7b3f5000000000, 0xe97048f600000000, 0xce9cde6700000000, 0x7a97a9c100000000, 0xe78d41f000000000, 0x5386365600000000, 0xddb8919300000000, 0x69b3e63500000000, 0xf4a90e0400000000, 0x40a279a200000000, 0xa9d2315400000000, 0x1dd946f200000000, 0x80c3aec300000000, 0x34c8d96500000000, 0xbaf67ea000000000, 0x0efd090600000000, 0x93e7e13700000000, 0x27ec969100000000, 0x9c39bdcf00000000, 0x2832ca6900000000, 0xb528225800000000, 0x012355fe00000000, 0x8f1df23b00000000, 0x3b16859d00000000, 0xa60c6dac00000000, 0x12071a0a00000000, 0xfb7752fc00000000, 0x4f7c255a00000000, 0xd266cd6b00000000, 0x666dbacd00000000, 0xe8531d0800000000, 0x5c586aae00000000, 0xc142829f00000000, 0x7549f53900000000, 0x52a563a800000000, 0xe6ae140e00000000, 0x7bb4fc3f00000000, 0xcfbf8b9900000000, 0x41812c5c00000000, 0xf58a5bfa00000000, 0x6890b3cb00000000, 0xdc9bc46d00000000, 0x35eb8c9b00000000, 0x81e0fb3d00000000, 0x1cfa130c00000000, 0xa8f164aa00000000, 0x26cfc36f00000000, 0x92c4b4c900000000, 0x0fde5cf800000000, 0xbbd52b5e00000000, 0x79750b4400000000, 0xcd7e7ce200000000, 0x506494d300000000, 0xe46fe37500000000, 0x6a5144b000000000, 0xde5a331600000000, 0x4340db2700000000, 0xf74bac8100000000, 0x1e3be47700000000, 0xaa3093d100000000, 0x372a7be000000000, 0x83210c4600000000, 0x0d1fab8300000000, 0xb914dc2500000000, 0x240e341400000000, 0x900543b200000000, 0xb7e9d52300000000, 0x03e2a28500000000, 0x9ef84ab400000000, 0x2af33d1200000000, 0xa4cd9ad700000000, 0x10c6ed7100000000, 0x8ddc054000000000, 0x39d772e600000000, 0xd0a73a1000000000, 0x64ac4db600000000, 0xf9b6a58700000000, 0x4dbdd22100000000, 0xc38375e400000000, 0x7788024200000000, 0xea92ea7300000000, 0x5e999dd500000000, 0xe54cb68b00000000, 0x5147c12d00000000, 0xcc5d291c00000000, 0x78565eba00000000, 0xf668f97f00000000, 0x42638ed900000000, 0xdf7966e800000000, 0x6b72114e00000000, 0x820259b800000000, 0x36092e1e00000000, 0xab13c62f00000000, 0x1f18b18900000000, 0x9126164c00000000, 0x252d61ea00000000, 0xb83789db00000000, 0x0c3cfe7d00000000, 0x2bd068ec00000000, 0x9fdb1f4a00000000, 0x02c1f77b00000000, 0xb6ca80dd00000000, 0x38f4271800000000, 0x8cff50be00000000, 0x11e5b88f00000000, 0xa5eecf2900000000, 0x4c9e87df00000000, 0xf895f07900000000, 0x658f184800000000, 0xd1846fee00000000, 0x5fbac82b00000000, 0xebb1bf8d00000000, 0x76ab57bc00000000, 0xc2a0201a00000000, 0xf2ea168800000000, 0x46e1612e00000000, 0xdbfb891f00000000, 0x6ff0feb900000000, 0xe1ce597c00000000, 0x55c52eda00000000, 0xc8dfc6eb00000000, 0x7cd4b14d00000000, 0x95a4f9bb00000000, 0x21af8e1d00000000, 0xbcb5662c00000000, 0x08be118a00000000, 0x8680b64f00000000, 0x328bc1e900000000, 0xaf9129d800000000, 0x1b9a5e7e00000000, 0x3c76c8ef00000000, 0x887dbf4900000000, 0x1567577800000000, 0xa16c20de00000000, 0x2f52871b00000000, 0x9b59f0bd00000000, 0x0643188c00000000, 0xb2486f2a00000000, 0x5b3827dc00000000, 0xef33507a00000000, 0x7229b84b00000000, 0xc622cfed00000000, 0x481c682800000000, 0xfc171f8e00000000, 0x610df7bf00000000, 0xd506801900000000, 0x6ed3ab4700000000, 0xdad8dce100000000, 0x47c234d000000000, 0xf3c9437600000000, 0x7df7e4b300000000, 0xc9fc931500000000, 0x54e67b2400000000, 0xe0ed0c8200000000, 0x099d447400000000, 0xbd9633d200000000, 0x208cdbe300000000, 0x9487ac4500000000, 0x1ab90b8000000000, 0xaeb27c2600000000, 0x33a8941700000000, 0x87a3e3b100000000, 0xa04f752000000000, 0x1444028600000000, 0x895eeab700000000, 0x3d559d1100000000, 0xb36b3ad400000000, 0x07604d7200000000, 0x9a7aa54300000000, 0x2e71d2e500000000, 0xc7019a1300000000, 0x730aedb500000000, 0xee10058400000000, 0x5a1b722200000000, 0xd425d5e700000000, 0x602ea24100000000, 0xfd344a7000000000, 0x493f3dd600000000, 0x8b9f1dcc00000000, 0x3f946a6a00000000, 0xa28e825b00000000, 0x1685f5fd00000000, 0x98bb523800000000, 0x2cb0259e00000000, 0xb1aacdaf00000000, 0x05a1ba0900000000, 0xecd1f2ff00000000, 0x58da855900000000, 0xc5c06d6800000000, 0x71cb1ace00000000, 0xfff5bd0b00000000, 0x4bfecaad00000000, 0xd6e4229c00000000, 0x62ef553a00000000, 0x4503c3ab00000000, 0xf108b40d00000000, 0x6c125c3c00000000, 0xd8192b9a00000000, 0x56278c5f00000000, 0xe22cfbf900000000, 0x7f3613c800000000, 0xcb3d646e00000000, 0x224d2c9800000000, 0x96465b3e00000000, 0x0b5cb30f00000000, 0xbf57c4a900000000, 0x3169636c00000000, 0x856214ca00000000, 0x1878fcfb00000000, 0xac738b5d00000000, 0x17a6a00300000000, 0xa3add7a500000000, 0x3eb73f9400000000, 0x8abc483200000000, 0x0482eff700000000, 0xb089985100000000, 0x2d93706000000000, 0x999807c600000000, 0x70e84f3000000000, 0xc4e3389600000000, 0x59f9d0a700000000, 0xedf2a70100000000, 0x63cc00c400000000, 0xd7c7776200000000, 0x4add9f5300000000, 0xfed6e8f500000000, 0xd93a7e6400000000, 0x6d3109c200000000, 0xf02be1f300000000, 0x4420965500000000, 0xca1e319000000000, 0x7e15463600000000, 0xe30fae0700000000, 0x5704d9a100000000, 0xbe74915700000000, 0x0a7fe6f100000000, 0x97650ec000000000, 0x236e796600000000, 0xad50dea300000000, 0x195ba90500000000, 0x8441413400000000, 0x304a369200000000}, {0x0000000000000000, 0x9e00aacc00000000, 0x7d07254200000000, 0xe3078f8e00000000, 0xfa0e4a8400000000, 0x640ee04800000000, 0x87096fc600000000, 0x1909c50a00000000, 0xb51be5d300000000, 0x2b1b4f1f00000000, 0xc81cc09100000000, 0x561c6a5d00000000, 0x4f15af5700000000, 0xd115059b00000000, 0x32128a1500000000, 0xac1220d900000000, 0x2b31bb7c00000000, 0xb53111b000000000, 0x56369e3e00000000, 0xc83634f200000000, 0xd13ff1f800000000, 0x4f3f5b3400000000, 0xac38d4ba00000000, 0x32387e7600000000, 0x9e2a5eaf00000000, 0x002af46300000000, 0xe32d7bed00000000, 0x7d2dd12100000000, 0x6424142b00000000, 0xfa24bee700000000, 0x1923316900000000, 0x87239ba500000000, 0x566276f900000000, 0xc862dc3500000000, 0x2b6553bb00000000, 0xb565f97700000000, 0xac6c3c7d00000000, 0x326c96b100000000, 0xd16b193f00000000, 0x4f6bb3f300000000, 0xe379932a00000000, 0x7d7939e600000000, 0x9e7eb66800000000, 0x007e1ca400000000, 0x1977d9ae00000000, 0x8777736200000000, 0x6470fcec00000000, 0xfa70562000000000, 0x7d53cd8500000000, 0xe353674900000000, 0x0054e8c700000000, 0x9e54420b00000000, 0x875d870100000000, 0x195d2dcd00000000, 0xfa5aa24300000000, 0x645a088f00000000, 0xc848285600000000, 0x5648829a00000000, 0xb54f0d1400000000, 0x2b4fa7d800000000, 0x324662d200000000, 0xac46c81e00000000, 0x4f41479000000000, 0xd141ed5c00000000, 0xedc29d2900000000, 0x73c237e500000000, 0x90c5b86b00000000, 0x0ec512a700000000, 0x17ccd7ad00000000, 0x89cc7d6100000000, 0x6acbf2ef00000000, 0xf4cb582300000000, 0x58d978fa00000000, 0xc6d9d23600000000, 0x25de5db800000000, 0xbbdef77400000000, 0xa2d7327e00000000, 0x3cd798b200000000, 0xdfd0173c00000000, 0x41d0bdf000000000, 0xc6f3265500000000, 0x58f38c9900000000, 0xbbf4031700000000, 0x25f4a9db00000000, 0x3cfd6cd100000000, 0xa2fdc61d00000000, 0x41fa499300000000, 0xdffae35f00000000, 0x73e8c38600000000, 0xede8694a00000000, 0x0eefe6c400000000, 0x90ef4c0800000000, 0x89e6890200000000, 0x17e623ce00000000, 0xf4e1ac4000000000, 0x6ae1068c00000000, 0xbba0ebd000000000, 0x25a0411c00000000, 0xc6a7ce9200000000, 0x58a7645e00000000, 0x41aea15400000000, 0xdfae0b9800000000, 0x3ca9841600000000, 0xa2a92eda00000000, 0x0ebb0e0300000000, 0x90bba4cf00000000, 0x73bc2b4100000000, 0xedbc818d00000000, 0xf4b5448700000000, 0x6ab5ee4b00000000, 0x89b261c500000000, 0x17b2cb0900000000, 0x909150ac00000000, 0x0e91fa6000000000, 0xed9675ee00000000, 0x7396df2200000000, 0x6a9f1a2800000000, 0xf49fb0e400000000, 0x17983f6a00000000, 0x899895a600000000, 0x258ab57f00000000, 0xbb8a1fb300000000, 0x588d903d00000000, 0xc68d3af100000000, 0xdf84fffb00000000, 0x4184553700000000, 0xa283dab900000000, 0x3c83707500000000, 0xda853b5300000000, 0x4485919f00000000, 0xa7821e1100000000, 0x3982b4dd00000000, 0x208b71d700000000, 0xbe8bdb1b00000000, 0x5d8c549500000000, 0xc38cfe5900000000, 0x6f9ede8000000000, 0xf19e744c00000000, 0x1299fbc200000000, 0x8c99510e00000000, 0x9590940400000000, 0x0b903ec800000000, 0xe897b14600000000, 0x76971b8a00000000, 0xf1b4802f00000000, 0x6fb42ae300000000, 0x8cb3a56d00000000, 0x12b30fa100000000, 0x0bbacaab00000000, 0x95ba606700000000, 0x76bdefe900000000, 0xe8bd452500000000, 0x44af65fc00000000, 0xdaafcf3000000000, 0x39a840be00000000, 0xa7a8ea7200000000, 0xbea12f7800000000, 0x20a185b400000000, 0xc3a60a3a00000000, 0x5da6a0f600000000, 0x8ce74daa00000000, 0x12e7e76600000000, 0xf1e068e800000000, 0x6fe0c22400000000, 0x76e9072e00000000, 0xe8e9ade200000000, 0x0bee226c00000000, 0x95ee88a000000000, 0x39fca87900000000, 0xa7fc02b500000000, 0x44fb8d3b00000000, 0xdafb27f700000000, 0xc3f2e2fd00000000, 0x5df2483100000000, 0xbef5c7bf00000000, 0x20f56d7300000000, 0xa7d6f6d600000000, 0x39d65c1a00000000, 0xdad1d39400000000, 0x44d1795800000000, 0x5dd8bc5200000000, 0xc3d8169e00000000, 0x20df991000000000, 0xbedf33dc00000000, 0x12cd130500000000, 0x8ccdb9c900000000, 0x6fca364700000000, 0xf1ca9c8b00000000, 0xe8c3598100000000, 0x76c3f34d00000000, 0x95c47cc300000000, 0x0bc4d60f00000000, 0x3747a67a00000000, 0xa9470cb600000000, 0x4a40833800000000, 0xd44029f400000000, 0xcd49ecfe00000000, 0x5349463200000000, 0xb04ec9bc00000000, 0x2e4e637000000000, 0x825c43a900000000, 0x1c5ce96500000000, 0xff5b66eb00000000, 0x615bcc2700000000, 0x7852092d00000000, 0xe652a3e100000000, 0x05552c6f00000000, 0x9b5586a300000000, 0x1c761d0600000000, 0x8276b7ca00000000, 0x6171384400000000, 0xff71928800000000, 0xe678578200000000, 0x7878fd4e00000000, 0x9b7f72c000000000, 0x057fd80c00000000, 0xa96df8d500000000, 0x376d521900000000, 0xd46add9700000000, 0x4a6a775b00000000, 0x5363b25100000000, 0xcd63189d00000000, 0x2e64971300000000, 0xb0643ddf00000000, 0x6125d08300000000, 0xff257a4f00000000, 0x1c22f5c100000000, 0x82225f0d00000000, 0x9b2b9a0700000000, 0x052b30cb00000000, 0xe62cbf4500000000, 0x782c158900000000, 0xd43e355000000000, 0x4a3e9f9c00000000, 0xa939101200000000, 0x3739bade00000000, 0x2e307fd400000000, 0xb030d51800000000, 0x53375a9600000000, 0xcd37f05a00000000, 0x4a146bff00000000, 0xd414c13300000000, 0x37134ebd00000000, 0xa913e47100000000, 0xb01a217b00000000, 0x2e1a8bb700000000, 0xcd1d043900000000, 0x531daef500000000, 0xff0f8e2c00000000, 0x610f24e000000000, 0x8208ab6e00000000, 0x1c0801a200000000, 0x0501c4a800000000, 0x9b016e6400000000, 0x7806e1ea00000000, 0xe6064b2600000000}}; #else /* W == 4 */ local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1}, {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed}, {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72}, {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, 0x8def022d}, {0x00000000, 0x41311b19, 0x82623632, 0xc3532d2b, 0x04c56c64, 0x45f4777d, 0x86a75a56, 0xc796414f, 0x088ad9c8, 0x49bbc2d1, 0x8ae8effa, 0xcbd9f4e3, 0x0c4fb5ac, 0x4d7eaeb5, 0x8e2d839e, 0xcf1c9887, 0x5112c24a, 0x1023d953, 0xd370f478, 0x9241ef61, 0x55d7ae2e, 0x14e6b537, 0xd7b5981c, 0x96848305, 0x59981b82, 0x18a9009b, 0xdbfa2db0, 0x9acb36a9, 0x5d5d77e6, 0x1c6c6cff, 0xdf3f41d4, 0x9e0e5acd, 0xa2248495, 0xe3159f8c, 0x2046b2a7, 0x6177a9be, 0xa6e1e8f1, 0xe7d0f3e8, 0x2483dec3, 0x65b2c5da, 0xaaae5d5d, 0xeb9f4644, 0x28cc6b6f, 0x69fd7076, 0xae6b3139, 0xef5a2a20, 0x2c09070b, 0x6d381c12, 0xf33646df, 0xb2075dc6, 0x715470ed, 0x30656bf4, 0xf7f32abb, 0xb6c231a2, 0x75911c89, 0x34a00790, 0xfbbc9f17, 0xba8d840e, 0x79dea925, 0x38efb23c, 0xff79f373, 0xbe48e86a, 0x7d1bc541, 0x3c2ade58, 0x054f79f0, 0x447e62e9, 0x872d4fc2, 0xc61c54db, 0x018a1594, 0x40bb0e8d, 0x83e823a6, 0xc2d938bf, 0x0dc5a038, 0x4cf4bb21, 0x8fa7960a, 0xce968d13, 0x0900cc5c, 0x4831d745, 0x8b62fa6e, 0xca53e177, 0x545dbbba, 0x156ca0a3, 0xd63f8d88, 0x970e9691, 0x5098d7de, 0x11a9ccc7, 0xd2fae1ec, 0x93cbfaf5, 0x5cd76272, 0x1de6796b, 0xdeb55440, 0x9f844f59, 0x58120e16, 0x1923150f, 0xda703824, 0x9b41233d, 0xa76bfd65, 0xe65ae67c, 0x2509cb57, 0x6438d04e, 0xa3ae9101, 0xe29f8a18, 0x21cca733, 0x60fdbc2a, 0xafe124ad, 0xeed03fb4, 0x2d83129f, 0x6cb20986, 0xab2448c9, 0xea1553d0, 0x29467efb, 0x687765e2, 0xf6793f2f, 0xb7482436, 0x741b091d, 0x352a1204, 0xf2bc534b, 0xb38d4852, 0x70de6579, 0x31ef7e60, 0xfef3e6e7, 0xbfc2fdfe, 0x7c91d0d5, 0x3da0cbcc, 0xfa368a83, 0xbb07919a, 0x7854bcb1, 0x3965a7a8, 0x4b98833b, 0x0aa99822, 0xc9fab509, 0x88cbae10, 0x4f5def5f, 0x0e6cf446, 0xcd3fd96d, 0x8c0ec274, 0x43125af3, 0x022341ea, 0xc1706cc1, 0x804177d8, 0x47d73697, 0x06e62d8e, 0xc5b500a5, 0x84841bbc, 0x1a8a4171, 0x5bbb5a68, 0x98e87743, 0xd9d96c5a, 0x1e4f2d15, 0x5f7e360c, 0x9c2d1b27, 0xdd1c003e, 0x120098b9, 0x533183a0, 0x9062ae8b, 0xd153b592, 0x16c5f4dd, 0x57f4efc4, 0x94a7c2ef, 0xd596d9f6, 0xe9bc07ae, 0xa88d1cb7, 0x6bde319c, 0x2aef2a85, 0xed796bca, 0xac4870d3, 0x6f1b5df8, 0x2e2a46e1, 0xe136de66, 0xa007c57f, 0x6354e854, 0x2265f34d, 0xe5f3b202, 0xa4c2a91b, 0x67918430, 0x26a09f29, 0xb8aec5e4, 0xf99fdefd, 0x3accf3d6, 0x7bfde8cf, 0xbc6ba980, 0xfd5ab299, 0x3e099fb2, 0x7f3884ab, 0xb0241c2c, 0xf1150735, 0x32462a1e, 0x73773107, 0xb4e17048, 0xf5d06b51, 0x3683467a, 0x77b25d63, 0x4ed7facb, 0x0fe6e1d2, 0xccb5ccf9, 0x8d84d7e0, 0x4a1296af, 0x0b238db6, 0xc870a09d, 0x8941bb84, 0x465d2303, 0x076c381a, 0xc43f1531, 0x850e0e28, 0x42984f67, 0x03a9547e, 0xc0fa7955, 0x81cb624c, 0x1fc53881, 0x5ef42398, 0x9da70eb3, 0xdc9615aa, 0x1b0054e5, 0x5a314ffc, 0x996262d7, 0xd85379ce, 0x174fe149, 0x567efa50, 0x952dd77b, 0xd41ccc62, 0x138a8d2d, 0x52bb9634, 0x91e8bb1f, 0xd0d9a006, 0xecf37e5e, 0xadc26547, 0x6e91486c, 0x2fa05375, 0xe836123a, 0xa9070923, 0x6a542408, 0x2b653f11, 0xe479a796, 0xa548bc8f, 0x661b91a4, 0x272a8abd, 0xe0bccbf2, 0xa18dd0eb, 0x62defdc0, 0x23efe6d9, 0xbde1bc14, 0xfcd0a70d, 0x3f838a26, 0x7eb2913f, 0xb924d070, 0xf815cb69, 0x3b46e642, 0x7a77fd5b, 0xb56b65dc, 0xf45a7ec5, 0x370953ee, 0x763848f7, 0xb1ae09b8, 0xf09f12a1, 0x33cc3f8a, 0x72fd2493}, {0x00000000, 0x376ac201, 0x6ed48403, 0x59be4602, 0xdca80907, 0xebc2cb06, 0xb27c8d04, 0x85164f05, 0xb851130e, 0x8f3bd10f, 0xd685970d, 0xe1ef550c, 0x64f91a09, 0x5393d808, 0x0a2d9e0a, 0x3d475c0b, 0x70a3261c, 0x47c9e41d, 0x1e77a21f, 0x291d601e, 0xac0b2f1b, 0x9b61ed1a, 0xc2dfab18, 0xf5b56919, 0xc8f23512, 0xff98f713, 0xa626b111, 0x914c7310, 0x145a3c15, 0x2330fe14, 0x7a8eb816, 0x4de47a17, 0xe0464d38, 0xd72c8f39, 0x8e92c93b, 0xb9f80b3a, 0x3cee443f, 0x0b84863e, 0x523ac03c, 0x6550023d, 0x58175e36, 0x6f7d9c37, 0x36c3da35, 0x01a91834, 0x84bf5731, 0xb3d59530, 0xea6bd332, 0xdd011133, 0x90e56b24, 0xa78fa925, 0xfe31ef27, 0xc95b2d26, 0x4c4d6223, 0x7b27a022, 0x2299e620, 0x15f32421, 0x28b4782a, 0x1fdeba2b, 0x4660fc29, 0x710a3e28, 0xf41c712d, 0xc376b32c, 0x9ac8f52e, 0xada2372f, 0xc08d9a70, 0xf7e75871, 0xae591e73, 0x9933dc72, 0x1c259377, 0x2b4f5176, 0x72f11774, 0x459bd575, 0x78dc897e, 0x4fb64b7f, 0x16080d7d, 0x2162cf7c, 0xa4748079, 0x931e4278, 0xcaa0047a, 0xfdcac67b, 0xb02ebc6c, 0x87447e6d, 0xdefa386f, 0xe990fa6e, 0x6c86b56b, 0x5bec776a, 0x02523168, 0x3538f369, 0x087faf62, 0x3f156d63, 0x66ab2b61, 0x51c1e960, 0xd4d7a665, 0xe3bd6464, 0xba032266, 0x8d69e067, 0x20cbd748, 0x17a11549, 0x4e1f534b, 0x7975914a, 0xfc63de4f, 0xcb091c4e, 0x92b75a4c, 0xa5dd984d, 0x989ac446, 0xaff00647, 0xf64e4045, 0xc1248244, 0x4432cd41, 0x73580f40, 0x2ae64942, 0x1d8c8b43, 0x5068f154, 0x67023355, 0x3ebc7557, 0x09d6b756, 0x8cc0f853, 0xbbaa3a52, 0xe2147c50, 0xd57ebe51, 0xe839e25a, 0xdf53205b, 0x86ed6659, 0xb187a458, 0x3491eb5d, 0x03fb295c, 0x5a456f5e, 0x6d2fad5f, 0x801b35e1, 0xb771f7e0, 0xeecfb1e2, 0xd9a573e3, 0x5cb33ce6, 0x6bd9fee7, 0x3267b8e5, 0x050d7ae4, 0x384a26ef, 0x0f20e4ee, 0x569ea2ec, 0x61f460ed, 0xe4e22fe8, 0xd388ede9, 0x8a36abeb, 0xbd5c69ea, 0xf0b813fd, 0xc7d2d1fc, 0x9e6c97fe, 0xa90655ff, 0x2c101afa, 0x1b7ad8fb, 0x42c49ef9, 0x75ae5cf8, 0x48e900f3, 0x7f83c2f2, 0x263d84f0, 0x115746f1, 0x944109f4, 0xa32bcbf5, 0xfa958df7, 0xcdff4ff6, 0x605d78d9, 0x5737bad8, 0x0e89fcda, 0x39e33edb, 0xbcf571de, 0x8b9fb3df, 0xd221f5dd, 0xe54b37dc, 0xd80c6bd7, 0xef66a9d6, 0xb6d8efd4, 0x81b22dd5, 0x04a462d0, 0x33cea0d1, 0x6a70e6d3, 0x5d1a24d2, 0x10fe5ec5, 0x27949cc4, 0x7e2adac6, 0x494018c7, 0xcc5657c2, 0xfb3c95c3, 0xa282d3c1, 0x95e811c0, 0xa8af4dcb, 0x9fc58fca, 0xc67bc9c8, 0xf1110bc9, 0x740744cc, 0x436d86cd, 0x1ad3c0cf, 0x2db902ce, 0x4096af91, 0x77fc6d90, 0x2e422b92, 0x1928e993, 0x9c3ea696, 0xab546497, 0xf2ea2295, 0xc580e094, 0xf8c7bc9f, 0xcfad7e9e, 0x9613389c, 0xa179fa9d, 0x246fb598, 0x13057799, 0x4abb319b, 0x7dd1f39a, 0x3035898d, 0x075f4b8c, 0x5ee10d8e, 0x698bcf8f, 0xec9d808a, 0xdbf7428b, 0x82490489, 0xb523c688, 0x88649a83, 0xbf0e5882, 0xe6b01e80, 0xd1dadc81, 0x54cc9384, 0x63a65185, 0x3a181787, 0x0d72d586, 0xa0d0e2a9, 0x97ba20a8, 0xce0466aa, 0xf96ea4ab, 0x7c78ebae, 0x4b1229af, 0x12ac6fad, 0x25c6adac, 0x1881f1a7, 0x2feb33a6, 0x765575a4, 0x413fb7a5, 0xc429f8a0, 0xf3433aa1, 0xaafd7ca3, 0x9d97bea2, 0xd073c4b5, 0xe71906b4, 0xbea740b6, 0x89cd82b7, 0x0cdbcdb2, 0x3bb10fb3, 0x620f49b1, 0x55658bb0, 0x6822d7bb, 0x5f4815ba, 0x06f653b8, 0x319c91b9, 0xb48adebc, 0x83e01cbd, 0xda5e5abf, 0xed3498be}, {0x00000000, 0x6567bcb8, 0x8bc809aa, 0xeeafb512, 0x5797628f, 0x32f0de37, 0xdc5f6b25, 0xb938d79d, 0xef28b4c5, 0x8a4f087d, 0x64e0bd6f, 0x018701d7, 0xb8bfd64a, 0xddd86af2, 0x3377dfe0, 0x56106358, 0x9f571950, 0xfa30a5e8, 0x149f10fa, 0x71f8ac42, 0xc8c07bdf, 0xada7c767, 0x43087275, 0x266fcecd, 0x707fad95, 0x1518112d, 0xfbb7a43f, 0x9ed01887, 0x27e8cf1a, 0x428f73a2, 0xac20c6b0, 0xc9477a08, 0x3eaf32a0, 0x5bc88e18, 0xb5673b0a, 0xd00087b2, 0x6938502f, 0x0c5fec97, 0xe2f05985, 0x8797e53d, 0xd1878665, 0xb4e03add, 0x5a4f8fcf, 0x3f283377, 0x8610e4ea, 0xe3775852, 0x0dd8ed40, 0x68bf51f8, 0xa1f82bf0, 0xc49f9748, 0x2a30225a, 0x4f579ee2, 0xf66f497f, 0x9308f5c7, 0x7da740d5, 0x18c0fc6d, 0x4ed09f35, 0x2bb7238d, 0xc518969f, 0xa07f2a27, 0x1947fdba, 0x7c204102, 0x928ff410, 0xf7e848a8, 0x3d58149b, 0x583fa823, 0xb6901d31, 0xd3f7a189, 0x6acf7614, 0x0fa8caac, 0xe1077fbe, 0x8460c306, 0xd270a05e, 0xb7171ce6, 0x59b8a9f4, 0x3cdf154c, 0x85e7c2d1, 0xe0807e69, 0x0e2fcb7b, 0x6b4877c3, 0xa20f0dcb, 0xc768b173, 0x29c70461, 0x4ca0b8d9, 0xf5986f44, 0x90ffd3fc, 0x7e5066ee, 0x1b37da56, 0x4d27b90e, 0x284005b6, 0xc6efb0a4, 0xa3880c1c, 0x1ab0db81, 0x7fd76739, 0x9178d22b, 0xf41f6e93, 0x03f7263b, 0x66909a83, 0x883f2f91, 0xed589329, 0x546044b4, 0x3107f80c, 0xdfa84d1e, 0xbacff1a6, 0xecdf92fe, 0x89b82e46, 0x67179b54, 0x027027ec, 0xbb48f071, 0xde2f4cc9, 0x3080f9db, 0x55e74563, 0x9ca03f6b, 0xf9c783d3, 0x176836c1, 0x720f8a79, 0xcb375de4, 0xae50e15c, 0x40ff544e, 0x2598e8f6, 0x73888bae, 0x16ef3716, 0xf8408204, 0x9d273ebc, 0x241fe921, 0x41785599, 0xafd7e08b, 0xcab05c33, 0x3bb659ed, 0x5ed1e555, 0xb07e5047, 0xd519ecff, 0x6c213b62, 0x094687da, 0xe7e932c8, 0x828e8e70, 0xd49eed28, 0xb1f95190, 0x5f56e482, 0x3a31583a, 0x83098fa7, 0xe66e331f, 0x08c1860d, 0x6da63ab5, 0xa4e140bd, 0xc186fc05, 0x2f294917, 0x4a4ef5af, 0xf3762232, 0x96119e8a, 0x78be2b98, 0x1dd99720, 0x4bc9f478, 0x2eae48c0, 0xc001fdd2, 0xa566416a, 0x1c5e96f7, 0x79392a4f, 0x97969f5d, 0xf2f123e5, 0x05196b4d, 0x607ed7f5, 0x8ed162e7, 0xebb6de5f, 0x528e09c2, 0x37e9b57a, 0xd9460068, 0xbc21bcd0, 0xea31df88, 0x8f566330, 0x61f9d622, 0x049e6a9a, 0xbda6bd07, 0xd8c101bf, 0x366eb4ad, 0x53090815, 0x9a4e721d, 0xff29cea5, 0x11867bb7, 0x74e1c70f, 0xcdd91092, 0xa8beac2a, 0x46111938, 0x2376a580, 0x7566c6d8, 0x10017a60, 0xfeaecf72, 0x9bc973ca, 0x22f1a457, 0x479618ef, 0xa939adfd, 0xcc5e1145, 0x06ee4d76, 0x6389f1ce, 0x8d2644dc, 0xe841f864, 0x51792ff9, 0x341e9341, 0xdab12653, 0xbfd69aeb, 0xe9c6f9b3, 0x8ca1450b, 0x620ef019, 0x07694ca1, 0xbe519b3c, 0xdb362784, 0x35999296, 0x50fe2e2e, 0x99b95426, 0xfcdee89e, 0x12715d8c, 0x7716e134, 0xce2e36a9, 0xab498a11, 0x45e63f03, 0x208183bb, 0x7691e0e3, 0x13f65c5b, 0xfd59e949, 0x983e55f1, 0x2106826c, 0x44613ed4, 0xaace8bc6, 0xcfa9377e, 0x38417fd6, 0x5d26c36e, 0xb389767c, 0xd6eecac4, 0x6fd61d59, 0x0ab1a1e1, 0xe41e14f3, 0x8179a84b, 0xd769cb13, 0xb20e77ab, 0x5ca1c2b9, 0x39c67e01, 0x80fea99c, 0xe5991524, 0x0b36a036, 0x6e511c8e, 0xa7166686, 0xc271da3e, 0x2cde6f2c, 0x49b9d394, 0xf0810409, 0x95e6b8b1, 0x7b490da3, 0x1e2eb11b, 0x483ed243, 0x2d596efb, 0xc3f6dbe9, 0xa6916751, 0x1fa9b0cc, 0x7ace0c74, 0x9461b966, 0xf10605de}}; #endif #endif #if N == 2 #if W == 8 local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, 0x0d7139d7}, {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, 0x1c53e98a}, {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, 0x3f88e851}, {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, 0x3dee8ca6}, {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, 0x36197165}, {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, 0x1a3b93aa}, {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, 0xe147d714}, {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, 0x494f0c4b}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x0000000000000000, 0x43147b1700000000, 0x8628f62e00000000, 0xc53c8d3900000000, 0x0c51ec5d00000000, 0x4f45974a00000000, 0x8a791a7300000000, 0xc96d616400000000, 0x18a2d8bb00000000, 0x5bb6a3ac00000000, 0x9e8a2e9500000000, 0xdd9e558200000000, 0x14f334e600000000, 0x57e74ff100000000, 0x92dbc2c800000000, 0xd1cfb9df00000000, 0x7142c0ac00000000, 0x3256bbbb00000000, 0xf76a368200000000, 0xb47e4d9500000000, 0x7d132cf100000000, 0x3e0757e600000000, 0xfb3bdadf00000000, 0xb82fa1c800000000, 0x69e0181700000000, 0x2af4630000000000, 0xefc8ee3900000000, 0xacdc952e00000000, 0x65b1f44a00000000, 0x26a58f5d00000000, 0xe399026400000000, 0xa08d797300000000, 0xa382f18200000000, 0xe0968a9500000000, 0x25aa07ac00000000, 0x66be7cbb00000000, 0xafd31ddf00000000, 0xecc766c800000000, 0x29fbebf100000000, 0x6aef90e600000000, 0xbb20293900000000, 0xf834522e00000000, 0x3d08df1700000000, 0x7e1ca40000000000, 0xb771c56400000000, 0xf465be7300000000, 0x3159334a00000000, 0x724d485d00000000, 0xd2c0312e00000000, 0x91d44a3900000000, 0x54e8c70000000000, 0x17fcbc1700000000, 0xde91dd7300000000, 0x9d85a66400000000, 0x58b92b5d00000000, 0x1bad504a00000000, 0xca62e99500000000, 0x8976928200000000, 0x4c4a1fbb00000000, 0x0f5e64ac00000000, 0xc63305c800000000, 0x85277edf00000000, 0x401bf3e600000000, 0x030f88f100000000, 0x070392de00000000, 0x4417e9c900000000, 0x812b64f000000000, 0xc23f1fe700000000, 0x0b527e8300000000, 0x4846059400000000, 0x8d7a88ad00000000, 0xce6ef3ba00000000, 0x1fa14a6500000000, 0x5cb5317200000000, 0x9989bc4b00000000, 0xda9dc75c00000000, 0x13f0a63800000000, 0x50e4dd2f00000000, 0x95d8501600000000, 0xd6cc2b0100000000, 0x7641527200000000, 0x3555296500000000, 0xf069a45c00000000, 0xb37ddf4b00000000, 0x7a10be2f00000000, 0x3904c53800000000, 0xfc38480100000000, 0xbf2c331600000000, 0x6ee38ac900000000, 0x2df7f1de00000000, 0xe8cb7ce700000000, 0xabdf07f000000000, 0x62b2669400000000, 0x21a61d8300000000, 0xe49a90ba00000000, 0xa78eebad00000000, 0xa481635c00000000, 0xe795184b00000000, 0x22a9957200000000, 0x61bdee6500000000, 0xa8d08f0100000000, 0xebc4f41600000000, 0x2ef8792f00000000, 0x6dec023800000000, 0xbc23bbe700000000, 0xff37c0f000000000, 0x3a0b4dc900000000, 0x791f36de00000000, 0xb07257ba00000000, 0xf3662cad00000000, 0x365aa19400000000, 0x754eda8300000000, 0xd5c3a3f000000000, 0x96d7d8e700000000, 0x53eb55de00000000, 0x10ff2ec900000000, 0xd9924fad00000000, 0x9a8634ba00000000, 0x5fbab98300000000, 0x1caec29400000000, 0xcd617b4b00000000, 0x8e75005c00000000, 0x4b498d6500000000, 0x085df67200000000, 0xc130971600000000, 0x8224ec0100000000, 0x4718613800000000, 0x040c1a2f00000000, 0x4f00556600000000, 0x0c142e7100000000, 0xc928a34800000000, 0x8a3cd85f00000000, 0x4351b93b00000000, 0x0045c22c00000000, 0xc5794f1500000000, 0x866d340200000000, 0x57a28ddd00000000, 0x14b6f6ca00000000, 0xd18a7bf300000000, 0x929e00e400000000, 0x5bf3618000000000, 0x18e71a9700000000, 0xdddb97ae00000000, 0x9ecfecb900000000, 0x3e4295ca00000000, 0x7d56eedd00000000, 0xb86a63e400000000, 0xfb7e18f300000000, 0x3213799700000000, 0x7107028000000000, 0xb43b8fb900000000, 0xf72ff4ae00000000, 0x26e04d7100000000, 0x65f4366600000000, 0xa0c8bb5f00000000, 0xe3dcc04800000000, 0x2ab1a12c00000000, 0x69a5da3b00000000, 0xac99570200000000, 0xef8d2c1500000000, 0xec82a4e400000000, 0xaf96dff300000000, 0x6aaa52ca00000000, 0x29be29dd00000000, 0xe0d348b900000000, 0xa3c733ae00000000, 0x66fbbe9700000000, 0x25efc58000000000, 0xf4207c5f00000000, 0xb734074800000000, 0x72088a7100000000, 0x311cf16600000000, 0xf871900200000000, 0xbb65eb1500000000, 0x7e59662c00000000, 0x3d4d1d3b00000000, 0x9dc0644800000000, 0xded41f5f00000000, 0x1be8926600000000, 0x58fce97100000000, 0x9191881500000000, 0xd285f30200000000, 0x17b97e3b00000000, 0x54ad052c00000000, 0x8562bcf300000000, 0xc676c7e400000000, 0x034a4add00000000, 0x405e31ca00000000, 0x893350ae00000000, 0xca272bb900000000, 0x0f1ba68000000000, 0x4c0fdd9700000000, 0x4803c7b800000000, 0x0b17bcaf00000000, 0xce2b319600000000, 0x8d3f4a8100000000, 0x44522be500000000, 0x074650f200000000, 0xc27addcb00000000, 0x816ea6dc00000000, 0x50a11f0300000000, 0x13b5641400000000, 0xd689e92d00000000, 0x959d923a00000000, 0x5cf0f35e00000000, 0x1fe4884900000000, 0xdad8057000000000, 0x99cc7e6700000000, 0x3941071400000000, 0x7a557c0300000000, 0xbf69f13a00000000, 0xfc7d8a2d00000000, 0x3510eb4900000000, 0x7604905e00000000, 0xb3381d6700000000, 0xf02c667000000000, 0x21e3dfaf00000000, 0x62f7a4b800000000, 0xa7cb298100000000, 0xe4df529600000000, 0x2db233f200000000, 0x6ea648e500000000, 0xab9ac5dc00000000, 0xe88ebecb00000000, 0xeb81363a00000000, 0xa8954d2d00000000, 0x6da9c01400000000, 0x2ebdbb0300000000, 0xe7d0da6700000000, 0xa4c4a17000000000, 0x61f82c4900000000, 0x22ec575e00000000, 0xf323ee8100000000, 0xb037959600000000, 0x750b18af00000000, 0x361f63b800000000, 0xff7202dc00000000, 0xbc6679cb00000000, 0x795af4f200000000, 0x3a4e8fe500000000, 0x9ac3f69600000000, 0xd9d78d8100000000, 0x1ceb00b800000000, 0x5fff7baf00000000, 0x96921acb00000000, 0xd58661dc00000000, 0x10baece500000000, 0x53ae97f200000000, 0x82612e2d00000000, 0xc175553a00000000, 0x0449d80300000000, 0x475da31400000000, 0x8e30c27000000000, 0xcd24b96700000000, 0x0818345e00000000, 0x4b0c4f4900000000}, {0x0000000000000000, 0x3e6bc2ef00000000, 0x3dd0f50400000000, 0x03bb37eb00000000, 0x7aa0eb0900000000, 0x44cb29e600000000, 0x47701e0d00000000, 0x791bdce200000000, 0xf440d71300000000, 0xca2b15fc00000000, 0xc990221700000000, 0xf7fbe0f800000000, 0x8ee03c1a00000000, 0xb08bfef500000000, 0xb330c91e00000000, 0x8d5b0bf100000000, 0xe881ae2700000000, 0xd6ea6cc800000000, 0xd5515b2300000000, 0xeb3a99cc00000000, 0x9221452e00000000, 0xac4a87c100000000, 0xaff1b02a00000000, 0x919a72c500000000, 0x1cc1793400000000, 0x22aabbdb00000000, 0x21118c3000000000, 0x1f7a4edf00000000, 0x6661923d00000000, 0x580a50d200000000, 0x5bb1673900000000, 0x65daa5d600000000, 0xd0035d4f00000000, 0xee689fa000000000, 0xedd3a84b00000000, 0xd3b86aa400000000, 0xaaa3b64600000000, 0x94c874a900000000, 0x9773434200000000, 0xa91881ad00000000, 0x24438a5c00000000, 0x1a2848b300000000, 0x19937f5800000000, 0x27f8bdb700000000, 0x5ee3615500000000, 0x6088a3ba00000000, 0x6333945100000000, 0x5d5856be00000000, 0x3882f36800000000, 0x06e9318700000000, 0x0552066c00000000, 0x3b39c48300000000, 0x4222186100000000, 0x7c49da8e00000000, 0x7ff2ed6500000000, 0x41992f8a00000000, 0xccc2247b00000000, 0xf2a9e69400000000, 0xf112d17f00000000, 0xcf79139000000000, 0xb662cf7200000000, 0x88090d9d00000000, 0x8bb23a7600000000, 0xb5d9f89900000000, 0xa007ba9e00000000, 0x9e6c787100000000, 0x9dd74f9a00000000, 0xa3bc8d7500000000, 0xdaa7519700000000, 0xe4cc937800000000, 0xe777a49300000000, 0xd91c667c00000000, 0x54476d8d00000000, 0x6a2caf6200000000, 0x6997988900000000, 0x57fc5a6600000000, 0x2ee7868400000000, 0x108c446b00000000, 0x1337738000000000, 0x2d5cb16f00000000, 0x488614b900000000, 0x76edd65600000000, 0x7556e1bd00000000, 0x4b3d235200000000, 0x3226ffb000000000, 0x0c4d3d5f00000000, 0x0ff60ab400000000, 0x319dc85b00000000, 0xbcc6c3aa00000000, 0x82ad014500000000, 0x811636ae00000000, 0xbf7df44100000000, 0xc66628a300000000, 0xf80dea4c00000000, 0xfbb6dda700000000, 0xc5dd1f4800000000, 0x7004e7d100000000, 0x4e6f253e00000000, 0x4dd412d500000000, 0x73bfd03a00000000, 0x0aa40cd800000000, 0x34cfce3700000000, 0x3774f9dc00000000, 0x091f3b3300000000, 0x844430c200000000, 0xba2ff22d00000000, 0xb994c5c600000000, 0x87ff072900000000, 0xfee4dbcb00000000, 0xc08f192400000000, 0xc3342ecf00000000, 0xfd5fec2000000000, 0x988549f600000000, 0xa6ee8b1900000000, 0xa555bcf200000000, 0x9b3e7e1d00000000, 0xe225a2ff00000000, 0xdc4e601000000000, 0xdff557fb00000000, 0xe19e951400000000, 0x6cc59ee500000000, 0x52ae5c0a00000000, 0x51156be100000000, 0x6f7ea90e00000000, 0x166575ec00000000, 0x280eb70300000000, 0x2bb580e800000000, 0x15de420700000000, 0x010905e600000000, 0x3f62c70900000000, 0x3cd9f0e200000000, 0x02b2320d00000000, 0x7ba9eeef00000000, 0x45c22c0000000000, 0x46791beb00000000, 0x7812d90400000000, 0xf549d2f500000000, 0xcb22101a00000000, 0xc89927f100000000, 0xf6f2e51e00000000, 0x8fe939fc00000000, 0xb182fb1300000000, 0xb239ccf800000000, 0x8c520e1700000000, 0xe988abc100000000, 0xd7e3692e00000000, 0xd4585ec500000000, 0xea339c2a00000000, 0x932840c800000000, 0xad43822700000000, 0xaef8b5cc00000000, 0x9093772300000000, 0x1dc87cd200000000, 0x23a3be3d00000000, 0x201889d600000000, 0x1e734b3900000000, 0x676897db00000000, 0x5903553400000000, 0x5ab862df00000000, 0x64d3a03000000000, 0xd10a58a900000000, 0xef619a4600000000, 0xecdaadad00000000, 0xd2b16f4200000000, 0xabaab3a000000000, 0x95c1714f00000000, 0x967a46a400000000, 0xa811844b00000000, 0x254a8fba00000000, 0x1b214d5500000000, 0x189a7abe00000000, 0x26f1b85100000000, 0x5fea64b300000000, 0x6181a65c00000000, 0x623a91b700000000, 0x5c51535800000000, 0x398bf68e00000000, 0x07e0346100000000, 0x045b038a00000000, 0x3a30c16500000000, 0x432b1d8700000000, 0x7d40df6800000000, 0x7efbe88300000000, 0x40902a6c00000000, 0xcdcb219d00000000, 0xf3a0e37200000000, 0xf01bd49900000000, 0xce70167600000000, 0xb76bca9400000000, 0x8900087b00000000, 0x8abb3f9000000000, 0xb4d0fd7f00000000, 0xa10ebf7800000000, 0x9f657d9700000000, 0x9cde4a7c00000000, 0xa2b5889300000000, 0xdbae547100000000, 0xe5c5969e00000000, 0xe67ea17500000000, 0xd815639a00000000, 0x554e686b00000000, 0x6b25aa8400000000, 0x689e9d6f00000000, 0x56f55f8000000000, 0x2fee836200000000, 0x1185418d00000000, 0x123e766600000000, 0x2c55b48900000000, 0x498f115f00000000, 0x77e4d3b000000000, 0x745fe45b00000000, 0x4a3426b400000000, 0x332ffa5600000000, 0x0d4438b900000000, 0x0eff0f5200000000, 0x3094cdbd00000000, 0xbdcfc64c00000000, 0x83a404a300000000, 0x801f334800000000, 0xbe74f1a700000000, 0xc76f2d4500000000, 0xf904efaa00000000, 0xfabfd84100000000, 0xc4d41aae00000000, 0x710de23700000000, 0x4f6620d800000000, 0x4cdd173300000000, 0x72b6d5dc00000000, 0x0bad093e00000000, 0x35c6cbd100000000, 0x367dfc3a00000000, 0x08163ed500000000, 0x854d352400000000, 0xbb26f7cb00000000, 0xb89dc02000000000, 0x86f602cf00000000, 0xffedde2d00000000, 0xc1861cc200000000, 0xc23d2b2900000000, 0xfc56e9c600000000, 0x998c4c1000000000, 0xa7e78eff00000000, 0xa45cb91400000000, 0x9a377bfb00000000, 0xe32ca71900000000, 0xdd4765f600000000, 0xdefc521d00000000, 0xe09790f200000000, 0x6dcc9b0300000000, 0x53a759ec00000000, 0x501c6e0700000000, 0x6e77ace800000000, 0x176c700a00000000, 0x2907b2e500000000, 0x2abc850e00000000, 0x14d747e100000000}, {0x0000000000000000, 0xc0df8ec100000000, 0xc1b96c5800000000, 0x0166e29900000000, 0x8273d9b000000000, 0x42ac577100000000, 0x43cab5e800000000, 0x83153b2900000000, 0x45e1c3ba00000000, 0x853e4d7b00000000, 0x8458afe200000000, 0x4487212300000000, 0xc7921a0a00000000, 0x074d94cb00000000, 0x062b765200000000, 0xc6f4f89300000000, 0xcbc4f6ae00000000, 0x0b1b786f00000000, 0x0a7d9af600000000, 0xcaa2143700000000, 0x49b72f1e00000000, 0x8968a1df00000000, 0x880e434600000000, 0x48d1cd8700000000, 0x8e25351400000000, 0x4efabbd500000000, 0x4f9c594c00000000, 0x8f43d78d00000000, 0x0c56eca400000000, 0xcc89626500000000, 0xcdef80fc00000000, 0x0d300e3d00000000, 0xd78f9c8600000000, 0x1750124700000000, 0x1636f0de00000000, 0xd6e97e1f00000000, 0x55fc453600000000, 0x9523cbf700000000, 0x9445296e00000000, 0x549aa7af00000000, 0x926e5f3c00000000, 0x52b1d1fd00000000, 0x53d7336400000000, 0x9308bda500000000, 0x101d868c00000000, 0xd0c2084d00000000, 0xd1a4ead400000000, 0x117b641500000000, 0x1c4b6a2800000000, 0xdc94e4e900000000, 0xddf2067000000000, 0x1d2d88b100000000, 0x9e38b39800000000, 0x5ee73d5900000000, 0x5f81dfc000000000, 0x9f5e510100000000, 0x59aaa99200000000, 0x9975275300000000, 0x9813c5ca00000000, 0x58cc4b0b00000000, 0xdbd9702200000000, 0x1b06fee300000000, 0x1a601c7a00000000, 0xdabf92bb00000000, 0xef1948d600000000, 0x2fc6c61700000000, 0x2ea0248e00000000, 0xee7faa4f00000000, 0x6d6a916600000000, 0xadb51fa700000000, 0xacd3fd3e00000000, 0x6c0c73ff00000000, 0xaaf88b6c00000000, 0x6a2705ad00000000, 0x6b41e73400000000, 0xab9e69f500000000, 0x288b52dc00000000, 0xe854dc1d00000000, 0xe9323e8400000000, 0x29edb04500000000, 0x24ddbe7800000000, 0xe40230b900000000, 0xe564d22000000000, 0x25bb5ce100000000, 0xa6ae67c800000000, 0x6671e90900000000, 0x67170b9000000000, 0xa7c8855100000000, 0x613c7dc200000000, 0xa1e3f30300000000, 0xa085119a00000000, 0x605a9f5b00000000, 0xe34fa47200000000, 0x23902ab300000000, 0x22f6c82a00000000, 0xe22946eb00000000, 0x3896d45000000000, 0xf8495a9100000000, 0xf92fb80800000000, 0x39f036c900000000, 0xbae50de000000000, 0x7a3a832100000000, 0x7b5c61b800000000, 0xbb83ef7900000000, 0x7d7717ea00000000, 0xbda8992b00000000, 0xbcce7bb200000000, 0x7c11f57300000000, 0xff04ce5a00000000, 0x3fdb409b00000000, 0x3ebda20200000000, 0xfe622cc300000000, 0xf35222fe00000000, 0x338dac3f00000000, 0x32eb4ea600000000, 0xf234c06700000000, 0x7121fb4e00000000, 0xb1fe758f00000000, 0xb098971600000000, 0x704719d700000000, 0xb6b3e14400000000, 0x766c6f8500000000, 0x770a8d1c00000000, 0xb7d503dd00000000, 0x34c038f400000000, 0xf41fb63500000000, 0xf57954ac00000000, 0x35a6da6d00000000, 0x9f35e17700000000, 0x5fea6fb600000000, 0x5e8c8d2f00000000, 0x9e5303ee00000000, 0x1d4638c700000000, 0xdd99b60600000000, 0xdcff549f00000000, 0x1c20da5e00000000, 0xdad422cd00000000, 0x1a0bac0c00000000, 0x1b6d4e9500000000, 0xdbb2c05400000000, 0x58a7fb7d00000000, 0x987875bc00000000, 0x991e972500000000, 0x59c119e400000000, 0x54f117d900000000, 0x942e991800000000, 0x95487b8100000000, 0x5597f54000000000, 0xd682ce6900000000, 0x165d40a800000000, 0x173ba23100000000, 0xd7e42cf000000000, 0x1110d46300000000, 0xd1cf5aa200000000, 0xd0a9b83b00000000, 0x107636fa00000000, 0x93630dd300000000, 0x53bc831200000000, 0x52da618b00000000, 0x9205ef4a00000000, 0x48ba7df100000000, 0x8865f33000000000, 0x890311a900000000, 0x49dc9f6800000000, 0xcac9a44100000000, 0x0a162a8000000000, 0x0b70c81900000000, 0xcbaf46d800000000, 0x0d5bbe4b00000000, 0xcd84308a00000000, 0xcce2d21300000000, 0x0c3d5cd200000000, 0x8f2867fb00000000, 0x4ff7e93a00000000, 0x4e910ba300000000, 0x8e4e856200000000, 0x837e8b5f00000000, 0x43a1059e00000000, 0x42c7e70700000000, 0x821869c600000000, 0x010d52ef00000000, 0xc1d2dc2e00000000, 0xc0b43eb700000000, 0x006bb07600000000, 0xc69f48e500000000, 0x0640c62400000000, 0x072624bd00000000, 0xc7f9aa7c00000000, 0x44ec915500000000, 0x84331f9400000000, 0x8555fd0d00000000, 0x458a73cc00000000, 0x702ca9a100000000, 0xb0f3276000000000, 0xb195c5f900000000, 0x714a4b3800000000, 0xf25f701100000000, 0x3280fed000000000, 0x33e61c4900000000, 0xf339928800000000, 0x35cd6a1b00000000, 0xf512e4da00000000, 0xf474064300000000, 0x34ab888200000000, 0xb7beb3ab00000000, 0x77613d6a00000000, 0x7607dff300000000, 0xb6d8513200000000, 0xbbe85f0f00000000, 0x7b37d1ce00000000, 0x7a51335700000000, 0xba8ebd9600000000, 0x399b86bf00000000, 0xf944087e00000000, 0xf822eae700000000, 0x38fd642600000000, 0xfe099cb500000000, 0x3ed6127400000000, 0x3fb0f0ed00000000, 0xff6f7e2c00000000, 0x7c7a450500000000, 0xbca5cbc400000000, 0xbdc3295d00000000, 0x7d1ca79c00000000, 0xa7a3352700000000, 0x677cbbe600000000, 0x661a597f00000000, 0xa6c5d7be00000000, 0x25d0ec9700000000, 0xe50f625600000000, 0xe46980cf00000000, 0x24b60e0e00000000, 0xe242f69d00000000, 0x229d785c00000000, 0x23fb9ac500000000, 0xe324140400000000, 0x60312f2d00000000, 0xa0eea1ec00000000, 0xa188437500000000, 0x6157cdb400000000, 0x6c67c38900000000, 0xacb84d4800000000, 0xaddeafd100000000, 0x6d01211000000000, 0xee141a3900000000, 0x2ecb94f800000000, 0x2fad766100000000, 0xef72f8a000000000, 0x2986003300000000, 0xe9598ef200000000, 0xe83f6c6b00000000, 0x28e0e2aa00000000, 0xabf5d98300000000, 0x6b2a574200000000, 0x6a4cb5db00000000, 0xaa933b1a00000000}, {0x0000000000000000, 0x6f4ca59b00000000, 0x9f9e3bec00000000, 0xf0d29e7700000000, 0x7f3b060300000000, 0x1077a39800000000, 0xe0a53def00000000, 0x8fe9987400000000, 0xfe760c0600000000, 0x913aa99d00000000, 0x61e837ea00000000, 0x0ea4927100000000, 0x814d0a0500000000, 0xee01af9e00000000, 0x1ed331e900000000, 0x719f947200000000, 0xfced180c00000000, 0x93a1bd9700000000, 0x637323e000000000, 0x0c3f867b00000000, 0x83d61e0f00000000, 0xec9abb9400000000, 0x1c4825e300000000, 0x7304807800000000, 0x029b140a00000000, 0x6dd7b19100000000, 0x9d052fe600000000, 0xf2498a7d00000000, 0x7da0120900000000, 0x12ecb79200000000, 0xe23e29e500000000, 0x8d728c7e00000000, 0xf8db311800000000, 0x9797948300000000, 0x67450af400000000, 0x0809af6f00000000, 0x87e0371b00000000, 0xe8ac928000000000, 0x187e0cf700000000, 0x7732a96c00000000, 0x06ad3d1e00000000, 0x69e1988500000000, 0x993306f200000000, 0xf67fa36900000000, 0x79963b1d00000000, 0x16da9e8600000000, 0xe60800f100000000, 0x8944a56a00000000, 0x0436291400000000, 0x6b7a8c8f00000000, 0x9ba812f800000000, 0xf4e4b76300000000, 0x7b0d2f1700000000, 0x14418a8c00000000, 0xe49314fb00000000, 0x8bdfb16000000000, 0xfa40251200000000, 0x950c808900000000, 0x65de1efe00000000, 0x0a92bb6500000000, 0x857b231100000000, 0xea37868a00000000, 0x1ae518fd00000000, 0x75a9bd6600000000, 0xf0b7633000000000, 0x9ffbc6ab00000000, 0x6f2958dc00000000, 0x0065fd4700000000, 0x8f8c653300000000, 0xe0c0c0a800000000, 0x10125edf00000000, 0x7f5efb4400000000, 0x0ec16f3600000000, 0x618dcaad00000000, 0x915f54da00000000, 0xfe13f14100000000, 0x71fa693500000000, 0x1eb6ccae00000000, 0xee6452d900000000, 0x8128f74200000000, 0x0c5a7b3c00000000, 0x6316dea700000000, 0x93c440d000000000, 0xfc88e54b00000000, 0x73617d3f00000000, 0x1c2dd8a400000000, 0xecff46d300000000, 0x83b3e34800000000, 0xf22c773a00000000, 0x9d60d2a100000000, 0x6db24cd600000000, 0x02fee94d00000000, 0x8d17713900000000, 0xe25bd4a200000000, 0x12894ad500000000, 0x7dc5ef4e00000000, 0x086c522800000000, 0x6720f7b300000000, 0x97f269c400000000, 0xf8becc5f00000000, 0x7757542b00000000, 0x181bf1b000000000, 0xe8c96fc700000000, 0x8785ca5c00000000, 0xf61a5e2e00000000, 0x9956fbb500000000, 0x698465c200000000, 0x06c8c05900000000, 0x8921582d00000000, 0xe66dfdb600000000, 0x16bf63c100000000, 0x79f3c65a00000000, 0xf4814a2400000000, 0x9bcdefbf00000000, 0x6b1f71c800000000, 0x0453d45300000000, 0x8bba4c2700000000, 0xe4f6e9bc00000000, 0x142477cb00000000, 0x7b68d25000000000, 0x0af7462200000000, 0x65bbe3b900000000, 0x95697dce00000000, 0xfa25d85500000000, 0x75cc402100000000, 0x1a80e5ba00000000, 0xea527bcd00000000, 0x851ede5600000000, 0xe06fc76000000000, 0x8f2362fb00000000, 0x7ff1fc8c00000000, 0x10bd591700000000, 0x9f54c16300000000, 0xf01864f800000000, 0x00cafa8f00000000, 0x6f865f1400000000, 0x1e19cb6600000000, 0x71556efd00000000, 0x8187f08a00000000, 0xeecb551100000000, 0x6122cd6500000000, 0x0e6e68fe00000000, 0xfebcf68900000000, 0x91f0531200000000, 0x1c82df6c00000000, 0x73ce7af700000000, 0x831ce48000000000, 0xec50411b00000000, 0x63b9d96f00000000, 0x0cf57cf400000000, 0xfc27e28300000000, 0x936b471800000000, 0xe2f4d36a00000000, 0x8db876f100000000, 0x7d6ae88600000000, 0x12264d1d00000000, 0x9dcfd56900000000, 0xf28370f200000000, 0x0251ee8500000000, 0x6d1d4b1e00000000, 0x18b4f67800000000, 0x77f853e300000000, 0x872acd9400000000, 0xe866680f00000000, 0x678ff07b00000000, 0x08c355e000000000, 0xf811cb9700000000, 0x975d6e0c00000000, 0xe6c2fa7e00000000, 0x898e5fe500000000, 0x795cc19200000000, 0x1610640900000000, 0x99f9fc7d00000000, 0xf6b559e600000000, 0x0667c79100000000, 0x692b620a00000000, 0xe459ee7400000000, 0x8b154bef00000000, 0x7bc7d59800000000, 0x148b700300000000, 0x9b62e87700000000, 0xf42e4dec00000000, 0x04fcd39b00000000, 0x6bb0760000000000, 0x1a2fe27200000000, 0x756347e900000000, 0x85b1d99e00000000, 0xeafd7c0500000000, 0x6514e47100000000, 0x0a5841ea00000000, 0xfa8adf9d00000000, 0x95c67a0600000000, 0x10d8a45000000000, 0x7f9401cb00000000, 0x8f469fbc00000000, 0xe00a3a2700000000, 0x6fe3a25300000000, 0x00af07c800000000, 0xf07d99bf00000000, 0x9f313c2400000000, 0xeeaea85600000000, 0x81e20dcd00000000, 0x713093ba00000000, 0x1e7c362100000000, 0x9195ae5500000000, 0xfed90bce00000000, 0x0e0b95b900000000, 0x6147302200000000, 0xec35bc5c00000000, 0x837919c700000000, 0x73ab87b000000000, 0x1ce7222b00000000, 0x930eba5f00000000, 0xfc421fc400000000, 0x0c9081b300000000, 0x63dc242800000000, 0x1243b05a00000000, 0x7d0f15c100000000, 0x8ddd8bb600000000, 0xe2912e2d00000000, 0x6d78b65900000000, 0x023413c200000000, 0xf2e68db500000000, 0x9daa282e00000000, 0xe803954800000000, 0x874f30d300000000, 0x779daea400000000, 0x18d10b3f00000000, 0x9738934b00000000, 0xf87436d000000000, 0x08a6a8a700000000, 0x67ea0d3c00000000, 0x1675994e00000000, 0x79393cd500000000, 0x89eba2a200000000, 0xe6a7073900000000, 0x694e9f4d00000000, 0x06023ad600000000, 0xf6d0a4a100000000, 0x999c013a00000000, 0x14ee8d4400000000, 0x7ba228df00000000, 0x8b70b6a800000000, 0xe43c133300000000, 0x6bd58b4700000000, 0x04992edc00000000, 0xf44bb0ab00000000, 0x9b07153000000000, 0xea98814200000000, 0x85d424d900000000, 0x7506baae00000000, 0x1a4a1f3500000000, 0x95a3874100000000, 0xfaef22da00000000, 0x0a3dbcad00000000, 0x6571193600000000}, {0x0000000000000000, 0x85d996dd00000000, 0x4bb55c6000000000, 0xce6ccabd00000000, 0x966ab9c000000000, 0x13b32f1d00000000, 0xdddfe5a000000000, 0x5806737d00000000, 0x6dd3035a00000000, 0xe80a958700000000, 0x26665f3a00000000, 0xa3bfc9e700000000, 0xfbb9ba9a00000000, 0x7e602c4700000000, 0xb00ce6fa00000000, 0x35d5702700000000, 0xdaa607b400000000, 0x5f7f916900000000, 0x91135bd400000000, 0x14cacd0900000000, 0x4cccbe7400000000, 0xc91528a900000000, 0x0779e21400000000, 0x82a074c900000000, 0xb77504ee00000000, 0x32ac923300000000, 0xfcc0588e00000000, 0x7919ce5300000000, 0x211fbd2e00000000, 0xa4c62bf300000000, 0x6aaae14e00000000, 0xef73779300000000, 0xf54b7eb300000000, 0x7092e86e00000000, 0xbefe22d300000000, 0x3b27b40e00000000, 0x6321c77300000000, 0xe6f851ae00000000, 0x28949b1300000000, 0xad4d0dce00000000, 0x98987de900000000, 0x1d41eb3400000000, 0xd32d218900000000, 0x56f4b75400000000, 0x0ef2c42900000000, 0x8b2b52f400000000, 0x4547984900000000, 0xc09e0e9400000000, 0x2fed790700000000, 0xaa34efda00000000, 0x6458256700000000, 0xe181b3ba00000000, 0xb987c0c700000000, 0x3c5e561a00000000, 0xf2329ca700000000, 0x77eb0a7a00000000, 0x423e7a5d00000000, 0xc7e7ec8000000000, 0x098b263d00000000, 0x8c52b0e000000000, 0xd454c39d00000000, 0x518d554000000000, 0x9fe19ffd00000000, 0x1a38092000000000, 0xab918dbd00000000, 0x2e481b6000000000, 0xe024d1dd00000000, 0x65fd470000000000, 0x3dfb347d00000000, 0xb822a2a000000000, 0x764e681d00000000, 0xf397fec000000000, 0xc6428ee700000000, 0x439b183a00000000, 0x8df7d28700000000, 0x082e445a00000000, 0x5028372700000000, 0xd5f1a1fa00000000, 0x1b9d6b4700000000, 0x9e44fd9a00000000, 0x71378a0900000000, 0xf4ee1cd400000000, 0x3a82d66900000000, 0xbf5b40b400000000, 0xe75d33c900000000, 0x6284a51400000000, 0xace86fa900000000, 0x2931f97400000000, 0x1ce4895300000000, 0x993d1f8e00000000, 0x5751d53300000000, 0xd28843ee00000000, 0x8a8e309300000000, 0x0f57a64e00000000, 0xc13b6cf300000000, 0x44e2fa2e00000000, 0x5edaf30e00000000, 0xdb0365d300000000, 0x156faf6e00000000, 0x90b639b300000000, 0xc8b04ace00000000, 0x4d69dc1300000000, 0x830516ae00000000, 0x06dc807300000000, 0x3309f05400000000, 0xb6d0668900000000, 0x78bcac3400000000, 0xfd653ae900000000, 0xa563499400000000, 0x20badf4900000000, 0xeed615f400000000, 0x6b0f832900000000, 0x847cf4ba00000000, 0x01a5626700000000, 0xcfc9a8da00000000, 0x4a103e0700000000, 0x12164d7a00000000, 0x97cfdba700000000, 0x59a3111a00000000, 0xdc7a87c700000000, 0xe9aff7e000000000, 0x6c76613d00000000, 0xa21aab8000000000, 0x27c33d5d00000000, 0x7fc54e2000000000, 0xfa1cd8fd00000000, 0x3470124000000000, 0xb1a9849d00000000, 0x17256aa000000000, 0x92fcfc7d00000000, 0x5c9036c000000000, 0xd949a01d00000000, 0x814fd36000000000, 0x049645bd00000000, 0xcafa8f0000000000, 0x4f2319dd00000000, 0x7af669fa00000000, 0xff2fff2700000000, 0x3143359a00000000, 0xb49aa34700000000, 0xec9cd03a00000000, 0x694546e700000000, 0xa7298c5a00000000, 0x22f01a8700000000, 0xcd836d1400000000, 0x485afbc900000000, 0x8636317400000000, 0x03efa7a900000000, 0x5be9d4d400000000, 0xde30420900000000, 0x105c88b400000000, 0x95851e6900000000, 0xa0506e4e00000000, 0x2589f89300000000, 0xebe5322e00000000, 0x6e3ca4f300000000, 0x363ad78e00000000, 0xb3e3415300000000, 0x7d8f8bee00000000, 0xf8561d3300000000, 0xe26e141300000000, 0x67b782ce00000000, 0xa9db487300000000, 0x2c02deae00000000, 0x7404add300000000, 0xf1dd3b0e00000000, 0x3fb1f1b300000000, 0xba68676e00000000, 0x8fbd174900000000, 0x0a64819400000000, 0xc4084b2900000000, 0x41d1ddf400000000, 0x19d7ae8900000000, 0x9c0e385400000000, 0x5262f2e900000000, 0xd7bb643400000000, 0x38c813a700000000, 0xbd11857a00000000, 0x737d4fc700000000, 0xf6a4d91a00000000, 0xaea2aa6700000000, 0x2b7b3cba00000000, 0xe517f60700000000, 0x60ce60da00000000, 0x551b10fd00000000, 0xd0c2862000000000, 0x1eae4c9d00000000, 0x9b77da4000000000, 0xc371a93d00000000, 0x46a83fe000000000, 0x88c4f55d00000000, 0x0d1d638000000000, 0xbcb4e71d00000000, 0x396d71c000000000, 0xf701bb7d00000000, 0x72d82da000000000, 0x2ade5edd00000000, 0xaf07c80000000000, 0x616b02bd00000000, 0xe4b2946000000000, 0xd167e44700000000, 0x54be729a00000000, 0x9ad2b82700000000, 0x1f0b2efa00000000, 0x470d5d8700000000, 0xc2d4cb5a00000000, 0x0cb801e700000000, 0x8961973a00000000, 0x6612e0a900000000, 0xe3cb767400000000, 0x2da7bcc900000000, 0xa87e2a1400000000, 0xf078596900000000, 0x75a1cfb400000000, 0xbbcd050900000000, 0x3e1493d400000000, 0x0bc1e3f300000000, 0x8e18752e00000000, 0x4074bf9300000000, 0xc5ad294e00000000, 0x9dab5a3300000000, 0x1872ccee00000000, 0xd61e065300000000, 0x53c7908e00000000, 0x49ff99ae00000000, 0xcc260f7300000000, 0x024ac5ce00000000, 0x8793531300000000, 0xdf95206e00000000, 0x5a4cb6b300000000, 0x94207c0e00000000, 0x11f9ead300000000, 0x242c9af400000000, 0xa1f50c2900000000, 0x6f99c69400000000, 0xea40504900000000, 0xb246233400000000, 0x379fb5e900000000, 0xf9f37f5400000000, 0x7c2ae98900000000, 0x93599e1a00000000, 0x168008c700000000, 0xd8ecc27a00000000, 0x5d3554a700000000, 0x053327da00000000, 0x80eab10700000000, 0x4e867bba00000000, 0xcb5fed6700000000, 0xfe8a9d4000000000, 0x7b530b9d00000000, 0xb53fc12000000000, 0x30e657fd00000000, 0x68e0248000000000, 0xed39b25d00000000, 0x235578e000000000, 0xa68cee3d00000000}, {0x0000000000000000, 0x76e10f9d00000000, 0xadc46ee100000000, 0xdb25617c00000000, 0x1b8fac1900000000, 0x6d6ea38400000000, 0xb64bc2f800000000, 0xc0aacd6500000000, 0x361e593300000000, 0x40ff56ae00000000, 0x9bda37d200000000, 0xed3b384f00000000, 0x2d91f52a00000000, 0x5b70fab700000000, 0x80559bcb00000000, 0xf6b4945600000000, 0x6c3cb26600000000, 0x1addbdfb00000000, 0xc1f8dc8700000000, 0xb719d31a00000000, 0x77b31e7f00000000, 0x015211e200000000, 0xda77709e00000000, 0xac967f0300000000, 0x5a22eb5500000000, 0x2cc3e4c800000000, 0xf7e685b400000000, 0x81078a2900000000, 0x41ad474c00000000, 0x374c48d100000000, 0xec6929ad00000000, 0x9a88263000000000, 0xd87864cd00000000, 0xae996b5000000000, 0x75bc0a2c00000000, 0x035d05b100000000, 0xc3f7c8d400000000, 0xb516c74900000000, 0x6e33a63500000000, 0x18d2a9a800000000, 0xee663dfe00000000, 0x9887326300000000, 0x43a2531f00000000, 0x35435c8200000000, 0xf5e991e700000000, 0x83089e7a00000000, 0x582dff0600000000, 0x2eccf09b00000000, 0xb444d6ab00000000, 0xc2a5d93600000000, 0x1980b84a00000000, 0x6f61b7d700000000, 0xafcb7ab200000000, 0xd92a752f00000000, 0x020f145300000000, 0x74ee1bce00000000, 0x825a8f9800000000, 0xf4bb800500000000, 0x2f9ee17900000000, 0x597feee400000000, 0x99d5238100000000, 0xef342c1c00000000, 0x34114d6000000000, 0x42f042fd00000000, 0xf1f7b94100000000, 0x8716b6dc00000000, 0x5c33d7a000000000, 0x2ad2d83d00000000, 0xea78155800000000, 0x9c991ac500000000, 0x47bc7bb900000000, 0x315d742400000000, 0xc7e9e07200000000, 0xb108efef00000000, 0x6a2d8e9300000000, 0x1ccc810e00000000, 0xdc664c6b00000000, 0xaa8743f600000000, 0x71a2228a00000000, 0x07432d1700000000, 0x9dcb0b2700000000, 0xeb2a04ba00000000, 0x300f65c600000000, 0x46ee6a5b00000000, 0x8644a73e00000000, 0xf0a5a8a300000000, 0x2b80c9df00000000, 0x5d61c64200000000, 0xabd5521400000000, 0xdd345d8900000000, 0x06113cf500000000, 0x70f0336800000000, 0xb05afe0d00000000, 0xc6bbf19000000000, 0x1d9e90ec00000000, 0x6b7f9f7100000000, 0x298fdd8c00000000, 0x5f6ed21100000000, 0x844bb36d00000000, 0xf2aabcf000000000, 0x3200719500000000, 0x44e17e0800000000, 0x9fc41f7400000000, 0xe92510e900000000, 0x1f9184bf00000000, 0x69708b2200000000, 0xb255ea5e00000000, 0xc4b4e5c300000000, 0x041e28a600000000, 0x72ff273b00000000, 0xa9da464700000000, 0xdf3b49da00000000, 0x45b36fea00000000, 0x3352607700000000, 0xe877010b00000000, 0x9e960e9600000000, 0x5e3cc3f300000000, 0x28ddcc6e00000000, 0xf3f8ad1200000000, 0x8519a28f00000000, 0x73ad36d900000000, 0x054c394400000000, 0xde69583800000000, 0xa88857a500000000, 0x68229ac000000000, 0x1ec3955d00000000, 0xc5e6f42100000000, 0xb307fbbc00000000, 0xe2ef738300000000, 0x940e7c1e00000000, 0x4f2b1d6200000000, 0x39ca12ff00000000, 0xf960df9a00000000, 0x8f81d00700000000, 0x54a4b17b00000000, 0x2245bee600000000, 0xd4f12ab000000000, 0xa210252d00000000, 0x7935445100000000, 0x0fd44bcc00000000, 0xcf7e86a900000000, 0xb99f893400000000, 0x62bae84800000000, 0x145be7d500000000, 0x8ed3c1e500000000, 0xf832ce7800000000, 0x2317af0400000000, 0x55f6a09900000000, 0x955c6dfc00000000, 0xe3bd626100000000, 0x3898031d00000000, 0x4e790c8000000000, 0xb8cd98d600000000, 0xce2c974b00000000, 0x1509f63700000000, 0x63e8f9aa00000000, 0xa34234cf00000000, 0xd5a33b5200000000, 0x0e865a2e00000000, 0x786755b300000000, 0x3a97174e00000000, 0x4c7618d300000000, 0x975379af00000000, 0xe1b2763200000000, 0x2118bb5700000000, 0x57f9b4ca00000000, 0x8cdcd5b600000000, 0xfa3dda2b00000000, 0x0c894e7d00000000, 0x7a6841e000000000, 0xa14d209c00000000, 0xd7ac2f0100000000, 0x1706e26400000000, 0x61e7edf900000000, 0xbac28c8500000000, 0xcc23831800000000, 0x56aba52800000000, 0x204aaab500000000, 0xfb6fcbc900000000, 0x8d8ec45400000000, 0x4d24093100000000, 0x3bc506ac00000000, 0xe0e067d000000000, 0x9601684d00000000, 0x60b5fc1b00000000, 0x1654f38600000000, 0xcd7192fa00000000, 0xbb909d6700000000, 0x7b3a500200000000, 0x0ddb5f9f00000000, 0xd6fe3ee300000000, 0xa01f317e00000000, 0x1318cac200000000, 0x65f9c55f00000000, 0xbedca42300000000, 0xc83dabbe00000000, 0x089766db00000000, 0x7e76694600000000, 0xa553083a00000000, 0xd3b207a700000000, 0x250693f100000000, 0x53e79c6c00000000, 0x88c2fd1000000000, 0xfe23f28d00000000, 0x3e893fe800000000, 0x4868307500000000, 0x934d510900000000, 0xe5ac5e9400000000, 0x7f2478a400000000, 0x09c5773900000000, 0xd2e0164500000000, 0xa40119d800000000, 0x64abd4bd00000000, 0x124adb2000000000, 0xc96fba5c00000000, 0xbf8eb5c100000000, 0x493a219700000000, 0x3fdb2e0a00000000, 0xe4fe4f7600000000, 0x921f40eb00000000, 0x52b58d8e00000000, 0x2454821300000000, 0xff71e36f00000000, 0x8990ecf200000000, 0xcb60ae0f00000000, 0xbd81a19200000000, 0x66a4c0ee00000000, 0x1045cf7300000000, 0xd0ef021600000000, 0xa60e0d8b00000000, 0x7d2b6cf700000000, 0x0bca636a00000000, 0xfd7ef73c00000000, 0x8b9ff8a100000000, 0x50ba99dd00000000, 0x265b964000000000, 0xe6f15b2500000000, 0x901054b800000000, 0x4b3535c400000000, 0x3dd43a5900000000, 0xa75c1c6900000000, 0xd1bd13f400000000, 0x0a98728800000000, 0x7c797d1500000000, 0xbcd3b07000000000, 0xca32bfed00000000, 0x1117de9100000000, 0x67f6d10c00000000, 0x9142455a00000000, 0xe7a34ac700000000, 0x3c862bbb00000000, 0x4a67242600000000, 0x8acde94300000000, 0xfc2ce6de00000000, 0x270987a200000000, 0x51e8883f00000000}, {0x0000000000000000, 0xe8dbfbb900000000, 0x91b186a800000000, 0x796a7d1100000000, 0x63657c8a00000000, 0x8bbe873300000000, 0xf2d4fa2200000000, 0x1a0f019b00000000, 0x87cc89cf00000000, 0x6f17727600000000, 0x167d0f6700000000, 0xfea6f4de00000000, 0xe4a9f54500000000, 0x0c720efc00000000, 0x751873ed00000000, 0x9dc3885400000000, 0x4f9f624400000000, 0xa74499fd00000000, 0xde2ee4ec00000000, 0x36f51f5500000000, 0x2cfa1ece00000000, 0xc421e57700000000, 0xbd4b986600000000, 0x559063df00000000, 0xc853eb8b00000000, 0x2088103200000000, 0x59e26d2300000000, 0xb139969a00000000, 0xab36970100000000, 0x43ed6cb800000000, 0x3a8711a900000000, 0xd25cea1000000000, 0x9e3ec58800000000, 0x76e53e3100000000, 0x0f8f432000000000, 0xe754b89900000000, 0xfd5bb90200000000, 0x158042bb00000000, 0x6cea3faa00000000, 0x8431c41300000000, 0x19f24c4700000000, 0xf129b7fe00000000, 0x8843caef00000000, 0x6098315600000000, 0x7a9730cd00000000, 0x924ccb7400000000, 0xeb26b66500000000, 0x03fd4ddc00000000, 0xd1a1a7cc00000000, 0x397a5c7500000000, 0x4010216400000000, 0xa8cbdadd00000000, 0xb2c4db4600000000, 0x5a1f20ff00000000, 0x23755dee00000000, 0xcbaea65700000000, 0x566d2e0300000000, 0xbeb6d5ba00000000, 0xc7dca8ab00000000, 0x2f07531200000000, 0x3508528900000000, 0xddd3a93000000000, 0xa4b9d42100000000, 0x4c622f9800000000, 0x7d7bfbca00000000, 0x95a0007300000000, 0xecca7d6200000000, 0x041186db00000000, 0x1e1e874000000000, 0xf6c57cf900000000, 0x8faf01e800000000, 0x6774fa5100000000, 0xfab7720500000000, 0x126c89bc00000000, 0x6b06f4ad00000000, 0x83dd0f1400000000, 0x99d20e8f00000000, 0x7109f53600000000, 0x0863882700000000, 0xe0b8739e00000000, 0x32e4998e00000000, 0xda3f623700000000, 0xa3551f2600000000, 0x4b8ee49f00000000, 0x5181e50400000000, 0xb95a1ebd00000000, 0xc03063ac00000000, 0x28eb981500000000, 0xb528104100000000, 0x5df3ebf800000000, 0x249996e900000000, 0xcc426d5000000000, 0xd64d6ccb00000000, 0x3e96977200000000, 0x47fcea6300000000, 0xaf2711da00000000, 0xe3453e4200000000, 0x0b9ec5fb00000000, 0x72f4b8ea00000000, 0x9a2f435300000000, 0x802042c800000000, 0x68fbb97100000000, 0x1191c46000000000, 0xf94a3fd900000000, 0x6489b78d00000000, 0x8c524c3400000000, 0xf538312500000000, 0x1de3ca9c00000000, 0x07eccb0700000000, 0xef3730be00000000, 0x965d4daf00000000, 0x7e86b61600000000, 0xacda5c0600000000, 0x4401a7bf00000000, 0x3d6bdaae00000000, 0xd5b0211700000000, 0xcfbf208c00000000, 0x2764db3500000000, 0x5e0ea62400000000, 0xb6d55d9d00000000, 0x2b16d5c900000000, 0xc3cd2e7000000000, 0xbaa7536100000000, 0x527ca8d800000000, 0x4873a94300000000, 0xa0a852fa00000000, 0xd9c22feb00000000, 0x3119d45200000000, 0xbbf0874e00000000, 0x532b7cf700000000, 0x2a4101e600000000, 0xc29afa5f00000000, 0xd895fbc400000000, 0x304e007d00000000, 0x49247d6c00000000, 0xa1ff86d500000000, 0x3c3c0e8100000000, 0xd4e7f53800000000, 0xad8d882900000000, 0x4556739000000000, 0x5f59720b00000000, 0xb78289b200000000, 0xcee8f4a300000000, 0x26330f1a00000000, 0xf46fe50a00000000, 0x1cb41eb300000000, 0x65de63a200000000, 0x8d05981b00000000, 0x970a998000000000, 0x7fd1623900000000, 0x06bb1f2800000000, 0xee60e49100000000, 0x73a36cc500000000, 0x9b78977c00000000, 0xe212ea6d00000000, 0x0ac911d400000000, 0x10c6104f00000000, 0xf81debf600000000, 0x817796e700000000, 0x69ac6d5e00000000, 0x25ce42c600000000, 0xcd15b97f00000000, 0xb47fc46e00000000, 0x5ca43fd700000000, 0x46ab3e4c00000000, 0xae70c5f500000000, 0xd71ab8e400000000, 0x3fc1435d00000000, 0xa202cb0900000000, 0x4ad930b000000000, 0x33b34da100000000, 0xdb68b61800000000, 0xc167b78300000000, 0x29bc4c3a00000000, 0x50d6312b00000000, 0xb80dca9200000000, 0x6a51208200000000, 0x828adb3b00000000, 0xfbe0a62a00000000, 0x133b5d9300000000, 0x09345c0800000000, 0xe1efa7b100000000, 0x9885daa000000000, 0x705e211900000000, 0xed9da94d00000000, 0x054652f400000000, 0x7c2c2fe500000000, 0x94f7d45c00000000, 0x8ef8d5c700000000, 0x66232e7e00000000, 0x1f49536f00000000, 0xf792a8d600000000, 0xc68b7c8400000000, 0x2e50873d00000000, 0x573afa2c00000000, 0xbfe1019500000000, 0xa5ee000e00000000, 0x4d35fbb700000000, 0x345f86a600000000, 0xdc847d1f00000000, 0x4147f54b00000000, 0xa99c0ef200000000, 0xd0f673e300000000, 0x382d885a00000000, 0x222289c100000000, 0xcaf9727800000000, 0xb3930f6900000000, 0x5b48f4d000000000, 0x89141ec000000000, 0x61cfe57900000000, 0x18a5986800000000, 0xf07e63d100000000, 0xea71624a00000000, 0x02aa99f300000000, 0x7bc0e4e200000000, 0x931b1f5b00000000, 0x0ed8970f00000000, 0xe6036cb600000000, 0x9f6911a700000000, 0x77b2ea1e00000000, 0x6dbdeb8500000000, 0x8566103c00000000, 0xfc0c6d2d00000000, 0x14d7969400000000, 0x58b5b90c00000000, 0xb06e42b500000000, 0xc9043fa400000000, 0x21dfc41d00000000, 0x3bd0c58600000000, 0xd30b3e3f00000000, 0xaa61432e00000000, 0x42bab89700000000, 0xdf7930c300000000, 0x37a2cb7a00000000, 0x4ec8b66b00000000, 0xa6134dd200000000, 0xbc1c4c4900000000, 0x54c7b7f000000000, 0x2dadcae100000000, 0xc576315800000000, 0x172adb4800000000, 0xfff120f100000000, 0x869b5de000000000, 0x6e40a65900000000, 0x744fa7c200000000, 0x9c945c7b00000000, 0xe5fe216a00000000, 0x0d25dad300000000, 0x90e6528700000000, 0x783da93e00000000, 0x0157d42f00000000, 0xe98c2f9600000000, 0xf3832e0d00000000, 0x1b58d5b400000000, 0x6232a8a500000000, 0x8ae9531c00000000}, {0x0000000000000000, 0x919168ae00000000, 0x6325a08700000000, 0xf2b4c82900000000, 0x874c31d400000000, 0x16dd597a00000000, 0xe469915300000000, 0x75f8f9fd00000000, 0x4f9f137300000000, 0xde0e7bdd00000000, 0x2cbab3f400000000, 0xbd2bdb5a00000000, 0xc8d322a700000000, 0x59424a0900000000, 0xabf6822000000000, 0x3a67ea8e00000000, 0x9e3e27e600000000, 0x0faf4f4800000000, 0xfd1b876100000000, 0x6c8aefcf00000000, 0x1972163200000000, 0x88e37e9c00000000, 0x7a57b6b500000000, 0xebc6de1b00000000, 0xd1a1349500000000, 0x40305c3b00000000, 0xb284941200000000, 0x2315fcbc00000000, 0x56ed054100000000, 0xc77c6def00000000, 0x35c8a5c600000000, 0xa459cd6800000000, 0x7d7b3f1700000000, 0xecea57b900000000, 0x1e5e9f9000000000, 0x8fcff73e00000000, 0xfa370ec300000000, 0x6ba6666d00000000, 0x9912ae4400000000, 0x0883c6ea00000000, 0x32e42c6400000000, 0xa37544ca00000000, 0x51c18ce300000000, 0xc050e44d00000000, 0xb5a81db000000000, 0x2439751e00000000, 0xd68dbd3700000000, 0x471cd59900000000, 0xe34518f100000000, 0x72d4705f00000000, 0x8060b87600000000, 0x11f1d0d800000000, 0x6409292500000000, 0xf598418b00000000, 0x072c89a200000000, 0x96bde10c00000000, 0xacda0b8200000000, 0x3d4b632c00000000, 0xcfffab0500000000, 0x5e6ec3ab00000000, 0x2b963a5600000000, 0xba0752f800000000, 0x48b39ad100000000, 0xd922f27f00000000, 0xfaf67e2e00000000, 0x6b67168000000000, 0x99d3dea900000000, 0x0842b60700000000, 0x7dba4ffa00000000, 0xec2b275400000000, 0x1e9fef7d00000000, 0x8f0e87d300000000, 0xb5696d5d00000000, 0x24f805f300000000, 0xd64ccdda00000000, 0x47dda57400000000, 0x32255c8900000000, 0xa3b4342700000000, 0x5100fc0e00000000, 0xc09194a000000000, 0x64c859c800000000, 0xf559316600000000, 0x07edf94f00000000, 0x967c91e100000000, 0xe384681c00000000, 0x721500b200000000, 0x80a1c89b00000000, 0x1130a03500000000, 0x2b574abb00000000, 0xbac6221500000000, 0x4872ea3c00000000, 0xd9e3829200000000, 0xac1b7b6f00000000, 0x3d8a13c100000000, 0xcf3edbe800000000, 0x5eafb34600000000, 0x878d413900000000, 0x161c299700000000, 0xe4a8e1be00000000, 0x7539891000000000, 0x00c170ed00000000, 0x9150184300000000, 0x63e4d06a00000000, 0xf275b8c400000000, 0xc812524a00000000, 0x59833ae400000000, 0xab37f2cd00000000, 0x3aa69a6300000000, 0x4f5e639e00000000, 0xdecf0b3000000000, 0x2c7bc31900000000, 0xbdeaabb700000000, 0x19b366df00000000, 0x88220e7100000000, 0x7a96c65800000000, 0xeb07aef600000000, 0x9eff570b00000000, 0x0f6e3fa500000000, 0xfddaf78c00000000, 0x6c4b9f2200000000, 0x562c75ac00000000, 0xc7bd1d0200000000, 0x3509d52b00000000, 0xa498bd8500000000, 0xd160447800000000, 0x40f12cd600000000, 0xb245e4ff00000000, 0x23d48c5100000000, 0xf4edfd5c00000000, 0x657c95f200000000, 0x97c85ddb00000000, 0x0659357500000000, 0x73a1cc8800000000, 0xe230a42600000000, 0x10846c0f00000000, 0x811504a100000000, 0xbb72ee2f00000000, 0x2ae3868100000000, 0xd8574ea800000000, 0x49c6260600000000, 0x3c3edffb00000000, 0xadafb75500000000, 0x5f1b7f7c00000000, 0xce8a17d200000000, 0x6ad3daba00000000, 0xfb42b21400000000, 0x09f67a3d00000000, 0x9867129300000000, 0xed9feb6e00000000, 0x7c0e83c000000000, 0x8eba4be900000000, 0x1f2b234700000000, 0x254cc9c900000000, 0xb4dda16700000000, 0x4669694e00000000, 0xd7f801e000000000, 0xa200f81d00000000, 0x339190b300000000, 0xc125589a00000000, 0x50b4303400000000, 0x8996c24b00000000, 0x1807aae500000000, 0xeab362cc00000000, 0x7b220a6200000000, 0x0edaf39f00000000, 0x9f4b9b3100000000, 0x6dff531800000000, 0xfc6e3bb600000000, 0xc609d13800000000, 0x5798b99600000000, 0xa52c71bf00000000, 0x34bd191100000000, 0x4145e0ec00000000, 0xd0d4884200000000, 0x2260406b00000000, 0xb3f128c500000000, 0x17a8e5ad00000000, 0x86398d0300000000, 0x748d452a00000000, 0xe51c2d8400000000, 0x90e4d47900000000, 0x0175bcd700000000, 0xf3c174fe00000000, 0x62501c5000000000, 0x5837f6de00000000, 0xc9a69e7000000000, 0x3b12565900000000, 0xaa833ef700000000, 0xdf7bc70a00000000, 0x4eeaafa400000000, 0xbc5e678d00000000, 0x2dcf0f2300000000, 0x0e1b837200000000, 0x9f8aebdc00000000, 0x6d3e23f500000000, 0xfcaf4b5b00000000, 0x8957b2a600000000, 0x18c6da0800000000, 0xea72122100000000, 0x7be37a8f00000000, 0x4184900100000000, 0xd015f8af00000000, 0x22a1308600000000, 0xb330582800000000, 0xc6c8a1d500000000, 0x5759c97b00000000, 0xa5ed015200000000, 0x347c69fc00000000, 0x9025a49400000000, 0x01b4cc3a00000000, 0xf300041300000000, 0x62916cbd00000000, 0x1769954000000000, 0x86f8fdee00000000, 0x744c35c700000000, 0xe5dd5d6900000000, 0xdfbab7e700000000, 0x4e2bdf4900000000, 0xbc9f176000000000, 0x2d0e7fce00000000, 0x58f6863300000000, 0xc967ee9d00000000, 0x3bd326b400000000, 0xaa424e1a00000000, 0x7360bc6500000000, 0xe2f1d4cb00000000, 0x10451ce200000000, 0x81d4744c00000000, 0xf42c8db100000000, 0x65bde51f00000000, 0x97092d3600000000, 0x0698459800000000, 0x3cffaf1600000000, 0xad6ec7b800000000, 0x5fda0f9100000000, 0xce4b673f00000000, 0xbbb39ec200000000, 0x2a22f66c00000000, 0xd8963e4500000000, 0x490756eb00000000, 0xed5e9b8300000000, 0x7ccff32d00000000, 0x8e7b3b0400000000, 0x1fea53aa00000000, 0x6a12aa5700000000, 0xfb83c2f900000000, 0x09370ad000000000, 0x98a6627e00000000, 0xa2c188f000000000, 0x3350e05e00000000, 0xc1e4287700000000, 0x507540d900000000, 0x258db92400000000, 0xb41cd18a00000000, 0x46a819a300000000, 0xd739710d00000000}}; #else /* W == 4 */ local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, 0x264b06e6}, {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, 0x92364a30}, {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, 0xe4c4abcc}, {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, 0xca64c78c}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x00000000, 0xb029603d, 0x6053c07a, 0xd07aa047, 0xc0a680f5, 0x708fe0c8, 0xa0f5408f, 0x10dc20b2, 0xc14b7030, 0x7162100d, 0xa118b04a, 0x1131d077, 0x01edf0c5, 0xb1c490f8, 0x61be30bf, 0xd1975082, 0x8297e060, 0x32be805d, 0xe2c4201a, 0x52ed4027, 0x42316095, 0xf21800a8, 0x2262a0ef, 0x924bc0d2, 0x43dc9050, 0xf3f5f06d, 0x238f502a, 0x93a63017, 0x837a10a5, 0x33537098, 0xe329d0df, 0x5300b0e2, 0x042fc1c1, 0xb406a1fc, 0x647c01bb, 0xd4556186, 0xc4894134, 0x74a02109, 0xa4da814e, 0x14f3e173, 0xc564b1f1, 0x754dd1cc, 0xa537718b, 0x151e11b6, 0x05c23104, 0xb5eb5139, 0x6591f17e, 0xd5b89143, 0x86b821a1, 0x3691419c, 0xe6ebe1db, 0x56c281e6, 0x461ea154, 0xf637c169, 0x264d612e, 0x96640113, 0x47f35191, 0xf7da31ac, 0x27a091eb, 0x9789f1d6, 0x8755d164, 0x377cb159, 0xe706111e, 0x572f7123, 0x4958f358, 0xf9719365, 0x290b3322, 0x9922531f, 0x89fe73ad, 0x39d71390, 0xe9adb3d7, 0x5984d3ea, 0x88138368, 0x383ae355, 0xe8404312, 0x5869232f, 0x48b5039d, 0xf89c63a0, 0x28e6c3e7, 0x98cfa3da, 0xcbcf1338, 0x7be67305, 0xab9cd342, 0x1bb5b37f, 0x0b6993cd, 0xbb40f3f0, 0x6b3a53b7, 0xdb13338a, 0x0a846308, 0xbaad0335, 0x6ad7a372, 0xdafec34f, 0xca22e3fd, 0x7a0b83c0, 0xaa712387, 0x1a5843ba, 0x4d773299, 0xfd5e52a4, 0x2d24f2e3, 0x9d0d92de, 0x8dd1b26c, 0x3df8d251, 0xed827216, 0x5dab122b, 0x8c3c42a9, 0x3c152294, 0xec6f82d3, 0x5c46e2ee, 0x4c9ac25c, 0xfcb3a261, 0x2cc90226, 0x9ce0621b, 0xcfe0d2f9, 0x7fc9b2c4, 0xafb31283, 0x1f9a72be, 0x0f46520c, 0xbf6f3231, 0x6f159276, 0xdf3cf24b, 0x0eaba2c9, 0xbe82c2f4, 0x6ef862b3, 0xded1028e, 0xce0d223c, 0x7e244201, 0xae5ee246, 0x1e77827b, 0x92b0e6b1, 0x2299868c, 0xf2e326cb, 0x42ca46f6, 0x52166644, 0xe23f0679, 0x3245a63e, 0x826cc603, 0x53fb9681, 0xe3d2f6bc, 0x33a856fb, 0x838136c6, 0x935d1674, 0x23747649, 0xf30ed60e, 0x4327b633, 0x102706d1, 0xa00e66ec, 0x7074c6ab, 0xc05da696, 0xd0818624, 0x60a8e619, 0xb0d2465e, 0x00fb2663, 0xd16c76e1, 0x614516dc, 0xb13fb69b, 0x0116d6a6, 0x11caf614, 0xa1e39629, 0x7199366e, 0xc1b05653, 0x969f2770, 0x26b6474d, 0xf6cce70a, 0x46e58737, 0x5639a785, 0xe610c7b8, 0x366a67ff, 0x864307c2, 0x57d45740, 0xe7fd377d, 0x3787973a, 0x87aef707, 0x9772d7b5, 0x275bb788, 0xf72117cf, 0x470877f2, 0x1408c710, 0xa421a72d, 0x745b076a, 0xc4726757, 0xd4ae47e5, 0x648727d8, 0xb4fd879f, 0x04d4e7a2, 0xd543b720, 0x656ad71d, 0xb510775a, 0x05391767, 0x15e537d5, 0xa5cc57e8, 0x75b6f7af, 0xc59f9792, 0xdbe815e9, 0x6bc175d4, 0xbbbbd593, 0x0b92b5ae, 0x1b4e951c, 0xab67f521, 0x7b1d5566, 0xcb34355b, 0x1aa365d9, 0xaa8a05e4, 0x7af0a5a3, 0xcad9c59e, 0xda05e52c, 0x6a2c8511, 0xba562556, 0x0a7f456b, 0x597ff589, 0xe95695b4, 0x392c35f3, 0x890555ce, 0x99d9757c, 0x29f01541, 0xf98ab506, 0x49a3d53b, 0x983485b9, 0x281de584, 0xf86745c3, 0x484e25fe, 0x5892054c, 0xe8bb6571, 0x38c1c536, 0x88e8a50b, 0xdfc7d428, 0x6feeb415, 0xbf941452, 0x0fbd746f, 0x1f6154dd, 0xaf4834e0, 0x7f3294a7, 0xcf1bf49a, 0x1e8ca418, 0xaea5c425, 0x7edf6462, 0xcef6045f, 0xde2a24ed, 0x6e0344d0, 0xbe79e497, 0x0e5084aa, 0x5d503448, 0xed795475, 0x3d03f432, 0x8d2a940f, 0x9df6b4bd, 0x2ddfd480, 0xfda574c7, 0x4d8c14fa, 0x9c1b4478, 0x2c322445, 0xfc488402, 0x4c61e43f, 0x5cbdc48d, 0xec94a4b0, 0x3cee04f7, 0x8cc764ca}, {0x00000000, 0xa5d35ccb, 0x0ba1c84d, 0xae729486, 0x1642919b, 0xb391cd50, 0x1de359d6, 0xb830051d, 0x6d8253ec, 0xc8510f27, 0x66239ba1, 0xc3f0c76a, 0x7bc0c277, 0xde139ebc, 0x70610a3a, 0xd5b256f1, 0x9b02d603, 0x3ed18ac8, 0x90a31e4e, 0x35704285, 0x8d404798, 0x28931b53, 0x86e18fd5, 0x2332d31e, 0xf68085ef, 0x5353d924, 0xfd214da2, 0x58f21169, 0xe0c21474, 0x451148bf, 0xeb63dc39, 0x4eb080f2, 0x3605ac07, 0x93d6f0cc, 0x3da4644a, 0x98773881, 0x20473d9c, 0x85946157, 0x2be6f5d1, 0x8e35a91a, 0x5b87ffeb, 0xfe54a320, 0x502637a6, 0xf5f56b6d, 0x4dc56e70, 0xe81632bb, 0x4664a63d, 0xe3b7faf6, 0xad077a04, 0x08d426cf, 0xa6a6b249, 0x0375ee82, 0xbb45eb9f, 0x1e96b754, 0xb0e423d2, 0x15377f19, 0xc08529e8, 0x65567523, 0xcb24e1a5, 0x6ef7bd6e, 0xd6c7b873, 0x7314e4b8, 0xdd66703e, 0x78b52cf5, 0x6c0a580f, 0xc9d904c4, 0x67ab9042, 0xc278cc89, 0x7a48c994, 0xdf9b955f, 0x71e901d9, 0xd43a5d12, 0x01880be3, 0xa45b5728, 0x0a29c3ae, 0xaffa9f65, 0x17ca9a78, 0xb219c6b3, 0x1c6b5235, 0xb9b80efe, 0xf7088e0c, 0x52dbd2c7, 0xfca94641, 0x597a1a8a, 0xe14a1f97, 0x4499435c, 0xeaebd7da, 0x4f388b11, 0x9a8adde0, 0x3f59812b, 0x912b15ad, 0x34f84966, 0x8cc84c7b, 0x291b10b0, 0x87698436, 0x22bad8fd, 0x5a0ff408, 0xffdca8c3, 0x51ae3c45, 0xf47d608e, 0x4c4d6593, 0xe99e3958, 0x47ecadde, 0xe23ff115, 0x378da7e4, 0x925efb2f, 0x3c2c6fa9, 0x99ff3362, 0x21cf367f, 0x841c6ab4, 0x2a6efe32, 0x8fbda2f9, 0xc10d220b, 0x64de7ec0, 0xcaacea46, 0x6f7fb68d, 0xd74fb390, 0x729cef5b, 0xdcee7bdd, 0x793d2716, 0xac8f71e7, 0x095c2d2c, 0xa72eb9aa, 0x02fde561, 0xbacde07c, 0x1f1ebcb7, 0xb16c2831, 0x14bf74fa, 0xd814b01e, 0x7dc7ecd5, 0xd3b57853, 0x76662498, 0xce562185, 0x6b857d4e, 0xc5f7e9c8, 0x6024b503, 0xb596e3f2, 0x1045bf39, 0xbe372bbf, 0x1be47774, 0xa3d47269, 0x06072ea2, 0xa875ba24, 0x0da6e6ef, 0x4316661d, 0xe6c53ad6, 0x48b7ae50, 0xed64f29b, 0x5554f786, 0xf087ab4d, 0x5ef53fcb, 0xfb266300, 0x2e9435f1, 0x8b47693a, 0x2535fdbc, 0x80e6a177, 0x38d6a46a, 0x9d05f8a1, 0x33776c27, 0x96a430ec, 0xee111c19, 0x4bc240d2, 0xe5b0d454, 0x4063889f, 0xf8538d82, 0x5d80d149, 0xf3f245cf, 0x56211904, 0x83934ff5, 0x2640133e, 0x883287b8, 0x2de1db73, 0x95d1de6e, 0x300282a5, 0x9e701623, 0x3ba34ae8, 0x7513ca1a, 0xd0c096d1, 0x7eb20257, 0xdb615e9c, 0x63515b81, 0xc682074a, 0x68f093cc, 0xcd23cf07, 0x189199f6, 0xbd42c53d, 0x133051bb, 0xb6e30d70, 0x0ed3086d, 0xab0054a6, 0x0572c020, 0xa0a19ceb, 0xb41ee811, 0x11cdb4da, 0xbfbf205c, 0x1a6c7c97, 0xa25c798a, 0x078f2541, 0xa9fdb1c7, 0x0c2eed0c, 0xd99cbbfd, 0x7c4fe736, 0xd23d73b0, 0x77ee2f7b, 0xcfde2a66, 0x6a0d76ad, 0xc47fe22b, 0x61acbee0, 0x2f1c3e12, 0x8acf62d9, 0x24bdf65f, 0x816eaa94, 0x395eaf89, 0x9c8df342, 0x32ff67c4, 0x972c3b0f, 0x429e6dfe, 0xe74d3135, 0x493fa5b3, 0xececf978, 0x54dcfc65, 0xf10fa0ae, 0x5f7d3428, 0xfaae68e3, 0x821b4416, 0x27c818dd, 0x89ba8c5b, 0x2c69d090, 0x9459d58d, 0x318a8946, 0x9ff81dc0, 0x3a2b410b, 0xef9917fa, 0x4a4a4b31, 0xe438dfb7, 0x41eb837c, 0xf9db8661, 0x5c08daaa, 0xf27a4e2c, 0x57a912e7, 0x19199215, 0xbccacede, 0x12b85a58, 0xb76b0693, 0x0f5b038e, 0xaa885f45, 0x04facbc3, 0xa1299708, 0x749bc1f9, 0xd1489d32, 0x7f3a09b4, 0xdae9557f, 0x62d95062, 0xc70a0ca9, 0x6978982f, 0xccabc4e4}, {0x00000000, 0xb40b77a6, 0x29119f97, 0x9d1ae831, 0x13244ff4, 0xa72f3852, 0x3a35d063, 0x8e3ea7c5, 0x674eef33, 0xd3459895, 0x4e5f70a4, 0xfa540702, 0x746aa0c7, 0xc061d761, 0x5d7b3f50, 0xe97048f6, 0xce9cde67, 0x7a97a9c1, 0xe78d41f0, 0x53863656, 0xddb89193, 0x69b3e635, 0xf4a90e04, 0x40a279a2, 0xa9d23154, 0x1dd946f2, 0x80c3aec3, 0x34c8d965, 0xbaf67ea0, 0x0efd0906, 0x93e7e137, 0x27ec9691, 0x9c39bdcf, 0x2832ca69, 0xb5282258, 0x012355fe, 0x8f1df23b, 0x3b16859d, 0xa60c6dac, 0x12071a0a, 0xfb7752fc, 0x4f7c255a, 0xd266cd6b, 0x666dbacd, 0xe8531d08, 0x5c586aae, 0xc142829f, 0x7549f539, 0x52a563a8, 0xe6ae140e, 0x7bb4fc3f, 0xcfbf8b99, 0x41812c5c, 0xf58a5bfa, 0x6890b3cb, 0xdc9bc46d, 0x35eb8c9b, 0x81e0fb3d, 0x1cfa130c, 0xa8f164aa, 0x26cfc36f, 0x92c4b4c9, 0x0fde5cf8, 0xbbd52b5e, 0x79750b44, 0xcd7e7ce2, 0x506494d3, 0xe46fe375, 0x6a5144b0, 0xde5a3316, 0x4340db27, 0xf74bac81, 0x1e3be477, 0xaa3093d1, 0x372a7be0, 0x83210c46, 0x0d1fab83, 0xb914dc25, 0x240e3414, 0x900543b2, 0xb7e9d523, 0x03e2a285, 0x9ef84ab4, 0x2af33d12, 0xa4cd9ad7, 0x10c6ed71, 0x8ddc0540, 0x39d772e6, 0xd0a73a10, 0x64ac4db6, 0xf9b6a587, 0x4dbdd221, 0xc38375e4, 0x77880242, 0xea92ea73, 0x5e999dd5, 0xe54cb68b, 0x5147c12d, 0xcc5d291c, 0x78565eba, 0xf668f97f, 0x42638ed9, 0xdf7966e8, 0x6b72114e, 0x820259b8, 0x36092e1e, 0xab13c62f, 0x1f18b189, 0x9126164c, 0x252d61ea, 0xb83789db, 0x0c3cfe7d, 0x2bd068ec, 0x9fdb1f4a, 0x02c1f77b, 0xb6ca80dd, 0x38f42718, 0x8cff50be, 0x11e5b88f, 0xa5eecf29, 0x4c9e87df, 0xf895f079, 0x658f1848, 0xd1846fee, 0x5fbac82b, 0xebb1bf8d, 0x76ab57bc, 0xc2a0201a, 0xf2ea1688, 0x46e1612e, 0xdbfb891f, 0x6ff0feb9, 0xe1ce597c, 0x55c52eda, 0xc8dfc6eb, 0x7cd4b14d, 0x95a4f9bb, 0x21af8e1d, 0xbcb5662c, 0x08be118a, 0x8680b64f, 0x328bc1e9, 0xaf9129d8, 0x1b9a5e7e, 0x3c76c8ef, 0x887dbf49, 0x15675778, 0xa16c20de, 0x2f52871b, 0x9b59f0bd, 0x0643188c, 0xb2486f2a, 0x5b3827dc, 0xef33507a, 0x7229b84b, 0xc622cfed, 0x481c6828, 0xfc171f8e, 0x610df7bf, 0xd5068019, 0x6ed3ab47, 0xdad8dce1, 0x47c234d0, 0xf3c94376, 0x7df7e4b3, 0xc9fc9315, 0x54e67b24, 0xe0ed0c82, 0x099d4474, 0xbd9633d2, 0x208cdbe3, 0x9487ac45, 0x1ab90b80, 0xaeb27c26, 0x33a89417, 0x87a3e3b1, 0xa04f7520, 0x14440286, 0x895eeab7, 0x3d559d11, 0xb36b3ad4, 0x07604d72, 0x9a7aa543, 0x2e71d2e5, 0xc7019a13, 0x730aedb5, 0xee100584, 0x5a1b7222, 0xd425d5e7, 0x602ea241, 0xfd344a70, 0x493f3dd6, 0x8b9f1dcc, 0x3f946a6a, 0xa28e825b, 0x1685f5fd, 0x98bb5238, 0x2cb0259e, 0xb1aacdaf, 0x05a1ba09, 0xecd1f2ff, 0x58da8559, 0xc5c06d68, 0x71cb1ace, 0xfff5bd0b, 0x4bfecaad, 0xd6e4229c, 0x62ef553a, 0x4503c3ab, 0xf108b40d, 0x6c125c3c, 0xd8192b9a, 0x56278c5f, 0xe22cfbf9, 0x7f3613c8, 0xcb3d646e, 0x224d2c98, 0x96465b3e, 0x0b5cb30f, 0xbf57c4a9, 0x3169636c, 0x856214ca, 0x1878fcfb, 0xac738b5d, 0x17a6a003, 0xa3add7a5, 0x3eb73f94, 0x8abc4832, 0x0482eff7, 0xb0899851, 0x2d937060, 0x999807c6, 0x70e84f30, 0xc4e33896, 0x59f9d0a7, 0xedf2a701, 0x63cc00c4, 0xd7c77762, 0x4add9f53, 0xfed6e8f5, 0xd93a7e64, 0x6d3109c2, 0xf02be1f3, 0x44209655, 0xca1e3190, 0x7e154636, 0xe30fae07, 0x5704d9a1, 0xbe749157, 0x0a7fe6f1, 0x97650ec0, 0x236e7966, 0xad50dea3, 0x195ba905, 0x84414134, 0x304a3692}, {0x00000000, 0x9e00aacc, 0x7d072542, 0xe3078f8e, 0xfa0e4a84, 0x640ee048, 0x87096fc6, 0x1909c50a, 0xb51be5d3, 0x2b1b4f1f, 0xc81cc091, 0x561c6a5d, 0x4f15af57, 0xd115059b, 0x32128a15, 0xac1220d9, 0x2b31bb7c, 0xb53111b0, 0x56369e3e, 0xc83634f2, 0xd13ff1f8, 0x4f3f5b34, 0xac38d4ba, 0x32387e76, 0x9e2a5eaf, 0x002af463, 0xe32d7bed, 0x7d2dd121, 0x6424142b, 0xfa24bee7, 0x19233169, 0x87239ba5, 0x566276f9, 0xc862dc35, 0x2b6553bb, 0xb565f977, 0xac6c3c7d, 0x326c96b1, 0xd16b193f, 0x4f6bb3f3, 0xe379932a, 0x7d7939e6, 0x9e7eb668, 0x007e1ca4, 0x1977d9ae, 0x87777362, 0x6470fcec, 0xfa705620, 0x7d53cd85, 0xe3536749, 0x0054e8c7, 0x9e54420b, 0x875d8701, 0x195d2dcd, 0xfa5aa243, 0x645a088f, 0xc8482856, 0x5648829a, 0xb54f0d14, 0x2b4fa7d8, 0x324662d2, 0xac46c81e, 0x4f414790, 0xd141ed5c, 0xedc29d29, 0x73c237e5, 0x90c5b86b, 0x0ec512a7, 0x17ccd7ad, 0x89cc7d61, 0x6acbf2ef, 0xf4cb5823, 0x58d978fa, 0xc6d9d236, 0x25de5db8, 0xbbdef774, 0xa2d7327e, 0x3cd798b2, 0xdfd0173c, 0x41d0bdf0, 0xc6f32655, 0x58f38c99, 0xbbf40317, 0x25f4a9db, 0x3cfd6cd1, 0xa2fdc61d, 0x41fa4993, 0xdffae35f, 0x73e8c386, 0xede8694a, 0x0eefe6c4, 0x90ef4c08, 0x89e68902, 0x17e623ce, 0xf4e1ac40, 0x6ae1068c, 0xbba0ebd0, 0x25a0411c, 0xc6a7ce92, 0x58a7645e, 0x41aea154, 0xdfae0b98, 0x3ca98416, 0xa2a92eda, 0x0ebb0e03, 0x90bba4cf, 0x73bc2b41, 0xedbc818d, 0xf4b54487, 0x6ab5ee4b, 0x89b261c5, 0x17b2cb09, 0x909150ac, 0x0e91fa60, 0xed9675ee, 0x7396df22, 0x6a9f1a28, 0xf49fb0e4, 0x17983f6a, 0x899895a6, 0x258ab57f, 0xbb8a1fb3, 0x588d903d, 0xc68d3af1, 0xdf84fffb, 0x41845537, 0xa283dab9, 0x3c837075, 0xda853b53, 0x4485919f, 0xa7821e11, 0x3982b4dd, 0x208b71d7, 0xbe8bdb1b, 0x5d8c5495, 0xc38cfe59, 0x6f9ede80, 0xf19e744c, 0x1299fbc2, 0x8c99510e, 0x95909404, 0x0b903ec8, 0xe897b146, 0x76971b8a, 0xf1b4802f, 0x6fb42ae3, 0x8cb3a56d, 0x12b30fa1, 0x0bbacaab, 0x95ba6067, 0x76bdefe9, 0xe8bd4525, 0x44af65fc, 0xdaafcf30, 0x39a840be, 0xa7a8ea72, 0xbea12f78, 0x20a185b4, 0xc3a60a3a, 0x5da6a0f6, 0x8ce74daa, 0x12e7e766, 0xf1e068e8, 0x6fe0c224, 0x76e9072e, 0xe8e9ade2, 0x0bee226c, 0x95ee88a0, 0x39fca879, 0xa7fc02b5, 0x44fb8d3b, 0xdafb27f7, 0xc3f2e2fd, 0x5df24831, 0xbef5c7bf, 0x20f56d73, 0xa7d6f6d6, 0x39d65c1a, 0xdad1d394, 0x44d17958, 0x5dd8bc52, 0xc3d8169e, 0x20df9910, 0xbedf33dc, 0x12cd1305, 0x8ccdb9c9, 0x6fca3647, 0xf1ca9c8b, 0xe8c35981, 0x76c3f34d, 0x95c47cc3, 0x0bc4d60f, 0x3747a67a, 0xa9470cb6, 0x4a408338, 0xd44029f4, 0xcd49ecfe, 0x53494632, 0xb04ec9bc, 0x2e4e6370, 0x825c43a9, 0x1c5ce965, 0xff5b66eb, 0x615bcc27, 0x7852092d, 0xe652a3e1, 0x05552c6f, 0x9b5586a3, 0x1c761d06, 0x8276b7ca, 0x61713844, 0xff719288, 0xe6785782, 0x7878fd4e, 0x9b7f72c0, 0x057fd80c, 0xa96df8d5, 0x376d5219, 0xd46add97, 0x4a6a775b, 0x5363b251, 0xcd63189d, 0x2e649713, 0xb0643ddf, 0x6125d083, 0xff257a4f, 0x1c22f5c1, 0x82225f0d, 0x9b2b9a07, 0x052b30cb, 0xe62cbf45, 0x782c1589, 0xd43e3550, 0x4a3e9f9c, 0xa9391012, 0x3739bade, 0x2e307fd4, 0xb030d518, 0x53375a96, 0xcd37f05a, 0x4a146bff, 0xd414c133, 0x37134ebd, 0xa913e471, 0xb01a217b, 0x2e1a8bb7, 0xcd1d0439, 0x531daef5, 0xff0f8e2c, 0x610f24e0, 0x8208ab6e, 0x1c0801a2, 0x0501c4a8, 0x9b016e64, 0x7806e1ea, 0xe6064b26}}; #endif #endif #if N == 3 #if W == 8 local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, 0x09cd8551}, {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, 0x7bc97a0c}, {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, 0x7851a2ca}, {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, 0x566b6848}, {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, 0xd8ac6b35}, {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, 0xa140efa8}, {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, 0x917cd6a1}, {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, 0x18ba364e}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x0000000000000000, 0x43cba68700000000, 0xc7903cd400000000, 0x845b9a5300000000, 0xcf27087300000000, 0x8cecaef400000000, 0x08b734a700000000, 0x4b7c922000000000, 0x9e4f10e600000000, 0xdd84b66100000000, 0x59df2c3200000000, 0x1a148ab500000000, 0x5168189500000000, 0x12a3be1200000000, 0x96f8244100000000, 0xd53382c600000000, 0x7d99511700000000, 0x3e52f79000000000, 0xba096dc300000000, 0xf9c2cb4400000000, 0xb2be596400000000, 0xf175ffe300000000, 0x752e65b000000000, 0x36e5c33700000000, 0xe3d641f100000000, 0xa01de77600000000, 0x24467d2500000000, 0x678ddba200000000, 0x2cf1498200000000, 0x6f3aef0500000000, 0xeb61755600000000, 0xa8aad3d100000000, 0xfa32a32e00000000, 0xb9f905a900000000, 0x3da29ffa00000000, 0x7e69397d00000000, 0x3515ab5d00000000, 0x76de0dda00000000, 0xf285978900000000, 0xb14e310e00000000, 0x647db3c800000000, 0x27b6154f00000000, 0xa3ed8f1c00000000, 0xe026299b00000000, 0xab5abbbb00000000, 0xe8911d3c00000000, 0x6cca876f00000000, 0x2f0121e800000000, 0x87abf23900000000, 0xc46054be00000000, 0x403bceed00000000, 0x03f0686a00000000, 0x488cfa4a00000000, 0x0b475ccd00000000, 0x8f1cc69e00000000, 0xccd7601900000000, 0x19e4e2df00000000, 0x5a2f445800000000, 0xde74de0b00000000, 0x9dbf788c00000000, 0xd6c3eaac00000000, 0x95084c2b00000000, 0x1153d67800000000, 0x529870ff00000000, 0xf465465d00000000, 0xb7aee0da00000000, 0x33f57a8900000000, 0x703edc0e00000000, 0x3b424e2e00000000, 0x7889e8a900000000, 0xfcd272fa00000000, 0xbf19d47d00000000, 0x6a2a56bb00000000, 0x29e1f03c00000000, 0xadba6a6f00000000, 0xee71cce800000000, 0xa50d5ec800000000, 0xe6c6f84f00000000, 0x629d621c00000000, 0x2156c49b00000000, 0x89fc174a00000000, 0xca37b1cd00000000, 0x4e6c2b9e00000000, 0x0da78d1900000000, 0x46db1f3900000000, 0x0510b9be00000000, 0x814b23ed00000000, 0xc280856a00000000, 0x17b307ac00000000, 0x5478a12b00000000, 0xd0233b7800000000, 0x93e89dff00000000, 0xd8940fdf00000000, 0x9b5fa95800000000, 0x1f04330b00000000, 0x5ccf958c00000000, 0x0e57e57300000000, 0x4d9c43f400000000, 0xc9c7d9a700000000, 0x8a0c7f2000000000, 0xc170ed0000000000, 0x82bb4b8700000000, 0x06e0d1d400000000, 0x452b775300000000, 0x9018f59500000000, 0xd3d3531200000000, 0x5788c94100000000, 0x14436fc600000000, 0x5f3ffde600000000, 0x1cf45b6100000000, 0x98afc13200000000, 0xdb6467b500000000, 0x73ceb46400000000, 0x300512e300000000, 0xb45e88b000000000, 0xf7952e3700000000, 0xbce9bc1700000000, 0xff221a9000000000, 0x7b7980c300000000, 0x38b2264400000000, 0xed81a48200000000, 0xae4a020500000000, 0x2a11985600000000, 0x69da3ed100000000, 0x22a6acf100000000, 0x616d0a7600000000, 0xe536902500000000, 0xa6fd36a200000000, 0xe8cb8cba00000000, 0xab002a3d00000000, 0x2f5bb06e00000000, 0x6c9016e900000000, 0x27ec84c900000000, 0x6427224e00000000, 0xe07cb81d00000000, 0xa3b71e9a00000000, 0x76849c5c00000000, 0x354f3adb00000000, 0xb114a08800000000, 0xf2df060f00000000, 0xb9a3942f00000000, 0xfa6832a800000000, 0x7e33a8fb00000000, 0x3df80e7c00000000, 0x9552ddad00000000, 0xd6997b2a00000000, 0x52c2e17900000000, 0x110947fe00000000, 0x5a75d5de00000000, 0x19be735900000000, 0x9de5e90a00000000, 0xde2e4f8d00000000, 0x0b1dcd4b00000000, 0x48d66bcc00000000, 0xcc8df19f00000000, 0x8f46571800000000, 0xc43ac53800000000, 0x87f163bf00000000, 0x03aaf9ec00000000, 0x40615f6b00000000, 0x12f92f9400000000, 0x5132891300000000, 0xd569134000000000, 0x96a2b5c700000000, 0xddde27e700000000, 0x9e15816000000000, 0x1a4e1b3300000000, 0x5985bdb400000000, 0x8cb63f7200000000, 0xcf7d99f500000000, 0x4b2603a600000000, 0x08eda52100000000, 0x4391370100000000, 0x005a918600000000, 0x84010bd500000000, 0xc7caad5200000000, 0x6f607e8300000000, 0x2cabd80400000000, 0xa8f0425700000000, 0xeb3be4d000000000, 0xa04776f000000000, 0xe38cd07700000000, 0x67d74a2400000000, 0x241ceca300000000, 0xf12f6e6500000000, 0xb2e4c8e200000000, 0x36bf52b100000000, 0x7574f43600000000, 0x3e08661600000000, 0x7dc3c09100000000, 0xf9985ac200000000, 0xba53fc4500000000, 0x1caecae700000000, 0x5f656c6000000000, 0xdb3ef63300000000, 0x98f550b400000000, 0xd389c29400000000, 0x9042641300000000, 0x1419fe4000000000, 0x57d258c700000000, 0x82e1da0100000000, 0xc12a7c8600000000, 0x4571e6d500000000, 0x06ba405200000000, 0x4dc6d27200000000, 0x0e0d74f500000000, 0x8a56eea600000000, 0xc99d482100000000, 0x61379bf000000000, 0x22fc3d7700000000, 0xa6a7a72400000000, 0xe56c01a300000000, 0xae10938300000000, 0xeddb350400000000, 0x6980af5700000000, 0x2a4b09d000000000, 0xff788b1600000000, 0xbcb32d9100000000, 0x38e8b7c200000000, 0x7b23114500000000, 0x305f836500000000, 0x739425e200000000, 0xf7cfbfb100000000, 0xb404193600000000, 0xe69c69c900000000, 0xa557cf4e00000000, 0x210c551d00000000, 0x62c7f39a00000000, 0x29bb61ba00000000, 0x6a70c73d00000000, 0xee2b5d6e00000000, 0xade0fbe900000000, 0x78d3792f00000000, 0x3b18dfa800000000, 0xbf4345fb00000000, 0xfc88e37c00000000, 0xb7f4715c00000000, 0xf43fd7db00000000, 0x70644d8800000000, 0x33afeb0f00000000, 0x9b0538de00000000, 0xd8ce9e5900000000, 0x5c95040a00000000, 0x1f5ea28d00000000, 0x542230ad00000000, 0x17e9962a00000000, 0x93b20c7900000000, 0xd079aafe00000000, 0x054a283800000000, 0x46818ebf00000000, 0xc2da14ec00000000, 0x8111b26b00000000, 0xca6d204b00000000, 0x89a686cc00000000, 0x0dfd1c9f00000000, 0x4e36ba1800000000}, {0x0000000000000000, 0xe1b652ef00000000, 0x836bd40500000000, 0x62dd86ea00000000, 0x06d7a80b00000000, 0xe761fae400000000, 0x85bc7c0e00000000, 0x640a2ee100000000, 0x0cae511700000000, 0xed1803f800000000, 0x8fc5851200000000, 0x6e73d7fd00000000, 0x0a79f91c00000000, 0xebcfabf300000000, 0x89122d1900000000, 0x68a47ff600000000, 0x185ca32e00000000, 0xf9eaf1c100000000, 0x9b37772b00000000, 0x7a8125c400000000, 0x1e8b0b2500000000, 0xff3d59ca00000000, 0x9de0df2000000000, 0x7c568dcf00000000, 0x14f2f23900000000, 0xf544a0d600000000, 0x9799263c00000000, 0x762f74d300000000, 0x12255a3200000000, 0xf39308dd00000000, 0x914e8e3700000000, 0x70f8dcd800000000, 0x30b8465d00000000, 0xd10e14b200000000, 0xb3d3925800000000, 0x5265c0b700000000, 0x366fee5600000000, 0xd7d9bcb900000000, 0xb5043a5300000000, 0x54b268bc00000000, 0x3c16174a00000000, 0xdda045a500000000, 0xbf7dc34f00000000, 0x5ecb91a000000000, 0x3ac1bf4100000000, 0xdb77edae00000000, 0xb9aa6b4400000000, 0x581c39ab00000000, 0x28e4e57300000000, 0xc952b79c00000000, 0xab8f317600000000, 0x4a39639900000000, 0x2e334d7800000000, 0xcf851f9700000000, 0xad58997d00000000, 0x4ceecb9200000000, 0x244ab46400000000, 0xc5fce68b00000000, 0xa721606100000000, 0x4697328e00000000, 0x229d1c6f00000000, 0xc32b4e8000000000, 0xa1f6c86a00000000, 0x40409a8500000000, 0x60708dba00000000, 0x81c6df5500000000, 0xe31b59bf00000000, 0x02ad0b5000000000, 0x66a725b100000000, 0x8711775e00000000, 0xe5ccf1b400000000, 0x047aa35b00000000, 0x6cdedcad00000000, 0x8d688e4200000000, 0xefb508a800000000, 0x0e035a4700000000, 0x6a0974a600000000, 0x8bbf264900000000, 0xe962a0a300000000, 0x08d4f24c00000000, 0x782c2e9400000000, 0x999a7c7b00000000, 0xfb47fa9100000000, 0x1af1a87e00000000, 0x7efb869f00000000, 0x9f4dd47000000000, 0xfd90529a00000000, 0x1c26007500000000, 0x74827f8300000000, 0x95342d6c00000000, 0xf7e9ab8600000000, 0x165ff96900000000, 0x7255d78800000000, 0x93e3856700000000, 0xf13e038d00000000, 0x1088516200000000, 0x50c8cbe700000000, 0xb17e990800000000, 0xd3a31fe200000000, 0x32154d0d00000000, 0x561f63ec00000000, 0xb7a9310300000000, 0xd574b7e900000000, 0x34c2e50600000000, 0x5c669af000000000, 0xbdd0c81f00000000, 0xdf0d4ef500000000, 0x3ebb1c1a00000000, 0x5ab132fb00000000, 0xbb07601400000000, 0xd9dae6fe00000000, 0x386cb41100000000, 0x489468c900000000, 0xa9223a2600000000, 0xcbffbccc00000000, 0x2a49ee2300000000, 0x4e43c0c200000000, 0xaff5922d00000000, 0xcd2814c700000000, 0x2c9e462800000000, 0x443a39de00000000, 0xa58c6b3100000000, 0xc751eddb00000000, 0x26e7bf3400000000, 0x42ed91d500000000, 0xa35bc33a00000000, 0xc18645d000000000, 0x2030173f00000000, 0x81e66bae00000000, 0x6050394100000000, 0x028dbfab00000000, 0xe33bed4400000000, 0x8731c3a500000000, 0x6687914a00000000, 0x045a17a000000000, 0xe5ec454f00000000, 0x8d483ab900000000, 0x6cfe685600000000, 0x0e23eebc00000000, 0xef95bc5300000000, 0x8b9f92b200000000, 0x6a29c05d00000000, 0x08f446b700000000, 0xe942145800000000, 0x99bac88000000000, 0x780c9a6f00000000, 0x1ad11c8500000000, 0xfb674e6a00000000, 0x9f6d608b00000000, 0x7edb326400000000, 0x1c06b48e00000000, 0xfdb0e66100000000, 0x9514999700000000, 0x74a2cb7800000000, 0x167f4d9200000000, 0xf7c91f7d00000000, 0x93c3319c00000000, 0x7275637300000000, 0x10a8e59900000000, 0xf11eb77600000000, 0xb15e2df300000000, 0x50e87f1c00000000, 0x3235f9f600000000, 0xd383ab1900000000, 0xb78985f800000000, 0x563fd71700000000, 0x34e251fd00000000, 0xd554031200000000, 0xbdf07ce400000000, 0x5c462e0b00000000, 0x3e9ba8e100000000, 0xdf2dfa0e00000000, 0xbb27d4ef00000000, 0x5a91860000000000, 0x384c00ea00000000, 0xd9fa520500000000, 0xa9028edd00000000, 0x48b4dc3200000000, 0x2a695ad800000000, 0xcbdf083700000000, 0xafd526d600000000, 0x4e63743900000000, 0x2cbef2d300000000, 0xcd08a03c00000000, 0xa5acdfca00000000, 0x441a8d2500000000, 0x26c70bcf00000000, 0xc771592000000000, 0xa37b77c100000000, 0x42cd252e00000000, 0x2010a3c400000000, 0xc1a6f12b00000000, 0xe196e61400000000, 0x0020b4fb00000000, 0x62fd321100000000, 0x834b60fe00000000, 0xe7414e1f00000000, 0x06f71cf000000000, 0x642a9a1a00000000, 0x859cc8f500000000, 0xed38b70300000000, 0x0c8ee5ec00000000, 0x6e53630600000000, 0x8fe531e900000000, 0xebef1f0800000000, 0x0a594de700000000, 0x6884cb0d00000000, 0x893299e200000000, 0xf9ca453a00000000, 0x187c17d500000000, 0x7aa1913f00000000, 0x9b17c3d000000000, 0xff1ded3100000000, 0x1eabbfde00000000, 0x7c76393400000000, 0x9dc06bdb00000000, 0xf564142d00000000, 0x14d246c200000000, 0x760fc02800000000, 0x97b992c700000000, 0xf3b3bc2600000000, 0x1205eec900000000, 0x70d8682300000000, 0x916e3acc00000000, 0xd12ea04900000000, 0x3098f2a600000000, 0x5245744c00000000, 0xb3f326a300000000, 0xd7f9084200000000, 0x364f5aad00000000, 0x5492dc4700000000, 0xb5248ea800000000, 0xdd80f15e00000000, 0x3c36a3b100000000, 0x5eeb255b00000000, 0xbf5d77b400000000, 0xdb57595500000000, 0x3ae10bba00000000, 0x583c8d5000000000, 0xb98adfbf00000000, 0xc972036700000000, 0x28c4518800000000, 0x4a19d76200000000, 0xabaf858d00000000, 0xcfa5ab6c00000000, 0x2e13f98300000000, 0x4cce7f6900000000, 0xad782d8600000000, 0xc5dc527000000000, 0x246a009f00000000, 0x46b7867500000000, 0xa701d49a00000000, 0xc30bfa7b00000000, 0x22bda89400000000, 0x40602e7e00000000, 0xa1d67c9100000000}, {0x0000000000000000, 0x5880e2d700000000, 0xf106b47400000000, 0xa98656a300000000, 0xe20d68e900000000, 0xba8d8a3e00000000, 0x130bdc9d00000000, 0x4b8b3e4a00000000, 0x851da10900000000, 0xdd9d43de00000000, 0x741b157d00000000, 0x2c9bf7aa00000000, 0x6710c9e000000000, 0x3f902b3700000000, 0x96167d9400000000, 0xce969f4300000000, 0x0a3b421300000000, 0x52bba0c400000000, 0xfb3df66700000000, 0xa3bd14b000000000, 0xe8362afa00000000, 0xb0b6c82d00000000, 0x19309e8e00000000, 0x41b07c5900000000, 0x8f26e31a00000000, 0xd7a601cd00000000, 0x7e20576e00000000, 0x26a0b5b900000000, 0x6d2b8bf300000000, 0x35ab692400000000, 0x9c2d3f8700000000, 0xc4addd5000000000, 0x1476842600000000, 0x4cf666f100000000, 0xe570305200000000, 0xbdf0d28500000000, 0xf67beccf00000000, 0xaefb0e1800000000, 0x077d58bb00000000, 0x5ffdba6c00000000, 0x916b252f00000000, 0xc9ebc7f800000000, 0x606d915b00000000, 0x38ed738c00000000, 0x73664dc600000000, 0x2be6af1100000000, 0x8260f9b200000000, 0xdae01b6500000000, 0x1e4dc63500000000, 0x46cd24e200000000, 0xef4b724100000000, 0xb7cb909600000000, 0xfc40aedc00000000, 0xa4c04c0b00000000, 0x0d461aa800000000, 0x55c6f87f00000000, 0x9b50673c00000000, 0xc3d085eb00000000, 0x6a56d34800000000, 0x32d6319f00000000, 0x795d0fd500000000, 0x21dded0200000000, 0x885bbba100000000, 0xd0db597600000000, 0x28ec084d00000000, 0x706cea9a00000000, 0xd9eabc3900000000, 0x816a5eee00000000, 0xcae160a400000000, 0x9261827300000000, 0x3be7d4d000000000, 0x6367360700000000, 0xadf1a94400000000, 0xf5714b9300000000, 0x5cf71d3000000000, 0x0477ffe700000000, 0x4ffcc1ad00000000, 0x177c237a00000000, 0xbefa75d900000000, 0xe67a970e00000000, 0x22d74a5e00000000, 0x7a57a88900000000, 0xd3d1fe2a00000000, 0x8b511cfd00000000, 0xc0da22b700000000, 0x985ac06000000000, 0x31dc96c300000000, 0x695c741400000000, 0xa7caeb5700000000, 0xff4a098000000000, 0x56cc5f2300000000, 0x0e4cbdf400000000, 0x45c783be00000000, 0x1d47616900000000, 0xb4c137ca00000000, 0xec41d51d00000000, 0x3c9a8c6b00000000, 0x641a6ebc00000000, 0xcd9c381f00000000, 0x951cdac800000000, 0xde97e48200000000, 0x8617065500000000, 0x2f9150f600000000, 0x7711b22100000000, 0xb9872d6200000000, 0xe107cfb500000000, 0x4881991600000000, 0x10017bc100000000, 0x5b8a458b00000000, 0x030aa75c00000000, 0xaa8cf1ff00000000, 0xf20c132800000000, 0x36a1ce7800000000, 0x6e212caf00000000, 0xc7a77a0c00000000, 0x9f2798db00000000, 0xd4aca69100000000, 0x8c2c444600000000, 0x25aa12e500000000, 0x7d2af03200000000, 0xb3bc6f7100000000, 0xeb3c8da600000000, 0x42badb0500000000, 0x1a3a39d200000000, 0x51b1079800000000, 0x0931e54f00000000, 0xa0b7b3ec00000000, 0xf837513b00000000, 0x50d8119a00000000, 0x0858f34d00000000, 0xa1dea5ee00000000, 0xf95e473900000000, 0xb2d5797300000000, 0xea559ba400000000, 0x43d3cd0700000000, 0x1b532fd000000000, 0xd5c5b09300000000, 0x8d45524400000000, 0x24c304e700000000, 0x7c43e63000000000, 0x37c8d87a00000000, 0x6f483aad00000000, 0xc6ce6c0e00000000, 0x9e4e8ed900000000, 0x5ae3538900000000, 0x0263b15e00000000, 0xabe5e7fd00000000, 0xf365052a00000000, 0xb8ee3b6000000000, 0xe06ed9b700000000, 0x49e88f1400000000, 0x11686dc300000000, 0xdffef28000000000, 0x877e105700000000, 0x2ef846f400000000, 0x7678a42300000000, 0x3df39a6900000000, 0x657378be00000000, 0xccf52e1d00000000, 0x9475ccca00000000, 0x44ae95bc00000000, 0x1c2e776b00000000, 0xb5a821c800000000, 0xed28c31f00000000, 0xa6a3fd5500000000, 0xfe231f8200000000, 0x57a5492100000000, 0x0f25abf600000000, 0xc1b334b500000000, 0x9933d66200000000, 0x30b580c100000000, 0x6835621600000000, 0x23be5c5c00000000, 0x7b3ebe8b00000000, 0xd2b8e82800000000, 0x8a380aff00000000, 0x4e95d7af00000000, 0x1615357800000000, 0xbf9363db00000000, 0xe713810c00000000, 0xac98bf4600000000, 0xf4185d9100000000, 0x5d9e0b3200000000, 0x051ee9e500000000, 0xcb8876a600000000, 0x9308947100000000, 0x3a8ec2d200000000, 0x620e200500000000, 0x29851e4f00000000, 0x7105fc9800000000, 0xd883aa3b00000000, 0x800348ec00000000, 0x783419d700000000, 0x20b4fb0000000000, 0x8932ada300000000, 0xd1b24f7400000000, 0x9a39713e00000000, 0xc2b993e900000000, 0x6b3fc54a00000000, 0x33bf279d00000000, 0xfd29b8de00000000, 0xa5a95a0900000000, 0x0c2f0caa00000000, 0x54afee7d00000000, 0x1f24d03700000000, 0x47a432e000000000, 0xee22644300000000, 0xb6a2869400000000, 0x720f5bc400000000, 0x2a8fb91300000000, 0x8309efb000000000, 0xdb890d6700000000, 0x9002332d00000000, 0xc882d1fa00000000, 0x6104875900000000, 0x3984658e00000000, 0xf712facd00000000, 0xaf92181a00000000, 0x06144eb900000000, 0x5e94ac6e00000000, 0x151f922400000000, 0x4d9f70f300000000, 0xe419265000000000, 0xbc99c48700000000, 0x6c429df100000000, 0x34c27f2600000000, 0x9d44298500000000, 0xc5c4cb5200000000, 0x8e4ff51800000000, 0xd6cf17cf00000000, 0x7f49416c00000000, 0x27c9a3bb00000000, 0xe95f3cf800000000, 0xb1dfde2f00000000, 0x1859888c00000000, 0x40d96a5b00000000, 0x0b52541100000000, 0x53d2b6c600000000, 0xfa54e06500000000, 0xa2d402b200000000, 0x6679dfe200000000, 0x3ef93d3500000000, 0x977f6b9600000000, 0xcfff894100000000, 0x8474b70b00000000, 0xdcf455dc00000000, 0x7572037f00000000, 0x2df2e1a800000000, 0xe3647eeb00000000, 0xbbe49c3c00000000, 0x1262ca9f00000000, 0x4ae2284800000000, 0x0169160200000000, 0x59e9f4d500000000, 0xf06fa27600000000, 0xa8ef40a100000000}, {0x0000000000000000, 0x463b676500000000, 0x8c76ceca00000000, 0xca4da9af00000000, 0x59ebed4e00000000, 0x1fd08a2b00000000, 0xd59d238400000000, 0x93a644e100000000, 0xb2d6db9d00000000, 0xf4edbcf800000000, 0x3ea0155700000000, 0x789b723200000000, 0xeb3d36d300000000, 0xad0651b600000000, 0x674bf81900000000, 0x21709f7c00000000, 0x25abc6e000000000, 0x6390a18500000000, 0xa9dd082a00000000, 0xefe66f4f00000000, 0x7c402bae00000000, 0x3a7b4ccb00000000, 0xf036e56400000000, 0xb60d820100000000, 0x977d1d7d00000000, 0xd1467a1800000000, 0x1b0bd3b700000000, 0x5d30b4d200000000, 0xce96f03300000000, 0x88ad975600000000, 0x42e03ef900000000, 0x04db599c00000000, 0x0b50fc1a00000000, 0x4d6b9b7f00000000, 0x872632d000000000, 0xc11d55b500000000, 0x52bb115400000000, 0x1480763100000000, 0xdecddf9e00000000, 0x98f6b8fb00000000, 0xb986278700000000, 0xffbd40e200000000, 0x35f0e94d00000000, 0x73cb8e2800000000, 0xe06dcac900000000, 0xa656adac00000000, 0x6c1b040300000000, 0x2a20636600000000, 0x2efb3afa00000000, 0x68c05d9f00000000, 0xa28df43000000000, 0xe4b6935500000000, 0x7710d7b400000000, 0x312bb0d100000000, 0xfb66197e00000000, 0xbd5d7e1b00000000, 0x9c2de16700000000, 0xda16860200000000, 0x105b2fad00000000, 0x566048c800000000, 0xc5c60c2900000000, 0x83fd6b4c00000000, 0x49b0c2e300000000, 0x0f8ba58600000000, 0x16a0f83500000000, 0x509b9f5000000000, 0x9ad636ff00000000, 0xdced519a00000000, 0x4f4b157b00000000, 0x0970721e00000000, 0xc33ddbb100000000, 0x8506bcd400000000, 0xa47623a800000000, 0xe24d44cd00000000, 0x2800ed6200000000, 0x6e3b8a0700000000, 0xfd9dcee600000000, 0xbba6a98300000000, 0x71eb002c00000000, 0x37d0674900000000, 0x330b3ed500000000, 0x753059b000000000, 0xbf7df01f00000000, 0xf946977a00000000, 0x6ae0d39b00000000, 0x2cdbb4fe00000000, 0xe6961d5100000000, 0xa0ad7a3400000000, 0x81dde54800000000, 0xc7e6822d00000000, 0x0dab2b8200000000, 0x4b904ce700000000, 0xd836080600000000, 0x9e0d6f6300000000, 0x5440c6cc00000000, 0x127ba1a900000000, 0x1df0042f00000000, 0x5bcb634a00000000, 0x9186cae500000000, 0xd7bdad8000000000, 0x441be96100000000, 0x02208e0400000000, 0xc86d27ab00000000, 0x8e5640ce00000000, 0xaf26dfb200000000, 0xe91db8d700000000, 0x2350117800000000, 0x656b761d00000000, 0xf6cd32fc00000000, 0xb0f6559900000000, 0x7abbfc3600000000, 0x3c809b5300000000, 0x385bc2cf00000000, 0x7e60a5aa00000000, 0xb42d0c0500000000, 0xf2166b6000000000, 0x61b02f8100000000, 0x278b48e400000000, 0xedc6e14b00000000, 0xabfd862e00000000, 0x8a8d195200000000, 0xccb67e3700000000, 0x06fbd79800000000, 0x40c0b0fd00000000, 0xd366f41c00000000, 0x955d937900000000, 0x5f103ad600000000, 0x192b5db300000000, 0x2c40f16b00000000, 0x6a7b960e00000000, 0xa0363fa100000000, 0xe60d58c400000000, 0x75ab1c2500000000, 0x33907b4000000000, 0xf9ddd2ef00000000, 0xbfe6b58a00000000, 0x9e962af600000000, 0xd8ad4d9300000000, 0x12e0e43c00000000, 0x54db835900000000, 0xc77dc7b800000000, 0x8146a0dd00000000, 0x4b0b097200000000, 0x0d306e1700000000, 0x09eb378b00000000, 0x4fd050ee00000000, 0x859df94100000000, 0xc3a69e2400000000, 0x5000dac500000000, 0x163bbda000000000, 0xdc76140f00000000, 0x9a4d736a00000000, 0xbb3dec1600000000, 0xfd068b7300000000, 0x374b22dc00000000, 0x717045b900000000, 0xe2d6015800000000, 0xa4ed663d00000000, 0x6ea0cf9200000000, 0x289ba8f700000000, 0x27100d7100000000, 0x612b6a1400000000, 0xab66c3bb00000000, 0xed5da4de00000000, 0x7efbe03f00000000, 0x38c0875a00000000, 0xf28d2ef500000000, 0xb4b6499000000000, 0x95c6d6ec00000000, 0xd3fdb18900000000, 0x19b0182600000000, 0x5f8b7f4300000000, 0xcc2d3ba200000000, 0x8a165cc700000000, 0x405bf56800000000, 0x0660920d00000000, 0x02bbcb9100000000, 0x4480acf400000000, 0x8ecd055b00000000, 0xc8f6623e00000000, 0x5b5026df00000000, 0x1d6b41ba00000000, 0xd726e81500000000, 0x911d8f7000000000, 0xb06d100c00000000, 0xf656776900000000, 0x3c1bdec600000000, 0x7a20b9a300000000, 0xe986fd4200000000, 0xafbd9a2700000000, 0x65f0338800000000, 0x23cb54ed00000000, 0x3ae0095e00000000, 0x7cdb6e3b00000000, 0xb696c79400000000, 0xf0ada0f100000000, 0x630be41000000000, 0x2530837500000000, 0xef7d2ada00000000, 0xa9464dbf00000000, 0x8836d2c300000000, 0xce0db5a600000000, 0x04401c0900000000, 0x427b7b6c00000000, 0xd1dd3f8d00000000, 0x97e658e800000000, 0x5dabf14700000000, 0x1b90962200000000, 0x1f4bcfbe00000000, 0x5970a8db00000000, 0x933d017400000000, 0xd506661100000000, 0x46a022f000000000, 0x009b459500000000, 0xcad6ec3a00000000, 0x8ced8b5f00000000, 0xad9d142300000000, 0xeba6734600000000, 0x21ebdae900000000, 0x67d0bd8c00000000, 0xf476f96d00000000, 0xb24d9e0800000000, 0x780037a700000000, 0x3e3b50c200000000, 0x31b0f54400000000, 0x778b922100000000, 0xbdc63b8e00000000, 0xfbfd5ceb00000000, 0x685b180a00000000, 0x2e607f6f00000000, 0xe42dd6c000000000, 0xa216b1a500000000, 0x83662ed900000000, 0xc55d49bc00000000, 0x0f10e01300000000, 0x492b877600000000, 0xda8dc39700000000, 0x9cb6a4f200000000, 0x56fb0d5d00000000, 0x10c06a3800000000, 0x141b33a400000000, 0x522054c100000000, 0x986dfd6e00000000, 0xde569a0b00000000, 0x4df0deea00000000, 0x0bcbb98f00000000, 0xc186102000000000, 0x87bd774500000000, 0xa6cde83900000000, 0xe0f68f5c00000000, 0x2abb26f300000000, 0x6c80419600000000, 0xff26057700000000, 0xb91d621200000000, 0x7350cbbd00000000, 0x356bacd800000000}, {0x0000000000000000, 0x9e83da9f00000000, 0x7d01c4e400000000, 0xe3821e7b00000000, 0xbb04f91200000000, 0x2587238d00000000, 0xc6053df600000000, 0x5886e76900000000, 0x7609f22500000000, 0xe88a28ba00000000, 0x0b0836c100000000, 0x958bec5e00000000, 0xcd0d0b3700000000, 0x538ed1a800000000, 0xb00ccfd300000000, 0x2e8f154c00000000, 0xec12e44b00000000, 0x72913ed400000000, 0x911320af00000000, 0x0f90fa3000000000, 0x57161d5900000000, 0xc995c7c600000000, 0x2a17d9bd00000000, 0xb494032200000000, 0x9a1b166e00000000, 0x0498ccf100000000, 0xe71ad28a00000000, 0x7999081500000000, 0x211fef7c00000000, 0xbf9c35e300000000, 0x5c1e2b9800000000, 0xc29df10700000000, 0xd825c89700000000, 0x46a6120800000000, 0xa5240c7300000000, 0x3ba7d6ec00000000, 0x6321318500000000, 0xfda2eb1a00000000, 0x1e20f56100000000, 0x80a32ffe00000000, 0xae2c3ab200000000, 0x30afe02d00000000, 0xd32dfe5600000000, 0x4dae24c900000000, 0x1528c3a000000000, 0x8bab193f00000000, 0x6829074400000000, 0xf6aadddb00000000, 0x34372cdc00000000, 0xaab4f64300000000, 0x4936e83800000000, 0xd7b532a700000000, 0x8f33d5ce00000000, 0x11b00f5100000000, 0xf232112a00000000, 0x6cb1cbb500000000, 0x423edef900000000, 0xdcbd046600000000, 0x3f3f1a1d00000000, 0xa1bcc08200000000, 0xf93a27eb00000000, 0x67b9fd7400000000, 0x843be30f00000000, 0x1ab8399000000000, 0xf14de1f400000000, 0x6fce3b6b00000000, 0x8c4c251000000000, 0x12cfff8f00000000, 0x4a4918e600000000, 0xd4cac27900000000, 0x3748dc0200000000, 0xa9cb069d00000000, 0x874413d100000000, 0x19c7c94e00000000, 0xfa45d73500000000, 0x64c60daa00000000, 0x3c40eac300000000, 0xa2c3305c00000000, 0x41412e2700000000, 0xdfc2f4b800000000, 0x1d5f05bf00000000, 0x83dcdf2000000000, 0x605ec15b00000000, 0xfedd1bc400000000, 0xa65bfcad00000000, 0x38d8263200000000, 0xdb5a384900000000, 0x45d9e2d600000000, 0x6b56f79a00000000, 0xf5d52d0500000000, 0x1657337e00000000, 0x88d4e9e100000000, 0xd0520e8800000000, 0x4ed1d41700000000, 0xad53ca6c00000000, 0x33d010f300000000, 0x2968296300000000, 0xb7ebf3fc00000000, 0x5469ed8700000000, 0xcaea371800000000, 0x926cd07100000000, 0x0cef0aee00000000, 0xef6d149500000000, 0x71eece0a00000000, 0x5f61db4600000000, 0xc1e201d900000000, 0x22601fa200000000, 0xbce3c53d00000000, 0xe465225400000000, 0x7ae6f8cb00000000, 0x9964e6b000000000, 0x07e73c2f00000000, 0xc57acd2800000000, 0x5bf917b700000000, 0xb87b09cc00000000, 0x26f8d35300000000, 0x7e7e343a00000000, 0xe0fdeea500000000, 0x037ff0de00000000, 0x9dfc2a4100000000, 0xb3733f0d00000000, 0x2df0e59200000000, 0xce72fbe900000000, 0x50f1217600000000, 0x0877c61f00000000, 0x96f41c8000000000, 0x757602fb00000000, 0xebf5d86400000000, 0xa39db33200000000, 0x3d1e69ad00000000, 0xde9c77d600000000, 0x401fad4900000000, 0x18994a2000000000, 0x861a90bf00000000, 0x65988ec400000000, 0xfb1b545b00000000, 0xd594411700000000, 0x4b179b8800000000, 0xa89585f300000000, 0x36165f6c00000000, 0x6e90b80500000000, 0xf013629a00000000, 0x13917ce100000000, 0x8d12a67e00000000, 0x4f8f577900000000, 0xd10c8de600000000, 0x328e939d00000000, 0xac0d490200000000, 0xf48bae6b00000000, 0x6a0874f400000000, 0x898a6a8f00000000, 0x1709b01000000000, 0x3986a55c00000000, 0xa7057fc300000000, 0x448761b800000000, 0xda04bb2700000000, 0x82825c4e00000000, 0x1c0186d100000000, 0xff8398aa00000000, 0x6100423500000000, 0x7bb87ba500000000, 0xe53ba13a00000000, 0x06b9bf4100000000, 0x983a65de00000000, 0xc0bc82b700000000, 0x5e3f582800000000, 0xbdbd465300000000, 0x233e9ccc00000000, 0x0db1898000000000, 0x9332531f00000000, 0x70b04d6400000000, 0xee3397fb00000000, 0xb6b5709200000000, 0x2836aa0d00000000, 0xcbb4b47600000000, 0x55376ee900000000, 0x97aa9fee00000000, 0x0929457100000000, 0xeaab5b0a00000000, 0x7428819500000000, 0x2cae66fc00000000, 0xb22dbc6300000000, 0x51afa21800000000, 0xcf2c788700000000, 0xe1a36dcb00000000, 0x7f20b75400000000, 0x9ca2a92f00000000, 0x022173b000000000, 0x5aa794d900000000, 0xc4244e4600000000, 0x27a6503d00000000, 0xb9258aa200000000, 0x52d052c600000000, 0xcc53885900000000, 0x2fd1962200000000, 0xb1524cbd00000000, 0xe9d4abd400000000, 0x7757714b00000000, 0x94d56f3000000000, 0x0a56b5af00000000, 0x24d9a0e300000000, 0xba5a7a7c00000000, 0x59d8640700000000, 0xc75bbe9800000000, 0x9fdd59f100000000, 0x015e836e00000000, 0xe2dc9d1500000000, 0x7c5f478a00000000, 0xbec2b68d00000000, 0x20416c1200000000, 0xc3c3726900000000, 0x5d40a8f600000000, 0x05c64f9f00000000, 0x9b45950000000000, 0x78c78b7b00000000, 0xe64451e400000000, 0xc8cb44a800000000, 0x56489e3700000000, 0xb5ca804c00000000, 0x2b495ad300000000, 0x73cfbdba00000000, 0xed4c672500000000, 0x0ece795e00000000, 0x904da3c100000000, 0x8af59a5100000000, 0x147640ce00000000, 0xf7f45eb500000000, 0x6977842a00000000, 0x31f1634300000000, 0xaf72b9dc00000000, 0x4cf0a7a700000000, 0xd2737d3800000000, 0xfcfc687400000000, 0x627fb2eb00000000, 0x81fdac9000000000, 0x1f7e760f00000000, 0x47f8916600000000, 0xd97b4bf900000000, 0x3af9558200000000, 0xa47a8f1d00000000, 0x66e77e1a00000000, 0xf864a48500000000, 0x1be6bafe00000000, 0x8565606100000000, 0xdde3870800000000, 0x43605d9700000000, 0xa0e243ec00000000, 0x3e61997300000000, 0x10ee8c3f00000000, 0x8e6d56a000000000, 0x6def48db00000000, 0xf36c924400000000, 0xabea752d00000000, 0x3569afb200000000, 0xd6ebb1c900000000, 0x48686b5600000000}, {0x0000000000000000, 0xc064281700000000, 0x80c9502e00000000, 0x40ad783900000000, 0x0093a15c00000000, 0xc0f7894b00000000, 0x805af17200000000, 0x403ed96500000000, 0x002643b900000000, 0xc0426bae00000000, 0x80ef139700000000, 0x408b3b8000000000, 0x00b5e2e500000000, 0xc0d1caf200000000, 0x807cb2cb00000000, 0x40189adc00000000, 0x414af7a900000000, 0x812edfbe00000000, 0xc183a78700000000, 0x01e78f9000000000, 0x41d956f500000000, 0x81bd7ee200000000, 0xc11006db00000000, 0x01742ecc00000000, 0x416cb41000000000, 0x81089c0700000000, 0xc1a5e43e00000000, 0x01c1cc2900000000, 0x41ff154c00000000, 0x819b3d5b00000000, 0xc136456200000000, 0x01526d7500000000, 0xc3929f8800000000, 0x03f6b79f00000000, 0x435bcfa600000000, 0x833fe7b100000000, 0xc3013ed400000000, 0x036516c300000000, 0x43c86efa00000000, 0x83ac46ed00000000, 0xc3b4dc3100000000, 0x03d0f42600000000, 0x437d8c1f00000000, 0x8319a40800000000, 0xc3277d6d00000000, 0x0343557a00000000, 0x43ee2d4300000000, 0x838a055400000000, 0x82d8682100000000, 0x42bc403600000000, 0x0211380f00000000, 0xc275101800000000, 0x824bc97d00000000, 0x422fe16a00000000, 0x0282995300000000, 0xc2e6b14400000000, 0x82fe2b9800000000, 0x429a038f00000000, 0x02377bb600000000, 0xc25353a100000000, 0x826d8ac400000000, 0x4209a2d300000000, 0x02a4daea00000000, 0xc2c0f2fd00000000, 0xc7234eca00000000, 0x074766dd00000000, 0x47ea1ee400000000, 0x878e36f300000000, 0xc7b0ef9600000000, 0x07d4c78100000000, 0x4779bfb800000000, 0x871d97af00000000, 0xc7050d7300000000, 0x0761256400000000, 0x47cc5d5d00000000, 0x87a8754a00000000, 0xc796ac2f00000000, 0x07f2843800000000, 0x475ffc0100000000, 0x873bd41600000000, 0x8669b96300000000, 0x460d917400000000, 0x06a0e94d00000000, 0xc6c4c15a00000000, 0x86fa183f00000000, 0x469e302800000000, 0x0633481100000000, 0xc657600600000000, 0x864ffada00000000, 0x462bd2cd00000000, 0x0686aaf400000000, 0xc6e282e300000000, 0x86dc5b8600000000, 0x46b8739100000000, 0x06150ba800000000, 0xc67123bf00000000, 0x04b1d14200000000, 0xc4d5f95500000000, 0x8478816c00000000, 0x441ca97b00000000, 0x0422701e00000000, 0xc446580900000000, 0x84eb203000000000, 0x448f082700000000, 0x049792fb00000000, 0xc4f3baec00000000, 0x845ec2d500000000, 0x443aeac200000000, 0x040433a700000000, 0xc4601bb000000000, 0x84cd638900000000, 0x44a94b9e00000000, 0x45fb26eb00000000, 0x859f0efc00000000, 0xc53276c500000000, 0x05565ed200000000, 0x456887b700000000, 0x850cafa000000000, 0xc5a1d79900000000, 0x05c5ff8e00000000, 0x45dd655200000000, 0x85b94d4500000000, 0xc514357c00000000, 0x05701d6b00000000, 0x454ec40e00000000, 0x852aec1900000000, 0xc587942000000000, 0x05e3bc3700000000, 0xcf41ed4f00000000, 0x0f25c55800000000, 0x4f88bd6100000000, 0x8fec957600000000, 0xcfd24c1300000000, 0x0fb6640400000000, 0x4f1b1c3d00000000, 0x8f7f342a00000000, 0xcf67aef600000000, 0x0f0386e100000000, 0x4faefed800000000, 0x8fcad6cf00000000, 0xcff40faa00000000, 0x0f9027bd00000000, 0x4f3d5f8400000000, 0x8f59779300000000, 0x8e0b1ae600000000, 0x4e6f32f100000000, 0x0ec24ac800000000, 0xcea662df00000000, 0x8e98bbba00000000, 0x4efc93ad00000000, 0x0e51eb9400000000, 0xce35c38300000000, 0x8e2d595f00000000, 0x4e49714800000000, 0x0ee4097100000000, 0xce80216600000000, 0x8ebef80300000000, 0x4edad01400000000, 0x0e77a82d00000000, 0xce13803a00000000, 0x0cd372c700000000, 0xccb75ad000000000, 0x8c1a22e900000000, 0x4c7e0afe00000000, 0x0c40d39b00000000, 0xcc24fb8c00000000, 0x8c8983b500000000, 0x4cedaba200000000, 0x0cf5317e00000000, 0xcc91196900000000, 0x8c3c615000000000, 0x4c58494700000000, 0x0c66902200000000, 0xcc02b83500000000, 0x8cafc00c00000000, 0x4ccbe81b00000000, 0x4d99856e00000000, 0x8dfdad7900000000, 0xcd50d54000000000, 0x0d34fd5700000000, 0x4d0a243200000000, 0x8d6e0c2500000000, 0xcdc3741c00000000, 0x0da75c0b00000000, 0x4dbfc6d700000000, 0x8ddbeec000000000, 0xcd7696f900000000, 0x0d12beee00000000, 0x4d2c678b00000000, 0x8d484f9c00000000, 0xcde537a500000000, 0x0d811fb200000000, 0x0862a38500000000, 0xc8068b9200000000, 0x88abf3ab00000000, 0x48cfdbbc00000000, 0x08f102d900000000, 0xc8952ace00000000, 0x883852f700000000, 0x485c7ae000000000, 0x0844e03c00000000, 0xc820c82b00000000, 0x888db01200000000, 0x48e9980500000000, 0x08d7416000000000, 0xc8b3697700000000, 0x881e114e00000000, 0x487a395900000000, 0x4928542c00000000, 0x894c7c3b00000000, 0xc9e1040200000000, 0x09852c1500000000, 0x49bbf57000000000, 0x89dfdd6700000000, 0xc972a55e00000000, 0x09168d4900000000, 0x490e179500000000, 0x896a3f8200000000, 0xc9c747bb00000000, 0x09a36fac00000000, 0x499db6c900000000, 0x89f99ede00000000, 0xc954e6e700000000, 0x0930cef000000000, 0xcbf03c0d00000000, 0x0b94141a00000000, 0x4b396c2300000000, 0x8b5d443400000000, 0xcb639d5100000000, 0x0b07b54600000000, 0x4baacd7f00000000, 0x8bcee56800000000, 0xcbd67fb400000000, 0x0bb257a300000000, 0x4b1f2f9a00000000, 0x8b7b078d00000000, 0xcb45dee800000000, 0x0b21f6ff00000000, 0x4b8c8ec600000000, 0x8be8a6d100000000, 0x8abacba400000000, 0x4adee3b300000000, 0x0a739b8a00000000, 0xca17b39d00000000, 0x8a296af800000000, 0x4a4d42ef00000000, 0x0ae03ad600000000, 0xca8412c100000000, 0x8a9c881d00000000, 0x4af8a00a00000000, 0x0a55d83300000000, 0xca31f02400000000, 0x8a0f294100000000, 0x4a6b015600000000, 0x0ac6796f00000000, 0xcaa2517800000000}, {0x0000000000000000, 0xd4ea739b00000000, 0xe9d396ed00000000, 0x3d39e57600000000, 0x93a15c0000000000, 0x474b2f9b00000000, 0x7a72caed00000000, 0xae98b97600000000, 0x2643b90000000000, 0xf2a9ca9b00000000, 0xcf902fed00000000, 0x1b7a5c7600000000, 0xb5e2e50000000000, 0x6108969b00000000, 0x5c3173ed00000000, 0x88db007600000000, 0x4c86720100000000, 0x986c019a00000000, 0xa555e4ec00000000, 0x71bf977700000000, 0xdf272e0100000000, 0x0bcd5d9a00000000, 0x36f4b8ec00000000, 0xe21ecb7700000000, 0x6ac5cb0100000000, 0xbe2fb89a00000000, 0x83165dec00000000, 0x57fc2e7700000000, 0xf964970100000000, 0x2d8ee49a00000000, 0x10b701ec00000000, 0xc45d727700000000, 0x980ce50200000000, 0x4ce6969900000000, 0x71df73ef00000000, 0xa535007400000000, 0x0badb90200000000, 0xdf47ca9900000000, 0xe27e2fef00000000, 0x36945c7400000000, 0xbe4f5c0200000000, 0x6aa52f9900000000, 0x579ccaef00000000, 0x8376b97400000000, 0x2dee000200000000, 0xf904739900000000, 0xc43d96ef00000000, 0x10d7e57400000000, 0xd48a970300000000, 0x0060e49800000000, 0x3d5901ee00000000, 0xe9b3727500000000, 0x472bcb0300000000, 0x93c1b89800000000, 0xaef85dee00000000, 0x7a122e7500000000, 0xf2c92e0300000000, 0x26235d9800000000, 0x1b1ab8ee00000000, 0xcff0cb7500000000, 0x6168720300000000, 0xb582019800000000, 0x88bbe4ee00000000, 0x5c51977500000000, 0x3019ca0500000000, 0xe4f3b99e00000000, 0xd9ca5ce800000000, 0x0d202f7300000000, 0xa3b8960500000000, 0x7752e59e00000000, 0x4a6b00e800000000, 0x9e81737300000000, 0x165a730500000000, 0xc2b0009e00000000, 0xff89e5e800000000, 0x2b63967300000000, 0x85fb2f0500000000, 0x51115c9e00000000, 0x6c28b9e800000000, 0xb8c2ca7300000000, 0x7c9fb80400000000, 0xa875cb9f00000000, 0x954c2ee900000000, 0x41a65d7200000000, 0xef3ee40400000000, 0x3bd4979f00000000, 0x06ed72e900000000, 0xd207017200000000, 0x5adc010400000000, 0x8e36729f00000000, 0xb30f97e900000000, 0x67e5e47200000000, 0xc97d5d0400000000, 0x1d972e9f00000000, 0x20aecbe900000000, 0xf444b87200000000, 0xa8152f0700000000, 0x7cff5c9c00000000, 0x41c6b9ea00000000, 0x952cca7100000000, 0x3bb4730700000000, 0xef5e009c00000000, 0xd267e5ea00000000, 0x068d967100000000, 0x8e56960700000000, 0x5abce59c00000000, 0x678500ea00000000, 0xb36f737100000000, 0x1df7ca0700000000, 0xc91db99c00000000, 0xf4245cea00000000, 0x20ce2f7100000000, 0xe4935d0600000000, 0x30792e9d00000000, 0x0d40cbeb00000000, 0xd9aab87000000000, 0x7732010600000000, 0xa3d8729d00000000, 0x9ee197eb00000000, 0x4a0be47000000000, 0xc2d0e40600000000, 0x163a979d00000000, 0x2b0372eb00000000, 0xffe9017000000000, 0x5171b80600000000, 0x859bcb9d00000000, 0xb8a22eeb00000000, 0x6c485d7000000000, 0x6032940b00000000, 0xb4d8e79000000000, 0x89e102e600000000, 0x5d0b717d00000000, 0xf393c80b00000000, 0x2779bb9000000000, 0x1a405ee600000000, 0xceaa2d7d00000000, 0x46712d0b00000000, 0x929b5e9000000000, 0xafa2bbe600000000, 0x7b48c87d00000000, 0xd5d0710b00000000, 0x013a029000000000, 0x3c03e7e600000000, 0xe8e9947d00000000, 0x2cb4e60a00000000, 0xf85e959100000000, 0xc56770e700000000, 0x118d037c00000000, 0xbf15ba0a00000000, 0x6bffc99100000000, 0x56c62ce700000000, 0x822c5f7c00000000, 0x0af75f0a00000000, 0xde1d2c9100000000, 0xe324c9e700000000, 0x37ceba7c00000000, 0x9956030a00000000, 0x4dbc709100000000, 0x708595e700000000, 0xa46fe67c00000000, 0xf83e710900000000, 0x2cd4029200000000, 0x11ede7e400000000, 0xc507947f00000000, 0x6b9f2d0900000000, 0xbf755e9200000000, 0x824cbbe400000000, 0x56a6c87f00000000, 0xde7dc80900000000, 0x0a97bb9200000000, 0x37ae5ee400000000, 0xe3442d7f00000000, 0x4ddc940900000000, 0x9936e79200000000, 0xa40f02e400000000, 0x70e5717f00000000, 0xb4b8030800000000, 0x6052709300000000, 0x5d6b95e500000000, 0x8981e67e00000000, 0x27195f0800000000, 0xf3f32c9300000000, 0xcecac9e500000000, 0x1a20ba7e00000000, 0x92fbba0800000000, 0x4611c99300000000, 0x7b282ce500000000, 0xafc25f7e00000000, 0x015ae60800000000, 0xd5b0959300000000, 0xe88970e500000000, 0x3c63037e00000000, 0x502b5e0e00000000, 0x84c12d9500000000, 0xb9f8c8e300000000, 0x6d12bb7800000000, 0xc38a020e00000000, 0x1760719500000000, 0x2a5994e300000000, 0xfeb3e77800000000, 0x7668e70e00000000, 0xa282949500000000, 0x9fbb71e300000000, 0x4b51027800000000, 0xe5c9bb0e00000000, 0x3123c89500000000, 0x0c1a2de300000000, 0xd8f05e7800000000, 0x1cad2c0f00000000, 0xc8475f9400000000, 0xf57ebae200000000, 0x2194c97900000000, 0x8f0c700f00000000, 0x5be6039400000000, 0x66dfe6e200000000, 0xb235957900000000, 0x3aee950f00000000, 0xee04e69400000000, 0xd33d03e200000000, 0x07d7707900000000, 0xa94fc90f00000000, 0x7da5ba9400000000, 0x409c5fe200000000, 0x94762c7900000000, 0xc827bb0c00000000, 0x1ccdc89700000000, 0x21f42de100000000, 0xf51e5e7a00000000, 0x5b86e70c00000000, 0x8f6c949700000000, 0xb25571e100000000, 0x66bf027a00000000, 0xee64020c00000000, 0x3a8e719700000000, 0x07b794e100000000, 0xd35de77a00000000, 0x7dc55e0c00000000, 0xa92f2d9700000000, 0x9416c8e100000000, 0x40fcbb7a00000000, 0x84a1c90d00000000, 0x504bba9600000000, 0x6d725fe000000000, 0xb9982c7b00000000, 0x1700950d00000000, 0xc3eae69600000000, 0xfed303e000000000, 0x2a39707b00000000, 0xa2e2700d00000000, 0x7608039600000000, 0x4b31e6e000000000, 0x9fdb957b00000000, 0x31432c0d00000000, 0xe5a95f9600000000, 0xd890bae000000000, 0x0c7ac97b00000000}, {0x0000000000000000, 0x2765258100000000, 0x0fcc3bd900000000, 0x28a91e5800000000, 0x5f9e066900000000, 0x78fb23e800000000, 0x50523db000000000, 0x7737183100000000, 0xbe3c0dd200000000, 0x9959285300000000, 0xb1f0360b00000000, 0x9695138a00000000, 0xe1a20bbb00000000, 0xc6c72e3a00000000, 0xee6e306200000000, 0xc90b15e300000000, 0x3d7f6b7f00000000, 0x1a1a4efe00000000, 0x32b350a600000000, 0x15d6752700000000, 0x62e16d1600000000, 0x4584489700000000, 0x6d2d56cf00000000, 0x4a48734e00000000, 0x834366ad00000000, 0xa426432c00000000, 0x8c8f5d7400000000, 0xabea78f500000000, 0xdcdd60c400000000, 0xfbb8454500000000, 0xd3115b1d00000000, 0xf4747e9c00000000, 0x7afed6fe00000000, 0x5d9bf37f00000000, 0x7532ed2700000000, 0x5257c8a600000000, 0x2560d09700000000, 0x0205f51600000000, 0x2aaceb4e00000000, 0x0dc9cecf00000000, 0xc4c2db2c00000000, 0xe3a7fead00000000, 0xcb0ee0f500000000, 0xec6bc57400000000, 0x9b5cdd4500000000, 0xbc39f8c400000000, 0x9490e69c00000000, 0xb3f5c31d00000000, 0x4781bd8100000000, 0x60e4980000000000, 0x484d865800000000, 0x6f28a3d900000000, 0x181fbbe800000000, 0x3f7a9e6900000000, 0x17d3803100000000, 0x30b6a5b000000000, 0xf9bdb05300000000, 0xded895d200000000, 0xf6718b8a00000000, 0xd114ae0b00000000, 0xa623b63a00000000, 0x814693bb00000000, 0xa9ef8de300000000, 0x8e8aa86200000000, 0xb5fadc2600000000, 0x929ff9a700000000, 0xba36e7ff00000000, 0x9d53c27e00000000, 0xea64da4f00000000, 0xcd01ffce00000000, 0xe5a8e19600000000, 0xc2cdc41700000000, 0x0bc6d1f400000000, 0x2ca3f47500000000, 0x040aea2d00000000, 0x236fcfac00000000, 0x5458d79d00000000, 0x733df21c00000000, 0x5b94ec4400000000, 0x7cf1c9c500000000, 0x8885b75900000000, 0xafe092d800000000, 0x87498c8000000000, 0xa02ca90100000000, 0xd71bb13000000000, 0xf07e94b100000000, 0xd8d78ae900000000, 0xffb2af6800000000, 0x36b9ba8b00000000, 0x11dc9f0a00000000, 0x3975815200000000, 0x1e10a4d300000000, 0x6927bce200000000, 0x4e42996300000000, 0x66eb873b00000000, 0x418ea2ba00000000, 0xcf040ad800000000, 0xe8612f5900000000, 0xc0c8310100000000, 0xe7ad148000000000, 0x909a0cb100000000, 0xb7ff293000000000, 0x9f56376800000000, 0xb83312e900000000, 0x7138070a00000000, 0x565d228b00000000, 0x7ef43cd300000000, 0x5991195200000000, 0x2ea6016300000000, 0x09c324e200000000, 0x216a3aba00000000, 0x060f1f3b00000000, 0xf27b61a700000000, 0xd51e442600000000, 0xfdb75a7e00000000, 0xdad27fff00000000, 0xade567ce00000000, 0x8a80424f00000000, 0xa2295c1700000000, 0x854c799600000000, 0x4c476c7500000000, 0x6b2249f400000000, 0x438b57ac00000000, 0x64ee722d00000000, 0x13d96a1c00000000, 0x34bc4f9d00000000, 0x1c1551c500000000, 0x3b70744400000000, 0x6af5b94d00000000, 0x4d909ccc00000000, 0x6539829400000000, 0x425ca71500000000, 0x356bbf2400000000, 0x120e9aa500000000, 0x3aa784fd00000000, 0x1dc2a17c00000000, 0xd4c9b49f00000000, 0xf3ac911e00000000, 0xdb058f4600000000, 0xfc60aac700000000, 0x8b57b2f600000000, 0xac32977700000000, 0x849b892f00000000, 0xa3feacae00000000, 0x578ad23200000000, 0x70eff7b300000000, 0x5846e9eb00000000, 0x7f23cc6a00000000, 0x0814d45b00000000, 0x2f71f1da00000000, 0x07d8ef8200000000, 0x20bdca0300000000, 0xe9b6dfe000000000, 0xced3fa6100000000, 0xe67ae43900000000, 0xc11fc1b800000000, 0xb628d98900000000, 0x914dfc0800000000, 0xb9e4e25000000000, 0x9e81c7d100000000, 0x100b6fb300000000, 0x376e4a3200000000, 0x1fc7546a00000000, 0x38a271eb00000000, 0x4f9569da00000000, 0x68f04c5b00000000, 0x4059520300000000, 0x673c778200000000, 0xae37626100000000, 0x895247e000000000, 0xa1fb59b800000000, 0x869e7c3900000000, 0xf1a9640800000000, 0xd6cc418900000000, 0xfe655fd100000000, 0xd9007a5000000000, 0x2d7404cc00000000, 0x0a11214d00000000, 0x22b83f1500000000, 0x05dd1a9400000000, 0x72ea02a500000000, 0x558f272400000000, 0x7d26397c00000000, 0x5a431cfd00000000, 0x9348091e00000000, 0xb42d2c9f00000000, 0x9c8432c700000000, 0xbbe1174600000000, 0xccd60f7700000000, 0xebb32af600000000, 0xc31a34ae00000000, 0xe47f112f00000000, 0xdf0f656b00000000, 0xf86a40ea00000000, 0xd0c35eb200000000, 0xf7a67b3300000000, 0x8091630200000000, 0xa7f4468300000000, 0x8f5d58db00000000, 0xa8387d5a00000000, 0x613368b900000000, 0x46564d3800000000, 0x6eff536000000000, 0x499a76e100000000, 0x3ead6ed000000000, 0x19c84b5100000000, 0x3161550900000000, 0x1604708800000000, 0xe2700e1400000000, 0xc5152b9500000000, 0xedbc35cd00000000, 0xcad9104c00000000, 0xbdee087d00000000, 0x9a8b2dfc00000000, 0xb22233a400000000, 0x9547162500000000, 0x5c4c03c600000000, 0x7b29264700000000, 0x5380381f00000000, 0x74e51d9e00000000, 0x03d205af00000000, 0x24b7202e00000000, 0x0c1e3e7600000000, 0x2b7b1bf700000000, 0xa5f1b39500000000, 0x8294961400000000, 0xaa3d884c00000000, 0x8d58adcd00000000, 0xfa6fb5fc00000000, 0xdd0a907d00000000, 0xf5a38e2500000000, 0xd2c6aba400000000, 0x1bcdbe4700000000, 0x3ca89bc600000000, 0x1401859e00000000, 0x3364a01f00000000, 0x4453b82e00000000, 0x63369daf00000000, 0x4b9f83f700000000, 0x6cfaa67600000000, 0x988ed8ea00000000, 0xbfebfd6b00000000, 0x9742e33300000000, 0xb027c6b200000000, 0xc710de8300000000, 0xe075fb0200000000, 0xc8dce55a00000000, 0xefb9c0db00000000, 0x26b2d53800000000, 0x01d7f0b900000000, 0x297eeee100000000, 0x0e1bcb6000000000, 0x792cd35100000000, 0x5e49f6d000000000, 0x76e0e88800000000, 0x5185cd0900000000}}; #else /* W == 4 */ local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, 0x36197165}, {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, 0x1a3b93aa}, {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, 0xe147d714}, {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, 0x494f0c4b}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x00000000, 0x43147b17, 0x8628f62e, 0xc53c8d39, 0x0c51ec5d, 0x4f45974a, 0x8a791a73, 0xc96d6164, 0x18a2d8bb, 0x5bb6a3ac, 0x9e8a2e95, 0xdd9e5582, 0x14f334e6, 0x57e74ff1, 0x92dbc2c8, 0xd1cfb9df, 0x7142c0ac, 0x3256bbbb, 0xf76a3682, 0xb47e4d95, 0x7d132cf1, 0x3e0757e6, 0xfb3bdadf, 0xb82fa1c8, 0x69e01817, 0x2af46300, 0xefc8ee39, 0xacdc952e, 0x65b1f44a, 0x26a58f5d, 0xe3990264, 0xa08d7973, 0xa382f182, 0xe0968a95, 0x25aa07ac, 0x66be7cbb, 0xafd31ddf, 0xecc766c8, 0x29fbebf1, 0x6aef90e6, 0xbb202939, 0xf834522e, 0x3d08df17, 0x7e1ca400, 0xb771c564, 0xf465be73, 0x3159334a, 0x724d485d, 0xd2c0312e, 0x91d44a39, 0x54e8c700, 0x17fcbc17, 0xde91dd73, 0x9d85a664, 0x58b92b5d, 0x1bad504a, 0xca62e995, 0x89769282, 0x4c4a1fbb, 0x0f5e64ac, 0xc63305c8, 0x85277edf, 0x401bf3e6, 0x030f88f1, 0x070392de, 0x4417e9c9, 0x812b64f0, 0xc23f1fe7, 0x0b527e83, 0x48460594, 0x8d7a88ad, 0xce6ef3ba, 0x1fa14a65, 0x5cb53172, 0x9989bc4b, 0xda9dc75c, 0x13f0a638, 0x50e4dd2f, 0x95d85016, 0xd6cc2b01, 0x76415272, 0x35552965, 0xf069a45c, 0xb37ddf4b, 0x7a10be2f, 0x3904c538, 0xfc384801, 0xbf2c3316, 0x6ee38ac9, 0x2df7f1de, 0xe8cb7ce7, 0xabdf07f0, 0x62b26694, 0x21a61d83, 0xe49a90ba, 0xa78eebad, 0xa481635c, 0xe795184b, 0x22a99572, 0x61bdee65, 0xa8d08f01, 0xebc4f416, 0x2ef8792f, 0x6dec0238, 0xbc23bbe7, 0xff37c0f0, 0x3a0b4dc9, 0x791f36de, 0xb07257ba, 0xf3662cad, 0x365aa194, 0x754eda83, 0xd5c3a3f0, 0x96d7d8e7, 0x53eb55de, 0x10ff2ec9, 0xd9924fad, 0x9a8634ba, 0x5fbab983, 0x1caec294, 0xcd617b4b, 0x8e75005c, 0x4b498d65, 0x085df672, 0xc1309716, 0x8224ec01, 0x47186138, 0x040c1a2f, 0x4f005566, 0x0c142e71, 0xc928a348, 0x8a3cd85f, 0x4351b93b, 0x0045c22c, 0xc5794f15, 0x866d3402, 0x57a28ddd, 0x14b6f6ca, 0xd18a7bf3, 0x929e00e4, 0x5bf36180, 0x18e71a97, 0xdddb97ae, 0x9ecfecb9, 0x3e4295ca, 0x7d56eedd, 0xb86a63e4, 0xfb7e18f3, 0x32137997, 0x71070280, 0xb43b8fb9, 0xf72ff4ae, 0x26e04d71, 0x65f43666, 0xa0c8bb5f, 0xe3dcc048, 0x2ab1a12c, 0x69a5da3b, 0xac995702, 0xef8d2c15, 0xec82a4e4, 0xaf96dff3, 0x6aaa52ca, 0x29be29dd, 0xe0d348b9, 0xa3c733ae, 0x66fbbe97, 0x25efc580, 0xf4207c5f, 0xb7340748, 0x72088a71, 0x311cf166, 0xf8719002, 0xbb65eb15, 0x7e59662c, 0x3d4d1d3b, 0x9dc06448, 0xded41f5f, 0x1be89266, 0x58fce971, 0x91918815, 0xd285f302, 0x17b97e3b, 0x54ad052c, 0x8562bcf3, 0xc676c7e4, 0x034a4add, 0x405e31ca, 0x893350ae, 0xca272bb9, 0x0f1ba680, 0x4c0fdd97, 0x4803c7b8, 0x0b17bcaf, 0xce2b3196, 0x8d3f4a81, 0x44522be5, 0x074650f2, 0xc27addcb, 0x816ea6dc, 0x50a11f03, 0x13b56414, 0xd689e92d, 0x959d923a, 0x5cf0f35e, 0x1fe48849, 0xdad80570, 0x99cc7e67, 0x39410714, 0x7a557c03, 0xbf69f13a, 0xfc7d8a2d, 0x3510eb49, 0x7604905e, 0xb3381d67, 0xf02c6670, 0x21e3dfaf, 0x62f7a4b8, 0xa7cb2981, 0xe4df5296, 0x2db233f2, 0x6ea648e5, 0xab9ac5dc, 0xe88ebecb, 0xeb81363a, 0xa8954d2d, 0x6da9c014, 0x2ebdbb03, 0xe7d0da67, 0xa4c4a170, 0x61f82c49, 0x22ec575e, 0xf323ee81, 0xb0379596, 0x750b18af, 0x361f63b8, 0xff7202dc, 0xbc6679cb, 0x795af4f2, 0x3a4e8fe5, 0x9ac3f696, 0xd9d78d81, 0x1ceb00b8, 0x5fff7baf, 0x96921acb, 0xd58661dc, 0x10baece5, 0x53ae97f2, 0x82612e2d, 0xc175553a, 0x0449d803, 0x475da314, 0x8e30c270, 0xcd24b967, 0x0818345e, 0x4b0c4f49}, {0x00000000, 0x3e6bc2ef, 0x3dd0f504, 0x03bb37eb, 0x7aa0eb09, 0x44cb29e6, 0x47701e0d, 0x791bdce2, 0xf440d713, 0xca2b15fc, 0xc9902217, 0xf7fbe0f8, 0x8ee03c1a, 0xb08bfef5, 0xb330c91e, 0x8d5b0bf1, 0xe881ae27, 0xd6ea6cc8, 0xd5515b23, 0xeb3a99cc, 0x9221452e, 0xac4a87c1, 0xaff1b02a, 0x919a72c5, 0x1cc17934, 0x22aabbdb, 0x21118c30, 0x1f7a4edf, 0x6661923d, 0x580a50d2, 0x5bb16739, 0x65daa5d6, 0xd0035d4f, 0xee689fa0, 0xedd3a84b, 0xd3b86aa4, 0xaaa3b646, 0x94c874a9, 0x97734342, 0xa91881ad, 0x24438a5c, 0x1a2848b3, 0x19937f58, 0x27f8bdb7, 0x5ee36155, 0x6088a3ba, 0x63339451, 0x5d5856be, 0x3882f368, 0x06e93187, 0x0552066c, 0x3b39c483, 0x42221861, 0x7c49da8e, 0x7ff2ed65, 0x41992f8a, 0xccc2247b, 0xf2a9e694, 0xf112d17f, 0xcf791390, 0xb662cf72, 0x88090d9d, 0x8bb23a76, 0xb5d9f899, 0xa007ba9e, 0x9e6c7871, 0x9dd74f9a, 0xa3bc8d75, 0xdaa75197, 0xe4cc9378, 0xe777a493, 0xd91c667c, 0x54476d8d, 0x6a2caf62, 0x69979889, 0x57fc5a66, 0x2ee78684, 0x108c446b, 0x13377380, 0x2d5cb16f, 0x488614b9, 0x76edd656, 0x7556e1bd, 0x4b3d2352, 0x3226ffb0, 0x0c4d3d5f, 0x0ff60ab4, 0x319dc85b, 0xbcc6c3aa, 0x82ad0145, 0x811636ae, 0xbf7df441, 0xc66628a3, 0xf80dea4c, 0xfbb6dda7, 0xc5dd1f48, 0x7004e7d1, 0x4e6f253e, 0x4dd412d5, 0x73bfd03a, 0x0aa40cd8, 0x34cfce37, 0x3774f9dc, 0x091f3b33, 0x844430c2, 0xba2ff22d, 0xb994c5c6, 0x87ff0729, 0xfee4dbcb, 0xc08f1924, 0xc3342ecf, 0xfd5fec20, 0x988549f6, 0xa6ee8b19, 0xa555bcf2, 0x9b3e7e1d, 0xe225a2ff, 0xdc4e6010, 0xdff557fb, 0xe19e9514, 0x6cc59ee5, 0x52ae5c0a, 0x51156be1, 0x6f7ea90e, 0x166575ec, 0x280eb703, 0x2bb580e8, 0x15de4207, 0x010905e6, 0x3f62c709, 0x3cd9f0e2, 0x02b2320d, 0x7ba9eeef, 0x45c22c00, 0x46791beb, 0x7812d904, 0xf549d2f5, 0xcb22101a, 0xc89927f1, 0xf6f2e51e, 0x8fe939fc, 0xb182fb13, 0xb239ccf8, 0x8c520e17, 0xe988abc1, 0xd7e3692e, 0xd4585ec5, 0xea339c2a, 0x932840c8, 0xad438227, 0xaef8b5cc, 0x90937723, 0x1dc87cd2, 0x23a3be3d, 0x201889d6, 0x1e734b39, 0x676897db, 0x59035534, 0x5ab862df, 0x64d3a030, 0xd10a58a9, 0xef619a46, 0xecdaadad, 0xd2b16f42, 0xabaab3a0, 0x95c1714f, 0x967a46a4, 0xa811844b, 0x254a8fba, 0x1b214d55, 0x189a7abe, 0x26f1b851, 0x5fea64b3, 0x6181a65c, 0x623a91b7, 0x5c515358, 0x398bf68e, 0x07e03461, 0x045b038a, 0x3a30c165, 0x432b1d87, 0x7d40df68, 0x7efbe883, 0x40902a6c, 0xcdcb219d, 0xf3a0e372, 0xf01bd499, 0xce701676, 0xb76bca94, 0x8900087b, 0x8abb3f90, 0xb4d0fd7f, 0xa10ebf78, 0x9f657d97, 0x9cde4a7c, 0xa2b58893, 0xdbae5471, 0xe5c5969e, 0xe67ea175, 0xd815639a, 0x554e686b, 0x6b25aa84, 0x689e9d6f, 0x56f55f80, 0x2fee8362, 0x1185418d, 0x123e7666, 0x2c55b489, 0x498f115f, 0x77e4d3b0, 0x745fe45b, 0x4a3426b4, 0x332ffa56, 0x0d4438b9, 0x0eff0f52, 0x3094cdbd, 0xbdcfc64c, 0x83a404a3, 0x801f3348, 0xbe74f1a7, 0xc76f2d45, 0xf904efaa, 0xfabfd841, 0xc4d41aae, 0x710de237, 0x4f6620d8, 0x4cdd1733, 0x72b6d5dc, 0x0bad093e, 0x35c6cbd1, 0x367dfc3a, 0x08163ed5, 0x854d3524, 0xbb26f7cb, 0xb89dc020, 0x86f602cf, 0xffedde2d, 0xc1861cc2, 0xc23d2b29, 0xfc56e9c6, 0x998c4c10, 0xa7e78eff, 0xa45cb914, 0x9a377bfb, 0xe32ca719, 0xdd4765f6, 0xdefc521d, 0xe09790f2, 0x6dcc9b03, 0x53a759ec, 0x501c6e07, 0x6e77ace8, 0x176c700a, 0x2907b2e5, 0x2abc850e, 0x14d747e1}, {0x00000000, 0xc0df8ec1, 0xc1b96c58, 0x0166e299, 0x8273d9b0, 0x42ac5771, 0x43cab5e8, 0x83153b29, 0x45e1c3ba, 0x853e4d7b, 0x8458afe2, 0x44872123, 0xc7921a0a, 0x074d94cb, 0x062b7652, 0xc6f4f893, 0xcbc4f6ae, 0x0b1b786f, 0x0a7d9af6, 0xcaa21437, 0x49b72f1e, 0x8968a1df, 0x880e4346, 0x48d1cd87, 0x8e253514, 0x4efabbd5, 0x4f9c594c, 0x8f43d78d, 0x0c56eca4, 0xcc896265, 0xcdef80fc, 0x0d300e3d, 0xd78f9c86, 0x17501247, 0x1636f0de, 0xd6e97e1f, 0x55fc4536, 0x9523cbf7, 0x9445296e, 0x549aa7af, 0x926e5f3c, 0x52b1d1fd, 0x53d73364, 0x9308bda5, 0x101d868c, 0xd0c2084d, 0xd1a4ead4, 0x117b6415, 0x1c4b6a28, 0xdc94e4e9, 0xddf20670, 0x1d2d88b1, 0x9e38b398, 0x5ee73d59, 0x5f81dfc0, 0x9f5e5101, 0x59aaa992, 0x99752753, 0x9813c5ca, 0x58cc4b0b, 0xdbd97022, 0x1b06fee3, 0x1a601c7a, 0xdabf92bb, 0xef1948d6, 0x2fc6c617, 0x2ea0248e, 0xee7faa4f, 0x6d6a9166, 0xadb51fa7, 0xacd3fd3e, 0x6c0c73ff, 0xaaf88b6c, 0x6a2705ad, 0x6b41e734, 0xab9e69f5, 0x288b52dc, 0xe854dc1d, 0xe9323e84, 0x29edb045, 0x24ddbe78, 0xe40230b9, 0xe564d220, 0x25bb5ce1, 0xa6ae67c8, 0x6671e909, 0x67170b90, 0xa7c88551, 0x613c7dc2, 0xa1e3f303, 0xa085119a, 0x605a9f5b, 0xe34fa472, 0x23902ab3, 0x22f6c82a, 0xe22946eb, 0x3896d450, 0xf8495a91, 0xf92fb808, 0x39f036c9, 0xbae50de0, 0x7a3a8321, 0x7b5c61b8, 0xbb83ef79, 0x7d7717ea, 0xbda8992b, 0xbcce7bb2, 0x7c11f573, 0xff04ce5a, 0x3fdb409b, 0x3ebda202, 0xfe622cc3, 0xf35222fe, 0x338dac3f, 0x32eb4ea6, 0xf234c067, 0x7121fb4e, 0xb1fe758f, 0xb0989716, 0x704719d7, 0xb6b3e144, 0x766c6f85, 0x770a8d1c, 0xb7d503dd, 0x34c038f4, 0xf41fb635, 0xf57954ac, 0x35a6da6d, 0x9f35e177, 0x5fea6fb6, 0x5e8c8d2f, 0x9e5303ee, 0x1d4638c7, 0xdd99b606, 0xdcff549f, 0x1c20da5e, 0xdad422cd, 0x1a0bac0c, 0x1b6d4e95, 0xdbb2c054, 0x58a7fb7d, 0x987875bc, 0x991e9725, 0x59c119e4, 0x54f117d9, 0x942e9918, 0x95487b81, 0x5597f540, 0xd682ce69, 0x165d40a8, 0x173ba231, 0xd7e42cf0, 0x1110d463, 0xd1cf5aa2, 0xd0a9b83b, 0x107636fa, 0x93630dd3, 0x53bc8312, 0x52da618b, 0x9205ef4a, 0x48ba7df1, 0x8865f330, 0x890311a9, 0x49dc9f68, 0xcac9a441, 0x0a162a80, 0x0b70c819, 0xcbaf46d8, 0x0d5bbe4b, 0xcd84308a, 0xcce2d213, 0x0c3d5cd2, 0x8f2867fb, 0x4ff7e93a, 0x4e910ba3, 0x8e4e8562, 0x837e8b5f, 0x43a1059e, 0x42c7e707, 0x821869c6, 0x010d52ef, 0xc1d2dc2e, 0xc0b43eb7, 0x006bb076, 0xc69f48e5, 0x0640c624, 0x072624bd, 0xc7f9aa7c, 0x44ec9155, 0x84331f94, 0x8555fd0d, 0x458a73cc, 0x702ca9a1, 0xb0f32760, 0xb195c5f9, 0x714a4b38, 0xf25f7011, 0x3280fed0, 0x33e61c49, 0xf3399288, 0x35cd6a1b, 0xf512e4da, 0xf4740643, 0x34ab8882, 0xb7beb3ab, 0x77613d6a, 0x7607dff3, 0xb6d85132, 0xbbe85f0f, 0x7b37d1ce, 0x7a513357, 0xba8ebd96, 0x399b86bf, 0xf944087e, 0xf822eae7, 0x38fd6426, 0xfe099cb5, 0x3ed61274, 0x3fb0f0ed, 0xff6f7e2c, 0x7c7a4505, 0xbca5cbc4, 0xbdc3295d, 0x7d1ca79c, 0xa7a33527, 0x677cbbe6, 0x661a597f, 0xa6c5d7be, 0x25d0ec97, 0xe50f6256, 0xe46980cf, 0x24b60e0e, 0xe242f69d, 0x229d785c, 0x23fb9ac5, 0xe3241404, 0x60312f2d, 0xa0eea1ec, 0xa1884375, 0x6157cdb4, 0x6c67c389, 0xacb84d48, 0xaddeafd1, 0x6d012110, 0xee141a39, 0x2ecb94f8, 0x2fad7661, 0xef72f8a0, 0x29860033, 0xe9598ef2, 0xe83f6c6b, 0x28e0e2aa, 0xabf5d983, 0x6b2a5742, 0x6a4cb5db, 0xaa933b1a}, {0x00000000, 0x6f4ca59b, 0x9f9e3bec, 0xf0d29e77, 0x7f3b0603, 0x1077a398, 0xe0a53def, 0x8fe99874, 0xfe760c06, 0x913aa99d, 0x61e837ea, 0x0ea49271, 0x814d0a05, 0xee01af9e, 0x1ed331e9, 0x719f9472, 0xfced180c, 0x93a1bd97, 0x637323e0, 0x0c3f867b, 0x83d61e0f, 0xec9abb94, 0x1c4825e3, 0x73048078, 0x029b140a, 0x6dd7b191, 0x9d052fe6, 0xf2498a7d, 0x7da01209, 0x12ecb792, 0xe23e29e5, 0x8d728c7e, 0xf8db3118, 0x97979483, 0x67450af4, 0x0809af6f, 0x87e0371b, 0xe8ac9280, 0x187e0cf7, 0x7732a96c, 0x06ad3d1e, 0x69e19885, 0x993306f2, 0xf67fa369, 0x79963b1d, 0x16da9e86, 0xe60800f1, 0x8944a56a, 0x04362914, 0x6b7a8c8f, 0x9ba812f8, 0xf4e4b763, 0x7b0d2f17, 0x14418a8c, 0xe49314fb, 0x8bdfb160, 0xfa402512, 0x950c8089, 0x65de1efe, 0x0a92bb65, 0x857b2311, 0xea37868a, 0x1ae518fd, 0x75a9bd66, 0xf0b76330, 0x9ffbc6ab, 0x6f2958dc, 0x0065fd47, 0x8f8c6533, 0xe0c0c0a8, 0x10125edf, 0x7f5efb44, 0x0ec16f36, 0x618dcaad, 0x915f54da, 0xfe13f141, 0x71fa6935, 0x1eb6ccae, 0xee6452d9, 0x8128f742, 0x0c5a7b3c, 0x6316dea7, 0x93c440d0, 0xfc88e54b, 0x73617d3f, 0x1c2dd8a4, 0xecff46d3, 0x83b3e348, 0xf22c773a, 0x9d60d2a1, 0x6db24cd6, 0x02fee94d, 0x8d177139, 0xe25bd4a2, 0x12894ad5, 0x7dc5ef4e, 0x086c5228, 0x6720f7b3, 0x97f269c4, 0xf8becc5f, 0x7757542b, 0x181bf1b0, 0xe8c96fc7, 0x8785ca5c, 0xf61a5e2e, 0x9956fbb5, 0x698465c2, 0x06c8c059, 0x8921582d, 0xe66dfdb6, 0x16bf63c1, 0x79f3c65a, 0xf4814a24, 0x9bcdefbf, 0x6b1f71c8, 0x0453d453, 0x8bba4c27, 0xe4f6e9bc, 0x142477cb, 0x7b68d250, 0x0af74622, 0x65bbe3b9, 0x95697dce, 0xfa25d855, 0x75cc4021, 0x1a80e5ba, 0xea527bcd, 0x851ede56, 0xe06fc760, 0x8f2362fb, 0x7ff1fc8c, 0x10bd5917, 0x9f54c163, 0xf01864f8, 0x00cafa8f, 0x6f865f14, 0x1e19cb66, 0x71556efd, 0x8187f08a, 0xeecb5511, 0x6122cd65, 0x0e6e68fe, 0xfebcf689, 0x91f05312, 0x1c82df6c, 0x73ce7af7, 0x831ce480, 0xec50411b, 0x63b9d96f, 0x0cf57cf4, 0xfc27e283, 0x936b4718, 0xe2f4d36a, 0x8db876f1, 0x7d6ae886, 0x12264d1d, 0x9dcfd569, 0xf28370f2, 0x0251ee85, 0x6d1d4b1e, 0x18b4f678, 0x77f853e3, 0x872acd94, 0xe866680f, 0x678ff07b, 0x08c355e0, 0xf811cb97, 0x975d6e0c, 0xe6c2fa7e, 0x898e5fe5, 0x795cc192, 0x16106409, 0x99f9fc7d, 0xf6b559e6, 0x0667c791, 0x692b620a, 0xe459ee74, 0x8b154bef, 0x7bc7d598, 0x148b7003, 0x9b62e877, 0xf42e4dec, 0x04fcd39b, 0x6bb07600, 0x1a2fe272, 0x756347e9, 0x85b1d99e, 0xeafd7c05, 0x6514e471, 0x0a5841ea, 0xfa8adf9d, 0x95c67a06, 0x10d8a450, 0x7f9401cb, 0x8f469fbc, 0xe00a3a27, 0x6fe3a253, 0x00af07c8, 0xf07d99bf, 0x9f313c24, 0xeeaea856, 0x81e20dcd, 0x713093ba, 0x1e7c3621, 0x9195ae55, 0xfed90bce, 0x0e0b95b9, 0x61473022, 0xec35bc5c, 0x837919c7, 0x73ab87b0, 0x1ce7222b, 0x930eba5f, 0xfc421fc4, 0x0c9081b3, 0x63dc2428, 0x1243b05a, 0x7d0f15c1, 0x8ddd8bb6, 0xe2912e2d, 0x6d78b659, 0x023413c2, 0xf2e68db5, 0x9daa282e, 0xe8039548, 0x874f30d3, 0x779daea4, 0x18d10b3f, 0x9738934b, 0xf87436d0, 0x08a6a8a7, 0x67ea0d3c, 0x1675994e, 0x79393cd5, 0x89eba2a2, 0xe6a70739, 0x694e9f4d, 0x06023ad6, 0xf6d0a4a1, 0x999c013a, 0x14ee8d44, 0x7ba228df, 0x8b70b6a8, 0xe43c1333, 0x6bd58b47, 0x04992edc, 0xf44bb0ab, 0x9b071530, 0xea988142, 0x85d424d9, 0x7506baae, 0x1a4a1f35, 0x95a38741, 0xfaef22da, 0x0a3dbcad, 0x65711936}}; #endif #endif #if N == 4 #if W == 8 local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xf1da05aa, 0x38c50d15, 0xc91f08bf, 0x718a1a2a, 0x80501f80, 0x494f173f, 0xb8951295, 0xe3143454, 0x12ce31fe, 0xdbd13941, 0x2a0b3ceb, 0x929e2e7e, 0x63442bd4, 0xaa5b236b, 0x5b8126c1, 0x1d596ee9, 0xec836b43, 0x259c63fc, 0xd4466656, 0x6cd374c3, 0x9d097169, 0x541679d6, 0xa5cc7c7c, 0xfe4d5abd, 0x0f975f17, 0xc68857a8, 0x37525202, 0x8fc74097, 0x7e1d453d, 0xb7024d82, 0x46d84828, 0x3ab2ddd2, 0xcb68d878, 0x0277d0c7, 0xf3add56d, 0x4b38c7f8, 0xbae2c252, 0x73fdcaed, 0x8227cf47, 0xd9a6e986, 0x287cec2c, 0xe163e493, 0x10b9e139, 0xa82cf3ac, 0x59f6f606, 0x90e9feb9, 0x6133fb13, 0x27ebb33b, 0xd631b691, 0x1f2ebe2e, 0xeef4bb84, 0x5661a911, 0xa7bbacbb, 0x6ea4a404, 0x9f7ea1ae, 0xc4ff876f, 0x352582c5, 0xfc3a8a7a, 0x0de08fd0, 0xb5759d45, 0x44af98ef, 0x8db09050, 0x7c6a95fa, 0x7565bba4, 0x84bfbe0e, 0x4da0b6b1, 0xbc7ab31b, 0x04efa18e, 0xf535a424, 0x3c2aac9b, 0xcdf0a931, 0x96718ff0, 0x67ab8a5a, 0xaeb482e5, 0x5f6e874f, 0xe7fb95da, 0x16219070, 0xdf3e98cf, 0x2ee49d65, 0x683cd54d, 0x99e6d0e7, 0x50f9d858, 0xa123ddf2, 0x19b6cf67, 0xe86ccacd, 0x2173c272, 0xd0a9c7d8, 0x8b28e119, 0x7af2e4b3, 0xb3edec0c, 0x4237e9a6, 0xfaa2fb33, 0x0b78fe99, 0xc267f626, 0x33bdf38c, 0x4fd76676, 0xbe0d63dc, 0x77126b63, 0x86c86ec9, 0x3e5d7c5c, 0xcf8779f6, 0x06987149, 0xf74274e3, 0xacc35222, 0x5d195788, 0x94065f37, 0x65dc5a9d, 0xdd494808, 0x2c934da2, 0xe58c451d, 0x145640b7, 0x528e089f, 0xa3540d35, 0x6a4b058a, 0x9b910020, 0x230412b5, 0xd2de171f, 0x1bc11fa0, 0xea1b1a0a, 0xb19a3ccb, 0x40403961, 0x895f31de, 0x78853474, 0xc01026e1, 0x31ca234b, 0xf8d52bf4, 0x090f2e5e, 0xeacb7748, 0x1b1172e2, 0xd20e7a5d, 0x23d47ff7, 0x9b416d62, 0x6a9b68c8, 0xa3846077, 0x525e65dd, 0x09df431c, 0xf80546b6, 0x311a4e09, 0xc0c04ba3, 0x78555936, 0x898f5c9c, 0x40905423, 0xb14a5189, 0xf79219a1, 0x06481c0b, 0xcf5714b4, 0x3e8d111e, 0x8618038b, 0x77c20621, 0xbedd0e9e, 0x4f070b34, 0x14862df5, 0xe55c285f, 0x2c4320e0, 0xdd99254a, 0x650c37df, 0x94d63275, 0x5dc93aca, 0xac133f60, 0xd079aa9a, 0x21a3af30, 0xe8bca78f, 0x1966a225, 0xa1f3b0b0, 0x5029b51a, 0x9936bda5, 0x68ecb80f, 0x336d9ece, 0xc2b79b64, 0x0ba893db, 0xfa729671, 0x42e784e4, 0xb33d814e, 0x7a2289f1, 0x8bf88c5b, 0xcd20c473, 0x3cfac1d9, 0xf5e5c966, 0x043fcccc, 0xbcaade59, 0x4d70dbf3, 0x846fd34c, 0x75b5d6e6, 0x2e34f027, 0xdfeef58d, 0x16f1fd32, 0xe72bf898, 0x5fbeea0d, 0xae64efa7, 0x677be718, 0x96a1e2b2, 0x9faeccec, 0x6e74c946, 0xa76bc1f9, 0x56b1c453, 0xee24d6c6, 0x1ffed36c, 0xd6e1dbd3, 0x273bde79, 0x7cbaf8b8, 0x8d60fd12, 0x447ff5ad, 0xb5a5f007, 0x0d30e292, 0xfceae738, 0x35f5ef87, 0xc42fea2d, 0x82f7a205, 0x732da7af, 0xba32af10, 0x4be8aaba, 0xf37db82f, 0x02a7bd85, 0xcbb8b53a, 0x3a62b090, 0x61e39651, 0x903993fb, 0x59269b44, 0xa8fc9eee, 0x10698c7b, 0xe1b389d1, 0x28ac816e, 0xd97684c4, 0xa51c113e, 0x54c61494, 0x9dd91c2b, 0x6c031981, 0xd4960b14, 0x254c0ebe, 0xec530601, 0x1d8903ab, 0x4608256a, 0xb7d220c0, 0x7ecd287f, 0x8f172dd5, 0x37823f40, 0xc6583aea, 0x0f473255, 0xfe9d37ff, 0xb8457fd7, 0x499f7a7d, 0x808072c2, 0x715a7768, 0xc9cf65fd, 0x38156057, 0xf10a68e8, 0x00d06d42, 0x5b514b83, 0xaa8b4e29, 0x63944696, 0x924e433c, 0x2adb51a9, 0xdb015403, 0x121e5cbc, 0xe3c45916}, {0x00000000, 0x0ee7e8d1, 0x1dcfd1a2, 0x13283973, 0x3b9fa344, 0x35784b95, 0x265072e6, 0x28b79a37, 0x773f4688, 0x79d8ae59, 0x6af0972a, 0x64177ffb, 0x4ca0e5cc, 0x42470d1d, 0x516f346e, 0x5f88dcbf, 0xee7e8d10, 0xe09965c1, 0xf3b15cb2, 0xfd56b463, 0xd5e12e54, 0xdb06c685, 0xc82efff6, 0xc6c91727, 0x9941cb98, 0x97a62349, 0x848e1a3a, 0x8a69f2eb, 0xa2de68dc, 0xac39800d, 0xbf11b97e, 0xb1f651af, 0x078c1c61, 0x096bf4b0, 0x1a43cdc3, 0x14a42512, 0x3c13bf25, 0x32f457f4, 0x21dc6e87, 0x2f3b8656, 0x70b35ae9, 0x7e54b238, 0x6d7c8b4b, 0x639b639a, 0x4b2cf9ad, 0x45cb117c, 0x56e3280f, 0x5804c0de, 0xe9f29171, 0xe71579a0, 0xf43d40d3, 0xfadaa802, 0xd26d3235, 0xdc8adae4, 0xcfa2e397, 0xc1450b46, 0x9ecdd7f9, 0x902a3f28, 0x8302065b, 0x8de5ee8a, 0xa55274bd, 0xabb59c6c, 0xb89da51f, 0xb67a4dce, 0x0f1838c2, 0x01ffd013, 0x12d7e960, 0x1c3001b1, 0x34879b86, 0x3a607357, 0x29484a24, 0x27afa2f5, 0x78277e4a, 0x76c0969b, 0x65e8afe8, 0x6b0f4739, 0x43b8dd0e, 0x4d5f35df, 0x5e770cac, 0x5090e47d, 0xe166b5d2, 0xef815d03, 0xfca96470, 0xf24e8ca1, 0xdaf91696, 0xd41efe47, 0xc736c734, 0xc9d12fe5, 0x9659f35a, 0x98be1b8b, 0x8b9622f8, 0x8571ca29, 0xadc6501e, 0xa321b8cf, 0xb00981bc, 0xbeee696d, 0x089424a3, 0x0673cc72, 0x155bf501, 0x1bbc1dd0, 0x330b87e7, 0x3dec6f36, 0x2ec45645, 0x2023be94, 0x7fab622b, 0x714c8afa, 0x6264b389, 0x6c835b58, 0x4434c16f, 0x4ad329be, 0x59fb10cd, 0x571cf81c, 0xe6eaa9b3, 0xe80d4162, 0xfb257811, 0xf5c290c0, 0xdd750af7, 0xd392e226, 0xc0badb55, 0xce5d3384, 0x91d5ef3b, 0x9f3207ea, 0x8c1a3e99, 0x82fdd648, 0xaa4a4c7f, 0xa4ada4ae, 0xb7859ddd, 0xb962750c, 0x1e307184, 0x10d79955, 0x03ffa026, 0x0d1848f7, 0x25afd2c0, 0x2b483a11, 0x38600362, 0x3687ebb3, 0x690f370c, 0x67e8dfdd, 0x74c0e6ae, 0x7a270e7f, 0x52909448, 0x5c777c99, 0x4f5f45ea, 0x41b8ad3b, 0xf04efc94, 0xfea91445, 0xed812d36, 0xe366c5e7, 0xcbd15fd0, 0xc536b701, 0xd61e8e72, 0xd8f966a3, 0x8771ba1c, 0x899652cd, 0x9abe6bbe, 0x9459836f, 0xbcee1958, 0xb209f189, 0xa121c8fa, 0xafc6202b, 0x19bc6de5, 0x175b8534, 0x0473bc47, 0x0a945496, 0x2223cea1, 0x2cc42670, 0x3fec1f03, 0x310bf7d2, 0x6e832b6d, 0x6064c3bc, 0x734cfacf, 0x7dab121e, 0x551c8829, 0x5bfb60f8, 0x48d3598b, 0x4634b15a, 0xf7c2e0f5, 0xf9250824, 0xea0d3157, 0xe4ead986, 0xcc5d43b1, 0xc2baab60, 0xd1929213, 0xdf757ac2, 0x80fda67d, 0x8e1a4eac, 0x9d3277df, 0x93d59f0e, 0xbb620539, 0xb585ede8, 0xa6add49b, 0xa84a3c4a, 0x11284946, 0x1fcfa197, 0x0ce798e4, 0x02007035, 0x2ab7ea02, 0x245002d3, 0x37783ba0, 0x399fd371, 0x66170fce, 0x68f0e71f, 0x7bd8de6c, 0x753f36bd, 0x5d88ac8a, 0x536f445b, 0x40477d28, 0x4ea095f9, 0xff56c456, 0xf1b12c87, 0xe29915f4, 0xec7efd25, 0xc4c96712, 0xca2e8fc3, 0xd906b6b0, 0xd7e15e61, 0x886982de, 0x868e6a0f, 0x95a6537c, 0x9b41bbad, 0xb3f6219a, 0xbd11c94b, 0xae39f038, 0xa0de18e9, 0x16a45527, 0x1843bdf6, 0x0b6b8485, 0x058c6c54, 0x2d3bf663, 0x23dc1eb2, 0x30f427c1, 0x3e13cf10, 0x619b13af, 0x6f7cfb7e, 0x7c54c20d, 0x72b32adc, 0x5a04b0eb, 0x54e3583a, 0x47cb6149, 0x492c8998, 0xf8dad837, 0xf63d30e6, 0xe5150995, 0xebf2e144, 0xc3457b73, 0xcda293a2, 0xde8aaad1, 0xd06d4200, 0x8fe59ebf, 0x8102766e, 0x922a4f1d, 0x9ccda7cc, 0xb47a3dfb, 0xba9dd52a, 0xa9b5ec59, 0xa7520488}, {0x00000000, 0x3c60e308, 0x78c1c610, 0x44a12518, 0xf1838c20, 0xcde36f28, 0x89424a30, 0xb522a938, 0x38761e01, 0x0416fd09, 0x40b7d811, 0x7cd73b19, 0xc9f59221, 0xf5957129, 0xb1345431, 0x8d54b739, 0x70ec3c02, 0x4c8cdf0a, 0x082dfa12, 0x344d191a, 0x816fb022, 0xbd0f532a, 0xf9ae7632, 0xc5ce953a, 0x489a2203, 0x74fac10b, 0x305be413, 0x0c3b071b, 0xb919ae23, 0x85794d2b, 0xc1d86833, 0xfdb88b3b, 0xe1d87804, 0xddb89b0c, 0x9919be14, 0xa5795d1c, 0x105bf424, 0x2c3b172c, 0x689a3234, 0x54fad13c, 0xd9ae6605, 0xe5ce850d, 0xa16fa015, 0x9d0f431d, 0x282dea25, 0x144d092d, 0x50ec2c35, 0x6c8ccf3d, 0x91344406, 0xad54a70e, 0xe9f58216, 0xd595611e, 0x60b7c826, 0x5cd72b2e, 0x18760e36, 0x2416ed3e, 0xa9425a07, 0x9522b90f, 0xd1839c17, 0xede37f1f, 0x58c1d627, 0x64a1352f, 0x20001037, 0x1c60f33f, 0x18c1f649, 0x24a11541, 0x60003059, 0x5c60d351, 0xe9427a69, 0xd5229961, 0x9183bc79, 0xade35f71, 0x20b7e848, 0x1cd70b40, 0x58762e58, 0x6416cd50, 0xd1346468, 0xed548760, 0xa9f5a278, 0x95954170, 0x682dca4b, 0x544d2943, 0x10ec0c5b, 0x2c8cef53, 0x99ae466b, 0xa5cea563, 0xe16f807b, 0xdd0f6373, 0x505bd44a, 0x6c3b3742, 0x289a125a, 0x14faf152, 0xa1d8586a, 0x9db8bb62, 0xd9199e7a, 0xe5797d72, 0xf9198e4d, 0xc5796d45, 0x81d8485d, 0xbdb8ab55, 0x089a026d, 0x34fae165, 0x705bc47d, 0x4c3b2775, 0xc16f904c, 0xfd0f7344, 0xb9ae565c, 0x85ceb554, 0x30ec1c6c, 0x0c8cff64, 0x482dda7c, 0x744d3974, 0x89f5b24f, 0xb5955147, 0xf134745f, 0xcd549757, 0x78763e6f, 0x4416dd67, 0x00b7f87f, 0x3cd71b77, 0xb183ac4e, 0x8de34f46, 0xc9426a5e, 0xf5228956, 0x4000206e, 0x7c60c366, 0x38c1e67e, 0x04a10576, 0x3183ec92, 0x0de30f9a, 0x49422a82, 0x7522c98a, 0xc00060b2, 0xfc6083ba, 0xb8c1a6a2, 0x84a145aa, 0x09f5f293, 0x3595119b, 0x71343483, 0x4d54d78b, 0xf8767eb3, 0xc4169dbb, 0x80b7b8a3, 0xbcd75bab, 0x416fd090, 0x7d0f3398, 0x39ae1680, 0x05cef588, 0xb0ec5cb0, 0x8c8cbfb8, 0xc82d9aa0, 0xf44d79a8, 0x7919ce91, 0x45792d99, 0x01d80881, 0x3db8eb89, 0x889a42b1, 0xb4faa1b9, 0xf05b84a1, 0xcc3b67a9, 0xd05b9496, 0xec3b779e, 0xa89a5286, 0x94fab18e, 0x21d818b6, 0x1db8fbbe, 0x5919dea6, 0x65793dae, 0xe82d8a97, 0xd44d699f, 0x90ec4c87, 0xac8caf8f, 0x19ae06b7, 0x25cee5bf, 0x616fc0a7, 0x5d0f23af, 0xa0b7a894, 0x9cd74b9c, 0xd8766e84, 0xe4168d8c, 0x513424b4, 0x6d54c7bc, 0x29f5e2a4, 0x159501ac, 0x98c1b695, 0xa4a1559d, 0xe0007085, 0xdc60938d, 0x69423ab5, 0x5522d9bd, 0x1183fca5, 0x2de31fad, 0x29421adb, 0x1522f9d3, 0x5183dccb, 0x6de33fc3, 0xd8c196fb, 0xe4a175f3, 0xa00050eb, 0x9c60b3e3, 0x113404da, 0x2d54e7d2, 0x69f5c2ca, 0x559521c2, 0xe0b788fa, 0xdcd76bf2, 0x98764eea, 0xa416ade2, 0x59ae26d9, 0x65cec5d1, 0x216fe0c9, 0x1d0f03c1, 0xa82daaf9, 0x944d49f1, 0xd0ec6ce9, 0xec8c8fe1, 0x61d838d8, 0x5db8dbd0, 0x1919fec8, 0x25791dc0, 0x905bb4f8, 0xac3b57f0, 0xe89a72e8, 0xd4fa91e0, 0xc89a62df, 0xf4fa81d7, 0xb05ba4cf, 0x8c3b47c7, 0x3919eeff, 0x05790df7, 0x41d828ef, 0x7db8cbe7, 0xf0ec7cde, 0xcc8c9fd6, 0x882dbace, 0xb44d59c6, 0x016ff0fe, 0x3d0f13f6, 0x79ae36ee, 0x45ced5e6, 0xb8765edd, 0x8416bdd5, 0xc0b798cd, 0xfcd77bc5, 0x49f5d2fd, 0x759531f5, 0x313414ed, 0x0d54f7e5, 0x800040dc, 0xbc60a3d4, 0xf8c186cc, 0xc4a165c4, 0x7183ccfc, 0x4de32ff4, 0x09420aec, 0x3522e9e4}, {0x00000000, 0x6307d924, 0xc60fb248, 0xa5086b6c, 0x576e62d1, 0x3469bbf5, 0x9161d099, 0xf26609bd, 0xaedcc5a2, 0xcddb1c86, 0x68d377ea, 0x0bd4aece, 0xf9b2a773, 0x9ab57e57, 0x3fbd153b, 0x5cbacc1f, 0x86c88d05, 0xe5cf5421, 0x40c73f4d, 0x23c0e669, 0xd1a6efd4, 0xb2a136f0, 0x17a95d9c, 0x74ae84b8, 0x281448a7, 0x4b139183, 0xee1bfaef, 0x8d1c23cb, 0x7f7a2a76, 0x1c7df352, 0xb975983e, 0xda72411a, 0xd6e01c4b, 0xb5e7c56f, 0x10efae03, 0x73e87727, 0x818e7e9a, 0xe289a7be, 0x4781ccd2, 0x248615f6, 0x783cd9e9, 0x1b3b00cd, 0xbe336ba1, 0xdd34b285, 0x2f52bb38, 0x4c55621c, 0xe95d0970, 0x8a5ad054, 0x5028914e, 0x332f486a, 0x96272306, 0xf520fa22, 0x0746f39f, 0x64412abb, 0xc14941d7, 0xa24e98f3, 0xfef454ec, 0x9df38dc8, 0x38fbe6a4, 0x5bfc3f80, 0xa99a363d, 0xca9def19, 0x6f958475, 0x0c925d51, 0x76b13ed7, 0x15b6e7f3, 0xb0be8c9f, 0xd3b955bb, 0x21df5c06, 0x42d88522, 0xe7d0ee4e, 0x84d7376a, 0xd86dfb75, 0xbb6a2251, 0x1e62493d, 0x7d659019, 0x8f0399a4, 0xec044080, 0x490c2bec, 0x2a0bf2c8, 0xf079b3d2, 0x937e6af6, 0x3676019a, 0x5571d8be, 0xa717d103, 0xc4100827, 0x6118634b, 0x021fba6f, 0x5ea57670, 0x3da2af54, 0x98aac438, 0xfbad1d1c, 0x09cb14a1, 0x6acccd85, 0xcfc4a6e9, 0xacc37fcd, 0xa051229c, 0xc356fbb8, 0x665e90d4, 0x055949f0, 0xf73f404d, 0x94389969, 0x3130f205, 0x52372b21, 0x0e8de73e, 0x6d8a3e1a, 0xc8825576, 0xab858c52, 0x59e385ef, 0x3ae45ccb, 0x9fec37a7, 0xfcebee83, 0x2699af99, 0x459e76bd, 0xe0961dd1, 0x8391c4f5, 0x71f7cd48, 0x12f0146c, 0xb7f87f00, 0xd4ffa624, 0x88456a3b, 0xeb42b31f, 0x4e4ad873, 0x2d4d0157, 0xdf2b08ea, 0xbc2cd1ce, 0x1924baa2, 0x7a236386, 0xed627dae, 0x8e65a48a, 0x2b6dcfe6, 0x486a16c2, 0xba0c1f7f, 0xd90bc65b, 0x7c03ad37, 0x1f047413, 0x43beb80c, 0x20b96128, 0x85b10a44, 0xe6b6d360, 0x14d0dadd, 0x77d703f9, 0xd2df6895, 0xb1d8b1b1, 0x6baaf0ab, 0x08ad298f, 0xada542e3, 0xcea29bc7, 0x3cc4927a, 0x5fc34b5e, 0xfacb2032, 0x99ccf916, 0xc5763509, 0xa671ec2d, 0x03798741, 0x607e5e65, 0x921857d8, 0xf11f8efc, 0x5417e590, 0x37103cb4, 0x3b8261e5, 0x5885b8c1, 0xfd8dd3ad, 0x9e8a0a89, 0x6cec0334, 0x0febda10, 0xaae3b17c, 0xc9e46858, 0x955ea447, 0xf6597d63, 0x5351160f, 0x3056cf2b, 0xc230c696, 0xa1371fb2, 0x043f74de, 0x6738adfa, 0xbd4aece0, 0xde4d35c4, 0x7b455ea8, 0x1842878c, 0xea248e31, 0x89235715, 0x2c2b3c79, 0x4f2ce55d, 0x13962942, 0x7091f066, 0xd5999b0a, 0xb69e422e, 0x44f84b93, 0x27ff92b7, 0x82f7f9db, 0xe1f020ff, 0x9bd34379, 0xf8d49a5d, 0x5ddcf131, 0x3edb2815, 0xccbd21a8, 0xafbaf88c, 0x0ab293e0, 0x69b54ac4, 0x350f86db, 0x56085fff, 0xf3003493, 0x9007edb7, 0x6261e40a, 0x01663d2e, 0xa46e5642, 0xc7698f66, 0x1d1bce7c, 0x7e1c1758, 0xdb147c34, 0xb813a510, 0x4a75acad, 0x29727589, 0x8c7a1ee5, 0xef7dc7c1, 0xb3c70bde, 0xd0c0d2fa, 0x75c8b996, 0x16cf60b2, 0xe4a9690f, 0x87aeb02b, 0x22a6db47, 0x41a10263, 0x4d335f32, 0x2e348616, 0x8b3ced7a, 0xe83b345e, 0x1a5d3de3, 0x795ae4c7, 0xdc528fab, 0xbf55568f, 0xe3ef9a90, 0x80e843b4, 0x25e028d8, 0x46e7f1fc, 0xb481f841, 0xd7862165, 0x728e4a09, 0x1189932d, 0xcbfbd237, 0xa8fc0b13, 0x0df4607f, 0x6ef3b95b, 0x9c95b0e6, 0xff9269c2, 0x5a9a02ae, 0x399ddb8a, 0x65271795, 0x0620ceb1, 0xa328a5dd, 0xc02f7cf9, 0x32497544, 0x514eac60, 0xf446c70c, 0x97411e28}, {0x00000000, 0x01b5fd1d, 0x036bfa3a, 0x02de0727, 0x06d7f474, 0x07620969, 0x05bc0e4e, 0x0409f353, 0x0dafe8e8, 0x0c1a15f5, 0x0ec412d2, 0x0f71efcf, 0x0b781c9c, 0x0acde181, 0x0813e6a6, 0x09a61bbb, 0x1b5fd1d0, 0x1aea2ccd, 0x18342bea, 0x1981d6f7, 0x1d8825a4, 0x1c3dd8b9, 0x1ee3df9e, 0x1f562283, 0x16f03938, 0x1745c425, 0x159bc302, 0x142e3e1f, 0x1027cd4c, 0x11923051, 0x134c3776, 0x12f9ca6b, 0x36bfa3a0, 0x370a5ebd, 0x35d4599a, 0x3461a487, 0x306857d4, 0x31ddaac9, 0x3303adee, 0x32b650f3, 0x3b104b48, 0x3aa5b655, 0x387bb172, 0x39ce4c6f, 0x3dc7bf3c, 0x3c724221, 0x3eac4506, 0x3f19b81b, 0x2de07270, 0x2c558f6d, 0x2e8b884a, 0x2f3e7557, 0x2b378604, 0x2a827b19, 0x285c7c3e, 0x29e98123, 0x204f9a98, 0x21fa6785, 0x232460a2, 0x22919dbf, 0x26986eec, 0x272d93f1, 0x25f394d6, 0x244669cb, 0x6d7f4740, 0x6ccaba5d, 0x6e14bd7a, 0x6fa14067, 0x6ba8b334, 0x6a1d4e29, 0x68c3490e, 0x6976b413, 0x60d0afa8, 0x616552b5, 0x63bb5592, 0x620ea88f, 0x66075bdc, 0x67b2a6c1, 0x656ca1e6, 0x64d95cfb, 0x76209690, 0x77956b8d, 0x754b6caa, 0x74fe91b7, 0x70f762e4, 0x71429ff9, 0x739c98de, 0x722965c3, 0x7b8f7e78, 0x7a3a8365, 0x78e48442, 0x7951795f, 0x7d588a0c, 0x7ced7711, 0x7e337036, 0x7f868d2b, 0x5bc0e4e0, 0x5a7519fd, 0x58ab1eda, 0x591ee3c7, 0x5d171094, 0x5ca2ed89, 0x5e7ceaae, 0x5fc917b3, 0x566f0c08, 0x57daf115, 0x5504f632, 0x54b10b2f, 0x50b8f87c, 0x510d0561, 0x53d30246, 0x5266ff5b, 0x409f3530, 0x412ac82d, 0x43f4cf0a, 0x42413217, 0x4648c144, 0x47fd3c59, 0x45233b7e, 0x4496c663, 0x4d30ddd8, 0x4c8520c5, 0x4e5b27e2, 0x4feedaff, 0x4be729ac, 0x4a52d4b1, 0x488cd396, 0x49392e8b, 0xdafe8e80, 0xdb4b739d, 0xd99574ba, 0xd82089a7, 0xdc297af4, 0xdd9c87e9, 0xdf4280ce, 0xdef77dd3, 0xd7516668, 0xd6e49b75, 0xd43a9c52, 0xd58f614f, 0xd186921c, 0xd0336f01, 0xd2ed6826, 0xd358953b, 0xc1a15f50, 0xc014a24d, 0xc2caa56a, 0xc37f5877, 0xc776ab24, 0xc6c35639, 0xc41d511e, 0xc5a8ac03, 0xcc0eb7b8, 0xcdbb4aa5, 0xcf654d82, 0xced0b09f, 0xcad943cc, 0xcb6cbed1, 0xc9b2b9f6, 0xc80744eb, 0xec412d20, 0xedf4d03d, 0xef2ad71a, 0xee9f2a07, 0xea96d954, 0xeb232449, 0xe9fd236e, 0xe848de73, 0xe1eec5c8, 0xe05b38d5, 0xe2853ff2, 0xe330c2ef, 0xe73931bc, 0xe68ccca1, 0xe452cb86, 0xe5e7369b, 0xf71efcf0, 0xf6ab01ed, 0xf47506ca, 0xf5c0fbd7, 0xf1c90884, 0xf07cf599, 0xf2a2f2be, 0xf3170fa3, 0xfab11418, 0xfb04e905, 0xf9daee22, 0xf86f133f, 0xfc66e06c, 0xfdd31d71, 0xff0d1a56, 0xfeb8e74b, 0xb781c9c0, 0xb63434dd, 0xb4ea33fa, 0xb55fcee7, 0xb1563db4, 0xb0e3c0a9, 0xb23dc78e, 0xb3883a93, 0xba2e2128, 0xbb9bdc35, 0xb945db12, 0xb8f0260f, 0xbcf9d55c, 0xbd4c2841, 0xbf922f66, 0xbe27d27b, 0xacde1810, 0xad6be50d, 0xafb5e22a, 0xae001f37, 0xaa09ec64, 0xabbc1179, 0xa962165e, 0xa8d7eb43, 0xa171f0f8, 0xa0c40de5, 0xa21a0ac2, 0xa3aff7df, 0xa7a6048c, 0xa613f991, 0xa4cdfeb6, 0xa57803ab, 0x813e6a60, 0x808b977d, 0x8255905a, 0x83e06d47, 0x87e99e14, 0x865c6309, 0x8482642e, 0x85379933, 0x8c918288, 0x8d247f95, 0x8ffa78b2, 0x8e4f85af, 0x8a4676fc, 0x8bf38be1, 0x892d8cc6, 0x889871db, 0x9a61bbb0, 0x9bd446ad, 0x990a418a, 0x98bfbc97, 0x9cb64fc4, 0x9d03b2d9, 0x9fddb5fe, 0x9e6848e3, 0x97ce5358, 0x967bae45, 0x94a5a962, 0x9510547f, 0x9119a72c, 0x90ac5a31, 0x92725d16, 0x93c7a00b}, {0x00000000, 0x6e8c1b41, 0xdd183682, 0xb3942dc3, 0x61416b45, 0x0fcd7004, 0xbc595dc7, 0xd2d54686, 0xc282d68a, 0xac0ecdcb, 0x1f9ae008, 0x7116fb49, 0xa3c3bdcf, 0xcd4fa68e, 0x7edb8b4d, 0x1057900c, 0x5e74ab55, 0x30f8b014, 0x836c9dd7, 0xede08696, 0x3f35c010, 0x51b9db51, 0xe22df692, 0x8ca1edd3, 0x9cf67ddf, 0xf27a669e, 0x41ee4b5d, 0x2f62501c, 0xfdb7169a, 0x933b0ddb, 0x20af2018, 0x4e233b59, 0xbce956aa, 0xd2654deb, 0x61f16028, 0x0f7d7b69, 0xdda83def, 0xb32426ae, 0x00b00b6d, 0x6e3c102c, 0x7e6b8020, 0x10e79b61, 0xa373b6a2, 0xcdffade3, 0x1f2aeb65, 0x71a6f024, 0xc232dde7, 0xacbec6a6, 0xe29dfdff, 0x8c11e6be, 0x3f85cb7d, 0x5109d03c, 0x83dc96ba, 0xed508dfb, 0x5ec4a038, 0x3048bb79, 0x201f2b75, 0x4e933034, 0xfd071df7, 0x938b06b6, 0x415e4030, 0x2fd25b71, 0x9c4676b2, 0xf2ca6df3, 0xa2a3ab15, 0xcc2fb054, 0x7fbb9d97, 0x113786d6, 0xc3e2c050, 0xad6edb11, 0x1efaf6d2, 0x7076ed93, 0x60217d9f, 0x0ead66de, 0xbd394b1d, 0xd3b5505c, 0x016016da, 0x6fec0d9b, 0xdc782058, 0xb2f43b19, 0xfcd70040, 0x925b1b01, 0x21cf36c2, 0x4f432d83, 0x9d966b05, 0xf31a7044, 0x408e5d87, 0x2e0246c6, 0x3e55d6ca, 0x50d9cd8b, 0xe34de048, 0x8dc1fb09, 0x5f14bd8f, 0x3198a6ce, 0x820c8b0d, 0xec80904c, 0x1e4afdbf, 0x70c6e6fe, 0xc352cb3d, 0xadded07c, 0x7f0b96fa, 0x11878dbb, 0xa213a078, 0xcc9fbb39, 0xdcc82b35, 0xb2443074, 0x01d01db7, 0x6f5c06f6, 0xbd894070, 0xd3055b31, 0x609176f2, 0x0e1d6db3, 0x403e56ea, 0x2eb24dab, 0x9d266068, 0xf3aa7b29, 0x217f3daf, 0x4ff326ee, 0xfc670b2d, 0x92eb106c, 0x82bc8060, 0xec309b21, 0x5fa4b6e2, 0x3128ada3, 0xe3fdeb25, 0x8d71f064, 0x3ee5dda7, 0x5069c6e6, 0x9e36506b, 0xf0ba4b2a, 0x432e66e9, 0x2da27da8, 0xff773b2e, 0x91fb206f, 0x226f0dac, 0x4ce316ed, 0x5cb486e1, 0x32389da0, 0x81acb063, 0xef20ab22, 0x3df5eda4, 0x5379f6e5, 0xe0eddb26, 0x8e61c067, 0xc042fb3e, 0xaecee07f, 0x1d5acdbc, 0x73d6d6fd, 0xa103907b, 0xcf8f8b3a, 0x7c1ba6f9, 0x1297bdb8, 0x02c02db4, 0x6c4c36f5, 0xdfd81b36, 0xb1540077, 0x638146f1, 0x0d0d5db0, 0xbe997073, 0xd0156b32, 0x22df06c1, 0x4c531d80, 0xffc73043, 0x914b2b02, 0x439e6d84, 0x2d1276c5, 0x9e865b06, 0xf00a4047, 0xe05dd04b, 0x8ed1cb0a, 0x3d45e6c9, 0x53c9fd88, 0x811cbb0e, 0xef90a04f, 0x5c048d8c, 0x328896cd, 0x7cabad94, 0x1227b6d5, 0xa1b39b16, 0xcf3f8057, 0x1deac6d1, 0x7366dd90, 0xc0f2f053, 0xae7eeb12, 0xbe297b1e, 0xd0a5605f, 0x63314d9c, 0x0dbd56dd, 0xdf68105b, 0xb1e40b1a, 0x027026d9, 0x6cfc3d98, 0x3c95fb7e, 0x5219e03f, 0xe18dcdfc, 0x8f01d6bd, 0x5dd4903b, 0x33588b7a, 0x80cca6b9, 0xee40bdf8, 0xfe172df4, 0x909b36b5, 0x230f1b76, 0x4d830037, 0x9f5646b1, 0xf1da5df0, 0x424e7033, 0x2cc26b72, 0x62e1502b, 0x0c6d4b6a, 0xbff966a9, 0xd1757de8, 0x03a03b6e, 0x6d2c202f, 0xdeb80dec, 0xb03416ad, 0xa06386a1, 0xceef9de0, 0x7d7bb023, 0x13f7ab62, 0xc122ede4, 0xafaef6a5, 0x1c3adb66, 0x72b6c027, 0x807cadd4, 0xeef0b695, 0x5d649b56, 0x33e88017, 0xe13dc691, 0x8fb1ddd0, 0x3c25f013, 0x52a9eb52, 0x42fe7b5e, 0x2c72601f, 0x9fe64ddc, 0xf16a569d, 0x23bf101b, 0x4d330b5a, 0xfea72699, 0x902b3dd8, 0xde080681, 0xb0841dc0, 0x03103003, 0x6d9c2b42, 0xbf496dc4, 0xd1c57685, 0x62515b46, 0x0cdd4007, 0x1c8ad00b, 0x7206cb4a, 0xc192e689, 0xaf1efdc8, 0x7dcbbb4e, 0x1347a00f, 0xa0d38dcc, 0xce5f968d}, {0x00000000, 0xe71da697, 0x154a4b6f, 0xf257edf8, 0x2a9496de, 0xcd893049, 0x3fdeddb1, 0xd8c37b26, 0x55292dbc, 0xb2348b2b, 0x406366d3, 0xa77ec044, 0x7fbdbb62, 0x98a01df5, 0x6af7f00d, 0x8dea569a, 0xaa525b78, 0x4d4ffdef, 0xbf181017, 0x5805b680, 0x80c6cda6, 0x67db6b31, 0x958c86c9, 0x7291205e, 0xff7b76c4, 0x1866d053, 0xea313dab, 0x0d2c9b3c, 0xd5efe01a, 0x32f2468d, 0xc0a5ab75, 0x27b80de2, 0x8fd5b0b1, 0x68c81626, 0x9a9ffbde, 0x7d825d49, 0xa541266f, 0x425c80f8, 0xb00b6d00, 0x5716cb97, 0xdafc9d0d, 0x3de13b9a, 0xcfb6d662, 0x28ab70f5, 0xf0680bd3, 0x1775ad44, 0xe52240bc, 0x023fe62b, 0x2587ebc9, 0xc29a4d5e, 0x30cda0a6, 0xd7d00631, 0x0f137d17, 0xe80edb80, 0x1a593678, 0xfd4490ef, 0x70aec675, 0x97b360e2, 0x65e48d1a, 0x82f92b8d, 0x5a3a50ab, 0xbd27f63c, 0x4f701bc4, 0xa86dbd53, 0xc4da6723, 0x23c7c1b4, 0xd1902c4c, 0x368d8adb, 0xee4ef1fd, 0x0953576a, 0xfb04ba92, 0x1c191c05, 0x91f34a9f, 0x76eeec08, 0x84b901f0, 0x63a4a767, 0xbb67dc41, 0x5c7a7ad6, 0xae2d972e, 0x493031b9, 0x6e883c5b, 0x89959acc, 0x7bc27734, 0x9cdfd1a3, 0x441caa85, 0xa3010c12, 0x5156e1ea, 0xb64b477d, 0x3ba111e7, 0xdcbcb770, 0x2eeb5a88, 0xc9f6fc1f, 0x11358739, 0xf62821ae, 0x047fcc56, 0xe3626ac1, 0x4b0fd792, 0xac127105, 0x5e459cfd, 0xb9583a6a, 0x619b414c, 0x8686e7db, 0x74d10a23, 0x93ccacb4, 0x1e26fa2e, 0xf93b5cb9, 0x0b6cb141, 0xec7117d6, 0x34b26cf0, 0xd3afca67, 0x21f8279f, 0xc6e58108, 0xe15d8cea, 0x06402a7d, 0xf417c785, 0x130a6112, 0xcbc91a34, 0x2cd4bca3, 0xde83515b, 0x399ef7cc, 0xb474a156, 0x536907c1, 0xa13eea39, 0x46234cae, 0x9ee03788, 0x79fd911f, 0x8baa7ce7, 0x6cb7da70, 0x52c5c807, 0xb5d86e90, 0x478f8368, 0xa09225ff, 0x78515ed9, 0x9f4cf84e, 0x6d1b15b6, 0x8a06b321, 0x07ece5bb, 0xe0f1432c, 0x12a6aed4, 0xf5bb0843, 0x2d787365, 0xca65d5f2, 0x3832380a, 0xdf2f9e9d, 0xf897937f, 0x1f8a35e8, 0xedddd810, 0x0ac07e87, 0xd20305a1, 0x351ea336, 0xc7494ece, 0x2054e859, 0xadbebec3, 0x4aa31854, 0xb8f4f5ac, 0x5fe9533b, 0x872a281d, 0x60378e8a, 0x92606372, 0x757dc5e5, 0xdd1078b6, 0x3a0dde21, 0xc85a33d9, 0x2f47954e, 0xf784ee68, 0x109948ff, 0xe2cea507, 0x05d30390, 0x8839550a, 0x6f24f39d, 0x9d731e65, 0x7a6eb8f2, 0xa2adc3d4, 0x45b06543, 0xb7e788bb, 0x50fa2e2c, 0x774223ce, 0x905f8559, 0x620868a1, 0x8515ce36, 0x5dd6b510, 0xbacb1387, 0x489cfe7f, 0xaf8158e8, 0x226b0e72, 0xc576a8e5, 0x3721451d, 0xd03ce38a, 0x08ff98ac, 0xefe23e3b, 0x1db5d3c3, 0xfaa87554, 0x961faf24, 0x710209b3, 0x8355e44b, 0x644842dc, 0xbc8b39fa, 0x5b969f6d, 0xa9c17295, 0x4edcd402, 0xc3368298, 0x242b240f, 0xd67cc9f7, 0x31616f60, 0xe9a21446, 0x0ebfb2d1, 0xfce85f29, 0x1bf5f9be, 0x3c4df45c, 0xdb5052cb, 0x2907bf33, 0xce1a19a4, 0x16d96282, 0xf1c4c415, 0x039329ed, 0xe48e8f7a, 0x6964d9e0, 0x8e797f77, 0x7c2e928f, 0x9b333418, 0x43f04f3e, 0xa4ede9a9, 0x56ba0451, 0xb1a7a2c6, 0x19ca1f95, 0xfed7b902, 0x0c8054fa, 0xeb9df26d, 0x335e894b, 0xd4432fdc, 0x2614c224, 0xc10964b3, 0x4ce33229, 0xabfe94be, 0x59a97946, 0xbeb4dfd1, 0x6677a4f7, 0x816a0260, 0x733def98, 0x9420490f, 0xb39844ed, 0x5485e27a, 0xa6d20f82, 0x41cfa915, 0x990cd233, 0x7e1174a4, 0x8c46995c, 0x6b5b3fcb, 0xe6b16951, 0x01accfc6, 0xf3fb223e, 0x14e684a9, 0xcc25ff8f, 0x2b385918, 0xd96fb4e0, 0x3e721277}, {0x00000000, 0xa58b900e, 0x9066265d, 0x35edb653, 0xfbbd4afb, 0x5e36daf5, 0x6bdb6ca6, 0xce50fca8, 0x2c0b93b7, 0x898003b9, 0xbc6db5ea, 0x19e625e4, 0xd7b6d94c, 0x723d4942, 0x47d0ff11, 0xe25b6f1f, 0x5817276e, 0xfd9cb760, 0xc8710133, 0x6dfa913d, 0xa3aa6d95, 0x0621fd9b, 0x33cc4bc8, 0x9647dbc6, 0x741cb4d9, 0xd19724d7, 0xe47a9284, 0x41f1028a, 0x8fa1fe22, 0x2a2a6e2c, 0x1fc7d87f, 0xba4c4871, 0xb02e4edc, 0x15a5ded2, 0x20486881, 0x85c3f88f, 0x4b930427, 0xee189429, 0xdbf5227a, 0x7e7eb274, 0x9c25dd6b, 0x39ae4d65, 0x0c43fb36, 0xa9c86b38, 0x67989790, 0xc213079e, 0xf7feb1cd, 0x527521c3, 0xe83969b2, 0x4db2f9bc, 0x785f4fef, 0xddd4dfe1, 0x13842349, 0xb60fb347, 0x83e20514, 0x2669951a, 0xc432fa05, 0x61b96a0b, 0x5454dc58, 0xf1df4c56, 0x3f8fb0fe, 0x9a0420f0, 0xafe996a3, 0x0a6206ad, 0xbb2d9bf9, 0x1ea60bf7, 0x2b4bbda4, 0x8ec02daa, 0x4090d102, 0xe51b410c, 0xd0f6f75f, 0x757d6751, 0x9726084e, 0x32ad9840, 0x07402e13, 0xa2cbbe1d, 0x6c9b42b5, 0xc910d2bb, 0xfcfd64e8, 0x5976f4e6, 0xe33abc97, 0x46b12c99, 0x735c9aca, 0xd6d70ac4, 0x1887f66c, 0xbd0c6662, 0x88e1d031, 0x2d6a403f, 0xcf312f20, 0x6ababf2e, 0x5f57097d, 0xfadc9973, 0x348c65db, 0x9107f5d5, 0xa4ea4386, 0x0161d388, 0x0b03d525, 0xae88452b, 0x9b65f378, 0x3eee6376, 0xf0be9fde, 0x55350fd0, 0x60d8b983, 0xc553298d, 0x27084692, 0x8283d69c, 0xb76e60cf, 0x12e5f0c1, 0xdcb50c69, 0x793e9c67, 0x4cd32a34, 0xe958ba3a, 0x5314f24b, 0xf69f6245, 0xc372d416, 0x66f94418, 0xa8a9b8b0, 0x0d2228be, 0x38cf9eed, 0x9d440ee3, 0x7f1f61fc, 0xda94f1f2, 0xef7947a1, 0x4af2d7af, 0x84a22b07, 0x2129bb09, 0x14c40d5a, 0xb14f9d54, 0xad2a31b3, 0x08a1a1bd, 0x3d4c17ee, 0x98c787e0, 0x56977b48, 0xf31ceb46, 0xc6f15d15, 0x637acd1b, 0x8121a204, 0x24aa320a, 0x11478459, 0xb4cc1457, 0x7a9ce8ff, 0xdf1778f1, 0xeafacea2, 0x4f715eac, 0xf53d16dd, 0x50b686d3, 0x655b3080, 0xc0d0a08e, 0x0e805c26, 0xab0bcc28, 0x9ee67a7b, 0x3b6dea75, 0xd936856a, 0x7cbd1564, 0x4950a337, 0xecdb3339, 0x228bcf91, 0x87005f9f, 0xb2ede9cc, 0x176679c2, 0x1d047f6f, 0xb88fef61, 0x8d625932, 0x28e9c93c, 0xe6b93594, 0x4332a59a, 0x76df13c9, 0xd35483c7, 0x310fecd8, 0x94847cd6, 0xa169ca85, 0x04e25a8b, 0xcab2a623, 0x6f39362d, 0x5ad4807e, 0xff5f1070, 0x45135801, 0xe098c80f, 0xd5757e5c, 0x70feee52, 0xbeae12fa, 0x1b2582f4, 0x2ec834a7, 0x8b43a4a9, 0x6918cbb6, 0xcc935bb8, 0xf97eedeb, 0x5cf57de5, 0x92a5814d, 0x372e1143, 0x02c3a710, 0xa748371e, 0x1607aa4a, 0xb38c3a44, 0x86618c17, 0x23ea1c19, 0xedbae0b1, 0x483170bf, 0x7ddcc6ec, 0xd85756e2, 0x3a0c39fd, 0x9f87a9f3, 0xaa6a1fa0, 0x0fe18fae, 0xc1b17306, 0x643ae308, 0x51d7555b, 0xf45cc555, 0x4e108d24, 0xeb9b1d2a, 0xde76ab79, 0x7bfd3b77, 0xb5adc7df, 0x102657d1, 0x25cbe182, 0x8040718c, 0x621b1e93, 0xc7908e9d, 0xf27d38ce, 0x57f6a8c0, 0x99a65468, 0x3c2dc466, 0x09c07235, 0xac4be23b, 0xa629e496, 0x03a27498, 0x364fc2cb, 0x93c452c5, 0x5d94ae6d, 0xf81f3e63, 0xcdf28830, 0x6879183e, 0x8a227721, 0x2fa9e72f, 0x1a44517c, 0xbfcfc172, 0x719f3dda, 0xd414add4, 0xe1f91b87, 0x44728b89, 0xfe3ec3f8, 0x5bb553f6, 0x6e58e5a5, 0xcbd375ab, 0x05838903, 0xa008190d, 0x95e5af5e, 0x306e3f50, 0xd235504f, 0x77bec041, 0x42537612, 0xe7d8e61c, 0x29881ab4, 0x8c038aba, 0xb9ee3ce9, 0x1c65ace7}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x0000000000000000, 0x0e908ba500000000, 0x5d26669000000000, 0x53b6ed3500000000, 0xfb4abdfb00000000, 0xf5da365e00000000, 0xa66cdb6b00000000, 0xa8fc50ce00000000, 0xb7930b2c00000000, 0xb903808900000000, 0xeab56dbc00000000, 0xe425e61900000000, 0x4cd9b6d700000000, 0x42493d7200000000, 0x11ffd04700000000, 0x1f6f5be200000000, 0x6e27175800000000, 0x60b79cfd00000000, 0x330171c800000000, 0x3d91fa6d00000000, 0x956daaa300000000, 0x9bfd210600000000, 0xc84bcc3300000000, 0xc6db479600000000, 0xd9b41c7400000000, 0xd72497d100000000, 0x84927ae400000000, 0x8a02f14100000000, 0x22fea18f00000000, 0x2c6e2a2a00000000, 0x7fd8c71f00000000, 0x71484cba00000000, 0xdc4e2eb000000000, 0xd2dea51500000000, 0x8168482000000000, 0x8ff8c38500000000, 0x2704934b00000000, 0x299418ee00000000, 0x7a22f5db00000000, 0x74b27e7e00000000, 0x6bdd259c00000000, 0x654dae3900000000, 0x36fb430c00000000, 0x386bc8a900000000, 0x9097986700000000, 0x9e0713c200000000, 0xcdb1fef700000000, 0xc321755200000000, 0xb26939e800000000, 0xbcf9b24d00000000, 0xef4f5f7800000000, 0xe1dfd4dd00000000, 0x4923841300000000, 0x47b30fb600000000, 0x1405e28300000000, 0x1a95692600000000, 0x05fa32c400000000, 0x0b6ab96100000000, 0x58dc545400000000, 0x564cdff100000000, 0xfeb08f3f00000000, 0xf020049a00000000, 0xa396e9af00000000, 0xad06620a00000000, 0xf99b2dbb00000000, 0xf70ba61e00000000, 0xa4bd4b2b00000000, 0xaa2dc08e00000000, 0x02d1904000000000, 0x0c411be500000000, 0x5ff7f6d000000000, 0x51677d7500000000, 0x4e08269700000000, 0x4098ad3200000000, 0x132e400700000000, 0x1dbecba200000000, 0xb5429b6c00000000, 0xbbd210c900000000, 0xe864fdfc00000000, 0xe6f4765900000000, 0x97bc3ae300000000, 0x992cb14600000000, 0xca9a5c7300000000, 0xc40ad7d600000000, 0x6cf6871800000000, 0x62660cbd00000000, 0x31d0e18800000000, 0x3f406a2d00000000, 0x202f31cf00000000, 0x2ebfba6a00000000, 0x7d09575f00000000, 0x7399dcfa00000000, 0xdb658c3400000000, 0xd5f5079100000000, 0x8643eaa400000000, 0x88d3610100000000, 0x25d5030b00000000, 0x2b4588ae00000000, 0x78f3659b00000000, 0x7663ee3e00000000, 0xde9fbef000000000, 0xd00f355500000000, 0x83b9d86000000000, 0x8d2953c500000000, 0x9246082700000000, 0x9cd6838200000000, 0xcf606eb700000000, 0xc1f0e51200000000, 0x690cb5dc00000000, 0x679c3e7900000000, 0x342ad34c00000000, 0x3aba58e900000000, 0x4bf2145300000000, 0x45629ff600000000, 0x16d472c300000000, 0x1844f96600000000, 0xb0b8a9a800000000, 0xbe28220d00000000, 0xed9ecf3800000000, 0xe30e449d00000000, 0xfc611f7f00000000, 0xf2f194da00000000, 0xa14779ef00000000, 0xafd7f24a00000000, 0x072ba28400000000, 0x09bb292100000000, 0x5a0dc41400000000, 0x549d4fb100000000, 0xb3312aad00000000, 0xbda1a10800000000, 0xee174c3d00000000, 0xe087c79800000000, 0x487b975600000000, 0x46eb1cf300000000, 0x155df1c600000000, 0x1bcd7a6300000000, 0x04a2218100000000, 0x0a32aa2400000000, 0x5984471100000000, 0x5714ccb400000000, 0xffe89c7a00000000, 0xf17817df00000000, 0xa2cefaea00000000, 0xac5e714f00000000, 0xdd163df500000000, 0xd386b65000000000, 0x80305b6500000000, 0x8ea0d0c000000000, 0x265c800e00000000, 0x28cc0bab00000000, 0x7b7ae69e00000000, 0x75ea6d3b00000000, 0x6a8536d900000000, 0x6415bd7c00000000, 0x37a3504900000000, 0x3933dbec00000000, 0x91cf8b2200000000, 0x9f5f008700000000, 0xcce9edb200000000, 0xc279661700000000, 0x6f7f041d00000000, 0x61ef8fb800000000, 0x3259628d00000000, 0x3cc9e92800000000, 0x9435b9e600000000, 0x9aa5324300000000, 0xc913df7600000000, 0xc78354d300000000, 0xd8ec0f3100000000, 0xd67c849400000000, 0x85ca69a100000000, 0x8b5ae20400000000, 0x23a6b2ca00000000, 0x2d36396f00000000, 0x7e80d45a00000000, 0x70105fff00000000, 0x0158134500000000, 0x0fc898e000000000, 0x5c7e75d500000000, 0x52eefe7000000000, 0xfa12aebe00000000, 0xf482251b00000000, 0xa734c82e00000000, 0xa9a4438b00000000, 0xb6cb186900000000, 0xb85b93cc00000000, 0xebed7ef900000000, 0xe57df55c00000000, 0x4d81a59200000000, 0x43112e3700000000, 0x10a7c30200000000, 0x1e3748a700000000, 0x4aaa071600000000, 0x443a8cb300000000, 0x178c618600000000, 0x191cea2300000000, 0xb1e0baed00000000, 0xbf70314800000000, 0xecc6dc7d00000000, 0xe25657d800000000, 0xfd390c3a00000000, 0xf3a9879f00000000, 0xa01f6aaa00000000, 0xae8fe10f00000000, 0x0673b1c100000000, 0x08e33a6400000000, 0x5b55d75100000000, 0x55c55cf400000000, 0x248d104e00000000, 0x2a1d9beb00000000, 0x79ab76de00000000, 0x773bfd7b00000000, 0xdfc7adb500000000, 0xd157261000000000, 0x82e1cb2500000000, 0x8c71408000000000, 0x931e1b6200000000, 0x9d8e90c700000000, 0xce387df200000000, 0xc0a8f65700000000, 0x6854a69900000000, 0x66c42d3c00000000, 0x3572c00900000000, 0x3be24bac00000000, 0x96e429a600000000, 0x9874a20300000000, 0xcbc24f3600000000, 0xc552c49300000000, 0x6dae945d00000000, 0x633e1ff800000000, 0x3088f2cd00000000, 0x3e18796800000000, 0x2177228a00000000, 0x2fe7a92f00000000, 0x7c51441a00000000, 0x72c1cfbf00000000, 0xda3d9f7100000000, 0xd4ad14d400000000, 0x871bf9e100000000, 0x898b724400000000, 0xf8c33efe00000000, 0xf653b55b00000000, 0xa5e5586e00000000, 0xab75d3cb00000000, 0x0389830500000000, 0x0d1908a000000000, 0x5eafe59500000000, 0x503f6e3000000000, 0x4f5035d200000000, 0x41c0be7700000000, 0x1276534200000000, 0x1ce6d8e700000000, 0xb41a882900000000, 0xba8a038c00000000, 0xe93ceeb900000000, 0xe7ac651c00000000}, {0x0000000000000000, 0x97a61de700000000, 0x6f4b4a1500000000, 0xf8ed57f200000000, 0xde96942a00000000, 0x493089cd00000000, 0xb1ddde3f00000000, 0x267bc3d800000000, 0xbc2d295500000000, 0x2b8b34b200000000, 0xd366634000000000, 0x44c07ea700000000, 0x62bbbd7f00000000, 0xf51da09800000000, 0x0df0f76a00000000, 0x9a56ea8d00000000, 0x785b52aa00000000, 0xeffd4f4d00000000, 0x171018bf00000000, 0x80b6055800000000, 0xa6cdc68000000000, 0x316bdb6700000000, 0xc9868c9500000000, 0x5e20917200000000, 0xc4767bff00000000, 0x53d0661800000000, 0xab3d31ea00000000, 0x3c9b2c0d00000000, 0x1ae0efd500000000, 0x8d46f23200000000, 0x75aba5c000000000, 0xe20db82700000000, 0xb1b0d58f00000000, 0x2616c86800000000, 0xdefb9f9a00000000, 0x495d827d00000000, 0x6f2641a500000000, 0xf8805c4200000000, 0x006d0bb000000000, 0x97cb165700000000, 0x0d9dfcda00000000, 0x9a3be13d00000000, 0x62d6b6cf00000000, 0xf570ab2800000000, 0xd30b68f000000000, 0x44ad751700000000, 0xbc4022e500000000, 0x2be63f0200000000, 0xc9eb872500000000, 0x5e4d9ac200000000, 0xa6a0cd3000000000, 0x3106d0d700000000, 0x177d130f00000000, 0x80db0ee800000000, 0x7836591a00000000, 0xef9044fd00000000, 0x75c6ae7000000000, 0xe260b39700000000, 0x1a8de46500000000, 0x8d2bf98200000000, 0xab503a5a00000000, 0x3cf627bd00000000, 0xc41b704f00000000, 0x53bd6da800000000, 0x2367dac400000000, 0xb4c1c72300000000, 0x4c2c90d100000000, 0xdb8a8d3600000000, 0xfdf14eee00000000, 0x6a57530900000000, 0x92ba04fb00000000, 0x051c191c00000000, 0x9f4af39100000000, 0x08ecee7600000000, 0xf001b98400000000, 0x67a7a46300000000, 0x41dc67bb00000000, 0xd67a7a5c00000000, 0x2e972dae00000000, 0xb931304900000000, 0x5b3c886e00000000, 0xcc9a958900000000, 0x3477c27b00000000, 0xa3d1df9c00000000, 0x85aa1c4400000000, 0x120c01a300000000, 0xeae1565100000000, 0x7d474bb600000000, 0xe711a13b00000000, 0x70b7bcdc00000000, 0x885aeb2e00000000, 0x1ffcf6c900000000, 0x3987351100000000, 0xae2128f600000000, 0x56cc7f0400000000, 0xc16a62e300000000, 0x92d70f4b00000000, 0x057112ac00000000, 0xfd9c455e00000000, 0x6a3a58b900000000, 0x4c419b6100000000, 0xdbe7868600000000, 0x230ad17400000000, 0xb4accc9300000000, 0x2efa261e00000000, 0xb95c3bf900000000, 0x41b16c0b00000000, 0xd61771ec00000000, 0xf06cb23400000000, 0x67caafd300000000, 0x9f27f82100000000, 0x0881e5c600000000, 0xea8c5de100000000, 0x7d2a400600000000, 0x85c717f400000000, 0x12610a1300000000, 0x341ac9cb00000000, 0xa3bcd42c00000000, 0x5b5183de00000000, 0xccf79e3900000000, 0x56a174b400000000, 0xc107695300000000, 0x39ea3ea100000000, 0xae4c234600000000, 0x8837e09e00000000, 0x1f91fd7900000000, 0xe77caa8b00000000, 0x70dab76c00000000, 0x07c8c55200000000, 0x906ed8b500000000, 0x68838f4700000000, 0xff2592a000000000, 0xd95e517800000000, 0x4ef84c9f00000000, 0xb6151b6d00000000, 0x21b3068a00000000, 0xbbe5ec0700000000, 0x2c43f1e000000000, 0xd4aea61200000000, 0x4308bbf500000000, 0x6573782d00000000, 0xf2d565ca00000000, 0x0a38323800000000, 0x9d9e2fdf00000000, 0x7f9397f800000000, 0xe8358a1f00000000, 0x10d8dded00000000, 0x877ec00a00000000, 0xa10503d200000000, 0x36a31e3500000000, 0xce4e49c700000000, 0x59e8542000000000, 0xc3bebead00000000, 0x5418a34a00000000, 0xacf5f4b800000000, 0x3b53e95f00000000, 0x1d282a8700000000, 0x8a8e376000000000, 0x7263609200000000, 0xe5c57d7500000000, 0xb67810dd00000000, 0x21de0d3a00000000, 0xd9335ac800000000, 0x4e95472f00000000, 0x68ee84f700000000, 0xff48991000000000, 0x07a5cee200000000, 0x9003d30500000000, 0x0a55398800000000, 0x9df3246f00000000, 0x651e739d00000000, 0xf2b86e7a00000000, 0xd4c3ada200000000, 0x4365b04500000000, 0xbb88e7b700000000, 0x2c2efa5000000000, 0xce23427700000000, 0x59855f9000000000, 0xa168086200000000, 0x36ce158500000000, 0x10b5d65d00000000, 0x8713cbba00000000, 0x7ffe9c4800000000, 0xe85881af00000000, 0x720e6b2200000000, 0xe5a876c500000000, 0x1d45213700000000, 0x8ae33cd000000000, 0xac98ff0800000000, 0x3b3ee2ef00000000, 0xc3d3b51d00000000, 0x5475a8fa00000000, 0x24af1f9600000000, 0xb309027100000000, 0x4be4558300000000, 0xdc42486400000000, 0xfa398bbc00000000, 0x6d9f965b00000000, 0x9572c1a900000000, 0x02d4dc4e00000000, 0x988236c300000000, 0x0f242b2400000000, 0xf7c97cd600000000, 0x606f613100000000, 0x4614a2e900000000, 0xd1b2bf0e00000000, 0x295fe8fc00000000, 0xbef9f51b00000000, 0x5cf44d3c00000000, 0xcb5250db00000000, 0x33bf072900000000, 0xa4191ace00000000, 0x8262d91600000000, 0x15c4c4f100000000, 0xed29930300000000, 0x7a8f8ee400000000, 0xe0d9646900000000, 0x777f798e00000000, 0x8f922e7c00000000, 0x1834339b00000000, 0x3e4ff04300000000, 0xa9e9eda400000000, 0x5104ba5600000000, 0xc6a2a7b100000000, 0x951fca1900000000, 0x02b9d7fe00000000, 0xfa54800c00000000, 0x6df29deb00000000, 0x4b895e3300000000, 0xdc2f43d400000000, 0x24c2142600000000, 0xb36409c100000000, 0x2932e34c00000000, 0xbe94feab00000000, 0x4679a95900000000, 0xd1dfb4be00000000, 0xf7a4776600000000, 0x60026a8100000000, 0x98ef3d7300000000, 0x0f49209400000000, 0xed4498b300000000, 0x7ae2855400000000, 0x820fd2a600000000, 0x15a9cf4100000000, 0x33d20c9900000000, 0xa474117e00000000, 0x5c99468c00000000, 0xcb3f5b6b00000000, 0x5169b1e600000000, 0xc6cfac0100000000, 0x3e22fbf300000000, 0xa984e61400000000, 0x8fff25cc00000000, 0x1859382b00000000, 0xe0b46fd900000000, 0x7712723e00000000}, {0x0000000000000000, 0x411b8c6e00000000, 0x823618dd00000000, 0xc32d94b300000000, 0x456b416100000000, 0x0470cd0f00000000, 0xc75d59bc00000000, 0x8646d5d200000000, 0x8ad682c200000000, 0xcbcd0eac00000000, 0x08e09a1f00000000, 0x49fb167100000000, 0xcfbdc3a300000000, 0x8ea64fcd00000000, 0x4d8bdb7e00000000, 0x0c90571000000000, 0x55ab745e00000000, 0x14b0f83000000000, 0xd79d6c8300000000, 0x9686e0ed00000000, 0x10c0353f00000000, 0x51dbb95100000000, 0x92f62de200000000, 0xd3eda18c00000000, 0xdf7df69c00000000, 0x9e667af200000000, 0x5d4bee4100000000, 0x1c50622f00000000, 0x9a16b7fd00000000, 0xdb0d3b9300000000, 0x1820af2000000000, 0x593b234e00000000, 0xaa56e9bc00000000, 0xeb4d65d200000000, 0x2860f16100000000, 0x697b7d0f00000000, 0xef3da8dd00000000, 0xae2624b300000000, 0x6d0bb00000000000, 0x2c103c6e00000000, 0x20806b7e00000000, 0x619be71000000000, 0xa2b673a300000000, 0xe3adffcd00000000, 0x65eb2a1f00000000, 0x24f0a67100000000, 0xe7dd32c200000000, 0xa6c6beac00000000, 0xfffd9de200000000, 0xbee6118c00000000, 0x7dcb853f00000000, 0x3cd0095100000000, 0xba96dc8300000000, 0xfb8d50ed00000000, 0x38a0c45e00000000, 0x79bb483000000000, 0x752b1f2000000000, 0x3430934e00000000, 0xf71d07fd00000000, 0xb6068b9300000000, 0x30405e4100000000, 0x715bd22f00000000, 0xb276469c00000000, 0xf36dcaf200000000, 0x15aba3a200000000, 0x54b02fcc00000000, 0x979dbb7f00000000, 0xd686371100000000, 0x50c0e2c300000000, 0x11db6ead00000000, 0xd2f6fa1e00000000, 0x93ed767000000000, 0x9f7d216000000000, 0xde66ad0e00000000, 0x1d4b39bd00000000, 0x5c50b5d300000000, 0xda16600100000000, 0x9b0dec6f00000000, 0x582078dc00000000, 0x193bf4b200000000, 0x4000d7fc00000000, 0x011b5b9200000000, 0xc236cf2100000000, 0x832d434f00000000, 0x056b969d00000000, 0x44701af300000000, 0x875d8e4000000000, 0xc646022e00000000, 0xcad6553e00000000, 0x8bcdd95000000000, 0x48e04de300000000, 0x09fbc18d00000000, 0x8fbd145f00000000, 0xcea6983100000000, 0x0d8b0c8200000000, 0x4c9080ec00000000, 0xbffd4a1e00000000, 0xfee6c67000000000, 0x3dcb52c300000000, 0x7cd0dead00000000, 0xfa960b7f00000000, 0xbb8d871100000000, 0x78a013a200000000, 0x39bb9fcc00000000, 0x352bc8dc00000000, 0x743044b200000000, 0xb71dd00100000000, 0xf6065c6f00000000, 0x704089bd00000000, 0x315b05d300000000, 0xf276916000000000, 0xb36d1d0e00000000, 0xea563e4000000000, 0xab4db22e00000000, 0x6860269d00000000, 0x297baaf300000000, 0xaf3d7f2100000000, 0xee26f34f00000000, 0x2d0b67fc00000000, 0x6c10eb9200000000, 0x6080bc8200000000, 0x219b30ec00000000, 0xe2b6a45f00000000, 0xa3ad283100000000, 0x25ebfde300000000, 0x64f0718d00000000, 0xa7dde53e00000000, 0xe6c6695000000000, 0x6b50369e00000000, 0x2a4bbaf000000000, 0xe9662e4300000000, 0xa87da22d00000000, 0x2e3b77ff00000000, 0x6f20fb9100000000, 0xac0d6f2200000000, 0xed16e34c00000000, 0xe186b45c00000000, 0xa09d383200000000, 0x63b0ac8100000000, 0x22ab20ef00000000, 0xa4edf53d00000000, 0xe5f6795300000000, 0x26dbede000000000, 0x67c0618e00000000, 0x3efb42c000000000, 0x7fe0ceae00000000, 0xbccd5a1d00000000, 0xfdd6d67300000000, 0x7b9003a100000000, 0x3a8b8fcf00000000, 0xf9a61b7c00000000, 0xb8bd971200000000, 0xb42dc00200000000, 0xf5364c6c00000000, 0x361bd8df00000000, 0x770054b100000000, 0xf146816300000000, 0xb05d0d0d00000000, 0x737099be00000000, 0x326b15d000000000, 0xc106df2200000000, 0x801d534c00000000, 0x4330c7ff00000000, 0x022b4b9100000000, 0x846d9e4300000000, 0xc576122d00000000, 0x065b869e00000000, 0x47400af000000000, 0x4bd05de000000000, 0x0acbd18e00000000, 0xc9e6453d00000000, 0x88fdc95300000000, 0x0ebb1c8100000000, 0x4fa090ef00000000, 0x8c8d045c00000000, 0xcd96883200000000, 0x94adab7c00000000, 0xd5b6271200000000, 0x169bb3a100000000, 0x57803fcf00000000, 0xd1c6ea1d00000000, 0x90dd667300000000, 0x53f0f2c000000000, 0x12eb7eae00000000, 0x1e7b29be00000000, 0x5f60a5d000000000, 0x9c4d316300000000, 0xdd56bd0d00000000, 0x5b1068df00000000, 0x1a0be4b100000000, 0xd926700200000000, 0x983dfc6c00000000, 0x7efb953c00000000, 0x3fe0195200000000, 0xfccd8de100000000, 0xbdd6018f00000000, 0x3b90d45d00000000, 0x7a8b583300000000, 0xb9a6cc8000000000, 0xf8bd40ee00000000, 0xf42d17fe00000000, 0xb5369b9000000000, 0x761b0f2300000000, 0x3700834d00000000, 0xb146569f00000000, 0xf05ddaf100000000, 0x33704e4200000000, 0x726bc22c00000000, 0x2b50e16200000000, 0x6a4b6d0c00000000, 0xa966f9bf00000000, 0xe87d75d100000000, 0x6e3ba00300000000, 0x2f202c6d00000000, 0xec0db8de00000000, 0xad1634b000000000, 0xa18663a000000000, 0xe09defce00000000, 0x23b07b7d00000000, 0x62abf71300000000, 0xe4ed22c100000000, 0xa5f6aeaf00000000, 0x66db3a1c00000000, 0x27c0b67200000000, 0xd4ad7c8000000000, 0x95b6f0ee00000000, 0x569b645d00000000, 0x1780e83300000000, 0x91c63de100000000, 0xd0ddb18f00000000, 0x13f0253c00000000, 0x52eba95200000000, 0x5e7bfe4200000000, 0x1f60722c00000000, 0xdc4de69f00000000, 0x9d566af100000000, 0x1b10bf2300000000, 0x5a0b334d00000000, 0x9926a7fe00000000, 0xd83d2b9000000000, 0x810608de00000000, 0xc01d84b000000000, 0x0330100300000000, 0x422b9c6d00000000, 0xc46d49bf00000000, 0x8576c5d100000000, 0x465b516200000000, 0x0740dd0c00000000, 0x0bd08a1c00000000, 0x4acb067200000000, 0x89e692c100000000, 0xc8fd1eaf00000000, 0x4ebbcb7d00000000, 0x0fa0471300000000, 0xcc8dd3a000000000, 0x8d965fce00000000}, {0x0000000000000000, 0x1dfdb50100000000, 0x3afa6b0300000000, 0x2707de0200000000, 0x74f4d70600000000, 0x6909620700000000, 0x4e0ebc0500000000, 0x53f3090400000000, 0xe8e8af0d00000000, 0xf5151a0c00000000, 0xd212c40e00000000, 0xcfef710f00000000, 0x9c1c780b00000000, 0x81e1cd0a00000000, 0xa6e6130800000000, 0xbb1ba60900000000, 0xd0d15f1b00000000, 0xcd2cea1a00000000, 0xea2b341800000000, 0xf7d6811900000000, 0xa425881d00000000, 0xb9d83d1c00000000, 0x9edfe31e00000000, 0x8322561f00000000, 0x3839f01600000000, 0x25c4451700000000, 0x02c39b1500000000, 0x1f3e2e1400000000, 0x4ccd271000000000, 0x5130921100000000, 0x76374c1300000000, 0x6bcaf91200000000, 0xa0a3bf3600000000, 0xbd5e0a3700000000, 0x9a59d43500000000, 0x87a4613400000000, 0xd457683000000000, 0xc9aadd3100000000, 0xeead033300000000, 0xf350b63200000000, 0x484b103b00000000, 0x55b6a53a00000000, 0x72b17b3800000000, 0x6f4cce3900000000, 0x3cbfc73d00000000, 0x2142723c00000000, 0x0645ac3e00000000, 0x1bb8193f00000000, 0x7072e02d00000000, 0x6d8f552c00000000, 0x4a888b2e00000000, 0x57753e2f00000000, 0x0486372b00000000, 0x197b822a00000000, 0x3e7c5c2800000000, 0x2381e92900000000, 0x989a4f2000000000, 0x8567fa2100000000, 0xa260242300000000, 0xbf9d912200000000, 0xec6e982600000000, 0xf1932d2700000000, 0xd694f32500000000, 0xcb69462400000000, 0x40477f6d00000000, 0x5dbaca6c00000000, 0x7abd146e00000000, 0x6740a16f00000000, 0x34b3a86b00000000, 0x294e1d6a00000000, 0x0e49c36800000000, 0x13b4766900000000, 0xa8afd06000000000, 0xb552656100000000, 0x9255bb6300000000, 0x8fa80e6200000000, 0xdc5b076600000000, 0xc1a6b26700000000, 0xe6a16c6500000000, 0xfb5cd96400000000, 0x9096207600000000, 0x8d6b957700000000, 0xaa6c4b7500000000, 0xb791fe7400000000, 0xe462f77000000000, 0xf99f427100000000, 0xde989c7300000000, 0xc365297200000000, 0x787e8f7b00000000, 0x65833a7a00000000, 0x4284e47800000000, 0x5f79517900000000, 0x0c8a587d00000000, 0x1177ed7c00000000, 0x3670337e00000000, 0x2b8d867f00000000, 0xe0e4c05b00000000, 0xfd19755a00000000, 0xda1eab5800000000, 0xc7e31e5900000000, 0x9410175d00000000, 0x89eda25c00000000, 0xaeea7c5e00000000, 0xb317c95f00000000, 0x080c6f5600000000, 0x15f1da5700000000, 0x32f6045500000000, 0x2f0bb15400000000, 0x7cf8b85000000000, 0x61050d5100000000, 0x4602d35300000000, 0x5bff665200000000, 0x30359f4000000000, 0x2dc82a4100000000, 0x0acff44300000000, 0x1732414200000000, 0x44c1484600000000, 0x593cfd4700000000, 0x7e3b234500000000, 0x63c6964400000000, 0xd8dd304d00000000, 0xc520854c00000000, 0xe2275b4e00000000, 0xffdaee4f00000000, 0xac29e74b00000000, 0xb1d4524a00000000, 0x96d38c4800000000, 0x8b2e394900000000, 0x808efeda00000000, 0x9d734bdb00000000, 0xba7495d900000000, 0xa78920d800000000, 0xf47a29dc00000000, 0xe9879cdd00000000, 0xce8042df00000000, 0xd37df7de00000000, 0x686651d700000000, 0x759be4d600000000, 0x529c3ad400000000, 0x4f618fd500000000, 0x1c9286d100000000, 0x016f33d000000000, 0x2668edd200000000, 0x3b9558d300000000, 0x505fa1c100000000, 0x4da214c000000000, 0x6aa5cac200000000, 0x77587fc300000000, 0x24ab76c700000000, 0x3956c3c600000000, 0x1e511dc400000000, 0x03aca8c500000000, 0xb8b70ecc00000000, 0xa54abbcd00000000, 0x824d65cf00000000, 0x9fb0d0ce00000000, 0xcc43d9ca00000000, 0xd1be6ccb00000000, 0xf6b9b2c900000000, 0xeb4407c800000000, 0x202d41ec00000000, 0x3dd0f4ed00000000, 0x1ad72aef00000000, 0x072a9fee00000000, 0x54d996ea00000000, 0x492423eb00000000, 0x6e23fde900000000, 0x73de48e800000000, 0xc8c5eee100000000, 0xd5385be000000000, 0xf23f85e200000000, 0xefc230e300000000, 0xbc3139e700000000, 0xa1cc8ce600000000, 0x86cb52e400000000, 0x9b36e7e500000000, 0xf0fc1ef700000000, 0xed01abf600000000, 0xca0675f400000000, 0xd7fbc0f500000000, 0x8408c9f100000000, 0x99f57cf000000000, 0xbef2a2f200000000, 0xa30f17f300000000, 0x1814b1fa00000000, 0x05e904fb00000000, 0x22eedaf900000000, 0x3f136ff800000000, 0x6ce066fc00000000, 0x711dd3fd00000000, 0x561a0dff00000000, 0x4be7b8fe00000000, 0xc0c981b700000000, 0xdd3434b600000000, 0xfa33eab400000000, 0xe7ce5fb500000000, 0xb43d56b100000000, 0xa9c0e3b000000000, 0x8ec73db200000000, 0x933a88b300000000, 0x28212eba00000000, 0x35dc9bbb00000000, 0x12db45b900000000, 0x0f26f0b800000000, 0x5cd5f9bc00000000, 0x41284cbd00000000, 0x662f92bf00000000, 0x7bd227be00000000, 0x1018deac00000000, 0x0de56bad00000000, 0x2ae2b5af00000000, 0x371f00ae00000000, 0x64ec09aa00000000, 0x7911bcab00000000, 0x5e1662a900000000, 0x43ebd7a800000000, 0xf8f071a100000000, 0xe50dc4a000000000, 0xc20a1aa200000000, 0xdff7afa300000000, 0x8c04a6a700000000, 0x91f913a600000000, 0xb6fecda400000000, 0xab0378a500000000, 0x606a3e8100000000, 0x7d978b8000000000, 0x5a90558200000000, 0x476de08300000000, 0x149ee98700000000, 0x09635c8600000000, 0x2e64828400000000, 0x3399378500000000, 0x8882918c00000000, 0x957f248d00000000, 0xb278fa8f00000000, 0xaf854f8e00000000, 0xfc76468a00000000, 0xe18bf38b00000000, 0xc68c2d8900000000, 0xdb71988800000000, 0xb0bb619a00000000, 0xad46d49b00000000, 0x8a410a9900000000, 0x97bcbf9800000000, 0xc44fb69c00000000, 0xd9b2039d00000000, 0xfeb5dd9f00000000, 0xe348689e00000000, 0x5853ce9700000000, 0x45ae7b9600000000, 0x62a9a59400000000, 0x7f54109500000000, 0x2ca7199100000000, 0x315aac9000000000, 0x165d729200000000, 0x0ba0c79300000000}, {0x0000000000000000, 0x24d9076300000000, 0x48b20fc600000000, 0x6c6b08a500000000, 0xd1626e5700000000, 0xf5bb693400000000, 0x99d0619100000000, 0xbd0966f200000000, 0xa2c5dcae00000000, 0x861cdbcd00000000, 0xea77d36800000000, 0xceaed40b00000000, 0x73a7b2f900000000, 0x577eb59a00000000, 0x3b15bd3f00000000, 0x1fccba5c00000000, 0x058dc88600000000, 0x2154cfe500000000, 0x4d3fc74000000000, 0x69e6c02300000000, 0xd4efa6d100000000, 0xf036a1b200000000, 0x9c5da91700000000, 0xb884ae7400000000, 0xa748142800000000, 0x8391134b00000000, 0xeffa1bee00000000, 0xcb231c8d00000000, 0x762a7a7f00000000, 0x52f37d1c00000000, 0x3e9875b900000000, 0x1a4172da00000000, 0x4b1ce0d600000000, 0x6fc5e7b500000000, 0x03aeef1000000000, 0x2777e87300000000, 0x9a7e8e8100000000, 0xbea789e200000000, 0xd2cc814700000000, 0xf615862400000000, 0xe9d93c7800000000, 0xcd003b1b00000000, 0xa16b33be00000000, 0x85b234dd00000000, 0x38bb522f00000000, 0x1c62554c00000000, 0x70095de900000000, 0x54d05a8a00000000, 0x4e91285000000000, 0x6a482f3300000000, 0x0623279600000000, 0x22fa20f500000000, 0x9ff3460700000000, 0xbb2a416400000000, 0xd74149c100000000, 0xf3984ea200000000, 0xec54f4fe00000000, 0xc88df39d00000000, 0xa4e6fb3800000000, 0x803ffc5b00000000, 0x3d369aa900000000, 0x19ef9dca00000000, 0x7584956f00000000, 0x515d920c00000000, 0xd73eb17600000000, 0xf3e7b61500000000, 0x9f8cbeb000000000, 0xbb55b9d300000000, 0x065cdf2100000000, 0x2285d84200000000, 0x4eeed0e700000000, 0x6a37d78400000000, 0x75fb6dd800000000, 0x51226abb00000000, 0x3d49621e00000000, 0x1990657d00000000, 0xa499038f00000000, 0x804004ec00000000, 0xec2b0c4900000000, 0xc8f20b2a00000000, 0xd2b379f000000000, 0xf66a7e9300000000, 0x9a01763600000000, 0xbed8715500000000, 0x03d117a700000000, 0x270810c400000000, 0x4b63186100000000, 0x6fba1f0200000000, 0x7076a55e00000000, 0x54afa23d00000000, 0x38c4aa9800000000, 0x1c1dadfb00000000, 0xa114cb0900000000, 0x85cdcc6a00000000, 0xe9a6c4cf00000000, 0xcd7fc3ac00000000, 0x9c2251a000000000, 0xb8fb56c300000000, 0xd4905e6600000000, 0xf049590500000000, 0x4d403ff700000000, 0x6999389400000000, 0x05f2303100000000, 0x212b375200000000, 0x3ee78d0e00000000, 0x1a3e8a6d00000000, 0x765582c800000000, 0x528c85ab00000000, 0xef85e35900000000, 0xcb5ce43a00000000, 0xa737ec9f00000000, 0x83eeebfc00000000, 0x99af992600000000, 0xbd769e4500000000, 0xd11d96e000000000, 0xf5c4918300000000, 0x48cdf77100000000, 0x6c14f01200000000, 0x007ff8b700000000, 0x24a6ffd400000000, 0x3b6a458800000000, 0x1fb342eb00000000, 0x73d84a4e00000000, 0x57014d2d00000000, 0xea082bdf00000000, 0xced12cbc00000000, 0xa2ba241900000000, 0x8663237a00000000, 0xae7d62ed00000000, 0x8aa4658e00000000, 0xe6cf6d2b00000000, 0xc2166a4800000000, 0x7f1f0cba00000000, 0x5bc60bd900000000, 0x37ad037c00000000, 0x1374041f00000000, 0x0cb8be4300000000, 0x2861b92000000000, 0x440ab18500000000, 0x60d3b6e600000000, 0xdddad01400000000, 0xf903d77700000000, 0x9568dfd200000000, 0xb1b1d8b100000000, 0xabf0aa6b00000000, 0x8f29ad0800000000, 0xe342a5ad00000000, 0xc79ba2ce00000000, 0x7a92c43c00000000, 0x5e4bc35f00000000, 0x3220cbfa00000000, 0x16f9cc9900000000, 0x093576c500000000, 0x2dec71a600000000, 0x4187790300000000, 0x655e7e6000000000, 0xd857189200000000, 0xfc8e1ff100000000, 0x90e5175400000000, 0xb43c103700000000, 0xe561823b00000000, 0xc1b8855800000000, 0xadd38dfd00000000, 0x890a8a9e00000000, 0x3403ec6c00000000, 0x10daeb0f00000000, 0x7cb1e3aa00000000, 0x5868e4c900000000, 0x47a45e9500000000, 0x637d59f600000000, 0x0f16515300000000, 0x2bcf563000000000, 0x96c630c200000000, 0xb21f37a100000000, 0xde743f0400000000, 0xfaad386700000000, 0xe0ec4abd00000000, 0xc4354dde00000000, 0xa85e457b00000000, 0x8c87421800000000, 0x318e24ea00000000, 0x1557238900000000, 0x793c2b2c00000000, 0x5de52c4f00000000, 0x4229961300000000, 0x66f0917000000000, 0x0a9b99d500000000, 0x2e429eb600000000, 0x934bf84400000000, 0xb792ff2700000000, 0xdbf9f78200000000, 0xff20f0e100000000, 0x7943d39b00000000, 0x5d9ad4f800000000, 0x31f1dc5d00000000, 0x1528db3e00000000, 0xa821bdcc00000000, 0x8cf8baaf00000000, 0xe093b20a00000000, 0xc44ab56900000000, 0xdb860f3500000000, 0xff5f085600000000, 0x933400f300000000, 0xb7ed079000000000, 0x0ae4616200000000, 0x2e3d660100000000, 0x42566ea400000000, 0x668f69c700000000, 0x7cce1b1d00000000, 0x58171c7e00000000, 0x347c14db00000000, 0x10a513b800000000, 0xadac754a00000000, 0x8975722900000000, 0xe51e7a8c00000000, 0xc1c77def00000000, 0xde0bc7b300000000, 0xfad2c0d000000000, 0x96b9c87500000000, 0xb260cf1600000000, 0x0f69a9e400000000, 0x2bb0ae8700000000, 0x47dba62200000000, 0x6302a14100000000, 0x325f334d00000000, 0x1686342e00000000, 0x7aed3c8b00000000, 0x5e343be800000000, 0xe33d5d1a00000000, 0xc7e45a7900000000, 0xab8f52dc00000000, 0x8f5655bf00000000, 0x909aefe300000000, 0xb443e88000000000, 0xd828e02500000000, 0xfcf1e74600000000, 0x41f881b400000000, 0x652186d700000000, 0x094a8e7200000000, 0x2d93891100000000, 0x37d2fbcb00000000, 0x130bfca800000000, 0x7f60f40d00000000, 0x5bb9f36e00000000, 0xe6b0959c00000000, 0xc26992ff00000000, 0xae029a5a00000000, 0x8adb9d3900000000, 0x9517276500000000, 0xb1ce200600000000, 0xdda528a300000000, 0xf97c2fc000000000, 0x4475493200000000, 0x60ac4e5100000000, 0x0cc746f400000000, 0x281e419700000000}, {0x0000000000000000, 0x08e3603c00000000, 0x10c6c17800000000, 0x1825a14400000000, 0x208c83f100000000, 0x286fe3cd00000000, 0x304a428900000000, 0x38a922b500000000, 0x011e763800000000, 0x09fd160400000000, 0x11d8b74000000000, 0x193bd77c00000000, 0x2192f5c900000000, 0x297195f500000000, 0x315434b100000000, 0x39b7548d00000000, 0x023cec7000000000, 0x0adf8c4c00000000, 0x12fa2d0800000000, 0x1a194d3400000000, 0x22b06f8100000000, 0x2a530fbd00000000, 0x3276aef900000000, 0x3a95cec500000000, 0x03229a4800000000, 0x0bc1fa7400000000, 0x13e45b3000000000, 0x1b073b0c00000000, 0x23ae19b900000000, 0x2b4d798500000000, 0x3368d8c100000000, 0x3b8bb8fd00000000, 0x0478d8e100000000, 0x0c9bb8dd00000000, 0x14be199900000000, 0x1c5d79a500000000, 0x24f45b1000000000, 0x2c173b2c00000000, 0x34329a6800000000, 0x3cd1fa5400000000, 0x0566aed900000000, 0x0d85cee500000000, 0x15a06fa100000000, 0x1d430f9d00000000, 0x25ea2d2800000000, 0x2d094d1400000000, 0x352cec5000000000, 0x3dcf8c6c00000000, 0x0644349100000000, 0x0ea754ad00000000, 0x1682f5e900000000, 0x1e6195d500000000, 0x26c8b76000000000, 0x2e2bd75c00000000, 0x360e761800000000, 0x3eed162400000000, 0x075a42a900000000, 0x0fb9229500000000, 0x179c83d100000000, 0x1f7fe3ed00000000, 0x27d6c15800000000, 0x2f35a16400000000, 0x3710002000000000, 0x3ff3601c00000000, 0x49f6c11800000000, 0x4115a12400000000, 0x5930006000000000, 0x51d3605c00000000, 0x697a42e900000000, 0x619922d500000000, 0x79bc839100000000, 0x715fe3ad00000000, 0x48e8b72000000000, 0x400bd71c00000000, 0x582e765800000000, 0x50cd166400000000, 0x686434d100000000, 0x608754ed00000000, 0x78a2f5a900000000, 0x7041959500000000, 0x4bca2d6800000000, 0x43294d5400000000, 0x5b0cec1000000000, 0x53ef8c2c00000000, 0x6b46ae9900000000, 0x63a5cea500000000, 0x7b806fe100000000, 0x73630fdd00000000, 0x4ad45b5000000000, 0x42373b6c00000000, 0x5a129a2800000000, 0x52f1fa1400000000, 0x6a58d8a100000000, 0x62bbb89d00000000, 0x7a9e19d900000000, 0x727d79e500000000, 0x4d8e19f900000000, 0x456d79c500000000, 0x5d48d88100000000, 0x55abb8bd00000000, 0x6d029a0800000000, 0x65e1fa3400000000, 0x7dc45b7000000000, 0x75273b4c00000000, 0x4c906fc100000000, 0x44730ffd00000000, 0x5c56aeb900000000, 0x54b5ce8500000000, 0x6c1cec3000000000, 0x64ff8c0c00000000, 0x7cda2d4800000000, 0x74394d7400000000, 0x4fb2f58900000000, 0x475195b500000000, 0x5f7434f100000000, 0x579754cd00000000, 0x6f3e767800000000, 0x67dd164400000000, 0x7ff8b70000000000, 0x771bd73c00000000, 0x4eac83b100000000, 0x464fe38d00000000, 0x5e6a42c900000000, 0x568922f500000000, 0x6e20004000000000, 0x66c3607c00000000, 0x7ee6c13800000000, 0x7605a10400000000, 0x92ec833100000000, 0x9a0fe30d00000000, 0x822a424900000000, 0x8ac9227500000000, 0xb26000c000000000, 0xba8360fc00000000, 0xa2a6c1b800000000, 0xaa45a18400000000, 0x93f2f50900000000, 0x9b11953500000000, 0x8334347100000000, 0x8bd7544d00000000, 0xb37e76f800000000, 0xbb9d16c400000000, 0xa3b8b78000000000, 0xab5bd7bc00000000, 0x90d06f4100000000, 0x98330f7d00000000, 0x8016ae3900000000, 0x88f5ce0500000000, 0xb05cecb000000000, 0xb8bf8c8c00000000, 0xa09a2dc800000000, 0xa8794df400000000, 0x91ce197900000000, 0x992d794500000000, 0x8108d80100000000, 0x89ebb83d00000000, 0xb1429a8800000000, 0xb9a1fab400000000, 0xa1845bf000000000, 0xa9673bcc00000000, 0x96945bd000000000, 0x9e773bec00000000, 0x86529aa800000000, 0x8eb1fa9400000000, 0xb618d82100000000, 0xbefbb81d00000000, 0xa6de195900000000, 0xae3d796500000000, 0x978a2de800000000, 0x9f694dd400000000, 0x874cec9000000000, 0x8faf8cac00000000, 0xb706ae1900000000, 0xbfe5ce2500000000, 0xa7c06f6100000000, 0xaf230f5d00000000, 0x94a8b7a000000000, 0x9c4bd79c00000000, 0x846e76d800000000, 0x8c8d16e400000000, 0xb424345100000000, 0xbcc7546d00000000, 0xa4e2f52900000000, 0xac01951500000000, 0x95b6c19800000000, 0x9d55a1a400000000, 0x857000e000000000, 0x8d9360dc00000000, 0xb53a426900000000, 0xbdd9225500000000, 0xa5fc831100000000, 0xad1fe32d00000000, 0xdb1a422900000000, 0xd3f9221500000000, 0xcbdc835100000000, 0xc33fe36d00000000, 0xfb96c1d800000000, 0xf375a1e400000000, 0xeb5000a000000000, 0xe3b3609c00000000, 0xda04341100000000, 0xd2e7542d00000000, 0xcac2f56900000000, 0xc221955500000000, 0xfa88b7e000000000, 0xf26bd7dc00000000, 0xea4e769800000000, 0xe2ad16a400000000, 0xd926ae5900000000, 0xd1c5ce6500000000, 0xc9e06f2100000000, 0xc1030f1d00000000, 0xf9aa2da800000000, 0xf1494d9400000000, 0xe96cecd000000000, 0xe18f8cec00000000, 0xd838d86100000000, 0xd0dbb85d00000000, 0xc8fe191900000000, 0xc01d792500000000, 0xf8b45b9000000000, 0xf0573bac00000000, 0xe8729ae800000000, 0xe091fad400000000, 0xdf629ac800000000, 0xd781faf400000000, 0xcfa45bb000000000, 0xc7473b8c00000000, 0xffee193900000000, 0xf70d790500000000, 0xef28d84100000000, 0xe7cbb87d00000000, 0xde7cecf000000000, 0xd69f8ccc00000000, 0xceba2d8800000000, 0xc6594db400000000, 0xfef06f0100000000, 0xf6130f3d00000000, 0xee36ae7900000000, 0xe6d5ce4500000000, 0xdd5e76b800000000, 0xd5bd168400000000, 0xcd98b7c000000000, 0xc57bd7fc00000000, 0xfdd2f54900000000, 0xf531957500000000, 0xed14343100000000, 0xe5f7540d00000000, 0xdc40008000000000, 0xd4a360bc00000000, 0xcc86c1f800000000, 0xc465a1c400000000, 0xfccc837100000000, 0xf42fe34d00000000, 0xec0a420900000000, 0xe4e9223500000000}, {0x0000000000000000, 0xd1e8e70e00000000, 0xa2d1cf1d00000000, 0x7339281300000000, 0x44a39f3b00000000, 0x954b783500000000, 0xe672502600000000, 0x379ab72800000000, 0x88463f7700000000, 0x59aed87900000000, 0x2a97f06a00000000, 0xfb7f176400000000, 0xcce5a04c00000000, 0x1d0d474200000000, 0x6e346f5100000000, 0xbfdc885f00000000, 0x108d7eee00000000, 0xc16599e000000000, 0xb25cb1f300000000, 0x63b456fd00000000, 0x542ee1d500000000, 0x85c606db00000000, 0xf6ff2ec800000000, 0x2717c9c600000000, 0x98cb419900000000, 0x4923a69700000000, 0x3a1a8e8400000000, 0xebf2698a00000000, 0xdc68dea200000000, 0x0d8039ac00000000, 0x7eb911bf00000000, 0xaf51f6b100000000, 0x611c8c0700000000, 0xb0f46b0900000000, 0xc3cd431a00000000, 0x1225a41400000000, 0x25bf133c00000000, 0xf457f43200000000, 0x876edc2100000000, 0x56863b2f00000000, 0xe95ab37000000000, 0x38b2547e00000000, 0x4b8b7c6d00000000, 0x9a639b6300000000, 0xadf92c4b00000000, 0x7c11cb4500000000, 0x0f28e35600000000, 0xdec0045800000000, 0x7191f2e900000000, 0xa07915e700000000, 0xd3403df400000000, 0x02a8dafa00000000, 0x35326dd200000000, 0xe4da8adc00000000, 0x97e3a2cf00000000, 0x460b45c100000000, 0xf9d7cd9e00000000, 0x283f2a9000000000, 0x5b06028300000000, 0x8aeee58d00000000, 0xbd7452a500000000, 0x6c9cb5ab00000000, 0x1fa59db800000000, 0xce4d7ab600000000, 0xc238180f00000000, 0x13d0ff0100000000, 0x60e9d71200000000, 0xb101301c00000000, 0x869b873400000000, 0x5773603a00000000, 0x244a482900000000, 0xf5a2af2700000000, 0x4a7e277800000000, 0x9b96c07600000000, 0xe8afe86500000000, 0x39470f6b00000000, 0x0eddb84300000000, 0xdf355f4d00000000, 0xac0c775e00000000, 0x7de4905000000000, 0xd2b566e100000000, 0x035d81ef00000000, 0x7064a9fc00000000, 0xa18c4ef200000000, 0x9616f9da00000000, 0x47fe1ed400000000, 0x34c736c700000000, 0xe52fd1c900000000, 0x5af3599600000000, 0x8b1bbe9800000000, 0xf822968b00000000, 0x29ca718500000000, 0x1e50c6ad00000000, 0xcfb821a300000000, 0xbc8109b000000000, 0x6d69eebe00000000, 0xa324940800000000, 0x72cc730600000000, 0x01f55b1500000000, 0xd01dbc1b00000000, 0xe7870b3300000000, 0x366fec3d00000000, 0x4556c42e00000000, 0x94be232000000000, 0x2b62ab7f00000000, 0xfa8a4c7100000000, 0x89b3646200000000, 0x585b836c00000000, 0x6fc1344400000000, 0xbe29d34a00000000, 0xcd10fb5900000000, 0x1cf81c5700000000, 0xb3a9eae600000000, 0x62410de800000000, 0x117825fb00000000, 0xc090c2f500000000, 0xf70a75dd00000000, 0x26e292d300000000, 0x55dbbac000000000, 0x84335dce00000000, 0x3befd59100000000, 0xea07329f00000000, 0x993e1a8c00000000, 0x48d6fd8200000000, 0x7f4c4aaa00000000, 0xaea4ada400000000, 0xdd9d85b700000000, 0x0c7562b900000000, 0x8471301e00000000, 0x5599d71000000000, 0x26a0ff0300000000, 0xf748180d00000000, 0xc0d2af2500000000, 0x113a482b00000000, 0x6203603800000000, 0xb3eb873600000000, 0x0c370f6900000000, 0xdddfe86700000000, 0xaee6c07400000000, 0x7f0e277a00000000, 0x4894905200000000, 0x997c775c00000000, 0xea455f4f00000000, 0x3badb84100000000, 0x94fc4ef000000000, 0x4514a9fe00000000, 0x362d81ed00000000, 0xe7c566e300000000, 0xd05fd1cb00000000, 0x01b736c500000000, 0x728e1ed600000000, 0xa366f9d800000000, 0x1cba718700000000, 0xcd52968900000000, 0xbe6bbe9a00000000, 0x6f83599400000000, 0x5819eebc00000000, 0x89f109b200000000, 0xfac821a100000000, 0x2b20c6af00000000, 0xe56dbc1900000000, 0x34855b1700000000, 0x47bc730400000000, 0x9654940a00000000, 0xa1ce232200000000, 0x7026c42c00000000, 0x031fec3f00000000, 0xd2f70b3100000000, 0x6d2b836e00000000, 0xbcc3646000000000, 0xcffa4c7300000000, 0x1e12ab7d00000000, 0x29881c5500000000, 0xf860fb5b00000000, 0x8b59d34800000000, 0x5ab1344600000000, 0xf5e0c2f700000000, 0x240825f900000000, 0x57310dea00000000, 0x86d9eae400000000, 0xb1435dcc00000000, 0x60abbac200000000, 0x139292d100000000, 0xc27a75df00000000, 0x7da6fd8000000000, 0xac4e1a8e00000000, 0xdf77329d00000000, 0x0e9fd59300000000, 0x390562bb00000000, 0xe8ed85b500000000, 0x9bd4ada600000000, 0x4a3c4aa800000000, 0x4649281100000000, 0x97a1cf1f00000000, 0xe498e70c00000000, 0x3570000200000000, 0x02eab72a00000000, 0xd302502400000000, 0xa03b783700000000, 0x71d39f3900000000, 0xce0f176600000000, 0x1fe7f06800000000, 0x6cded87b00000000, 0xbd363f7500000000, 0x8aac885d00000000, 0x5b446f5300000000, 0x287d474000000000, 0xf995a04e00000000, 0x56c456ff00000000, 0x872cb1f100000000, 0xf41599e200000000, 0x25fd7eec00000000, 0x1267c9c400000000, 0xc38f2eca00000000, 0xb0b606d900000000, 0x615ee1d700000000, 0xde82698800000000, 0x0f6a8e8600000000, 0x7c53a69500000000, 0xadbb419b00000000, 0x9a21f6b300000000, 0x4bc911bd00000000, 0x38f039ae00000000, 0xe918dea000000000, 0x2755a41600000000, 0xf6bd431800000000, 0x85846b0b00000000, 0x546c8c0500000000, 0x63f63b2d00000000, 0xb21edc2300000000, 0xc127f43000000000, 0x10cf133e00000000, 0xaf139b6100000000, 0x7efb7c6f00000000, 0x0dc2547c00000000, 0xdc2ab37200000000, 0xebb0045a00000000, 0x3a58e35400000000, 0x4961cb4700000000, 0x98892c4900000000, 0x37d8daf800000000, 0xe6303df600000000, 0x950915e500000000, 0x44e1f2eb00000000, 0x737b45c300000000, 0xa293a2cd00000000, 0xd1aa8ade00000000, 0x00426dd000000000, 0xbf9ee58f00000000, 0x6e76028100000000, 0x1d4f2a9200000000, 0xcca7cd9c00000000, 0xfb3d7ab400000000, 0x2ad59dba00000000, 0x59ecb5a900000000, 0x880452a700000000}, {0x0000000000000000, 0xaa05daf100000000, 0x150dc53800000000, 0xbf081fc900000000, 0x2a1a8a7100000000, 0x801f508000000000, 0x3f174f4900000000, 0x951295b800000000, 0x543414e300000000, 0xfe31ce1200000000, 0x4139d1db00000000, 0xeb3c0b2a00000000, 0x7e2e9e9200000000, 0xd42b446300000000, 0x6b235baa00000000, 0xc126815b00000000, 0xe96e591d00000000, 0x436b83ec00000000, 0xfc639c2500000000, 0x566646d400000000, 0xc374d36c00000000, 0x6971099d00000000, 0xd679165400000000, 0x7c7ccca500000000, 0xbd5a4dfe00000000, 0x175f970f00000000, 0xa85788c600000000, 0x0252523700000000, 0x9740c78f00000000, 0x3d451d7e00000000, 0x824d02b700000000, 0x2848d84600000000, 0xd2ddb23a00000000, 0x78d868cb00000000, 0xc7d0770200000000, 0x6dd5adf300000000, 0xf8c7384b00000000, 0x52c2e2ba00000000, 0xedcafd7300000000, 0x47cf278200000000, 0x86e9a6d900000000, 0x2cec7c2800000000, 0x93e463e100000000, 0x39e1b91000000000, 0xacf32ca800000000, 0x06f6f65900000000, 0xb9fee99000000000, 0x13fb336100000000, 0x3bb3eb2700000000, 0x91b631d600000000, 0x2ebe2e1f00000000, 0x84bbf4ee00000000, 0x11a9615600000000, 0xbbacbba700000000, 0x04a4a46e00000000, 0xaea17e9f00000000, 0x6f87ffc400000000, 0xc582253500000000, 0x7a8a3afc00000000, 0xd08fe00d00000000, 0x459d75b500000000, 0xef98af4400000000, 0x5090b08d00000000, 0xfa956a7c00000000, 0xa4bb657500000000, 0x0ebebf8400000000, 0xb1b6a04d00000000, 0x1bb37abc00000000, 0x8ea1ef0400000000, 0x24a435f500000000, 0x9bac2a3c00000000, 0x31a9f0cd00000000, 0xf08f719600000000, 0x5a8aab6700000000, 0xe582b4ae00000000, 0x4f876e5f00000000, 0xda95fbe700000000, 0x7090211600000000, 0xcf983edf00000000, 0x659de42e00000000, 0x4dd53c6800000000, 0xe7d0e69900000000, 0x58d8f95000000000, 0xf2dd23a100000000, 0x67cfb61900000000, 0xcdca6ce800000000, 0x72c2732100000000, 0xd8c7a9d000000000, 0x19e1288b00000000, 0xb3e4f27a00000000, 0x0cecedb300000000, 0xa6e9374200000000, 0x33fba2fa00000000, 0x99fe780b00000000, 0x26f667c200000000, 0x8cf3bd3300000000, 0x7666d74f00000000, 0xdc630dbe00000000, 0x636b127700000000, 0xc96ec88600000000, 0x5c7c5d3e00000000, 0xf67987cf00000000, 0x4971980600000000, 0xe37442f700000000, 0x2252c3ac00000000, 0x8857195d00000000, 0x375f069400000000, 0x9d5adc6500000000, 0x084849dd00000000, 0xa24d932c00000000, 0x1d458ce500000000, 0xb740561400000000, 0x9f088e5200000000, 0x350d54a300000000, 0x8a054b6a00000000, 0x2000919b00000000, 0xb512042300000000, 0x1f17ded200000000, 0xa01fc11b00000000, 0x0a1a1bea00000000, 0xcb3c9ab100000000, 0x6139404000000000, 0xde315f8900000000, 0x7434857800000000, 0xe12610c000000000, 0x4b23ca3100000000, 0xf42bd5f800000000, 0x5e2e0f0900000000, 0x4877cbea00000000, 0xe272111b00000000, 0x5d7a0ed200000000, 0xf77fd42300000000, 0x626d419b00000000, 0xc8689b6a00000000, 0x776084a300000000, 0xdd655e5200000000, 0x1c43df0900000000, 0xb64605f800000000, 0x094e1a3100000000, 0xa34bc0c000000000, 0x3659557800000000, 0x9c5c8f8900000000, 0x2354904000000000, 0x89514ab100000000, 0xa11992f700000000, 0x0b1c480600000000, 0xb41457cf00000000, 0x1e118d3e00000000, 0x8b03188600000000, 0x2106c27700000000, 0x9e0eddbe00000000, 0x340b074f00000000, 0xf52d861400000000, 0x5f285ce500000000, 0xe020432c00000000, 0x4a2599dd00000000, 0xdf370c6500000000, 0x7532d69400000000, 0xca3ac95d00000000, 0x603f13ac00000000, 0x9aaa79d000000000, 0x30afa32100000000, 0x8fa7bce800000000, 0x25a2661900000000, 0xb0b0f3a100000000, 0x1ab5295000000000, 0xa5bd369900000000, 0x0fb8ec6800000000, 0xce9e6d3300000000, 0x649bb7c200000000, 0xdb93a80b00000000, 0x719672fa00000000, 0xe484e74200000000, 0x4e813db300000000, 0xf189227a00000000, 0x5b8cf88b00000000, 0x73c420cd00000000, 0xd9c1fa3c00000000, 0x66c9e5f500000000, 0xcccc3f0400000000, 0x59deaabc00000000, 0xf3db704d00000000, 0x4cd36f8400000000, 0xe6d6b57500000000, 0x27f0342e00000000, 0x8df5eedf00000000, 0x32fdf11600000000, 0x98f82be700000000, 0x0deabe5f00000000, 0xa7ef64ae00000000, 0x18e77b6700000000, 0xb2e2a19600000000, 0xecccae9f00000000, 0x46c9746e00000000, 0xf9c16ba700000000, 0x53c4b15600000000, 0xc6d624ee00000000, 0x6cd3fe1f00000000, 0xd3dbe1d600000000, 0x79de3b2700000000, 0xb8f8ba7c00000000, 0x12fd608d00000000, 0xadf57f4400000000, 0x07f0a5b500000000, 0x92e2300d00000000, 0x38e7eafc00000000, 0x87eff53500000000, 0x2dea2fc400000000, 0x05a2f78200000000, 0xafa72d7300000000, 0x10af32ba00000000, 0xbaaae84b00000000, 0x2fb87df300000000, 0x85bda70200000000, 0x3ab5b8cb00000000, 0x90b0623a00000000, 0x5196e36100000000, 0xfb93399000000000, 0x449b265900000000, 0xee9efca800000000, 0x7b8c691000000000, 0xd189b3e100000000, 0x6e81ac2800000000, 0xc48476d900000000, 0x3e111ca500000000, 0x9414c65400000000, 0x2b1cd99d00000000, 0x8119036c00000000, 0x140b96d400000000, 0xbe0e4c2500000000, 0x010653ec00000000, 0xab03891d00000000, 0x6a25084600000000, 0xc020d2b700000000, 0x7f28cd7e00000000, 0xd52d178f00000000, 0x403f823700000000, 0xea3a58c600000000, 0x5532470f00000000, 0xff379dfe00000000, 0xd77f45b800000000, 0x7d7a9f4900000000, 0xc272808000000000, 0x68775a7100000000, 0xfd65cfc900000000, 0x5760153800000000, 0xe8680af100000000, 0x426dd00000000000, 0x834b515b00000000, 0x294e8baa00000000, 0x9646946300000000, 0x3c434e9200000000, 0xa951db2a00000000, 0x035401db00000000, 0xbc5c1e1200000000, 0x1659c4e300000000}}; #else /* W == 4 */ local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, 0x0d7139d7}, {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, 0x1c53e98a}, {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, 0x3f88e851}, {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, 0x3dee8ca6}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x00000000, 0x85d996dd, 0x4bb55c60, 0xce6ccabd, 0x966ab9c0, 0x13b32f1d, 0xdddfe5a0, 0x5806737d, 0x6dd3035a, 0xe80a9587, 0x26665f3a, 0xa3bfc9e7, 0xfbb9ba9a, 0x7e602c47, 0xb00ce6fa, 0x35d57027, 0xdaa607b4, 0x5f7f9169, 0x91135bd4, 0x14cacd09, 0x4cccbe74, 0xc91528a9, 0x0779e214, 0x82a074c9, 0xb77504ee, 0x32ac9233, 0xfcc0588e, 0x7919ce53, 0x211fbd2e, 0xa4c62bf3, 0x6aaae14e, 0xef737793, 0xf54b7eb3, 0x7092e86e, 0xbefe22d3, 0x3b27b40e, 0x6321c773, 0xe6f851ae, 0x28949b13, 0xad4d0dce, 0x98987de9, 0x1d41eb34, 0xd32d2189, 0x56f4b754, 0x0ef2c429, 0x8b2b52f4, 0x45479849, 0xc09e0e94, 0x2fed7907, 0xaa34efda, 0x64582567, 0xe181b3ba, 0xb987c0c7, 0x3c5e561a, 0xf2329ca7, 0x77eb0a7a, 0x423e7a5d, 0xc7e7ec80, 0x098b263d, 0x8c52b0e0, 0xd454c39d, 0x518d5540, 0x9fe19ffd, 0x1a380920, 0xab918dbd, 0x2e481b60, 0xe024d1dd, 0x65fd4700, 0x3dfb347d, 0xb822a2a0, 0x764e681d, 0xf397fec0, 0xc6428ee7, 0x439b183a, 0x8df7d287, 0x082e445a, 0x50283727, 0xd5f1a1fa, 0x1b9d6b47, 0x9e44fd9a, 0x71378a09, 0xf4ee1cd4, 0x3a82d669, 0xbf5b40b4, 0xe75d33c9, 0x6284a514, 0xace86fa9, 0x2931f974, 0x1ce48953, 0x993d1f8e, 0x5751d533, 0xd28843ee, 0x8a8e3093, 0x0f57a64e, 0xc13b6cf3, 0x44e2fa2e, 0x5edaf30e, 0xdb0365d3, 0x156faf6e, 0x90b639b3, 0xc8b04ace, 0x4d69dc13, 0x830516ae, 0x06dc8073, 0x3309f054, 0xb6d06689, 0x78bcac34, 0xfd653ae9, 0xa5634994, 0x20badf49, 0xeed615f4, 0x6b0f8329, 0x847cf4ba, 0x01a56267, 0xcfc9a8da, 0x4a103e07, 0x12164d7a, 0x97cfdba7, 0x59a3111a, 0xdc7a87c7, 0xe9aff7e0, 0x6c76613d, 0xa21aab80, 0x27c33d5d, 0x7fc54e20, 0xfa1cd8fd, 0x34701240, 0xb1a9849d, 0x17256aa0, 0x92fcfc7d, 0x5c9036c0, 0xd949a01d, 0x814fd360, 0x049645bd, 0xcafa8f00, 0x4f2319dd, 0x7af669fa, 0xff2fff27, 0x3143359a, 0xb49aa347, 0xec9cd03a, 0x694546e7, 0xa7298c5a, 0x22f01a87, 0xcd836d14, 0x485afbc9, 0x86363174, 0x03efa7a9, 0x5be9d4d4, 0xde304209, 0x105c88b4, 0x95851e69, 0xa0506e4e, 0x2589f893, 0xebe5322e, 0x6e3ca4f3, 0x363ad78e, 0xb3e34153, 0x7d8f8bee, 0xf8561d33, 0xe26e1413, 0x67b782ce, 0xa9db4873, 0x2c02deae, 0x7404add3, 0xf1dd3b0e, 0x3fb1f1b3, 0xba68676e, 0x8fbd1749, 0x0a648194, 0xc4084b29, 0x41d1ddf4, 0x19d7ae89, 0x9c0e3854, 0x5262f2e9, 0xd7bb6434, 0x38c813a7, 0xbd11857a, 0x737d4fc7, 0xf6a4d91a, 0xaea2aa67, 0x2b7b3cba, 0xe517f607, 0x60ce60da, 0x551b10fd, 0xd0c28620, 0x1eae4c9d, 0x9b77da40, 0xc371a93d, 0x46a83fe0, 0x88c4f55d, 0x0d1d6380, 0xbcb4e71d, 0x396d71c0, 0xf701bb7d, 0x72d82da0, 0x2ade5edd, 0xaf07c800, 0x616b02bd, 0xe4b29460, 0xd167e447, 0x54be729a, 0x9ad2b827, 0x1f0b2efa, 0x470d5d87, 0xc2d4cb5a, 0x0cb801e7, 0x8961973a, 0x6612e0a9, 0xe3cb7674, 0x2da7bcc9, 0xa87e2a14, 0xf0785969, 0x75a1cfb4, 0xbbcd0509, 0x3e1493d4, 0x0bc1e3f3, 0x8e18752e, 0x4074bf93, 0xc5ad294e, 0x9dab5a33, 0x1872ccee, 0xd61e0653, 0x53c7908e, 0x49ff99ae, 0xcc260f73, 0x024ac5ce, 0x87935313, 0xdf95206e, 0x5a4cb6b3, 0x94207c0e, 0x11f9ead3, 0x242c9af4, 0xa1f50c29, 0x6f99c694, 0xea405049, 0xb2462334, 0x379fb5e9, 0xf9f37f54, 0x7c2ae989, 0x93599e1a, 0x168008c7, 0xd8ecc27a, 0x5d3554a7, 0x053327da, 0x80eab107, 0x4e867bba, 0xcb5fed67, 0xfe8a9d40, 0x7b530b9d, 0xb53fc120, 0x30e657fd, 0x68e02480, 0xed39b25d, 0x235578e0, 0xa68cee3d}, {0x00000000, 0x76e10f9d, 0xadc46ee1, 0xdb25617c, 0x1b8fac19, 0x6d6ea384, 0xb64bc2f8, 0xc0aacd65, 0x361e5933, 0x40ff56ae, 0x9bda37d2, 0xed3b384f, 0x2d91f52a, 0x5b70fab7, 0x80559bcb, 0xf6b49456, 0x6c3cb266, 0x1addbdfb, 0xc1f8dc87, 0xb719d31a, 0x77b31e7f, 0x015211e2, 0xda77709e, 0xac967f03, 0x5a22eb55, 0x2cc3e4c8, 0xf7e685b4, 0x81078a29, 0x41ad474c, 0x374c48d1, 0xec6929ad, 0x9a882630, 0xd87864cd, 0xae996b50, 0x75bc0a2c, 0x035d05b1, 0xc3f7c8d4, 0xb516c749, 0x6e33a635, 0x18d2a9a8, 0xee663dfe, 0x98873263, 0x43a2531f, 0x35435c82, 0xf5e991e7, 0x83089e7a, 0x582dff06, 0x2eccf09b, 0xb444d6ab, 0xc2a5d936, 0x1980b84a, 0x6f61b7d7, 0xafcb7ab2, 0xd92a752f, 0x020f1453, 0x74ee1bce, 0x825a8f98, 0xf4bb8005, 0x2f9ee179, 0x597feee4, 0x99d52381, 0xef342c1c, 0x34114d60, 0x42f042fd, 0xf1f7b941, 0x8716b6dc, 0x5c33d7a0, 0x2ad2d83d, 0xea781558, 0x9c991ac5, 0x47bc7bb9, 0x315d7424, 0xc7e9e072, 0xb108efef, 0x6a2d8e93, 0x1ccc810e, 0xdc664c6b, 0xaa8743f6, 0x71a2228a, 0x07432d17, 0x9dcb0b27, 0xeb2a04ba, 0x300f65c6, 0x46ee6a5b, 0x8644a73e, 0xf0a5a8a3, 0x2b80c9df, 0x5d61c642, 0xabd55214, 0xdd345d89, 0x06113cf5, 0x70f03368, 0xb05afe0d, 0xc6bbf190, 0x1d9e90ec, 0x6b7f9f71, 0x298fdd8c, 0x5f6ed211, 0x844bb36d, 0xf2aabcf0, 0x32007195, 0x44e17e08, 0x9fc41f74, 0xe92510e9, 0x1f9184bf, 0x69708b22, 0xb255ea5e, 0xc4b4e5c3, 0x041e28a6, 0x72ff273b, 0xa9da4647, 0xdf3b49da, 0x45b36fea, 0x33526077, 0xe877010b, 0x9e960e96, 0x5e3cc3f3, 0x28ddcc6e, 0xf3f8ad12, 0x8519a28f, 0x73ad36d9, 0x054c3944, 0xde695838, 0xa88857a5, 0x68229ac0, 0x1ec3955d, 0xc5e6f421, 0xb307fbbc, 0xe2ef7383, 0x940e7c1e, 0x4f2b1d62, 0x39ca12ff, 0xf960df9a, 0x8f81d007, 0x54a4b17b, 0x2245bee6, 0xd4f12ab0, 0xa210252d, 0x79354451, 0x0fd44bcc, 0xcf7e86a9, 0xb99f8934, 0x62bae848, 0x145be7d5, 0x8ed3c1e5, 0xf832ce78, 0x2317af04, 0x55f6a099, 0x955c6dfc, 0xe3bd6261, 0x3898031d, 0x4e790c80, 0xb8cd98d6, 0xce2c974b, 0x1509f637, 0x63e8f9aa, 0xa34234cf, 0xd5a33b52, 0x0e865a2e, 0x786755b3, 0x3a97174e, 0x4c7618d3, 0x975379af, 0xe1b27632, 0x2118bb57, 0x57f9b4ca, 0x8cdcd5b6, 0xfa3dda2b, 0x0c894e7d, 0x7a6841e0, 0xa14d209c, 0xd7ac2f01, 0x1706e264, 0x61e7edf9, 0xbac28c85, 0xcc238318, 0x56aba528, 0x204aaab5, 0xfb6fcbc9, 0x8d8ec454, 0x4d240931, 0x3bc506ac, 0xe0e067d0, 0x9601684d, 0x60b5fc1b, 0x1654f386, 0xcd7192fa, 0xbb909d67, 0x7b3a5002, 0x0ddb5f9f, 0xd6fe3ee3, 0xa01f317e, 0x1318cac2, 0x65f9c55f, 0xbedca423, 0xc83dabbe, 0x089766db, 0x7e766946, 0xa553083a, 0xd3b207a7, 0x250693f1, 0x53e79c6c, 0x88c2fd10, 0xfe23f28d, 0x3e893fe8, 0x48683075, 0x934d5109, 0xe5ac5e94, 0x7f2478a4, 0x09c57739, 0xd2e01645, 0xa40119d8, 0x64abd4bd, 0x124adb20, 0xc96fba5c, 0xbf8eb5c1, 0x493a2197, 0x3fdb2e0a, 0xe4fe4f76, 0x921f40eb, 0x52b58d8e, 0x24548213, 0xff71e36f, 0x8990ecf2, 0xcb60ae0f, 0xbd81a192, 0x66a4c0ee, 0x1045cf73, 0xd0ef0216, 0xa60e0d8b, 0x7d2b6cf7, 0x0bca636a, 0xfd7ef73c, 0x8b9ff8a1, 0x50ba99dd, 0x265b9640, 0xe6f15b25, 0x901054b8, 0x4b3535c4, 0x3dd43a59, 0xa75c1c69, 0xd1bd13f4, 0x0a987288, 0x7c797d15, 0xbcd3b070, 0xca32bfed, 0x1117de91, 0x67f6d10c, 0x9142455a, 0xe7a34ac7, 0x3c862bbb, 0x4a672426, 0x8acde943, 0xfc2ce6de, 0x270987a2, 0x51e8883f}, {0x00000000, 0xe8dbfbb9, 0x91b186a8, 0x796a7d11, 0x63657c8a, 0x8bbe8733, 0xf2d4fa22, 0x1a0f019b, 0x87cc89cf, 0x6f177276, 0x167d0f67, 0xfea6f4de, 0xe4a9f545, 0x0c720efc, 0x751873ed, 0x9dc38854, 0x4f9f6244, 0xa74499fd, 0xde2ee4ec, 0x36f51f55, 0x2cfa1ece, 0xc421e577, 0xbd4b9866, 0x559063df, 0xc853eb8b, 0x20881032, 0x59e26d23, 0xb139969a, 0xab369701, 0x43ed6cb8, 0x3a8711a9, 0xd25cea10, 0x9e3ec588, 0x76e53e31, 0x0f8f4320, 0xe754b899, 0xfd5bb902, 0x158042bb, 0x6cea3faa, 0x8431c413, 0x19f24c47, 0xf129b7fe, 0x8843caef, 0x60983156, 0x7a9730cd, 0x924ccb74, 0xeb26b665, 0x03fd4ddc, 0xd1a1a7cc, 0x397a5c75, 0x40102164, 0xa8cbdadd, 0xb2c4db46, 0x5a1f20ff, 0x23755dee, 0xcbaea657, 0x566d2e03, 0xbeb6d5ba, 0xc7dca8ab, 0x2f075312, 0x35085289, 0xddd3a930, 0xa4b9d421, 0x4c622f98, 0x7d7bfbca, 0x95a00073, 0xecca7d62, 0x041186db, 0x1e1e8740, 0xf6c57cf9, 0x8faf01e8, 0x6774fa51, 0xfab77205, 0x126c89bc, 0x6b06f4ad, 0x83dd0f14, 0x99d20e8f, 0x7109f536, 0x08638827, 0xe0b8739e, 0x32e4998e, 0xda3f6237, 0xa3551f26, 0x4b8ee49f, 0x5181e504, 0xb95a1ebd, 0xc03063ac, 0x28eb9815, 0xb5281041, 0x5df3ebf8, 0x249996e9, 0xcc426d50, 0xd64d6ccb, 0x3e969772, 0x47fcea63, 0xaf2711da, 0xe3453e42, 0x0b9ec5fb, 0x72f4b8ea, 0x9a2f4353, 0x802042c8, 0x68fbb971, 0x1191c460, 0xf94a3fd9, 0x6489b78d, 0x8c524c34, 0xf5383125, 0x1de3ca9c, 0x07eccb07, 0xef3730be, 0x965d4daf, 0x7e86b616, 0xacda5c06, 0x4401a7bf, 0x3d6bdaae, 0xd5b02117, 0xcfbf208c, 0x2764db35, 0x5e0ea624, 0xb6d55d9d, 0x2b16d5c9, 0xc3cd2e70, 0xbaa75361, 0x527ca8d8, 0x4873a943, 0xa0a852fa, 0xd9c22feb, 0x3119d452, 0xbbf0874e, 0x532b7cf7, 0x2a4101e6, 0xc29afa5f, 0xd895fbc4, 0x304e007d, 0x49247d6c, 0xa1ff86d5, 0x3c3c0e81, 0xd4e7f538, 0xad8d8829, 0x45567390, 0x5f59720b, 0xb78289b2, 0xcee8f4a3, 0x26330f1a, 0xf46fe50a, 0x1cb41eb3, 0x65de63a2, 0x8d05981b, 0x970a9980, 0x7fd16239, 0x06bb1f28, 0xee60e491, 0x73a36cc5, 0x9b78977c, 0xe212ea6d, 0x0ac911d4, 0x10c6104f, 0xf81debf6, 0x817796e7, 0x69ac6d5e, 0x25ce42c6, 0xcd15b97f, 0xb47fc46e, 0x5ca43fd7, 0x46ab3e4c, 0xae70c5f5, 0xd71ab8e4, 0x3fc1435d, 0xa202cb09, 0x4ad930b0, 0x33b34da1, 0xdb68b618, 0xc167b783, 0x29bc4c3a, 0x50d6312b, 0xb80dca92, 0x6a512082, 0x828adb3b, 0xfbe0a62a, 0x133b5d93, 0x09345c08, 0xe1efa7b1, 0x9885daa0, 0x705e2119, 0xed9da94d, 0x054652f4, 0x7c2c2fe5, 0x94f7d45c, 0x8ef8d5c7, 0x66232e7e, 0x1f49536f, 0xf792a8d6, 0xc68b7c84, 0x2e50873d, 0x573afa2c, 0xbfe10195, 0xa5ee000e, 0x4d35fbb7, 0x345f86a6, 0xdc847d1f, 0x4147f54b, 0xa99c0ef2, 0xd0f673e3, 0x382d885a, 0x222289c1, 0xcaf97278, 0xb3930f69, 0x5b48f4d0, 0x89141ec0, 0x61cfe579, 0x18a59868, 0xf07e63d1, 0xea71624a, 0x02aa99f3, 0x7bc0e4e2, 0x931b1f5b, 0x0ed8970f, 0xe6036cb6, 0x9f6911a7, 0x77b2ea1e, 0x6dbdeb85, 0x8566103c, 0xfc0c6d2d, 0x14d79694, 0x58b5b90c, 0xb06e42b5, 0xc9043fa4, 0x21dfc41d, 0x3bd0c586, 0xd30b3e3f, 0xaa61432e, 0x42bab897, 0xdf7930c3, 0x37a2cb7a, 0x4ec8b66b, 0xa6134dd2, 0xbc1c4c49, 0x54c7b7f0, 0x2dadcae1, 0xc5763158, 0x172adb48, 0xfff120f1, 0x869b5de0, 0x6e40a659, 0x744fa7c2, 0x9c945c7b, 0xe5fe216a, 0x0d25dad3, 0x90e65287, 0x783da93e, 0x0157d42f, 0xe98c2f96, 0xf3832e0d, 0x1b58d5b4, 0x6232a8a5, 0x8ae9531c}, {0x00000000, 0x919168ae, 0x6325a087, 0xf2b4c829, 0x874c31d4, 0x16dd597a, 0xe4699153, 0x75f8f9fd, 0x4f9f1373, 0xde0e7bdd, 0x2cbab3f4, 0xbd2bdb5a, 0xc8d322a7, 0x59424a09, 0xabf68220, 0x3a67ea8e, 0x9e3e27e6, 0x0faf4f48, 0xfd1b8761, 0x6c8aefcf, 0x19721632, 0x88e37e9c, 0x7a57b6b5, 0xebc6de1b, 0xd1a13495, 0x40305c3b, 0xb2849412, 0x2315fcbc, 0x56ed0541, 0xc77c6def, 0x35c8a5c6, 0xa459cd68, 0x7d7b3f17, 0xecea57b9, 0x1e5e9f90, 0x8fcff73e, 0xfa370ec3, 0x6ba6666d, 0x9912ae44, 0x0883c6ea, 0x32e42c64, 0xa37544ca, 0x51c18ce3, 0xc050e44d, 0xb5a81db0, 0x2439751e, 0xd68dbd37, 0x471cd599, 0xe34518f1, 0x72d4705f, 0x8060b876, 0x11f1d0d8, 0x64092925, 0xf598418b, 0x072c89a2, 0x96bde10c, 0xacda0b82, 0x3d4b632c, 0xcfffab05, 0x5e6ec3ab, 0x2b963a56, 0xba0752f8, 0x48b39ad1, 0xd922f27f, 0xfaf67e2e, 0x6b671680, 0x99d3dea9, 0x0842b607, 0x7dba4ffa, 0xec2b2754, 0x1e9fef7d, 0x8f0e87d3, 0xb5696d5d, 0x24f805f3, 0xd64ccdda, 0x47dda574, 0x32255c89, 0xa3b43427, 0x5100fc0e, 0xc09194a0, 0x64c859c8, 0xf5593166, 0x07edf94f, 0x967c91e1, 0xe384681c, 0x721500b2, 0x80a1c89b, 0x1130a035, 0x2b574abb, 0xbac62215, 0x4872ea3c, 0xd9e38292, 0xac1b7b6f, 0x3d8a13c1, 0xcf3edbe8, 0x5eafb346, 0x878d4139, 0x161c2997, 0xe4a8e1be, 0x75398910, 0x00c170ed, 0x91501843, 0x63e4d06a, 0xf275b8c4, 0xc812524a, 0x59833ae4, 0xab37f2cd, 0x3aa69a63, 0x4f5e639e, 0xdecf0b30, 0x2c7bc319, 0xbdeaabb7, 0x19b366df, 0x88220e71, 0x7a96c658, 0xeb07aef6, 0x9eff570b, 0x0f6e3fa5, 0xfddaf78c, 0x6c4b9f22, 0x562c75ac, 0xc7bd1d02, 0x3509d52b, 0xa498bd85, 0xd1604478, 0x40f12cd6, 0xb245e4ff, 0x23d48c51, 0xf4edfd5c, 0x657c95f2, 0x97c85ddb, 0x06593575, 0x73a1cc88, 0xe230a426, 0x10846c0f, 0x811504a1, 0xbb72ee2f, 0x2ae38681, 0xd8574ea8, 0x49c62606, 0x3c3edffb, 0xadafb755, 0x5f1b7f7c, 0xce8a17d2, 0x6ad3daba, 0xfb42b214, 0x09f67a3d, 0x98671293, 0xed9feb6e, 0x7c0e83c0, 0x8eba4be9, 0x1f2b2347, 0x254cc9c9, 0xb4dda167, 0x4669694e, 0xd7f801e0, 0xa200f81d, 0x339190b3, 0xc125589a, 0x50b43034, 0x8996c24b, 0x1807aae5, 0xeab362cc, 0x7b220a62, 0x0edaf39f, 0x9f4b9b31, 0x6dff5318, 0xfc6e3bb6, 0xc609d138, 0x5798b996, 0xa52c71bf, 0x34bd1911, 0x4145e0ec, 0xd0d48842, 0x2260406b, 0xb3f128c5, 0x17a8e5ad, 0x86398d03, 0x748d452a, 0xe51c2d84, 0x90e4d479, 0x0175bcd7, 0xf3c174fe, 0x62501c50, 0x5837f6de, 0xc9a69e70, 0x3b125659, 0xaa833ef7, 0xdf7bc70a, 0x4eeaafa4, 0xbc5e678d, 0x2dcf0f23, 0x0e1b8372, 0x9f8aebdc, 0x6d3e23f5, 0xfcaf4b5b, 0x8957b2a6, 0x18c6da08, 0xea721221, 0x7be37a8f, 0x41849001, 0xd015f8af, 0x22a13086, 0xb3305828, 0xc6c8a1d5, 0x5759c97b, 0xa5ed0152, 0x347c69fc, 0x9025a494, 0x01b4cc3a, 0xf3000413, 0x62916cbd, 0x17699540, 0x86f8fdee, 0x744c35c7, 0xe5dd5d69, 0xdfbab7e7, 0x4e2bdf49, 0xbc9f1760, 0x2d0e7fce, 0x58f68633, 0xc967ee9d, 0x3bd326b4, 0xaa424e1a, 0x7360bc65, 0xe2f1d4cb, 0x10451ce2, 0x81d4744c, 0xf42c8db1, 0x65bde51f, 0x97092d36, 0x06984598, 0x3cffaf16, 0xad6ec7b8, 0x5fda0f91, 0xce4b673f, 0xbbb39ec2, 0x2a22f66c, 0xd8963e45, 0x490756eb, 0xed5e9b83, 0x7ccff32d, 0x8e7b3b04, 0x1fea53aa, 0x6a12aa57, 0xfb83c2f9, 0x09370ad0, 0x98a6627e, 0xa2c188f0, 0x3350e05e, 0xc1e42877, 0x507540d9, 0x258db924, 0xb41cd18a, 0x46a819a3, 0xd739710d}}; #endif #endif #if N == 5 #if W == 8 local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0xaf449247, 0x85f822cf, 0x2abcb088, 0xd08143df, 0x7fc5d198, 0x55796110, 0xfa3df357, 0x7a7381ff, 0xd53713b8, 0xff8ba330, 0x50cf3177, 0xaaf2c220, 0x05b65067, 0x2f0ae0ef, 0x804e72a8, 0xf4e703fe, 0x5ba391b9, 0x711f2131, 0xde5bb376, 0x24664021, 0x8b22d266, 0xa19e62ee, 0x0edaf0a9, 0x8e948201, 0x21d01046, 0x0b6ca0ce, 0xa4283289, 0x5e15c1de, 0xf1515399, 0xdbede311, 0x74a97156, 0x32bf01bd, 0x9dfb93fa, 0xb7472372, 0x1803b135, 0xe23e4262, 0x4d7ad025, 0x67c660ad, 0xc882f2ea, 0x48cc8042, 0xe7881205, 0xcd34a28d, 0x627030ca, 0x984dc39d, 0x370951da, 0x1db5e152, 0xb2f17315, 0xc6580243, 0x691c9004, 0x43a0208c, 0xece4b2cb, 0x16d9419c, 0xb99dd3db, 0x93216353, 0x3c65f114, 0xbc2b83bc, 0x136f11fb, 0x39d3a173, 0x96973334, 0x6caac063, 0xc3ee5224, 0xe952e2ac, 0x461670eb, 0x657e037a, 0xca3a913d, 0xe08621b5, 0x4fc2b3f2, 0xb5ff40a5, 0x1abbd2e2, 0x3007626a, 0x9f43f02d, 0x1f0d8285, 0xb04910c2, 0x9af5a04a, 0x35b1320d, 0xcf8cc15a, 0x60c8531d, 0x4a74e395, 0xe53071d2, 0x91990084, 0x3edd92c3, 0x1461224b, 0xbb25b00c, 0x4118435b, 0xee5cd11c, 0xc4e06194, 0x6ba4f3d3, 0xebea817b, 0x44ae133c, 0x6e12a3b4, 0xc15631f3, 0x3b6bc2a4, 0x942f50e3, 0xbe93e06b, 0x11d7722c, 0x57c102c7, 0xf8859080, 0xd2392008, 0x7d7db24f, 0x87404118, 0x2804d35f, 0x02b863d7, 0xadfcf190, 0x2db28338, 0x82f6117f, 0xa84aa1f7, 0x070e33b0, 0xfd33c0e7, 0x527752a0, 0x78cbe228, 0xd78f706f, 0xa3260139, 0x0c62937e, 0x26de23f6, 0x899ab1b1, 0x73a742e6, 0xdce3d0a1, 0xf65f6029, 0x591bf26e, 0xd95580c6, 0x76111281, 0x5cada209, 0xf3e9304e, 0x09d4c319, 0xa690515e, 0x8c2ce1d6, 0x23687391, 0xcafc06f4, 0x65b894b3, 0x4f04243b, 0xe040b67c, 0x1a7d452b, 0xb539d76c, 0x9f8567e4, 0x30c1f5a3, 0xb08f870b, 0x1fcb154c, 0x3577a5c4, 0x9a333783, 0x600ec4d4, 0xcf4a5693, 0xe5f6e61b, 0x4ab2745c, 0x3e1b050a, 0x915f974d, 0xbbe327c5, 0x14a7b582, 0xee9a46d5, 0x41ded492, 0x6b62641a, 0xc426f65d, 0x446884f5, 0xeb2c16b2, 0xc190a63a, 0x6ed4347d, 0x94e9c72a, 0x3bad556d, 0x1111e5e5, 0xbe5577a2, 0xf8430749, 0x5707950e, 0x7dbb2586, 0xd2ffb7c1, 0x28c24496, 0x8786d6d1, 0xad3a6659, 0x027ef41e, 0x823086b6, 0x2d7414f1, 0x07c8a479, 0xa88c363e, 0x52b1c569, 0xfdf5572e, 0xd749e7a6, 0x780d75e1, 0x0ca404b7, 0xa3e096f0, 0x895c2678, 0x2618b43f, 0xdc254768, 0x7361d52f, 0x59dd65a7, 0xf699f7e0, 0x76d78548, 0xd993170f, 0xf32fa787, 0x5c6b35c0, 0xa656c697, 0x091254d0, 0x23aee458, 0x8cea761f, 0xaf82058e, 0x00c697c9, 0x2a7a2741, 0x853eb506, 0x7f034651, 0xd047d416, 0xfafb649e, 0x55bff6d9, 0xd5f18471, 0x7ab51636, 0x5009a6be, 0xff4d34f9, 0x0570c7ae, 0xaa3455e9, 0x8088e561, 0x2fcc7726, 0x5b650670, 0xf4219437, 0xde9d24bf, 0x71d9b6f8, 0x8be445af, 0x24a0d7e8, 0x0e1c6760, 0xa158f527, 0x2116878f, 0x8e5215c8, 0xa4eea540, 0x0baa3707, 0xf197c450, 0x5ed35617, 0x746fe69f, 0xdb2b74d8, 0x9d3d0433, 0x32799674, 0x18c526fc, 0xb781b4bb, 0x4dbc47ec, 0xe2f8d5ab, 0xc8446523, 0x6700f764, 0xe74e85cc, 0x480a178b, 0x62b6a703, 0xcdf23544, 0x37cfc613, 0x988b5454, 0xb237e4dc, 0x1d73769b, 0x69da07cd, 0xc69e958a, 0xec222502, 0x4366b745, 0xb95b4412, 0x161fd655, 0x3ca366dd, 0x93e7f49a, 0x13a98632, 0xbced1475, 0x9651a4fd, 0x391536ba, 0xc328c5ed, 0x6c6c57aa, 0x46d0e722, 0xe9947565}, {0x00000000, 0x4e890ba9, 0x9d121752, 0xd39b1cfb, 0xe15528e5, 0xafdc234c, 0x7c473fb7, 0x32ce341e, 0x19db578b, 0x57525c22, 0x84c940d9, 0xca404b70, 0xf88e7f6e, 0xb60774c7, 0x659c683c, 0x2b156395, 0x33b6af16, 0x7d3fa4bf, 0xaea4b844, 0xe02db3ed, 0xd2e387f3, 0x9c6a8c5a, 0x4ff190a1, 0x01789b08, 0x2a6df89d, 0x64e4f334, 0xb77fefcf, 0xf9f6e466, 0xcb38d078, 0x85b1dbd1, 0x562ac72a, 0x18a3cc83, 0x676d5e2c, 0x29e45585, 0xfa7f497e, 0xb4f642d7, 0x863876c9, 0xc8b17d60, 0x1b2a619b, 0x55a36a32, 0x7eb609a7, 0x303f020e, 0xe3a41ef5, 0xad2d155c, 0x9fe32142, 0xd16a2aeb, 0x02f13610, 0x4c783db9, 0x54dbf13a, 0x1a52fa93, 0xc9c9e668, 0x8740edc1, 0xb58ed9df, 0xfb07d276, 0x289cce8d, 0x6615c524, 0x4d00a6b1, 0x0389ad18, 0xd012b1e3, 0x9e9bba4a, 0xac558e54, 0xe2dc85fd, 0x31479906, 0x7fce92af, 0xcedabc58, 0x8053b7f1, 0x53c8ab0a, 0x1d41a0a3, 0x2f8f94bd, 0x61069f14, 0xb29d83ef, 0xfc148846, 0xd701ebd3, 0x9988e07a, 0x4a13fc81, 0x049af728, 0x3654c336, 0x78ddc89f, 0xab46d464, 0xe5cfdfcd, 0xfd6c134e, 0xb3e518e7, 0x607e041c, 0x2ef70fb5, 0x1c393bab, 0x52b03002, 0x812b2cf9, 0xcfa22750, 0xe4b744c5, 0xaa3e4f6c, 0x79a55397, 0x372c583e, 0x05e26c20, 0x4b6b6789, 0x98f07b72, 0xd67970db, 0xa9b7e274, 0xe73ee9dd, 0x34a5f526, 0x7a2cfe8f, 0x48e2ca91, 0x066bc138, 0xd5f0ddc3, 0x9b79d66a, 0xb06cb5ff, 0xfee5be56, 0x2d7ea2ad, 0x63f7a904, 0x51399d1a, 0x1fb096b3, 0xcc2b8a48, 0x82a281e1, 0x9a014d62, 0xd48846cb, 0x07135a30, 0x499a5199, 0x7b546587, 0x35dd6e2e, 0xe64672d5, 0xa8cf797c, 0x83da1ae9, 0xcd531140, 0x1ec80dbb, 0x50410612, 0x628f320c, 0x2c0639a5, 0xff9d255e, 0xb1142ef7, 0x46c47ef1, 0x084d7558, 0xdbd669a3, 0x955f620a, 0xa7915614, 0xe9185dbd, 0x3a834146, 0x740a4aef, 0x5f1f297a, 0x119622d3, 0xc20d3e28, 0x8c843581, 0xbe4a019f, 0xf0c30a36, 0x235816cd, 0x6dd11d64, 0x7572d1e7, 0x3bfbda4e, 0xe860c6b5, 0xa6e9cd1c, 0x9427f902, 0xdaaef2ab, 0x0935ee50, 0x47bce5f9, 0x6ca9866c, 0x22208dc5, 0xf1bb913e, 0xbf329a97, 0x8dfcae89, 0xc375a520, 0x10eeb9db, 0x5e67b272, 0x21a920dd, 0x6f202b74, 0xbcbb378f, 0xf2323c26, 0xc0fc0838, 0x8e750391, 0x5dee1f6a, 0x136714c3, 0x38727756, 0x76fb7cff, 0xa5606004, 0xebe96bad, 0xd9275fb3, 0x97ae541a, 0x443548e1, 0x0abc4348, 0x121f8fcb, 0x5c968462, 0x8f0d9899, 0xc1849330, 0xf34aa72e, 0xbdc3ac87, 0x6e58b07c, 0x20d1bbd5, 0x0bc4d840, 0x454dd3e9, 0x96d6cf12, 0xd85fc4bb, 0xea91f0a5, 0xa418fb0c, 0x7783e7f7, 0x390aec5e, 0x881ec2a9, 0xc697c900, 0x150cd5fb, 0x5b85de52, 0x694bea4c, 0x27c2e1e5, 0xf459fd1e, 0xbad0f6b7, 0x91c59522, 0xdf4c9e8b, 0x0cd78270, 0x425e89d9, 0x7090bdc7, 0x3e19b66e, 0xed82aa95, 0xa30ba13c, 0xbba86dbf, 0xf5216616, 0x26ba7aed, 0x68337144, 0x5afd455a, 0x14744ef3, 0xc7ef5208, 0x896659a1, 0xa2733a34, 0xecfa319d, 0x3f612d66, 0x71e826cf, 0x432612d1, 0x0daf1978, 0xde340583, 0x90bd0e2a, 0xef739c85, 0xa1fa972c, 0x72618bd7, 0x3ce8807e, 0x0e26b460, 0x40afbfc9, 0x9334a332, 0xddbda89b, 0xf6a8cb0e, 0xb821c0a7, 0x6bbadc5c, 0x2533d7f5, 0x17fde3eb, 0x5974e842, 0x8aeff4b9, 0xc466ff10, 0xdcc53393, 0x924c383a, 0x41d724c1, 0x0f5e2f68, 0x3d901b76, 0x731910df, 0xa0820c24, 0xee0b078d, 0xc51e6418, 0x8b976fb1, 0x580c734a, 0x168578e3, 0x244b4cfd, 0x6ac24754, 0xb9595baf, 0xf7d05006}, {0x00000000, 0x8d88fde2, 0xc060fd85, 0x4de80067, 0x5bb0fd4b, 0xd63800a9, 0x9bd000ce, 0x1658fd2c, 0xb761fa96, 0x3ae90774, 0x77010713, 0xfa89faf1, 0xecd107dd, 0x6159fa3f, 0x2cb1fa58, 0xa13907ba, 0xb5b2f36d, 0x383a0e8f, 0x75d20ee8, 0xf85af30a, 0xee020e26, 0x638af3c4, 0x2e62f3a3, 0xa3ea0e41, 0x02d309fb, 0x8f5bf419, 0xc2b3f47e, 0x4f3b099c, 0x5963f4b0, 0xd4eb0952, 0x99030935, 0x148bf4d7, 0xb014e09b, 0x3d9c1d79, 0x70741d1e, 0xfdfce0fc, 0xeba41dd0, 0x662ce032, 0x2bc4e055, 0xa64c1db7, 0x07751a0d, 0x8afde7ef, 0xc715e788, 0x4a9d1a6a, 0x5cc5e746, 0xd14d1aa4, 0x9ca51ac3, 0x112de721, 0x05a613f6, 0x882eee14, 0xc5c6ee73, 0x484e1391, 0x5e16eebd, 0xd39e135f, 0x9e761338, 0x13feeeda, 0xb2c7e960, 0x3f4f1482, 0x72a714e5, 0xff2fe907, 0xe977142b, 0x64ffe9c9, 0x2917e9ae, 0xa49f144c, 0xbb58c777, 0x36d03a95, 0x7b383af2, 0xf6b0c710, 0xe0e83a3c, 0x6d60c7de, 0x2088c7b9, 0xad003a5b, 0x0c393de1, 0x81b1c003, 0xcc59c064, 0x41d13d86, 0x5789c0aa, 0xda013d48, 0x97e93d2f, 0x1a61c0cd, 0x0eea341a, 0x8362c9f8, 0xce8ac99f, 0x4302347d, 0x555ac951, 0xd8d234b3, 0x953a34d4, 0x18b2c936, 0xb98bce8c, 0x3403336e, 0x79eb3309, 0xf463ceeb, 0xe23b33c7, 0x6fb3ce25, 0x225bce42, 0xafd333a0, 0x0b4c27ec, 0x86c4da0e, 0xcb2cda69, 0x46a4278b, 0x50fcdaa7, 0xdd742745, 0x909c2722, 0x1d14dac0, 0xbc2ddd7a, 0x31a52098, 0x7c4d20ff, 0xf1c5dd1d, 0xe79d2031, 0x6a15ddd3, 0x27fdddb4, 0xaa752056, 0xbefed481, 0x33762963, 0x7e9e2904, 0xf316d4e6, 0xe54e29ca, 0x68c6d428, 0x252ed44f, 0xa8a629ad, 0x099f2e17, 0x8417d3f5, 0xc9ffd392, 0x44772e70, 0x522fd35c, 0xdfa72ebe, 0x924f2ed9, 0x1fc7d33b, 0xadc088af, 0x2048754d, 0x6da0752a, 0xe02888c8, 0xf67075e4, 0x7bf88806, 0x36108861, 0xbb987583, 0x1aa17239, 0x97298fdb, 0xdac18fbc, 0x5749725e, 0x41118f72, 0xcc997290, 0x817172f7, 0x0cf98f15, 0x18727bc2, 0x95fa8620, 0xd8128647, 0x559a7ba5, 0x43c28689, 0xce4a7b6b, 0x83a27b0c, 0x0e2a86ee, 0xaf138154, 0x229b7cb6, 0x6f737cd1, 0xe2fb8133, 0xf4a37c1f, 0x792b81fd, 0x34c3819a, 0xb94b7c78, 0x1dd46834, 0x905c95d6, 0xddb495b1, 0x503c6853, 0x4664957f, 0xcbec689d, 0x860468fa, 0x0b8c9518, 0xaab592a2, 0x273d6f40, 0x6ad56f27, 0xe75d92c5, 0xf1056fe9, 0x7c8d920b, 0x3165926c, 0xbced6f8e, 0xa8669b59, 0x25ee66bb, 0x680666dc, 0xe58e9b3e, 0xf3d66612, 0x7e5e9bf0, 0x33b69b97, 0xbe3e6675, 0x1f0761cf, 0x928f9c2d, 0xdf679c4a, 0x52ef61a8, 0x44b79c84, 0xc93f6166, 0x84d76101, 0x095f9ce3, 0x16984fd8, 0x9b10b23a, 0xd6f8b25d, 0x5b704fbf, 0x4d28b293, 0xc0a04f71, 0x8d484f16, 0x00c0b2f4, 0xa1f9b54e, 0x2c7148ac, 0x619948cb, 0xec11b529, 0xfa494805, 0x77c1b5e7, 0x3a29b580, 0xb7a14862, 0xa32abcb5, 0x2ea24157, 0x634a4130, 0xeec2bcd2, 0xf89a41fe, 0x7512bc1c, 0x38fabc7b, 0xb5724199, 0x144b4623, 0x99c3bbc1, 0xd42bbba6, 0x59a34644, 0x4ffbbb68, 0xc273468a, 0x8f9b46ed, 0x0213bb0f, 0xa68caf43, 0x2b0452a1, 0x66ec52c6, 0xeb64af24, 0xfd3c5208, 0x70b4afea, 0x3d5caf8d, 0xb0d4526f, 0x11ed55d5, 0x9c65a837, 0xd18da850, 0x5c0555b2, 0x4a5da89e, 0xc7d5557c, 0x8a3d551b, 0x07b5a8f9, 0x133e5c2e, 0x9eb6a1cc, 0xd35ea1ab, 0x5ed65c49, 0x488ea165, 0xc5065c87, 0x88ee5ce0, 0x0566a102, 0xa45fa6b8, 0x29d75b5a, 0x643f5b3d, 0xe9b7a6df, 0xffef5bf3, 0x7267a611, 0x3f8fa676, 0xb2075b94}, {0x00000000, 0x80f0171f, 0xda91287f, 0x5a613f60, 0x6e5356bf, 0xeea341a0, 0xb4c27ec0, 0x343269df, 0xdca6ad7e, 0x5c56ba61, 0x06378501, 0x86c7921e, 0xb2f5fbc1, 0x3205ecde, 0x6864d3be, 0xe894c4a1, 0x623c5cbd, 0xe2cc4ba2, 0xb8ad74c2, 0x385d63dd, 0x0c6f0a02, 0x8c9f1d1d, 0xd6fe227d, 0x560e3562, 0xbe9af1c3, 0x3e6ae6dc, 0x640bd9bc, 0xe4fbcea3, 0xd0c9a77c, 0x5039b063, 0x0a588f03, 0x8aa8981c, 0xc478b97a, 0x4488ae65, 0x1ee99105, 0x9e19861a, 0xaa2befc5, 0x2adbf8da, 0x70bac7ba, 0xf04ad0a5, 0x18de1404, 0x982e031b, 0xc24f3c7b, 0x42bf2b64, 0x768d42bb, 0xf67d55a4, 0xac1c6ac4, 0x2cec7ddb, 0xa644e5c7, 0x26b4f2d8, 0x7cd5cdb8, 0xfc25daa7, 0xc817b378, 0x48e7a467, 0x12869b07, 0x92768c18, 0x7ae248b9, 0xfa125fa6, 0xa07360c6, 0x208377d9, 0x14b11e06, 0x94410919, 0xce203679, 0x4ed02166, 0x538074b5, 0xd37063aa, 0x89115cca, 0x09e14bd5, 0x3dd3220a, 0xbd233515, 0xe7420a75, 0x67b21d6a, 0x8f26d9cb, 0x0fd6ced4, 0x55b7f1b4, 0xd547e6ab, 0xe1758f74, 0x6185986b, 0x3be4a70b, 0xbb14b014, 0x31bc2808, 0xb14c3f17, 0xeb2d0077, 0x6bdd1768, 0x5fef7eb7, 0xdf1f69a8, 0x857e56c8, 0x058e41d7, 0xed1a8576, 0x6dea9269, 0x378bad09, 0xb77bba16, 0x8349d3c9, 0x03b9c4d6, 0x59d8fbb6, 0xd928eca9, 0x97f8cdcf, 0x1708dad0, 0x4d69e5b0, 0xcd99f2af, 0xf9ab9b70, 0x795b8c6f, 0x233ab30f, 0xa3caa410, 0x4b5e60b1, 0xcbae77ae, 0x91cf48ce, 0x113f5fd1, 0x250d360e, 0xa5fd2111, 0xff9c1e71, 0x7f6c096e, 0xf5c49172, 0x7534866d, 0x2f55b90d, 0xafa5ae12, 0x9b97c7cd, 0x1b67d0d2, 0x4106efb2, 0xc1f6f8ad, 0x29623c0c, 0xa9922b13, 0xf3f31473, 0x7303036c, 0x47316ab3, 0xc7c17dac, 0x9da042cc, 0x1d5055d3, 0xa700e96a, 0x27f0fe75, 0x7d91c115, 0xfd61d60a, 0xc953bfd5, 0x49a3a8ca, 0x13c297aa, 0x933280b5, 0x7ba64414, 0xfb56530b, 0xa1376c6b, 0x21c77b74, 0x15f512ab, 0x950505b4, 0xcf643ad4, 0x4f942dcb, 0xc53cb5d7, 0x45cca2c8, 0x1fad9da8, 0x9f5d8ab7, 0xab6fe368, 0x2b9ff477, 0x71fecb17, 0xf10edc08, 0x199a18a9, 0x996a0fb6, 0xc30b30d6, 0x43fb27c9, 0x77c94e16, 0xf7395909, 0xad586669, 0x2da87176, 0x63785010, 0xe388470f, 0xb9e9786f, 0x39196f70, 0x0d2b06af, 0x8ddb11b0, 0xd7ba2ed0, 0x574a39cf, 0xbfdefd6e, 0x3f2eea71, 0x654fd511, 0xe5bfc20e, 0xd18dabd1, 0x517dbcce, 0x0b1c83ae, 0x8bec94b1, 0x01440cad, 0x81b41bb2, 0xdbd524d2, 0x5b2533cd, 0x6f175a12, 0xefe74d0d, 0xb586726d, 0x35766572, 0xdde2a1d3, 0x5d12b6cc, 0x077389ac, 0x87839eb3, 0xb3b1f76c, 0x3341e073, 0x6920df13, 0xe9d0c80c, 0xf4809ddf, 0x74708ac0, 0x2e11b5a0, 0xaee1a2bf, 0x9ad3cb60, 0x1a23dc7f, 0x4042e31f, 0xc0b2f400, 0x282630a1, 0xa8d627be, 0xf2b718de, 0x72470fc1, 0x4675661e, 0xc6857101, 0x9ce44e61, 0x1c14597e, 0x96bcc162, 0x164cd67d, 0x4c2de91d, 0xccddfe02, 0xf8ef97dd, 0x781f80c2, 0x227ebfa2, 0xa28ea8bd, 0x4a1a6c1c, 0xcaea7b03, 0x908b4463, 0x107b537c, 0x24493aa3, 0xa4b92dbc, 0xfed812dc, 0x7e2805c3, 0x30f824a5, 0xb00833ba, 0xea690cda, 0x6a991bc5, 0x5eab721a, 0xde5b6505, 0x843a5a65, 0x04ca4d7a, 0xec5e89db, 0x6cae9ec4, 0x36cfa1a4, 0xb63fb6bb, 0x820ddf64, 0x02fdc87b, 0x589cf71b, 0xd86ce004, 0x52c47818, 0xd2346f07, 0x88555067, 0x08a54778, 0x3c972ea7, 0xbc6739b8, 0xe60606d8, 0x66f611c7, 0x8e62d566, 0x0e92c279, 0x54f3fd19, 0xd403ea06, 0xe03183d9, 0x60c194c6, 0x3aa0aba6, 0xba50bcb9}, {0x00000000, 0x9570d495, 0xf190af6b, 0x64e07bfe, 0x38505897, 0xad208c02, 0xc9c0f7fc, 0x5cb02369, 0x70a0b12e, 0xe5d065bb, 0x81301e45, 0x1440cad0, 0x48f0e9b9, 0xdd803d2c, 0xb96046d2, 0x2c109247, 0xe141625c, 0x7431b6c9, 0x10d1cd37, 0x85a119a2, 0xd9113acb, 0x4c61ee5e, 0x288195a0, 0xbdf14135, 0x91e1d372, 0x049107e7, 0x60717c19, 0xf501a88c, 0xa9b18be5, 0x3cc15f70, 0x5821248e, 0xcd51f01b, 0x19f3c2f9, 0x8c83166c, 0xe8636d92, 0x7d13b907, 0x21a39a6e, 0xb4d34efb, 0xd0333505, 0x4543e190, 0x695373d7, 0xfc23a742, 0x98c3dcbc, 0x0db30829, 0x51032b40, 0xc473ffd5, 0xa093842b, 0x35e350be, 0xf8b2a0a5, 0x6dc27430, 0x09220fce, 0x9c52db5b, 0xc0e2f832, 0x55922ca7, 0x31725759, 0xa40283cc, 0x8812118b, 0x1d62c51e, 0x7982bee0, 0xecf26a75, 0xb042491c, 0x25329d89, 0x41d2e677, 0xd4a232e2, 0x33e785f2, 0xa6975167, 0xc2772a99, 0x5707fe0c, 0x0bb7dd65, 0x9ec709f0, 0xfa27720e, 0x6f57a69b, 0x434734dc, 0xd637e049, 0xb2d79bb7, 0x27a74f22, 0x7b176c4b, 0xee67b8de, 0x8a87c320, 0x1ff717b5, 0xd2a6e7ae, 0x47d6333b, 0x233648c5, 0xb6469c50, 0xeaf6bf39, 0x7f866bac, 0x1b661052, 0x8e16c4c7, 0xa2065680, 0x37768215, 0x5396f9eb, 0xc6e62d7e, 0x9a560e17, 0x0f26da82, 0x6bc6a17c, 0xfeb675e9, 0x2a14470b, 0xbf64939e, 0xdb84e860, 0x4ef43cf5, 0x12441f9c, 0x8734cb09, 0xe3d4b0f7, 0x76a46462, 0x5ab4f625, 0xcfc422b0, 0xab24594e, 0x3e548ddb, 0x62e4aeb2, 0xf7947a27, 0x937401d9, 0x0604d54c, 0xcb552557, 0x5e25f1c2, 0x3ac58a3c, 0xafb55ea9, 0xf3057dc0, 0x6675a955, 0x0295d2ab, 0x97e5063e, 0xbbf59479, 0x2e8540ec, 0x4a653b12, 0xdf15ef87, 0x83a5ccee, 0x16d5187b, 0x72356385, 0xe745b710, 0x67cf0be4, 0xf2bfdf71, 0x965fa48f, 0x032f701a, 0x5f9f5373, 0xcaef87e6, 0xae0ffc18, 0x3b7f288d, 0x176fbaca, 0x821f6e5f, 0xe6ff15a1, 0x738fc134, 0x2f3fe25d, 0xba4f36c8, 0xdeaf4d36, 0x4bdf99a3, 0x868e69b8, 0x13febd2d, 0x771ec6d3, 0xe26e1246, 0xbede312f, 0x2baee5ba, 0x4f4e9e44, 0xda3e4ad1, 0xf62ed896, 0x635e0c03, 0x07be77fd, 0x92cea368, 0xce7e8001, 0x5b0e5494, 0x3fee2f6a, 0xaa9efbff, 0x7e3cc91d, 0xeb4c1d88, 0x8fac6676, 0x1adcb2e3, 0x466c918a, 0xd31c451f, 0xb7fc3ee1, 0x228cea74, 0x0e9c7833, 0x9becaca6, 0xff0cd758, 0x6a7c03cd, 0x36cc20a4, 0xa3bcf431, 0xc75c8fcf, 0x522c5b5a, 0x9f7dab41, 0x0a0d7fd4, 0x6eed042a, 0xfb9dd0bf, 0xa72df3d6, 0x325d2743, 0x56bd5cbd, 0xc3cd8828, 0xefdd1a6f, 0x7aadcefa, 0x1e4db504, 0x8b3d6191, 0xd78d42f8, 0x42fd966d, 0x261ded93, 0xb36d3906, 0x54288e16, 0xc1585a83, 0xa5b8217d, 0x30c8f5e8, 0x6c78d681, 0xf9080214, 0x9de879ea, 0x0898ad7f, 0x24883f38, 0xb1f8ebad, 0xd5189053, 0x406844c6, 0x1cd867af, 0x89a8b33a, 0xed48c8c4, 0x78381c51, 0xb569ec4a, 0x201938df, 0x44f94321, 0xd18997b4, 0x8d39b4dd, 0x18496048, 0x7ca91bb6, 0xe9d9cf23, 0xc5c95d64, 0x50b989f1, 0x3459f20f, 0xa129269a, 0xfd9905f3, 0x68e9d166, 0x0c09aa98, 0x99797e0d, 0x4ddb4cef, 0xd8ab987a, 0xbc4be384, 0x293b3711, 0x758b1478, 0xe0fbc0ed, 0x841bbb13, 0x116b6f86, 0x3d7bfdc1, 0xa80b2954, 0xcceb52aa, 0x599b863f, 0x052ba556, 0x905b71c3, 0xf4bb0a3d, 0x61cbdea8, 0xac9a2eb3, 0x39eafa26, 0x5d0a81d8, 0xc87a554d, 0x94ca7624, 0x01baa2b1, 0x655ad94f, 0xf02a0dda, 0xdc3a9f9d, 0x494a4b08, 0x2daa30f6, 0xb8dae463, 0xe46ac70a, 0x711a139f, 0x15fa6861, 0x808abcf4}, {0x00000000, 0xcf9e17c8, 0x444d29d1, 0x8bd33e19, 0x889a53a2, 0x4704446a, 0xccd77a73, 0x03496dbb, 0xca45a105, 0x05dbb6cd, 0x8e0888d4, 0x41969f1c, 0x42dff2a7, 0x8d41e56f, 0x0692db76, 0xc90cccbe, 0x4ffa444b, 0x80645383, 0x0bb76d9a, 0xc4297a52, 0xc76017e9, 0x08fe0021, 0x832d3e38, 0x4cb329f0, 0x85bfe54e, 0x4a21f286, 0xc1f2cc9f, 0x0e6cdb57, 0x0d25b6ec, 0xc2bba124, 0x49689f3d, 0x86f688f5, 0x9ff48896, 0x506a9f5e, 0xdbb9a147, 0x1427b68f, 0x176edb34, 0xd8f0ccfc, 0x5323f2e5, 0x9cbde52d, 0x55b12993, 0x9a2f3e5b, 0x11fc0042, 0xde62178a, 0xdd2b7a31, 0x12b56df9, 0x996653e0, 0x56f84428, 0xd00eccdd, 0x1f90db15, 0x9443e50c, 0x5bddf2c4, 0x58949f7f, 0x970a88b7, 0x1cd9b6ae, 0xd347a166, 0x1a4b6dd8, 0xd5d57a10, 0x5e064409, 0x919853c1, 0x92d13e7a, 0x5d4f29b2, 0xd69c17ab, 0x19020063, 0xe498176d, 0x2b0600a5, 0xa0d53ebc, 0x6f4b2974, 0x6c0244cf, 0xa39c5307, 0x284f6d1e, 0xe7d17ad6, 0x2eddb668, 0xe143a1a0, 0x6a909fb9, 0xa50e8871, 0xa647e5ca, 0x69d9f202, 0xe20acc1b, 0x2d94dbd3, 0xab625326, 0x64fc44ee, 0xef2f7af7, 0x20b16d3f, 0x23f80084, 0xec66174c, 0x67b52955, 0xa82b3e9d, 0x6127f223, 0xaeb9e5eb, 0x256adbf2, 0xeaf4cc3a, 0xe9bda181, 0x2623b649, 0xadf08850, 0x626e9f98, 0x7b6c9ffb, 0xb4f28833, 0x3f21b62a, 0xf0bfa1e2, 0xf3f6cc59, 0x3c68db91, 0xb7bbe588, 0x7825f240, 0xb1293efe, 0x7eb72936, 0xf564172f, 0x3afa00e7, 0x39b36d5c, 0xf62d7a94, 0x7dfe448d, 0xb2605345, 0x3496dbb0, 0xfb08cc78, 0x70dbf261, 0xbf45e5a9, 0xbc0c8812, 0x73929fda, 0xf841a1c3, 0x37dfb60b, 0xfed37ab5, 0x314d6d7d, 0xba9e5364, 0x750044ac, 0x76492917, 0xb9d73edf, 0x320400c6, 0xfd9a170e, 0x1241289b, 0xdddf3f53, 0x560c014a, 0x99921682, 0x9adb7b39, 0x55456cf1, 0xde9652e8, 0x11084520, 0xd804899e, 0x179a9e56, 0x9c49a04f, 0x53d7b787, 0x509eda3c, 0x9f00cdf4, 0x14d3f3ed, 0xdb4de425, 0x5dbb6cd0, 0x92257b18, 0x19f64501, 0xd66852c9, 0xd5213f72, 0x1abf28ba, 0x916c16a3, 0x5ef2016b, 0x97fecdd5, 0x5860da1d, 0xd3b3e404, 0x1c2df3cc, 0x1f649e77, 0xd0fa89bf, 0x5b29b7a6, 0x94b7a06e, 0x8db5a00d, 0x422bb7c5, 0xc9f889dc, 0x06669e14, 0x052ff3af, 0xcab1e467, 0x4162da7e, 0x8efccdb6, 0x47f00108, 0x886e16c0, 0x03bd28d9, 0xcc233f11, 0xcf6a52aa, 0x00f44562, 0x8b277b7b, 0x44b96cb3, 0xc24fe446, 0x0dd1f38e, 0x8602cd97, 0x499cda5f, 0x4ad5b7e4, 0x854ba02c, 0x0e989e35, 0xc10689fd, 0x080a4543, 0xc794528b, 0x4c476c92, 0x83d97b5a, 0x809016e1, 0x4f0e0129, 0xc4dd3f30, 0x0b4328f8, 0xf6d93ff6, 0x3947283e, 0xb2941627, 0x7d0a01ef, 0x7e436c54, 0xb1dd7b9c, 0x3a0e4585, 0xf590524d, 0x3c9c9ef3, 0xf302893b, 0x78d1b722, 0xb74fa0ea, 0xb406cd51, 0x7b98da99, 0xf04be480, 0x3fd5f348, 0xb9237bbd, 0x76bd6c75, 0xfd6e526c, 0x32f045a4, 0x31b9281f, 0xfe273fd7, 0x75f401ce, 0xba6a1606, 0x7366dab8, 0xbcf8cd70, 0x372bf369, 0xf8b5e4a1, 0xfbfc891a, 0x34629ed2, 0xbfb1a0cb, 0x702fb703, 0x692db760, 0xa6b3a0a8, 0x2d609eb1, 0xe2fe8979, 0xe1b7e4c2, 0x2e29f30a, 0xa5facd13, 0x6a64dadb, 0xa3681665, 0x6cf601ad, 0xe7253fb4, 0x28bb287c, 0x2bf245c7, 0xe46c520f, 0x6fbf6c16, 0xa0217bde, 0x26d7f32b, 0xe949e4e3, 0x629adafa, 0xad04cd32, 0xae4da089, 0x61d3b741, 0xea008958, 0x259e9e90, 0xec92522e, 0x230c45e6, 0xa8df7bff, 0x67416c37, 0x6408018c, 0xab961644, 0x2045285d, 0xefdb3f95}, {0x00000000, 0x24825136, 0x4904a26c, 0x6d86f35a, 0x920944d8, 0xb68b15ee, 0xdb0de6b4, 0xff8fb782, 0xff638ff1, 0xdbe1dec7, 0xb6672d9d, 0x92e57cab, 0x6d6acb29, 0x49e89a1f, 0x246e6945, 0x00ec3873, 0x25b619a3, 0x01344895, 0x6cb2bbcf, 0x4830eaf9, 0xb7bf5d7b, 0x933d0c4d, 0xfebbff17, 0xda39ae21, 0xdad59652, 0xfe57c764, 0x93d1343e, 0xb7536508, 0x48dcd28a, 0x6c5e83bc, 0x01d870e6, 0x255a21d0, 0x4b6c3346, 0x6fee6270, 0x0268912a, 0x26eac01c, 0xd965779e, 0xfde726a8, 0x9061d5f2, 0xb4e384c4, 0xb40fbcb7, 0x908ded81, 0xfd0b1edb, 0xd9894fed, 0x2606f86f, 0x0284a959, 0x6f025a03, 0x4b800b35, 0x6eda2ae5, 0x4a587bd3, 0x27de8889, 0x035cd9bf, 0xfcd36e3d, 0xd8513f0b, 0xb5d7cc51, 0x91559d67, 0x91b9a514, 0xb53bf422, 0xd8bd0778, 0xfc3f564e, 0x03b0e1cc, 0x2732b0fa, 0x4ab443a0, 0x6e361296, 0x96d8668c, 0xb25a37ba, 0xdfdcc4e0, 0xfb5e95d6, 0x04d12254, 0x20537362, 0x4dd58038, 0x6957d10e, 0x69bbe97d, 0x4d39b84b, 0x20bf4b11, 0x043d1a27, 0xfbb2ada5, 0xdf30fc93, 0xb2b60fc9, 0x96345eff, 0xb36e7f2f, 0x97ec2e19, 0xfa6add43, 0xdee88c75, 0x21673bf7, 0x05e56ac1, 0x6863999b, 0x4ce1c8ad, 0x4c0df0de, 0x688fa1e8, 0x050952b2, 0x218b0384, 0xde04b406, 0xfa86e530, 0x9700166a, 0xb382475c, 0xddb455ca, 0xf93604fc, 0x94b0f7a6, 0xb032a690, 0x4fbd1112, 0x6b3f4024, 0x06b9b37e, 0x223be248, 0x22d7da3b, 0x06558b0d, 0x6bd37857, 0x4f512961, 0xb0de9ee3, 0x945ccfd5, 0xf9da3c8f, 0xdd586db9, 0xf8024c69, 0xdc801d5f, 0xb106ee05, 0x9584bf33, 0x6a0b08b1, 0x4e895987, 0x230faadd, 0x078dfbeb, 0x0761c398, 0x23e392ae, 0x4e6561f4, 0x6ae730c2, 0x95688740, 0xb1ead676, 0xdc6c252c, 0xf8ee741a, 0xf6c1cb59, 0xd2439a6f, 0xbfc56935, 0x9b473803, 0x64c88f81, 0x404adeb7, 0x2dcc2ded, 0x094e7cdb, 0x09a244a8, 0x2d20159e, 0x40a6e6c4, 0x6424b7f2, 0x9bab0070, 0xbf295146, 0xd2afa21c, 0xf62df32a, 0xd377d2fa, 0xf7f583cc, 0x9a737096, 0xbef121a0, 0x417e9622, 0x65fcc714, 0x087a344e, 0x2cf86578, 0x2c145d0b, 0x08960c3d, 0x6510ff67, 0x4192ae51, 0xbe1d19d3, 0x9a9f48e5, 0xf719bbbf, 0xd39bea89, 0xbdadf81f, 0x992fa929, 0xf4a95a73, 0xd02b0b45, 0x2fa4bcc7, 0x0b26edf1, 0x66a01eab, 0x42224f9d, 0x42ce77ee, 0x664c26d8, 0x0bcad582, 0x2f4884b4, 0xd0c73336, 0xf4456200, 0x99c3915a, 0xbd41c06c, 0x981be1bc, 0xbc99b08a, 0xd11f43d0, 0xf59d12e6, 0x0a12a564, 0x2e90f452, 0x43160708, 0x6794563e, 0x67786e4d, 0x43fa3f7b, 0x2e7ccc21, 0x0afe9d17, 0xf5712a95, 0xd1f37ba3, 0xbc7588f9, 0x98f7d9cf, 0x6019add5, 0x449bfce3, 0x291d0fb9, 0x0d9f5e8f, 0xf210e90d, 0xd692b83b, 0xbb144b61, 0x9f961a57, 0x9f7a2224, 0xbbf87312, 0xd67e8048, 0xf2fcd17e, 0x0d7366fc, 0x29f137ca, 0x4477c490, 0x60f595a6, 0x45afb476, 0x612de540, 0x0cab161a, 0x2829472c, 0xd7a6f0ae, 0xf324a198, 0x9ea252c2, 0xba2003f4, 0xbacc3b87, 0x9e4e6ab1, 0xf3c899eb, 0xd74ac8dd, 0x28c57f5f, 0x0c472e69, 0x61c1dd33, 0x45438c05, 0x2b759e93, 0x0ff7cfa5, 0x62713cff, 0x46f36dc9, 0xb97cda4b, 0x9dfe8b7d, 0xf0787827, 0xd4fa2911, 0xd4161162, 0xf0944054, 0x9d12b30e, 0xb990e238, 0x461f55ba, 0x629d048c, 0x0f1bf7d6, 0x2b99a6e0, 0x0ec38730, 0x2a41d606, 0x47c7255c, 0x6345746a, 0x9ccac3e8, 0xb84892de, 0xd5ce6184, 0xf14c30b2, 0xf1a008c1, 0xd52259f7, 0xb8a4aaad, 0x9c26fb9b, 0x63a94c19, 0x472b1d2f, 0x2aadee75, 0x0e2fbf43}, {0x00000000, 0x36f290f3, 0x6de521e6, 0x5b17b115, 0xdbca43cc, 0xed38d33f, 0xb62f622a, 0x80ddf2d9, 0x6ce581d9, 0x5a17112a, 0x0100a03f, 0x37f230cc, 0xb72fc215, 0x81dd52e6, 0xdacae3f3, 0xec387300, 0xd9cb03b2, 0xef399341, 0xb42e2254, 0x82dcb2a7, 0x0201407e, 0x34f3d08d, 0x6fe46198, 0x5916f16b, 0xb52e826b, 0x83dc1298, 0xd8cba38d, 0xee39337e, 0x6ee4c1a7, 0x58165154, 0x0301e041, 0x35f370b2, 0x68e70125, 0x5e1591d6, 0x050220c3, 0x33f0b030, 0xb32d42e9, 0x85dfd21a, 0xdec8630f, 0xe83af3fc, 0x040280fc, 0x32f0100f, 0x69e7a11a, 0x5f1531e9, 0xdfc8c330, 0xe93a53c3, 0xb22de2d6, 0x84df7225, 0xb12c0297, 0x87de9264, 0xdcc92371, 0xea3bb382, 0x6ae6415b, 0x5c14d1a8, 0x070360bd, 0x31f1f04e, 0xddc9834e, 0xeb3b13bd, 0xb02ca2a8, 0x86de325b, 0x0603c082, 0x30f15071, 0x6be6e164, 0x5d147197, 0xd1ce024a, 0xe73c92b9, 0xbc2b23ac, 0x8ad9b35f, 0x0a044186, 0x3cf6d175, 0x67e16060, 0x5113f093, 0xbd2b8393, 0x8bd91360, 0xd0cea275, 0xe63c3286, 0x66e1c05f, 0x501350ac, 0x0b04e1b9, 0x3df6714a, 0x080501f8, 0x3ef7910b, 0x65e0201e, 0x5312b0ed, 0xd3cf4234, 0xe53dd2c7, 0xbe2a63d2, 0x88d8f321, 0x64e08021, 0x521210d2, 0x0905a1c7, 0x3ff73134, 0xbf2ac3ed, 0x89d8531e, 0xd2cfe20b, 0xe43d72f8, 0xb929036f, 0x8fdb939c, 0xd4cc2289, 0xe23eb27a, 0x62e340a3, 0x5411d050, 0x0f066145, 0x39f4f1b6, 0xd5cc82b6, 0xe33e1245, 0xb829a350, 0x8edb33a3, 0x0e06c17a, 0x38f45189, 0x63e3e09c, 0x5511706f, 0x60e200dd, 0x5610902e, 0x0d07213b, 0x3bf5b1c8, 0xbb284311, 0x8ddad3e2, 0xd6cd62f7, 0xe03ff204, 0x0c078104, 0x3af511f7, 0x61e2a0e2, 0x57103011, 0xd7cdc2c8, 0xe13f523b, 0xba28e32e, 0x8cda73dd, 0x78ed02d5, 0x4e1f9226, 0x15082333, 0x23fab3c0, 0xa3274119, 0x95d5d1ea, 0xcec260ff, 0xf830f00c, 0x1408830c, 0x22fa13ff, 0x79eda2ea, 0x4f1f3219, 0xcfc2c0c0, 0xf9305033, 0xa227e126, 0x94d571d5, 0xa1260167, 0x97d49194, 0xccc32081, 0xfa31b072, 0x7aec42ab, 0x4c1ed258, 0x1709634d, 0x21fbf3be, 0xcdc380be, 0xfb31104d, 0xa026a158, 0x96d431ab, 0x1609c372, 0x20fb5381, 0x7bece294, 0x4d1e7267, 0x100a03f0, 0x26f89303, 0x7def2216, 0x4b1db2e5, 0xcbc0403c, 0xfd32d0cf, 0xa62561da, 0x90d7f129, 0x7cef8229, 0x4a1d12da, 0x110aa3cf, 0x27f8333c, 0xa725c1e5, 0x91d75116, 0xcac0e003, 0xfc3270f0, 0xc9c10042, 0xff3390b1, 0xa42421a4, 0x92d6b157, 0x120b438e, 0x24f9d37d, 0x7fee6268, 0x491cf29b, 0xa524819b, 0x93d61168, 0xc8c1a07d, 0xfe33308e, 0x7eeec257, 0x481c52a4, 0x130be3b1, 0x25f97342, 0xa923009f, 0x9fd1906c, 0xc4c62179, 0xf234b18a, 0x72e94353, 0x441bd3a0, 0x1f0c62b5, 0x29fef246, 0xc5c68146, 0xf33411b5, 0xa823a0a0, 0x9ed13053, 0x1e0cc28a, 0x28fe5279, 0x73e9e36c, 0x451b739f, 0x70e8032d, 0x461a93de, 0x1d0d22cb, 0x2bffb238, 0xab2240e1, 0x9dd0d012, 0xc6c76107, 0xf035f1f4, 0x1c0d82f4, 0x2aff1207, 0x71e8a312, 0x471a33e1, 0xc7c7c138, 0xf13551cb, 0xaa22e0de, 0x9cd0702d, 0xc1c401ba, 0xf7369149, 0xac21205c, 0x9ad3b0af, 0x1a0e4276, 0x2cfcd285, 0x77eb6390, 0x4119f363, 0xad218063, 0x9bd31090, 0xc0c4a185, 0xf6363176, 0x76ebc3af, 0x4019535c, 0x1b0ee249, 0x2dfc72ba, 0x180f0208, 0x2efd92fb, 0x75ea23ee, 0x4318b31d, 0xc3c541c4, 0xf537d137, 0xae206022, 0x98d2f0d1, 0x74ea83d1, 0x42181322, 0x190fa237, 0x2ffd32c4, 0xaf20c01d, 0x99d250ee, 0xc2c5e1fb, 0xf4377108}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x0000000000000000, 0xf390f23600000000, 0xe621e56d00000000, 0x15b1175b00000000, 0xcc43cadb00000000, 0x3fd338ed00000000, 0x2a622fb600000000, 0xd9f2dd8000000000, 0xd981e56c00000000, 0x2a11175a00000000, 0x3fa0000100000000, 0xcc30f23700000000, 0x15c22fb700000000, 0xe652dd8100000000, 0xf3e3cada00000000, 0x007338ec00000000, 0xb203cbd900000000, 0x419339ef00000000, 0x54222eb400000000, 0xa7b2dc8200000000, 0x7e40010200000000, 0x8dd0f33400000000, 0x9861e46f00000000, 0x6bf1165900000000, 0x6b822eb500000000, 0x9812dc8300000000, 0x8da3cbd800000000, 0x7e3339ee00000000, 0xa7c1e46e00000000, 0x5451165800000000, 0x41e0010300000000, 0xb270f33500000000, 0x2501e76800000000, 0xd691155e00000000, 0xc320020500000000, 0x30b0f03300000000, 0xe9422db300000000, 0x1ad2df8500000000, 0x0f63c8de00000000, 0xfcf33ae800000000, 0xfc80020400000000, 0x0f10f03200000000, 0x1aa1e76900000000, 0xe931155f00000000, 0x30c3c8df00000000, 0xc3533ae900000000, 0xd6e22db200000000, 0x2572df8400000000, 0x97022cb100000000, 0x6492de8700000000, 0x7123c9dc00000000, 0x82b33bea00000000, 0x5b41e66a00000000, 0xa8d1145c00000000, 0xbd60030700000000, 0x4ef0f13100000000, 0x4e83c9dd00000000, 0xbd133beb00000000, 0xa8a22cb000000000, 0x5b32de8600000000, 0x82c0030600000000, 0x7150f13000000000, 0x64e1e66b00000000, 0x9771145d00000000, 0x4a02ced100000000, 0xb9923ce700000000, 0xac232bbc00000000, 0x5fb3d98a00000000, 0x8641040a00000000, 0x75d1f63c00000000, 0x6060e16700000000, 0x93f0135100000000, 0x93832bbd00000000, 0x6013d98b00000000, 0x75a2ced000000000, 0x86323ce600000000, 0x5fc0e16600000000, 0xac50135000000000, 0xb9e1040b00000000, 0x4a71f63d00000000, 0xf801050800000000, 0x0b91f73e00000000, 0x1e20e06500000000, 0xedb0125300000000, 0x3442cfd300000000, 0xc7d23de500000000, 0xd2632abe00000000, 0x21f3d88800000000, 0x2180e06400000000, 0xd210125200000000, 0xc7a1050900000000, 0x3431f73f00000000, 0xedc32abf00000000, 0x1e53d88900000000, 0x0be2cfd200000000, 0xf8723de400000000, 0x6f0329b900000000, 0x9c93db8f00000000, 0x8922ccd400000000, 0x7ab23ee200000000, 0xa340e36200000000, 0x50d0115400000000, 0x4561060f00000000, 0xb6f1f43900000000, 0xb682ccd500000000, 0x45123ee300000000, 0x50a329b800000000, 0xa333db8e00000000, 0x7ac1060e00000000, 0x8951f43800000000, 0x9ce0e36300000000, 0x6f70115500000000, 0xdd00e26000000000, 0x2e90105600000000, 0x3b21070d00000000, 0xc8b1f53b00000000, 0x114328bb00000000, 0xe2d3da8d00000000, 0xf762cdd600000000, 0x04f23fe000000000, 0x0481070c00000000, 0xf711f53a00000000, 0xe2a0e26100000000, 0x1130105700000000, 0xc8c2cdd700000000, 0x3b523fe100000000, 0x2ee328ba00000000, 0xdd73da8c00000000, 0xd502ed7800000000, 0x26921f4e00000000, 0x3323081500000000, 0xc0b3fa2300000000, 0x194127a300000000, 0xead1d59500000000, 0xff60c2ce00000000, 0x0cf030f800000000, 0x0c83081400000000, 0xff13fa2200000000, 0xeaa2ed7900000000, 0x19321f4f00000000, 0xc0c0c2cf00000000, 0x335030f900000000, 0x26e127a200000000, 0xd571d59400000000, 0x670126a100000000, 0x9491d49700000000, 0x8120c3cc00000000, 0x72b031fa00000000, 0xab42ec7a00000000, 0x58d21e4c00000000, 0x4d63091700000000, 0xbef3fb2100000000, 0xbe80c3cd00000000, 0x4d1031fb00000000, 0x58a126a000000000, 0xab31d49600000000, 0x72c3091600000000, 0x8153fb2000000000, 0x94e2ec7b00000000, 0x67721e4d00000000, 0xf0030a1000000000, 0x0393f82600000000, 0x1622ef7d00000000, 0xe5b21d4b00000000, 0x3c40c0cb00000000, 0xcfd032fd00000000, 0xda6125a600000000, 0x29f1d79000000000, 0x2982ef7c00000000, 0xda121d4a00000000, 0xcfa30a1100000000, 0x3c33f82700000000, 0xe5c125a700000000, 0x1651d79100000000, 0x03e0c0ca00000000, 0xf07032fc00000000, 0x4200c1c900000000, 0xb19033ff00000000, 0xa42124a400000000, 0x57b1d69200000000, 0x8e430b1200000000, 0x7dd3f92400000000, 0x6862ee7f00000000, 0x9bf21c4900000000, 0x9b8124a500000000, 0x6811d69300000000, 0x7da0c1c800000000, 0x8e3033fe00000000, 0x57c2ee7e00000000, 0xa4521c4800000000, 0xb1e30b1300000000, 0x4273f92500000000, 0x9f0023a900000000, 0x6c90d19f00000000, 0x7921c6c400000000, 0x8ab134f200000000, 0x5343e97200000000, 0xa0d31b4400000000, 0xb5620c1f00000000, 0x46f2fe2900000000, 0x4681c6c500000000, 0xb51134f300000000, 0xa0a023a800000000, 0x5330d19e00000000, 0x8ac20c1e00000000, 0x7952fe2800000000, 0x6ce3e97300000000, 0x9f731b4500000000, 0x2d03e87000000000, 0xde931a4600000000, 0xcb220d1d00000000, 0x38b2ff2b00000000, 0xe14022ab00000000, 0x12d0d09d00000000, 0x0761c7c600000000, 0xf4f135f000000000, 0xf4820d1c00000000, 0x0712ff2a00000000, 0x12a3e87100000000, 0xe1331a4700000000, 0x38c1c7c700000000, 0xcb5135f100000000, 0xdee022aa00000000, 0x2d70d09c00000000, 0xba01c4c100000000, 0x499136f700000000, 0x5c2021ac00000000, 0xafb0d39a00000000, 0x76420e1a00000000, 0x85d2fc2c00000000, 0x9063eb7700000000, 0x63f3194100000000, 0x638021ad00000000, 0x9010d39b00000000, 0x85a1c4c000000000, 0x763136f600000000, 0xafc3eb7600000000, 0x5c53194000000000, 0x49e20e1b00000000, 0xba72fc2d00000000, 0x08020f1800000000, 0xfb92fd2e00000000, 0xee23ea7500000000, 0x1db3184300000000, 0xc441c5c300000000, 0x37d137f500000000, 0x226020ae00000000, 0xd1f0d29800000000, 0xd183ea7400000000, 0x2213184200000000, 0x37a20f1900000000, 0xc432fd2f00000000, 0x1dc020af00000000, 0xee50d29900000000, 0xfbe1c5c200000000, 0x087137f400000000}, {0x0000000000000000, 0x3651822400000000, 0x6ca2044900000000, 0x5af3866d00000000, 0xd844099200000000, 0xee158bb600000000, 0xb4e60ddb00000000, 0x82b78fff00000000, 0xf18f63ff00000000, 0xc7dee1db00000000, 0x9d2d67b600000000, 0xab7ce59200000000, 0x29cb6a6d00000000, 0x1f9ae84900000000, 0x45696e2400000000, 0x7338ec0000000000, 0xa319b62500000000, 0x9548340100000000, 0xcfbbb26c00000000, 0xf9ea304800000000, 0x7b5dbfb700000000, 0x4d0c3d9300000000, 0x17ffbbfe00000000, 0x21ae39da00000000, 0x5296d5da00000000, 0x64c757fe00000000, 0x3e34d19300000000, 0x086553b700000000, 0x8ad2dc4800000000, 0xbc835e6c00000000, 0xe670d80100000000, 0xd0215a2500000000, 0x46336c4b00000000, 0x7062ee6f00000000, 0x2a91680200000000, 0x1cc0ea2600000000, 0x9e7765d900000000, 0xa826e7fd00000000, 0xf2d5619000000000, 0xc484e3b400000000, 0xb7bc0fb400000000, 0x81ed8d9000000000, 0xdb1e0bfd00000000, 0xed4f89d900000000, 0x6ff8062600000000, 0x59a9840200000000, 0x035a026f00000000, 0x350b804b00000000, 0xe52ada6e00000000, 0xd37b584a00000000, 0x8988de2700000000, 0xbfd95c0300000000, 0x3d6ed3fc00000000, 0x0b3f51d800000000, 0x51ccd7b500000000, 0x679d559100000000, 0x14a5b99100000000, 0x22f43bb500000000, 0x7807bdd800000000, 0x4e563ffc00000000, 0xcce1b00300000000, 0xfab0322700000000, 0xa043b44a00000000, 0x9612366e00000000, 0x8c66d89600000000, 0xba375ab200000000, 0xe0c4dcdf00000000, 0xd6955efb00000000, 0x5422d10400000000, 0x6273532000000000, 0x3880d54d00000000, 0x0ed1576900000000, 0x7de9bb6900000000, 0x4bb8394d00000000, 0x114bbf2000000000, 0x271a3d0400000000, 0xa5adb2fb00000000, 0x93fc30df00000000, 0xc90fb6b200000000, 0xff5e349600000000, 0x2f7f6eb300000000, 0x192eec9700000000, 0x43dd6afa00000000, 0x758ce8de00000000, 0xf73b672100000000, 0xc16ae50500000000, 0x9b99636800000000, 0xadc8e14c00000000, 0xdef00d4c00000000, 0xe8a18f6800000000, 0xb252090500000000, 0x84038b2100000000, 0x06b404de00000000, 0x30e586fa00000000, 0x6a16009700000000, 0x5c4782b300000000, 0xca55b4dd00000000, 0xfc0436f900000000, 0xa6f7b09400000000, 0x90a632b000000000, 0x1211bd4f00000000, 0x24403f6b00000000, 0x7eb3b90600000000, 0x48e23b2200000000, 0x3bdad72200000000, 0x0d8b550600000000, 0x5778d36b00000000, 0x6129514f00000000, 0xe39edeb000000000, 0xd5cf5c9400000000, 0x8f3cdaf900000000, 0xb96d58dd00000000, 0x694c02f800000000, 0x5f1d80dc00000000, 0x05ee06b100000000, 0x33bf849500000000, 0xb1080b6a00000000, 0x8759894e00000000, 0xddaa0f2300000000, 0xebfb8d0700000000, 0x98c3610700000000, 0xae92e32300000000, 0xf461654e00000000, 0xc230e76a00000000, 0x4087689500000000, 0x76d6eab100000000, 0x2c256cdc00000000, 0x1a74eef800000000, 0x59cbc1f600000000, 0x6f9a43d200000000, 0x3569c5bf00000000, 0x0338479b00000000, 0x818fc86400000000, 0xb7de4a4000000000, 0xed2dcc2d00000000, 0xdb7c4e0900000000, 0xa844a20900000000, 0x9e15202d00000000, 0xc4e6a64000000000, 0xf2b7246400000000, 0x7000ab9b00000000, 0x465129bf00000000, 0x1ca2afd200000000, 0x2af32df600000000, 0xfad277d300000000, 0xcc83f5f700000000, 0x9670739a00000000, 0xa021f1be00000000, 0x22967e4100000000, 0x14c7fc6500000000, 0x4e347a0800000000, 0x7865f82c00000000, 0x0b5d142c00000000, 0x3d0c960800000000, 0x67ff106500000000, 0x51ae924100000000, 0xd3191dbe00000000, 0xe5489f9a00000000, 0xbfbb19f700000000, 0x89ea9bd300000000, 0x1ff8adbd00000000, 0x29a92f9900000000, 0x735aa9f400000000, 0x450b2bd000000000, 0xc7bca42f00000000, 0xf1ed260b00000000, 0xab1ea06600000000, 0x9d4f224200000000, 0xee77ce4200000000, 0xd8264c6600000000, 0x82d5ca0b00000000, 0xb484482f00000000, 0x3633c7d000000000, 0x006245f400000000, 0x5a91c39900000000, 0x6cc041bd00000000, 0xbce11b9800000000, 0x8ab099bc00000000, 0xd0431fd100000000, 0xe6129df500000000, 0x64a5120a00000000, 0x52f4902e00000000, 0x0807164300000000, 0x3e56946700000000, 0x4d6e786700000000, 0x7b3ffa4300000000, 0x21cc7c2e00000000, 0x179dfe0a00000000, 0x952a71f500000000, 0xa37bf3d100000000, 0xf98875bc00000000, 0xcfd9f79800000000, 0xd5ad196000000000, 0xe3fc9b4400000000, 0xb90f1d2900000000, 0x8f5e9f0d00000000, 0x0de910f200000000, 0x3bb892d600000000, 0x614b14bb00000000, 0x571a969f00000000, 0x24227a9f00000000, 0x1273f8bb00000000, 0x48807ed600000000, 0x7ed1fcf200000000, 0xfc66730d00000000, 0xca37f12900000000, 0x90c4774400000000, 0xa695f56000000000, 0x76b4af4500000000, 0x40e52d6100000000, 0x1a16ab0c00000000, 0x2c47292800000000, 0xaef0a6d700000000, 0x98a124f300000000, 0xc252a29e00000000, 0xf40320ba00000000, 0x873bccba00000000, 0xb16a4e9e00000000, 0xeb99c8f300000000, 0xddc84ad700000000, 0x5f7fc52800000000, 0x692e470c00000000, 0x33ddc16100000000, 0x058c434500000000, 0x939e752b00000000, 0xa5cff70f00000000, 0xff3c716200000000, 0xc96df34600000000, 0x4bda7cb900000000, 0x7d8bfe9d00000000, 0x277878f000000000, 0x1129fad400000000, 0x621116d400000000, 0x544094f000000000, 0x0eb3129d00000000, 0x38e290b900000000, 0xba551f4600000000, 0x8c049d6200000000, 0xd6f71b0f00000000, 0xe0a6992b00000000, 0x3087c30e00000000, 0x06d6412a00000000, 0x5c25c74700000000, 0x6a74456300000000, 0xe8c3ca9c00000000, 0xde9248b800000000, 0x8461ced500000000, 0xb2304cf100000000, 0xc108a0f100000000, 0xf75922d500000000, 0xadaaa4b800000000, 0x9bfb269c00000000, 0x194ca96300000000, 0x2f1d2b4700000000, 0x75eead2a00000000, 0x43bf2f0e00000000}, {0x0000000000000000, 0xc8179ecf00000000, 0xd1294d4400000000, 0x193ed38b00000000, 0xa2539a8800000000, 0x6a44044700000000, 0x737ad7cc00000000, 0xbb6d490300000000, 0x05a145ca00000000, 0xcdb6db0500000000, 0xd488088e00000000, 0x1c9f964100000000, 0xa7f2df4200000000, 0x6fe5418d00000000, 0x76db920600000000, 0xbecc0cc900000000, 0x4b44fa4f00000000, 0x8353648000000000, 0x9a6db70b00000000, 0x527a29c400000000, 0xe91760c700000000, 0x2100fe0800000000, 0x383e2d8300000000, 0xf029b34c00000000, 0x4ee5bf8500000000, 0x86f2214a00000000, 0x9fccf2c100000000, 0x57db6c0e00000000, 0xecb6250d00000000, 0x24a1bbc200000000, 0x3d9f684900000000, 0xf588f68600000000, 0x9688f49f00000000, 0x5e9f6a5000000000, 0x47a1b9db00000000, 0x8fb6271400000000, 0x34db6e1700000000, 0xfcccf0d800000000, 0xe5f2235300000000, 0x2de5bd9c00000000, 0x9329b15500000000, 0x5b3e2f9a00000000, 0x4200fc1100000000, 0x8a1762de00000000, 0x317a2bdd00000000, 0xf96db51200000000, 0xe053669900000000, 0x2844f85600000000, 0xddcc0ed000000000, 0x15db901f00000000, 0x0ce5439400000000, 0xc4f2dd5b00000000, 0x7f9f945800000000, 0xb7880a9700000000, 0xaeb6d91c00000000, 0x66a147d300000000, 0xd86d4b1a00000000, 0x107ad5d500000000, 0x0944065e00000000, 0xc153989100000000, 0x7a3ed19200000000, 0xb2294f5d00000000, 0xab179cd600000000, 0x6300021900000000, 0x6d1798e400000000, 0xa500062b00000000, 0xbc3ed5a000000000, 0x74294b6f00000000, 0xcf44026c00000000, 0x07539ca300000000, 0x1e6d4f2800000000, 0xd67ad1e700000000, 0x68b6dd2e00000000, 0xa0a143e100000000, 0xb99f906a00000000, 0x71880ea500000000, 0xcae547a600000000, 0x02f2d96900000000, 0x1bcc0ae200000000, 0xd3db942d00000000, 0x265362ab00000000, 0xee44fc6400000000, 0xf77a2fef00000000, 0x3f6db12000000000, 0x8400f82300000000, 0x4c1766ec00000000, 0x5529b56700000000, 0x9d3e2ba800000000, 0x23f2276100000000, 0xebe5b9ae00000000, 0xf2db6a2500000000, 0x3accf4ea00000000, 0x81a1bde900000000, 0x49b6232600000000, 0x5088f0ad00000000, 0x989f6e6200000000, 0xfb9f6c7b00000000, 0x3388f2b400000000, 0x2ab6213f00000000, 0xe2a1bff000000000, 0x59ccf6f300000000, 0x91db683c00000000, 0x88e5bbb700000000, 0x40f2257800000000, 0xfe3e29b100000000, 0x3629b77e00000000, 0x2f1764f500000000, 0xe700fa3a00000000, 0x5c6db33900000000, 0x947a2df600000000, 0x8d44fe7d00000000, 0x455360b200000000, 0xb0db963400000000, 0x78cc08fb00000000, 0x61f2db7000000000, 0xa9e545bf00000000, 0x12880cbc00000000, 0xda9f927300000000, 0xc3a141f800000000, 0x0bb6df3700000000, 0xb57ad3fe00000000, 0x7d6d4d3100000000, 0x64539eba00000000, 0xac44007500000000, 0x1729497600000000, 0xdf3ed7b900000000, 0xc600043200000000, 0x0e179afd00000000, 0x9b28411200000000, 0x533fdfdd00000000, 0x4a010c5600000000, 0x8216929900000000, 0x397bdb9a00000000, 0xf16c455500000000, 0xe85296de00000000, 0x2045081100000000, 0x9e8904d800000000, 0x569e9a1700000000, 0x4fa0499c00000000, 0x87b7d75300000000, 0x3cda9e5000000000, 0xf4cd009f00000000, 0xedf3d31400000000, 0x25e44ddb00000000, 0xd06cbb5d00000000, 0x187b259200000000, 0x0145f61900000000, 0xc95268d600000000, 0x723f21d500000000, 0xba28bf1a00000000, 0xa3166c9100000000, 0x6b01f25e00000000, 0xd5cdfe9700000000, 0x1dda605800000000, 0x04e4b3d300000000, 0xccf32d1c00000000, 0x779e641f00000000, 0xbf89fad000000000, 0xa6b7295b00000000, 0x6ea0b79400000000, 0x0da0b58d00000000, 0xc5b72b4200000000, 0xdc89f8c900000000, 0x149e660600000000, 0xaff32f0500000000, 0x67e4b1ca00000000, 0x7eda624100000000, 0xb6cdfc8e00000000, 0x0801f04700000000, 0xc0166e8800000000, 0xd928bd0300000000, 0x113f23cc00000000, 0xaa526acf00000000, 0x6245f40000000000, 0x7b7b278b00000000, 0xb36cb94400000000, 0x46e44fc200000000, 0x8ef3d10d00000000, 0x97cd028600000000, 0x5fda9c4900000000, 0xe4b7d54a00000000, 0x2ca04b8500000000, 0x359e980e00000000, 0xfd8906c100000000, 0x43450a0800000000, 0x8b5294c700000000, 0x926c474c00000000, 0x5a7bd98300000000, 0xe116908000000000, 0x29010e4f00000000, 0x303fddc400000000, 0xf828430b00000000, 0xf63fd9f600000000, 0x3e28473900000000, 0x271694b200000000, 0xef010a7d00000000, 0x546c437e00000000, 0x9c7bddb100000000, 0x85450e3a00000000, 0x4d5290f500000000, 0xf39e9c3c00000000, 0x3b8902f300000000, 0x22b7d17800000000, 0xeaa04fb700000000, 0x51cd06b400000000, 0x99da987b00000000, 0x80e44bf000000000, 0x48f3d53f00000000, 0xbd7b23b900000000, 0x756cbd7600000000, 0x6c526efd00000000, 0xa445f03200000000, 0x1f28b93100000000, 0xd73f27fe00000000, 0xce01f47500000000, 0x06166aba00000000, 0xb8da667300000000, 0x70cdf8bc00000000, 0x69f32b3700000000, 0xa1e4b5f800000000, 0x1a89fcfb00000000, 0xd29e623400000000, 0xcba0b1bf00000000, 0x03b72f7000000000, 0x60b72d6900000000, 0xa8a0b3a600000000, 0xb19e602d00000000, 0x7989fee200000000, 0xc2e4b7e100000000, 0x0af3292e00000000, 0x13cdfaa500000000, 0xdbda646a00000000, 0x651668a300000000, 0xad01f66c00000000, 0xb43f25e700000000, 0x7c28bb2800000000, 0xc745f22b00000000, 0x0f526ce400000000, 0x166cbf6f00000000, 0xde7b21a000000000, 0x2bf3d72600000000, 0xe3e449e900000000, 0xfada9a6200000000, 0x32cd04ad00000000, 0x89a04dae00000000, 0x41b7d36100000000, 0x588900ea00000000, 0x909e9e2500000000, 0x2e5292ec00000000, 0xe6450c2300000000, 0xff7bdfa800000000, 0x376c416700000000, 0x8c01086400000000, 0x441696ab00000000, 0x5d28452000000000, 0x953fdbef00000000}, {0x0000000000000000, 0x95d4709500000000, 0x6baf90f100000000, 0xfe7be06400000000, 0x9758503800000000, 0x028c20ad00000000, 0xfcf7c0c900000000, 0x6923b05c00000000, 0x2eb1a07000000000, 0xbb65d0e500000000, 0x451e308100000000, 0xd0ca401400000000, 0xb9e9f04800000000, 0x2c3d80dd00000000, 0xd24660b900000000, 0x4792102c00000000, 0x5c6241e100000000, 0xc9b6317400000000, 0x37cdd11000000000, 0xa219a18500000000, 0xcb3a11d900000000, 0x5eee614c00000000, 0xa095812800000000, 0x3541f1bd00000000, 0x72d3e19100000000, 0xe707910400000000, 0x197c716000000000, 0x8ca801f500000000, 0xe58bb1a900000000, 0x705fc13c00000000, 0x8e24215800000000, 0x1bf051cd00000000, 0xf9c2f31900000000, 0x6c16838c00000000, 0x926d63e800000000, 0x07b9137d00000000, 0x6e9aa32100000000, 0xfb4ed3b400000000, 0x053533d000000000, 0x90e1434500000000, 0xd773536900000000, 0x42a723fc00000000, 0xbcdcc39800000000, 0x2908b30d00000000, 0x402b035100000000, 0xd5ff73c400000000, 0x2b8493a000000000, 0xbe50e33500000000, 0xa5a0b2f800000000, 0x3074c26d00000000, 0xce0f220900000000, 0x5bdb529c00000000, 0x32f8e2c000000000, 0xa72c925500000000, 0x5957723100000000, 0xcc8302a400000000, 0x8b11128800000000, 0x1ec5621d00000000, 0xe0be827900000000, 0x756af2ec00000000, 0x1c4942b000000000, 0x899d322500000000, 0x77e6d24100000000, 0xe232a2d400000000, 0xf285e73300000000, 0x675197a600000000, 0x992a77c200000000, 0x0cfe075700000000, 0x65ddb70b00000000, 0xf009c79e00000000, 0x0e7227fa00000000, 0x9ba6576f00000000, 0xdc34474300000000, 0x49e037d600000000, 0xb79bd7b200000000, 0x224fa72700000000, 0x4b6c177b00000000, 0xdeb867ee00000000, 0x20c3878a00000000, 0xb517f71f00000000, 0xaee7a6d200000000, 0x3b33d64700000000, 0xc548362300000000, 0x509c46b600000000, 0x39bff6ea00000000, 0xac6b867f00000000, 0x5210661b00000000, 0xc7c4168e00000000, 0x805606a200000000, 0x1582763700000000, 0xebf9965300000000, 0x7e2de6c600000000, 0x170e569a00000000, 0x82da260f00000000, 0x7ca1c66b00000000, 0xe975b6fe00000000, 0x0b47142a00000000, 0x9e9364bf00000000, 0x60e884db00000000, 0xf53cf44e00000000, 0x9c1f441200000000, 0x09cb348700000000, 0xf7b0d4e300000000, 0x6264a47600000000, 0x25f6b45a00000000, 0xb022c4cf00000000, 0x4e5924ab00000000, 0xdb8d543e00000000, 0xb2aee46200000000, 0x277a94f700000000, 0xd901749300000000, 0x4cd5040600000000, 0x572555cb00000000, 0xc2f1255e00000000, 0x3c8ac53a00000000, 0xa95eb5af00000000, 0xc07d05f300000000, 0x55a9756600000000, 0xabd2950200000000, 0x3e06e59700000000, 0x7994f5bb00000000, 0xec40852e00000000, 0x123b654a00000000, 0x87ef15df00000000, 0xeecca58300000000, 0x7b18d51600000000, 0x8563357200000000, 0x10b745e700000000, 0xe40bcf6700000000, 0x71dfbff200000000, 0x8fa45f9600000000, 0x1a702f0300000000, 0x73539f5f00000000, 0xe687efca00000000, 0x18fc0fae00000000, 0x8d287f3b00000000, 0xcaba6f1700000000, 0x5f6e1f8200000000, 0xa115ffe600000000, 0x34c18f7300000000, 0x5de23f2f00000000, 0xc8364fba00000000, 0x364dafde00000000, 0xa399df4b00000000, 0xb8698e8600000000, 0x2dbdfe1300000000, 0xd3c61e7700000000, 0x46126ee200000000, 0x2f31debe00000000, 0xbae5ae2b00000000, 0x449e4e4f00000000, 0xd14a3eda00000000, 0x96d82ef600000000, 0x030c5e6300000000, 0xfd77be0700000000, 0x68a3ce9200000000, 0x01807ece00000000, 0x94540e5b00000000, 0x6a2fee3f00000000, 0xfffb9eaa00000000, 0x1dc93c7e00000000, 0x881d4ceb00000000, 0x7666ac8f00000000, 0xe3b2dc1a00000000, 0x8a916c4600000000, 0x1f451cd300000000, 0xe13efcb700000000, 0x74ea8c2200000000, 0x33789c0e00000000, 0xa6acec9b00000000, 0x58d70cff00000000, 0xcd037c6a00000000, 0xa420cc3600000000, 0x31f4bca300000000, 0xcf8f5cc700000000, 0x5a5b2c5200000000, 0x41ab7d9f00000000, 0xd47f0d0a00000000, 0x2a04ed6e00000000, 0xbfd09dfb00000000, 0xd6f32da700000000, 0x43275d3200000000, 0xbd5cbd5600000000, 0x2888cdc300000000, 0x6f1addef00000000, 0xfacead7a00000000, 0x04b54d1e00000000, 0x91613d8b00000000, 0xf8428dd700000000, 0x6d96fd4200000000, 0x93ed1d2600000000, 0x06396db300000000, 0x168e285400000000, 0x835a58c100000000, 0x7d21b8a500000000, 0xe8f5c83000000000, 0x81d6786c00000000, 0x140208f900000000, 0xea79e89d00000000, 0x7fad980800000000, 0x383f882400000000, 0xadebf8b100000000, 0x539018d500000000, 0xc644684000000000, 0xaf67d81c00000000, 0x3ab3a88900000000, 0xc4c848ed00000000, 0x511c387800000000, 0x4aec69b500000000, 0xdf38192000000000, 0x2143f94400000000, 0xb49789d100000000, 0xddb4398d00000000, 0x4860491800000000, 0xb61ba97c00000000, 0x23cfd9e900000000, 0x645dc9c500000000, 0xf189b95000000000, 0x0ff2593400000000, 0x9a2629a100000000, 0xf30599fd00000000, 0x66d1e96800000000, 0x98aa090c00000000, 0x0d7e799900000000, 0xef4cdb4d00000000, 0x7a98abd800000000, 0x84e34bbc00000000, 0x11373b2900000000, 0x78148b7500000000, 0xedc0fbe000000000, 0x13bb1b8400000000, 0x866f6b1100000000, 0xc1fd7b3d00000000, 0x54290ba800000000, 0xaa52ebcc00000000, 0x3f869b5900000000, 0x56a52b0500000000, 0xc3715b9000000000, 0x3d0abbf400000000, 0xa8decb6100000000, 0xb32e9aac00000000, 0x26faea3900000000, 0xd8810a5d00000000, 0x4d557ac800000000, 0x2476ca9400000000, 0xb1a2ba0100000000, 0x4fd95a6500000000, 0xda0d2af000000000, 0x9d9f3adc00000000, 0x084b4a4900000000, 0xf630aa2d00000000, 0x63e4dab800000000, 0x0ac76ae400000000, 0x9f131a7100000000, 0x6168fa1500000000, 0xf4bc8a8000000000}, {0x0000000000000000, 0x1f17f08000000000, 0x7f2891da00000000, 0x603f615a00000000, 0xbf56536e00000000, 0xa041a3ee00000000, 0xc07ec2b400000000, 0xdf69323400000000, 0x7eada6dc00000000, 0x61ba565c00000000, 0x0185370600000000, 0x1e92c78600000000, 0xc1fbf5b200000000, 0xdeec053200000000, 0xbed3646800000000, 0xa1c494e800000000, 0xbd5c3c6200000000, 0xa24bcce200000000, 0xc274adb800000000, 0xdd635d3800000000, 0x020a6f0c00000000, 0x1d1d9f8c00000000, 0x7d22fed600000000, 0x62350e5600000000, 0xc3f19abe00000000, 0xdce66a3e00000000, 0xbcd90b6400000000, 0xa3cefbe400000000, 0x7ca7c9d000000000, 0x63b0395000000000, 0x038f580a00000000, 0x1c98a88a00000000, 0x7ab978c400000000, 0x65ae884400000000, 0x0591e91e00000000, 0x1a86199e00000000, 0xc5ef2baa00000000, 0xdaf8db2a00000000, 0xbac7ba7000000000, 0xa5d04af000000000, 0x0414de1800000000, 0x1b032e9800000000, 0x7b3c4fc200000000, 0x642bbf4200000000, 0xbb428d7600000000, 0xa4557df600000000, 0xc46a1cac00000000, 0xdb7dec2c00000000, 0xc7e544a600000000, 0xd8f2b42600000000, 0xb8cdd57c00000000, 0xa7da25fc00000000, 0x78b317c800000000, 0x67a4e74800000000, 0x079b861200000000, 0x188c769200000000, 0xb948e27a00000000, 0xa65f12fa00000000, 0xc66073a000000000, 0xd977832000000000, 0x061eb11400000000, 0x1909419400000000, 0x793620ce00000000, 0x6621d04e00000000, 0xb574805300000000, 0xaa6370d300000000, 0xca5c118900000000, 0xd54be10900000000, 0x0a22d33d00000000, 0x153523bd00000000, 0x750a42e700000000, 0x6a1db26700000000, 0xcbd9268f00000000, 0xd4ced60f00000000, 0xb4f1b75500000000, 0xabe647d500000000, 0x748f75e100000000, 0x6b98856100000000, 0x0ba7e43b00000000, 0x14b014bb00000000, 0x0828bc3100000000, 0x173f4cb100000000, 0x77002deb00000000, 0x6817dd6b00000000, 0xb77eef5f00000000, 0xa8691fdf00000000, 0xc8567e8500000000, 0xd7418e0500000000, 0x76851aed00000000, 0x6992ea6d00000000, 0x09ad8b3700000000, 0x16ba7bb700000000, 0xc9d3498300000000, 0xd6c4b90300000000, 0xb6fbd85900000000, 0xa9ec28d900000000, 0xcfcdf89700000000, 0xd0da081700000000, 0xb0e5694d00000000, 0xaff299cd00000000, 0x709babf900000000, 0x6f8c5b7900000000, 0x0fb33a2300000000, 0x10a4caa300000000, 0xb1605e4b00000000, 0xae77aecb00000000, 0xce48cf9100000000, 0xd15f3f1100000000, 0x0e360d2500000000, 0x1121fda500000000, 0x711e9cff00000000, 0x6e096c7f00000000, 0x7291c4f500000000, 0x6d86347500000000, 0x0db9552f00000000, 0x12aea5af00000000, 0xcdc7979b00000000, 0xd2d0671b00000000, 0xb2ef064100000000, 0xadf8f6c100000000, 0x0c3c622900000000, 0x132b92a900000000, 0x7314f3f300000000, 0x6c03037300000000, 0xb36a314700000000, 0xac7dc1c700000000, 0xcc42a09d00000000, 0xd355501d00000000, 0x6ae900a700000000, 0x75fef02700000000, 0x15c1917d00000000, 0x0ad661fd00000000, 0xd5bf53c900000000, 0xcaa8a34900000000, 0xaa97c21300000000, 0xb580329300000000, 0x1444a67b00000000, 0x0b5356fb00000000, 0x6b6c37a100000000, 0x747bc72100000000, 0xab12f51500000000, 0xb405059500000000, 0xd43a64cf00000000, 0xcb2d944f00000000, 0xd7b53cc500000000, 0xc8a2cc4500000000, 0xa89dad1f00000000, 0xb78a5d9f00000000, 0x68e36fab00000000, 0x77f49f2b00000000, 0x17cbfe7100000000, 0x08dc0ef100000000, 0xa9189a1900000000, 0xb60f6a9900000000, 0xd6300bc300000000, 0xc927fb4300000000, 0x164ec97700000000, 0x095939f700000000, 0x696658ad00000000, 0x7671a82d00000000, 0x1050786300000000, 0x0f4788e300000000, 0x6f78e9b900000000, 0x706f193900000000, 0xaf062b0d00000000, 0xb011db8d00000000, 0xd02ebad700000000, 0xcf394a5700000000, 0x6efddebf00000000, 0x71ea2e3f00000000, 0x11d54f6500000000, 0x0ec2bfe500000000, 0xd1ab8dd100000000, 0xcebc7d5100000000, 0xae831c0b00000000, 0xb194ec8b00000000, 0xad0c440100000000, 0xb21bb48100000000, 0xd224d5db00000000, 0xcd33255b00000000, 0x125a176f00000000, 0x0d4de7ef00000000, 0x6d7286b500000000, 0x7265763500000000, 0xd3a1e2dd00000000, 0xccb6125d00000000, 0xac89730700000000, 0xb39e838700000000, 0x6cf7b1b300000000, 0x73e0413300000000, 0x13df206900000000, 0x0cc8d0e900000000, 0xdf9d80f400000000, 0xc08a707400000000, 0xa0b5112e00000000, 0xbfa2e1ae00000000, 0x60cbd39a00000000, 0x7fdc231a00000000, 0x1fe3424000000000, 0x00f4b2c000000000, 0xa130262800000000, 0xbe27d6a800000000, 0xde18b7f200000000, 0xc10f477200000000, 0x1e66754600000000, 0x017185c600000000, 0x614ee49c00000000, 0x7e59141c00000000, 0x62c1bc9600000000, 0x7dd64c1600000000, 0x1de92d4c00000000, 0x02feddcc00000000, 0xdd97eff800000000, 0xc2801f7800000000, 0xa2bf7e2200000000, 0xbda88ea200000000, 0x1c6c1a4a00000000, 0x037beaca00000000, 0x63448b9000000000, 0x7c537b1000000000, 0xa33a492400000000, 0xbc2db9a400000000, 0xdc12d8fe00000000, 0xc305287e00000000, 0xa524f83000000000, 0xba3308b000000000, 0xda0c69ea00000000, 0xc51b996a00000000, 0x1a72ab5e00000000, 0x05655bde00000000, 0x655a3a8400000000, 0x7a4dca0400000000, 0xdb895eec00000000, 0xc49eae6c00000000, 0xa4a1cf3600000000, 0xbbb63fb600000000, 0x64df0d8200000000, 0x7bc8fd0200000000, 0x1bf79c5800000000, 0x04e06cd800000000, 0x1878c45200000000, 0x076f34d200000000, 0x6750558800000000, 0x7847a50800000000, 0xa72e973c00000000, 0xb83967bc00000000, 0xd80606e600000000, 0xc711f66600000000, 0x66d5628e00000000, 0x79c2920e00000000, 0x19fdf35400000000, 0x06ea03d400000000, 0xd98331e000000000, 0xc694c16000000000, 0xa6aba03a00000000, 0xb9bc50ba00000000}, {0x0000000000000000, 0xe2fd888d00000000, 0x85fd60c000000000, 0x6700e84d00000000, 0x4bfdb05b00000000, 0xa90038d600000000, 0xce00d09b00000000, 0x2cfd581600000000, 0x96fa61b700000000, 0x7407e93a00000000, 0x1307017700000000, 0xf1fa89fa00000000, 0xdd07d1ec00000000, 0x3ffa596100000000, 0x58fab12c00000000, 0xba0739a100000000, 0x6df3b2b500000000, 0x8f0e3a3800000000, 0xe80ed27500000000, 0x0af35af800000000, 0x260e02ee00000000, 0xc4f38a6300000000, 0xa3f3622e00000000, 0x410eeaa300000000, 0xfb09d30200000000, 0x19f45b8f00000000, 0x7ef4b3c200000000, 0x9c093b4f00000000, 0xb0f4635900000000, 0x5209ebd400000000, 0x3509039900000000, 0xd7f48b1400000000, 0x9be014b000000000, 0x791d9c3d00000000, 0x1e1d747000000000, 0xfce0fcfd00000000, 0xd01da4eb00000000, 0x32e02c6600000000, 0x55e0c42b00000000, 0xb71d4ca600000000, 0x0d1a750700000000, 0xefe7fd8a00000000, 0x88e715c700000000, 0x6a1a9d4a00000000, 0x46e7c55c00000000, 0xa41a4dd100000000, 0xc31aa59c00000000, 0x21e72d1100000000, 0xf613a60500000000, 0x14ee2e8800000000, 0x73eec6c500000000, 0x91134e4800000000, 0xbdee165e00000000, 0x5f139ed300000000, 0x3813769e00000000, 0xdaeefe1300000000, 0x60e9c7b200000000, 0x82144f3f00000000, 0xe514a77200000000, 0x07e92fff00000000, 0x2b1477e900000000, 0xc9e9ff6400000000, 0xaee9172900000000, 0x4c149fa400000000, 0x77c758bb00000000, 0x953ad03600000000, 0xf23a387b00000000, 0x10c7b0f600000000, 0x3c3ae8e000000000, 0xdec7606d00000000, 0xb9c7882000000000, 0x5b3a00ad00000000, 0xe13d390c00000000, 0x03c0b18100000000, 0x64c059cc00000000, 0x863dd14100000000, 0xaac0895700000000, 0x483d01da00000000, 0x2f3de99700000000, 0xcdc0611a00000000, 0x1a34ea0e00000000, 0xf8c9628300000000, 0x9fc98ace00000000, 0x7d34024300000000, 0x51c95a5500000000, 0xb334d2d800000000, 0xd4343a9500000000, 0x36c9b21800000000, 0x8cce8bb900000000, 0x6e33033400000000, 0x0933eb7900000000, 0xebce63f400000000, 0xc7333be200000000, 0x25ceb36f00000000, 0x42ce5b2200000000, 0xa033d3af00000000, 0xec274c0b00000000, 0x0edac48600000000, 0x69da2ccb00000000, 0x8b27a44600000000, 0xa7dafc5000000000, 0x452774dd00000000, 0x22279c9000000000, 0xc0da141d00000000, 0x7add2dbc00000000, 0x9820a53100000000, 0xff204d7c00000000, 0x1dddc5f100000000, 0x31209de700000000, 0xd3dd156a00000000, 0xb4ddfd2700000000, 0x562075aa00000000, 0x81d4febe00000000, 0x6329763300000000, 0x04299e7e00000000, 0xe6d416f300000000, 0xca294ee500000000, 0x28d4c66800000000, 0x4fd42e2500000000, 0xad29a6a800000000, 0x172e9f0900000000, 0xf5d3178400000000, 0x92d3ffc900000000, 0x702e774400000000, 0x5cd32f5200000000, 0xbe2ea7df00000000, 0xd92e4f9200000000, 0x3bd3c71f00000000, 0xaf88c0ad00000000, 0x4d75482000000000, 0x2a75a06d00000000, 0xc88828e000000000, 0xe47570f600000000, 0x0688f87b00000000, 0x6188103600000000, 0x837598bb00000000, 0x3972a11a00000000, 0xdb8f299700000000, 0xbc8fc1da00000000, 0x5e72495700000000, 0x728f114100000000, 0x907299cc00000000, 0xf772718100000000, 0x158ff90c00000000, 0xc27b721800000000, 0x2086fa9500000000, 0x478612d800000000, 0xa57b9a5500000000, 0x8986c24300000000, 0x6b7b4ace00000000, 0x0c7ba28300000000, 0xee862a0e00000000, 0x548113af00000000, 0xb67c9b2200000000, 0xd17c736f00000000, 0x3381fbe200000000, 0x1f7ca3f400000000, 0xfd812b7900000000, 0x9a81c33400000000, 0x787c4bb900000000, 0x3468d41d00000000, 0xd6955c9000000000, 0xb195b4dd00000000, 0x53683c5000000000, 0x7f95644600000000, 0x9d68eccb00000000, 0xfa68048600000000, 0x18958c0b00000000, 0xa292b5aa00000000, 0x406f3d2700000000, 0x276fd56a00000000, 0xc5925de700000000, 0xe96f05f100000000, 0x0b928d7c00000000, 0x6c92653100000000, 0x8e6fedbc00000000, 0x599b66a800000000, 0xbb66ee2500000000, 0xdc66066800000000, 0x3e9b8ee500000000, 0x1266d6f300000000, 0xf09b5e7e00000000, 0x979bb63300000000, 0x75663ebe00000000, 0xcf61071f00000000, 0x2d9c8f9200000000, 0x4a9c67df00000000, 0xa861ef5200000000, 0x849cb74400000000, 0x66613fc900000000, 0x0161d78400000000, 0xe39c5f0900000000, 0xd84f981600000000, 0x3ab2109b00000000, 0x5db2f8d600000000, 0xbf4f705b00000000, 0x93b2284d00000000, 0x714fa0c000000000, 0x164f488d00000000, 0xf4b2c00000000000, 0x4eb5f9a100000000, 0xac48712c00000000, 0xcb48996100000000, 0x29b511ec00000000, 0x054849fa00000000, 0xe7b5c17700000000, 0x80b5293a00000000, 0x6248a1b700000000, 0xb5bc2aa300000000, 0x5741a22e00000000, 0x30414a6300000000, 0xd2bcc2ee00000000, 0xfe419af800000000, 0x1cbc127500000000, 0x7bbcfa3800000000, 0x994172b500000000, 0x23464b1400000000, 0xc1bbc39900000000, 0xa6bb2bd400000000, 0x4446a35900000000, 0x68bbfb4f00000000, 0x8a4673c200000000, 0xed469b8f00000000, 0x0fbb130200000000, 0x43af8ca600000000, 0xa152042b00000000, 0xc652ec6600000000, 0x24af64eb00000000, 0x08523cfd00000000, 0xeaafb47000000000, 0x8daf5c3d00000000, 0x6f52d4b000000000, 0xd555ed1100000000, 0x37a8659c00000000, 0x50a88dd100000000, 0xb255055c00000000, 0x9ea85d4a00000000, 0x7c55d5c700000000, 0x1b553d8a00000000, 0xf9a8b50700000000, 0x2e5c3e1300000000, 0xcca1b69e00000000, 0xaba15ed300000000, 0x495cd65e00000000, 0x65a18e4800000000, 0x875c06c500000000, 0xe05cee8800000000, 0x02a1660500000000, 0xb8a65fa400000000, 0x5a5bd72900000000, 0x3d5b3f6400000000, 0xdfa6b7e900000000, 0xf35befff00000000, 0x11a6677200000000, 0x76a68f3f00000000, 0x945b07b200000000}, {0x0000000000000000, 0xa90b894e00000000, 0x5217129d00000000, 0xfb1c9bd300000000, 0xe52855e100000000, 0x4c23dcaf00000000, 0xb73f477c00000000, 0x1e34ce3200000000, 0x8b57db1900000000, 0x225c525700000000, 0xd940c98400000000, 0x704b40ca00000000, 0x6e7f8ef800000000, 0xc77407b600000000, 0x3c689c6500000000, 0x9563152b00000000, 0x16afb63300000000, 0xbfa43f7d00000000, 0x44b8a4ae00000000, 0xedb32de000000000, 0xf387e3d200000000, 0x5a8c6a9c00000000, 0xa190f14f00000000, 0x089b780100000000, 0x9df86d2a00000000, 0x34f3e46400000000, 0xcfef7fb700000000, 0x66e4f6f900000000, 0x78d038cb00000000, 0xd1dbb18500000000, 0x2ac72a5600000000, 0x83cca31800000000, 0x2c5e6d6700000000, 0x8555e42900000000, 0x7e497ffa00000000, 0xd742f6b400000000, 0xc976388600000000, 0x607db1c800000000, 0x9b612a1b00000000, 0x326aa35500000000, 0xa709b67e00000000, 0x0e023f3000000000, 0xf51ea4e300000000, 0x5c152dad00000000, 0x4221e39f00000000, 0xeb2a6ad100000000, 0x1036f10200000000, 0xb93d784c00000000, 0x3af1db5400000000, 0x93fa521a00000000, 0x68e6c9c900000000, 0xc1ed408700000000, 0xdfd98eb500000000, 0x76d207fb00000000, 0x8dce9c2800000000, 0x24c5156600000000, 0xb1a6004d00000000, 0x18ad890300000000, 0xe3b112d000000000, 0x4aba9b9e00000000, 0x548e55ac00000000, 0xfd85dce200000000, 0x0699473100000000, 0xaf92ce7f00000000, 0x58bcdace00000000, 0xf1b7538000000000, 0x0aabc85300000000, 0xa3a0411d00000000, 0xbd948f2f00000000, 0x149f066100000000, 0xef839db200000000, 0x468814fc00000000, 0xd3eb01d700000000, 0x7ae0889900000000, 0x81fc134a00000000, 0x28f79a0400000000, 0x36c3543600000000, 0x9fc8dd7800000000, 0x64d446ab00000000, 0xcddfcfe500000000, 0x4e136cfd00000000, 0xe718e5b300000000, 0x1c047e6000000000, 0xb50ff72e00000000, 0xab3b391c00000000, 0x0230b05200000000, 0xf92c2b8100000000, 0x5027a2cf00000000, 0xc544b7e400000000, 0x6c4f3eaa00000000, 0x9753a57900000000, 0x3e582c3700000000, 0x206ce20500000000, 0x89676b4b00000000, 0x727bf09800000000, 0xdb7079d600000000, 0x74e2b7a900000000, 0xdde93ee700000000, 0x26f5a53400000000, 0x8ffe2c7a00000000, 0x91cae24800000000, 0x38c16b0600000000, 0xc3ddf0d500000000, 0x6ad6799b00000000, 0xffb56cb000000000, 0x56bee5fe00000000, 0xada27e2d00000000, 0x04a9f76300000000, 0x1a9d395100000000, 0xb396b01f00000000, 0x488a2bcc00000000, 0xe181a28200000000, 0x624d019a00000000, 0xcb4688d400000000, 0x305a130700000000, 0x99519a4900000000, 0x8765547b00000000, 0x2e6edd3500000000, 0xd57246e600000000, 0x7c79cfa800000000, 0xe91ada8300000000, 0x401153cd00000000, 0xbb0dc81e00000000, 0x1206415000000000, 0x0c328f6200000000, 0xa539062c00000000, 0x5e259dff00000000, 0xf72e14b100000000, 0xf17ec44600000000, 0x58754d0800000000, 0xa369d6db00000000, 0x0a625f9500000000, 0x145691a700000000, 0xbd5d18e900000000, 0x4641833a00000000, 0xef4a0a7400000000, 0x7a291f5f00000000, 0xd322961100000000, 0x283e0dc200000000, 0x8135848c00000000, 0x9f014abe00000000, 0x360ac3f000000000, 0xcd16582300000000, 0x641dd16d00000000, 0xe7d1727500000000, 0x4edafb3b00000000, 0xb5c660e800000000, 0x1ccde9a600000000, 0x02f9279400000000, 0xabf2aeda00000000, 0x50ee350900000000, 0xf9e5bc4700000000, 0x6c86a96c00000000, 0xc58d202200000000, 0x3e91bbf100000000, 0x979a32bf00000000, 0x89aefc8d00000000, 0x20a575c300000000, 0xdbb9ee1000000000, 0x72b2675e00000000, 0xdd20a92100000000, 0x742b206f00000000, 0x8f37bbbc00000000, 0x263c32f200000000, 0x3808fcc000000000, 0x9103758e00000000, 0x6a1fee5d00000000, 0xc314671300000000, 0x5677723800000000, 0xff7cfb7600000000, 0x046060a500000000, 0xad6be9eb00000000, 0xb35f27d900000000, 0x1a54ae9700000000, 0xe148354400000000, 0x4843bc0a00000000, 0xcb8f1f1200000000, 0x6284965c00000000, 0x99980d8f00000000, 0x309384c100000000, 0x2ea74af300000000, 0x87acc3bd00000000, 0x7cb0586e00000000, 0xd5bbd12000000000, 0x40d8c40b00000000, 0xe9d34d4500000000, 0x12cfd69600000000, 0xbbc45fd800000000, 0xa5f091ea00000000, 0x0cfb18a400000000, 0xf7e7837700000000, 0x5eec0a3900000000, 0xa9c21e8800000000, 0x00c997c600000000, 0xfbd50c1500000000, 0x52de855b00000000, 0x4cea4b6900000000, 0xe5e1c22700000000, 0x1efd59f400000000, 0xb7f6d0ba00000000, 0x2295c59100000000, 0x8b9e4cdf00000000, 0x7082d70c00000000, 0xd9895e4200000000, 0xc7bd907000000000, 0x6eb6193e00000000, 0x95aa82ed00000000, 0x3ca10ba300000000, 0xbf6da8bb00000000, 0x166621f500000000, 0xed7aba2600000000, 0x4471336800000000, 0x5a45fd5a00000000, 0xf34e741400000000, 0x0852efc700000000, 0xa159668900000000, 0x343a73a200000000, 0x9d31faec00000000, 0x662d613f00000000, 0xcf26e87100000000, 0xd112264300000000, 0x7819af0d00000000, 0x830534de00000000, 0x2a0ebd9000000000, 0x859c73ef00000000, 0x2c97faa100000000, 0xd78b617200000000, 0x7e80e83c00000000, 0x60b4260e00000000, 0xc9bfaf4000000000, 0x32a3349300000000, 0x9ba8bddd00000000, 0x0ecba8f600000000, 0xa7c021b800000000, 0x5cdcba6b00000000, 0xf5d7332500000000, 0xebe3fd1700000000, 0x42e8745900000000, 0xb9f4ef8a00000000, 0x10ff66c400000000, 0x9333c5dc00000000, 0x3a384c9200000000, 0xc124d74100000000, 0x682f5e0f00000000, 0x761b903d00000000, 0xdf10197300000000, 0x240c82a000000000, 0x8d070bee00000000, 0x18641ec500000000, 0xb16f978b00000000, 0x4a730c5800000000, 0xe378851600000000, 0xfd4c4b2400000000, 0x5447c26a00000000, 0xaf5b59b900000000, 0x0650d0f700000000}, {0x0000000000000000, 0x479244af00000000, 0xcf22f88500000000, 0x88b0bc2a00000000, 0xdf4381d000000000, 0x98d1c57f00000000, 0x1061795500000000, 0x57f33dfa00000000, 0xff81737a00000000, 0xb81337d500000000, 0x30a38bff00000000, 0x7731cf5000000000, 0x20c2f2aa00000000, 0x6750b60500000000, 0xefe00a2f00000000, 0xa8724e8000000000, 0xfe03e7f400000000, 0xb991a35b00000000, 0x31211f7100000000, 0x76b35bde00000000, 0x2140662400000000, 0x66d2228b00000000, 0xee629ea100000000, 0xa9f0da0e00000000, 0x0182948e00000000, 0x4610d02100000000, 0xcea06c0b00000000, 0x893228a400000000, 0xdec1155e00000000, 0x995351f100000000, 0x11e3eddb00000000, 0x5671a97400000000, 0xbd01bf3200000000, 0xfa93fb9d00000000, 0x722347b700000000, 0x35b1031800000000, 0x62423ee200000000, 0x25d07a4d00000000, 0xad60c66700000000, 0xeaf282c800000000, 0x4280cc4800000000, 0x051288e700000000, 0x8da234cd00000000, 0xca30706200000000, 0x9dc34d9800000000, 0xda51093700000000, 0x52e1b51d00000000, 0x1573f1b200000000, 0x430258c600000000, 0x04901c6900000000, 0x8c20a04300000000, 0xcbb2e4ec00000000, 0x9c41d91600000000, 0xdbd39db900000000, 0x5363219300000000, 0x14f1653c00000000, 0xbc832bbc00000000, 0xfb116f1300000000, 0x73a1d33900000000, 0x3433979600000000, 0x63c0aa6c00000000, 0x2452eec300000000, 0xace252e900000000, 0xeb70164600000000, 0x7a037e6500000000, 0x3d913aca00000000, 0xb52186e000000000, 0xf2b3c24f00000000, 0xa540ffb500000000, 0xe2d2bb1a00000000, 0x6a62073000000000, 0x2df0439f00000000, 0x85820d1f00000000, 0xc21049b000000000, 0x4aa0f59a00000000, 0x0d32b13500000000, 0x5ac18ccf00000000, 0x1d53c86000000000, 0x95e3744a00000000, 0xd27130e500000000, 0x8400999100000000, 0xc392dd3e00000000, 0x4b22611400000000, 0x0cb025bb00000000, 0x5b43184100000000, 0x1cd15cee00000000, 0x9461e0c400000000, 0xd3f3a46b00000000, 0x7b81eaeb00000000, 0x3c13ae4400000000, 0xb4a3126e00000000, 0xf33156c100000000, 0xa4c26b3b00000000, 0xe3502f9400000000, 0x6be093be00000000, 0x2c72d71100000000, 0xc702c15700000000, 0x809085f800000000, 0x082039d200000000, 0x4fb27d7d00000000, 0x1841408700000000, 0x5fd3042800000000, 0xd763b80200000000, 0x90f1fcad00000000, 0x3883b22d00000000, 0x7f11f68200000000, 0xf7a14aa800000000, 0xb0330e0700000000, 0xe7c033fd00000000, 0xa052775200000000, 0x28e2cb7800000000, 0x6f708fd700000000, 0x390126a300000000, 0x7e93620c00000000, 0xf623de2600000000, 0xb1b19a8900000000, 0xe642a77300000000, 0xa1d0e3dc00000000, 0x29605ff600000000, 0x6ef21b5900000000, 0xc68055d900000000, 0x8112117600000000, 0x09a2ad5c00000000, 0x4e30e9f300000000, 0x19c3d40900000000, 0x5e5190a600000000, 0xd6e12c8c00000000, 0x9173682300000000, 0xf406fcca00000000, 0xb394b86500000000, 0x3b24044f00000000, 0x7cb640e000000000, 0x2b457d1a00000000, 0x6cd739b500000000, 0xe467859f00000000, 0xa3f5c13000000000, 0x0b878fb000000000, 0x4c15cb1f00000000, 0xc4a5773500000000, 0x8337339a00000000, 0xd4c40e6000000000, 0x93564acf00000000, 0x1be6f6e500000000, 0x5c74b24a00000000, 0x0a051b3e00000000, 0x4d975f9100000000, 0xc527e3bb00000000, 0x82b5a71400000000, 0xd5469aee00000000, 0x92d4de4100000000, 0x1a64626b00000000, 0x5df626c400000000, 0xf584684400000000, 0xb2162ceb00000000, 0x3aa690c100000000, 0x7d34d46e00000000, 0x2ac7e99400000000, 0x6d55ad3b00000000, 0xe5e5111100000000, 0xa27755be00000000, 0x490743f800000000, 0x0e95075700000000, 0x8625bb7d00000000, 0xc1b7ffd200000000, 0x9644c22800000000, 0xd1d6868700000000, 0x59663aad00000000, 0x1ef47e0200000000, 0xb686308200000000, 0xf114742d00000000, 0x79a4c80700000000, 0x3e368ca800000000, 0x69c5b15200000000, 0x2e57f5fd00000000, 0xa6e749d700000000, 0xe1750d7800000000, 0xb704a40c00000000, 0xf096e0a300000000, 0x78265c8900000000, 0x3fb4182600000000, 0x684725dc00000000, 0x2fd5617300000000, 0xa765dd5900000000, 0xe0f799f600000000, 0x4885d77600000000, 0x0f1793d900000000, 0x87a72ff300000000, 0xc0356b5c00000000, 0x97c656a600000000, 0xd054120900000000, 0x58e4ae2300000000, 0x1f76ea8c00000000, 0x8e0582af00000000, 0xc997c60000000000, 0x41277a2a00000000, 0x06b53e8500000000, 0x5146037f00000000, 0x16d447d000000000, 0x9e64fbfa00000000, 0xd9f6bf5500000000, 0x7184f1d500000000, 0x3616b57a00000000, 0xbea6095000000000, 0xf9344dff00000000, 0xaec7700500000000, 0xe95534aa00000000, 0x61e5888000000000, 0x2677cc2f00000000, 0x7006655b00000000, 0x379421f400000000, 0xbf249dde00000000, 0xf8b6d97100000000, 0xaf45e48b00000000, 0xe8d7a02400000000, 0x60671c0e00000000, 0x27f558a100000000, 0x8f87162100000000, 0xc815528e00000000, 0x40a5eea400000000, 0x0737aa0b00000000, 0x50c497f100000000, 0x1756d35e00000000, 0x9fe66f7400000000, 0xd8742bdb00000000, 0x33043d9d00000000, 0x7496793200000000, 0xfc26c51800000000, 0xbbb481b700000000, 0xec47bc4d00000000, 0xabd5f8e200000000, 0x236544c800000000, 0x64f7006700000000, 0xcc854ee700000000, 0x8b170a4800000000, 0x03a7b66200000000, 0x4435f2cd00000000, 0x13c6cf3700000000, 0x54548b9800000000, 0xdce437b200000000, 0x9b76731d00000000, 0xcd07da6900000000, 0x8a959ec600000000, 0x022522ec00000000, 0x45b7664300000000, 0x12445bb900000000, 0x55d61f1600000000, 0xdd66a33c00000000, 0x9af4e79300000000, 0x3286a91300000000, 0x7514edbc00000000, 0xfda4519600000000, 0xba36153900000000, 0xedc528c300000000, 0xaa576c6c00000000, 0x22e7d04600000000, 0x657594e900000000}}; #else /* W == 4 */ local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, 0xd8ac6b35}, {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, 0xa140efa8}, {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, 0x917cd6a1}, {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, 0x18ba364e}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x00000000, 0x43cba687, 0xc7903cd4, 0x845b9a53, 0xcf270873, 0x8cecaef4, 0x08b734a7, 0x4b7c9220, 0x9e4f10e6, 0xdd84b661, 0x59df2c32, 0x1a148ab5, 0x51681895, 0x12a3be12, 0x96f82441, 0xd53382c6, 0x7d995117, 0x3e52f790, 0xba096dc3, 0xf9c2cb44, 0xb2be5964, 0xf175ffe3, 0x752e65b0, 0x36e5c337, 0xe3d641f1, 0xa01de776, 0x24467d25, 0x678ddba2, 0x2cf14982, 0x6f3aef05, 0xeb617556, 0xa8aad3d1, 0xfa32a32e, 0xb9f905a9, 0x3da29ffa, 0x7e69397d, 0x3515ab5d, 0x76de0dda, 0xf2859789, 0xb14e310e, 0x647db3c8, 0x27b6154f, 0xa3ed8f1c, 0xe026299b, 0xab5abbbb, 0xe8911d3c, 0x6cca876f, 0x2f0121e8, 0x87abf239, 0xc46054be, 0x403bceed, 0x03f0686a, 0x488cfa4a, 0x0b475ccd, 0x8f1cc69e, 0xccd76019, 0x19e4e2df, 0x5a2f4458, 0xde74de0b, 0x9dbf788c, 0xd6c3eaac, 0x95084c2b, 0x1153d678, 0x529870ff, 0xf465465d, 0xb7aee0da, 0x33f57a89, 0x703edc0e, 0x3b424e2e, 0x7889e8a9, 0xfcd272fa, 0xbf19d47d, 0x6a2a56bb, 0x29e1f03c, 0xadba6a6f, 0xee71cce8, 0xa50d5ec8, 0xe6c6f84f, 0x629d621c, 0x2156c49b, 0x89fc174a, 0xca37b1cd, 0x4e6c2b9e, 0x0da78d19, 0x46db1f39, 0x0510b9be, 0x814b23ed, 0xc280856a, 0x17b307ac, 0x5478a12b, 0xd0233b78, 0x93e89dff, 0xd8940fdf, 0x9b5fa958, 0x1f04330b, 0x5ccf958c, 0x0e57e573, 0x4d9c43f4, 0xc9c7d9a7, 0x8a0c7f20, 0xc170ed00, 0x82bb4b87, 0x06e0d1d4, 0x452b7753, 0x9018f595, 0xd3d35312, 0x5788c941, 0x14436fc6, 0x5f3ffde6, 0x1cf45b61, 0x98afc132, 0xdb6467b5, 0x73ceb464, 0x300512e3, 0xb45e88b0, 0xf7952e37, 0xbce9bc17, 0xff221a90, 0x7b7980c3, 0x38b22644, 0xed81a482, 0xae4a0205, 0x2a119856, 0x69da3ed1, 0x22a6acf1, 0x616d0a76, 0xe5369025, 0xa6fd36a2, 0xe8cb8cba, 0xab002a3d, 0x2f5bb06e, 0x6c9016e9, 0x27ec84c9, 0x6427224e, 0xe07cb81d, 0xa3b71e9a, 0x76849c5c, 0x354f3adb, 0xb114a088, 0xf2df060f, 0xb9a3942f, 0xfa6832a8, 0x7e33a8fb, 0x3df80e7c, 0x9552ddad, 0xd6997b2a, 0x52c2e179, 0x110947fe, 0x5a75d5de, 0x19be7359, 0x9de5e90a, 0xde2e4f8d, 0x0b1dcd4b, 0x48d66bcc, 0xcc8df19f, 0x8f465718, 0xc43ac538, 0x87f163bf, 0x03aaf9ec, 0x40615f6b, 0x12f92f94, 0x51328913, 0xd5691340, 0x96a2b5c7, 0xddde27e7, 0x9e158160, 0x1a4e1b33, 0x5985bdb4, 0x8cb63f72, 0xcf7d99f5, 0x4b2603a6, 0x08eda521, 0x43913701, 0x005a9186, 0x84010bd5, 0xc7caad52, 0x6f607e83, 0x2cabd804, 0xa8f04257, 0xeb3be4d0, 0xa04776f0, 0xe38cd077, 0x67d74a24, 0x241ceca3, 0xf12f6e65, 0xb2e4c8e2, 0x36bf52b1, 0x7574f436, 0x3e086616, 0x7dc3c091, 0xf9985ac2, 0xba53fc45, 0x1caecae7, 0x5f656c60, 0xdb3ef633, 0x98f550b4, 0xd389c294, 0x90426413, 0x1419fe40, 0x57d258c7, 0x82e1da01, 0xc12a7c86, 0x4571e6d5, 0x06ba4052, 0x4dc6d272, 0x0e0d74f5, 0x8a56eea6, 0xc99d4821, 0x61379bf0, 0x22fc3d77, 0xa6a7a724, 0xe56c01a3, 0xae109383, 0xeddb3504, 0x6980af57, 0x2a4b09d0, 0xff788b16, 0xbcb32d91, 0x38e8b7c2, 0x7b231145, 0x305f8365, 0x739425e2, 0xf7cfbfb1, 0xb4041936, 0xe69c69c9, 0xa557cf4e, 0x210c551d, 0x62c7f39a, 0x29bb61ba, 0x6a70c73d, 0xee2b5d6e, 0xade0fbe9, 0x78d3792f, 0x3b18dfa8, 0xbf4345fb, 0xfc88e37c, 0xb7f4715c, 0xf43fd7db, 0x70644d88, 0x33afeb0f, 0x9b0538de, 0xd8ce9e59, 0x5c95040a, 0x1f5ea28d, 0x542230ad, 0x17e9962a, 0x93b20c79, 0xd079aafe, 0x054a2838, 0x46818ebf, 0xc2da14ec, 0x8111b26b, 0xca6d204b, 0x89a686cc, 0x0dfd1c9f, 0x4e36ba18}, {0x00000000, 0xe1b652ef, 0x836bd405, 0x62dd86ea, 0x06d7a80b, 0xe761fae4, 0x85bc7c0e, 0x640a2ee1, 0x0cae5117, 0xed1803f8, 0x8fc58512, 0x6e73d7fd, 0x0a79f91c, 0xebcfabf3, 0x89122d19, 0x68a47ff6, 0x185ca32e, 0xf9eaf1c1, 0x9b37772b, 0x7a8125c4, 0x1e8b0b25, 0xff3d59ca, 0x9de0df20, 0x7c568dcf, 0x14f2f239, 0xf544a0d6, 0x9799263c, 0x762f74d3, 0x12255a32, 0xf39308dd, 0x914e8e37, 0x70f8dcd8, 0x30b8465d, 0xd10e14b2, 0xb3d39258, 0x5265c0b7, 0x366fee56, 0xd7d9bcb9, 0xb5043a53, 0x54b268bc, 0x3c16174a, 0xdda045a5, 0xbf7dc34f, 0x5ecb91a0, 0x3ac1bf41, 0xdb77edae, 0xb9aa6b44, 0x581c39ab, 0x28e4e573, 0xc952b79c, 0xab8f3176, 0x4a396399, 0x2e334d78, 0xcf851f97, 0xad58997d, 0x4ceecb92, 0x244ab464, 0xc5fce68b, 0xa7216061, 0x4697328e, 0x229d1c6f, 0xc32b4e80, 0xa1f6c86a, 0x40409a85, 0x60708dba, 0x81c6df55, 0xe31b59bf, 0x02ad0b50, 0x66a725b1, 0x8711775e, 0xe5ccf1b4, 0x047aa35b, 0x6cdedcad, 0x8d688e42, 0xefb508a8, 0x0e035a47, 0x6a0974a6, 0x8bbf2649, 0xe962a0a3, 0x08d4f24c, 0x782c2e94, 0x999a7c7b, 0xfb47fa91, 0x1af1a87e, 0x7efb869f, 0x9f4dd470, 0xfd90529a, 0x1c260075, 0x74827f83, 0x95342d6c, 0xf7e9ab86, 0x165ff969, 0x7255d788, 0x93e38567, 0xf13e038d, 0x10885162, 0x50c8cbe7, 0xb17e9908, 0xd3a31fe2, 0x32154d0d, 0x561f63ec, 0xb7a93103, 0xd574b7e9, 0x34c2e506, 0x5c669af0, 0xbdd0c81f, 0xdf0d4ef5, 0x3ebb1c1a, 0x5ab132fb, 0xbb076014, 0xd9dae6fe, 0x386cb411, 0x489468c9, 0xa9223a26, 0xcbffbccc, 0x2a49ee23, 0x4e43c0c2, 0xaff5922d, 0xcd2814c7, 0x2c9e4628, 0x443a39de, 0xa58c6b31, 0xc751eddb, 0x26e7bf34, 0x42ed91d5, 0xa35bc33a, 0xc18645d0, 0x2030173f, 0x81e66bae, 0x60503941, 0x028dbfab, 0xe33bed44, 0x8731c3a5, 0x6687914a, 0x045a17a0, 0xe5ec454f, 0x8d483ab9, 0x6cfe6856, 0x0e23eebc, 0xef95bc53, 0x8b9f92b2, 0x6a29c05d, 0x08f446b7, 0xe9421458, 0x99bac880, 0x780c9a6f, 0x1ad11c85, 0xfb674e6a, 0x9f6d608b, 0x7edb3264, 0x1c06b48e, 0xfdb0e661, 0x95149997, 0x74a2cb78, 0x167f4d92, 0xf7c91f7d, 0x93c3319c, 0x72756373, 0x10a8e599, 0xf11eb776, 0xb15e2df3, 0x50e87f1c, 0x3235f9f6, 0xd383ab19, 0xb78985f8, 0x563fd717, 0x34e251fd, 0xd5540312, 0xbdf07ce4, 0x5c462e0b, 0x3e9ba8e1, 0xdf2dfa0e, 0xbb27d4ef, 0x5a918600, 0x384c00ea, 0xd9fa5205, 0xa9028edd, 0x48b4dc32, 0x2a695ad8, 0xcbdf0837, 0xafd526d6, 0x4e637439, 0x2cbef2d3, 0xcd08a03c, 0xa5acdfca, 0x441a8d25, 0x26c70bcf, 0xc7715920, 0xa37b77c1, 0x42cd252e, 0x2010a3c4, 0xc1a6f12b, 0xe196e614, 0x0020b4fb, 0x62fd3211, 0x834b60fe, 0xe7414e1f, 0x06f71cf0, 0x642a9a1a, 0x859cc8f5, 0xed38b703, 0x0c8ee5ec, 0x6e536306, 0x8fe531e9, 0xebef1f08, 0x0a594de7, 0x6884cb0d, 0x893299e2, 0xf9ca453a, 0x187c17d5, 0x7aa1913f, 0x9b17c3d0, 0xff1ded31, 0x1eabbfde, 0x7c763934, 0x9dc06bdb, 0xf564142d, 0x14d246c2, 0x760fc028, 0x97b992c7, 0xf3b3bc26, 0x1205eec9, 0x70d86823, 0x916e3acc, 0xd12ea049, 0x3098f2a6, 0x5245744c, 0xb3f326a3, 0xd7f90842, 0x364f5aad, 0x5492dc47, 0xb5248ea8, 0xdd80f15e, 0x3c36a3b1, 0x5eeb255b, 0xbf5d77b4, 0xdb575955, 0x3ae10bba, 0x583c8d50, 0xb98adfbf, 0xc9720367, 0x28c45188, 0x4a19d762, 0xabaf858d, 0xcfa5ab6c, 0x2e13f983, 0x4cce7f69, 0xad782d86, 0xc5dc5270, 0x246a009f, 0x46b78675, 0xa701d49a, 0xc30bfa7b, 0x22bda894, 0x40602e7e, 0xa1d67c91}, {0x00000000, 0x5880e2d7, 0xf106b474, 0xa98656a3, 0xe20d68e9, 0xba8d8a3e, 0x130bdc9d, 0x4b8b3e4a, 0x851da109, 0xdd9d43de, 0x741b157d, 0x2c9bf7aa, 0x6710c9e0, 0x3f902b37, 0x96167d94, 0xce969f43, 0x0a3b4213, 0x52bba0c4, 0xfb3df667, 0xa3bd14b0, 0xe8362afa, 0xb0b6c82d, 0x19309e8e, 0x41b07c59, 0x8f26e31a, 0xd7a601cd, 0x7e20576e, 0x26a0b5b9, 0x6d2b8bf3, 0x35ab6924, 0x9c2d3f87, 0xc4addd50, 0x14768426, 0x4cf666f1, 0xe5703052, 0xbdf0d285, 0xf67beccf, 0xaefb0e18, 0x077d58bb, 0x5ffdba6c, 0x916b252f, 0xc9ebc7f8, 0x606d915b, 0x38ed738c, 0x73664dc6, 0x2be6af11, 0x8260f9b2, 0xdae01b65, 0x1e4dc635, 0x46cd24e2, 0xef4b7241, 0xb7cb9096, 0xfc40aedc, 0xa4c04c0b, 0x0d461aa8, 0x55c6f87f, 0x9b50673c, 0xc3d085eb, 0x6a56d348, 0x32d6319f, 0x795d0fd5, 0x21dded02, 0x885bbba1, 0xd0db5976, 0x28ec084d, 0x706cea9a, 0xd9eabc39, 0x816a5eee, 0xcae160a4, 0x92618273, 0x3be7d4d0, 0x63673607, 0xadf1a944, 0xf5714b93, 0x5cf71d30, 0x0477ffe7, 0x4ffcc1ad, 0x177c237a, 0xbefa75d9, 0xe67a970e, 0x22d74a5e, 0x7a57a889, 0xd3d1fe2a, 0x8b511cfd, 0xc0da22b7, 0x985ac060, 0x31dc96c3, 0x695c7414, 0xa7caeb57, 0xff4a0980, 0x56cc5f23, 0x0e4cbdf4, 0x45c783be, 0x1d476169, 0xb4c137ca, 0xec41d51d, 0x3c9a8c6b, 0x641a6ebc, 0xcd9c381f, 0x951cdac8, 0xde97e482, 0x86170655, 0x2f9150f6, 0x7711b221, 0xb9872d62, 0xe107cfb5, 0x48819916, 0x10017bc1, 0x5b8a458b, 0x030aa75c, 0xaa8cf1ff, 0xf20c1328, 0x36a1ce78, 0x6e212caf, 0xc7a77a0c, 0x9f2798db, 0xd4aca691, 0x8c2c4446, 0x25aa12e5, 0x7d2af032, 0xb3bc6f71, 0xeb3c8da6, 0x42badb05, 0x1a3a39d2, 0x51b10798, 0x0931e54f, 0xa0b7b3ec, 0xf837513b, 0x50d8119a, 0x0858f34d, 0xa1dea5ee, 0xf95e4739, 0xb2d57973, 0xea559ba4, 0x43d3cd07, 0x1b532fd0, 0xd5c5b093, 0x8d455244, 0x24c304e7, 0x7c43e630, 0x37c8d87a, 0x6f483aad, 0xc6ce6c0e, 0x9e4e8ed9, 0x5ae35389, 0x0263b15e, 0xabe5e7fd, 0xf365052a, 0xb8ee3b60, 0xe06ed9b7, 0x49e88f14, 0x11686dc3, 0xdffef280, 0x877e1057, 0x2ef846f4, 0x7678a423, 0x3df39a69, 0x657378be, 0xccf52e1d, 0x9475ccca, 0x44ae95bc, 0x1c2e776b, 0xb5a821c8, 0xed28c31f, 0xa6a3fd55, 0xfe231f82, 0x57a54921, 0x0f25abf6, 0xc1b334b5, 0x9933d662, 0x30b580c1, 0x68356216, 0x23be5c5c, 0x7b3ebe8b, 0xd2b8e828, 0x8a380aff, 0x4e95d7af, 0x16153578, 0xbf9363db, 0xe713810c, 0xac98bf46, 0xf4185d91, 0x5d9e0b32, 0x051ee9e5, 0xcb8876a6, 0x93089471, 0x3a8ec2d2, 0x620e2005, 0x29851e4f, 0x7105fc98, 0xd883aa3b, 0x800348ec, 0x783419d7, 0x20b4fb00, 0x8932ada3, 0xd1b24f74, 0x9a39713e, 0xc2b993e9, 0x6b3fc54a, 0x33bf279d, 0xfd29b8de, 0xa5a95a09, 0x0c2f0caa, 0x54afee7d, 0x1f24d037, 0x47a432e0, 0xee226443, 0xb6a28694, 0x720f5bc4, 0x2a8fb913, 0x8309efb0, 0xdb890d67, 0x9002332d, 0xc882d1fa, 0x61048759, 0x3984658e, 0xf712facd, 0xaf92181a, 0x06144eb9, 0x5e94ac6e, 0x151f9224, 0x4d9f70f3, 0xe4192650, 0xbc99c487, 0x6c429df1, 0x34c27f26, 0x9d442985, 0xc5c4cb52, 0x8e4ff518, 0xd6cf17cf, 0x7f49416c, 0x27c9a3bb, 0xe95f3cf8, 0xb1dfde2f, 0x1859888c, 0x40d96a5b, 0x0b525411, 0x53d2b6c6, 0xfa54e065, 0xa2d402b2, 0x6679dfe2, 0x3ef93d35, 0x977f6b96, 0xcfff8941, 0x8474b70b, 0xdcf455dc, 0x7572037f, 0x2df2e1a8, 0xe3647eeb, 0xbbe49c3c, 0x1262ca9f, 0x4ae22848, 0x01691602, 0x59e9f4d5, 0xf06fa276, 0xa8ef40a1}, {0x00000000, 0x463b6765, 0x8c76ceca, 0xca4da9af, 0x59ebed4e, 0x1fd08a2b, 0xd59d2384, 0x93a644e1, 0xb2d6db9d, 0xf4edbcf8, 0x3ea01557, 0x789b7232, 0xeb3d36d3, 0xad0651b6, 0x674bf819, 0x21709f7c, 0x25abc6e0, 0x6390a185, 0xa9dd082a, 0xefe66f4f, 0x7c402bae, 0x3a7b4ccb, 0xf036e564, 0xb60d8201, 0x977d1d7d, 0xd1467a18, 0x1b0bd3b7, 0x5d30b4d2, 0xce96f033, 0x88ad9756, 0x42e03ef9, 0x04db599c, 0x0b50fc1a, 0x4d6b9b7f, 0x872632d0, 0xc11d55b5, 0x52bb1154, 0x14807631, 0xdecddf9e, 0x98f6b8fb, 0xb9862787, 0xffbd40e2, 0x35f0e94d, 0x73cb8e28, 0xe06dcac9, 0xa656adac, 0x6c1b0403, 0x2a206366, 0x2efb3afa, 0x68c05d9f, 0xa28df430, 0xe4b69355, 0x7710d7b4, 0x312bb0d1, 0xfb66197e, 0xbd5d7e1b, 0x9c2de167, 0xda168602, 0x105b2fad, 0x566048c8, 0xc5c60c29, 0x83fd6b4c, 0x49b0c2e3, 0x0f8ba586, 0x16a0f835, 0x509b9f50, 0x9ad636ff, 0xdced519a, 0x4f4b157b, 0x0970721e, 0xc33ddbb1, 0x8506bcd4, 0xa47623a8, 0xe24d44cd, 0x2800ed62, 0x6e3b8a07, 0xfd9dcee6, 0xbba6a983, 0x71eb002c, 0x37d06749, 0x330b3ed5, 0x753059b0, 0xbf7df01f, 0xf946977a, 0x6ae0d39b, 0x2cdbb4fe, 0xe6961d51, 0xa0ad7a34, 0x81dde548, 0xc7e6822d, 0x0dab2b82, 0x4b904ce7, 0xd8360806, 0x9e0d6f63, 0x5440c6cc, 0x127ba1a9, 0x1df0042f, 0x5bcb634a, 0x9186cae5, 0xd7bdad80, 0x441be961, 0x02208e04, 0xc86d27ab, 0x8e5640ce, 0xaf26dfb2, 0xe91db8d7, 0x23501178, 0x656b761d, 0xf6cd32fc, 0xb0f65599, 0x7abbfc36, 0x3c809b53, 0x385bc2cf, 0x7e60a5aa, 0xb42d0c05, 0xf2166b60, 0x61b02f81, 0x278b48e4, 0xedc6e14b, 0xabfd862e, 0x8a8d1952, 0xccb67e37, 0x06fbd798, 0x40c0b0fd, 0xd366f41c, 0x955d9379, 0x5f103ad6, 0x192b5db3, 0x2c40f16b, 0x6a7b960e, 0xa0363fa1, 0xe60d58c4, 0x75ab1c25, 0x33907b40, 0xf9ddd2ef, 0xbfe6b58a, 0x9e962af6, 0xd8ad4d93, 0x12e0e43c, 0x54db8359, 0xc77dc7b8, 0x8146a0dd, 0x4b0b0972, 0x0d306e17, 0x09eb378b, 0x4fd050ee, 0x859df941, 0xc3a69e24, 0x5000dac5, 0x163bbda0, 0xdc76140f, 0x9a4d736a, 0xbb3dec16, 0xfd068b73, 0x374b22dc, 0x717045b9, 0xe2d60158, 0xa4ed663d, 0x6ea0cf92, 0x289ba8f7, 0x27100d71, 0x612b6a14, 0xab66c3bb, 0xed5da4de, 0x7efbe03f, 0x38c0875a, 0xf28d2ef5, 0xb4b64990, 0x95c6d6ec, 0xd3fdb189, 0x19b01826, 0x5f8b7f43, 0xcc2d3ba2, 0x8a165cc7, 0x405bf568, 0x0660920d, 0x02bbcb91, 0x4480acf4, 0x8ecd055b, 0xc8f6623e, 0x5b5026df, 0x1d6b41ba, 0xd726e815, 0x911d8f70, 0xb06d100c, 0xf6567769, 0x3c1bdec6, 0x7a20b9a3, 0xe986fd42, 0xafbd9a27, 0x65f03388, 0x23cb54ed, 0x3ae0095e, 0x7cdb6e3b, 0xb696c794, 0xf0ada0f1, 0x630be410, 0x25308375, 0xef7d2ada, 0xa9464dbf, 0x8836d2c3, 0xce0db5a6, 0x04401c09, 0x427b7b6c, 0xd1dd3f8d, 0x97e658e8, 0x5dabf147, 0x1b909622, 0x1f4bcfbe, 0x5970a8db, 0x933d0174, 0xd5066611, 0x46a022f0, 0x009b4595, 0xcad6ec3a, 0x8ced8b5f, 0xad9d1423, 0xeba67346, 0x21ebdae9, 0x67d0bd8c, 0xf476f96d, 0xb24d9e08, 0x780037a7, 0x3e3b50c2, 0x31b0f544, 0x778b9221, 0xbdc63b8e, 0xfbfd5ceb, 0x685b180a, 0x2e607f6f, 0xe42dd6c0, 0xa216b1a5, 0x83662ed9, 0xc55d49bc, 0x0f10e013, 0x492b8776, 0xda8dc397, 0x9cb6a4f2, 0x56fb0d5d, 0x10c06a38, 0x141b33a4, 0x522054c1, 0x986dfd6e, 0xde569a0b, 0x4df0deea, 0x0bcbb98f, 0xc1861020, 0x87bd7745, 0xa6cde839, 0xe0f68f5c, 0x2abb26f3, 0x6c804196, 0xff260577, 0xb91d6212, 0x7350cbbd, 0x356bacd8}}; #endif #endif #if N == 6 #if W == 8 local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0x3db1ecdc, 0x7b63d9b8, 0x46d23564, 0xf6c7b370, 0xcb765fac, 0x8da46ac8, 0xb0158614, 0x36fe60a1, 0x0b4f8c7d, 0x4d9db919, 0x702c55c5, 0xc039d3d1, 0xfd883f0d, 0xbb5a0a69, 0x86ebe6b5, 0x6dfcc142, 0x504d2d9e, 0x169f18fa, 0x2b2ef426, 0x9b3b7232, 0xa68a9eee, 0xe058ab8a, 0xdde94756, 0x5b02a1e3, 0x66b34d3f, 0x2061785b, 0x1dd09487, 0xadc51293, 0x9074fe4f, 0xd6a6cb2b, 0xeb1727f7, 0xdbf98284, 0xe6486e58, 0xa09a5b3c, 0x9d2bb7e0, 0x2d3e31f4, 0x108fdd28, 0x565de84c, 0x6bec0490, 0xed07e225, 0xd0b60ef9, 0x96643b9d, 0xabd5d741, 0x1bc05155, 0x2671bd89, 0x60a388ed, 0x5d126431, 0xb60543c6, 0x8bb4af1a, 0xcd669a7e, 0xf0d776a2, 0x40c2f0b6, 0x7d731c6a, 0x3ba1290e, 0x0610c5d2, 0x80fb2367, 0xbd4acfbb, 0xfb98fadf, 0xc6291603, 0x763c9017, 0x4b8d7ccb, 0x0d5f49af, 0x30eea573, 0x6c820349, 0x5133ef95, 0x17e1daf1, 0x2a50362d, 0x9a45b039, 0xa7f45ce5, 0xe1266981, 0xdc97855d, 0x5a7c63e8, 0x67cd8f34, 0x211fba50, 0x1cae568c, 0xacbbd098, 0x910a3c44, 0xd7d80920, 0xea69e5fc, 0x017ec20b, 0x3ccf2ed7, 0x7a1d1bb3, 0x47acf76f, 0xf7b9717b, 0xca089da7, 0x8cdaa8c3, 0xb16b441f, 0x3780a2aa, 0x0a314e76, 0x4ce37b12, 0x715297ce, 0xc14711da, 0xfcf6fd06, 0xba24c862, 0x879524be, 0xb77b81cd, 0x8aca6d11, 0xcc185875, 0xf1a9b4a9, 0x41bc32bd, 0x7c0dde61, 0x3adfeb05, 0x076e07d9, 0x8185e16c, 0xbc340db0, 0xfae638d4, 0xc757d408, 0x7742521c, 0x4af3bec0, 0x0c218ba4, 0x31906778, 0xda87408f, 0xe736ac53, 0xa1e49937, 0x9c5575eb, 0x2c40f3ff, 0x11f11f23, 0x57232a47, 0x6a92c69b, 0xec79202e, 0xd1c8ccf2, 0x971af996, 0xaaab154a, 0x1abe935e, 0x270f7f82, 0x61dd4ae6, 0x5c6ca63a, 0xd9040692, 0xe4b5ea4e, 0xa267df2a, 0x9fd633f6, 0x2fc3b5e2, 0x1272593e, 0x54a06c5a, 0x69118086, 0xeffa6633, 0xd24b8aef, 0x9499bf8b, 0xa9285357, 0x193dd543, 0x248c399f, 0x625e0cfb, 0x5fefe027, 0xb4f8c7d0, 0x89492b0c, 0xcf9b1e68, 0xf22af2b4, 0x423f74a0, 0x7f8e987c, 0x395cad18, 0x04ed41c4, 0x8206a771, 0xbfb74bad, 0xf9657ec9, 0xc4d49215, 0x74c11401, 0x4970f8dd, 0x0fa2cdb9, 0x32132165, 0x02fd8416, 0x3f4c68ca, 0x799e5dae, 0x442fb172, 0xf43a3766, 0xc98bdbba, 0x8f59eede, 0xb2e80202, 0x3403e4b7, 0x09b2086b, 0x4f603d0f, 0x72d1d1d3, 0xc2c457c7, 0xff75bb1b, 0xb9a78e7f, 0x841662a3, 0x6f014554, 0x52b0a988, 0x14629cec, 0x29d37030, 0x99c6f624, 0xa4771af8, 0xe2a52f9c, 0xdf14c340, 0x59ff25f5, 0x644ec929, 0x229cfc4d, 0x1f2d1091, 0xaf389685, 0x92897a59, 0xd45b4f3d, 0xe9eaa3e1, 0xb58605db, 0x8837e907, 0xcee5dc63, 0xf35430bf, 0x4341b6ab, 0x7ef05a77, 0x38226f13, 0x059383cf, 0x8378657a, 0xbec989a6, 0xf81bbcc2, 0xc5aa501e, 0x75bfd60a, 0x480e3ad6, 0x0edc0fb2, 0x336de36e, 0xd87ac499, 0xe5cb2845, 0xa3191d21, 0x9ea8f1fd, 0x2ebd77e9, 0x130c9b35, 0x55deae51, 0x686f428d, 0xee84a438, 0xd33548e4, 0x95e77d80, 0xa856915c, 0x18431748, 0x25f2fb94, 0x6320cef0, 0x5e91222c, 0x6e7f875f, 0x53ce6b83, 0x151c5ee7, 0x28adb23b, 0x98b8342f, 0xa509d8f3, 0xe3dbed97, 0xde6a014b, 0x5881e7fe, 0x65300b22, 0x23e23e46, 0x1e53d29a, 0xae46548e, 0x93f7b852, 0xd5258d36, 0xe89461ea, 0x0383461d, 0x3e32aac1, 0x78e09fa5, 0x45517379, 0xf544f56d, 0xc8f519b1, 0x8e272cd5, 0xb396c009, 0x357d26bc, 0x08ccca60, 0x4e1eff04, 0x73af13d8, 0xc3ba95cc, 0xfe0b7910, 0xb8d94c74, 0x8568a0a8}, {0x00000000, 0x69790b65, 0xd2f216ca, 0xbb8b1daf, 0x7e952bd5, 0x17ec20b0, 0xac673d1f, 0xc51e367a, 0xfd2a57aa, 0x94535ccf, 0x2fd84160, 0x46a14a05, 0x83bf7c7f, 0xeac6771a, 0x514d6ab5, 0x383461d0, 0x2125a915, 0x485ca270, 0xf3d7bfdf, 0x9aaeb4ba, 0x5fb082c0, 0x36c989a5, 0x8d42940a, 0xe43b9f6f, 0xdc0ffebf, 0xb576f5da, 0x0efde875, 0x6784e310, 0xa29ad56a, 0xcbe3de0f, 0x7068c3a0, 0x1911c8c5, 0x424b522a, 0x2b32594f, 0x90b944e0, 0xf9c04f85, 0x3cde79ff, 0x55a7729a, 0xee2c6f35, 0x87556450, 0xbf610580, 0xd6180ee5, 0x6d93134a, 0x04ea182f, 0xc1f42e55, 0xa88d2530, 0x1306389f, 0x7a7f33fa, 0x636efb3f, 0x0a17f05a, 0xb19cedf5, 0xd8e5e690, 0x1dfbd0ea, 0x7482db8f, 0xcf09c620, 0xa670cd45, 0x9e44ac95, 0xf73da7f0, 0x4cb6ba5f, 0x25cfb13a, 0xe0d18740, 0x89a88c25, 0x3223918a, 0x5b5a9aef, 0x8496a454, 0xedefaf31, 0x5664b29e, 0x3f1db9fb, 0xfa038f81, 0x937a84e4, 0x28f1994b, 0x4188922e, 0x79bcf3fe, 0x10c5f89b, 0xab4ee534, 0xc237ee51, 0x0729d82b, 0x6e50d34e, 0xd5dbcee1, 0xbca2c584, 0xa5b30d41, 0xccca0624, 0x77411b8b, 0x1e3810ee, 0xdb262694, 0xb25f2df1, 0x09d4305e, 0x60ad3b3b, 0x58995aeb, 0x31e0518e, 0x8a6b4c21, 0xe3124744, 0x260c713e, 0x4f757a5b, 0xf4fe67f4, 0x9d876c91, 0xc6ddf67e, 0xafa4fd1b, 0x142fe0b4, 0x7d56ebd1, 0xb848ddab, 0xd131d6ce, 0x6abacb61, 0x03c3c004, 0x3bf7a1d4, 0x528eaab1, 0xe905b71e, 0x807cbc7b, 0x45628a01, 0x2c1b8164, 0x97909ccb, 0xfee997ae, 0xe7f85f6b, 0x8e81540e, 0x350a49a1, 0x5c7342c4, 0x996d74be, 0xf0147fdb, 0x4b9f6274, 0x22e66911, 0x1ad208c1, 0x73ab03a4, 0xc8201e0b, 0xa159156e, 0x64472314, 0x0d3e2871, 0xb6b535de, 0xdfcc3ebb, 0xd25c4ee9, 0xbb25458c, 0x00ae5823, 0x69d75346, 0xacc9653c, 0xc5b06e59, 0x7e3b73f6, 0x17427893, 0x2f761943, 0x460f1226, 0xfd840f89, 0x94fd04ec, 0x51e33296, 0x389a39f3, 0x8311245c, 0xea682f39, 0xf379e7fc, 0x9a00ec99, 0x218bf136, 0x48f2fa53, 0x8deccc29, 0xe495c74c, 0x5f1edae3, 0x3667d186, 0x0e53b056, 0x672abb33, 0xdca1a69c, 0xb5d8adf9, 0x70c69b83, 0x19bf90e6, 0xa2348d49, 0xcb4d862c, 0x90171cc3, 0xf96e17a6, 0x42e50a09, 0x2b9c016c, 0xee823716, 0x87fb3c73, 0x3c7021dc, 0x55092ab9, 0x6d3d4b69, 0x0444400c, 0xbfcf5da3, 0xd6b656c6, 0x13a860bc, 0x7ad16bd9, 0xc15a7676, 0xa8237d13, 0xb132b5d6, 0xd84bbeb3, 0x63c0a31c, 0x0ab9a879, 0xcfa79e03, 0xa6de9566, 0x1d5588c9, 0x742c83ac, 0x4c18e27c, 0x2561e919, 0x9eeaf4b6, 0xf793ffd3, 0x328dc9a9, 0x5bf4c2cc, 0xe07fdf63, 0x8906d406, 0x56caeabd, 0x3fb3e1d8, 0x8438fc77, 0xed41f712, 0x285fc168, 0x4126ca0d, 0xfaadd7a2, 0x93d4dcc7, 0xabe0bd17, 0xc299b672, 0x7912abdd, 0x106ba0b8, 0xd57596c2, 0xbc0c9da7, 0x07878008, 0x6efe8b6d, 0x77ef43a8, 0x1e9648cd, 0xa51d5562, 0xcc645e07, 0x097a687d, 0x60036318, 0xdb887eb7, 0xb2f175d2, 0x8ac51402, 0xe3bc1f67, 0x583702c8, 0x314e09ad, 0xf4503fd7, 0x9d2934b2, 0x26a2291d, 0x4fdb2278, 0x1481b897, 0x7df8b3f2, 0xc673ae5d, 0xaf0aa538, 0x6a149342, 0x036d9827, 0xb8e68588, 0xd19f8eed, 0xe9abef3d, 0x80d2e458, 0x3b59f9f7, 0x5220f292, 0x973ec4e8, 0xfe47cf8d, 0x45ccd222, 0x2cb5d947, 0x35a41182, 0x5cdd1ae7, 0xe7560748, 0x8e2f0c2d, 0x4b313a57, 0x22483132, 0x99c32c9d, 0xf0ba27f8, 0xc88e4628, 0xa1f74d4d, 0x1a7c50e2, 0x73055b87, 0xb61b6dfd, 0xdf626698, 0x64e97b37, 0x0d907052}, {0x00000000, 0x7fc99b93, 0xff933726, 0x805aacb5, 0x2457680d, 0x5b9ef39e, 0xdbc45f2b, 0xa40dc4b8, 0x48aed01a, 0x37674b89, 0xb73de73c, 0xc8f47caf, 0x6cf9b817, 0x13302384, 0x936a8f31, 0xeca314a2, 0x915da034, 0xee943ba7, 0x6ece9712, 0x11070c81, 0xb50ac839, 0xcac353aa, 0x4a99ff1f, 0x3550648c, 0xd9f3702e, 0xa63aebbd, 0x26604708, 0x59a9dc9b, 0xfda41823, 0x826d83b0, 0x02372f05, 0x7dfeb496, 0xf9ca4629, 0x8603ddba, 0x0659710f, 0x7990ea9c, 0xdd9d2e24, 0xa254b5b7, 0x220e1902, 0x5dc78291, 0xb1649633, 0xcead0da0, 0x4ef7a115, 0x313e3a86, 0x9533fe3e, 0xeafa65ad, 0x6aa0c918, 0x1569528b, 0x6897e61d, 0x175e7d8e, 0x9704d13b, 0xe8cd4aa8, 0x4cc08e10, 0x33091583, 0xb353b936, 0xcc9a22a5, 0x20393607, 0x5ff0ad94, 0xdfaa0121, 0xa0639ab2, 0x046e5e0a, 0x7ba7c599, 0xfbfd692c, 0x8434f2bf, 0x28e58a13, 0x572c1180, 0xd776bd35, 0xa8bf26a6, 0x0cb2e21e, 0x737b798d, 0xf321d538, 0x8ce84eab, 0x604b5a09, 0x1f82c19a, 0x9fd86d2f, 0xe011f6bc, 0x441c3204, 0x3bd5a997, 0xbb8f0522, 0xc4469eb1, 0xb9b82a27, 0xc671b1b4, 0x462b1d01, 0x39e28692, 0x9def422a, 0xe226d9b9, 0x627c750c, 0x1db5ee9f, 0xf116fa3d, 0x8edf61ae, 0x0e85cd1b, 0x714c5688, 0xd5419230, 0xaa8809a3, 0x2ad2a516, 0x551b3e85, 0xd12fcc3a, 0xaee657a9, 0x2ebcfb1c, 0x5175608f, 0xf578a437, 0x8ab13fa4, 0x0aeb9311, 0x75220882, 0x99811c20, 0xe64887b3, 0x66122b06, 0x19dbb095, 0xbdd6742d, 0xc21fefbe, 0x4245430b, 0x3d8cd898, 0x40726c0e, 0x3fbbf79d, 0xbfe15b28, 0xc028c0bb, 0x64250403, 0x1bec9f90, 0x9bb63325, 0xe47fa8b6, 0x08dcbc14, 0x77152787, 0xf74f8b32, 0x888610a1, 0x2c8bd419, 0x53424f8a, 0xd318e33f, 0xacd178ac, 0x51cb1426, 0x2e028fb5, 0xae582300, 0xd191b893, 0x759c7c2b, 0x0a55e7b8, 0x8a0f4b0d, 0xf5c6d09e, 0x1965c43c, 0x66ac5faf, 0xe6f6f31a, 0x993f6889, 0x3d32ac31, 0x42fb37a2, 0xc2a19b17, 0xbd680084, 0xc096b412, 0xbf5f2f81, 0x3f058334, 0x40cc18a7, 0xe4c1dc1f, 0x9b08478c, 0x1b52eb39, 0x649b70aa, 0x88386408, 0xf7f1ff9b, 0x77ab532e, 0x0862c8bd, 0xac6f0c05, 0xd3a69796, 0x53fc3b23, 0x2c35a0b0, 0xa801520f, 0xd7c8c99c, 0x57926529, 0x285bfeba, 0x8c563a02, 0xf39fa191, 0x73c50d24, 0x0c0c96b7, 0xe0af8215, 0x9f661986, 0x1f3cb533, 0x60f52ea0, 0xc4f8ea18, 0xbb31718b, 0x3b6bdd3e, 0x44a246ad, 0x395cf23b, 0x469569a8, 0xc6cfc51d, 0xb9065e8e, 0x1d0b9a36, 0x62c201a5, 0xe298ad10, 0x9d513683, 0x71f22221, 0x0e3bb9b2, 0x8e611507, 0xf1a88e94, 0x55a54a2c, 0x2a6cd1bf, 0xaa367d0a, 0xd5ffe699, 0x792e9e35, 0x06e705a6, 0x86bda913, 0xf9743280, 0x5d79f638, 0x22b06dab, 0xa2eac11e, 0xdd235a8d, 0x31804e2f, 0x4e49d5bc, 0xce137909, 0xb1dae29a, 0x15d72622, 0x6a1ebdb1, 0xea441104, 0x958d8a97, 0xe8733e01, 0x97baa592, 0x17e00927, 0x682992b4, 0xcc24560c, 0xb3edcd9f, 0x33b7612a, 0x4c7efab9, 0xa0ddee1b, 0xdf147588, 0x5f4ed93d, 0x208742ae, 0x848a8616, 0xfb431d85, 0x7b19b130, 0x04d02aa3, 0x80e4d81c, 0xff2d438f, 0x7f77ef3a, 0x00be74a9, 0xa4b3b011, 0xdb7a2b82, 0x5b208737, 0x24e91ca4, 0xc84a0806, 0xb7839395, 0x37d93f20, 0x4810a4b3, 0xec1d600b, 0x93d4fb98, 0x138e572d, 0x6c47ccbe, 0x11b97828, 0x6e70e3bb, 0xee2a4f0e, 0x91e3d49d, 0x35ee1025, 0x4a278bb6, 0xca7d2703, 0xb5b4bc90, 0x5917a832, 0x26de33a1, 0xa6849f14, 0xd94d0487, 0x7d40c03f, 0x02895bac, 0x82d3f719, 0xfd1a6c8a}, {0x00000000, 0xa396284c, 0x9c5d56d9, 0x3fcb7e95, 0xe3cbabf3, 0x405d83bf, 0x7f96fd2a, 0xdc00d566, 0x1ce651a7, 0xbf7079eb, 0x80bb077e, 0x232d2f32, 0xff2dfa54, 0x5cbbd218, 0x6370ac8d, 0xc0e684c1, 0x39cca34e, 0x9a5a8b02, 0xa591f597, 0x0607dddb, 0xda0708bd, 0x799120f1, 0x465a5e64, 0xe5cc7628, 0x252af2e9, 0x86bcdaa5, 0xb977a430, 0x1ae18c7c, 0xc6e1591a, 0x65777156, 0x5abc0fc3, 0xf92a278f, 0x7399469c, 0xd00f6ed0, 0xefc41045, 0x4c523809, 0x9052ed6f, 0x33c4c523, 0x0c0fbbb6, 0xaf9993fa, 0x6f7f173b, 0xcce93f77, 0xf32241e2, 0x50b469ae, 0x8cb4bcc8, 0x2f229484, 0x10e9ea11, 0xb37fc25d, 0x4a55e5d2, 0xe9c3cd9e, 0xd608b30b, 0x759e9b47, 0xa99e4e21, 0x0a08666d, 0x35c318f8, 0x965530b4, 0x56b3b475, 0xf5259c39, 0xcaeee2ac, 0x6978cae0, 0xb5781f86, 0x16ee37ca, 0x2925495f, 0x8ab36113, 0xe7328d38, 0x44a4a574, 0x7b6fdbe1, 0xd8f9f3ad, 0x04f926cb, 0xa76f0e87, 0x98a47012, 0x3b32585e, 0xfbd4dc9f, 0x5842f4d3, 0x67898a46, 0xc41fa20a, 0x181f776c, 0xbb895f20, 0x844221b5, 0x27d409f9, 0xdefe2e76, 0x7d68063a, 0x42a378af, 0xe13550e3, 0x3d358585, 0x9ea3adc9, 0xa168d35c, 0x02fefb10, 0xc2187fd1, 0x618e579d, 0x5e452908, 0xfdd30144, 0x21d3d422, 0x8245fc6e, 0xbd8e82fb, 0x1e18aab7, 0x94abcba4, 0x373de3e8, 0x08f69d7d, 0xab60b531, 0x77606057, 0xd4f6481b, 0xeb3d368e, 0x48ab1ec2, 0x884d9a03, 0x2bdbb24f, 0x1410ccda, 0xb786e496, 0x6b8631f0, 0xc81019bc, 0xf7db6729, 0x544d4f65, 0xad6768ea, 0x0ef140a6, 0x313a3e33, 0x92ac167f, 0x4eacc319, 0xed3aeb55, 0xd2f195c0, 0x7167bd8c, 0xb181394d, 0x12171101, 0x2ddc6f94, 0x8e4a47d8, 0x524a92be, 0xf1dcbaf2, 0xce17c467, 0x6d81ec2b, 0x15141c31, 0xb682347d, 0x89494ae8, 0x2adf62a4, 0xf6dfb7c2, 0x55499f8e, 0x6a82e11b, 0xc914c957, 0x09f24d96, 0xaa6465da, 0x95af1b4f, 0x36393303, 0xea39e665, 0x49afce29, 0x7664b0bc, 0xd5f298f0, 0x2cd8bf7f, 0x8f4e9733, 0xb085e9a6, 0x1313c1ea, 0xcf13148c, 0x6c853cc0, 0x534e4255, 0xf0d86a19, 0x303eeed8, 0x93a8c694, 0xac63b801, 0x0ff5904d, 0xd3f5452b, 0x70636d67, 0x4fa813f2, 0xec3e3bbe, 0x668d5aad, 0xc51b72e1, 0xfad00c74, 0x59462438, 0x8546f15e, 0x26d0d912, 0x191ba787, 0xba8d8fcb, 0x7a6b0b0a, 0xd9fd2346, 0xe6365dd3, 0x45a0759f, 0x99a0a0f9, 0x3a3688b5, 0x05fdf620, 0xa66bde6c, 0x5f41f9e3, 0xfcd7d1af, 0xc31caf3a, 0x608a8776, 0xbc8a5210, 0x1f1c7a5c, 0x20d704c9, 0x83412c85, 0x43a7a844, 0xe0318008, 0xdffafe9d, 0x7c6cd6d1, 0xa06c03b7, 0x03fa2bfb, 0x3c31556e, 0x9fa77d22, 0xf2269109, 0x51b0b945, 0x6e7bc7d0, 0xcdedef9c, 0x11ed3afa, 0xb27b12b6, 0x8db06c23, 0x2e26446f, 0xeec0c0ae, 0x4d56e8e2, 0x729d9677, 0xd10bbe3b, 0x0d0b6b5d, 0xae9d4311, 0x91563d84, 0x32c015c8, 0xcbea3247, 0x687c1a0b, 0x57b7649e, 0xf4214cd2, 0x282199b4, 0x8bb7b1f8, 0xb47ccf6d, 0x17eae721, 0xd70c63e0, 0x749a4bac, 0x4b513539, 0xe8c71d75, 0x34c7c813, 0x9751e05f, 0xa89a9eca, 0x0b0cb686, 0x81bfd795, 0x2229ffd9, 0x1de2814c, 0xbe74a900, 0x62747c66, 0xc1e2542a, 0xfe292abf, 0x5dbf02f3, 0x9d598632, 0x3ecfae7e, 0x0104d0eb, 0xa292f8a7, 0x7e922dc1, 0xdd04058d, 0xe2cf7b18, 0x41595354, 0xb87374db, 0x1be55c97, 0x242e2202, 0x87b80a4e, 0x5bb8df28, 0xf82ef764, 0xc7e589f1, 0x6473a1bd, 0xa495257c, 0x07030d30, 0x38c873a5, 0x9b5e5be9, 0x475e8e8f, 0xe4c8a6c3, 0xdb03d856, 0x7895f01a}, {0x00000000, 0x2a283862, 0x545070c4, 0x7e7848a6, 0xa8a0e188, 0x8288d9ea, 0xfcf0914c, 0xd6d8a92e, 0x8a30c551, 0xa018fd33, 0xde60b595, 0xf4488df7, 0x229024d9, 0x08b81cbb, 0x76c0541d, 0x5ce86c7f, 0xcf108ce3, 0xe538b481, 0x9b40fc27, 0xb168c445, 0x67b06d6b, 0x4d985509, 0x33e01daf, 0x19c825cd, 0x452049b2, 0x6f0871d0, 0x11703976, 0x3b580114, 0xed80a83a, 0xc7a89058, 0xb9d0d8fe, 0x93f8e09c, 0x45501f87, 0x6f7827e5, 0x11006f43, 0x3b285721, 0xedf0fe0f, 0xc7d8c66d, 0xb9a08ecb, 0x9388b6a9, 0xcf60dad6, 0xe548e2b4, 0x9b30aa12, 0xb1189270, 0x67c03b5e, 0x4de8033c, 0x33904b9a, 0x19b873f8, 0x8a409364, 0xa068ab06, 0xde10e3a0, 0xf438dbc2, 0x22e072ec, 0x08c84a8e, 0x76b00228, 0x5c983a4a, 0x00705635, 0x2a586e57, 0x542026f1, 0x7e081e93, 0xa8d0b7bd, 0x82f88fdf, 0xfc80c779, 0xd6a8ff1b, 0x8aa03f0e, 0xa088076c, 0xdef04fca, 0xf4d877a8, 0x2200de86, 0x0828e6e4, 0x7650ae42, 0x5c789620, 0x0090fa5f, 0x2ab8c23d, 0x54c08a9b, 0x7ee8b2f9, 0xa8301bd7, 0x821823b5, 0xfc606b13, 0xd6485371, 0x45b0b3ed, 0x6f988b8f, 0x11e0c329, 0x3bc8fb4b, 0xed105265, 0xc7386a07, 0xb94022a1, 0x93681ac3, 0xcf8076bc, 0xe5a84ede, 0x9bd00678, 0xb1f83e1a, 0x67209734, 0x4d08af56, 0x3370e7f0, 0x1958df92, 0xcff02089, 0xe5d818eb, 0x9ba0504d, 0xb188682f, 0x6750c101, 0x4d78f963, 0x3300b1c5, 0x192889a7, 0x45c0e5d8, 0x6fe8ddba, 0x1190951c, 0x3bb8ad7e, 0xed600450, 0xc7483c32, 0xb9307494, 0x93184cf6, 0x00e0ac6a, 0x2ac89408, 0x54b0dcae, 0x7e98e4cc, 0xa8404de2, 0x82687580, 0xfc103d26, 0xd6380544, 0x8ad0693b, 0xa0f85159, 0xde8019ff, 0xf4a8219d, 0x227088b3, 0x0858b0d1, 0x7620f877, 0x5c08c015, 0xce31785d, 0xe419403f, 0x9a610899, 0xb04930fb, 0x669199d5, 0x4cb9a1b7, 0x32c1e911, 0x18e9d173, 0x4401bd0c, 0x6e29856e, 0x1051cdc8, 0x3a79f5aa, 0xeca15c84, 0xc68964e6, 0xb8f12c40, 0x92d91422, 0x0121f4be, 0x2b09ccdc, 0x5571847a, 0x7f59bc18, 0xa9811536, 0x83a92d54, 0xfdd165f2, 0xd7f95d90, 0x8b1131ef, 0xa139098d, 0xdf41412b, 0xf5697949, 0x23b1d067, 0x0999e805, 0x77e1a0a3, 0x5dc998c1, 0x8b6167da, 0xa1495fb8, 0xdf31171e, 0xf5192f7c, 0x23c18652, 0x09e9be30, 0x7791f696, 0x5db9cef4, 0x0151a28b, 0x2b799ae9, 0x5501d24f, 0x7f29ea2d, 0xa9f14303, 0x83d97b61, 0xfda133c7, 0xd7890ba5, 0x4471eb39, 0x6e59d35b, 0x10219bfd, 0x3a09a39f, 0xecd10ab1, 0xc6f932d3, 0xb8817a75, 0x92a94217, 0xce412e68, 0xe469160a, 0x9a115eac, 0xb03966ce, 0x66e1cfe0, 0x4cc9f782, 0x32b1bf24, 0x18998746, 0x44914753, 0x6eb97f31, 0x10c13797, 0x3ae90ff5, 0xec31a6db, 0xc6199eb9, 0xb861d61f, 0x9249ee7d, 0xcea18202, 0xe489ba60, 0x9af1f2c6, 0xb0d9caa4, 0x6601638a, 0x4c295be8, 0x3251134e, 0x18792b2c, 0x8b81cbb0, 0xa1a9f3d2, 0xdfd1bb74, 0xf5f98316, 0x23212a38, 0x0909125a, 0x77715afc, 0x5d59629e, 0x01b10ee1, 0x2b993683, 0x55e17e25, 0x7fc94647, 0xa911ef69, 0x8339d70b, 0xfd419fad, 0xd769a7cf, 0x01c158d4, 0x2be960b6, 0x55912810, 0x7fb91072, 0xa961b95c, 0x8349813e, 0xfd31c998, 0xd719f1fa, 0x8bf19d85, 0xa1d9a5e7, 0xdfa1ed41, 0xf589d523, 0x23517c0d, 0x0979446f, 0x77010cc9, 0x5d2934ab, 0xced1d437, 0xe4f9ec55, 0x9a81a4f3, 0xb0a99c91, 0x667135bf, 0x4c590ddd, 0x3221457b, 0x18097d19, 0x44e11166, 0x6ec92904, 0x10b161a2, 0x3a9959c0, 0xec41f0ee, 0xc669c88c, 0xb811802a, 0x9239b848}, {0x00000000, 0x4713f6fb, 0x8e27edf6, 0xc9341b0d, 0xc73eddad, 0x802d2b56, 0x4919305b, 0x0e0ac6a0, 0x550cbd1b, 0x121f4be0, 0xdb2b50ed, 0x9c38a616, 0x923260b6, 0xd521964d, 0x1c158d40, 0x5b067bbb, 0xaa197a36, 0xed0a8ccd, 0x243e97c0, 0x632d613b, 0x6d27a79b, 0x2a345160, 0xe3004a6d, 0xa413bc96, 0xff15c72d, 0xb80631d6, 0x71322adb, 0x3621dc20, 0x382b1a80, 0x7f38ec7b, 0xb60cf776, 0xf11f018d, 0x8f43f22d, 0xc85004d6, 0x01641fdb, 0x4677e920, 0x487d2f80, 0x0f6ed97b, 0xc65ac276, 0x8149348d, 0xda4f4f36, 0x9d5cb9cd, 0x5468a2c0, 0x137b543b, 0x1d71929b, 0x5a626460, 0x93567f6d, 0xd4458996, 0x255a881b, 0x62497ee0, 0xab7d65ed, 0xec6e9316, 0xe26455b6, 0xa577a34d, 0x6c43b840, 0x2b504ebb, 0x70563500, 0x3745c3fb, 0xfe71d8f6, 0xb9622e0d, 0xb768e8ad, 0xf07b1e56, 0x394f055b, 0x7e5cf3a0, 0xc5f6e21b, 0x82e514e0, 0x4bd10fed, 0x0cc2f916, 0x02c83fb6, 0x45dbc94d, 0x8cefd240, 0xcbfc24bb, 0x90fa5f00, 0xd7e9a9fb, 0x1eddb2f6, 0x59ce440d, 0x57c482ad, 0x10d77456, 0xd9e36f5b, 0x9ef099a0, 0x6fef982d, 0x28fc6ed6, 0xe1c875db, 0xa6db8320, 0xa8d14580, 0xefc2b37b, 0x26f6a876, 0x61e55e8d, 0x3ae32536, 0x7df0d3cd, 0xb4c4c8c0, 0xf3d73e3b, 0xfdddf89b, 0xbace0e60, 0x73fa156d, 0x34e9e396, 0x4ab51036, 0x0da6e6cd, 0xc492fdc0, 0x83810b3b, 0x8d8bcd9b, 0xca983b60, 0x03ac206d, 0x44bfd696, 0x1fb9ad2d, 0x58aa5bd6, 0x919e40db, 0xd68db620, 0xd8877080, 0x9f94867b, 0x56a09d76, 0x11b36b8d, 0xe0ac6a00, 0xa7bf9cfb, 0x6e8b87f6, 0x2998710d, 0x2792b7ad, 0x60814156, 0xa9b55a5b, 0xeea6aca0, 0xb5a0d71b, 0xf2b321e0, 0x3b873aed, 0x7c94cc16, 0x729e0ab6, 0x358dfc4d, 0xfcb9e740, 0xbbaa11bb, 0x509cc277, 0x178f348c, 0xdebb2f81, 0x99a8d97a, 0x97a21fda, 0xd0b1e921, 0x1985f22c, 0x5e9604d7, 0x05907f6c, 0x42838997, 0x8bb7929a, 0xcca46461, 0xc2aea2c1, 0x85bd543a, 0x4c894f37, 0x0b9ab9cc, 0xfa85b841, 0xbd964eba, 0x74a255b7, 0x33b1a34c, 0x3dbb65ec, 0x7aa89317, 0xb39c881a, 0xf48f7ee1, 0xaf89055a, 0xe89af3a1, 0x21aee8ac, 0x66bd1e57, 0x68b7d8f7, 0x2fa42e0c, 0xe6903501, 0xa183c3fa, 0xdfdf305a, 0x98ccc6a1, 0x51f8ddac, 0x16eb2b57, 0x18e1edf7, 0x5ff21b0c, 0x96c60001, 0xd1d5f6fa, 0x8ad38d41, 0xcdc07bba, 0x04f460b7, 0x43e7964c, 0x4ded50ec, 0x0afea617, 0xc3cabd1a, 0x84d94be1, 0x75c64a6c, 0x32d5bc97, 0xfbe1a79a, 0xbcf25161, 0xb2f897c1, 0xf5eb613a, 0x3cdf7a37, 0x7bcc8ccc, 0x20caf777, 0x67d9018c, 0xaeed1a81, 0xe9feec7a, 0xe7f42ada, 0xa0e7dc21, 0x69d3c72c, 0x2ec031d7, 0x956a206c, 0xd279d697, 0x1b4dcd9a, 0x5c5e3b61, 0x5254fdc1, 0x15470b3a, 0xdc731037, 0x9b60e6cc, 0xc0669d77, 0x87756b8c, 0x4e417081, 0x0952867a, 0x075840da, 0x404bb621, 0x897fad2c, 0xce6c5bd7, 0x3f735a5a, 0x7860aca1, 0xb154b7ac, 0xf6474157, 0xf84d87f7, 0xbf5e710c, 0x766a6a01, 0x31799cfa, 0x6a7fe741, 0x2d6c11ba, 0xe4580ab7, 0xa34bfc4c, 0xad413aec, 0xea52cc17, 0x2366d71a, 0x647521e1, 0x1a29d241, 0x5d3a24ba, 0x940e3fb7, 0xd31dc94c, 0xdd170fec, 0x9a04f917, 0x5330e21a, 0x142314e1, 0x4f256f5a, 0x083699a1, 0xc10282ac, 0x86117457, 0x881bb2f7, 0xcf08440c, 0x063c5f01, 0x412fa9fa, 0xb030a877, 0xf7235e8c, 0x3e174581, 0x7904b37a, 0x770e75da, 0x301d8321, 0xf929982c, 0xbe3a6ed7, 0xe53c156c, 0xa22fe397, 0x6b1bf89a, 0x2c080e61, 0x2202c8c1, 0x65113e3a, 0xac252537, 0xeb36d3cc}, {0x00000000, 0xa13984ee, 0x99020f9d, 0x383b8b73, 0xe975197b, 0x484c9d95, 0x707716e6, 0xd14e9208, 0x099b34b7, 0xa8a2b059, 0x90993b2a, 0x31a0bfc4, 0xe0ee2dcc, 0x41d7a922, 0x79ec2251, 0xd8d5a6bf, 0x1336696e, 0xb20fed80, 0x8a3466f3, 0x2b0de21d, 0xfa437015, 0x5b7af4fb, 0x63417f88, 0xc278fb66, 0x1aad5dd9, 0xbb94d937, 0x83af5244, 0x2296d6aa, 0xf3d844a2, 0x52e1c04c, 0x6ada4b3f, 0xcbe3cfd1, 0x266cd2dc, 0x87555632, 0xbf6edd41, 0x1e5759af, 0xcf19cba7, 0x6e204f49, 0x561bc43a, 0xf72240d4, 0x2ff7e66b, 0x8ece6285, 0xb6f5e9f6, 0x17cc6d18, 0xc682ff10, 0x67bb7bfe, 0x5f80f08d, 0xfeb97463, 0x355abbb2, 0x94633f5c, 0xac58b42f, 0x0d6130c1, 0xdc2fa2c9, 0x7d162627, 0x452dad54, 0xe41429ba, 0x3cc18f05, 0x9df80beb, 0xa5c38098, 0x04fa0476, 0xd5b4967e, 0x748d1290, 0x4cb699e3, 0xed8f1d0d, 0x4cd9a5b8, 0xede02156, 0xd5dbaa25, 0x74e22ecb, 0xa5acbcc3, 0x0495382d, 0x3caeb35e, 0x9d9737b0, 0x4542910f, 0xe47b15e1, 0xdc409e92, 0x7d791a7c, 0xac378874, 0x0d0e0c9a, 0x353587e9, 0x940c0307, 0x5fefccd6, 0xfed64838, 0xc6edc34b, 0x67d447a5, 0xb69ad5ad, 0x17a35143, 0x2f98da30, 0x8ea15ede, 0x5674f861, 0xf74d7c8f, 0xcf76f7fc, 0x6e4f7312, 0xbf01e11a, 0x1e3865f4, 0x2603ee87, 0x873a6a69, 0x6ab57764, 0xcb8cf38a, 0xf3b778f9, 0x528efc17, 0x83c06e1f, 0x22f9eaf1, 0x1ac26182, 0xbbfbe56c, 0x632e43d3, 0xc217c73d, 0xfa2c4c4e, 0x5b15c8a0, 0x8a5b5aa8, 0x2b62de46, 0x13595535, 0xb260d1db, 0x79831e0a, 0xd8ba9ae4, 0xe0811197, 0x41b89579, 0x90f60771, 0x31cf839f, 0x09f408ec, 0xa8cd8c02, 0x70182abd, 0xd121ae53, 0xe91a2520, 0x4823a1ce, 0x996d33c6, 0x3854b728, 0x006f3c5b, 0xa156b8b5, 0x99b34b70, 0x388acf9e, 0x00b144ed, 0xa188c003, 0x70c6520b, 0xd1ffd6e5, 0xe9c45d96, 0x48fdd978, 0x90287fc7, 0x3111fb29, 0x092a705a, 0xa813f4b4, 0x795d66bc, 0xd864e252, 0xe05f6921, 0x4166edcf, 0x8a85221e, 0x2bbca6f0, 0x13872d83, 0xb2bea96d, 0x63f03b65, 0xc2c9bf8b, 0xfaf234f8, 0x5bcbb016, 0x831e16a9, 0x22279247, 0x1a1c1934, 0xbb259dda, 0x6a6b0fd2, 0xcb528b3c, 0xf369004f, 0x525084a1, 0xbfdf99ac, 0x1ee61d42, 0x26dd9631, 0x87e412df, 0x56aa80d7, 0xf7930439, 0xcfa88f4a, 0x6e910ba4, 0xb644ad1b, 0x177d29f5, 0x2f46a286, 0x8e7f2668, 0x5f31b460, 0xfe08308e, 0xc633bbfd, 0x670a3f13, 0xace9f0c2, 0x0dd0742c, 0x35ebff5f, 0x94d27bb1, 0x459ce9b9, 0xe4a56d57, 0xdc9ee624, 0x7da762ca, 0xa572c475, 0x044b409b, 0x3c70cbe8, 0x9d494f06, 0x4c07dd0e, 0xed3e59e0, 0xd505d293, 0x743c567d, 0xd56aeec8, 0x74536a26, 0x4c68e155, 0xed5165bb, 0x3c1ff7b3, 0x9d26735d, 0xa51df82e, 0x04247cc0, 0xdcf1da7f, 0x7dc85e91, 0x45f3d5e2, 0xe4ca510c, 0x3584c304, 0x94bd47ea, 0xac86cc99, 0x0dbf4877, 0xc65c87a6, 0x67650348, 0x5f5e883b, 0xfe670cd5, 0x2f299edd, 0x8e101a33, 0xb62b9140, 0x171215ae, 0xcfc7b311, 0x6efe37ff, 0x56c5bc8c, 0xf7fc3862, 0x26b2aa6a, 0x878b2e84, 0xbfb0a5f7, 0x1e892119, 0xf3063c14, 0x523fb8fa, 0x6a043389, 0xcb3db767, 0x1a73256f, 0xbb4aa181, 0x83712af2, 0x2248ae1c, 0xfa9d08a3, 0x5ba48c4d, 0x639f073e, 0xc2a683d0, 0x13e811d8, 0xb2d19536, 0x8aea1e45, 0x2bd39aab, 0xe030557a, 0x4109d194, 0x79325ae7, 0xd80bde09, 0x09454c01, 0xa87cc8ef, 0x9047439c, 0x317ec772, 0xe9ab61cd, 0x4892e523, 0x70a96e50, 0xd190eabe, 0x00de78b6, 0xa1e7fc58, 0x99dc772b, 0x38e5f3c5}, {0x00000000, 0xe81790a1, 0x0b5e2703, 0xe349b7a2, 0x16bc4e06, 0xfeabdea7, 0x1de26905, 0xf5f5f9a4, 0x2d789c0c, 0xc56f0cad, 0x2626bb0f, 0xce312bae, 0x3bc4d20a, 0xd3d342ab, 0x309af509, 0xd88d65a8, 0x5af13818, 0xb2e6a8b9, 0x51af1f1b, 0xb9b88fba, 0x4c4d761e, 0xa45ae6bf, 0x4713511d, 0xaf04c1bc, 0x7789a414, 0x9f9e34b5, 0x7cd78317, 0x94c013b6, 0x6135ea12, 0x89227ab3, 0x6a6bcd11, 0x827c5db0, 0xb5e27030, 0x5df5e091, 0xbebc5733, 0x56abc792, 0xa35e3e36, 0x4b49ae97, 0xa8001935, 0x40178994, 0x989aec3c, 0x708d7c9d, 0x93c4cb3f, 0x7bd35b9e, 0x8e26a23a, 0x6631329b, 0x85788539, 0x6d6f1598, 0xef134828, 0x0704d889, 0xe44d6f2b, 0x0c5aff8a, 0xf9af062e, 0x11b8968f, 0xf2f1212d, 0x1ae6b18c, 0xc26bd424, 0x2a7c4485, 0xc935f327, 0x21226386, 0xd4d79a22, 0x3cc00a83, 0xdf89bd21, 0x379e2d80, 0xb0b5e621, 0x58a27680, 0xbbebc122, 0x53fc5183, 0xa609a827, 0x4e1e3886, 0xad578f24, 0x45401f85, 0x9dcd7a2d, 0x75daea8c, 0x96935d2e, 0x7e84cd8f, 0x8b71342b, 0x6366a48a, 0x802f1328, 0x68388389, 0xea44de39, 0x02534e98, 0xe11af93a, 0x090d699b, 0xfcf8903f, 0x14ef009e, 0xf7a6b73c, 0x1fb1279d, 0xc73c4235, 0x2f2bd294, 0xcc626536, 0x2475f597, 0xd1800c33, 0x39979c92, 0xdade2b30, 0x32c9bb91, 0x05579611, 0xed4006b0, 0x0e09b112, 0xe61e21b3, 0x13ebd817, 0xfbfc48b6, 0x18b5ff14, 0xf0a26fb5, 0x282f0a1d, 0xc0389abc, 0x23712d1e, 0xcb66bdbf, 0x3e93441b, 0xd684d4ba, 0x35cd6318, 0xdddaf3b9, 0x5fa6ae09, 0xb7b13ea8, 0x54f8890a, 0xbcef19ab, 0x491ae00f, 0xa10d70ae, 0x4244c70c, 0xaa5357ad, 0x72de3205, 0x9ac9a2a4, 0x79801506, 0x919785a7, 0x64627c03, 0x8c75eca2, 0x6f3c5b00, 0x872bcba1, 0xba1aca03, 0x520d5aa2, 0xb144ed00, 0x59537da1, 0xaca68405, 0x44b114a4, 0xa7f8a306, 0x4fef33a7, 0x9762560f, 0x7f75c6ae, 0x9c3c710c, 0x742be1ad, 0x81de1809, 0x69c988a8, 0x8a803f0a, 0x6297afab, 0xe0ebf21b, 0x08fc62ba, 0xebb5d518, 0x03a245b9, 0xf657bc1d, 0x1e402cbc, 0xfd099b1e, 0x151e0bbf, 0xcd936e17, 0x2584feb6, 0xc6cd4914, 0x2edad9b5, 0xdb2f2011, 0x3338b0b0, 0xd0710712, 0x386697b3, 0x0ff8ba33, 0xe7ef2a92, 0x04a69d30, 0xecb10d91, 0x1944f435, 0xf1536494, 0x121ad336, 0xfa0d4397, 0x2280263f, 0xca97b69e, 0x29de013c, 0xc1c9919d, 0x343c6839, 0xdc2bf898, 0x3f624f3a, 0xd775df9b, 0x5509822b, 0xbd1e128a, 0x5e57a528, 0xb6403589, 0x43b5cc2d, 0xaba25c8c, 0x48ebeb2e, 0xa0fc7b8f, 0x78711e27, 0x90668e86, 0x732f3924, 0x9b38a985, 0x6ecd5021, 0x86dac080, 0x65937722, 0x8d84e783, 0x0aaf2c22, 0xe2b8bc83, 0x01f10b21, 0xe9e69b80, 0x1c136224, 0xf404f285, 0x174d4527, 0xff5ad586, 0x27d7b02e, 0xcfc0208f, 0x2c89972d, 0xc49e078c, 0x316bfe28, 0xd97c6e89, 0x3a35d92b, 0xd222498a, 0x505e143a, 0xb849849b, 0x5b003339, 0xb317a398, 0x46e25a3c, 0xaef5ca9d, 0x4dbc7d3f, 0xa5abed9e, 0x7d268836, 0x95311897, 0x7678af35, 0x9e6f3f94, 0x6b9ac630, 0x838d5691, 0x60c4e133, 0x88d37192, 0xbf4d5c12, 0x575accb3, 0xb4137b11, 0x5c04ebb0, 0xa9f11214, 0x41e682b5, 0xa2af3517, 0x4ab8a5b6, 0x9235c01e, 0x7a2250bf, 0x996be71d, 0x717c77bc, 0x84898e18, 0x6c9e1eb9, 0x8fd7a91b, 0x67c039ba, 0xe5bc640a, 0x0dabf4ab, 0xeee24309, 0x06f5d3a8, 0xf3002a0c, 0x1b17baad, 0xf85e0d0f, 0x10499dae, 0xc8c4f806, 0x20d368a7, 0xc39adf05, 0x2b8d4fa4, 0xde78b600, 0x366f26a1, 0xd5269103, 0x3d3101a2}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x0000000000000000, 0xa19017e800000000, 0x03275e0b00000000, 0xa2b749e300000000, 0x064ebc1600000000, 0xa7deabfe00000000, 0x0569e21d00000000, 0xa4f9f5f500000000, 0x0c9c782d00000000, 0xad0c6fc500000000, 0x0fbb262600000000, 0xae2b31ce00000000, 0x0ad2c43b00000000, 0xab42d3d300000000, 0x09f59a3000000000, 0xa8658dd800000000, 0x1838f15a00000000, 0xb9a8e6b200000000, 0x1b1faf5100000000, 0xba8fb8b900000000, 0x1e764d4c00000000, 0xbfe65aa400000000, 0x1d51134700000000, 0xbcc104af00000000, 0x14a4897700000000, 0xb5349e9f00000000, 0x1783d77c00000000, 0xb613c09400000000, 0x12ea356100000000, 0xb37a228900000000, 0x11cd6b6a00000000, 0xb05d7c8200000000, 0x3070e2b500000000, 0x91e0f55d00000000, 0x3357bcbe00000000, 0x92c7ab5600000000, 0x363e5ea300000000, 0x97ae494b00000000, 0x351900a800000000, 0x9489174000000000, 0x3cec9a9800000000, 0x9d7c8d7000000000, 0x3fcbc49300000000, 0x9e5bd37b00000000, 0x3aa2268e00000000, 0x9b32316600000000, 0x3985788500000000, 0x98156f6d00000000, 0x284813ef00000000, 0x89d8040700000000, 0x2b6f4de400000000, 0x8aff5a0c00000000, 0x2e06aff900000000, 0x8f96b81100000000, 0x2d21f1f200000000, 0x8cb1e61a00000000, 0x24d46bc200000000, 0x85447c2a00000000, 0x27f335c900000000, 0x8663222100000000, 0x229ad7d400000000, 0x830ac03c00000000, 0x21bd89df00000000, 0x802d9e3700000000, 0x21e6b5b000000000, 0x8076a25800000000, 0x22c1ebbb00000000, 0x8351fc5300000000, 0x27a809a600000000, 0x86381e4e00000000, 0x248f57ad00000000, 0x851f404500000000, 0x2d7acd9d00000000, 0x8ceada7500000000, 0x2e5d939600000000, 0x8fcd847e00000000, 0x2b34718b00000000, 0x8aa4666300000000, 0x28132f8000000000, 0x8983386800000000, 0x39de44ea00000000, 0x984e530200000000, 0x3af91ae100000000, 0x9b690d0900000000, 0x3f90f8fc00000000, 0x9e00ef1400000000, 0x3cb7a6f700000000, 0x9d27b11f00000000, 0x35423cc700000000, 0x94d22b2f00000000, 0x366562cc00000000, 0x97f5752400000000, 0x330c80d100000000, 0x929c973900000000, 0x302bdeda00000000, 0x91bbc93200000000, 0x1196570500000000, 0xb00640ed00000000, 0x12b1090e00000000, 0xb3211ee600000000, 0x17d8eb1300000000, 0xb648fcfb00000000, 0x14ffb51800000000, 0xb56fa2f000000000, 0x1d0a2f2800000000, 0xbc9a38c000000000, 0x1e2d712300000000, 0xbfbd66cb00000000, 0x1b44933e00000000, 0xbad484d600000000, 0x1863cd3500000000, 0xb9f3dadd00000000, 0x09aea65f00000000, 0xa83eb1b700000000, 0x0a89f85400000000, 0xab19efbc00000000, 0x0fe01a4900000000, 0xae700da100000000, 0x0cc7444200000000, 0xad5753aa00000000, 0x0532de7200000000, 0xa4a2c99a00000000, 0x0615807900000000, 0xa785979100000000, 0x037c626400000000, 0xa2ec758c00000000, 0x005b3c6f00000000, 0xa1cb2b8700000000, 0x03ca1aba00000000, 0xa25a0d5200000000, 0x00ed44b100000000, 0xa17d535900000000, 0x0584a6ac00000000, 0xa414b14400000000, 0x06a3f8a700000000, 0xa733ef4f00000000, 0x0f56629700000000, 0xaec6757f00000000, 0x0c713c9c00000000, 0xade12b7400000000, 0x0918de8100000000, 0xa888c96900000000, 0x0a3f808a00000000, 0xabaf976200000000, 0x1bf2ebe000000000, 0xba62fc0800000000, 0x18d5b5eb00000000, 0xb945a20300000000, 0x1dbc57f600000000, 0xbc2c401e00000000, 0x1e9b09fd00000000, 0xbf0b1e1500000000, 0x176e93cd00000000, 0xb6fe842500000000, 0x1449cdc600000000, 0xb5d9da2e00000000, 0x11202fdb00000000, 0xb0b0383300000000, 0x120771d000000000, 0xb397663800000000, 0x33baf80f00000000, 0x922aefe700000000, 0x309da60400000000, 0x910db1ec00000000, 0x35f4441900000000, 0x946453f100000000, 0x36d31a1200000000, 0x97430dfa00000000, 0x3f26802200000000, 0x9eb697ca00000000, 0x3c01de2900000000, 0x9d91c9c100000000, 0x39683c3400000000, 0x98f82bdc00000000, 0x3a4f623f00000000, 0x9bdf75d700000000, 0x2b82095500000000, 0x8a121ebd00000000, 0x28a5575e00000000, 0x893540b600000000, 0x2dccb54300000000, 0x8c5ca2ab00000000, 0x2eebeb4800000000, 0x8f7bfca000000000, 0x271e717800000000, 0x868e669000000000, 0x24392f7300000000, 0x85a9389b00000000, 0x2150cd6e00000000, 0x80c0da8600000000, 0x2277936500000000, 0x83e7848d00000000, 0x222caf0a00000000, 0x83bcb8e200000000, 0x210bf10100000000, 0x809be6e900000000, 0x2462131c00000000, 0x85f204f400000000, 0x27454d1700000000, 0x86d55aff00000000, 0x2eb0d72700000000, 0x8f20c0cf00000000, 0x2d97892c00000000, 0x8c079ec400000000, 0x28fe6b3100000000, 0x896e7cd900000000, 0x2bd9353a00000000, 0x8a4922d200000000, 0x3a145e5000000000, 0x9b8449b800000000, 0x3933005b00000000, 0x98a317b300000000, 0x3c5ae24600000000, 0x9dcaf5ae00000000, 0x3f7dbc4d00000000, 0x9eedaba500000000, 0x3688267d00000000, 0x9718319500000000, 0x35af787600000000, 0x943f6f9e00000000, 0x30c69a6b00000000, 0x91568d8300000000, 0x33e1c46000000000, 0x9271d38800000000, 0x125c4dbf00000000, 0xb3cc5a5700000000, 0x117b13b400000000, 0xb0eb045c00000000, 0x1412f1a900000000, 0xb582e64100000000, 0x1735afa200000000, 0xb6a5b84a00000000, 0x1ec0359200000000, 0xbf50227a00000000, 0x1de76b9900000000, 0xbc777c7100000000, 0x188e898400000000, 0xb91e9e6c00000000, 0x1ba9d78f00000000, 0xba39c06700000000, 0x0a64bce500000000, 0xabf4ab0d00000000, 0x0943e2ee00000000, 0xa8d3f50600000000, 0x0c2a00f300000000, 0xadba171b00000000, 0x0f0d5ef800000000, 0xae9d491000000000, 0x06f8c4c800000000, 0xa768d32000000000, 0x05df9ac300000000, 0xa44f8d2b00000000, 0x00b678de00000000, 0xa1266f3600000000, 0x039126d500000000, 0xa201313d00000000}, {0x0000000000000000, 0xee8439a100000000, 0x9d0f029900000000, 0x738b3b3800000000, 0x7b1975e900000000, 0x959d4c4800000000, 0xe616777000000000, 0x08924ed100000000, 0xb7349b0900000000, 0x59b0a2a800000000, 0x2a3b999000000000, 0xc4bfa03100000000, 0xcc2deee000000000, 0x22a9d74100000000, 0x5122ec7900000000, 0xbfa6d5d800000000, 0x6e69361300000000, 0x80ed0fb200000000, 0xf366348a00000000, 0x1de20d2b00000000, 0x157043fa00000000, 0xfbf47a5b00000000, 0x887f416300000000, 0x66fb78c200000000, 0xd95dad1a00000000, 0x37d994bb00000000, 0x4452af8300000000, 0xaad6962200000000, 0xa244d8f300000000, 0x4cc0e15200000000, 0x3f4bda6a00000000, 0xd1cfe3cb00000000, 0xdcd26c2600000000, 0x3256558700000000, 0x41dd6ebf00000000, 0xaf59571e00000000, 0xa7cb19cf00000000, 0x494f206e00000000, 0x3ac41b5600000000, 0xd44022f700000000, 0x6be6f72f00000000, 0x8562ce8e00000000, 0xf6e9f5b600000000, 0x186dcc1700000000, 0x10ff82c600000000, 0xfe7bbb6700000000, 0x8df0805f00000000, 0x6374b9fe00000000, 0xb2bb5a3500000000, 0x5c3f639400000000, 0x2fb458ac00000000, 0xc130610d00000000, 0xc9a22fdc00000000, 0x2726167d00000000, 0x54ad2d4500000000, 0xba2914e400000000, 0x058fc13c00000000, 0xeb0bf89d00000000, 0x9880c3a500000000, 0x7604fa0400000000, 0x7e96b4d500000000, 0x90128d7400000000, 0xe399b64c00000000, 0x0d1d8fed00000000, 0xb8a5d94c00000000, 0x5621e0ed00000000, 0x25aadbd500000000, 0xcb2ee27400000000, 0xc3bcaca500000000, 0x2d38950400000000, 0x5eb3ae3c00000000, 0xb037979d00000000, 0x0f91424500000000, 0xe1157be400000000, 0x929e40dc00000000, 0x7c1a797d00000000, 0x748837ac00000000, 0x9a0c0e0d00000000, 0xe987353500000000, 0x07030c9400000000, 0xd6ccef5f00000000, 0x3848d6fe00000000, 0x4bc3edc600000000, 0xa547d46700000000, 0xadd59ab600000000, 0x4351a31700000000, 0x30da982f00000000, 0xde5ea18e00000000, 0x61f8745600000000, 0x8f7c4df700000000, 0xfcf776cf00000000, 0x12734f6e00000000, 0x1ae101bf00000000, 0xf465381e00000000, 0x87ee032600000000, 0x696a3a8700000000, 0x6477b56a00000000, 0x8af38ccb00000000, 0xf978b7f300000000, 0x17fc8e5200000000, 0x1f6ec08300000000, 0xf1eaf92200000000, 0x8261c21a00000000, 0x6ce5fbbb00000000, 0xd3432e6300000000, 0x3dc717c200000000, 0x4e4c2cfa00000000, 0xa0c8155b00000000, 0xa85a5b8a00000000, 0x46de622b00000000, 0x3555591300000000, 0xdbd160b200000000, 0x0a1e837900000000, 0xe49abad800000000, 0x971181e000000000, 0x7995b84100000000, 0x7107f69000000000, 0x9f83cf3100000000, 0xec08f40900000000, 0x028ccda800000000, 0xbd2a187000000000, 0x53ae21d100000000, 0x20251ae900000000, 0xcea1234800000000, 0xc6336d9900000000, 0x28b7543800000000, 0x5b3c6f0000000000, 0xb5b856a100000000, 0x704bb39900000000, 0x9ecf8a3800000000, 0xed44b10000000000, 0x03c088a100000000, 0x0b52c67000000000, 0xe5d6ffd100000000, 0x965dc4e900000000, 0x78d9fd4800000000, 0xc77f289000000000, 0x29fb113100000000, 0x5a702a0900000000, 0xb4f413a800000000, 0xbc665d7900000000, 0x52e264d800000000, 0x21695fe000000000, 0xcfed664100000000, 0x1e22858a00000000, 0xf0a6bc2b00000000, 0x832d871300000000, 0x6da9beb200000000, 0x653bf06300000000, 0x8bbfc9c200000000, 0xf834f2fa00000000, 0x16b0cb5b00000000, 0xa9161e8300000000, 0x4792272200000000, 0x34191c1a00000000, 0xda9d25bb00000000, 0xd20f6b6a00000000, 0x3c8b52cb00000000, 0x4f0069f300000000, 0xa184505200000000, 0xac99dfbf00000000, 0x421de61e00000000, 0x3196dd2600000000, 0xdf12e48700000000, 0xd780aa5600000000, 0x390493f700000000, 0x4a8fa8cf00000000, 0xa40b916e00000000, 0x1bad44b600000000, 0xf5297d1700000000, 0x86a2462f00000000, 0x68267f8e00000000, 0x60b4315f00000000, 0x8e3008fe00000000, 0xfdbb33c600000000, 0x133f0a6700000000, 0xc2f0e9ac00000000, 0x2c74d00d00000000, 0x5fffeb3500000000, 0xb17bd29400000000, 0xb9e99c4500000000, 0x576da5e400000000, 0x24e69edc00000000, 0xca62a77d00000000, 0x75c472a500000000, 0x9b404b0400000000, 0xe8cb703c00000000, 0x064f499d00000000, 0x0edd074c00000000, 0xe0593eed00000000, 0x93d205d500000000, 0x7d563c7400000000, 0xc8ee6ad500000000, 0x266a537400000000, 0x55e1684c00000000, 0xbb6551ed00000000, 0xb3f71f3c00000000, 0x5d73269d00000000, 0x2ef81da500000000, 0xc07c240400000000, 0x7fdaf1dc00000000, 0x915ec87d00000000, 0xe2d5f34500000000, 0x0c51cae400000000, 0x04c3843500000000, 0xea47bd9400000000, 0x99cc86ac00000000, 0x7748bf0d00000000, 0xa6875cc600000000, 0x4803656700000000, 0x3b885e5f00000000, 0xd50c67fe00000000, 0xdd9e292f00000000, 0x331a108e00000000, 0x40912bb600000000, 0xae15121700000000, 0x11b3c7cf00000000, 0xff37fe6e00000000, 0x8cbcc55600000000, 0x6238fcf700000000, 0x6aaab22600000000, 0x842e8b8700000000, 0xf7a5b0bf00000000, 0x1921891e00000000, 0x143c06f300000000, 0xfab83f5200000000, 0x8933046a00000000, 0x67b73dcb00000000, 0x6f25731a00000000, 0x81a14abb00000000, 0xf22a718300000000, 0x1cae482200000000, 0xa3089dfa00000000, 0x4d8ca45b00000000, 0x3e079f6300000000, 0xd083a6c200000000, 0xd811e81300000000, 0x3695d1b200000000, 0x451eea8a00000000, 0xab9ad32b00000000, 0x7a5530e000000000, 0x94d1094100000000, 0xe75a327900000000, 0x09de0bd800000000, 0x014c450900000000, 0xefc87ca800000000, 0x9c43479000000000, 0x72c77e3100000000, 0xcd61abe900000000, 0x23e5924800000000, 0x506ea97000000000, 0xbeea90d100000000, 0xb678de0000000000, 0x58fce7a100000000, 0x2b77dc9900000000, 0xc5f3e53800000000}, {0x0000000000000000, 0xfbf6134700000000, 0xf6ed278e00000000, 0x0d1b34c900000000, 0xaddd3ec700000000, 0x562b2d8000000000, 0x5b30194900000000, 0xa0c60a0e00000000, 0x1bbd0c5500000000, 0xe04b1f1200000000, 0xed502bdb00000000, 0x16a6389c00000000, 0xb660329200000000, 0x4d9621d500000000, 0x408d151c00000000, 0xbb7b065b00000000, 0x367a19aa00000000, 0xcd8c0aed00000000, 0xc0973e2400000000, 0x3b612d6300000000, 0x9ba7276d00000000, 0x6051342a00000000, 0x6d4a00e300000000, 0x96bc13a400000000, 0x2dc715ff00000000, 0xd63106b800000000, 0xdb2a327100000000, 0x20dc213600000000, 0x801a2b3800000000, 0x7bec387f00000000, 0x76f70cb600000000, 0x8d011ff100000000, 0x2df2438f00000000, 0xd60450c800000000, 0xdb1f640100000000, 0x20e9774600000000, 0x802f7d4800000000, 0x7bd96e0f00000000, 0x76c25ac600000000, 0x8d34498100000000, 0x364f4fda00000000, 0xcdb95c9d00000000, 0xc0a2685400000000, 0x3b547b1300000000, 0x9b92711d00000000, 0x6064625a00000000, 0x6d7f569300000000, 0x968945d400000000, 0x1b885a2500000000, 0xe07e496200000000, 0xed657dab00000000, 0x16936eec00000000, 0xb65564e200000000, 0x4da377a500000000, 0x40b8436c00000000, 0xbb4e502b00000000, 0x0035567000000000, 0xfbc3453700000000, 0xf6d871fe00000000, 0x0d2e62b900000000, 0xade868b700000000, 0x561e7bf000000000, 0x5b054f3900000000, 0xa0f35c7e00000000, 0x1be2f6c500000000, 0xe014e58200000000, 0xed0fd14b00000000, 0x16f9c20c00000000, 0xb63fc80200000000, 0x4dc9db4500000000, 0x40d2ef8c00000000, 0xbb24fccb00000000, 0x005ffa9000000000, 0xfba9e9d700000000, 0xf6b2dd1e00000000, 0x0d44ce5900000000, 0xad82c45700000000, 0x5674d71000000000, 0x5b6fe3d900000000, 0xa099f09e00000000, 0x2d98ef6f00000000, 0xd66efc2800000000, 0xdb75c8e100000000, 0x2083dba600000000, 0x8045d1a800000000, 0x7bb3c2ef00000000, 0x76a8f62600000000, 0x8d5ee56100000000, 0x3625e33a00000000, 0xcdd3f07d00000000, 0xc0c8c4b400000000, 0x3b3ed7f300000000, 0x9bf8ddfd00000000, 0x600eceba00000000, 0x6d15fa7300000000, 0x96e3e93400000000, 0x3610b54a00000000, 0xcde6a60d00000000, 0xc0fd92c400000000, 0x3b0b818300000000, 0x9bcd8b8d00000000, 0x603b98ca00000000, 0x6d20ac0300000000, 0x96d6bf4400000000, 0x2dadb91f00000000, 0xd65baa5800000000, 0xdb409e9100000000, 0x20b68dd600000000, 0x807087d800000000, 0x7b86949f00000000, 0x769da05600000000, 0x8d6bb31100000000, 0x006aace000000000, 0xfb9cbfa700000000, 0xf6878b6e00000000, 0x0d71982900000000, 0xadb7922700000000, 0x5641816000000000, 0x5b5ab5a900000000, 0xa0aca6ee00000000, 0x1bd7a0b500000000, 0xe021b3f200000000, 0xed3a873b00000000, 0x16cc947c00000000, 0xb60a9e7200000000, 0x4dfc8d3500000000, 0x40e7b9fc00000000, 0xbb11aabb00000000, 0x77c29c5000000000, 0x8c348f1700000000, 0x812fbbde00000000, 0x7ad9a89900000000, 0xda1fa29700000000, 0x21e9b1d000000000, 0x2cf2851900000000, 0xd704965e00000000, 0x6c7f900500000000, 0x9789834200000000, 0x9a92b78b00000000, 0x6164a4cc00000000, 0xc1a2aec200000000, 0x3a54bd8500000000, 0x374f894c00000000, 0xccb99a0b00000000, 0x41b885fa00000000, 0xba4e96bd00000000, 0xb755a27400000000, 0x4ca3b13300000000, 0xec65bb3d00000000, 0x1793a87a00000000, 0x1a889cb300000000, 0xe17e8ff400000000, 0x5a0589af00000000, 0xa1f39ae800000000, 0xace8ae2100000000, 0x571ebd6600000000, 0xf7d8b76800000000, 0x0c2ea42f00000000, 0x013590e600000000, 0xfac383a100000000, 0x5a30dfdf00000000, 0xa1c6cc9800000000, 0xacddf85100000000, 0x572beb1600000000, 0xf7ede11800000000, 0x0c1bf25f00000000, 0x0100c69600000000, 0xfaf6d5d100000000, 0x418dd38a00000000, 0xba7bc0cd00000000, 0xb760f40400000000, 0x4c96e74300000000, 0xec50ed4d00000000, 0x17a6fe0a00000000, 0x1abdcac300000000, 0xe14bd98400000000, 0x6c4ac67500000000, 0x97bcd53200000000, 0x9aa7e1fb00000000, 0x6151f2bc00000000, 0xc197f8b200000000, 0x3a61ebf500000000, 0x377adf3c00000000, 0xcc8ccc7b00000000, 0x77f7ca2000000000, 0x8c01d96700000000, 0x811aedae00000000, 0x7aecfee900000000, 0xda2af4e700000000, 0x21dce7a000000000, 0x2cc7d36900000000, 0xd731c02e00000000, 0x6c206a9500000000, 0x97d679d200000000, 0x9acd4d1b00000000, 0x613b5e5c00000000, 0xc1fd545200000000, 0x3a0b471500000000, 0x371073dc00000000, 0xcce6609b00000000, 0x779d66c000000000, 0x8c6b758700000000, 0x8170414e00000000, 0x7a86520900000000, 0xda40580700000000, 0x21b64b4000000000, 0x2cad7f8900000000, 0xd75b6cce00000000, 0x5a5a733f00000000, 0xa1ac607800000000, 0xacb754b100000000, 0x574147f600000000, 0xf7874df800000000, 0x0c715ebf00000000, 0x016a6a7600000000, 0xfa9c793100000000, 0x41e77f6a00000000, 0xba116c2d00000000, 0xb70a58e400000000, 0x4cfc4ba300000000, 0xec3a41ad00000000, 0x17cc52ea00000000, 0x1ad7662300000000, 0xe121756400000000, 0x41d2291a00000000, 0xba243a5d00000000, 0xb73f0e9400000000, 0x4cc91dd300000000, 0xec0f17dd00000000, 0x17f9049a00000000, 0x1ae2305300000000, 0xe114231400000000, 0x5a6f254f00000000, 0xa199360800000000, 0xac8202c100000000, 0x5774118600000000, 0xf7b21b8800000000, 0x0c4408cf00000000, 0x015f3c0600000000, 0xfaa92f4100000000, 0x77a830b000000000, 0x8c5e23f700000000, 0x8145173e00000000, 0x7ab3047900000000, 0xda750e7700000000, 0x21831d3000000000, 0x2c9829f900000000, 0xd76e3abe00000000, 0x6c153ce500000000, 0x97e32fa200000000, 0x9af81b6b00000000, 0x610e082c00000000, 0xc1c8022200000000, 0x3a3e116500000000, 0x372525ac00000000, 0xccd336eb00000000}, {0x0000000000000000, 0x6238282a00000000, 0xc470505400000000, 0xa648787e00000000, 0x88e1a0a800000000, 0xead9888200000000, 0x4c91f0fc00000000, 0x2ea9d8d600000000, 0x51c5308a00000000, 0x33fd18a000000000, 0x95b560de00000000, 0xf78d48f400000000, 0xd924902200000000, 0xbb1cb80800000000, 0x1d54c07600000000, 0x7f6ce85c00000000, 0xe38c10cf00000000, 0x81b438e500000000, 0x27fc409b00000000, 0x45c468b100000000, 0x6b6db06700000000, 0x0955984d00000000, 0xaf1de03300000000, 0xcd25c81900000000, 0xb249204500000000, 0xd071086f00000000, 0x7639701100000000, 0x1401583b00000000, 0x3aa880ed00000000, 0x5890a8c700000000, 0xfed8d0b900000000, 0x9ce0f89300000000, 0x871f504500000000, 0xe527786f00000000, 0x436f001100000000, 0x2157283b00000000, 0x0ffef0ed00000000, 0x6dc6d8c700000000, 0xcb8ea0b900000000, 0xa9b6889300000000, 0xd6da60cf00000000, 0xb4e248e500000000, 0x12aa309b00000000, 0x709218b100000000, 0x5e3bc06700000000, 0x3c03e84d00000000, 0x9a4b903300000000, 0xf873b81900000000, 0x6493408a00000000, 0x06ab68a000000000, 0xa0e310de00000000, 0xc2db38f400000000, 0xec72e02200000000, 0x8e4ac80800000000, 0x2802b07600000000, 0x4a3a985c00000000, 0x3556700000000000, 0x576e582a00000000, 0xf126205400000000, 0x931e087e00000000, 0xbdb7d0a800000000, 0xdf8ff88200000000, 0x79c780fc00000000, 0x1bffa8d600000000, 0x0e3fa08a00000000, 0x6c0788a000000000, 0xca4ff0de00000000, 0xa877d8f400000000, 0x86de002200000000, 0xe4e6280800000000, 0x42ae507600000000, 0x2096785c00000000, 0x5ffa900000000000, 0x3dc2b82a00000000, 0x9b8ac05400000000, 0xf9b2e87e00000000, 0xd71b30a800000000, 0xb523188200000000, 0x136b60fc00000000, 0x715348d600000000, 0xedb3b04500000000, 0x8f8b986f00000000, 0x29c3e01100000000, 0x4bfbc83b00000000, 0x655210ed00000000, 0x076a38c700000000, 0xa12240b900000000, 0xc31a689300000000, 0xbc7680cf00000000, 0xde4ea8e500000000, 0x7806d09b00000000, 0x1a3ef8b100000000, 0x3497206700000000, 0x56af084d00000000, 0xf0e7703300000000, 0x92df581900000000, 0x8920f0cf00000000, 0xeb18d8e500000000, 0x4d50a09b00000000, 0x2f6888b100000000, 0x01c1506700000000, 0x63f9784d00000000, 0xc5b1003300000000, 0xa789281900000000, 0xd8e5c04500000000, 0xbadde86f00000000, 0x1c95901100000000, 0x7eadb83b00000000, 0x500460ed00000000, 0x323c48c700000000, 0x947430b900000000, 0xf64c189300000000, 0x6aace00000000000, 0x0894c82a00000000, 0xaedcb05400000000, 0xcce4987e00000000, 0xe24d40a800000000, 0x8075688200000000, 0x263d10fc00000000, 0x440538d600000000, 0x3b69d08a00000000, 0x5951f8a000000000, 0xff1980de00000000, 0x9d21a8f400000000, 0xb388702200000000, 0xd1b0580800000000, 0x77f8207600000000, 0x15c0085c00000000, 0x5d7831ce00000000, 0x3f4019e400000000, 0x9908619a00000000, 0xfb3049b000000000, 0xd599916600000000, 0xb7a1b94c00000000, 0x11e9c13200000000, 0x73d1e91800000000, 0x0cbd014400000000, 0x6e85296e00000000, 0xc8cd511000000000, 0xaaf5793a00000000, 0x845ca1ec00000000, 0xe66489c600000000, 0x402cf1b800000000, 0x2214d99200000000, 0xbef4210100000000, 0xdccc092b00000000, 0x7a84715500000000, 0x18bc597f00000000, 0x361581a900000000, 0x542da98300000000, 0xf265d1fd00000000, 0x905df9d700000000, 0xef31118b00000000, 0x8d0939a100000000, 0x2b4141df00000000, 0x497969f500000000, 0x67d0b12300000000, 0x05e8990900000000, 0xa3a0e17700000000, 0xc198c95d00000000, 0xda67618b00000000, 0xb85f49a100000000, 0x1e1731df00000000, 0x7c2f19f500000000, 0x5286c12300000000, 0x30bee90900000000, 0x96f6917700000000, 0xf4ceb95d00000000, 0x8ba2510100000000, 0xe99a792b00000000, 0x4fd2015500000000, 0x2dea297f00000000, 0x0343f1a900000000, 0x617bd98300000000, 0xc733a1fd00000000, 0xa50b89d700000000, 0x39eb714400000000, 0x5bd3596e00000000, 0xfd9b211000000000, 0x9fa3093a00000000, 0xb10ad1ec00000000, 0xd332f9c600000000, 0x757a81b800000000, 0x1742a99200000000, 0x682e41ce00000000, 0x0a1669e400000000, 0xac5e119a00000000, 0xce6639b000000000, 0xe0cfe16600000000, 0x82f7c94c00000000, 0x24bfb13200000000, 0x4687991800000000, 0x5347914400000000, 0x317fb96e00000000, 0x9737c11000000000, 0xf50fe93a00000000, 0xdba631ec00000000, 0xb99e19c600000000, 0x1fd661b800000000, 0x7dee499200000000, 0x0282a1ce00000000, 0x60ba89e400000000, 0xc6f2f19a00000000, 0xa4cad9b000000000, 0x8a63016600000000, 0xe85b294c00000000, 0x4e13513200000000, 0x2c2b791800000000, 0xb0cb818b00000000, 0xd2f3a9a100000000, 0x74bbd1df00000000, 0x1683f9f500000000, 0x382a212300000000, 0x5a12090900000000, 0xfc5a717700000000, 0x9e62595d00000000, 0xe10eb10100000000, 0x8336992b00000000, 0x257ee15500000000, 0x4746c97f00000000, 0x69ef11a900000000, 0x0bd7398300000000, 0xad9f41fd00000000, 0xcfa769d700000000, 0xd458c10100000000, 0xb660e92b00000000, 0x1028915500000000, 0x7210b97f00000000, 0x5cb961a900000000, 0x3e81498300000000, 0x98c931fd00000000, 0xfaf119d700000000, 0x859df18b00000000, 0xe7a5d9a100000000, 0x41eda1df00000000, 0x23d589f500000000, 0x0d7c512300000000, 0x6f44790900000000, 0xc90c017700000000, 0xab34295d00000000, 0x37d4d1ce00000000, 0x55ecf9e400000000, 0xf3a4819a00000000, 0x919ca9b000000000, 0xbf35716600000000, 0xdd0d594c00000000, 0x7b45213200000000, 0x197d091800000000, 0x6611e14400000000, 0x0429c96e00000000, 0xa261b11000000000, 0xc059993a00000000, 0xeef041ec00000000, 0x8cc869c600000000, 0x2a8011b800000000, 0x48b8399200000000}, {0x0000000000000000, 0x4c2896a300000000, 0xd9565d9c00000000, 0x957ecb3f00000000, 0xf3abcbe300000000, 0xbf835d4000000000, 0x2afd967f00000000, 0x66d500dc00000000, 0xa751e61c00000000, 0xeb7970bf00000000, 0x7e07bb8000000000, 0x322f2d2300000000, 0x54fa2dff00000000, 0x18d2bb5c00000000, 0x8dac706300000000, 0xc184e6c000000000, 0x4ea3cc3900000000, 0x028b5a9a00000000, 0x97f591a500000000, 0xdbdd070600000000, 0xbd0807da00000000, 0xf120917900000000, 0x645e5a4600000000, 0x2876cce500000000, 0xe9f22a2500000000, 0xa5dabc8600000000, 0x30a477b900000000, 0x7c8ce11a00000000, 0x1a59e1c600000000, 0x5671776500000000, 0xc30fbc5a00000000, 0x8f272af900000000, 0x9c46997300000000, 0xd06e0fd000000000, 0x4510c4ef00000000, 0x0938524c00000000, 0x6fed529000000000, 0x23c5c43300000000, 0xb6bb0f0c00000000, 0xfa9399af00000000, 0x3b177f6f00000000, 0x773fe9cc00000000, 0xe24122f300000000, 0xae69b45000000000, 0xc8bcb48c00000000, 0x8494222f00000000, 0x11eae91000000000, 0x5dc27fb300000000, 0xd2e5554a00000000, 0x9ecdc3e900000000, 0x0bb308d600000000, 0x479b9e7500000000, 0x214e9ea900000000, 0x6d66080a00000000, 0xf818c33500000000, 0xb430559600000000, 0x75b4b35600000000, 0x399c25f500000000, 0xace2eeca00000000, 0xe0ca786900000000, 0x861f78b500000000, 0xca37ee1600000000, 0x5f49252900000000, 0x1361b38a00000000, 0x388d32e700000000, 0x74a5a44400000000, 0xe1db6f7b00000000, 0xadf3f9d800000000, 0xcb26f90400000000, 0x870e6fa700000000, 0x1270a49800000000, 0x5e58323b00000000, 0x9fdcd4fb00000000, 0xd3f4425800000000, 0x468a896700000000, 0x0aa21fc400000000, 0x6c771f1800000000, 0x205f89bb00000000, 0xb521428400000000, 0xf909d42700000000, 0x762efede00000000, 0x3a06687d00000000, 0xaf78a34200000000, 0xe35035e100000000, 0x8585353d00000000, 0xc9ada39e00000000, 0x5cd368a100000000, 0x10fbfe0200000000, 0xd17f18c200000000, 0x9d578e6100000000, 0x0829455e00000000, 0x4401d3fd00000000, 0x22d4d32100000000, 0x6efc458200000000, 0xfb828ebd00000000, 0xb7aa181e00000000, 0xa4cbab9400000000, 0xe8e33d3700000000, 0x7d9df60800000000, 0x31b560ab00000000, 0x5760607700000000, 0x1b48f6d400000000, 0x8e363deb00000000, 0xc21eab4800000000, 0x039a4d8800000000, 0x4fb2db2b00000000, 0xdacc101400000000, 0x96e486b700000000, 0xf031866b00000000, 0xbc1910c800000000, 0x2967dbf700000000, 0x654f4d5400000000, 0xea6867ad00000000, 0xa640f10e00000000, 0x333e3a3100000000, 0x7f16ac9200000000, 0x19c3ac4e00000000, 0x55eb3aed00000000, 0xc095f1d200000000, 0x8cbd677100000000, 0x4d3981b100000000, 0x0111171200000000, 0x946fdc2d00000000, 0xd8474a8e00000000, 0xbe924a5200000000, 0xf2badcf100000000, 0x67c417ce00000000, 0x2bec816d00000000, 0x311c141500000000, 0x7d3482b600000000, 0xe84a498900000000, 0xa462df2a00000000, 0xc2b7dff600000000, 0x8e9f495500000000, 0x1be1826a00000000, 0x57c914c900000000, 0x964df20900000000, 0xda6564aa00000000, 0x4f1baf9500000000, 0x0333393600000000, 0x65e639ea00000000, 0x29ceaf4900000000, 0xbcb0647600000000, 0xf098f2d500000000, 0x7fbfd82c00000000, 0x33974e8f00000000, 0xa6e985b000000000, 0xeac1131300000000, 0x8c1413cf00000000, 0xc03c856c00000000, 0x55424e5300000000, 0x196ad8f000000000, 0xd8ee3e3000000000, 0x94c6a89300000000, 0x01b863ac00000000, 0x4d90f50f00000000, 0x2b45f5d300000000, 0x676d637000000000, 0xf213a84f00000000, 0xbe3b3eec00000000, 0xad5a8d6600000000, 0xe1721bc500000000, 0x740cd0fa00000000, 0x3824465900000000, 0x5ef1468500000000, 0x12d9d02600000000, 0x87a71b1900000000, 0xcb8f8dba00000000, 0x0a0b6b7a00000000, 0x4623fdd900000000, 0xd35d36e600000000, 0x9f75a04500000000, 0xf9a0a09900000000, 0xb588363a00000000, 0x20f6fd0500000000, 0x6cde6ba600000000, 0xe3f9415f00000000, 0xafd1d7fc00000000, 0x3aaf1cc300000000, 0x76878a6000000000, 0x10528abc00000000, 0x5c7a1c1f00000000, 0xc904d72000000000, 0x852c418300000000, 0x44a8a74300000000, 0x088031e000000000, 0x9dfefadf00000000, 0xd1d66c7c00000000, 0xb7036ca000000000, 0xfb2bfa0300000000, 0x6e55313c00000000, 0x227da79f00000000, 0x099126f200000000, 0x45b9b05100000000, 0xd0c77b6e00000000, 0x9cefedcd00000000, 0xfa3aed1100000000, 0xb6127bb200000000, 0x236cb08d00000000, 0x6f44262e00000000, 0xaec0c0ee00000000, 0xe2e8564d00000000, 0x77969d7200000000, 0x3bbe0bd100000000, 0x5d6b0b0d00000000, 0x11439dae00000000, 0x843d569100000000, 0xc815c03200000000, 0x4732eacb00000000, 0x0b1a7c6800000000, 0x9e64b75700000000, 0xd24c21f400000000, 0xb499212800000000, 0xf8b1b78b00000000, 0x6dcf7cb400000000, 0x21e7ea1700000000, 0xe0630cd700000000, 0xac4b9a7400000000, 0x3935514b00000000, 0x751dc7e800000000, 0x13c8c73400000000, 0x5fe0519700000000, 0xca9e9aa800000000, 0x86b60c0b00000000, 0x95d7bf8100000000, 0xd9ff292200000000, 0x4c81e21d00000000, 0x00a974be00000000, 0x667c746200000000, 0x2a54e2c100000000, 0xbf2a29fe00000000, 0xf302bf5d00000000, 0x3286599d00000000, 0x7eaecf3e00000000, 0xebd0040100000000, 0xa7f892a200000000, 0xc12d927e00000000, 0x8d0504dd00000000, 0x187bcfe200000000, 0x5453594100000000, 0xdb7473b800000000, 0x975ce51b00000000, 0x02222e2400000000, 0x4e0ab88700000000, 0x28dfb85b00000000, 0x64f72ef800000000, 0xf189e5c700000000, 0xbda1736400000000, 0x7c2595a400000000, 0x300d030700000000, 0xa573c83800000000, 0xe95b5e9b00000000, 0x8f8e5e4700000000, 0xc3a6c8e400000000, 0x56d803db00000000, 0x1af0957800000000}, {0x0000000000000000, 0x939bc97f00000000, 0x263793ff00000000, 0xb5ac5a8000000000, 0x0d68572400000000, 0x9ef39e5b00000000, 0x2b5fc4db00000000, 0xb8c40da400000000, 0x1ad0ae4800000000, 0x894b673700000000, 0x3ce73db700000000, 0xaf7cf4c800000000, 0x17b8f96c00000000, 0x8423301300000000, 0x318f6a9300000000, 0xa214a3ec00000000, 0x34a05d9100000000, 0xa73b94ee00000000, 0x1297ce6e00000000, 0x810c071100000000, 0x39c80ab500000000, 0xaa53c3ca00000000, 0x1fff994a00000000, 0x8c64503500000000, 0x2e70f3d900000000, 0xbdeb3aa600000000, 0x0847602600000000, 0x9bdca95900000000, 0x2318a4fd00000000, 0xb0836d8200000000, 0x052f370200000000, 0x96b4fe7d00000000, 0x2946caf900000000, 0xbadd038600000000, 0x0f71590600000000, 0x9cea907900000000, 0x242e9ddd00000000, 0xb7b554a200000000, 0x02190e2200000000, 0x9182c75d00000000, 0x339664b100000000, 0xa00dadce00000000, 0x15a1f74e00000000, 0x863a3e3100000000, 0x3efe339500000000, 0xad65faea00000000, 0x18c9a06a00000000, 0x8b52691500000000, 0x1de6976800000000, 0x8e7d5e1700000000, 0x3bd1049700000000, 0xa84acde800000000, 0x108ec04c00000000, 0x8315093300000000, 0x36b953b300000000, 0xa5229acc00000000, 0x0736392000000000, 0x94adf05f00000000, 0x2101aadf00000000, 0xb29a63a000000000, 0x0a5e6e0400000000, 0x99c5a77b00000000, 0x2c69fdfb00000000, 0xbff2348400000000, 0x138ae52800000000, 0x80112c5700000000, 0x35bd76d700000000, 0xa626bfa800000000, 0x1ee2b20c00000000, 0x8d797b7300000000, 0x38d521f300000000, 0xab4ee88c00000000, 0x095a4b6000000000, 0x9ac1821f00000000, 0x2f6dd89f00000000, 0xbcf611e000000000, 0x04321c4400000000, 0x97a9d53b00000000, 0x22058fbb00000000, 0xb19e46c400000000, 0x272ab8b900000000, 0xb4b171c600000000, 0x011d2b4600000000, 0x9286e23900000000, 0x2a42ef9d00000000, 0xb9d926e200000000, 0x0c757c6200000000, 0x9feeb51d00000000, 0x3dfa16f100000000, 0xae61df8e00000000, 0x1bcd850e00000000, 0x88564c7100000000, 0x309241d500000000, 0xa30988aa00000000, 0x16a5d22a00000000, 0x853e1b5500000000, 0x3acc2fd100000000, 0xa957e6ae00000000, 0x1cfbbc2e00000000, 0x8f60755100000000, 0x37a478f500000000, 0xa43fb18a00000000, 0x1193eb0a00000000, 0x8208227500000000, 0x201c819900000000, 0xb38748e600000000, 0x062b126600000000, 0x95b0db1900000000, 0x2d74d6bd00000000, 0xbeef1fc200000000, 0x0b43454200000000, 0x98d88c3d00000000, 0x0e6c724000000000, 0x9df7bb3f00000000, 0x285be1bf00000000, 0xbbc028c000000000, 0x0304256400000000, 0x909fec1b00000000, 0x2533b69b00000000, 0xb6a87fe400000000, 0x14bcdc0800000000, 0x8727157700000000, 0x328b4ff700000000, 0xa110868800000000, 0x19d48b2c00000000, 0x8a4f425300000000, 0x3fe318d300000000, 0xac78d1ac00000000, 0x2614cb5100000000, 0xb58f022e00000000, 0x002358ae00000000, 0x93b891d100000000, 0x2b7c9c7500000000, 0xb8e7550a00000000, 0x0d4b0f8a00000000, 0x9ed0c6f500000000, 0x3cc4651900000000, 0xaf5fac6600000000, 0x1af3f6e600000000, 0x89683f9900000000, 0x31ac323d00000000, 0xa237fb4200000000, 0x179ba1c200000000, 0x840068bd00000000, 0x12b496c000000000, 0x812f5fbf00000000, 0x3483053f00000000, 0xa718cc4000000000, 0x1fdcc1e400000000, 0x8c47089b00000000, 0x39eb521b00000000, 0xaa709b6400000000, 0x0864388800000000, 0x9bfff1f700000000, 0x2e53ab7700000000, 0xbdc8620800000000, 0x050c6fac00000000, 0x9697a6d300000000, 0x233bfc5300000000, 0xb0a0352c00000000, 0x0f5201a800000000, 0x9cc9c8d700000000, 0x2965925700000000, 0xbafe5b2800000000, 0x023a568c00000000, 0x91a19ff300000000, 0x240dc57300000000, 0xb7960c0c00000000, 0x1582afe000000000, 0x8619669f00000000, 0x33b53c1f00000000, 0xa02ef56000000000, 0x18eaf8c400000000, 0x8b7131bb00000000, 0x3edd6b3b00000000, 0xad46a24400000000, 0x3bf25c3900000000, 0xa869954600000000, 0x1dc5cfc600000000, 0x8e5e06b900000000, 0x369a0b1d00000000, 0xa501c26200000000, 0x10ad98e200000000, 0x8336519d00000000, 0x2122f27100000000, 0xb2b93b0e00000000, 0x0715618e00000000, 0x948ea8f100000000, 0x2c4aa55500000000, 0xbfd16c2a00000000, 0x0a7d36aa00000000, 0x99e6ffd500000000, 0x359e2e7900000000, 0xa605e70600000000, 0x13a9bd8600000000, 0x803274f900000000, 0x38f6795d00000000, 0xab6db02200000000, 0x1ec1eaa200000000, 0x8d5a23dd00000000, 0x2f4e803100000000, 0xbcd5494e00000000, 0x097913ce00000000, 0x9ae2dab100000000, 0x2226d71500000000, 0xb1bd1e6a00000000, 0x041144ea00000000, 0x978a8d9500000000, 0x013e73e800000000, 0x92a5ba9700000000, 0x2709e01700000000, 0xb492296800000000, 0x0c5624cc00000000, 0x9fcdedb300000000, 0x2a61b73300000000, 0xb9fa7e4c00000000, 0x1beedda000000000, 0x887514df00000000, 0x3dd94e5f00000000, 0xae42872000000000, 0x16868a8400000000, 0x851d43fb00000000, 0x30b1197b00000000, 0xa32ad00400000000, 0x1cd8e48000000000, 0x8f432dff00000000, 0x3aef777f00000000, 0xa974be0000000000, 0x11b0b3a400000000, 0x822b7adb00000000, 0x3787205b00000000, 0xa41ce92400000000, 0x06084ac800000000, 0x959383b700000000, 0x203fd93700000000, 0xb3a4104800000000, 0x0b601dec00000000, 0x98fbd49300000000, 0x2d578e1300000000, 0xbecc476c00000000, 0x2878b91100000000, 0xbbe3706e00000000, 0x0e4f2aee00000000, 0x9dd4e39100000000, 0x2510ee3500000000, 0xb68b274a00000000, 0x03277dca00000000, 0x90bcb4b500000000, 0x32a8175900000000, 0xa133de2600000000, 0x149f84a600000000, 0x87044dd900000000, 0x3fc0407d00000000, 0xac5b890200000000, 0x19f7d38200000000, 0x8a6c1afd00000000}, {0x0000000000000000, 0x650b796900000000, 0xca16f2d200000000, 0xaf1d8bbb00000000, 0xd52b957e00000000, 0xb020ec1700000000, 0x1f3d67ac00000000, 0x7a361ec500000000, 0xaa572afd00000000, 0xcf5c539400000000, 0x6041d82f00000000, 0x054aa14600000000, 0x7f7cbf8300000000, 0x1a77c6ea00000000, 0xb56a4d5100000000, 0xd061343800000000, 0x15a9252100000000, 0x70a25c4800000000, 0xdfbfd7f300000000, 0xbab4ae9a00000000, 0xc082b05f00000000, 0xa589c93600000000, 0x0a94428d00000000, 0x6f9f3be400000000, 0xbffe0fdc00000000, 0xdaf576b500000000, 0x75e8fd0e00000000, 0x10e3846700000000, 0x6ad59aa200000000, 0x0fdee3cb00000000, 0xa0c3687000000000, 0xc5c8111900000000, 0x2a524b4200000000, 0x4f59322b00000000, 0xe044b99000000000, 0x854fc0f900000000, 0xff79de3c00000000, 0x9a72a75500000000, 0x356f2cee00000000, 0x5064558700000000, 0x800561bf00000000, 0xe50e18d600000000, 0x4a13936d00000000, 0x2f18ea0400000000, 0x552ef4c100000000, 0x30258da800000000, 0x9f38061300000000, 0xfa337f7a00000000, 0x3ffb6e6300000000, 0x5af0170a00000000, 0xf5ed9cb100000000, 0x90e6e5d800000000, 0xead0fb1d00000000, 0x8fdb827400000000, 0x20c609cf00000000, 0x45cd70a600000000, 0x95ac449e00000000, 0xf0a73df700000000, 0x5fbab64c00000000, 0x3ab1cf2500000000, 0x4087d1e000000000, 0x258ca88900000000, 0x8a91233200000000, 0xef9a5a5b00000000, 0x54a4968400000000, 0x31afefed00000000, 0x9eb2645600000000, 0xfbb91d3f00000000, 0x818f03fa00000000, 0xe4847a9300000000, 0x4b99f12800000000, 0x2e92884100000000, 0xfef3bc7900000000, 0x9bf8c51000000000, 0x34e54eab00000000, 0x51ee37c200000000, 0x2bd8290700000000, 0x4ed3506e00000000, 0xe1cedbd500000000, 0x84c5a2bc00000000, 0x410db3a500000000, 0x2406cacc00000000, 0x8b1b417700000000, 0xee10381e00000000, 0x942626db00000000, 0xf12d5fb200000000, 0x5e30d40900000000, 0x3b3bad6000000000, 0xeb5a995800000000, 0x8e51e03100000000, 0x214c6b8a00000000, 0x444712e300000000, 0x3e710c2600000000, 0x5b7a754f00000000, 0xf467fef400000000, 0x916c879d00000000, 0x7ef6ddc600000000, 0x1bfda4af00000000, 0xb4e02f1400000000, 0xd1eb567d00000000, 0xabdd48b800000000, 0xced631d100000000, 0x61cbba6a00000000, 0x04c0c30300000000, 0xd4a1f73b00000000, 0xb1aa8e5200000000, 0x1eb705e900000000, 0x7bbc7c8000000000, 0x018a624500000000, 0x64811b2c00000000, 0xcb9c909700000000, 0xae97e9fe00000000, 0x6b5ff8e700000000, 0x0e54818e00000000, 0xa1490a3500000000, 0xc442735c00000000, 0xbe746d9900000000, 0xdb7f14f000000000, 0x74629f4b00000000, 0x1169e62200000000, 0xc108d21a00000000, 0xa403ab7300000000, 0x0b1e20c800000000, 0x6e1559a100000000, 0x1423476400000000, 0x71283e0d00000000, 0xde35b5b600000000, 0xbb3eccdf00000000, 0xe94e5cd200000000, 0x8c4525bb00000000, 0x2358ae0000000000, 0x4653d76900000000, 0x3c65c9ac00000000, 0x596eb0c500000000, 0xf6733b7e00000000, 0x9378421700000000, 0x4319762f00000000, 0x26120f4600000000, 0x890f84fd00000000, 0xec04fd9400000000, 0x9632e35100000000, 0xf3399a3800000000, 0x5c24118300000000, 0x392f68ea00000000, 0xfce779f300000000, 0x99ec009a00000000, 0x36f18b2100000000, 0x53faf24800000000, 0x29ccec8d00000000, 0x4cc795e400000000, 0xe3da1e5f00000000, 0x86d1673600000000, 0x56b0530e00000000, 0x33bb2a6700000000, 0x9ca6a1dc00000000, 0xf9add8b500000000, 0x839bc67000000000, 0xe690bf1900000000, 0x498d34a200000000, 0x2c864dcb00000000, 0xc31c179000000000, 0xa6176ef900000000, 0x090ae54200000000, 0x6c019c2b00000000, 0x163782ee00000000, 0x733cfb8700000000, 0xdc21703c00000000, 0xb92a095500000000, 0x694b3d6d00000000, 0x0c40440400000000, 0xa35dcfbf00000000, 0xc656b6d600000000, 0xbc60a81300000000, 0xd96bd17a00000000, 0x76765ac100000000, 0x137d23a800000000, 0xd6b532b100000000, 0xb3be4bd800000000, 0x1ca3c06300000000, 0x79a8b90a00000000, 0x039ea7cf00000000, 0x6695dea600000000, 0xc988551d00000000, 0xac832c7400000000, 0x7ce2184c00000000, 0x19e9612500000000, 0xb6f4ea9e00000000, 0xd3ff93f700000000, 0xa9c98d3200000000, 0xccc2f45b00000000, 0x63df7fe000000000, 0x06d4068900000000, 0xbdeaca5600000000, 0xd8e1b33f00000000, 0x77fc388400000000, 0x12f741ed00000000, 0x68c15f2800000000, 0x0dca264100000000, 0xa2d7adfa00000000, 0xc7dcd49300000000, 0x17bde0ab00000000, 0x72b699c200000000, 0xddab127900000000, 0xb8a06b1000000000, 0xc29675d500000000, 0xa79d0cbc00000000, 0x0880870700000000, 0x6d8bfe6e00000000, 0xa843ef7700000000, 0xcd48961e00000000, 0x62551da500000000, 0x075e64cc00000000, 0x7d687a0900000000, 0x1863036000000000, 0xb77e88db00000000, 0xd275f1b200000000, 0x0214c58a00000000, 0x671fbce300000000, 0xc802375800000000, 0xad094e3100000000, 0xd73f50f400000000, 0xb234299d00000000, 0x1d29a22600000000, 0x7822db4f00000000, 0x97b8811400000000, 0xf2b3f87d00000000, 0x5dae73c600000000, 0x38a50aaf00000000, 0x4293146a00000000, 0x27986d0300000000, 0x8885e6b800000000, 0xed8e9fd100000000, 0x3defabe900000000, 0x58e4d28000000000, 0xf7f9593b00000000, 0x92f2205200000000, 0xe8c43e9700000000, 0x8dcf47fe00000000, 0x22d2cc4500000000, 0x47d9b52c00000000, 0x8211a43500000000, 0xe71add5c00000000, 0x480756e700000000, 0x2d0c2f8e00000000, 0x573a314b00000000, 0x3231482200000000, 0x9d2cc39900000000, 0xf827baf000000000, 0x28468ec800000000, 0x4d4df7a100000000, 0xe2507c1a00000000, 0x875b057300000000, 0xfd6d1bb600000000, 0x986662df00000000, 0x377be96400000000, 0x5270900d00000000}, {0x0000000000000000, 0xdcecb13d00000000, 0xb8d9637b00000000, 0x6435d24600000000, 0x70b3c7f600000000, 0xac5f76cb00000000, 0xc86aa48d00000000, 0x148615b000000000, 0xa160fe3600000000, 0x7d8c4f0b00000000, 0x19b99d4d00000000, 0xc5552c7000000000, 0xd1d339c000000000, 0x0d3f88fd00000000, 0x690a5abb00000000, 0xb5e6eb8600000000, 0x42c1fc6d00000000, 0x9e2d4d5000000000, 0xfa189f1600000000, 0x26f42e2b00000000, 0x32723b9b00000000, 0xee9e8aa600000000, 0x8aab58e000000000, 0x5647e9dd00000000, 0xe3a1025b00000000, 0x3f4db36600000000, 0x5b78612000000000, 0x8794d01d00000000, 0x9312c5ad00000000, 0x4ffe749000000000, 0x2bcba6d600000000, 0xf72717eb00000000, 0x8482f9db00000000, 0x586e48e600000000, 0x3c5b9aa000000000, 0xe0b72b9d00000000, 0xf4313e2d00000000, 0x28dd8f1000000000, 0x4ce85d5600000000, 0x9004ec6b00000000, 0x25e207ed00000000, 0xf90eb6d000000000, 0x9d3b649600000000, 0x41d7d5ab00000000, 0x5551c01b00000000, 0x89bd712600000000, 0xed88a36000000000, 0x3164125d00000000, 0xc64305b600000000, 0x1aafb48b00000000, 0x7e9a66cd00000000, 0xa276d7f000000000, 0xb6f0c24000000000, 0x6a1c737d00000000, 0x0e29a13b00000000, 0xd2c5100600000000, 0x6723fb8000000000, 0xbbcf4abd00000000, 0xdffa98fb00000000, 0x031629c600000000, 0x17903c7600000000, 0xcb7c8d4b00000000, 0xaf495f0d00000000, 0x73a5ee3000000000, 0x4903826c00000000, 0x95ef335100000000, 0xf1dae11700000000, 0x2d36502a00000000, 0x39b0459a00000000, 0xe55cf4a700000000, 0x816926e100000000, 0x5d8597dc00000000, 0xe8637c5a00000000, 0x348fcd6700000000, 0x50ba1f2100000000, 0x8c56ae1c00000000, 0x98d0bbac00000000, 0x443c0a9100000000, 0x2009d8d700000000, 0xfce569ea00000000, 0x0bc27e0100000000, 0xd72ecf3c00000000, 0xb31b1d7a00000000, 0x6ff7ac4700000000, 0x7b71b9f700000000, 0xa79d08ca00000000, 0xc3a8da8c00000000, 0x1f446bb100000000, 0xaaa2803700000000, 0x764e310a00000000, 0x127be34c00000000, 0xce97527100000000, 0xda1147c100000000, 0x06fdf6fc00000000, 0x62c824ba00000000, 0xbe24958700000000, 0xcd817bb700000000, 0x116dca8a00000000, 0x755818cc00000000, 0xa9b4a9f100000000, 0xbd32bc4100000000, 0x61de0d7c00000000, 0x05ebdf3a00000000, 0xd9076e0700000000, 0x6ce1858100000000, 0xb00d34bc00000000, 0xd438e6fa00000000, 0x08d457c700000000, 0x1c52427700000000, 0xc0bef34a00000000, 0xa48b210c00000000, 0x7867903100000000, 0x8f4087da00000000, 0x53ac36e700000000, 0x3799e4a100000000, 0xeb75559c00000000, 0xfff3402c00000000, 0x231ff11100000000, 0x472a235700000000, 0x9bc6926a00000000, 0x2e2079ec00000000, 0xf2ccc8d100000000, 0x96f91a9700000000, 0x4a15abaa00000000, 0x5e93be1a00000000, 0x827f0f2700000000, 0xe64add6100000000, 0x3aa66c5c00000000, 0x920604d900000000, 0x4eeab5e400000000, 0x2adf67a200000000, 0xf633d69f00000000, 0xe2b5c32f00000000, 0x3e59721200000000, 0x5a6ca05400000000, 0x8680116900000000, 0x3366faef00000000, 0xef8a4bd200000000, 0x8bbf999400000000, 0x575328a900000000, 0x43d53d1900000000, 0x9f398c2400000000, 0xfb0c5e6200000000, 0x27e0ef5f00000000, 0xd0c7f8b400000000, 0x0c2b498900000000, 0x681e9bcf00000000, 0xb4f22af200000000, 0xa0743f4200000000, 0x7c988e7f00000000, 0x18ad5c3900000000, 0xc441ed0400000000, 0x71a7068200000000, 0xad4bb7bf00000000, 0xc97e65f900000000, 0x1592d4c400000000, 0x0114c17400000000, 0xddf8704900000000, 0xb9cda20f00000000, 0x6521133200000000, 0x1684fd0200000000, 0xca684c3f00000000, 0xae5d9e7900000000, 0x72b12f4400000000, 0x66373af400000000, 0xbadb8bc900000000, 0xdeee598f00000000, 0x0202e8b200000000, 0xb7e4033400000000, 0x6b08b20900000000, 0x0f3d604f00000000, 0xd3d1d17200000000, 0xc757c4c200000000, 0x1bbb75ff00000000, 0x7f8ea7b900000000, 0xa362168400000000, 0x5445016f00000000, 0x88a9b05200000000, 0xec9c621400000000, 0x3070d32900000000, 0x24f6c69900000000, 0xf81a77a400000000, 0x9c2fa5e200000000, 0x40c314df00000000, 0xf525ff5900000000, 0x29c94e6400000000, 0x4dfc9c2200000000, 0x91102d1f00000000, 0x859638af00000000, 0x597a899200000000, 0x3d4f5bd400000000, 0xe1a3eae900000000, 0xdb0586b500000000, 0x07e9378800000000, 0x63dce5ce00000000, 0xbf3054f300000000, 0xabb6414300000000, 0x775af07e00000000, 0x136f223800000000, 0xcf83930500000000, 0x7a65788300000000, 0xa689c9be00000000, 0xc2bc1bf800000000, 0x1e50aac500000000, 0x0ad6bf7500000000, 0xd63a0e4800000000, 0xb20fdc0e00000000, 0x6ee36d3300000000, 0x99c47ad800000000, 0x4528cbe500000000, 0x211d19a300000000, 0xfdf1a89e00000000, 0xe977bd2e00000000, 0x359b0c1300000000, 0x51aede5500000000, 0x8d426f6800000000, 0x38a484ee00000000, 0xe44835d300000000, 0x807de79500000000, 0x5c9156a800000000, 0x4817431800000000, 0x94fbf22500000000, 0xf0ce206300000000, 0x2c22915e00000000, 0x5f877f6e00000000, 0x836bce5300000000, 0xe75e1c1500000000, 0x3bb2ad2800000000, 0x2f34b89800000000, 0xf3d809a500000000, 0x97eddbe300000000, 0x4b016ade00000000, 0xfee7815800000000, 0x220b306500000000, 0x463ee22300000000, 0x9ad2531e00000000, 0x8e5446ae00000000, 0x52b8f79300000000, 0x368d25d500000000, 0xea6194e800000000, 0x1d46830300000000, 0xc1aa323e00000000, 0xa59fe07800000000, 0x7973514500000000, 0x6df544f500000000, 0xb119f5c800000000, 0xd52c278e00000000, 0x09c096b300000000, 0xbc267d3500000000, 0x60cacc0800000000, 0x04ff1e4e00000000, 0xd813af7300000000, 0xcc95bac300000000, 0x10790bfe00000000, 0x744cd9b800000000, 0xa8a0688500000000}}; #else /* W == 4 */ local const z_crc_t FAR crc_braid_table[][256] = { {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, 0x09cd8551}, {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, 0x7bc97a0c}, {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, 0x7851a2ca}, {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, 0x566b6848}}; local const z_word_t FAR crc_braid_big_table[][256] = { {0x00000000, 0x9e83da9f, 0x7d01c4e4, 0xe3821e7b, 0xbb04f912, 0x2587238d, 0xc6053df6, 0x5886e769, 0x7609f225, 0xe88a28ba, 0x0b0836c1, 0x958bec5e, 0xcd0d0b37, 0x538ed1a8, 0xb00ccfd3, 0x2e8f154c, 0xec12e44b, 0x72913ed4, 0x911320af, 0x0f90fa30, 0x57161d59, 0xc995c7c6, 0x2a17d9bd, 0xb4940322, 0x9a1b166e, 0x0498ccf1, 0xe71ad28a, 0x79990815, 0x211fef7c, 0xbf9c35e3, 0x5c1e2b98, 0xc29df107, 0xd825c897, 0x46a61208, 0xa5240c73, 0x3ba7d6ec, 0x63213185, 0xfda2eb1a, 0x1e20f561, 0x80a32ffe, 0xae2c3ab2, 0x30afe02d, 0xd32dfe56, 0x4dae24c9, 0x1528c3a0, 0x8bab193f, 0x68290744, 0xf6aadddb, 0x34372cdc, 0xaab4f643, 0x4936e838, 0xd7b532a7, 0x8f33d5ce, 0x11b00f51, 0xf232112a, 0x6cb1cbb5, 0x423edef9, 0xdcbd0466, 0x3f3f1a1d, 0xa1bcc082, 0xf93a27eb, 0x67b9fd74, 0x843be30f, 0x1ab83990, 0xf14de1f4, 0x6fce3b6b, 0x8c4c2510, 0x12cfff8f, 0x4a4918e6, 0xd4cac279, 0x3748dc02, 0xa9cb069d, 0x874413d1, 0x19c7c94e, 0xfa45d735, 0x64c60daa, 0x3c40eac3, 0xa2c3305c, 0x41412e27, 0xdfc2f4b8, 0x1d5f05bf, 0x83dcdf20, 0x605ec15b, 0xfedd1bc4, 0xa65bfcad, 0x38d82632, 0xdb5a3849, 0x45d9e2d6, 0x6b56f79a, 0xf5d52d05, 0x1657337e, 0x88d4e9e1, 0xd0520e88, 0x4ed1d417, 0xad53ca6c, 0x33d010f3, 0x29682963, 0xb7ebf3fc, 0x5469ed87, 0xcaea3718, 0x926cd071, 0x0cef0aee, 0xef6d1495, 0x71eece0a, 0x5f61db46, 0xc1e201d9, 0x22601fa2, 0xbce3c53d, 0xe4652254, 0x7ae6f8cb, 0x9964e6b0, 0x07e73c2f, 0xc57acd28, 0x5bf917b7, 0xb87b09cc, 0x26f8d353, 0x7e7e343a, 0xe0fdeea5, 0x037ff0de, 0x9dfc2a41, 0xb3733f0d, 0x2df0e592, 0xce72fbe9, 0x50f12176, 0x0877c61f, 0x96f41c80, 0x757602fb, 0xebf5d864, 0xa39db332, 0x3d1e69ad, 0xde9c77d6, 0x401fad49, 0x18994a20, 0x861a90bf, 0x65988ec4, 0xfb1b545b, 0xd5944117, 0x4b179b88, 0xa89585f3, 0x36165f6c, 0x6e90b805, 0xf013629a, 0x13917ce1, 0x8d12a67e, 0x4f8f5779, 0xd10c8de6, 0x328e939d, 0xac0d4902, 0xf48bae6b, 0x6a0874f4, 0x898a6a8f, 0x1709b010, 0x3986a55c, 0xa7057fc3, 0x448761b8, 0xda04bb27, 0x82825c4e, 0x1c0186d1, 0xff8398aa, 0x61004235, 0x7bb87ba5, 0xe53ba13a, 0x06b9bf41, 0x983a65de, 0xc0bc82b7, 0x5e3f5828, 0xbdbd4653, 0x233e9ccc, 0x0db18980, 0x9332531f, 0x70b04d64, 0xee3397fb, 0xb6b57092, 0x2836aa0d, 0xcbb4b476, 0x55376ee9, 0x97aa9fee, 0x09294571, 0xeaab5b0a, 0x74288195, 0x2cae66fc, 0xb22dbc63, 0x51afa218, 0xcf2c7887, 0xe1a36dcb, 0x7f20b754, 0x9ca2a92f, 0x022173b0, 0x5aa794d9, 0xc4244e46, 0x27a6503d, 0xb9258aa2, 0x52d052c6, 0xcc538859, 0x2fd19622, 0xb1524cbd, 0xe9d4abd4, 0x7757714b, 0x94d56f30, 0x0a56b5af, 0x24d9a0e3, 0xba5a7a7c, 0x59d86407, 0xc75bbe98, 0x9fdd59f1, 0x015e836e, 0xe2dc9d15, 0x7c5f478a, 0xbec2b68d, 0x20416c12, 0xc3c37269, 0x5d40a8f6, 0x05c64f9f, 0x9b459500, 0x78c78b7b, 0xe64451e4, 0xc8cb44a8, 0x56489e37, 0xb5ca804c, 0x2b495ad3, 0x73cfbdba, 0xed4c6725, 0x0ece795e, 0x904da3c1, 0x8af59a51, 0x147640ce, 0xf7f45eb5, 0x6977842a, 0x31f16343, 0xaf72b9dc, 0x4cf0a7a7, 0xd2737d38, 0xfcfc6874, 0x627fb2eb, 0x81fdac90, 0x1f7e760f, 0x47f89166, 0xd97b4bf9, 0x3af95582, 0xa47a8f1d, 0x66e77e1a, 0xf864a485, 0x1be6bafe, 0x85656061, 0xdde38708, 0x43605d97, 0xa0e243ec, 0x3e619973, 0x10ee8c3f, 0x8e6d56a0, 0x6def48db, 0xf36c9244, 0xabea752d, 0x3569afb2, 0xd6ebb1c9, 0x48686b56}, {0x00000000, 0xc0642817, 0x80c9502e, 0x40ad7839, 0x0093a15c, 0xc0f7894b, 0x805af172, 0x403ed965, 0x002643b9, 0xc0426bae, 0x80ef1397, 0x408b3b80, 0x00b5e2e5, 0xc0d1caf2, 0x807cb2cb, 0x40189adc, 0x414af7a9, 0x812edfbe, 0xc183a787, 0x01e78f90, 0x41d956f5, 0x81bd7ee2, 0xc11006db, 0x01742ecc, 0x416cb410, 0x81089c07, 0xc1a5e43e, 0x01c1cc29, 0x41ff154c, 0x819b3d5b, 0xc1364562, 0x01526d75, 0xc3929f88, 0x03f6b79f, 0x435bcfa6, 0x833fe7b1, 0xc3013ed4, 0x036516c3, 0x43c86efa, 0x83ac46ed, 0xc3b4dc31, 0x03d0f426, 0x437d8c1f, 0x8319a408, 0xc3277d6d, 0x0343557a, 0x43ee2d43, 0x838a0554, 0x82d86821, 0x42bc4036, 0x0211380f, 0xc2751018, 0x824bc97d, 0x422fe16a, 0x02829953, 0xc2e6b144, 0x82fe2b98, 0x429a038f, 0x02377bb6, 0xc25353a1, 0x826d8ac4, 0x4209a2d3, 0x02a4daea, 0xc2c0f2fd, 0xc7234eca, 0x074766dd, 0x47ea1ee4, 0x878e36f3, 0xc7b0ef96, 0x07d4c781, 0x4779bfb8, 0x871d97af, 0xc7050d73, 0x07612564, 0x47cc5d5d, 0x87a8754a, 0xc796ac2f, 0x07f28438, 0x475ffc01, 0x873bd416, 0x8669b963, 0x460d9174, 0x06a0e94d, 0xc6c4c15a, 0x86fa183f, 0x469e3028, 0x06334811, 0xc6576006, 0x864ffada, 0x462bd2cd, 0x0686aaf4, 0xc6e282e3, 0x86dc5b86, 0x46b87391, 0x06150ba8, 0xc67123bf, 0x04b1d142, 0xc4d5f955, 0x8478816c, 0x441ca97b, 0x0422701e, 0xc4465809, 0x84eb2030, 0x448f0827, 0x049792fb, 0xc4f3baec, 0x845ec2d5, 0x443aeac2, 0x040433a7, 0xc4601bb0, 0x84cd6389, 0x44a94b9e, 0x45fb26eb, 0x859f0efc, 0xc53276c5, 0x05565ed2, 0x456887b7, 0x850cafa0, 0xc5a1d799, 0x05c5ff8e, 0x45dd6552, 0x85b94d45, 0xc514357c, 0x05701d6b, 0x454ec40e, 0x852aec19, 0xc5879420, 0x05e3bc37, 0xcf41ed4f, 0x0f25c558, 0x4f88bd61, 0x8fec9576, 0xcfd24c13, 0x0fb66404, 0x4f1b1c3d, 0x8f7f342a, 0xcf67aef6, 0x0f0386e1, 0x4faefed8, 0x8fcad6cf, 0xcff40faa, 0x0f9027bd, 0x4f3d5f84, 0x8f597793, 0x8e0b1ae6, 0x4e6f32f1, 0x0ec24ac8, 0xcea662df, 0x8e98bbba, 0x4efc93ad, 0x0e51eb94, 0xce35c383, 0x8e2d595f, 0x4e497148, 0x0ee40971, 0xce802166, 0x8ebef803, 0x4edad014, 0x0e77a82d, 0xce13803a, 0x0cd372c7, 0xccb75ad0, 0x8c1a22e9, 0x4c7e0afe, 0x0c40d39b, 0xcc24fb8c, 0x8c8983b5, 0x4cedaba2, 0x0cf5317e, 0xcc911969, 0x8c3c6150, 0x4c584947, 0x0c669022, 0xcc02b835, 0x8cafc00c, 0x4ccbe81b, 0x4d99856e, 0x8dfdad79, 0xcd50d540, 0x0d34fd57, 0x4d0a2432, 0x8d6e0c25, 0xcdc3741c, 0x0da75c0b, 0x4dbfc6d7, 0x8ddbeec0, 0xcd7696f9, 0x0d12beee, 0x4d2c678b, 0x8d484f9c, 0xcde537a5, 0x0d811fb2, 0x0862a385, 0xc8068b92, 0x88abf3ab, 0x48cfdbbc, 0x08f102d9, 0xc8952ace, 0x883852f7, 0x485c7ae0, 0x0844e03c, 0xc820c82b, 0x888db012, 0x48e99805, 0x08d74160, 0xc8b36977, 0x881e114e, 0x487a3959, 0x4928542c, 0x894c7c3b, 0xc9e10402, 0x09852c15, 0x49bbf570, 0x89dfdd67, 0xc972a55e, 0x09168d49, 0x490e1795, 0x896a3f82, 0xc9c747bb, 0x09a36fac, 0x499db6c9, 0x89f99ede, 0xc954e6e7, 0x0930cef0, 0xcbf03c0d, 0x0b94141a, 0x4b396c23, 0x8b5d4434, 0xcb639d51, 0x0b07b546, 0x4baacd7f, 0x8bcee568, 0xcbd67fb4, 0x0bb257a3, 0x4b1f2f9a, 0x8b7b078d, 0xcb45dee8, 0x0b21f6ff, 0x4b8c8ec6, 0x8be8a6d1, 0x8abacba4, 0x4adee3b3, 0x0a739b8a, 0xca17b39d, 0x8a296af8, 0x4a4d42ef, 0x0ae03ad6, 0xca8412c1, 0x8a9c881d, 0x4af8a00a, 0x0a55d833, 0xca31f024, 0x8a0f2941, 0x4a6b0156, 0x0ac6796f, 0xcaa25178}, {0x00000000, 0xd4ea739b, 0xe9d396ed, 0x3d39e576, 0x93a15c00, 0x474b2f9b, 0x7a72caed, 0xae98b976, 0x2643b900, 0xf2a9ca9b, 0xcf902fed, 0x1b7a5c76, 0xb5e2e500, 0x6108969b, 0x5c3173ed, 0x88db0076, 0x4c867201, 0x986c019a, 0xa555e4ec, 0x71bf9777, 0xdf272e01, 0x0bcd5d9a, 0x36f4b8ec, 0xe21ecb77, 0x6ac5cb01, 0xbe2fb89a, 0x83165dec, 0x57fc2e77, 0xf9649701, 0x2d8ee49a, 0x10b701ec, 0xc45d7277, 0x980ce502, 0x4ce69699, 0x71df73ef, 0xa5350074, 0x0badb902, 0xdf47ca99, 0xe27e2fef, 0x36945c74, 0xbe4f5c02, 0x6aa52f99, 0x579ccaef, 0x8376b974, 0x2dee0002, 0xf9047399, 0xc43d96ef, 0x10d7e574, 0xd48a9703, 0x0060e498, 0x3d5901ee, 0xe9b37275, 0x472bcb03, 0x93c1b898, 0xaef85dee, 0x7a122e75, 0xf2c92e03, 0x26235d98, 0x1b1ab8ee, 0xcff0cb75, 0x61687203, 0xb5820198, 0x88bbe4ee, 0x5c519775, 0x3019ca05, 0xe4f3b99e, 0xd9ca5ce8, 0x0d202f73, 0xa3b89605, 0x7752e59e, 0x4a6b00e8, 0x9e817373, 0x165a7305, 0xc2b0009e, 0xff89e5e8, 0x2b639673, 0x85fb2f05, 0x51115c9e, 0x6c28b9e8, 0xb8c2ca73, 0x7c9fb804, 0xa875cb9f, 0x954c2ee9, 0x41a65d72, 0xef3ee404, 0x3bd4979f, 0x06ed72e9, 0xd2070172, 0x5adc0104, 0x8e36729f, 0xb30f97e9, 0x67e5e472, 0xc97d5d04, 0x1d972e9f, 0x20aecbe9, 0xf444b872, 0xa8152f07, 0x7cff5c9c, 0x41c6b9ea, 0x952cca71, 0x3bb47307, 0xef5e009c, 0xd267e5ea, 0x068d9671, 0x8e569607, 0x5abce59c, 0x678500ea, 0xb36f7371, 0x1df7ca07, 0xc91db99c, 0xf4245cea, 0x20ce2f71, 0xe4935d06, 0x30792e9d, 0x0d40cbeb, 0xd9aab870, 0x77320106, 0xa3d8729d, 0x9ee197eb, 0x4a0be470, 0xc2d0e406, 0x163a979d, 0x2b0372eb, 0xffe90170, 0x5171b806, 0x859bcb9d, 0xb8a22eeb, 0x6c485d70, 0x6032940b, 0xb4d8e790, 0x89e102e6, 0x5d0b717d, 0xf393c80b, 0x2779bb90, 0x1a405ee6, 0xceaa2d7d, 0x46712d0b, 0x929b5e90, 0xafa2bbe6, 0x7b48c87d, 0xd5d0710b, 0x013a0290, 0x3c03e7e6, 0xe8e9947d, 0x2cb4e60a, 0xf85e9591, 0xc56770e7, 0x118d037c, 0xbf15ba0a, 0x6bffc991, 0x56c62ce7, 0x822c5f7c, 0x0af75f0a, 0xde1d2c91, 0xe324c9e7, 0x37ceba7c, 0x9956030a, 0x4dbc7091, 0x708595e7, 0xa46fe67c, 0xf83e7109, 0x2cd40292, 0x11ede7e4, 0xc507947f, 0x6b9f2d09, 0xbf755e92, 0x824cbbe4, 0x56a6c87f, 0xde7dc809, 0x0a97bb92, 0x37ae5ee4, 0xe3442d7f, 0x4ddc9409, 0x9936e792, 0xa40f02e4, 0x70e5717f, 0xb4b80308, 0x60527093, 0x5d6b95e5, 0x8981e67e, 0x27195f08, 0xf3f32c93, 0xcecac9e5, 0x1a20ba7e, 0x92fbba08, 0x4611c993, 0x7b282ce5, 0xafc25f7e, 0x015ae608, 0xd5b09593, 0xe88970e5, 0x3c63037e, 0x502b5e0e, 0x84c12d95, 0xb9f8c8e3, 0x6d12bb78, 0xc38a020e, 0x17607195, 0x2a5994e3, 0xfeb3e778, 0x7668e70e, 0xa2829495, 0x9fbb71e3, 0x4b510278, 0xe5c9bb0e, 0x3123c895, 0x0c1a2de3, 0xd8f05e78, 0x1cad2c0f, 0xc8475f94, 0xf57ebae2, 0x2194c979, 0x8f0c700f, 0x5be60394, 0x66dfe6e2, 0xb2359579, 0x3aee950f, 0xee04e694, 0xd33d03e2, 0x07d77079, 0xa94fc90f, 0x7da5ba94, 0x409c5fe2, 0x94762c79, 0xc827bb0c, 0x1ccdc897, 0x21f42de1, 0xf51e5e7a, 0x5b86e70c, 0x8f6c9497, 0xb25571e1, 0x66bf027a, 0xee64020c, 0x3a8e7197, 0x07b794e1, 0xd35de77a, 0x7dc55e0c, 0xa92f2d97, 0x9416c8e1, 0x40fcbb7a, 0x84a1c90d, 0x504bba96, 0x6d725fe0, 0xb9982c7b, 0x1700950d, 0xc3eae696, 0xfed303e0, 0x2a39707b, 0xa2e2700d, 0x76080396, 0x4b31e6e0, 0x9fdb957b, 0x31432c0d, 0xe5a95f96, 0xd890bae0, 0x0c7ac97b}, {0x00000000, 0x27652581, 0x0fcc3bd9, 0x28a91e58, 0x5f9e0669, 0x78fb23e8, 0x50523db0, 0x77371831, 0xbe3c0dd2, 0x99592853, 0xb1f0360b, 0x9695138a, 0xe1a20bbb, 0xc6c72e3a, 0xee6e3062, 0xc90b15e3, 0x3d7f6b7f, 0x1a1a4efe, 0x32b350a6, 0x15d67527, 0x62e16d16, 0x45844897, 0x6d2d56cf, 0x4a48734e, 0x834366ad, 0xa426432c, 0x8c8f5d74, 0xabea78f5, 0xdcdd60c4, 0xfbb84545, 0xd3115b1d, 0xf4747e9c, 0x7afed6fe, 0x5d9bf37f, 0x7532ed27, 0x5257c8a6, 0x2560d097, 0x0205f516, 0x2aaceb4e, 0x0dc9cecf, 0xc4c2db2c, 0xe3a7fead, 0xcb0ee0f5, 0xec6bc574, 0x9b5cdd45, 0xbc39f8c4, 0x9490e69c, 0xb3f5c31d, 0x4781bd81, 0x60e49800, 0x484d8658, 0x6f28a3d9, 0x181fbbe8, 0x3f7a9e69, 0x17d38031, 0x30b6a5b0, 0xf9bdb053, 0xded895d2, 0xf6718b8a, 0xd114ae0b, 0xa623b63a, 0x814693bb, 0xa9ef8de3, 0x8e8aa862, 0xb5fadc26, 0x929ff9a7, 0xba36e7ff, 0x9d53c27e, 0xea64da4f, 0xcd01ffce, 0xe5a8e196, 0xc2cdc417, 0x0bc6d1f4, 0x2ca3f475, 0x040aea2d, 0x236fcfac, 0x5458d79d, 0x733df21c, 0x5b94ec44, 0x7cf1c9c5, 0x8885b759, 0xafe092d8, 0x87498c80, 0xa02ca901, 0xd71bb130, 0xf07e94b1, 0xd8d78ae9, 0xffb2af68, 0x36b9ba8b, 0x11dc9f0a, 0x39758152, 0x1e10a4d3, 0x6927bce2, 0x4e429963, 0x66eb873b, 0x418ea2ba, 0xcf040ad8, 0xe8612f59, 0xc0c83101, 0xe7ad1480, 0x909a0cb1, 0xb7ff2930, 0x9f563768, 0xb83312e9, 0x7138070a, 0x565d228b, 0x7ef43cd3, 0x59911952, 0x2ea60163, 0x09c324e2, 0x216a3aba, 0x060f1f3b, 0xf27b61a7, 0xd51e4426, 0xfdb75a7e, 0xdad27fff, 0xade567ce, 0x8a80424f, 0xa2295c17, 0x854c7996, 0x4c476c75, 0x6b2249f4, 0x438b57ac, 0x64ee722d, 0x13d96a1c, 0x34bc4f9d, 0x1c1551c5, 0x3b707444, 0x6af5b94d, 0x4d909ccc, 0x65398294, 0x425ca715, 0x356bbf24, 0x120e9aa5, 0x3aa784fd, 0x1dc2a17c, 0xd4c9b49f, 0xf3ac911e, 0xdb058f46, 0xfc60aac7, 0x8b57b2f6, 0xac329777, 0x849b892f, 0xa3feacae, 0x578ad232, 0x70eff7b3, 0x5846e9eb, 0x7f23cc6a, 0x0814d45b, 0x2f71f1da, 0x07d8ef82, 0x20bdca03, 0xe9b6dfe0, 0xced3fa61, 0xe67ae439, 0xc11fc1b8, 0xb628d989, 0x914dfc08, 0xb9e4e250, 0x9e81c7d1, 0x100b6fb3, 0x376e4a32, 0x1fc7546a, 0x38a271eb, 0x4f9569da, 0x68f04c5b, 0x40595203, 0x673c7782, 0xae376261, 0x895247e0, 0xa1fb59b8, 0x869e7c39, 0xf1a96408, 0xd6cc4189, 0xfe655fd1, 0xd9007a50, 0x2d7404cc, 0x0a11214d, 0x22b83f15, 0x05dd1a94, 0x72ea02a5, 0x558f2724, 0x7d26397c, 0x5a431cfd, 0x9348091e, 0xb42d2c9f, 0x9c8432c7, 0xbbe11746, 0xccd60f77, 0xebb32af6, 0xc31a34ae, 0xe47f112f, 0xdf0f656b, 0xf86a40ea, 0xd0c35eb2, 0xf7a67b33, 0x80916302, 0xa7f44683, 0x8f5d58db, 0xa8387d5a, 0x613368b9, 0x46564d38, 0x6eff5360, 0x499a76e1, 0x3ead6ed0, 0x19c84b51, 0x31615509, 0x16047088, 0xe2700e14, 0xc5152b95, 0xedbc35cd, 0xcad9104c, 0xbdee087d, 0x9a8b2dfc, 0xb22233a4, 0x95471625, 0x5c4c03c6, 0x7b292647, 0x5380381f, 0x74e51d9e, 0x03d205af, 0x24b7202e, 0x0c1e3e76, 0x2b7b1bf7, 0xa5f1b395, 0x82949614, 0xaa3d884c, 0x8d58adcd, 0xfa6fb5fc, 0xdd0a907d, 0xf5a38e25, 0xd2c6aba4, 0x1bcdbe47, 0x3ca89bc6, 0x1401859e, 0x3364a01f, 0x4453b82e, 0x63369daf, 0x4b9f83f7, 0x6cfaa676, 0x988ed8ea, 0xbfebfd6b, 0x9742e333, 0xb027c6b2, 0xc710de83, 0xe075fb02, 0xc8dce55a, 0xefb9c0db, 0x26b2d538, 0x01d7f0b9, 0x297eeee1, 0x0e1bcb60, 0x792cd351, 0x5e49f6d0, 0x76e0e888, 0x5185cd09}}; #endif #endif #endif local const z_crc_t FAR x2n_table[] = { 0x40000000, 0x20000000, 0x08000000, 0x00800000, 0x00008000, 0xedb88320, 0xb1e6b092, 0xa06a2517, 0xed627dae, 0x88d14467, 0xd7bbfe6a, 0xec447f11, 0x8e7ea170, 0x6427800e, 0x4d47bae0, 0x09fe548f, 0x83852d0f, 0x30362f1a, 0x7b5a9cc3, 0x31fec169, 0x9fec022a, 0x6c8dedc4, 0x15d6874d, 0x5fde7a4e, 0xbad90e37, 0x2e4e5eef, 0x4eaba214, 0xa8a472c0, 0x429a969e, 0x148d302a, 0xc40ba6d0, 0xc4e22c3c}; chibicc-1.0.23.1/test/crc32b.c000066400000000000000000000014421505335450300155250ustar00rootroot00000000000000#include "test.h" #include #include typedef struct { int64_t a; char b; // Padding likely here due to alignment int32_t c; } MyStruct; uint32_t simple_crc32c(const void *data, size_t len) { const unsigned char *p = data; uint32_t crc = 0; for (size_t i = 0; i < len; i++) crc += p[i]; // simple accumulation to mimic CRC return crc; } int main(void) { MyStruct arr[2]; for (int i = 0; i < 2; i++) { arr[i].a = i + 1; arr[i].b = i + 2; // leave c uninitialized to mimic padding issue } for (int i = 0; i < 2; i++) { uint32_t crc = simple_crc32c(&arr[i], sizeof(MyStruct)); printf("Struct %d CRC: %u\n", i, crc); } return 0; } chibicc-1.0.23.1/test/curl2.c000066400000000000000000000031121505335450300154720ustar00rootroot00000000000000#include #include #include #include "test.h" // Declare the variadic function (simulating curl_msprintf or dprintf_format) // Simulated curl-style dprintf_format int dprintf_format(const char *fmt, ...) { va_list ap; va_start(ap, fmt); int ret = vprintf(fmt, ap); // You can replace this with vsnprintf if needed va_end(ap); return ret; } int main(void) { char c = -1; unsigned char uc = 255; short s = -12345; unsigned short us = 54321; int i = -123456; unsigned int ui = 123456; long l = -123456789; unsigned long ul = 123456789; long long ll = -123456789012345; unsigned long long ull = 123456789012345; float f = 1.25f; double d = 3.14159; // Pass all the above to your variadic dprintf_format int n = dprintf_format( "char: %hhd\n" "unsigned char: %hhu\n" "short: %hd\n" "unsigned short: %hu\n" "int: %d\n" "unsigned int: %u\n" "long: %ld\n" "unsigned long: %lu\n" "long long: %lld\n" "unsigned long long: %llu\n" "float: %f\n" "double: %f\n", c, uc, s, us, i, ui, l, ul, ll, ull, f, d); printf("Printed %d characters\n", n); ASSERT(-1, c); ASSERT(255, uc); ASSERT(-12345, s); ASSERT(54321, us); ASSERT(-123456, i); ASSERT(123456, ui); ASSERT(-123456789, l); ASSERT(123456789, ul); ASSERT(-123456789012345LL, ll); ASSERT(123456789012345ULL, ull); ASSERT(1.25f, f); ASSERT(3.14159, d); printf("All tests passed!\n"); return 0; } chibicc-1.0.23.1/test/curl6.c000066400000000000000000000017161505335450300155060ustar00rootroot00000000000000#include #include #include "test.h" void print_args(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { int val = va_arg(ap, int); printf("arg[%d] = %d\n", i, val); if (i == 127) ASSERT(127, val); } va_end(ap); } int main() { // Call print_args with 128 integer args: 0, 1, 2, ..., 127 print_args(128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27,28,29, 30,31,32,33,34,35,36,37,38,39, 40,41,42,43,44,45,46,47,48,49, 50,51,52,53,54,55,56,57,58,59, 60,61,62,63,64,65,66,67,68,69, 70,71,72,73,74,75,76,77,78,79, 80,81,82,83,84,85,86,87,88,89, 90,91,92,93,94,95,96,97,98,99, 100,101,102,103,104,105,106,107,108,109, 110,111,112,113,114,115,116,117,118,119, 120,121,122,123,124,125,126,127 ); return 0; } chibicc-1.0.23.1/test/decl.c000077500000000000000000000010351505335450300153570ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(1, ({ char x; sizeof(x); })); ASSERT(2, ({ short int x; sizeof(x); })); ASSERT(2, ({ int short x; sizeof(x); })); ASSERT(4, ({ int x; sizeof(x); })); ASSERT(8, ({ long int x; sizeof(x); })); ASSERT(8, ({ int long x; sizeof(x); })); ASSERT(8, ({ long long x; sizeof(x); })); ASSERT(0, ({ _Bool x=0; x; })); ASSERT(1, ({ _Bool x=1; x; })); ASSERT(1, ({ _Bool x=2; x; })); ASSERT(1, (_Bool)1); ASSERT(1, (_Bool)2); ASSERT(0, (_Bool)(char)256); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/define.c000077500000000000000000000002111505335450300156750ustar00rootroot00000000000000 #include "test.h" int main() { int m; #if defined(M13) m = 3; #else m = 4; #endif printf("%d\n", m); ASSERT(4, m); return 0; }chibicc-1.0.23.1/test/deprecated.c000077500000000000000000000011101505335450300165420ustar00rootroot00000000000000 #include "test.h" // Pre-attribute __attribute__((deprecated)) enum Color1 { RED1, GREEN1, BLUE1 }; // Post-attribute enum Color2 __attribute__((deprecated)) { RED2, GREEN2, BLUE2 }; // Attribute on enum constants enum Color3 { RED3 __attribute__((deprecated)), GREEN3, BLUE3 }; int main() { enum Color1 c1 = RED1; enum Color2 c2 = RED2; enum Color3 c3 = RED3; printf("Color1: %d\n", c1); ASSERT(0, c1); printf("Color2: %d\n", c2); ASSERT(0, c2); printf("Color3: %d\n", c3); ASSERT(0, c3); return 0; } chibicc-1.0.23.1/test/dereference.c000066400000000000000000000131631505335450300167210ustar00rootroot00000000000000#include "test.h" /* confdefs.h */ #define PACKAGE_NAME "PostgreSQL" #define PACKAGE_TARNAME "postgresql" #define PACKAGE_VERSION "17devel" #define PACKAGE_STRING "PostgreSQL 17devel" #define PACKAGE_BUGREPORT "pgsql-bugs@lists.postgresql.org" #define PACKAGE_URL "https://www.postgresql.org/" #define CONFIGURE_ARGS " 'CC=chibicc' 'CFLAGS=-fpic' 'LDFLAGS=-fpic'" #define PG_MAJORVERSION "17" #define PG_MAJORVERSION_NUM 17 #define PG_MINORVERSION_NUM 0 #define PG_VERSION "17devel" #define DEF_PGPORT 5432 #define DEF_PGPORT_STR "5432" #define BLCKSZ 8192 #define RELSEG_SIZE 131072 #define XLOG_BLCKSZ 8192 /* end confdefs.h. */ /* Does the compiler advertise C89 conformance? Do not test the value of __STDC__, because some compilers set it to 0 while being otherwise adequately conformant. */ #if !defined __STDC__ # error "Compiler does not advertise C89 conformance" #endif #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ struct buf { int x; }; struct buf * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not \xHH hex character constants. These do not provoke an error unfortunately, instead are silently treated as an "x". The following induces an error, until -std is added to get proper ANSI mode. Curiously \x00 != x always comes out true, for an array size at least. It is necessary to write \x00 == 0 to get something that is true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), int, int); // Does the compiler advertise C99 conformance? #if !defined __STDC_VERSION__ ||__STDC_VERSION__ < 199901L # error "Compiler does not advertise C99 conformance" #endif #include extern int puts (const char *); extern int printf (const char *, ...); extern int dprintf (int, const char *, ...); extern void *malloc (size_t); // Check varargs macros. These examples are taken from C99 6.10.3.5. // dprintf is used instead of fprintf to avoid needing to declare // FILE and stderr. #define debug(...) dprintf (2, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK #error "your preprocessor is broken" #endif #if BIG_OK #else #error "your preprocessor is broken" #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } int main (int argc, char **argv) { int ok = 0; ok |= (argc == 0 ||f (e, argv, 0) != argv[0] ||f (e, argv, 1) != argv[1]); // Check bool. _Bool success = false; success |= (argc != 0); // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[0] = argv[0][0]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings ok |= (!success ||bignum == 0LL ||ubignum == 0uLL ||newvar[0] == 'x' ||dynamic_array[ni.number - 1] != 543); printf("\nOK=%d\n", ok); ASSERT(0, ok); return ok; }chibicc-1.0.23.1/test/driver.sh000077500000000000000000000221771505335450300161450ustar00rootroot00000000000000#!/bin/bash chibicc=$1 tmp=`mktemp -d /tmp/chibicc-test-XXXXXX` trap 'rm -rf $tmp' INT TERM HUP EXIT echo > $tmp/empty.c check() { if [ $? -eq 0 ]; then echo "testing $1 ... passed" else echo "testing $1 ... failed" exit 1 fi } # -o rm -f $tmp/out ./chibicc -c -o $tmp/out $tmp/empty.c [ -f $tmp/out ] check -o # --help $chibicc --help 2>&1 | grep -q chibicc check --help # -S echo 'int main() {}' | $chibicc -S -o- -xc - | grep -q 'main:' check -S # Default output file rm -f $tmp/out.o $tmp/out.s echo 'int main() {}' > $tmp/out.c (cd $tmp; $OLDPWD/$chibicc -c out.c) [ -f $tmp/out.o ] check 'default output file' (cd $tmp; $OLDPWD/$chibicc -c -S out.c) [ -f $tmp/out.s ] check 'default output file' # Multiple input files rm -f $tmp/foo.o $tmp/bar.o echo 'int x;' > $tmp/foo.c echo 'int y;' > $tmp/bar.c (cd $tmp; $OLDPWD/$chibicc -c $tmp/foo.c $tmp/bar.c) [ -f $tmp/foo.o ] && [ -f $tmp/bar.o ] check 'multiple input files' rm -f $tmp/foo.s $tmp/bar.s echo 'int x;' > $tmp/foo.c echo 'int y;' > $tmp/bar.c (cd $tmp; $OLDPWD/$chibicc -c -S $tmp/foo.c $tmp/bar.c) [ -f $tmp/foo.s ] && [ -f $tmp/bar.s ] check 'multiple input files' # Run linker rm -f $tmp/foo echo 'int main() { return 0; }' | $chibicc -o $tmp/foo -xc -xc - $tmp/foo check linker rm -f $tmp/foo echo 'int bar(); int main() { return bar(); }' > $tmp/foo.c echo 'int bar() { return 42; }' > $tmp/bar.c $chibicc -o $tmp/foo $tmp/foo.c $tmp/bar.c $tmp/foo [ "$?" = 42 ] check linker # a.out rm -f $tmp/a.out echo 'int main() {}' > $tmp/foo.c (cd $tmp; $OLDPWD/$chibicc foo.c) [ -f $tmp/a.out ] check a.out # -E echo foo > $tmp/out echo "#include \"$tmp/out\"" | $chibicc -E -xc - | grep -q foo check -E echo foo > $tmp/out1 echo "#include \"$tmp/out1\"" | $chibicc -E -o $tmp/out2 -xc - cat $tmp/out2 | grep -q foo check '-E and -o' # -I mkdir $tmp/dir echo foo > $tmp/dir/i-option-test echo "#include \"i-option-test\"" | $chibicc -I$tmp/dir -E -xc - | grep -q foo check -I # -D echo foo | $chibicc -Dfoo -E -xc - | grep -q 1 check -D # -D echo foo | $chibicc -Dfoo=bar -E -xc - | grep -q bar check -D # -U echo foo | $chibicc -Dfoo=bar -Ufoo -E -xc - | grep -q foo check -U # ignored options $chibicc -c -O -Wall -g -std=c11 -ffreestanding -fno-builtin \ -fno-omit-frame-pointer -fno-stack-protector -fno-strict-aliasing \ -m64 -mno-red-zone -w -o /dev/null $tmp/empty.c check 'ignored options' # BOM marker printf '\xef\xbb\xbfxyz\n' | $chibicc -E -o- -xc - | grep -q '^xyz' check 'BOM marker' # Inline functions echo 'inline void foo() {}' > $tmp/inline1.c echo 'inline void foo() {}' > $tmp/inline2.c echo 'int main() { return 0; }' > $tmp/inline3.c $chibicc -o /dev/null $tmp/inline1.c $tmp/inline2.c $tmp/inline3.c check inline echo 'extern inline void foo() {}' > $tmp/inline1.c echo 'int foo(); int main() { foo(); }' > $tmp/inline2.c $chibicc -o /dev/null $tmp/inline1.c $tmp/inline2.c check inline echo 'static inline void f1() {}' | $chibicc -o- -S -xc - | grep -v -q f1: check inline echo 'static inline void f1() {} void foo() { f1(); }' | $chibicc -o- -S -xc - | grep -q f1: check inline echo 'static inline void f1() {} static inline void f2() { f1(); } void foo() { f1(); }' | $chibicc -o- -S -xc - | grep -q f1: check inline echo 'static inline void f1() {} static inline void f2() { f1(); } void foo() { f1(); }' | $chibicc -o- -S -xc - | grep -v -q f2: check inline echo 'static inline void f1() {} static inline void f2() { f1(); } void foo() { f2(); }' | $chibicc -o- -S -xc - | grep -q f1: check inline echo 'static inline void f1() {} static inline void f2() { f1(); } void foo() { f2(); }' | $chibicc -o- -S -xc - | grep -q f2: check inline echo 'static inline void f2(); static inline void f1() { f2(); } static inline void f2() { f1(); } void foo() {}' | $chibicc -o- -S -xc - | grep -v -q f1: check inline echo 'static inline void f2(); static inline void f1() { f2(); } static inline void f2() { f1(); } void foo() {}' | $chibicc -o- -S -xc - | grep -v -q f2: check inline echo 'static inline void f2(); static inline void f1() { f2(); } static inline void f2() { f1(); } void foo() { f1(); }' | $chibicc -o- -S -xc - | grep -q f1: check inline echo 'static inline void f2(); static inline void f1() { f2(); } static inline void f2() { f1(); } void foo() { f1(); }' | $chibicc -o- -S -xc - | grep -q f2: check inline echo 'static inline void f2(); static inline void f1() { f2(); } static inline void f2() { f1(); } void foo() { f2(); }' | $chibicc -o- -S -xc - | grep -q f1: check inline echo 'static inline void f2(); static inline void f1() { f2(); } static inline void f2() { f1(); } void foo() { f2(); }' | $chibicc -o- -S -xc - | grep -q f2: check inline # -idirafter mkdir -p $tmp/dir1 $tmp/dir2 echo foo > $tmp/dir1/idirafter echo bar > $tmp/dir2/idirafter echo "#include \"idirafter\"" | $chibicc -I$tmp/dir1 -I$tmp/dir2 -E -xc - | grep -q foo check -idirafter echo "#include \"idirafter\"" | $chibicc -idirafter $tmp/dir1 -I$tmp/dir2 -E -xc - | grep -q bar check -idirafter # -fcommon echo 'int foo;' | $chibicc -S -o- -xc - | grep -q '\.comm foo' check '-fcommon (default)' echo 'int foo;' | $chibicc -fcommon -S -o- -xc - | grep -q '\.comm foo' check '-fcommon' # -fno-common echo 'int foo;' | $chibicc -fno-common -S -o- -xc - | grep -q '^foo:' check '-fno-common' # -include echo foo > $tmp/out.h echo bar | $chibicc -include $tmp/out.h -E -o- -xc - | grep -q -z 'foo.*bar' check -include echo NULL | $chibicc -Iinclude -include stdio.h -E -o- -xc - | grep -q 0 check -include # -x echo 'int x;' | $chibicc -c -xc -o $tmp/foo.o - check -xc echo 'x:' | $chibicc -c -x assembler -o $tmp/foo.o - check '-x assembler' echo 'int x;' > $tmp/foo.c $chibicc -c -x assembler -x none -o $tmp/foo.o $tmp/foo.c check '-x none' # -E echo foo | $chibicc -E - | grep -q foo check -E # .a file echo 'void foo() {}' | $chibicc -c -xc -o $tmp/foo.o - echo 'void bar() {}' | $chibicc -c -xc -o $tmp/bar.o - ar rcs $tmp/foo.a $tmp/foo.o $tmp/bar.o echo 'void foo(); void bar(); int main() { foo(); bar(); }' > $tmp/main.c $chibicc -o $tmp/foo $tmp/main.c $tmp/foo.a check '.a' # .so file echo 'void foo() {}' | cc -fPIC -c -xc -o $tmp/foo.o - echo 'void bar() {}' | cc -fPIC -c -xc -o $tmp/bar.o - cc -shared -o $tmp/foo.so $tmp/foo.o $tmp/bar.o echo 'void foo(); void bar(); int main() { foo(); bar(); }' > $tmp/main.c $chibicc -o $tmp/foo $tmp/main.c $tmp/foo.so check '.so' $chibicc -hashmap-test check 'hashmap' # -M echo '#include "out2.h"' > $tmp/out.c echo '#include "out3.h"' >> $tmp/out.c touch $tmp/out2.h $tmp/out3.h $chibicc -M -I$tmp $tmp/out.c | grep -q -z '^out.o: .*/out\.c .*/out2\.h .*/out3\.h' check -M # -MF $chibicc -MF $tmp/mf -M -I$tmp $tmp/out.c grep -q -z '^out.o: .*/out\.c .*/out2\.h .*/out3\.h' $tmp/mf check -MF # -MP $chibicc -MF $tmp/mp -MP -M -I$tmp $tmp/out.c grep -q '^.*/out2.h:' $tmp/mp check -MP grep -q '^.*/out3.h:' $tmp/mp check -MP # -MT $chibicc -MT foo -M -I$tmp $tmp/out.c | grep -q '^foo:' check -MT $chibicc -MT foo -MT bar -M -I$tmp $tmp/out.c | grep -q '^foo bar:' check -MT # -MD echo '#include "out2.h"' > $tmp/md2.c echo '#include "out3.h"' > $tmp/md3.c (cd $tmp; $OLDPWD/$chibicc -c -MD -I. md2.c md3.c) grep -q -z '^md2.o:.* md2\.c .* ./out2\.h' $tmp/md2.d check -MD grep -q -z '^md3.o:.* md3\.c .* ./out3\.h' $tmp/md3.d check -MD $chibicc -c -MD -MF $tmp/md-mf.d -I. $tmp/md2.c grep -q -z '^md2.o:.*md2\.c .*/out2\.h' $tmp/md-mf.d check -MD echo 'extern int bar; int foo() { return bar; }' | $chibicc -fPIC -xc -c -o $tmp/foo.o - cc -shared -o $tmp/foo.so $tmp/foo.o echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/main.c $chibicc -o $tmp/foo $tmp/main.c $tmp/foo.so check -fPIC # #include_next mkdir -p $tmp/next1 $tmp/next2 $tmp/next3 echo '#include "file1.h"' > $tmp/file.c echo '#include_next "file1.h"' > $tmp/next1/file1.h echo '#include_next "file2.h"' > $tmp/next2/file1.h echo 'foo' > $tmp/next3/file2.h $chibicc -I$tmp/next1 -I$tmp/next2 -I$tmp/next3 -E $tmp/file.c | grep -q foo check '#include_next' # -static echo 'extern int bar; int foo() { return bar; }' > $tmp/foo.c echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/bar.c $chibicc -static -o $tmp/foo $tmp/foo.c $tmp/bar.c check -static file $tmp/foo | grep -q 'statically linked' check -static # -shared echo 'extern int bar; int foo() { return bar; }' > $tmp/foo.c echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/bar.c $chibicc -fPIC -shared -o $tmp/foo.so $tmp/foo.c $tmp/bar.c check -shared # -L echo 'extern int bar; int foo() { return bar; }' > $tmp/foo.c $chibicc -fPIC -shared -o $tmp/libfoobar.so $tmp/foo.c echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/bar.c $chibicc -o $tmp/foo $tmp/bar.c -L$tmp -lfoobar check -L # -Wl, echo 'int foo() {}' | $chibicc -c -o $tmp/foo.o -xc - echo 'int foo() {}' | $chibicc -c -o $tmp/bar.o -xc - echo 'int main() {}' | $chibicc -c -o $tmp/baz.o -xc - cc -Wl,-z,muldefs,--gc-sections -o $tmp/foo $tmp/foo.o $tmp/bar.o $tmp/baz.o check -Wl, # -Xlinker echo 'int foo() {}' | $chibicc -c -o $tmp/foo.o -xc - echo 'int foo() {}' | $chibicc -c -o $tmp/bar.o -xc - echo 'int main() {}' | $chibicc -c -o $tmp/baz.o -xc - cc -Xlinker -z -Xlinker muldefs -Xlinker --gc-sections -o $tmp/foo $tmp/foo.o $tmp/bar.o $tmp/baz.o check -Xlinker echo OK chibicc-1.0.23.1/test/enum.c000077500000000000000000000013041505335450300154130ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(0, ({ enum { zero, one, two }; zero; })); ASSERT(1, ({ enum { zero, one, two }; one; })); ASSERT(2, ({ enum { zero, one, two }; two; })); ASSERT(5, ({ enum { five=5, six, seven }; five; })); ASSERT(6, ({ enum { five=5, six, seven }; six; })); ASSERT(0, ({ enum { zero, five=5, three=3, four }; zero; })); ASSERT(5, ({ enum { zero, five=5, three=3, four }; five; })); ASSERT(3, ({ enum { zero, five=5, three=3, four }; three; })); ASSERT(4, ({ enum { zero, five=5, three=3, four }; four; })); ASSERT(4, ({ enum { zero, one, two } x; sizeof(x); })); ASSERT(4, ({ enum t { zero, one, two }; enum t y; sizeof(y); })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/extern.c000077500000000000000000000005061505335450300157570ustar00rootroot00000000000000#include "test.h" extern int ext1; extern int *ext2; inline int inline_fn(void) { return 3; } int main() { ASSERT(5, ext1); ASSERT(5, *ext2); extern int ext3; ASSERT(7, ext3); int ext_fn1(int x); ASSERT(5, ext_fn1(5)); extern int ext_fn2(int x); ASSERT(8, ext_fn2(8)); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/fallthrough.c000066400000000000000000000011071505335450300167640ustar00rootroot00000000000000#include "test.h" int main() { int state = 0; int c = '5'; // ASCII value of character '5' int arg = -1; switch (state) { case 0: // Simulate condition that fails (c < 0x3c or c > 0x3f), so no break if (c >= 0x3c && c <= 0x3f) { // shouldn't enter here break; } // fallthrough to case 1 arg = 0; // no break case 1: if (c >= '0' && c <= '9') { arg *= 10; arg += c - '0'; } break; } printf("arg = %d\n", arg); ASSERT(5, arg); return 0; } chibicc-1.0.23.1/test/float.c000077500000000000000000000042451505335450300155630ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(35, (float)(char)35); ASSERT(35, (float)(short)35); ASSERT(35, (float)(int)35); ASSERT(35, (float)(long)35); ASSERT(35, (float)(unsigned char)35); ASSERT(35, (float)(unsigned short)35); ASSERT(35, (float)(unsigned int)35); ASSERT(35, (float)(unsigned long)35); ASSERT(35, (double)(char)35); ASSERT(35, (double)(short)35); ASSERT(35, (double)(int)35); ASSERT(35, (double)(long)35); ASSERT(35, (double)(unsigned char)35); ASSERT(35, (double)(unsigned short)35); ASSERT(35, (double)(unsigned int)35); ASSERT(35, (double)(unsigned long)35); ASSERT(35, (char)(float)35); ASSERT(35, (short)(float)35); ASSERT(35, (int)(float)35); ASSERT(35, (long)(float)35); ASSERT(35, (unsigned char)(float)35); ASSERT(35, (unsigned short)(float)35); ASSERT(35, (unsigned int)(float)35); ASSERT(35, (unsigned long)(float)35); ASSERT(35, (char)(double)35); ASSERT(35, (short)(double)35); ASSERT(35, (int)(double)35); ASSERT(35, (long)(double)35); ASSERT(35, (unsigned char)(double)35); ASSERT(35, (unsigned short)(double)35); ASSERT(35, (unsigned int)(double)35); ASSERT(35, (unsigned long)(double)35); ASSERT(-2147483648, (double)(unsigned long)(long)-1); ASSERT(1, 2e3==2e3); ASSERT(0, 2e3==2e5); ASSERT(1, 2.0==2); ASSERT(0, 5.1<5); ASSERT(0, 5.0<5); ASSERT(1, 4.9<5); ASSERT(0, 5.1<=5); ASSERT(1, 5.0<=5); ASSERT(1, 4.9<=5); ASSERT(1, 2e3f==2e3); ASSERT(0, 2e3f==2e5); ASSERT(1, 2.0f==2); ASSERT(0, 5.1f<5); ASSERT(0, 5.0f<5); ASSERT(1, 4.9f<5); ASSERT(0, 5.1f<=5); ASSERT(1, 5.0f<=5); ASSERT(1, 4.9f<=5); ASSERT(6, 2.3+3.8); ASSERT(-1, 2.3-3.8); ASSERT(-3, -3.8); ASSERT(13, 3.3*4); ASSERT(2, 5.0/2); ASSERT(6, 2.3f+3.8f); ASSERT(6, 2.3f+3.8); ASSERT(-1, 2.3f-3.8); ASSERT(-3, -3.8f); ASSERT(13, 3.3f*4); ASSERT(2, 5.0f/2); ASSERT(0, 0.0/0.0 == 0.0/0.0); ASSERT(1, 0.0/0.0 != 0.0/0.0); ASSERT(0, 0.0/0.0 < 0); ASSERT(0, 0.0/0.0 <= 0); ASSERT(0, 0.0/0.0 > 0); ASSERT(0, 0.0/0.0 >= 0); ASSERT(0, !3.); ASSERT(1, !0.); ASSERT(0, !3.f); ASSERT(1, !0.f); ASSERT(5, 0.0 ? 3 : 5); ASSERT(3, 1.2 ? 3 : 5); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/floatb.c000066400000000000000000000002431505335450300157140ustar00rootroot00000000000000 #include "test.h" float add_float2(float x, float y) { return x + y; } int main() { float r = add_float2(2.3, 3.8); printf("%f\n", r); ASSERT(6.1, r); } chibicc-1.0.23.1/test/foo.c000066400000000000000000000002161505335450300152300ustar00rootroot00000000000000 #include "test.h" const char str[] = {"foo"}; int main() { printf("foo %ld\n", sizeof(str)); ASSERT(4, sizeof(str)); return 0; }chibicc-1.0.23.1/test/fpie.c000066400000000000000000000003151505335450300153700ustar00rootroot00000000000000 #include "test.h" char message[] = "Hello World"; int main(int argc, char *argv[], char *envp[]) { puts(message); printf("%ld\n", sizeof(message)); ASSERT(12, sizeof(message)); return 0; }chibicc-1.0.23.1/test/funcstack.c000066400000000000000000000046071505335450300164360ustar00rootroot00000000000000#include "test.h" typedef struct StRegSized { unsigned char r; } StRegSized; void func1(int a, int b, int c, int d, StRegSized st) { ASSERT(1, a); ASSERT(2, b); ASSERT(3, c); ASSERT(4, d); ASSERT(99, st.r); } void func2(int a, int b, int c, int d, int e, StRegSized st) { ASSERT(1, a); ASSERT(2, b); ASSERT(3, c); ASSERT(4, d); ASSERT(5, e); ASSERT(99, st.r); } void func3(int a, int b, int c, int d, int e, int f, StRegSized st) { ASSERT(1, a); ASSERT(2, b); ASSERT(3, c); ASSERT(4, d); ASSERT(5, e); ASSERT(6, f); ASSERT(99, st.r); } void func4(int a, int b, int c, int d, int e, int f, int g, StRegSized st) { ASSERT(1, a); ASSERT(2, b); ASSERT(3, c); ASSERT(4, d); ASSERT(5, e); ASSERT(6, f); ASSERT(7, g); ASSERT(99, st.r); } void func5(int a, int b, int c, StRegSized st) { ASSERT(1, a); ASSERT(2, b); ASSERT(3, c); ASSERT(99, st.r); } void func6(int a, int b, StRegSized st) { ASSERT(1, a); ASSERT(2, b); ASSERT(99, st.r); } void func7(int a, StRegSized st) { ASSERT(1, a); ASSERT(99, st.r); } void func8(int a, int b, int c, StRegSized st, int d) { ASSERT(1, a); ASSERT(2, b); ASSERT(3, c); ASSERT(99, st.r); ASSERT(4, d); } void func9(int a, int b, StRegSized st, int c, int d) { ASSERT(1, a); ASSERT(2, b); ASSERT(99, st.r); ASSERT(3, c); ASSERT(4, d); } void funca(int a, StRegSized st, int b, int c, int d) { ASSERT(1, a); ASSERT(99, st.r); ASSERT(2, b); ASSERT(3, c); ASSERT(4, d); } void funcb(int a, StRegSized st, int b, StRegSized st2, int c) { ASSERT(1, a); ASSERT(99, st.r); ASSERT(2, b); ASSERT(98, st2.r); ASSERT(3, c); } void funcc(int a, StRegSized st, int b, StRegSized st2, StRegSized st3) { ASSERT(1, a); ASSERT(99, st.r); ASSERT(2, b); ASSERT(98, st2.r); ASSERT(97, st3.r); } void funcd(int a, StRegSized st, int b, StRegSized st2, StRegSized st3, int c) { ASSERT(1, a); ASSERT(99, st.r); ASSERT(2, b); ASSERT(98, st2.r); ASSERT(97, st3.r); ASSERT(3, c); } int main(void) { StRegSized x = {99}; StRegSized y = {98}; StRegSized z = {97}; func1(1, 2, 3, 4, x); func2(1, 2, 3, 4, 5, x); func3(1, 2, 3, 4, 5, 6, x); func4(1, 2, 3, 4, 5, 6, 7, x); func5(1, 2, 3, x); func6(1, 2, x); func7(1, x); func8(1, 2, 3, x, 4); func9(1, 2, x, 3, 4); funca(1, x, 2, 3, 4); funcb(1, x, 2, y, 3); funcc(1, x, 2, y, z); funcd(1, x, 2, y, z, 3); }chibicc-1.0.23.1/test/function.c000077500000000000000000000233551505335450300163060ustar00rootroot00000000000000#include "test.h" int ret3(void) { return 3; return 5; } int add2(int x, int y) { return x + y; } int sub2(int x, int y) { return x - y; } int add6(int a, int b, int c, int d, int e, int f) { return a + b + c + d + e + f; } int addx(int *x, int y) { return *x + y; } int sub_char(char a, char b, char c) { return a - b - c; } int fib(int x) { if (x <= 1) return 1; return fib(x - 1) + fib(x - 2); } int sub_long(long a, long b, long c) { return a - b - c; } int sub_short(short a, short b, short c) { return a - b - c; } int g1; int *g1_ptr(void) { return &g1; } char int_to_char(int x) { return x; } int div_long(long a, long b) { return a / b; } _Bool bool_fn_add(_Bool x) { return x + 1; } _Bool bool_fn_sub(_Bool x) { return x - 1; } static int static_fn(void) { return 3; } int param_decay(int x[]) { return x[0]; } int counter() { static int i; static int j = 1 + 1; return i++ + j++; } void ret_none() { return; } _Bool true_fn(); _Bool false_fn(); char char_fn(); short short_fn(); unsigned char uchar_fn(); unsigned short ushort_fn(); char schar_fn(); short sshort_fn(); int multiple1(), multiple2(); int add_all(int n, ...); typedef struct { int gp_offset; int fp_offset; void *overflow_arg_area; unsigned int remaining; void *reg_save_area; } __va_elem; typedef __va_elem va_list[1]; int add_all(int n, ...); int sprintf(char *buf, char *fmt, ...); int vsprintf(char *buf, char *fmt, va_list ap); char *fmt(char *buf, char *fmt, ...) { va_list ap; *ap = *(__va_elem *)__va_area__; vsprintf(buf, fmt, ap); } double add_double(double x, double y); float add_float(float x, float y); float add_float3(float x, float y, float z) { return x + y + z; } double add_double3(double x, double y, double z) { return x + y + z; } int (*fnptr(int (*fn)(int n, ...)))(int, ...) { return fn; } int param_decay2(int x()) { return x(); } char *func_fn(void) { return __func__; } char *function_fn(void) { return __FUNCTION__; } int add10_int(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10); float add10_float(float x1, float x2, float x3, float x4, float x5, float x6, float x7, float x8, float x9, float x10); double add10_double(double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9, double x10); int many_args1(int a, int b, int c, int d, int e, int f, int g, int h) { return g / h; } double many_args2(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j) { return i / j; } int many_args3(int a, double b, int c, int d, double e, int f, double g, int h, double i, double j, double k, double l, double m, int n, int o, double p) { return o / p; } typedef struct { int a, b; short c; char d; } Ty4; typedef struct { int a; float b; double c; } Ty5; typedef struct { unsigned char a[3]; } Ty6; typedef struct { long a, b, c; } Ty7; int struct_test5(Ty5 x, int n); int struct_test4(Ty4 x, int n); int struct_test6(Ty6 x, int n); int struct_test7(Ty7 x, int n); int struct_test14(Ty4 x, int n) { switch (n) { case 0: return x.a; case 1: return x.b; case 2: return x.c; default: return x.d; } } int struct_test15(Ty5 x, int n) { switch (n) { case 0: return x.a; case 1: return x.b; default: return x.c; } } typedef struct { unsigned char a[10]; } Ty20; typedef struct { unsigned char a[20]; } Ty21; Ty4 struct_test24(void); Ty5 struct_test25(void); Ty6 struct_test26(void); Ty20 struct_test27(void); Ty21 struct_test28(void); Ty4 struct_test34(void) { return (Ty4){10, 20, 30, 40}; } Ty5 struct_test35(void) { return (Ty5){10, 20, 30}; } Ty6 struct_test36(void) { return (Ty6){10, 20, 30}; } Ty20 struct_test37(void) { return (Ty20){10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; } Ty21 struct_test38(void) { return (Ty21){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; } inline int inline_fn(void) { return 3; } double to_double(long double x) { return x; } long double to_ldouble(int x) { return x; } int main() { ASSERT(3, ret3()); ASSERT(8, add2(3, 5)); ASSERT(2, sub2(5, 3)); ASSERT(21, add6(1, 2, 3, 4, 5, 6)); ASSERT(66, add6(1, 2, add6(3, 4, 5, 6, 7, 8), 9, 10, 11)); ASSERT(136, add6(1, 2, add6(3, add6(4, 5, 6, 7, 8, 9), 10, 11, 12, 13), 14, 15, 16)); ASSERT(7, add2(3, 4)); ASSERT(1, sub2(4, 3)); ASSERT(55, fib(9)); ASSERT(1, ({ sub_char(7, 3, 3); })); ASSERT(1, sub_long(7, 3, 3)); ASSERT(1, sub_short(7, 3, 3)); g1 = 3; ASSERT(3, *g1_ptr()); ASSERT(5, int_to_char(261)); ASSERT(5, int_to_char(261)); ASSERT(-5, div_long(-10, 2)); ASSERT(1, bool_fn_add(3)); ASSERT(0, bool_fn_sub(3)); ASSERT(1, bool_fn_add(-3)); ASSERT(0, bool_fn_sub(-3)); ASSERT(1, bool_fn_add(0)); ASSERT(1, bool_fn_sub(0)); ASSERT(3, static_fn()); ASSERT(3, ({ int x[2]; x[0]=3; param_decay(x); })); ASSERT(2, counter()); ASSERT(4, counter()); ASSERT(6, counter()); ret_none(); ASSERT(1, true_fn()); ASSERT(0, false_fn()); ASSERT(3, char_fn()); ASSERT(5, short_fn()); ASSERT(6, add_all(3, 1, 2, 3)); ASSERT(5, add_all(4, 1, 2, 3, -1)); { char buf[100]; fmt(buf, "%d %d %s", 1, 2, "foo"); printf("%s\n", buf); } ASSERT(0, ({ char buf[100]; sprintf(buf, "%d %d %s", 1, 2, "foo"); strcmp("1 2 foo", buf); })); ASSERT(0, ({ char buf[100]; fmt(buf, "%d %d %s", 1, 2, "foo"); strcmp("1 2 foo", buf); })); ASSERT(251, uchar_fn()); ASSERT(65528, ushort_fn()); ASSERT(-5, schar_fn()); ASSERT(-8, sshort_fn()); ASSERT(6, add_float(2.3, 3.8)); ASSERT(6, add_double(2.3, 3.8)); ASSERT(7, add_float3(2.5, 2.5, 2.5)); ASSERT(7, add_double3(2.5, 2.5, 2.5)); ASSERT(0, ({ char buf[100]; sprintf(buf, "%.1f", (float)3.5); strcmp(buf, "3.5"); })); ASSERT(0, ({ char buf[100]; fmt(buf, "%.1f", (float)3.5); strcmp(buf, "3.5"); })); ASSERT(5, (add2)(2, 3)); ASSERT(5, (&add2)(2, 3)); ASSERT(7, ({ int (*fn)(int,int) = add2; fn(2,5); })); ASSERT(6, fnptr(add_all)(3, 1, 2, 3)); ASSERT(3, param_decay2(ret3)); ASSERT(5, sizeof(__func__)); ASSERT(0, strcmp("main", __func__)); ASSERT(0, strcmp("func_fn", func_fn())); ASSERT(0, strcmp("main", __FUNCTION__)); ASSERT(0, strcmp("function_fn", function_fn())); ASSERT(55, add10_int(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); ASSERT(55, add10_float(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); ASSERT(55, add10_double(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); ASSERT(0, ({ char buf[200]; sprintf(buf, "%d %.1f %.1f %.1f %d %d %.1f %d %d %d %d %.1f %d %d %.1f %.1f %.1f %.1f %d", 1, 1.0, 1.0, 1.0, 1, 1, 1.0, 1, 1, 1, 1, 1.0, 1, 1, 1.0, 1.0, 1.0, 1.0, 1); strcmp("1 1.0 1.0 1.0 1 1 1.0 1 1 1 1 1.0 1 1 1.0 1.0 1.0 1.0 1", buf); })); ASSERT(4, many_args1(1, 2, 3, 4, 5, 6, 40, 10)); ASSERT(4, many_args2(1, 2, 3, 4, 5, 6, 7, 8, 40, 10)); ASSERT(8, many_args3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 80, 10)); ASSERT(10, ({ Ty4 x={10,20,30,40}; struct_test4(x, 0); })); ASSERT(20, ({ Ty4 x={10,20,30,40}; struct_test4(x, 1); })); ASSERT(30, ({ Ty4 x={10,20,30,40}; struct_test4(x, 2); })); ASSERT(40, ({ Ty4 x={10,20,30,40}; struct_test4(x, 3); })); ASSERT(10, ({ Ty5 x={10,20,30}; struct_test5(x, 0); })); ASSERT(20, ({ Ty5 x={10,20,30}; struct_test5(x, 1); })); ASSERT(30, ({ Ty5 x={10,20,30}; struct_test5(x, 2); })); ASSERT(10, ({ Ty6 x={10,20,30}; struct_test6(x, 0); })); ASSERT(20, ({ Ty6 x={10,20,30}; struct_test6(x, 1); })); ASSERT(30, ({ Ty6 x={10,20,30}; struct_test6(x, 2); })); ASSERT(10, ({ Ty7 x={10,20,30}; struct_test7(x, 0); })); ASSERT(20, ({ Ty7 x={10,20,30}; struct_test7(x, 1); })); ASSERT(30, ({ Ty7 x={10,20,30}; struct_test7(x, 2); })); ASSERT(10, ({ Ty4 x={10,20,30,40}; struct_test14(x, 0); })); ASSERT(20, ({ Ty4 x={10,20,30,40}; struct_test14(x, 1); })); ASSERT(30, ({ Ty4 x={10,20,30,40}; struct_test14(x, 2); })); ASSERT(40, ({ Ty4 x={10,20,30,40}; struct_test14(x, 3); })); ASSERT(10, ({ Ty5 x={10,20,30}; struct_test15(x, 0); })); ASSERT(20, ({ Ty5 x={10,20,30}; struct_test15(x, 1); })); ASSERT(30, ({ Ty5 x={10,20,30}; struct_test15(x, 2); })); ASSERT(10, struct_test24().a); ASSERT(20, struct_test24().b); ASSERT(30, struct_test24().c); ASSERT(40, struct_test24().d); ASSERT(10, struct_test25().a); ASSERT(20, struct_test25().b); ASSERT(30, struct_test25().c); ASSERT(10, struct_test26().a[0]); ASSERT(20, struct_test26().a[1]); ASSERT(30, struct_test26().a[2]); ASSERT(10, struct_test27().a[0]); ASSERT(60, struct_test27().a[5]); ASSERT(100, struct_test27().a[9]); ASSERT(1, struct_test28().a[0]); ASSERT(5, struct_test28().a[4]); ASSERT(10, struct_test28().a[9]); ASSERT(15, struct_test28().a[14]); ASSERT(20, struct_test28().a[19]); ASSERT(10, struct_test34().a); ASSERT(20, struct_test34().b); ASSERT(30, struct_test34().c); ASSERT(40, struct_test34().d); ASSERT(10, struct_test35().a); ASSERT(20, struct_test35().b); ASSERT(30, struct_test35().c); ASSERT(10, struct_test36().a[0]); ASSERT(20, struct_test36().a[1]); ASSERT(30, struct_test36().a[2]); ASSERT(10, struct_test37().a[0]); ASSERT(60, struct_test37().a[5]); ASSERT(100, struct_test37().a[9]); ASSERT(1, struct_test38().a[0]); ASSERT(5, struct_test38().a[4]); ASSERT(10, struct_test38().a[9]); ASSERT(15, struct_test38().a[14]); ASSERT(20, struct_test38().a[19]); ASSERT(5, (***add2)(2, 3)); ASSERT(3, inline_fn()); ASSERT(0, ({ char buf[100]; sprintf(buf, "%Lf", (long double)12.3); strncmp(buf, "12.3", 4); })); ASSERT(1, to_double(3.5) == 3.5); ASSERT(0, to_double(3.5) == 3); ASSERT(1, (long double)5.0 == (long double)5.0); ASSERT(0, (long double)5.0 == (long double)5.2); ASSERT(1, to_ldouble(5.0) == 5.0); ASSERT(0, to_ldouble(5.0) == 5.2); printf("OK\n"); } chibicc-1.0.23.1/test/function2.c000066400000000000000000000045511505335450300163620ustar00rootroot00000000000000#include "test.h" typedef struct { char g; } G; typedef struct { float f; } F; typedef struct { char l; float d; } A; extern float struct_test101( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ); float struct_test100( G g0, G g1, G g2, G g3, G g4, G g5, F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } extern float struct_test111( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ); float struct_test110( F f0, F f1, F f2, F f3, F f4, F f5, F f6, F f7, G g0, G g1, G g2, G g3, G g4, G g5, G gs0, F fs0, G gs1, F fs1 ) { return g0.g + g1.g + g2.g + g3.g + g4.g + g5.g + f0.f + f1.f + f2.f + f3.f + f4.f + f5.f + f6.f + f7.f + gs0.g + gs1.g + fs0.f + fs1.f; } extern float struct_test121( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1); float struct_test120( A reg0, A reg1, A reg2, A reg3, A reg4, A reg5, A s0, F f6, F f7, A s1) { return reg0.l + reg0.d + reg1.l + reg1.d + reg2.l + reg2.d + reg3.l + reg3.d + reg4.l + reg4.d + reg5.l + reg5.d + s0.l + s0.d + s1.l + s1.d + f6.f + f7.f; } int main(void) { G g[] = {10,11,12,13,14,15}; F f[] = {20,21,22,23,24,25,26,27}; G gs[] = {30,31}; F fs[] = {40,41}; ASSERT(405, struct_test100( g[0], g[1], g[2], g[3], g[4], g[5], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test101( g[0], g[1], g[2], g[3], g[4], g[5], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test110( f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], g[0], g[1], g[2], g[3], g[4], g[5], gs[0], fs[0], gs[1], fs[1])); ASSERT(405, struct_test111( f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], g[0], g[1], g[2], g[3], g[4], g[5], gs[0], fs[0], gs[1], fs[1])); A reg[] = {10,11,20,21,30,31,40,41,50,51,60,61}; A as[] = {70,71,80,81}; ASSERT(781, struct_test120( reg[0], reg[1], reg[2], reg[3], reg[4], reg[5], as[0], f[6], f[7], as[1])); ASSERT(781, struct_test121( reg[0], reg[1], reg[2], reg[3], reg[4], reg[5], as[0], f[6], f[7], as[1])); printf("OK\n"); }chibicc-1.0.23.1/test/function3b.c000066400000000000000000000027641505335450300165310ustar00rootroot00000000000000#include #include #include "test.h" typedef struct { char g; } G; typedef struct { float f; } F; long double test_func(G g0, G g1, F f0, F f1, int i0, int i1, ...) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); ret += va_arg(ap, int); ret += va_arg(ap, double); va_end(ap); return ret; } long double test_func1(G g0, G g1, F f0, F f1, int i0, int i1, ...) { va_list ap; va_start(ap, i1); long double ld = va_arg(ap, long double); va_end(ap); return ld; } double test_func2(G g0, G g1, F f0, F f1, int i0, int i1, ...) { va_list ap; va_start(ap, i1); double d = va_arg(ap, double); va_end(ap); return d; } int test_func3(G g0, G g1, F f0, F f1, int i0, int i1, ...) { va_list ap; va_start(ap, i1); int x = va_arg(ap, int); va_end(ap); return x; } int main() { G g0 = {10}, g1 = {11}; F f0 = {20.0f}, f1 = {21.0f}; long double ld = 2.5L; int i = 5; double d = 4.5; long double res1 = test_func1(g0, g1, f0, f1, 1, 2, ld); printf("Result: %Lf\n", res1); ASSERT(2, res1); double res2 = test_func2(g0, g1, f0, f1, 1, 2, d); printf("Result: %f\n", res2); ASSERT(4, res2); int res3 = test_func3(g0, g1, f0, f1, 1, 2, i); printf("Result: %d\n", res3); ASSERT(5, res3); long double res = test_func(g0, g1, f0, f1, 1, 2, ld, i, d); printf("Result: %Lf\n", res); ASSERT(15, res); return 0; } chibicc-1.0.23.1/test/function3c.c000066400000000000000000000032171505335450300165240ustar00rootroot00000000000000#include #include "test.h" typedef struct { char g; } G; typedef struct { float f; } F; typedef struct { char l; float d; } A; typedef struct __attribute__((aligned(32))) { char c; char pad[31]; // ensure struct size >= alignment } Aligned1024; long double test_variadic(G g0, G g1, F f0, F f1, int i0, int i1, ...) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; printf("start ret=%Lf\n", ret); ASSERT(300, ret); // Read long double long double ld = va_arg(ap, long double); ret += ld; printf("after long double ret=%Lf\n", ret); ASSERT(301, ret); // Read Aligned1024 Aligned1024 s1 = va_arg(ap, Aligned1024); ret += s1.c; printf("after Aligned1024 ret=%Lf (s1.c=%d)\n", ret, s1.c); ASSERT(378, ret); // Read int int i2 = va_arg(ap, int); ret += i2; printf("after int ret=%Lf (i2=%d)\n", ret, i2); ASSERT(678, ret); // Read double double d = va_arg(ap, double); ret += d; printf("after double ret=%Lf (d=%f)\n", ret, d); ASSERT(683, ret); // Read another Aligned1024 Aligned1024 s2 = va_arg(ap, Aligned1024); ret += s2.c; printf("after second Aligned1024 ret=%Lf (s2.c=%d)\n", ret, s2.c); ASSERT(760, ret); int i3 = va_arg(ap, int); ret += i3; printf("after last int ret=%Lf (d=%d)\n", ret, i3); ASSERT(1160, ret); va_end(ap); return ret; } int main(void) { G g0 = {10}, g1 = {11}; F f0 = {20.0}, f1 = {21.0}; Aligned1024 s = {.c = 77}; long double res = test_variadic( g0, g1, f0, f1, 100, 200, (long double)1.5, s, 300, (double)4.5, s, 400 ); printf("Final result: %Lf\n", res); ASSERT(1160, res); return 0; } chibicc-1.0.23.1/test/function4.c000066400000000000000000000011741505335450300163620ustar00rootroot00000000000000#include #include #include "test.h" typedef struct { char _Alignas(1024) c; } Aligned1024; void test_va_args(const char *label, int n, ...) { va_list ap; va_start(ap, n); long double ld = va_arg(ap, long double); Aligned1024 *a = va_arg(ap, Aligned1024 *); int i = va_arg(ap, int); printf("%s:\n", label); printf("long double = %Lf\n", ld); printf("Aligned1024->c = %d\n", a->c); printf("int = %d\n", i); ASSERT(77, a->c); va_end(ap); } int main(void) { long double ld = 3.1415926535897932384626L; Aligned1024 a = {.c = 77}; test_va_args("Test2", 3, ld, &a, 123); return 0; } chibicc-1.0.23.1/test/function5.c000066400000000000000000000015761505335450300163710ustar00rootroot00000000000000#include #include #include "test.h" void dummy(long double x1, long double x2, long double x3, long double x4, long double x5, long double x6, long double x7, long double x8, long double x9, long double x10, long double x11, long double x12, long double x13, long double x14, int dummy, ...) { va_list ap; va_start(ap, dummy); long double x = va_arg(ap, long double); // Should now be on stack printf("Overflow long double = %Lf\n", x); ASSERT( 99.99L, x); va_end(ap); } int main() { // 14 long double args → xmm0-xmm7 are full → remaining will go to overflow (stack) dummy(1.1L, 2.2L, 3.3L, 4.4L, 5.5L, 6.6L, 7.7L, 8.8L, 9.9L, 10.10L, 11.11L, 12.12L, 13.13L, 14.14L, 42, // Dummy int to mark end of named args 99.99L); // This long double should be read from stack return 0; } chibicc-1.0.23.1/test/function6.c000066400000000000000000000025721505335450300163670ustar00rootroot00000000000000#include #include #include "test.h" typedef int G; // Dummy placeholder for G type typedef double F; // Dummy placeholder for F type typedef struct { char c; // no special alignment here } Aligned1024; // name kept, but no _Alignas long double struct_test130( G g0, G g1, G g2, G g3, G g4, F f0, F f1, F f2, F f3, F f4, F f5, int i0, int i1, ... ) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, long double); ASSERT(310, ret); ret += va_arg(ap, int); // read int ASSERT(330, ret); ret += va_arg(ap, Aligned1024).c; // read struct (just its char) ASSERT(337, ret); // you can uncomment and add more va_arg calls here as needed va_end(ap); return ret; } int main() { G g_vals[5] = {1,2,3,4,5}; F f_vals[6] = {1,2,3,4,5,6}; Aligned1024 s = {7}; // Call with variadic args: long double, int, Aligned1024 long double ld = 10.5L; int i = 20; long double result = struct_test130( g_vals[0], g_vals[1], g_vals[2], g_vals[3], g_vals[4], f_vals[0], f_vals[1], f_vals[2], f_vals[3], f_vals[4], f_vals[5], 100, 200, ld, // variadic long double i, // variadic int s // variadic struct ); printf("Result = %.2Lf\n", result); // Expected: 100 + 200 + 10.5 + 20 + 7 = 337.5 ASSERT(337.5, result); return 0; } chibicc-1.0.23.1/test/function6b.c000066400000000000000000000025771505335450300165360ustar00rootroot00000000000000#include #include #include "test.h" typedef int G; // Dummy placeholder for G type typedef double F; // Dummy placeholder for F type typedef struct { char c; // no special alignment here } Aligned1024; // name kept, but no _Alignas long double struct_test130( G g0, G g1, G g2, G g3, G g4, F f0, F f1, F f2, F f3, F f4, F f5, int i0, int i1, ... ) { va_list ap; va_start(ap, i1); long double ret = i0 + i1; ret += va_arg(ap, int); // read int ASSERT(320, ret); ret += va_arg(ap, long double); ASSERT(330, ret); ret += va_arg(ap, Aligned1024).c; // read struct (just its char) ASSERT(337, ret); // you can uncomment and add more va_arg calls here as needed va_end(ap); return ret; } int main() { G g_vals[5] = {1,2,3,4,5}; F f_vals[6] = {1,2,3,4,5,6}; Aligned1024 s = {7}; // Call with variadic args: long double, int, Aligned1024 long double ld = 10.5L; int i = 20; long double result = struct_test130( g_vals[0], g_vals[1], g_vals[2], g_vals[3], g_vals[4], f_vals[0], f_vals[1], f_vals[2], f_vals[3], f_vals[4], f_vals[5], 100, 200, i, // variadic int ld, // variadic long double s // variadic struct ); printf("Result = %.2Lf\n", result); // Expected: 100 + 200 + 10.5 + 20 + 7 = 337.5 ASSERT(337.5, result); return 0; } chibicc-1.0.23.1/test/function6c.c000066400000000000000000000011301505335450300165170ustar00rootroot00000000000000#include #include #include "test.h" void test_variadic(double first_named, int count, ...) { printf("named arg = %f\n", first_named); va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { double val = va_arg(ap, double); printf("variadic arg[%d] = %f\n", i, val); if (i == 15) ASSERT(15, val ); } va_end(ap); } int main() { test_variadic( 0.0, 15, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10, 11.11, 12.12, 13.13, 14.14, 15.15 ); return 0; } chibicc-1.0.23.1/test/function6d.c000066400000000000000000000026341505335450300165320ustar00rootroot00000000000000#include #include #include "test.h" void test_variadic(int named_int, double named_double, long double named_longdouble, int count, ...) { printf("named int = %d\n", named_int); printf("named double = %f\n", named_double); printf("named long double = %Lf\n", named_longdouble); va_list ap; va_start(ap, count); int v_int = va_arg(ap, int); printf("variadic int = %d\n", v_int); ASSERT(11, v_int); double v_double = va_arg(ap, double); printf("variadic double = %f\n", v_double); ASSERT(6, v_double); long double v_longdouble = va_arg(ap, long double); printf("variadic long double = %Lf\n", v_longdouble); ASSERT(1, v_longdouble); for (int i = 0; i < count; i++) { double val = va_arg(ap, double); printf("variadic extra double[%d] = %f\n", i, val); } va_end(ap); } int main() { test_variadic( 42, // named int 3.14159, // named double 2.718281828459, // named long double 10, // count of extra doubles // Variadic arguments 11, // variadic int 6.62607015, // variadic double 1.61803398875L, // variadic long double // 10 extra variadic doubles 10.10, 20.20, 30.30, 40.40, 50.50, 60.60, 70.70, 80.80, 90.90, 100.100 ); return 0; } chibicc-1.0.23.1/test/function7.c000066400000000000000000000007441505335450300163670ustar00rootroot00000000000000#include #include #include "test.h" long double add_int_ld_variadic(int count, ...) { va_list ap; va_start(ap, count); int a = va_arg(ap, int); long double b = va_arg(ap, long double); va_end(ap); return a + b; } int main() { int x = 100; long double y = 10.5; long double result = add_int_ld_variadic(2, x, y); printf("Result = %.2Lf\n", result); ASSERT(110.5, result); // Expected: 110.50 return 0; } chibicc-1.0.23.1/test/generic.c000077500000000000000000000006371505335450300160730ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(1, _Generic(100.0, double: 1, int *: 2, int: 3, float: 4)); ASSERT(2, _Generic((int *)0, double: 1, int *: 2, int: 3, float: 4)); ASSERT(2, _Generic((int[3]){}, double: 1, int *: 2, int: 3, float: 4)); ASSERT(3, _Generic(100, double: 1, int *: 2, int: 3, float: 4)); ASSERT(4, _Generic(100f, double: 1, int *: 2, int: 3, float: 4)); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/generic2.c000066400000000000000000000020371505335450300161460ustar00rootroot00000000000000#include "test.h" int main(int argc, char**argv) { ASSERT(1, ({ char c; _Generic(c << 1, int:1 ); }) ); ASSERT(1, ({ short s; _Generic(s >> 1, int:1 ); }) ); ASSERT(1, ({ struct { unsigned int c : 17; } s; _Generic(~s.c, int:1 ); }) ); ASSERT(1, ({ struct { unsigned long long c : 17; } s; _Generic(~s.c, int:1 ); }) ); ASSERT(1, ({ char c; _Generic(-c, int:1 ); }) ); ASSERT(1, ({ short s; _Generic(+s, int:1 ); }) ); ASSERT(1, _Generic((long){0}, long:1, long long:0) ); ASSERT(1, _Generic((long long){0}, long long:1, long:0) ); ASSERT(1, _Generic(1L, long:1, long long:0) ); ASSERT(1, _Generic(1LL, long long:1, long:0) ); ASSERT(1, _Generic(1UL, unsigned long:1, unsigned long long:0) ); ASSERT(1, _Generic(1lu, unsigned long:1, unsigned long long:0) ); ASSERT(1, _Generic(1ULL, unsigned long long:1, unsigned long:0) ); ASSERT(1, _Generic(1llu, unsigned long long:1, unsigned long:0) ); ASSERT(1, ({ unsigned long a; long long b; _Generic(a + b, unsigned long long:1, unsigned long:0); }) ); printf("OK\n"); }chibicc-1.0.23.1/test/generic3.c000066400000000000000000000020441505335450300161450ustar00rootroot00000000000000#include "test.h" #include static bool test_unsigned(unsigned a, unsigned *r) { *r = a + 1; return true; } static bool test_ulong(unsigned long a, unsigned long *r) { *r = a + 10; return true; } static bool test_ull(unsigned long long a, unsigned long long *r) { *r = a + 100; return true; } // Generic macro using pointer type #define add_generic(a, r) \ _Generic((r), \ unsigned*: test_unsigned(a, (unsigned *)(r)), \ unsigned long*: test_ulong(a, (unsigned long *)(r)), \ unsigned long long*: test_ull(a, (unsigned long long *)(r))) int main(void) { unsigned u = 1; unsigned long ul = 10; unsigned long long ull = 100; unsigned ru = 0; unsigned long rul = 0; unsigned long long rull = 0; add_generic(u, &ru); add_generic(ul, &rul); add_generic(ull, &rull); printf("Results: ru=%u, rul=%lu, rull=%llu\n", ru, rul, rull); ASSERT(2, ru); ASSERT(20, rul); ASSERT(200, rull); return 0; } chibicc-1.0.23.1/test/hash.h000066400000000000000000000003771505335450300154050ustar00rootroot00000000000000#ifndef HASH_H #define HASH_H typedef uint32_t (*hash_func)(const void *key, size_t length); extern hash_func hash; enum hashfunc_type { JENKINS_HASH=0, MURMUR3_HASH, XXH3_HASH }; int hash_init(enum hashfunc_type type); #endif /* HASH_H */ chibicc-1.0.23.1/test/hello.c000077500000000000000000000002231505335450300155510ustar00rootroot00000000000000 #include "test.h" int main(int argc, char **argv) { printf("Hello World!\n"); printf("%d\n", argc); ASSERT(1, argc); return 0; }chibicc-1.0.23.1/test/huge.c000066400000000000000000000013561505335450300154030ustar00rootroot00000000000000 #include #include "test.h" int main() { // Test with HUGE_VALF float huge_valf = HUGE_VALF; if (huge_valf == __builtin_huge_valf()) { printf("HUGE_VALF test passed: %f\n", huge_valf); } else { printf("HUGE_VALF test failed.\n"); } // Test with HUGE_VALL long double huge_vall = HUGE_VALL; if (huge_vall == __builtin_huge_vall()) { printf("HUGE_VALL test passed: %Lf\n", huge_vall); } else { printf("HUGE_VALL test failed.\n"); } // Test with HUGE_VAL double huge_val = HUGE_VAL; if (huge_val == __builtin_huge_val()) { printf("HUGE_VAL test passed: %f\n", huge_val); } else { printf("HUGE_VAL test failed.\n"); } return 0; } chibicc-1.0.23.1/test/implicit.c000066400000000000000000000003171505335450300162610ustar00rootroot00000000000000#include #include #include int execl(const char *path, ...); //#include int main() { execl("/bin/sh", "sh", "-c", "echo hello", NULL); return 0; }chibicc-1.0.23.1/test/implicit2.c000066400000000000000000000001451505335450300163420ustar00rootroot00000000000000#include int main() { printf("Hello world\n"); fflush(stdout); return 0; }chibicc-1.0.23.1/test/inb.c000066400000000000000000000007241505335450300152210ustar00rootroot00000000000000#include "test.h" #include #include #include #include int main() { if (geteuid() != 0) { printf("Must be run as root.\n"); return 0; } // Request access to port 0x60 (keyboard controller) if (ioperm(0x60, 1, 1)) { printf("ioperm failed\n"); return 0; } unsigned char val = inb(0x60); printf("Read value: 0x%02x from port 0x60\n", val); // Revoke access ioperm(0x60, 1, 0); return 0; }chibicc-1.0.23.1/test/include1.h000077500000000000000000000001541505335450300161620ustar00rootroot00000000000000#include "include2.h" char *include1_filename = __FILE__; int include1_line = __LINE__; int include1 = 5; chibicc-1.0.23.1/test/include2.h000077500000000000000000000000221505335450300161550ustar00rootroot00000000000000int include2 = 7; chibicc-1.0.23.1/test/include3.h000077500000000000000000000000161505335450300161610ustar00rootroot00000000000000#define foo 3 chibicc-1.0.23.1/test/include4.h000077500000000000000000000000161505335450300161620ustar00rootroot00000000000000#define foo 4 chibicc-1.0.23.1/test/initializer.c000077500000000000000000000223771505335450300170070ustar00rootroot00000000000000#include "test.h" char g3 = 3; short g4 = 4; int g5 = 5; long g6 = 6; int g9[3] = {0, 1, 2}; struct {char a; int b;} g11[2] = {{1, 2}, {3, 4}}; struct {int a[2];} g12[2] = {{{1, 2}}}; union { int a; char b[8]; } g13[2] = {0x01020304, 0x05060708}; char g17[] = "foobar"; char g18[10] = "foobar"; char g19[3] = "foobar"; char *g20 = g17+0; char *g21 = g17+3; char (*g22)[7] = &g17-3; char *g23[] = {g17+0, g17+3, g17-3}; int g24=3; int *g25=&g24; int g26[3] = {1, 2, 3}; int *g27 = g26 + 1; int *g28 = &g11[1].a; long g29 = (long)(long)g26; struct { struct { int a[3]; } a; } g30 = {{{1,2,3}}}; int *g31=g30.a.a; struct {int a[2];} g40[2] = {{1, 2}, 3, 4}; struct {int a[2];} g41[2] = {1, 2, 3, 4}; char g43[][4] = {'f', 'o', 'o', 0, 'b', 'a', 'r', 0}; char *g44 = {"foo"}; union { int a; char b[4]; } g50 = {.b[2]=0x12}; union { int a; } g51[2] = {}; typedef char T60[]; T60 g60 = {1, 2, 3}; T60 g61 = {1, 2, 3, 4, 5, 6}; typedef struct { char a, b[]; } T65; T65 g65 = {'f','o','o',0}; T65 g66 = {'f','o','o','b','a','r',0}; int main() { ASSERT(1, ({ int x[3]={1,2,3}; x[0]; })); ASSERT(2, ({ int x[3]={1,2,3}; x[1]; })); ASSERT(3, ({ int x[3]={1,2,3}; x[2]; })); ASSERT(3, ({ int x[3]={1,2,3}; x[2]; })); ASSERT(2, ({ int x[2][3]={{1,2,3},{4,5,6}}; x[0][1]; })); ASSERT(4, ({ int x[2][3]={{1,2,3},{4,5,6}}; x[1][0]; })); ASSERT(6, ({ int x[2][3]={{1,2,3},{4,5,6}}; x[1][2]; })); ASSERT(0, ({ int x[3]={}; x[0]; })); ASSERT(0, ({ int x[3]={}; x[1]; })); ASSERT(0, ({ int x[3]={}; x[2]; })); ASSERT(2, ({ int x[2][3]={{1,2}}; x[0][1]; })); ASSERT(0, ({ int x[2][3]={{1,2}}; x[1][0]; })); ASSERT(0, ({ int x[2][3]={{1,2}}; x[1][2]; })); ASSERT('a', ({ char x[4]="abc"; x[0]; })); ASSERT('c', ({ char x[4]="abc"; x[2]; })); ASSERT(0, ({ char x[4]="abc"; x[3]; })); ASSERT('a', ({ char x[2][4]={"abc","def"}; x[0][0]; })); ASSERT(0, ({ char x[2][4]={"abc","def"}; x[0][3]; })); ASSERT('d', ({ char x[2][4]={"abc","def"}; x[1][0]; })); ASSERT('f', ({ char x[2][4]={"abc","def"}; x[1][2]; })); ASSERT(4, ({ int x[]={1,2,3,4}; x[3]; })); ASSERT(16, ({ int x[]={1,2,3,4}; sizeof(x); })); ASSERT(4, ({ char x[]="foo"; sizeof(x); })); ASSERT(4, ({ typedef char T[]; T x="foo"; T y="x"; sizeof(x); })); ASSERT(2, ({ typedef char T[]; T x="foo"; T y="x"; sizeof(y); })); ASSERT(2, ({ typedef char T[]; T x="x"; T y="foo"; sizeof(x); })); ASSERT(4, ({ typedef char T[]; T x="x"; T y="foo"; sizeof(y); })); ASSERT(1, ({ struct {int a; int b; int c;} x={1,2,3}; x.a; })); ASSERT(2, ({ struct {int a; int b; int c;} x={1,2,3}; x.b; })); ASSERT(3, ({ struct {int a; int b; int c;} x={1,2,3}; x.c; })); ASSERT(1, ({ struct {int a; int b; int c;} x={1}; x.a; })); ASSERT(0, ({ struct {int a; int b; int c;} x={1}; x.b; })); ASSERT(0, ({ struct {int a; int b; int c;} x={1}; x.c; })); ASSERT(1, ({ struct {int a; int b;} x[2]={{1,2},{3,4}}; x[0].a; })); ASSERT(2, ({ struct {int a; int b;} x[2]={{1,2},{3,4}}; x[0].b; })); ASSERT(3, ({ struct {int a; int b;} x[2]={{1,2},{3,4}}; x[1].a; })); ASSERT(4, ({ struct {int a; int b;} x[2]={{1,2},{3,4}}; x[1].b; })); ASSERT(0, ({ struct {int a; int b;} x[2]={{1,2}}; x[1].b; })); ASSERT(0, ({ struct {int a; int b;} x={}; x.a; })); ASSERT(0, ({ struct {int a; int b;} x={}; x.b; })); ASSERT(5, ({ typedef struct {int a,b,c,d,e,f;} T; T x={1,2,3,4,5,6}; T y; y=x; y.e; })); ASSERT(2, ({ typedef struct {int a,b;} T; T x={1,2}; T y, z; z=y=x; z.b; })); ASSERT(1, ({ typedef struct {int a,b;} T; T x={1,2}; T y=x; y.a; })); ASSERT(4, ({ union { int a; char b[4]; } x={0x01020304}; x.b[0]; })); ASSERT(3, ({ union { int a; char b[4]; } x={0x01020304}; x.b[1]; })); ASSERT(0x01020304, ({ union { struct { char a,b,c,d; } e; int f; } x={{4,3,2,1}}; x.f; })); ASSERT(3, g3); ASSERT(4, g4); ASSERT(5, g5); ASSERT(6, g6); ASSERT(0, g9[0]); ASSERT(1, g9[1]); ASSERT(2, g9[2]); ASSERT(1, g11[0].a); ASSERT(2, g11[0].b); ASSERT(3, g11[1].a); ASSERT(4, g11[1].b); ASSERT(1, g12[0].a[0]); ASSERT(2, g12[0].a[1]); ASSERT(0, g12[1].a[0]); ASSERT(0, g12[1].a[1]); ASSERT(4, g13[0].b[0]); ASSERT(3, g13[0].b[1]); ASSERT(8, g13[1].b[0]); ASSERT(7, g13[1].b[1]); ASSERT(7, sizeof(g17)); ASSERT(10, sizeof(g18)); ASSERT(3, sizeof(g19)); ASSERT(0, memcmp(g17, "foobar", 7)); ASSERT(0, memcmp(g18, "foobar\0\0\0", 10)); ASSERT(0, memcmp(g19, "foo", 3)); ASSERT(0, strcmp(g20, "foobar")); ASSERT(0, strcmp(g21, "bar")); ASSERT(0, strcmp(*(g22+3), "foobar")); ASSERT(0, strcmp(g23[0], "foobar")); ASSERT(0, strcmp(g23[1], "bar")); ASSERT(0, strcmp(g23[2]+3, "foobar")); ASSERT(3, g24); ASSERT(3, *g25); ASSERT(2, *g27); ASSERT(3, *g28); ASSERT(1, *(int *)g29); ASSERT(1, g31[0]); ASSERT(2, g31[1]); ASSERT(3, g31[2]); ASSERT(1, g40[0].a[0]); ASSERT(2, g40[0].a[1]); ASSERT(3, g40[1].a[0]); ASSERT(4, g40[1].a[1]); ASSERT(1, g41[0].a[0]); ASSERT(2, g41[0].a[1]); ASSERT(3, g41[1].a[0]); ASSERT(4, g41[1].a[1]); ASSERT(0, ({ int x[2][3]={0,1,2,3,4,5}; x[0][0]; })); ASSERT(3, ({ int x[2][3]={0,1,2,3,4,5}; x[1][0]; })); ASSERT(0, ({ struct {int a; int b;} x[2]={0,1,2,3}; x[0].a; })); ASSERT(2, ({ struct {int a; int b;} x[2]={0,1,2,3}; x[1].a; })); ASSERT(0, strcmp(g43[0], "foo")); ASSERT(0, strcmp(g43[1], "bar")); ASSERT(0, strcmp(g44, "foo")); ASSERT(3, ({ int a[]={1,2,3,}; a[2]; })); ASSERT(1, ({ struct {int a,b,c;} x={1,2,3,}; x.a; })); ASSERT(1, ({ union {int a; char b;} x={1,}; x.a; })); ASSERT(2, ({ enum {x,y,z,}; z; })); ASSERT(3, sizeof(g60)); ASSERT(6, sizeof(g61)); ASSERT(1, sizeof(g65)); ASSERT(1, sizeof(g66)); ASSERT(0, strcmp(g65.b, "oo")); ASSERT(0, strcmp(g66.b, "oobar")); ASSERT(4, ({ int x[3]={1, 2, 3, [0]=4, 5}; x[0]; })); ASSERT(5, ({ int x[3]={1, 2, 3, [0]=4, 5}; x[1]; })); ASSERT(3, ({ int x[3]={1, 2, 3, [0]=4, 5}; x[2]; })); ASSERT(10, ({ int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; x[0][0]; })); ASSERT(11, ({ int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; x[0][1]; })); ASSERT(8, ({ int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; x[0][2]; })); ASSERT(12, ({ int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; x[1][0]; })); ASSERT(5, ({ int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; x[1][1]; })); ASSERT(6, ({ int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; x[1][2]; })); ASSERT(7, ({ int x[2][3]={1,2,3,4,5,6,[0]={7,8},9,10}; x[0][0]; })); ASSERT(8, ({ int x[2][3]={1,2,3,4,5,6,[0]={7,8},9,10}; x[0][1]; })); ASSERT(3, ({ int x[2][3]={1,2,3,4,5,6,[0]={7,8},9,10}; x[0][2]; })); ASSERT(9, ({ int x[2][3]={1,2,3,4,5,6,[0]={7,8},9,10}; x[1][0]; })); ASSERT(10, ({ int x[2][3]={1,2,3,4,5,6,[0]={7,8},9,10}; x[1][1]; })); ASSERT(6, ({ int x[2][3]={1,2,3,4,5,6,[0]={7,8},9,10}; x[1][2]; })); ASSERT(7, ((int[10]){ [3]=7 })[3]); ASSERT(0, ((int[10]){ [3]=7 })[4]); ASSERT(10, ({ char x[]={[10-3]=1,2,3}; sizeof(x); })); ASSERT(20, ({ char x[][2]={[8][1]=1,2}; sizeof(x); })); ASSERT(4, ({ struct { int a,b; } x={1,2,.b=3,.a=4}; x.a; })); ASSERT(3, ({ struct { int a,b; } x={1,2,.b=3,.a=4}; x.b; })); ASSERT(1, ({ struct { struct { int a,b; } c; } x={.c=1,2}; x.c.a; })); ASSERT(2, ({ struct { struct { int a,b; } c; } x={.c=1,2}; x.c.b; })); ASSERT(0, ({ struct { struct { int a,b; } c; } x={.c.b=1}; x.c.a; })); ASSERT(1, ({ struct { struct { int a,b; } c; } x={.c.b=1}; x.c.b; })); ASSERT(1, ({ struct { int a[2]; } x={.a=1,2}; x.a[0]; })); ASSERT(2, ({ struct { int a[2]; } x={.a=1,2}; x.a[1]; })); ASSERT(0, ({ struct { int a[2]; } x={.a[1]=1}; x.a[0]; })); ASSERT(1, ({ struct { int a[2]; } x={.a[1]=1}; x.a[1]; })); ASSERT(3, ({ struct { int a,b; } x[]={[1].b=1,2,[0]=3,4,}; x[0].a; })); ASSERT(4, ({ struct { int a,b; } x[]={[1].b=1,2,[0]=3,4,}; x[0].b; })); ASSERT(0, ({ struct { int a,b; } x[]={[1].b=1,2,[0]=3,4,}; x[1].a; })); ASSERT(1, ({ struct { int a,b; } x[]={[1].b=1,2,[0]=3,4,}; x[1].b; })); ASSERT(2, ({ struct { int a,b; } x[]={[1].b=1,2,[0]=3,4,}; x[2].a; })); ASSERT(0, ({ struct { int a,b; } x[]={[1].b=1,2,[0]=3,4,}; x[2].b; })); ASSERT(1, ({ typedef struct { int a,b; } T; T x={1,2}; T y[]={x}; y[0].a; })); ASSERT(2, ({ typedef struct { int a,b; } T; T x={1,2}; T y[]={x}; y[0].b; })); ASSERT(0, ({ typedef struct { int a,b; } T; T x={1,2}; T y[]={x, [0].b=3}; y[0].a; })); ASSERT(3, ({ typedef struct { int a,b; } T; T x={1,2}; T y[]={x, [0].b=3}; y[0].b; })); ASSERT(5, ((struct { int a,b,c; }){ .c=5 }).c); ASSERT(0, ((struct { int a,b,c; }){ .c=5 }).a); ASSERT(0x00ff, ({ union { unsigned short a; char b[2]; } x={.b[0]=0xff}; x.a; })); ASSERT(0xff00, ({ union { unsigned short a; char b[2]; } x={.b[1]=0xff}; x.a; })); ASSERT(0x00120000, g50.a); ASSERT(0, g51[0].a); ASSERT(0, g51[1].a); ASSERT(1, ({ struct { struct { int a; struct { int b; }; }; int c; } x={1,2,3,.b=4,5}; x.a; })); ASSERT(4, ({ struct { struct { int a; struct { int b; }; }; int c; } x={1,2,3,.b=4,5}; x.b; })); ASSERT(5, ({ struct { struct { int a; struct { int b; }; }; int c; } x={1,2,3,.b=4,5}; x.c; })); ASSERT(16, ({ char x[]={[2 ... 10]='a', [7]='b', [15 ... 15]='c', [3 ... 5]='d'}; sizeof(x); })); ASSERT(0, ({ char x[]={[2 ... 10]='a', [7]='b', [15 ... 15]='c', [3 ... 5]='d'}; memcmp(x, "\0\0adddabaaa\0\0\0\0c", 16); })); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/initializer_list.c000066400000000000000000000013351505335450300200260ustar00rootroot00000000000000 #include "test.h" struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; signed char __rwelision; unsigned char __pad1[7]; unsigned long int __pad2; unsigned int __flags; }; typedef union { struct __pthread_rwlock_arch_t __data; char __size[56]; long int __align; } pthread_rwlock_t; typedef union { char __size[8]; long int __align; } pthread_rwlockattr_t; int main() { pthread_rwlock_t lock = {0, }; lock.__align = 8; printf("%ld\n", lock.__align); ASSERT(8, lock.__align); printf("%ld\n", sizeof(lock)); ASSERT(56, sizeof(lock)); return 0; }chibicc-1.0.23.1/test/int128.c000066400000000000000000006615461505335450300155150ustar00rootroot00000000000000/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "test.h" #include #define BANE 0x8000000000000000 #define BANE1 0x8000000000000001 #define BANE2 0x8000000000000002 #define IMAX 0x7fffffffffffffff #define IMAX2 0xfffffffffffffffd #define I128(HI, LO) ((LO) | (unsigned __int128)(HI) << 64) __int128 add128(__int128 x, __int128 y) { return x + y; } __int128 sub128x5(__int128 a, __int128 b, __int128 c, __int128 d, __int128 e) { return a - b - c - d - e; } __int128 sub128x6(int f, __int128 a, __int128 b, __int128 c, __int128 d, __int128 e) { return f - a - b - c - d - e; } void lotsOfArgs(const char *file, int line, const char *func, __int128 beg, __int128 end, __int128 got, const char *gotcode, bool isfatal) { } void testLang128(void) { lotsOfArgs(__FILE__, __LINE__, __FUNCTION__, 0, 0, 0, "", false); ASSERT(16, sizeof(__int128)); ASSERT(16, sizeof(unsigned __int128)); ASSERT(16, _Alignof(__int128)); ASSERT(16, ({ struct T { __int128 x; }; _Alignof(struct T); })); ASSERT(16, ({ struct __attribute__((__aligned__(16))) T { __int128 x; }; _Alignof(struct T); })); ASSERT128(7, ({ __int128 i = 2; i += 5; i; })); ASSERT128(I128(0xffffffffffffffff, 0xffffffffffffffff), ({ __int128 i = 0; add128(i, -1); })); ASSERT128(I128(0x3a8eaaa2e9af03f5, 0xd7ed730a55920176), sub128x5(I128(0x0db9cd085ab6ba38, 0xdaf9c05f15896b5f), I128(0xb6429ba7b5b38454, 0x4061839d268a0a78), I128(0x19a0da005190a5ac, 0x755fa06484419e38), I128(0xafc6e44400b9eadd, 0x05e5afdb2e66cdb8), I128(0x5380c8796909a165, 0x47657977e6c4f381))); ASSERT128(I128(0x1f1b109234418f84, 0x21f9f24c8535e4f0), sub128x6(0x5ab6ba38, I128(0x0db9cd085ab6ba38, 0xdaf9c05f15896b5f), I128(0xb6429ba7b5b38454, 0x4061839d268a0a78), I128(0x19a0da005190a5ac, 0x755fa06484419e38), I128(0xafc6e44400b9eadd, 0x05e5afdb2e66cdb8), I128(0x5380c8796909a165, 0x47657977e6c4f381))); } void testCompare128(void) { __int128 x = 1, y = 2; ASSERT(0, x == y); ASSERT(1, x != y); ASSERT(1, x < y); ASSERT(1, x <= y); ASSERT(0, x > y); ASSERT(0, x >= y); ASSERT(1, x >= x); x = I128(-1ul, 2); y = I128(0xfffffffffffffff0, 2); ASSERT(0, x == y); } void testCastDblInt128(void) { int k; double f; __int128 i, w; k = 110; i = 1; i <<= k; f = i; f /= 2; i = f; w = 1; w <<= k - 1; ASSERT128(w, i); } void testCastDblUint128(void) { double f; unsigned __int128 i; i = 0x0000ffffffffffff; ++i; f = i; --f; i = f; --i; ASSERT128(0x0000fffffffffffe, i); } void testCastLdblInt128(void) { int k; __int128 i, w; long double f; k = 110; i = 1; i <<= k; f = i; f /= 2; i = f; w = 1; w <<= k - 1; ASSERT128(w, i); } void testCastLdblUint128(void) { long double f; unsigned __int128 i; i = 0xffffffffffffffff; ++i; f = i; --f; i = f; --i; ASSERT128(0xfffffffffffffffe, i); } void testAdd128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x + y); x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 2), x + y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, BANE), x + y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x + y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x + y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x + y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x + y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x + y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x + y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x + y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x + y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x + y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x + y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x + y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x + y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(0, 2); y = I128(0, 0); ASSERT128(I128(0, 2), x + y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 4), x + y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, BANE2), x + y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(1, 1), x + y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x + y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(2, 4), x + y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x + y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(3, 1), x + y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x + y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 4), x + y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x + y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 1), x + y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x + y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 4), x + y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x + y); x = I128(0, BANE); y = I128(0, 0); ASSERT128(I128(0, BANE), x + y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, BANE2), x + y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(1, 0), x + y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(1, IMAX), x + y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x + y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x + y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(3, 0), x + y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(3, IMAX), x + y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x + y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x + y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE1, 0), x + y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x + y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x + y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, IMAX), x + y); x = I128(0, -1ul); y = I128(0, 0); ASSERT128(I128(0, -1ul), x + y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(1, 1), x + y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(1, IMAX), x + y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x + y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x + y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(3, 1), x + y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(3, IMAX), x + y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(3, 0xfffffffffffffffe), x + y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x + y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE1, 1), x + y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x + y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x + y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x + y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x + y); x = I128(2, 0); y = I128(0, 0); ASSERT128(I128(2, 0), x + y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(2, 2), x + y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(2, BANE), x + y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x + y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(4, 0), x + y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(4, 2), x + y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(4, BANE), x + y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(4, -1ul), x + y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x + y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x + y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x + y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x + y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(1, 2), x + y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(1, BANE), x + y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(1, -1ul), x + y); x = I128(2, 2); y = I128(0, 0); ASSERT128(I128(2, 2), x + y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 4), x + y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(2, BANE2), x + y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(3, 1), x + y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(4, 2), x + y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(4, 4), x + y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(4, BANE2), x + y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(5, 1), x + y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x + y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 4), x + y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(1, 2), x + y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(1, 4), x + y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(1, BANE2), x + y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 1), x + y); x = I128(2, BANE); y = I128(0, 0); ASSERT128(I128(2, BANE), x + y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, BANE2), x + y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(3, 0), x + y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(3, IMAX), x + y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(4, BANE), x + y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(4, BANE2), x + y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(5, 0), x + y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(5, IMAX), x + y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x + y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x8000000000000003, 0), x + y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(1, BANE), x + y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(1, BANE2), x + y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x + y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, IMAX), x + y); x = I128(2, -1ul); y = I128(0, 0); ASSERT128(I128(2, -1ul), x + y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(3, 1), x + y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(3, IMAX), x + y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(3, 0xfffffffffffffffe), x + y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(4, -1ul), x + y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(5, 1), x + y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(5, IMAX), x + y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(5, 0xfffffffffffffffe), x + y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0x8000000000000003, 0xfffffffffffffffe), x + y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, -1ul), x + y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 1), x + y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(2, IMAX), x + y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x + y); x = I128(BANE, 0); y = I128(0, 0); ASSERT128(I128(BANE, 0), x + y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(BANE, 2), x + y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x + y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x + y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(BANE2, 0), x + y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x + y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x + y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x + y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 2), x + y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x + y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x + y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 0), x + y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 2), x + y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE), x + y); x = I128(BANE, 0); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(BANE, 2); y = I128(0, 0); ASSERT128(I128(BANE, 2), x + y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 4), x + y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(BANE, BANE2), x + y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE1, 1), x + y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(BANE2, 2), x + y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(BANE2, 4), x + y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x + y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 4), x + y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, BANE2), x + y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(1, 1), x + y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 2), x + y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 4), x + y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 1), x + y); x = I128(BANE, BANE); y = I128(0, 0); ASSERT128(I128(BANE, BANE), x + y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, BANE2), x + y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE1, 0), x + y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(BANE2, BANE), x + y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(BANE2, BANE2), x + y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0x8000000000000003, 0), x + y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x + y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE2), x + y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x + y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(1, IMAX), x + y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(IMAX, BANE), x + y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x + y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, IMAX), x + y); x = I128(BANE, -1ul); y = I128(0, 0); ASSERT128(I128(BANE, -1ul), x + y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE1, 1), x + y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE1, IMAX), x + y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x + y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(BANE2, -1ul), x + y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0x8000000000000003, 1), x + y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0x8000000000000003, IMAX), x + y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000003, 0xfffffffffffffffe), x + y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x + y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(1, 1), x + y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(1, IMAX), x + y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x + y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE, 1), x + y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, IMAX), x + y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 0xfffffffffffffffe), x + y); x = I128(-1ul, 0); y = I128(0, 0); ASSERT128(I128(-1ul, 0), x + y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x + y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x + y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(1, 0), x + y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(1, 2), x + y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(1, BANE), x + y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(1, -1ul), x + y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x + y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(IMAX, 2), x + y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x + y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x + y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 2), x + y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE), x + y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0xfffffffffffffffe, -1ul), x + y); x = I128(-1ul, 2); y = I128(0, 0); ASSERT128(I128(-1ul, 2), x + y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 4), x + y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 1), x + y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(1, 2), x + y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(1, 4), x + y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(1, BANE2), x + y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(2, 1), x + y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x + y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 4), x + y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 1), x + y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 2), x + y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x + y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE2), x + y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x + y); x = I128(-1ul, BANE); y = I128(0, 0); ASSERT128(I128(-1ul, BANE), x + y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, BANE2), x + y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x + y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, IMAX), x + y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(1, BANE), x + y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(1, BANE2), x + y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(2, 0), x + y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(2, IMAX), x + y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x + y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, BANE2), x + y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x + y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, IMAX), x + y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, BANE), x + y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, BANE2), x + y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x + y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(0, 0); ASSERT128(I128(-1ul, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x + y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x + y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(1, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(2, 1), x + y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(2, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x + y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, 1), x + y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0xfffffffffffffffe), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, -1ul), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 1), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, IMAX), x + y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x + y); } void testSub128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x - y); x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), x - y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 1), x - y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x - y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x - y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 1), x - y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x - y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0xfffffffffffffffe), x - y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x - y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x - y); x = I128(0, 2); y = I128(0, 0); ASSERT128(I128(0, 2), x - y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x - y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 2), x - y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE2), x - y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 3), x - y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x - y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x - y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE2), x - y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 3), x - y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(1, 2), x - y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(1, 0), x - y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE2), x - y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 3), x - y); x = I128(0, BANE); y = I128(0, 0); ASSERT128(I128(0, BANE), x - y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x - y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, BANE), x - y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(IMAX2, BANE1), x - y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x - y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x - y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, BANE1), x - y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(1, BANE), x - y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(1, 0x7ffffffffffffffe), x - y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(1, 0), x - y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE1), x - y); x = I128(0, -1ul); y = I128(0, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x - y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, -1ul), x - y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, IMAX2), x - y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffe, IMAX), x - y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x - y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x - y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, IMAX2), x - y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, IMAX), x - y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x - y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, -1ul), x - y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(1, IMAX2), x - y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(1, IMAX), x - y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(1, 0), x - y); x = I128(2, 0); y = I128(0, 0); ASSERT128(I128(2, 0), x - y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(1, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(1, BANE), x - y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(1, 1), x - y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x - y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE1, BANE), x - y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 1), x - y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(3, 0), x - y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(2, 0xfffffffffffffffe), x - y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x - y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(2, 1), x - y); x = I128(2, 2); y = I128(0, 0); ASSERT128(I128(2, 2), x - y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 0), x - y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(1, BANE2), x - y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(1, 3), x - y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x - y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x - y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x - y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE1, BANE2), x - y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 3), x - y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(3, 2), x - y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(3, 0), x - y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE2), x - y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 3), x - y); x = I128(2, BANE); y = I128(0, 0); ASSERT128(I128(2, BANE), x - y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(2, 0), x - y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(1, BANE1), x - y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x - y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x - y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x - y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, BANE1), x - y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(3, BANE), x - y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(3, 0x7ffffffffffffffe), x - y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(3, 0), x - y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, BANE1), x - y); x = I128(2, -1ul); y = I128(0, 0); ASSERT128(I128(2, -1ul), x - y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(2, IMAX2), x - y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(2, IMAX), x - y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(2, 0), x - y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x - y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x - y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE2, IMAX2), x - y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE2, IMAX), x - y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, 0), x - y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(3, -1ul), x - y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(3, IMAX2), x - y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(3, IMAX), x - y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(3, 0), x - y); x = I128(BANE, 0); y = I128(0, 0); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x - y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(IMAX, 1), x - y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffd, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x - y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, 1), x - y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x - y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(BANE1, 0), x - y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0xfffffffffffffffe), x - y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x - y); x = I128(BANE, 0); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 1), x - y); x = I128(BANE, 2); y = I128(0, 0); ASSERT128(I128(BANE, 2), x - y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE2), x - y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(IMAX, 3), x - y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, 2), x - y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE2), x - y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, 3), x - y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x - y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x - y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(BANE1, 2), x - y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0), x - y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE2), x - y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 3), x - y); x = I128(BANE, BANE); y = I128(0, 0); ASSERT128(I128(BANE, BANE), x - y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(IMAX, BANE1), x - y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, BANE), x - y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffe, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE1), x - y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x - y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x - y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE1, BANE), x - y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0x7ffffffffffffffe), x - y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE1, 0), x - y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, BANE1), x - y); x = I128(BANE, -1ul); y = I128(0, 0); ASSERT128(I128(BANE, -1ul), x - y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE, IMAX), x - y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE, 0), x - y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0x7ffffffffffffffe, -1ul), x - y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0x7ffffffffffffffe, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffe, IMAX), x - y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 0), x - y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x - y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(BANE1, -1ul), x - y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE1, IMAX2), x - y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE1, IMAX), x - y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE1, 0), x - y); x = I128(-1ul, 0); y = I128(0, 0); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0xfffffffffffffffe, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE), x - y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 1), x - y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffc, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffc, BANE), x - y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, 1), x - y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0x7ffffffffffffffe, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE), x - y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x - y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x - y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x - y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x - y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x - y); x = I128(-1ul, 2); y = I128(0, 0); ASSERT128(I128(-1ul, 2), x - y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(0xfffffffffffffffe, BANE2), x - y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 3), x - y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(IMAX2, 2), x - y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0xfffffffffffffffc, BANE2), x - y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, 3), x - y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x - y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE2), x - y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 3), x - y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x - y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x - y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x - y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 3), x - y); x = I128(-1ul, BANE); y = I128(0, 0); ASSERT128(I128(-1ul, BANE), x - y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, BANE1), x - y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(IMAX2, BANE), x - y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(IMAX2, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, BANE1), x - y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x - y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, BANE1), x - y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x - y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x - y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x - y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE1), x - y); x = I128(-1ul, -1ul); y = I128(0, 0); ASSERT128(I128(-1ul, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, 0), x - y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(IMAX2, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(IMAX2, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0), x - y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x - y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x - y); } void testMul128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x * y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x * y); x = I128(0, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 4), x * y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x * y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(4, 4), x * y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(5, 0), x * y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(5, 0xfffffffffffffffe), x * y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 4), x * y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x * y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x * y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(0, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(1, 0), x * y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(1, 0), x * y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(1, 0), x * y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0), x * y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(0, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 1), x * y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffc, 1), x * y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x * y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x * y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x * y); x = I128(2, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(4, 0), x * y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x * y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(4, 4), x * y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x * y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0x0000000000000008, 4), x * y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(5, 0), x * y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(3, 0xfffffffffffffffe), x * y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(4, 4), x * y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x * y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(2, 4), x * y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x * y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x * y); x = I128(2, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(5, 0), x * y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(5, 0), x * y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(5, 0), x * y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(0x8000000000000005, 0), x * y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, BANE), x * y); x = I128(2, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(5, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0xfffffffffffffffc, 1), x * y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(3, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffa, 1), x * y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0x8000000000000005, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffc, 1), x * y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0x0000000000000006, 0xfffffffffffffffe), x * y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x * y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 1), x * y); x = I128(BANE, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 0); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 4), x * y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x * y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(4, 4), x * y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(5, 0), x * y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0x8000000000000005, 0xfffffffffffffffe), x * y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 4), x * y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(1, 0), x * y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x * y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x * y); x = I128(BANE, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(1, 0), x * y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(1, 0), x * y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(1, 0), x * y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE1, 0), x * y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, BANE), x * y); x = I128(BANE, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(1, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x * y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0x7ffffffffffffffd, BANE), x * y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0x7ffffffffffffffc, 1), x * y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE1, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0xfffffffffffffffe, 1), x * y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x * y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 1), x * y); x = I128(-1ul, 0); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, 2); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(BANE1, 0), x * y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(4, 0), x * y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(2, 4), x * y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0x8000000000000005, 0), x * y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0x0000000000000006, 0xfffffffffffffffe), x * y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(0xfffffffffffffffe, 4), x * y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE1, 0), x * y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(2, 0xfffffffffffffffe), x * y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0xfffffffffffffffc, 4), x * y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, 0), x * y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x * y); x = I128(-1ul, BANE); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, 0), x * y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE, BANE), x * y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, 0), x * y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(BANE, BANE), x * y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0), x * y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(0xc000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x * y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 0), x * y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0x4000000000000000, 0), x * y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x * y); x = I128(-1ul, -1ul); y = I128(0, 0); ASSERT128(I128(0, 0), x * y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x * y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, 1), x * y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), x * y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), x * y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 1), x * y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x * y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x * y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 1), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(1, 0), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0xfffffffffffffffe), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x * y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x * y); } void testDiv128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 1), x / y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 1), x / y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(1, 0), x / y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffc), x / y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0), x / y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(1, 1), x / y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffc), x / y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), x / y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(1, 0x4000000000000000), x / y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffb), x / y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, BANE), x / y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(1, IMAX), x / y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 3), x / y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, IMAX2), x / y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffb), x / y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 1), x / y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, 0), x / y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, 0), x / y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000000), x / y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xcccccccccccccccd), x / y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(1, 0), x / y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, 1), x / y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, 1), x / y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xcccccccccccccccd), x / y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, -1ul), x / y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 0xfffffffffffffffe), x / y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, 1), x / y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x / y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xcccccccccccccccd), x / y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, -1ul), x / y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, BANE), x / y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0xc000000000000000, BANE), x / y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, 2), x / y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE1), x / y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0xc000000000000001), x / y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(-1ul, 0xccccccccccccccce), x / y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0xd555555555555556), x / y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0xfffffffffffffffe), x / y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 1), x / y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, BANE), x / y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x / y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x / y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, BANE1), x / y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0xfffffffffffffffe), x / y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, 0xc000000000000000), x / y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x / y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x / y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x / y); } void testDivu128(void) { unsigned __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 1), x / y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(1, 0), x / y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(1, 1), x / y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 4), x / y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(1, 0x4000000000000000), x / y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 2), x / y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(1, IMAX), x / y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, 5), x / y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 3), x / y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, 0), x / y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(1, 0), x / y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0, 0x3fffffffffffffff), x / y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x / y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, 1), x / y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(1, 0), x / y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x / y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0, 0x3fffffffffffffff), x / y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x / y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(1, 1), x / y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x / y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0x4000000000000000, IMAX), x / y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(1, 1), x / y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, BANE1), x / y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0, 0x4000000000000000), x / y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0x3333333333333333), x / y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaab), x / y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(IMAX, BANE), x / y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(1, 0xfffffffffffffffe), x / y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(IMAX, BANE1), x / y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(1, 0xfffffffffffffffe), x / y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(IMAX, 0xc000000000000000), x / y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(1, -1ul), x / y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(1, 0), x / y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x / y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(IMAX, -1ul), x / y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(1, -1ul), x / y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(1, 1), x / y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX), x / y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(0, 0x6666666666666666), x / y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, 1), x / y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 1), x / y); } void testRem128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 1), x % y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 4), x % y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 4), x % y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0x0000000000000006), x % y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE2), x % y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0x8000000000000004), x % y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 5), x % y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0x7ffffffffffffffe), x % y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0xd555555555555556), x % y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x % y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 1), x % y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x % y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 2), x % y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, BANE), x % y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0xd555555555555558), x % y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 3), x % y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, BANE), x % y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0xfffffffffffffffe, 0xfffffffffffffffe), x % y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0x5555555555555556), x % y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE1), x % y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, -1ul), x % y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, 0x7ffffffffffffffd), x % y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, -1ul), x % y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0xfffffffffffffffe, 0xd555555555555555), x % y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), x % y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x % y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); } void testRemu128(void) { unsigned __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 2), x % y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, -1ul), x % y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x % y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(2, 0), x % y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 4), x % y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(2, 2), x % y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 2), x % y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE2), x % y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x % y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, BANE), x % y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(2, -1ul), x % y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(2, -1ul), x % y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(1, BANE2), x % y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0x2aaaaaaaaaaaaaaa), x % y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x % y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(0, BANE2), x % y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x % y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(1, 0x8000000000000004), x % y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0, BANE2), x % y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(2, 0x2aaaaaaaaaaaaaac), x % y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x % y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 2), x % y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, 1), x % y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(1, 0), x % y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(2, 0xaaaaaaaaaaaaaaaa), x % y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x % y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, BANE), x % y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX), x % y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(1, IMAX), x % y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0x2aaaaaaaaaaaaaaa), x % y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, -1ul), x % y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, -1ul), x % y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(1, 0), x % y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555555), x % y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(0x7ffffffffffffffe, 0xfffffffffffffffe), x % y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE), x % y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 1), x % y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0), x % y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(1, 2), x % y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(0, 4), x % y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(0, 0x5555555555555557), x % y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x % y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(0x7ffffffffffffffe, BANE2), x % y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, 3), x % y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 2), x % y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(1, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE2), x % y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x % y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(0, 0xd555555555555555), x % y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x % y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0x7ffffffffffffffe), x % y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0x7ffffffffffffffe, BANE1), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x % y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0x7ffffffffffffffe), x % y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x % y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 1), x % y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x % y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(1, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(1, 1), x % y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(0, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(1, 0x5555555555555554), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), x % y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), x % y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x % y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x % y); } void testShr128(void) { unsigned __int128 x; x = I128(0, 0); x >>= 0; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 1; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 0; ASSERT128(I128(0, 2), x); x = I128(0, 2); x >>= 1; ASSERT128(I128(0, 1), x); x = I128(0, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 0; ASSERT128(I128(0, BANE), x); x = I128(0, BANE); x >>= 1; ASSERT128(I128(0, 0x4000000000000000), x); x = I128(0, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 0; ASSERT128(I128(0, -1ul), x); x = I128(0, -1ul); x >>= 1; ASSERT128(I128(0, IMAX), x); x = I128(0, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 0; ASSERT128(I128(2, 0), x); x = I128(2, 0); x >>= 1; ASSERT128(I128(1, 0), x); x = I128(2, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 0; ASSERT128(I128(2, 2), x); x = I128(2, 2); x >>= 1; ASSERT128(I128(1, 1), x); x = I128(2, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 0; ASSERT128(I128(2, BANE), x); x = I128(2, BANE); x >>= 1; ASSERT128(I128(1, 0x4000000000000000), x); x = I128(2, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 0; ASSERT128(I128(2, -1ul), x); x = I128(2, -1ul); x >>= 1; ASSERT128(I128(1, IMAX), x); x = I128(2, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x >>= 0; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x >>= 1; ASSERT128(I128(0x4000000000000000, 0), x); x = I128(BANE, 0); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, 0); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(BANE, 2); x >>= 0; ASSERT128(I128(BANE, 2), x); x = I128(BANE, 2); x >>= 1; ASSERT128(I128(0x4000000000000000, 1), x); x = I128(BANE, 2); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, 2); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(BANE, BANE); x >>= 0; ASSERT128(I128(BANE, BANE), x); x = I128(BANE, BANE); x >>= 1; ASSERT128(I128(0x4000000000000000, 0x4000000000000000), x); x = I128(BANE, BANE); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, BANE); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(BANE, -1ul); x >>= 0; ASSERT128(I128(BANE, -1ul), x); x = I128(BANE, -1ul); x >>= 1; ASSERT128(I128(0x4000000000000000, IMAX), x); x = I128(BANE, -1ul); x >>= 126; ASSERT128(I128(0, 2), x); x = I128(BANE, -1ul); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, 0); x >>= 0; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, 0); x >>= 1; ASSERT128(I128(IMAX, BANE), x); x = I128(-1ul, 0); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, 0); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, 2); x >>= 0; ASSERT128(I128(-1ul, 2), x); x = I128(-1ul, 2); x >>= 1; ASSERT128(I128(IMAX, BANE1), x); x = I128(-1ul, 2); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, 2); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, BANE); x >>= 0; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, BANE); x >>= 1; ASSERT128(I128(IMAX, 0xc000000000000000), x); x = I128(-1ul, BANE); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, BANE); x >>= 127; ASSERT128(I128(0, 1), x); x = I128(-1ul, -1ul); x >>= 0; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 1; ASSERT128(I128(IMAX, -1ul), x); x = I128(-1ul, -1ul); x >>= 126; ASSERT128(I128(0, 3), x); x = I128(-1ul, -1ul); x >>= 127; ASSERT128(I128(0, 1), x); } void testSar128(void) { __int128 x; x = I128(0, 0); x >>= 0; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 1; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 0; ASSERT128(I128(0, 2), x); x = I128(0, 2); x >>= 1; ASSERT128(I128(0, 1), x); x = I128(0, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 0; ASSERT128(I128(0, BANE), x); x = I128(0, BANE); x >>= 1; ASSERT128(I128(0, 0x4000000000000000), x); x = I128(0, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 0; ASSERT128(I128(0, -1ul), x); x = I128(0, -1ul); x >>= 1; ASSERT128(I128(0, IMAX), x); x = I128(0, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 0; ASSERT128(I128(2, 0), x); x = I128(2, 0); x >>= 1; ASSERT128(I128(1, 0), x); x = I128(2, 0); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 0); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 0; ASSERT128(I128(2, 2), x); x = I128(2, 2); x >>= 1; ASSERT128(I128(1, 1), x); x = I128(2, 2); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, 2); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 0; ASSERT128(I128(2, BANE), x); x = I128(2, BANE); x >>= 1; ASSERT128(I128(1, 0x4000000000000000), x); x = I128(2, BANE); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 0; ASSERT128(I128(2, -1ul), x); x = I128(2, -1ul); x >>= 1; ASSERT128(I128(1, IMAX), x); x = I128(2, -1ul); x >>= 126; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x >>= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x >>= 0; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x >>= 1; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(BANE, 0); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, 0); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(BANE, 2); x >>= 0; ASSERT128(I128(BANE, 2), x); x = I128(BANE, 2); x >>= 1; ASSERT128(I128(0xc000000000000000, 1), x); x = I128(BANE, 2); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, 2); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(BANE, BANE); x >>= 0; ASSERT128(I128(BANE, BANE), x); x = I128(BANE, BANE); x >>= 1; ASSERT128(I128(0xc000000000000000, 0x4000000000000000), x); x = I128(BANE, BANE); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, BANE); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(BANE, -1ul); x >>= 0; ASSERT128(I128(BANE, -1ul), x); x = I128(BANE, -1ul); x >>= 1; ASSERT128(I128(0xc000000000000000, IMAX), x); x = I128(BANE, -1ul); x >>= 126; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(BANE, -1ul); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 0); x >>= 0; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, 0); x >>= 1; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, 0); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 0); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 2); x >>= 0; ASSERT128(I128(-1ul, 2), x); x = I128(-1ul, 2); x >>= 1; ASSERT128(I128(-1ul, BANE1), x); x = I128(-1ul, 2); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, 2); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, BANE); x >>= 0; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, BANE); x >>= 1; ASSERT128(I128(-1ul, 0xc000000000000000), x); x = I128(-1ul, BANE); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, BANE); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 0; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 1; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 126; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x >>= 127; ASSERT128(I128(-1ul, -1ul), x); } void testShl128(void) { __int128 x; x = I128(0, 0); x <<= 0; ASSERT128(I128(0, 0), x); x = I128(0, 0); x <<= 1; ASSERT128(I128(0, 0), x); x = I128(0, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(0, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(0, 2); x <<= 0; ASSERT128(I128(0, 2), x); x = I128(0, 2); x <<= 1; ASSERT128(I128(0, 4), x); x = I128(0, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(0, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x <<= 0; ASSERT128(I128(0, BANE), x); x = I128(0, BANE); x <<= 1; ASSERT128(I128(1, 0), x); x = I128(0, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(0, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(0, -1ul); x <<= 0; ASSERT128(I128(0, -1ul), x); x = I128(0, -1ul); x <<= 1; ASSERT128(I128(1, 0xfffffffffffffffe), x); x = I128(0, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(0, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); x = I128(2, 0); x <<= 0; ASSERT128(I128(2, 0), x); x = I128(2, 0); x <<= 1; ASSERT128(I128(4, 0), x); x = I128(2, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(2, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(2, 2); x <<= 0; ASSERT128(I128(2, 2), x); x = I128(2, 2); x <<= 1; ASSERT128(I128(4, 4), x); x = I128(2, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(2, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x <<= 0; ASSERT128(I128(2, BANE), x); x = I128(2, BANE); x <<= 1; ASSERT128(I128(5, 0), x); x = I128(2, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(2, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(2, -1ul); x <<= 0; ASSERT128(I128(2, -1ul), x); x = I128(2, -1ul); x <<= 1; ASSERT128(I128(5, 0xfffffffffffffffe), x); x = I128(2, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(2, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x <<= 0; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 0); x <<= 1; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(BANE, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, 2); x <<= 0; ASSERT128(I128(BANE, 2), x); x = I128(BANE, 2); x <<= 1; ASSERT128(I128(0, 4), x); x = I128(BANE, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(BANE, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, BANE); x <<= 0; ASSERT128(I128(BANE, BANE), x); x = I128(BANE, BANE); x <<= 1; ASSERT128(I128(1, 0), x); x = I128(BANE, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(BANE, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(BANE, -1ul); x <<= 0; ASSERT128(I128(BANE, -1ul), x); x = I128(BANE, -1ul); x <<= 1; ASSERT128(I128(1, 0xfffffffffffffffe), x); x = I128(BANE, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(BANE, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); x = I128(-1ul, 0); x <<= 0; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, 0); x <<= 1; ASSERT128(I128(0xfffffffffffffffe, 0), x); x = I128(-1ul, 0); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(-1ul, 0); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(-1ul, 2); x <<= 0; ASSERT128(I128(-1ul, 2), x); x = I128(-1ul, 2); x <<= 1; ASSERT128(I128(0xfffffffffffffffe, 4), x); x = I128(-1ul, 2); x <<= 126; ASSERT128(I128(BANE, 0), x); x = I128(-1ul, 2); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(-1ul, BANE); x <<= 0; ASSERT128(I128(-1ul, BANE), x); x = I128(-1ul, BANE); x <<= 1; ASSERT128(I128(-1ul, 0), x); x = I128(-1ul, BANE); x <<= 126; ASSERT128(I128(0, 0), x); x = I128(-1ul, BANE); x <<= 127; ASSERT128(I128(0, 0), x); x = I128(-1ul, -1ul); x <<= 0; ASSERT128(I128(-1ul, -1ul), x); x = I128(-1ul, -1ul); x <<= 1; ASSERT128(I128(-1ul, 0xfffffffffffffffe), x); x = I128(-1ul, -1ul); x <<= 126; ASSERT128(I128(0xc000000000000000, 0), x); x = I128(-1ul, -1ul); x <<= 127; ASSERT128(I128(BANE, 0), x); } void testNeg128(void) { __int128 x; x = I128(0, 0); ASSERT128(I128(0, 0), -x); x = I128(0, 2); ASSERT128(I128(-1ul, 0xfffffffffffffffe), -x); x = I128(0, BANE); ASSERT128(I128(-1ul, BANE), -x); x = I128(0, -1ul); ASSERT128(I128(-1ul, 1), -x); x = I128(2, 0); ASSERT128(I128(0xfffffffffffffffe, 0), -x); x = I128(2, 2); ASSERT128(I128(IMAX2, 0xfffffffffffffffe), -x); x = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), -x); x = I128(2, -1ul); ASSERT128(I128(IMAX2, 1), -x); x = I128(BANE, 0); ASSERT128(I128(BANE, 0), -x); x = I128(BANE, 2); ASSERT128(I128(IMAX, 0xfffffffffffffffe), -x); x = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), -x); x = I128(BANE, -1ul); ASSERT128(I128(IMAX, 1), -x); x = I128(-1ul, 0); ASSERT128(I128(1, 0), -x); x = I128(-1ul, 2); ASSERT128(I128(0, 0xfffffffffffffffe), -x); x = I128(-1ul, BANE); ASSERT128(I128(0, BANE), -x); x = I128(-1ul, -1ul); ASSERT128(I128(0, 1), -x); } void testXor128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x ^ y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x ^ y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x ^ y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x ^ y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x ^ y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x ^ y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x ^ y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x ^ y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x ^ y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x ^ y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x ^ y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(2, 0), x ^ y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x ^ y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x ^ y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x ^ y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x ^ y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x ^ y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(2, 0), x ^ y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(2, IMAX), x ^ y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x ^ y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x ^ y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, 0), x ^ y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x ^ y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(2, IMAX), x ^ y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, 0), x ^ y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x ^ y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x ^ y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x ^ y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(2, 2), x ^ y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(2, BANE), x ^ y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x ^ y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x ^ y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 0), x ^ y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(2, BANE2), x ^ y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(0, 2), x ^ y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, BANE2), x ^ y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(2, 0), x ^ y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(2, IMAX), x ^ y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(0, BANE), x ^ y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(2, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(2, 0), x ^ y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(0, -1ul), x ^ y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, 0), x ^ y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(BANE, 2), x ^ y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x ^ y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x ^ y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 0), x ^ y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(BANE2, 2), x ^ y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(0, 2), x ^ y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE, 0), x ^ y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(BANE2, BANE), x ^ y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(BANE2, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(0, BANE), x ^ y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE, 0), x ^ y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(BANE2, -1ul), x ^ y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(BANE2, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(BANE2, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(BANE2, 0), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, -1ul), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(IMAX, -1ul), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x ^ y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x ^ y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x ^ y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, -1ul), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x ^ y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, -1ul), x ^ y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(IMAX2, 2), x ^ y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(IMAX, 2), x ^ y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 2), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE2), x ^ y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(IMAX2, BANE), x ^ y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(IMAX2, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(IMAX, BANE), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(IMAX, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, BANE), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, BANE2), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x ^ y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, 0), x ^ y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(IMAX2, -1ul), x ^ y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(IMAX2, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(IMAX2, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(IMAX2, 0), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, -1ul), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), x ^ y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x ^ y); } void testAnd128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(0, 0), x & y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(0, 0), x & y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(0, 0), x & y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(0, 2), x & y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x & y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(0, 0), x & y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(2, 0), x & y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(2, 2), x & y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x & y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(0, 0), x & y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(2, 0), x & y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(2, BANE), x & y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x & y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(0, 0), x & y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(0, 2), x & y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(2, 0), x & y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(2, 2), x & y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(2, -1ul), x & y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(0, 0), x & y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(0, 0), x & y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(0, 0), x & y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(0, 2), x & y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x & y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(BANE, -1ul), x & y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(0, 2), x & y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(2, 2), x & y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, 2), x & y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x & y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, 2), x & y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(0, 0), x & y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(0, BANE), x & y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(2, BANE), x & y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, BANE), x & y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x & y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, BANE), x & y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(0, 2), x & y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(0, BANE), x & y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x & y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(2, 0), x & y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(2, 2), x & y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(2, BANE), x & y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x & y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x & y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x & y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x & y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x & y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x & y); } void testOr128(void) { __int128 x, y; x = I128(0, 0); y = I128(0, 2); ASSERT128(I128(0, 2), x | y); x = I128(0, 0); y = I128(0, BANE); ASSERT128(I128(0, BANE), x | y); x = I128(0, 0); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x | y); x = I128(0, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(0, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(0, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x | y); x = I128(0, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(0, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(0, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(0, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(0, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(0, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, 2); y = I128(0, 2); ASSERT128(I128(0, 2), x | y); x = I128(0, 2); y = I128(0, BANE); ASSERT128(I128(0, BANE2), x | y); x = I128(0, 2); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x | y); x = I128(0, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(0, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x | y); x = I128(0, 2); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x | y); x = I128(0, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(0, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x | y); x = I128(0, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(0, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(0, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(0, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, BANE); y = I128(0, 2); ASSERT128(I128(0, BANE2), x | y); x = I128(0, BANE); y = I128(0, BANE); ASSERT128(I128(0, BANE), x | y); x = I128(0, BANE); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x | y); x = I128(0, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x | y); x = I128(0, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(0, BANE); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x | y); x = I128(0, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x | y); x = I128(0, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(0, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(0, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(0, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(0, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(0, 2); ASSERT128(I128(0, -1ul), x | y); x = I128(0, -1ul); y = I128(0, BANE); ASSERT128(I128(0, -1ul), x | y); x = I128(0, -1ul); y = I128(0, -1ul); ASSERT128(I128(0, -1ul), x | y); x = I128(0, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(2, 2); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(2, BANE); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(0, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, 0); y = I128(0, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 0); y = I128(0, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, 0); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 0); y = I128(2, 0); ASSERT128(I128(2, 0), x | y); x = I128(2, 0); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 0); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, 0); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 0); y = I128(BANE, 0); ASSERT128(I128(BANE2, 0), x | y); x = I128(2, 0); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(2, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(2, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(2, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(2, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(2, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, 2); y = I128(0, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 2); y = I128(0, BANE); ASSERT128(I128(2, BANE2), x | y); x = I128(2, 2); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 2); y = I128(2, 0); ASSERT128(I128(2, 2), x | y); x = I128(2, 2); y = I128(2, 2); ASSERT128(I128(2, 2), x | y); x = I128(2, 2); y = I128(2, BANE); ASSERT128(I128(2, BANE2), x | y); x = I128(2, 2); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, 2); y = I128(BANE, 0); ASSERT128(I128(BANE2, 2), x | y); x = I128(2, 2); y = I128(BANE, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(2, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(2, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(2, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(2, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(2, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, BANE); y = I128(0, 2); ASSERT128(I128(2, BANE2), x | y); x = I128(2, BANE); y = I128(0, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, BANE); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, BANE); y = I128(2, 0); ASSERT128(I128(2, BANE), x | y); x = I128(2, BANE); y = I128(2, 2); ASSERT128(I128(2, BANE2), x | y); x = I128(2, BANE); y = I128(2, BANE); ASSERT128(I128(2, BANE), x | y); x = I128(2, BANE); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE2, BANE), x | y); x = I128(2, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(2, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(2, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(2, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(2, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(2, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(0, 2); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(0, BANE); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(0, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, 0); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, 2); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, BANE); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(2, -1ul); ASSERT128(I128(2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(2, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, 0); y = I128(0, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 0); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, 0); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 0); y = I128(2, 0); ASSERT128(I128(BANE2, 0), x | y); x = I128(BANE, 0); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(BANE, 0); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(BANE, 0); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, 0); y = I128(BANE, 0); ASSERT128(I128(BANE, 0), x | y); x = I128(BANE, 0); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 0); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, 0); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(BANE, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(BANE, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(BANE, 2); y = I128(0, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 2); y = I128(0, BANE); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, 2); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 2); y = I128(2, 0); ASSERT128(I128(BANE2, 2), x | y); x = I128(BANE, 2); y = I128(2, 2); ASSERT128(I128(BANE2, 2), x | y); x = I128(BANE, 2); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(BANE, 2); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, 2); y = I128(BANE, 0); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 2); y = I128(BANE, 2); ASSERT128(I128(BANE, 2), x | y); x = I128(BANE, 2); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, 2); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(BANE, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(BANE, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(BANE, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, BANE); y = I128(0, 2); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, BANE); y = I128(0, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, BANE); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, BANE); y = I128(2, 0); ASSERT128(I128(BANE2, BANE), x | y); x = I128(BANE, BANE); y = I128(2, 2); ASSERT128(I128(BANE2, BANE2), x | y); x = I128(BANE, BANE); y = I128(2, BANE); ASSERT128(I128(BANE2, BANE), x | y); x = I128(BANE, BANE); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, BANE); y = I128(BANE, 0); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, BANE); y = I128(BANE, 2); ASSERT128(I128(BANE, BANE2), x | y); x = I128(BANE, BANE); y = I128(BANE, BANE); ASSERT128(I128(BANE, BANE), x | y); x = I128(BANE, BANE); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(BANE, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(BANE, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(BANE, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(0, 2); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(0, BANE); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(0, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, 0); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, 2); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, BANE); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(2, -1ul); ASSERT128(I128(BANE2, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, 0); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, 2); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, BANE); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(BANE, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(BANE, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(2, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(-1ul, 0); y = I128(2, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(BANE, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(-1ul, 0); y = I128(BANE, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 0); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 0), x | y); x = I128(-1ul, 0); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 0); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, 0); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(0, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(2, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(2, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(BANE, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(BANE, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, 2); y = I128(-1ul, 0); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(-1ul, 2); ASSERT128(I128(-1ul, 2), x | y); x = I128(-1ul, 2); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, 2); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(0, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(0, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(2, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(2, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(2, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(BANE, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(BANE, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(BANE, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, BANE); y = I128(-1ul, 0); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(-1ul, 2); ASSERT128(I128(-1ul, BANE2), x | y); x = I128(-1ul, BANE); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, BANE), x | y); x = I128(-1ul, BANE); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(0, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(0, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(0, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(2, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(BANE, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, 0); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, 2); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, BANE); ASSERT128(I128(-1ul, -1ul), x | y); x = I128(-1ul, -1ul); y = I128(-1ul, -1ul); ASSERT128(I128(-1ul, -1ul), x | y); } void testNot128(void) { __int128 x; x = I128(0, 0); ASSERT128(I128(-1ul, -1ul), ~x); x = I128(0, 2); ASSERT128(I128(-1ul, IMAX2), ~x); x = I128(0, BANE); ASSERT128(I128(-1ul, IMAX), ~x); x = I128(0, -1ul); ASSERT128(I128(-1ul, 0), ~x); x = I128(2, 0); ASSERT128(I128(IMAX2, -1ul), ~x); x = I128(2, 2); ASSERT128(I128(IMAX2, IMAX2), ~x); x = I128(2, BANE); ASSERT128(I128(IMAX2, IMAX), ~x); x = I128(2, -1ul); ASSERT128(I128(IMAX2, 0), ~x); x = I128(BANE, 0); ASSERT128(I128(IMAX, -1ul), ~x); x = I128(BANE, 2); ASSERT128(I128(IMAX, IMAX2), ~x); x = I128(BANE, BANE); ASSERT128(I128(IMAX, IMAX), ~x); x = I128(BANE, -1ul); ASSERT128(I128(IMAX, 0), ~x); x = I128(-1ul, 0); ASSERT128(I128(0, -1ul), ~x); x = I128(-1ul, 2); ASSERT128(I128(0, IMAX2), ~x); x = I128(-1ul, BANE); ASSERT128(I128(0, IMAX), ~x); x = I128(-1ul, -1ul); ASSERT128(I128(0, 0), ~x); } // Helper macro to append a 128-bit value to a string in minimal hex #define PRINT_I128(buf, v) do { \ unsigned long long hi = (unsigned long long)((v) >> 64); \ unsigned long long lo = (unsigned long long)(v); \ char tmp[32]; \ sprintf(tmp, "%llx%llx", hi, lo); \ strcat(buf, tmp); \ } while(0) void testAbi(void) { ASSERT(11, ({ char buf[200]; sprintf(buf, "%d %d %d %d %032jjx %032jjx", 1, 2, 3, 4, I128(0x1ffffffff, 0x2ffffffff), I128(0x3eeeeeeee, 0x4eeeeeeee)); strcmp("1 2 3 4 00000001ffffffff00000002ffffffff " "00000003eeeeeeee00000004eeeeeeee", buf); })); ASSERT(11, ({ char buf[200]; sprintf(buf, "%d %d %d %d %d %032jjx %032jjx", 1, 2, 3, 4, 5, I128(0x1ffffffff, 0x2ffffffff), I128(0x3eeeeeeee, 0x4eeeeeeee)); strcmp("1 2 3 4 5 00000001ffffffff00000002ffffffff " "00000003eeeeeeee00000004eeeeeeee", buf); })); } int main(void) { testLang128(); testCompare128(); testAdd128(); testSub128(); testMul128(); testDiv128(); testDivu128(); testRem128(); testRemu128(); testShr128(); testSar128(); testShl128(); testNeg128(); testXor128(); testAnd128(); testOr128(); testNot128(); testCastDblInt128(); testCastDblUint128(); testCastLdblInt128(); testCastLdblUint128(); testAbi(); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/int128_test.c000066400000000000000000000007011505335450300165300ustar00rootroot00000000000000#include "test.h" int main() { __int128 a = 8 ; __int128 b = 7; __int128 c = a + b ; printf("c=%d\n", c); ASSERT(15, c); c = c + 17 + a + b + (7 * 8); printf("c=%d\n", c); ASSERT(103, c); c = a - b; ASSERT(1, c); c = a * b; ASSERT(56, c); c = c / 2; ASSERT(28, c); c = c % 2; ASSERT(0, c); c++; ASSERT(1, c); c--; ASSERT(0, c); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/ipcs.c000066400000000000000000000016501505335450300154060ustar00rootroot00000000000000#include #include #include #include "test.h" int main() { int id = semget(IPC_PRIVATE, 1, IPC_CREAT | 0666); if (id < 0) { perror("semget failed"); return 1; } struct semid_ds buf; int ret = semctl(id, 0, IPC_STAT, &buf); if (ret < 0) { perror("semctl IPC_STAT failed"); } else { printf("semctl IPC_STAT succeeded\n"); } semctl(id, 0, IPC_RMID); printf("sizeof(msginfo) = %zu\n", sizeof(struct msginfo)); ASSERT(32, sizeof(struct msginfo)); printf("msgmax offset = %zu\n", offsetof(struct msginfo, msgmax)); ASSERT(8, offsetof(struct msginfo, msgmax) ); printf("msgmnb offset = %zu\n", offsetof(struct msginfo, msgmnb)); ASSERT(12, offsetof(struct msginfo, msgmnb)); printf("msgtql offset = %zu\n", offsetof(struct msginfo, msgtql)); ASSERT(24, offsetof(struct msginfo, msgtql)); return 0; } chibicc-1.0.23.1/test/issue105.c000077500000000000000000000001441505335450300160260ustar00rootroot00000000000000#define __WCHAR_TYPE__ unsigned char; typedef __WCHAR_TYPE__ wchar_t; int main() { return 0; }chibicc-1.0.23.1/test/issue106.c000077500000000000000000000352141505335450300160350ustar00rootroot00000000000000#include #include # define VLC_EXPORT __attribute__((visibility("default"))) # define VLC_USED __attribute__((warn_unused_result)) #define VLC_STATIC_ONCE { ATOMIC_VAR_INIT(0) } # define VLC_EXTERN typedef int64_t vlc_tick_t; typedef struct date_t date_t; struct date_t { vlc_tick_t date; uint32_t i_divider_num; uint32_t i_divider_den; uint32_t i_remainder; }; #define VLC_API VLC_EXTERN VLC_EXPORT typedef struct { long long quot; /* Quotient. */ long long rem; /* Remainder. */ } lldiv_t; lldiv_t lldiv (long long num, long long denom) { lldiv_t d = { num / denom, num % denom, }; return d; } /***************************************************************************** * vlc_config.h: limits and configuration * Defines all compilation-time configuration constants and size limits ***************************************************************************** * Copyright (C) 1999-2003 VLC authors and VideoLAN * * Authors: Vincent Seguin * Samuel Hocevar * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /** * \file * This file defines of values used in interface, vout, aout and vlc core functions. */ /* Conventions regarding names of symbols and variables * ---------------------------------------------------- * * - Symbols should begin with a prefix indicating in which module they are * used, such as INTF_, VOUT_ or AOUT_. */ /***************************************************************************** * General configuration *****************************************************************************/ /* All timestamp below or equal to this define are invalid/unset * XXX the numerical value is 0 because of historical reason and will change.*/ #define VLC_TICK_INVALID INT64_C(0) #define VLC_TICK_0 INT64_C(1) #define CLOCK_FREQ INT64_C(1000000) /***************************************************************************** * Interface configuration *****************************************************************************/ /* Base delay in micro second for interface sleeps */ #define INTF_IDLE_SLEEP VLC_TICK_FROM_MS(50) /***************************************************************************** * Input thread configuration *****************************************************************************/ /* Used in ErrorThread */ #define INPUT_IDLE_SLEEP VLC_TICK_FROM_MS(100) /* * General limitations */ /* Duration between the time we receive the data packet, and the time we will * mark it to be presented */ #define DEFAULT_PTS_DELAY VLC_TICK_FROM_MS(300) /***************************************************************************** * Video configuration *****************************************************************************/ /* * Default settings for video output threads */ /* Multiplier value for aspect ratio calculation (2^7 * 3^3 * 5^3) */ #define VOUT_ASPECT_FACTOR 432000 /* Maximum width of a scaled source picture - this should be relatively high, * since higher stream values will result in no display at all. */ #define VOUT_MAX_WIDTH 4096 /* Number of planes in a picture */ #define VOUT_MAX_PLANES 5 /* * Time settings */ /* Time to sleep when waiting for a buffer (from vout or the video fifo). * It should be approximately the time needed to perform a complete picture * loop. Since it only happens when the video heap is full, it does not need * to be too low, even if it blocks the decoder. */ #define VOUT_OUTMEM_SLEEP VLC_TICK_FROM_MS(20) /* The default video output window title */ #define VOUT_TITLE "VLC" /***************************************************************************** * vlc_tick.h: high resolution time management functions ***************************************************************************** * This header provides portable high precision time management functions, * which should be the only ones used in other segments of the program, since * functions like gettimeofday() and ftime() are not always supported. * Most functions are declared as inline or as macros since they are only * interfaces to system calls and have to be called frequently. ***************************************************************************** * Copyright (C) 1996, 1997, 1998, 1999, 2000 VLC authors and VideoLAN * * Authors: Vincent Seguin * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef __VLC_MTIME_H # define __VLC_MTIME_H 1 struct timespec; /** * High precision date or time interval * * Store a high precision date or time interval. The maximum precision is the * microsecond, and a 64 bits integer is used to avoid overflows (maximum * time interval is then 292271 years, which should be long enough for any * video). Dates are stored as microseconds since a common date (usually the * epoch). Note that date and time intervals can be manipulated using regular * arithmetic operators, and that no special functions are required. */ typedef int64_t vlc_tick_t; #define VLC_TICK_MIN INT64_MIN #define VLC_TICK_MAX INT64_MAX /* * vlc_tick_t <> seconds (sec) conversions */ #define VLC_TICK_FROM_SEC(sec) (CLOCK_FREQ * (sec)) #define SEC_FROM_VLC_TICK(vtk) ((vtk) / CLOCK_FREQ) #ifdef __cplusplus #include template static inline auto vlc_tick_from_sec(T sec) -> typename std::enable_if::value, vlc_tick_t>::type { return CLOCK_FREQ * sec; } /* seconds in floating point */ static inline vlc_tick_t vlc_tick_from_sec(double secf) { return (vlc_tick_t)(CLOCK_FREQ * secf); /* TODO use llround ? */ } #else /* !__cplusplus */ static inline vlc_tick_t vlc_tick_from_seci(int64_t sec) { return CLOCK_FREQ * sec; } /* seconds in floating point */ static inline vlc_tick_t vlc_tick_from_secf(double secf) { return (vlc_tick_t)(CLOCK_FREQ * secf); /* TODO use llround ? */ } #define vlc_tick_from_sec(sec) _Generic((sec), \ double: vlc_tick_from_secf(sec), \ float: vlc_tick_from_secf(sec), \ default: vlc_tick_from_seci(sec) ) #endif /* !__cplusplus */ /* seconds in floating point from vlc_tick_t */ static inline double secf_from_vlc_tick(vlc_tick_t vtk) { return (double)vtk / (double)CLOCK_FREQ; } static inline vlc_tick_t vlc_tick_rate_duration(float frame_rate) { return CLOCK_FREQ / frame_rate; } /* * samples<>vlc_tick_t */ static inline vlc_tick_t vlc_tick_from_samples(int64_t samples, int samp_rate) { return CLOCK_FREQ * samples / samp_rate; } static inline int64_t samples_from_vlc_tick(vlc_tick_t t, int samp_rate) { return t * samp_rate / CLOCK_FREQ; } static inline vlc_tick_t vlc_tick_from_frac(uint64_t num, uint64_t den) { lldiv_t d = lldiv (num, den); return vlc_tick_from_sec( d.quot ) + vlc_tick_from_samples(d.rem, den); } /* * vlc_tick_t <> milliseconds (ms) conversions */ #if (CLOCK_FREQ % 1000) == 0 #define VLC_TICK_FROM_MS(ms) ((CLOCK_FREQ / INT64_C(1000)) * (ms)) #define MS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000))) #elif (1000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_MS(ms) ((ms) / (INT64_C(1000) / CLOCK_FREQ)) #define MS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_MS(ms) (CLOCK_FREQ * (ms) / 1000) #define MS_FROM_VLC_TICK(vtk) ((vtk) * 1000 / CLOCK_FREQ) #endif /* CLOCK_FREQ / 1000 */ /* * vlc_tick_t <> microseconds (us) conversions */ #if (CLOCK_FREQ % 1000000) == 0 #define VLC_TICK_FROM_US(us) ((CLOCK_FREQ / INT64_C(1000000)) * (us)) #define US_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000000))) #elif (1000000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_US(us) ((us) / (INT64_C(1000000) / CLOCK_FREQ)) #define US_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_US(us) (CLOCK_FREQ * (us) / INT64_C(1000000)) #define US_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(1000000) / CLOCK_FREQ) #endif /* CLOCK_FREQ / 1000000 */ /* * vlc_tick_t <> nanoseconds (ns) conversions */ #if (CLOCK_FREQ % 1000000000) == 0 #define VLC_TICK_FROM_NS(ns) ((ns) * (CLOCK_FREQ / (INT64_C(1000000000)))) #define NS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / (INT64_C(1000000000)))) #elif (1000000000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_NS(ns) ((ns) / (INT64_C(1000000000) / CLOCK_FREQ)) #define NS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000000000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_NS(ns) (CLOCK_FREQ * (ns) / INT64_C(1000000000)) #define NS_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(1000000000) / CLOCK_FREQ) #endif /* CLOCK_FREQ / 1000000000 */ /* * msftime_t is a time with 100ns resolutions, typically used by Microsoft */ typedef int64_t msftime_t; #define MSFTIME_FROM_SEC(sec) (INT64_C(10000000) * (sec)) /* seconds in msftime_t */ #define MSFTIME_FROM_MS(sec) (INT64_C(10000) * (sec)) /* milliseconds in msftime_t */ #if (CLOCK_FREQ % 10000000) == 0 #define VLC_TICK_FROM_MSFTIME(msft) ((msft) * (CLOCK_FREQ / INT64_C(10000000)) #define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(10000000)) #elif (10000000 % CLOCK_FREQ) == 0 #define VLC_TICK_FROM_MSFTIME(msft) ((msft) / (INT64_C(10000000) / CLOCK_FREQ)) #define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(10000000) / CLOCK_FREQ)) #else /* rounded overflowing conversion */ #define VLC_TICK_FROM_MSFTIME(msft) (CLOCK_FREQ * (msft) / INT64_C(10000000)) #define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(10000000) / CLOCK_FREQ) #endif /* CLOCK_FREQ / 10000000 */ #define vlc_tick_from_timeval(tv) \ (vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_US( (tv)->tv_usec )) #define vlc_tick_from_timespec(tv) \ (vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_NS( (tv)->tv_nsec )) /** * Converts a VLC tick to a POSIX time specification. * * \param ts [out] storage space for the time specification * \param tick VLC tick * \return @c ts */ VLC_API struct timespec *vlc_tick_to_timespec(struct timespec *restrict ts, vlc_tick_t tick); /***************************************************************************** * MSTRTIME_MAX_SIZE: maximum possible size of vlc_tick_to_str ***************************************************************************** * This values is the maximal possible size of the string returned by the * vlc_tick_to_str() function, including '-' and the final '\0'. It should be * used to allocate the buffer. *****************************************************************************/ #define MSTRTIME_MAX_SIZE 22 /***************************************************************************** * Prototypes *****************************************************************************/ /** * Convert seconds to a time in the format h:mm:ss. * * This function is provided for any interface function which need to print a * time string in the format h:mm:ss * date. * \param ticks the time to be converted * \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters * \return psz_buffer is returned so this can be used as printf parameter. */ VLC_API char * vlc_tick_to_str( char *psz_buffer, vlc_tick_t ticks ); /** * \defgroup date Timestamps, error-free * These functions support generating timestamps without long term rounding * errors due to sample rate conversions. * \ingroup input * @{ */ /** * Timestamps without long-term rounding errors */ /** * Initializes a date_t. * * \param date date to initialize [OUT] * \param num divider (sample rate) numerator * \param den divider (sample rate) denominator */ VLC_API void date_Init(date_t *restrict date, uint32_t num, uint32_t den); /** * Changes the rate of a date_t. * * \param date date to change * \param num divider (sample rate) numerator * \param den divider (sample rate) denominator */ VLC_API void date_Change(date_t *restrict date, uint32_t num, uint32_t den); /** * Sets the exact timestamp of a date_t. * * \param date date to set the timestamp into * \param value date value */ static inline void date_Set(date_t *restrict date, vlc_tick_t value) { date->date = value; date->i_remainder = 0; } /** * Gets the current timestamp from a date_t. * * \param date date to fetch the timestamp from * \return date value */ VLC_USED static inline vlc_tick_t date_Get(const date_t *restrict date) { return date->date; } /** * Increments a date. * * Moves the date_t timestamp forward by a given number of samples. * * \param date date to move forward * \param count number of samples * \return timestamp value after incrementing */ VLC_API vlc_tick_t date_Increment(date_t *restrict date, uint32_t count); /** * Decrements a date. * * Moves the date_t timestamp backward by a given number of samples. * * \param date date to move backward * \param count number of samples * \return date value */ VLC_API vlc_tick_t date_Decrement(date_t *restrict date, uint32_t count); /** @} */ /** * @return NTP 64-bits timestamp in host byte order. */ VLC_API uint64_t NTPtime64( void ); #endif /* !__VLC_MTIME_ */ int main(void) { return 0; }chibicc-1.0.23.1/test/issue107.c000077500000000000000000000032411505335450300160310ustar00rootroot00000000000000 #include "test.h" #define gettext_noop(str) (str) #define N_(str) gettext_noop (str) static const char vlc_usage[] = N_( "Usage: %s [options] [stream] ...\n" "You can specify multiple streams on the commandline.\n" "They will be enqueued in the playlist.\n" "The first item specified will be played first.\n" "\n" "Options-styles:\n" " --option A global option that is set for the duration of the program.\n" " -option A single letter version of a global --option.\n" " :option An option that only applies to the stream directly before it\n" " and that overrides previous settings.\n" "\n" "Stream MRL syntax:\n" " [[access][/demux]://]URL[#[title][:chapter][-[title][:chapter]]]\n" " [:option=value ...]\n" "\n" " Many of the global --options can also be used as MRL specific :options.\n" " Multiple :option=value pairs can be specified.\n" "\n" "URL syntax:\n" " file:///path/file Plain media file\n" " http://host[:port]/file HTTP URL\n" " ftp://host[:port]/file FTP URL\n" " mms://host[:port]/file MMS URL\n" " screen:// Screen capture\n" " dvd://[device] DVD device\n" " vcd://[device] VCD device\n" " cdda://[device] Audio CD device\n" " udp://[[]@[][:]]\n" " UDP stream sent by a streaming server\n" " vlc://pause: Pause the playlist for a certain time\n" " vlc://quit Special item to quit VLC\n" "\n"); int main(void) { printf("%s", vlc_usage); return 0; }chibicc-1.0.23.1/test/issue108.c000077500000000000000000000004601505335450300160320ustar00rootroot00000000000000#include "test.h" #define VLC_USED __attribute__((warn_unused_result)) #ifndef VLC_CHARSET_H #define VLC_CHARSET_H 1 int vlc_sscanf_c(const char*, const char*, ...) VLC_USED #ifdef __GNUC__ __attribute__((format(scanf, 2, 3))) #endif ; /** @} */ /** @} */ #endif int main(void) { return 0; }chibicc-1.0.23.1/test/issue109.c000077500000000000000000000001241505335450300160300ustar00rootroot00000000000000 #warning "input_clock_SetJitter needs more work" int main(void) { return 0; }chibicc-1.0.23.1/test/issue110.c000077500000000000000000000075401505335450300160310ustar00rootroot00000000000000 #include #include #include #include #warning "input_clock_SetJitter needs more work" enum input_control_e { INPUT_CONTROL_SET_STATE, INPUT_CONTROL_SET_RATE, INPUT_CONTROL_SET_POSITION, INPUT_CONTROL_JUMP_POSITION, INPUT_CONTROL_SET_TIME, INPUT_CONTROL_JUMP_TIME, INPUT_CONTROL_SET_PROGRAM, INPUT_CONTROL_SET_TITLE, INPUT_CONTROL_SET_TITLE_NEXT, INPUT_CONTROL_SET_TITLE_PREV, INPUT_CONTROL_SET_SEEKPOINT, INPUT_CONTROL_SET_SEEKPOINT_NEXT, INPUT_CONTROL_SET_SEEKPOINT_PREV, INPUT_CONTROL_SET_BOOKMARK, INPUT_CONTROL_NAV_ACTIVATE, // NOTE: INPUT_CONTROL_NAV_* values must be INPUT_CONTROL_NAV_UP, // contiguous and in the same order as INPUT_CONTROL_NAV_DOWN, // INPUT_NAV_* and DEMUX_NAV_*. INPUT_CONTROL_NAV_LEFT, INPUT_CONTROL_NAV_RIGHT, INPUT_CONTROL_NAV_POPUP, INPUT_CONTROL_NAV_MENU, INPUT_CONTROL_SET_ES, INPUT_CONTROL_SET_ES_LIST, // select a list of ES atomically INPUT_CONTROL_UNSET_ES, INPUT_CONTROL_RESTART_ES, INPUT_CONTROL_SET_ES_CAT_IDS, INPUT_CONTROL_SET_VIEWPOINT, // new absolute viewpoint INPUT_CONTROL_SET_INITIAL_VIEWPOINT, // set initial viewpoint (generally from video) INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current INPUT_CONTROL_SET_CATEGORY_DELAY, INPUT_CONTROL_SET_ES_DELAY, INPUT_CONTROL_ADD_SLAVE, INPUT_CONTROL_SET_SUBS_FPS, INPUT_CONTROL_SET_RECORD_STATE, INPUT_CONTROL_SET_FRAME_NEXT, INPUT_CONTROL_SET_RENDERER, INPUT_CONTROL_SET_VBI_PAGE, INPUT_CONTROL_SET_VBI_TRANSPARENCY, }; typedef struct input_item_node_t input_item_node_t; struct input_item_node_t { char * p_item; int i_children; input_item_node_t **pp_children; }; struct vlc_object_t { struct vlc_logger *logger; union { struct vlc_object_internals *priv; struct vlc_object_marker *obj; }; bool no_interact; /** Module probe flag * * A boolean during module probing when the probe is "forced". * See \ref module_need(). */ bool force; }; typedef struct stream_t stream_t; struct stream_t { struct vlc_object_t obj; char *psz_name; char *psz_url; /**< Full URL or MRL (can be NULL) */ const char *psz_location; /**< Location (URL with the scheme stripped) */ char *psz_filepath; /**< Local file path (if applicable) */ bool b_preparsing; /**< True if this access is used to preparse */ char *p_input_item;/**< Input item (can be NULL) */ stream_t *s; char *out; /* our p_es_out */ ssize_t (*pf_read)(stream_t *, void *buf, size_t len); char *(*pf_block)(stream_t *, bool *eof); int (*pf_readdir)(stream_t *, input_item_node_t *); int (*pf_demux)(stream_t *); int (*pf_seek)(stream_t *, uint64_t); int (*pf_control)(stream_t *, int i_query, va_list); void *p_sys; }; typedef union { char * val; char * viewpoint; char *id; struct { int cat; char **ids; } list; struct { bool b_fast_seek; int i_val; } time; struct { bool b_fast_seek; double f_val; } pos; struct { int cat; int delay; } cat_delay; struct { int cat; char *str_ids; } cat_ids; struct { char *id; int delay; } es_delay; struct { char *id; unsigned page; } vbi_page; struct { char *id; bool enabled; } vbi_transparency; struct { bool enabled; char *dir_path; } record_state; } input_control_param_t; int main(void) { char * p_input; input_control_param_t it = { .id = p_input, .time.i_val = 1}; return 0; }chibicc-1.0.23.1/test/issue111.c000077500000000000000000000074621505335450300160350ustar00rootroot00000000000000 #include #include #include #include enum input_control_e { INPUT_CONTROL_SET_STATE, INPUT_CONTROL_SET_RATE, INPUT_CONTROL_SET_POSITION, INPUT_CONTROL_JUMP_POSITION, INPUT_CONTROL_SET_TIME, INPUT_CONTROL_JUMP_TIME, INPUT_CONTROL_SET_PROGRAM, INPUT_CONTROL_SET_TITLE, INPUT_CONTROL_SET_TITLE_NEXT, INPUT_CONTROL_SET_TITLE_PREV, INPUT_CONTROL_SET_SEEKPOINT, INPUT_CONTROL_SET_SEEKPOINT_NEXT, INPUT_CONTROL_SET_SEEKPOINT_PREV, INPUT_CONTROL_SET_BOOKMARK, INPUT_CONTROL_NAV_ACTIVATE, // NOTE: INPUT_CONTROL_NAV_* values must be INPUT_CONTROL_NAV_UP, // contiguous and in the same order as INPUT_CONTROL_NAV_DOWN, // INPUT_NAV_* and DEMUX_NAV_*. INPUT_CONTROL_NAV_LEFT, INPUT_CONTROL_NAV_RIGHT, INPUT_CONTROL_NAV_POPUP, INPUT_CONTROL_NAV_MENU, INPUT_CONTROL_SET_ES, INPUT_CONTROL_SET_ES_LIST, // select a list of ES atomically INPUT_CONTROL_UNSET_ES, INPUT_CONTROL_RESTART_ES, INPUT_CONTROL_SET_ES_CAT_IDS, INPUT_CONTROL_SET_VIEWPOINT, // new absolute viewpoint INPUT_CONTROL_SET_INITIAL_VIEWPOINT, // set initial viewpoint (generally from video) INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current INPUT_CONTROL_SET_CATEGORY_DELAY, INPUT_CONTROL_SET_ES_DELAY, INPUT_CONTROL_ADD_SLAVE, INPUT_CONTROL_SET_SUBS_FPS, INPUT_CONTROL_SET_RECORD_STATE, INPUT_CONTROL_SET_FRAME_NEXT, INPUT_CONTROL_SET_RENDERER, INPUT_CONTROL_SET_VBI_PAGE, INPUT_CONTROL_SET_VBI_TRANSPARENCY, }; typedef struct input_item_node_t input_item_node_t; struct input_item_node_t { char * p_item; int i_children; input_item_node_t **pp_children; }; struct vlc_object_t { struct vlc_logger *logger; union { struct vlc_object_internals *priv; struct vlc_object_marker *obj; }; bool no_interact; /** Module probe flag * * A boolean during module probing when the probe is "forced". * See \ref module_need(). */ bool force; }; typedef struct stream_t stream_t; struct stream_t { struct vlc_object_t obj; char *psz_name; char *psz_url; /**< Full URL or MRL (can be NULL) */ const char *psz_location; /**< Location (URL with the scheme stripped) */ char *psz_filepath; /**< Local file path (if applicable) */ bool b_preparsing; /**< True if this access is used to preparse */ char *p_input_item;/**< Input item (can be NULL) */ stream_t *s; char *out; /* our p_es_out */ ssize_t (*pf_read)(stream_t *, void *buf, size_t len); char *(*pf_block)(stream_t *, bool *eof); int (*pf_readdir)(stream_t *, input_item_node_t *); int (*pf_demux)(stream_t *); int (*pf_seek)(stream_t *, uint64_t); int (*pf_control)(stream_t *, int i_query, va_list); void *p_sys; }; typedef union { char * val; char * viewpoint; char *id; struct { int cat; char **ids; } list; struct { bool b_fast_seek; int i_val; } time; struct { bool b_fast_seek; double f_val; } pos; struct { int cat; int delay; } cat_delay; struct { int cat; char *str_ids; } cat_ids; struct { char *id; int delay; } es_delay; struct { char *id; unsigned page; } vbi_page; struct { char *id; bool enabled; } vbi_transparency; struct { bool enabled; char *dir_path; } record_state; } input_control_param_t; int main(void) { char * p_input; input_control_param_t it = { .id = p_input, .time.i_val = 1,}; return 0; } chibicc-1.0.23.1/test/issue113.c000077500000000000000000000012671505335450300160340ustar00rootroot00000000000000 struct vlc_param { union { _Atomic int i; /**< Current value (if integer or boolean) */ _Atomic float f; /**< Current value (if floating point) */ char *_Atomic str; /**< Current value (if character string) */ } value; unsigned char shortname; /**< Optional short option name */ unsigned internal:1; /**< Hidden from preferences and help */ unsigned unsaved:1; /**< Not stored in persistent configuration */ unsigned safe:1; /**< Safe for untrusted provisioning (playlists) */ unsigned obsolete:1; /**< Ignored for backward compatibility */ }; int main(void) { struct vlc_param vlc1 = { .value.i = 1, .value.f = 1.0f}; return 0; }chibicc-1.0.23.1/test/issue114.c000077500000000000000000000074411505335450300160350ustar00rootroot00000000000000 #include #include #include #include enum input_control_e { INPUT_CONTROL_SET_STATE, INPUT_CONTROL_SET_RATE, INPUT_CONTROL_SET_POSITION, INPUT_CONTROL_JUMP_POSITION, INPUT_CONTROL_SET_TIME, INPUT_CONTROL_JUMP_TIME, INPUT_CONTROL_SET_PROGRAM, INPUT_CONTROL_SET_TITLE, INPUT_CONTROL_SET_TITLE_NEXT, INPUT_CONTROL_SET_TITLE_PREV, INPUT_CONTROL_SET_SEEKPOINT, INPUT_CONTROL_SET_SEEKPOINT_NEXT, INPUT_CONTROL_SET_SEEKPOINT_PREV, INPUT_CONTROL_SET_BOOKMARK, INPUT_CONTROL_NAV_ACTIVATE, // NOTE: INPUT_CONTROL_NAV_* values must be INPUT_CONTROL_NAV_UP, // contiguous and in the same order as INPUT_CONTROL_NAV_DOWN, // INPUT_NAV_* and DEMUX_NAV_*. INPUT_CONTROL_NAV_LEFT, INPUT_CONTROL_NAV_RIGHT, INPUT_CONTROL_NAV_POPUP, INPUT_CONTROL_NAV_MENU, INPUT_CONTROL_SET_ES, INPUT_CONTROL_SET_ES_LIST, // select a list of ES atomically INPUT_CONTROL_UNSET_ES, INPUT_CONTROL_RESTART_ES, INPUT_CONTROL_SET_ES_CAT_IDS, INPUT_CONTROL_SET_VIEWPOINT, // new absolute viewpoint INPUT_CONTROL_SET_INITIAL_VIEWPOINT, // set initial viewpoint (generally from video) INPUT_CONTROL_UPDATE_VIEWPOINT, // update viewpoint relative to current INPUT_CONTROL_SET_CATEGORY_DELAY, INPUT_CONTROL_SET_ES_DELAY, INPUT_CONTROL_ADD_SLAVE, INPUT_CONTROL_SET_SUBS_FPS, INPUT_CONTROL_SET_RECORD_STATE, INPUT_CONTROL_SET_FRAME_NEXT, INPUT_CONTROL_SET_RENDERER, INPUT_CONTROL_SET_VBI_PAGE, INPUT_CONTROL_SET_VBI_TRANSPARENCY, }; typedef struct input_item_node_t input_item_node_t; struct input_item_node_t { char * p_item; int i_children; input_item_node_t **pp_children; }; struct vlc_object_t { struct vlc_logger *logger; union { struct vlc_object_internals *priv; struct vlc_object_marker *obj; }; bool no_interact; /** Module probe flag * * A boolean during module probing when the probe is "forced". * See \ref module_need(). */ bool force; }; typedef struct stream_t stream_t; struct stream_t { struct vlc_object_t obj; char *psz_name; char *psz_url; /**< Full URL or MRL (can be NULL) */ const char *psz_location; /**< Location (URL with the scheme stripped) */ char *psz_filepath; /**< Local file path (if applicable) */ bool b_preparsing; /**< True if this access is used to preparse */ char *p_input_item;/**< Input item (can be NULL) */ stream_t *s; char *out; /* our p_es_out */ ssize_t (*pf_read)(stream_t *, void *buf, size_t len); char *(*pf_block)(stream_t *, bool *eof); int (*pf_readdir)(stream_t *, input_item_node_t *); int (*pf_demux)(stream_t *); int (*pf_seek)(stream_t *, uint64_t); int (*pf_control)(stream_t *, int i_query, va_list); void *p_sys; }; typedef union { char * val; char * viewpoint; char *id; struct { int cat; char **ids; } list; struct { bool b_fast_seek; int i_val; } time; struct { bool b_fast_seek; double f_val; } pos; struct { int cat; int delay; } cat_delay; struct { int cat; char *str_ids; } cat_ids; struct { char *id; int delay; } es_delay; struct { char *id; unsigned page; } vbi_page; struct { char *id; bool enabled; } vbi_transparency; struct { bool enabled; char *dir_path; } record_state; } input_control_param_t; int main(void) { char * p_input; input_control_param_t it = { .id = p_input,}; return 0; } chibicc-1.0.23.1/test/issue116.c000077500000000000000000000006451505335450300160360ustar00rootroot00000000000000#include struct DH { char *field1; char *field2; }; typedef struct DH DH; #define make_dh(x) \ char *DH_get_##x(void) \ { \ char *dh; \ if (dh == NULL) \ return NULL; \ return dh; \ } char *DH_get_tt1024_160() { char *dh; return dh; } int main(void) { make_dh(1024_160); return 0; } chibicc-1.0.23.1/test/issue117.c000077500000000000000000000041751505335450300160410ustar00rootroot00000000000000#include #define OSSL_FUNC_DECODER_NEWCTX 1 #define OSSL_FUNC_DECODER_FREECTX 2 #define OSSL_FUNC_DECODER_GET_PARAMS 3 #define OSSL_FUNC_DECODER_GETTABLE_PARAMS 4 #define OSSL_FUNC_DECODER_SET_CTX_PARAMS 5 #define OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS 6 #define OSSL_FUNC_DECODER_DOES_SELECTION 10 #define OSSL_FUNC_DECODER_DECODE 11 #define OSSL_FUNC_DECODER_EXPORT_OBJECT 20 #define OSSL_OBJECT_UNKNOWN 0 #define OSSL_OBJECT_NAME 1 /* char * */ #define OSSL_OBJECT_PKEY 2 /* EVP_PKEY * */ #define OSSL_OBJECT_CERT 3 /* X509 * */ #define OSSL_OBJECT_CRL 4 /* X509_CRL * */ struct ossl_dispatch_st { int function_id; void (*function)(void); }; static void any2obj_freectx(void *vctx) { } static void *any2obj_newctx(void *provctx) { return provctx; } typedef struct ossl_dispatch_st OSSL_DISPATCH; static void *pem2der_newctx(void *provctx) { return provctx; } static void pem2der_freectx(void *vctx) { void *tmp = vctx; } static int der2obj_decode(void *provctx) { return 0; } static int pvk2obj_decode(void *provctx) { return 0; } static int msblob2obj_decode(void *provctx) { return 0; } static int any2obj_decode_final(void *provctx) { return 0; } static int pem2der_decode(void *vctx) { #define MAKE_DECODER(fromtype, objtype) \ static const OSSL_DISPATCH fromtype##_to_obj_decoder_functions[] = { \ {OSSL_FUNC_DECODER_NEWCTX, (void (*)(void))any2obj_newctx}, \ {OSSL_FUNC_DECODER_FREECTX, (void (*)(void))any2obj_freectx}, \ {OSSL_FUNC_DECODER_DECODE, (void (*)(void))fromtype##2obj_decode}, \ {0, NULL} \ } MAKE_DECODER(der, OSSL_OBJECT_UNKNOWN); MAKE_DECODER(msblob, OSSL_OBJECT_PKEY); MAKE_DECODER(pvk, OSSL_OBJECT_PKEY); return 0; } const OSSL_DISPATCH ossl_pem_to_der_decoder_functions[] = { {OSSL_FUNC_DECODER_NEWCTX, (void (*)(void))pem2der_newctx}, {OSSL_FUNC_DECODER_FREECTX, (void (*)(void))pem2der_freectx}, {OSSL_FUNC_DECODER_DECODE, (void (*)(void))pem2der_decode}, {0, NULL}}; int main(void) { return 0; } chibicc-1.0.23.1/test/issue118.c000066400000000000000000000026671505335450300160430ustar00rootroot00000000000000#include #include "test.h" #define NID_sha1 64 #define NID_sha224 675 #define NID_sha256 672 #define NID_sha384 673 #define NID_sha512 674 #define NID_sha512_224 1094 #define NID_sha512_256 1095 static const unsigned char der_aid_mgf1SHA512_224Identifier[] = { }; static const unsigned char der_aid_mgf1SHA512Identifier[] = { }; static const unsigned char der_aid_mgf1SHA384Identifier[] = { }; static const unsigned char der_aid_mgf1SHA256Identifier[] = { }; static const unsigned char der_aid_mgf1SHA224Identifier[] = { }; static const unsigned char der_aid_mgf1SHA512_256Identifier[] = { }; #define MGF1_SHA_CASE(bits, var) \ case NID_sha##bits: \ var = der_aid_mgf1SHA##bits##Identifier; \ var##_sz = sizeof(der_aid_mgf1SHA##bits##Identifier); \ printf("sizeof=%ld\n", sizeof(der_aid_mgf1SHA##bits##Identifier)); \ break; int main(void) { int maskgenhashalg_nid = 64; const unsigned char *maskgenalg = NULL; size_t maskgenalg_sz = 0; switch (maskgenhashalg_nid) { case NID_sha1: MGF1_SHA_CASE(224, maskgenalg); MGF1_SHA_CASE(256, maskgenalg); MGF1_SHA_CASE(384, maskgenalg); MGF1_SHA_CASE(512, maskgenalg); MGF1_SHA_CASE(512_224, maskgenalg); MGF1_SHA_CASE(512_256, maskgenalg); break; default: return 0; } return 0; }chibicc-1.0.23.1/test/issue119.c000066400000000000000000000010501505335450300160250ustar00rootroot00000000000000 #if !defined(__DJGPP__) #if defined(__STDC_VERSION__) #if __STDC_VERSION__ >= 199901L #include #endif #endif #endif #include // chibicc -Iinclude -Iapps/include -pthread -m64 -Wall -O3 -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -c -o test/rsa_complex-bin-rsa_complex.o test/rsa_complex.c // /usr/include/x86_64-linux-gnu/bits/cmathcalls.h:55: __MATHCALL (cacos, (_Mdouble_complex_ __z)); // ^ expected ',' int main(void) { return 0; }chibicc-1.0.23.1/test/issue121.c000066400000000000000000000024071505335450300160250ustar00rootroot00000000000000 //#include #include #include #include #include #include // test typedef struct PodTag { int i; double d; char c; } PodType; struct vcddev_s { char *psz_dev; /* vcd device name */ /* Section used in vcd image mode */ int i_vcdimage_handle; }; typedef struct vcddev_s vcddev_t; typedef struct { vcddev_t *vcddev; /* vcd device descriptor */ unsigned start; /**< Track first sector */ unsigned length; /**< Track total sectors */ unsigned position; /**< Current offset within track sectors */ } demux_sys_t; static_assert(offsetof(demux_sys_t, vcddev) == 0, "Invalid cast"); static const size_t alignv[] = { alignof(char), alignof(short), alignof(int), alignof(long), alignof(long long), alignof(float), alignof(double), alignof(struct big_align_struct), alignof(void *), alignof(max_align_t), }; static_assert(sizeof(atomic_uint) <= sizeof(struct vlc_suuint), "Size mismatch"); static_assert(alignof(atomic_uint) <= alignof(struct vlc_suuint), "Alignment mismatch"); int main(void) { printf("%llu\n", offsetof(PodType, c)); assert(16 == offsetof(PodType, c)); return 0; }chibicc-1.0.23.1/test/issue122.c000066400000000000000000000006341505335450300160260ustar00rootroot00000000000000 /* Value type. */ /* Value type. */ #if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 294 "sys-utils/hwclock-parse-date.y" int intval; char *textintval; struct timespec timespec; int rel; #line 454 "sys-utils/hwclock-parse-date.c" }; typedef union YYSTYPE YYSTYPE; #define YYSTYPE_IS_TRIVIAL 1 #define YYSTYPE_IS_DECLARED 1 #endif int main(void) { return 0; }chibicc-1.0.23.1/test/issue123.c000066400000000000000000000004321505335450300160230ustar00rootroot00000000000000#include #include #include union semun { int val; struct semid_ds *buf; unsigned short *array; struct seminfo *__buf; }; int main() { union semun sem_union; if (sizeof(sem_union) > 0) return 0; return 1; } chibicc-1.0.23.1/test/issue124.c000066400000000000000000000005031505335450300160230ustar00rootroot00000000000000 // if we move the use of the macro after #define statement chibicc compiles it fine. // but if the macro is used before its definition, chibicc fails to compile it. gcc compiles it fine! static const char rcsid[] __attribute__((unused)) = "@(#) $Header$"; #define __attribute__(args) int main(void) { return 0; }chibicc-1.0.23.1/test/issue125a.c000066400000000000000000000002611505335450300161660ustar00rootroot00000000000000#include #include "test.h" int main(void) { __u32 val = 12; val = __arch_swab32(val); printf("%d\n", val); ASSERT(201326592, val); return 0; }chibicc-1.0.23.1/test/issue126.c000066400000000000000000000016341505335450300160330ustar00rootroot00000000000000#include #include #include "test.h" size_t strlcpy(dst, src, siz) char *dst; const char *src; size_t siz; { register char *d = dst; register const char *s = src; register size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return (s - src - 1); /* count does not include NUL */ } int main(void) { size_t res; char *src = "hello"; char *dst = calloc (20, sizeof(char)); int siz = 6; res = strlcpy(dst, src, siz); printf("res=%ld dst=%s\n", res, dst); ASSERT(5, res); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/issue127.c000066400000000000000000000004401505335450300160260ustar00rootroot00000000000000 #include "test.h" typedef struct StRegSized { unsigned char r; } StRegSized; void func1(int a, int b, int c, int d, StRegSized st) { printf("%d %d %d %d %d\n", a, b, c, d, st.r); ASSERT(99, st.r); } int main(void) { StRegSized x = {99}; func1(1, 2, 3, 4, x); return 0; }chibicc-1.0.23.1/test/issue129.c000066400000000000000000000022641505335450300160360ustar00rootroot00000000000000 #include #include "test.h" #define HYPERVISOR_INFO_LEAF 0x40000000 #define VMWARE_BDOOR_MAGIC 0x564D5868 #define VMWARE_BDOOR_PORT 0x5658 #define VMWARE_BDOOR_CMD_GETVERSION 10 static inline void cpuid(unsigned int op, unsigned int *teax, unsigned int *tebx, unsigned int *tecx, unsigned int *tedx) { __asm__( "cpuid;" : "=b"(*tebx), "=a"(*teax), "=c"(*tecx), "=d"(*tedx) : "1"(op), "c"(0)); } // void vmware_bdoor(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) // { // __asm__( // "inl (%%dx), %%eax;" // : "=b"(*ebx), // "=a"(*eax), // "=c"(*ecx), // "=d"(*edx) // : "0"(VMWARE_BDOOR_MAGIC), // "1"(VMWARE_BDOOR_CMD_GETVERSION), // "2"(VMWARE_BDOOR_PORT), // "3"(0) // : "memory"); // } int main(void) { unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; cpuid(HYPERVISOR_INFO_LEAF, &eax, &ebx, &ecx, &edx); printf("%d %d %d %d\n", eax, ebx, ecx, edx); ASSERT(1073741835, eax); ASSERT(1919117645, ebx); ASSERT(1718580079, ecx); ASSERT(1984438388, edx); // uint32_t eax2, ebx2, ecx2, edx2; // vmware_bdoor(&eax2, &ebx2, &ecx2, &edx2); // printf("%d %d %d %d\n", eax2, ebx2, ecx2, edx2); return 0; }chibicc-1.0.23.1/test/issue130.c000066400000000000000000000001041505335450300160150ustar00rootroot00000000000000#include int main() { static_assert(3 < 4, "hello"); }chibicc-1.0.23.1/test/issue134.c000066400000000000000000000071001505335450300160240ustar00rootroot00000000000000 #define FAR #define Z_U8 unsigned long #define Z_U4 unsigned typedef Z_U4 z_crc_t; typedef Z_U8 z_word_t; #define W 8 #define local local const z_crc_t FAR crc_table[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; local z_crc_t crc_word(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data >> 8) ^ crc_table[data & 0xff]; return (z_crc_t)data; } int main(void) { return 0; }chibicc-1.0.23.1/test/issue137.c000066400000000000000000000006641505335450300160370ustar00rootroot00000000000000#include #include static const char hello[] = "hello, hello!"; void test_compress(compr, comprLen, uncompr, uncomprLen) char *compr, *uncompr; long comprLen, uncomprLen; { int err; long len = (long)strlen(hello) + 1; //strncpy(uncompr, "garbage", 8); printf("uncompress(): %s\n", (char *)uncompr); } int main(int argc, char **argv) { test_compress(&hello, 14, &hello, 14); return 0; } chibicc-1.0.23.1/test/issue138.c000066400000000000000000000017031505335450300160330ustar00rootroot00000000000000#include #include #include "test.h" #define NGX_SMP_LOCK #define ngx_inline inline typedef __u_char u_char; typedef unsigned long ngx_atomic_uint_t; typedef volatile ngx_atomic_uint_t ngx_atomic_t; static ngx_inline ngx_atomic_uint_t ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, ngx_atomic_uint_t set) { u_char res; __asm__ volatile( NGX_SMP_LOCK " cmpxchgq %3, %1; " " sete %0; " : "=a"(res) : "m"(*lock), "a"(old), "r"(set) : "cc", "memory"); return res; } int main(void) { ngx_atomic_uint_t mylock = 8; ngx_atomic_t *lock = &mylock; ngx_atomic_uint_t old = 7; ngx_atomic_uint_t set = 1; ngx_atomic_uint_t t = ngx_atomic_cmp_set(lock, old, set); printf("lock = %ld, old= %ld, set = %ld\n", mylock, old, set); ASSERT(8, mylock); ASSERT(7, old); ASSERT(1, set); return 0; }chibicc-1.0.23.1/test/issue142.c000066400000000000000000000004471505335450300160320ustar00rootroot00000000000000#include #include "test.h" #define WITH_LIBGC #define PRINT_ERROR(...) ((void)fprintf(stderr, __VA_ARGS__)) int main(int argc, char *argv[]) { PRINT_ERROR( "NIT_GC_OPTION accepts 'malloc', 'large'" #ifdef WITH_LIBGC ", 'boehm'" #endif ". Default is 0.\n"); return 0; }chibicc-1.0.23.1/test/issue145.c000066400000000000000000000006241505335450300160320ustar00rootroot00000000000000#include "test.h" #define THREAD_LOCAL static __thread int uuid_generate_time_generic() { const int cs_min = 1<<6; const int cs_max = (1<<18); const int cs_factor = 2; THREAD_LOCAL int num = 0; THREAD_LOCAL int cache_size = cs_min; //int cache_size = cs_min; return cs_min; } int main() { int a = uuid_generate_time_generic(); printf("a=%d\n", a); ASSERT(64, a); return 0; }chibicc-1.0.23.1/test/issue147.c000066400000000000000000000004721505335450300160350ustar00rootroot00000000000000#include #include #include "test.h" #define __ORDER_LITTLE_ENDIAN__ 1234 //#define __BYTE_ORDER__ 1234 #define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) int main() { printf("is_little_endian=%d\n", IS_LITTLE_ENDIAN); ASSERT(1, IS_LITTLE_ENDIAN); return 0; }chibicc-1.0.23.1/test/issue148.c000066400000000000000000000002411505335450300160300ustar00rootroot00000000000000#include "test.h" static_assert(1 == 1, "channel count mismatch"); typedef struct { int remap[1]; } aout_filters_cfg_t; int main() { return 0; }chibicc-1.0.23.1/test/issue149.c000077500000000000000000000015001505335450300160330ustar00rootroot00000000000000 #include "test.h" #ifdef _WIN32 #include #include typedef unsigned __int32 uint32_t; #else #include #endif int main (void) { uint32_t r[4]; uint32_t eax_in = 0x80000008U; // uint32_t eax_out = r[0]; // uint32_t vaddr = ((eax_out & 0x0000ff00U) >> 8); // FILE *f = fopen("./conftest.out", "w"); // if (f == NULL) { // printf("f is null\n"); // return 1; // } #ifdef _WIN32 __cpuid((int *)r, (int)eax_in); #else asm volatile ("cpuid" : "=a" (r[3]), "=b" (r[1]), "=c" (r[2]), "=d" (r[0]) : "a" (eax_in), "c" (0) ); #endif // if (vaddr > (sizeof(void *) << 3)) { // vaddr = sizeof(void *) << 3; // } //fprintf(f, "%u", vaddr); printf("%d, %d, %d, %d\n", r[0], r[1], r[2], r[3]); //fclose(f); ASSERT(1, r[3] == 12334 || r[3] == 12336); return 0; ; return 0; } chibicc-1.0.23.1/test/issue149b.c000077500000000000000000000020321505335450300161760ustar00rootroot00000000000000 #include "test.h" #ifdef _WIN32 #include #include typedef unsigned __int32 uint32_t; #else #include #endif int main (void) { uint32_t r[4] = {1, 2, 3, 4}; uint32_t eax_in = 0x80000008U; uint32_t a = 7, b = 8, c = 9, d = 6; // uint32_t eax_out = r[0]; // uint32_t vaddr = ((eax_out & 0x0000ff00U) >> 8); // FILE *f = fopen("./conftest.out", "w"); // if (f == NULL) { // printf("f is null\n"); // return 1; // } #ifdef _WIN32 __cpuid((int *)r, (int)eax_in); #else asm volatile ("cpuid" : "=a" (r[0]), "=b" (r[1]), "=c" (r[2]), "=d" (r[3]) : "a" (eax_in), "c" (0) ); #endif printf("%d, %d, %d, %d\n", a, b, c, d); printf("%d, %d, %d, %d\n", r[0], r[1], r[2], r[3]); ASSERT(1, r[0] == 12336 || r[0] == 12334); // if (vaddr > (sizeof(void *) << 3)) { // vaddr = sizeof(void *) << 3; // } //fprintf(f, "%u", vaddr); // printf("%d, %d, %d, %d\n", r[0], r[1], r[2], r[3]); // for (int i = 0; i < (sizeof(r)/sizeof(r[0])); i++) // printf("%d\n", r[i]); //fclose(f); return 0; } chibicc-1.0.23.1/test/issue149c.c000077500000000000000000000011651505335450300162050ustar00rootroot00000000000000 #include "test.h" #ifdef _WIN32 #include #include typedef unsigned __int32 uint32_t; #else #include #endif void asmfunc(void) { uint32_t eax_in = 0x80000008U; uint32_t r[4] = {1, 2, 3, 4}; printf("%d, %d, %d, %d\n", r[0], r[1], r[2], r[3]); #ifdef _WIN32 __cpuid((int *)r, (int)eax_in); #else asm volatile ("cpuid" : "=a" (r[0]), "=b" (r[1]), "=c" (r[2]), "=d" (r[3]) : "a" (eax_in), "c" (0) ); #endif for (int i = 0; i < (sizeof(r)/sizeof(r[0])); i++) printf("%d\n", r[i]); ASSERT(1, r[0] == 12336 || r[0] == 12334 ); } int main (void) { asmfunc(); return 0; } chibicc-1.0.23.1/test/issue149d.c000066400000000000000000000016171505335450300162050ustar00rootroot00000000000000 #include "test.h" static void GetCPUInfo(int cpu_info[4], int info_type) { __asm__ volatile ( "cpuid\n" : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "a"(info_type), "c"(0)); for (int i = 0; i < 4; i++) { printf("%d\n", cpu_info[i]); } } void mycpuinfo(void) { int max_cpuid_value; int cpu_info[4] = {1, 2, 3, 4}; int is_intel = 0; // get the highest feature value cpuid supports GetCPUInfo(cpu_info, 0); max_cpuid_value = cpu_info[0]; for (int i = 0; i < 4; i++) printf("%d\n", cpu_info[i]); //it depends on which computer is it running //ASSERT(20, cpu_info[0]); ASSERT(1, cpu_info[1] == 1752462657 || cpu_info[1] == 1970169159); ASSERT(1, cpu_info[2] == 1145913699 || cpu_info[2] == 1818588270); ASSERT(1, cpu_info[3] == 1769238117 || cpu_info[3] == 1231384169); } int main() { mycpuinfo(); return 0; }chibicc-1.0.23.1/test/issue150.c000066400000000000000000000002751505335450300160300ustar00rootroot00000000000000 #include "test.h" #define HOST_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) int main() { printf("%d\n", __ORDER_BIG_ENDIAN__ ); ASSERT(4321, __ORDER_BIG_ENDIAN__); return 0; }chibicc-1.0.23.1/test/issue151.c000066400000000000000000000006001505335450300160210ustar00rootroot00000000000000 #include "test.h" static int ngx_atomic_fetch_add(char *value, int add) { int *ptr = &add; __asm__ volatile ( " xaddq %0, %1; " : "+r" (ptr) : "m" (*value) : "cc", "memory"); return add; } int main () { int a = 10; int *b = 8; int res = ngx_atomic_fetch_add(&b, a); printf("res=%d\n", res); ASSERT(10, res); return 0; }chibicc-1.0.23.1/test/issue155.c000066400000000000000000000002331505335450300160270ustar00rootroot00000000000000 int main() { #if defined(__i386__) || defined(__x86_64__) __asm__ __volatile__("rep; nop;"::: "memory"); /* a.k.a. PAUSE */ #endif return 0; }chibicc-1.0.23.1/test/issue155b.c000066400000000000000000000037741505335450300162060ustar00rootroot00000000000000#include #include #include #include "test.h" static inline int lxc_caps_down(void) { return 0; } static inline int lxc_caps_up(void) { return 0; } static inline int lxc_ambient_caps_up(void) { return 0; } static inline int lxc_ambient_caps_down(void) { return 0; } static inline int lxc_caps_init(void) { return 0; } static inline int lxc_caps_last_cap(__u32 *cap) { return -1; } typedef int cap_value_t; typedef int cap_flag_t; static inline bool lxc_proc_cap_is_set(cap_value_t cap, cap_flag_t flag) { return false; } static inline bool lxc_file_cap_is_set(const char *path, cap_value_t cap, cap_flag_t flag) { return false; } #define lxc_priv(__lxc_function) \ ({ \ __label__ out; \ int __ret, __ret2, ___errno = 0; \ __ret = lxc_caps_up(); \ if (__ret) \ goto out; \ __ret = __lxc_function; \ if (__ret) \ ___errno = errno; \ __ret2 = lxc_caps_down(); \ out: \ __ret ? errno = ___errno, __ret : __ret2; \ }) #define lxc_unpriv(__lxc_function) \ ({ \ __label__ out; \ int __ret, __ret2, ___errno = 0; \ __ret = lxc_caps_down(); \ if (__ret) \ goto out; \ __ret = __lxc_function; \ if (__ret) \ ___errno = errno; \ __ret2 = lxc_caps_up(); \ out: \ __ret ? errno = ___errno, __ret : __ret2; \ }) int main() { int a = lxc_unpriv(lxc_caps_up()); printf("%d\n", a); ASSERT(0, a); return 0; } chibicc-1.0.23.1/test/issue156.c000066400000000000000000000042361505335450300160370ustar00rootroot00000000000000#include #include "test.h" #include #include #include /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ #define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ #define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ #define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ #define lengthof(array) (sizeof (array) / sizeof ((array)[0])) typedef size_t Size; typedef struct MemoryChunk { /* bitfield for storing details about the chunk */ unsigned long int hdrmask; /* must be last */ } MemoryChunk; typedef enum MemoryContextMethodID { MCTX_UNUSED1_ID, /* 000 occurs in never-used memory */ MCTX_UNUSED2_ID, /* glibc malloc'd chunks usually match 001 */ MCTX_UNUSED3_ID, /* glibc malloc'd chunks > 128kB match 010 */ MCTX_ASET_ID, MCTX_GENERATION_ID, MCTX_SLAB_ID, MCTX_ALIGNED_REDIRECT_ID, MCTX_UNUSED4_ID /* 111 occurs in wipe_mem'd memory */ } MemoryContextMethodID; STATIC_ASSERT(EPOLL_CTL_ADD < 4); struct uv__io_cqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t overflow; uint32_t cqes; uint64_t reserved0; uint64_t reserved1; }; STATIC_ASSERT(40 == sizeof(struct uv__io_cqring_offsets)); struct uv__io_sqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t flags; uint32_t dropped; uint32_t array; uint32_t reserved0; uint64_t reserved1; }; struct uv__io_uring_params { uint32_t sq_entries; uint32_t cq_entries; uint32_t flags; uint32_t sq_thread_cpu; uint32_t sq_thread_idle; uint32_t features; uint32_t reserved[4]; struct uv__io_sqring_offsets sq_off; /* 40 bytes */ struct uv__io_cqring_offsets cq_off; /* 40 bytes */ }; STATIC_ASSERT(40 + 40 + 40 == sizeof(struct uv__io_uring_params)); int main() { char s [10] = {0}; int x = lengthof(s); MemoryChunk *chunk = (struct MemoryChunk*)malloc(sizeof(struct MemoryChunk)); Size value; MemoryContextMethodID methodid = 3; chunk->hdrmask = (((unsigned long int) 100) << 34) | (((unsigned long int) value) << 4) | methodid; return 0; }chibicc-1.0.23.1/test/issue156b.c000066400000000000000000000006251505335450300161770ustar00rootroot00000000000000#include #include "test.h" void asmfunc(void) { const uint32_t ecx = 0; uint32_t eax, edx; // Use the raw opcode for xgetbv for compatibility with older toolchains. __asm__ volatile ( ".byte 0x0f, 0x01, 0xd0\n" : "=a"(eax), "=d"(edx) : "c" (ecx)); ASSERT(7, eax); ASSERT(0, edx); printf("eax=%d, edx=%d\n", eax, edx); } int main() { asmfunc(); return 0; }chibicc-1.0.23.1/test/issue157.c000066400000000000000000000016751505335450300160440ustar00rootroot00000000000000#include #include #include "test.h" #define Array(T) \ struct { \ T *contents; \ uint32_t size; \ uint32_t capacity; \ } typedef union { char * data; const char *ptr; } Subtree; typedef struct { uint32_t bytes; char *extent; } Length; typedef struct { const Subtree *subtree; Length position; uint32_t child_index; uint32_t structural_child_index; uint32_t descendant_index; } TreeCursorEntry; typedef struct { const char *tree; Array(TreeCursorEntry) stack; } TreeCursor; typedef struct { TreeCursor cursor; const char *language; unsigned visible_depth; bool in_padding; } Iterator; static bool iterator_tree_is_visible(const Iterator *self) { if (self->cursor.stack.size > 1) { Subtree parent = *self->cursor.stack.contents[self->cursor.stack.size - 2].subtree; return false; } return false; } int main() { return 0; }chibicc-1.0.23.1/test/issue157b.c000066400000000000000000000010331505335450300161720ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2002 Roman Zippel */ #include #include #include "test.h" #include #include //#include "lkc.h" #define DEBUG_EXPR 0 enum string_value_kind { k_string, k_signed, k_unsigned, }; union string_value { unsigned long long u; signed long long s; }; void expr_calc_value(struct expr *e) { union string_value lval = {}, rval = {}; } int main() { return 0; }chibicc-1.0.23.1/test/issue158.c000066400000000000000000000013471505335450300160410ustar00rootroot00000000000000#include "test.h" #include #include #define MPACK_PARENT_NODE(n) (((n) - 1)->pos == (size_t)-1 ? NULL : (n) - 1) typedef struct mpack_node_s { char *tok; size_t pos; /* flag to determine if the key was visited when traversing a map */ int key_visited; /* allow 2 instances mpack_data_t per node. the reason is that when * serializing, the user may need to keep track of traversal state besides the * parent node reference */ char *data[2]; } mpack_node_t; typedef struct { char *parser; int reg, ext, unpacking, mtdict; char *string_buffer; } Unpacker; int main() { Unpacker *unpacker; mpack_node_t *node; if (1 == 0 ) unpacker->string_buffer + MPACK_PARENT_NODE(node)->pos; return 0; }chibicc-1.0.23.1/test/issue159.c000066400000000000000000000035211505335450300160360ustar00rootroot00000000000000 #include #include #include "test.h" // represents a variable union Var { float f; char *s; bool b; // 'f' 's' or 'b' char type; }; // #define foo(x) \ // __builtin_choose_expr ( \ // __builtin_types_compatible_p (typeof (x), double), \ // foo_double (x), \ // __builtin_choose_expr ( \ // __builtin_types_compatible_p (typeof (x), float), \ // foo_float (x), \ // /* The void expression results in a compile-time error \ // when assigning the result to something. */ \ // (void)0)) #define ts_subtree_children(self) \ ((self) ? NULL : (union Var *)((self))) // // setter void set_int(union Var *var, int newval) { var->f = (float)newval; var->type = 'f'; } void set_float(union Var *var, float newval) { var->f = newval; var->type = 'f'; printf("var->f=%f\n", var->f); ASSERT(1, var->f);} void set_char(union Var *var, char newval) { var->s = (char[2]){newval, 0}; var->type = 's'; } void set_string(union Var *var, char *newval) { var->s = newval; var->type = 's'; } void set_bool(union Var *var, bool newval) { var->b = newval; var->type = 'b'; } #define set(VAR, X) \ _Generic((X), \ int: set_int, \ float: set_float, \ double: set_float, \ char: set_char, \ char *: set_string, \ bool: set_bool)((VAR), (X)) int main(void) { union Var myvar; set(&myvar, 1.5); char c = 'c'; char *pc = &c; int i = 0; union Var *tsubtree[1]; const union Var *child = &ts_subtree_children(tsubtree)[i]; ASSERT(NULL, child); printf("child is null! = %p\n", child); return 0; }chibicc-1.0.23.1/test/issue159b.c000066400000000000000000000004301505335450300161740ustar00rootroot00000000000000#include #include #include "test.h" static inline uint32_t lj_bswap(uint32_t x) { uint32_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; } int main() { int a = lj_bswap(18); printf("%d\n", a); ASSERT(301989888, a); return 0; }chibicc-1.0.23.1/test/issue160.c000066400000000000000000000006671505335450300160360ustar00rootroot00000000000000#include #include #include #include "memcached.h" #include int main() { int t1 = IOV_MAX - 1; int iovused = 10; int iovcnt = 10; bool resp = false; while (resp && iovused + iovcnt < IOV_MAX-1) { break; } printf("t1=%d iovused=%d iovcnt=%d\n", t1, iovused, iovcnt); assert(1023 == t1); assert(10 == iovused); assert(10 == iovcnt); return 0; }chibicc-1.0.23.1/test/issue162.c000066400000000000000000000045071505335450300160350ustar00rootroot00000000000000#include #include "test.h" #ifndef __cplusplus #ifdef HAVE__STATIC_ASSERT #define StaticAssertDecl(condition, errmessage) \ _Static_assert(condition, errmessage) #define StaticAssertStmt(condition, errmessage) \ do { _Static_assert(condition, errmessage); } while(0) #define StaticAssertExpr(condition, errmessage) \ ((void) ({ StaticAssertStmt(condition, errmessage); true; })) #else /* !HAVE__STATIC_ASSERT */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) #define StaticAssertStmt(condition, errmessage) \ ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; })) #define StaticAssertExpr(condition, errmessage) \ StaticAssertStmt(condition, errmessage) #endif /* HAVE__STATIC_ASSERT */ #else /* C++ */ #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 #define StaticAssertDecl(condition, errmessage) \ static_assert(condition, errmessage) #define StaticAssertStmt(condition, errmessage) \ static_assert(condition, errmessage) #define StaticAssertExpr(condition, errmessage) \ ({ static_assert(condition, errmessage); }) #else /* !__cpp_static_assert */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) #define StaticAssertStmt(condition, errmessage) \ do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0) #define StaticAssertExpr(condition, errmessage) \ ((void) ({ StaticAssertStmt(condition, errmessage); })) #endif /* __cpp_static_assert */ #endif /* C++ */ #define HAVE__BUILTIN_TYPES_COMPATIBLE_P 1 #if defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P) #define unconstify(underlying_type, expr) \ (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \ "wrong cast"), \ (underlying_type) (expr)) #define unvolatize(underlying_type, expr) \ (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \ "wrong cast"), \ (underlying_type) (expr)) #else #define unconstify(underlying_type, expr) \ ((underlying_type) (expr)) #define unvolatize(underlying_type, expr) \ ((underlying_type) (expr)) #endif int main() { bool b = unconstify(int, 5 + 8); ASSERT(1, b); return 0; }chibicc-1.0.23.1/test/issue164.c000066400000000000000000000006371505335450300160370ustar00rootroot00000000000000#include "test.h" typedef struct pg_atomic_flag { volatile char value; } pg_atomic_flag; pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr) { char _res = 1; __asm__ __volatile__( " lock \n" " xchgb %0,%1 \n" : "+q"(_res), "+m"(ptr->value) : : "memory"); ASSERT(8, _res); return _res == 0; } int main() { pg_atomic_flag t = {.value= 8}; pg_atomic_test_set_flag_impl(&t); return 0; }chibicc-1.0.23.1/test/issue165.c000066400000000000000000000006111505335450300160300ustar00rootroot00000000000000//#include #include "test.h" #define BT_OFFSET_MASK 0x0FFF #define INDEX_MAX_KEYS 32 StaticAssertDecl(BT_OFFSET_MASK >= INDEX_MAX_KEYS, "BT_OFFSET_MASK can't fit INDEX_MAX_KEYS"); //static_assert(8 > 10, "8 can't be greater than 10"); ; int main() { int c = BT_OFFSET_MASK; printf("c=%d\n", c); ASSERT(0x0FFF, c); return 0; }chibicc-1.0.23.1/test/issue166.c000066400000000000000000000065131505335450300160400ustar00rootroot00000000000000 #include #include #include #include #include "test.h" #define MAXIMUM_ALIGNOF 8 #define BLCKSZ 8192 typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ typedef uint8 bits8; /* >= 8 bits */ typedef uint16 bits16; /* >= 16 bits */ typedef uint32 bits32; /* >= 32 bits */ #define FLEXIBLE_ARRAY_MEMBER /* empty */ typedef struct ItemIdData { unsigned lp_off:15, /* offset to tuple (from start of page) */ lp_flags:2, /* state of line pointer, see below */ lp_len:15; /* byte length of tuple */ } ItemIdData; struct HeapTupleHeaderData { union { char * t_heap; char * t_datum; } t_choice; char * t_ctid; /* current TID of this or newer tuple (or a * speculative insertion token) */ /* Fields below here must match MinimalTupleData! */ #define FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK2 2 uint16 t_infomask2; /* number of attributes + various flags */ #define FIELDNO_HEAPTUPLEHEADERDATA_INFOMASK 3 uint16 t_infomask; /* various flag bits, see below */ #define FIELDNO_HEAPTUPLEHEADERDATA_HOFF 4 uint8 t_hoff; /* sizeof header incl. bitmap, padding */ /* ^ - 23 bytes - ^ */ #define FIELDNO_HEAPTUPLEHEADERDATA_BITS 5 bits8 t_bits[FLEXIBLE_ARRAY_MEMBER]; /* bitmap of NULLs */ }; typedef struct HeapTupleHeaderData HeapTupleHeaderData; typedef struct PageHeaderData { /* XXX LSN is member of *any* block, not only page-organized ones */ char * pd_lsn; /* LSN: next byte after last byte of xlog * record for last change to this page */ uint16 pd_checksum; /* checksum */ uint16 pd_flags; /* flag bits, see below */ int * pd_lower; /* offset to start of free space */ int * pd_upper; /* offset to end of free space */ int * pd_special; /* offset to start of special space */ uint16 pd_pagesize_version; char * pd_prune_xid; /* oldest prunable XID, or zero if none */ ItemIdData pd_linp[FLEXIBLE_ARRAY_MEMBER]; /* line pointer array */ } PageHeaderData; #define SizeofHeapTupleHeader offsetof(HeapTupleHeaderData, t_bits) // #define offsetof(t, d) __builtin_offsetof(t, d) #define SizeOfPageHeaderData (offsetof(PageHeaderData, pd_linp)) #define TYPEALIGN(ALIGNVAL,LEN) \ (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1))) #define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN)) #define MaxHeapTuplesPerPage \ ((int) ((BLCKSZ - SizeOfPageHeaderData) / \ (MAXALIGN(SizeofHeapTupleHeader) + sizeof(ItemIdData)))) // #define myvalue 190 // #define MaxHeapTuplesPerPage myvalue + 100 #define MAX_TUPLES_PER_PAGE MaxHeapTuplesPerPage typedef struct { int nredirected; /* numbers of entries in arrays below */ int ndead; int nunused; /* * marked[i] is true if item i is entered in one of the above arrays. * * This needs to be MaxHeapTuplesPerPage + 1 long as FirstOffsetNumber is * 1. Otherwise every access would need to subtract 1. */ bool marked[MaxHeapTuplesPerPage + 1]; } PruneState; int heap_page_prune() { PruneState prstate; memset(prstate.marked, 0, sizeof(prstate.marked)); printf("====%ld\n", sizeof(prstate.marked)); ASSERT(291, sizeof(prstate.marked) ); printf("====%d\n", MaxHeapTuplesPerPage + 1); ASSERT(291, MaxHeapTuplesPerPage + 1); return 0; } int main() { heap_page_prune(); return 0; }chibicc-1.0.23.1/test/issue166b.c000066400000000000000000000010001505335450300161640ustar00rootroot00000000000000#include #include #include struct abc1 { int a, b, c; }; union abc2 { int a, b, c; }; typedef struct abc1 abc1; typedef union abc2 abc2; int main () { assert(offsetof(abc1, a) == 0); // always, because there's no padding before a. assert(offsetof(abc1, b) == 4); // here, on my system assert(offsetof(abc2, a) == offsetof(abc2, b)); // (members overlap) printf("%ld\n", offsetof(abc1, a) ); printf("%ld\n", offsetof(abc1, b) ); printf("%ld\n", offsetof(abc2, a) ); return 0; }chibicc-1.0.23.1/test/issue166c.c000066400000000000000000000005551505335450300162030ustar00rootroot00000000000000#include #include "test.h" #define N 4 typedef struct { bool arr[N + 1]; } S; int foo(int x) { typedef struct { bool arr[x + 1]; } S; return sizeof(S); } int main() { S s = {0}; s.arr[0] = 1; printf("%d\n", foo(10)); //should return 11 ASSERT(11, foo(10)); if (s.arr[0]) return 0; return 1; } chibicc-1.0.23.1/test/issue167.c000066400000000000000000000034651505335450300160440ustar00rootroot00000000000000#include #include #include #include "test.h" typedef unsigned long int uint64; typedef unsigned int uint32; typedef struct pg_atomic_uint64 { /* alignment guaranteed due to being on a 64bit platform */ volatile uint64 value; } pg_atomic_uint64; typedef struct pg_atomic_uint32 { volatile uint32 value; } pg_atomic_uint32; static inline bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval) { char ret; /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgq %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); ASSERT(1, ret); return (bool) ret; } static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { char ret; /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgl %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); return (bool) ret; } int main() { pg_atomic_uint32 a; a.value = 10; uint32 b = 17; uint32 c = 0; pg_atomic_compare_exchange_u32_impl(&a, &b, c); ASSERT(10, a.value); ASSERT(10, b); ASSERT(0, c); return 0; }chibicc-1.0.23.1/test/issue168.c000066400000000000000000000021661505335450300160420ustar00rootroot00000000000000#include #include #include "test.h" //#include #define HIGHBIT (0x80) #define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT) int pg_strcasecmp(const char *s1, const char *s2) { // for (;;) // { // unsigned char ch1 = (unsigned char) *s1++; // unsigned char ch2 = (unsigned char) *s2++; // if (ch1 != ch2) // { // if (ch1 >= 'A' && ch1 <= 'Z') // ch1 += 'a' - 'A'; // else if (IS_HIGHBIT_SET(ch1) && isupper(ch1)) // ch1 = tolower(ch1); // if (ch2 >= 'A' && ch2 <= 'Z') // ch2 += 'a' - 'A'; // else if (IS_HIGHBIT_SET(ch2) && isupper(ch2)) // ch2 = tolower(ch2); // if (ch1 != ch2) // return (int) ch1 - (int) ch2; // } // if (ch1 == 0) // break; // } return 0; } void add_additional_variables(char *name, bool insert) { int (* strcmp_fn)(const char *, const char *) = ((name[0] == ':' || name[0] == '"') ? strcmp : pg_strcasecmp); //int (* strcmp_fn) = ((name[0] == ':' || name[0] == '"') ? strcmp : pg_strcasecmp); } int main() { char *name = "test"; bool insert = true; add_additional_variables(name, insert); return 0; }chibicc-1.0.23.1/test/issue168b.c000066400000000000000000000002731505335450300162010ustar00rootroot00000000000000 #include "test.h" int add2(int x, int y) { return x + y; } int main() { int res = 0; int (*fn)(int,int) = add2; res = fn(2,5); printf("res=%d\n", res); ASSERT(7, res); return 0; }chibicc-1.0.23.1/test/issue168c.c000066400000000000000000000007461505335450300162070ustar00rootroot00000000000000#include #include #include "test.h" #define CDTEXT_MAX_TRACKS 0x7f static void CdTextParsePackText( const int *p_pack, size_t *pi_textbuffer, size_t *pi_repeatbuffer, char *textbuffer, int *pi_last_track, char *pppsz_info[CDTEXT_MAX_TRACKS + 1][0x10] ) { return; } int main() { return 0; }chibicc-1.0.23.1/test/issue170b.c000066400000000000000000000606021505335450300161740ustar00rootroot00000000000000#include "assert.h" #include #ifdef __cplusplus # error "A C++ compiler has been selected for C." #endif #if defined(__18CXX) # define ID_VOID_MAIN #endif #if defined(__CLASSIC_C__) /* cv-qualifiers did not exist in K&R C */ # define const # define volatile #endif #if !defined(__has_include) /* If the compiler does not have __has_include, pretend the answer is always no. */ # define __has_include(x) 0 #endif /* Version number components: V=Version, R=Revision, P=Patch Version date components: YYYY=Year, MM=Month, DD=Day */ #if defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" # if defined(_MSC_VER) # define SIMULATE_ID "MSVC" # endif # if defined(__GNUC__) # define SIMULATE_ID "GNU" # endif /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, except that a few beta releases use the old format with V=2021. */ # if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) # if defined(__INTEL_COMPILER_UPDATE) # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) # else # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) # endif # else # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) /* The third version component from --version is an update index, but no macro is provided for it. */ # define COMPILER_VERSION_PATCH DEC(0) # endif # if defined(__INTEL_COMPILER_BUILD_DATE) /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) # endif # if defined(_MSC_VER) /* _MSC_VER = VVRR */ # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) # endif # if defined(__GNUC__) # define SIMULATE_VERSION_MAJOR DEC(__GNUC__) # elif defined(__GNUG__) # define SIMULATE_VERSION_MAJOR DEC(__GNUG__) # endif # if defined(__GNUC_MINOR__) # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) # endif # if defined(__GNUC_PATCHLEVEL__) # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) # endif #elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER) # define COMPILER_ID "IntelLLVM" #if defined(_MSC_VER) # define SIMULATE_ID "MSVC" #endif #if defined(__GNUC__) # define SIMULATE_ID "GNU" #endif /* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and * later. Look for 6 digit vs. 8 digit version number to decide encoding. * VVVV is no smaller than the current year when a version is released. */ #if __INTEL_LLVM_COMPILER < 1000000L # define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100) # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10) # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10) #else # define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000) # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) #endif #if defined(_MSC_VER) /* _MSC_VER = VVRR */ # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) #endif #if defined(__GNUC__) # define SIMULATE_VERSION_MAJOR DEC(__GNUC__) #elif defined(__GNUG__) # define SIMULATE_VERSION_MAJOR DEC(__GNUG__) #endif #if defined(__GNUC_MINOR__) # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) #endif #if defined(__GNUC_PATCHLEVEL__) # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) #endif #elif defined(__PATHCC__) # define COMPILER_ID "PathScale" # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) # if defined(__PATHCC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) # endif #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) # define COMPILER_ID "Embarcadero" # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) #elif defined(__BORLANDC__) # define COMPILER_ID "Borland" /* __BORLANDC__ = 0xVRR */ # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) && __WATCOMC__ < 1200 # define COMPILER_ID "Watcom" /* __WATCOMC__ = VVRR */ # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) # if (__WATCOMC__ % 10) > 0 # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) # endif #elif defined(__WATCOMC__) # define COMPILER_ID "OpenWatcom" /* __WATCOMC__ = VVRP + 1100 */ # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) # if (__WATCOMC__ % 10) > 0 # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) # endif #elif defined(__SUNPRO_C) # define COMPILER_ID "SunPro" # if __SUNPRO_C >= 0x5100 /* __SUNPRO_C = 0xVRRP */ # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) # else /* __SUNPRO_CC = 0xVRP */ # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) # endif #elif defined(__HP_cc) # define COMPILER_ID "HP" /* __HP_cc = VVRRPP */ # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) #elif defined(__DECC) # define COMPILER_ID "Compaq" /* __DECC_VER = VVRRTPPPP */ # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) #elif defined(__IBMC__) && defined(__COMPILER_VER__) # define COMPILER_ID "zOS" /* __IBMC__ = VRP */ # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) #elif defined(__ibmxl__) && defined(__clang__) # define COMPILER_ID "XLClang" # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 # define COMPILER_ID "XL" /* __IBMC__ = VRP */ # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 # define COMPILER_ID "VisualAge" /* __IBMC__ = VRP */ # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) #elif defined(__NVCOMPILER) # define COMPILER_ID "NVHPC" # define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__) # define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__) # if defined(__NVCOMPILER_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__) # endif #elif defined(__PGI) # define COMPILER_ID "PGI" # define COMPILER_VERSION_MAJOR DEC(__PGIC__) # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) # if defined(__PGIC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) # endif #elif defined(_CRAYC) # define COMPILER_ID "Cray" # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI" /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) #elif defined(__CLANG_FUJITSU) # define COMPILER_ID "FujitsuClang" # define COMPILER_VERSION_MAJOR DEC(__FCC_major__) # define COMPILER_VERSION_MINOR DEC(__FCC_minor__) # define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) # define COMPILER_VERSION_INTERNAL_STR __clang_version__ #elif defined(__FUJITSU) # define COMPILER_ID "Fujitsu" # if defined(__FCC_version__) # define COMPILER_VERSION __FCC_version__ # elif defined(__FCC_major__) # define COMPILER_VERSION_MAJOR DEC(__FCC_major__) # define COMPILER_VERSION_MINOR DEC(__FCC_minor__) # define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) # endif # if defined(__fcc_version) # define COMPILER_VERSION_INTERNAL DEC(__fcc_version) # elif defined(__FCC_VERSION) # define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION) # endif #elif defined(__ghs__) # define COMPILER_ID "GHS" /* __GHS_VERSION_NUMBER = VVVVRP */ # ifdef __GHS_VERSION_NUMBER # define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) # define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) # define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) # endif #elif defined(__TINYC__) # define COMPILER_ID "TinyCC" #elif defined(__BCC__) # define COMPILER_ID "Bruce" #elif defined(__SCO_VERSION__) # define COMPILER_ID "SCO" #elif defined(__ARMCC_VERSION) && !defined(__clang__) # define COMPILER_ID "ARMCC" #if __ARMCC_VERSION >= 1000000 /* __ARMCC_VERSION = VRRPPPP */ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) #else /* __ARMCC_VERSION = VRPPPP */ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) #endif #elif defined(__clang__) && defined(__apple_build_version__) # define COMPILER_ID "AppleClang" # if defined(_MSC_VER) # define SIMULATE_ID "MSVC" # endif # define COMPILER_VERSION_MAJOR DEC(__clang_major__) # define COMPILER_VERSION_MINOR DEC(__clang_minor__) # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) # if defined(_MSC_VER) /* _MSC_VER = VVRR */ # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) # endif # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) #elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) # define COMPILER_ID "ARMClang" # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000) # define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) #elif defined(__clang__) # define COMPILER_ID "Clang" # if defined(_MSC_VER) # define SIMULATE_ID "MSVC" # endif # define COMPILER_VERSION_MAJOR DEC(__clang_major__) # define COMPILER_VERSION_MINOR DEC(__clang_minor__) # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) # if defined(_MSC_VER) /* _MSC_VER = VVRR */ # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) # endif #elif defined(__GNUC__) # define COMPILER_ID "GNU" # define COMPILER_VERSION_MAJOR DEC(__GNUC__) # if defined(__GNUC_MINOR__) # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) # endif # if defined(__GNUC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) # endif #elif defined(_MSC_VER) # define COMPILER_ID "MSVC" /* _MSC_VER = VVRR */ # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) # if defined(_MSC_FULL_VER) # if _MSC_VER >= 1400 /* _MSC_FULL_VER = VVRRPPPPP */ # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) # else /* _MSC_FULL_VER = VVRRPPPP */ # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) # endif # endif # if defined(_MSC_BUILD) # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) # endif #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) # define COMPILER_ID "ADSP" #if defined(__VISUALDSPVERSION__) /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) #endif #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) # define COMPILER_ID "IAR" # if defined(__VER__) && defined(__ICCARM__) # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) # elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__)) # define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) # define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) # define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) # endif #elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) # define COMPILER_ID "SDCC" # if defined(__SDCC_VERSION_MAJOR) # define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) # define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) # define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) # else /* SDCC = VRP */ # define COMPILER_VERSION_MAJOR DEC(SDCC/100) # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) # define COMPILER_VERSION_PATCH DEC(SDCC % 10) # endif /* These compilers are either not known or too old to define an identification macro. Try to identify the platform and guess that it is the native compiler. */ #elif defined(__hpux) || defined(__hpua) # define COMPILER_ID "HP" #else /* unknown compiler */ # define COMPILER_ID "" #endif /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the array rather than assigning a pointer to a static array. */ char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; #ifdef SIMULATE_ID char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif #ifdef __QNXNTO__ char const* qnxnto = "INFO" ":" "qnxnto[]"; #endif #if defined(__CRAYXT_COMPUTE_LINUX_TARGET) char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; #endif #define STRINGIFY_HELPER(X) #X #define STRINGIFY(X) STRINGIFY_HELPER(X) /* Identify known platforms by name. */ #if defined(__linux) || defined(__linux__) || defined(linux) # define PLATFORM_ID "Linux" #elif defined(__MSYS__) # define PLATFORM_ID "MSYS" #elif defined(__CYGWIN__) # define PLATFORM_ID "Cygwin" #elif defined(__MINGW32__) # define PLATFORM_ID "MinGW" #elif defined(__APPLE__) # define PLATFORM_ID "Darwin" #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) # define PLATFORM_ID "Windows" #elif defined(__FreeBSD__) || defined(__FreeBSD) # define PLATFORM_ID "FreeBSD" #elif defined(__NetBSD__) || defined(__NetBSD) # define PLATFORM_ID "NetBSD" #elif defined(__OpenBSD__) || defined(__OPENBSD) # define PLATFORM_ID "OpenBSD" #elif defined(__sun) || defined(sun) # define PLATFORM_ID "SunOS" #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) # define PLATFORM_ID "AIX" #elif defined(__hpux) || defined(__hpux__) # define PLATFORM_ID "HP-UX" #elif defined(__HAIKU__) # define PLATFORM_ID "Haiku" #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) # define PLATFORM_ID "BeOS" #elif defined(__QNX__) || defined(__QNXNTO__) # define PLATFORM_ID "QNX" #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) # define PLATFORM_ID "Tru64" #elif defined(__riscos) || defined(__riscos__) # define PLATFORM_ID "RISCos" #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) # define PLATFORM_ID "SINIX" #elif defined(__UNIX_SV__) # define PLATFORM_ID "UNIX_SV" #elif defined(__bsdos__) # define PLATFORM_ID "BSDOS" #elif defined(_MPRAS) || defined(MPRAS) # define PLATFORM_ID "MP-RAS" #elif defined(__osf) || defined(__osf__) # define PLATFORM_ID "OSF1" #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) # define PLATFORM_ID "SCO_SV" #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) # define PLATFORM_ID "ULTRIX" #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) # define PLATFORM_ID "Xenix" #elif defined(__WATCOMC__) # if defined(__LINUX__) # define PLATFORM_ID "Linux" # elif defined(__DOS__) # define PLATFORM_ID "DOS" # elif defined(__OS2__) # define PLATFORM_ID "OS2" # elif defined(__WINDOWS__) # define PLATFORM_ID "Windows3x" # elif defined(__VXWORKS__) # define PLATFORM_ID "VxWorks" # else /* unknown platform */ # define PLATFORM_ID # endif #elif defined(__INTEGRITY) # if defined(INT_178B) # define PLATFORM_ID "Integrity178" # else /* regular Integrity */ # define PLATFORM_ID "Integrity" # endif #else /* unknown platform */ # define PLATFORM_ID #endif /* For windows compilers MSVC and Intel we can determine the architecture of the compiler being used. This is because the compilers do not have flags that can change the architecture, but rather depend on which compiler is being used */ #if defined(_WIN32) && defined(_MSC_VER) # if defined(_M_IA64) # define ARCHITECTURE_ID "IA64" # elif defined(_M_ARM64EC) # define ARCHITECTURE_ID "ARM64EC" # elif defined(_M_X64) || defined(_M_AMD64) # define ARCHITECTURE_ID "x64" # elif defined(_M_IX86) # define ARCHITECTURE_ID "X86" # elif defined(_M_ARM64) # define ARCHITECTURE_ID "ARM64" # elif defined(_M_ARM) # if _M_ARM == 4 # define ARCHITECTURE_ID "ARMV4I" # elif _M_ARM == 5 # define ARCHITECTURE_ID "ARMV5I" # else # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) # endif # elif defined(_M_MIPS) # define ARCHITECTURE_ID "MIPS" # elif defined(_M_SH) # define ARCHITECTURE_ID "SHx" # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif #elif defined(__WATCOMC__) # if defined(_M_I86) # define ARCHITECTURE_ID "I86" # elif defined(_M_IX86) # define ARCHITECTURE_ID "X86" # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) # if defined(__ICCARM__) # define ARCHITECTURE_ID "ARM" # elif defined(__ICCRX__) # define ARCHITECTURE_ID "RX" # elif defined(__ICCRH850__) # define ARCHITECTURE_ID "RH850" # elif defined(__ICCRL78__) # define ARCHITECTURE_ID "RL78" # elif defined(__ICCRISCV__) # define ARCHITECTURE_ID "RISCV" # elif defined(__ICCAVR__) # define ARCHITECTURE_ID "AVR" # elif defined(__ICC430__) # define ARCHITECTURE_ID "MSP430" # elif defined(__ICCV850__) # define ARCHITECTURE_ID "V850" # elif defined(__ICC8051__) # define ARCHITECTURE_ID "8051" # elif defined(__ICCSTM8__) # define ARCHITECTURE_ID "STM8" # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif #elif defined(__ghs__) # if defined(__PPC64__) # define ARCHITECTURE_ID "PPC64" # elif defined(__ppc__) # define ARCHITECTURE_ID "PPC" # elif defined(__ARM__) # define ARCHITECTURE_ID "ARM" # elif defined(__x86_64__) # define ARCHITECTURE_ID "x64" # elif defined(__i386__) # define ARCHITECTURE_ID "X86" # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif #elif defined(__TI_COMPILER_VERSION__) # if defined(__TI_ARM__) # define ARCHITECTURE_ID "ARM" # elif defined(__MSP430__) # define ARCHITECTURE_ID "MSP430" # elif defined(__TMS320C28XX__) # define ARCHITECTURE_ID "TMS320C28x" # elif defined(__TMS320C6X__) || defined(_TMS320C6X) # define ARCHITECTURE_ID "TMS320C6x" # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif #else # define ARCHITECTURE_ID #endif /* Convert integer to decimal digit literals. */ #define DEC(n) \ ('0' + (((n) / 10000000)%10)), \ ('0' + (((n) / 1000000)%10)), \ ('0' + (((n) / 100000)%10)), \ ('0' + (((n) / 10000)%10)), \ ('0' + (((n) / 1000)%10)), \ ('0' + (((n) / 100)%10)), \ ('0' + (((n) / 10)%10)), \ ('0' + ((n) % 10)) /* Convert integer to hex digit literals. */ #define HEX(n) \ ('0' + ((n)>>28 & 0xF)), \ ('0' + ((n)>>24 & 0xF)), \ ('0' + ((n)>>20 & 0xF)), \ ('0' + ((n)>>16 & 0xF)), \ ('0' + ((n)>>12 & 0xF)), \ ('0' + ((n)>>8 & 0xF)), \ ('0' + ((n)>>4 & 0xF)), \ ('0' + ((n) & 0xF)) /* Construct a string literal encoding the version number. */ #ifdef COMPILER_VERSION char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; /* Construct a string literal encoding the version number components. */ #elif defined(COMPILER_VERSION_MAJOR) char const info_version[] = { 'I', 'N', 'F', 'O', ':', 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', COMPILER_VERSION_MAJOR, # ifdef COMPILER_VERSION_MINOR '.', COMPILER_VERSION_MINOR, # ifdef COMPILER_VERSION_PATCH '.', COMPILER_VERSION_PATCH, # ifdef COMPILER_VERSION_TWEAK '.', COMPILER_VERSION_TWEAK, # endif # endif # endif ']','\0'}; #endif /* Construct a string literal encoding the internal version number. */ #ifdef COMPILER_VERSION_INTERNAL char const info_version_internal[] = { 'I', 'N', 'F', 'O', ':', 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', 'i','n','t','e','r','n','a','l','[', COMPILER_VERSION_INTERNAL,']','\0'}; #elif defined(COMPILER_VERSION_INTERNAL_STR) char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; #endif /* Construct a string literal encoding the version number components. */ #ifdef SIMULATE_VERSION_MAJOR char const info_simulate_version[] = { 'I', 'N', 'F', 'O', ':', 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', SIMULATE_VERSION_MAJOR, # ifdef SIMULATE_VERSION_MINOR '.', SIMULATE_VERSION_MINOR, # ifdef SIMULATE_VERSION_PATCH '.', SIMULATE_VERSION_PATCH, # ifdef SIMULATE_VERSION_TWEAK '.', SIMULATE_VERSION_TWEAK, # endif # endif # endif ']','\0'}; #endif /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the array rather than assigning a pointer to a static array. */ char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; #if !defined(__STDC__) && !defined(__clang__) # if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__) # define C_VERSION "90" # else # define C_VERSION # endif #elif __STDC_VERSION__ > 201710L # define C_VERSION "23" #elif __STDC_VERSION__ >= 201710L # define C_VERSION "17" #elif __STDC_VERSION__ >= 201000L # define C_VERSION "11" #elif __STDC_VERSION__ >= 199901L # define C_VERSION "99" #else # define C_VERSION "90" #endif const char* info_language_standard_default = "INFO" ":" "standard_default[" C_VERSION "]"; const char* info_language_extensions_default = "INFO" ":" "extensions_default[" /* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */ #if (defined(__clang__) || defined(__GNUC__) || \ defined(__TI_COMPILER_VERSION__)) && \ !defined(__STRICT_ANSI__) && !defined(_MSC_VER) "ON" #else "OFF" #endif "]"; /*--------------------------------------------------------------------------*/ #ifdef ID_VOID_MAIN void main() {} #else # if defined(__CLASSIC_C__) int main(argc, argv) int argc; char *argv[]; # else int main(int argc, char* argv[]) # endif { int require = 0; require += info_compiler[argc]; require += info_platform[argc]; require += info_arch[argc]; #ifdef COMPILER_VERSION_MAJOR require += info_version[argc]; #endif #ifdef COMPILER_VERSION_INTERNAL require += info_version_internal[argc]; #endif #ifdef SIMULATE_ID require += info_simulate[argc]; #endif #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif #if defined(__CRAYXT_COMPUTE_LINUX_TARGET) require += info_cray[argc]; #endif require += info_language_standard_default[argc]; require += info_language_extensions_default[argc]; (void)argv; assert(require != 0 ? printf("require=%d\n"): "require should not be 0"); return 0; } #endifchibicc-1.0.23.1/test/issue170c.c000066400000000000000000000002101505335450300161620ustar00rootroot00000000000000 #include "test.h" int main(int argc, char *argv[]) { printf("argc=%d\n", argc); ASSERT(1, argc); return argc - 1; }chibicc-1.0.23.1/test/issue31.c000077500000000000000000000004751505335450300157530ustar00rootroot00000000000000 #include "test.h" struct info { int key; int :5; int data; }; int Get(struct info * m) { return m->data;} int main() { struct info info = {1, 1, 1}; printf("%ld\n", sizeof(info)); ASSERT(12, sizeof(info)); printf("%d\n", Get(&info)); ASSERT(1, Get(&info)); return 0; }chibicc-1.0.23.1/test/issue35.c000077500000000000000000000007341505335450300157550ustar00rootroot00000000000000#include #include "test.h" #define SIZE 10 int myarr[SIZE]; int myarr[] = {11, 34, }; int main(void) { for(int i = 0; i < SIZE; i++) { printf("%d: %d\n", i, myarr[i]); } ASSERT(11, myarr[0]); ASSERT(34, myarr[1]); ASSERT(0, myarr[2]); ASSERT(0, myarr[3]); ASSERT(0, myarr[4]); ASSERT(0, myarr[5]); ASSERT(0, myarr[6]); ASSERT(0, myarr[7]); ASSERT(0, myarr[8]); ASSERT(0, myarr[9]); return 0; }chibicc-1.0.23.1/test/issue36.c000077500000000000000000000003571505335450300157570ustar00rootroot00000000000000 #include "test.h" typedef struct empty_struct {} empty_struct; int f(empty_struct a) { return 0; } int main() { f((empty_struct){}); printf("%ld\n", sizeof(empty_struct)); ASSERT(0, sizeof(empty_struct)); return 0; }chibicc-1.0.23.1/test/issue37.c000077500000000000000000000002111505335450300157450ustar00rootroot00000000000000#include "test.h" int main() { int r = ({ int x; goto label; label: x = 42; ASSERT(42, x); x; }); return 0; }chibicc-1.0.23.1/test/issue40.c000077500000000000000000000004161505335450300157460ustar00rootroot00000000000000 #include "test.h" int fun(int n, int a[n]) { int res = 0; for (int i = 0; i < n; i++) res = res + a[i]; return res; }; int main(void) { int a[3] = {1, 2, 3}; int b = fun(3, a); printf("%d %p \n", b, a); ASSERT(6, b); return 0; }chibicc-1.0.23.1/test/issue40a.c000077500000000000000000000003421505335450300161050ustar00rootroot00000000000000 #include "test.h" // fails silently (pointer to VLA) int x = 10; void fun(char (*a)[x]) { sizeof *a; printf("%zu\n", sizeof *a); ASSERT(10, sizeof *a);} int main(void) { char arr[10][20]; fun(arr); return 0; }chibicc-1.0.23.1/test/issue40b.c000077500000000000000000000005141505335450300161070ustar00rootroot00000000000000 #include "test.h" int fun( int n, int a[n]) { int res = 0; for (int i = 0; i < n; i++) res = res + a[i]; return res; }; int main(void) { int c = 3; int a[c]; for (int i = 0; i < c; i++) a[i] = i + 1; int b = fun(c, a); printf("%d %d \n", b, a[0]); ASSERT(6, b); return 0; }chibicc-1.0.23.1/test/issue45.c000077500000000000000000000001521505335450300157500ustar00rootroot00000000000000struct S { union { int A; }; }; int main(void) { (struct S){.A = 0}; return 0; }chibicc-1.0.23.1/test/issue47.c000077500000000000000000000002241505335450300157520ustar00rootroot00000000000000#include "test.h" // a.c struct S { int n; }; int main(void) { printf("%d\n", (struct S){1}.n); ASSERT(1, (struct S){1}.n); return 0; }chibicc-1.0.23.1/test/issue59.c000077500000000000000000000002631505335450300157600ustar00rootroot00000000000000#include "test.h" typedef int MyInt, MyInt2[4]; enum MyEnum { ENUM_TEST }; typedef enum MyEnum MyEnum; int main() { printf("OK\n"); ASSERT(0, ENUM_TEST); return 0; }chibicc-1.0.23.1/test/issue62.c000077500000000000000000000004611505335450300157520ustar00rootroot00000000000000 #include "test.h" struct s { struct { int i; int j; } t; int k; }; int main() { struct s x = {.t.i = 1, .k = 2}; //int x[2][3]={1,2,3,4,5,6,[0][1]=7,8,[0]=9,[0]=10,11,[1][0]=12}; //printf("%d\n", x[0][2]); printf("%d %d %d\n", x.t.i, x.t.j, x.k); ASSERT(2, x.k); return 0; }chibicc-1.0.23.1/test/issue63.c000077500000000000000000000000621505335450300157500ustar00rootroot00000000000000int f(int(int)); int main(void) { return 0; }chibicc-1.0.23.1/test/issue65.c000077500000000000000000000002141505335450300157510ustar00rootroot00000000000000#include "test.h" struct S { unsigned long long int b:32; } s; void f() { s.b = 10; ASSERT(10, s.b); } int main() { return 0; }chibicc-1.0.23.1/test/issue69.c000077500000000000000000000002111505335450300157520ustar00rootroot00000000000000 #include "test.h" long double x = 0; int main(void) { printf("%Lf %ld\n", x, sizeof(x)); ASSERT(16, sizeof(x)); return 0; }chibicc-1.0.23.1/test/issue71.c000077500000000000000000000001301505335450300157430ustar00rootroot00000000000000_Atomic long double b; void bug(void) { b += 3; } int main(void) { return 0; }chibicc-1.0.23.1/test/issue80.c000077500000000000000000000002131505335450300157450ustar00rootroot00000000000000 #include "test.h" const char str[] = {"foo"}; int main() { printf("%d\n", sizeof(str) ); ASSERT(4, sizeof(str)); return 0; }chibicc-1.0.23.1/test/issue94.c000066400000000000000000000001441505335450300157520ustar00rootroot00000000000000 #include "test.h" #if !1u - 1 > 0 #error #endif int main() { printf("OK\n"); return 0; }chibicc-1.0.23.1/test/issue96.c000077500000000000000000000001261505335450300157570ustar00rootroot00000000000000#if (-(0x7fffffffffffffffLL) - 1) / -1 #endif int x; int main(void) { return 0; }chibicc-1.0.23.1/test/issue_asm_multiline.c000077500000000000000000000003211505335450300205170ustar00rootroot00000000000000 #include "test.h" int main(void) { int a = 10, b = 0; asm ("movl %eax, %ebx\n\t" "add $10, %ebx\n\t" ); printf("a=%d, b=%d\n", a, b); ASSERT(10, a); ASSERT(0, b); return 0; }chibicc-1.0.23.1/test/issue_cmake.c000066400000000000000000000002551505335450300167400ustar00rootroot00000000000000 #if defined(__CLASSIC_C__) int main(argc, argv) int argc; char* argv[]; #else int main(int argc, char* argv[]) #endif { (void)argv; return argc-1;}chibicc-1.0.23.1/test/issue_extended_asm.c000077500000000000000000000003571505335450300203260ustar00rootroot00000000000000 #include "test.h" int main(void) { int a = 10, b = 21; asm ("add %1, %0\n\t" : "+r" (a) : "r" (b) : "cc" ); printf("%d\n", a); printf("%d\n", b); ASSERT(31, a); ASSERT(21, b); return 0; }chibicc-1.0.23.1/test/issue_vlcasm2.c000066400000000000000000000002571505335450300172310ustar00rootroot00000000000000#include "test.h" int foo (int *dstp) { asm volatile ( "movntdq %%xmm1, 0(%[dst])" : : [dst] "r"(dstp) : "memory" ); } int main() { printf("OK\n"); return 0; }chibicc-1.0.23.1/test/issue_vlcparse.c000066400000000000000000000006201505335450300174730ustar00rootroot00000000000000//#include "sd-id128.h" #include #include #include typedef union sd_id128 sd_id128_t; union sd_id128 { uint8_t bytes[16]; uint64_t qwords[2]; }; int sd_id128_in_setv2(sd_id128_t a, va_list ap) { for (;;) { sd_id128_t b = va_arg(ap, sd_id128_t); } return 0; } int main() { return 0; }chibicc-1.0.23.1/test/issuephp.c000066400000000000000000000026011505335450300163050ustar00rootroot00000000000000#include "test.h" #include #include bool multiply_with_overflow(uint32_t a, uint32_t b, uint32_t *result) { uint32_t res, m_overflow; // Use GCC inline assembly to do: res = a * b, with overflow in m_overflow asm volatile ( "mull %3" // Multiply EAX by operand %3 → result in EDX:EAX : "=&a"(res), "=&d"(m_overflow) // outputs: EAX → res, EDX → m_overflow : "a"(a), "rm"(b) // inputs: a in EAX, b in reg/mem ); *result = res; return m_overflow != 0; } int main(void) { uint32_t a = 0xFFFFFFFF; uint32_t b = 2; uint32_t res; bool overflow = multiply_with_overflow(a, b, &res); printf("Result: %u (0x%08x)\n", res, res); printf("Overflow: %s\n", overflow ? "Yes" : "No"); ASSERT(1, overflow); ASSERT(0xfffffffe, res); uint32_t nmemb = 0xFFFFFFFE; uint32_t size = 2; uint32_t offset = 1; uint32_t resm = nmemb; uint32_t m_overflow; __asm__ volatile ( "mull %3\n\t" "add %4, %0\n\t" "adc $0, %1" : "=&a"(resm), "=&d"(m_overflow) : "%0"(resm), "rm"(size), "rm"(offset) : "cc" ); printf("Result: %u (0x%08x)\n", resm, resm); printf("Overflow: %u\n", m_overflow); ASSERT(1, m_overflow); ASSERT(0xfffffffd, resm); return 0; }chibicc-1.0.23.1/test/issuephp2.c000066400000000000000000000007201505335450300163670ustar00rootroot00000000000000#include "test.h" asm(".pushsection \".test_section\", \"a\"\n" ".ascii \"hello world\\n\"\n" ".popsection\n"); asm(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n" ".byte 4\n" ".ascii \"gdb.inlined-script\\n\"\n" ".ascii \"gdb.execute('''\\n\"\n" ".ascii \"define set_ts\\n\"\n" ".ascii \" return orig_value\\n\"\n" ".byte 0\n" ".popsection\n" ); int main() { printf("OK\n"); return 0; }chibicc-1.0.23.1/test/issuephp3.c000066400000000000000000000004421505335450300163710ustar00rootroot00000000000000#include "test.h" int main(void) { unsigned int eax, edx; __asm__ __volatile__ ( ".byte 0x0f, 0x01, 0xd0" // xgetbv : "=a"(eax), "=d"(edx) : "c"(0) ); printf("xgetbv eax: %08x edx: %08x\n", eax, edx); ASSERT(7, eax); ASSERT(0, edx); return 0; }chibicc-1.0.23.1/test/issuephp4.c000066400000000000000000000015731505335450300164000ustar00rootroot00000000000000#include "test.h" #include #include #include int test(const char *ptr, size_t len, uintptr_t delta) { unsigned long ret; __asm__ ( "0:\n\t" "movq (%2,%3), %0\n\t" "xorq (%2), %0\n\t" "jne 1f\n\t" "addq $0x8, %2\n\t" "subq $0x8, %1\n\t" "ja 0b\n\t" "movq $0x1, %0\n\t" "jmp 3f\n\t" "1:\n\t" "cmpq $0x8,%1\n\t" "jb 2f\n\t" "xorq %0, %0\n\t" "jmp 3f\n\t" "2:\n\t" "negq %1\n\t" "lea 0x40(,%1,8), %1\n\t" "shlq %b1, %0\n\t" "sete %b0\n\t" "movzbq %b0, %0\n\t" "3:\n" : "=&a"(ret), "+c"(len), "+r"(ptr) : "r"(delta) : "cc"); return ret; } int main() { uint8_t data[8] = {0, 0, 0, 0, 0, 0, 0, 0}; int delta = 0; int len = 4; int result = test(data, len, delta); printf("Result: %d\n", result); ASSERT(1, result); return 0; }chibicc-1.0.23.1/test/items.h000066400000000000000000000060231505335450300155750ustar00rootroot00000000000000#define HOT_LRU 0 #define WARM_LRU 64 #define COLD_LRU 128 #define TEMP_LRU 192 #define CLEAR_LRU(id) (id & ~(3<<6)) #define GET_LRU(id) (id & (3<<6)) /* See items.c */ uint64_t get_cas_id(void); void set_cas_id(uint64_t new_cas); /*@null@*/ item *do_item_alloc(const char *key, const size_t nkey, const unsigned int flags, const rel_time_t exptime, const int nbytes); item_chunk *do_item_alloc_chunk(item_chunk *ch, const size_t bytes_remain); item *do_item_alloc_pull(const size_t ntotal, const unsigned int id); void item_free(item *it); bool item_size_ok(const size_t nkey, const int flags, const int nbytes); int do_item_link(item *it, const uint32_t hv); /** may fail if transgresses limits */ void do_item_unlink(item *it, const uint32_t hv); void do_item_unlink_nolock(item *it, const uint32_t hv); void do_item_remove(item *it); void do_item_update(item *it); /** update LRU time to current and reposition */ void do_item_update_nolock(item *it); int do_item_replace(item *it, item *new_it, const uint32_t hv); void do_item_link_fixup(item *it); int item_is_flushed(item *it); unsigned int do_get_lru_size(uint32_t id); void do_item_linktail_q(item *it); void do_item_unlinktail_q(item *it); item *do_item_crawl_q(item *it); void *item_lru_bump_buf_create(void); #define LRU_PULL_EVICT 1 #define LRU_PULL_CRAWL_BLOCKS 2 #define LRU_PULL_RETURN_ITEM 4 /* fill info struct if available */ struct lru_pull_tail_return { item *it; uint32_t hv; }; int lru_pull_tail(const int orig_id, const int cur_lru, const uint64_t total_bytes, const uint8_t flags, const rel_time_t max_age, struct lru_pull_tail_return *ret_it); /*@null@*/ char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes); void item_stats(ADD_STAT add_stats, void *c); void do_item_stats_add_crawl(const int i, const uint64_t reclaimed, const uint64_t unfetched, const uint64_t checked); void item_stats_totals(ADD_STAT add_stats, void *c); /*@null@*/ void item_stats_sizes(ADD_STAT add_stats, void *c); void item_stats_sizes_init(void); void item_stats_sizes_enable(ADD_STAT add_stats, void *c); void item_stats_sizes_disable(ADD_STAT add_stats, void *c); void item_stats_sizes_add(item *it); void item_stats_sizes_remove(item *it); bool item_stats_sizes_status(void); /* stats getter for slab automover */ typedef struct { int64_t evicted; int64_t outofmemory; uint32_t age; } item_stats_automove; void fill_item_stats_automove(item_stats_automove *am); item *do_item_get(const char *key, const size_t nkey, const uint32_t hv, LIBEVENT_THREAD *t, const bool do_update); item *do_item_touch(const char *key, const size_t nkey, uint32_t exptime, const uint32_t hv, LIBEVENT_THREAD *t); void do_item_bump(LIBEVENT_THREAD *t, item *it, const uint32_t hv); void item_stats_reset(void); extern pthread_mutex_t lru_locks[POWER_LARGEST]; int start_lru_maintainer_thread(void *arg); int stop_lru_maintainer_thread(void); void lru_maintainer_pause(void); void lru_maintainer_resume(void); void *lru_bump_buf_create(void); chibicc-1.0.23.1/test/itoa_ljust.h000066400000000000000000000014661505335450300166370ustar00rootroot00000000000000#ifndef ITOA_LJUST_H #define ITOA_LJUST_H //=== itoa_ljust.h - Fast integer to ascii conversion // // Fast and simple integer to ASCII conversion: // // - 32 and 64-bit integers // - signed and unsigned // - user supplied buffer must be large enough for all decimal digits // in value plus minus sign if negative // - left-justified // - NUL terminated // - return value is pointer to NUL terminator // // Copyright (c) 2016 Arturo Martin-de-Nicolas // arturomdn@gmail.com // https://github.com/amdn/itoa_ljust/ //===----------------------------------------------------------------------===// #include char* itoa_u32(uint32_t u, char* buffer); char* itoa_32( int32_t i, char* buffer); char* itoa_u64(uint64_t u, char* buffer); char* itoa_64( int64_t i, char* buffer); #endif // ITOA_LJUST_H chibicc-1.0.23.1/test/limits.c000066400000000000000000000004561505335450300157540ustar00rootroot00000000000000 #include #include "test.h" int main() { printf("INT_MAX: %d\n", INT_MAX); printf("INT_MIN: %d\n", INT_MIN); printf("LONG_MAX: %ld\n", LONG_MAX); ASSERT(2147483647, INT_MAX); ASSERT(-2147483648, INT_MIN); ASSERT(9223372036854775807L, LONG_MAX); return 0; } chibicc-1.0.23.1/test/line.c000077500000000000000000000006461505335450300154060ustar00rootroot00000000000000#include "test.h" int main() { #line 500 "foo" ASSERT(500, __LINE__); ASSERT(0, strcmp(__FILE__, "foo")); #line 400 "test.h" ASSERT(400, __LINE__); ASSERT(0, strcmp(__FILE__, "test.h")); #line 800 "bar" ASSERT(800, __LINE__); ASSERT(0, strcmp(__FILE__, "bar")); #line 1 ASSERT(1, __LINE__); # 200 "xyz" 2 3 ASSERT(200, __LINE__); ASSERT(0, strcmp(__FILE__, "xyz")); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/literal.c000077500000000000000000000046741505335450300161200ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(97, 'a'); ASSERT(10, '\n'); ASSERT(-128, '\x80'); ASSERT(511, 0777); ASSERT(0, 0x0); ASSERT(10, 0xa); ASSERT(10, 0XA); ASSERT(48879, 0xbeef); ASSERT(48879, 0xBEEF); ASSERT(48879, 0XBEEF); ASSERT(0, 0b0); ASSERT(1, 0b1); ASSERT(47, 0b101111); ASSERT(47, 0B101111); ASSERT(4, sizeof(0)); ASSERT(8, sizeof(0L)); ASSERT(8, sizeof(0LU)); ASSERT(8, sizeof(0UL)); ASSERT(8, sizeof(0LL)); ASSERT(8, sizeof(0LLU)); ASSERT(8, sizeof(0Ull)); ASSERT(8, sizeof(0l)); ASSERT(8, sizeof(0ll)); ASSERT(8, sizeof(0x0L)); ASSERT(8, sizeof(0b0L)); ASSERT(4, sizeof(2147483647)); ASSERT(8, sizeof(2147483648)); ASSERT(-1, 0xffffffffffffffff); ASSERT(8, sizeof(0xffffffffffffffff)); ASSERT(4, sizeof(4294967295U)); ASSERT(8, sizeof(4294967296U)); ASSERT(3, -1U>>30); ASSERT(3, -1Ul>>62); ASSERT(3, -1ull>>62); ASSERT(1, 0xffffffffffffffffl>>63); ASSERT(1, 0xffffffffffffffffll>>63); ASSERT(-1, 18446744073709551615); ASSERT(8, sizeof(18446744073709551615)); ASSERT(-1, 18446744073709551615>>63); ASSERT(-1, 0xffffffffffffffff); ASSERT(8, sizeof(0xffffffffffffffff)); ASSERT(1, 0xffffffffffffffff>>63); ASSERT(-1, 01777777777777777777777); ASSERT(8, sizeof(01777777777777777777777)); ASSERT(1, 01777777777777777777777>>63); ASSERT(-1, 0b1111111111111111111111111111111111111111111111111111111111111111); ASSERT(8, sizeof(0b1111111111111111111111111111111111111111111111111111111111111111)); ASSERT(1, 0b1111111111111111111111111111111111111111111111111111111111111111>>63); ASSERT(8, sizeof(2147483648)); ASSERT(4, sizeof(2147483647)); ASSERT(8, sizeof(0x1ffffffff)); ASSERT(4, sizeof(0xffffffff)); ASSERT(1, 0xffffffff>>31); ASSERT(8, sizeof(040000000000)); ASSERT(4, sizeof(037777777777)); ASSERT(1, 037777777777>>31); ASSERT(8, sizeof(0b111111111111111111111111111111111)); ASSERT(4, sizeof(0b11111111111111111111111111111111)); ASSERT(1, 0b11111111111111111111111111111111>>31); ASSERT(-1, 1 << 31 >> 31); ASSERT(-1, 01 << 31 >> 31); ASSERT(-1, 0x1 << 31 >> 31); ASSERT(-1, 0b1 << 31 >> 31); 0.0; 1.0; 3e+8; 0x10.1p0; .1E4f; ASSERT(4, sizeof(8f)); ASSERT(4, sizeof(0.3F)); ASSERT(8, sizeof(0.)); ASSERT(8, sizeof(.0)); ASSERT(16, sizeof(5.l)); ASSERT(16, sizeof(2.0L)); assert(1, size\ of(char), \ "sizeof(char)"); ASSERT(4, sizeof(L'\0')); ASSERT(97, L'a'); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/logger.h000066400000000000000000000141511505335450300157340ustar00rootroot00000000000000/* logging functions */ #ifndef LOGGER_H #define LOGGER_H #include "bipbuffer.h" /* TODO: starttime tunable */ #define LOGGER_BUF_SIZE 1024 * 64 #define LOGGER_WATCHER_BUF_SIZE 1024 * 256 #define LOGGER_ENTRY_MAX_SIZE 2048 #define GET_LOGGER() ((logger *) pthread_getspecific(logger_key)); /* Inlined from memcached.h - should go into sub header */ typedef unsigned int rel_time_t; enum log_entry_type { LOGGER_ASCII_CMD = 0, LOGGER_EVICTION, LOGGER_ITEM_GET, LOGGER_ITEM_STORE, LOGGER_CRAWLER_STATUS, LOGGER_SLAB_MOVE, LOGGER_CONNECTION_NEW, LOGGER_CONNECTION_CLOSE, LOGGER_DELETIONS, #ifdef EXTSTORE LOGGER_EXTSTORE_WRITE, LOGGER_COMPACT_START, LOGGER_COMPACT_ABORT, LOGGER_COMPACT_READ_START, LOGGER_COMPACT_READ_END, LOGGER_COMPACT_END, LOGGER_COMPACT_FRAGINFO, #endif #ifdef PROXY LOGGER_PROXY_CONFIG, LOGGER_PROXY_RAW, LOGGER_PROXY_ERROR, LOGGER_PROXY_USER, LOGGER_PROXY_REQ, LOGGER_PROXY_BE_ERROR, #endif }; enum logger_ret_type { LOGGER_RET_OK = 0, LOGGER_RET_NOSPACE, LOGGER_RET_ERR }; enum logger_parse_entry_ret { LOGGER_PARSE_ENTRY_OK = 0, LOGGER_PARSE_ENTRY_FULLBUF, LOGGER_PARSE_ENTRY_FAILED }; typedef struct _logentry logentry; typedef struct _entry_details entry_details; typedef void (*entry_log_cb)(logentry *e, const entry_details *d, const void *entry, va_list ap); typedef int (*entry_parse_cb)(logentry *e, char *scratch); struct _entry_details { int reqlen; uint16_t eflags; entry_log_cb log_cb; entry_parse_cb parse_cb; char *format; }; /* log entry intermediary structures */ struct logentry_eviction { long long int exptime; int nbytes; uint32_t latime; uint16_t it_flags; uint8_t nkey; uint8_t clsid; char key[]; }; #ifdef EXTSTORE struct logentry_ext_write { long long int exptime; uint32_t latime; uint16_t it_flags; uint8_t nkey; uint8_t clsid; uint8_t bucket; char key[]; }; #endif struct logentry_item_get { uint8_t was_found; uint8_t nkey; uint8_t clsid; int nbytes; int sfd; char key[]; }; struct logentry_item_store { int status; int cmd; rel_time_t ttl; uint8_t nkey; uint8_t clsid; int nbytes; int sfd; char key[]; }; struct logentry_deletion { int nbytes; int cmd; uint8_t nkey; uint8_t clsid; char key[]; }; struct logentry_conn_event { int transport; int reason; int sfd; struct sockaddr_in6 addr; }; #ifdef PROXY struct logentry_proxy_req { unsigned short type; unsigned short code; int status; uint32_t reqlen; size_t dlen; size_t be_namelen; size_t be_portlen; long elapsed; char data[]; }; struct logentry_proxy_errbe { size_t errlen; size_t be_namelen; size_t be_portlen; size_t be_rbuflen; int be_depth; char data[]; }; #endif /* end intermediary structures */ /* WARNING: cuddled items aren't compatible with warm restart. more code * necessary to ensure log streams are all flushed/processed before stopping */ struct _logentry { enum log_entry_type event; uint8_t pad; uint16_t eflags; uint64_t gid; struct timeval tv; /* not monotonic! */ int size; union { char end; } data[]; }; #define LOG_SYSEVENTS (1<<1) /* threads start/stop/working */ #define LOG_FETCHERS (1<<2) /* get/gets/etc */ #define LOG_MUTATIONS (1<<3) /* set/append/incr/etc */ #define LOG_SYSERRORS (1<<4) /* malloc/etc errors */ #define LOG_CONNEVENTS (1<<5) /* new client, closed, etc */ #define LOG_EVICTIONS (1<<6) /* details of evicted items */ #define LOG_STRICT (1<<7) /* block worker instead of drop */ #define LOG_RAWCMDS (1<<9) /* raw ascii commands */ #define LOG_PROXYREQS (1<<10) /* command logs from proxy */ #define LOG_PROXYEVENTS (1<<11) /* error log stream from proxy */ #define LOG_PROXYUSER (1<<12) /* user generated logs from proxy */ #define LOG_DELETIONS (1<<13) /* see whats deleted */ typedef struct _logger { struct _logger *prev; struct _logger *next; pthread_mutex_t mutex; /* guard for this + *buf */ uint64_t written; /* entries written to the buffer */ uint64_t dropped; /* entries dropped */ uint64_t blocked; /* times blocked instead of dropped */ uint16_t fetcher_ratio; /* log one out of every N fetches */ uint16_t mutation_ratio; /* log one out of every N mutations */ uint16_t eflags; /* flags this logger should log */ bipbuf_t *buf; const entry_details *entry_map; } logger; enum logger_watcher_type { LOGGER_WATCHER_STDERR = 0, LOGGER_WATCHER_CLIENT = 1 }; typedef struct { void *c; /* original connection structure. still with source thread attached */ int sfd; /* client fd */ int id; /* id number for watcher list */ uint64_t skipped; /* lines skipped since last successful print */ uint64_t min_gid; /* don't show log entries older than this GID */ bool failed_flush; /* recently failed to write out (EAGAIN), wait before retry */ enum logger_watcher_type t; /* stderr, client, syslog, etc */ uint16_t eflags; /* flags we are interested in */ bipbuf_t *buf; /* per-watcher output buffer */ } logger_watcher; struct logger_stats { uint64_t worker_dropped; uint64_t worker_written; uint64_t watcher_skipped; uint64_t watcher_sent; uint64_t watcher_count; }; extern pthread_key_t logger_key; /* public functions */ void logger_init(void); void logger_stop(void); logger *logger_create(void); #define LOGGER_LOG(l, flag, type, ...) \ do { \ logger *myl = l; \ if (l == NULL) \ myl = GET_LOGGER(); \ if (myl->eflags & flag) \ logger_log(myl, type, __VA_ARGS__); \ } while (0) enum logger_ret_type logger_log(logger *l, const enum log_entry_type event, const void *entry, ...); enum logger_add_watcher_ret { LOGGER_ADD_WATCHER_TOO_MANY = 0, LOGGER_ADD_WATCHER_OK, LOGGER_ADD_WATCHER_FAILED }; enum logger_add_watcher_ret logger_add_watcher(void *c, const int sfd, uint16_t f); /* functions used by restart system */ uint64_t logger_get_gid(void); void logger_set_gid(uint64_t gid); #endif chibicc-1.0.23.1/test/lscpu.c000066400000000000000000000011621505335450300155740ustar00rootroot00000000000000 #include #include "test.h" void test_variadic(const char *fmt, ...) { va_list ap; va_start(ap, fmt); // Assume you expect two ints: cores_per_socket and sockets int cores_per_socket = va_arg(ap, int); ASSERT(2, cores_per_socket); int sockets = va_arg(ap, int); ASSERT(1, sockets); va_end(ap); printf("Read cores_per_socket = %d\n", cores_per_socket); printf("Read sockets = %d\n", sockets); } int main() { int cores = 2; int sockets = 1; printf("Passing cores=%d, sockets=%d\n", cores, sockets); test_variadic("%d%d", cores, sockets); return 0; } chibicc-1.0.23.1/test/lscpu2.c000066400000000000000000000032411505335450300156560ustar00rootroot00000000000000 #include "test.h" #if defined(__x86_64__) || defined(__i386__) #define HYPERVISOR_INFO_LEAF 0x40000000 static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { __asm__( #if defined(__PIC__) && defined(__i386__) /* x86 PIC cannot clobber ebx -- gcc bitches */ "xchg %%ebx, %%esi;" "cpuid;" "xchg %%esi, %%ebx;" : "=S" (*ebx), #else "cpuid;" : "=b" (*ebx), #endif "=a" (*eax), "=c" (*ecx), "=d" (*edx) : "1" (op), "c"(0)); } int main(void) { unsigned int eax, ebx, ecx, edx; cpuid(HYPERVISOR_INFO_LEAF, &eax, &ebx, &ecx, &edx); // Print max supported leaf printf("CPUID 0x%08X: max supported leaf = 0x%08X\n", HYPERVISOR_INFO_LEAF, eax); ASSERT(1073741835, eax); // Vendor ID string is EBX, ECX, EDX concatenated as ASCII char vendor[13]; vendor[0] = (char)(ebx & 0xFF); vendor[1] = (char)((ebx >> 8) & 0xFF); vendor[2] = (char)((ebx >> 16) & 0xFF); vendor[3] = (char)((ebx >> 24) & 0xFF); vendor[4] = (char)(ecx & 0xFF); vendor[5] = (char)((ecx >> 8) & 0xFF); vendor[6] = (char)((ecx >> 16) & 0xFF); vendor[7] = (char)((ecx >> 24) & 0xFF); vendor[8] = (char)(edx & 0xFF); vendor[9] = (char)((edx >> 8) & 0xFF); vendor[10] = (char)((edx >> 16) & 0xFF); vendor[11] = (char)((edx >> 24) & 0xFF); vendor[12] = '\0'; printf("Hypervisor vendor ID: '%s'\n", vendor); return 0; } #else int main(void) { printf("CPUID is only supported on x86/x86_64 architectures.\n"); return 0; } #endif chibicc-1.0.23.1/test/lxc1.c000066400000000000000000000013241505335450300153150ustar00rootroot00000000000000 #include #include "test.h" /* Container's specific file/directory names */ #define LXC_CONFIG_FNAME "config" #define LXC_PARTIAL_FNAME "partial" #define LXC_ROOTFS_DNAME "rootfs" #define LXC_TIMESTAMP_FNAME "ts" #define LXC_COMMENT_FNAME "comment" #define ARRAY_SIZE(x) \ (__builtin_choose_expr(!__builtin_types_compatible_p(typeof(x), \ typeof(&*(x))), \ sizeof(x) / sizeof((x)[0]), ((void)0))) int main(int argc, char *argv[]) { int std_fds[] = {STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO}; printf("ARRAY_SIZE(std_fds) = %ld\n", ARRAY_SIZE(std_fds)); ASSERT(3, ARRAY_SIZE(std_fds)); return 0; }chibicc-1.0.23.1/test/macro.c000077500000000000000000000150221505335450300155520ustar00rootroot00000000000000#include "test.h" #include "include1.h" char *main_filename1 = __FILE__; int main_line1 = __LINE__; #define LINE() __LINE__ int main_line2 = LINE(); # /* */ # int ret3(void) { return 3; } int dbl(int x) { return x*x; } int add2(int x, int y) { return x + y; } int add6(int a, int b, int c, int d, int e, int f) { return a + b + c + d + e + f; } int main() { ASSERT(5, include1); ASSERT(7, include2); #if 0 #include "/no/such/file" ASSERT(0, 1); #if nested #endif #endif int m = 0; #if 1 m = 5; #endif ASSERT(5, m); #if 1 # if 0 # if 1 foo bar # endif # endif m = 3; #endif ASSERT(3, m); #if 1-1 # if 1 # endif # if 1 # else # endif # if 0 # else # endif m = 2; #else # if 1 m = 3; # endif #endif ASSERT(3, m); #if 1 m = 2; #else m = 3; #endif ASSERT(2, m); #if 1 m = 2; #else m = 3; #endif ASSERT(2, m); #if 0 m = 1; #elif 0 m = 2; #elif 3+5 m = 3; #elif 1*5 m = 4; #endif ASSERT(3, m); #if 1+5 m = 1; #elif 1 m = 2; #elif 3 m = 2; #endif ASSERT(1, m); #if 0 m = 1; #elif 1 # if 1 m = 2; # else m = 3; # endif #else m = 5; #endif ASSERT(2, m); int M1 = 5; #define M1 3 ASSERT(3, M1); #define M1 4 ASSERT(4, M1); #define M1 3+4+ ASSERT(12, M1 5); #define M1 3+4 ASSERT(23, M1*5); #define ASSERT_ assert( #define if 5 #define five "5" #define END ) ASSERT_ 5, if, five END; #undef ASSERT_ #undef if #undef five #undef END if (0); #define M 5 #if M m = 5; #else m = 6; #endif ASSERT(5, m); #define M 5 #if M-5 m = 6; #elif M m = 5; #endif ASSERT(5, m); int M2 = 6; #define M2 M2 + 3 ASSERT(9, M2); #define M3 M2 + 3 ASSERT(12, M3); int M4 = 3; #define M4 M5 * 5 #define M5 M4 + 2 ASSERT(13, M4); #ifdef M6 m = 5; #else m = 3; #endif ASSERT(3, m); #define M6 #ifdef M6 m = 5; #else m = 3; #endif ASSERT(5, m); #ifndef M7 m = 3; #else m = 5; #endif ASSERT(3, m); #define M7 #ifndef M7 m = 3; #else m = 5; #endif ASSERT(5, m); #if 0 #ifdef NO_SUCH_MACRO #endif #ifndef NO_SUCH_MACRO #endif #else #endif #define M7() 1 int M7 = 5; ASSERT(1, M7()); ASSERT(5, M7); #define M7 () ASSERT(3, ret3 M7); #define M8(x,y) x+y ASSERT(7, M8(3, 4)); #define M8(x,y) x*y ASSERT(24, M8(3+4, 4+5)); #define M8(x,y) (x)*(y) ASSERT(63, M8(3+4, 4+5)); #define M8(x,y) x y ASSERT(9, M8(, 4+5)); #define M8(x,y) x*y ASSERT(20, M8((2+3), 4)); #define M8(x,y) x*y ASSERT(12, M8((2,3), 4)); #define dbl(x) M10(x) * x #define M10(x) dbl(x) + 3 ASSERT(10, dbl(2)); #define M11(x) #x ASSERT('a', M11( a!b `""c)[0]); ASSERT('!', M11( a!b `""c)[1]); ASSERT('b', M11( a!b `""c)[2]); ASSERT(' ', M11( a!b `""c)[3]); ASSERT('`', M11( a!b `""c)[4]); ASSERT('"', M11( a!b `""c)[5]); ASSERT('"', M11( a!b `""c)[6]); ASSERT('c', M11( a!b `""c)[7]); ASSERT(0, M11( a!b `""c)[8]); #define paste(x,y) x##y ASSERT(15, paste(1,5)); ASSERT(255, paste(0,xff)); ASSERT(3, ({ int foobar=3; paste(foo,bar); })); ASSERT(5, paste(5,)); ASSERT(5, paste(,5)); #define i 5 ASSERT(101, ({ int i3=100; paste(1+i,3); })); #undef i #define paste2(x) x##5 ASSERT(26, paste2(1+2)); #define paste3(x) 2##x ASSERT(23, paste3(1+2)); #define paste4(x, y, z) x##y##z ASSERT(123, paste4(1,2,3)); #define M12 #if defined(M12) m = 3; #else m = 4; #endif ASSERT(3, m); #define M12 #if defined M12 m = 3; #else m = 4; #endif ASSERT(3, m); #if defined(M12) - 1 m = 3; #else m = 4; #endif ASSERT(4, m); #if defined(NO_SUCH_MACRO) m = 3; #else m = 4; #endif ASSERT(4, m); #if no_such_symbol == 0 m = 5; #else m = 6; #endif ASSERT(5, m); #define STR(x) #x #define M12(x) STR(x) #define M13(x) M12(foo.x) ASSERT(0, strcmp(M13(bar), "foo.bar")); #define M13(x) M12(foo. x) ASSERT(0, strcmp(M13(bar), "foo. bar")); #define M12 foo #define M13(x) STR(x) #define M14(x) M13(x.M12) ASSERT(0, strcmp(M14(bar), "bar.foo")); #define M14(x) M13(x. M12) ASSERT(0, strcmp(M14(bar), "bar. foo")); #include "include3.h" ASSERT(3, foo); #include "include4.h" ASSERT(4, foo); #define M13 "include3.h" #include M13 ASSERT(3, foo); #define M13 < include4.h #include M13 > ASSERT(4, foo); #undef foo ASSERT(1, __STDC__); ASSERT(0, strcmp(main_filename1, "test/macro.c")); ASSERT(5, main_line1); ASSERT(7, main_line2); ASSERT(0, strcmp(include1_filename, "test/include1.h")); ASSERT(4, include1_line); #define M14(...) 3 ASSERT(3, M14()); #define M14(...) __VA_ARGS__ ASSERT(2, M14() 2); ASSERT(5, M14(5)); #define M14(...) add2(__VA_ARGS__) ASSERT(8, M14(2, 6)); #define M14(...) add6(1,2,__VA_ARGS__,6) ASSERT(21, M14(3,4,5)); #define M14(x, ...) add6(1,2,x,__VA_ARGS__,6) ASSERT(21, M14(3,4,5)); #define M14(args...) 3 ASSERT(3, M14()); #define M14(x, ...) x ASSERT(5, M14(5)); #define M14(args...) args ASSERT(2, M14() 2); ASSERT(5, M14(5)); #define M14(args...) add2(args) ASSERT(8, M14(2, 6)); #define M14(args...) add6(1,2,args,6) ASSERT(21, M14(3,4,5)); #define M14(x, args...) add6(1,2,x,args,6) ASSERT(21, M14(3,4,5)); #define M14(x, args...) x ASSERT(5, M14(5)); #define CONCAT(x,y) x##y ASSERT(5, ({ int f0zz=5; CONCAT(f,0zz); })); ASSERT(5, ({ CONCAT(4,.57) + 0.5; })); ASSERT(11, strlen(__DATE__)); ASSERT(8, strlen(__TIME__)); ASSERT(0, __COUNTER__); ASSERT(1, __COUNTER__); ASSERT(2, __COUNTER__); ASSERT(24, strlen(__TIMESTAMP__)); ASSERT(0, strcmp(__BASE_FILE__, "test/macro.c")); #define M30(buf, fmt, ...) sprintf(buf, fmt __VA_OPT__(,) __VA_ARGS__) ASSERT(0, ({ char buf[100]; M30(buf, "foo"); strcmp(buf, "foo"); })); ASSERT(0, ({ char buf[100]; M30(buf, "foo%d", 3); strcmp(buf, "foo3"); })); ASSERT(0, ({ char buf[100]; M30(buf, "foo%d%d", 3, 5); strcmp(buf, "foo35"); })); #define M31(buf, fmt, ...) sprintf(buf, fmt, ## __VA_ARGS__) ASSERT(0, ({ char buf[100]; M31(buf, "foo"); strcmp(buf, "foo"); })); ASSERT(0, ({ char buf[100]; M31(buf, "foo%d", 3); strcmp(buf, "foo3"); })); ASSERT(0, ({ char buf[100]; M31(buf, "foo%d%d", 3, 5); strcmp(buf, "foo35"); })); #define M31(x, y) (1, ##x y) ASSERT(3, M31(, 3)); #define M32 3 ## 4 ## 5 ASSERT(345, M32); #define M33(...) # \ __VA_ARGS__ #define M34(x, ...) # \ __VA_ARGS__ ASSERT(0, strcmp(M33(1,2,3,4), "1,2,3,4")); ASSERT(0, strcmp(M34(1,2,3,4), "2,3,4")); #define M35(x, y, z) x ## y ## z ASSERT(123, M35(1,2,3)); ASSERT(45, M35(,4,5)); ASSERT(67, M35(6,,7)); ASSERT(89, M35(8,9,)); ASSERT(10, M35(10,,)); ASSERT(11, M35(,11,)); ASSERT(12, M35(,,12)); #define M36 - int p = 2; int q = p M36-p; ASSERT(4, q); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/memcached.h000066400000000000000000001152641505335450300163720ustar00rootroot00000000000000/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /** \file * The main memcached header holding commonly used data * structures and function prototypes. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include /* need this to get IOV_MAX on some platforms. */ #ifndef __need_IOV_MAX #define __need_IOV_MAX #endif #include /* FreeBSD 4.x doesn't have IOV_MAX exposed. */ #ifndef IOV_MAX #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__GNU__) || defined(__GNUC__) # define IOV_MAX 1024 /* GNU/Hurd don't set MAXPATHLEN * http://www.gnu.org/software/hurd/hurd/porting/guidelines.html#PATH_MAX_tt_MAX_PATH_tt_MAXPATHL */ #ifndef MAXPATHLEN #define MAXPATHLEN 4096 #endif #endif #endif #if defined(__linux__) # define SOCK_COOKIE_ID SO_MARK #elif defined(__FreeBSD__) # define SOCK_COOKIE_ID SO_USER_COOKIE #elif defined(__OpenBSD__) # define SOCK_COOKIE_ID SO_RTABLE #endif #include "itoa_ljust.h" #include "protocol_binary.h" #include "cache.h" #include "logger.h" #ifdef EXTSTORE #include "crc32c.h" #endif #include "sasl_defs.h" #ifdef TLS #include #endif /* for NAPI pinning feature */ #ifndef SO_INCOMING_NAPI_ID #define SO_INCOMING_NAPI_ID 56 #endif /** Maximum length of a key. */ #define KEY_MAX_LENGTH 250 /** Maximum length of a uri encoded key. */ #define KEY_MAX_URI_ENCODED_LENGTH (KEY_MAX_LENGTH * 3 + 1) /** Size of an incr buf. */ #define INCR_MAX_STORAGE_LEN 24 #define WRITE_BUFFER_SIZE 1024 #define READ_BUFFER_SIZE 16384 #define READ_BUFFER_CACHED 0 #define UDP_READ_BUFFER_SIZE 65536 #define UDP_MAX_PAYLOAD_SIZE 1400 #define UDP_HEADER_SIZE 8 #define UDP_DATA_SIZE 1392 // UDP_MAX_PAYLOAD_SIZE - UDP_HEADER_SIZE #define MAX_SENDBUF_SIZE (256 * 1024 * 1024) /* Binary protocol stuff */ #define BIN_MAX_EXTLEN 20 // length of the _incr command is currently the longest. /* Initial power multiplier for the hash table */ #define HASHPOWER_DEFAULT 16 #define HASHPOWER_MAX 32 /* * We only reposition items in the LRU queue if they haven't been repositioned * in this many seconds. That saves us from churning on frequently-accessed * items. */ #define ITEM_UPDATE_INTERVAL 60 /* * Valid range of the maximum size of an item, in bytes. */ #define ITEM_SIZE_MAX_LOWER_LIMIT 1024 #define ITEM_SIZE_MAX_UPPER_LIMIT 1024 * 1024 * 1024 /* Slab sizing definitions. */ #define POWER_SMALLEST 1 #define POWER_LARGEST 256 /* actual cap is 255 */ #define SLAB_GLOBAL_PAGE_POOL 0 /* magic slab class for storing pages for reassignment */ #define CHUNK_ALIGN_BYTES 8 /* slab class max is a 6-bit number, -1. */ #define MAX_NUMBER_OF_SLAB_CLASSES (63 + 1) /** How long an object can reasonably be assumed to be locked before harvesting it on a low memory condition. Default: disabled. */ #define TAIL_REPAIR_TIME_DEFAULT 0 /* warning: don't use these macros with a function, as it evals its arg twice */ #define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \ (i)->data->cas : (uint64_t)0) #define ITEM_set_cas(i,v) { \ if ((i)->it_flags & ITEM_CAS) { \ (i)->data->cas = v; \ } \ } #define ITEM_key(item) (((char*)&((item)->data)) \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \ + (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 \ + (item)->nbytes \ + (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #define ITEM_clsid(item) ((item)->slabs_clsid & ~(3<<6)) #define ITEM_lruid(item) ((item)->slabs_clsid & (3<<6)) #define STAT_KEY_LEN 128 #define STAT_VAL_LEN 128 /** Append a simple stat with a stat name, value format and value */ #define APPEND_STAT(name, fmt, val) \ append_stat(name, add_stats, c, fmt, val); /** Append an indexed stat with a stat name (with format), value format and value */ #define APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) \ klen = snprintf(key_str, STAT_KEY_LEN, name_fmt, num, name); \ vlen = snprintf(val_str, STAT_VAL_LEN, fmt, val); \ add_stats(key_str, klen, val_str, vlen, c); /** Common APPEND_NUM_FMT_STAT format. */ #define APPEND_NUM_STAT(num, name, fmt, val) \ APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val) /** Item client flag conversion */ #define FLAGS_CONV(it, flag) { \ if ((it)->it_flags & ITEM_CFLAGS) { \ flag = *((uint32_t *)ITEM_suffix((it))); \ } else { \ flag = 0; \ } \ } #define FLAGS_SIZE(item) (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) /** * Callback for any function producing stats. * * @param key the stat's key * @param klen length of the key * @param val the stat's value in an ascii form (e.g. text form of a number) * @param vlen length of the value * @parm cookie magic callback cookie */ typedef void (*ADD_STAT)(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, const void *cookie); /* * NOTE: If you modify this table you _MUST_ update the function state_text */ /** * Possible states of a connection. */ enum conn_states { conn_listening, /**< the socket which listens for connections */ conn_new_cmd, /**< Prepare connection for next command */ conn_waiting, /**< waiting for a readable socket */ conn_read, /**< reading in a command line */ conn_parse_cmd, /**< try to parse a command from the input buffer */ conn_write, /**< writing out a simple response */ conn_nread, /**< reading in a fixed number of bytes */ conn_swallow, /**< swallowing unnecessary bytes w/o storing */ conn_closing, /**< closing this connection */ conn_mwrite, /**< writing out many items sequentially */ conn_closed, /**< connection is closed */ conn_watch, /**< held by the logger thread as a watcher */ conn_io_queue, /**< wait on async. process to get response object */ conn_max_state /**< Max state value (used for assertion) */ }; enum bin_substates { bin_no_state, bin_reading_set_header, bin_reading_cas_header, bin_read_set_value, bin_reading_get_key, bin_reading_stat, bin_reading_del_header, bin_reading_incr_header, bin_read_flush_exptime, bin_reading_sasl_auth, bin_reading_sasl_auth_data, bin_reading_touch_key, }; enum protocol { ascii_prot = 3, /* arbitrary value. */ binary_prot, negotiating_prot, /* Discovering the protocol */ #ifdef PROXY proxy_prot, #endif }; enum network_transport { local_transport, /* Unix sockets*/ tcp_transport, udp_transport }; enum pause_thread_types { PAUSE_WORKER_THREADS = 0, PAUSE_ALL_THREADS, RESUME_ALL_THREADS, RESUME_WORKER_THREADS }; enum stop_reasons { NOT_STOP, GRACE_STOP, EXIT_NORMALLY }; enum close_reasons { ERROR_CLOSE, NORMAL_CLOSE, IDLE_TIMEOUT_CLOSE, SHUTDOWN_CLOSE, }; #define IS_TCP(x) (x == tcp_transport) #define IS_UDP(x) (x == udp_transport) #define NREAD_ADD 1 #define NREAD_SET 2 #define NREAD_REPLACE 3 #define NREAD_APPEND 4 #define NREAD_PREPEND 5 #define NREAD_CAS 6 #define NREAD_APPENDVIV 7 // specific to meta #define NREAD_PREPENDVIV 8 // specific to meta #define CAS_ALLOW_STALE true #define CAS_NO_STALE false #define LOG_TYPE_DELETE 1 #define LOG_TYPE_META_DELETE 2 enum store_item_type { NOT_STORED=0, STORED, EXISTS, NOT_FOUND, TOO_LARGE, NO_MEMORY }; enum delta_result_type { OK, NON_NUMERIC, EOM, DELTA_ITEM_NOT_FOUND, DELTA_ITEM_CAS_MISMATCH }; /** Time relative to server start. Smaller than time_t on 64-bit systems. */ // TODO: Move to sub-header. needed in logger.h //typedef unsigned int rel_time_t; /** Use X macros to avoid iterating over the stats fields during reset and * aggregation. No longer have to add new stats in 3+ places. */ #define SLAB_STATS_FIELDS \ X(set_cmds) \ X(get_hits) \ X(touch_hits) \ X(delete_hits) \ X(cas_hits) \ X(cas_badval) \ X(incr_hits) \ X(decr_hits) /** Stats stored per slab (and per thread). */ struct slab_stats { #define X(name) uint64_t name; SLAB_STATS_FIELDS #undef X }; #define THREAD_STATS_FIELDS \ X(get_cmds) \ X(get_misses) \ X(get_expired) \ X(get_flushed) \ X(touch_cmds) \ X(touch_misses) \ X(delete_misses) \ X(incr_misses) \ X(decr_misses) \ X(cas_misses) \ X(meta_cmds) \ X(bytes_read) \ X(bytes_written) \ X(flush_cmds) \ X(conn_yields) /* # of yields for connections (-R option)*/ \ X(auth_cmds) \ X(auth_errors) \ X(idle_kicks) /* idle connections killed */ \ X(response_obj_oom) \ X(response_obj_count) \ X(response_obj_bytes) \ X(read_buf_oom) \ X(store_too_large) \ X(store_no_memory) #ifdef EXTSTORE #define EXTSTORE_THREAD_STATS_FIELDS \ X(get_extstore) \ X(get_aborted_extstore) \ X(get_oom_extstore) \ X(recache_from_extstore) \ X(miss_from_extstore) \ X(badcrc_from_extstore) #endif #ifdef PROXY #define PROXY_THREAD_STATS_FIELDS \ X(proxy_conn_requests) \ X(proxy_conn_errors) \ X(proxy_conn_oom) \ X(proxy_req_active) \ X(proxy_await_active) #endif /** * Stats stored per-thread. */ struct thread_stats { pthread_mutex_t mutex; #define X(name) uint64_t name; THREAD_STATS_FIELDS #ifdef EXTSTORE EXTSTORE_THREAD_STATS_FIELDS #endif #ifdef PROXY PROXY_THREAD_STATS_FIELDS #endif #undef X struct slab_stats slab_stats[MAX_NUMBER_OF_SLAB_CLASSES]; uint64_t lru_hits[POWER_LARGEST]; uint64_t read_buf_count; uint64_t read_buf_bytes; uint64_t read_buf_bytes_free; }; /** * Global stats. Only resettable stats should go into this structure. */ struct stats { uint64_t total_items; uint64_t total_conns; uint64_t rejected_conns; uint64_t malloc_fails; uint64_t listen_disabled_num; uint64_t slabs_moved; /* times slabs were moved around */ uint64_t slab_reassign_rescues; /* items rescued during slab move */ uint64_t slab_reassign_evictions_nomem; /* valid items lost during slab move */ uint64_t slab_reassign_inline_reclaim; /* valid items lost during slab move */ uint64_t slab_reassign_chunk_rescues; /* chunked-item chunks recovered */ uint64_t slab_reassign_busy_items; /* valid temporarily unmovable */ uint64_t slab_reassign_busy_deletes; /* refcounted items killed */ uint64_t lru_crawler_starts; /* Number of item crawlers kicked off */ uint64_t lru_maintainer_juggles; /* number of LRU bg pokes */ uint64_t time_in_listen_disabled_us; /* elapsed time in microseconds while server unable to process new connections */ uint64_t log_worker_dropped; /* logs dropped by worker threads */ uint64_t log_worker_written; /* logs written by worker threads */ uint64_t log_watcher_skipped; /* logs watchers missed */ uint64_t log_watcher_sent; /* logs sent to watcher buffers */ #ifdef EXTSTORE uint64_t extstore_compact_lost; /* items lost because they were locked */ uint64_t extstore_compact_rescues; /* items re-written during compaction */ uint64_t extstore_compact_skipped; /* unhit items skipped during compaction */ #endif #ifdef TLS uint64_t ssl_handshake_errors; /* TLS failures at accept/handshake time */ uint64_t ssl_new_sessions; /* successfully negotiated new (non-reused) TLS sessions */ #endif struct timeval maxconns_entered; /* last time maxconns entered */ uint64_t unexpected_napi_ids; /* see doc/napi_ids.txt */ uint64_t round_robin_fallback; /* see doc/napi_ids.txt */ }; /** * Global "state" stats. Reflects state that shouldn't be wiped ever. * Ordered for some cache line locality for commonly updated counters. */ struct stats_state { uint64_t curr_items; uint64_t curr_bytes; uint64_t curr_conns; uint64_t hash_bytes; /* size used for hash tables */ unsigned int conn_structs; unsigned int reserved_fds; unsigned int hash_power_level; /* Better hope it's not over 9000 */ unsigned int log_watchers; /* number of currently active watchers */ bool hash_is_expanding; /* If the hash table is being expanded */ bool accepting_conns; /* whether we are currently accepting */ bool slab_reassign_running; /* slab reassign in progress */ bool lru_crawler_running; /* crawl in progress */ }; #define MAX_VERBOSITY_LEVEL 2 /* When adding a setting, be sure to update process_stat_settings */ /** * Globally accessible settings as derived from the commandline. */ struct settings { size_t maxbytes; int maxconns; int port; int udpport; char *inter; int verbose; rel_time_t oldest_live; /* ignore existing items older than this */ uint64_t oldest_cas; /* ignore existing items with CAS values lower than this */ int evict_to_free; char *socketpath; /* path to unix socket if using local socket */ char *auth_file; /* path to user authentication file */ int access; /* access mask (a la chmod) for unix domain socket */ double factor; /* chunk size growth factor */ int chunk_size; int num_threads; /* number of worker (without dispatcher) libevent threads to run */ int num_threads_per_udp; /* number of worker threads serving each udp socket */ char prefix_delimiter; /* character that marks a key prefix (for stats) */ int detail_enabled; /* nonzero if we're collecting detailed stats */ int reqs_per_event; /* Maximum number of io to process on each io-event. */ bool use_cas; enum protocol binding_protocol; int backlog; int item_size_max; /* Maximum item size */ int slab_chunk_size_max; /* Upper end for chunks within slab pages. */ int slab_page_size; /* Slab's page units. */ volatile sig_atomic_t sig_hup; /* a HUP signal was received but not yet handled */ bool sasl; /* SASL on/off */ bool maxconns_fast; /* Whether or not to early close connections */ bool lru_crawler; /* Whether or not to enable the autocrawler thread */ bool lru_maintainer_thread; /* LRU maintainer background thread */ bool lru_segmented; /* Use split or flat LRU's */ bool slab_reassign; /* Whether or not slab reassignment is allowed */ int slab_automove; /* Whether or not to automatically move slabs */ double slab_automove_ratio; /* youngest must be within pct of oldest */ unsigned int slab_automove_window; /* window mover for algorithm */ int hashpower_init; /* Starting hash power level */ bool shutdown_command; /* allow shutdown command */ int tail_repair_time; /* LRU tail refcount leak repair time */ bool flush_enabled; /* flush_all enabled */ bool dump_enabled; /* whether cachedump/metadump commands work */ char *hash_algorithm; /* Hash algorithm in use */ int lru_crawler_sleep; /* Microsecond sleep between items */ uint32_t lru_crawler_tocrawl; /* Number of items to crawl per run */ int hot_lru_pct; /* percentage of slab space for HOT_LRU */ int warm_lru_pct; /* percentage of slab space for WARM_LRU */ double hot_max_factor; /* HOT tail age relative to COLD tail */ double warm_max_factor; /* WARM tail age relative to COLD tail */ int crawls_persleep; /* Number of LRU crawls to run before sleeping */ bool temp_lru; /* TTL < temporary_ttl uses TEMP_LRU */ uint32_t temporary_ttl; /* temporary LRU threshold */ int idle_timeout; /* Number of seconds to let connections idle */ unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */ unsigned int logger_buf_size; /* size of per-thread logger buffer */ unsigned int read_buf_mem_limit; /* total megabytes allowable for net buffers */ bool drop_privileges; /* Whether or not to drop unnecessary process privileges */ bool watch_enabled; /* allows watch commands to be dropped */ bool relaxed_privileges; /* Relax process restrictions when running testapp */ #ifdef EXTSTORE unsigned int ext_io_threadcount; /* number of IO threads to run. */ unsigned int ext_page_size; /* size in megabytes of storage pages. */ unsigned int ext_item_size; /* minimum size of items to store externally */ unsigned int ext_item_age; /* max age of tail item before storing ext. */ unsigned int ext_low_ttl; /* remaining TTL below this uses own pages */ unsigned int ext_recache_rate; /* counter++ % recache_rate == 0 > recache */ unsigned int ext_wbuf_size; /* read only note for the engine */ unsigned int ext_compact_under; /* when fewer than this many pages, compact */ unsigned int ext_drop_under; /* when fewer than this many pages, drop COLD items */ unsigned int ext_max_sleep; /* maximum sleep time for extstore bg threads, in us */ double ext_max_frag; /* ideal maximum page fragmentation */ double slab_automove_freeratio; /* % of memory to hold free as buffer */ bool ext_drop_unread; /* skip unread items during compaction */ /* start flushing to extstore after memory below this */ unsigned int ext_global_pool_min; #endif #ifdef TLS bool ssl_enabled; /* indicates whether SSL is enabled */ SSL_CTX *ssl_ctx; /* holds the SSL server context which has the server certificate */ char *ssl_chain_cert; /* path to the server SSL chain certificate */ char *ssl_key; /* path to the server key */ int ssl_verify_mode; /* client certificate verify mode */ int ssl_keyformat; /* key format , default is PEM */ char *ssl_ciphers; /* list of SSL ciphers */ char *ssl_ca_cert; /* certificate with CAs. */ rel_time_t ssl_last_cert_refresh_time; /* time of the last server certificate refresh */ unsigned int ssl_wbuf_size; /* size of the write buffer used by ssl_sendmsg method */ bool ssl_session_cache; /* enable SSL server session caching */ bool ssl_kernel_tls; /* enable server kTLS */ int ssl_min_version; /* minimum SSL protocol version to accept */ #endif int num_napi_ids; /* maximum number of NAPI IDs */ char *memory_file; /* warm restart memory file path */ #ifdef PROXY bool proxy_enabled; bool proxy_uring; /* if the proxy should use io_uring */ char *proxy_startfile; /* lua file to run when workers start */ void *proxy_ctx; /* proxy's state context */ #endif #ifdef SOCK_COOKIE_ID uint32_t sock_cookie_id; #endif }; extern struct stats stats; extern struct stats_state stats_state; extern time_t process_started; extern struct settings settings; #define ITEM_LINKED 1 #define ITEM_CAS 2 /* temp */ #define ITEM_SLABBED 4 /* Item was fetched at least once in its lifetime */ #define ITEM_FETCHED 8 /* Appended on fetch, removed on LRU shuffling */ #define ITEM_ACTIVE 16 /* If an item's storage are chained chunks. */ #define ITEM_CHUNKED 32 #define ITEM_CHUNK 64 /* ITEM_data bulk is external to item */ #define ITEM_HDR 128 /* additional 4 bytes for item client flags */ #define ITEM_CFLAGS 256 /* item has sent out a token already */ #define ITEM_TOKEN_SENT 512 /* reserved, in case tokens should be a 2-bit count in future */ #define ITEM_TOKEN_RESERVED 1024 /* if item has been marked as a stale value */ #define ITEM_STALE 2048 /* if item key was sent in binary */ #define ITEM_KEY_BINARY 4096 /** * Structure for storing items within memcached. */ typedef struct _stritem { /* Protected by LRU locks */ struct _stritem *next; struct _stritem *prev; /* Rest are protected by an item lock */ struct _stritem *h_next; /* hash chain next */ rel_time_t time; /* least recent access */ rel_time_t exptime; /* expire time */ int nbytes; /* size of data */ unsigned short refcount; uint16_t it_flags; /* ITEM_* above */ uint8_t slabs_clsid;/* which slab class we're in */ uint8_t nkey; /* key length, w/terminating null and padding */ /* this odd type prevents type-punning issues when we do * the little shuffle to save space when not using CAS. */ union { uint64_t cas; char end; } data[]; /* if it_flags & ITEM_CAS we have 8 bytes CAS */ /* then null-terminated key */ /* then " flags length\r\n" (no terminating null) */ /* then data with terminating \r\n (no terminating null; it's binary!) */ } item; // TODO: If we eventually want user loaded modules, we can't use an enum :( enum crawler_run_type { CRAWLER_AUTOEXPIRE=0, CRAWLER_EXPIRED, CRAWLER_METADUMP, CRAWLER_MGDUMP }; typedef struct { struct _stritem *next; struct _stritem *prev; struct _stritem *h_next; /* hash chain next */ rel_time_t time; /* least recent access */ rel_time_t exptime; /* expire time */ int nbytes; /* size of data */ unsigned short refcount; uint16_t it_flags; /* ITEM_* above */ uint8_t slabs_clsid;/* which slab class we're in */ uint8_t nkey; /* key length, w/terminating null and padding */ uint32_t remaining; /* Max keys to crawl per slab per invocation */ uint64_t reclaimed; /* items reclaimed during this crawl. */ uint64_t unfetched; /* items reclaimed unfetched during this crawl. */ uint64_t checked; /* items examined during this crawl. */ } crawler; /* Header when an item is actually a chunk of another item. */ typedef struct _strchunk { struct _strchunk *next; /* points within its own chain. */ struct _strchunk *prev; /* can potentially point to the head. */ struct _stritem *head; /* always points to the owner chunk */ int size; /* available chunk space in bytes */ int used; /* chunk space used */ int nbytes; /* used. */ unsigned short refcount; /* used? */ uint16_t it_flags; /* ITEM_* above. */ uint8_t slabs_clsid; /* Same as above. */ uint8_t orig_clsid; /* For obj hdr chunks slabs_clsid is fake. */ char data[]; } item_chunk; #ifdef NEED_ALIGN static inline char *ITEM_schunk(item *it) { int offset = it->nkey + 1 + ((it->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) + ((it->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0); int remain = offset % 8; if (remain != 0) { offset += 8 - remain; } return ((char *) &(it->data)) + offset; } #else #define ITEM_schunk(item) ((char*) &((item)->data) + (item)->nkey + 1 \ + (((item)->it_flags & ITEM_CFLAGS) ? sizeof(uint32_t) : 0) \ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0)) #endif #ifdef EXTSTORE typedef struct { unsigned int page_version; /* from IO header */ unsigned int offset; /* from IO header */ unsigned short page_id; /* from IO header */ } item_hdr; #endif #define IO_QUEUE_COUNT 3 #define IO_QUEUE_NONE 0 #define IO_QUEUE_EXTSTORE 1 #define IO_QUEUE_PROXY 2 typedef struct _io_pending_t io_pending_t; typedef struct io_queue_s io_queue_t; typedef void (*io_queue_stack_cb)(io_queue_t *q); typedef void (*io_queue_cb)(io_pending_t *pending); // This structure used to be passed between threads, but is now owned entirely // by the worker threads. // IO pending objects are created and stacked into this structure. They are // then sent off to remote threads. // The objects are returned one at a time to the worker threads, and this // structure is then consulted to see when to resume the worker. struct io_queue_s { void *ctx; // duplicated from io_queue_cb_t void *stack_ctx; // module-specific context to be batch-submitted int count; // ios to process before returning. only accessed by queue processor once submitted int type; // duplicated from io_queue_cb_t }; typedef struct io_queue_cb_s { void *ctx; // untouched ptr for specific context io_queue_stack_cb submit_cb; // callback given a full stack of pending IO's at once. int type; } io_queue_cb_t; typedef struct _mc_resp_bundle mc_resp_bundle; typedef struct { pthread_t thread_id; /* unique ID of this thread */ struct event_base *base; /* libevent handle this thread uses */ struct event notify_event; /* listen event for notify pipe */ #ifdef HAVE_EVENTFD int notify_event_fd; /* notify counter */ #else int notify_receive_fd; /* receiving end of notify pipe */ int notify_send_fd; /* sending end of notify pipe */ #endif int cur_sfd; /* client fd for logging commands */ int thread_baseid; /* which "number" thread this is for data offsets */ struct thread_stats stats; /* Stats generated by this thread */ io_queue_cb_t io_queues[IO_QUEUE_COUNT]; struct conn_queue *ev_queue; /* Worker/conn event queue */ cache_t *rbuf_cache; /* static-sized read buffers */ mc_resp_bundle *open_bundle; cache_t *io_cache; /* IO objects */ #ifdef EXTSTORE void *storage; /* data object for storage system */ #endif logger *l; /* logger buffer */ void *lru_bump_buf; /* async LRU bump buffer */ #ifdef TLS char *ssl_wbuf; #endif int napi_id; /* napi id associated with this thread */ #ifdef PROXY void *proxy_ctx; // proxy global context void *L; // lua VM void *proxy_hooks; void *proxy_user_stats; void *proxy_int_stats; void *proxy_event_thread; // worker threads can also be proxy IO threads pthread_mutex_t proxy_limit_lock; uint64_t proxy_active_req_limit; uint64_t proxy_buffer_memory_limit; // protected by limit_lock uint64_t proxy_buffer_memory_used; // protected by limit_lock uint32_t proxy_rng[4]; // fast per-thread rng for lua. // TODO: add ctx object so we can attach to queue. #endif } LIBEVENT_THREAD; /** * Response objects */ #define MC_RESP_IOVCOUNT 4 typedef struct _mc_resp { mc_resp_bundle *bundle; // ptr back to bundle struct _mc_resp *next; // choo choo. int wbytes; // bytes to write out of wbuf: might be able to nuke this. int tosend; // total bytes to send for this response void *write_and_free; /** free this memory after finishing writing */ io_pending_t *io_pending; /* pending IO descriptor for this response */ item *item; /* item associated with this response object, with reference held */ struct iovec iov[MC_RESP_IOVCOUNT]; /* built-in iovecs to simplify network code */ int chunked_total; /* total amount of chunked item data to send. */ uint8_t iovcnt; uint8_t chunked_data_iov; /* this iov is a pointer to chunked data header */ /* instruct transmit to skip this response object. used by storage engines * to asynchronously kill an object that was queued to write */ bool skip; bool free; // double free detection. // UDP bits. Copied in from the client. uint16_t request_id; /* Incoming UDP request ID, if this is a UDP "connection" */ uint16_t udp_sequence; /* packet counter when transmitting result */ uint16_t udp_total; /* total number of packets in sequence */ struct sockaddr_in6 request_addr; /* udp: Who sent this request */ socklen_t request_addr_size; char wbuf[WRITE_BUFFER_SIZE]; } mc_resp; #define MAX_RESP_PER_BUNDLE ((READ_BUFFER_SIZE - sizeof(mc_resp_bundle)) / sizeof(mc_resp)) struct _mc_resp_bundle { uint8_t refcount; uint8_t next_check; // next object to check on assignment. struct _mc_resp_bundle *next; struct _mc_resp_bundle *prev; mc_resp r[]; }; typedef struct conn conn; struct _io_pending_t { int io_queue_type; // matches one of IO_QUEUE_* LIBEVENT_THREAD *thread; conn *c; mc_resp *resp; // associated response object io_queue_cb return_cb; // called on worker thread. io_queue_cb finalize_cb; // called back on the worker thread. char data[120]; }; /** * The structure representing a connection into memcached. */ struct conn { sasl_conn_t *sasl_conn; int sfd; bool sasl_started; bool authenticated; bool set_stale; bool mset_res; /** uses mset format for return code */ bool close_after_write; /** flush write then move to close connection */ bool rbuf_malloced; /** read buffer was malloc'ed for ascii mget, needs free() */ bool item_malloced; /** item for conn_nread state is a temporary malloc */ #ifdef TLS SSL *ssl; char *ssl_wbuf; bool ssl_enabled; #endif enum conn_states state; enum bin_substates substate; rel_time_t last_cmd_time; struct event event; short ev_flags; short which; /** which events were just triggered */ char *rbuf; /** buffer to read commands into */ char *rcurr; /** but if we parsed some already, this is where we stopped */ int rsize; /** total allocated size of rbuf */ int rbytes; /** how much data, starting from rcur, do we have unparsed */ mc_resp *resp; // tail response. mc_resp *resp_head; // first response in current stack. char *ritem; /** when we read in an item's value, it goes here */ int rlbytes; /** * item is used to hold an item structure created after reading the command * line of set/add/replace commands, but before we finished reading the actual * data. The data is read into ITEM_data(item) to avoid extra copying. */ void *item; /* for commands set/add/replace */ /* data for the swallow state */ int sbytes; /* how many bytes to swallow */ int io_queues_submitted; /* see notes on io_queue_t */ io_queue_t io_queues[IO_QUEUE_COUNT]; /* set of deferred IO queues. */ #ifdef PROXY unsigned int proxy_coro_ref; /* lua reference for active coroutine */ #endif #ifdef EXTSTORE unsigned int recache_counter; #endif enum protocol protocol; /* which protocol this connection speaks */ enum network_transport transport; /* what transport is used by this connection */ enum close_reasons close_reason; /* reason for transition into conn_closing */ /* data for UDP clients */ int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */ struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request */ socklen_t request_addr_size; bool noreply; /* True if the reply should not be sent. */ /* current stats command */ struct { char *buffer; size_t size; size_t offset; } stats; /* Binary protocol stuff */ /* This is where the binary header goes */ protocol_binary_request_header binary_header; uint64_t cas; /* the cas to return */ uint64_t tag; /* listener stocket tag */ short cmd; /* current command being processed */ int opaque; int keylen; conn *next; /* Used for generating a list of conn structures */ LIBEVENT_THREAD *thread; /* Pointer to the thread object serving this connection */ int (*try_read_command)(conn *c); /* pointer for top level input parser */ ssize_t (*read)(conn *c, void *buf, size_t count); ssize_t (*sendmsg)(conn *c, struct msghdr *msg, int flags); ssize_t (*write)(conn *c, void *buf, size_t count); }; /* array of conn structures, indexed by file descriptor */ extern conn **conns; /* current time of day (updated periodically) */ extern volatile rel_time_t current_time; #ifdef MEMCACHED_DEBUG extern volatile bool is_paused; extern volatile int64_t delta; #endif /* TODO: Move to slabs.h? */ extern volatile int slab_rebalance_signal; struct slab_rebalance { void *slab_start; void *slab_end; void *slab_pos; int s_clsid; int d_clsid; uint32_t busy_items; uint32_t rescues; uint32_t evictions_nomem; uint32_t inline_reclaim; uint32_t chunk_rescues; uint32_t busy_deletes; uint32_t busy_loops; uint8_t done; uint8_t *completed; }; extern struct slab_rebalance slab_rebal; #ifdef EXTSTORE extern void *ext_storage; #endif /* * Functions */ void do_accept_new_conns(const bool do_accept); enum delta_result_type do_add_delta(LIBEVENT_THREAD *t, const char *key, const size_t nkey, const bool incr, const int64_t delta, char *buf, uint64_t *cas, const uint32_t hv, item **it_ret); enum store_item_type do_store_item(item *item, int comm, LIBEVENT_THREAD *t, const uint32_t hv, int *nbytes, uint64_t *cas, bool cas_stale); void thread_io_queue_add(LIBEVENT_THREAD *t, int type, void *ctx, io_queue_stack_cb cb); void conn_io_queue_setup(conn *c); io_queue_t *conn_io_queue_get(conn *c, int type); io_queue_cb_t *thread_io_queue_get(LIBEVENT_THREAD *t, int type); void conn_io_queue_return(io_pending_t *io); conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base, void *ssl, uint64_t conntag, enum protocol bproto); void conn_worker_readd(conn *c); extern int daemonize(int nochdir, int noclose); #define mutex_lock(x) pthread_mutex_lock(x) #define mutex_unlock(x) pthread_mutex_unlock(x) #include "stats_prefix.h" #include "slabs.h" #include "assoc.h" #include "items.h" #include "crawler.h" #include "trace.h" #include "hash.h" #include "util.h" /* * Functions such as the libevent-related calls that need to do cross-thread * communication in multithreaded mode (rather than actually doing the work * in the current thread) are called via "dispatch_" frontends, which are * also #define-d to directly call the underlying code in singlethreaded mode. */ void memcached_thread_init(int nthreads, void *arg); void redispatch_conn(conn *c); void timeout_conn(conn *c); #ifdef PROXY void proxy_reload_notify(LIBEVENT_THREAD *t); #endif void return_io_pending(io_pending_t *io); void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport, void *ssl, uint64_t conntag, enum protocol bproto); void sidethread_conn_close(conn *c); /* Lock wrappers for cache functions that are called from main loop. */ enum delta_result_type add_delta(LIBEVENT_THREAD *t, const char *key, const size_t nkey, bool incr, const int64_t delta, char *buf, uint64_t *cas); void accept_new_conns(const bool do_accept); void conn_close_idle(conn *c); void conn_close_all(void); item *item_alloc(const char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes); #define DO_UPDATE true #define DONT_UPDATE false item *item_get(const char *key, const size_t nkey, LIBEVENT_THREAD *t, const bool do_update); item *item_get_locked(const char *key, const size_t nkey, LIBEVENT_THREAD *t, const bool do_update, uint32_t *hv); item *item_touch(const char *key, const size_t nkey, uint32_t exptime, LIBEVENT_THREAD *t); int item_link(item *it); void item_remove(item *it); int item_replace(item *it, item *new_it, const uint32_t hv); void item_unlink(item *it); void item_lock(uint32_t hv); void *item_trylock(uint32_t hv); void item_trylock_unlock(void *arg); void item_unlock(uint32_t hv); void pause_threads(enum pause_thread_types type); void stop_threads(void); int stop_conn_timeout_thread(void); #define refcount_incr(it) ++(it->refcount) #define refcount_decr(it) --(it->refcount) void STATS_LOCK(void); void STATS_UNLOCK(void); #define THR_STATS_LOCK(t) pthread_mutex_lock(&t->stats.mutex) #define THR_STATS_UNLOCK(t) pthread_mutex_unlock(&t->stats.mutex) void threadlocal_stats_reset(void); void threadlocal_stats_aggregate(struct thread_stats *stats); void slab_stats_aggregate(struct thread_stats *stats, struct slab_stats *out); void thread_setname(pthread_t thread, const char *name); LIBEVENT_THREAD *get_worker_thread(int id); /* Stat processing functions */ void append_stat(const char *name, ADD_STAT add_stats, conn *c, const char *fmt, ...); enum store_item_type store_item(item *item, int comm, LIBEVENT_THREAD *t, int *nbytes, uint64_t *cas, bool cas_stale); /* Protocol related code */ void out_string(conn *c, const char *str); #define REALTIME_MAXDELTA 60*60*24*30 /* Negative exptimes can underflow and end up immortal. realtime() will immediately expire values that are greater than REALTIME_MAXDELTA, but less than process_started, so lets aim for that. */ #define EXPTIME_TO_POSITIVE_TIME(exptime) (exptime < 0) ? \ REALTIME_MAXDELTA + 1 : exptime rel_time_t realtime(const time_t exptime); item* limited_get(const char *key, size_t nkey, LIBEVENT_THREAD *t, uint32_t exptime, bool should_touch, bool do_update, bool *overflow); item* limited_get_locked(const char *key, size_t nkey, LIBEVENT_THREAD *t, bool do_update, uint32_t *hv, bool *overflow); // Read/Response object handlers. void resp_reset(mc_resp *resp); void resp_add_iov(mc_resp *resp, const void *buf, int len); void resp_add_chunked_iov(mc_resp *resp, const void *buf, int len); bool resp_start(conn *c); mc_resp *resp_start_unlinked(conn *c); mc_resp* resp_finish(conn *c, mc_resp *resp); void resp_free(LIBEVENT_THREAD *th, mc_resp *resp); bool resp_has_stack(conn *c); bool rbuf_switch_to_malloc(conn *c); void conn_release_items(conn *c); void conn_set_state(conn *c, enum conn_states state); void out_of_memory(conn *c, char *ascii_error); void out_errstring(conn *c, const char *str); void write_and_free(conn *c, char *buf, int bytes); void server_stats(ADD_STAT add_stats, conn *c); void append_stats(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, const void *cookie); /** Return a datum for stats in binary protocol */ bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c); void stats_reset(void); void process_stat_settings(ADD_STAT add_stats, void *c); void process_stats_conns(ADD_STAT add_stats, void *c); #if HAVE_DROP_PRIVILEGES extern void setup_privilege_violations_handler(void); extern void drop_privileges(void); #else #define setup_privilege_violations_handler() #define drop_privileges() #endif #if HAVE_DROP_WORKER_PRIVILEGES extern void drop_worker_privileges(void); #else #define drop_worker_privileges() #endif /* If supported, give compiler hints for branch prediction. */ #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) #define __builtin_expect(x, expected_value) (x) #endif #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) chibicc-1.0.23.1/test/memory_barrier.c000066400000000000000000000007341505335450300174700ustar00rootroot00000000000000 #include "test.h" static inline void pg_memory_barrier_impl(void) { #if defined(__i386__) || defined(__i386) __asm__ __volatile__("lock; addl $0,0(%%esp)" : : : "memory", "cc"); #elif defined(__x86_64__) __asm__ __volatile__("lock; addl $0,0(%%rsp)" : : : "memory", "cc"); #endif } int main() { int x = 0; pg_memory_barrier_impl(); x = 1; pg_memory_barrier_impl(); printf("Memory barrier applied. x = %d\n", x); ASSERT(1, x); return 0; } chibicc-1.0.23.1/test/memory_status.c000066400000000000000000000023231505335450300173610ustar00rootroot00000000000000 #include #include "test.h" #define MEM_SIZE 100 // Define the size of the memory block void printMemoryStatus(char *memory, int size); int main() { char *memory = (char *)malloc(MEM_SIZE * sizeof(char)); // Allocate memory block if (memory == NULL) { printf("Memory allocation failed. Exiting.\n"); return 1; } // Initially, mark all memory as free for (int i = 0; i < MEM_SIZE; ++i) { memory[i] = 'F'; } // Example usage: Allocating memory at address 10 to 20 for (int i = 10; i < 20; ++i) { memory[i] = '*'; } // Print the memory status printMemoryStatus(memory, MEM_SIZE); // Freeing memory at address 10 to 20 for (int i = 10; i < 20; ++i) { memory[i] = 'F'; } // Print the memory status after freeing memory printMemoryStatus(memory, MEM_SIZE); // Free dynamically allocated memory free(memory); return 0; } // Function to print memory status void printMemoryStatus(char *memory, int size) { printf("Memory Status:\n"); for (int i = 0; i < size; ++i) { printf("memory[%d]=%c ", i, memory[i]); if (i < 10 ) ASSERT(70, memory[i]); } printf("\n"); } chibicc-1.0.23.1/test/memorychunk.c000066400000000000000000000034771505335450300170220ustar00rootroot00000000000000#include #include #include #include typedef uint64_t Size; typedef uint8_t MemoryContextMethodID; typedef struct MemoryChunk { uint64_t hdrmask; } MemoryChunk; #define MEMORY_CONTEXT_METHODID_BITS 8 #define MEMORYCHUNK_EXTERNAL_BASEBIT MEMORY_CONTEXT_METHODID_BITS #define MEMORYCHUNK_VALUE_BASEBIT (MEMORYCHUNK_EXTERNAL_BASEBIT + 1) #define MEMORYCHUNK_BLOCKOFFSET_BASEBIT (MEMORYCHUNK_VALUE_BASEBIT + 30) #define UINT64CONST(x) (x##ULL) #define MEMORYCHUNK_MAGIC (UINT64CONST(0xB1A8DB858EB6EFBA) >> MEMORYCHUNK_VALUE_BASEBIT << MEMORYCHUNK_VALUE_BASEBIT) #define METHOD_ID 0x01 static inline void MemoryChunkSetHdrMask(MemoryChunk *chunk, void *block, Size value, MemoryContextMethodID methodid) { Size blockoffset = (char *)chunk - (char *)block; chunk->hdrmask = (((uint64_t)blockoffset) << 34) | (((uint64_t)value) << 4) | methodid; } static inline void MemoryChunkSetHdrMaskExternal(MemoryChunk *chunk, MemoryContextMethodID methodid) { chunk->hdrmask = MEMORYCHUNK_MAGIC | (((uint64_t)1) << MEMORYCHUNK_EXTERNAL_BASEBIT) | methodid; } int main() { void *block = malloc(1024); MemoryChunk *chunk = (MemoryChunk *)((char *)block + 64); // Example offset Size value = 0x12345; MemoryContextMethodID methodid = METHOD_ID; MemoryChunkSetHdrMask(chunk, block, value, methodid); printf("Internal hdrmask: 0x%016lx\n", chunk->hdrmask); // Check that hdrmask is not null assert(chunk->hdrmask != 0); MemoryChunkSetHdrMaskExternal(chunk, methodid); printf("External hdrmask: 0x%016lx\n", chunk->hdrmask); // Check that hdrmask is not null assert(chunk->hdrmask != 0); free(block); return 0; } chibicc-1.0.23.1/test/memorychunk2.c000066400000000000000000000201531505335450300170720ustar00rootroot00000000000000#include #include #include #include #include // Define the required constants and types typedef uint64_t Size; typedef uint8_t MemoryContextMethodID; typedef struct MemoryChunk { uint64_t hdrmask; } MemoryChunk; typedef struct AllocBlockData { struct AllocBlockData *prev; struct AllocBlockData *next; char *freeptr; char *endptr; void *aset; } AllocBlockData; typedef AllocBlockData *AllocBlock; typedef struct AllocSetData { struct AllocBlockData *blocks; Size allocChunkLimit; Size initBlockSize; Size maxBlockSize; Size nextBlockSize; Size mem_allocated; MemoryChunk **freelist; } AllocSetData; typedef AllocSetData *AllocSet; typedef AllocSet MemoryContext; #define MEMORY_CONTEXT_METHODID_BITS 8 #define MEMORYCHUNK_EXTERNAL_BASEBIT MEMORY_CONTEXT_METHODID_BITS #define MEMORYCHUNK_VALUE_BASEBIT (MEMORYCHUNK_EXTERNAL_BASEBIT + 1) #define MEMORYCHUNK_BLOCKOFFSET_BASEBIT (MEMORYCHUNK_VALUE_BASEBIT + 30) #define UINT64CONST(x) (x##ULL) #define MEMORYCHUNK_MAGIC (UINT64CONST(0xB1A8DB858EB6EFBA) >> MEMORYCHUNK_VALUE_BASEBIT << MEMORYCHUNK_VALUE_BASEBIT) #define METHOD_ID 0x01 #define ALLOC_BLOCKHDRSZ offsetof(AllocBlockData, freeptr) #define ALLOC_CHUNKHDRSZ sizeof(MemoryChunk) #define ALLOC_MINBITS 3 #define ALLOCSET_NUM_FREELISTS 11 #define MAXALIGN(x) (((x) + 7) & ~7) #define MCTX_ASET_ID 1 // Define dummy implementations of undefined functions/macros #define VALGRIND_MAKE_MEM_NOACCESS(addr, size) #define VALGRIND_MAKE_MEM_DEFINED(addr, size) #define VALGRIND_MAKE_MEM_UNDEFINED(addr, size) static inline void *MemoryChunkGetPointer(MemoryChunk *chunk) { return (void *)(chunk + 1); } static inline int AllocSetFreeIndex(Size size) { int idx = 0; while ((1U << idx) < size) { idx++; } return idx; } static inline Size GetChunkSizeFromFreeListIdx(int idx) { return (1U << idx); } typedef struct AllocFreeListLink { struct MemoryChunk *next; } AllocFreeListLink; static inline AllocFreeListLink *GetFreeListLink(MemoryChunk *chunk) { return (AllocFreeListLink *) chunk; } static inline void MemoryChunkSetHdrMask(MemoryChunk *chunk, void *block, Size value, MemoryContextMethodID methodid) { Size blockoffset = (char *)chunk - (char *)block; chunk->hdrmask = (((uint64_t)blockoffset) << 34) | (((uint64_t)value) << 4) | methodid; } static inline void MemoryChunkSetHdrMaskExternal(MemoryChunk *chunk, MemoryContextMethodID methodid) { chunk->hdrmask = MEMORYCHUNK_MAGIC | (((uint64_t)1) << MEMORYCHUNK_EXTERNAL_BASEBIT) | methodid; } // Define AllocSetAlloc function void *AllocSetAlloc(MemoryContext context, Size size) { AllocSet set = (AllocSet)context; AllocBlock block; MemoryChunk *chunk; int fidx; Size chunk_size; Size blksize; if (size > set->allocChunkLimit) { chunk_size = MAXALIGN(size); blksize = chunk_size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ; block = (AllocBlock)malloc(blksize); if (block == NULL) return NULL; context->mem_allocated += blksize; block->aset = set; block->freeptr = block->endptr = ((char *)block) + blksize; chunk = (MemoryChunk *)(((char *)block) + ALLOC_BLOCKHDRSZ); MemoryChunkSetHdrMaskExternal(chunk, MCTX_ASET_ID); if (set->blocks != NULL) { block->prev = set->blocks; block->next = set->blocks->next; if (block->next) block->next->prev = block; set->blocks->next = block; } else { block->prev = NULL; block->next = NULL; set->blocks = block; } VALGRIND_MAKE_MEM_NOACCESS((char *)MemoryChunkGetPointer(chunk) + size, chunk_size - size); VALGRIND_MAKE_MEM_NOACCESS(chunk, ALLOC_CHUNKHDRSZ); return MemoryChunkGetPointer(chunk); } fidx = AllocSetFreeIndex(size); chunk = set->freelist[fidx]; if (chunk != NULL) { AllocFreeListLink *link = GetFreeListLink(chunk); VALGRIND_MAKE_MEM_DEFINED(chunk, ALLOC_CHUNKHDRSZ); VALGRIND_MAKE_MEM_DEFINED(link, sizeof(AllocFreeListLink)); set->freelist[fidx] = link->next; VALGRIND_MAKE_MEM_NOACCESS(link, sizeof(AllocFreeListLink)); VALGRIND_MAKE_MEM_NOACCESS((char *)MemoryChunkGetPointer(chunk) + size, GetChunkSizeFromFreeListIdx(fidx) - size); VALGRIND_MAKE_MEM_NOACCESS(chunk, ALLOC_CHUNKHDRSZ); return MemoryChunkGetPointer(chunk); } chunk_size = GetChunkSizeFromFreeListIdx(fidx); if ((block = set->blocks) != NULL) { Size availspace = block->endptr - block->freeptr; if (availspace < (chunk_size + ALLOC_CHUNKHDRSZ)) { while (availspace >= ((1 << ALLOC_MINBITS) + ALLOC_CHUNKHDRSZ)) { AllocFreeListLink *link; Size availchunk = availspace - ALLOC_CHUNKHDRSZ; int a_fidx = AllocSetFreeIndex(availchunk); if (availchunk != GetChunkSizeFromFreeListIdx(a_fidx)) { a_fidx--; availchunk = GetChunkSizeFromFreeListIdx(a_fidx); } chunk = (MemoryChunk *)(block->freeptr); VALGRIND_MAKE_MEM_UNDEFINED(chunk, ALLOC_CHUNKHDRSZ); block->freeptr += (availchunk + ALLOC_CHUNKHDRSZ); availspace -= (availchunk + ALLOC_CHUNKHDRSZ); MemoryChunkSetHdrMask(chunk, block, a_fidx, MCTX_ASET_ID); link = GetFreeListLink(chunk); VALGRIND_MAKE_MEM_DEFINED(link, sizeof(AllocFreeListLink)); link->next = set->freelist[a_fidx]; VALGRIND_MAKE_MEM_NOACCESS(link, sizeof(AllocFreeListLink)); set->freelist[a_fidx] = chunk; } block = NULL; } } if (block == NULL) { Size required_size; blksize = set->nextBlockSize; set->nextBlockSize <<= 1; if (set->nextBlockSize > set->maxBlockSize) set->nextBlockSize = set->maxBlockSize; required_size = chunk_size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ; while (blksize < required_size) blksize <<= 1; block = (AllocBlock)malloc(blksize); while (block == NULL && blksize > 1024 * 1024) { blksize >>= 1; if (blksize < required_size) break; block = (AllocBlock)malloc(blksize); } if (block == NULL) return NULL; context->mem_allocated += blksize; block->aset = set; block->freeptr = ((char *)block) + ALLOC_BLOCKHDRSZ; block->endptr = ((char *)block) + blksize; VALGRIND_MAKE_MEM_NOACCESS(block->freeptr, blksize - ALLOC_BLOCKHDRSZ); block->prev = NULL; block->next = set->blocks; if (block->next) block->next->prev = block; set->blocks = block; } chunk = (MemoryChunk *)(block->freeptr); VALGRIND_MAKE_MEM_UNDEFINED(chunk, ALLOC_CHUNKHDRSZ); block->freeptr += (chunk_size + ALLOC_CHUNKHDRSZ); MemoryChunkSetHdrMask(chunk, block, fidx, MCTX_ASET_ID); VALGRIND_MAKE_MEM_NOACCESS((char *)MemoryChunkGetPointer(chunk) + size, chunk_size - size); VALGRIND_MAKE_MEM_NOACCESS(chunk, ALLOC_CHUNKHDRSZ); return MemoryChunkGetPointer(chunk); } // Main function to test AllocSetAlloc int main() { void *block = malloc(1024); MemoryChunk *chunk = (MemoryChunk *)((char *)block + 64); // Example offset Size value = 0x12345; MemoryContextMethodID methodid = METHOD_ID; MemoryChunkSetHdrMask(chunk, block, value, methodid); printf("Internal hdrmask: 0x%016lx\n", chunk->hdrmask); // Check that hdrmask is not null assert(chunk->hdrmask != 0); MemoryChunkSetHdrMaskExternal(chunk, methodid); printf("External hdrmask: 0x%016lx\n", chunk->hdrmask); // Check that hdrmask is not null assert(chunk->hdrmask != 0); free(block); return 0; } chibicc-1.0.23.1/test/meson.c000066400000000000000000000005301505335450300155650ustar00rootroot00000000000000#include #include #include #include #include #include #include #include "test.h" #include int main(){ printf("sizeof struct clone_args=%ld\n", sizeof(struct clone_args)); ASSERT(88, sizeof(struct clone_args)); return 0; }chibicc-1.0.23.1/test/mm_set_ps.c000066400000000000000000000015161505335450300164370ustar00rootroot00000000000000#include "test.h" #include // __m128, _mm_add_ps, _mm_set_ps typedef __m128 v4; v4 add7(v4 a, v4 b, v4 c, v4 d, v4 e, v4 f, v4 g) { return _mm_add_ps(_mm_add_ps(_mm_add_ps(_mm_add_ps(_mm_add_ps(_mm_add_ps(a,b),c),d),e),f),g); } void print_v4(v4 x) { float f[4]; _mm_storeu_ps(f, x); printf("%f %f %f %f\n", f[0], f[1], f[2], f[3]); } int main(){ v4 a = _mm_set_ps(10,20,30,40); v4 b = _mm_set_ps(1,1,1,1); v4 c = _mm_set_ps(2,2,2,2); v4 d = _mm_set_ps(3,3,3,3); v4 e = _mm_set_ps(4,4,4,4); v4 f = _mm_set_ps(5,5,5,5); v4 g = _mm_set_ps(6,6,6,6); v4 r = add7(a,b,c,d,e,f,g); print_v4(r); // expect element-wise sums ASSERT(61, r[0]); ASSERT(51, r[1]); ASSERT(41, r[2]); ASSERT(31, r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/non_variadic.c000066400000000000000000000041661505335450300171110ustar00rootroot00000000000000 #include "test.h" void test_non_variadic( int a1, long double a2, double a3, long double a4, double a5, long double a6, double a7, int a8, double a9, long double a10, double a11, long double a12, double a13, long double a14, double a15, double a16 ) { printf("a1 (int) = %d\n", a1); ASSERT(1, a1); printf("a2 (long double) = %Lf\n", a2); ASSERT(2, a2); printf("a3 (double) = %f\n", a3); ASSERT(3, a3); printf("a4 (long double) = %Lf\n", a4); ASSERT(4, a4); printf("a5 (double) = %f\n", a5); ASSERT(5, a5); printf("a6 (long double) = %Lf\n", a6); ASSERT(6, a6); printf("a7 (double) = %f\n", a7); ASSERT(7, a7); printf("a8 (int) = %d\n", a8); ASSERT(8, a8); printf("a9 (double) = %f\n", a9); ASSERT(9, a9); printf("a10 (long double) = %Lf\n", a10); ASSERT(10, a10); printf("a11 (double) = %f\n", a11); ASSERT(11, a11); printf("a12 (long double) = %Lf\n", a12); ASSERT(12, a12); printf("a13 (double) = %f\n", a13); ASSERT(13, a13); printf("a14 (long double) = %Lf\n", a14); ASSERT(14, a14); printf("a15 (double) = %f\n", a15); ASSERT(15, a15); printf("a16 (double) = %f\n", a16); ASSERT(16, a16); } int main() { test_non_variadic( 1, // int 2.222222222222L, // long double 3.333333, // double 4.444444444444L, // long double 5.555555, // double 6.666666666666L, // long double 7.777777, // double 8, // int 9.999999, // double 10.101010101010L, // long double 11.111111, // double 12.121212121212L, // long double 13.131313, // double 14.141414141414L, // long double 15.151515, // double 16.161616 // double ); return 0; } chibicc-1.0.23.1/test/nonnull.c000066400000000000000000000014631505335450300161370ustar00rootroot00000000000000#include #include "test.h" // Declarations + definitions so linker can find them void foo(char *p, char *q) __attribute__((__nonnull__)); void foo(char *p, char *q) { } void bar(char *p, char *q, char *r) __attribute__((__nonnull__(1, 3))); void bar(char *p, char *q, char *r) { } void baz(char *p, char *q) __attribute__((__nonnull__)); void baz(char *p, char *q) { if (p) *p = 'A'; if (q) *q = 'B'; } typedef void (*nonnull_fn_t)(char *p, char *q) __attribute__((__nonnull__(2))); void use_typedef(nonnull_fn_t fn, char *a, char *b) { fn(a, b); } int main() { char x = 'x', y = 'y', z = 'z'; foo(&x, &y); bar(&x, NULL, &z); baz(&x, &y); use_typedef(baz, &x, &y); printf("x: %c, y: %c, z: %c\n", x, y, z); ASSERT(65, x); ASSERT(66, y); ASSERT(122, z); return 0; } chibicc-1.0.23.1/test/offsetof.c000077500000000000000000000004111505335450300162600ustar00rootroot00000000000000#include "test.h" #include typedef struct { int a; char b; int c; double d; } T; int main() { ASSERT(0, offsetof(T, a)); ASSERT(4, offsetof(T, b)); ASSERT(8, offsetof(T, c)); ASSERT(16, offsetof(T, d)); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/offsetof1.c000066400000000000000000000016111505335450300163410ustar00rootroot00000000000000 #include #include "test.h" typedef void (*FuncPtr)(void); typedef struct { int a; FuncPtr func; double b; } MyStruct; void myFunction(void) { printf("Function called!\n"); } int main() { printf("Offset of a: %zu\n", offsetof(MyStruct, a)); // Should be 0 printf("Offset of func: %zu\n", offsetof(MyStruct, func)); // Should be sizeof(int) printf("Offset of b: %zu\n", offsetof(MyStruct, b)); // Should be sizeof(int) + sizeof(FuncPtr) printf("sizeof(int)= %zu\n", sizeof(int)); // Should be 4 ASSERT(4, sizeof(int)); ASSERT(8, sizeof(long)); ASSERT(4, SIZEOF_INT); ASSERT(8, SIZEOF_LONG); ASSERT(0, offsetof(MyStruct, a)); ASSERT(8, offsetof(MyStruct, func)); ASSERT(16, offsetof(MyStruct, b)); // Example usage MyStruct s; s.func = myFunction; s.func(); // Should print "Function called!" return 0; } chibicc-1.0.23.1/test/offsetof2.c000066400000000000000000000022621505335450300163450ustar00rootroot00000000000000 #include #include "test.h" typedef void (*Func1)(void); typedef void (*Func2)(int); typedef int (*Func3)(int); typedef struct { Func1 func1; Func2 func2; Func3 func3; } FunctionStruct; void myFunc1(void) { printf("Func1 called!\n"); } void myFunc2(int x) { printf("Func2 called with %d!\n", x); } int myFunc3(int x) { return x * 2; } int main() { printf("Offset of func1: %zu\n", offsetof(FunctionStruct, func1)); // Should be 0 ASSERT(0, offsetof(FunctionStruct, func1)); printf("Offset of func2: %zu\n", offsetof(FunctionStruct, func2)); // Should be sizeof(Func1) ASSERT(8, offsetof(FunctionStruct, func2) ); printf("Offset of func3: %zu\n", offsetof(FunctionStruct, func3)); // Should be sizeof(Func1) + sizeof(Func2) ASSERT(16, offsetof(FunctionStruct, func3)); // Example usage FunctionStruct fs; fs.func1 = myFunc1; fs.func2 = myFunc2; fs.func3 = myFunc3; fs.func1(); // Should print "Func1 called!" fs.func2(10); // Should print "Func2 called with 10!" printf("Func3 result: %d\n", fs.func3(5)); // Should print "Func3 result: 10" ASSERT(10, fs.func3(5)); return 0; } chibicc-1.0.23.1/test/offsetof3.c000066400000000000000000000020711505335450300163440ustar00rootroot00000000000000 #include #include "test.h" typedef void (*Callback)(int); typedef struct { int a; char b; Callback callback; double c; } ComplexStruct; void myCallback(int x) { printf("Callback called with %d\n", x); } int main() { printf("Offset of a: %zu\n", offsetof(ComplexStruct, a)); // Should be 0 printf("Offset of b: %zu\n", offsetof(ComplexStruct, b)); // Should be sizeof(int) printf("Offset of callback: %zu\n", offsetof(ComplexStruct, callback)); // Should be sizeof(int) + sizeof(char) printf("Offset of c: %zu\n", offsetof(ComplexStruct, c)); // Should be sizeof(int) + sizeof(char) + sizeof(Callback) ASSERT(0, offsetof(ComplexStruct, a)); ASSERT(4, offsetof(ComplexStruct, b)); // Assuming int is 4 bytes ASSERT(8, offsetof(ComplexStruct, callback)); // Assuming char is 1 byte ASSERT(16, offsetof(ComplexStruct, c)); // Assuming Callback is a pointer // Example usage ComplexStruct cs; cs.callback = myCallback; cs.callback(42); // Should print "Callback called with 42" return 0; } chibicc-1.0.23.1/test/oldc.c000066400000000000000000000014061505335450300153700ustar00rootroot00000000000000 //#include typedef unsigned char Byte; /* 8 bits */ typedef unsigned long uLong; /* 32 bits or more */ #define OF(args) args static char hello[] = "hello, hello!"; void test_compress OF((Byte * compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); /* =========================================================================== * Test compress() and uncompress() */ void test_compress(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; uLong len = 14; // if (strcmp((char *)uncompr, hello)) // { // return; // } // else // { // //printf("uncompress(): %s\n", (char *)uncompr); // } } int main() { return 0; }chibicc-1.0.23.1/test/pointer.c000077500000000000000000000034751505335450300161420ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(3, ({ int x=3; *&x; })); ASSERT(3, ({ int x=3; int *y=&x; int **z=&y; **z; })); ASSERT(5, ({ int x=3; int y=5; *(&x+1); })); ASSERT(3, ({ int x=3; int y=5; *(&y-1); })); ASSERT(5, ({ int x=3; int y=5; *(&x-(-1)); })); ASSERT(5, ({ int x=3; int *y=&x; *y=5; x; })); ASSERT(7, ({ int x=3; int y=5; *(&x+1)=7; y; })); ASSERT(7, ({ int x=3; int y=5; *(&y-2+1)=7; x; })); ASSERT(5, ({ int x=3; (&x+2)-&x+3; })); ASSERT(8, ({ int x, y; x=3; y=5; x+y; })); ASSERT(8, ({ int x=3, y=5; x+y; })); ASSERT(3, ({ int x[2]; int *y=&x; *y=3; *x; })); ASSERT(3, ({ int x[3]; *x=3; *(x+1)=4; *(x+2)=5; *x; })); ASSERT(4, ({ int x[3]; *x=3; *(x+1)=4; *(x+2)=5; *(x+1); })); ASSERT(5, ({ int x[3]; *x=3; *(x+1)=4; *(x+2)=5; *(x+2); })); ASSERT(0, ({ int x[2][3]; int *y=x; *y=0; **x; })); ASSERT(1, ({ int x[2][3]; int *y=x; *(y+1)=1; *(*x+1); })); ASSERT(2, ({ int x[2][3]; int *y=x; *(y+2)=2; *(*x+2); })); ASSERT(3, ({ int x[2][3]; int *y=x; *(y+3)=3; **(x+1); })); ASSERT(4, ({ int x[2][3]; int *y=x; *(y+4)=4; *(*(x+1)+1); })); ASSERT(5, ({ int x[2][3]; int *y=x; *(y+5)=5; *(*(x+1)+2); })); ASSERT(3, ({ int x[3]; *x=3; x[1]=4; x[2]=5; *x; })); ASSERT(4, ({ int x[3]; *x=3; x[1]=4; x[2]=5; *(x+1); })); ASSERT(5, ({ int x[3]; *x=3; x[1]=4; x[2]=5; *(x+2); })); ASSERT(5, ({ int x[3]; *x=3; x[1]=4; x[2]=5; *(x+2); })); ASSERT(5, ({ int x[3]; *x=3; x[1]=4; 2[x]=5; *(x+2); })); ASSERT(0, ({ int x[2][3]; int *y=x; y[0]=0; x[0][0]; })); ASSERT(1, ({ int x[2][3]; int *y=x; y[1]=1; x[0][1]; })); ASSERT(2, ({ int x[2][3]; int *y=x; y[2]=2; x[0][2]; })); ASSERT(3, ({ int x[2][3]; int *y=x; y[3]=3; x[1][0]; })); ASSERT(4, ({ int x[2][3]; int *y=x; y[4]=4; x[1][1]; })); ASSERT(5, ({ int x[2][3]; int *y=x; y[5]=5; x[1][2]; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/postgres_auth.c000066400000000000000000000054701505335450300173430ustar00rootroot00000000000000#include #include #include #include typedef uint32_t uint32; typedef struct { volatile uint32 value; } pg_atomic_uint32; #define AssertPointerAlignment(ptr, align) assert(((uintptr_t)(ptr) % (align)) == 0) #define LW_EXCLUSIVE 1 #define LW_SHARED 2 #define LW_LOCK_MASK 0xF #define LW_VAL_EXCLUSIVE 0x10 #define LW_VAL_SHARED 0x20 typedef struct { pg_atomic_uint32 state; #ifdef LOCK_DEBUG void* owner; #endif } LWLock; /* Atomic compare-and-exchange function */ static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { unsigned char ret; // Use unsigned char for setz result __asm__ __volatile__( "lock\n\t" "cmpxchgl %3, %2\n\t" "setz %1" : "=a" (*expected), "=q" (ret), "+m" (ptr->value) : "r" (newval), "a" (*expected) : "memory", "cc"); assert(1 == ret); return (bool) ret; } static inline bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { AssertPointerAlignment(ptr, 4); AssertPointerAlignment(expected, 4); return pg_atomic_compare_exchange_u32_impl(ptr, expected, newval); } /* Attempt to lock function */ static bool LWLockAttemptLock(LWLock *lock, uint32 mode) { uint32 old_state; //Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED); old_state = lock->state.value; while (true) { uint32 desired_state; bool lock_free; desired_state = old_state; if (mode == LW_EXCLUSIVE) { lock_free = (old_state & LW_LOCK_MASK) == 0; if (lock_free) desired_state += LW_VAL_EXCLUSIVE; } else { lock_free = (old_state & LW_VAL_EXCLUSIVE) == 0; if (lock_free) desired_state += LW_VAL_SHARED; } if (pg_atomic_compare_exchange_u32(&lock->state, &old_state, desired_state)) { if (lock_free) { #ifdef LOCK_DEBUG if (mode == LW_EXCLUSIVE) lock->owner = (void*)1; // Simulating a lock owner for debug #endif return false; } else return true; } } } int main() { LWLock lock = {{0}}; // Initialize the lock // Attempt to acquire an exclusive lock if (!LWLockAttemptLock(&lock, LW_EXCLUSIVE)) { printf("Acquired exclusive lock.\n"); } else { printf("Failed to acquire exclusive lock.\n"); } // Attempt to acquire a shared lock if (!LWLockAttemptLock(&lock, LW_SHARED)) { printf("Acquired shared lock.\n"); } else { printf("Failed to acquire shared lock.\n"); } return 0; } chibicc-1.0.23.1/test/postgres_compare.c000066400000000000000000000016651505335450300200320ustar00rootroot00000000000000 #include #include #include "test.h" typedef uint32_t uint32; typedef struct { volatile uint32_t value; } pg_atomic_uint32; static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { char ret; /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgl %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); ASSERT(1, ret); return (bool) ret; } int main() { pg_atomic_uint32 atomic_var = {0}; uint32_t expected = 0; uint32_t newval = 1; if (pg_atomic_compare_exchange_u32_impl(&atomic_var, &expected, newval)) { printf("Exchange succeeded\n"); } else { printf("Exchange failed\n"); } return 0; } chibicc-1.0.23.1/test/postgres_controlfile.c000066400000000000000000000025211505335450300207140ustar00rootroot00000000000000#include "test.h" #include #include typedef struct { union { uint32_t x; uint64_t y; } u; uint32_t version; uint8_t flags[4]; } ControlFile; int main(void) { ControlFile cf; // Zero the whole struct (mimics memset in write_gvar_data) memset(&cf, 0, sizeof(cf)); // Initialize union member 'x' cf.u.x = 0x12345678; // Initialize version cf.version = 42; // Initialize flags array cf.flags[0] = 1; cf.flags[1] = 2; cf.flags[2] = 3; cf.flags[3] = 4; // "Write" the struct to a buffer uint8_t buf[sizeof(ControlFile)]; memcpy(buf, &cf, sizeof(cf)); // Print buffer contents in hex printf("Buffer bytes:\n"); for (size_t i = 0; i < sizeof(buf); i++) { printf("%02x ", buf[i]); if ((i + 1) % 8 == 0) printf("\n"); } ASSERT(0x78, buf[0]); ASSERT(0x56, buf[1]); ASSERT(0x34, buf[2]); ASSERT(0x12, buf[3]); ASSERT(0x00, buf[4]); ASSERT(0x00, buf[5]); ASSERT(0x00, buf[6]); ASSERT(0x00, buf[7]); ASSERT(0x2a, buf[8]); ASSERT(0x00, buf[9]); ASSERT(0x00, buf[10]); ASSERT(0x00, buf[11]); ASSERT(0x01, buf[12]); ASSERT(0x02, buf[13]); ASSERT(0x03, buf[14]); ASSERT(0x04, buf[15]); return 0; } chibicc-1.0.23.1/test/postgres_crc32_sb8.c000066400000000000000000000670021505335450300200710ustar00rootroot00000000000000#include #include "test.h" #include typedef uint32_t uint32; typedef uint8_t uint8; typedef uint32_t pg_crc32c; // Simulated CRC table (values don't matter for reproducing the bug) pg_crc32c pg_crc32c_table[8][256] = { { 0x00000000, 0x03836BF2, 0xF7703BE1, 0xF4F35013, 0x1F979AC7, 0x1C14F135, 0xE8E7A126, 0xEB64CAD4, 0xCF58D98A, 0xCCDBB278, 0x3828E26B, 0x3BAB8999, 0xD0CF434D, 0xD34C28BF, 0x27BF78AC, 0x243C135E, 0x6FC75E10, 0x6C4435E2, 0x98B765F1, 0x9B340E03, 0x7050C4D7, 0x73D3AF25, 0x8720FF36, 0x84A394C4, 0xA09F879A, 0xA31CEC68, 0x57EFBC7B, 0x546CD789, 0xBF081D5D, 0xBC8B76AF, 0x487826BC, 0x4BFB4D4E, 0xDE8EBD20, 0xDD0DD6D2, 0x29FE86C1, 0x2A7DED33, 0xC11927E7, 0xC29A4C15, 0x36691C06, 0x35EA77F4, 0x11D664AA, 0x12550F58, 0xE6A65F4B, 0xE52534B9, 0x0E41FE6D, 0x0DC2959F, 0xF931C58C, 0xFAB2AE7E, 0xB149E330, 0xB2CA88C2, 0x4639D8D1, 0x45BAB323, 0xAEDE79F7, 0xAD5D1205, 0x59AE4216, 0x5A2D29E4, 0x7E113ABA, 0x7D925148, 0x8961015B, 0x8AE26AA9, 0x6186A07D, 0x6205CB8F, 0x96F69B9C, 0x9575F06E, 0xBC1D7B41, 0xBF9E10B3, 0x4B6D40A0, 0x48EE2B52, 0xA38AE186, 0xA0098A74, 0x54FADA67, 0x5779B195, 0x7345A2CB, 0x70C6C939, 0x8435992A, 0x87B6F2D8, 0x6CD2380C, 0x6F5153FE, 0x9BA203ED, 0x9821681F, 0xD3DA2551, 0xD0594EA3, 0x24AA1EB0, 0x27297542, 0xCC4DBF96, 0xCFCED464, 0x3B3D8477, 0x38BEEF85, 0x1C82FCDB, 0x1F019729, 0xEBF2C73A, 0xE871ACC8, 0x0315661C, 0x00960DEE, 0xF4655DFD, 0xF7E6360F, 0x6293C661, 0x6110AD93, 0x95E3FD80, 0x96609672, 0x7D045CA6, 0x7E873754, 0x8A746747, 0x89F70CB5, 0xADCB1FEB, 0xAE487419, 0x5ABB240A, 0x59384FF8, 0xB25C852C, 0xB1DFEEDE, 0x452CBECD, 0x46AFD53F, 0x0D549871, 0x0ED7F383, 0xFA24A390, 0xF9A7C862, 0x12C302B6, 0x11406944, 0xE5B33957, 0xE63052A5, 0xC20C41FB, 0xC18F2A09, 0x357C7A1A, 0x36FF11E8, 0xDD9BDB3C, 0xDE18B0CE, 0x2AEBE0DD, 0x29688B2F, 0x783BF682, 0x7BB89D70, 0x8F4BCD63, 0x8CC8A691, 0x67AC6C45, 0x642F07B7, 0x90DC57A4, 0x935F3C56, 0xB7632F08, 0xB4E044FA, 0x401314E9, 0x43907F1B, 0xA8F4B5CF, 0xAB77DE3D, 0x5F848E2E, 0x5C07E5DC, 0x17FCA892, 0x147FC360, 0xE08C9373, 0xE30FF881, 0x086B3255, 0x0BE859A7, 0xFF1B09B4, 0xFC986246, 0xD8A47118, 0xDB271AEA, 0x2FD44AF9, 0x2C57210B, 0xC733EBDF, 0xC4B0802D, 0x3043D03E, 0x33C0BBCC, 0xA6B54BA2, 0xA5362050, 0x51C57043, 0x52461BB1, 0xB922D165, 0xBAA1BA97, 0x4E52EA84, 0x4DD18176, 0x69ED9228, 0x6A6EF9DA, 0x9E9DA9C9, 0x9D1EC23B, 0x767A08EF, 0x75F9631D, 0x810A330E, 0x828958FC, 0xC97215B2, 0xCAF17E40, 0x3E022E53, 0x3D8145A1, 0xD6E58F75, 0xD566E487, 0x2195B494, 0x2216DF66, 0x062ACC38, 0x05A9A7CA, 0xF15AF7D9, 0xF2D99C2B, 0x19BD56FF, 0x1A3E3D0D, 0xEECD6D1E, 0xED4E06EC, 0xC4268DC3, 0xC7A5E631, 0x3356B622, 0x30D5DDD0, 0xDBB11704, 0xD8327CF6, 0x2CC12CE5, 0x2F424717, 0x0B7E5449, 0x08FD3FBB, 0xFC0E6FA8, 0xFF8D045A, 0x14E9CE8E, 0x176AA57C, 0xE399F56F, 0xE01A9E9D, 0xABE1D3D3, 0xA862B821, 0x5C91E832, 0x5F1283C0, 0xB4764914, 0xB7F522E6, 0x430672F5, 0x40851907, 0x64B90A59, 0x673A61AB, 0x93C931B8, 0x904A5A4A, 0x7B2E909E, 0x78ADFB6C, 0x8C5EAB7F, 0x8FDDC08D, 0x1AA830E3, 0x192B5B11, 0xEDD80B02, 0xEE5B60F0, 0x053FAA24, 0x06BCC1D6, 0xF24F91C5, 0xF1CCFA37, 0xD5F0E969, 0xD673829B, 0x2280D288, 0x2103B97A, 0xCA6773AE, 0xC9E4185C, 0x3D17484F, 0x3E9423BD, 0x756F6EF3, 0x76EC0501, 0x821F5512, 0x819C3EE0, 0x6AF8F434, 0x697B9FC6, 0x9D88CFD5, 0x9E0BA427, 0xBA37B779, 0xB9B4DC8B, 0x4D478C98, 0x4EC4E76A, 0xA5A02DBE, 0xA623464C, 0x52D0165F, 0x51537DAD, }, { 0x00000000, 0x7798A213, 0xEE304527, 0x99A8E734, 0xDC618A4E, 0xABF9285D, 0x3251CF69, 0x45C96D7A, 0xB8C3149D, 0xCF5BB68E, 0x56F351BA, 0x216BF3A9, 0x64A29ED3, 0x133A3CC0, 0x8A92DBF4, 0xFD0A79E7, 0x81F1C53F, 0xF669672C, 0x6FC18018, 0x1859220B, 0x5D904F71, 0x2A08ED62, 0xB3A00A56, 0xC438A845, 0x3932D1A2, 0x4EAA73B1, 0xD7029485, 0xA09A3696, 0xE5535BEC, 0x92CBF9FF, 0x0B631ECB, 0x7CFBBCD8, 0x02E38B7F, 0x757B296C, 0xECD3CE58, 0x9B4B6C4B, 0xDE820131, 0xA91AA322, 0x30B24416, 0x472AE605, 0xBA209FE2, 0xCDB83DF1, 0x5410DAC5, 0x238878D6, 0x664115AC, 0x11D9B7BF, 0x8871508B, 0xFFE9F298, 0x83124E40, 0xF48AEC53, 0x6D220B67, 0x1ABAA974, 0x5F73C40E, 0x28EB661D, 0xB1438129, 0xC6DB233A, 0x3BD15ADD, 0x4C49F8CE, 0xD5E11FFA, 0xA279BDE9, 0xE7B0D093, 0x90287280, 0x098095B4, 0x7E1837A7, 0x04C617FF, 0x735EB5EC, 0xEAF652D8, 0x9D6EF0CB, 0xD8A79DB1, 0xAF3F3FA2, 0x3697D896, 0x410F7A85, 0xBC050362, 0xCB9DA171, 0x52354645, 0x25ADE456, 0x6064892C, 0x17FC2B3F, 0x8E54CC0B, 0xF9CC6E18, 0x8537D2C0, 0xF2AF70D3, 0x6B0797E7, 0x1C9F35F4, 0x5956588E, 0x2ECEFA9D, 0xB7661DA9, 0xC0FEBFBA, 0x3DF4C65D, 0x4A6C644E, 0xD3C4837A, 0xA45C2169, 0xE1954C13, 0x960DEE00, 0x0FA50934, 0x783DAB27, 0x06259C80, 0x71BD3E93, 0xE815D9A7, 0x9F8D7BB4, 0xDA4416CE, 0xADDCB4DD, 0x347453E9, 0x43ECF1FA, 0xBEE6881D, 0xC97E2A0E, 0x50D6CD3A, 0x274E6F29, 0x62870253, 0x151FA040, 0x8CB74774, 0xFB2FE567, 0x87D459BF, 0xF04CFBAC, 0x69E41C98, 0x1E7CBE8B, 0x5BB5D3F1, 0x2C2D71E2, 0xB58596D6, 0xC21D34C5, 0x3F174D22, 0x488FEF31, 0xD1270805, 0xA6BFAA16, 0xE376C76C, 0x94EE657F, 0x0D46824B, 0x7ADE2058, 0xF9FAC3FB, 0x8E6261E8, 0x17CA86DC, 0x605224CF, 0x259B49B5, 0x5203EBA6, 0xCBAB0C92, 0xBC33AE81, 0x4139D766, 0x36A17575, 0xAF099241, 0xD8913052, 0x9D585D28, 0xEAC0FF3B, 0x7368180F, 0x04F0BA1C, 0x780B06C4, 0x0F93A4D7, 0x963B43E3, 0xE1A3E1F0, 0xA46A8C8A, 0xD3F22E99, 0x4A5AC9AD, 0x3DC26BBE, 0xC0C81259, 0xB750B04A, 0x2EF8577E, 0x5960F56D, 0x1CA99817, 0x6B313A04, 0xF299DD30, 0x85017F23, 0xFB194884, 0x8C81EA97, 0x15290DA3, 0x62B1AFB0, 0x2778C2CA, 0x50E060D9, 0xC94887ED, 0xBED025FE, 0x43DA5C19, 0x3442FE0A, 0xADEA193E, 0xDA72BB2D, 0x9FBBD657, 0xE8237444, 0x718B9370, 0x06133163, 0x7AE88DBB, 0x0D702FA8, 0x94D8C89C, 0xE3406A8F, 0xA68907F5, 0xD111A5E6, 0x48B942D2, 0x3F21E0C1, 0xC22B9926, 0xB5B33B35, 0x2C1BDC01, 0x5B837E12, 0x1E4A1368, 0x69D2B17B, 0xF07A564F, 0x87E2F45C, 0xFD3CD404, 0x8AA47617, 0x130C9123, 0x64943330, 0x215D5E4A, 0x56C5FC59, 0xCF6D1B6D, 0xB8F5B97E, 0x45FFC099, 0x3267628A, 0xABCF85BE, 0xDC5727AD, 0x999E4AD7, 0xEE06E8C4, 0x77AE0FF0, 0x0036ADE3, 0x7CCD113B, 0x0B55B328, 0x92FD541C, 0xE565F60F, 0xA0AC9B75, 0xD7343966, 0x4E9CDE52, 0x39047C41, 0xC40E05A6, 0xB396A7B5, 0x2A3E4081, 0x5DA6E292, 0x186F8FE8, 0x6FF72DFB, 0xF65FCACF, 0x81C768DC, 0xFFDF5F7B, 0x8847FD68, 0x11EF1A5C, 0x6677B84F, 0x23BED535, 0x54267726, 0xCD8E9012, 0xBA163201, 0x471C4BE6, 0x3084E9F5, 0xA92C0EC1, 0xDEB4ACD2, 0x9B7DC1A8, 0xECE563BB, 0x754D848F, 0x02D5269C, 0x7E2E9A44, 0x09B63857, 0x901EDF63, 0xE7867D70, 0xA24F100A, 0xD5D7B219, 0x4C7F552D, 0x3BE7F73E, 0xC6ED8ED9, 0xB1752CCA, 0x28DDCBFE, 0x5F4569ED, 0x1A8C0497, 0x6D14A684, 0xF4BC41B0, 0x8324E3A3, }, { 0x00000000, 0x7E9241A5, 0x0D526F4F, 0x73C02EEA, 0x1AA4DE9E, 0x64369F3B, 0x17F6B1D1, 0x6964F074, 0xC53E5138, 0xBBAC109D, 0xC86C3E77, 0xB6FE7FD2, 0xDF9A8FA6, 0xA108CE03, 0xD2C8E0E9, 0xAC5AA14C, 0x8A7DA270, 0xF4EFE3D5, 0x872FCD3F, 0xF9BD8C9A, 0x90D97CEE, 0xEE4B3D4B, 0x9D8B13A1, 0xE3195204, 0x4F43F348, 0x31D1B2ED, 0x42119C07, 0x3C83DDA2, 0x55E72DD6, 0x2B756C73, 0x58B54299, 0x2627033C, 0x14FB44E1, 0x6A690544, 0x19A92BAE, 0x673B6A0B, 0x0E5F9A7F, 0x70CDDBDA, 0x030DF530, 0x7D9FB495, 0xD1C515D9, 0xAF57547C, 0xDC977A96, 0xA2053B33, 0xCB61CB47, 0xB5F38AE2, 0xC633A408, 0xB8A1E5AD, 0x9E86E691, 0xE014A734, 0x93D489DE, 0xED46C87B, 0x8422380F, 0xFAB079AA, 0x89705740, 0xF7E216E5, 0x5BB8B7A9, 0x252AF60C, 0x56EAD8E6, 0x28789943, 0x411C6937, 0x3F8E2892, 0x4C4E0678, 0x32DC47DD, 0xD98065C7, 0xA7122462, 0xD4D20A88, 0xAA404B2D, 0xC324BB59, 0xBDB6FAFC, 0xCE76D416, 0xB0E495B3, 0x1CBE34FF, 0x622C755A, 0x11EC5BB0, 0x6F7E1A15, 0x061AEA61, 0x7888ABC4, 0x0B48852E, 0x75DAC48B, 0x53FDC7B7, 0x2D6F8612, 0x5EAFA8F8, 0x203DE95D, 0x49591929, 0x37CB588C, 0x440B7666, 0x3A9937C3, 0x96C3968F, 0xE851D72A, 0x9B91F9C0, 0xE503B865, 0x8C674811, 0xF2F509B4, 0x8135275E, 0xFFA766FB, 0xCD7B2126, 0xB3E96083, 0xC0294E69, 0xBEBB0FCC, 0xD7DFFFB8, 0xA94DBE1D, 0xDA8D90F7, 0xA41FD152, 0x0845701E, 0x76D731BB, 0x05171F51, 0x7B855EF4, 0x12E1AE80, 0x6C73EF25, 0x1FB3C1CF, 0x6121806A, 0x47068356, 0x3994C2F3, 0x4A54EC19, 0x34C6ADBC, 0x5DA25DC8, 0x23301C6D, 0x50F03287, 0x2E627322, 0x8238D26E, 0xFCAA93CB, 0x8F6ABD21, 0xF1F8FC84, 0x989C0CF0, 0xE60E4D55, 0x95CE63BF, 0xEB5C221A, 0x4377278B, 0x3DE5662E, 0x4E2548C4, 0x30B70961, 0x59D3F915, 0x2741B8B0, 0x5481965A, 0x2A13D7FF, 0x864976B3, 0xF8DB3716, 0x8B1B19FC, 0xF5895859, 0x9CEDA82D, 0xE27FE988, 0x91BFC762, 0xEF2D86C7, 0xC90A85FB, 0xB798C45E, 0xC458EAB4, 0xBACAAB11, 0xD3AE5B65, 0xAD3C1AC0, 0xDEFC342A, 0xA06E758F, 0x0C34D4C3, 0x72A69566, 0x0166BB8C, 0x7FF4FA29, 0x16900A5D, 0x68024BF8, 0x1BC26512, 0x655024B7, 0x578C636A, 0x291E22CF, 0x5ADE0C25, 0x244C4D80, 0x4D28BDF4, 0x33BAFC51, 0x407AD2BB, 0x3EE8931E, 0x92B23252, 0xEC2073F7, 0x9FE05D1D, 0xE1721CB8, 0x8816ECCC, 0xF684AD69, 0x85448383, 0xFBD6C226, 0xDDF1C11A, 0xA36380BF, 0xD0A3AE55, 0xAE31EFF0, 0xC7551F84, 0xB9C75E21, 0xCA0770CB, 0xB495316E, 0x18CF9022, 0x665DD187, 0x159DFF6D, 0x6B0FBEC8, 0x026B4EBC, 0x7CF90F19, 0x0F3921F3, 0x71AB6056, 0x9AF7424C, 0xE46503E9, 0x97A52D03, 0xE9376CA6, 0x80539CD2, 0xFEC1DD77, 0x8D01F39D, 0xF393B238, 0x5FC91374, 0x215B52D1, 0x529B7C3B, 0x2C093D9E, 0x456DCDEA, 0x3BFF8C4F, 0x483FA2A5, 0x36ADE300, 0x108AE03C, 0x6E18A199, 0x1DD88F73, 0x634ACED6, 0x0A2E3EA2, 0x74BC7F07, 0x077C51ED, 0x79EE1048, 0xD5B4B104, 0xAB26F0A1, 0xD8E6DE4B, 0xA6749FEE, 0xCF106F9A, 0xB1822E3F, 0xC24200D5, 0xBCD04170, 0x8E0C06AD, 0xF09E4708, 0x835E69E2, 0xFDCC2847, 0x94A8D833, 0xEA3A9996, 0x99FAB77C, 0xE768F6D9, 0x4B325795, 0x35A01630, 0x466038DA, 0x38F2797F, 0x5196890B, 0x2F04C8AE, 0x5CC4E644, 0x2256A7E1, 0x0471A4DD, 0x7AE3E578, 0x0923CB92, 0x77B18A37, 0x1ED57A43, 0x60473BE6, 0x1387150C, 0x6D1554A9, 0xC14FF5E5, 0xBFDDB440, 0xCC1D9AAA, 0xB28FDB0F, 0xDBEB2B7B, 0xA5796ADE, 0xD6B94434, 0xA82B0591, }, { 0x00000000, 0xB8AA45DD, 0x812367BF, 0x39892262, 0xF331227B, 0x4B9B67A6, 0x721245C4, 0xCAB80019, 0xE66344F6, 0x5EC9012B, 0x67402349, 0xDFEA6694, 0x1552668D, 0xADF82350, 0x94710132, 0x2CDB44EF, 0x3DB164E9, 0x851B2134, 0xBC920356, 0x0438468B, 0xCE804692, 0x762A034F, 0x4FA3212D, 0xF70964F0, 0xDBD2201F, 0x637865C2, 0x5AF147A0, 0xE25B027D, 0x28E30264, 0x904947B9, 0xA9C065DB, 0x116A2006, 0x8B1425D7, 0x33BE600A, 0x0A374268, 0xB29D07B5, 0x782507AC, 0xC08F4271, 0xF9066013, 0x41AC25CE, 0x6D776121, 0xD5DD24FC, 0xEC54069E, 0x54FE4343, 0x9E46435A, 0x26EC0687, 0x1F6524E5, 0xA7CF6138, 0xB6A5413E, 0x0E0F04E3, 0x37862681, 0x8F2C635C, 0x45946345, 0xFD3E2698, 0xC4B704FA, 0x7C1D4127, 0x50C605C8, 0xE86C4015, 0xD1E56277, 0x694F27AA, 0xA3F727B3, 0x1B5D626E, 0x22D4400C, 0x9A7E05D1, 0xE75FA6AB, 0x5FF5E376, 0x667CC114, 0xDED684C9, 0x146E84D0, 0xACC4C10D, 0x954DE36F, 0x2DE7A6B2, 0x013CE25D, 0xB996A780, 0x801F85E2, 0x38B5C03F, 0xF20DC026, 0x4AA785FB, 0x732EA799, 0xCB84E244, 0xDAEEC242, 0x6244879F, 0x5BCDA5FD, 0xE367E020, 0x29DFE039, 0x9175A5E4, 0xA8FC8786, 0x1056C25B, 0x3C8D86B4, 0x8427C369, 0xBDAEE10B, 0x0504A4D6, 0xCFBCA4CF, 0x7716E112, 0x4E9FC370, 0xF63586AD, 0x6C4B837C, 0xD4E1C6A1, 0xED68E4C3, 0x55C2A11E, 0x9F7AA107, 0x27D0E4DA, 0x1E59C6B8, 0xA6F38365, 0x8A28C78A, 0x32828257, 0x0B0BA035, 0xB3A1E5E8, 0x7919E5F1, 0xC1B3A02C, 0xF83A824E, 0x4090C793, 0x51FAE795, 0xE950A248, 0xD0D9802A, 0x6873C5F7, 0xA2CBC5EE, 0x1A618033, 0x23E8A251, 0x9B42E78C, 0xB799A363, 0x0F33E6BE, 0x36BAC4DC, 0x8E108101, 0x44A88118, 0xFC02C4C5, 0xC58BE6A7, 0x7D21A37A, 0x3FC9A052, 0x8763E58F, 0xBEEAC7ED, 0x06408230, 0xCCF88229, 0x7452C7F4, 0x4DDBE596, 0xF571A04B, 0xD9AAE4A4, 0x6100A179, 0x5889831B, 0xE023C6C6, 0x2A9BC6DF, 0x92318302, 0xABB8A160, 0x1312E4BD, 0x0278C4BB, 0xBAD28166, 0x835BA304, 0x3BF1E6D9, 0xF149E6C0, 0x49E3A31D, 0x706A817F, 0xC8C0C4A2, 0xE41B804D, 0x5CB1C590, 0x6538E7F2, 0xDD92A22F, 0x172AA236, 0xAF80E7EB, 0x9609C589, 0x2EA38054, 0xB4DD8585, 0x0C77C058, 0x35FEE23A, 0x8D54A7E7, 0x47ECA7FE, 0xFF46E223, 0xC6CFC041, 0x7E65859C, 0x52BEC173, 0xEA1484AE, 0xD39DA6CC, 0x6B37E311, 0xA18FE308, 0x1925A6D5, 0x20AC84B7, 0x9806C16A, 0x896CE16C, 0x31C6A4B1, 0x084F86D3, 0xB0E5C30E, 0x7A5DC317, 0xC2F786CA, 0xFB7EA4A8, 0x43D4E175, 0x6F0FA59A, 0xD7A5E047, 0xEE2CC225, 0x568687F8, 0x9C3E87E1, 0x2494C23C, 0x1D1DE05E, 0xA5B7A583, 0xD89606F9, 0x603C4324, 0x59B56146, 0xE11F249B, 0x2BA72482, 0x930D615F, 0xAA84433D, 0x122E06E0, 0x3EF5420F, 0x865F07D2, 0xBFD625B0, 0x077C606D, 0xCDC46074, 0x756E25A9, 0x4CE707CB, 0xF44D4216, 0xE5276210, 0x5D8D27CD, 0x640405AF, 0xDCAE4072, 0x1616406B, 0xAEBC05B6, 0x973527D4, 0x2F9F6209, 0x034426E6, 0xBBEE633B, 0x82674159, 0x3ACD0484, 0xF075049D, 0x48DF4140, 0x71566322, 0xC9FC26FF, 0x5382232E, 0xEB2866F3, 0xD2A14491, 0x6A0B014C, 0xA0B30155, 0x18194488, 0x219066EA, 0x993A2337, 0xB5E167D8, 0x0D4B2205, 0x34C20067, 0x8C6845BA, 0x46D045A3, 0xFE7A007E, 0xC7F3221C, 0x7F5967C1, 0x6E3347C7, 0xD699021A, 0xEF102078, 0x57BA65A5, 0x9D0265BC, 0x25A82061, 0x1C210203, 0xA48B47DE, 0x88500331, 0x30FA46EC, 0x0973648E, 0xB1D92153, 0x7B61214A, 0xC3CB6497, 0xFA4246F5, 0x42E80328, }, { 0x00000000, 0xAC6F1138, 0x58DF2270, 0xF4B03348, 0xB0BE45E0, 0x1CD154D8, 0xE8616790, 0x440E76A8, 0x910B67C5, 0x3D6476FD, 0xC9D445B5, 0x65BB548D, 0x21B52225, 0x8DDA331D, 0x796A0055, 0xD505116D, 0xD361228F, 0x7F0E33B7, 0x8BBE00FF, 0x27D111C7, 0x63DF676F, 0xCFB07657, 0x3B00451F, 0x976F5427, 0x426A454A, 0xEE055472, 0x1AB5673A, 0xB6DA7602, 0xF2D400AA, 0x5EBB1192, 0xAA0B22DA, 0x066433E2, 0x57B5A81B, 0xFBDAB923, 0x0F6A8A6B, 0xA3059B53, 0xE70BEDFB, 0x4B64FCC3, 0xBFD4CF8B, 0x13BBDEB3, 0xC6BECFDE, 0x6AD1DEE6, 0x9E61EDAE, 0x320EFC96, 0x76008A3E, 0xDA6F9B06, 0x2EDFA84E, 0x82B0B976, 0x84D48A94, 0x28BB9BAC, 0xDC0BA8E4, 0x7064B9DC, 0x346ACF74, 0x9805DE4C, 0x6CB5ED04, 0xC0DAFC3C, 0x15DFED51, 0xB9B0FC69, 0x4D00CF21, 0xE16FDE19, 0xA561A8B1, 0x090EB989, 0xFDBE8AC1, 0x51D19BF9, 0xAE6A5137, 0x0205400F, 0xF6B57347, 0x5ADA627F, 0x1ED414D7, 0xB2BB05EF, 0x460B36A7, 0xEA64279F, 0x3F6136F2, 0x930E27CA, 0x67BE1482, 0xCBD105BA, 0x8FDF7312, 0x23B0622A, 0xD7005162, 0x7B6F405A, 0x7D0B73B8, 0xD1646280, 0x25D451C8, 0x89BB40F0, 0xCDB53658, 0x61DA2760, 0x956A1428, 0x39050510, 0xEC00147D, 0x406F0545, 0xB4DF360D, 0x18B02735, 0x5CBE519D, 0xF0D140A5, 0x046173ED, 0xA80E62D5, 0xF9DFF92C, 0x55B0E814, 0xA100DB5C, 0x0D6FCA64, 0x4961BCCC, 0xE50EADF4, 0x11BE9EBC, 0xBDD18F84, 0x68D49EE9, 0xC4BB8FD1, 0x300BBC99, 0x9C64ADA1, 0xD86ADB09, 0x7405CA31, 0x80B5F979, 0x2CDAE841, 0x2ABEDBA3, 0x86D1CA9B, 0x7261F9D3, 0xDE0EE8EB, 0x9A009E43, 0x366F8F7B, 0xC2DFBC33, 0x6EB0AD0B, 0xBBB5BC66, 0x17DAAD5E, 0xE36A9E16, 0x4F058F2E, 0x0B0BF986, 0xA764E8BE, 0x53D4DBF6, 0xFFBBCACE, 0x5CD5A26E, 0xF0BAB356, 0x040A801E, 0xA8659126, 0xEC6BE78E, 0x4004F6B6, 0xB4B4C5FE, 0x18DBD4C6, 0xCDDEC5AB, 0x61B1D493, 0x9501E7DB, 0x396EF6E3, 0x7D60804B, 0xD10F9173, 0x25BFA23B, 0x89D0B303, 0x8FB480E1, 0x23DB91D9, 0xD76BA291, 0x7B04B3A9, 0x3F0AC501, 0x9365D439, 0x67D5E771, 0xCBBAF649, 0x1EBFE724, 0xB2D0F61C, 0x4660C554, 0xEA0FD46C, 0xAE01A2C4, 0x026EB3FC, 0xF6DE80B4, 0x5AB1918C, 0x0B600A75, 0xA70F1B4D, 0x53BF2805, 0xFFD0393D, 0xBBDE4F95, 0x17B15EAD, 0xE3016DE5, 0x4F6E7CDD, 0x9A6B6DB0, 0x36047C88, 0xC2B44FC0, 0x6EDB5EF8, 0x2AD52850, 0x86BA3968, 0x720A0A20, 0xDE651B18, 0xD80128FA, 0x746E39C2, 0x80DE0A8A, 0x2CB11BB2, 0x68BF6D1A, 0xC4D07C22, 0x30604F6A, 0x9C0F5E52, 0x490A4F3F, 0xE5655E07, 0x11D56D4F, 0xBDBA7C77, 0xF9B40ADF, 0x55DB1BE7, 0xA16B28AF, 0x0D043997, 0xF2BFF359, 0x5ED0E261, 0xAA60D129, 0x060FC011, 0x4201B6B9, 0xEE6EA781, 0x1ADE94C9, 0xB6B185F1, 0x63B4949C, 0xCFDB85A4, 0x3B6BB6EC, 0x9704A7D4, 0xD30AD17C, 0x7F65C044, 0x8BD5F30C, 0x27BAE234, 0x21DED1D6, 0x8DB1C0EE, 0x7901F3A6, 0xD56EE29E, 0x91609436, 0x3D0F850E, 0xC9BFB646, 0x65D0A77E, 0xB0D5B613, 0x1CBAA72B, 0xE80A9463, 0x4465855B, 0x006BF3F3, 0xAC04E2CB, 0x58B4D183, 0xF4DBC0BB, 0xA50A5B42, 0x09654A7A, 0xFDD57932, 0x51BA680A, 0x15B41EA2, 0xB9DB0F9A, 0x4D6B3CD2, 0xE1042DEA, 0x34013C87, 0x986E2DBF, 0x6CDE1EF7, 0xC0B10FCF, 0x84BF7967, 0x28D0685F, 0xDC605B17, 0x700F4A2F, 0x766B79CD, 0xDA0468F5, 0x2EB45BBD, 0x82DB4A85, 0xC6D53C2D, 0x6ABA2D15, 0x9E0A1E5D, 0x32650F65, 0xE7601E08, 0x4B0F0F30, 0xBFBF3C78, 0x13D02D40, 0x57DE5BE8, 0xFBB14AD0, 0x0F017998, 0xA36E68A0, }, { 0x00000000, 0x196B30EF, 0xC3A08CDB, 0xDACBBC34, 0x7737F5B2, 0x6E5CC55D, 0xB4977969, 0xADFC4986, 0x1F180660, 0x0673368F, 0xDCB88ABB, 0xC5D3BA54, 0x682FF3D2, 0x7144C33D, 0xAB8F7F09, 0xB2E44FE6, 0x3E300CC0, 0x275B3C2F, 0xFD90801B, 0xE4FBB0F4, 0x4907F972, 0x506CC99D, 0x8AA775A9, 0x93CC4546, 0x21280AA0, 0x38433A4F, 0xE288867B, 0xFBE3B694, 0x561FFF12, 0x4F74CFFD, 0x95BF73C9, 0x8CD44326, 0x8D16F485, 0x947DC46A, 0x4EB6785E, 0x57DD48B1, 0xFA210137, 0xE34A31D8, 0x39818DEC, 0x20EABD03, 0x920EF2E5, 0x8B65C20A, 0x51AE7E3E, 0x48C54ED1, 0xE5390757, 0xFC5237B8, 0x26998B8C, 0x3FF2BB63, 0xB326F845, 0xAA4DC8AA, 0x7086749E, 0x69ED4471, 0xC4110DF7, 0xDD7A3D18, 0x07B1812C, 0x1EDAB1C3, 0xAC3EFE25, 0xB555CECA, 0x6F9E72FE, 0x76F54211, 0xDB090B97, 0xC2623B78, 0x18A9874C, 0x01C2B7A3, 0xEB5B040E, 0xF23034E1, 0x28FB88D5, 0x3190B83A, 0x9C6CF1BC, 0x8507C153, 0x5FCC7D67, 0x46A74D88, 0xF443026E, 0xED283281, 0x37E38EB5, 0x2E88BE5A, 0x8374F7DC, 0x9A1FC733, 0x40D47B07, 0x59BF4BE8, 0xD56B08CE, 0xCC003821, 0x16CB8415, 0x0FA0B4FA, 0xA25CFD7C, 0xBB37CD93, 0x61FC71A7, 0x78974148, 0xCA730EAE, 0xD3183E41, 0x09D38275, 0x10B8B29A, 0xBD44FB1C, 0xA42FCBF3, 0x7EE477C7, 0x678F4728, 0x664DF08B, 0x7F26C064, 0xA5ED7C50, 0xBC864CBF, 0x117A0539, 0x081135D6, 0xD2DA89E2, 0xCBB1B90D, 0x7955F6EB, 0x603EC604, 0xBAF57A30, 0xA39E4ADF, 0x0E620359, 0x170933B6, 0xCDC28F82, 0xD4A9BF6D, 0x587DFC4B, 0x4116CCA4, 0x9BDD7090, 0x82B6407F, 0x2F4A09F9, 0x36213916, 0xECEA8522, 0xF581B5CD, 0x4765FA2B, 0x5E0ECAC4, 0x84C576F0, 0x9DAE461F, 0x30520F99, 0x29393F76, 0xF3F28342, 0xEA99B3AD, 0xD6B7081C, 0xCFDC38F3, 0x151784C7, 0x0C7CB428, 0xA180FDAE, 0xB8EBCD41, 0x62207175, 0x7B4B419A, 0xC9AF0E7C, 0xD0C43E93, 0x0A0F82A7, 0x1364B248, 0xBE98FBCE, 0xA7F3CB21, 0x7D387715, 0x645347FA, 0xE88704DC, 0xF1EC3433, 0x2B278807, 0x324CB8E8, 0x9FB0F16E, 0x86DBC181, 0x5C107DB5, 0x457B4D5A, 0xF79F02BC, 0xEEF43253, 0x343F8E67, 0x2D54BE88, 0x80A8F70E, 0x99C3C7E1, 0x43087BD5, 0x5A634B3A, 0x5BA1FC99, 0x42CACC76, 0x98017042, 0x816A40AD, 0x2C96092B, 0x35FD39C4, 0xEF3685F0, 0xF65DB51F, 0x44B9FAF9, 0x5DD2CA16, 0x87197622, 0x9E7246CD, 0x338E0F4B, 0x2AE53FA4, 0xF02E8390, 0xE945B37F, 0x6591F059, 0x7CFAC0B6, 0xA6317C82, 0xBF5A4C6D, 0x12A605EB, 0x0BCD3504, 0xD1068930, 0xC86DB9DF, 0x7A89F639, 0x63E2C6D6, 0xB9297AE2, 0xA0424A0D, 0x0DBE038B, 0x14D53364, 0xCE1E8F50, 0xD775BFBF, 0x3DEC0C12, 0x24873CFD, 0xFE4C80C9, 0xE727B026, 0x4ADBF9A0, 0x53B0C94F, 0x897B757B, 0x90104594, 0x22F40A72, 0x3B9F3A9D, 0xE15486A9, 0xF83FB646, 0x55C3FFC0, 0x4CA8CF2F, 0x9663731B, 0x8F0843F4, 0x03DC00D2, 0x1AB7303D, 0xC07C8C09, 0xD917BCE6, 0x74EBF560, 0x6D80C58F, 0xB74B79BB, 0xAE204954, 0x1CC406B2, 0x05AF365D, 0xDF648A69, 0xC60FBA86, 0x6BF3F300, 0x7298C3EF, 0xA8537FDB, 0xB1384F34, 0xB0FAF897, 0xA991C878, 0x735A744C, 0x6A3144A3, 0xC7CD0D25, 0xDEA63DCA, 0x046D81FE, 0x1D06B111, 0xAFE2FEF7, 0xB689CE18, 0x6C42722C, 0x752942C3, 0xD8D50B45, 0xC1BE3BAA, 0x1B75879E, 0x021EB771, 0x8ECAF457, 0x97A1C4B8, 0x4D6A788C, 0x54014863, 0xF9FD01E5, 0xE096310A, 0x3A5D8D3E, 0x2336BDD1, 0x91D2F237, 0x88B9C2D8, 0x52727EEC, 0x4B194E03, 0xE6E50785, 0xFF8E376A, 0x25458B5E, 0x3C2EBBB1, }, { 0x00000000, 0xC82C0368, 0x905906D0, 0x587505B8, 0xD1C5E0A5, 0x19E9E3CD, 0x419CE675, 0x89B0E51D, 0x53FD2D4E, 0x9BD12E26, 0xC3A42B9E, 0x0B8828F6, 0x8238CDEB, 0x4A14CE83, 0x1261CB3B, 0xDA4DC853, 0xA6FA5B9C, 0x6ED658F4, 0x36A35D4C, 0xFE8F5E24, 0x773FBB39, 0xBF13B851, 0xE766BDE9, 0x2F4ABE81, 0xF50776D2, 0x3D2B75BA, 0x655E7002, 0xAD72736A, 0x24C29677, 0xECEE951F, 0xB49B90A7, 0x7CB793CF, 0xBD835B3D, 0x75AF5855, 0x2DDA5DED, 0xE5F65E85, 0x6C46BB98, 0xA46AB8F0, 0xFC1FBD48, 0x3433BE20, 0xEE7E7673, 0x2652751B, 0x7E2770A3, 0xB60B73CB, 0x3FBB96D6, 0xF79795BE, 0xAFE29006, 0x67CE936E, 0x1B7900A1, 0xD35503C9, 0x8B200671, 0x430C0519, 0xCABCE004, 0x0290E36C, 0x5AE5E6D4, 0x92C9E5BC, 0x48842DEF, 0x80A82E87, 0xD8DD2B3F, 0x10F12857, 0x9941CD4A, 0x516DCE22, 0x0918CB9A, 0xC134C8F2, 0x7A07B77A, 0xB22BB412, 0xEA5EB1AA, 0x2272B2C2, 0xABC257DF, 0x63EE54B7, 0x3B9B510F, 0xF3B75267, 0x29FA9A34, 0xE1D6995C, 0xB9A39CE4, 0x718F9F8C, 0xF83F7A91, 0x301379F9, 0x68667C41, 0xA04A7F29, 0xDCFDECE6, 0x14D1EF8E, 0x4CA4EA36, 0x8488E95E, 0x0D380C43, 0xC5140F2B, 0x9D610A93, 0x554D09FB, 0x8F00C1A8, 0x472CC2C0, 0x1F59C778, 0xD775C410, 0x5EC5210D, 0x96E92265, 0xCE9C27DD, 0x06B024B5, 0xC784EC47, 0x0FA8EF2F, 0x57DDEA97, 0x9FF1E9FF, 0x16410CE2, 0xDE6D0F8A, 0x86180A32, 0x4E34095A, 0x9479C109, 0x5C55C261, 0x0420C7D9, 0xCC0CC4B1, 0x45BC21AC, 0x8D9022C4, 0xD5E5277C, 0x1DC92414, 0x617EB7DB, 0xA952B4B3, 0xF127B10B, 0x390BB263, 0xB0BB577E, 0x78975416, 0x20E251AE, 0xE8CE52C6, 0x32839A95, 0xFAAF99FD, 0xA2DA9C45, 0x6AF69F2D, 0xE3467A30, 0x2B6A7958, 0x731F7CE0, 0xBB337F88, 0xF40E6EF5, 0x3C226D9D, 0x64576825, 0xAC7B6B4D, 0x25CB8E50, 0xEDE78D38, 0xB5928880, 0x7DBE8BE8, 0xA7F343BB, 0x6FDF40D3, 0x37AA456B, 0xFF864603, 0x7636A31E, 0xBE1AA076, 0xE66FA5CE, 0x2E43A6A6, 0x52F43569, 0x9AD83601, 0xC2AD33B9, 0x0A8130D1, 0x8331D5CC, 0x4B1DD6A4, 0x1368D31C, 0xDB44D074, 0x01091827, 0xC9251B4F, 0x91501EF7, 0x597C1D9F, 0xD0CCF882, 0x18E0FBEA, 0x4095FE52, 0x88B9FD3A, 0x498D35C8, 0x81A136A0, 0xD9D43318, 0x11F83070, 0x9848D56D, 0x5064D605, 0x0811D3BD, 0xC03DD0D5, 0x1A701886, 0xD25C1BEE, 0x8A291E56, 0x42051D3E, 0xCBB5F823, 0x0399FB4B, 0x5BECFEF3, 0x93C0FD9B, 0xEF776E54, 0x275B6D3C, 0x7F2E6884, 0xB7026BEC, 0x3EB28EF1, 0xF69E8D99, 0xAEEB8821, 0x66C78B49, 0xBC8A431A, 0x74A64072, 0x2CD345CA, 0xE4FF46A2, 0x6D4FA3BF, 0xA563A0D7, 0xFD16A56F, 0x353AA607, 0x8E09D98F, 0x4625DAE7, 0x1E50DF5F, 0xD67CDC37, 0x5FCC392A, 0x97E03A42, 0xCF953FFA, 0x07B93C92, 0xDDF4F4C1, 0x15D8F7A9, 0x4DADF211, 0x8581F179, 0x0C311464, 0xC41D170C, 0x9C6812B4, 0x544411DC, 0x28F38213, 0xE0DF817B, 0xB8AA84C3, 0x708687AB, 0xF93662B6, 0x311A61DE, 0x696F6466, 0xA143670E, 0x7B0EAF5D, 0xB322AC35, 0xEB57A98D, 0x237BAAE5, 0xAACB4FF8, 0x62E74C90, 0x3A924928, 0xF2BE4A40, 0x338A82B2, 0xFBA681DA, 0xA3D38462, 0x6BFF870A, 0xE24F6217, 0x2A63617F, 0x721664C7, 0xBA3A67AF, 0x6077AFFC, 0xA85BAC94, 0xF02EA92C, 0x3802AA44, 0xB1B24F59, 0x799E4C31, 0x21EB4989, 0xE9C74AE1, 0x9570D92E, 0x5D5CDA46, 0x0529DFFE, 0xCD05DC96, 0x44B5398B, 0x8C993AE3, 0xD4EC3F5B, 0x1CC03C33, 0xC68DF460, 0x0EA1F708, 0x56D4F2B0, 0x9EF8F1D8, 0x174814C5, 0xDF6417AD, 0x87111215, 0x4F3D117D, }, { 0x00000000, 0x277D3C49, 0x4EFA7892, 0x698744DB, 0x6D821D21, 0x4AFF2168, 0x237865B3, 0x040559FA, 0xDA043B42, 0xFD79070B, 0x94FE43D0, 0xB3837F99, 0xB7862663, 0x90FB1A2A, 0xF97C5EF1, 0xDE0162B8, 0xB4097684, 0x93744ACD, 0xFAF30E16, 0xDD8E325F, 0xD98B6BA5, 0xFEF657EC, 0x97711337, 0xB00C2F7E, 0x6E0D4DC6, 0x4970718F, 0x20F73554, 0x078A091D, 0x038F50E7, 0x24F26CAE, 0x4D752875, 0x6A08143C, 0x9965000D, 0xBE183C44, 0xD79F789F, 0xF0E244D6, 0xF4E71D2C, 0xD39A2165, 0xBA1D65BE, 0x9D6059F7, 0x43613B4F, 0x641C0706, 0x0D9B43DD, 0x2AE67F94, 0x2EE3266E, 0x099E1A27, 0x60195EFC, 0x476462B5, 0x2D6C7689, 0x0A114AC0, 0x63960E1B, 0x44EB3252, 0x40EE6BA8, 0x679357E1, 0x0E14133A, 0x29692F73, 0xF7684DCB, 0xD0157182, 0xB9923559, 0x9EEF0910, 0x9AEA50EA, 0xBD976CA3, 0xD4102878, 0xF36D1431, 0x32CB001A, 0x15B63C53, 0x7C317888, 0x5B4C44C1, 0x5F491D3B, 0x78342172, 0x11B365A9, 0x36CE59E0, 0xE8CF3B58, 0xCFB20711, 0xA63543CA, 0x81487F83, 0x854D2679, 0xA2301A30, 0xCBB75EEB, 0xECCA62A2, 0x86C2769E, 0xA1BF4AD7, 0xC8380E0C, 0xEF453245, 0xEB406BBF, 0xCC3D57F6, 0xA5BA132D, 0x82C72F64, 0x5CC64DDC, 0x7BBB7195, 0x123C354E, 0x35410907, 0x314450FD, 0x16396CB4, 0x7FBE286F, 0x58C31426, 0xABAE0017, 0x8CD33C5E, 0xE5547885, 0xC22944CC, 0xC62C1D36, 0xE151217F, 0x88D665A4, 0xAFAB59ED, 0x71AA3B55, 0x56D7071C, 0x3F5043C7, 0x182D7F8E, 0x1C282674, 0x3B551A3D, 0x52D25EE6, 0x75AF62AF, 0x1FA77693, 0x38DA4ADA, 0x515D0E01, 0x76203248, 0x72256BB2, 0x555857FB, 0x3CDF1320, 0x1BA22F69, 0xC5A34DD1, 0xE2DE7198, 0x8B593543, 0xAC24090A, 0xA82150F0, 0x8F5C6CB9, 0xE6DB2862, 0xC1A6142B, 0x64960134, 0x43EB3D7D, 0x2A6C79A6, 0x0D1145EF, 0x09141C15, 0x2E69205C, 0x47EE6487, 0x609358CE, 0xBE923A76, 0x99EF063F, 0xF06842E4, 0xD7157EAD, 0xD3102757, 0xF46D1B1E, 0x9DEA5FC5, 0xBA97638C, 0xD09F77B0, 0xF7E24BF9, 0x9E650F22, 0xB918336B, 0xBD1D6A91, 0x9A6056D8, 0xF3E71203, 0xD49A2E4A, 0x0A9B4CF2, 0x2DE670BB, 0x44613460, 0x631C0829, 0x671951D3, 0x40646D9A, 0x29E32941, 0x0E9E1508, 0xFDF30139, 0xDA8E3D70, 0xB30979AB, 0x947445E2, 0x90711C18, 0xB70C2051, 0xDE8B648A, 0xF9F658C3, 0x27F73A7B, 0x008A0632, 0x690D42E9, 0x4E707EA0, 0x4A75275A, 0x6D081B13, 0x048F5FC8, 0x23F26381, 0x49FA77BD, 0x6E874BF4, 0x07000F2F, 0x207D3366, 0x24786A9C, 0x030556D5, 0x6A82120E, 0x4DFF2E47, 0x93FE4CFF, 0xB48370B6, 0xDD04346D, 0xFA790824, 0xFE7C51DE, 0xD9016D97, 0xB086294C, 0x97FB1505, 0x565D012E, 0x71203D67, 0x18A779BC, 0x3FDA45F5, 0x3BDF1C0F, 0x1CA22046, 0x7525649D, 0x525858D4, 0x8C593A6C, 0xAB240625, 0xC2A342FE, 0xE5DE7EB7, 0xE1DB274D, 0xC6A61B04, 0xAF215FDF, 0x885C6396, 0xE25477AA, 0xC5294BE3, 0xACAE0F38, 0x8BD33371, 0x8FD66A8B, 0xA8AB56C2, 0xC12C1219, 0xE6512E50, 0x38504CE8, 0x1F2D70A1, 0x76AA347A, 0x51D70833, 0x55D251C9, 0x72AF6D80, 0x1B28295B, 0x3C551512, 0xCF380123, 0xE8453D6A, 0x81C279B1, 0xA6BF45F8, 0xA2BA1C02, 0x85C7204B, 0xEC406490, 0xCB3D58D9, 0x153C3A61, 0x32410628, 0x5BC642F3, 0x7CBB7EBA, 0x78BE2740, 0x5FC31B09, 0x36445FD2, 0x1139639B, 0x7B3177A7, 0x5C4C4BEE, 0x35CB0F35, 0x12B6337C, 0x16B36A86, 0x31CE56CF, 0x58491214, 0x7F342E5D, 0xA1354CE5, 0x864870AC, 0xEFCF3477, 0xC8B2083E, 0xCCB751C4, 0xEBCA6D8D, 0x824D2956, 0xA530151F } }; // Simple CRC macro for testing #define CRC8(x) ((pg_crc32c)(x)) pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len) { const unsigned char *p = data; const uint32 *p4; // Handle 0-3 initial bytes one at a time while (len > 0 && ((uintptr_t)p & 3)) { crc = CRC8(*p++); len--; } // Process eight bytes at a time p4 = (const uint32 *)p; while (len >= 8) { uint32 a = *p4++ ^ crc; uint32 b = *p4++; // <-- can be uninitialized if len < 8 at end #ifdef WORDS_BIGENDIAN const uint8 c0 = b; const uint8 c1 = b >> 8; const uint8 c2 = b >> 16; const uint8 c3 = b >> 24; const uint8 c4 = a; const uint8 c5 = a >> 8; const uint8 c6 = a >> 16; const uint8 c7 = a >> 24; #else const uint8 c0 = b >> 24; const uint8 c1 = b >> 16; const uint8 c2 = b >> 8; const uint8 c3 = b; const uint8 c4 = a >> 24; const uint8 c5 = a >> 16; const uint8 c6 = a >> 8; const uint8 c7 = a; #endif crc = pg_crc32c_table[0][c0] ^ pg_crc32c_table[1][c1] ^ pg_crc32c_table[2][c2] ^ pg_crc32c_table[3][c3] ^ pg_crc32c_table[4][c4] ^ pg_crc32c_table[5][c5] ^ pg_crc32c_table[6][c6] ^ pg_crc32c_table[7][c7]; len -= 8; } return crc; } int main() { uint8_t buf[13]; // deliberately not multiple of 8 for (int i = 0; i < 13; i++) buf[i] = i + 1; pg_crc32c crc = 0; crc = pg_comp_crc32c_sb8(crc, buf, 13); printf("CRC: %u\n", crc); ASSERT(897250140, crc); return 0; } chibicc-1.0.23.1/test/postgres_hash.c000066400000000000000000000176771505335450300173410ustar00rootroot00000000000000#include #include #include #include #include "test.h" #define NUM_FREELISTS 32 typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ const uint8 pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; typedef uint32_t uint32; typedef uint32_t Size; // Placeholder for actual size type // Define the HASHELEMENT structure typedef struct HASHELEMENT { struct HASHELEMENT *link; // link to next entry in same bucket uint32 hashvalue; // hash function result for this entry } HASHELEMENT; // Define hash bucket and segment typedef HASHELEMENT *HASHBUCKET; typedef HASHBUCKET *HASHSEGMENT; // Define the structure for the hash header struct hash_header { // Placeholder for actual header contents }; // Define the HTAB structure struct HTAB { struct hash_header *hctl; /* => shared control information */ HASHSEGMENT *dir; /* directory of segment starts */ Size keysize; /* hash key length in bytes */ long ssize; /* segment size --- must be power of 2 */ int sshift; /* segment shift = log2(ssize) */ }; typedef struct HASHHDR HASHHDR; typedef unsigned char slock_t; typedef struct { slock_t mutex; /* spinlock for this freelist */ long nentries; /* number of entries in associated buckets */ HASHELEMENT *freeList; /* chain of free elements */ } FreeListData; struct HASHHDR { FreeListData freeList[NUM_FREELISTS]; long dsize; /* directory size */ long nsegs; /* number of allocated segments (<= dsize) */ uint32 max_bucket; /* ID of maximum bucket in use */ uint32 high_mask; /* mask to modulo into entire table */ uint32 low_mask; /* mask to modulo into lower half of table */ Size keysize; /* hash key length in bytes */ Size entrysize; /* total user element size in bytes */ long num_partitions; /* # partitions (must be power of 2), or 0 */ long max_dsize; /* 'dsize' limit if directory is fixed size */ long ssize; /* segment size --- must be power of 2 */ int sshift; /* segment shift = log2(ssize) */ int nelem_alloc; /* number of entries to allocate at once */ #ifdef HASH_STATISTICS long accesses; long collisions; #endif }; // Simulate error handling void hash_corrupted(struct HTAB *hashp) { fprintf(stderr, "Hash table corrupted!\n"); exit(EXIT_FAILURE); } static inline int pg_leftmost_one_pos32(uint32 word) { #ifdef HAVE__BUILTIN_CLZ return 31 - __builtin_clz(word); #elif defined(_MSC_VER) unsigned long result; bool non_zero; non_zero = _BitScanReverse(&result, word); return (int) result; #else int shift = 32 - 8; while ((word >> shift) == 0) shift -= 8; return shift + pg_leftmost_one_pos[(word >> shift) & 255]; #endif } static inline uint32 pg_ceil_log2_32(uint32 num) { if (num < 2) return 0; else return pg_leftmost_one_pos32(num - 1) + 1; } /* calculate ceil(log base 2) of num */ int my_log2(long num) { /* guard against too-large input, which would be invalid for pg_ceil_log2_*() */ if (num > LONG_MAX / 2) num = LONG_MAX / 2; #if SIZEOF_LONG < 8 return pg_ceil_log2_32(num); #else // return pg_ceil_log2_64(num); #endif } /* calculate first power of 2 >= num, bounded to what will fit in an int */ static int next_pow2_int(long num) { if (num > INT_MAX / 2) num = INT_MAX / 2; return 1 << my_log2(num); } /* Convert a hash value to a bucket number */ static inline uint32 calc_bucket(HASHHDR *hctl, uint32 hash_val) { uint32 bucket; bucket = hash_val & hctl->high_mask; if (bucket > hctl->max_bucket) bucket = bucket & hctl->low_mask; return bucket; } // Define the MOD macro #define MOD(x, y) ((x) & ((y) - 1)) // The function to be tested static inline uint32_t hash_initial_lookup(struct HTAB *hashp, uint32_t hashvalue, HASHBUCKET **bucketptr) { if (!hashp || !hashp->dir) { fprintf(stderr, "Hash table or directory is NULL!\n"); exit(EXIT_FAILURE); } struct hash_header *hctl = hashp->hctl; HASHSEGMENT segp; long segment_num; long segment_ndx; uint32_t bucket; bucket = calc_bucket(hctl, hashvalue); segment_num = bucket >> hashp->sshift; segment_ndx = MOD(bucket, hashp->ssize); if (segment_num >= hashp->ssize) { fprintf(stderr, "Segment number %ld out of bounds (%ld)!\n", segment_num, hashp->ssize); exit(EXIT_FAILURE); } segp = hashp->dir[segment_num]; if (!segp) { fprintf(stderr, "Hash segment %ld is NULL!\n", segment_num); exit(EXIT_FAILURE); } *bucketptr = &segp[segment_ndx]; return bucket; } // Initialize the hash table (simplified version) void init_htab(struct HTAB *hashp, int nelem) { int ssize; int sshift; int max_bucket; int high_mask; int low_mask; int nbuckets; HASHHDR *hctl; // Calculate segment size and shift ssize = next_pow2_int(nelem / 256); if (ssize < 1) ssize = 1; sshift = 8; // Allocate memory for hctl hctl = (HASHHDR *) malloc(sizeof(HASHHDR)); if (!hctl) { fprintf(stderr, "Memory allocation failed!\n"); exit(EXIT_FAILURE); } // Initialize hctl hctl->dsize = 1; hctl->nsegs = 1; hctl->max_bucket = 0; hctl->high_mask = 1; hctl->low_mask = 0; hctl->keysize = sizeof(int); // Example key size hctl->entrysize = sizeof(HASHELEMENT); hctl->num_partitions = 1; hctl->max_dsize = 1; hctl->ssize = ssize; hctl->sshift = sshift; hctl->nelem_alloc = nelem; nbuckets = next_pow2_int(nelem); // Allocate memory for directory hashp->dir = (HASHSEGMENT *) malloc(hctl->dsize * sizeof(HASHSEGMENT)); if (!hashp->dir) { fprintf(stderr, "Memory allocation failed!\n"); free(hctl); exit(EXIT_FAILURE); } // Allocate memory for first segment hashp->dir[0] = (HASHBUCKET *) calloc(ssize, sizeof(HASHBUCKET)); if (!hashp->dir[0]) { fprintf(stderr, "Memory allocation failed!\n"); free(hashp->dir); free(hctl); exit(EXIT_FAILURE); } // Initialize the hash table structure hashp->hctl = hctl; hashp->keysize = sizeof(int); hashp->ssize = ssize; hashp->sshift = sshift; } // Test the hash_initial_lookup function int main() { struct HTAB hash_table; struct HASHELEMENT element; uint32_t hash_value = 3926571702; HASHBUCKET *bucketptr; // Initialize the hash table with an example size init_htab(&hash_table, 1000); // Perform the hash lookup uint32_t bucket = hash_initial_lookup(&hash_table, hash_value, &bucketptr); // Output the result printf("Hash value: %u\n", hash_value); ASSERT(3926571702, hash_value); printf("Bucket: %u\n", bucket); printf("Bucket pointer: %p\n", (void *)bucketptr); // Cleanup allocated memory free(hash_table.dir[0]); free(hash_table.dir); free(hash_table.hctl); return 0; } chibicc-1.0.23.1/test/postgres_hash2.c000066400000000000000000000122221505335450300174000ustar00rootroot00000000000000#include #include #include #include #include #include "test.h" // Define types typedef unsigned char uint8; /* == 8 bits */ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ typedef uint32_t Size; // Placeholder for actual size type // Array for leftmost one position const uint8 pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; // Define the HASHELEMENT structure typedef struct HASHELEMENT { struct HASHELEMENT *link; // link to next entry in same bucket uint32 hashvalue; // hash function result for this entry } HASHELEMENT; // Define hash bucket and segment typedef HASHELEMENT *HASHBUCKET; typedef HASHBUCKET *HASHSEGMENT; // Define the structure for the hash header struct hash_header { // Placeholder for actual header contents }; // Define the HTAB structure struct HTAB { struct hash_header *hctl; /* => shared control information */ HASHSEGMENT *dir; /* directory of segment starts */ Size keysize; /* hash key length in bytes */ long ssize; /* segment size --- must be power of 2 */ int sshift; /* segment shift = log2(ssize) */ }; // Function to get the position of the leftmost one bit static inline int pg_leftmost_one_pos32(uint32 word) { if (word == 0) return -1; int shift = 24; if (word & 0xFFFF0000) { word >>= 16; shift += 16; } if (word & 0x0000FF00) { word >>= 8; shift += 8; } return shift + pg_leftmost_one_pos[word]; } // Function to calculate the ceiling of the log base 2 static inline uint32 pg_ceil_log2_32(uint32 num) { if (num < 2) return 0; else return pg_leftmost_one_pos32(num - 1) + 1; } // Simulate bucket calculation uint32_t calc_bucket(struct hash_header *hctl, uint32_t hashvalue) { return hashvalue % 16; // Simple hash function for simulation } // Define the MOD macro #define MOD(x, y) ((x) & ((y) - 1)) // Simulate error handling void hash_corrupted(struct HTAB *hashp) { fprintf(stderr, "Hash table corrupted!\n"); exit(EXIT_FAILURE); } // The function to be tested static inline uint32_t hash_initial_lookup(struct HTAB *hashp, uint32_t hashvalue, HASHBUCKET **bucketptr) { if (!hashp || !hashp->dir) { fprintf(stderr, "Hash table or directory is NULL!\n"); exit(EXIT_FAILURE); } struct hash_header *hctl = hashp->hctl; HASHSEGMENT segp; long segment_num; long segment_ndx; uint32_t bucket; bucket = calc_bucket(hctl, hashvalue); segment_num = bucket >> hashp->sshift; segment_ndx = MOD(bucket, hashp->ssize); if (segment_num >= hashp->ssize) { fprintf(stderr, "Segment number %ld out of bounds (%ld)!\n", segment_num, hashp->ssize); hash_corrupted(hashp); } segp = hashp->dir[segment_num]; if (segp == NULL) { hash_corrupted(hashp); } *bucketptr = &segp[segment_ndx]; return bucket; } // Main function to test the `hash_initial_lookup` function int main() { struct HTAB hashp; struct hash_header hctl; HASHBUCKET buckets[4]; // Array to hold bucket pointers HASHSEGMENT segments[2]; // Array to hold segment pointers // Initialize example data hashp.hctl = &hctl; hashp.ssize = 4; // Segment size (must be power of 2) hashp.sshift = 8; // Segment shift (log2 of ssize) hashp.dir = segments; hashp.ssize = 2; // Number of segments // Initialize segments for (int i = 0; i < 4; ++i) { buckets[i] = (HASHELEMENT *)malloc(sizeof(HASHELEMENT)); if (buckets[i] == NULL) { fprintf(stderr, "Memory allocation failed!\n"); exit(EXIT_FAILURE); } buckets[i]->link = NULL; buckets[i]->hashvalue = i; // Example hash value } segments[0] = &buckets[0]; segments[1] = &buckets[2]; HASHBUCKET *bucketptr; uint32_t bucket = hash_initial_lookup(&hashp, 3926571702, &bucketptr); printf("Bucket: %u\n", bucket); ASSERT(6, bucket); if (bucketptr != NULL) { HASHELEMENT *elem = (HASHELEMENT *)*bucketptr; printf("Bucket pointer value: %u\n", elem->hashvalue); ASSERT(0, elem->hashvalue); } else { printf("Bucket pointer is NULL\n"); } // Free allocated memory for (int i = 0; i < 4; ++i) { free(buckets[i]); } return 0; } chibicc-1.0.23.1/test/postgres_issues.c000066400000000000000000000173641505335450300177220ustar00rootroot00000000000000#include #include #include #include #include #include typedef int64_t int64; typedef uint64_t uint64; typedef int32_t int32; typedef uint32_t uint32; // Define macros for delays and logging #define MIN_DELAY_USEC 1000 #define MAX_DELAY_USEC 1000000 #define NUM_DELAYS 10 #define SPINS_PER_DELAY 1000 #define PANIC 1 #define S_LOCK_TEST #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define PG_HAVE_ATOMIC_FLAG_SUPPORT typedef struct pg_atomic_flag { volatile char value; } pg_atomic_flag; #define PG_HAVE_ATOMIC_U32_SUPPORT typedef struct pg_atomic_uint32 { volatile uint32 value; } pg_atomic_uint32; #endif #ifdef __x86_64__ #define PG_HAVE_ATOMIC_U64_SUPPORT typedef struct pg_atomic_uint64 { /* alignment guaranteed due to being on a 64bit platform */ volatile uint64 value; } pg_atomic_uint64; #endif /* __x86_64__ */ #ifdef __x86_64__ /* AMD Opteron, Intel EM64T */ #define HAS_TEST_AND_SET typedef unsigned char slock_t; #define TAS(lock) tas(lock) /* * On Intel EM64T, it's a win to use a non-locking test before the xchg proper, * but only when spinning. * * See also Implementing Scalable Atomic Locks for Multi-Core Intel(tm) EM64T * and IA32, by Michael Chynoweth and Mary R. Lee. As of this writing, it is * available at: * http://software.intel.com/en-us/articles/implementing-scalable-atomic-locks-for-multi-core-intel-em64t-and-ia32-architectures */ #define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock)) static __inline__ int tas(volatile slock_t *lock) { slock_t _res = 1; __asm__ __volatile__( " lock \n" " xchgb %0,%1 \n" : "+q"(_res), "+m"(*lock) : /* no inputs */ : "memory", "cc"); return (int) _res; } #define SPIN_DELAY() spin_delay() static __inline__ void spin_delay(void) { /* * Adding a PAUSE in the spin delay loop is demonstrably a no-op on * Opteron, but it may be of some use on EM64T, so we keep it. */ __asm__ __volatile__( " rep; nop \n"); } #endif /* __x86_64__ */ #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define PG_HAVE_ATOMIC_TEST_SET_FLAG static inline bool pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr) { char _res = 1; __asm__ __volatile__( " lock \n" " xchgb %0,%1 \n" : "+q"(_res), "+m"(ptr->value) : : "memory"); return _res == 0; } #define PG_HAVE_ATOMIC_CLEAR_FLAG static inline void pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr) { /* * On a TSO architecture like x86 it's sufficient to use a compiler * barrier to achieve release semantics. */ __asm__ __volatile__("" ::: "memory"); ptr->value = 0; } #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32 static inline bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval) { char ret; /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgl %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); return (bool) ret; } #define PG_HAVE_ATOMIC_FETCH_ADD_U32 static inline uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_) { uint32 res; __asm__ __volatile__( " lock \n" " xaddl %0,%1 \n" : "=q"(res), "=m"(ptr->value) : "0" (add_), "m"(ptr->value) : "memory", "cc"); return res; } #ifdef __x86_64__ #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64 static inline bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval) { char ret; //AssertPointerAlignment(expected, 8); /* * Perform cmpxchg and use the zero flag which it implicitly sets when * equal to measure the success. */ __asm__ __volatile__( " lock \n" " cmpxchgq %4,%5 \n" " setz %2 \n" : "=a" (*expected), "=m"(ptr->value), "=q" (ret) : "a" (*expected), "r" (newval), "m"(ptr->value) : "memory", "cc"); return (bool) ret; } #define PG_HAVE_ATOMIC_FETCH_ADD_U64 static inline uint64 pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_) { uint64 res; __asm__ __volatile__( " lock \n" " xaddq %0,%1 \n" : "=q"(res), "=m"(ptr->value) : "0" (add_), "m"(ptr->value) : "memory", "cc"); return res; } #endif /* __x86_64__ */ #endif /* defined(__GNUC__) || defined(__INTEL_COMPILER) */ // Struct to hold spin delay status typedef struct { int spins; int delays; int cur_delay; const char *file; int line; const char *func; } SpinDelayStatus; void s_unlock(volatile slock_t *lock) { *lock = 0; } // Dummy functions for simulation void pg_usleep(int usec) { usleep(usec); } void pgstat_report_wait_start(int event) { printf("Wait event started: %d\n", event); } void pgstat_report_wait_end() { printf("Wait event ended\n"); } void elog(int level, const char *fmt, ...) { // Simplified logging function va_list args; va_start(args, fmt); fprintf(stderr, "LOG [%d]: ", level); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); } double pg_prng_double(void *state) { // Simple random number generator for delay increase return (double)rand() / RAND_MAX; } static void s_lock_stuck(const char *file, int line, const char *func) { if (!func) func = "(unknown)"; #if defined(S_LOCK_TEST) fprintf(stderr, "\nStuck spinlock detected at %s, %s:%d.\n", func, file, line); exit(1); #else elog(PANIC, "stuck spinlock detected at %s, %s:%d", func, file, line); #endif } // Initialize spin delay status static void init_spin_delay(SpinDelayStatus *status, const char *file, int line, const char *func) { status->spins = 0; status->delays = 0; status->cur_delay = 0; status->file = file; status->line = line; status->func = func; } // Finish spin delay static void finish_spin_delay(SpinDelayStatus *status) { // Placeholder for additional cleanup if needed } // Perform spin delay void perform_spin_delay(SpinDelayStatus *status) { // CPU-specific delay each time through the loop for (int i = 0; i < SPINS_PER_DELAY; i++) { // Simulate spinning } // Block the process every spins_per_delay tries if (++(status->spins) >= SPINS_PER_DELAY) { if (++(status->delays) > NUM_DELAYS) s_lock_stuck(status->file, status->line, status->func); if (status->cur_delay == 0) // first time to delay? status->cur_delay = MIN_DELAY_USEC; // Report wait event and sleep pgstat_report_wait_start(0); pg_usleep(status->cur_delay); pgstat_report_wait_end(); // Increase delay by a random fraction between 1X and 2X status->cur_delay += (int)(status->cur_delay * pg_prng_double(NULL) + 0.5); // Wrap back to minimum delay when max is exceeded if (status->cur_delay > MAX_DELAY_USEC) status->cur_delay = MIN_DELAY_USEC; status->spins = 0; } } // Platform-independent portion of waiting for a spinlock int s_lock(volatile slock_t *lock, const char *file, int line, const char *func) { SpinDelayStatus delayStatus; init_spin_delay(&delayStatus, file, line, func); while (TAS_SPIN(lock)) { perform_spin_delay(&delayStatus); } finish_spin_delay(&delayStatus); return delayStatus.delays; } #ifdef USE_DEFAULT_S_UNLOCK void s_unlock(volatile slock_t *lock) { *lock = 0; // Release lock } #endif // Main function to test the spinlock functions int main() { slock_t lock = 0; SpinDelayStatus status = {0, 0, 0, __FILE__, __LINE__, __func__}; // Simulate acquiring and releasing the spinlock s_lock(&lock, __FILE__, __LINE__, __func__); printf("Lock acquired\n"); s_unlock(&lock); printf("Lock released\n"); return 0; } chibicc-1.0.23.1/test/postgres_log.c000066400000000000000000000044751505335450300171670ustar00rootroot00000000000000#include #include #include #include #include "test.h" const uint8_t pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; static inline int pg_leftmost_one_pos64(uint64_t word) { int shift = 64 - 8; while ((word >> shift) == 0) shift -= 8; return shift + pg_leftmost_one_pos[(word >> shift) & 255]; } static inline int pg_ceil_log2_64(uint64_t num) { if (num < 2) return 0; else return pg_leftmost_one_pos64(num - 1) + 1; } static int my_log2(long num) { if (num > LONG_MAX / 2) num = LONG_MAX / 2; #if SIZEOF_LONG < 8 return 2; #else return pg_ceil_log2_64(num); #endif } static int next_pow2_int(long num) { if (num > INT_MAX / 2) num = INT_MAX / 2; int log2 = my_log2(num); printf("pg_ceil_log2_64=%d\n", log2); return 1 << log2; } int main() { long test_values[] = {1, 2, 3, 536870912, LONG_MAX}; for (int i = 0; i < sizeof(test_values) / sizeof(test_values[0]); ++i) { printf("Input: %ld, next_pow2_int: %d\n", test_values[i], next_pow2_int(test_values[i])); if (i == 0) ASSERT(1, next_pow2_int(test_values[i]) ); else if (i == 1) ASSERT(2, next_pow2_int(test_values[i]) ); else if (i == 2) ASSERT(4, next_pow2_int(test_values[i]) ); else if (i == 3) ASSERT(536870912, next_pow2_int(test_values[i]) ); else if (i == 4) ASSERT(1073741824, next_pow2_int(test_values[i]) ); } return 0; } chibicc-1.0.23.1/test/postgres_log2.c000066400000000000000000000060161505335450300172420ustar00rootroot00000000000000#include #include #include #include #include "test.h" typedef uint32_t uint32; #define SIZEOF_LONG 8 const uint8_t pg_leftmost_one_pos[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }; static inline int pg_leftmost_one_pos32(uint32 word) { #ifdef HAVE__BUILTIN_CLZ return 31 - __builtin_clz(word); #elif defined(_MSC_VER) unsigned long result; bool non_zero; non_zero = _BitScanReverse(&result, word); return (int) result; #else int shift = 32 - 8; while ((word >> shift) == 0) shift -= 8; return shift + pg_leftmost_one_pos[(word >> shift) & 255]; #endif /* HAVE__BUILTIN_CLZ */ } static inline uint32 pg_ceil_log2_32(uint32 num) { if (num < 2) return 0; else return pg_leftmost_one_pos32(num - 1) + 1; } static inline int pg_leftmost_one_pos64(uint64_t word) { int shift = 64 - 8; while ((word >> shift) == 0) { shift -= 8; } int pos = shift + pg_leftmost_one_pos[(word >> shift) & 255]; printf("======%u\n", pos); return pos; } static inline int pg_ceil_log2_64(uint64_t num) { if (num < 2) return 0; else return pg_leftmost_one_pos64(num - 1) + 1; } static int my_log2(long num) { if (num > LONG_MAX / 2) num = LONG_MAX / 2; #if SIZEOF_LONG < 8 return pg_ceil_log2_32(num); #else return pg_ceil_log2_64(num); #endif } static int next_pow2_int(long num) { if (num > INT_MAX / 2) num = INT_MAX / 2; int log2 = my_log2(num); return 1 << log2; } int main() { long test_values[] = {1, 2, 3, 536870912, LONG_MAX}; printf("Size of long: %zu SIZEOF_LONG: %zu \n", sizeof(long), SIZEOF_LONG); for (int i = 0; i < sizeof(test_values) / sizeof(test_values[0]); ++i) { printf("Input: %ld, next_pow2_int: %d\n", test_values[i], next_pow2_int(test_values[i])); if (i == 0) ASSERT(1, next_pow2_int(test_values[i]) ); else if (i == 1) ASSERT(2, next_pow2_int(test_values[i]) ); else if (i == 2) ASSERT(4, next_pow2_int(test_values[i]) ); else if (i == 3) ASSERT(536870912, next_pow2_int(test_values[i]) ); else if (i == 4) ASSERT(1073741824, next_pow2_int(test_values[i]) ); } return 0; } chibicc-1.0.23.1/test/postgres_static.c000066400000000000000000000060351505335450300176670ustar00rootroot00000000000000#include #include #ifndef __cplusplus #ifdef HAVE__STATIC_ASSERT #define StaticAssertDecl(condition, errmessage) \ _Static_assert(condition, errmessage) #define StaticAssertStmt(condition, errmessage) \ do { _Static_assert(condition, errmessage); } while(0) #define StaticAssertExpr(condition, errmessage) \ ((void) ({ StaticAssertStmt(condition, errmessage); true; })) #else /* !HAVE__STATIC_ASSERT */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) #define StaticAssertStmt(condition, errmessage) \ ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; })) #define StaticAssertExpr(condition, errmessage) \ StaticAssertStmt(condition, errmessage) #endif /* HAVE__STATIC_ASSERT */ #else /* C++ */ #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 #define StaticAssertDecl(condition, errmessage) \ static_assert(condition, errmessage) #define StaticAssertStmt(condition, errmessage) \ static_assert(condition, errmessage) #define StaticAssertExpr(condition, errmessage) \ ({ static_assert(condition, errmessage); }) #else /* !__cpp_static_assert */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) #define StaticAssertStmt(condition, errmessage) \ do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0) #define StaticAssertExpr(condition, errmessage) \ ((void) ({ StaticAssertStmt(condition, errmessage); })) #endif /* __cpp_static_assert */ #endif /* C++ */ // Simulate the StaticAssertExpr macro (usually provided by PostgreSQL or a similar project) //#define StaticAssertExpr(condition, message) _Static_assert(condition, message) // Forward declaration of the AllocSetContextCreateInternal function void* AllocSetContextCreateInternal(void* parent, const char* name, int size); #ifdef HAVE__BUILTIN_CONSTANT_P #define AllocSetContextCreate(parent, name, ...) \ (StaticAssertExpr(__builtin_constant_p(name), \ "memory context names must be constant strings"), \ AllocSetContextCreateInternal(parent, name, __VA_ARGS__)) #else #define AllocSetContextCreate \ AllocSetContextCreateInternal #endif // Implementation of AllocSetContextCreateInternal function void* AllocSetContextCreateInternal(void* parent, const char* name, int size) { printf("Context created: name = %s, size = %d\n", name, size); return NULL; } int main(void) { // Define some parent context (NULL in this example) void* parent_context = NULL; // Use the macro with a constant string name AllocSetContextCreate(parent_context, "MyConstantContext", 1024); // Use the macro with a non-constant name (will trigger a static assertion if HAVE__BUILTIN_CONSTANT_P is defined) const char* non_constant_name = "MyDynamicContext"; // AllocSetContextCreate(parent_context, non_constant_name, 2048); // Uncommenting this will cause a compile-time error return 0; } chibicc-1.0.23.1/test/postgres_struct_func1.c000066400000000000000000000010131505335450300210070ustar00rootroot00000000000000 #include #include "test.h" struct MyStruct { void (*myFunc)(void *, const void *, size_t); }; // Initialize the struct with memcpy assigned to the function pointer struct MyStruct myStruct = { .myFunc = memcpy }; int main() { // Use the function pointer char src[20] = "Hello, World!"; char dest[20]; myStruct.myFunc(dest, src, strlen(src) + 1); printf("Copied string: %s\n", dest); // Should print: "Copied string: Hello, World!" ASSERT(13, strlen(dest)); return 0; } chibicc-1.0.23.1/test/postgres_struct_func2.c000066400000000000000000000010131505335450300210100ustar00rootroot00000000000000 #include #include "test.h" struct MyStruct { void (*myFunc)(void *, const void *, size_t); }; // Initialize the struct with memcpy assigned to the function pointer struct MyStruct myStruct = { .myFunc = memcpy }; int main() { // Use the function pointer char src[20] = "Hello, World!"; char dest[20]; myStruct.myFunc(dest, src, strlen(src) + 1); printf("Copied string: %s\n", dest); // Should print: "Copied string: Hello, World!" ASSERT(13, strlen(dest)); return 0; } chibicc-1.0.23.1/test/postgres_struct_func3.c000066400000000000000000000032471505335450300210240ustar00rootroot00000000000000 #include #include "test.h" // Define the functions with the required signatures void pgstat_archiver_init_shmem_cb(void *stats) { printf("Archiver init_shmem_cb called with %p\n", stats); ASSERT(0x1234, stats); } // Define a struct with two function pointers struct MyStruct { void (*copy_func)(void *dest, const void *src, size_t n); // Function like memcpy void (*init_shmem_cb)(void *stats); // Function for initializing shared memory }; // Initialize a static const array of MyStruct with two elements static const struct MyStruct myArray[2] = { [0] = { .copy_func = memcpy, // Only initialize the first function // init_shmem_cb is not initialized }, [1] = { // copy_func is not initialized .init_shmem_cb = pgstat_archiver_init_shmem_cb, // Only initialize the second function } }; int main() { char src[] = "Hello, world!"; char dest[50]; void *dummyStats = (void *)0x1234; // Some dummy stats pointer // Loop through the array and call the appropriate function for (int i = 0; i < 2; i++) { if (myArray[i].copy_func) { // Call the first function if it's initialized myArray[i].copy_func(dest, src, sizeof(src)); printf("Array element %d - Copy result: %s\n", i + 1, dest); } else if (myArray[i].init_shmem_cb) { // Call the second function if it's initialized myArray[i].init_shmem_cb(dummyStats); printf("Array element %d - Called init_shmem_cb\n", i + 1); } else { printf("Array element %d - No function initialized\n", i + 1); } } return 0; } chibicc-1.0.23.1/test/pragma-once.c000077500000000000000000000001551505335450300166430ustar00rootroot00000000000000#include "test.h" #pragma once #include "test/pragma-once.c" int main() { printf("OK\n"); return 0; } chibicc-1.0.23.1/test/protocol_binary.h000066400000000000000000000402151505335450300176620ustar00rootroot00000000000000/* * Copyright (c) <2008>, Sun Microsystems, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Summary: Constants used by to implement the binary protocol. * * Copy: See Copyright for the status of this software. * * Author: Trond Norbye */ #ifndef PROTOCOL_BINARY_H #define PROTOCOL_BINARY_H /** * This file contains definitions of the constants and packet formats * defined in the binary specification. Please note that you _MUST_ remember * to convert each multibyte field to / from network byte order to / from * host order. */ #ifdef __cplusplus extern "C" { #endif /** * Definition of the legal "magic" values used in a packet. * See section 3.1 Magic byte */ typedef enum { PROTOCOL_BINARY_REQ = 0x80, PROTOCOL_BINARY_RES = 0x81 } protocol_binary_magic; /** * Definition of the valid response status numbers. * See section 3.2 Response Status */ typedef enum { PROTOCOL_BINARY_RESPONSE_SUCCESS = 0x00, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT = 0x01, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS = 0x02, PROTOCOL_BINARY_RESPONSE_E2BIG = 0x03, PROTOCOL_BINARY_RESPONSE_EINVAL = 0x04, PROTOCOL_BINARY_RESPONSE_NOT_STORED = 0x05, PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL = 0x06, PROTOCOL_BINARY_RESPONSE_AUTH_ERROR = 0x20, PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE = 0x21, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND = 0x81, PROTOCOL_BINARY_RESPONSE_ENOMEM = 0x82 } protocol_binary_response_status; /** * Definition of the different command opcodes. * See section 3.3 Command Opcodes */ typedef enum { PROTOCOL_BINARY_CMD_GET = 0x00, PROTOCOL_BINARY_CMD_SET = 0x01, PROTOCOL_BINARY_CMD_ADD = 0x02, PROTOCOL_BINARY_CMD_REPLACE = 0x03, PROTOCOL_BINARY_CMD_DELETE = 0x04, PROTOCOL_BINARY_CMD_INCREMENT = 0x05, PROTOCOL_BINARY_CMD_DECREMENT = 0x06, PROTOCOL_BINARY_CMD_QUIT = 0x07, PROTOCOL_BINARY_CMD_FLUSH = 0x08, PROTOCOL_BINARY_CMD_GETQ = 0x09, PROTOCOL_BINARY_CMD_NOOP = 0x0a, PROTOCOL_BINARY_CMD_VERSION = 0x0b, PROTOCOL_BINARY_CMD_GETK = 0x0c, PROTOCOL_BINARY_CMD_GETKQ = 0x0d, PROTOCOL_BINARY_CMD_APPEND = 0x0e, PROTOCOL_BINARY_CMD_PREPEND = 0x0f, PROTOCOL_BINARY_CMD_STAT = 0x10, PROTOCOL_BINARY_CMD_SETQ = 0x11, PROTOCOL_BINARY_CMD_ADDQ = 0x12, PROTOCOL_BINARY_CMD_REPLACEQ = 0x13, PROTOCOL_BINARY_CMD_DELETEQ = 0x14, PROTOCOL_BINARY_CMD_INCREMENTQ = 0x15, PROTOCOL_BINARY_CMD_DECREMENTQ = 0x16, PROTOCOL_BINARY_CMD_QUITQ = 0x17, PROTOCOL_BINARY_CMD_FLUSHQ = 0x18, PROTOCOL_BINARY_CMD_APPENDQ = 0x19, PROTOCOL_BINARY_CMD_PREPENDQ = 0x1a, PROTOCOL_BINARY_CMD_TOUCH = 0x1c, PROTOCOL_BINARY_CMD_GAT = 0x1d, PROTOCOL_BINARY_CMD_GATQ = 0x1e, PROTOCOL_BINARY_CMD_GATK = 0x23, PROTOCOL_BINARY_CMD_GATKQ = 0x24, PROTOCOL_BINARY_CMD_SASL_LIST_MECHS = 0x20, PROTOCOL_BINARY_CMD_SASL_AUTH = 0x21, PROTOCOL_BINARY_CMD_SASL_STEP = 0x22, /* These commands are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ PROTOCOL_BINARY_CMD_RGET = 0x30, PROTOCOL_BINARY_CMD_RSET = 0x31, PROTOCOL_BINARY_CMD_RSETQ = 0x32, PROTOCOL_BINARY_CMD_RAPPEND = 0x33, PROTOCOL_BINARY_CMD_RAPPENDQ = 0x34, PROTOCOL_BINARY_CMD_RPREPEND = 0x35, PROTOCOL_BINARY_CMD_RPREPENDQ = 0x36, PROTOCOL_BINARY_CMD_RDELETE = 0x37, PROTOCOL_BINARY_CMD_RDELETEQ = 0x38, PROTOCOL_BINARY_CMD_RINCR = 0x39, PROTOCOL_BINARY_CMD_RINCRQ = 0x3a, PROTOCOL_BINARY_CMD_RDECR = 0x3b, PROTOCOL_BINARY_CMD_RDECRQ = 0x3c /* End Range operations */ } protocol_binary_command; /** * Definition of the data types in the packet * See section 3.4 Data Types */ typedef enum { PROTOCOL_BINARY_RAW_BYTES = 0x00 } protocol_binary_datatypes; /** * Definition of the header structure for a request packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t reserved; uint32_t bodylen; uint32_t opaque; uint64_t cas; } request; uint8_t bytes[24]; } protocol_binary_request_header; /** * Definition of the header structure for a response packet. * See section 2 */ typedef union { struct { uint8_t magic; uint8_t opcode; uint16_t keylen; uint8_t extlen; uint8_t datatype; uint16_t status; uint32_t bodylen; uint32_t opaque; uint64_t cas; } response; uint8_t bytes[24]; } protocol_binary_response_header; /** * Definition of a request-packet containing no extras */ typedef union { struct { protocol_binary_request_header header; } message; uint8_t bytes[sizeof(protocol_binary_request_header)]; } protocol_binary_request_no_extras; /** * Definition of a response-packet containing no extras */ typedef union { struct { protocol_binary_response_header header; } message; uint8_t bytes[sizeof(protocol_binary_response_header)]; } protocol_binary_response_no_extras; /** * Definition of the packet used by the get, getq, getk and getkq command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_get; typedef protocol_binary_request_no_extras protocol_binary_request_getq; typedef protocol_binary_request_no_extras protocol_binary_request_getk; typedef protocol_binary_request_no_extras protocol_binary_request_getkq; /** * Definition of the packet returned from a successful get, getq, getk and * getkq. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint32_t flags; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 4]; } protocol_binary_response_get; typedef protocol_binary_response_get protocol_binary_response_getq; typedef protocol_binary_response_get protocol_binary_response_getk; typedef protocol_binary_response_get protocol_binary_response_getkq; /** * Definition of the packet used by the delete command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_delete; /** * Definition of the packet returned by the delete command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_delete; /** * Definition of the packet used by the flush command * See section 4 * Please note that the expiration field is optional, so remember to see * check the header.bodysize to see if it is present. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_flush; /** * Definition of the packet returned by the flush command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_flush; /** * Definition of the packet used by set, add and replace * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t flags; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 8]; } protocol_binary_request_set; typedef protocol_binary_request_set protocol_binary_request_add; typedef protocol_binary_request_set protocol_binary_request_replace; /** * Definition of the packet returned by set, add and replace * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_set; typedef protocol_binary_response_no_extras protocol_binary_response_add; typedef protocol_binary_response_no_extras protocol_binary_response_replace; /** * Definition of the noop packet * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_noop; /** * Definition of the packet returned by the noop command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_noop; /** * Definition of the structure used by the increment and decrement * command. * See section 4 */ typedef union { struct { protocol_binary_request_header header; struct { uint64_t delta; uint64_t initial; uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 20]; } protocol_binary_request_incr; typedef protocol_binary_request_incr protocol_binary_request_decr; /** * Definition of the response from an incr or decr command * command. * See section 4 */ typedef union { struct { protocol_binary_response_header header; struct { uint64_t value; } body; } message; uint8_t bytes[sizeof(protocol_binary_response_header) + 8]; } protocol_binary_response_incr; typedef protocol_binary_response_incr protocol_binary_response_decr; /** * Definition of the quit * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_quit; /** * Definition of the packet returned by the quit command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_quit; /** * Definition of the packet used by append and prepend command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_append; typedef protocol_binary_request_no_extras protocol_binary_request_prepend; /** * Definition of the packet returned from a successful append or prepend * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_append; typedef protocol_binary_response_no_extras protocol_binary_response_prepend; /** * Definition of the packet used by the version command * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_version; /** * Definition of the packet returned from a successful version command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_version; /** * Definition of the packet used by the stats command. * See section 4 */ typedef protocol_binary_request_no_extras protocol_binary_request_stats; /** * Definition of the packet returned from a successful stats command * See section 4 */ typedef protocol_binary_response_no_extras protocol_binary_response_stats; /** * Definition of the packet used by the touch command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_touch; /** * Definition of the packet returned from the touch command */ typedef protocol_binary_response_no_extras protocol_binary_response_touch; /** * Definition of the packet used by the GAT(Q) command. */ typedef union { struct { protocol_binary_request_header header; struct { uint32_t expiration; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_gat; typedef protocol_binary_request_gat protocol_binary_request_gatq; typedef protocol_binary_request_gat protocol_binary_request_gatk; typedef protocol_binary_request_gat protocol_binary_request_gatkq; /** * Definition of the packet returned from the GAT(Q) */ typedef protocol_binary_response_get protocol_binary_response_gat; typedef protocol_binary_response_get protocol_binary_response_gatq; typedef protocol_binary_response_get protocol_binary_response_gatk; typedef protocol_binary_response_get protocol_binary_response_gatkq; /** * Definition of a request for a range operation. * See http://code.google.com/p/memcached/wiki/RangeOps * * These types are used for range operations and exist within * this header for use in other projects. Range operations are * not expected to be implemented in the memcached server itself. */ typedef union { struct { protocol_binary_response_header header; struct { uint16_t size; uint8_t reserved; uint8_t flags; uint32_t max_results; } body; } message; uint8_t bytes[sizeof(protocol_binary_request_header) + 4]; } protocol_binary_request_rangeop; typedef protocol_binary_request_rangeop protocol_binary_request_rget; typedef protocol_binary_request_rangeop protocol_binary_request_rset; typedef protocol_binary_request_rangeop protocol_binary_request_rsetq; typedef protocol_binary_request_rangeop protocol_binary_request_rappend; typedef protocol_binary_request_rangeop protocol_binary_request_rappendq; typedef protocol_binary_request_rangeop protocol_binary_request_rprepend; typedef protocol_binary_request_rangeop protocol_binary_request_rprependq; typedef protocol_binary_request_rangeop protocol_binary_request_rdelete; typedef protocol_binary_request_rangeop protocol_binary_request_rdeleteq; typedef protocol_binary_request_rangeop protocol_binary_request_rincr; typedef protocol_binary_request_rangeop protocol_binary_request_rincrq; typedef protocol_binary_request_rangeop protocol_binary_request_rdecr; typedef protocol_binary_request_rangeop protocol_binary_request_rdecrq; #ifdef __cplusplus } #endif #endif /* PROTOCOL_BINARY_H */ chibicc-1.0.23.1/test/queue.h000066400000000000000000000713131505335450300156040ustar00rootroot00000000000000// grabbed from https://raw.githubusercontent.com/freebsd/freebsd-src/master/sys/sys/queue.h // on jan 17th, 2021. /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)queue.h 8.5 (Berkeley) 8/20/94 * $FreeBSD$ */ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ /* * This file defines four types of data structures: singly-linked lists, * singly-linked tail queues, lists and tail queues. * * A singly-linked list is headed by a single forward pointer. The elements * are singly linked for minimum space and pointer manipulation overhead at * the expense of O(n) removal for arbitrary elements. New elements can be * added to the list after an existing element or at the head of the list. * Elements being removed from the head of the list should use the explicit * macro for this purpose for optimum efficiency. A singly-linked list may * only be traversed in the forward direction. Singly-linked lists are ideal * for applications with large datasets and few or no removals or for * implementing a LIFO queue. * * A singly-linked tail queue is headed by a pair of pointers, one to the * head of the list and the other to the tail of the list. The elements are * singly linked for minimum space and pointer manipulation overhead at the * expense of O(n) removal for arbitrary elements. New elements can be added * to the list after an existing element, at the head of the list, or at the * end of the list. Elements being removed from the head of the tail queue * should use the explicit macro for this purpose for optimum efficiency. * A singly-linked tail queue may only be traversed in the forward direction. * Singly-linked tail queues are ideal for applications with large datasets * and few or no removals or for implementing a FIFO queue. * * A list is headed by a single forward pointer (or an array of forward * pointers for a hash table header). The elements are doubly linked * so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before * or after an existing element or at the head of the list. A list * may be traversed in either direction. * * A tail queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly * linked so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before or * after an existing element, at the head of the list, or at the end of * the list. A tail queue may be traversed in either direction. * * For details on the use of these macros, see the queue(3) manual page. * * Below is a summary of implemented functions where: * + means the macro is available * - means the macro is not available * s means the macro is available but is slow (runs in O(n) time) * * SLIST LIST STAILQ TAILQ * _HEAD + + + + * _CLASS_HEAD + + + + * _HEAD_INITIALIZER + + + + * _ENTRY + + + + * _CLASS_ENTRY + + + + * _INIT + + + + * _EMPTY + + + + * _FIRST + + + + * _NEXT + + + + * _PREV - + - + * _LAST - - + + * _LAST_FAST - - - + * _FOREACH + + + + * _FOREACH_FROM + + + + * _FOREACH_SAFE + + + + * _FOREACH_FROM_SAFE + + + + * _FOREACH_REVERSE - - - + * _FOREACH_REVERSE_FROM - - - + * _FOREACH_REVERSE_SAFE - - - + * _FOREACH_REVERSE_FROM_SAFE - - - + * _INSERT_HEAD + + + + * _INSERT_BEFORE - + - + * _INSERT_AFTER + + + + * _INSERT_TAIL - - + + * _CONCAT s s + + * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - * _REMOVE s + s + * _SWAP + + + + * */ #ifdef QUEUE_MACRO_DEBUG #warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH #define QUEUE_MACRO_DEBUG_TRACE #define QUEUE_MACRO_DEBUG_TRASH #endif #ifdef QUEUE_MACRO_DEBUG_TRACE /* Store the last 2 places the queue element or head was altered */ struct qm_trace { unsigned long lastline; unsigned long prevline; const char *lastfile; const char *prevfile; }; #define TRACEBUF struct qm_trace trace; #define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } , #define QMD_TRACE_HEAD(head) do { \ (head)->trace.prevline = (head)->trace.lastline; \ (head)->trace.prevfile = (head)->trace.lastfile; \ (head)->trace.lastline = __LINE__; \ (head)->trace.lastfile = __FILE__; \ } while (0) #define QMD_TRACE_ELEM(elem) do { \ (elem)->trace.prevline = (elem)->trace.lastline; \ (elem)->trace.prevfile = (elem)->trace.lastfile; \ (elem)->trace.lastline = __LINE__; \ (elem)->trace.lastfile = __FILE__; \ } while (0) #else /* !QUEUE_MACRO_DEBUG_TRACE */ #define QMD_TRACE_ELEM(elem) #define QMD_TRACE_HEAD(head) #define TRACEBUF #define TRACEBUF_INITIALIZER #endif /* QUEUE_MACRO_DEBUG_TRACE */ #ifdef QUEUE_MACRO_DEBUG_TRASH #define QMD_SAVELINK(name, link) void **name = (void *)&(link) #define TRASHIT(x) do {(x) = (void *)-1;} while (0) #define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1) #else /* !QUEUE_MACRO_DEBUG_TRASH */ #define QMD_SAVELINK(name, link) #define TRASHIT(x) #define QMD_IS_TRASHED(x) 0 #endif /* QUEUE_MACRO_DEBUG_TRASH */ #ifdef __cplusplus /* * In C++ there can be structure lists and class lists: */ #define QUEUE_TYPEOF(type) type #else #define QUEUE_TYPEOF(type) struct type #endif /* * Singly-linked List declarations. */ #define SLIST_HEAD(name, type) \ struct name { \ struct type *slh_first; /* first element */ \ } #define SLIST_CLASS_HEAD(name, type) \ struct name { \ class type *slh_first; /* first element */ \ } #define SLIST_HEAD_INITIALIZER(head) \ { NULL } #define SLIST_ENTRY(type) \ struct { \ struct type *sle_next; /* next element */ \ } #define SLIST_CLASS_ENTRY(type) \ struct { \ class type *sle_next; /* next element */ \ } /* * Singly-linked List functions. */ #if (defined(_KERNEL) && defined(INVARIANTS)) #define QMD_SLIST_CHECK_PREVPTR(prevp, elm) do { \ if (*(prevp) != (elm)) \ panic("Bad prevptr *(%p) == %p != %p", \ (prevp), *(prevp), (elm)); \ } while (0) #else #define QMD_SLIST_CHECK_PREVPTR(prevp, elm) #endif #define SLIST_CONCAT(head1, head2, type, field) do { \ QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ if (curelm == NULL) { \ if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ SLIST_INIT(head2); \ } else if (SLIST_FIRST(head2) != NULL) { \ while (SLIST_NEXT(curelm, field) != NULL) \ curelm = SLIST_NEXT(curelm, field); \ SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ SLIST_INIT(head2); \ } \ } while (0) #define SLIST_EMPTY(head) ((head)->slh_first == NULL) #define SLIST_FIRST(head) ((head)->slh_first) #define SLIST_FOREACH(var, head, field) \ for ((var) = SLIST_FIRST((head)); \ (var); \ (var) = SLIST_NEXT((var), field)) #define SLIST_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ (var); \ (var) = SLIST_NEXT((var), field)) #define SLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = SLIST_FIRST((head)); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) = (tvar)) #define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) = (tvar)) #define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ for ((varp) = &SLIST_FIRST((head)); \ ((var) = *(varp)) != NULL; \ (varp) = &SLIST_NEXT((var), field)) #define SLIST_INIT(head) do { \ SLIST_FIRST((head)) = NULL; \ } while (0) #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ SLIST_NEXT((slistelm), field) = (elm); \ } while (0) #define SLIST_INSERT_HEAD(head, elm, field) do { \ SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ SLIST_FIRST((head)) = (elm); \ } while (0) #define SLIST_NEXT(elm, field) ((elm)->field.sle_next) #define SLIST_REMOVE(head, elm, type, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ if (SLIST_FIRST((head)) == (elm)) { \ SLIST_REMOVE_HEAD((head), field); \ } \ else { \ QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \ while (SLIST_NEXT(curelm, field) != (elm)) \ curelm = SLIST_NEXT(curelm, field); \ SLIST_REMOVE_AFTER(curelm, field); \ } \ TRASHIT(*oldnext); \ } while (0) #define SLIST_REMOVE_AFTER(elm, field) do { \ SLIST_NEXT(elm, field) = \ SLIST_NEXT(SLIST_NEXT(elm, field), field); \ } while (0) #define SLIST_REMOVE_HEAD(head, field) do { \ SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ } while (0) #define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \ QMD_SLIST_CHECK_PREVPTR(prevp, elm); \ *(prevp) = SLIST_NEXT(elm, field); \ TRASHIT((elm)->field.sle_next); \ } while (0) #define SLIST_SWAP(head1, head2, type) do { \ QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ SLIST_FIRST(head1) = SLIST_FIRST(head2); \ SLIST_FIRST(head2) = swap_first; \ } while (0) /* * Singly-linked Tail queue declarations. */ #define STAILQ_HEAD(name, type) \ struct name { \ struct type *stqh_first;/* first element */ \ struct type **stqh_last;/* addr of last next element */ \ } #define STAILQ_CLASS_HEAD(name, type) \ struct name { \ class type *stqh_first; /* first element */ \ class type **stqh_last; /* addr of last next element */ \ } #define STAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).stqh_first } #define STAILQ_ENTRY(type) \ struct { \ struct type *stqe_next; /* next element */ \ } #define STAILQ_CLASS_ENTRY(type) \ struct { \ class type *stqe_next; /* next element */ \ } /* * Singly-linked Tail queue functions. */ #define STAILQ_CONCAT(head1, head2) do { \ if (!STAILQ_EMPTY((head2))) { \ *(head1)->stqh_last = (head2)->stqh_first; \ (head1)->stqh_last = (head2)->stqh_last; \ STAILQ_INIT((head2)); \ } \ } while (0) #define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) #define STAILQ_FIRST(head) ((head)->stqh_first) #define STAILQ_FOREACH(var, head, field) \ for((var) = STAILQ_FIRST((head)); \ (var); \ (var) = STAILQ_NEXT((var), field)) #define STAILQ_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ (var); \ (var) = STAILQ_NEXT((var), field)) #define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = STAILQ_FIRST((head)); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) = (tvar)) #define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) = (tvar)) #define STAILQ_INIT(head) do { \ STAILQ_FIRST((head)) = NULL; \ (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ STAILQ_NEXT((tqelm), field) = (elm); \ } while (0) #define STAILQ_INSERT_HEAD(head, elm, field) do { \ if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ STAILQ_FIRST((head)) = (elm); \ } while (0) #define STAILQ_INSERT_TAIL(head, elm, field) do { \ STAILQ_NEXT((elm), field) = NULL; \ *(head)->stqh_last = (elm); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) #define STAILQ_LAST(head, type, field) \ (STAILQ_EMPTY((head)) ? NULL : \ __containerof((head)->stqh_last, \ QUEUE_TYPEOF(type), field.stqe_next)) #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) #define STAILQ_REMOVE(head, elm, type, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ if (STAILQ_FIRST((head)) == (elm)) { \ STAILQ_REMOVE_HEAD((head), field); \ } \ else { \ QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \ while (STAILQ_NEXT(curelm, field) != (elm)) \ curelm = STAILQ_NEXT(curelm, field); \ STAILQ_REMOVE_AFTER(head, curelm, field); \ } \ TRASHIT(*oldnext); \ } while (0) #define STAILQ_REMOVE_AFTER(head, elm, field) do { \ if ((STAILQ_NEXT(elm, field) = \ STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) #define STAILQ_REMOVE_HEAD(head, field) do { \ if ((STAILQ_FIRST((head)) = \ STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ (head)->stqh_last = &STAILQ_FIRST((head)); \ } while (0) #define STAILQ_SWAP(head1, head2, type) do { \ QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \ QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \ STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ (head1)->stqh_last = (head2)->stqh_last; \ STAILQ_FIRST(head2) = swap_first; \ (head2)->stqh_last = swap_last; \ if (STAILQ_EMPTY(head1)) \ (head1)->stqh_last = &STAILQ_FIRST(head1); \ if (STAILQ_EMPTY(head2)) \ (head2)->stqh_last = &STAILQ_FIRST(head2); \ } while (0) /* * List declarations. */ #define LIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } #define LIST_CLASS_HEAD(name, type) \ struct name { \ class type *lh_first; /* first element */ \ } #define LIST_HEAD_INITIALIZER(head) \ { NULL } #define LIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ } #define LIST_CLASS_ENTRY(type) \ struct { \ class type *le_next; /* next element */ \ class type **le_prev; /* address of previous next element */ \ } /* * List functions. */ #if (defined(_KERNEL) && defined(INVARIANTS)) /* * QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) * * If the list is non-empty, validates that the first element of the list * points back at 'head.' */ #define QMD_LIST_CHECK_HEAD(head, field) do { \ if (LIST_FIRST((head)) != NULL && \ LIST_FIRST((head))->field.le_prev != \ &LIST_FIRST((head))) \ panic("Bad list head %p first->prev != head", (head)); \ } while (0) /* * QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) * * If an element follows 'elm' in the list, validates that the next element * points back at 'elm.' */ #define QMD_LIST_CHECK_NEXT(elm, field) do { \ if (LIST_NEXT((elm), field) != NULL && \ LIST_NEXT((elm), field)->field.le_prev != \ &((elm)->field.le_next)) \ panic("Bad link elm %p next->prev != elm", (elm)); \ } while (0) /* * QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) * * Validates that the previous element (or head of the list) points to 'elm.' */ #define QMD_LIST_CHECK_PREV(elm, field) do { \ if (*(elm)->field.le_prev != (elm)) \ panic("Bad link elm %p prev->next != elm", (elm)); \ } while (0) #else #define QMD_LIST_CHECK_HEAD(head, field) #define QMD_LIST_CHECK_NEXT(elm, field) #define QMD_LIST_CHECK_PREV(elm, field) #endif /* (_KERNEL && INVARIANTS) */ #define LIST_CONCAT(head1, head2, type, field) do { \ QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ if (curelm == NULL) { \ if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ LIST_FIRST(head2)->field.le_prev = \ &LIST_FIRST((head1)); \ LIST_INIT(head2); \ } \ } else if (LIST_FIRST(head2) != NULL) { \ while (LIST_NEXT(curelm, field) != NULL) \ curelm = LIST_NEXT(curelm, field); \ LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \ LIST_INIT(head2); \ } \ } while (0) #define LIST_EMPTY(head) ((head)->lh_first == NULL) #define LIST_FIRST(head) ((head)->lh_first) #define LIST_FOREACH(var, head, field) \ for ((var) = LIST_FIRST((head)); \ (var); \ (var) = LIST_NEXT((var), field)) #define LIST_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ (var); \ (var) = LIST_NEXT((var), field)) #define LIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = LIST_FIRST((head)); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) = (tvar)) #define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) = (tvar)) #define LIST_INIT(head) do { \ LIST_FIRST((head)) = NULL; \ } while (0) #define LIST_INSERT_AFTER(listelm, elm, field) do { \ QMD_LIST_CHECK_NEXT(listelm, field); \ if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ LIST_NEXT((listelm), field)->field.le_prev = \ &LIST_NEXT((elm), field); \ LIST_NEXT((listelm), field) = (elm); \ (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ } while (0) #define LIST_INSERT_BEFORE(listelm, elm, field) do { \ QMD_LIST_CHECK_PREV(listelm, field); \ (elm)->field.le_prev = (listelm)->field.le_prev; \ LIST_NEXT((elm), field) = (listelm); \ *(listelm)->field.le_prev = (elm); \ (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ } while (0) #define LIST_INSERT_HEAD(head, elm, field) do { \ QMD_LIST_CHECK_HEAD((head), field); \ if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ LIST_FIRST((head)) = (elm); \ (elm)->field.le_prev = &LIST_FIRST((head)); \ } while (0) #define LIST_NEXT(elm, field) ((elm)->field.le_next) #define LIST_PREV(elm, head, type, field) \ ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ __containerof((elm)->field.le_prev, \ QUEUE_TYPEOF(type), field.le_next)) #define LIST_REMOVE(elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.le_next); \ QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ QMD_LIST_CHECK_NEXT(elm, field); \ QMD_LIST_CHECK_PREV(elm, field); \ if (LIST_NEXT((elm), field) != NULL) \ LIST_NEXT((elm), field)->field.le_prev = \ (elm)->field.le_prev; \ *(elm)->field.le_prev = LIST_NEXT((elm), field); \ TRASHIT(*oldnext); \ TRASHIT(*oldprev); \ } while (0) #define LIST_SWAP(head1, head2, type, field) do { \ QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \ LIST_FIRST((head1)) = LIST_FIRST((head2)); \ LIST_FIRST((head2)) = swap_tmp; \ if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ } while (0) /* * Tail queue declarations. */ #define TAILQ_HEAD(name, type) \ struct name { \ struct type *tqh_first; /* first element */ \ struct type **tqh_last; /* addr of last next element */ \ TRACEBUF \ } #define TAILQ_CLASS_HEAD(name, type) \ struct name { \ class type *tqh_first; /* first element */ \ class type **tqh_last; /* addr of last next element */ \ TRACEBUF \ } #define TAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } #define TAILQ_ENTRY(type) \ struct { \ struct type *tqe_next; /* next element */ \ struct type **tqe_prev; /* address of previous next element */ \ TRACEBUF \ } #define TAILQ_CLASS_ENTRY(type) \ struct { \ class type *tqe_next; /* next element */ \ class type **tqe_prev; /* address of previous next element */ \ TRACEBUF \ } /* * Tail queue functions. */ #if (defined(_KERNEL) && defined(INVARIANTS)) /* * QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) * * If the tailq is non-empty, validates that the first element of the tailq * points back at 'head.' */ #define QMD_TAILQ_CHECK_HEAD(head, field) do { \ if (!TAILQ_EMPTY(head) && \ TAILQ_FIRST((head))->field.tqe_prev != \ &TAILQ_FIRST((head))) \ panic("Bad tailq head %p first->prev != head", (head)); \ } while (0) /* * QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) * * Validates that the tail of the tailq is a pointer to pointer to NULL. */ #define QMD_TAILQ_CHECK_TAIL(head, field) do { \ if (*(head)->tqh_last != NULL) \ panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ } while (0) /* * QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) * * If an element follows 'elm' in the tailq, validates that the next element * points back at 'elm.' */ #define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ if (TAILQ_NEXT((elm), field) != NULL && \ TAILQ_NEXT((elm), field)->field.tqe_prev != \ &((elm)->field.tqe_next)) \ panic("Bad link elm %p next->prev != elm", (elm)); \ } while (0) /* * QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) * * Validates that the previous element (or head of the tailq) points to 'elm.' */ #define QMD_TAILQ_CHECK_PREV(elm, field) do { \ if (*(elm)->field.tqe_prev != (elm)) \ panic("Bad link elm %p prev->next != elm", (elm)); \ } while (0) #else #define QMD_TAILQ_CHECK_HEAD(head, field) #define QMD_TAILQ_CHECK_TAIL(head, headname) #define QMD_TAILQ_CHECK_NEXT(elm, field) #define QMD_TAILQ_CHECK_PREV(elm, field) #endif /* (_KERNEL && INVARIANTS) */ #define TAILQ_CONCAT(head1, head2, field) do { \ if (!TAILQ_EMPTY(head2)) { \ *(head1)->tqh_last = (head2)->tqh_first; \ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ (head1)->tqh_last = (head2)->tqh_last; \ TAILQ_INIT((head2)); \ QMD_TRACE_HEAD(head1); \ QMD_TRACE_HEAD(head2); \ } \ } while (0) #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) #define TAILQ_FIRST(head) ((head)->tqh_first) #define TAILQ_FOREACH(var, head, field) \ for ((var) = TAILQ_FIRST((head)); \ (var); \ (var) = TAILQ_NEXT((var), field)) #define TAILQ_FOREACH_FROM(var, head, field) \ for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ (var); \ (var) = TAILQ_NEXT((var), field)) #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = TAILQ_FIRST((head)); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) = (tvar)) #define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) = (tvar)) #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = TAILQ_LAST((head), headname); \ (var); \ (var) = TAILQ_PREV((var), headname, field)) #define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ (var); \ (var) = TAILQ_PREV((var), headname, field)) #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ for ((var) = TAILQ_LAST((head), headname); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) = (tvar)) #define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) = (tvar)) #define TAILQ_INIT(head) do { \ TAILQ_FIRST((head)) = NULL; \ (head)->tqh_last = &TAILQ_FIRST((head)); \ QMD_TRACE_HEAD(head); \ } while (0) #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ QMD_TAILQ_CHECK_NEXT(listelm, field); \ if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ TAILQ_NEXT((elm), field)->field.tqe_prev = \ &TAILQ_NEXT((elm), field); \ else { \ (head)->tqh_last = &TAILQ_NEXT((elm), field); \ QMD_TRACE_HEAD(head); \ } \ TAILQ_NEXT((listelm), field) = (elm); \ (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(listelm)->field); \ } while (0) #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ QMD_TAILQ_CHECK_PREV(listelm, field); \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ TAILQ_NEXT((elm), field) = (listelm); \ *(listelm)->field.tqe_prev = (elm); \ (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(listelm)->field); \ } while (0) #define TAILQ_INSERT_HEAD(head, elm, field) do { \ QMD_TAILQ_CHECK_HEAD(head, field); \ if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ TAILQ_FIRST((head))->field.tqe_prev = \ &TAILQ_NEXT((elm), field); \ else \ (head)->tqh_last = &TAILQ_NEXT((elm), field); \ TAILQ_FIRST((head)) = (elm); \ (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ QMD_TRACE_HEAD(head); \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) #define TAILQ_INSERT_TAIL(head, elm, field) do { \ QMD_TAILQ_CHECK_TAIL(head, field); \ TAILQ_NEXT((elm), field) = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &TAILQ_NEXT((elm), field); \ QMD_TRACE_HEAD(head); \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) #define TAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) /* * The FAST function is fast in that it causes no data access other * then the access to the head. The standard LAST function above * will cause a data access of both the element you want and * the previous element. FAST is very useful for instances when * you may want to prefetch the last data element. */ #define TAILQ_LAST_FAST(head, type, field) \ (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next)) #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) #define TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) #define TAILQ_PREV_FAST(elm, head, type, field) \ ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) #define TAILQ_REMOVE(head, elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ QMD_TAILQ_CHECK_NEXT(elm, field); \ QMD_TAILQ_CHECK_PREV(elm, field); \ if ((TAILQ_NEXT((elm), field)) != NULL) \ TAILQ_NEXT((elm), field)->field.tqe_prev = \ (elm)->field.tqe_prev; \ else { \ (head)->tqh_last = (elm)->field.tqe_prev; \ QMD_TRACE_HEAD(head); \ } \ *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ TRASHIT(*oldnext); \ TRASHIT(*oldprev); \ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) #define TAILQ_SWAP(head1, head2, type, field) do { \ QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \ QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \ (head1)->tqh_first = (head2)->tqh_first; \ (head1)->tqh_last = (head2)->tqh_last; \ (head2)->tqh_first = swap_first; \ (head2)->tqh_last = swap_last; \ if ((swap_first = (head1)->tqh_first) != NULL) \ swap_first->field.tqe_prev = &(head1)->tqh_first; \ else \ (head1)->tqh_last = &(head1)->tqh_first; \ if ((swap_first = (head2)->tqh_first) != NULL) \ swap_first->field.tqe_prev = &(head2)->tqh_first; \ else \ (head2)->tqh_last = &(head2)->tqh_first; \ } while (0) #endif /* !_SYS_QUEUE_H_ */ chibicc-1.0.23.1/test/regex.c000066400000000000000000000001061505335450300155550ustar00rootroot00000000000000#include #include "test.h" int main(void) { return 0; }chibicc-1.0.23.1/test/sasl_defs.h000066400000000000000000000012651505335450300164220ustar00rootroot00000000000000#ifndef SASL_DEFS_H #define SASL_DEFS_H 1 // Longest one I could find was ``9798-U-RSA-SHA1-ENC'' #define MAX_SASL_MECH_LEN 32 #if defined(HAVE_SASL_SASL_H) && defined(ENABLE_SASL) #include void init_sasl(void); extern char my_sasl_hostname[1025]; #else /* End of SASL support */ typedef void* sasl_conn_t; #define init_sasl() {} #define sasl_dispose(x) {} #define sasl_server_new(a, b, c, d, e, f, g, h) 1 #define sasl_listmech(a, b, c, d, e, f, g, h) 1 #define sasl_server_start(a, b, c, d, e, f) 1 #define sasl_server_step(a, b, c, d, e) 1 #define sasl_getprop(a, b, c) {} #define SASL_OK 0 #define SASL_CONTINUE -1 #endif /* sasl compat */ #endif /* SASL_DEFS_H */ chibicc-1.0.23.1/test/scalar.c000066400000000000000000000013461505335450300157170ustar00rootroot00000000000000#include "test.h" typedef int myint; typedef int myarr[5]; float add_many(float a, float b, float c, float d, float e) { return a + b + c + d + e; } myarr myarrfunc() { myarr m = {1, 2, 3, 4, 5}; return m; } myint add_many_int(myint a, myint b, myint c, myint d, myint e) { return a + b + c + d + e; } int main() { float x = add_many(1, 2, 3, 4, 5); printf("x = %f\n", x); ASSERT(15, x); myint a = 10; myint b = 5; myint c = 3; myint d = 7; myint e = 8; myint z = a + b + c + d + e; printf("z=%d\n", z); ASSERT(33, z); z = add_many_int(a, b, c, d, e); printf("z=%d\n", z); ASSERT(33, z); myarr t = myarrfunc(); return 0; } chibicc-1.0.23.1/test/semaphore.c000066400000000000000000000017211505335450300164320ustar00rootroot00000000000000#include #include #include #include #include "test.h" /* * Note: On modern Linux, `union semun` is typically not declared in headers * due to historical POSIX issues, so we declare it ourselves. */ union semun { int val; struct semid_ds *buf; unsigned short *array; struct seminfo *__buf; }; int main() { struct seminfo seminfo; union semun arg; printf("sizeof(struct seminfo) = %zu\n", sizeof(struct seminfo)); ASSERT(40, sizeof(struct seminfo)); arg.__buf = &seminfo; // For SEM_INFO, .__buf should point to seminfo int ret = semctl(0, 0, SEM_INFO, arg); if (ret < 0) { printf("semctl SEM_INFO failed: %s\n", strerror(errno)); return 1; } printf("semctl SEM_INFO succeeded\n"); printf("seminfo.semusz (used arrays): %d\n", seminfo.semusz); ASSERT(0, seminfo.semusz); printf("seminfo.semaem (allocated semaphores): %d\n", seminfo.semaem); ASSERT(0, seminfo.semaem); return 0; } chibicc-1.0.23.1/test/sizeof.c000077500000000000000000000057051505335450300157570ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(1, sizeof(char)); ASSERT(2, sizeof(short)); ASSERT(2, sizeof(short int)); ASSERT(2, sizeof(int short)); ASSERT(4, sizeof(int)); ASSERT(8, sizeof(long)); ASSERT(8, sizeof(long int)); ASSERT(8, sizeof(long int)); ASSERT(8, sizeof(char *)); ASSERT(8, sizeof(int *)); ASSERT(8, sizeof(long *)); ASSERT(8, sizeof(int **)); ASSERT(8, sizeof(int(*)[4])); ASSERT(32, sizeof(int*[4])); ASSERT(16, sizeof(int[4])); ASSERT(48, sizeof(int[3][4])); ASSERT(8, sizeof(struct {int a; int b;})); ASSERT(8, sizeof(-10 + (long)5)); ASSERT(8, sizeof(-10 - (long)5)); ASSERT(8, sizeof(-10 * (long)5)); ASSERT(8, sizeof(-10 / (long)5)); ASSERT(8, sizeof((long)-10 + 5)); ASSERT(8, sizeof((long)-10 - 5)); ASSERT(8, sizeof((long)-10 * 5)); ASSERT(8, sizeof((long)-10 / 5)); ASSERT(1, ({ char i; sizeof(++i); })); ASSERT(1, ({ char i; sizeof(i++); })); ASSERT(8, sizeof(int(*)[10])); ASSERT(8, sizeof(int(*)[][10])); ASSERT(4, sizeof(struct { int x, y[]; })); ASSERT(1, sizeof(char)); ASSERT(1, sizeof(signed char)); ASSERT(1, sizeof(signed char signed)); ASSERT(1, sizeof(unsigned char)); ASSERT(1, sizeof(unsigned char unsigned)); ASSERT(2, sizeof(short)); ASSERT(2, sizeof(int short)); ASSERT(2, sizeof(short int)); ASSERT(2, sizeof(signed short)); ASSERT(2, sizeof(int short signed)); ASSERT(2, sizeof(unsigned short)); ASSERT(2, sizeof(int short unsigned)); ASSERT(4, sizeof(int)); ASSERT(4, sizeof(signed int)); ASSERT(4, sizeof(signed)); ASSERT(4, sizeof(signed signed)); ASSERT(4, sizeof(unsigned int)); ASSERT(4, sizeof(unsigned)); ASSERT(4, sizeof(unsigned unsigned)); ASSERT(8, sizeof(long)); ASSERT(8, sizeof(signed long)); ASSERT(8, sizeof(signed long int)); ASSERT(8, sizeof(unsigned long)); ASSERT(8, sizeof(unsigned long int)); ASSERT(8, sizeof(long long)); ASSERT(8, sizeof(signed long long)); ASSERT(8, sizeof(signed long long int)); ASSERT(8, sizeof(unsigned long long)); ASSERT(8, sizeof(unsigned long long int)); ASSERT(1, sizeof((char)1)); ASSERT(2, sizeof((short)1)); ASSERT(4, sizeof((int)1)); ASSERT(8, sizeof((long)1)); ASSERT(4, sizeof((char)1 + (char)1)); ASSERT(4, sizeof((short)1 + (short)1)); ASSERT(4, sizeof(1?2:3)); ASSERT(4, sizeof(1?(short)2:(char)3)); ASSERT(8, sizeof(1?(long)2:(char)3)); ASSERT(1, sizeof(char) << 31 >> 31); ASSERT(1, sizeof(char) << 63 >> 63); ASSERT(4, sizeof(float)); ASSERT(8, sizeof(double)); ASSERT(4, sizeof(1f+2)); ASSERT(8, sizeof(1.0+2)); ASSERT(4, sizeof(1f-2)); ASSERT(8, sizeof(1.0-2)); ASSERT(4, sizeof(1f*2)); ASSERT(8, sizeof(1.0*2)); ASSERT(4, sizeof(1f/2)); ASSERT(8, sizeof(1.0/2)); ASSERT(16, sizeof(long double)); ASSERT(1, sizeof(main)); ASSERT(2147483647,0x7FFFFFFF); ASSERT(2147483646,0x7FFFFFFE); ASSERT(18446744073709551615,0xFFFFFFFFFFFFFFFFUL); ASSERT(4294967295,0x00000000FFFFFFFFUL); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/sizeof_struct.c000066400000000000000000000002531505335450300173510ustar00rootroot00000000000000 #include "test.h" struct { char c; char arr[]; } s = {1,2,3}; int main(void) { printf("%zu\n",sizeof(s)); // expected 1 ASSERT(1, sizeof(s)); return 0; }chibicc-1.0.23.1/test/sizeof_tests.c000066400000000000000000000121051505335450300171660ustar00rootroot00000000000000 #include #include "test.h" int main() { printf("sizeof(char) = %ld\n", sizeof(char)); ASSERT(1, sizeof(char)); printf("sizeof(short) = %ld\n", sizeof(short)); ASSERT(2, sizeof(short)); printf("sizeof(int) = %ld\n", sizeof(int)); ASSERT(4, sizeof(int)); printf("sizeof(long) = %ld\n", sizeof(long)); ASSERT(8, sizeof(long)); printf("sizeof(long long) = %ld\n", sizeof(long long)); ASSERT(8, sizeof(long long)); printf("sizeof(float) = %ld\n", sizeof(float)); ASSERT(4, sizeof(float)); printf("sizeof(double) = %ld\n", sizeof(double)); ASSERT(8, sizeof(double)); printf("sizeof(long double) = %ld\n", sizeof(long double)); ASSERT(16, sizeof(long double)); printf("sizeof(void *) = %ld\n", sizeof(void *)); ASSERT(8, sizeof(void *)); printf("sizeof(char *) = %ld\n", sizeof(char *)); ASSERT(8, sizeof(char *)); printf("sizeof(int *) = %ld\n", sizeof(int *)); ASSERT(8, sizeof(int *)); printf("sizeof(long *) = %ld\n", sizeof(long *)); ASSERT(8, sizeof(long *)); printf("sizeof(float *) = %ld\n", sizeof(long *)); ASSERT(8, sizeof(long *)); printf("sizeof(double *) = %ld\n", sizeof(double *)); ASSERT(8, sizeof(double *)); printf("sizeof(long double *) = %ld\n", sizeof(long double *)); ASSERT(8, sizeof(long double *)); printf("sizeof(char[10]) = %ld\n", sizeof(char[10])); ASSERT(10, sizeof(char[10])); printf("sizeof(int[10]) = %ld\n", sizeof(int[10])); ASSERT(40, sizeof(int[10])); printf("sizeof(long[10]) = %ld\n", sizeof(long[10])); ASSERT(80, sizeof(long[10])); printf("sizeof(float[10]) = %ld\n", sizeof(float[10])); ASSERT(40, sizeof(float[10])); printf("sizeof(double[10]) = %ld\n", sizeof(double[10])); ASSERT(80, sizeof(double[10])); printf("sizeof(long double[10]) = %ld\n", sizeof(long double[10])); ASSERT(160, sizeof(long double[10])); printf("sizeof(struct {int a; int b;}) = %ld\n", sizeof(struct {int a; int b;})); ASSERT(8, sizeof(struct {int a; int b;})); printf("sizeof(struct {int a; int b; int c;}) = %ld\n", sizeof(struct {int a; int b; int c;})); ASSERT(12, sizeof(struct {int a; int b; int c;})); printf("sizeof(struct {int a; int b; int c; int d;}) = %ld\n", sizeof(struct {int a; int b; int c; int d;})); ASSERT(16, sizeof(struct {int a; int b; int c; int d;})); printf("sizeof(struct {int a; int b; int c; int d; int e;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e;})); ASSERT(20, sizeof(struct {int a; int b; int c; int d; int e;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f;})); ASSERT(24, sizeof(struct {int a; int b; int c; int d; int e; int f;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g;})); ASSERT(28, sizeof(struct {int a; int b; int c; int d; int e; int f; int g;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h;})); ASSERT(32, sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i;})); ASSERT(36, sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j;})); ASSERT(40, sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k;})); ASSERT(44, sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l;})); ASSERT(48, sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l;})); printf("sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l; int m;}) = %ld\n", sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l; int m;})); ASSERT(52, sizeof(struct {int a; int b; int c; int d; int e; int f; int g; int h; int i; int j; int k; int l; int m;})); printf("expected = 18446744073709551615 %lld\n", 0xFFFFFFFFFFFFFFFFULL); printf("__WORDSIZE = %d\n", __WORDSIZE); ASSERT(64, __WORDSIZE); // __uint128_t u128 = 12345678900987654321; printf("%lld\n", (unsigned long long) LONG_MAX); // printf("%llx\n", (unsigned long long)(u128 & 0xFFFFFFFFFFFFFFFF)); printf("%lld\n", (unsigned long long) ULONG_MAX); return(0); }chibicc-1.0.23.1/test/sizeof_vla.c000066400000000000000000000002431505335450300166060ustar00rootroot00000000000000 #include "test.h" struct { char c; char arr[]; } s = {1,2,3}; int main(void) { printf("%zu\n", sizeof(s)); ASSERT(1, sizeof(s)); return 0; }chibicc-1.0.23.1/test/slabs.h000066400000000000000000000044521505335450300155640ustar00rootroot00000000000000/* slabs memory allocation */ #ifndef SLABS_H #define SLABS_H /** Init the subsystem. 1st argument is the limit on no. of bytes to allocate, 0 if no limit. 2nd argument is the growth factor; each slab will use a chunk size equal to the previous slab's chunk size times this factor. 3rd argument specifies if the slab allocator should allocate all memory up front (if true), or allocate memory in chunks as it is needed (if false) */ void slabs_init(const size_t limit, const double factor, const bool prealloc, const uint32_t *slab_sizes, void *mem_base_external, bool reuse_mem); /** Call only during init. Pre-allocates all available memory */ void slabs_prefill_global(void); /** * Given object size, return id to use when allocating/freeing memory for object * 0 means error: can't store such a large object */ unsigned int slabs_clsid(const size_t size); unsigned int slabs_size(const int clsid); /** Allocate object of given length. 0 on error */ /*@null@*/ #define SLABS_ALLOC_NO_NEWPAGE 1 void *slabs_alloc(const size_t size, unsigned int id, unsigned int flags); /** Free previously allocated object */ void slabs_free(void *ptr, size_t size, unsigned int id); /** Adjust global memory limit up or down */ bool slabs_adjust_mem_limit(size_t new_mem_limit); typedef struct { unsigned int chunks_per_page; unsigned int chunk_size; long int free_chunks; long int total_pages; } slab_stats_automove; void fill_slab_stats_automove(slab_stats_automove *am); unsigned int global_page_pool_size(bool *mem_flag); /** Fill buffer with stats */ /*@null@*/ void slabs_stats(ADD_STAT add_stats, void *c); /* Hints as to freespace in slab class */ unsigned int slabs_available_chunks(unsigned int id, bool *mem_flag, unsigned int *chunks_perslab); void slabs_mlock(void); void slabs_munlock(void); int start_slab_maintenance_thread(void); void stop_slab_maintenance_thread(void); enum reassign_result_type { REASSIGN_OK=0, REASSIGN_RUNNING, REASSIGN_BADCLASS, REASSIGN_NOSPARE, REASSIGN_SRC_DST_SAME }; enum reassign_result_type slabs_reassign(int src, int dst); void slabs_rebalancer_pause(void); void slabs_rebalancer_resume(void); #ifdef EXTSTORE void slabs_set_storage(void *arg); #endif /* Fixup for restartable code. */ unsigned int slabs_fixup(char *chunk, const int border); #endif chibicc-1.0.23.1/test/spin_delay.c000066400000000000000000000004321505335450300165740ustar00rootroot00000000000000#include "test.h" static inline void pg_spin_delay_impl(void) { __asm__ __volatile__("rep; nop"); } int main() { printf("Before spin delay.\n"); for (int i = 0; i < 1000000; i++) { pg_spin_delay_impl(); } printf("After spin delay.\n"); return 0; } chibicc-1.0.23.1/test/static_assert_1.c000066400000000000000000000001071505335450300175340ustar00rootroot00000000000000#include int main() { static_assert(3 < 4, "hello"); } chibicc-1.0.23.1/test/stats_prefix.h000066400000000000000000000034731505335450300171750ustar00rootroot00000000000000#ifndef STATS_PREFIX_H #define STATS_PREFIX_H /* The stats prefix subsystem stores detailed statistics for each key prefix. * Simple statistics like total number of GETS are stored by the Stats * subsystem defined elsewhere. * * Suppose the prefix delimiter is ":", then "user:123" and "user:456" both * have the same prefix "user". */ /* Initialize the stats prefix subsystem. Should be called once before other * functions are called. The global hash initialization should be done before * using this subsystem. */ void stats_prefix_init(char prefix_delimiter); /* Clear previously collected stats. Requires you to have the acquired * the STATS_LOCK() first. */ void stats_prefix_clear(void); /* Record a GET for a key */ void stats_prefix_record_get(const char *key, const size_t nkey, const bool is_hit); /* Record a DELETE for a key */ void stats_prefix_record_delete(const char *key, const size_t nkey); /* Record a SET for a key */ void stats_prefix_record_set(const char *key, const size_t nkey); /* Return the collected stats in a textual for suitable for writing to a client. * The size of the output text is stored in the length parameter. * Returns NULL on error */ char *stats_prefix_dump(int *length); /* Visible for testing */ #define PREFIX_HASH_SIZE 256 typedef struct _prefix_stats PREFIX_STATS; struct _prefix_stats { char *prefix; size_t prefix_len; uint64_t num_gets; uint64_t num_sets; uint64_t num_deletes; uint64_t num_hits; PREFIX_STATS *next; }; /* Return the PREFIX_STATS structure for the specified key, creating it if * it does not already exist. Returns NULL if the key does not contain * prefix delimiter, or if there was an error. Requires you to have acquired * STATS_LOCK() first. */ PREFIX_STATS *stats_prefix_find(const char *key, const size_t nkey); #endif chibicc-1.0.23.1/test/stdhdr.c000077500000000000000000000002771505335450300157470ustar00rootroot00000000000000#include "test.h" #include #include #include #include #include #include int main() { printf("OK\n"); return 0; } chibicc-1.0.23.1/test/stmtexpr2.c000066400000000000000000000010001505335450300164050ustar00rootroot00000000000000#include "test.h" struct S { int a, b; }; int main() { struct S s1 = {11,-22 }; ASSERT(11, ({ ({ s1; }).a; })); ASSERT(-22, ({ ({ s1; }); }).b ); ASSERT(11, ({ ({ struct S s2 = s1; s2; }).a; })); ASSERT(-22, ({ ({ struct S s2 = s1; s2; }); }).b ); ASSERT(11, ({ ({(struct S){11,22}; }).a; })); ASSERT(22, ({ ({(struct S){11,22}; }); }).b ); ASSERT(sizeof(void*), sizeof ({ int arr[17]; arr; }) ); ASSERT(sizeof(void*), sizeof ({ int arr[s1.a]; arr; }) ); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/string.c000077500000000000000000000032341505335450300157610ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(0, ""[0]); ASSERT(1, sizeof("")); ASSERT(97, "abc"[0]); ASSERT(98, "abc"[1]); ASSERT(99, "abc"[2]); ASSERT(0, "abc"[3]); ASSERT(4, sizeof("abc")); ASSERT(7, "\a"[0]); ASSERT(8, "\b"[0]); ASSERT(9, "\t"[0]); ASSERT(10, "\n"[0]); ASSERT(11, "\v"[0]); ASSERT(12, "\f"[0]); ASSERT(13, "\r"[0]); ASSERT(27, "\e"[0]); ASSERT(106, "\j"[0]); ASSERT(107, "\k"[0]); ASSERT(108, "\l"[0]); ASSERT(7, "\ax\ny"[0]); ASSERT(120, "\ax\ny"[1]); ASSERT(10, "\ax\ny"[2]); ASSERT(121, "\ax\ny"[3]); ASSERT(0, "\0"[0]); ASSERT(16, "\20"[0]); ASSERT(65, "\101"[0]); ASSERT(104, "\1500"[0]); ASSERT(0, "\x00"[0]); ASSERT(119, "\x77"[0]); ASSERT(7, sizeof("abc" "def")); ASSERT(9, sizeof("abc" "d" "efgh")); ASSERT(0, strcmp("abc" "d" "\nefgh", "abcd\nefgh")); ASSERT(0, !strcmp("abc" "d", "abcd\nefgh")); ASSERT(0, strcmp("\x9" "0", "\t0")); ASSERT(16, sizeof(L"abc" "")); ASSERT(28, sizeof(L"abc" "def")); ASSERT(28, sizeof(L"abc" L"def")); ASSERT(14, sizeof(u"abc" "def")); ASSERT(14, sizeof(u"abc" u"def")); ASSERT(L'a', (L"abc" "def")[0]); ASSERT(L'd', (L"abc" "def")[3]); ASSERT(L'\0', (L"abc" "def")[6]); ASSERT(u'a', (u"abc" "def")[0]); ASSERT(u'd', (u"abc" "def")[3]); ASSERT(u'\0', (u"abc" "def")[6]); ASSERT(L'あ', ("あ" L"")[0]); ASSERT(0343, ("\343\201\202" L"")[0]); ASSERT(0201, ("\343\201\202" L"")[1]); ASSERT(0202, ("\343\201\202" L"")[2]); ASSERT(0, ("\343\201\202" L"")[3]); ASSERT(L'a', ("a" "b" L"c")[0]); ASSERT(L'b', ("a" "b" L"c")[1]); ASSERT(L'c', ("a" "b" L"c")[2]); ASSERT(0, ("a" "b" L"c")[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/struct.c000077500000000000000000000064561505335450300160100ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(1, ({ struct {int a; int b;} x; x.a=1; x.b=2; x.a; })); ASSERT(2, ({ struct {int a; int b;} x; x.a=1; x.b=2; x.b; })); ASSERT(1, ({ struct {char a; int b; char c;} x; x.a=1; x.b=2; x.c=3; x.a; })); ASSERT(2, ({ struct {char a; int b; char c;} x; x.b=1; x.b=2; x.c=3; x.b; })); ASSERT(3, ({ struct {char a; int b; char c;} x; x.a=1; x.b=2; x.c=3; x.c; })); ASSERT(0, ({ struct {char a; char b;} x[3]; char *p=x; p[0]=0; x[0].a; })); ASSERT(1, ({ struct {char a; char b;} x[3]; char *p=x; p[1]=1; x[0].b; })); ASSERT(2, ({ struct {char a; char b;} x[3]; char *p=x; p[2]=2; x[1].a; })); ASSERT(3, ({ struct {char a; char b;} x[3]; char *p=x; p[3]=3; x[1].b; })); ASSERT(6, ({ struct {char a[3]; char b[5];} x; char *p=&x; x.a[0]=6; p[0]; })); ASSERT(7, ({ struct {char a[3]; char b[5];} x; char *p=&x; x.b[0]=7; p[3]; })); ASSERT(6, ({ struct { struct { char b; } a; } x; x.a.b=6; x.a.b; })); ASSERT(4, ({ struct {int a;} x; sizeof(x); })); ASSERT(8, ({ struct {int a; int b;} x; sizeof(x); })); ASSERT(8, ({ struct {int a, b;} x; sizeof(x); })); ASSERT(12, ({ struct {int a[3];} x; sizeof(x); })); ASSERT(16, ({ struct {int a;} x[4]; sizeof(x); })); ASSERT(24, ({ struct {int a[3];} x[2]; sizeof(x); })); ASSERT(2, ({ struct {char a; char b;} x; sizeof(x); })); ASSERT(0, ({ struct {} x; sizeof(x); })); ASSERT(8, ({ struct {char a; int b;} x; sizeof(x); })); ASSERT(8, ({ struct {int a; char b;} x; sizeof(x); })); ASSERT(8, ({ struct t {int a; int b;} x; struct t y; sizeof(y); })); ASSERT(8, ({ struct t {int a; int b;}; struct t y; sizeof(y); })); ASSERT(2, ({ struct t {char a[2];}; { struct t {char a[4];}; } struct t y; sizeof(y); })); ASSERT(3, ({ struct t {int x;}; int t=1; struct t y; y.x=2; t+y.x; })); ASSERT(3, ({ struct t {char a;} x; struct t *y = &x; x.a=3; y->a; })); ASSERT(3, ({ struct t {char a;} x; struct t *y = &x; y->a=3; x.a; })); ASSERT(3, ({ struct {int a,b;} x,y; x.a=3; y=x; y.a; })); ASSERT(7, ({ struct t {int a,b;}; struct t x; x.a=7; struct t y; struct t *z=&y; *z=x; y.a; })); ASSERT(7, ({ struct t {int a,b;}; struct t x; x.a=7; struct t y, *p=&x, *q=&y; *q=*p; y.a; })); ASSERT(5, ({ struct t {char a, b;} x, y; x.a=5; y=x; y.a; })); ASSERT(3, ({ struct {int a,b;} x,y; x.a=3; y=x; y.a; })); ASSERT(7, ({ struct t {int a,b;}; struct t x; x.a=7; struct t y; struct t *z=&y; *z=x; y.a; })); ASSERT(7, ({ struct t {int a,b;}; struct t x; x.a=7; struct t y, *p=&x, *q=&y; *q=*p; y.a; })); ASSERT(5, ({ struct t {char a, b;} x, y; x.a=5; y=x; y.a; })); ASSERT(8, ({ struct t {int a; int b;} x; struct t y; sizeof(y); })); ASSERT(8, ({ struct t {int a; int b;}; struct t y; sizeof(y); })); ASSERT(16, ({ struct {char a; long b;} x; sizeof(x); })); ASSERT(4, ({ struct {char a; short b;} x; sizeof(x); })); ASSERT(8, ({ struct foo *bar; sizeof(bar); })); ASSERT(4, ({ struct T *foo; struct T {int x;}; sizeof(struct T); })); ASSERT(1, ({ struct T { struct T *next; int x; } a; struct T b; b.x=1; a.next=&b; a.next->x; })); ASSERT(4, ({ typedef struct T T; struct T { int x; }; sizeof(T); })); ASSERT(2, ({ struct {int a;} x={1}, y={2}; (x=y).a; })); ASSERT(1, ({ struct {int a;} x={1}, y={2}; (1?x:y).a; })); ASSERT(2, ({ struct {int a;} x={1}, y={2}; (0?x:y).a; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/struct4.c000066400000000000000000000006401505335450300160560ustar00rootroot00000000000000#include #include "test.h" typedef unsigned char u8; struct S { u8 a,b; u8 c[2]; }; struct U { u8 a; struct S s; u8 b; }; struct U gu = {3, 5,6,7,8, 4}; int main() { printf("%ld\n", sizeof(struct U)); ASSERT(6, sizeof(struct U)); printf("%ld\n", sizeof(gu)); ASSERT(6, sizeof(gu)); ({ struct { struct { int a; struct { int b; }; }; int c; } x={1,2,3,.b=4,5}; x.c; }); return 0; } chibicc-1.0.23.1/test/struct5.c000066400000000000000000000046561505335450300160720ustar00rootroot00000000000000// This program is designed to test some arm64-specific things, such as the // calling convention, but should give the same results on any architecture. #include #include #include #include "test.h" struct hfa21 { double a; } hfa21 = { 21.1 }; struct hfa22 { double a, b; } hfa22 = { 22.1, 22.2 }; struct hfa23 { double a, b, c; } hfa23 = { 23.1, 23.2, 23.3 }; struct hfa24 { double a, b, c, d; } hfa24 = { 24.1, 24.2, 24.3, 24.4 }; struct hfa31 { long double a; } hfa31 = { 31.1 }; struct hfa32 { long double a, b; } hfa32 = { 32.1, 32.2 }; struct hfa33 { long double a, b, c; } hfa33 = { 33.1, 33.2, 33.3 }; struct hfa34 { long double a, b, c, d; } hfa34 = { 34.1, 34.2, 34.3, 34.4 }; int match(const char **s, const char *f) { const char *p = *s; for (p = *s; *f && *f == *p; f++, p++) ; if (!*f) { *s = p - 1; return 1; } return 0; } void myprintf(const char *format, ...) { const char *s; va_list ap; va_start(ap, format); for (s = format; *s; s++) { if (match(&s, "%hfa21")) { struct hfa21 x = va_arg(ap, struct hfa21); printf("%.1f,%.1f", x.a, x.a); } else if (match(&s, "%hfa22")) { struct hfa22 x = va_arg(ap, struct hfa22); printf("%.1f,%.1f", x.a, x.b); } else if (match(&s, "%hfa23")) { struct hfa23 x = va_arg(ap, struct hfa23); printf("%.1f,%.1f", x.a, x.c); } else if (match(&s, "%hfa24")) { struct hfa24 x = va_arg(ap, struct hfa24); printf("%.1f,%.1f", x.a, x.d); } else if (match(&s, "%hfa31")) { struct hfa31 x = va_arg(ap, struct hfa31); printf("%.1Lf,%.1Lf", x.a, x.a); } else if (match(&s, "%hfa32")) { struct hfa32 x = va_arg(ap, struct hfa32); printf("%.1Lf,%.1Lf", x.a, x.b); } else if (match(&s, "%hfa33")) { struct hfa33 x = va_arg(ap, struct hfa33); printf("%.1Lf,%.1Lf", x.a, x.c); } else if (match(&s, "%hfa34")) { struct hfa34 x = va_arg(ap, struct hfa34); printf("%.1Lf,%.1Lf", x.a, x.d); } else putchar(*s); } putchar('\n'); } int main() { printf("stdarg:\n"); myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21", hfa24, hfa22, hfa21, hfa21, hfa21, hfa21); return 0; }chibicc-1.0.23.1/test/struct6.c000066400000000000000000000014141505335450300160600ustar00rootroot00000000000000#include #include "test.h" typedef struct S { __attribute__((aligned(32))) char data[32]; } S; void print7(S a, S b, S c, S d, S e, S f, S g) { printf("%d %d %d %d %d %d %d\n", a.data[0], b.data[0], c.data[0], d.data[0], e.data[0], f.data[0], g.data[0]); ASSERT(1, a.data[0]); ASSERT(2, b.data[0]); ASSERT(3, c.data[0]); ASSERT(4, d.data[0]); ASSERT(5, e.data[0]); ASSERT(6, f.data[0]); ASSERT(7, g.data[0]); } int main() { S s1 = {.data = {1}}; S s2 = {.data = {2}}; S s3 = {.data = {3}}; S s4 = {.data = {4}}; S s5 = {.data = {5}}; S s6 = {.data = {6}}; S s7 = {.data = {7}}; print7(s1, s2, s3, s4, s5, s6, s7); return 0; } chibicc-1.0.23.1/test/struct_array.c000066400000000000000000000017161505335450300171750ustar00rootroot00000000000000 #include "test.h" // Define the struct with float, double, and int types struct Data { float a; double b; int c; }; // Define a typedef for an array of struct Data typedef struct Data ARR[]; typedef float F; ARR arr = { {(F)1.1f, (F)2.2, (F)3}, {(F)4.4f, (F)5.5, (F)6}, {(F)7.7f, (F)8.8, (F)9} }; // Function to process an array of structs void process_array(ARR arr, int size) { for (int i = 0; i < size; i++) { printf("Struct %d:\n", i); printf(" a = %.2f\n", arr[i].a); printf(" b = %.2lf\n", arr[i].b); printf(" c = %d\n", arr[i].c); if (i == 0) { ASSERT(1, arr[i].a); ASSERT(2, arr[i].b); ASSERT(3, arr[i].c); } } } int main() { // Define and initialize an array of structs using the typedef int size = sizeof(arr) / sizeof(arr[0]); // Pass the array to the function process_array(arr, size); return 0; } chibicc-1.0.23.1/test/struct_pack.c000066400000000000000000000034211505335450300167700ustar00rootroot00000000000000 #include "test.h" struct Fields { _Bool a :1; long long :3; unsigned b :4; _Bool c :1; unsigned d :3; unsigned e :2; long :2; } __attribute__((packed)); struct WithPadding { char a; // 1 byte unsigned b : 3; // 3 bits unsigned c : 5; // 5 bits int d; // 4 bytes }; struct ZeroWidth { unsigned a : 5; // 5 bits unsigned : 0; // Forces alignment to next int unsigned b : 3; // 3 bits }; struct Complex { _Bool a : 1; // 1 bit unsigned b : 3; // 3 bits unsigned c : 5; // 5 bits int d : 4; // 4 bits unsigned long long e : 10; // 10 bits }; struct MaxAlign { unsigned long long a : 64; // 64 bits unsigned long long b : 64; // 64 bits }; int main() { { struct { char a; int b; } __attribute__((packed)) x; printf("%d\n", sizeof(x)); ASSERT(5, sizeof(x)); } { union { int a; char b[4]; } x={0x01020304}; printf("%d\n", x.b[0]); ASSERT(4, x.b[0]); } struct Fields s1 = {11,22,33,44,55,66,77}; struct Fields s2 = {77,66,55,44,33,22,11}; printf("%d\n", sizeof(struct Fields)); ASSERT(2, sizeof(struct Fields)); printf("%d\n", _Alignof(struct Fields)); ASSERT(1, _Alignof(struct Fields)); printf("Size of WithPadding struct: %lu\n", sizeof(struct WithPadding)); // Expected: 8 ASSERT(8, sizeof(struct WithPadding)); printf("Size of ZeroWidth struct: %lu\n", sizeof(struct ZeroWidth)); // Expected: 8 ASSERT(8, sizeof(struct ZeroWidth)); printf("Size of Complex struct: %lu\n", sizeof(struct Complex)); // Expected: 8 ASSERT(8, sizeof(struct Complex)); printf("Size of MaxAlign struct: %lu\n", sizeof(struct MaxAlign)); // Expected: 16 ASSERT(16, sizeof(struct MaxAlign)); return 0; }chibicc-1.0.23.1/test/struct_sizeof.c000066400000000000000000000031721505335450300173540ustar00rootroot00000000000000#include "test.h" #include // For offsetof #include // For bool type typedef struct PgStatShared_Archiver { int stats; } PgStatShared_Archiver; // Define a struct with boolean bitfields and other fields typedef struct { bool fixed_amount : 1; // Bitfield for fixed amount bool accessed_across_databases : 1; // Bitfield for access across databases int id; // Integer ID char name[20]; // Name field size_t shared_size; // This will be initialized using sizeof } Item; // Define a struct to hold an array of items typedef struct { Item items[5]; // Array of 5 Items } ItemCollection; int main(void) { ItemCollection collection = { .items[0] = {0}, .items[1] = { .shared_size = sizeof(PgStatShared_Archiver), .fixed_amount = false, .accessed_across_databases = true, .id = 2, .name = "Item2" }, // shared_size will be uninitialized .items[2] = { .id = 3, .name = "Item3" }, // Only id and name initialized, shared_size uninitialized }; // Print the details of the collection for (int i = 0; i < 3; i++) { if (!collection.items[i].name) continue; printf("Item %d:\n", collection.items[i].id); printf(" Name: %s\n", collection.items[i].name); printf(" Fixed Amount: %d\n", collection.items[i].fixed_amount); printf(" Accessed Across Databases: %d\n", collection.items[i].accessed_across_databases); printf(" Shared Size: %zu\n", collection.items[i].shared_size); // May be uninitialized for some items } return 0; } chibicc-1.0.23.1/test/stub.c000066400000000000000000000004411505335450300154220ustar00rootroot00000000000000#include "test.h" // Declare a stub function void my_function() __attribute__((__stub__)); void my_function() { // Function implementation could be added later printf("This function is a stub.\n"); } int main() { my_function(); // Calling the stub function return 0; } chibicc-1.0.23.1/test/suite152.c000066400000000000000000000003541505335450300160310ustar00rootroot00000000000000 #include "test.h" #undef line #define line 1000 #line line #if 1000 != __LINE__ #error" # line line" not work as expected #endif #undef line #define line 8 int main() { printf("line=%d\n", line); ASSERT(8, line); return 0; }chibicc-1.0.23.1/test/suite162.c000066400000000000000000000013451505335450300160330ustar00rootroot00000000000000 #include "test.h" void foo(int [5]); void fooc(int x[const 5]); void foos(int x[static 5]); void foov(int x[volatile 5]); void foor(int x[restrict 5]); void fooc(int [const 5]); void foos(int [static 5]); void foov(int [volatile 5]); void foor(int [restrict 5]); void fooc(int (* const x)); void foos(int *x); void foov(int * volatile x); void foor(int * restrict x); void fooc(int x[volatile 5]) { x[3] = 42; #ifdef INVALID x = 0; #endif } void foovm(int x[const *]); void foovm(int * const x); #ifdef INVALID void wrongc(int x[3][const 4]); void wrongvm(int x[static *]); void foovm(int x[const *]) { x[2] = 1; } #endif int main() { printf("sizeof(const *) = %ld\n", sizeof(const *)); ASSERT(8, sizeof(const *) ); return 0; }chibicc-1.0.23.1/test/suite170.c000066400000000000000000000027471505335450300160410ustar00rootroot00000000000000 #include "test.h" enum fred { a, b, c, d, e = 54, f = 73, g, h }; /* All following uses of enum efoo should compile without warning. While forward enums aren't ISO C, it's accepted by GCC also in strict mode, and only warned about with -pedantic. This happens in the real world. */ /* Strict ISO C doesn't allow this kind of forward declaration of enums, but GCC accepts it (and gives only pedantic warning), and it occurs in the wild. */ enum efoo; struct Sforward_use { int (*fmember) (enum efoo x); }; extern enum efoo it_real_fn(void); enum efoo { ONE, TWO, }; struct S2 { enum efoo (*f2) (void); }; void should_compile(struct S2 *s) { s->f2 = it_real_fn; } enum efoo it_real_fn(void) { return TWO; } static unsigned int deref_uintptr(unsigned int *p) { return *p; } enum Epositive { epos_one, epos_two }; int main() { enum fred frod; enum Epositive epos = epos_two; printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h); ASSERT(0, a); ASSERT(1, b); ASSERT(2, c); ASSERT(3, d); ASSERT(54, e); ASSERT(73, f); ASSERT(74, g); ASSERT(75, h); /* printf("%d\n", frod); */ frod = 12; printf("%d\n", frod); ASSERT(12, frod); frod = e; printf("%d\n", frod); ASSERT(54, frod); /* Following should compile without warning. */ printf ("enum to int: %u\n", deref_uintptr(&epos)); ASSERT(1, deref_uintptr(&epos)); return 0; } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/chibicc-1.0.23.1/test/suite174.c000066400000000000000000000022501505335450300160320ustar00rootroot00000000000000 #include #include "test.h" int main() { // variables float a = 12.34 + 56.78; printf("%f\n", a); ASSERT(69, a); // infix operators printf("%f\n", 12.34 + 56.78); printf("%f\n", 12.34 - 56.78); printf("%f\n", 12.34 * 56.78); printf("%f\n", 12.34 / 56.78); // comparison operators printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78); printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34); printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34); // assignment operators a = 12.34; a += 56.78; printf("%f\n", a); ASSERT(69, a); a = 12.34; a -= 56.78; printf("%f\n", a); ASSERT(-44, a); a = 12.34; a *= 56.78; printf("%f\n", a); ASSERT(700, a); a = 12.34; a /= 56.78; printf("%f\n", a); ASSERT(0, a); // prefix operators printf("%f\n", +12.34); printf("%f\n", -12.34); // type coercion a = 2; printf("%f\n", a); printf("%f\n", sin(2)); return 0; } chibicc-1.0.23.1/test/suite204.c000066400000000000000000000414411505335450300160310ustar00rootroot00000000000000// This program is designed to test some arm64-specific things, such as the // calling convention, but should give the same results on any architecture. #include #include #include "test.h" struct s1 { char x[1]; } s1 = { "0" }; struct s2 { char x[2]; } s2 = { "12" }; struct s3 { char x[3]; } s3 = { "345" }; struct s4 { char x[4]; } s4 = { "6789" }; struct s5 { char x[5]; } s5 = { "abcde" }; struct s6 { char x[6]; } s6 = { "fghijk" }; struct s7 { char x[7]; } s7 = { "lmnopqr" }; struct s8 { char x[8]; } s8 = { "stuvwxyz" }; struct s9 { char x[9]; } s9 = { "ABCDEFGHI" }; struct s10 { char x[10]; } s10 = { "JKLMNOPQRS" }; struct s11 { char x[11]; } s11 = { "TUVWXYZ0123" }; struct s12 { char x[12]; } s12 = { "456789abcdef" }; struct s13 { char x[13]; } s13 = { "ghijklmnopqrs" }; struct s14 { char x[14]; } s14 = { "tuvwxyzABCDEFG" }; struct s15 { char x[15]; } s15 = { "HIJKLMNOPQRSTUV" }; struct s16 { char x[16]; } s16 = { "WXYZ0123456789ab" }; struct s17 { char x[17]; } s17 = { "cdefghijklmnopqrs" }; struct hfa11 { float a; } hfa11 = { 11.1 }; struct hfa12 { float a, b; } hfa12 = { 12.1, 12.2 }; struct hfa13 { float a, b, c; } hfa13 = { 13.1, 13.2, 13.3 }; struct hfa14 { float a, b, c, d; } hfa14 = { 14.1, 14.2, 14.3, 14.4 }; struct hfa21 { double a; } hfa21 = { 21.1 }; struct hfa22 { double a, b; } hfa22 = { 22.1, 22.2 }; struct hfa23 { double a, b, c; } hfa23 = { 23.1, 23.2, 23.3 }; struct hfa24 { double a, b, c, d; } hfa24 = { 24.1, 24.2, 24.3, 24.4 }; struct hfa31 { long double a; } hfa31 = { 31.1 }; struct hfa32 { long double a, b; } hfa32 = { 32.1, 32.2 }; struct hfa33 { long double a, b, c; } hfa33 = { 33.1, 33.2, 33.3 }; struct hfa34 { long double a, b, c, d; } hfa34 = { 34.1, 34.2, 34.3, 34.4 }; void fa_s1(struct s1 a) { printf("%.1s\n", a.x); } void fa_s2(struct s2 a) { printf("%.2s\n", a.x); } void fa_s3(struct s3 a) { printf("%.3s\n", a.x); } void fa_s4(struct s4 a) { printf("%.4s\n", a.x); } void fa_s5(struct s5 a) { printf("%.5s\n", a.x); } void fa_s6(struct s6 a) { printf("%.6s\n", a.x); } void fa_s7(struct s7 a) { printf("%.7s\n", a.x); } void fa_s8(struct s8 a) { printf("%.8s\n", a.x); } void fa_s9(struct s9 a) { printf("%.9s\n", a.x); } void fa_s10(struct s10 a) { printf("%.10s\n", a.x); } void fa_s11(struct s11 a) { printf("%.11s\n", a.x); } void fa_s12(struct s12 a) { printf("%.12s\n", a.x); } void fa_s13(struct s13 a) { printf("%.13s\n", a.x); } void fa_s14(struct s14 a) { printf("%.14s\n", a.x); } void fa_s15(struct s15 a) { printf("%.15s\n", a.x); } void fa_s16(struct s16 a) { printf("%.16s\n", a.x); } void fa_s17(struct s17 a) { printf("%.17s\n", a.x); } void fa_hfa11(struct hfa11 a) { printf("%.1f\n", a.a); } void fa_hfa12(struct hfa12 a) { printf("%.1f %.1f\n", a.a, a.a); } void fa_hfa13(struct hfa13 a) { printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); } void fa_hfa14(struct hfa14 a) { printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); } void fa_hfa21(struct hfa21 a) { printf("%.1f\n", a.a); } void fa_hfa22(struct hfa22 a) { printf("%.1f %.1f\n", a.a, a.a); } void fa_hfa23(struct hfa23 a) { printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); } void fa_hfa24(struct hfa24 a) { printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); } void fa_hfa31(struct hfa31 a) { printf("%.1Lf\n", a.a); } void fa_hfa32(struct hfa32 a) { printf("%.1Lf %.1Lf\n", a.a, a.a); } void fa_hfa33(struct hfa33 a) { printf("%.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c); } void fa_hfa34(struct hfa34 a) { printf("%.1Lf %.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c, a.d); } void fa1(struct s8 a, struct s9 b, struct s10 c, struct s11 d, struct s12 e, struct s13 f) { printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x); } void fa2(struct s9 a, struct s10 b, struct s11 c, struct s12 d, struct s13 e, struct s14 f) { printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x); } void fa3(struct hfa14 a, struct hfa23 b, struct hfa32 c) { printf("%.1f %.1f %.1f %.1f %.1Lf %.1Lf\n", a.a, a.d, b.a, b.c, c.a, c.b); } void fa4(struct s1 a, struct hfa14 b, struct s2 c, struct hfa24 d, struct s3 e, struct hfa34 f) { printf("%.1s %.1f %.1f %.2s %.1f %.1f %.3s %.1Lf %.1Lf\n", a.x, b.a, b.d, c.x, d.a, d.d, e.x, f.a, f.d); } void arg(void) { printf("Arguments:\n"); fa_s1(s1); fa_s2(s2); fa_s3(s3); fa_s4(s4); fa_s5(s5); fa_s6(s6); fa_s7(s7); fa_s8(s8); fa_s9(s9); fa_s10(s10); fa_s11(s11); fa_s12(s12); fa_s13(s13); fa_s14(s14); fa_s15(s15); fa_s16(s16); fa_s17(s17); fa_hfa11(hfa11); fa_hfa12(hfa12); fa_hfa13(hfa13); fa_hfa14(hfa14); fa_hfa21(hfa21); fa_hfa22(hfa22); fa_hfa23(hfa23); fa_hfa24(hfa24); fa_hfa31(hfa31); fa_hfa32(hfa32); fa_hfa33(hfa33); fa_hfa34(hfa34); fa1(s8, s9, s10, s11, s12, s13); fa2(s9, s10, s11, s12, s13, s14); fa3(hfa14, hfa23, hfa32); fa4(s1, hfa14, s2, hfa24, s3, hfa34); } struct s1 fr_s1(void) { return s1; } struct s2 fr_s2(void) { return s2; } struct s3 fr_s3(void) { return s3; } struct s4 fr_s4(void) { return s4; } struct s5 fr_s5(void) { return s5; } struct s6 fr_s6(void) { return s6; } struct s7 fr_s7(void) { return s7; } struct s8 fr_s8(void) { return s8; } struct s9 fr_s9(void) { return s9; } struct s10 fr_s10(void) { return s10; } struct s11 fr_s11(void) { return s11; } struct s12 fr_s12(void) { return s12; } struct s13 fr_s13(void) { return s13; } struct s14 fr_s14(void) { return s14; } struct s15 fr_s15(void) { return s15; } struct s16 fr_s16(void) { return s16; } struct s17 fr_s17(void) { return s17; } struct hfa11 fr_hfa11(void) { return hfa11; } struct hfa12 fr_hfa12(void) { return hfa12; } struct hfa13 fr_hfa13(void) { return hfa13; } struct hfa14 fr_hfa14(void) { return hfa14; } struct hfa21 fr_hfa21(void) { return hfa21; } struct hfa22 fr_hfa22(void) { return hfa22; } struct hfa23 fr_hfa23(void) { return hfa23; } struct hfa24 fr_hfa24(void) { return hfa24; } struct hfa31 fr_hfa31(void) { return hfa31; } struct hfa32 fr_hfa32(void) { return hfa32; } struct hfa33 fr_hfa33(void) { return hfa33; } struct hfa34 fr_hfa34(void) { return hfa34; } void ret(void) { struct s1 t1 = fr_s1(); struct s2 t2 = fr_s2(); struct s3 t3 = fr_s3(); struct s4 t4 = fr_s4(); struct s5 t5 = fr_s5(); struct s6 t6 = fr_s6(); struct s7 t7 = fr_s7(); struct s8 t8 = fr_s8(); struct s9 t9 = fr_s9(); struct s10 t10 = fr_s10(); struct s11 t11 = fr_s11(); struct s12 t12 = fr_s12(); struct s13 t13 = fr_s13(); struct s14 t14 = fr_s14(); struct s15 t15 = fr_s15(); struct s16 t16 = fr_s16(); struct s17 t17 = fr_s17(); printf("Return values:\n"); printf("%.1s\n", t1.x); printf("%.2s\n", t2.x); printf("%.3s\n", t3.x); printf("%.4s\n", t4.x); printf("%.5s\n", t5.x); printf("%.6s\n", t6.x); printf("%.7s\n", t7.x); printf("%.8s\n", t8.x); printf("%.9s\n", t9.x); printf("%.10s\n", t10.x); printf("%.11s\n", t11.x); printf("%.12s\n", t12.x); printf("%.13s\n", t13.x); printf("%.14s\n", t14.x); printf("%.15s\n", t15.x); printf("%.16s\n", t16.x); printf("%.17s\n", t17.x); printf("%.1f\n", fr_hfa11().a); printf("%.1f %.1f\n", fr_hfa12().a, fr_hfa12().b); printf("%.1f %.1f\n", fr_hfa13().a, fr_hfa13().c); printf("%.1f %.1f\n", fr_hfa14().a, fr_hfa14().d); printf("%.1f\n", fr_hfa21().a); printf("%.1f %.1f\n", fr_hfa22().a, fr_hfa22().b); printf("%.1f %.1f\n", fr_hfa23().a, fr_hfa23().c); printf("%.1f %.1f\n", fr_hfa24().a, fr_hfa24().d); printf("%.1Lf\n", fr_hfa31().a); printf("%.1Lf %.1Lf\n", fr_hfa32().a, fr_hfa32().b); printf("%.1Lf %.1Lf\n", fr_hfa33().a, fr_hfa33().c); printf("%.1Lf %.1Lf\n", fr_hfa34().a, fr_hfa34().d); } int match(const char **s, const char *f) { const char *p = *s; for (p = *s; *f && *f == *p; f++, p++) ; if (!*f) { *s = p - 1; return 1; } return 0; } void myprintf(const char *format, ...) { const char *s; va_list ap; va_start(ap, format); for (s = format; *s; s++) { if (match(&s, "%7s")) { struct s7 t7 = va_arg(ap, struct s7); printf("%.7s", t7.x); } else if (match(&s, "%9s")) { struct s9 t9 = va_arg(ap, struct s9); printf("%.9s", t9.x); } else if (match(&s, "%hfa11")) { struct hfa11 x = va_arg(ap, struct hfa11); printf("%.1f,%.1f", x.a, x.a); } else if (match(&s, "%hfa12")) { struct hfa12 x = va_arg(ap, struct hfa12); printf("%.1f,%.1f", x.a, x.b); } else if (match(&s, "%hfa13")) { struct hfa13 x = va_arg(ap, struct hfa13); printf("%.1f,%.1f", x.a, x.c); } else if (match(&s, "%hfa14")) { struct hfa14 x = va_arg(ap, struct hfa14); printf("%.1f,%.1f", x.a, x.d); } else if (match(&s, "%hfa21")) { struct hfa21 x = va_arg(ap, struct hfa21); printf("%.1f,%.1f", x.a, x.a); } else if (match(&s, "%hfa22")) { struct hfa22 x = va_arg(ap, struct hfa22); printf("%.1f,%.1f", x.a, x.b); } else if (match(&s, "%hfa23")) { struct hfa23 x = va_arg(ap, struct hfa23); printf("%.1f,%.1f", x.a, x.c); } else if (match(&s, "%hfa24")) { struct hfa24 x = va_arg(ap, struct hfa24); printf("%.1f,%.1f", x.a, x.d); } else if (match(&s, "%hfa31")) { struct hfa31 x = va_arg(ap, struct hfa31); printf("%.1Lf,%.1Lf", x.a, x.a); } else if (match(&s, "%hfa32")) { struct hfa32 x = va_arg(ap, struct hfa32); printf("%.1Lf,%.1Lf", x.a, x.b); } else if (match(&s, "%hfa33")) { struct hfa33 x = va_arg(ap, struct hfa33); printf("%.1Lf,%.1Lf", x.a, x.c); } else if (match(&s, "%hfa34")) { struct hfa34 x = va_arg(ap, struct hfa34); printf("%.1Lf,%.1Lf", x.a, x.d); } else putchar(*s); } putchar('\n'); } void stdarg(void) { printf("stdarg:\n"); myprintf("%9s %9s %9s %9s %9s %9s", s9, s9, s9, s9, s9, s9); myprintf("%7s %9s %9s %9s %9s %9s", s7, s9, s9, s9, s9, s9); myprintf("HFA long double:"); myprintf("%hfa34 %hfa34 %hfa34 %hfa34", hfa34, hfa34, hfa34, hfa34); myprintf("%hfa33 %hfa34 %hfa34 %hfa34", hfa33, hfa34, hfa34, hfa34); myprintf("%hfa32 %hfa34 %hfa34 %hfa34", hfa32, hfa34, hfa34, hfa34); myprintf("%hfa31 %hfa34 %hfa34 %hfa34", hfa31, hfa34, hfa34, hfa34); myprintf("%hfa32 %hfa33 %hfa33 %hfa33 %hfa33", hfa32, hfa33, hfa33, hfa33, hfa33); myprintf("%hfa31 %hfa33 %hfa33 %hfa33 %hfa33", hfa31, hfa33, hfa33, hfa33, hfa33); myprintf("%hfa33 %hfa33 %hfa33 %hfa33", hfa33, hfa33, hfa33, hfa33); myprintf("%hfa34 %hfa32 %hfa32 %hfa32 %hfa32", hfa34, hfa32, hfa32, hfa32, hfa32); myprintf("%hfa33 %hfa32 %hfa32 %hfa32 %hfa32", hfa33, hfa32, hfa32, hfa32, hfa32); myprintf("%hfa34 %hfa32 %hfa31 %hfa31 %hfa31 %hfa31", hfa34, hfa32, hfa31, hfa31, hfa31, hfa31); myprintf("HFA double:"); myprintf("%hfa24 %hfa24 %hfa24 %hfa24", hfa24, hfa24, hfa24, hfa24); myprintf("%hfa23 %hfa24 %hfa24 %hfa24", hfa23, hfa24, hfa24, hfa24); myprintf("%hfa22 %hfa24 %hfa24 %hfa24", hfa22, hfa24, hfa24, hfa24); myprintf("%hfa21 %hfa24 %hfa24 %hfa24", hfa21, hfa24, hfa24, hfa24); myprintf("%hfa22 %hfa23 %hfa23 %hfa23 %hfa23", hfa22, hfa23, hfa23, hfa23, hfa23); myprintf("%hfa21 %hfa23 %hfa23 %hfa23 %hfa23", hfa21, hfa23, hfa23, hfa23, hfa23); myprintf("%hfa23 %hfa23 %hfa23 %hfa23", hfa23, hfa23, hfa23, hfa23); myprintf("%hfa24 %hfa22 %hfa22 %hfa22 %hfa22", hfa24, hfa22, hfa22, hfa22, hfa22); myprintf("%hfa23 %hfa22 %hfa22 %hfa22 %hfa22", hfa23, hfa22, hfa22, hfa22, hfa22); myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21", hfa24, hfa22, hfa21, hfa21, hfa21, hfa21); myprintf("HFA float:"); myprintf("%hfa14 %hfa14 %hfa14 %hfa14", hfa14, hfa14, hfa14, hfa14); myprintf("%hfa13 %hfa14 %hfa14 %hfa14", hfa13, hfa14, hfa14, hfa14); myprintf("%hfa12 %hfa14 %hfa14 %hfa14", hfa12, hfa14, hfa14, hfa14); myprintf("%hfa11 %hfa14 %hfa14 %hfa14", hfa11, hfa14, hfa14, hfa14); myprintf("%hfa12 %hfa13 %hfa13 %hfa13 %hfa13", hfa12, hfa13, hfa13, hfa13, hfa13); myprintf("%hfa11 %hfa13 %hfa13 %hfa13 %hfa13", hfa11, hfa13, hfa13, hfa13, hfa13); myprintf("%hfa13 %hfa13 %hfa13 %hfa13", hfa13, hfa13, hfa13, hfa13); myprintf("%hfa14 %hfa12 %hfa12 %hfa12 %hfa12", hfa14, hfa12, hfa12, hfa12, hfa12); myprintf("%hfa13 %hfa12 %hfa12 %hfa12 %hfa12", hfa13, hfa12, hfa12, hfa12, hfa12); myprintf("%hfa14 %hfa12 %hfa11 %hfa11 %hfa11 %hfa11", hfa14, hfa12, hfa11, hfa11, hfa11, hfa11); } void pll(unsigned long long x) { printf("%llx\n", x); } void movi(void) { printf("MOVI:\n"); pll(0); pll(0xabcd); pll(0xabcd0000); pll(0xabcd00000000); pll(0xabcd000000000000); pll(0xffffabcd); pll(0xabcdffff); pll(0xffffffffffffabcd); pll(0xffffffffabcdffff); pll(0xffffabcdffffffff); pll(0xabcdffffffffffff); pll(0xaaaaaaaa); pll(0x5555555555555555); pll(0x77777777); pll(0x3333333333333333); pll(0xf8f8f8f8); pll(0x1e1e1e1e1e1e1e1e); pll(0x3f803f80); pll(0x01ff01ff01ff01ff); pll(0x007fffc0); pll(0x03fff80003fff800); pll(0x0007fffffffffe00); pll(0xabcd1234); pll(0xabcd00001234); pll(0xabcd000000001234); pll(0xabcd12340000); pll(0xabcd000012340000); pll(0xabcd123400000000); pll(0xffffffffabcd1234); pll(0xffffabcdffff1234); pll(0xabcdffffffff1234); pll(0xffffabcd1234ffff); pll(0xabcdffff1234ffff); pll(0xabcd1234ffffffff); pll(0xffffef0123456789); pll(0xabcdef012345ffff); pll(0xabcdef0123456789); } static uint32_t addip0(uint32_t x) { return x + 0; } static uint64_t sublp0(uint64_t x) { return x - 0; } static uint32_t addip123(uint32_t x) { return x + 123; } static uint64_t addlm123(uint64_t x) { return x + -123; } static uint64_t sublp4095(uint64_t x) { return x - 4095; } static uint32_t subim503808(uint32_t x) { return x - -503808; } static uint64_t addp12345(uint64_t x) { return x + 12345; } static uint32_t subp12345(uint32_t x) { return x - 12345; } static uint32_t mvni(uint32_t x) { return 0xffffffff - x; } static uint64_t negl(uint64_t x) { return 0 - x; } static uint32_t rsbi123(uint32_t x) { return 123 - x; } static uint64_t rsbl123(uint64_t x) { return 123 - x; } static uint32_t andi0(uint32_t x) { return x & 0; } static uint64_t andlm1(uint64_t x) { return x & -1; } static uint64_t orrl0(uint64_t x) { return x | 0; } static uint32_t orrim1(uint32_t x) { return x | -1; } static uint32_t eori0(uint32_t x) { return x ^ 0; } static uint64_t eorlm1(uint64_t x) { return x ^ -1; } static uint32_t and0xf0(uint32_t x) { return x & 0xf0; } static uint64_t orr0xf0(uint64_t x) { return x | 0xf0; } static uint64_t eor0xf0(uint64_t x) { return x ^ 0xf0; } static uint32_t lsli0(uint32_t x) { return x << 0; } static uint32_t lsri0(uint32_t x) { return x >> 0; } static int64_t asrl0(int64_t x) { return x >> 0; } static uint32_t lsli1(uint32_t x) { return x << 1; } static uint32_t lsli31(uint32_t x) { return x << 31; } static uint64_t lsll1(uint64_t x) { return x << 1; } static uint64_t lsll63(uint64_t x) { return x << 63; } static uint32_t lsri1(uint32_t x) { return x >> 1; } static uint32_t lsri31(uint32_t x) { return x >> 31; } static uint64_t lsrl1(uint64_t x) { return x >> 1; } static uint64_t lsrl63(uint64_t x) { return x >> 63; } static int32_t asri1(int32_t x) { return x >> 1; } static int32_t asri31(int32_t x) { return x >> 31; } static int64_t asrl1(int64_t x) { return x >> 1; } static int64_t asrl63(int64_t x) { return x >> 63; } void opi(void) { int x = 1000; pll(addip0(x)); pll(sublp0(x)); pll(addip123(x)); pll(addlm123(x)); pll(sublp4095(x)); pll(subim503808(x)); pll(addp12345(x)); pll(subp12345(x)); pll(mvni(x)); pll(negl(x)); pll(rsbi123(x)); pll(rsbl123(x)); pll(andi0(x)); pll(andlm1(x)); pll(orrl0(x)); pll(orrim1(x)); pll(eori0(x)); pll(eorlm1(x)); pll(and0xf0(x)); pll(orr0xf0(x)); pll(eor0xf0(x)); pll(lsli0(x)); pll(lsri0(x)); pll(asrl0(x)); pll(lsli1(x)); pll(lsli31(x)); pll(lsll1(x)); pll(lsll63(x)); pll(lsri1(x)); pll(lsri31(x)); pll(lsrl1(x)); pll(lsrl63(x)); pll(asri1(x)); pll(asri31(x)); pll(asrl1(x)); pll(asrl63(x)); } void pcs(void) { //arg(); //ret(); stdarg(); //movi(); //opi(); } int main() { pcs(); return 0; }chibicc-1.0.23.1/test/suite204b.c000066400000000000000000000222741505335450300161760ustar00rootroot00000000000000// This program is designed to test some arm64-specific things, such as the // calling convention, but should give the same results on any architecture. #include #include #include "test.h" #include struct s1 { char x[1]; } s1 = { "0" }; struct s2 { char x[2]; } s2 = { "12" }; struct s3 { char x[3]; } s3 = { "345" }; struct s4 { char x[4]; } s4 = { "6789" }; struct s5 { char x[5]; } s5 = { "abcde" }; struct s6 { char x[6]; } s6 = { "fghijk" }; struct s7 { char x[7]; } s7 = { "lmnopqr" }; struct s8 { char x[8]; } s8 = { "stuvwxyz" }; struct s9 { char x[9]; } s9 = { "ABCDEFGHI" }; struct s10 { char x[10]; } s10 = { "JKLMNOPQRS" }; struct s11 { char x[11]; } s11 = { "TUVWXYZ0123" }; struct s12 { char x[12]; } s12 = { "456789abcdef" }; struct s13 { char x[13]; } s13 = { "ghijklmnopqrs" }; struct s14 { char x[14]; } s14 = { "tuvwxyzABCDEFG" }; struct s15 { char x[15]; } s15 = { "HIJKLMNOPQRSTUV" }; struct s16 { char x[16]; } s16 = { "WXYZ0123456789ab" }; struct s17 { char x[17]; } s17 = { "cdefghijklmnopqrs" }; struct hfa11 { float a; } hfa11 = { 11.1 }; struct hfa12 { float a, b; } hfa12 = { 12.1, 12.2 }; struct hfa13 { float a, b, c; } hfa13 = { 13.1, 13.2, 13.3 }; struct hfa14 { float a, b, c, d; } hfa14 = { 14.1, 14.2, 14.3, 14.4 }; struct hfa21 { double a; } hfa21 = { 21.1 }; struct hfa22 { double a, b; } hfa22 = { 22.1, 22.2 }; struct hfa23 { double a, b, c; } hfa23 = { 23.1, 23.2, 23.3 }; struct hfa24 { double a, b, c, d; } hfa24 = { 24.1, 24.2, 24.3, 24.4 }; struct hfa31 { long double a; } hfa31 = { 31.1 }; struct hfa32 { long double a, b; } hfa32 = { 32.1, 32.2 }; struct hfa33 { long double a, b, c; } hfa33 = { 33.1, 33.2, 33.3 }; struct hfa34 { long double a, b, c, d; } hfa34 = { 34.1, 34.2, 34.3, 34.4 }; void fa_s1(struct s1 a) { printf("%.1s\n", a.x); } void fa_s2(struct s2 a) { printf("%.2s\n", a.x); } void fa_s3(struct s3 a) { printf("%.3s\n", a.x); } void fa_s4(struct s4 a) { printf("%.4s\n", a.x); } void fa_s5(struct s5 a) { printf("%.5s\n", a.x); } void fa_s6(struct s6 a) { printf("%.6s\n", a.x); } void fa_s7(struct s7 a) { printf("%.7s\n", a.x); } void fa_s8(struct s8 a) { printf("%.8s\n", a.x); } void fa_s9(struct s9 a) { printf("%.9s\n", a.x); } void fa_s10(struct s10 a) { printf("%.10s\n", a.x); } void fa_s11(struct s11 a) { printf("%.11s\n", a.x); } void fa_s12(struct s12 a) { printf("%.12s\n", a.x); } void fa_s13(struct s13 a) { printf("%.13s\n", a.x); } void fa_s14(struct s14 a) { printf("%.14s\n", a.x); } void fa_s15(struct s15 a) { printf("%.15s\n", a.x); } void fa_s16(struct s16 a) { printf("%.16s\n", a.x); } void fa_s17(struct s17 a) { printf("%.17s\n", a.x); } void fa_hfa11(struct hfa11 a) { printf("%.1f\n", a.a); } void fa_hfa12(struct hfa12 a) { printf("%.1f %.1f\n", a.a, a.a); } void fa_hfa13(struct hfa13 a) { printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); } void fa_hfa14(struct hfa14 a) { printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); } void fa_hfa21(struct hfa21 a) { printf("%.1f\n", a.a); } void fa_hfa22(struct hfa22 a) { printf("%.1f %.1f\n", a.a, a.a); } void fa_hfa23(struct hfa23 a) { printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); } void fa_hfa24(struct hfa24 a) { printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); } void fa_hfa31(struct hfa31 a) { printf("%.1Lf\n", a.a); } void fa_hfa32(struct hfa32 a) { printf("%.1Lf %.1Lf\n", a.a, a.a); } void fa_hfa33(struct hfa33 a) { printf("%.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c); } void fa_hfa34(struct hfa34 a) { printf("%.1Lf %.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c, a.d); } void fa1(struct s8 a, struct s9 b, struct s10 c, struct s11 d, struct s12 e, struct s13 f) { printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x); } void fa2(struct s9 a, struct s10 b, struct s11 c, struct s12 d, struct s13 e, struct s14 f) { printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x); } void fa3(struct hfa14 a, struct hfa23 b, struct hfa32 c) { printf("%.1f %.1f %.1f %.1f %.1Lf %.1Lf\n", a.a, a.d, b.a, b.c, c.a, c.b); } void fa4(struct s1 a, struct hfa14 b, struct s2 c, struct hfa24 d, struct s3 e, struct hfa34 f) { printf("%.1s %.1f %.1f %.2s %.1f %.1f %.3s %.1Lf %.1Lf\n", a.x, b.a, b.d, c.x, d.a, d.d, e.x, f.a, f.d); } struct s1 fr_s1(void) { return s1; } struct s2 fr_s2(void) { return s2; } struct s3 fr_s3(void) { return s3; } struct s4 fr_s4(void) { return s4; } struct s5 fr_s5(void) { return s5; } struct s6 fr_s6(void) { return s6; } struct s7 fr_s7(void) { return s7; } struct s8 fr_s8(void) { return s8; } struct s9 fr_s9(void) { return s9; } struct s10 fr_s10(void) { return s10; } struct s11 fr_s11(void) { return s11; } struct s12 fr_s12(void) { return s12; } struct s13 fr_s13(void) { return s13; } struct s14 fr_s14(void) { return s14; } struct s15 fr_s15(void) { return s15; } struct s16 fr_s16(void) { return s16; } struct s17 fr_s17(void) { return s17; } struct hfa11 fr_hfa11(void) { return hfa11; } struct hfa12 fr_hfa12(void) { return hfa12; } struct hfa13 fr_hfa13(void) { return hfa13; } struct hfa14 fr_hfa14(void) { return hfa14; } struct hfa21 fr_hfa21(void) { return hfa21; } struct hfa22 fr_hfa22(void) { return hfa22; } struct hfa23 fr_hfa23(void) { return hfa23; } struct hfa24 fr_hfa24(void) { return hfa24; } struct hfa31 fr_hfa31(void) { return hfa31; } struct hfa32 fr_hfa32(void) { return hfa32; } struct hfa33 fr_hfa33(void) { return hfa33; } struct hfa34 fr_hfa34(void) { return hfa34; } int match(const char **s, const char *f) { const char *p = *s; for (p = *s; *f && *f == *p; f++, p++) ; if (!*f) { *s = p - 1; return 1; } return 0; } void myprintf(const char *format, ...) { const char *s; va_list ap; va_start(ap, format); for (s = format; *s; s++) { if (match(&s, "%7s")) { struct s7 t7 = va_arg(ap, struct s7); printf("%.7s", t7.x); } else if (match(&s, "%9s")) { struct s9 t9 = va_arg(ap, struct s9); printf("%.9s", t9.x); } else if (match(&s, "%hfa11")) { struct hfa11 x = va_arg(ap, struct hfa11); printf("%.1f,%.1f", x.a, x.a); } else if (match(&s, "%hfa12")) { struct hfa12 x = va_arg(ap, struct hfa12); printf("%.1f,%.1f", x.a, x.b); } else if (match(&s, "%hfa13")) { struct hfa13 x = va_arg(ap, struct hfa13); printf("%.1f,%.1f", x.a, x.c); } else if (match(&s, "%hfa14")) { struct hfa14 x = va_arg(ap, struct hfa14); printf("%.1f,%.1f", x.a, x.d); } else if (match(&s, "%hfa21")) { struct hfa21 x = va_arg(ap, struct hfa21); printf("%.1f,%.1f", x.a, x.a); } else if (match(&s, "%hfa22")) { struct hfa22 x = va_arg(ap, struct hfa22); printf("%.1f,%.1f", x.a, x.b); } else if (match(&s, "%hfa23")) { struct hfa23 x = va_arg(ap, struct hfa23); printf("%.1f,%.1f", x.a, x.c); } else if (match(&s, "%hfa24")) { struct hfa24 x = va_arg(ap, struct hfa24); printf("%.1f,%.1f", x.a, x.d); } else if (match(&s, "%hfa31")) { struct hfa31 x = va_arg(ap, struct hfa31); printf("%.1Lf,%.1Lf", x.a, x.a); } else if (match(&s, "%hfa32")) { struct hfa32 x = va_arg(ap, struct hfa32); printf("%.1Lf,%.1Lf", x.a, x.b); } else if (match(&s, "%hfa33")) { struct hfa33 x = va_arg(ap, struct hfa33); printf("%.1Lf,%.1Lf", x.a, x.c); } else if (match(&s, "%hfa34")) { struct hfa34 x = va_arg(ap, struct hfa34); printf("%.1Lf,%.1Lf", x.a, x.d); } else putchar(*s); } putchar('\n'); } void stdarg(void) { printf("stdarg:\n"); myprintf("%9s %9s %9s %9s %9s %9s", s9, s9, s9, s9, s9, s9); myprintf("%7s %9s %9s %9s %9s %9s", s7, s9, s9, s9, s9, s9); myprintf("HFA long double:"); myprintf("%hfa34 ", hfa34); //myprintf("%hfa34 %hfa34 %hfa34 %hfa34", hfa34, hfa34, hfa34, hfa34); } void pll(unsigned long long x) { printf("%llx\n", x); } void movi(void) { printf("MOVI:\n"); pll(0); pll(0xabcd); pll(0xabcd0000); pll(0xabcd00000000); pll(0xabcd000000000000); pll(0xffffabcd); pll(0xabcdffff); pll(0xffffffffffffabcd); pll(0xffffffffabcdffff); pll(0xffffabcdffffffff); pll(0xabcdffffffffffff); pll(0xaaaaaaaa); pll(0x5555555555555555); pll(0x77777777); pll(0x3333333333333333); pll(0xf8f8f8f8); pll(0x1e1e1e1e1e1e1e1e); pll(0x3f803f80); pll(0x01ff01ff01ff01ff); pll(0x007fffc0); pll(0x03fff80003fff800); pll(0x0007fffffffffe00); pll(0xabcd1234); pll(0xabcd00001234); pll(0xabcd000000001234); pll(0xabcd12340000); pll(0xabcd000012340000); pll(0xabcd123400000000); pll(0xffffffffabcd1234); pll(0xffffabcdffff1234); pll(0xabcdffffffff1234); pll(0xffffabcd1234ffff); pll(0xabcdffff1234ffff); pll(0xabcd1234ffffffff); pll(0xffffef0123456789); pll(0xabcdef012345ffff); pll(0xabcdef0123456789); } void pcs(void) { stdarg(); } int main() { pcs(); return 0; }chibicc-1.0.23.1/test/suite205.c000066400000000000000000000114761505335450300160370ustar00rootroot00000000000000#include "test.h" /* This test is a snippet from the J interpreter */ typedef long I; typedef struct{I c[4];I b,e,k;} PT; PT cases[] = { ((I)4194304L +(I)2097152L +(I)67108864L), (I)262144L, (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), -1L, 1,2,1, ((I)+4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L, (I)262144L, (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), 2,3,2, ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)262144L, (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), 1,3,2, ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)524288L, -1L, 1,2,1, ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)1048576L, (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), 1,3,1, ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)262144L, (I)262144L, 1,3,1, ((I)4194304L +(I)2097152L +(I)67108864L), ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), -1L, 1,2,1, (I)33554432L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)2097152L, ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), -1L, 0,2,1, (I)67108864L, ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)134217728L, -1L, 0,2,0, }; int main() { int i, j; for(j=0; j < sizeof(cases)/sizeof(cases[0]); j++) { for(i=0; i < sizeof(cases->c)/sizeof(cases->c[0]); i++) { printf("cases[%d].c[%d]=%ld\n", j, i, cases[j].c[i]); if (j ==0 && i == 0) ASSERT( 73400320,cases[j].c[i]); else if (j == 0 && i == 1) ASSERT( 262144,cases[j].c[i]); } printf("cases[%d].b=%ld\n", j, cases[j].b); printf("cases[%d].e=%ld\n", j, cases[j].e); printf("cases[%d].k=%ld\n", j, cases[j].k); printf("\n"); } return 0; } chibicc-1.0.23.1/test/suite210.c000066400000000000000000000016551505335450300160310ustar00rootroot00000000000000#include "test.h" typedef unsigned short uint16_t; typedef unsigned char uint8_t; typedef union Unaligned16a { uint16_t u; uint8_t b[2]; } __attribute__((packed)) Unaligned16a; typedef union __attribute__((packed)) Unaligned16b { uint16_t u; uint8_t b[2]; } Unaligned16b; extern void foo (void) __attribute__((stdcall)); void __attribute__((stdcall)) foo (void) { } /* The actual attribute isn't important, must just be parsable. */ #define ATTR __attribute__((__noinline__)) int ATTR actual_function() { return 42; } extern int printf (const char *, ...); int main() { void *function_pointer = &actual_function; int a = ((ATTR int(*) (void)) function_pointer)(); printf("%i\n", a); /* In the following we once misparsed 'ATTR *' is a btype and hence the whole type was garbled. */ int b = ( (int(ATTR *)(void)) function_pointer)(); printf("%i\n", b); ASSERT(42, b); return 0; }chibicc-1.0.23.1/test/suite213.c000066400000000000000000000062471505335450300160360ustar00rootroot00000000000000#include "test.h" /* This checks various ways of dead code inside if statements where there are non-obvious ways of how the code is actually not dead due to reachable by labels. */ extern int printf (const char *, ...); static void kb_wait_1(void) { unsigned long timeout = 2; do { /* Here the else arm is a statement expression that's supposed to be suppressed. The label inside the while would unsuppress code generation again if not handled correctly. And that would wreak havoc to the cond-expression because there's no jump-around emitted, the whole statement expression really needs to not generate code (perhaps except useless forward jumps). */ (1 ? printf("timeout=%ld\n", timeout) : ({ int i = 1; while (1) while (i--) some_label: printf("error\n"); goto some_label; }) ); timeout--; } while (timeout); } static int global; static void foo(int i) { global+=i; printf ("g=%d\n", global); } static int check(void) { printf ("check %d\n", global); return 1; } static void dowhile(void) { do { foo(1); if (global == 1) { continue; } else if (global == 2) { continue; } /* The following break shouldn't disable the check() call, as it's reachable by the continues above. */ break; } while (check()); } int main (void) { int i = 1; kb_wait_1(); /* Simple test of dead code at first sight which isn't actually dead. */ if (0) { yeah: printf ("yeah\n"); } else { printf ("boo\n"); } if (i--) goto yeah; /* Some more non-obvious uses where the problems are loops, so that even the first loop statements aren't actually dead. */ i = 1; if (0) { while (i--) { printf ("once\n"); enterloop: printf ("twice\n"); } } if (i >= 0) goto enterloop; /* The same with statement expressions. One might be tempted to handle them specially by counting if inside statement exprs and not unsuppressing code at loops at all then. See kb_wait_1 for the other side of the medal where that wouldn't work. */ i = ({ int j = 1; if (0) { while (j--) { printf ("SEonce\n"); enterexprloop: printf ("SEtwice\n"); } } if (j >= 0) goto enterexprloop; j; }); /* The other two loop forms: */ i = 1; if (0) { for (i = 1; i--;) { printf ("once2\n"); enterloop2: printf ("twice2\n"); } } if (i > 0) goto enterloop2; i = 1; if (0) { do { printf ("once3\n"); enterloop3: printf ("twice3\n"); } while (i--); } if (i > 0) goto enterloop3; /* And check that case and default labels have the same effect of disabling code suppression. */ i = 41; switch (i) { if (0) { printf ("error\n"); ASSERT(0, i); case 42: printf ("error2\n"); ASSERT(42, i); case 41: printf ("caseok\n"); ASSERT(41, i); } } i = 41; switch (i) { if (0) { printf ("error3\n"); ASSERT(0, i); default: printf ("caseok2\n"); ASSERT(41, i); break; case 42: printf ("error4\n"); ASSERT(42, i); } } dowhile(); return 0; }chibicc-1.0.23.1/test/suite216.c000066400000000000000000000150241505335450300160320ustar00rootroot00000000000000#include "test.h" typedef unsigned char u8; typedef struct {} empty_s; struct contains_empty { u8 a; empty_s empty; u8 b; }; struct contains_empty ce = { { (1) }, (empty_s){}, 022, }; /* The following decl of 'q' would demonstrate the TCC bug in init_putv when handling copying compound literals. (Compound literals aren't acceptable constant initializers in isoc99, but we accept them like gcc, except for this case) //char *q = (char *){ "trara" }; */ struct SS {u8 a[3], b; }; struct SS sinit16[] = { { 1 }, 2 }; struct S { u8 a,b; u8 c[2]; }; struct T { u8 s[16]; u8 a; }; struct U { u8 a; struct S s; u8 b; struct T t; }; struct V { struct S s; struct T t; u8 a; }; struct W { struct V t; struct S s[]; }; struct S gs = ((struct S){1, 2, 3, 4}); struct S gs2 = {1, 2, {3, 4}}; struct T gt = {"hello", 42}; struct U gu = {3, 5,6,7,8, 4, "huhu", 43}; struct U gu2 = {3, {5,6,7,8}, 4, {"huhu", 43}}; /* Optional braces around scalar initializers. Accepted, but with a warning. */ struct U gu3 = { {3}, {5,6,7,8,}, 4, {"huhu", 43}}; /* Many superfluous braces and leaving out one initializer for U.s.c[1] */ struct U gu4 = { 3, {5,6,7,}, 5, { "bla", {44}} }; /* Superfluous braces and useless parens around values */ struct S gs3 = { (1), {(2)}, {(((3))), {4}}}; /* Superfluous braces, and leaving out braces for V.t, plus cast */ struct V gv = {{{3},4,{5,6}}, "haha", (u8)45, 46}; /* Compound literal */ struct V gv2 = {(struct S){7,8,{9,10}}, {"hihi", 47}, 48}; /* Parens around compound literal */ struct V gv3 = {((struct S){7,8,{9,10}}), {"hoho", 49}, 50}; /* Initialization of a flex array member (warns in GCC) */ struct W gw = {{1,2,3,4}, {1,2,3,4,5}}; union UU { u8 a; u8 b; }; struct SU { union UU u; u8 c; }; struct SU gsu = {5,6}; /* Unnamed struct/union members aren't ISO C, but it's a widely accepted extension. See below for further extensions to that under -fms-extension.*/ union UV { struct {u8 a,b;}; struct S s; }; union UV guv = {{6,5}}; union UV guv2 = {{.b = 7, .a = 8}}; union UV guv3 = {.b = 8, .a = 7}; /* Under -fms-extensions also the following is valid: union UV2 { struct Anon {u8 a,b;}; // unnamed member, but tagged struct, ... struct S s; }; struct Anon gan = { 10, 11 }; // ... which makes it available here. union UV2 guv4 = {{4,3}}; // and the other inits from above as well */ struct in6_addr { union { u8 u6_addr8[16]; unsigned short u6_addr16[8]; } u; }; struct flowi6 { struct in6_addr saddr, daddr; }; struct pkthdr { struct in6_addr daddr, saddr; }; struct pkthdr phdr = { { { 6,5,4,3 } }, { { 9,8,7,6 } } }; struct Wrap { void *func; }; int global; void inc_global (void) { global++; } struct Wrap global_wrap[] = { ((struct Wrap) {inc_global}), inc_global, }; #include void print_ (const char *name, const u8 *p, long size) { printf ("%s:", name); while (size--) { printf (" %x", *p++); } printf ("\n"); } #define print(x) print_(#x, (u8*)&x, sizeof (x)) #if 1 void foo (struct W *w, struct pkthdr *phdr_) { struct S ls = {1, 2, 3, 4}; struct S ls2 = {1, 2, {3, 4}}; struct T lt = {"hello", 42}; struct U lu = {3, 5,6,7,8, 4, "huhu", 43}; struct U lu1 = {3, ls, 4, {"huhu", 43}}; struct U lu2 = {3, (ls), 4, {"huhu", 43}}; const struct S *pls = &ls; struct S ls21 = *pls; struct U lu22 = {3, *pls, 4, {"huhu", 43}}; /* Incomplete bracing. */ struct U lu21 = {3, ls, 4, "huhu", 43}; /* Optional braces around scalar initializers. Accepted, but with a warning. */ struct U lu3 = { 3, {5,6,7,8,}, 4, {"huhu", 43}}; /* Many superfluous braces and leaving out one initializer for U.s.c[1] */ struct U lu4 = { 3, {5,6,7,}, 5, { "bla", 44} }; /* Superfluous braces and useless parens around values */ struct S ls3 = { (1), (2), {(((3))), 4}}; /* Superfluous braces, and leaving out braces for V.t, plus cast */ struct V lv = {{3,4,{5,6}}, "haha", (u8)45, 46}; /* Compound literal */ struct V lv2 = {(struct S)w->t.s, {"hihi", 47}, 48}; /* Parens around compound literal */ struct V lv3 = {((struct S){7,8,{9,10}}), ((const struct W *)w)->t.t, 50}; const struct pkthdr *phdr = phdr_; struct flowi6 flow = { .daddr = phdr->daddr, .saddr = phdr->saddr }; int elt = 0x42; /* Range init, overlapping */ struct T lt2 = { { [1 ... 5] = 9, [6 ... 10] = elt, [4 ... 7] = elt+1 }, 1 }; print(ls); print(ls2); print(lt); print(lu); print(lu1); print(lu2); print(ls21); print(lu21); print(lu22); print(lu3); print(lu4); print(ls3); print(lv); print(lv2); print(lv3); print(lt2); print(flow); } #endif void test_compound_with_relocs (void) { struct Wrap local_wrap[] = { ((struct Wrap) {inc_global}), inc_global, }; void (*p)(void); p = global_wrap[0].func; p(); p = global_wrap[1].func; p(); p = local_wrap[0].func; p(); p = local_wrap[1].func; p(); } void sys_ni(void) { printf("ni\n"); } void sys_one(void) { printf("one\n"); } void sys_two(void) { printf("two\n"); } void sys_three(void) { printf("three\n"); } typedef void (*fptr)(void); const fptr table[3] = { [0 ... 2] = &sys_ni, [0] = sys_one, [1] = sys_two, [2] = sys_three, }; void test_multi_relocs(void) { int i; for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) table[i](); } /* Following is from GCC gcc.c-torture/execute/20050613-1.c. */ struct SEA { int i; int j; int k; int l; }; struct SEB { struct SEA a; int r[1]; }; struct SEC { struct SEA a; int r[0]; }; struct SED { struct SEA a; int r[]; }; static void test_correct_filling (struct SEA *x) { static int i; if (x->i != 0 || x->j != 5 || x->k != 0 || x->l != 0) printf("sea_fill%d: wrong\n", i); else printf("sea_fill%d: okay\n", i); i++; } int test_zero_init (void) { /* The peculiarity here is that only a.j is initialized. That means that all other members must be zero initialized. TCC once didn't do that for sub-level designators. */ struct SEB b = { .a.j = 5 }; struct SEC c = { .a.j = 5 }; struct SED d = { .a.j = 5 }; test_correct_filling (&b.a); test_correct_filling (&c.a); test_correct_filling (&d.a); return 0; } int main() { print(ce); print(gs); print(gs2); print(gt); print(gu); print(gu2); print(gu3); print(gu4); print(gs3); print(gv); print(gv2); print(gv3); print(sinit16); print(gw); print(gsu); print(guv); print(guv.b); print(guv2); print(guv3); print(phdr); foo(&gw, &phdr); //printf("q: %s\n", q); test_compound_with_relocs(); test_multi_relocs(); test_zero_init(); return 0; }chibicc-1.0.23.1/test/syscalls1.c000066400000000000000000000056001505335450300163650ustar00rootroot00000000000000 #include #include #include #include #include #include #include #include #include #include #include "test.h" int main() { // Write to standard output const char *msg = "Hello, world!\n"; syscall(SYS_write, STDOUT_FILENO, msg, 14); // Read from standard input // char buffer[128]; // ssize_t bytesRead = syscall(SYS_read, STDIN_FILENO, buffer, sizeof(buffer) - 1); // if (bytesRead >= 0) { // buffer[bytesRead] = '\0'; // printf("Read: %s\n", buffer); // } // Open a file and read from it int fd = syscall(SYS_open, "test.txt", O_RDONLY); if (fd >= 0) { char buffer[128]; ssize_t bytesRead = syscall(SYS_read, fd, buffer, sizeof(buffer) - 1); if (bytesRead >= 0) { buffer[bytesRead] = '\0'; printf("Read from file: %s\n", buffer); } syscall(SYS_close, fd); } // Get the process ID pid_t pid = syscall(SYS_getpid); printf("Process ID: %d\n", pid); // Fork a child process pid = syscall(SYS_fork); if (pid == 0) { printf("This is the child process\n"); } else if (pid > 0) { printf("This is the parent process, child PID: %d\n", pid); } else { printf("Fork failed\n"); } //Execute a program // char *argv[] = { "/bin/ls", "-l", NULL }; // char *envp[] = { NULL }; // syscall(SYS_execve, "/bin/ls", argv, envp); // Map a file into memory fd = syscall(SYS_open, "test.txt", O_RDONLY); if (fd >= 0) { char *data = syscall(SYS_mmap, NULL, 4096, PROT_READ, MAP_PRIVATE, fd, 0); if (data != MAP_FAILED) { printf("Mapped data: %s\n", data); syscall(SYS_munmap, data, 4096); } syscall(SYS_close, fd); } // Kill a process // pid = syscall(SYS_getpid); // syscall(SYS_kill, pid, SIGTERM); // Get the current time struct timeval tv; syscall(SYS_gettimeofday, &tv, NULL); printf("Seconds: %ld\nMicroseconds: %ld\n", tv.tv_sec, tv.tv_usec); // Get system information struct utsname bufferinfo; if (syscall(SYS_uname, &bufferinfo) == 0) { printf("System name: %s\n", bufferinfo.sysname); printf("Node name: %s\n", bufferinfo.nodename); printf("Release: %s\n", bufferinfo.release); printf("Version: %s\n", bufferinfo.version); printf("Machine: %s\n", bufferinfo.machine); Assert("x86_64", bufferinfo.machine); Assert("Linux", bufferinfo.sysname); } else { perror("syscall(SYS_uname) failed"); } // Get the current user and group IDs uid_t uid = syscall(SYS_getuid); printf("User ID: %d\n", uid); gid_t gid = syscall(SYS_getgid); printf("Group ID: %d\n", gid); // Exit the process syscall(SYS_exit, 0); } chibicc-1.0.23.1/test/test.h000077500000000000000000000022741505335450300154420ustar00rootroot00000000000000#if defined(__slimcc__) || defined(__chibicc__) #include #undef assert #define ASSERT(x, y) assert(x, y, #y) #define DASSERT(x) _Static_assert((x), ""); ASSERT(1, x) #define EASSERT(x, y) _Static_assert((x) == (y), ""); ASSERT(x, y) #define LASSERT(x, y) assert64(x, y, #y) #define ASSERT128(x, y) assert128(x, y, #y, __FILE__, __LINE__) void assert128(__int128, __int128, char *, char *, int); void assert(int expected, int actual, char *code); void assert64(long long expected, long long actual, char *code); int printf(char *fmt, ...); int sprintf(char *buf, char *fmt, ...); int vsprintf(char *buf, char *fmt, void *ap); int strcmp(char *p, char *q); int strncmp(char *p, char *q, long n); int memcmp(char *p, char *q, long n); void exit(int n); int vsprintf(); long strlen(char *s); void *memcpy(void *dest, void *src, long n); void *memset(void *s, int c, long n); #else #include #include #undef assert extern void assert(int expected, int actual, char *code); extern void assert128(__int128, __int128, char *, char *, int); #define ASSERT(x, y) assert(x, y, #y) #define LASSERT(x, y) assert(x, y, #y) #define ASSERT128(x, y) assert128(x, y, #y, __FILE__, __LINE__) #endif chibicc-1.0.23.1/test/test.txt000066400000000000000000000000341505335450300160170ustar00rootroot00000000000000this is a test file for mmapchibicc-1.0.23.1/test/test1.c000066400000000000000000000000401505335450300155000ustar00rootroot00000000000000int main(void) { return 0; }chibicc-1.0.23.1/test/test_array.c000066400000000000000000000006751505335450300166330ustar00rootroot00000000000000#include #include "test.h" int main(int argc, char** argv) { char _Alignas(1024) arr1[11]; char _Alignas(1024) arr2[argc]; printf("%d\n", _Alignof arr1); // gcc/clang: 1024 chibicc: 1024 ASSERT(1024, _Alignof arr1); printf("%d\n", _Alignof arr2); // gcc/clang: 1024 chibicc: 8 ASSERT(8, _Alignof arr2); printf("%d\n", _Alignof *&arr1); // gcc:1024 clang:1 ASSERT(1024, _Alignof *&arr1); return 0; }chibicc-1.0.23.1/test/test_array_vla.c000066400000000000000000000004631505335450300174700ustar00rootroot00000000000000#include #include "test.h" int main() { int arr[10]; int *ptr = arr; printf("sizeof(arr) = %zu\n", sizeof(arr)); // Should print 40 (for int[10]) ASSERT(40, sizeof(arr)); printf("sizeof(ptr) = %zu\n", sizeof(ptr)); // Should print 8 (assuming 64-bit system) ASSERT(8, sizeof(ptr)); return 0; }chibicc-1.0.23.1/test/test_atomic_add.c000066400000000000000000000016121505335450300175710ustar00rootroot00000000000000#include #include #include "test.h" typedef uint32_t uint32; typedef int32_t int32; typedef struct { volatile uint32_t value; } pg_atomic_uint32; #define PG_HAVE_ATOMIC_FETCH_ADD_U32 static inline uint32_t pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_) { uint32 res; __asm__ __volatile__( " lock \n" " xaddl %0,%1 \n" : "=q"(res), "=m"(ptr->value) : "0" (add_), "m"(ptr->value) : "memory", "cc"); return res; } int main() { pg_atomic_uint32 atomic_var = {10}; // Initialize the atomic variable with 10 int32_t add_value = 5; printf("Initial value: %u\n", atomic_var.value); uint32_t old_value = pg_atomic_fetch_add_u32_impl(&atomic_var, add_value); printf("Old value: %u\n", old_value); printf("New value: %u\n", atomic_var.value); ASSERT(10, old_value); ASSERT(15, atomic_var.value); return 0; } chibicc-1.0.23.1/test/test_hash.c000066400000000000000000000012151505335450300164270ustar00rootroot00000000000000#include #include "test.h" #define HASHMAP_SIZE 10 unsigned int hash(const char *key) { unsigned int hash = 5381; int c; while ((c = *key++)) hash = ((hash << 5) + hash) + c; // hash * 33 + c return hash % HASHMAP_SIZE; } int main() { char *keys[] = {"float4", "float4a1", "float4a16"}; for (int i = 0; i < 3; i++) { printf("Key: %s, Hash: %u\n", keys[i], hash(keys[i])); if (i == 0) { ASSERT(5, hash(keys[i])); } else if (i == 1) { ASSERT(1, hash(keys[i])); } else if (i == 2) { ASSERT(3, hash(keys[i])); } } return 0; } chibicc-1.0.23.1/test/test_stdint.c000066400000000000000000000007001505335450300170070ustar00rootroot00000000000000#include #include #include #include #include "test.h" uint16_t swap_bytes(uint16_t x) { return (x >> 8) | (x << 8); } int main() { uint16_t x = 0x1234; uint16_t y = swap_bytes(x); printf("Original: 0x%x, Swapped: 0x%x\n", x, y); ASSERT(0x3412, y); __uint16_t a = 0x3456; __uint16_t b = swap_bytes(a); printf("Original: 0x%x, Swapped: 0x%x\n", a, b); ASSERT(0x5634, b); return 0; } chibicc-1.0.23.1/test/thirdparty/000077500000000000000000000000001505335450300164745ustar00rootroot00000000000000chibicc-1.0.23.1/test/thirdparty/common000077500000000000000000000002411505335450300177070ustar00rootroot00000000000000make="make -j$(nproc)" chibicc=`pwd`/chibicc dir=$(basename -s .git $repo) set -e -x mkdir -p thirdparty cd thirdparty [ -d $dir ] || git clone $repo cd $dir chibicc-1.0.23.1/test/thirdparty/cpython.sh000077500000000000000000000006231505335450300205200ustar00rootroot00000000000000#!/bin/bash repo='git@github.com:python/cpython.git' . test/thirdparty/common git reset --hard c75330605d4795850ec74fdc4d69aa5d92f76c00 # Python's './configure' command misidentifies chibicc as icc # (Intel C Compiler) because icc is a substring of chibicc. # Modify the configure file as a workaround. sed -i -e 1996,2011d configure.ac autoreconf CC=$chibicc ./configure $make clean $make $make test chibicc-1.0.23.1/test/thirdparty/git.sh000077500000000000000000000002511505335450300176140ustar00rootroot00000000000000#!/bin/bash repo='git@github.com:git/git.git' . test/thirdparty/common git reset --hard 54e85e7af1ac9e9a92888060d6811ae767fea1bc $make clean $make V=1 CC=$chibicc test chibicc-1.0.23.1/test/thirdparty/libpng.sh000077500000000000000000000004001505335450300203000ustar00rootroot00000000000000#!/bin/bash repo='git@github.com:rui314/libpng.git' . test/thirdparty/common git reset --hard dbe3e0c43e549a1602286144d94b0666549b18e6 CC=$chibicc ./configure sed -i 's/^wl=.*/wl=-Wl,/; s/^pic_flag=.*/pic_flag=-fPIC/' libtool $make clean $make $make test chibicc-1.0.23.1/test/thirdparty/sqlite.sh000077500000000000000000000004251505335450300203350ustar00rootroot00000000000000#!/bin/bash repo='git@github.com:sqlite/sqlite.git' . test/thirdparty/common git reset --hard 86f477edaa17767b39c7bae5b67cac8580f7a8c1 CC=$chibicc CFLAGS=-D_GNU_SOURCE ./configure sed -i 's/^wl=.*/wl=-Wl,/; s/^pic_flag=.*/pic_flag=-fPIC/' libtool $make clean $make $make test chibicc-1.0.23.1/test/thirdparty/tinycc.sh000077500000000000000000000003051505335450300203220ustar00rootroot00000000000000#!/bin/bash repo='git@github.com:TinyCC/tinycc.git' . test/thirdparty/common git reset --hard df67d8617b7d1d03a480a28f9f901848ffbfb7ec ./configure --cc=$chibicc $make clean $make $make CC=cc test chibicc-1.0.23.1/test/tls.c000077500000000000000000000010711505335450300152520ustar00rootroot00000000000000#include "test.h" #include #include _Thread_local int v1; _Thread_local int v2 = 5; int v3 = 7; int thread_main(void *unused) { ASSERT(0, v1); ASSERT(5, v2); ASSERT(7, v3); v1 = 1; v2 = 2; v3 = 3; ASSERT(1, v1); ASSERT(2, v2); ASSERT(3, v3); return 0; } int main() { pthread_t thr; ASSERT(0, v1); ASSERT(5, v2); ASSERT(7, v3); ASSERT(0, pthread_create(&thr, NULL, thread_main, NULL)); ASSERT(0, pthread_join(thr, NULL)); ASSERT(0, v1); ASSERT(5, v2); ASSERT(3, v3); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/tls2.c000066400000000000000000000015161505335450300153350ustar00rootroot00000000000000#include "test.h" #include #include static _Thread_local int tentative_tls; static _Thread_local int tentative_tls = 3; extern _Thread_local int extern_tls; void *thread_main(void *unused) { static _Thread_local int v1; static _Thread_local int v2 = 5; ASSERT(0, v1); ASSERT(5, v2); ASSERT(3, tentative_tls); ASSERT(0, extern_tls); v1 = 1; v2 = 2; tentative_tls = 9; extern_tls = 7; ASSERT(1, v1); ASSERT(2, v2); ASSERT(9, tentative_tls); ASSERT(7, extern_tls); return NULL; } int main() { pthread_t thr1; pthread_t thr2; ASSERT(0, pthread_create(&thr1, NULL, thread_main, NULL)); thread_main(NULL); ASSERT(0, pthread_create(&thr2, NULL, thread_main, NULL)); ASSERT(0, pthread_join(thr1, NULL)); ASSERT(0, pthread_join(thr2, NULL)); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/trace.h000066400000000000000000000061371505335450300155600ustar00rootroot00000000000000#ifndef TRACE_H #define TRACE_H #ifdef ENABLE_DTRACE #include "memcached_dtrace.h" #else #define MEMCACHED_ASSOC_DELETE(arg0, arg1) #define MEMCACHED_ASSOC_DELETE_ENABLED() (0) #define MEMCACHED_ASSOC_FIND(arg0, arg1, arg2) #define MEMCACHED_ASSOC_FIND_ENABLED() (0) #define MEMCACHED_ASSOC_INSERT(arg0, arg1) #define MEMCACHED_ASSOC_INSERT_ENABLED() (0) #define MEMCACHED_COMMAND_ADD(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_ADD_ENABLED() (0) #define MEMCACHED_COMMAND_APPEND(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_APPEND_ENABLED() (0) #define MEMCACHED_COMMAND_CAS(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_CAS_ENABLED() (0) #define MEMCACHED_COMMAND_DECR(arg0, arg1, arg2, arg3) #define MEMCACHED_COMMAND_DECR_ENABLED() (0) #define MEMCACHED_COMMAND_DELETE(arg0, arg1, arg2) #define MEMCACHED_COMMAND_DELETE_ENABLED() (0) #define MEMCACHED_COMMAND_GET(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_GET_ENABLED() (0) #define MEMCACHED_COMMAND_TOUCH(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_TOUCH_ENABLED() (0) #define MEMCACHED_COMMAND_INCR(arg0, arg1, arg2, arg3) #define MEMCACHED_COMMAND_INCR_ENABLED() (0) #define MEMCACHED_COMMAND_PREPEND(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_PREPEND_ENABLED() (0) #define MEMCACHED_COMMAND_REPLACE(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_REPLACE_ENABLED() (0) #define MEMCACHED_COMMAND_SET(arg0, arg1, arg2, arg3, arg4) #define MEMCACHED_COMMAND_SET_ENABLED() (0) #define MEMCACHED_CONN_ALLOCATE(arg0) #define MEMCACHED_CONN_ALLOCATE_ENABLED() (0) #define MEMCACHED_CONN_CREATE(arg0) #define MEMCACHED_CONN_CREATE_ENABLED() (0) #define MEMCACHED_CONN_DESTROY(arg0) #define MEMCACHED_CONN_DESTROY_ENABLED() (0) #define MEMCACHED_CONN_DISPATCH(arg0, arg1) #define MEMCACHED_CONN_DISPATCH_ENABLED() (0) #define MEMCACHED_CONN_RELEASE(arg0) #define MEMCACHED_CONN_RELEASE_ENABLED() (0) #define MEMCACHED_ITEM_LINK(arg0, arg1, arg2) #define MEMCACHED_ITEM_LINK_ENABLED() (0) #define MEMCACHED_ITEM_REMOVE(arg0, arg1, arg2) #define MEMCACHED_ITEM_REMOVE_ENABLED() (0) #define MEMCACHED_ITEM_REPLACE(arg0, arg1, arg2, arg3, arg4, arg5) #define MEMCACHED_ITEM_REPLACE_ENABLED() (0) #define MEMCACHED_ITEM_UNLINK(arg0, arg1, arg2) #define MEMCACHED_ITEM_UNLINK_ENABLED() (0) #define MEMCACHED_ITEM_UPDATE(arg0, arg1, arg2) #define MEMCACHED_ITEM_UPDATE_ENABLED() (0) #define MEMCACHED_PROCESS_COMMAND_END(arg0, arg1, arg2) #define MEMCACHED_PROCESS_COMMAND_END_ENABLED() (0) #define MEMCACHED_PROCESS_COMMAND_START(arg0, arg1, arg2) #define MEMCACHED_PROCESS_COMMAND_START_ENABLED() (0) #define MEMCACHED_SLABS_ALLOCATE(arg0, arg1, arg2, arg3) #define MEMCACHED_SLABS_ALLOCATE_ENABLED() (0) #define MEMCACHED_SLABS_ALLOCATE_FAILED(arg0, arg1) #define MEMCACHED_SLABS_ALLOCATE_FAILED_ENABLED() (0) #define MEMCACHED_SLABS_FREE(arg0, arg1, arg2) #define MEMCACHED_SLABS_FREE_ENABLED() (0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE(arg0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_ENABLED() (0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(arg0) #define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED_ENABLED() (0) #endif #endif chibicc-1.0.23.1/test/typedef.c000077500000000000000000000007251505335450300161150ustar00rootroot00000000000000#include "test.h" typedef int MyInt, MyInt2[4]; typedef int; int main() { ASSERT(1, ({ typedef int t; t x=1; x; })); ASSERT(1, ({ typedef struct {int a;} t; t x; x.a=1; x.a; })); ASSERT(1, ({ typedef int t; t t=1; t; })); ASSERT(2, ({ typedef struct {int a;} t; { typedef int t; } t x; x.a=2; x.a; })); ASSERT(4, ({ typedef t; t x; sizeof(x); })); ASSERT(3, ({ MyInt x=3; x; })); ASSERT(16, ({ MyInt2 x; sizeof(x); })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/typeof.c000077500000000000000000000005331505335450300157600ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(3, ({ typeof(int) x=3; x; })); ASSERT(3, ({ typeof(1) x=3; x; })); ASSERT(4, ({ int x; typeof(x) y; sizeof(y); })); ASSERT(8, ({ int x; typeof(&x) y; sizeof(y); })); ASSERT(4, ({ typeof("foo") x; sizeof(x); })); ASSERT(12, sizeof(typeof(struct { int a,b,c; }))); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/umul.c000066400000000000000000000045661505335450300154430ustar00rootroot00000000000000#include "test.h" #include #include #include typedef __int128 __uint128_t; bool umul_overflow_u8(uint8_t a, uint8_t b, uint8_t *res) { uint16_t r = (uint16_t)a * (uint16_t)b; *res = (uint8_t)r; return r > UINT8_MAX; } bool umul_overflow_u16(uint16_t a, uint16_t b, uint16_t *res) { uint32_t r = (uint32_t)a * (uint32_t)b; *res = (uint16_t)r; return r > UINT16_MAX; } bool umul_overflow_u32(uint32_t a, uint32_t b, uint32_t *res) { uint64_t r = (uint64_t)a * (uint64_t)b; *res = (uint32_t)r; return r > UINT32_MAX; } bool umul_overflow_u64(uint64_t a, uint64_t b, uint64_t *res) { __uint128_t r = (__uint128_t)a * (__uint128_t)b; *res = (uint64_t)r; return r > UINT64_MAX; } void test_umul_overflow() { uint8_t r8; uint16_t r16; uint32_t r32; uint64_t r64; __int128 r128; // 8-bit printf("8-bit: %d %d -> %d, overflow=%d\n", 10, 20, r8, umul_overflow_u8(10, 20, &r8)); printf("8-bit overflow: %d %d -> %d, overflow=%d\n", 200, 2, r8, umul_overflow_u8(200, 2, &r8)); ASSERT(0, umul_overflow_u8(10, 20, &r8)); ASSERT(1, umul_overflow_u8(200, 2, &r8)); // 16-bit printf("16-bit: %d %d -> %d, overflow=%d\n", 300, 100, r16, umul_overflow_u16(300, 100, &r16)); printf("16-bit overflow: %d %d -> %d, overflow=%d\n", 40000, 2, r16, umul_overflow_u16(40000, 2, &r16)); ASSERT(0, umul_overflow_u16(300, 100, &r16)); ASSERT(1, umul_overflow_u16(40000, 2, &r16)); // 32-bit printf("32-bit: %u %u -> %u, overflow=%d\n", 100000, 1000, r32, umul_overflow_u32(100000, 1000, &r32)); printf("32-bit overflow: %u %u -> %u, overflow=%d\n", 3000000000U, 2U, r32, umul_overflow_u32(3000000000U, 2U, &r32)); ASSERT(0, umul_overflow_u32(100000, 1000, &r32)); ASSERT(1, umul_overflow_u32(3000000000U, 2U, &r32)); // 64-bit printf("64-bit: %llu %llu -> %llu, overflow=%d\n", 10000000000ULL, 1000ULL, r64, umul_overflow_u64(10000000000ULL, 1000ULL, &r64)); printf("64-bit overflow: %llu %llu -> %llu, overflow=%d\n", 0xFFFFFFFFFFFFFFF0ULL, 2ULL, r64, umul_overflow_u64(0xFFFFFFFFFFFFFFF0ULL, 2ULL, &r64)); ASSERT(0, umul_overflow_u64(10000000000ULL, 1000ULL, &r64)); ASSERT(1, umul_overflow_u64(0xFFFFFFFFFFFFFFF0ULL, 2ULL, &r64)); } int main() { test_umul_overflow(); return 0; } chibicc-1.0.23.1/test/unicode.c000077500000000000000000000056231505335450300161050ustar00rootroot00000000000000#include "test.h" #define STR(x) #x typedef unsigned short char16_t; typedef unsigned int char32_t; typedef int wchar_t; int π = 3; int main() { ASSERT(4, sizeof(L'\0')); ASSERT(97, L'a'); ASSERT(0, strcmp("αβγ", "\u03B1\u03B2\u03B3")); ASSERT(0, strcmp("日本語", "\u65E5\u672C\u8A9E")); ASSERT(0, strcmp("日本語", "\U000065E5\U0000672C\U00008A9E")); ASSERT(0, strcmp("🌮", "\U0001F32E")); ASSERT(-1, L'\xffffffff'>>31); ASSERT(946, L'β'); ASSERT(12354, L'あ'); ASSERT(127843, L'🍣'); ASSERT(2, sizeof(u'\0')); ASSERT(1, u'\xffff'>>15); ASSERT(97, u'a'); ASSERT(946, u'β'); ASSERT(12354, u'あ'); ASSERT(62307, u'🍣'); ASSERT(0, strcmp(STR(u'a'), "u'a'")); ASSERT(4, sizeof(U'\0')); ASSERT(1, U'\xffffffff'>>31); ASSERT(97, U'a'); ASSERT(946, U'β'); ASSERT(12354, U'あ'); ASSERT(127843, U'🍣'); ASSERT(0, strcmp(STR(U'a'), "U'a'")); ASSERT(4, sizeof(u8"abc")); ASSERT(0, strcmp(u8"abc", "abc")); ASSERT(0, strcmp(STR(u8"a"), "u8\"a\"")); ASSERT(2, sizeof(u"")); ASSERT(10, sizeof(u"\xffzzz")); ASSERT(0, memcmp(u"", "\0\0", 2)); ASSERT(0, memcmp(u"abc", "a\0b\0c\0\0\0", 8)); ASSERT(0, memcmp(u"日本語", "\345e,g\236\212\0\0", 8)); ASSERT(0, memcmp(u"🍣", "<\330c\337\0\0", 6)); ASSERT(u'β', u"βb"[0]); ASSERT(u'b', u"βb"[1]); ASSERT(0, u"βb"[2]); ASSERT(0, strcmp(STR(u"a"), "u\"a\"")); ASSERT(4, sizeof(U"")); ASSERT(20, sizeof(U"\xffzzz")); ASSERT(0, memcmp(U"", "\0\0\0\0", 4)); ASSERT(0, memcmp(U"abc", "a\0\0\0b\0\0\0c\0\0\0\0\0\0\0", 16)); ASSERT(0, memcmp(U"日本語", "\345e\0\0,g\0\0\236\212\0\0\0\0\0\0", 16)); ASSERT(0, memcmp(U"🍣", "c\363\001\0\0\0\0\0", 8)); ASSERT(u'β', U"βb"[0]); ASSERT(u'b', U"βb"[1]); ASSERT(0, U"βb"[2]); ASSERT(1, U"\xffffffff"[0] >> 31); ASSERT(0, strcmp(STR(U"a"), "U\"a\"")); ASSERT(4, sizeof(L"")); ASSERT(20, sizeof(L"\xffzzz")); ASSERT(0, memcmp(L"", "\0\0\0\0", 4)); ASSERT(0, memcmp(L"abc", "a\0\0\0b\0\0\0c\0\0\0\0\0\0\0", 16)); ASSERT(0, memcmp(L"日本語", "\345e\0\0,g\0\0\236\212\0\0\0\0\0\0", 16)); ASSERT(0, memcmp(L"🍣", "c\363\001\0\0\0\0\0", 8)); ASSERT(u'β', L"βb"[0]); ASSERT(u'b', L"βb"[1]); ASSERT(0, L"βb"[2]); ASSERT(-1, L"\xffffffff"[0] >> 31); ASSERT(0, strcmp(STR(L"a"), "L\"a\"")); ASSERT(u'α', ({ char16_t x[] = u"αβ"; x[0]; })); ASSERT(u'β', ({ char16_t x[] = u"αβ"; x[1]; })); ASSERT(6, ({ char16_t x[] = u"αβ"; sizeof(x); })); ASSERT(U'🤔', ({ char32_t x[] = U"🤔x"; x[0]; })); ASSERT(U'x', ({ char32_t x[] = U"🤔x"; x[1]; })); ASSERT(12, ({ char32_t x[] = U"🤔x"; sizeof(x); })); ASSERT(L'🤔', ({ wchar_t x[] = L"🤔x"; x[0]; })); ASSERT(L'x', ({ wchar_t x[] = L"🤔x"; x[1]; })); ASSERT(12, ({ wchar_t x[] = L"🤔x"; sizeof(x); })); ASSERT(3, π); ASSERT(3, ({ int あβ0¾=3; あβ0¾; })); ASSERT(5, ({ int $$$=5; $$$; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/unicode2.c000077500000000000000000000004171505335450300161630ustar00rootroot00000000000000#include #include #include "test.h" int main(void) { printf("\xE2\x98\xA0 \n"); printf("\U0001F602\n"); printf("\u2620\n"); printf("\x09\x65\n"); printf("\u0965\n"); printf("%d\n", '\\'); ASSERT(92, '\\'); return 0; }chibicc-1.0.23.1/test/union.c000077500000000000000000000021521505335450300156010ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(8, ({ union { int a; char b[6]; } x; sizeof(x); })); ASSERT(3, ({ union { int a; char b[4]; } x; x.a = 515; x.b[0]; })); ASSERT(2, ({ union { int a; char b[4]; } x; x.a = 515; x.b[1]; })); ASSERT(0, ({ union { int a; char b[4]; } x; x.a = 515; x.b[2]; })); ASSERT(0, ({ union { int a; char b[4]; } x; x.a = 515; x.b[3]; })); ASSERT(3, ({ union {int a,b;} x,y; x.a=3; y.a=5; y=x; y.a; })); ASSERT(3, ({ union {struct {int a,b;} c;} x,y; x.c.b=3; y.c.b=5; y=x; y.c.b; })); ASSERT(0xef, ({ union { struct { unsigned char a,b,c,d; }; long e; } x; x.e=0xdeadbeef; x.a; })); ASSERT(0xbe, ({ union { struct { unsigned char a,b,c,d; }; long e; } x; x.e=0xdeadbeef; x.b; })); ASSERT(0xad, ({ union { struct { unsigned char a,b,c,d; }; long e; } x; x.e=0xdeadbeef; x.c; })); ASSERT(0xde, ({ union { struct { unsigned char a,b,c,d; }; long e; } x; x.e=0xdeadbeef; x.d; })); ASSERT(3, ({struct { union { int a,b; }; union { int c,d; }; } x; x.a=3; x.b; })); ASSERT(5, ({struct { union { int a,b; }; union { int c,d; }; } x; x.d=5; x.c; })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/union2.c000066400000000000000000000160631505335450300156660ustar00rootroot00000000000000#include "test.h" #include union {char a; int b;} g11[2] = {{1}, {3}}; union {int a[2];} g12[2] = {{{1, 2}}}; int *g28 = &g11[1].a; union { struct { int a[3]; } a; } g30 = {{{1,2,3}}}; int *g31=g30.a.a; union {int a[2];} g40[2] = {{1, 2}, 3, 4}; union {int a[2];} g41[2] = {1, 2, 3, 4}; int main() { ASSERT(1, ({ union {int i;} u = {.i=1,}; u.i; })); ASSERT(1, ({ union { int i,j; } u[] = {1,2,3,4}; u[0].i; })); ASSERT(1, ({ union { int i,j; } u[] = {1,2,3,4}; u[0].j; })); ASSERT(2, ({ union { int i,j; } u[] = {1,2,3,4}; u[1].i; })); ASSERT(2, ({ union { int i,j; } u[] = {1,2,3,4}; u[1].j; })); ASSERT(1, ({ typedef union { struct {int i,j;};} U; U u1={1,2}; U u2=u1; u2.i; })); ASSERT(2, ({ typedef union { struct {int i,j;};} U; U u1={1,2}; U u2=u1; u2.j; })); ASSERT(0, ({ typedef union { struct {int a,b;}; struct {int c,d;};} U; U u1={.d=1,}; U u2=u1; u2.a; })); ASSERT(1, ({ typedef union { struct {int a,b;}; struct {int c,d;};} U; U u1={.d=1,}; U u2=u1; u2.b; })); ASSERT(0, ({ typedef union { struct {int a,b;}; struct {int c,d;};} U; U u1={.b=1,}; U u2=u1; u2.c; })); ASSERT(1, ({ typedef union { struct {int a,b;}; struct {int c,d;};} U; U u1={.b=1,}; U u2=u1; u2.d; })); ASSERT(2, ({ union { struct {int i; int j;} t; int k;} s = {.t.i=1, .k=2,}; s.t.i; })); ASSERT(0, ({ union { struct {int i; int j;} t; int k;} s = {.t.i=1, .k=2,}; s.t.j; })); ASSERT(2, ({ union { struct {int i; int j;} t; int k;} s = {.t.i=1, .k=2,}; s.k; })); ASSERT(1, ({ union { struct {int a, b;} c;} s = {.c.a = 1,.c.b = 2,}; s.c.a; })); ASSERT(2, ({ union { struct {int a, b;} c;} s = {.c.a = 1,.c.b = 2,}; s.c.b; })); ASSERT(7, ({ union { struct {int a,b,c;};} s = {.a=7,5,3}; s.a; })); ASSERT(5, ({ union { struct {int a,b,c;};} s = {.a=7,5,3}; s.b; })); ASSERT(3, ({ union { struct {int a,b,c;};} s = {.a=7,5,3}; s.c; })); ASSERT(0, ({ union { struct {char a,b,c;};} s = {.b=7,5}; s.a; })); ASSERT(7, ({ union { struct {char a,b,c;};} s = {.b=7,5}; s.b; })); ASSERT(5, ({ union { struct {char a,b,c;};} s = {.b=7,5}; s.c; })); ASSERT(3, ({ union { struct {char a,b,c;};} s = {.b=7,5,.a=3,1}; s.a; })); ASSERT(1, ({ union { struct {char a,b,c;};} s = {.b=7,5,.a=3,1}; s.b; })); ASSERT(5, ({ union { struct {char a,b,c;};} s = {.b=7,5,.a=3,1}; s.c; })); ASSERT(3, ({ union { struct {int a,b,c;};} s = {3,.b=5,7}; s.a; })); ASSERT(5, ({ union { struct {int a,b,c;};} s = {3,.b=5,7}; s.b; })); ASSERT(7, ({ union { struct {int a,b,c;};} s = {3,.b=5,7}; s.c; })); ASSERT(3, ({ union { struct {int a,b,c;};} s = {3,5,.c=7}; s.a; })); ASSERT(5, ({ union { struct {int a,b,c;};} s = {3,5,.c=7}; s.b; })); ASSERT(7, ({ union { struct {int a,b,c;};} s = {3,5,.c=7}; s.c; })); ASSERT(1, ({ union {int a; int b; int c;} x={1,2,3}; x.a; })); ASSERT(1, ({ union {int a; int b; int c;} x={1,2,3}; x.b; })); ASSERT(1, ({ union {int a; int b; int c;} x={1,2,3}; x.c; })); ASSERT(1, ({ union {int a; int b; int c;} x={1}; x.a; })); ASSERT(1, ({ union {int a; int b; int c;} x={1}; x.b; })); ASSERT(1, ({ union {int a; int b; int c;} x={1}; x.c; })); ASSERT(1, ({ union {int a; int b;} x[2]={{1,2},{3,4}}; x[0].a; })); ASSERT(1, ({ union {int a; int b;} x[2]={{1,2},{3,4}}; x[0].b; })); ASSERT(3, ({ union {int a; int b;} x[2]={{1,2},{3,4}}; x[1].a; })); ASSERT(3, ({ union {int a; int b;} x[2]={{1,2},{3,4}}; x[1].b; })); ASSERT(2, ({ union {int a; int b;} x[2]={{1},{2}}; x[1].b; })); ASSERT(0, ({ union {int a; int b;} x={}; x.a; })); ASSERT(0, ({ union {int a; int b;} x={}; x.b; })); ASSERT(1, ({ typedef union {int a,b,c,d,e,f;} T; T x={1,2,3,4,5,6}; T y; y=x; y.e; })); ASSERT(1, ({ typedef union {int a,b;} T; T x={1,2}; T y, z; z=y=x; z.b; })); ASSERT(1, ({ typedef union {int a,b;} T; T x={1,2}; T y=x; y.a; })); ASSERT(1, g11[0].a); ASSERT(1, g11[0].b); ASSERT(3, g11[1].a); ASSERT(3, g11[1].b); ASSERT(1, g12[0].a[0]); ASSERT(2, g12[0].a[1]); ASSERT(0, g12[1].a[0]); ASSERT(0, g12[1].a[1]); ASSERT(3, *g28); ASSERT(1, g31[0]); ASSERT(2, g31[1]); ASSERT(3, g31[2]); ASSERT(1, g40[0].a[0]); ASSERT(2, g40[0].a[1]); ASSERT(3, g40[1].a[0]); ASSERT(4, g40[1].a[1]); ASSERT(1, g41[0].a[0]); ASSERT(2, g41[0].a[1]); ASSERT(3, g41[1].a[0]); ASSERT(4, g41[1].a[1]); ASSERT(0, ({ union {int a; int b;} x[2]={0,1,2,3}; x[0].a; })); ASSERT(1, ({ union {int a; int b;} x[2]={0,1,2,3}; x[1].a; })); ASSERT(1, ({ union {int a,b,c;} x={1,2,3,}; x.a; })); ASSERT(1, ({ union {int a; char b;} x={1,}; x.a; })); ASSERT(4, ({ union { int a,b; } x={1,.a=4}; x.a; })); ASSERT(4, ({ union { int a,b; } x={1,2,.b=3,.a=4}; x.b; })); ASSERT(1, ({ union { struct { int a,b; } c; } x={.c=1,2}; x.c.a; })); ASSERT(2, ({ union { struct { int a,b; } c; } x={.c=1,2}; x.c.b; })); ASSERT(0, ({ union { struct { int a,b; } c; } x={.c.b=1}; x.c.a; })); ASSERT(1, ({ union { struct { int a,b; } c; } x={.c.b=1}; x.c.b; })); ASSERT(1, ({ union { int a[2]; } x={.a=1,2}; x.a[0]; })); ASSERT(2, ({ union { int a[2]; } x={.a=1,2}; x.a[1]; })); ASSERT(0, ({ union { int a[2]; } x={.a[1]=1}; x.a[0]; })); ASSERT(1, ({ union { int a[2]; } x={.a[1]=1}; x.a[1]; })); ASSERT(3, ({ union { int a,b; } x[]={[1].b=1,2,[0]=3,}; x[0].a; })); ASSERT(3, ({ union { int a,b; } x[]={[1].b=1,2,[0]=3,}; x[0].b; })); ASSERT(1, ({ union { int a,b; } x[]={[1].b=1,2,[0]=3,}; x[1].a; })); ASSERT(1, ({ union { int a,b; } x[]={[1].b=1,2,[0]=3,}; x[1].b; })); ASSERT(2, ({ union { int a,b; } x[]={[1].b=1,2,[0]=3,}; x[2].a; })); ASSERT(2, ({ union { int a,b; } x[]={[1].b=1,2,[0]=3,}; x[2].b; })); ASSERT(3, ({ union { int a; struct {int b,c;}; } x[]={[1].c=1,2,[0]=3,}; x[0].a; })); ASSERT(0, ({ union { int a; struct {int b,c;}; } x[]={[1].c=1,2,[0]=3,}; x[0].c; })); ASSERT(0, ({ union { int a; struct {int b,c;}; } x[]={[1].c=1,2,[0]=3,}; x[1].a; })); ASSERT(1, ({ union { int a; struct {int b,c;}; } x[]={[1].c=1,2,[0]=3,}; x[1].c; })); ASSERT(2, ({ union { int a; struct {int b,c;}; } x[]={[1].c=1,2,[0]=3,}; x[2].a; })); ASSERT(0, ({ union { int a; struct {int b,c;}; } x[]={[1].c=1,2,[0]=3,}; x[2].c; })); ASSERT(1, ({ typedef union { int a,b; } T; T x={1,2}; T y[]={x}; y[0].a; })); ASSERT(1, ({ typedef union { int a,b; } T; T x={1,2}; T y[]={x}; y[0].b; })); ASSERT(1, ({ typedef union { int a,b; } T; T x={1}; T y[]={x, [2].b=3}; y[0].a; })); ASSERT(3, ({ typedef union { int a,b; } T; T x={1}; T y[]={x, [2].b=3}; y[2].b; })); ASSERT(5, ((union { int a,b,c; }){ .c=5 }).c); ASSERT(5, ((union { int a,b,c; }){ .c=5 }).a); ASSERT(3, ({ union { struct { int a; struct { int b, c; }; }; } x={.b=1,2,.a=3}; x.a; })); ASSERT(1, ({ union { struct { int a; struct { int b, c; }; }; } x={.b=1,2,.a=3}; x.b; })); ASSERT(2, ({ union { struct { int a; struct { int b, c; }; }; } x={.b=1,2,.a=3}; x.c; })); ASSERT(5, ({ union U { int8_t a; int64_t :37; }; sizeof(union U); })); ASSERT(1, ({ union U { int8_t a; int64_t :37; }; _Alignof(union U); })); ASSERT(6, ({ union U { int16_t a; int64_t :47; }; sizeof(union U); })); ASSERT(2, ({ union U { int16_t a; int64_t :47; }; _Alignof(union U); })); printf("OK\n"); return 0; }chibicc-1.0.23.1/test/usualconv.c000077500000000000000000000014611505335450300164720ustar00rootroot00000000000000#include "test.h" static int ret10(void) { return 10; } int main() { ASSERT((long)-5, -10 + (long)5); ASSERT((long)-15, -10 - (long)5); ASSERT((long)-50, -10 * (long)5); ASSERT((long)-2, -10 / (long)5); ASSERT(1, -2 < (long)-1); ASSERT(1, -2 <= (long)-1); ASSERT(0, -2 > (long)-1); ASSERT(0, -2 >= (long)-1); ASSERT(1, (long)-2 < -1); ASSERT(1, (long)-2 <= -1); ASSERT(0, (long)-2 > -1); ASSERT(0, (long)-2 >= -1); ASSERT(0, 2147483647 + 2147483647 + 2); ASSERT((long)-1, ({ long x; x=-1; x; })); ASSERT(1, ({ char x[3]; x[0]=0; x[1]=1; x[2]=2; char *y=x+1; y[0]; })); ASSERT(0, ({ char x[3]; x[0]=0; x[1]=1; x[2]=2; char *y=x+1; y[-1]; })); ASSERT(5, ({ struct t {char a;} x, y; x.a=5; y=x; y.a; })); ASSERT(10, (1 ? ret10 : (void *)0)()); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/util.h000066400000000000000000000024631505335450300154350ustar00rootroot00000000000000#include "config.h" /* fast-enough functions for uriencoding strings. */ void uriencode_init(void); bool uriencode(const char *src, char *dst, const size_t srclen, const size_t dstlen); /* * Wrappers around strtoull/strtoll that are safer and easier to * use. For tests and assumptions, see internal_tests.c. * * str a NULL-terminated base decimal 10 unsigned integer * out out parameter, if conversion succeeded * * returns true if conversion succeeded. */ bool safe_strtoull(const char *str, uint64_t *out); bool safe_strtoull_hex(const char *str, uint64_t *out); bool safe_strtoll(const char *str, int64_t *out); bool safe_strtoul(const char *str, uint32_t *out); bool safe_strtol(const char *str, int32_t *out); bool safe_strtod(const char *str, double *out); bool safe_strcpy(char *dst, const char *src, const size_t dstmax); bool safe_memcmp(const void *a, const void *b, size_t len); #ifndef HAVE_HTONLL extern uint64_t htonll(uint64_t); extern uint64_t ntohll(uint64_t); #endif #ifdef __GCC # define __gcc_attribute__ __attribute__ #else # define __gcc_attribute__(x) #endif /** * Vararg variant of perror that makes for more useful error messages * when reporting with parameters. * * @param fmt a printf format */ void vperror(const char *fmt, ...) __gcc_attribute__ ((format (printf, 1, 2))); chibicc-1.0.23.1/test/uuid.c000066400000000000000000000053401505335450300154160ustar00rootroot00000000000000#define _GNU_SOURCE #include "test.h" #include #include #include typedef unsigned char uuid_t[16]; // If is not found struct uuid { uint32_t time_low; uint16_t time_mid; uint16_t time_hi_and_version; uint8_t clock_seq_hi_and_reserved; uint8_t clock_seq_low; uint8_t node[6]; }; // Weak alias extern time_t uuid_time(const uuid_t uu, struct timeval *ret_tv) __attribute__((weak, alias("__uuid_time"))); // Simulate the type decoder int __uuid_type(const struct uuid *uu) { return (uu->time_hi_and_version >> 12); } #define UUID_TYPE_DCE_TIME 1 #define UUID_TYPE_DCE_TIME_V6 6 #define UUID_TYPE_DCE_TIME_V7 7 void uuid_unpack(const uuid_t in, struct uuid *uu) { // Very naive unpacking; only for test/demo purposes uu->time_low = (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3]; uu->time_mid = (in[4] << 8) | in[5]; uu->time_hi_and_version = (in[6] << 8) | in[7]; uu->clock_seq_hi_and_reserved = in[8]; uu->clock_seq_low = in[9]; for (int i = 0; i < 6; i++) { uu->node[i] = in[10 + i]; } } void uuid_time_v1(const struct uuid *uu, struct timeval *tv) { tv->tv_sec = 111111; tv->tv_usec = 222; } void uuid_time_v6(const struct uuid *uu, struct timeval *tv) { tv->tv_sec = 666666; tv->tv_usec = 666; } void uuid_time_v7(const struct uuid *uu, struct timeval *tv) { tv->tv_sec = 777777; tv->tv_usec = 777; } // Real implementation time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv) { struct timeval tv; struct uuid uuid; uint8_t type; uuid_unpack(uu, &uuid); type = __uuid_type(&uuid); switch (type) { case UUID_TYPE_DCE_TIME: uuid_time_v1(&uuid, &tv); break; case UUID_TYPE_DCE_TIME_V6: uuid_time_v6(&uuid, &tv); break; case UUID_TYPE_DCE_TIME_V7: uuid_time_v7(&uuid, &tv); break; default: tv.tv_sec = -1; tv.tv_usec = -1; break; } if (ret_tv) *ret_tv = tv; return tv.tv_sec; } int main(void) { uuid_t test_uuid = { 0x12, 0x34, 0x56, 0x78, // time_low 0x9a, 0xbc, // time_mid 0x10, 0x00, // version = 1 (UUID_TYPE_DCE_TIME) 0xde, 0xad, // clock seq 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe // node }; struct timeval tv; time_t t = uuid_time(test_uuid, &tv); printf("uuid_time result: %ld.%06ld\n", (long)t, (long)tv.tv_usec); ASSERT(111111, (long)t); ASSERT(222, (long)tv.tv_usec); return 0; }chibicc-1.0.23.1/test/varargs.c000077500000000000000000000017011505335450300161150ustar00rootroot00000000000000#include "test.h" #include int sum1(int x, ...) { va_list ap; va_start(ap, x); for (;;) { int y = va_arg(ap, int); if (y == 0) return x; x += y; } } int sum2(int x, ...) { va_list ap; va_start(ap, x); for (;;) { double y = va_arg(ap, double); x += y; int z = va_arg(ap, int); if (z == 0) return x; x += z; } } void fmt(char *buf, char *fmt, ...) { va_list ap; va_start(ap, fmt); va_list ap2; va_copy(ap2, ap); vsprintf(buf, fmt, ap2); va_end(buf); } int main() { ASSERT(6, sum1(1, 2, 3, 0)); ASSERT(55, sum1(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0)); ASSERT(21, sum2(1, 2.0, 3, 4.0, 5, 6.0, 0)); ASSERT(21, sum2(1, 2.0, 3, 4.0, 5, 6.0, 0)); ASSERT(210, sum2(1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9, 10.0, 11, 12.0, 13, 14.0, 15, 16.0, 17, 18.0, 19, 20.0, 0)); ASSERT(0, ({ char buf[100]; fmt(buf, "%d %d", 2, 3); strcmp(buf, "2 3"); })); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/variable.c000077500000000000000000000044101505335450300162350ustar00rootroot00000000000000#include "test.h" int g1, g2[4]; static int g3 = 3; int main() { ASSERT(3, ({ int a; a=3; a; })); ASSERT(3, ({ int a=3; a; })); ASSERT(8, ({ int a=3; int z=5; a+z; })); ASSERT(3, ({ int a=3; a; })); ASSERT(8, ({ int a=3; int z=5; a+z; })); ASSERT(6, ({ int a; int b; a=b=3; a+b; })); ASSERT(3, ({ int foo=3; foo; })); ASSERT(8, ({ int foo123=3; int bar=5; foo123+bar; })); ASSERT(4, ({ int x; sizeof(x); })); ASSERT(4, ({ int x; sizeof x; })); ASSERT(8, ({ int *x; sizeof(x); })); ASSERT(16, ({ int x[4]; sizeof(x); })); ASSERT(48, ({ int x[3][4]; sizeof(x); })); ASSERT(16, ({ int x[3][4]; sizeof(*x); })); ASSERT(4, ({ int x[3][4]; sizeof(**x); })); ASSERT(5, ({ int x[3][4]; sizeof(**x) + 1; })); ASSERT(5, ({ int x[3][4]; sizeof **x + 1; })); ASSERT(4, ({ int x[3][4]; sizeof(**x + 1); })); ASSERT(4, ({ int x=1; sizeof(x=2); })); ASSERT(1, ({ int x=1; sizeof(x=2); x; })); ASSERT(0, g1); ASSERT(3, ({ g1=3; g1; })); ASSERT(0, ({ g2[0]=0; g2[1]=1; g2[2]=2; g2[3]=3; g2[0]; })); ASSERT(1, ({ g2[0]=0; g2[1]=1; g2[2]=2; g2[3]=3; g2[1]; })); ASSERT(2, ({ g2[0]=0; g2[1]=1; g2[2]=2; g2[3]=3; g2[2]; })); ASSERT(3, ({ g2[0]=0; g2[1]=1; g2[2]=2; g2[3]=3; g2[3]; })); ASSERT(4, sizeof(g1)); ASSERT(16, sizeof(g2)); ASSERT(1, ({ char x=1; x; })); ASSERT(1, ({ char x=1; char y=2; x; })); ASSERT(2, ({ char x=1; char y=2; y; })); ASSERT(1, ({ char x; sizeof(x); })); ASSERT(10, ({ char x[10]; sizeof(x); })); ASSERT(2, ({ int x=2; { int x=3; } x; })); ASSERT(2, ({ int x=2; { int x=3; } int y=4; x; })); ASSERT(3, ({ int x=2; { x=3; } x; })); ASSERT(7, ({ int x; int y; char z; char *a=&y; char *b=&z; b-a; })); ASSERT(1, ({ int x; char y; int z; char *a=&y; char *b=&z; b-a; })); ASSERT(8, ({ long x; sizeof(x); })); ASSERT(2, ({ short x; sizeof(x); })); ASSERT(24, ({ char *x[3]; sizeof(x); })); ASSERT(8, ({ char (*x)[3]; sizeof(x); })); ASSERT(1, ({ char (x); sizeof(x); })); ASSERT(3, ({ char (x)[3]; sizeof(x); })); ASSERT(12, ({ char (x[3])[4]; sizeof(x); })); ASSERT(4, ({ char (x[3])[4]; sizeof(x[0]); })); ASSERT(3, ({ char *x[3]; char y; x[0]=&y; y=3; x[0][0]; })); ASSERT(4, ({ char x[3]; char (*y)[3]=x; y[0][0]=4; y[0][0]; })); { void *x; } ASSERT(3, g3); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/variable_test.c000066400000000000000000000101721505335450300172730ustar00rootroot00000000000000#include "test.h" int g1, g2[4]; static int g3 = 3; int main() { ASSERT(3, ({ int a; a = 3; a; })); ASSERT(3, ({ int a = 3; a; })); ASSERT(8, ({ int a = 3; int z = 5; a + z; })); ASSERT(3, ({ int a = 3; a; })); ASSERT(8, ({ int a = 3; int z = 5; a + z; })); ASSERT(6, ({ int a; int b; a = b = 3; a + b; })); ASSERT(3, ({ int foo = 3; foo; })); ASSERT(8, ({ int foo123 = 3; int bar = 5; foo123 + bar; })); ASSERT(4, ({ int x; sizeof(x); })); ASSERT(4, ({ int x; sizeof x; })); ASSERT(8, ({ int *x; sizeof(x); })); ASSERT(16, ({ int x[4]; sizeof(x); })); ASSERT(48, ({ int x[3][4]; sizeof(x); })); ASSERT(16, ({ int x[3][4]; sizeof(*x); })); ASSERT(4, ({ int x[3][4]; sizeof(**x); })); ASSERT(5, ({ int x[3][4]; sizeof(**x) + 1; })); ASSERT(5, ({ int x[3][4]; sizeof **x + 1; })); ASSERT(4, ({ int x[3][4]; sizeof(**x + 1); })); ASSERT(4, ({ int x = 1; sizeof(x = 2); })); ASSERT(1, ({ int x = 1; sizeof(x = 2); x; })); ASSERT(0, g1); ASSERT(3, ({ g1 = 3; g1; })); ASSERT(0, ({ g2[0] = 0; g2[1] = 1; g2[2] = 2; g2[3] = 3; g2[0]; })); ASSERT(1, ({ g2[0] = 0; g2[1] = 1; g2[2] = 2; g2[3] = 3; g2[1]; })); ASSERT(2, ({ g2[0] = 0; g2[1] = 1; g2[2] = 2; g2[3] = 3; g2[2]; })); ASSERT(3, ({ g2[0] = 0; g2[1] = 1; g2[2] = 2; g2[3] = 3; g2[3]; })); ASSERT(4, sizeof(g1)); ASSERT(16, sizeof(g2)); ASSERT(1, ({ char x = 1; x; })); ASSERT(1, ({ char x = 1; char y = 2; x; })); ASSERT(2, ({ char x = 1; char y = 2; y; })); ASSERT(1, ({ char x; sizeof(x); })); ASSERT(10, ({ char x[10]; sizeof(x); })); ASSERT(2, ({ int x = 2; { int x = 3; } x; })); ASSERT(2, ({ int x = 2; { int x = 3; } int y = 4; x; })); ASSERT(3, ({ int x = 2; { x = 3; } x; })); ASSERT(7, ({ int x; int y; char z; char *a = &y; char *b = &z; b - a; })); ASSERT(1, ({ int x; char y; int z; char *a = &y; char *b = &z; b - a; })); ASSERT(8, ({ long x; sizeof(x); })); ASSERT(2, ({ short x; sizeof(x); })); ASSERT(24, ({ char *x[3]; sizeof(x); })); ASSERT(8, ({ char(*x)[3]; sizeof(x); })); ASSERT(1, ({ char(x); sizeof(x); })); ASSERT(3, ({ char(x)[3]; sizeof(x); })); ASSERT(12, ({ char(x[3])[4]; sizeof(x); })); ASSERT(4, ({ char(x[3])[4]; sizeof(x[0]); })); ASSERT(3, ({ char *x[3]; char y; x[0] = &y; y = 3; x[0][0]; })); ASSERT(4, ({ char x[3]; char(*y)[3] = x; y[0][0] = 4; y[0][0]; })); { void *x; } ASSERT(3, g3); return 0; }chibicc-1.0.23.1/test/variadic.c000066400000000000000000000003511505335450300162270ustar00rootroot00000000000000#include #include #include "test.h" void test(const char *fmt, ...) { va_list ap; va_start(ap, fmt); int x = va_arg(ap, int); printf("x = %d\n", x); ASSERT(42, x); } int main() { test("int", 42); } chibicc-1.0.23.1/test/variadic2.c000066400000000000000000000005301505335450300163100ustar00rootroot00000000000000#include #include #include "test.h" typedef struct { char c; } SmallStruct; void test(const char *fmt, ...) { va_list ap; va_start(ap, fmt); SmallStruct s = va_arg(ap, SmallStruct); printf("s.c = %d\n", s.c); ASSERT(42, s.c); } int main() { SmallStruct s = {42}; test("struct", s); ASSERT(42, s.c); } chibicc-1.0.23.1/test/variadic2b.c000066400000000000000000000005501505335450300164540ustar00rootroot00000000000000#include #include #include void test(const char *fmt, ...) { va_list ap; va_start(ap, fmt); // char is promoted to int in variadic arguments int c = va_arg(ap, int); printf("c = %d\n", c); assert(c == 42); va_end(ap); } int main() { char x = 42; test("char", x); printf("Test passed.\n"); return 0; } chibicc-1.0.23.1/test/variadic3.c000066400000000000000000000011261505335450300163130ustar00rootroot00000000000000#include #include #include "test.h" typedef struct { long double ld; } MyStruct; void print_variadic(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { MyStruct s = va_arg(ap, MyStruct); printf("MyStruct[%d].ld = %Lf\n", i, s.ld); if (i == 0) ASSERT(1, s.ld); else if (i == 1) ASSERT(9, s.ld); } va_end(ap); } int main(void) { MyStruct a = {1.234567890123456789L}; MyStruct b = {9.876543210987654321L}; print_variadic(2, a, b); return 0; } chibicc-1.0.23.1/test/variadic4.c000066400000000000000000000032001505335450300163070ustar00rootroot00000000000000#include #include #include #include "test.h" void test_variadic(int count, ...) { va_list ap; va_start(ap, count); char c = va_arg(ap, int); // promoted unsigned char uc = va_arg(ap, int); // promoted short s = va_arg(ap, int); // promoted unsigned short us = va_arg(ap, int); // promoted int i = va_arg(ap, int); unsigned int ui = va_arg(ap, unsigned int); long l = va_arg(ap, long); unsigned long ul = va_arg(ap, unsigned long); long long ll = va_arg(ap, long long); unsigned long long ull = va_arg(ap, unsigned long long); float f = (float)va_arg(ap, double); // promoted to double double d = va_arg(ap, double); printf("char: %d\n", c); printf("unsigned char: %u\n", uc); printf("short: %d\n", s); printf("unsigned short: %u\n", us); printf("int: %d\n", i); printf("unsigned int: %u\n", ui); printf("long: %ld\n", l); printf("unsigned long: %lu\n", ul); printf("long long: %lld\n", ll); printf("unsigned long long: %llu\n", ull); printf("float: %f\n", f); printf("double: %f\n", d); ASSERT(-1, c); ASSERT(255, uc); ASSERT(-12345, s); ASSERT(54321, us); ASSERT(-123456, i); ASSERT(123456u, ui); ASSERT(-123456789L, l); ASSERT(123456789UL, ul); ASSERT(-123456789012345LL, ll); ASSERT(123456789012345ULL, ull); ASSERT(1.25f, f); ASSERT(3.14159, d); va_end(ap); } int main() { test_variadic(12, (char)-1, (unsigned char)255, (short)-12345, (unsigned short)54321, -123456, 123456u, -123456789L, 123456789UL, -123456789012345LL, 123456789012345ULL, 1.25f, 3.14159 ); } chibicc-1.0.23.1/test/variadic5.c000066400000000000000000000006171505335450300163210ustar00rootroot00000000000000#include #include #include "test.h" typedef struct { char _Alignas(1024) pad; } BigAlign; void test(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) printf("arg[%d] = %p\n", i, va_arg(ap, void *)); va_end(ap); } int main() { BigAlign a, b; test(2, &a, &b); // If va_area isn't big enough or not aligned, crash likely } chibicc-1.0.23.1/test/variadic6.c000066400000000000000000000011531505335450300163160ustar00rootroot00000000000000#include #include #include "test.h" typedef struct S { char data[32]; } S; void print7(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { S s = va_arg(ap, S); printf("%d ", s.data[0]); ASSERT(i + 1, s.data[0]); } va_end(ap); printf("\n"); } int main() { S s1 = {.data = {1}}; S s2 = {.data = {2}}; S s3 = {.data = {3}}; S s4 = {.data = {4}}; S s5 = {.data = {5}}; S s6 = {.data = {6}}; S s7 = {.data = {7}}; print7(7, s1, s2, s3, s4, s5, s6, s7); return 0; } chibicc-1.0.23.1/test/variadic6b.c000066400000000000000000000025531505335450300164650ustar00rootroot00000000000000#include #include "test.h" typedef struct { int x; int y; } Point; int sum_point_array(int count, ...) { va_list ap; va_start(ap, count); Point *arr = va_arg(ap, Point *); va_end(ap); int sum = 0; for (int i = 0; i < count; i++) sum += arr[i].x + arr[i].y; return sum; } int sum_array(int count, ...) { va_list ap; va_start(ap, count); int *arr = va_arg(ap, int *); va_end(ap); int sum = 0; for (int i = 0; i < count; i++) sum += arr[i]; return sum; } int sum_float_array(int count, ...) { va_list ap; va_start(ap, count); float *arr = va_arg(ap, float *); va_end(ap); float sum = 0; for (int i = 0; i < count; i++) sum += arr[i]; return (int)sum; } int mix_array_scalar(int count, ...) { va_list ap; va_start(ap, count); int *arr = va_arg(ap, int *); int extra = va_arg(ap, int); va_end(ap); int sum = extra; for (int i = 0; i < count; i++) sum += arr[i]; return sum; } int main() { ASSERT(10, ({ int a[] = {1,2,3,4}; sum_array(4, a); })); ASSERT(6, ({ float a[] = {1.5, 2.5, 2.0}; sum_float_array(3, a); })); ASSERT(20, ({ int a[] = {3,4,5,6}; mix_array_scalar(4, a, 2); // 2 + 3+4+5+6 = 20 })); ASSERT(21, ({ Point pts[] = {{1,2},{3,4},{5,6}}; sum_point_array(3, pts); })); return 0; } chibicc-1.0.23.1/test/variadic6c.c000066400000000000000000000012151505335450300164600ustar00rootroot00000000000000#include #include #include "test.h" typedef struct S { char data[32] __attribute__((aligned(32))); } S; void print7(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { S s = va_arg(ap, S); printf("%d ", s.data[0]); ASSERT(i + 1, s.data[0]); } va_end(ap); printf("\n"); } int main() { S s1 = {.data = {1}}; S s2 = {.data = {2}}; S s3 = {.data = {3}}; S s4 = {.data = {4}}; S s5 = {.data = {5}}; S s6 = {.data = {6}}; S s7 = {.data = {7}}; print7(7, s1, s2, s3, s4, s5, s6, s7); return 0; } chibicc-1.0.23.1/test/variadic6d.c000066400000000000000000000012201505335450300164550ustar00rootroot00000000000000#include #include #include "test.h" typedef struct S { _Alignas(32) char data[32]; } S; void print7(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { S s = va_arg(ap, S); printf("%d ", s.data[0]); ASSERT(i + 1, s.data[0]); } va_end(ap); printf("\n"); } int main() { S s1 = {.data = {1}}; S s2 = {.data = {2}}; S s3 = {.data = {3}}; S s4 = {.data = {4}}; S s5 = {.data = {5}}; S s6 = {.data = {6}}; S s7 = {.data = {7}}; S s8 = {.data = {8}}; print7(8, s1, s2, s3, s4, s5, s6, s7, s8); return 0; } chibicc-1.0.23.1/test/variadic6e.c000066400000000000000000000022501505335450300164620ustar00rootroot00000000000000#include #include #include "test.h" typedef struct S { _Alignas(32) char data[32]; } S; void print7(int count, ...) { va_list ap; va_start(ap, count); int a = va_arg(ap, int); printf("a=%d\n", a); ASSERT(17, a); int b = va_arg(ap, int); printf("b=%d\n", b); ASSERT(23, b); int c = va_arg(ap, int); printf("c=%d\n", b); ASSERT(19, c); double f = va_arg(ap, double); printf("f=%lf\n", f); ASSERT(10, f); long double ld = va_arg(ap, long double); printf("ld=%Ld\n", ld); ASSERT(25, ld); for (int i = 0; i < count - 5 ; i++) { S s = va_arg(ap, S); printf("%d ", s.data[0]); ASSERT(i + 1, s.data[0]); } va_end(ap); printf("\n"); } int main() { S s1 = {.data = {1}}; S s2 = {.data = {2}}; S s3 = {.data = {3}}; S s4 = {.data = {4}}; S s5 = {.data = {5}}; S s6 = {.data = {6}}; S s7 = {.data = {7}}; S s8 = {.data = {8}}; int a = 17; int b = 23; int c = 19; float f = 10.50; long double ld = 25.50L; print7(13, a, b, c, f, ld, s1, s2, s3, s4, s5, s6, s7, s8); return 0; } chibicc-1.0.23.1/test/variadic6f.c000066400000000000000000000012151505335450300164630ustar00rootroot00000000000000#include #include #include "test.h" typedef struct S { __attribute__((aligned(32))) char data[32] ; } S; void print7(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { S s = va_arg(ap, S); printf("%d ", s.data[0]); ASSERT(i + 1, s.data[0]); } va_end(ap); printf("\n"); } int main() { S s1 = {.data = {1}}; S s2 = {.data = {2}}; S s3 = {.data = {3}}; S s4 = {.data = {4}}; S s5 = {.data = {5}}; S s6 = {.data = {6}}; S s7 = {.data = {7}}; print7(7, s1, s2, s3, s4, s5, s6, s7); return 0; } chibicc-1.0.23.1/test/variadic_struct.c000066400000000000000000000026401505335450300176360ustar00rootroot00000000000000#include #include "test.h" typedef struct { int x; int y; } Point; typedef struct { int i; double d; } Mixed; typedef union { int i; float f; } IntOrFloat; typedef struct { long a; long b; } Pair; typedef struct { int a, b, c, d, e; } BigStruct; int test_big_struct(int count, ...) { va_list ap; va_start(ap, count); BigStruct bs = va_arg(ap, BigStruct); va_end(ap); return bs.a + bs.b + bs.c + bs.d + bs.e; } long test_multi(int count, ...) { va_list ap; va_start(ap, count); int x = va_arg(ap, int); Pair p = va_arg(ap, Pair); double d = va_arg(ap, double); va_end(ap); return x + p.a + p.b + (long)d; } int test_union_int(int count, ...) { va_list ap; va_start(ap, count); IntOrFloat u = va_arg(ap, IntOrFloat); va_end(ap); return u.i; } int test_mixed_struct(int count, ...) { va_list ap; va_start(ap, count); Mixed m = va_arg(ap, Mixed); va_end(ap); return m.i + (int)m.d; } int test_struct_sum(int count, ...) { va_list ap; va_start(ap, count); Point p = va_arg(ap, Point); va_end(ap); return p.x + p.y; } int main() { ASSERT(30, test_struct_sum(1, (Point){10, 20})); ASSERT(15, test_mixed_struct(1, (Mixed){5, 10.5})); ASSERT(42, test_union_int(1, (IntOrFloat){42})); ASSERT(1 + 2 + 3 + 4, test_multi(3, 1, (Pair){2,3}, 4.0)); ASSERT(15, test_big_struct(1, (BigStruct){1,2,3,4,5})); return 0; } chibicc-1.0.23.1/test/variadic_struct2.c000066400000000000000000000110521505335450300177150ustar00rootroot00000000000000#include #include #include "test.h" typedef struct { int a; // 4 bytes } SmallStruct; typedef struct { int a; // 4 bytes double b; // 8 bytes } MediumStruct; typedef struct { double a; // 8 bytes double b; // 8 bytes double c; // 8 bytes } LargeStruct; void print_large(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { LargeStruct s = va_arg(ap, LargeStruct); printf("LargeStruct %d: a = %f, b = %f, c = %f\n", i, s.a, s.b, s.c); if (i == 0) { ASSERT(1, s.a); ASSERT(1, s.b); ASSERT(1, s.c); } } va_end(ap); } void print_medium(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { MediumStruct s = va_arg(ap, MediumStruct); printf("MediumStruct %d: a = %d, b = %f\n", i, s.a, s.b); if (i == 0) { ASSERT(1, s.a); ASSERT(1, s.b); } } va_end(ap); } void print_small(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { SmallStruct s = va_arg(ap, SmallStruct); printf("SmallStruct %d: a = %d\n", i, s.a); if (i == 0) { ASSERT(1, s.a); } } va_end(ap); } void print_small_ptr(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { SmallStruct *s = va_arg(ap, SmallStruct *); printf("SmallStruct %d: a = %d\n", i, s->a); if (i == 0) { ASSERT(1, s->a); } } va_end(ap); } void print_medium_ptr(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { MediumStruct *s = va_arg(ap, MediumStruct *); printf("MediumStruct %d: a = %d, b = %f\n", i, s->a, s->b); if (i == 0) { ASSERT(1, s->a); ASSERT(1, s->b); } } va_end(ap); } void print_large_ptr(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { LargeStruct *s = va_arg(ap, LargeStruct *); printf("LargeStruct %d: a = %f, b = %f, c = %f\n", i, s->a, s->b, s->c); if (i == 0) { ASSERT(1, s->a); ASSERT(1, s->b); ASSERT(1, s->c); } else if (i == 1) { ASSERT(2, s->a); ASSERT(2, s->b); ASSERT(2, s->c); } else if (i == 2) { ASSERT(3, s->a); ASSERT(3, s->b); ASSERT(3, s->c); } } va_end(ap); } void test_mixed1(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { int x = va_arg(ap, int); double y = va_arg(ap, double); SmallStruct s = va_arg(ap, SmallStruct); if (i == 0) { ASSERT(1, x); ASSERT(1, y); ASSERT(1, s.a); } printf("int: %d, double: %f, SmallStruct.a: %d\n", x, y, s.a); } va_end(ap); } void test_mixed2(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { char *str = va_arg(ap, char *); MediumStruct s = va_arg(ap, MediumStruct); MediumStruct *ps = va_arg(ap, MediumStruct *); printf("str: %s, MediumStruct.a: %d, b: %f, Pointer MediumStruct.a: %d, b: %f\n", str, s.a, s.b, ps->a, ps->b); if (i == 0) { ASSERT(2, ps->a); ASSERT(2, ps->b); ASSERT(1, s.a); ASSERT(1, s.b); } } va_end(ap); } void test_mixed3(int n, ...) { va_list ap; va_start(ap, n); for (int i = 0; i < n; i++) { int x = va_arg(ap, int); LargeStruct *p = va_arg(ap, LargeStruct *); double y = va_arg(ap, double); printf("int: %d, LargeStruct.a: %f, b: %f, c: %f, double: %f\n", x, p->a, p->b, p->c, y); } va_end(ap); } int main() { SmallStruct s1 = {1}, s2 = {2}, s3 = {3}; print_small(3, s1, s2, s3); print_small_ptr(3, &s1, &s2, &s3); test_mixed1(2, 1, 1.1, s1, 2, 2.2, s2); MediumStruct s1 = {1, 1.1}, s2 = {2, 2.2}, s3 = {3, 3.3}; print_medium(3, s1, s2, s3); print_medium_ptr(3, &s1, &s2, &s3); test_mixed2(1, "hello", s1, &s2); LargeStruct s1 = {1.1, 1.2, 1.3}; LargeStruct s2 = {2.1, 2.2, 2.3}; LargeStruct s3 = {3.1, 3.2, 3.3}; print_large(3, s1, s2, s3); print_large_ptr(3, &s1, &s2, &s3); LargeStruct ls = {1.1, 2.2, 3.3}; test_mixed3(1, 42, &ls, 4.4); return 0; } chibicc-1.0.23.1/test/varscope.c000077500000000000000000000003651505335450300162770ustar00rootroot00000000000000#include "test.h" void Increment(int a) { a = a + 1; printf("Address of a inside the function %d\n", &a ); } int main(int argc, char **argv) { int a = 10; Increment(a); printf("Address of a inside the function %d\n", &a ); return 0; }chibicc-1.0.23.1/test/vector1.c000066400000000000000000000016731505335450300160400ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 a = {1.0, 2.0, 3.0, 4.0}; float4 b = {10.0, 20.0, 30.0, 40.0}; float4 c; typedef int myint; int main() { float4 vec = {1.0, 2.0, 3.0, 4.0}; printf("vec[0]=%f\n", vec[0]); printf("vec[1]=%f\n", vec[1]); printf("vec[2]=%f\n", vec[2]); printf("vec[3]=%f\n", vec[3]); ASSERT(1, vec[0]); ASSERT(2, vec[1]); ASSERT(3, vec[2]); ASSERT(4, vec[3]); c = a + b; printf("after %f %f %f %f\n", c[0], c[1], c[2], c[3]); ASSERT(11, c[0]); ASSERT(22, c[1]); ASSERT(33, c[2]); ASSERT(44, c[3]); myint x = 42; printf("x = %d\n", x); ASSERT(42, x); int a[4] = {1, 2, 3, 4}; int b[4] = {10, 20, 30, 40}; int c[4]; for (int i = 0; i < 4; i++) c[i] = a[i] + b[i]; for (int i = 0; i < 4; i++) printf("c[%d] = %d\n", i, c[i]); return 0; }chibicc-1.0.23.1/test/vector2.c000066400000000000000000000011451505335450300160330ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); int main() { float4 a = {1.0f, 2.0f, 3.0f, 4.0f}; float4 b = {10.0f, 20.0f, 30.0f, 40.0f}; float4 c; c = a + b; for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, c[i]); } ASSERT(11, c[0]); ASSERT(22, c[1]); ASSERT(33, c[2]); ASSERT(44, c[3]); // test 1: expression float4 a, b, c; a = (float4){1, 2, 3, 4}; b = (float4){10, 20, 30, 40}; c = a + b; // test 2: brace init float4 d = {100, 200, 300, 400}; return 0; } chibicc-1.0.23.1/test/vector_basic.c000066400000000000000000000027041505335450300171140ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 make_vec() { return (float4){1.0f, 2.0f, 3.0f, 4.0f}; // compound literal for vector } float make_float() { return (float){1.0f}; // compound literal for vector } int main() { float4 v = make_vec(); float4 z; float4 a = {1.0f, 11.0f, 111.0f, 1111.0f }; float4 b = {2.0f, 22.0f, 222.0f, 2222.0f}; float4 d = {1.1f, 2.2f, 3.3f, 4.4f}; float f= 12.0f; float g = 7.0f; float h = make_float(); float i; i = f + g + h; float4 c; c = a + b + d ; float4 j = a + b + d; z = make_vec(); printf("v=%f %f %f %f\n", v[0], v[1], v[2], v[3]); ASSERT(1, v[0]); ASSERT(2, v[1]); ASSERT(3, v[2]); ASSERT(4, v[3]); printf("c= %f %f %f %f\n", c[0], c[1], c[2], c[3]); ASSERT(4, c[0]); ASSERT(35, c[1]); ASSERT(336, c[2]); ASSERT(3337, c[3]); printf("i=%f\n", i); ASSERT(20, i); printf("z=%f %f %f %f\n", z[0], z[1], z[2], z[3]); ASSERT(1, z[0]); ASSERT(2, z[1]); ASSERT(3, z[2]); ASSERT(4, z[3]); printf("a=%f %f %f %f\n", a[0], a[1], a[2], a[3]); ASSERT(1, a[0]); ASSERT(11, a[1]); ASSERT(111, a[2]); ASSERT(1111, a[3]); printf("j=%f %f %f %f\n", j[0], j[1], j[2], j[3]); ASSERT(4, j[0]); ASSERT(35, j[1]); ASSERT(336, j[2]); ASSERT(3337, j[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_bitwise.c000066400000000000000000000026351505335450300175040ustar00rootroot00000000000000#include "test.h" #include typedef int int4 __attribute__((vector_size(16))); // 4×32-bit integers int main(void) { int4 a = {0x0f0f0f0f, 0x00ff00ff, 0x12345678, 0xffffffff}; int4 b = {0x00ff00ff, 0x0f0f0f0f, 0x87654321, 0x00000000}; // Bitwise AND int4 and_res = a & b; printf("AND: 0x%x 0x%x 0x%x 0x%x\n", and_res[0], and_res[1], and_res[2], and_res[3]); ASSERT(0xf000f, and_res[0]); ASSERT(0xf000f, and_res[1]); ASSERT(0x2244220, and_res[2]); ASSERT(0x0, and_res[3]); // Bitwise OR int4 or_res = a | b; printf("OR: 0x%x 0x%x 0x%x 0x%x\n", or_res[0], or_res[1], or_res[2], or_res[3]); ASSERT(0xfff0fff, or_res[0]); ASSERT(0xfff0fff, or_res[1]); ASSERT(0x97755779, or_res[2]); ASSERT(0xffffffff, or_res[3]); // Bitwise XOR int4 xor_res = a ^ b; printf("XOR: 0x%x 0x%x 0x%x 0x%x\n", xor_res[0], xor_res[1], xor_res[2], xor_res[3]); ASSERT(0xff00ff0, xor_res[0]); ASSERT(0xff00ff0, xor_res[1]); ASSERT( 0x95511559, xor_res[2]); ASSERT(0xffffffff, xor_res[3]); // Bitwise NOT int4 not_a = ~a; printf("NOT a: 0x%x 0x%x 0x%x 0x%x\n", not_a[0], not_a[1], not_a[2], not_a[3]); ASSERT(0xf0f0f0f0, not_a[0]); ASSERT(0xff00ff00, not_a[1]); ASSERT(0xedcba987, not_a[2]); ASSERT(0x00000000, not_a[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_complit.c000066400000000000000000000116361505335450300175060ustar00rootroot00000000000000// test_vectors_compound.c #include "test.h" typedef float float4 __attribute__((vector_size(16))); typedef double double2 __attribute__((vector_size(16))); typedef int int4 __attribute__((vector_size(16))); int main(void) { // ---- FLOAT ---- float4 a = {1.0, 2.0, 3.0, 4.0}; float4 b = (float4){5.0, 6.0, 7.0, 8.0}; float4 r1 = a + (float4){10.0, 10.0, 10.0, 10.0}; float4 r2 = (float4){1.0, 1.0, 1.0, 1.0} + b; float4 r3 = a - (float4){1.0, 1.0, 1.0, 1.0}; float4 r4 = (float4){2.0, 2.0, 2.0, 2.0} * b; float4 r5 = b / (float4){2.0, 2.0, 2.0, 2.0}; float4 r6 = -(float4){1.0, 2.0, 3.0, 4.0}; float4 r7 = -b; printf("float4 results:\n"); for (int i = 0; i < 4; i++) printf("r1[%d]=%f ", i, r1[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("r2[%d]=%f ", i, r2[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("r3[%d]=%f ", i, r3[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("r4[%d]=%f ", i, r4[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("r5[%d]=%f ", i, r5[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("r6[%d]=%f ", i, r6[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("r7[%d]=%f ", i, r7[i]); printf("\n"); ASSERT(11, r1[0]); ASSERT(12, r1[1]); ASSERT(13, r1[2]); ASSERT(14, r1[3]); ASSERT(6, r2[0]); ASSERT(7, r2[1]); ASSERT(8, r2[2]); ASSERT(9, r2[3]); ASSERT(0, r3[0]); ASSERT(1, r3[1]); ASSERT(2, r3[2]); ASSERT(3, r3[3]); ASSERT(10, r4[0]); ASSERT(12, r4[1]); ASSERT(14, r4[2]); ASSERT(16, r4[3]); ASSERT(2, r5[0]); ASSERT(3, r5[1]); ASSERT(3, r5[2]); ASSERT(4, r5[3]); ASSERT(-1, r6[0]); ASSERT(-2, r6[1]); ASSERT(-3, r6[2]); ASSERT(-4, r6[3]); ASSERT(-5, r7[0]); ASSERT(-6, r7[1]); ASSERT(-7, r7[2]); ASSERT(-8, r7[3]); // ---- DOUBLE ---- double2 d1 = {1.0, 2.0}; double2 d2 = (double2){3.0, 4.0}; double2 dr1 = d1 + (double2){10.0, 20.0}; double2 dr2 = (double2){2.0, 2.0} * d2; double2 dr3 = -(double2){5.0, 6.0}; printf("\ndouble2 results:\n"); for (int i = 0; i < 2; i++) printf("dr1[%d]=%lf ", i, dr1[i]); printf("\n"); for (int i = 0; i < 2; i++) printf("dr2[%d]=%lf ", i, dr2[i]); printf("\n"); for (int i = 0; i < 2; i++) printf("dr3[%d]=%lf ", i, dr3[i]); printf("\n"); ASSERT(11, dr1[0]); ASSERT(22, dr1[1]); ASSERT(6, dr2[0]); ASSERT(8, dr2[1]); ASSERT(-5, dr3[0]); ASSERT(-6, dr3[1]); // ---- INT ---- int4 i1 = {1, 2, 3, 4}; int4 i2 = (int4){5, 6, 7, 8}; int4 ir1 = i1 + (int4){10, 10, 10, 10}; int4 ir2 = (int4){1, 1, 1, 1} + i2; int4 ir3 = i2 - (int4){1, 2, 3, 4}; int4 ir4 = i1 * (int4){2, 2, 2, 2}; int4 ir5 = -(int4){1, 2, 3, 4}; int4 ir6 = i1 ^ (int4){1, 0, 1, 0}; int4 ir7 = i2 & (int4){0xffffffff, 0, 0xffffffff, 0}; int4 ir8 = i1 | (int4){0, 0, 0, 0xffffffff}; printf("\nint4 results:\n"); for (int i = 0; i < 4; i++) printf("ir1[%d]=%d ", i, ir1[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir2[%d]=%d ", i, ir2[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir3[%d]=%d ", i, ir3[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir4[%d]=%d ", i, ir4[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir5[%d]=%d ", i, ir5[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir6[%d]=%d ", i, ir6[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir7[%d]=%d ", i, ir7[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir8[%d]=%d ", i, ir8[i]); printf("\n"); ASSERT(11, ir1[0]); ASSERT(12, ir1[1]); ASSERT(13, ir1[2]); ASSERT(14, ir1[3]); ASSERT(6, ir2[0]); ASSERT(7, ir2[1]); ASSERT(8, ir2[2]); ASSERT(9, ir2[3]); ASSERT(4, ir3[0]); ASSERT(4, ir3[1]); ASSERT(4, ir3[2]); ASSERT(4, ir3[3]); ASSERT(2, ir4[0]); ASSERT(4, ir4[1]); ASSERT(6, ir4[2]); ASSERT(8, ir4[3]); ASSERT(-1, ir5[0]); ASSERT(-2, ir5[1]); ASSERT(-3, ir5[2]); ASSERT(-4, ir5[3]); ASSERT(0, ir6[0]); ASSERT(2, ir6[1]); ASSERT(2, ir6[2]); ASSERT(4, ir6[3]); ASSERT(5, ir7[0]); ASSERT(0, ir7[1]); ASSERT(7, ir7[2]); ASSERT(0, ir7[3]); ASSERT(1, ir8[0]); ASSERT(2, ir8[1]); ASSERT(3, ir8[2]); ASSERT(-1, ir8[3]); // ---- INT (extra tests) ---- int4 ir9 = ~(int4){0, -1, 0xffffffff, 1234}; // bitnot int4 ir10 = (int4){1, 2, 3, 4} + (int4){10, 20, 30, 40}; // compound + compound printf("\nint4 extra results:\n"); for (int i = 0; i < 4; i++) printf("ir9[%d]=%d ", i, ir9[i]); printf("\n"); for (int i = 0; i < 4; i++) printf("ir10[%d]=%d ", i, ir10[i]); printf("\n"); ASSERT(-1, ir9[0]); // ~0 ASSERT(0, ir9[1]); // ~(-1) == 0 ASSERT(0, ir9[2]); // ~0xffffffff == 0 ASSERT(-1235, ir9[3]); // ~(1234) == -1235 ASSERT(11, ir10[0]); ASSERT(22, ir10[1]); ASSERT(33, ir10[2]); ASSERT(44, ir10[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_div.c000066400000000000000000000013571505335450300166200ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 div_vectors(float4 a, float4 b) { return a / b; } int main() { float4 a = {10.0f, 20.0f, 30.0f, 40.0f}; float4 b = {2.0f, 4.0f, 5.0f, 8.0f}; float4 c; c = div_vectors(a, b); float4 d = {5.0f, 5.0f, 5.0f, 5.0f}; float4 e = div_vectors(a, d); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, c[i]); } ASSERT(5, (int)c[0]); ASSERT(5, (int)c[1]); ASSERT(6, (int)c[2]); ASSERT(5, (int)c[3]); for (int i = 0; i < 4; i++) { printf("e[%d] = %f\n", i, e[i]); } ASSERT(2, e[0]); ASSERT(4, e[1]); ASSERT(6, e[2]); ASSERT(8, e[3]); return 0; } chibicc-1.0.23.1/test/vector_double.c000066400000000000000000000007631505335450300173100ustar00rootroot00000000000000#include "test.h" typedef double double2 __attribute__((vector_size(16))); double2 add_double2(double2 a, double2 b) { return a + b; } int main() { double2 a = {1.1, 2.2}; double2 b = {3.3, 4.4}; double2 c ; c = add_double2(a, b); double2 d = add_double2(a, c); printf("c = %f %f\n", c[0], c[1]); ASSERT(4, (int)c[0]); ASSERT(6, (int)c[1]); printf("d = %f %f\n", d[0], d[1]); ASSERT(5, d[0]); ASSERT(8, d[1]); return 0; } chibicc-1.0.23.1/test/vector_filled.c000066400000000000000000000027531505335450300172760ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 add_some(float4 a, float4 b, float4 c, float4 d, float4 e) { return a + b + c + d + e ; } float4 add_all2(float4 a, float4 b, float4 c, float4 d, float4 e, float4 f, float4 g, float4 h) { return a + b + c + d + e + f + g + h; //return a + b + c; } int main() { float4 a = {1, 2, 3, 4}; float4 b = {10, 20, 30, 40}; float4 c = {5, 6, 7, 8}; float4 d = {9, 10, 11, 12}; float4 e = {13, 14, 14, 16}; float4 v = add_some(a, b, c, d, e); float4 g = a + b + c + d + e; printf("v = %f %f %f %f\n", v[0], v[1], v[2], v[3]); printf("g = %f %f %f %f\n", g[0], g[1], g[2], g[3]); v = add_some( (float4){1,2,3,4}, (float4){10,20,30,40}, (float4){5,6,7,8}, (float4){9,10,11,12}, (float4){13,14,15,16} ); printf("v = %f %f %f %f\n", v[0], v[1], v[2], v[3]); ASSERT(38, (int)v[0]); ASSERT(52, (int)v[1]); ASSERT(66, (int)v[2]); ASSERT(80, (int)v[3]); v = add_all2( (float4){1,2,3,4}, (float4){10,20,30,40}, (float4){5,6,7,8}, (float4){9,10,11,12}, (float4){13,14,15,16}, (float4){17,18,19,20}, (float4){21,22,23,24}, (float4){25,26,27,28} ); printf("v = %f %f %f %f\n", v[0], v[1], v[2], v[3]); ASSERT(101, (int)v[0]); ASSERT(118, (int)v[1]); ASSERT(135, (int)v[2]); ASSERT(152, (int)v[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_init.c000066400000000000000000000010101505335450300167630ustar00rootroot00000000000000#include "test.h" #define SCALAR 500 typedef int int4 __attribute__((vector_size(16))); int main() { // This will trigger Chibicc error: int4 v = SCALAR; // vector initializer must be an initializer list // Workaround: use braces int4 v2 = {SCALAR}; // Print v2 to verify for (int i = 0; i < 4; i++) { printf("%d ", v2[i]); } printf("\n"); ASSERT(500, v2[0]); ASSERT(0, v2[1]); ASSERT(0, v2[2]); ASSERT(0, v2[3]); return 0; } chibicc-1.0.23.1/test/vector_int.c000066400000000000000000000011201505335450300166140ustar00rootroot00000000000000#include "test.h" typedef int int4 __attribute__((vector_size(16))); int4 add_int4(int4 a, int4 b) { return a + b; } int main() { int4 a = {1, 2, 3, 4}; int4 b = {10, 20, 30, 40}; int4 c; c = add_int4(a, b); int4 d = add_int4(a, c); printf("c = %d %d %d %d\n", c[0], c[1], c[2], c[3]); ASSERT(11, c[0]); ASSERT(22, c[1]); ASSERT(33, c[2]); ASSERT(44, c[3]); printf("d = %d %d %d %d\n", d[0], d[1], d[2], d[3]); ASSERT(12, d[0]); ASSERT(24, d[1]); ASSERT(36, d[2]); ASSERT(48, d[3]); return 0; } chibicc-1.0.23.1/test/vector_long.c000066400000000000000000000004301505335450300167640ustar00rootroot00000000000000#include "test.h" typedef long long4 __attribute__((vector_size(16))); int main() { long4 lv = {1, 2}; long4 res; res = lv + 1; // scalar promotion printf("%ld %ld\n", res[0], res[1]); ASSERT(2, res[0]); ASSERT(3, res[1]); return 0; } chibicc-1.0.23.1/test/vector_m128.c000066400000000000000000000005271505335450300165230ustar00rootroot00000000000000#include #include "test.h" int main() { __m128 a = _mm_set_ps(4, 3, 2, 1); __m128 b = _mm_add_ps(a, a); float *f = (float *)&b; printf("%f %f %f %f\n", f[0], f[1], f[2], f[3]); ASSERT(2, f[0]); ASSERT(4, f[1]); ASSERT(6, f[2]); ASSERT(8, f[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_mixed.c000066400000000000000000000007061505335450300171410ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 mix_params(float a, float4 v, float b) { return (float4){a, b, a, b} + v; } int main() { float4 res = mix_params(1.0f, (float4){2,4,6,8}, 3.0f); for (int i = 0; i < 4; i++) printf("res[%d] = %f\n", i, res[i]); ASSERT(3, (int)res[0]); ASSERT(7, (int)res[1]); ASSERT(7, (int)res[2]); ASSERT(11, (int)res[3]); } chibicc-1.0.23.1/test/vector_mixed2.c000066400000000000000000000027161505335450300172260ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 mix_params(float a, float4 v, float b) { return v + (float4){a, b, a, b}; } float4 sub_mix_params(float a, float4 v, float b) { return (float4){a, b, a, b} - v; } float4 sub_mix_params2(float a, float4 v, float b) { return v - (float4){a, b, a, b} ; } int main() { float4 res = mix_params(1.0f, (float4){2,4,6,8}, 3.0f); for (int i = 0; i < 4; i++) printf("res[%d] = %f\n", i, res[i]); ASSERT(3, (int)res[0]); ASSERT(7, (int)res[1]); ASSERT(7, (int)res[2]); ASSERT(11, (int)res[3]); res = sub_mix_params(1.0f, (float4){2,4,6,8}, 3.0f); for (int i = 0; i < 4; i++) printf("res[%d] = %f\n", i, res[i]); ASSERT(-1, (int)res[0]); ASSERT(-1, (int)res[1]); ASSERT(-5, (int)res[2]); ASSERT(-5, (int)res[3]); res = sub_mix_params2(1.0f, (float4){2,4,6,8}, 3.0f); for (int i = 0; i < 4; i++) printf("res[%d] = %f\n", i, res[i]); ASSERT(1, (int)res[0]); ASSERT(1, (int)res[1]); ASSERT(5, (int)res[2]); ASSERT(5, (int)res[3]); float4 x = {1.0, -2.0, 3.0, -4.0}; float4 r = -x; // negate the vector printf("%f %f %f %f\n", r[0], r[1], r[2], r[3]); ASSERT(-1, (int)r[0]); ASSERT(2, (int)r[1]); ASSERT(-3, (int)r[2]); ASSERT(4, (int)r[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_mult.c000066400000000000000000000013201505335450300170050ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 mul_vectors(float4 a, float4 b) { return a * b; } int main() { float4 a = {1.0f, 2.0f, 3.0f, 4.0f}; float4 b = {10.0f, 20.0f, 30.0f, 40.0f}; float4 c; c = mul_vectors(a, b); float4 d = mul_vectors(a, c); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, c[i]); } ASSERT(10, (int)c[0]); ASSERT(40, (int)c[1]); ASSERT(90, (int)c[2]); ASSERT(160, (int)c[3]); for (int i = 0; i < 4; i++) { printf("d[%d] = %f\n", i, d[i]); } ASSERT(10, d[0]); ASSERT(80, d[1]); ASSERT(270, d[2]); ASSERT(640, d[3]); return 0; } chibicc-1.0.23.1/test/vector_mult2.c000066400000000000000000000012471505335450300170770ustar00rootroot00000000000000#include "test.h" typedef int int4 __attribute__((vector_size(16))); int4 mul_int_vectors(int4 a, int4 b) { return a * b; } int main() { int4 a = {1, 2, 3, 4}; int4 b = {10, 20, 30, 40}; int4 c ; c = mul_int_vectors(a, b); int4 d = mul_int_vectors(a, c); for (int i = 0; i < 4; i++) { printf("c[%d] = %d\n", i, c[i]); } ASSERT(10, c[0]); ASSERT(40, c[1]); ASSERT(90, c[2]); ASSERT(160, c[3]); for (int i = 0; i < 4; i++) { printf("d[%d] = %d\n", i, d[i]); } ASSERT(10, d[0]); ASSERT(80, d[1]); ASSERT(270, d[2]); ASSERT(640, d[3]); return 0; } chibicc-1.0.23.1/test/vector_param.c000066400000000000000000000016511505335450300171330ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); void print_vector(float4 v) { for (int i = 0; i < 4; i++) { printf("v[%d] = %f\n", i, v[i]); } ASSERT(11, v[0]); ASSERT(22, v[1]); ASSERT(33, v[2]); ASSERT(44, v[3]); } float4 add_vectors(float4 a, float4 b) { return a + b; } int main() { float4 a = {1.0f, 2.0f, 3.0f, 4.0f}; float4 b = {10.0f, 20.0f, 30.0f, 40.0f}; float4 c; c = add_vectors(a, b); for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, c[i]); } ASSERT(11, c[0]); ASSERT(22, c[1]); ASSERT(33, c[2]); ASSERT(44, c[3]); print_vector(c); float4 d = add_vectors(a, c); for (int i = 0; i < 4; i++) { printf("d[%d] = %f\n", i, d[i]); } ASSERT(12, d[0]); ASSERT(24, d[1]); ASSERT(36, d[2]); ASSERT(48, d[3]); return 0; } chibicc-1.0.23.1/test/vector_pointer.c000066400000000000000000000007531505335450300175150ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); void add_vectors_ptr(const float4 *a, const float4 *b, float4 *res) { *res = *a + *b; } int main() { float4 a = {1, 2, 3, 4}; float4 b = {10, 20, 30, 40}; float4 c; add_vectors_ptr(&a, &b, &c); printf("c = %f %f %f %f\n", c[0], c[1], c[2], c[3]); ASSERT(11, (int)c[0]); ASSERT(22, (int)c[1]); ASSERT(33, (int)c[2]); ASSERT(44, (int)c[3]); return 0; } chibicc-1.0.23.1/test/vector_promotion.c000066400000000000000000000034551505335450300200650ustar00rootroot00000000000000#include "test.h" #include typedef int int4 __attribute__((vector_size(16))); // 4×int typedef float float4 __attribute__((vector_size(16))); // 4×float typedef double double2 __attribute__((vector_size(16))); // 2×double int main(void) { // int vector + scalar int4 vi = {1, 2, 3, 4}; int4 res_i = vi + 5; // scalar 5 promoted to {5,5,5,5} for (int i =0; i < 4 ; i++) printf("res[%d]=%d ", i, res_i[i]); printf("\n"); ASSERT(6, res_i[0]); ASSERT(7, res_i[1]); ASSERT(8, res_i[2]); ASSERT(9, res_i[3]); // chained: scalar + vector int4 res_i2 = 10 + vi; // scalar promoted to {10,10,10,10} ASSERT(11, res_i2[0]); ASSERT(12, res_i2[1]); ASSERT(13, res_i2[2]); ASSERT(14, res_i2[3]); for (int i =0; i < 4 ; i++) printf("res[%d]=%d ", i, res_i2[i]); printf("\n"); // float vector + scalar float4 vf = {1.0f, 2.0f, 3.0f, 4.0f}; float4 res_f = vf + 1.5f; // scalar promoted to {1.5,1.5,1.5,1.5} for (int i =0; i < 4 ; i++) printf("res[%d]=%f ", i, res_f[i]); printf("\n"); ASSERT(2.5f, res_f[0]); ASSERT(3.5f, res_f[1]); ASSERT(4.5f, res_f[2]); ASSERT(5.5f, res_f[3]); res_f = 1.5f + vf; ASSERT(2.5f, res_f[0]); ASSERT(3.5f, res_f[1]); ASSERT(4.5f, res_f[2]); ASSERT(5.5f, res_f[3]); // double vector + scalar double2 vd = {1.0, 2.0}; double2 res_d = vd + 3.0; // scalar promoted to {3.0,3.0} ASSERT(4.0, res_d[0]); ASSERT(5.0, res_d[1]); for (int i =0; i < 2 ; i++) printf("res[%d]=%f ", i, res_d[i]); printf("\n"); res_d = 3.0 + vd; ASSERT(4.0, res_d[0]); ASSERT(5.0, res_d[1]); printf("Scalar to vector promotion OK\n"); return 0; } chibicc-1.0.23.1/test/vector_scalar.c000066400000000000000000000107561505335450300173060ustar00rootroot00000000000000#include "test.h" #include typedef float float4 __attribute__((vector_size(16))); typedef double double2 __attribute__((vector_size(16))); typedef int int4 __attribute__((vector_size(16))); void print_float4(float4 v) { for (int i = 0; i < 4; i++) printf("%f ", v[i]); printf("\n"); } void print_double2(double2 v) { for (int i = 0; i < 2; i++) printf("%f ", v[i]); printf("\n"); } void print_int4(int4 v) { for (int i = 0; i < 4; i++) printf("%d ", v[i]); printf("\n"); } int main() { float4 fv = {1,2,3,4}; float4 fr; double2 dv = {1.5, 2.5}; double2 dr; int4 iv = {10,20,30,40}; int4 ir; // Float4 operations with scalar fr = fv + 2.0f; // scalar rhs print_float4(fr); ASSERT(3, fr[0]); ASSERT(4, fr[1]); ASSERT(5, fr[2]); ASSERT(6, fr[3]); fr = 3.0f + fv; // scalar lhs print_float4(fr); ASSERT(4, fr[0]); ASSERT(5, fr[1]); ASSERT(6, fr[2]); ASSERT(7, fr[3]); fr = fv - 1.0f; print_float4(fr); ASSERT(0, fr[0]); ASSERT(1, fr[1]); ASSERT(2, fr[2]); ASSERT(3, fr[3]); fr = 2.0f - fv; print_float4(fr); ASSERT(1, fr[0]); ASSERT(0, fr[1]); ASSERT(-1, fr[2]); ASSERT(-2, fr[3]); fr = fv * 2.0f; print_float4(fr); ASSERT(2, fr[0]); ASSERT(4, fr[1]); ASSERT(6, fr[2]); ASSERT(8, fr[3]); fr = 0.5f * fv; print_float4(fr); ASSERT(0, fr[0]); ASSERT(1, fr[1]); ASSERT(1, fr[2]); ASSERT(2, fr[3]); fr = fv / 2.0f; print_float4(fr); ASSERT(0, fr[0]); ASSERT(1, fr[1]); ASSERT(1, fr[2]); ASSERT(2, fr[3]); fr = 8.0f / fv; print_float4(fr); ASSERT(8, fr[0]); ASSERT(4, fr[1]); ASSERT(2, fr[2]); ASSERT(2, fr[3]); fr = -fv; print_float4(fr); ASSERT(-1, fr[0]); ASSERT(-2, fr[1]); ASSERT(-3, fr[2]); ASSERT(-4, fr[3]); // Double2 operations with scalar dr = dv + 1.0; print_double2(dr); ASSERT(2, dr[0]); ASSERT(3, dr[1]); dr = 2.0 + dv; print_double2(dr); ASSERT(3, dr[0]); ASSERT(4, dr[1]); dr = dv - 1.0; print_double2(dr); ASSERT(0, dr[0]); ASSERT(1, dr[1]); dr = 5.0 - dv; print_double2(dr); ASSERT(3, dr[0]); ASSERT(2, dr[1]); dr = dv * 2.0; print_double2(dr); ASSERT(3, dr[0]); ASSERT(5, dr[1]); dr = 0.5 * dv; print_double2(dr); ASSERT(0, dr[0]); ASSERT(1, dr[1]); dr = dv / 2.0; print_double2(dr); ASSERT(0, dr[0]); ASSERT(1, dr[1]); dr = 4.0 / dv; print_double2(dr); ASSERT(2, dr[0]); ASSERT(1, dr[1]); dr = -dv; print_double2(dr); ASSERT(-1, dr[0]); ASSERT(-2, dr[1]); // Int4 operations with scalar ir = iv + 5; print_int4(ir); ASSERT(15, ir[0]); ASSERT(25, ir[1]); ASSERT(35, ir[2]); ASSERT(45, ir[3]); ir = 10 + iv; print_int4(ir); ASSERT(20, ir[0]); ASSERT(30, ir[1]); ASSERT(40, ir[2]); ASSERT(50, ir[3]); ir = iv - 3; print_int4(ir); ASSERT(7, ir[0]); ASSERT(17, ir[1]); ASSERT(27, ir[2]); ASSERT(37, ir[3]); ir = 50 - iv; print_int4(ir); ASSERT(40, ir[0]); ASSERT(30, ir[1]); ASSERT(20, ir[2]); ASSERT(10, ir[3]); ir = iv * 2; print_int4(ir); ASSERT(20, ir[0]); ASSERT(40, ir[1]); ASSERT(60, ir[2]); ASSERT(80, ir[3]); ir = 3 * iv; print_int4(ir); ASSERT(30, ir[0]); ASSERT(60, ir[1]); ASSERT(90, ir[2]); ASSERT(120, ir[3]); ir = ~iv; print_int4(ir); ASSERT(-11, ir[0]); ASSERT(-21, ir[1]); ASSERT(-31, ir[2]); ASSERT(-41, ir[3]); ir = -iv; print_int4(ir); ASSERT(-10, ir[0]); ASSERT(-20, ir[1]); ASSERT(-30, ir[2]); ASSERT(-40, ir[3]); ir = iv & 0x0F; print_int4(ir); ASSERT(10, ir[0]); ASSERT(4, ir[1]); ASSERT(14, ir[2]); ASSERT(8, ir[3]); ir = iv | 0x0F; print_int4(ir); ASSERT(15, ir[0]); ASSERT(31, ir[1]); ASSERT(31, ir[2]); ASSERT(47, ir[3]); ir = iv ^ 0x0F; print_int4(ir); ASSERT(5, ir[0]); ASSERT(27, ir[1]); ASSERT(17, ir[2]); ASSERT(39, ir[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_scalar2.c000066400000000000000000000050401505335450300173560ustar00rootroot00000000000000#include "test.h" #include typedef float float4 __attribute__((vector_size(16))); typedef double double2 __attribute__((vector_size(16))); typedef int int4 __attribute__((vector_size(16))); void print_float4(float4 v) { for (int i = 0; i < 4; i++) printf("%f ", v[i]); printf("\n"); } void print_double2(double2 v) { for (int i = 0; i < 2; i++) printf("%f ", v[i]); printf("\n"); } void print_int4(int4 v) { for (int i = 0; i < 4; i++) printf("%d ", v[i]); printf("\n"); } int main() { float4 fv1 = {1, 2, 3, 4}; float4 fv2 = {5, 6, 7, 8}; float4 fr; double2 dv1 = {1.5, 2.5}; double2 dv2 = {3.5, 4.5}; double2 dr; int4 iv1 = {10, 20, 30, 40}; int4 iv2 = {1, 2, 3, 4}; int4 ir; // Compound float4 expression fr = fv1 + 2.0f * fv2 - 1.0f; // vector + scalar*vector - scalar print_float4(fr); ASSERT(10, fr[0]); ASSERT(13, fr[1]); ASSERT(16, fr[2]); ASSERT(19, fr[3]); fr = (3.0f + fv1) * (fv2 - 1.0f); // scalar + vector multiplied by (vector - scalar) print_float4(fr); ASSERT(16, fr[0]); ASSERT(25, fr[1]); ASSERT(36, fr[2]); ASSERT(49, fr[3]); fr = -fv1 + fv2 / 2.0f; // unary negation + vector / scalar print_float4(fr); ASSERT(1, fr[0]); ASSERT(1, fr[1]); ASSERT(0, fr[2]); ASSERT(0, fr[3]); // Compound double2 expression dr = dv1 + 1.0 * dv2 - 0.5; // vector + scalar*vector - scalar print_double2(dr); ASSERT(4, dr[0]); ASSERT(6, dr[1]); dr = (2.0 + dv1) / (dv2 - 1.0); // scalar + vector divided by (vector - scalar) print_double2(dr); ASSERT(1, dr[0]); ASSERT(1, dr[1]); dr = -dv1 + dv2 * 0.5; // unary negation + vector * scalar print_double2(dr); ASSERT(0, dr[0]); ASSERT(-0, dr[1]); // Compound int4 expression ir = iv1 + 3 * iv2 - 5; // vector + scalar*vector - scalar print_int4(ir); ASSERT(8, ir[0]); ASSERT(21, ir[1]); ASSERT(34, ir[2]); ASSERT(47, ir[3]); ir = (10 + iv1) * (iv2 - 2); // scalar + vector multiplied by (vector - scalar) print_int4(ir); ASSERT(-20, ir[0]); ASSERT(0, ir[1]); ASSERT(40, ir[2]); ASSERT(100, ir[3]); ir = ~iv1 ^ iv2 + 1; // bitwise NOT, XOR, addition print_int4(ir); ASSERT(-9, ir[0]); ASSERT(-24, ir[1]); ASSERT(-27, ir[2]); ASSERT(-46, ir[3]); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/vector_segfault.c000066400000000000000000000015031505335450300176410ustar00rootroot00000000000000#include "test.h" typedef double __m128d __attribute__ ((__vector_size__ (16))); void test_case(__m128d a, __m128d b, const char *desc) { int result = __builtin_ia32_comisdeq(a, b); printf("%-30s -> %d\n", desc, result); ASSERT(result, __builtin_ia32_comisdeq(a, b)); } int main(void) { __m128d v1 = {2.0, 1.0}; // [2.0, 1.0] __m128d v2 = {3.0, 1.0}; // [3.0, 1.0] __m128d v3 = {4.0, 2.0}; // [4.0, 2.0] __m128d vnan = {9.0, 0.0/0.0}; // NaN in low element // Only low element (index 0) is compared! test_case(v1, v2, "Equal low elements (1.0 == 1.0)"); test_case(v1, v3, "Unequal low elements (1.0 != 2.0)"); test_case(vnan, v1, "NaN vs normal"); test_case(v1, vnan, "Normal vs NaN"); test_case(vnan, vnan, "NaN vs NaN"); return 0; } chibicc-1.0.23.1/test/vector_sub.c000066400000000000000000000011331505335450300166170ustar00rootroot00000000000000#include "test.h" typedef float float4 __attribute__((vector_size(16))); float4 sub_vectors(float4 a, float4 b) { return a - b; } int main() { float4 a = {10.0f, 20.0f, 30.0f, 40.0f}; float4 b = {1.0f, 2.0f, 3.0f, 4.0f}; float4 c; c = a - b; for (int i = 0; i < 4; i++) { printf("c[%d] = %f\n", i, c[i]); } ASSERT(9, c[0]); ASSERT(18, c[1]); ASSERT(27, c[2]); ASSERT(36, c[3]); float4 d = sub_vectors(a, b); ASSERT(9, d[0]); ASSERT(18, d[1]); ASSERT(27, d[2]); ASSERT(36, d[3]); return 0; } chibicc-1.0.23.1/test/vector_sub2.c000066400000000000000000000012551505335450300167060ustar00rootroot00000000000000#include "test.h" typedef int int4 __attribute__((vector_size(16))); int4 sub_int_vectors(int4 a, int4 b) { return a - b; } int main() { int4 a = {100, 200, 300, 400}; int4 b = {10, 20, 30, 40}; int4 c; c = sub_int_vectors(a, b); for (int i = 0; i < 4; i++) { printf("c[%d] = %d\n", i, c[i]); } ASSERT(90, c[0]); ASSERT(180, c[1]); ASSERT(270, c[2]); ASSERT(360, c[3]); int4 d = sub_int_vectors(c, b); for (int i = 0; i < 4; i++) { printf("d[%d] = %d\n", i, d[i]); } ASSERT(80, d[0]); ASSERT(160, d[1]); ASSERT(240, d[2]); ASSERT(320, d[3]); return 0; } chibicc-1.0.23.1/test/vector_test.c000066400000000000000000000100621505335450300170060ustar00rootroot00000000000000/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "test.h" #include #include typedef char byte16 __attribute__((__vector_size__(16))); typedef float float4 __attribute__((__vector_size__(16))); typedef float float4a1 __attribute__((__vector_size__(16), __aligned__(1))); typedef float float4a16 __attribute__((__vector_size__(16), __aligned__(16))); typedef double double2 __attribute__((__vector_size__(16))); typedef double double2a1 __attribute__((__vector_size__(16), __aligned__(1))); typedef double double2a16 __attribute__((__vector_size__(16), __aligned__(16))); int main(void) { printf("sizeof(float4) = %ld\n", sizeof(float4)); printf("sizeof(float4a1) = %ld\n", sizeof(float4a1)); printf("sizeof(float4a16) = %ld\n", sizeof(float4a16)); printf("sizeof(double2) = %ld\n", sizeof(double2)); printf("sizeof(double2) = %ld\n", sizeof(double2a1)); printf("sizeof(double2) = %ld\n", sizeof(double2a16)); printf(" _Alignof(float4) = %ld\n", _Alignof(float4)); printf(" _Alignof(float4a1) = %ld\n", _Alignof(float4a1)); printf(" _Alignof(float4a16) = %ld\n", _Alignof(float4a16)); printf(" _Alignof(double2) = %ld\n", _Alignof(double2)); printf(" _Alignof(double2a1) = %ld\n", _Alignof(double2a1)); printf(" _Alignof(double2a16) = %ld\n", _Alignof(double2a16)); printf(" _Alignof(double2) = %ld\n", _Alignof(double2)); ASSERT(16, sizeof(float4)); ASSERT(16, sizeof(float4a1)); ASSERT(16, sizeof(float4a16)); ASSERT(16, sizeof(double2)); ASSERT(16, sizeof(double2a1)); ASSERT(16, sizeof(double2a16)); ASSERT(16, _Alignof(float4)); ASSERT(1, _Alignof(float4a1)); ASSERT(16, _Alignof(float4a16)); ASSERT(16, _Alignof(double2)); ASSERT(1, _Alignof(double2a1)); ASSERT(16, _Alignof(double2a16)); { float4 v1; float4 v2; float x[4] = {1, 2, 3, 4}; float y[4] = {1, 1, 1, 1}; memcpy(&v1, x, 16); memcpy(&v2, y, 16); v1 = v1 + v2; memcpy(x, &v1, 16); ASSERT(2, x[0]); // TODO(jart): fix me ASSERT(3, x[1]); ASSERT(4, x[2]); ASSERT(5, x[3]); } { byte16 v; float x1[4] = {1, 2, 3, 4}; float x2[4]; memcpy(&v, x1, 16); //__builtin_ia32_movntdq(x1, &v); memcpy(x2, &v, 16); ASSERT(1, x2[0]); //TODO(jart): fix me ASSERT(2, x1[1]); } return 0; }chibicc-1.0.23.1/test/vector_test2.c000066400000000000000000000102011505335450300170630ustar00rootroot00000000000000/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "test.h" #include typedef char byte16 __attribute__((__vector_size__(16))); typedef float float4 __attribute__((__vector_size__(16))); typedef float float5a1 __attribute__((__vector_size__(16), __aligned__(1))); typedef float float6a16 __attribute__((__vector_size__(16), __aligned__(16))); typedef double double2 __attribute__((__vector_size__(16))); typedef double double3a1 __attribute__((__vector_size__(16), __aligned__(1))); typedef double double4a16 __attribute__((__vector_size__(16), __aligned__(16))); int main(void) { printf("sizeof(float4) = %ld\n", sizeof(float4)); printf("sizeof(float4a1) = %ld\n", sizeof(float5a1)); printf("sizeof(float4a16) = %ld\n", sizeof(float6a16)); printf("sizeof(double2) = %ld\n", sizeof(double2)); printf("sizeof(double2) = %ld\n", sizeof(double3a1)); printf("sizeof(double2) = %ld\n", sizeof(double4a16)); printf(" _Alignof(float4) = %ld\n", _Alignof(float4)); printf(" _Alignof(float4a1) = %ld\n", _Alignof(float5a1)); printf(" _Alignof(float4a16) = %ld\n", _Alignof(float6a16)); printf(" _Alignof(double2) = %ld\n", _Alignof(double2)); printf(" _Alignof(double2a1) = %ld\n", _Alignof(double3a1)); printf(" _Alignof(double2a16) = %ld\n", _Alignof(double4a16)); printf(" _Alignof(double2) = %ld\n", _Alignof(double2)); ASSERT(16, sizeof(float4)); ASSERT(16, sizeof(float5a1)); ASSERT(16, sizeof(float6a16)); ASSERT(16, sizeof(double2)); ASSERT(16, sizeof(double3a1)); ASSERT(16, sizeof(double4a16)); ASSERT(16, _Alignof(float4)); ASSERT(1, _Alignof(float5a1)); ASSERT(16, _Alignof(float6a16)); ASSERT(16, _Alignof(double2)); ASSERT(1, _Alignof(double3a1)); ASSERT(16, _Alignof(double4a16)); { float4 v1; float4 v2; float x[4] = {1, 2, 3, 4}; float y[4] = {1, 1, 1, 1}; memcpy(&v1, x, 16); memcpy(&v2, y, 16); v1 = v1 + v2; memcpy(x, &v1, 16); ASSERT(2, x[0]); // TODO(jart): fix me ASSERT(3, x[1]); ASSERT(4, x[2]); ASSERT(5, x[3]); } { byte16 v; float x1[4] = {1, 2, 3, 4}; float x2[4]; // memcpy(&v, x1, 16); // __builtin_ia32_movntdq(x1, &v); // memcpy(x2, &v, 16); // ASSERT(1, x2[0]); // TODO(jart): fix me // ASSERT(2, x[1]); } return 0; }chibicc-1.0.23.1/test/vector_variadic.c000066400000000000000000000007131505335450300176130ustar00rootroot00000000000000#include "test.h" #include typedef float float4 __attribute__((vector_size(16))); void print_vectors(int count, ...) { va_list ap; va_start(ap, count); for (int i = 0; i < count; i++) { float4 v = va_arg(ap, float4); printf("vec %d = %f %f %f %f\n", i, v[0], v[1], v[2], v[3]); } va_end(ap); } int main() { float4 a = {1,2,3,4}; float4 b = {5,6,7,8}; print_vectors(2, a, b); } chibicc-1.0.23.1/test/vim.c000066400000000000000000000002311505335450300152350ustar00rootroot00000000000000#include "test.h" int main() { int x = (0 < 2 || 0) ? -1 : 42; printf("%d\n", x); // Should print -1 ASSERT(-1, x); return 0; } chibicc-1.0.23.1/test/vim2.c000066400000000000000000000002611505335450300153220ustar00rootroot00000000000000#include #include "test.h" int main() { int r = system("XXXX"); // Command doesn't exist printf("Returned: %d\n", r); ASSERT(32512, r); return 0; } chibicc-1.0.23.1/test/vim3.c000066400000000000000000000005421505335450300153250ustar00rootroot00000000000000#include #include "test.h" int main() { FILE *fp = popen("XXXX", "r"); if (fp == NULL) { perror("popen"); return 1; } char buf[128]; while (fgets(buf, sizeof(buf), fp)) { printf("Output: %s", buf); } int status = pclose(fp); printf("Status: %d\n", status); ASSERT(32512, status); return 0; } chibicc-1.0.23.1/test/vim5.c000066400000000000000000000013441505335450300153300ustar00rootroot00000000000000#include "test.h" #include #include // For WEXITSTATUS and related macros int main(void) { int ret = system("XXXX"); // Intentionally invalid command if (ret == -1) { perror("system"); return 1; } // Check if the command terminated normally if (WIFEXITED(ret)) { int exit_status = WEXITSTATUS(ret); printf("Command exited with status: %d\n", exit_status); if (exit_status == 127) printf("As expected: command not found\n"); else printf("Unexpected exit status\n"); ASSERT(127, exit_status); } else { printf("Command did not exit normally\n"); } return 0; } chibicc-1.0.23.1/test/vla.c000077500000000000000000000020331505335450300152310ustar00rootroot00000000000000#include "test.h" int main() { ASSERT(20, ({ int n=5; int x[n]; sizeof(x); })); ASSERT((5+1)*(8*2)*4, ({ int m=5, n=8; int x[m+1][n*2]; sizeof(x); })); ASSERT(8, ({ char n=10; int (*x)[n][n+2]; sizeof(x); })); ASSERT(480, ({ char n=10; int (*x)[n][n+2]; sizeof(*x); })); ASSERT(48, ({ char n=10; int (*x)[n][n+2]; sizeof(**x); })); ASSERT(4, ({ char n=10; int (*x)[n][n+2]; sizeof(***x); })); ASSERT(60, ({ char n=3; int x[5][n]; sizeof(x); })); ASSERT(12, ({ char n=3; int x[5][n]; sizeof(*x); })); ASSERT(60, ({ char n=3; int x[n][5]; sizeof(x); })); ASSERT(20, ({ char n=3; int x[n][5]; sizeof(*x); })); ASSERT(0, ({ int n=10; int x[n+1][n+6]; int *p=x; for (int i = 0; i #include #include #include #define VLC_USED __attribute__((unused)) #define VLC_MALLOC __attribute__((malloc)) // Generic macro using builtins #define mul_overflow(a,b,r) \ _Generic(*(r), \ unsigned: __builtin_umul_overflow(a, b, (unsigned *)(r)), \ unsigned long: __builtin_umull_overflow(a, b, (unsigned long *)(r)), \ unsigned long long: __builtin_umulll_overflow(a, b, (unsigned long long *)(r))) // VLC-like allocation using builtins VLC_USED VLC_MALLOC static inline void *vlc_alloc(size_t count, size_t size) { size_t total = 0; if (mul_overflow(count, size, &total)) return NULL; return malloc(total); } int main(void) { size_t n = 10, sz = sizeof(int); int *arr = vlc_alloc(n, sz); if (!arr) { printf("Allocation failed (overflow?)\n"); return 1; } printf("=======n=%d, sz=%d, arr=%p\n"); for (size_t i = 0; i < n; i++) arr[i] = (int)i; for (size_t i = 0; i < n; i++) printf("%d ", arr[i]); printf("\n"); free(arr); // Test overflow int *overflow_test = vlc_alloc(SIZE_MAX, SIZE_MAX); if (!overflow_test) printf("Overflow detected correctly!\n"); return 0; } chibicc-1.0.23.1/test/vlc_undefine.c000066400000000000000000000030321505335450300171050ustar00rootroot00000000000000#include "test.h" typedef int vlc_action_id_t; typedef struct { int dummy; } intf_thread_t; // Normal function that the action_handler will call void player_navigate(intf_thread_t *player, int nav) { printf("player_navigate called with %d\n", nav); ASSERT(42, nav); } // Macro defining static inline action handlers #define PLAYER_ACTION_HANDLER(name) \ static inline void action_handler_##name(intf_thread_t *player, vlc_action_id_t action_id) PLAYER_ACTION_HANDLER(Navigate) { enum { NAV_UP = 1, NAV_DOWN = 2, NAV_LEFT = 3, NAV_RIGHT = 4, NAV_ACTIVATE = 42 }; int nav; switch (action_id) { #define PLAYER_NAV_FROM_ACTION(navval) \ case NAV_##navval: \ nav = NAV_##navval; \ break; PLAYER_NAV_FROM_ACTION(ACTIVATE) PLAYER_NAV_FROM_ACTION(UP) PLAYER_NAV_FROM_ACTION(DOWN) PLAYER_NAV_FROM_ACTION(LEFT) PLAYER_NAV_FROM_ACTION(RIGHT) #undef PLAYER_NAV_FROM_ACTION default: ASSERT(0, action_id); // simulate vlc_assert_unreachable } // Call a normal function player_navigate(player, nav); } typedef void (*handler_t)(intf_thread_t*, vlc_action_id_t); struct vlc_action { handler_t fptr; }; // Array of pointers to inline action handlers static struct vlc_action actions[] = { { .fptr = action_handler_Navigate } }; int main() { intf_thread_t i; vlc_action_id_t act = 42; // NAV_ACTIVATE actions[0].fptr(&i, act); printf("OK\n"); return 0; } chibicc-1.0.23.1/test/weak.c000066400000000000000000000004711505335450300153770ustar00rootroot00000000000000#include "test.h" // Define the original function `lxc_attach_main`. int lxc_attach_main(int argc, char *argv[]) { printf("This is lxc_attach_main.\n"); return 0; } // Declare `main` as a weak alias of `lxc_attach_main`. int __attribute__((weak, alias("lxc_attach_main"))) main(int argc, char *argv[]); chibicc-1.0.23.1/test/zconf.h000066400000000000000000000414021505335450300155730ustar00rootroot00000000000000/* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. * Even better than compiling with -DZ_PREFIX would be to use configure to set * this permanently in zconf.h using "./configure --zprefix". */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ # define Z_PREFIX_SET /* all linked symbols and init macros */ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align # define _tr_flush_bits z__tr_flush_bits # define _tr_flush_block z__tr_flush_block # define _tr_init z__tr_init # define _tr_stored_block z__tr_stored_block # define _tr_tally z__tr_tally # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define crc32_combine_gen z_crc32_combine_gen # define crc32_combine_gen64 z_crc32_combine_gen64 # define crc32_combine_op z_crc32_combine_op # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateGetDictionary z_deflateGetDictionary # define deflateInit z_deflateInit # define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflateUsed z_deflateUsed # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # ifndef Z_SOLO # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer # define gzclearerr z_gzclearerr # define gzclose z_gzclose # define gzclose_r z_gzclose_r # define gzclose_w z_gzclose_w # define gzdirect z_gzdirect # define gzdopen z_gzdopen # define gzeof z_gzeof # define gzerror z_gzerror # define gzflush z_gzflush # define gzfread z_gzfread # define gzfwrite z_gzfwrite # define gzgetc z_gzgetc # define gzgetc_ z_gzgetc_ # define gzgets z_gzgets # define gzoffset z_gzoffset # define gzoffset64 z_gzoffset64 # define gzopen z_gzopen # define gzopen64 z_gzopen64 # ifdef _WIN32 # define gzopen_w z_gzopen_w # endif # define gzprintf z_gzprintf # define gzputc z_gzputc # define gzputs z_gzputs # define gzread z_gzread # define gzrewind z_gzrewind # define gzseek z_gzseek # define gzseek64 z_gzseek64 # define gzsetparams z_gzsetparams # define gztell z_gztell # define gztell64 z_gztell64 # define gzungetc z_gzungetc # define gzvprintf z_gzvprintf # define gzwrite z_gzwrite # endif # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define inflateBackInit z_inflateBackInit # define inflateBackInit_ z_inflateBackInit_ # define inflateCodesUsed z_inflateCodesUsed # define inflateCopy z_inflateCopy # define inflateEnd z_inflateEnd # define inflateGetDictionary z_inflateGetDictionary # define inflateGetHeader z_inflateGetHeader # define inflateInit z_inflateInit # define inflateInit2 z_inflateInit2 # define inflateInit2_ z_inflateInit2_ # define inflateInit_ z_inflateInit_ # define inflateMark z_inflateMark # define inflatePrime z_inflatePrime # define inflateReset z_inflateReset # define inflateReset2 z_inflateReset2 # define inflateResetKeep z_inflateResetKeep # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # ifndef Z_SOLO # define uncompress z_uncompress # define uncompress2 z_uncompress2 # endif # define zError z_zError # ifndef Z_SOLO # define zcalloc z_zcalloc # define zcfree z_zcfree # endif # define zlibCompileFlags z_zlibCompileFlags # define zlibVersion z_zlibVersion /* all zlib typedefs in zlib.h and zconf.h */ # define Byte z_Byte # define Bytef z_Bytef # define alloc_func z_alloc_func # define charf z_charf # define free_func z_free_func # ifndef Z_SOLO # define gzFile z_gzFile # endif # define gz_header z_gz_header # define gz_headerp z_gz_headerp # define in_func z_in_func # define intf z_intf # define out_func z_out_func # define uInt z_uInt # define uIntf z_uIntf # define uLong z_uLong # define uLongf z_uLongf # define voidp z_voidp # define voidpc z_voidpc # define voidpf z_voidpf /* all zlib structs in zlib.h and zconf.h */ # define gz_header_s z_gz_header_s # define internal_state z_internal_state #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif #ifndef z_const # ifdef ZLIB_CONST # define z_const const # else # define z_const # endif #endif #ifdef Z_SOLO # ifdef _WIN64 typedef unsigned long long z_size_t; # else typedef unsigned long z_size_t; # endif #else # define z_longlong long long # if defined(NO_SIZE_T) typedef unsigned NO_SIZE_T z_size_t; # elif defined(STDC) # include typedef size_t z_size_t; # else typedef unsigned long z_size_t; # endif # undef z_longlong #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus about 7 kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # endif # include /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC typedef void const *voidpc; typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) # include # if (UINT_MAX == 0xffffffffUL) # define Z_U4 unsigned # elif (ULONG_MAX == 0xffffffffUL) # define Z_U4 unsigned long # elif (USHRT_MAX == 0xffffffffUL) # define Z_U4 unsigned short # endif #endif #ifdef Z_U4 typedef Z_U4 z_crc_t; #else typedef unsigned long z_crc_t; #endif #if HAVE_UNISTD_H-0 /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif #if HAVE_STDARG_H-0 /* may be set to #if 1 by ./configure */ # define Z_HAVE_STDARG_H #endif #ifdef STDC # ifndef Z_SOLO # include /* for off_t */ # endif #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO # include /* for va_list */ # endif #endif #ifdef _WIN32 # ifndef Z_SOLO # include /* for wchar_t */ # endif #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * though the former does not conform to the LFS document), but considering * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * equivalently requesting no 64-bit operations */ #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif #ifndef Z_HAVE_UNISTD_H # if defined(__WATCOMC__) || defined(__GO32__) || \ (defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)) # define Z_HAVE_UNISTD_H # endif #endif #ifndef Z_SOLO # if defined(Z_HAVE_UNISTD_H) # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ # ifdef VMS # include /* for off_t */ # endif # ifndef z_off_t # define z_off_t off_t # endif # endif #endif #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 # define Z_LFS64 #endif #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) # define Z_LARGE64 #endif #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) # define Z_WANT64 #endif #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long long #endif #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #elif defined(__MINGW32__) # define z_off64_t long long #elif defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 #elif defined(__GO32__) # define z_off64_t offset_t #else # define z_off64_t z_off_t #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") #pragma map(deflateInit2_,"DEIN2") #pragma map(deflateEnd,"DEEND") #pragma map(deflateBound,"DEBND") #pragma map(inflateInit_,"ININ") #pragma map(inflateInit2_,"ININ2") #pragma map(inflateEnd,"INEND") #pragma map(inflateSync,"INSY") #pragma map(inflateSetDictionary,"INSEDI") #pragma map(compressBound,"CMBND") #pragma map(inflate_table,"INTABL") #pragma map(inflate_fast,"INFA") #pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */chibicc-1.0.23.1/test/zlib.h000077500000000000000000002765071505335450300154370ustar00rootroot00000000000000 /* zlib.h -- interface of the 'zlib' general purpose compression library version 1.3.1.1, January xxth, 2024 Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). */ #ifndef ZLIB_H #define ZLIB_H #ifdef ZLIB_BUILD # include #else # include "zconf.h" #endif #ifdef __cplusplus extern "C" { #endif #define ZLIB_VERSION "1.3.1.1-motley" #define ZLIB_VERNUM 0x1311 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 3 #define ZLIB_VER_REVISION 1 #define ZLIB_VER_SUBREVISION 1 /* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) but other algorithms will be added later and will have the same stream interface. Compression can be done in a single step if the buffers are large enough, or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. The compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. This library can optionally read and write gzip and raw deflate streams in memory as well. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in the case of corrupted input. */ typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); typedef void (*free_func)(voidpf opaque, voidpf address); struct internal_state; typedef struct z_stream_s { z_const Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total number of input bytes read so far */ Bytef *next_out; /* next output byte will go here */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total number of bytes output so far */ z_const char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: binary or text for deflate, or the decoding state for inflate */ uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* gzip header information passed to and from zlib routines. See RFC 1952 for more details on the meanings of these fields. */ typedef struct gz_header_s { int text; /* true if compressed data believed to be text */ uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ Bytef *extra; /* pointer to extra field or Z_NULL if none */ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ uInt extra_max; /* space at extra (only when reading header) */ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max; /* space at name (only when reading header) */ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ uInt comm_max; /* space at comment (only when reading header) */ int hcrc; /* true if there was or will be a header crc */ int done; /* true when done reading gzip header (not used when writing a gzip file) */ } gz_header; typedef gz_header FAR *gz_headerp; /* The application must update next_in and avail_in when avail_in has dropped to zero. It must update next_out and avail_out when avail_out has dropped to zero. The application must initialize zalloc, zfree and opaque before calling the init function. All other fields are set by the compression library and must not be updated by the application. The opaque value provided by the application will be passed as the first parameter for calls of zalloc and zfree. This can be useful for custom memory management. The compression library attaches no meaning to the opaque value. zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be thread safe. In that case, zlib is thread-safe. When zalloc and zfree are Z_NULL on entry to the initialization function, they are set to internal routines that use the standard library functions malloc() and free(). On 16-bit systems, the functions zalloc and zfree must be able to allocate exactly 65536 bytes, but will not be required to allocate more than this if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers returned by zalloc for objects of exactly 65536 bytes *must* have their offset normalized to zero. The default allocation function provided by this library ensures this (see zutil.c). To reduce memory requirements and avoid any allocation of 64K objects, at the expense of compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). The fields total_in and total_out can be used for statistics or progress reports. After compression, total_in holds the total size of the uncompressed data and may be saved for use by the decompressor (particularly if the decompressor wants to decompress everything in a single step). */ /* constants */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 #define Z_BLOCK 5 #define Z_TREES 6 /* Allowed flush values; see deflate() and inflate() below for details */ #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative values * are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_RLE 3 #define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field for deflate() */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ /* basic functions */ ZEXTERN const char * ZEXPORT zlibVersion(void); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ /* ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default allocation functions. total_in, total_out, adler, and msg are initialized. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Generate more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary. Some output may be provided even if flush is zero. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating avail_in or avail_out accordingly; avail_out should never be zero before the call. The application can consume the compressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. See deflatePending(), which can be used if desired to determine whether or not there is more output in that case. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to decide how much data to accumulate before producing output, in order to maximize compression. If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so that the decompressor can get all input data available so far. (In particular avail_in is zero after the call if enough output space has been provided before the call.) Flushing may degrade compression for some compression algorithms and so it should be used only when necessary. This completes the current deflate block and follows it with an empty stored block that is three bits plus filler bits to the next byte, followed by four bytes (00 00 ff ff). If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the output buffer, but the output is not aligned to a byte boundary. All of the input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. This completes the current deflate block and follows it with an empty fixed codes block that is 10 bits long. This assures that enough bytes are output in order for the decompressor to finish the block before the empty fixed codes block. If flush is set to Z_BLOCK, a deflate block is completed and emitted, as for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to seven bits of the current block are held to be written as the next byte after the next deflate block is completed. In this case, the decompressor may not be provided enough bits at this point in order to complete decompression of the data provided so far to the compressor. It may need to wait for the next block to be emitted. This is for advanced applications that need to control the emission of deflate blocks. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out is greater than six when the flush marker begins, in order to avoid repeated flush markers upon calling deflate() again when avail_out == 0. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. Z_FINISH can be used in the first deflate call after deflateInit if all the compression is to be done in a single step. In order to complete in one call, avail_out must be at least the value returned by deflateBound (see below). Then deflate is guaranteed to return Z_STREAM_END. If not enough output space is provided, deflate will not return Z_STREAM_END, and it must be called again as described above. deflate() sets strm->adler to the Adler-32 checksum of all input read so far (that is, total_in bytes). If a gzip stream is being generated, then strm->adler will be the CRC-32 checksum of the input read so far. (See deflateInit2 below.) deflate() may update strm->data_type if it can make a good guess about the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example if next_in or next_out was Z_NULL or the state was inadvertently written over by the application), or Z_BUF_ERROR if no progress is possible (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and deflate() can be called again with more input and more output space to continue compressing. */ ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded). In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* ZEXTERN int ZEXPORT inflateInit(z_streamp strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. In the current version of inflate, the provided input is not read or consumed. The allocation of a sliding window will be deferred to the first call of inflate (if the decompression does not complete on the first call). If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions. total_in, total_out, adler, and msg are initialized. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit does not perform any decompression. Actual decompression will be done by inflate(). So next_in, and avail_in, next_out, and avail_out are unused and unchanged. The current implementation of inflateInit() does not process any header information -- that is deferred until inflate() is called. */ ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), then next_in and avail_in are updated accordingly, and processing will resume at this point for the next call of inflate(). - Generate more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. If the caller of inflate() does not provide both available input and available output space, it is possible that there will be no progress made. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much output as possible to the output buffer. Z_BLOCK requests that inflate() stop if and when it gets to the next deflate block boundary. When decoding the zlib or gzip format, this will cause inflate() to return immediately after the header and before the first block. When doing a raw inflate, inflate() will go ahead and process the first block, and will return when it gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. To assist in this, on return inflate() always sets strm->data_type to the number of unused bits in the last byte taken from strm->next_in, plus 64 if inflate() is currently decoding the last block in the deflate stream, plus 128 if inflate() returned immediately after decoding an end-of-block code or decoding the complete header up to just before the first byte of the deflate stream. The end-of-block will not be indicated until all of the uncompressed data from that block has been written to strm->next_out. The number of unused bits may in general be greater than seven, except when bit 7 of data_type is set, in which case the number of unused bits will be less than eight. data_type is set as noted here every time inflate() returns for all flush options, and so can be used to determine the amount of currently consumed input in bits. The Z_TREES option behaves as Z_BLOCK does, but it also returns when the end of each deflate block header is reached, before any actual data in that block is decoded. This allows the caller to determine the length of the deflate block header for later use in random access within a deflate block. 256 is added to the value of strm->data_type when inflate() returns immediately after reaching the end of the deflate block header. inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all of the uncompressed data for the operation to complete. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The use of Z_FINISH is not required to perform an inflation in one step. However it may be used to inform inflate that a faster approach can be used for the single inflate() call. Z_FINISH also informs inflate to not maintain a sliding window if the stream completes, which reduces inflate's memory footprint. If the stream does not complete, either because not all of the stream is provided or not enough output space is provided, then a sliding window will be allocated and inflate() can be called again to continue the operation as if Z_NO_FLUSH had been used. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the first call. So the effects of the flush parameter in this implementation are on the return value of inflate() as noted below, when inflate() returns early when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of memory for a sliding window when Z_FINISH is used. If a preset dictionary is needed after this call (see inflateSetDictionary below), inflate sets strm->adler to the Adler-32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the Adler-32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() checks that its computed Adler-32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() can decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically, if requested when initializing with inflateInit2(). Any information contained in the gzip header is not retained unless inflateGetHeader() is used. When processing gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output produced so far. The CRC-32 is checked against the gzip trailer, as is the uncompressed length, modulo 2^32. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check value, in which case strm->msg points to a string with a more specific error), Z_STREAM_ERROR if the stream structure was inconsistent (for example next_in or next_out was Z_NULL, or the state was inadvertently written over by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress was possible or if there was not enough room in the output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial recovery of the data is to be attempted. */ ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state was inconsistent. */ /* Advanced functions */ /* The following functions are needed only in some special applications. */ /* ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy); This is another version of deflateInit with more compression options. The fields zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. For the current implementation of deflate(), a windowBits value of 8 (a window size of 256 bytes) is not supported. As a result, a request for 8 will result in 9 (a 512-byte window). In that case, providing 8 to inflateInit2() will result in an error when the zlib header with 9 is checked against the initialization of inflate(). The remedy is to not use 8 with deflateInit2() with this initialization, or at least in that case use 9 with inflateInit2(). windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute a check value. windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no header crc, and the operating system will be set to the appropriate value, if the operating system was determined at compile time. If a gzip stream is being written, strm->adler is a CRC-32 instead of an Adler-32. For raw deflate or gzip encoding, a request for a 256-byte window is rejected as invalid, since only the zlib header provides a means of transmitting the window size to the decompressor. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed. The default value is 8. See zconf.h for total memory usage as a function of windowBits and memLevel. The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), Z_RLE to limit match distances to one (run-length encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string matching). Filtered data consists mostly of small values with a somewhat random distribution, as produced by the PNG filters. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching than the default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better compression for PNG image data than Huffman only. The degree of string matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then Z_HUFFMAN_ONLY. The strategy parameter affects the compression ratio but never the correctness of the compressed output, even if it is not set optimally for the given data. Z_FIXED uses the default string matching, but prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. When using the zlib format, this function must be called immediately after deflateInit, deflateInit2 or deflateReset, and before any call of deflate. When doing raw deflate, this function must be called either before any call of deflate, or immediately after the completion of a deflate block, i.e. after all input has been consumed and all output has been delivered when using any of the flush options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size provided in deflateInit or deflateInit2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. In addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary. Upon return of this function, strm->adler is set to the Adler-32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The Adler-32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the Adler-32 value is not computed and strm->adler is not set. deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream or if not at a block boundary for raw deflate). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If deflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. Similarly, if dictLength is Z_NULL, then it is not set. deflateGetDictionary() may return a length less than the window size, even when more than the window size in input has been provided. It may return up to 258 bytes less in that case, due to how zlib's implementation of deflate manages the sliding window and lookahead for matches, where matches can be up to 258 bytes long. If the application needs the last window-size bytes of input, then that would need to be saved by the application outside of zlib. deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent. */ ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, z_streamp source); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT deflateReset(z_streamp strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream will leave the compression level and any other attributes that may have been set unchanged. total_in, total_out, adler, and msg are initialized. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ ZEXTERN int ZEXPORT deflateParams(z_streamp strm, int level, int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the strategy is changed, and if there have been any deflate() calls since the state was initialized or reset, then the input available so far is compressed with the old level and strategy using deflate(strm, Z_BLOCK). There are three approaches for the compression levels 0, 1..3, and 4..9 respectively. The new level and strategy will take effect at the next call of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not take effect. In this case, deflateParams() can be called again with the same parameters and more output space to try again. In order to assure a change in the parameters on the first try, the deflate stream should be flushed using deflate() with Z_BLOCK or other flush request until strm.avail_out is not zero, before calling deflateParams(). Then no more input data should be provided before the deflateParams() call. If this is done, the old level and strategy will be applied to the data compressed before deflateParams(), and the new level and strategy will be applied to the data compressed after deflateParams(). deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if there was not enough output space to complete the compression of the available input data before a change in the strategy or approach. Note that in the case of a Z_BUF_ERROR, the parameters are not changed. A return value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be retried with more output space. */ ZEXTERN int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for searching for the best matching string, and even then only by the most fanatic optimizer trying to squeeze out the last compressed bit for their specific input data. Read the deflate.c source code for the meaning of the max_lazy, good_length, nice_length, and max_chain parameters. deflateTune() can be called after deflateInit() or deflateInit2(), and returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or deflateInit2(), and after deflateSetHeader(), if used. This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate(). If that first deflate() call is provided the sourceLen input bytes, an output buffer allocated to the size returned by deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed to return Z_STREAM_END. Note that it is possible for the compressed size to be larger than the value returned by deflateBound() if flush options other than Z_FINISH or Z_NO_FLUSH are used. */ ZEXTERN int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not provided would be due to the available output space having being consumed. The number of bits of output not provided are between 0 and 7, where they await more bits to join them in order to fill out a full byte. If pending or bits are Z_NULL, then those values are not set. deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateUsed(z_streamp strm, int *bits); /* deflateUsed() returns in *bits the most recent number of deflate bits used in the last byte when flushing to a byte boundary. The result is in 1..8, or 0 if there has not yet been a flush. This helps determine the location of the last bit of a deflate stream. deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, int bits, int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits leftover from a previous deflate stream when appending to it. As such, this function can only be used for raw deflate, and must be used before the first deflate() call after a deflateInit2() or deflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the output. deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information in the provided gz_header structure are written to the gzip header (xflag is ignored -- the extra flags are set according to the compression level). The caller must assure that, if not Z_NULL, name and comment are terminated with a zero byte, and that if extra is not Z_NULL, that extra_len bytes are available there. If hcrc is true, a gzip header crc is included. Note that the current versions of the command-line version of gzip (up through version 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, the time set to zero, and os set to the current operating system, with no extra, name, or comment fields. The gzip header is returned to the default state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The default value is 15 if inflateInit is used instead. windowBits must be greater than or equal to the windowBits value provided to deflateInit2() while compressing, or it must be equal to 15 if deflateInit2() was not used. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. windowBits can also be zero to request that inflate use the window size in the zlib header of the compressed stream. windowBits can also be -8..-15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is recommended that a check value such as an Adler-32 or a CRC-32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see below), inflate() will *not* automatically decode concatenated gzip members. inflate() will return Z_STREAM_END at the end of the gzip member. The state would need to be reset to continue decoding a subsequent gzip member. This *must* be done if there is more data after a gzip member, in order for the decompression to be compliant with the gzip standard (RFC 1952). inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit2 does not perform any decompression apart from possibly reading the zlib header if present: actual decompression will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unused and unchanged.) The current implementation of inflateInit2() does not process any header information -- that is deferred until inflate() is called. */ ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the Adler-32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called at any time to set the dictionary. If the provided dictionary is smaller than the window and there is already data in the window, then the provided dictionary will amend what's there. The application must insure that the dictionary that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect Adler-32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If inflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. Similarly, if dictLength is Z_NULL, then it is not set. inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent. */ ZEXTERN int ZEXPORT inflateSync(z_streamp strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. inflateSync searches for a 00 00 FF FF pattern in the compressed data. All full flush points have this pattern, but not all occurrences of this pattern are full flush points. inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success case, the application may save the current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, z_streamp source); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when randomly accessing a large stream. The first pass through the stream can periodically record the inflate state, allowing restarting inflate at those points when randomly accessing the stream. inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT inflateReset(z_streamp strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. total_in, total_out, adler, and msg are initialized. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted the same as it is for inflateInit2. If the window size is changed, then the memory allocated for the window is freed, and the window will be reallocated by inflate() if needed. inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL), or if the windowBits parameter is invalid. */ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, int bits, int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the middle of a byte. The provided bits will be used before any bytes are used from next_in. This function should only be used with raw inflate, and should be used before the first inflate() call after inflateInit2() or inflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the input. If bits is negative, then the input stream bit buffer is emptied. Then inflatePrime() can be called again to put bits in the buffer. This is used to clear out bits leftover after feeding inflate a block description prior to feeding inflate codes. inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN long ZEXPORT inflateMark(z_streamp strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the return value down 16 bits. If the upper value is -1 and the lower value is zero, then inflate() is currently decoding information outside of a block. If the upper value is -1 and the lower value is non-zero, then inflate is in the middle of a stored block, with the lower value equaling the number of bytes from the input remaining to copy. If the upper value is not -1, then it is the number of bits back from the current bit position in the input of the code (literal or length/distance pair) currently being processed. In that case the lower value is the number of bytes already emitted for that code. A code is being processed if inflate is waiting for more input to complete decoding of the code, or if it has completed decoding but is waiting for more output space to write the literal or match data. inflateMark() is used to mark locations in the input data for random access, which may be at bit positions, and to note those cases where the output of a code may span boundaries of random access blocks. The current location in the input stream can be determined from avail_in and data_type as noted in the description for the Z_BLOCK flush parameter for inflate. inflateMark returns the value noted above, or -65536 if the provided source stream state was inconsistent. */ ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be used to force inflate() to return immediately after header processing is complete and before any actual data is decompressed. The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, terminated with a zero unless the length is greater than comm_max. When any of extra, name, or comment are not Z_NULL and the respective field is not present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed. If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream. inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, unsigned char FAR *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized before the call. If zalloc and zfree are Z_NULL, then the default library- derived memory allocation routines are used. windowBits is the base two logarithm of the window size, in the range 8..15. window is a caller supplied buffer of that size. Except for special applications where it is assured that deflate was used with small window sizes, windowBits must be 15 and a 32K byte window must be supplied to be able to decompress general deflate streams. See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of the parameters are invalid, Z_MEM_ERROR if the internal state could not be allocated, or Z_VERSION_ERROR if the version of the library does not match the version of the header file. */ typedef unsigned (*in_func)(void FAR *, z_const unsigned char FAR * FAR *); typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); ZEXTERN int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than inflate() for file i/o applications, in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. inflate() can be faster on modern CPUs when used with large buffers. inflateBack() trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns. inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw deflate stream with each call. inflateBackEnd() is then called to free the allocated state. A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only the raw deflate stream to decompress. This is different from the default behavior of inflate(), which expects a zlib header and trailer around the deflate stream. inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those routines until it reads a complete deflate stream and writes out all of the uncompressed data, or until it encounters an error. The function's parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If there is no input available, in() must return zero -- buf is ignored in that case -- and inflateBack() will return a buffer error. inflateBack() will call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() should return zero on success, or non-zero on failure. If out() returns non-zero, inflateBack() will return with an error. Neither in() nor out() are permitted to change the contents of the window provided to inflateBackInit(), which is also the buffer that out() uses to write from. The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in(). For convenience, inflateBack() can be provided input on the first call by setting strm->next_in and strm->avail_in. If that input is exhausted, then in() will be called. Therefore strm->next_in must be initialized before calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will initially be taken from strm->next_in[0 .. strm->avail_in - 1]. The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These descriptors can be optionally used to pass any information that the caller- supplied in() and out() functions need to do their job. On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR if in() or out() returned an error, Z_DATA_ERROR if there was a format error in the deflate stream (in which case strm->msg is set to indicate the nature of the error), or Z_STREAM_ERROR if the stream was not properly initialized. In the case of Z_BUF_ERROR, an input or output error can be distinguished using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK. */ ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); /* All memory allocated by inflateBackInit() is freed. inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream state was inconsistent. */ ZEXTERN uLong ZEXPORT zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 1.0: size of uInt 3.2: size of uLong 5.4: size of voidpf (pointer) 7.6: size of z_off_t Compiler, assembler, and debug options: 8: ZLIB_DEBUG 9: ASMV or ASMINF -- use ASM code 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) Library content (indicates missing functionality): 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking deflate code when not needed) 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect and decode gzip streams (to avoid linking crc code) 18-19: 0 (reserved) Operation variations (changes in library functionality): 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 21: FASTEST -- deflate algorithm with only one, lowest compression level 22,23: 0 (reserved) The sprintf variant used by gzprintf (zero is best): 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 26: 0 = returns value, 1 = void -- 1 means inferred string length returned Remainder: 27-31: 0 (reserved) */ #ifndef Z_SOLO /* utility functions */ /* The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can be modified if you need special options. */ ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed data. compress() is equivalent to compress2() with a level parameter of Z_DEFAULT_COMPRESSION. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed data. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the uncompressed data. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In the case where there is not enough room, uncompress() will fill the output buffer with the uncompressed data up to that point. */ ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of source bytes consumed. */ /* gzip file access functions */ /* This library supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio, using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. */ typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); Open the gzip (.gz) file at path for reading and decompressing, or compressing and writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression as in "wb9F". (See the description of deflateInit2 for more information about the strategy parameter.) 'T' will request transparent writing or appending with no compression and not using the gzip format. "a" can be used instead of "w" to request that the gzip stream that will be written be appended to the file. "+" will result in an error, since reading and writing to the same gzip file is not supported. The addition of "x" when writing will create the file exclusively, which fails if the file already exists. On systems that support it, the addition of "e" when reading or writing will set the flag to close the file on an execve() call. These functions, as well as gzip, will read and decode a sequence of gzip streams in a file. The append function of gzopen() can be used to create such a file. (Also see gzflush() for another way to do this.) When appending, gzopen does not test whether the file begins with a gzip stream, nor does it look for the end of the gzip streams to begin appending. gzopen will simply append a gzip stream to the existing file. gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. When reading, this will be detected automatically by looking for the magic two- byte gzip header. gzopen returns NULL if the file could not be opened, if there was insufficient memory to allocate the gzFile state, or if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). errno can be checked to determine if the reason gzopen failed was that the file could not be opened. */ ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); /* Associate a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, mode);. The duplicated descriptor should be saved to avoid a leak, since gzdopen does not close fd if it fails. If you are using fileno() to get the file descriptor from a FILE *, then you will have to use dup() to avoid double-close()ing the file descriptor. Both gzclose() and fclose() will close the associated file descriptor, so they need to have different file descriptors. gzdopen returns NULL if there was insufficient memory to allocate the gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided), or if fd is -1. The file descriptor is not used until the next gz* read, write, seek, or close operation, so gzdopen will not detect if fd is invalid (unless fd is -1). */ ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); /* Set the internal buffer size used by this library's functions for file to size. The default buffer size is 8192 bytes. This function must be called after gzopen() or gzdopen(), and before any other calls that read or write the file. The buffer memory allocation is always deferred to the first read or write. Three times that size in buffer space is allocated. A larger buffer size of, for example, 64K or 128K bytes will noticeably increase the speed of decompression (reading). The new buffer size also affects the maximum length for gzprintf(). gzbuffer() returns 0 on success, or -1 on failure, such as being called too late. */ ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); /* Dynamically update the compression level and strategy for file. See the description of deflateInit2 for the meaning of these parameters. Previously provided data is flushed before applying the parameter changes. gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not opened for writing, Z_ERRNO if there is an error writing the flushed data, or Z_MEM_ERROR if there is a memory allocation error. */ ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); /* Read and decompress up to len uncompressed bytes from file into buf. If the input file is not in gzip format, gzread copies the given number of bytes into the buffer directly from the file. After reaching the end of a gzip stream in the input, gzread will continue to read, looking for another gzip stream. Any number of gzip streams may be concatenated in the input file, and will all be decompressed by gzread(). If something other than a gzip stream is encountered after a gzip stream, that remaining trailing garbage is ignored (and no error is returned). gzread can be used to read a gzip file that is being concurrently written. Upon reaching the end of the input, gzread will return with the available data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then gzclearerr can be used to clear the end of file indicator in order to permit gzread to be tried again. Z_OK indicates that a gzip stream was completed on the last gzread. Z_BUF_ERROR indicates that the input file ended in the middle of a gzip stream. Note that gzread does not return -1 in the event of an incomplete gzip stream. This error is deferred until gzclose(), which will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip stream. Alternatively, gzerror can be used before gzclose to detect this case. gzread returns the number of uncompressed bytes actually read, less than len for end of file, or -1 for error. If len is too large to fit in an int, then nothing is read, -1 is returned, and the error state is set to Z_STREAM_ERROR. */ ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file); /* Read and decompress up to nitems items of size size from file into buf, otherwise operating as gzread() does. This duplicates the interface of stdio's fread(), with size_t request and return types. If the library defines size_t, then z_size_t is identical to size_t. If not, then z_size_t is an unsigned integer type that can contain a pointer. gzfread() returns the number of full items read of size size, or zero if the end of the file was reached and a full item could not be read, or if there was an error. gzerror() must be consulted if zero is returned in order to determine if there was an error. If the multiplication of size and nitems overflows, i.e. the product does not fit in a z_size_t, then nothing is read, zero is returned, and the error state is set to Z_STREAM_ERROR. In the event that the end of file is reached and only a partial item is available at the end, i.e. the remaining uncompressed data length is not a multiple of size, then the final partial item is nevertheless read into buf and the end-of-file flag is set. The length of the partial item read is not provided, but could be inferred from the result of gztell(). This behavior is the same as the behavior of fread() implementations in common libraries, but it prevents the direct use of gzfread() to read a concurrently written file, resetting and retrying on end-of-file, when size is not 1. */ ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); /* Compress and write the len uncompressed bytes at buf to file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, gzFile file); /* Compress and write nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. If the library defines size_t, then z_size_t is identical to size_t. If not, then z_size_t is an unsigned integer type that can contain a pointer. gzfwrite() returns the number of full items written of size size, or zero if there was an error. If the multiplication of size and nitems overflows, i.e. the product does not fit in a z_size_t, then nothing is written, zero is returned, and the error state is set to Z_STREAM_ERROR. */ ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); /* Convert, format, compress, and write the arguments (...) to file under control of the string format, as in fprintf. gzprintf returns the number of uncompressed bytes actually written, or a negative zlib error code in case of error. The number of uncompressed bytes written is limited to 8191, or one less than the buffer size given to gzbuffer(). The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if zlib was compiled with the insecure functions sprintf() or vsprintf(), because the secure snprintf() or vsnprintf() functions were not available. This can be determined using zlibCompileFlags(). */ ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); /* Compress and write the given null-terminated string s to file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); /* Read and decompress bytes from file into buf, until len-1 characters are read, or until a newline character is read and transferred to buf, or an end-of-file condition is encountered. If any characters are read or if len is one, the string is terminated with a null character. If no characters are read due to an end-of-file or len is less than one, then the buffer is left untouched. gzgets returns buf which is a null-terminated string, or it returns NULL for end-of-file or in case of error. If there was an error, the contents at buf are indeterminate. */ ZEXTERN int ZEXPORT gzputc(gzFile file, int c); /* Compress and write c, converted to an unsigned char, into file. gzputc returns the value that was written, or -1 in case of error. */ ZEXTERN int ZEXPORT gzgetc(gzFile file); /* Read and decompress one byte from file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. As such, it does not do all of the checking the other functions do. I.e. it does not check to see if file is NULL, nor whether the structure file points to has been clobbered or not. */ ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); /* Push c back onto the stream for file to be read as the first character on the next read. At least one character of push-back is always allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if c is -1, and may fail if a character has been pushed but not read yet. If gzungetc is used immediately after gzopen or gzdopen, at least the output buffer size of pushed characters is allowed. (See gzbuffer above.) The pushed character will be discarded if the stream is repositioned with gzseek() or gzrewind(). */ ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); /* Flush all pending output to file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush is only permitted when writing. If the flush parameter is Z_FINISH, the remaining data is written and the gzip stream is completed in the output. If gzwrite() is called again, a new gzip stream will be started in the output. gzread() is able to read such concatenated gzip streams. gzflush should be called only when strictly necessary because it will degrade compression if called too often. */ /* ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence); Set the starting position to offset relative to whence for the next gzread or gzwrite on file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. */ ZEXTERN int ZEXPORT gzrewind(gzFile file); /* Rewind file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). */ /* ZEXTERN z_off_t ZEXPORT gztell(gzFile file); Return the starting position for the next gzread or gzwrite on file. This position represents a number of bytes in the uncompressed data stream, and is zero when starting, even if appending or reading a gzip stream from the middle of a file using gzdopen(). gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ /* ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); Return the current compressed (actual) read or write offset of file. This offset includes the count of bytes that precede the gzip stream, for example when appending or when using gzdopen() for reading. When reading, the offset does not include as yet unused buffered input. This information can be used for a progress indicator. On error, gzoffset() returns -1. */ ZEXTERN int ZEXPORT gzeof(gzFile file); /* Return true (1) if the end-of-file indicator for file has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set only if the read tried to go past the end of the input, but came up short. Therefore, just like feof(), gzeof() may return false even if there is no more data to read, in the event that the last read request was for the exact number of bytes remaining in the input file. This will happen if the input file size is an exact multiple of the buffer size. If gzeof() returns true, then the read functions will return no more data, unless the end-of-file indicator is reset by gzclearerr() and the input file has grown since the previous end of file was detected. */ ZEXTERN int ZEXPORT gzdirect(gzFile file); /* Return true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. If the input file is empty, gzdirect() will return true, since the input does not contain a gzip stream. If gzdirect() is used immediately after gzopen() or gzdopen() it will cause buffers to be allocated to allow reading the file to determine if it is a gzip file. Therefore if gzbuffer() is used, it should be called before gzdirect(). When writing, gzdirect() returns true (1) if transparent writing was requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: gzdirect() is not needed when writing. Transparent writing must be explicitly requested, so the application already knows the answer. When linking statically, using gzdirect() will include all of the zlib code for gzip file reading and decompression, which may not be desired.) */ ZEXTERN int ZEXPORT gzclose(gzFile file); /* Flush all pending output for file, if necessary, close file and deallocate the (de)compression state. Note that once file is closed, you cannot call gzerror with file, since its structures have been deallocated. gzclose must not be called more than once on the same file, just as free must not be called more than once on the same allocation. gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the last read ended in the middle of a gzip stream, or Z_OK on success. */ ZEXTERN int ZEXPORT gzclose_r(gzFile file); ZEXTERN int ZEXPORT gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to using these instead of gzclose() is that they avoid linking in zlib compression or decompression code that is not used when only reading or only writing respectively. If gzclose() is used, then both compression and decompression code will be included the application when linking to a static zlib library. */ ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); /* Return the error message for the last error which occurred on file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. The application must not modify the returned string. Future calls to this function may invalidate the previously returned string. If file is closed, then the string previously returned by gzerror will no longer be available. gzerror() should be used to distinguish errors from end-of-file for those functions above that do not distinguish those cases in their return values. */ ZEXTERN void ZEXPORT gzclearerr(gzFile file); /* Clear the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ #endif /* !Z_SOLO */ /* checksum functions */ /* These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library. */ ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. An Adler-32 value is in the range of a 32-bit unsigned integer. If buf is Z_NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len); /* Same as adler32(), but with a size_t length. */ /* ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note that the z_off_t type (like off_t) is a signed integer. If len2 is negative, the result has no meaning or utility. */ ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. If buf is Z_NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, z_size_t len); /* Same as crc32(), but with a size_t length. */ /* ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2. len2 must be non-negative. */ /* ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); Return the operator corresponding to length len2, to be used with crc32_combine_op(). len2 must be non-negative. */ ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); /* Give the same result as crc32_combine(), using op in place of len2. op is is generated from len2 by crc32_combine_gen(). This will be faster than crc32_combine() if the generated op is used more than once. */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size); ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size); ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size); ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size); ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size); #ifdef Z_PREFIX_SET # define z_deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) # define z_inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) # define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) # define z_inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ (int)sizeof(z_stream)) # define z_inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, (int)sizeof(z_stream)) #else # define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) # define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) # define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) # define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ (int)sizeof(z_stream)) # define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, (int)sizeof(z_stream)) #endif #ifndef Z_SOLO /* gzgetc() macro and its supporting function and exposed data structure. Note * that the real internal state is much larger than the exposed structure. * This abbreviated structure exposes just enough for the gzgetc() macro. The * user should not mess with these exposed elements, since their names or * behavior could change in the future, perhaps even capriciously. They can * only be used by the gzgetc() macro. You have been warned. */ struct gzFile_s { unsigned have; unsigned char *next; z_off64_t pos; }; ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ #ifdef Z_PREFIX_SET # undef z_gzgetc # define z_gzgetc(g) \ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) #else # define gzgetc(g) \ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) #endif /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if * both are true, the application gets the *64 functions, and the regular * functions are changed to 64 bits) -- in case these are set on systems * without large file support, _LFS64_LARGEFILE must also be true */ #ifdef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) # ifdef Z_PREFIX_SET # define z_gzopen z_gzopen64 # define z_gzseek z_gzseek64 # define z_gztell z_gztell64 # define z_gzoffset z_gzoffset64 # define z_adler32_combine z_adler32_combine64 # define z_crc32_combine z_crc32_combine64 # define z_crc32_combine_gen z_crc32_combine_gen64 # else # define gzopen gzopen64 # define gzseek gzseek64 # define gztell gztell64 # define gzoffset gzoffset64 # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 # define crc32_combine_gen crc32_combine_gen64 # endif # ifndef Z_LARGE64 ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); ZEXTERN z_off_t ZEXPORT gztell64(gzFile); ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); # endif #else ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); ZEXTERN z_off_t ZEXPORT gztell(gzFile); ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif #else /* Z_SOLO */ ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif /* !Z_SOLO */ /* undocumented functions */ ZEXTERN const char * ZEXPORT zError(int); ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); #if defined(_WIN32) && !defined(Z_SOLO) ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode); #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va); # endif #endif #ifdef __cplusplus } #endif #endif /* ZLIB_H */chibicc-1.0.23.1/test/zutil.h000077500000000000000000000161041505335450300156270ustar00rootroot00000000000000/* zutil.h -- internal interface and configuration of the compression library * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef ZUTIL_H #define ZUTIL_H #ifdef HAVE_HIDDEN # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL #endif #include "zlib.h" #if defined(STDC) && !defined(Z_SOLO) # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) # include # endif # include # include #endif #ifndef local # define local static #endif /* since "static" is used to mean two completely different things in C, we define "local" for the non-static meaning of "static", for readability (compile with -Dlocal if your debugger can't find static symbols) */ typedef unsigned char uch; typedef uch FAR uchf; typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; #if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC) # include # if (ULONG_MAX == 0xffffffffffffffff) # define Z_U8 unsigned long # elif (ULLONG_MAX == 0xffffffffffffffff) # define Z_U8 unsigned long long # elif (UINT_MAX == 0xffffffffffffffff) # define Z_U8 unsigned # endif #endif extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ /* common constants */ #ifndef DEF_WBITS # define DEF_WBITS MAX_WBITS #endif /* default windowBits for decompression. MAX_WBITS is for compression only */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default memLevel */ #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 /* The three kinds of block type */ #define MIN_MATCH 3 #define MAX_MATCH 258 /* The minimum and maximum match lengths */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ /* target dependencies */ #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) # define OS_CODE 0x00 # ifndef Z_SOLO # if defined(__TURBOC__) || defined(__BORLANDC__) # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) /* Allow compilation with ANSI keywords only enabled */ void _Cdecl farfree( void *block ); void *_Cdecl farmalloc( unsigned long nbytes ); # else # include # endif # else /* MSC or DJGPP */ # include # endif # endif #endif #ifdef AMIGA # define OS_CODE 1 #endif #if defined(VAXC) || defined(VMS) # define OS_CODE 2 # define F_OPEN(name, mode) \ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #ifdef __370__ # if __TARGET_LIB__ < 0x20000000 # define OS_CODE 4 # elif __TARGET_LIB__ < 0x40000000 # define OS_CODE 11 # else # define OS_CODE 8 # endif #endif #if defined(ATARI) || defined(atarist) # define OS_CODE 5 #endif #ifdef OS2 # define OS_CODE 6 # if defined(M_I86) && !defined(Z_SOLO) # include # endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 7 # ifndef Z_SOLO # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include /* for fdopen */ # else # ifndef fdopen # define fdopen(fd,mode) NULL /* No fdopen() */ # endif # endif # endif #endif #ifdef __acorn # define OS_CODE 13 #endif #if defined(WIN32) && !defined(__CYGWIN__) # define OS_CODE 10 #endif #ifdef _BEOS_ # define OS_CODE 16 #endif #ifdef __TOS_OS400__ # define OS_CODE 18 #endif #ifdef __APPLE__ # define OS_CODE 19 #endif #if defined(_BEOS_) || defined(RISCOS) # define fdopen(fd,mode) NULL /* No fdopen() */ #endif #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX # if defined(_WIN32_WCE) # define fdopen(fd,mode) NULL /* No fdopen() */ # else # define fdopen(fd,type) _fdopen(fd,type) # endif #endif #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 #pragma warn -8066 #endif /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); #endif /* common defaults */ #ifndef OS_CODE # define OS_CODE 3 /* assume Unix */ #endif #ifndef F_OPEN # define F_OPEN(name, mode) fopen((name), (mode)) #endif /* functions */ #if defined(pyr) || defined(Z_SOLO) # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) /* Use our own functions for small and medium model with MSC <= 5.0. * You may have to use the same strategy for Borland C (untested). * The __SC__ check is for Symantec. */ # define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_MEMCPY #endif #ifdef HAVE_MEMCPY # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ # define zmemcpy _fmemcpy # define zmemcmp _fmemcmp # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy memcpy # define zmemcmp memcmp # define zmemzero(dest, len) memset(dest, 0, len) # endif #else void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); #endif /* Diagnostic functions */ #ifdef ZLIB_DEBUG # include extern int ZLIB_INTERNAL z_verbose; extern void ZLIB_INTERNAL z_error OF((char *m)); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracevv(x) {if (z_verbose>1) fprintf x ;} # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else # define Assert(cond,msg) # define Trace(x) # define Tracev(x) # define Tracevv(x) # define Tracec(c,x) # define Tracecv(c,x) #endif #ifndef Z_SOLO voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, unsigned size)); void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); #endif #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} /* Reverse the bytes in a 32-bit value */ #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) #endif /* ZUTIL_H */ chibicc-1.0.23.1/tokenize.c000077500000000000000000000627631505335450300153400ustar00rootroot00000000000000#include "chibicc.h" #define TOKENIZE_C "tokenize.c" // Define the ANSI color codes #define RED "\033[31m" #define RESET "\033[0m" // Length of the color codes #define PURPLE "\033[0;35m" #define RED_LEN 5 // \033[31m #define RESET_LEN 4 // \033[0m #define PURPLE_LEN 7 // Input file static File *current_file; // A list of all input files. static File **input_files; // True if the current position is at the beginning of a line static bool at_bol; // True if the current position follows a space character static bool has_space; //static Token *read_pragma(Token *cur, char **rest, char *start); // Reports an error and exit. void error(char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); va_end(ap); exit(1); } // Reports an error message in the following format. // // foo.c:10: x = y + 1; // ^ static void verror_at(char *filename, char *input, unsigned int line_no, char *loc, char *fmt, va_list ap) { // Find a line containing `loc`. char *line = loc; while (input < line && line[-1] != '\n') line--; char *end = loc; while (*end && *end != '\n') end++; // Print out the line. int indent = fprintf(stderr, "%s:%u: " RED "error:" RESET " ", filename, line_no); fprintf(stderr, "%.*s\n", (int)(end - line), line); // Show the error message. int pos = display_width(line, loc - line) + indent; fprintf(stderr, "%*s", pos - (RED_LEN + RESET_LEN), ""); // print pos spaces, adjusting for color codes fprintf(stderr, RED "^" RESET " "); // Print caret in red vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); } void error_at(char *loc, char *fmt, ...) { unsigned int line_no = 1; for (char *p = current_file->contents; p < loc; p++) if (*p == '\n') line_no++; va_list ap; va_start(ap, fmt); verror_at(current_file->name, current_file->contents, line_no, loc, fmt, ap); va_end(ap); exit(1); } void error_tok(Token *tok, char *fmt, ...) { va_list ap; va_start(ap, fmt); verror_at(tok->file->name, tok->file->contents, tok->line_no, tok->loc, fmt, ap); va_end(ap); exit(1); } //to print warning message in purple color static void vwarning_at(char *filename, char *input, unsigned int line_no, char *loc, char *fmt, va_list ap) { // Find a line containing `loc`. char *line = loc; while (input < line && line[-1] != '\n') line--; char *end = loc; while (*end && *end != '\n') end++; // Print out the line. int indent = fprintf(stderr, "%s:%u: " PURPLE "warning:" RESET " ", filename, line_no); fprintf(stderr, "%.*s\n", (int)(end - line), line); // Show the error message. int pos = display_width(line, loc - line) + indent; fprintf(stderr, "%*s", pos - (PURPLE_LEN + RESET_LEN), ""); // print pos spaces, adjusting for color codes fprintf(stderr, PURPLE "^" RESET " "); // Print caret in purple vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); } void warning_at(char *loc, char *fmt, ...) { unsigned int line_no = 1; for (char *p = current_file->contents; p < loc; p++) if (*p == '\n') line_no++; va_list ap; va_start(ap, fmt); vwarning_at(current_file->name, current_file->contents, line_no, loc, fmt, ap); va_end(ap); } void warn_tok(Token *tok, char *fmt, ...) { va_list ap; va_start(ap, fmt); vwarning_at(tok->file->name, tok->file->contents, tok->line_no, tok->loc, fmt, ap); va_end(ap); } // Consumes the current token if it matches `op`. bool equal(Token *tok, const char *op) { //return strncmp(tok->loc, op, tok->len) == 0 && op[tok->len] == '\0'; return tok->len == strlen(op) && strncmp(tok->loc, op, tok->len) == 0 && op[tok->len] == '\0'; } // Ensure that the current token is `op`. Token *skip(Token *tok, char *op, Context *ctx) { if (!equal(tok, op)) error_tok(tok, "%s %s %s %u: in skip : expected '%s'", TOKENIZE_C, ctx->filename, ctx->funcname, ctx->line_no, op ); return tok->next; } bool consume(Token **rest, Token *tok, char *str) { if (equal(tok, str)) { *rest = tok->next; return true; } *rest = tok; return false; } // Create a new token. static Token *new_token(TokenKind kind, char *start, char *end) { Token *tok = calloc(1, sizeof(Token)); if (tok == NULL) error("%s: in new_token tok is null!", TOKENIZE_C); tok->kind = kind; tok->loc = start; tok->len = end - start; tok->file = current_file; tok->filename = current_file->display_name; tok->at_bol = at_bol; tok->has_space = has_space; at_bol = has_space = false; return tok; } bool startswith(char *p, char *q) { return strncmp(p, q, strlen(q)) == 0; } // Read an identifier and returns the length of it. // If p does not point to a valid identifier, 0 is returned. static int read_ident(char *start, char *previous, bool isNotANumber) { char *p = start; uint32_t c = decode_utf8(&p, p); // allows identifier starting by a number if previous character was an hashtag if (*previous == '#' || isNotANumber) { if (!is_ident3(c)) return 0; } else { if (!is_ident1(c)) return 0; } for (;;) { char *q; c = decode_utf8(&q, p); if (!is_ident2(c)) return p - start; p = q; } } static int from_hex(char c) { if ('0' <= c && c <= '9') return c - '0'; if ('a' <= c && c <= 'f') return c - 'a' + 10; return c - 'A' + 10; } // Read a punctuator token from p and returns its length. static int read_punct(char *p) { static char *kw[] = { "<<=", ">>=", "...", "==", "!=", "<=", ">=", "->", "+=", "-=", "*=", "/=", "++", "--", "%=", "&=", "|=", "^=", "&&", "||", "<<", ">>", "##", }; for (int i = 0; i < sizeof(kw) / sizeof(*kw); i++) if (startswith(p, kw[i])) return strlen(kw[i]); return ispunct(*p) ? 1 : 0; } static bool is_keyword(Token *tok) { static HashMap map; if (map.capacity == 0) { static char *kw[] = { "return", "if", "else", "for", "while", "int", "sizeof", "char", "struct", "union", "short", "long", "void", "typedef", "_Bool", "enum", "static", "goto", "break", "continue", "switch", "case", "default", "extern", "_Alignof", "_Alignas", "do", "signed", "unsigned", "const", "volatile", "auto", "register", "restrict", "__restrict", "__restrict__", "_Noreturn", "float", "double", "typeof", "asm", "_Thread_local", "__thread", "_Atomic", "__attribute__", "__label__", "inline", "__int128", }; for (int i = 0; i < sizeof(kw) / sizeof(*kw); i++) hashmap_put(&map, kw[i], (void *)1); } return hashmap_get2(&map, tok->loc, tok->len); } static int read_escaped_char(char **new_pos, char *p) { if ('0' <= *p && *p <= '7') { // Read an octal number. int c = *p++ - '0'; if ('0' <= *p && *p <= '7') { c = (c << 3) + (*p++ - '0'); if ('0' <= *p && *p <= '7') c = (c << 3) + (*p++ - '0'); } *new_pos = p; return c; } if (*p == 'x') { // Read a hexadecimal number. p++; if (!isxdigit(*p)) error_at(p, "%s: in read_escaped_char : invalid hex escape sequence", TOKENIZE_C); int c = 0; for (; isxdigit(*p); p++) c = (c << 4) + from_hex(*p); *new_pos = p; return c; } *new_pos = p + 1; // Escape sequences are defined using themselves here. E.g. // '\n' is implemented using '\n'. This tautological definition // works because the compiler that compiles our compiler knows // what '\n' actually is. In other words, we "inherit" the ASCII // code of '\n' from the compiler that compiles our compiler, // so we don't have to teach the actual code here. // // This fact has huge implications not only for the correctness // of the compiler but also for the security of the generated code. // For more info, read "Reflections on Trusting Trust" by Ken Thompson. // https://github.com/rui314/chibicc/wiki/thompson1984.pdf switch (*p) { case 'a': return '\a'; case 'b': return '\b'; case 't': return '\t'; case 'n': return '\n'; case 'v': return '\v'; case 'f': return '\f'; case 'r': return '\r'; // [GNU] \e for the ASCII escape character is a GNU C extension. case 'e': return 27; default: return *p; } } // Find a closing double-quote. static char *string_literal_end(char *p) { char *start = p; for (; *p != '"'; p++) { if (*p == '\n' || *p == '\0') error_at(start, "%s %d: in string_literal_end : unclosed string literal", TOKENIZE_C, __LINE__); if (*p == '\\') p++; } return p; } static Token *read_string_literal(char *start, char *quote) { char *end = string_literal_end(quote + 1); char *buf = calloc(1, end - quote); if (buf == NULL) error("%s: %s:%d: error: in read_string_literal buf is null!", TOKENIZE_C, __FILE__, __LINE__); int len = 0; for (char *p = quote + 1; p < end;) { if (*p == '\\') buf[len++] = read_escaped_char(&p, p + 1); else buf[len++] = *p++; } Token *tok = new_token(TK_STR, start, end + 1); tok->ty = array_of(ty_char, len + 1); tok->str = buf; return tok; } // Read a UTF-8-encoded string literal and transcode it in UTF-16. // // UTF-16 is yet another variable-width encoding for Unicode. Code // points smaller than U+10000 are encoded in 2 bytes. Code points // equal to or larger than that are encoded in 4 bytes. Each 2 bytes // in the 4 byte sequence is called "surrogate", and a 4 byte sequence // is called a "surrogate pair". static Token *read_utf16_string_literal(char *start, char *quote) { char *end = string_literal_end(quote + 1); uint16_t *buf = calloc(2, end - start); if (buf == NULL) error("%s: %s:%d: error: in read_utf16_string_literal buf is null!", TOKENIZE_C, __FILE__, __LINE__); int len = 0; for (char *p = quote + 1; p < end;) { if (*p == '\\') { buf[len++] = read_escaped_char(&p, p + 1); continue; } uint32_t c = decode_utf8(&p, p); if (c < 0x10000) { // Encode a code point in 2 bytes. buf[len++] = c; } else { // Encode a code point in 4 bytes. c -= 0x10000; buf[len++] = 0xd800 + ((c >> 10) & 0x3ff); buf[len++] = 0xdc00 + (c & 0x3ff); } } Token *tok = new_token(TK_STR, start, end + 1); tok->ty = array_of(ty_ushort, len + 1); tok->str = (char *)buf; return tok; } // Read a UTF-8-encoded string literal and transcode it in UTF-32. // // UTF-32 is a fixed-width encoding for Unicode. Each code point is // encoded in 4 bytes. static Token *read_utf32_string_literal(char *start, char *quote, Type *ty) { char *end = string_literal_end(quote + 1); uint32_t *buf = calloc(4, end - quote); if (buf == NULL) error("%s: %s:%d: error: in read_utf32_string_literal buf is null!", TOKENIZE_C, __FILE__, __LINE__); int len = 0; for (char *p = quote + 1; p < end;) { if (*p == '\\') buf[len++] = read_escaped_char(&p, p + 1); else buf[len++] = decode_utf8(&p, p); } Token *tok = new_token(TK_STR, start, end + 1); tok->ty = array_of(ty, len + 1); tok->str = (char *)buf; return tok; } static Token *read_char_literal(char *start, char *quote, Type *ty) { char *p = quote + 1; if (*p == '\0') error_at(start, "%s: in read_char_literal : unclosed char literal", TOKENIZE_C); int c; if (*p == '\\') c = read_escaped_char(&p, p + 1); else c = decode_utf8(&p, p); char *end = strchr(p, '\''); if (!end) error_at(p, "%s: in read_char_literal : unclosed char literal", TOKENIZE_C); Token *tok = new_token(TK_NUM, start, end + 1); tok->val = c; tok->ty = ty; return tok; } // static bool convert_pp_int(Token *tok) // { // char *p = tok->loc; // // Read a binary, octal, decimal or hexadecimal number. // int base = 10; // if (!strncasecmp(p, "0x", 2) && isxdigit(p[2])) // { // p += 2; // base = 16; // } // else if (!strncasecmp(p, "0b", 2) && (p[2] == '0' || p[2] == '1')) // { // p += 2; // base = 2; // } // else if (*p == '0') // { // base = 8; // } // int64_t val = strtoul(p, &p, base); // // Read U, L or LL suffixes. // bool l = false; // bool u = false; // if (startswith(p, "LLU") || startswith(p, "LLu") || // startswith(p, "llU") || startswith(p, "llu") || // startswith(p, "ULL") || startswith(p, "Ull") || // startswith(p, "uLL") || startswith(p, "ull")) // { // p += 3; // l = u = true; // } // else if (!strncasecmp(p, "lu", 2) || !strncasecmp(p, "ul", 2)) // { // p += 2; // l = u = true; // } // else if (startswith(p, "LL") || startswith(p, "ll")) // { // p += 2; // l = true; // } // else if (*p == 'L' || *p == 'l') // { // p++; // l = true; // } // else if (*p == 'U' || *p == 'u') // { // p++; // u = true; // } // if (p != tok->loc + tok->len) // return false; // // Infer a type. // Type *ty; // if (base == 10) // { // if (l && u) // ty = ty_ulong; // else if (l) // ty = ty_long; // else if (u) // ty = (val >> 32) ? ty_ulong : ty_uint; // else // ty = (val >> 31) ? ty_long : ty_int; // } // else // { // if (l && u) // ty = ty_ulong; // else if (l) // ty = (val >> 63) ? ty_ulong : ty_long; // else if (u) // ty = (val >> 32) ? ty_ulong : ty_uint; // else if (val >> 63) // ty = ty_ulong; // else if (val >> 32) // ty = ty_long; // else if (val >> 31) // ty = ty_uint; // else // ty = ty_int; // } // tok->kind = TK_NUM; // tok->val = val; // tok->ty = ty; // return true; // } static bool convert_pp_int(Token *tok) { char *p = tok->loc; // Read a binary, octal, decimal or hexadecimal number. int base = 10; if (!strncasecmp(p, "0x", 2) && isxdigit(p[2])) { p += 2; base = 16; } else if (!strncasecmp(p, "0b", 2) && (p[2] == '0' || p[2] == '1')) { p += 2; base = 2; } else if (*p == '0') { base = 8; } int64_t val = strtoul(p, &p, base); // Read U, L or LL suffixes. bool ll = false; bool l = false; bool u = false; if (startswith(p, "LLU") || startswith(p, "LLu") || startswith(p, "llU") || startswith(p, "llu") || startswith(p, "ULL") || startswith(p, "Ull") || startswith(p, "uLL") || startswith(p, "ull")) { p += 3; ll = u = true; } else if (!strncasecmp(p, "lu", 2) || !strncasecmp(p, "ul", 2)) { p += 2; l = u = true; } else if (startswith(p, "LL") || startswith(p, "ll")) { p += 2; ll = true; } else if (*p == 'L' || *p == 'l') { p++; l = true; } else if (*p == 'U' || *p == 'u') { p++; u = true; } if (p != tok->loc + tok->len) return false; // Infer a type. Type *ty; if (base == 10) { if (ll && u) ty = ty_ullong; else if (l && u) ty = ty_ulong; else if (ll) ty = ty_llong; else if (l) ty = ty_long; else if (u) ty = (val >> 32) ? ty_ulong : ty_uint; else ty = (val >> 31) ? ty_long : ty_int; } else { if (ll && u) ty = ty_ullong; else if (l && u) ty = ty_ulong; else if (ll) ty = (val >> 63) ? ty_ullong : ty_llong; else if (l) ty = (val >> 63) ? ty_ulong : ty_long; else if (u) ty = (val >> 32) ? ty_ulong : ty_uint; else if (val >> 63) ty = ty_ulong; else if (val >> 32) ty = ty_long; else if (val >> 31) ty = ty_uint; else ty = ty_int; } tok->kind = TK_NUM; tok->val = val; tok->ty = ty; return true; } // The definition of the numeric literal at the preprocessing stage // is more relaxed than the definition of that at the later stages. // In order to handle that, a numeric literal is tokenized as a // "pp-number" token first and then converted to a regular number // token after preprocessing. // // This function converts a pp-number token to a regular number token. static void convert_pp_number(Token *tok) { // Try to parse as an integer constant. if (convert_pp_int(tok)) return; // If it's not an integer, it must be a floating point constant. char *end; long double val = strtold(tok->loc, &end); Type *ty; if (*end == 'f' || *end == 'F') { ty = ty_float; end++; } else if (*end == 'l' || *end == 'L') { ty = ty_ldouble; end++; } else { ty = ty_double; } if (tok->loc + tok->len != end) error_tok(tok, "%s: in convert_pp_number : invalid numeric constant", TOKENIZE_C); tok->kind = TK_NUM; tok->fval = val; tok->ty = ty; } void convert_pp_tokens(Token *tok) { for (Token *t = tok; t->kind != TK_EOF; t = t->next) { if (is_keyword(t)) t->kind = TK_KEYWORD; else if (t->kind == TK_PP_NUM) convert_pp_number(t); } } // Initialize line info for all tokens. static void add_line_numbers(Token *tok) { char *p = current_file->contents; unsigned int n = 1; do { if (p == tok->loc) { tok->line_no = n; tok = tok->next; } if (*p == '\n') n++; } while (*p++); } Token *tokenize_string_literal(Token *tok, Type *basety) { Token *t; if (basety->size == 2) t = read_utf16_string_literal(tok->loc, tok->loc); else t = read_utf32_string_literal(tok->loc, tok->loc, basety); t->next = tok->next; return t; } // Tokenize a given string and returns new tokens. Token *tokenize(File *file) { current_file = file; char *p = file->contents; Token head = {}; Token *cur = &head; bool isNotANumber = false; at_bol = true; has_space = false; while (*p) { // Skip line comments. if (startswith(p, "//")) { p += 2; //while (*p != '\n') while (*p && *p != '\n') p++; has_space = true; continue; } // Skip block comments. if (startswith(p, "/*")) { char *q = strstr(p + 2, "*/"); if (!q) error_at(p, "%s: in tokenize : unclosed block comment", TOKENIZE_C); p = q + 2; has_space = true; continue; } // Skip newline. if (*p == '\n') { p++; at_bol = true; has_space = false; continue; } // Skip whitespace characters. if (isspace(*p)) { p++; has_space = true; continue; } // to manage particular cases see issue 116, 117, 118 char *previous = p; char *current = p; if (p != file->contents) previous = p - 1; // Numeric literal // to fix issue #117, checking that previous character is not an hashtag! if ((isdigit(*p) || (*p == '.' && isdigit(p[1]))) && *(previous) != '#') { char *q = p++; for (;;) { if (p[0] && p[1] && strchr("eEpP", p[0]) && strchr("+-", p[1])) p += 2; else if (isalnum(*p) || *p == '.') p++; else break; } // fixing issue #116 with wrong number detected 1024_160 was considered as number 1024 and other token _160! if (*p != '_') { cur = cur->next = new_token(TK_PP_NUM, q, p); continue; } else { p = current; isNotANumber = true; } } // String literal if (*p == '"') { cur = cur->next = read_string_literal(p, p); p += cur->len; continue; } // UTF-8 string literal if (startswith(p, "u8\"")) { cur = cur->next = read_string_literal(p, p + 2); p += cur->len; continue; } // UTF-16 string literal if (startswith(p, "u\"")) { cur = cur->next = read_utf16_string_literal(p, p + 1); p += cur->len; continue; } // Wide string literal if (startswith(p, "L\"")) { cur = cur->next = read_utf32_string_literal(p, p + 1, ty_int); p += cur->len; continue; } // UTF-32 string literal if (startswith(p, "U\"")) { cur = cur->next = read_utf32_string_literal(p, p + 1, ty_uint); p += cur->len; continue; } // Character literal if (*p == '\'') { cur = cur->next = read_char_literal(p, p, ty_int); cur->val = (char)cur->val; p += cur->len; continue; } // UTF-16 character literal if (startswith(p, "u'")) { cur = cur->next = read_char_literal(p, p + 1, ty_ushort); cur->val &= 0xffff; p += cur->len; continue; } // Wide character literal if (startswith(p, "L'")) { cur = cur->next = read_char_literal(p, p + 1, ty_int); p += cur->len; continue; } // UTF-32 character literal if (startswith(p, "U'")) { cur = cur->next = read_char_literal(p, p + 1, ty_uint); p += cur->len; continue; } // Identifier or keyword int ident_len = read_ident(p, previous, isNotANumber); if (ident_len) { cur = cur->next = new_token(TK_IDENT, p, p + ident_len); p += cur->len; continue; } // Punctuators int punct_len = read_punct(p); if (punct_len) { cur = cur->next = new_token(TK_PUNCT, p, p + punct_len); p += cur->len; continue; } error_at(p, "%s: in tokenize : invalid token", TOKENIZE_C); } cur = cur->next = new_token(TK_EOF, p, p); add_line_numbers(head.next); // for debug needs print all the tokens with values if (printTokens && f != NULL) print_debug_tokens(TOKENIZE_C, "tokenize", head.next); return head.next; } // Returns the contents of a given file. static char *read_file(char *path) { FILE *fp; if (strcmp(path, "-") == 0) { // By convention, read from stdin if a given filename is "-". fp = stdin; } else { fp = fopen(path, "r"); if (!fp) return NULL; } char *buf; size_t buflen; FILE *out = open_memstream(&buf, &buflen); // Read the entire file. for (;;) { char buf2[4096]; int n = fread(buf2, 1, sizeof(buf2), fp); if (n == 0) break; fwrite(buf2, 1, n, out); } if (fp != stdin) fclose(fp); // Make sure that the last line is properly terminated with '\n'. fflush(out); if (buflen == 0 || buf[buflen - 1] != '\n') fputc('\n', out); fputc('\0', out); fclose(out); return buf; } File **get_input_files(void) { return input_files; } File *new_file(char *name, unsigned int file_no, char *contents) { File *file = calloc(1, sizeof(File)); if (file == NULL) error("%s: %s:%d: error: in new_file file is null!", TOKENIZE_C, __FILE__, __LINE__); file->name = name; file->display_name = name; file->file_no = file_no; file->contents = contents; return file; } // Replaces \r or \r\n with \n. static void canonicalize_newline(char *p) { int i = 0, j = 0; while (p[i]) { if (p[i] == '\r' && p[i + 1] == '\n') { i += 2; p[j++] = '\n'; } else if (p[i] == '\r') { i++; p[j++] = '\n'; } else { p[j++] = p[i++]; } } p[j] = '\0'; } // Removes backslashes followed by a newline. static void remove_backslash_newline(char *p) { int i = 0, j = 0; // We want to keep the number of newline characters so that // the logical line number matches the physical one. // This counter maintain the number of newlines we have removed. int n = 0; while (p[i]) { if (p[i] == '\\' && p[i + 1] == '\n') { i += 2; n++; } else if (p[i] == '\n') { p[j++] = p[i++]; for (; n > 0; n--) p[j++] = '\n'; } else { p[j++] = p[i++]; } } for (; n > 0; n--) p[j++] = '\n'; p[j] = '\0'; } static uint32_t read_universal_char(char *p, int len) { uint32_t c = 0; for (int i = 0; i < len; i++) { if (!isxdigit(p[i])) return 0; c = (c << 4) | from_hex(p[i]); } return c; } // Replace \u or \U escape sequences with corresponding UTF-8 bytes. static void convert_universal_chars(char *p) { char *q = p; while (*p) { if (startswith(p, "\\u")) { uint32_t c = read_universal_char(p + 2, 4); if (c) { p += 6; q += encode_utf8(q, c); } else { *q++ = *p++; } } else if (startswith(p, "\\U")) { uint32_t c = read_universal_char(p + 2, 8); if (c) { p += 10; q += encode_utf8(q, c); } else { *q++ = *p++; } } else if (p[0] == '\\') { *q++ = *p++; *q++ = *p++; } else { *q++ = *p++; } } *q = '\0'; } Token *tokenize_file(char *path) { char *p = read_file(path); if (!p) return NULL; // UTF-8 texts may start with a 3-byte "BOM" marker sequence. // If exists, just skip them because they are useless bytes. // (It is actually not recommended to add BOM markers to UTF-8 // texts, but it's not uncommon particularly on Windows.) if (!memcmp(p, "\xef\xbb\xbf", 3)) p += 3; canonicalize_newline(p); remove_backslash_newline(p); convert_universal_chars(p); // Save the filename for assembler .file directive. static unsigned int file_no; File *file = new_file(path, file_no + 1, p); // Save the filename for assembler .file directive. input_files = realloc(input_files, sizeof(char *) * (file_no + 2)); if (input_files == NULL) error("%s: %s:%d: error: in tokenize_file input_files is null!", TOKENIZE_C, __FILE__, __LINE__); input_files[file_no] = file; input_files[file_no + 1] = NULL; file_no++; return tokenize(file); } chibicc-1.0.23.1/type.c000077500000000000000000000573321505335450300144650ustar00rootroot00000000000000#include "chibicc.h" #define TYPE_C "type.c" Type *ty_void = &(Type){TY_VOID, 1, 1}; Type *ty_bool = &(Type){TY_BOOL, 1, 1, true}; Type *ty_char = &(Type){TY_CHAR, 1, 1}; Type *ty_short = &(Type){TY_SHORT, 2, 2}; Type *ty_int = &(Type){TY_INT, 4, 4}; Type *ty_long = &(Type){TY_LONG, 8, 8}; Type *ty_uchar = &(Type){TY_CHAR, 1, 1, true}; Type *ty_ushort = &(Type){TY_SHORT, 2, 2, true}; Type *ty_uint = &(Type){TY_INT, 4, 4, true}; Type *ty_ulong = &(Type){TY_LONG, 8, 8, true}; Type *ty_llong = &(Type){TY_LLONG, 8, 8}; Type *ty_ullong = &(Type){TY_LLONG, 8, 8, true}; Type *ty_float = &(Type){TY_FLOAT, 4, 4}; Type *ty_double = &(Type){TY_DOUBLE, 8, 8}; Type *ty_ldouble = &(Type){TY_LDOUBLE, 16, 16}; Type *ty_void_ptr = &(Type){TY_PTR, 8, 8, true}; Type *ty_int128 = &(Type){TY_INT128, 16, 16}; Type *ty_uint128 = &(Type){TY_INT128, 16, 16, true}; static Type *new_type(TypeKind kind, int size, int align) { Type *ty = calloc(1, sizeof(Type)); if (ty == NULL) error("%s: %s:%d: error: in new_type ty is null!", TYPE_C, __FILE__, __LINE__); ty->kind = kind; ty->size = size; ty->align = align; if (ty->kind == TY_INT128) ty->is_aligned = true; return ty; } Type *new_qualified_type(Type *ty) { if (ty->origin) ty = ty->origin; Type *ret = calloc(1, sizeof(Type)); *ret = *ty; ret->origin = ty; if (ty->size < 0) { ret->decl_next = ty->decl_next; ty->decl_next = ret; } return ret; } bool is_integer(Type *ty) { TypeKind k = ty->kind; return k == TY_BOOL || k == TY_CHAR || k == TY_SHORT || k == TY_INT128 || k == TY_INT || k == TY_LONG || k == TY_LLONG || k == TY_ENUM; } bool is_flonum(Type *ty) { return ty->kind == TY_FLOAT || ty->kind == TY_DOUBLE || ty->kind == TY_LDOUBLE; } bool is_array(Type *ty) { return ty->kind == TY_ARRAY || ty->kind == TY_VLA; } bool is_bitfield(Node *node) { return node->kind == ND_MEMBER && node->member->is_bitfield; } // static bool is_bitfield2(Node *node, int *width) { // switch (node->kind) { // case ND_ASSIGN: // return is_bitfield2(node->lhs, width); // case ND_COMMA: // return is_bitfield2(node->rhs, width); // case ND_STMT_EXPR: { // Node *stmt = node->body; // while (stmt->next) // stmt = stmt->next; // if (stmt->kind == ND_EXPR_STMT) // return is_bitfield2(stmt->lhs, width); // } // case ND_MEMBER: // if (!node->member->is_bitfield) // return false; // *width = node->member->bit_width; // return true; // } // return false; // } int int_rank(Type *t) { switch (t->kind) { case TY_ENUM: case TY_BOOL: case TY_CHAR: case TY_SHORT: return 0; case TY_INT: return 1; case TY_LONG: return 2; case TY_LLONG: return 3; } printf("======%d\n", t->kind); unreachable(); } static void int_promotion(Node **node) { Type *ty = (*node)->ty; if (is_bitfield(*node)) { int int_width = ty_int->size * 8; int bit_width = (*node)->member->bit_width; if (bit_width == int_width && ty->is_unsigned) { *node = new_cast(*node, ty_uint); } else if (bit_width <= int_width) { *node = new_cast(*node, ty_int); } else { *node = new_cast(*node, ty); } return; } if (ty->size < ty_int->size) { *node = new_cast(*node, ty_int); return; } if (ty->size == ty_int->size && int_rank(ty) < int_rank(ty_int)) { if (ty->is_unsigned) *node = new_cast(*node, ty_uint); else *node = new_cast(*node, ty_int); return; } } bool is_numeric(Type *ty) { return is_integer(ty) || is_flonum(ty); } bool is_compatible(Type *t1, Type *t2) { if (t1 == t2) return true; if (t1->origin) return is_compatible(t1->origin, t2); if (t2->origin) return is_compatible(t1, t2->origin); if (t1->kind != t2->kind) return false; if ((t1->kind == TY_VLA && t2->kind == TY_VLA) || (t1->kind == TY_VLA && t2->kind == TY_ARRAY) || (t1->kind == TY_ARRAY && t2->kind == TY_VLA)) return is_compatible(t1->base, t2->base); if(is_vector(t1) && is_vector(t2)) return is_compatible(t1->base, t2->base); switch (t1->kind) { case TY_CHAR: case TY_SHORT: case TY_INT: case TY_LONG: case TY_LLONG: return t1->is_unsigned == t2->is_unsigned; case TY_FLOAT: case TY_DOUBLE: case TY_LDOUBLE: return true; case TY_INT128: return t1->is_unsigned == t2->is_unsigned; case TY_PTR: return is_compatible(t1->base, t2->base); case TY_FUNC: { if (!is_compatible(t1->return_ty, t2->return_ty)) return false; if (t1->is_variadic != t2->is_variadic) return false; Type *p1 = t1->params; Type *p2 = t2->params; for (; p1 && p2; p1 = p1->next, p2 = p2->next) if (!is_compatible(p1, p2)) return false; return p1 == NULL && p2 == NULL; } case TY_ARRAY: if (!is_compatible(t1->base, t2->base)) return false; return t1->array_len < 0 && t2->array_len < 0 && t1->array_len == t2->array_len; case TY_VECTOR: if (!is_compatible(t1->base, t2->base)) return false; return t1->array_len < 0 && t2->array_len < 0 && t1->array_len == t2->array_len; } return false; } Type *copy_type(Type *ty) { Type *ret = calloc(1, sizeof(Type)); if (ret == NULL) error("%s: %s:%d: error: in copy_type ret is null!", TYPE_C, __FILE__, __LINE__); *ret = *ty; ret->origin = ty; return ret; } Type *pointer_to(Type *base) { Type *ty = new_type(TY_PTR, 8, 8); ty->base = base; ty->is_pointer = true; ty->pointertype = base; ty->is_unsigned = true; ty->is_vector = base->is_vector; return ty; } Type *func_type(Type *return_ty) { // The C spec disallows sizeof(), but // GCC allows that and the expression is evaluated to 1. Type *ty = new_type(TY_FUNC, 1, 1); ty->return_ty = return_ty; ty->is_constructor = false; ty->is_destructor = false; ty->destructor_priority = 0; ty->constructor_priority = 0; return ty; } Type *array_of(Type *base, int len) { if (!base) error("%s %d: in array_of : base is null", TYPE_C, __LINE__); Type *ty = new_type(TY_ARRAY, base->size * len, base->align); ty->base = base; ty->array_len = len; ty->has_vla = base->has_vla; return ty; } Type *vector_of(Type *base, int len) { if (!base) error("%s %d: in vector_of : base is null", TYPE_C, __LINE__); Type *ty = new_type(TY_VECTOR, base->size * len, base->align); int total_size = base->size * len; ty->size = total_size; ty->base = base; ty->array_len = len; ty->has_vla = base->has_vla; ty->is_vector = true; return ty; } Type *vla_of(Type *base, Node *len) { Type *ty = new_type(TY_VLA, 8, 8); ty->base = base; ty->vla_len = len; ty->has_vla = true; return ty; } Type *enum_type(void) { return new_type(TY_ENUM, 4, 4); } Type *struct_type(void) { return new_type(TY_STRUCT, 0, 1); } static Type *get_common_type(Node **lhs, Node **rhs) { Type *ty1 = (*lhs)->ty; Type *ty2 = (*rhs)->ty; //======ISS-158 trying to fix issue with "parse.c: in struct_ref : not a struct nor a union" when in a macro definition we have (size_t)-1 ? NULL : (n) - 1 //assuming that if one is void it returns the second type that could be void also or different type. if (!ty2) { return ty1; } if (ty1->base) { if (ty1->base->kind == TY_VOID) if (ty2->base) return pointer_to(ty2->base); return pointer_to(ty1->base); } if (ty1->kind == TY_FUNC) return pointer_to(ty1); if (ty2->kind == TY_FUNC) return pointer_to(ty2); if (ty1->kind == TY_LDOUBLE || ty2->kind == TY_LDOUBLE) return ty_ldouble; if (ty1->kind == TY_DOUBLE || ty2->kind == TY_DOUBLE) return ty_double; if (ty1->kind == TY_FLOAT || ty2->kind == TY_FLOAT) return ty_float; if (ty1->kind == TY_INT128 || ty2->kind == TY_INT128) { if( ty1->is_unsigned || ty2->is_unsigned) return ty_uint128; else return ty_int128; } if (ty1->kind == TY_STRUCT || ty1->kind == TY_UNION) { if (is_compatible(ty1, ty2)) return ty1; } if (ty2->kind == TY_STRUCT || ty2->kind == TY_UNION) { if (is_compatible(ty1, ty2)) return ty2; } // if (ty1->size < 4) // ty1 = ty_int; // if (ty2->size < 4) // ty2 = ty_int; // if (ty1->size != ty2->size) // return (ty1->size < ty2->size) ? ty2 : ty1; // if (ty2->is_unsigned) // return ty2; // return ty1; int_promotion(lhs); int_promotion(rhs); ty1 = (*lhs)->ty; ty2 = (*rhs)->ty; if (ty1->size != ty2->size) return (ty1->size < ty2->size) ? ty2 : ty1; Type *ranked_ty = int_rank(ty1) > int_rank(ty2) ? ty1 : ty2; if (ty1->is_unsigned == ty2->is_unsigned) return ranked_ty; // If same size but different sign, the common type is unsigned // variant of the highest-ranked type between the two. switch (ranked_ty->kind) { case TY_INT: return ty_uint; case TY_LONG: return ty_ulong; case TY_LLONG: return ty_ullong; } unreachable(); } // For many binary operators, we implicitly promote operands so that // both operands have the same type. Any integral type smaller than // int is always promoted to int. If the type of one operand is larger // than the other's (e.g. "long" vs. "int"), the smaller operand will // be promoted to match with the other. // // This operation is called the "usual arithmetic conversion". static void usual_arith_conv(Node **lhs, Node **rhs) { Type *ty = get_common_type(lhs, rhs); *lhs = new_cast(*lhs, ty); *rhs = new_cast(*rhs, ty); } bool is_vector(Type *ty) { return ty && ty->kind == TY_VECTOR; } bool is_int128(Type *ty) { return ty && ty->kind == TY_INT128; } void add_type(Node *node) { if (!node || node->ty) return; add_type(node->lhs); add_type(node->rhs); add_type(node->cond); add_type(node->then); add_type(node->els); add_type(node->init); add_type(node->inc); for (Node *n = node->body; n; n = n->next) add_type(n); for (Node *n = node->args; n; n = n->next) add_type(n); switch (node->kind) { case ND_NUM: node->ty = ty_int; return; case ND_ADD: case ND_SUB: case ND_MUL: case ND_DIV: case ND_MOD: case ND_BITAND: case ND_BITOR: case ND_BITXOR: if (is_vector(node->lhs->ty) && is_vector(node->rhs->ty)) { node->ty = node->lhs->ty; } else { usual_arith_conv(&node->lhs, &node->rhs); node->ty = node->lhs->ty; } return; case ND_POS: case ND_NEG: if (!is_numeric(node->lhs->ty) && !is_vector(node->lhs->ty)) error_tok(node->lhs->tok, "%s %d: in add_type: invalid operand", TYPE_C, __LINE__); if (is_integer(node->lhs->ty)) int_promotion(&node->lhs); node->ty = node->lhs->ty; return; case ND_ASSIGN: if (node->lhs->ty->kind == TY_ARRAY) error_tok(node->lhs->tok, "%s %d: not an lvalue", TYPE_C, __LINE__); if (node->lhs->ty->kind != TY_STRUCT && node->lhs->ty->kind != TY_UNION) node->rhs = new_cast(node->rhs, node->lhs->ty); node->ty = node->lhs->ty; return; case ND_EQ: case ND_NE: case ND_LT: case ND_LE: usual_arith_conv(&node->lhs, &node->rhs); node->ty = ty_int; return; case ND_ALLOC: add_type(node->lhs); case ND_FUNCALL: node->ty = node->func_ty->return_ty; return; case ND_NOT: case ND_LOGOR: case ND_LOGAND: node->ty = ty_int; return; case ND_BITNOT: case ND_SHL: case ND_SHR: //node->ty = node->lhs->ty; if (!is_integer(node->lhs->ty) && !is_vector(node->lhs->ty)) error_tok(node->tok, "%s %d %d invalid operand ", TYPE_C, __LINE__, node->kind); if (is_integer(node->lhs->ty)) int_promotion(&node->lhs); node->ty = node->lhs->ty; return; case ND_VAR: if (!node->var) { error_tok(node->tok, "%s %d %d variable undefined ", TYPE_C, __LINE__, node->kind); } case ND_VLA_PTR: node->ty = node->var->ty; return; case ND_COND: //======ISS-154 trying to fix deferencing pointer issue when we have a macro that can return a pointer or null (self) ? NULL //printf("======%d %d %s\n", node->then->ty->kind, node->els->ty->kind, node->tok->loc); if (node->then->ty->kind == TY_VOID && node->els->ty->kind == TY_VOID) { node->ty = ty_void; } else { usual_arith_conv(&node->then, &node->els); node->ty = node->then->ty; } return; case ND_COMMA: node->ty = node->rhs->ty; return; case ND_MEMBER: node->ty = node->member->ty; return; case ND_ADDR: { Type *ty = node->lhs->ty; //from @fuhsnn add_type():Remove overaggressive array decaying node->ty = pointer_to(ty); return; } case ND_DEREF: if (!node->lhs->ty->base) { //ISS-163 trying to fix issue with pointer dereference if (node->lhs->ty) node->lhs->ty->base = node->lhs->ty; else error_tok(node->tok, "%s %d: invalid pointer dereference", TYPE_C, __LINE__); } //======ISS-154 trying to fix deferencing pointer issue when we have a macro that can return a pointer or null (self) ? NULL //printf("======%d %d %s\n", node->lhs->ty->base->kind, node->lhs->ty->kind, node->lhs->tok->loc); if (node->lhs->ty->base->kind == TY_VOID && node->lhs->ty->kind == TY_VOID) error_tok(node->tok, "%s %d : dereferencing a void pointer", TYPE_C, __LINE__); if (node->lhs->ty->base->kind == TY_VOID) node->lhs->ty->base = node->lhs->ty; node->ty = node->lhs->ty->base; return; case ND_STMT_EXPR: if (node->body) { Node *stmt = node->body; while (stmt->next) { stmt = stmt->next; add_type(stmt); } while (stmt->kind == ND_LABEL) { stmt = stmt->lhs; add_type(stmt); } if (stmt->kind == ND_EXPR_STMT) { node->ty = stmt->lhs->ty; return; } } //trying to fix =====ISS-144 compiling util-linux failed with expression returning void is not supported //error_tok(node->tok, "%s statement expression returning void is not supported", TYPE_C); return; case ND_LABEL_VAL: node->ty = pointer_to(ty_void); return; case ND_CAS: add_type(node->cas_addr); add_type(node->cas_old); add_type(node->cas_new); node->ty = ty_bool; if (node->cas_addr->ty->kind != TY_PTR) error_tok(node->cas_addr->tok, "%s %d: pointer expected", TYPE_C, __LINE__); if (node->cas_old->ty->kind != TY_PTR) error_tok(node->cas_old->tok, "%s %d: pointer expected", TYPE_C, __LINE__); return; case ND_CAS_N: add_type(node->cas_addr); add_type(node->cas_old); add_type(node->cas_new); node->ty = ty_bool; if (node->cas_addr->ty->kind != TY_PTR) error_tok(node->cas_addr->tok, "%s %d: pointer expected", TYPE_C, __LINE__); return; case ND_BUILTIN_MEMCPY: add_type(node->builtin_dest); add_type(node->builtin_src); add_type(node->builtin_size); return; case ND_BUILTIN_MEMSET: add_type(node->builtin_dest); add_type(node->builtin_val); add_type(node->builtin_size); return; case ND_PSADBW: case ND_PMULUDQ: node->ty = vector_of(ty_ulong, 1); return; case ND_PMULUDQ128: node->ty = vector_of(ty_ulong, 2); return; case ND_PXOR: case ND_POR: case ND_PAND: case ND_PANDN: case ND_PSRLQ: case ND_PSRLQI: case ND_PSLLQI: case ND_PSLLQ: case ND_PSUBQ: case ND_PADDQ: case ND_MOVQ128: node->ty = vector_of(ty_long, 1); return; case ND_PCMPGTD: case ND_PCMPEQD: case ND_PSRADI: case ND_PSRAD: case ND_PSLLDI: case ND_PSLLD: case ND_PSUBD: case ND_PADDD: case ND_PUNPCKLDQ: case ND_PUNPCKHDQ: case ND_VECINITV2SI: case ND_CVTPS2PI: case ND_CVTTPS2PI: case ND_CVTPD2PI: case ND_CVTTPD2PI: node->ty = vector_of(ty_int, 2); return; case ND_CVTPD2DQ: case ND_CVTTPD2DQ: case ND_CVTPS2DQ: case ND_CVTTPS2DQ: node->ty = vector_of(ty_int, 4); return; case ND_CMPUNORDPS: case ND_CMPORDPS: case ND_CMPNGEPS: case ND_CMPNGTPS: case ND_CMPNLEPS: case ND_CMPNLTPS: case ND_CMPNEQPS: case ND_CMPGEPS: case ND_CMPGTPS: case ND_CMPLEPS: case ND_CMPLTPS: case ND_CMPEQPS: case ND_CMPUNORDSS: case ND_CMPORDSS: case ND_CMPNLESS: case ND_CMPNLTSS: case ND_CMPNEQSS: case ND_MOVSS: case ND_CMPLESS: case ND_CMPLTSS: case ND_CMPEQSS: case ND_XORPS: case ND_ORPS: case ND_ANDNPS: case ND_ANDPS: case ND_MAXPS: case ND_MINPS: case ND_RSQRTPS: case ND_RCPPS: case ND_SQRTPS: case ND_MAXSS: case ND_MINSS: case ND_RSQRTSS: case ND_RCPSS: case ND_SQRTSS: case ND_DIVSS: case ND_MULSS: case ND_SUBSS: case ND_ADDSS: case ND_CVTPI2PS: case ND_CVTSI2SS: case ND_CVTSI642SS: case ND_MOVLHPS: case ND_MOVHLPS: case ND_UNPCKHPS: case ND_UNPCKLPS: case ND_LOADHPS: case ND_LOADLPS: case ND_SHUFPS: case ND_SHUFFLE: case ND_PMAXSW: case ND_PMINSW: case ND_SHUFPD: case ND_CVTDQ2PS: case ND_CVTPD2PS: case ND_CVTSD2SS: node->ty = vector_of(ty_float, 4); return; case ND_EXPECT: add_type(node->rhs); add_type(node->lhs); node->ty = ty_bool; return; case ND_ABORT: return; case ND_STORELPS: case ND_STOREHPS: case ND_LDMXCSR: case ND_STMXCSR: case ND_MASKMOVQ: case ND_MOVNTQ: case ND_MOVNTPS: case ND_MASKMOVDQU: case ND_MOVNTI: case ND_MOVNTI64: case ND_MOVNTDQ: node->ty = ty_void_ptr; return; case ND_CLFLUSH: case ND_BUILTIN_FRAME_ADDRESS: case ND_RETURN_ADDR: add_type(node->lhs); node->ty = ty_void_ptr; return; case ND_BUILTIN_SUB_OVERFLOW: case ND_BUILTIN_MUL_OVERFLOW: case ND_BUILTIN_ADD_OVERFLOW: case ND_UMULLL_OVERFLOW: case ND_UMULL_OVERFLOW: case ND_UMUL_OVERFLOW: case ND_UADDLL_OVERFLOW: case ND_UADDL_OVERFLOW: case ND_UADD_OVERFLOW: add_type(node->lhs); add_type(node->rhs); add_type(node->builtin_dest); if (node->builtin_dest->kind == ND_NUM && node->builtin_dest->val == 0) { node->builtin_dest->ty = pointer_to(ty_void); } node->ty = ty_bool; return; case ND_BUILTIN_ISNAN: add_type(node->builtin_val); node->ty = ty_bool; return; case ND_BUILTIN_CTZ: case ND_BUILTIN_CTZL: case ND_BUILTIN_CTZLL: case ND_BUILTIN_CLZ: case ND_BUILTIN_CLZL: case ND_BUILTIN_CLZLL: case ND_BUILTIN_BSWAP32: case ND_POPCOUNT: add_type(node->builtin_val); node->ty = ty_int; return; case ND_POPCOUNTL: add_type(node->builtin_val); node->ty = ty_long; return; case ND_POPCOUNTLL: add_type(node->builtin_val); node->ty = ty_llong; return; case ND_BUILTIN_BSWAP16: add_type(node->builtin_val); node->ty = ty_short; return; case ND_BUILTIN_BSWAP64: add_type(node->builtin_val); node->ty = ty_long; return; case ND_CMPEXCH: case ND_CMPEXCH_N: node->ty = ty_bool; return; case ND_EXCH_N: case ND_FETCHADD: case ND_FETCHSUB: case ND_FETCHXOR: case ND_FETCHAND: case ND_FETCHOR: case ND_SUBFETCH: if (node->lhs->ty->kind != TY_PTR) error_tok(node->lhs->tok, "pointer expected"); node->rhs = new_cast(node->rhs, node->lhs->ty->base); node->ty = node->lhs->ty->base; return; case ND_EMMS: case ND_SFENCE: case ND_LFENCE: case ND_MFENCE: case ND_PAUSE: case ND_UNREACHABLE: node->ty = ty_void; return; case ND_EXCH: if (node->lhs->ty->kind != TY_PTR) error_tok(node->cas_addr->tok, "%s %d: pointer expected", TYPE_C, __LINE__); node->ty = node->lhs->ty->base; return; case ND_BUILTIN_NANF: case ND_BUILTIN_INFF: case ND_BUILTIN_HUGE_VALF: node->ty = ty_float; return; case ND_BUILTIN_NAN: case ND_BUILTIN_INF: case ND_BUILTIN_HUGE_VAL: node->ty = ty_double; return; case ND_BUILTIN_NANL: case ND_BUILTIN_HUGE_VALL: node->ty = ty_ldouble; return; case ND_CVTTSS2SI: case ND_CVTTSD2SI: case ND_VECEXTV2SI: case ND_VECEXTV4SI: node->ty = ty_int; return; case ND_CVTTSD2SI64: case ND_CVTSD2SI64: case ND_CVTSS2SI64: case ND_CVTTSS2SI64: case ND_PARITYL: node->ty = ty_long; return; case ND_PARITYLL: node->ty = ty_llong; return; case ND_VECINITV4HI: case ND_PCMPGTW: case ND_PCMPEQW: case ND_PSRLDI: case ND_PSRLD: case ND_PSRLWI: case ND_PSRLW: case ND_PSRAWI: case ND_PSRAW: case ND_PSLLWI: case ND_PSLLW: case ND_PMULLW: case ND_PMULHW: case ND_PMADDWD: case ND_PSUBSW: case ND_PSUBW: case ND_PADDW: case ND_PADDSW: case ND_PADDUSW: case ND_PUNPCKLWD: case ND_PUNPCKHWD: case ND_PACKSSDW: case ND_PAVGW: case ND_PACKSSDW128: node->ty = vector_of(ty_short, 4); return; case ND_PCMPEQB: case ND_PSUBUSB: case ND_PACKUSWB: case ND_PADDUSB: case ND_PMAXUB: case ND_PMINUB: case ND_PAVGB: node->ty = vector_of(ty_uchar, 8); return; case ND_VECINITV8QI: case ND_PCMPGTB: case ND_PSUBSB: case ND_PSUBB: case ND_PADDB: case ND_PADDSB: case ND_PUNPCKLBW: case ND_PUNPCKHBW: case ND_PACKSSWB: node->ty = vector_of(ty_char, 8); return; case ND_PSUBUSW: case ND_PMULHUW: node->ty = vector_of(ty_ushort, 4); return; case ND_PSUBUSW128: case ND_PMULHUW128: case ND_PAVGW128: node->ty = vector_of(ty_ushort, 8); return; case ND_PUNPCKHWD128: case ND_PUNPCKLWD128: case ND_PADDSW128: case ND_PADDUSW128: case ND_PSUBSW128: case ND_PSLLWI128: case ND_PSRAWI128: case ND_PSRLWI128: case ND_PSLLW128: case ND_PSRAW128: case ND_PSRLW128: case ND_PMAXSW128: case ND_PMINSW128: node->ty = vector_of(ty_short, 8); return; case ND_PUNPCKHDQ128: case ND_PUNPCKHQDQ128: case ND_PUNPCKLDQ128: case ND_PMADDWD128: case ND_PMULHW128: case ND_PSLLDI128: case ND_PSRADI128: case ND_PSRLDI128: case ND_PSLLD128: case ND_PSRAD128: case ND_PSRLD128: case ND_PANDN128: node->ty = vector_of(ty_int, 4); return; case ND_PUNPCKLQDQ128: case ND_PSLLQI128: case ND_PSRLQI128: case ND_PSLLQ128: case ND_PSRLQ128: case ND_PSADBW128: node->ty = vector_of(ty_long, 2); return; case ND_ADDSD: case ND_SUBSD: case ND_MULSD: case ND_DIVSD: case ND_SQRTPD: case ND_MOVSD: case ND_SQRTSD: case ND_MINPD: case ND_MINSD: case ND_MAXPD: case ND_MAXSD: case ND_ANDPD: case ND_ANDNPD: case ND_ORPD: case ND_XORPD: case ND_CMPEQPD: case ND_CMPLTPD: case ND_CMPLEPD: case ND_CMPGTPD: case ND_CMPGEPD: case ND_CMPNEQPD: case ND_CMPNLTPD: case ND_CMPNLEPD: case ND_CMPNGTPD: case ND_CMPNGEPD: case ND_CMPORDPD: case ND_CMPUNORDPD: case ND_CMPEQSD: case ND_CMPLTSD: case ND_CMPLESD: case ND_CMPNEQSD: case ND_CMPNLTSD: case ND_CMPNLESD: case ND_CMPORDSD: case ND_CMPUNORDSD: case ND_CVTDQ2PD: case ND_CVTPI2PD: case ND_CVTPS2PD: case ND_CVTSI2SD: case ND_CVTSI642SD: case ND_CVTSS2SD: case ND_UNPCKHPD: case ND_UNPCKLPD: case ND_LOADHPD: case ND_LOADLPD: case ND_MOVMSKPD: case ND_MOVNTPD: node->ty = vector_of(ty_double, 2); return; case ND_PACKUSWB128: case ND_PUNPCKHBW128: case ND_PUNPCKLBW128: case ND_PADDUSB128: case ND_PSUBUSB128: case ND_PMAXUB128: case ND_PMINUB128: case ND_PAVGB128: node->ty = vector_of(ty_uchar, 16); return; case ND_PACKSSWB128: case ND_PADDSB128: case ND_PSUBSB128: node->ty = vector_of(ty_char, 16); return; case ND_CVTSS2SI: case ND_UCOMINEQ: case ND_UCOMIGE: case ND_UCOMIGT: case ND_UCOMILE: case ND_UCOMILT: case ND_UCOMIEQ: case ND_COMINEQ: case ND_COMIGE: case ND_COMIGT: case ND_COMILE: case ND_COMILT: case ND_COMIEQ: case ND_MOVMSKPS: case ND_PMOVMSKB: case ND_COMISDEQ: case ND_COMISDLT: case ND_COMISDLE: case ND_COMISDGT: case ND_COMISDGE: case ND_COMISDNEQ: case ND_UCOMISDEQ: case ND_UCOMISDLT: case ND_UCOMISDLE: case ND_UCOMISDGT: case ND_UCOMISDGE: case ND_UCOMISDNEQ: case ND_CVTSD2SI: case ND_PMOVMSKB128: case ND_PARITY: node->ty = ty_int; } }chibicc-1.0.23.1/unicode.c000077500000000000000000000267631505335450300151360ustar00rootroot00000000000000#include "chibicc.h" #define UNICODE_C "unicode.c" // Encode a given character in UTF-8. int encode_utf8(char *buf, uint32_t c) { if (c <= 0x7F) { buf[0] = c; return 1; } if (c <= 0x7FF) { buf[0] = 0b11000000 | (c >> 6); buf[1] = 0b10000000 | (c & 0b00111111); return 2; } if (c <= 0xFFFF) { buf[0] = 0b11100000 | (c >> 12); buf[1] = 0b10000000 | ((c >> 6) & 0b00111111); buf[2] = 0b10000000 | (c & 0b00111111); return 3; } buf[0] = 0b11110000 | (c >> 18); buf[1] = 0b10000000 | ((c >> 12) & 0b00111111); buf[2] = 0b10000000 | ((c >> 6) & 0b00111111); buf[3] = 0b10000000 | (c & 0b00111111); return 4; } // Read a UTF-8-encoded Unicode code point from a source file. // We assume that source files are always in UTF-8. // // UTF-8 is a variable-width encoding in which one code point is // encoded in one to four bytes. One byte UTF-8 code points are // identical to ASCII. Non-ASCII characters are encoded using more // than one byte. uint32_t decode_utf8(char **new_pos, char *p) { if ((unsigned char)*p < 128) { *new_pos = p + 1; return *p; } char *start = p; int len; uint32_t c; if ((unsigned char)*p >= 0b11110000) { len = 4; c = *p & 0b111; } else if ((unsigned char)*p >= 0b11100000) { len = 3; c = *p & 0b1111; } else if ((unsigned char)*p >= 0b11000000) { len = 2; c = *p & 0b11111; } else { error_at(start, "%s invalid UTF-8 sequence", UNICODE_C); } for (int i = 1; i < len; i++) { if ((unsigned char)p[i] >> 6 != 0b10) error_at(start, "%s invalid UTF-8 sequence", UNICODE_C); c = (c << 6) | (p[i] & 0b111111); } *new_pos = p + len; return c; } static bool in_range(uint32_t *range, uint32_t c) { for (int i = 0; range[i] != -1; i += 2) if (range[i] <= c && c <= range[i + 1]) return true; return false; } // [https://www.sigbus.info/n1570#D] C11 allows not only ASCII but // some multibyte characters in certan Unicode ranges to be used in an // identifier. // // This function returns true if a given character is acceptable as // the first character of an identifier. // // For example, ¾ (U+00BE) is a valid identifier because characters in // 0x00BE-0x00C0 are allowed, while neither ⟘ (U+27D8) nor ' ' // (U+3000, full-width space) are allowed because they are out of range. // to solve issue #117 I had to add 0--9 range to be allowed because some generics parameters // are defined after ## (double hashtag). Exemple in openssl ...(void))fromtype##2obj_decode}, // In this case chibicc manages 2 as a number because identifier should not start by a numeric value! // creating is_ident3 to manage it bool is_ident1(uint32_t c) { static uint32_t range[] = { '_', '_', 'a', 'z', 'A', 'Z', '$', '$', 0x00A8, 0x00A8, 0x00AA, 0x00AA, 0x00AD, 0x00AD, 0x00AF, 0x00AF, 0x00B2, 0x00B5, 0x00B7, 0x00BA, 0x00BC, 0x00BE, 0x00C0, 0x00D6, 0x00D8, 0x00F6, 0x00F8, 0x00FF, 0x0100, 0x02FF, 0x0370, 0x167F, 0x1681, 0x180D, 0x180F, 0x1DBF, 0x1E00, 0x1FFF, 0x200B, 0x200D, 0x202A, 0x202E, 0x203F, 0x2040, 0x2054, 0x2054, 0x2060, 0x206F, 0x2070, 0x20CF, 0x2100, 0x218F, 0x2460, 0x24FF, 0x2776, 0x2793, 0x2C00, 0x2DFF, 0x2E80, 0x2FFF, 0x3004, 0x3007, 0x3021, 0x302F, 0x3031, 0x303F, 0x3040, 0xD7FF, 0xF900, 0xFD3D, 0xFD40, 0xFDCF, 0xFDF0, 0xFE1F, 0xFE30, 0xFE44, 0xFE47, 0xFFFD, 0x10000, 0x1FFFD, 0x20000, 0x2FFFD, 0x30000, 0x3FFFD, 0x40000, 0x4FFFD, 0x50000, 0x5FFFD, 0x60000, 0x6FFFD, 0x70000, 0x7FFFD, 0x80000, 0x8FFFD, 0x90000, 0x9FFFD, 0xA0000, 0xAFFFD, 0xB0000, 0xBFFFD, 0xC0000, 0xCFFFD, 0xD0000, 0xDFFFD, 0xE0000, 0xEFFFD, -1, }; return in_range(range, c); } // Returns true if a given character is acceptable as a non-first // character of an identifier. bool is_ident2(uint32_t c) { static uint32_t range[] = { '_', '_', 'a', 'z', 'A', 'Z', '0', '9', '$', '$', 0x0300, 0x036F, 0x1DC0, 0x1DFF, 0x20D0, 0x20FF, 0xFE20, 0xFE2F, -1, }; return is_ident1(c) || in_range(range, c); } // For now the solution I found is to add here the range 0-9 has valid character for identifier. // it means that some incorrect values would be allowed. To avoid it, I need to check if the previous character // is hashtag to allow in this case an identifier starting with numeric character bool is_ident3(uint32_t c) { static uint32_t range[] = { '_', '_', 'a', 'z', 'A', 'Z', '0', '9', '$', '$', 0x00A8, 0x00A8, 0x00AA, 0x00AA, 0x00AD, 0x00AD, 0x00AF, 0x00AF, 0x00B2, 0x00B5, 0x00B7, 0x00BA, 0x00BC, 0x00BE, 0x00C0, 0x00D6, 0x00D8, 0x00F6, 0x00F8, 0x00FF, 0x0100, 0x02FF, 0x0370, 0x167F, 0x1681, 0x180D, 0x180F, 0x1DBF, 0x1E00, 0x1FFF, 0x200B, 0x200D, 0x202A, 0x202E, 0x203F, 0x2040, 0x2054, 0x2054, 0x2060, 0x206F, 0x2070, 0x20CF, 0x2100, 0x218F, 0x2460, 0x24FF, 0x2776, 0x2793, 0x2C00, 0x2DFF, 0x2E80, 0x2FFF, 0x3004, 0x3007, 0x3021, 0x302F, 0x3031, 0x303F, 0x3040, 0xD7FF, 0xF900, 0xFD3D, 0xFD40, 0xFDCF, 0xFDF0, 0xFE1F, 0xFE30, 0xFE44, 0xFE47, 0xFFFD, 0x10000, 0x1FFFD, 0x20000, 0x2FFFD, 0x30000, 0x3FFFD, 0x40000, 0x4FFFD, 0x50000, 0x5FFFD, 0x60000, 0x6FFFD, 0x70000, 0x7FFFD, 0x80000, 0x8FFFD, 0x90000, 0x9FFFD, 0xA0000, 0xAFFFD, 0xB0000, 0xBFFFD, 0xC0000, 0xCFFFD, 0xD0000, 0xDFFFD, 0xE0000, 0xEFFFD, -1, }; return in_range(range, c); } // Returns the number of columns needed to display a given // character in a fixed-width font. // // Based on https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c static int char_width(uint32_t c) { static uint32_t range1[] = { 0x0000, 0x001F, 0x007f, 0x00a0, 0x0300, 0x036F, 0x0483, 0x0486, 0x0488, 0x0489, 0x0591, 0x05BD, 0x05BF, 0x05BF, 0x05C1, 0x05C2, 0x05C4, 0x05C5, 0x05C7, 0x05C7, 0x0600, 0x0603, 0x0610, 0x0615, 0x064B, 0x065E, 0x0670, 0x0670, 0x06D6, 0x06E4, 0x06E7, 0x06E8, 0x06EA, 0x06ED, 0x070F, 0x070F, 0x0711, 0x0711, 0x0730, 0x074A, 0x07A6, 0x07B0, 0x07EB, 0x07F3, 0x0901, 0x0902, 0x093C, 0x093C, 0x0941, 0x0948, 0x094D, 0x094D, 0x0951, 0x0954, 0x0962, 0x0963, 0x0981, 0x0981, 0x09BC, 0x09BC, 0x09C1, 0x09C4, 0x09CD, 0x09CD, 0x09E2, 0x09E3, 0x0A01, 0x0A02, 0x0A3C, 0x0A3C, 0x0A41, 0x0A42, 0x0A47, 0x0A48, 0x0A4B, 0x0A4D, 0x0A70, 0x0A71, 0x0A81, 0x0A82, 0x0ABC, 0x0ABC, 0x0AC1, 0x0AC5, 0x0AC7, 0x0AC8, 0x0ACD, 0x0ACD, 0x0AE2, 0x0AE3, 0x0B01, 0x0B01, 0x0B3C, 0x0B3C, 0x0B3F, 0x0B3F, 0x0B41, 0x0B43, 0x0B4D, 0x0B4D, 0x0B56, 0x0B56, 0x0B82, 0x0B82, 0x0BC0, 0x0BC0, 0x0BCD, 0x0BCD, 0x0C3E, 0x0C40, 0x0C46, 0x0C48, 0x0C4A, 0x0C4D, 0x0C55, 0x0C56, 0x0CBC, 0x0CBC, 0x0CBF, 0x0CBF, 0x0CC6, 0x0CC6, 0x0CCC, 0x0CCD, 0x0CE2, 0x0CE3, 0x0D41, 0x0D43, 0x0D4D, 0x0D4D, 0x0DCA, 0x0DCA, 0x0DD2, 0x0DD4, 0x0DD6, 0x0DD6, 0x0E31, 0x0E31, 0x0E34, 0x0E3A, 0x0E47, 0x0E4E, 0x0EB1, 0x0EB1, 0x0EB4, 0x0EB9, 0x0EBB, 0x0EBC, 0x0EC8, 0x0ECD, 0x0F18, 0x0F19, 0x0F35, 0x0F35, 0x0F37, 0x0F37, 0x0F39, 0x0F39, 0x0F71, 0x0F7E, 0x0F80, 0x0F84, 0x0F86, 0x0F87, 0x0F90, 0x0F97, 0x0F99, 0x0FBC, 0x0FC6, 0x0FC6, 0x102D, 0x1030, 0x1032, 0x1032, 0x1036, 0x1037, 0x1039, 0x1039, 0x1058, 0x1059, 0x1160, 0x11FF, 0x135F, 0x135F, 0x1712, 0x1714, 0x1732, 0x1734, 0x1752, 0x1753, 0x1772, 0x1773, 0x17B4, 0x17B5, 0x17B7, 0x17BD, 0x17C6, 0x17C6, 0x17C9, 0x17D3, 0x17DD, 0x17DD, 0x180B, 0x180D, 0x18A9, 0x18A9, 0x1920, 0x1922, 0x1927, 0x1928, 0x1932, 0x1932, 0x1939, 0x193B, 0x1A17, 0x1A18, 0x1B00, 0x1B03, 0x1B34, 0x1B34, 0x1B36, 0x1B3A, 0x1B3C, 0x1B3C, 0x1B42, 0x1B42, 0x1B6B, 0x1B73, 0x1DC0, 0x1DCA, 0x1DFE, 0x1DFF, 0x200B, 0x200F, 0x202A, 0x202E, 0x2060, 0x2063, 0x206A, 0x206F, 0x20D0, 0x20EF, 0x302A, 0x302F, 0x3099, 0x309A, 0xA806, 0xA806, 0xA80B, 0xA80B, 0xA825, 0xA826, 0xFB1E, 0xFB1E, 0xFE00, 0xFE0F, 0xFE20, 0xFE23, 0xFEFF, 0xFEFF, 0xFFF9, 0xFFFB, 0x10A01, 0x10A03, 0x10A05, 0x10A06, 0x10A0C, 0x10A0F, 0x10A38, 0x10A3A, 0x10A3F, 0x10A3F, 0x1D167, 0x1D169, 0x1D173, 0x1D182, 0x1D185, 0x1D18B, 0x1D1AA, 0x1D1AD, 0x1D242, 0x1D244, 0xE0001, 0xE0001, 0xE0020, 0xE007F, 0xE0100, 0xE01EF, -1, }; if (in_range(range1, c)) return 0; static uint32_t range2[] = { 0x1100, 0x115F, 0x2329, 0x2329, 0x232A, 0x232A, 0x2E80, 0x303E, 0x3040, 0xA4CF, 0xAC00, 0xD7A3, 0xF900, 0xFAFF, 0xFE10, 0xFE19, 0xFE30, 0xFE6F, 0xFF00, 0xFF60, 0xFFE0, 0xFFE6, 0x1F000, 0x1F644, 0x20000, 0x2FFFD, 0x30000, 0x3FFFD, -1, }; if (in_range(range2, c)) return 2; return 1; } // Returns the number of columns needed to display a given // string in a fixed-width font. int display_width(char *p, int len) { char *start = p; int w = 0; while (p - start < len) { uint32_t c = decode_utf8(&p, p); w += char_width(c); } return w; }