blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
721
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
5
91
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
321 values
visit_date
timestamp[ns]date
2016-08-12 09:31:09
2023-09-06 10:45:07
revision_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
committer_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
github_id
int64
426
681M
star_events_count
int64
101
243k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[ns]date
2012-06-28 18:51:49
2023-09-14 21:59:16
gha_created_at
timestamp[ns]date
2008-02-11 22:55:26
2023-08-10 11:14:58
gha_language
stringclasses
147 values
src_encoding
stringclasses
26 values
language
stringclasses
2 values
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
6
10.2M
extension
stringclasses
115 values
filename
stringlengths
3
113
content
stringlengths
6
10.2M
3e5846c48308c8d1dad01ab35a5b725acab12901
c475cd8531a94ffae69cc92371d41531dbbddb6c
/Libraries/ovr_sdk_win_1.12.0_public/OculusSDK/LibOVR/Include/OVR_CAPI_Keys.h
e3e9d689c5202724751fa90a30037d3d369a579e
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
WolfireGames/overgrowth
72d3dd29cbd7254337265c29f8de3e5c32400114
594a2a4f9da0855304ee8cd5335d042f8e954ce1
refs/heads/main
2023-08-15T19:36:56.156578
2023-05-17T08:17:53
2023-05-17T08:20:36
467,448,492
2,264
245
Apache-2.0
2023-05-09T07:29:58
2022-03-08T09:38:54
C++
UTF-8
C
false
false
2,433
h
OVR_CAPI_Keys.h
/********************************************************************************//** \file OVR_CAPI.h \brief Keys for CAPI proprty function calls \copyright Copyright 2015 Oculus VR, LLC All Rights reserved. ************************************************************************************/ #ifndef OVR_CAPI_Keys_h #define OVR_CAPI_Keys_h #include "OVR_Version.h" #define OVR_KEY_USER "User" // string #define OVR_KEY_NAME "Name" // string #define OVR_KEY_GENDER "Gender" // string "Male", "Female", or "Unknown" #define OVR_DEFAULT_GENDER "Unknown" #define OVR_KEY_PLAYER_HEIGHT "PlayerHeight" // float meters #define OVR_DEFAULT_PLAYER_HEIGHT 1.778f #define OVR_KEY_EYE_HEIGHT "EyeHeight" // float meters #define OVR_DEFAULT_EYE_HEIGHT 1.675f #define OVR_KEY_NECK_TO_EYE_DISTANCE "NeckEyeDistance" // float[2] meters #define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.0805f #define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.075f #define OVR_KEY_EYE_TO_NOSE_DISTANCE "EyeToNoseDist" // float[2] meters #define OVR_PERF_HUD_MODE "PerfHudMode" // int, allowed values are defined in enum ovrPerfHudMode #define OVR_LAYER_HUD_MODE "LayerHudMode" // int, allowed values are defined in enum ovrLayerHudMode #define OVR_LAYER_HUD_CURRENT_LAYER "LayerHudCurrentLayer" // int, The layer to show #define OVR_LAYER_HUD_SHOW_ALL_LAYERS "LayerHudShowAll" // bool, Hide other layers when the hud is enabled #define OVR_DEBUG_HUD_STEREO_MODE "DebugHudStereoMode" // int, allowed values are defined in enum ovrDebugHudStereoMode #define OVR_DEBUG_HUD_STEREO_GUIDE_INFO_ENABLE "DebugHudStereoGuideInfoEnable" // bool #define OVR_DEBUG_HUD_STEREO_GUIDE_SIZE "DebugHudStereoGuideSize2f" // float[2] #define OVR_DEBUG_HUD_STEREO_GUIDE_POSITION "DebugHudStereoGuidePosition3f" // float[3] #define OVR_DEBUG_HUD_STEREO_GUIDE_YAWPITCHROLL "DebugHudStereoGuideYawPitchRoll3f" // float[3] #define OVR_DEBUG_HUD_STEREO_GUIDE_COLOR "DebugHudStereoGuideColor4f" // float[4] #endif // OVR_CAPI_Keys_h
885f432e29e9c99c27b95100d88321e5b9713a7d
9b55ac8ba38f2e964c132d299b52529de050b632
/Modules/_billiard/win32_functions.c
716990eb3df9ce0106501a2316a2dad365996a0b
[ "BSD-3-Clause" ]
permissive
celery/billiard
88b1c3bf45aa1bc099d5f9bebb3c50811d045796
32e51b50aa3e6eaec597f5587c41951376554066
refs/heads/main
2023-09-04T21:45:53.033094
2023-07-24T07:53:37
2023-08-04T06:16:59
374,820
326
165
NOASSERTION
2023-08-04T06:17:00
2009-11-16T15:39:48
Python
UTF-8
C
false
false
27,251
c
win32_functions.c
/* * Win32 functions used by multiprocessing package * * win32_functions.c * * Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt */ #include "multiprocessing.h" #if defined(MS_WIN32) && !defined(MS_WIN64) #define HANDLE_TO_PYNUM(handle) \ PyLong_FromUnsignedLong((unsigned long) handle) #define PYNUM_TO_HANDLE(obj) ((HANDLE)PyLong_AsUnsignedLong(obj)) #define F_POINTER "k" #define T_POINTER T_ULONG #else #define HANDLE_TO_PYNUM(handle) \ PyLong_FromUnsignedLongLong((unsigned long long) handle) #define PYNUM_TO_HANDLE(obj) ((HANDLE)PyLong_AsUnsignedLongLong(obj)) #define F_POINTER "K" #define T_POINTER T_ULONGLONG #endif #define F_HANDLE F_POINTER #define F_DWORD "k" #define F_BOOL "i" #define F_UINT "I" #define T_HANDLE T_POINTER #define DWORD_MAX 4294967295U #define Py_MIN(x, y) (((x) > (y)) ? (y) : (x)) /* Grab CancelIoEx dynamically from kernel32 */ static int has_CancelIoEx = -1; static BOOL (CALLBACK *Py_CancelIoEx)(HANDLE, LPOVERLAPPED); static int check_CancelIoEx() { if (has_CancelIoEx == -1) { HINSTANCE hKernel32 = GetModuleHandle("KERNEL32"); * (FARPROC *) &Py_CancelIoEx = GetProcAddress(hKernel32, "CancelIoEx"); has_CancelIoEx = (Py_CancelIoEx != NULL); } return has_CancelIoEx; } /* * A Python object wrapping an OVERLAPPED structure and other useful data * for overlapped I/O */ typedef struct { PyObject_HEAD OVERLAPPED overlapped; /* For convenience, we store the file handle too */ HANDLE handle; /* Whether there's I/O in flight */ int pending; /* Whether I/O completed successfully */ int completed; /* Buffer used for reading (optional) */ PyObject *read_buffer; /* Buffer used for writing (optional) */ Py_buffer write_buffer; } OverlappedObject; static void overlapped_dealloc(OverlappedObject *self) { DWORD bytes; int err = GetLastError(); if (self->pending) { if (check_CancelIoEx() && Py_CancelIoEx(self->handle, &self->overlapped) && GetOverlappedResult(self->handle, &self->overlapped, &bytes, TRUE)) { /* The operation is no longer pending -- nothing to do. */ } else { /* The operation is still pending, but the process is probably about to exit, so we need not worry too much about memory leaks. Leaking self prevents a potential crash. This can happen when a daemon thread is cleaned up at exit -- see #19565. We only expect to get here on Windows XP. */ CloseHandle(self->overlapped.hEvent); SetLastError(err); return; } } CloseHandle(self->overlapped.hEvent); SetLastError(err); if (self->write_buffer.obj) PyBuffer_Release(&self->write_buffer); Py_CLEAR(self->read_buffer); PyObject_Del(self); } static PyObject * overlapped_GetOverlappedResult(OverlappedObject *self, PyObject *waitobj) { int wait; BOOL res; DWORD transferred = 0; DWORD err; wait = PyObject_IsTrue(waitobj); if (wait < 0) return NULL; Py_BEGIN_ALLOW_THREADS res = GetOverlappedResult(self->handle, &self->overlapped, &transferred, wait != 0); Py_END_ALLOW_THREADS err = res ? ERROR_SUCCESS : GetLastError(); switch (err) { case ERROR_SUCCESS: case ERROR_MORE_DATA: case ERROR_OPERATION_ABORTED: self->completed = 1; self->pending = 0; break; case ERROR_IO_INCOMPLETE: break; default: self->pending = 0; return PyErr_SetExcFromWindowsErr(PyExc_IOError, err); } if (self->completed && self->read_buffer != NULL) { assert(PyBytes_CheckExact(self->read_buffer)); if (transferred != PyBytes_GET_SIZE(self->read_buffer) && _PyBytes_Resize(&self->read_buffer, transferred)) return NULL; } return Py_BuildValue("II", (unsigned) transferred, (unsigned) err); } static PyObject * overlapped_getbuffer(OverlappedObject *self) { PyObject *res; if (!self->completed) { PyErr_SetString(PyExc_ValueError, "can't get read buffer before GetOverlappedResult() " "signals the operation completed"); return NULL; } res = self->read_buffer ? self->read_buffer : Py_None; Py_INCREF(res); return res; } static PyObject * overlapped_cancel(OverlappedObject *self) { BOOL res = TRUE; if (self->pending) { Py_BEGIN_ALLOW_THREADS if (check_CancelIoEx()) res = Py_CancelIoEx(self->handle, &self->overlapped); else res = CancelIo(self->handle); Py_END_ALLOW_THREADS } /* CancelIoEx returns ERROR_NOT_FOUND if the I/O completed in-between */ if (!res && GetLastError() != ERROR_NOT_FOUND) return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); self->pending = 0; Py_RETURN_NONE; } static PyMethodDef overlapped_methods[] = { {"GetOverlappedResult", (PyCFunction) overlapped_GetOverlappedResult, METH_O, NULL}, {"getbuffer", (PyCFunction) overlapped_getbuffer, METH_NOARGS, NULL}, {"cancel", (PyCFunction) overlapped_cancel, METH_NOARGS, NULL}, {NULL} }; static PyMemberDef overlapped_members[] = { {"event", T_HANDLE, offsetof(OverlappedObject, overlapped) + offsetof(OVERLAPPED, hEvent), READONLY, "overlapped event handle"}, {NULL} }; PyTypeObject OverlappedType = { PyVarObject_HEAD_INIT(NULL, 0) /* tp_name */ "_winapi.Overlapped", /* tp_basicsize */ sizeof(OverlappedObject), /* tp_itemsize */ 0, /* tp_dealloc */ (destructor) overlapped_dealloc, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ Py_TPFLAGS_DEFAULT, /* tp_doc */ "OVERLAPPED structure wrapper", /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ overlapped_methods, /* tp_members */ overlapped_members, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, }; static OverlappedObject * new_overlapped(HANDLE handle) { OverlappedObject *self; self = PyObject_New(OverlappedObject, &OverlappedType); if (!self) return NULL; self->handle = handle; self->read_buffer = NULL; self->pending = 0; self->completed = 0; memset(&self->overlapped, 0, sizeof(OVERLAPPED)); memset(&self->write_buffer, 0, sizeof(Py_buffer)); /* Manual reset, initially non-signaled */ self->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); return self; } static PyObject * win32_CloseHandle(PyObject *self, PyObject *args) { HANDLE hObject; BOOL success; if (!PyArg_ParseTuple(args, F_HANDLE, &hObject)) return NULL; Py_BEGIN_ALLOW_THREADS success = CloseHandle(hObject); Py_END_ALLOW_THREADS if (!success) return PyErr_SetFromWindowsErr(0); Py_RETURN_NONE; } static PyObject * win32_ConnectNamedPipe(PyObject *self, PyObject *args, PyObject *kwds) { HANDLE hNamedPipe; int use_overlapped = 0; BOOL success; OverlappedObject *overlapped = NULL; static char *kwlist[] = {"handle", "overlapped", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, F_HANDLE "|" F_BOOL, kwlist, &hNamedPipe, &use_overlapped)) return NULL; if (use_overlapped) { overlapped = new_overlapped(hNamedPipe); if (!overlapped) return NULL; } Py_BEGIN_ALLOW_THREADS success = ConnectNamedPipe(hNamedPipe, overlapped ? &overlapped->overlapped : NULL); Py_END_ALLOW_THREADS if (overlapped) { int err = GetLastError(); /* Overlapped ConnectNamedPipe never returns a success code */ assert(success == 0); if (err == ERROR_IO_PENDING) overlapped->pending = 1; else if (err == ERROR_PIPE_CONNECTED) SetEvent(overlapped->overlapped.hEvent); else { Py_DECREF(overlapped); return PyErr_SetFromWindowsErr(err); } return (PyObject *) overlapped; } if (!success) return PyErr_SetFromWindowsErr(0); Py_RETURN_NONE; } static PyObject * win32_CreateFile(PyObject *self, PyObject *args) { LPCTSTR lpFileName; DWORD dwDesiredAccess; DWORD dwShareMode; LPSECURITY_ATTRIBUTES lpSecurityAttributes; DWORD dwCreationDisposition; DWORD dwFlagsAndAttributes; HANDLE hTemplateFile; HANDLE handle; if (!PyArg_ParseTuple(args, "s" F_DWORD F_DWORD F_POINTER F_DWORD F_DWORD F_HANDLE, &lpFileName, &dwDesiredAccess, &dwShareMode, &lpSecurityAttributes, &dwCreationDisposition, &dwFlagsAndAttributes, &hTemplateFile)) return NULL; Py_BEGIN_ALLOW_THREADS handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); Py_END_ALLOW_THREADS if (handle == INVALID_HANDLE_VALUE) return PyErr_SetFromWindowsErr(0); return Py_BuildValue(F_HANDLE, handle); } static PyObject * win32_CreateNamedPipe(PyObject *self, PyObject *args) { LPCTSTR lpName; DWORD dwOpenMode; DWORD dwPipeMode; DWORD nMaxInstances; DWORD nOutBufferSize; DWORD nInBufferSize; DWORD nDefaultTimeOut; LPSECURITY_ATTRIBUTES lpSecurityAttributes; HANDLE handle; if (!PyArg_ParseTuple(args, "s" F_DWORD F_DWORD F_DWORD F_DWORD F_DWORD F_DWORD F_POINTER, &lpName, &dwOpenMode, &dwPipeMode, &nMaxInstances, &nOutBufferSize, &nInBufferSize, &nDefaultTimeOut, &lpSecurityAttributes)) return NULL; Py_BEGIN_ALLOW_THREADS handle = CreateNamedPipe(lpName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes); Py_END_ALLOW_THREADS if (handle == INVALID_HANDLE_VALUE) return PyErr_SetFromWindowsErr(0); return Py_BuildValue(F_HANDLE, handle); } static PyObject * win32_ExitProcess(PyObject *self, PyObject *args) { UINT uExitCode; if (!PyArg_ParseTuple(args, "I", &uExitCode)) return NULL; #if defined(Py_DEBUG) SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOALIGNMENTFAULTEXCEPT|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); #endif ExitProcess(uExitCode); return NULL; } static PyObject * win32_GetLastError(PyObject *self, PyObject *args) { return Py_BuildValue(F_DWORD, GetLastError()); } static PyObject * win32_OpenProcess(PyObject *self, PyObject *args) { DWORD dwDesiredAccess; BOOL bInheritHandle; DWORD dwProcessId; HANDLE handle; if (!PyArg_ParseTuple(args, F_DWORD "i" F_DWORD, &dwDesiredAccess, &bInheritHandle, &dwProcessId)) return NULL; handle = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId); if (handle == NULL) return PyErr_SetFromWindowsErr(0); return Py_BuildValue(F_HANDLE, handle); } static PyObject * win32_SetNamedPipeHandleState(PyObject *self, PyObject *args) { HANDLE hNamedPipe; PyObject *oArgs[3]; DWORD dwArgs[3], *pArgs[3] = {NULL, NULL, NULL}; int i; if (!PyArg_ParseTuple(args, F_HANDLE "OOO", &hNamedPipe, &oArgs[0], &oArgs[1], &oArgs[2])) return NULL; PyErr_Clear(); for (i = 0 ; i < 3 ; i++) { if (oArgs[i] != Py_None) { dwArgs[i] = PyInt_AsUnsignedLongMask(oArgs[i]); if (PyErr_Occurred()) return NULL; pArgs[i] = &dwArgs[i]; } } if (!SetNamedPipeHandleState(hNamedPipe, pArgs[0], pArgs[1], pArgs[2])) return PyErr_SetFromWindowsErr(0); Py_RETURN_NONE; } static PyObject * win32_WaitNamedPipe(PyObject *self, PyObject *args) { LPCTSTR lpNamedPipeName; DWORD nTimeOut; BOOL success; if (!PyArg_ParseTuple(args, "s" F_DWORD, &lpNamedPipeName, &nTimeOut)) return NULL; Py_BEGIN_ALLOW_THREADS success = WaitNamedPipe(lpNamedPipeName, nTimeOut); Py_END_ALLOW_THREADS if (!success) return PyErr_SetFromWindowsErr(0); Py_RETURN_NONE; } static PyObject * win32_PeekNamedPipe(PyObject *self, PyObject *args) { HANDLE handle; int size = 0; PyObject *buf = NULL; DWORD nread, navail, nleft; BOOL ret; if (!PyArg_ParseTuple(args, F_HANDLE "|i:PeekNamedPipe" , &handle, &size)) return NULL; if (size < 0) { PyErr_SetString(PyExc_ValueError, "negative size"); return NULL; } if (size) { buf = PyBytes_FromStringAndSize(NULL, size); if (!buf) return NULL; Py_BEGIN_ALLOW_THREADS ret = PeekNamedPipe(handle, PyBytes_AS_STRING(buf), size, &nread, &navail, &nleft); Py_END_ALLOW_THREADS if (!ret) { Py_DECREF(buf); return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); } if (_PyBytes_Resize(&buf, nread)) return NULL; return Py_BuildValue("Nii", buf, navail, nleft); } else { Py_BEGIN_ALLOW_THREADS ret = PeekNamedPipe(handle, NULL, 0, NULL, &navail, &nleft); Py_END_ALLOW_THREADS if (!ret) { return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); } return Py_BuildValue("ii", navail, nleft); } } static PyObject * win32_WriteFile(PyObject *self, PyObject *args, PyObject *kwds) { HANDLE handle; Py_buffer _buf, *buf; PyObject *bufobj; DWORD len, written; BOOL ret; int use_overlapped = 0; DWORD err; OverlappedObject *overlapped = NULL; static char *kwlist[] = {"handle", "buffer", "overlapped", NULL}; /* First get handle and use_overlapped to know which Py_buffer to use */ if (!PyArg_ParseTupleAndKeywords(args, kwds, F_HANDLE "O|i:WriteFile", kwlist, &handle, &bufobj, &use_overlapped)) return NULL; if (use_overlapped) { overlapped = new_overlapped(handle); if (!overlapped) return NULL; buf = &overlapped->write_buffer; } else buf = &_buf; if (!PyArg_Parse(bufobj, "s*", buf)) { Py_XDECREF(overlapped); return NULL; } Py_BEGIN_ALLOW_THREADS len = (DWORD)Py_MIN(buf->len, DWORD_MAX); ret = WriteFile(handle, buf->buf, len, &written, overlapped ? &overlapped->overlapped : NULL); Py_END_ALLOW_THREADS err = ret ? 0 : GetLastError(); if (overlapped) { if (!ret) { if (err == ERROR_IO_PENDING) overlapped->pending = 1; else { Py_DECREF(overlapped); return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); } } return Py_BuildValue("NI", (PyObject *) overlapped, err); } PyBuffer_Release(buf); if (!ret) return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); return Py_BuildValue("II", written, err); } static PyObject * win32_ReadFile(PyObject *self, PyObject *args, PyObject *kwds) { HANDLE handle; int size; DWORD nread; PyObject *buf; BOOL ret; int use_overlapped = 0; DWORD err; OverlappedObject *overlapped = NULL; static char *kwlist[] = {"handle", "size", "overlapped", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, F_HANDLE "i|i:ReadFile", kwlist, &handle, &size, &use_overlapped)) return NULL; buf = PyBytes_FromStringAndSize(NULL, size); if (!buf) return NULL; if (use_overlapped) { overlapped = new_overlapped(handle); if (!overlapped) { Py_DECREF(buf); return NULL; } /* Steals reference to buf */ overlapped->read_buffer = buf; } Py_BEGIN_ALLOW_THREADS ret = ReadFile(handle, PyBytes_AS_STRING(buf), size, &nread, overlapped ? &overlapped->overlapped : NULL); Py_END_ALLOW_THREADS err = ret ? 0 : GetLastError(); if (overlapped) { if (!ret) { if (err == ERROR_IO_PENDING) overlapped->pending = 1; else if (err != ERROR_MORE_DATA) { Py_DECREF(overlapped); return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); } } return Py_BuildValue("NI", (PyObject *) overlapped, err); } if (!ret && err != ERROR_MORE_DATA) { Py_DECREF(buf); return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); } if (_PyBytes_Resize(&buf, nread)) return NULL; return Py_BuildValue("NI", buf, err); } static PyObject * win32_WaitForMultipleObjects(PyObject* self, PyObject* args) { DWORD result; PyObject *handle_seq; HANDLE handles[MAXIMUM_WAIT_OBJECTS]; HANDLE sigint_event = NULL; Py_ssize_t nhandles, i; BOOL wait_flag; DWORD milliseconds = INFINITE; if (!PyArg_ParseTuple(args, "O" F_BOOL "|" F_DWORD ":WaitForMultipleObjects", &handle_seq, &wait_flag, &milliseconds)) return NULL; if (!PySequence_Check(handle_seq)) { PyErr_Format(PyExc_TypeError, "sequence type expected, got '%s'", Py_TYPE(handle_seq)->tp_name); return NULL; } nhandles = PySequence_Length(handle_seq); if (nhandles == -1) return NULL; if (nhandles < 0 || nhandles >= MAXIMUM_WAIT_OBJECTS - 1) { PyErr_Format(PyExc_ValueError, "need at most %zd handles, got a sequence of length %zd", MAXIMUM_WAIT_OBJECTS - 1, nhandles); return NULL; } for (i = 0; i < nhandles; i++) { HANDLE h; PyObject *v = PySequence_GetItem(handle_seq, i); if (v == NULL) return NULL; if (!PyArg_Parse(v, F_HANDLE, &h)) { Py_DECREF(v); return NULL; } handles[i] = h; Py_DECREF(v); } /* If this is the main thread then make the wait interruptible by Ctrl-C unless we are waiting for *all* handles if (!wait_flag && _PyOS_IsMainThread()) { sigint_event = _PyOS_SigintEvent(); assert(sigint_event != NULL); handles[nhandles++] = sigint_event; }*/ Py_BEGIN_ALLOW_THREADS /*if (sigint_event != NULL) ResetEvent(sigint_event);*/ result = WaitForMultipleObjects((DWORD) nhandles, handles, wait_flag, milliseconds); Py_END_ALLOW_THREADS if (result == WAIT_FAILED) return PyErr_SetExcFromWindowsErr(PyExc_IOError, 0); /* else if (sigint_event != NULL && result == WAIT_OBJECT_0 + nhandles - 1) { errno = EINTR; return PyErr_SetFromErrno(PyExc_IOError); }*/ return PyLong_FromLong((int) result); } static PyObject * win32_GetCurrentProcess(PyObject* self, PyObject* args) { if (! PyArg_ParseTuple(args, ":GetCurrentProcess")) return NULL; return HANDLE_TO_PYNUM(GetCurrentProcess()); } static PyObject * win32_DuplicateHandle(PyObject* self, PyObject* args) { HANDLE target_handle; BOOL result; HANDLE source_process_handle; HANDLE source_handle; HANDLE target_process_handle; DWORD desired_access; BOOL inherit_handle; DWORD options = 0; if (! PyArg_ParseTuple(args, F_HANDLE F_HANDLE F_HANDLE F_DWORD F_BOOL F_DWORD ":DuplicateHandle", &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) return NULL; Py_BEGIN_ALLOW_THREADS result = DuplicateHandle( source_process_handle, source_handle, target_process_handle, &target_handle, desired_access, inherit_handle, options ); Py_END_ALLOW_THREADS if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return HANDLE_TO_PYNUM(target_handle); } static PyObject * win32_CreatePipe(PyObject* self, PyObject* args) { HANDLE read_pipe; HANDLE write_pipe; BOOL result; PyObject* pipe_attributes; /* ignored */ DWORD size; if (! PyArg_ParseTuple(args, "O" F_DWORD ":CreatePipe", &pipe_attributes, &size)) return NULL; Py_BEGIN_ALLOW_THREADS result = CreatePipe(&read_pipe, &write_pipe, NULL, size); Py_END_ALLOW_THREADS if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return Py_BuildValue( "NN", HANDLE_TO_PYNUM(read_pipe), HANDLE_TO_PYNUM(write_pipe)); } static PyObject * win32_WaitForSingleObject(PyObject* self, PyObject* args) { DWORD result; HANDLE handle; DWORD milliseconds; if (! PyArg_ParseTuple(args, F_HANDLE F_DWORD ":WaitForSingleObject", &handle, &milliseconds)) return NULL; Py_BEGIN_ALLOW_THREADS result = WaitForSingleObject(handle, milliseconds); Py_END_ALLOW_THREADS if (result == WAIT_FAILED) return PyErr_SetFromWindowsErr(GetLastError()); return PyLong_FromUnsignedLong(result); } static PyObject * win32_GetExitCodeProcess(PyObject* self, PyObject* args) { DWORD exit_code; BOOL result; HANDLE process; if (! PyArg_ParseTuple(args, F_HANDLE ":GetExitCodeProcess", &process)) return NULL; result = GetExitCodeProcess(process, &exit_code); if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return PyLong_FromUnsignedLong(exit_code); } static PyObject * win32_TerminateProcess(PyObject* self, PyObject* args) { BOOL result; HANDLE process; UINT exit_code; if (! PyArg_ParseTuple(args, F_HANDLE F_UINT ":TerminateProcess", &process, &exit_code)) return NULL; result = TerminateProcess(process, exit_code); if (! result) return PyErr_SetFromWindowsErr(GetLastError()); Py_INCREF(Py_None); return Py_None; } static PyMethodDef win32_functions[] = { {"CloseHandle", win32_CloseHandle, METH_VARARGS, ""}, {"GetLastError", win32_GetLastError, METH_NOARGS, ""}, {"OpenProcess", win32_OpenProcess, METH_VARARGS, ""}, {"ExitProcess", win32_ExitProcess, METH_VARARGS, ""}, {"ConnectNamedPipe", (PyCFunction)win32_ConnectNamedPipe, METH_VARARGS | METH_KEYWORDS, ""}, {"CreateFile", win32_CreateFile, METH_VARARGS, ""}, {"WriteFile", (PyCFunction)win32_WriteFile, METH_VARARGS | METH_KEYWORDS, ""}, {"ReadFile", (PyCFunction)win32_ReadFile, METH_VARARGS | METH_KEYWORDS, ""}, {"CreateNamedPipe", win32_CreateNamedPipe, METH_VARARGS, ""}, {"SetNamedPipeHandleState", win32_SetNamedPipeHandleState, METH_VARARGS, ""}, {"WaitNamedPipe", win32_WaitNamedPipe, METH_VARARGS, ""}, {"PeekNamedPipe", win32_PeekNamedPipe, METH_VARARGS, ""}, {"WaitForMultipleObjects", win32_WaitForMultipleObjects, METH_VARARGS, ""}, {"WaitForSingleObject", win32_WaitForSingleObject, METH_VARARGS, ""}, {"GetCurrentProcess", win32_GetCurrentProcess, METH_VARARGS, ""}, {"GetExitCodeProcess", win32_GetExitCodeProcess, METH_VARARGS, ""}, {"TerminateProcess", win32_TerminateProcess, METH_VARARGS, ""}, {"DuplicateHandle", win32_DuplicateHandle, METH_VARARGS, ""}, {"CreatePipe", win32_CreatePipe, METH_VARARGS, ""}, {NULL} }; #define WIN32_CONSTANT(fmt, con) \ PyDict_SetItemString(d, #con, Py_BuildValue(fmt, con)) PyMODINIT_FUNC init_winapi(void) { PyObject *d; PyObject *m; if (PyType_Ready(&OverlappedType) < 0) return NULL; m = Py_InitModule("_winapi", win32_functions); if (!m) return; d = PyModule_GetDict(m); PyDict_SetItemString(d, "Overlapped", (PyObject *) &OverlappedType); /* constants */ WIN32_CONSTANT(F_DWORD, ERROR_ALREADY_EXISTS); WIN32_CONSTANT(F_DWORD, ERROR_PIPE_BUSY); WIN32_CONSTANT(F_DWORD, ERROR_PIPE_CONNECTED); WIN32_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT); WIN32_CONSTANT(F_DWORD, ERROR_MORE_DATA); WIN32_CONSTANT(F_DWORD, ERROR_BROKEN_PIPE); WIN32_CONSTANT(F_DWORD, ERROR_IO_PENDING); WIN32_CONSTANT(F_DWORD, ERROR_NETNAME_DELETED); WIN32_CONSTANT(F_DWORD, ERROR_OPERATION_ABORTED); WIN32_CONSTANT(F_DWORD, GENERIC_READ); WIN32_CONSTANT(F_DWORD, GENERIC_WRITE); WIN32_CONSTANT(F_DWORD, DUPLICATE_SAME_ACCESS); WIN32_CONSTANT(F_DWORD, DUPLICATE_CLOSE_SOURCE); WIN32_CONSTANT(F_DWORD, INFINITE); WIN32_CONSTANT(F_DWORD, NMPWAIT_WAIT_FOREVER); WIN32_CONSTANT(F_DWORD, OPEN_EXISTING); WIN32_CONSTANT(F_DWORD, PIPE_ACCESS_DUPLEX); WIN32_CONSTANT(F_DWORD, PIPE_ACCESS_INBOUND); WIN32_CONSTANT(F_DWORD, PIPE_READMODE_MESSAGE); WIN32_CONSTANT(F_DWORD, PIPE_TYPE_MESSAGE); WIN32_CONSTANT(F_DWORD, PIPE_UNLIMITED_INSTANCES); WIN32_CONSTANT(F_DWORD, PIPE_WAIT); WIN32_CONSTANT(F_DWORD, PROCESS_ALL_ACCESS); WIN32_CONSTANT(F_DWORD, PROCESS_DUP_HANDLE); WIN32_CONSTANT(F_DWORD, WAIT_OBJECT_0); WIN32_CONSTANT(F_DWORD, WAIT_ABANDONED_0); WIN32_CONSTANT(F_DWORD, WAIT_TIMEOUT); WIN32_CONSTANT(F_DWORD, FILE_FLAG_FIRST_PIPE_INSTANCE); WIN32_CONSTANT(F_DWORD, FILE_FLAG_OVERLAPPED); WIN32_CONSTANT(F_DWORD, FILE_GENERIC_READ); WIN32_CONSTANT(F_DWORD, FILE_GENERIC_WRITE); WIN32_CONSTANT("i", NULL); }
47406e6c4a5d92aea2a85ba7df3bb351b899badc
9ceacf33fd96913cac7ef15492c126d96cae6911
/sys/dev/wsfont/spleen5x8.h
bc7c3b0395d7389789a042ca65a0364cdf09b306
[]
no_license
openbsd/src
ab97ef834fd2d5a7f6729814665e9782b586c130
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
refs/heads/master
2023-09-02T18:54:56.624627
2023-09-02T15:16:12
2023-09-02T15:16:12
66,966,208
3,394
1,235
null
2023-08-08T02:42:25
2016-08-30T18:18:25
C
UTF-8
C
false
false
19,610
h
spleen5x8.h
/* $OpenBSD: spleen5x8.h,v 1.9 2021/03/12 14:39:37 fcambus Exp $ */ /* * Copyright (c) 2018-2021 Frederic Cambus <fcambus@openbsd.org> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ static u_char spleen5x8_data[]; struct wsdisplay_font spleen5x8 = { .name = "Spleen 5x8", .index = 0, .firstchar = ' ', .numchars = 128 - ' ', .encoding = WSDISPLAY_FONTENC_ISO, .fontwidth = 5, .fontheight = 8, .stride = 1, .bitorder = WSDISPLAY_FONTORDER_L2R, .byteorder = WSDISPLAY_FONTORDER_L2R, .cookie = NULL, .data = spleen5x8_data }; static u_char spleen5x8_data[] = { 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x50, /* .*.*.... */ 0x50, /* .*.*.... */ 0x50, /* .*.*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x50, /* .*.*.... */ 0xf8, /* *****... */ 0x50, /* .*.*.... */ 0x50, /* .*.*.... */ 0xf8, /* *****... */ 0x50, /* .*.*.... */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x70, /* .***.... */ 0xa0, /* *.*..... */ 0x60, /* .**..... */ 0x30, /* ..**.... */ 0x30, /* ..**.... */ 0xe0, /* ***..... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x90, /* *..*.... */ 0xa0, /* *.*..... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x50, /* .*.*.... */ 0x90, /* *..*.... */ 0x80, /* *....... */ 0x20, /* ..*..... */ 0x50, /* .*.*.... */ 0x50, /* .*.*.... */ 0x60, /* .**..... */ 0xa8, /* *.*.*... */ 0x90, /* *..*.... */ 0x68, /* .**.*... */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x40, /* .*...... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0xf0, /* ****.... */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0xf8, /* *****... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0xb0, /* *.**.... */ 0xd0, /* **.*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x60, /* .**..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x10, /* ...*.... */ 0x60, /* .**..... */ 0x80, /* *....... */ 0xf0, /* ****.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x80, /* *....... */ 0xa0, /* *.*..... */ 0xa0, /* *.*..... */ 0xf0, /* ****.... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x80, /* *....... */ 0xe0, /* ***..... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x80, /* *....... */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x10, /* ...*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x40, /* .*...... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0xb0, /* *.**.... */ 0xb0, /* *.**.... */ 0x80, /* *....... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0xe0, /* ***..... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0x80, /* *....... */ 0xe0, /* ***..... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0xb0, /* *.**.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0xc0, /* **...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0xd0, /* **.*.... */ 0xd0, /* **.*.... */ 0xb0, /* *.**.... */ 0xb0, /* *.**.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x30, /* ..**.... */ 0x00, /* ........ */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0x60, /* .**..... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf8, /* *****... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x10, /* ...*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0x80, /* *....... */ 0xf0, /* ****.... */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x70, /* .***.... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x70, /* .***.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x50, /* .*.*.... */ 0x88, /* *...*... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x40, /* .*...... */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x10, /* ...*.... */ 0x70, /* .***.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x80, /* *....... */ 0x80, /* *....... */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x70, /* .***.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0x80, /* *....... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x30, /* ..**.... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0xe0, /* ***..... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x10, /* ...*.... */ 0xe0, /* ***..... */ 0x80, /* *....... */ 0x80, /* *....... */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x30, /* ..**.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x00, /* ........ */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0xc0, /* **...... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x90, /* *..*.... */ 0xa0, /* *.*..... */ 0xc0, /* **...... */ 0xa0, /* *.*..... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x30, /* ..**.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0xe0, /* ***..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xe0, /* ***..... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x10, /* ...*.... */ 0x10, /* ...*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x90, /* *..*.... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x80, /* *....... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x70, /* .***.... */ 0x80, /* *....... */ 0x60, /* .**..... */ 0x10, /* ...*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0xe0, /* ***..... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x30, /* ..**.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x60, /* .**..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0xf0, /* ****.... */ 0xf0, /* ****.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x60, /* .**..... */ 0x60, /* .**..... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x90, /* *..*.... */ 0x70, /* .***.... */ 0x10, /* ...*.... */ 0xe0, /* ***..... */ 0x00, /* ........ */ 0x00, /* ........ */ 0xf0, /* ****.... */ 0x10, /* ...*.... */ 0x20, /* ..*..... */ 0x40, /* .*...... */ 0xf0, /* ****.... */ 0x00, /* ........ */ 0x30, /* ..**.... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0xc0, /* **...... */ 0xc0, /* **...... */ 0x40, /* .*...... */ 0x40, /* .*...... */ 0x30, /* ..**.... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0xc0, /* **...... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0x30, /* ..**.... */ 0x30, /* ..**.... */ 0x20, /* ..*..... */ 0x20, /* ..*..... */ 0xc0, /* **...... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x48, /* .*..*... */ 0xb0, /* *.**.... */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ 0x00, /* ........ */ };
934b71a1b59592afeb94b0b904f65b9cc227804f
e73547787354afd9b717ea57fe8dd0695d161821
/src/world/area_omo/omo_07/omo_07.h
4b02cc06b82c1fd3ef6f9ea8472cc89517e5c155
[]
no_license
pmret/papermario
8b514b19653cef8d6145e47499b3636b8c474a37
9774b26d93f1045dd2a67e502b6efc9599fb6c31
refs/heads/main
2023-08-31T07:09:48.951514
2023-08-21T18:07:08
2023-08-21T18:07:08
287,151,133
904
139
null
2023-09-14T02:44:23
2020-08-13T01:22:57
C
UTF-8
C
false
false
1,253
h
omo_07.h
/// @file omo_07.h /// @brief Shy Guy's Toybox - PNK Playhouse #include "common.h" #include "message_ids.h" #include "map.h" #include "../omo.h" #include "mapfs/omo_07_shape.h" #include "mapfs/omo_07_hit.h" #include "sprite/npc/ShyGuy.h" #include "sprite/npc/Fuzzy.h" #include "sprite/npc/HammerBros.h" #include "sprite/npc/SkyGuy.h" #include "sprite/npc/WorldKammy.h" enum { NPC_ShyGuy_01 = 1, NPC_ShyGuy_02 = 2, NPC_ShyGuy_03 = 3, NPC_ShyGuy_04 = 4, // never appears NPC_Fuzzy = 5, NPC_HammerBros = 6, NPC_Kammy = 7, NPC_SkyGuy_01 = 8, NPC_SkyGuy_02 = 9, }; enum { MV_SecretDoorAngle = MapVar(0), MV_AmbushID = MapVar(10), // npcID or itemID depending on GB_OMO_PeachChoice1 }; #define NAMESPACE omo_07 extern EvtScript N(EVS_Main); extern EvtScript N(EVS_SetupMusic); extern EvtScript N(EVS_SetupGizmos); extern EvtScript N(EVS_MakeEntities); extern EvtScript N(EVS_SetupShyGuyPool); extern EvtScript N(EVS_Scene_KammySetAmbush); extern EvtScript N(EVS_NpcIdle_Kammy); extern NpcGroupList N(KammySceneNPCs); extern NpcGroupList N(FuzzyAmbushNPCs); extern NpcGroupList N(HammerBrosAmbushNPCs); extern NpcGroupList N(DefaultNPCs);
c727557b273e357afeeaaf6f440ba0bbc19d4824
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/third_party/sqlite3/decimal.shell.c
96118f74ead5da59ebd67e1c6852d84e2b2738f5
[ "ISC", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
41
c
decimal.shell.c
#include "third_party/sqlite3/decimal.c"
e475a0673be8033c1935b485e195d8d611fb932c
70ffcb065027032a399f44b9ec91e7b61d73583d
/ccan/ccan/rbuf/test/run-term-eof.c
0c346d7eac94ee83f9fd3614d501a4baec33843a
[ "MIT", "BSD-3-Clause" ]
permissive
ElementsProject/lightning
4e260841b2ebad8c772a5ff91ef1ebbc3fe1ad71
990096f904e26386527a4eddd8d3262464bacabd
refs/heads/master
2023-09-01T07:11:34.794039
2023-08-31T09:55:14
2023-08-31T22:02:14
37,350,472
2,812
961
NOASSERTION
2023-09-14T19:33:22
2015-06-13T00:04:22
C
UTF-8
C
false
false
1,574
c
run-term-eof.c
#include <ccan/rbuf/rbuf.h> /* Include the C files directly. */ #include <ccan/rbuf/rbuf.c> #include <ccan/tap/tap.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> static bool test_realloc_fail; static void *test_realloc(struct membuf *mb, void *buf, size_t n) { if (test_realloc_fail) return NULL; return realloc(buf, n); } int main(void) { struct rbuf in; char buf[4096], *p; int fd = open("test/run-term-eof.c", O_RDONLY), len; /* This is how many tests you plan to run */ plan_tests(10); /* Grab ourselves for comparison. */ len = read(fd, buf, sizeof(buf)); buf[len] = '\0'; lseek(fd, 0, SEEK_SET); /* We have exact-size buffer, which causes problems adding term. */ rbuf_init(&in, fd, malloc(len), len, test_realloc); test_realloc_fail = true; p = rbuf_read_str(&in, 64); /* At symbol does not appear. */ ok1(errno == ENOMEM); ok1(!p); /* This should succeed... */ test_realloc_fail = false; p = rbuf_read_str(&in, 64); ok1(p); ok1(strcmp(p, buf) == 0); ok1(rbuf_start(&in) == p + strlen(p)); free(rbuf_cleanup(&in)); /* Try again. */ lseek(fd, 0, SEEK_SET); rbuf_init(&in, fd, malloc(len), len, test_realloc); p = rbuf_read_str(&in, 64); ok1(p); ok1(strcmp(p, buf) == 0); ok1(rbuf_start(&in) == p + strlen(p)); free(rbuf_cleanup(&in)); /* Normal case, we get rbuf_start after nul */ lseek(fd, 0, SEEK_SET); rbuf_init(&in, fd, NULL, 0, test_realloc); p = rbuf_read_str(&in, '^'); ok1(p); ok1(rbuf_start(&in) == p + strlen(p) + 1); free(rbuf_cleanup(&in)); return exit_status(); }
3fb4d8349ed3578abf660996f1d27584c9c79cfd
f7a34c7cc3534cd49d4505198c294b607949a26c
/src/YamlCppLib/config.h
3cdb04fafc90f6b5a14b52a1c96654fd84aeed5c
[ "LicenseRef-scancode-generic-cla", "BSL-1.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LGPL-2.1-or-later", "MIT", "BSD-3-Clause" ]
permissive
microsoft/winget-cli
4176b886b257ec562cf6d8a74a9b4410693f9627
f7c1a4499af38608f378a30f0a3e2417ec595529
refs/heads/master
2023-09-06T10:45:08.034474
2023-09-05T23:26:37
2023-09-05T23:26:37
197,275,130
22,630
1,570
MIT
2023-09-14T21:29:31
2019-07-16T22:16:49
C++
UTF-8
C
false
false
123
h
config.h
#define YAML_VERSION_MAJOR 0 #define YAML_VERSION_MINOR 2 #define YAML_VERSION_PATCH 5 #define YAML_VERSION_STRING "0.2.5"
baf22ea53dfeac71e56a44c5b4ef07cbd6768060
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/raspberry-pi/raspi3-32/driver/board.c
a16c62450d9148df3987b7bbdacf86a6afaea904
[ "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
3,760
c
board.c
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2019-07-29 zdzn first version */ #include <rthw.h> #include <rtthread.h> #include "board.h" #include "drv_uart.h" #include "drv_timer.h" #include "cp15.h" #ifdef RT_USING_SMP unsigned int cntfrq; #endif void rt_hw_timer_isr(int vector, void *parameter) { rt_tick_increase(); #ifndef RT_USING_SMP ARM_TIMER_IRQCLR = 0; #else mask_cntv(); __DSB(); write_cntv_tval(cntfrq); __DSB(); unmask_cntv(); __DSB(); #endif } int rt_hw_timer_init() { #ifndef RT_USING_SMP /* timer_clock = apb_clock/(pre_divider + 1) */ ARM_TIMER_PREDIV = (250 - 1); ARM_TIMER_RELOAD = 0; ARM_TIMER_LOAD = 0; ARM_TIMER_IRQCLR = 0; ARM_TIMER_CTRL = 0; ARM_TIMER_RELOAD = 10000; ARM_TIMER_LOAD = 10000; /* 23-bit counter, enable interrupt, enable timer */ ARM_TIMER_CTRL = (1 << 1) | (1 << 5) | (1 << 7); #else __DSB(); cntfrq = 35000; write_cntv_tval(cntfrq); enable_cntv(); __DSB(); enable_cpu_timer_intr(rt_hw_cpu_id()); #endif rt_hw_interrupt_install(IRQ_ARM_TIMER, rt_hw_timer_isr, RT_NULL, "tick"); rt_hw_interrupt_umask(IRQ_ARM_TIMER); return 0; } #ifdef RT_USING_SMP extern void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler); void ipi_handler() { rt_scheduler_ipi_handler(0,RT_NULL); } #endif void idle_wfi(void) { asm volatile ("wfi"); } void rt_hw_board_init(void) { /* initialize hardware interrupt */ rt_hw_interrupt_init(); rt_hw_vector_init(); /* initialize uart */ rt_hw_uart_init(); /* initialize timer for os tick */ rt_hw_timer_init(); rt_thread_idle_sethook(idle_wfi); #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) /* set console device */ rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif #ifdef RT_USING_HEAP /* initialize memory system */ rt_kprintf("heap: 0x%08x - 0x%08x\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); #endif #ifdef RT_USING_SMP /* install IPI handle */ rt_hw_ipi_handler_install(IRQ_ARM_MAILBOX, ipi_handler); rt_hw_interrupt_umask(IRQ_ARM_MAILBOX); enable_cpu_ipi_intr(0); #endif #ifdef RT_USING_COMPONENTS_INIT rt_components_board_init(); #endif } void _reset(void); void secondary_cpu_start(void); #ifdef RT_USING_SMP void rt_hw_secondary_cpu_up(void) { int i; int retry,val; rt_cpu_dcache_clean_flush(); rt_cpu_icache_flush(); /*TODO maybe, there is some bug */ for (i = RT_CPUS_NR - 1; i>0; i-- ) { rt_kprintf("boot cpu:%d\n", i); setup_bootstrap_addr(i, (int)_reset); __SEV(); __DSB(); __ISB(); retry = 10; rt_thread_delay(RT_TICK_PER_SECOND/1000); do { val = CORE_MAILBOX3_CLEAR(i); if (val == 0) { rt_kprintf("start OK: CPU %d \n",i); break; } rt_thread_delay(RT_TICK_PER_SECOND); retry --; if (retry <= 0) { rt_kprintf("can't start for CPU %d \n",i); break; } } while (1); } __DSB(); __SEV(); } void secondary_cpu_c_start(void) { uint32_t id; id = rt_hw_cpu_id(); rt_kprintf("cpu = 0x%08x\n",id); rt_hw_timer_init(); rt_kprintf("cpu %d startup.\n",id); rt_hw_vector_init(); enable_cpu_ipi_intr(id); rt_hw_spin_lock(&_cpus_lock); rt_system_scheduler_start(); } void rt_hw_secondary_cpu_idle_exec(void) { __WFE(); } #endif
b2553a8ae86f37f2d0d28057bad2940367d11dbf
7df190df28da7e4ff166e55dc8ce780f11236a9f
/src/include.v24/include/sbsocram.h
09a7b3e0719da4e7dacb33d19ed3f13e49973e10
[]
no_license
mirror/dd-wrt
25416946e6132aa54b35809de61834a1825a9a36
8f2934a5a2adfbb59b471375aa3a38de5d036531
refs/heads/master
2023-08-31T14:54:47.496685
2023-08-30T17:40:54
2023-08-30T17:40:54
7,470,282
520
281
null
2023-05-29T20:56:24
2013-01-06T17:21:29
null
UTF-8
C
false
false
928
h
sbsocram.h
/* * BCM47XX Sonics SiliconBackplane embedded ram core * * Copyright 2005, Broadcom Corporation * All Rights Reserved. * * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. * * $Id$ */ #ifndef _SBSOCRAM_H #define _SBSOCRAM_H #define SOCRAM_MEMSIZE 0x00 #define SOCRAM_BISTSTAT 0x0c #ifndef _LANGUAGE_ASSEMBLY /* Memcsocram core registers */ typedef volatile struct sbsocramregs { uint32 memsize; uint32 biststat; } sbsocramregs_t; #endif /* Them memory size is 2 to the power of the following * base added to the contents of the memsize register. */ #define SOCRAM_MEMSIZE_BASESHIFT 16 #endif /* _SBSOCRAM_H */
75cb79dd39c8915e8ad229edad472bda9c9d45b3
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/libaom/source/libaom/av1/av1_cx_iface.c
c469ad57308a68f5e2915f4b3730a2c823a4679d
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-2-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
198,300
c
av1_cx_iface.c
/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #include <stdlib.h> #include <string.h> #include "aom_mem/aom_mem.h" #include "config/aom_config.h" #include "config/aom_version.h" #include "aom_ports/mem_ops.h" #include "aom/aom_encoder.h" #include "aom/internal/aom_codec_internal.h" #include "aom_dsp/flow_estimation/flow_estimation.h" #include "av1/av1_iface_common.h" #include "av1/encoder/bitstream.h" #include "av1/encoder/encoder.h" #include "av1/encoder/encoder_alloc.h" #include "av1/encoder/encoder_utils.h" #include "av1/encoder/ethread.h" #include "av1/encoder/external_partition.h" #include "av1/encoder/firstpass.h" #include "av1/encoder/rc_utils.h" #include "av1/arg_defs.h" #include "common/args_helper.h" struct av1_extracfg { int cpu_used; unsigned int enable_auto_alt_ref; unsigned int enable_auto_bwd_ref; unsigned int noise_sensitivity; unsigned int sharpness; unsigned int static_thresh; unsigned int row_mt; unsigned int fp_mt; unsigned int tile_columns; // log2 number of tile columns unsigned int tile_rows; // log2 number of tile rows unsigned int enable_tpl_model; unsigned int enable_keyframe_filtering; unsigned int arnr_max_frames; unsigned int arnr_strength; unsigned int min_gf_interval; unsigned int max_gf_interval; unsigned int gf_min_pyr_height; unsigned int gf_max_pyr_height; aom_tune_metric tuning; const char *vmaf_model_path; const char *partition_info_path; unsigned int enable_rate_guide_deltaq; const char *rate_distribution_info; aom_dist_metric dist_metric; unsigned int cq_level; // constrained quality level unsigned int rc_max_intra_bitrate_pct; unsigned int rc_max_inter_bitrate_pct; unsigned int gf_cbr_boost_pct; unsigned int lossless; unsigned int enable_cdef; unsigned int enable_restoration; unsigned int force_video_mode; unsigned int enable_obmc; unsigned int disable_trellis_quant; unsigned int enable_qm; unsigned int qm_y; unsigned int qm_u; unsigned int qm_v; unsigned int qm_min; unsigned int qm_max; unsigned int num_tg; unsigned int mtu_size; aom_timing_info_type_t timing_info_type; unsigned int frame_parallel_decoding_mode; int enable_dual_filter; unsigned int enable_chroma_deltaq; AQ_MODE aq_mode; DELTAQ_MODE deltaq_mode; int deltaq_strength; int deltalf_mode; unsigned int frame_periodic_boost; aom_bit_depth_t bit_depth; aom_tune_content content; aom_color_primaries_t color_primaries; aom_transfer_characteristics_t transfer_characteristics; aom_matrix_coefficients_t matrix_coefficients; aom_chroma_sample_position_t chroma_sample_position; int color_range; int render_width; int render_height; aom_superblock_size_t superblock_size; unsigned int single_tile_decoding; int error_resilient_mode; int s_frame_mode; int film_grain_test_vector; const char *film_grain_table_filename; unsigned int motion_vector_unit_test; #if CONFIG_FPMT_TEST unsigned int fpmt_unit_test; #endif unsigned int cdf_update_mode; int enable_rect_partitions; // enable rectangular partitions for sequence int enable_ab_partitions; // enable AB partitions for sequence int enable_1to4_partitions; // enable 1:4 and 4:1 partitions for sequence int min_partition_size; // min partition size [4,8,16,32,64,128] int max_partition_size; // max partition size [4,8,16,32,64,128] int enable_intra_edge_filter; // enable intra-edge filter for sequence int enable_order_hint; // enable order hint for sequence int enable_tx64; // enable 64-pt transform usage for sequence int enable_flip_idtx; // enable flip and identity transform types int enable_rect_tx; // enable rectangular transform usage for sequence int enable_dist_wtd_comp; // enable dist wtd compound for sequence int max_reference_frames; // maximum number of references per frame int enable_reduced_reference_set; // enable reduced set of references int enable_ref_frame_mvs; // sequence level int allow_ref_frame_mvs; // frame level int enable_masked_comp; // enable masked compound for sequence int enable_onesided_comp; // enable one sided compound for sequence int enable_interintra_comp; // enable interintra compound for sequence int enable_smooth_interintra; // enable smooth interintra mode usage int enable_diff_wtd_comp; // enable diff-wtd compound usage int enable_interinter_wedge; // enable interinter-wedge compound usage int enable_interintra_wedge; // enable interintra-wedge compound usage int enable_global_motion; // enable global motion usage for sequence int enable_warped_motion; // sequence level int allow_warped_motion; // frame level int enable_filter_intra; // enable filter intra for sequence int enable_smooth_intra; // enable smooth intra modes for sequence int enable_paeth_intra; // enable Paeth intra mode for sequence int enable_cfl_intra; // enable CFL uv intra mode for sequence int enable_directional_intra; // enable directional modes for sequence int enable_diagonal_intra; // enable D45 to D203 intra modes for sequence int enable_superres; int enable_overlay; // enable overlay for filtered arf frames int enable_palette; int enable_intrabc; int enable_angle_delta; #if CONFIG_DENOISE float noise_level; int noise_block_size; int enable_dnl_denoising; #endif unsigned int chroma_subsampling_x; unsigned int chroma_subsampling_y; int reduced_tx_type_set; int use_intra_dct_only; int use_inter_dct_only; int use_intra_default_tx_only; int enable_tx_size_search; int quant_b_adapt; unsigned int vbr_corpus_complexity_lap; AV1_LEVEL target_seq_level_idx[MAX_NUM_OPERATING_POINTS]; // Bit mask to specify which tier each of the 32 possible operating points // conforms to. unsigned int tier_mask; // min_cr / 100 is the target minimum compression ratio for each frame. unsigned int min_cr; COST_UPDATE_TYPE coeff_cost_upd_freq; COST_UPDATE_TYPE mode_cost_upd_freq; COST_UPDATE_TYPE mv_cost_upd_freq; COST_UPDATE_TYPE dv_cost_upd_freq; unsigned int ext_tile_debug; unsigned int sb_multipass_unit_test; // Total number of passes. If this number is -1, then we assume passes = 1 or // 2 (passes = 1 if pass == AOM_RC_ONE_PASS and passes = 2 otherwise). int passes; int fwd_kf_dist; LOOPFILTER_CONTROL loopfilter_control; // Indicates if the application of post-processing filters should be skipped // on reconstructed frame. unsigned int skip_postproc_filtering; // the name of the second pass output file when passes > 2 const char *two_pass_output; const char *second_pass_log; // Automatically determine whether to disable several intra tools // when "--deltaq-mode=3" is true. // Default as 0. // When set to 1, the encoder will analyze the reconstruction quality // as compared to the source image in the preprocessing pass. // If the recontruction quality is considered high enough, we disable // the following intra coding tools, for better encoding speed: // "--enable_smooth_intra", // "--enable_paeth_intra", // "--enable_cfl_intra", // "--enable_diagonal_intra". int auto_intra_tools_off; int strict_level_conformance; int kf_max_pyr_height; int sb_qp_sweep; GlobalMotionMethod global_motion_method; }; #if CONFIG_REALTIME_ONLY // Settings changed for realtime only build: // cpu_used: 7 // enable_tpl_model: 0 // enable_restoration: 0 // enable_obmc: 0 // deltaq_mode: NO_DELTA_Q // enable_global_motion usage: 0 // enable_warped_motion at sequence level: 0 // allow_warped_motion at frame level: 0 // coeff_cost_upd_freq: COST_UPD_OFF // mode_cost_upd_freq: COST_UPD_OFF // mv_cost_upd_freq: COST_UPD_OFF // dv_cost_upd_freq: COST_UPD_OFF static const struct av1_extracfg default_extra_cfg = { 7, // cpu_used 1, // enable_auto_alt_ref 0, // enable_auto_bwd_ref 0, // noise_sensitivity 0, // sharpness 0, // static_thresh 1, // row_mt 0, // fp_mt 0, // tile_columns 0, // tile_rows 0, // enable_tpl_model 1, // enable_keyframe_filtering 7, // arnr_max_frames 5, // arnr_strength 0, // min_gf_interval; 0 -> default decision 0, // max_gf_interval; 0 -> default decision 0, // gf_min_pyr_height 5, // gf_max_pyr_height AOM_TUNE_PSNR, // tuning "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path ".", // partition info path 0, // enable rate guide deltaq "./rate_map.txt", // rate distribution input AOM_DIST_METRIC_PSNR, // dist_metric 10, // cq_level 0, // rc_max_intra_bitrate_pct 0, // rc_max_inter_bitrate_pct 0, // gf_cbr_boost_pct 0, // lossless 1, // enable_cdef 0, // enable_restoration 0, // force_video_mode 0, // enable_obmc 3, // disable_trellis_quant 0, // enable_qm DEFAULT_QM_Y, // qm_y DEFAULT_QM_U, // qm_u DEFAULT_QM_V, // qm_v DEFAULT_QM_FIRST, // qm_min DEFAULT_QM_LAST, // qm_max 1, // max number of tile groups 0, // mtu_size AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream 0, // frame_parallel_decoding_mode 1, // enable dual filter 0, // enable delta quant in chroma planes NO_AQ, // aq_mode NO_DELTA_Q, // deltaq_mode 100, // deltaq_strength 0, // delta lf mode 0, // frame_periodic_boost AOM_BITS_8, // Bit depth AOM_CONTENT_DEFAULT, // content AOM_CICP_CP_UNSPECIFIED, // CICP color primaries AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients AOM_CSP_UNKNOWN, // chroma sample position 0, // color range 0, // render width 0, // render height AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size 1, // this depends on large_scale_tile. 0, // error_resilient_mode off by default. 0, // s_frame_mode off by default. 0, // film_grain_test_vector NULL, // film_grain_table_filename 0, // motion_vector_unit_test #if CONFIG_FPMT_TEST 0, // fpmt_unit_test #endif 1, // CDF update mode 1, // enable rectangular partitions 1, // enable ab shape partitions 1, // enable 1:4 and 4:1 partitions 4, // min_partition_size 128, // max_partition_size 1, // enable intra edge filter 1, // frame order hint 1, // enable 64-pt transform usage 1, // enable flip and identity transform 1, // enable rectangular transform usage 1, // dist-wtd compound 7, // max_reference_frames 0, // enable_reduced_reference_set 1, // enable_ref_frame_mvs sequence level 1, // allow ref_frame_mvs frame level 1, // enable masked compound at sequence level 1, // enable one sided compound at sequence level 1, // enable interintra compound at sequence level 1, // enable smooth interintra mode 1, // enable difference-weighted compound 1, // enable interinter wedge compound 1, // enable interintra wedge compound 0, // enable_global_motion usage 0, // enable_warped_motion at sequence level 0, // allow_warped_motion at frame level 1, // enable filter intra at sequence level 1, // enable smooth intra modes usage for sequence 1, // enable Paeth intra mode usage for sequence 1, // enable CFL uv intra mode usage for sequence 1, // enable directional intra mode usage for sequence 1, // enable D45 to D203 intra mode usage for sequence 1, // superres 1, // enable overlay 1, // enable palette 1, // enable intrabc 1, // enable angle delta #if CONFIG_DENOISE 0, // noise_level 32, // noise_block_size 1, // enable_dnl_denoising #endif 0, // chroma_subsampling_x 0, // chroma_subsampling_y 0, // reduced_tx_type_set 0, // use_intra_dct_only 0, // use_inter_dct_only 0, // use_intra_default_tx_only 1, // enable_tx_size_search 0, // quant_b_adapt 0, // vbr_corpus_complexity_lap { SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, }, // target_seq_level_idx 0, // tier_mask 0, // min_cr COST_UPD_OFF, // coeff_cost_upd_freq COST_UPD_OFF, // mode_cost_upd_freq COST_UPD_OFF, // mv_cost_upd_freq COST_UPD_OFF, // dv_cost_upd_freq 0, // ext_tile_debug 0, // sb_multipass_unit_test -1, // passes -1, // fwd_kf_dist LOOPFILTER_ALL, // loopfilter_control 0, // skip_postproc_filtering NULL, // two_pass_output NULL, // second_pass_log 0, // auto_intra_tools_off 0, // strict_level_conformance -1, // kf_max_pyr_height 0, // sb_qp_sweep GLOBAL_MOTION_METHOD_DISFLOW, // global_motion_method }; #else static const struct av1_extracfg default_extra_cfg = { 0, // cpu_used 1, // enable_auto_alt_ref 0, // enable_auto_bwd_ref 0, // noise_sensitivity 0, // sharpness 0, // static_thresh 1, // row_mt 0, // fp_mt 0, // tile_columns 0, // tile_rows 1, // enable_tpl_model 1, // enable_keyframe_filtering 7, // arnr_max_frames 5, // arnr_strength 0, // min_gf_interval; 0 -> default decision 0, // max_gf_interval; 0 -> default decision 0, // gf_min_pyr_height 5, // gf_max_pyr_height AOM_TUNE_PSNR, // tuning "/usr/local/share/model/vmaf_v0.6.1.json", // VMAF model path ".", // partition info path 0, // enable rate guide deltaq "./rate_map.txt", // rate distribution input AOM_DIST_METRIC_PSNR, // dist_metric 10, // cq_level 0, // rc_max_intra_bitrate_pct 0, // rc_max_inter_bitrate_pct 0, // gf_cbr_boost_pct 0, // lossless 1, // enable_cdef 1, // enable_restoration 0, // force_video_mode 1, // enable_obmc 3, // disable_trellis_quant 0, // enable_qm DEFAULT_QM_Y, // qm_y DEFAULT_QM_U, // qm_u DEFAULT_QM_V, // qm_v DEFAULT_QM_FIRST, // qm_min DEFAULT_QM_LAST, // qm_max 1, // max number of tile groups 0, // mtu_size AOM_TIMING_UNSPECIFIED, // No picture timing signaling in bitstream 0, // frame_parallel_decoding_mode 1, // enable dual filter 0, // enable delta quant in chroma planes NO_AQ, // aq_mode DELTA_Q_OBJECTIVE, // deltaq_mode 100, // deltaq_strength 0, // delta lf mode 0, // frame_periodic_boost AOM_BITS_8, // Bit depth AOM_CONTENT_DEFAULT, // content AOM_CICP_CP_UNSPECIFIED, // CICP color primaries AOM_CICP_TC_UNSPECIFIED, // CICP transfer characteristics AOM_CICP_MC_UNSPECIFIED, // CICP matrix coefficients AOM_CSP_UNKNOWN, // chroma sample position 0, // color range 0, // render width 0, // render height AOM_SUPERBLOCK_SIZE_DYNAMIC, // superblock_size 1, // this depends on large_scale_tile. 0, // error_resilient_mode off by default. 0, // s_frame_mode off by default. 0, // film_grain_test_vector NULL, // film_grain_table_filename 0, // motion_vector_unit_test #if CONFIG_FPMT_TEST 0, // fpmt_unit_test #endif 1, // CDF update mode 1, // enable rectangular partitions 1, // enable ab shape partitions 1, // enable 1:4 and 4:1 partitions 4, // min_partition_size 128, // max_partition_size 1, // enable intra edge filter 1, // frame order hint 1, // enable 64-pt transform usage 1, // enable flip and identity transform 1, // enable rectangular transform usage 1, // dist-wtd compound 7, // max_reference_frames 0, // enable_reduced_reference_set 1, // enable_ref_frame_mvs sequence level 1, // allow ref_frame_mvs frame level 1, // enable masked compound at sequence level 1, // enable one sided compound at sequence level 1, // enable interintra compound at sequence level 1, // enable smooth interintra mode 1, // enable difference-weighted compound 1, // enable interinter wedge compound 1, // enable interintra wedge compound 1, // enable_global_motion usage 1, // enable_warped_motion at sequence level 1, // allow_warped_motion at frame level 1, // enable filter intra at sequence level 1, // enable smooth intra modes usage for sequence 1, // enable Paeth intra mode usage for sequence 1, // enable CFL uv intra mode usage for sequence 1, // enable directional intra mode usage for sequence 1, // enable D45 to D203 intra mode usage for sequence 1, // superres 1, // enable overlay 1, // enable palette 1, // enable intrabc 1, // enable angle delta #if CONFIG_DENOISE 0, // noise_level 32, // noise_block_size 1, // enable_dnl_denoising #endif 0, // chroma_subsampling_x 0, // chroma_subsampling_y 0, // reduced_tx_type_set 0, // use_intra_dct_only 0, // use_inter_dct_only 0, // use_intra_default_tx_only 1, // enable_tx_size_search 0, // quant_b_adapt 0, // vbr_corpus_complexity_lap { SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, SEQ_LEVEL_MAX, }, // target_seq_level_idx 0, // tier_mask 0, // min_cr COST_UPD_SB, // coeff_cost_upd_freq COST_UPD_SB, // mode_cost_upd_freq COST_UPD_SB, // mv_cost_upd_freq COST_UPD_SB, // dv_cost_upd_freq 0, // ext_tile_debug 0, // sb_multipass_unit_test -1, // passes -1, // fwd_kf_dist LOOPFILTER_ALL, // loopfilter_control 0, // skip_postproc_filtering NULL, // two_pass_output NULL, // second_pass_log 0, // auto_intra_tools_off 0, // strict_level_conformance -1, // kf_max_pyr_height 0, // sb_qp_sweep GLOBAL_MOTION_METHOD_DISFLOW, // global_motion_method }; #endif struct aom_codec_alg_priv { aom_codec_priv_t base; aom_codec_enc_cfg_t cfg; struct av1_extracfg extra_cfg; aom_rational64_t timestamp_ratio; aom_codec_pts_t pts_offset; unsigned char pts_offset_initialized; AV1EncoderConfig oxcf; AV1_PRIMARY *ppi; unsigned char *cx_data; size_t cx_data_sz; size_t pending_cx_data_sz; aom_image_t preview_img; aom_enc_frame_flags_t next_frame_flags; aom_codec_pkt_list_decl(256) pkt_list; unsigned int fixed_kf_cntr; // BufferPool that holds all reference frames. BufferPool *buffer_pool; // lookahead instance variables BufferPool *buffer_pool_lap; FIRSTPASS_STATS *frame_stats_buffer; // Number of stats buffers required for look ahead int num_lap_buffers; STATS_BUFFER_CTX stats_buf_context; }; static INLINE int gcd(int64_t a, int b) { int remainder; while (b > 0) { remainder = (int)(a % b); a = b; b = remainder; } return (int)a; } static void reduce_ratio(aom_rational64_t *ratio) { const int denom = gcd(ratio->num, ratio->den); ratio->num /= denom; ratio->den /= denom; } // Called by encoder_encode() only. Must not be called by encoder_init(). static aom_codec_err_t update_error_state( aom_codec_alg_priv_t *ctx, const struct aom_internal_error_info *error) { const aom_codec_err_t res = error->error_code; if (res != AOM_CODEC_OK) ctx->base.err_detail = error->has_detail ? error->detail : NULL; return res; } // This function deep copies a string src to *dst. For default string we will // use a string literal, and otherwise we will allocate memory for the string. static aom_codec_err_t allocate_and_set_string(const char *src, const char *default_src, const char **dst, char *err_detail) { if (!src) { snprintf(err_detail, ARG_ERR_MSG_MAX_LEN, "Null pointer given to a string parameter."); return AOM_CODEC_INVALID_PARAM; } if (*dst && strcmp(src, *dst) == 0) return AOM_CODEC_OK; // If the input is exactly the same as default, we will use the string // literal, so do not free here. if (*dst != default_src) { aom_free((void *)*dst); } if (default_src && strcmp(src, default_src) == 0) { // default_src should be a string literal *dst = default_src; } else { size_t len = strlen(src) + 1; char *tmp = aom_malloc(len * sizeof(*tmp)); if (!tmp) { snprintf(err_detail, ARG_ERR_MSG_MAX_LEN, "Failed to allocate memory for copying parameters."); return AOM_CODEC_MEM_ERROR; } memcpy(tmp, src, len); *dst = tmp; } return 0; } #undef ERROR #define ERROR(str) \ do { \ ctx->base.err_detail = str; \ return AOM_CODEC_INVALID_PARAM; \ } while (0) #define RANGE_CHECK(p, memb, lo, hi) \ do { \ if (!((p)->memb >= (lo) && (p)->memb <= (hi))) \ ERROR(#memb " out of range [" #lo ".." #hi "]"); \ } while (0) #define RANGE_CHECK_HI(p, memb, hi) \ do { \ if (!((p)->memb <= (hi))) ERROR(#memb " out of range [.." #hi "]"); \ } while (0) #define RANGE_CHECK_BOOL(p, memb) \ do { \ if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ } while (0) static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, const aom_codec_enc_cfg_t *cfg, const struct av1_extracfg *extra_cfg) { RANGE_CHECK(cfg, g_w, 1, 65536); // 16 bits available RANGE_CHECK(cfg, g_h, 1, 65536); // 16 bits available RANGE_CHECK_HI(cfg, g_forced_max_frame_width, 65536); // 16 bits available RANGE_CHECK_HI(cfg, g_forced_max_frame_height, 65536); // 16 bits available if (cfg->g_forced_max_frame_width) { RANGE_CHECK_HI(cfg, g_w, cfg->g_forced_max_frame_width); } if (cfg->g_forced_max_frame_height) { RANGE_CHECK_HI(cfg, g_h, cfg->g_forced_max_frame_height); } RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den); RANGE_CHECK_HI(cfg, g_profile, MAX_PROFILES - 1); RANGE_CHECK_HI(cfg, rc_max_quantizer, 63); RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); RANGE_CHECK_BOOL(extra_cfg, lossless); RANGE_CHECK_HI(extra_cfg, aq_mode, AQ_MODE_COUNT - 1); RANGE_CHECK_HI(extra_cfg, deltaq_mode, DELTA_Q_MODE_COUNT - 1); RANGE_CHECK_HI(extra_cfg, deltalf_mode, 1); RANGE_CHECK_HI(extra_cfg, frame_periodic_boost, 1); #if CONFIG_REALTIME_ONLY RANGE_CHECK(cfg, g_usage, AOM_USAGE_REALTIME, AOM_USAGE_REALTIME); #else RANGE_CHECK_HI(cfg, g_usage, AOM_USAGE_ALL_INTRA); #endif RANGE_CHECK_HI(cfg, g_threads, MAX_NUM_THREADS); RANGE_CHECK(cfg, rc_end_usage, AOM_VBR, AOM_Q); RANGE_CHECK_HI(cfg, rc_undershoot_pct, 100); RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100); RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); RANGE_CHECK(cfg, kf_mode, AOM_KF_DISABLED, AOM_KF_AUTO); RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); RANGE_CHECK(cfg, g_pass, AOM_RC_ONE_PASS, AOM_RC_THIRD_PASS); if (cfg->g_pass == AOM_RC_ONE_PASS) { RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_TOTAL_BUFFERS); } else { RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); } if (cfg->g_usage == AOM_USAGE_ALL_INTRA) { RANGE_CHECK_HI(cfg, g_lag_in_frames, 0); RANGE_CHECK_HI(cfg, kf_max_dist, 0); } RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1); RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1); if (extra_cfg->max_gf_interval > 0) { RANGE_CHECK(extra_cfg, max_gf_interval, AOMMAX(2, extra_cfg->min_gf_interval), (MAX_LAG_BUFFERS - 1)); } RANGE_CHECK_HI(extra_cfg, gf_min_pyr_height, 5); RANGE_CHECK_HI(extra_cfg, gf_max_pyr_height, 5); if (extra_cfg->gf_min_pyr_height > extra_cfg->gf_max_pyr_height) { ERROR( "gf_min_pyr_height must be less than or equal to " "gf_max_pyramid_height"); } RANGE_CHECK_HI(cfg, rc_resize_mode, RESIZE_MODES - 1); RANGE_CHECK(cfg, rc_resize_denominator, SCALE_NUMERATOR, SCALE_NUMERATOR << 1); RANGE_CHECK(cfg, rc_resize_kf_denominator, SCALE_NUMERATOR, SCALE_NUMERATOR << 1); RANGE_CHECK_HI(cfg, rc_superres_mode, AOM_SUPERRES_AUTO); RANGE_CHECK(cfg, rc_superres_denominator, SCALE_NUMERATOR, SCALE_NUMERATOR << 1); RANGE_CHECK(cfg, rc_superres_kf_denominator, SCALE_NUMERATOR, SCALE_NUMERATOR << 1); RANGE_CHECK(cfg, rc_superres_qthresh, 1, 63); RANGE_CHECK(cfg, rc_superres_kf_qthresh, 1, 63); RANGE_CHECK_HI(extra_cfg, cdf_update_mode, 2); RANGE_CHECK_HI(extra_cfg, motion_vector_unit_test, 2); #if CONFIG_FPMT_TEST RANGE_CHECK_HI(extra_cfg, fpmt_unit_test, 1); #endif RANGE_CHECK_HI(extra_cfg, sb_multipass_unit_test, 1); RANGE_CHECK_HI(extra_cfg, ext_tile_debug, 1); RANGE_CHECK_HI(extra_cfg, enable_auto_alt_ref, 1); RANGE_CHECK_HI(extra_cfg, enable_auto_bwd_ref, 2); RANGE_CHECK(extra_cfg, cpu_used, 0, (cfg->g_usage == AOM_USAGE_REALTIME) ? 11 : 9); RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6); RANGE_CHECK(extra_cfg, superblock_size, AOM_SUPERBLOCK_SIZE_64X64, AOM_SUPERBLOCK_SIZE_DYNAMIC); RANGE_CHECK_HI(cfg, large_scale_tile, 1); RANGE_CHECK_HI(extra_cfg, single_tile_decoding, 1); RANGE_CHECK_HI(extra_cfg, enable_rate_guide_deltaq, 1); RANGE_CHECK_HI(extra_cfg, row_mt, 1); RANGE_CHECK_HI(extra_cfg, fp_mt, 1); RANGE_CHECK_HI(extra_cfg, tile_columns, 6); RANGE_CHECK_HI(extra_cfg, tile_rows, 6); RANGE_CHECK_HI(cfg, monochrome, 1); if (cfg->large_scale_tile && extra_cfg->aq_mode) ERROR( "Adaptive quantization are not supported in large scale tile " "coding."); RANGE_CHECK_HI(extra_cfg, sharpness, 7); RANGE_CHECK_HI(extra_cfg, arnr_max_frames, 15); RANGE_CHECK_HI(extra_cfg, arnr_strength, 6); RANGE_CHECK_HI(extra_cfg, cq_level, 63); RANGE_CHECK(cfg, g_bit_depth, AOM_BITS_8, AOM_BITS_12); RANGE_CHECK(cfg, g_input_bit_depth, 8, 12); RANGE_CHECK(extra_cfg, content, AOM_CONTENT_DEFAULT, AOM_CONTENT_INVALID - 1); if (cfg->g_pass >= AOM_RC_SECOND_PASS) { const size_t packet_sz = sizeof(FIRSTPASS_STATS); const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); const FIRSTPASS_STATS *stats; if (cfg->rc_twopass_stats_in.buf == NULL) ERROR("rc_twopass_stats_in.buf not set."); if (cfg->rc_twopass_stats_in.sz % packet_sz) ERROR("rc_twopass_stats_in.sz indicates truncated packet."); if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz) ERROR("rc_twopass_stats_in requires at least two packets."); stats = (const FIRSTPASS_STATS *)cfg->rc_twopass_stats_in.buf + n_packets - 1; if ((int)(stats->count + 0.5) != n_packets - 1) ERROR("rc_twopass_stats_in missing EOS stats packet"); } if (extra_cfg->passes != -1 && cfg->g_pass == AOM_RC_ONE_PASS && extra_cfg->passes != 1) { ERROR("One pass encoding but passes != 1."); } if (extra_cfg->passes != -1 && (int)cfg->g_pass > extra_cfg->passes) { ERROR("Current pass is larger than total number of passes."); } if (cfg->g_profile == (unsigned int)PROFILE_1 && cfg->monochrome) { ERROR("Monochrome is not supported in profile 1"); } if (cfg->g_profile <= (unsigned int)PROFILE_1 && cfg->g_bit_depth > AOM_BITS_10) { ERROR("Codec bit-depth 12 not supported in profile < 2"); } if (cfg->g_profile <= (unsigned int)PROFILE_1 && cfg->g_input_bit_depth > 10) { ERROR("Source bit-depth 12 not supported in profile < 2"); } if (cfg->rc_end_usage == AOM_Q) { RANGE_CHECK_HI(cfg, use_fixed_qp_offsets, 1); } else { if (cfg->use_fixed_qp_offsets > 0) { ERROR("--use_fixed_qp_offsets can only be used with --end-usage=q"); } } RANGE_CHECK(extra_cfg, color_primaries, AOM_CICP_CP_BT_709, AOM_CICP_CP_EBU_3213); // Need to check range more precisely to // check for reserved values? RANGE_CHECK(extra_cfg, transfer_characteristics, AOM_CICP_TC_BT_709, AOM_CICP_TC_HLG); RANGE_CHECK(extra_cfg, matrix_coefficients, AOM_CICP_MC_IDENTITY, AOM_CICP_MC_ICTCP); RANGE_CHECK(extra_cfg, color_range, 0, 1); /* Average corpus complexity is supported only in the case of single pass * VBR*/ if (cfg->g_pass == AOM_RC_ONE_PASS && cfg->rc_end_usage == AOM_VBR) RANGE_CHECK_HI(extra_cfg, vbr_corpus_complexity_lap, MAX_VBR_CORPUS_COMPLEXITY); else if (extra_cfg->vbr_corpus_complexity_lap != 0) ERROR( "VBR corpus complexity is supported only in the case of single pass " "VBR mode."); #if !CONFIG_TUNE_BUTTERAUGLI if (extra_cfg->tuning == AOM_TUNE_BUTTERAUGLI) { ERROR( "This error may be related to the wrong configuration options: try to " "set -DCONFIG_TUNE_BUTTERAUGLI=1 at the time CMake is run."); } #endif #if !CONFIG_TUNE_VMAF if (extra_cfg->tuning >= AOM_TUNE_VMAF_WITH_PREPROCESSING && extra_cfg->tuning <= AOM_TUNE_VMAF_NEG_MAX_GAIN) { ERROR( "This error may be related to the wrong configuration options: try to " "set -DCONFIG_TUNE_VMAF=1 at the time CMake is run."); } #endif RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR, AOM_TUNE_VMAF_SALIENCY_MAP); RANGE_CHECK(extra_cfg, dist_metric, AOM_DIST_METRIC_PSNR, AOM_DIST_METRIC_QM_PSNR); RANGE_CHECK(extra_cfg, timing_info_type, AOM_TIMING_UNSPECIFIED, AOM_TIMING_DEC_MODEL); RANGE_CHECK(extra_cfg, film_grain_test_vector, 0, 16); if (extra_cfg->lossless) { if (extra_cfg->aq_mode != 0) ERROR("Only --aq_mode=0 can be used with --lossless=1."); if (extra_cfg->enable_chroma_deltaq) ERROR("Only --enable_chroma_deltaq=0 can be used with --lossless=1."); } RANGE_CHECK(extra_cfg, max_reference_frames, 3, 7); RANGE_CHECK(extra_cfg, enable_reduced_reference_set, 0, 1); RANGE_CHECK_HI(extra_cfg, chroma_subsampling_x, 1); RANGE_CHECK_HI(extra_cfg, chroma_subsampling_y, 1); RANGE_CHECK_HI(extra_cfg, disable_trellis_quant, 3); RANGE_CHECK(extra_cfg, coeff_cost_upd_freq, 0, 3); RANGE_CHECK(extra_cfg, mode_cost_upd_freq, 0, 3); RANGE_CHECK(extra_cfg, mv_cost_upd_freq, 0, 3); RANGE_CHECK(extra_cfg, dv_cost_upd_freq, 0, 3); RANGE_CHECK(extra_cfg, min_partition_size, 4, 128); RANGE_CHECK(extra_cfg, max_partition_size, 4, 128); RANGE_CHECK_HI(extra_cfg, min_partition_size, extra_cfg->max_partition_size); for (int i = 0; i < MAX_NUM_OPERATING_POINTS; ++i) { const int level_idx = extra_cfg->target_seq_level_idx[i]; if (!is_valid_seq_level_idx(level_idx) && level_idx != SEQ_LEVEL_KEEP_STATS) { ERROR("Target sequence level index is invalid"); } } RANGE_CHECK(extra_cfg, deltaq_strength, 0, 1000); RANGE_CHECK_HI(extra_cfg, loopfilter_control, 3); RANGE_CHECK_BOOL(extra_cfg, skip_postproc_filtering); RANGE_CHECK_HI(extra_cfg, enable_cdef, 2); RANGE_CHECK_BOOL(extra_cfg, auto_intra_tools_off); RANGE_CHECK_BOOL(extra_cfg, strict_level_conformance); RANGE_CHECK_BOOL(extra_cfg, sb_qp_sweep); RANGE_CHECK(extra_cfg, global_motion_method, GLOBAL_MOTION_METHOD_FEATURE_MATCH, GLOBAL_MOTION_METHOD_LAST); RANGE_CHECK(extra_cfg, kf_max_pyr_height, -1, 5); if (extra_cfg->kf_max_pyr_height != -1 && extra_cfg->kf_max_pyr_height < (int)extra_cfg->gf_min_pyr_height) { ERROR( "The value of kf-max-pyr-height should not be smaller than " "gf-min-pyr-height"); } return AOM_CODEC_OK; } static aom_codec_err_t validate_img(aom_codec_alg_priv_t *ctx, const aom_image_t *img) { switch (img->fmt) { case AOM_IMG_FMT_YV12: case AOM_IMG_FMT_NV12: case AOM_IMG_FMT_I420: case AOM_IMG_FMT_YV1216: case AOM_IMG_FMT_I42016: break; case AOM_IMG_FMT_I444: case AOM_IMG_FMT_I44416: if (ctx->cfg.g_profile == (unsigned int)PROFILE_0 && !ctx->cfg.monochrome) { ERROR("Invalid image format. I444 images not supported in profile."); } break; case AOM_IMG_FMT_I422: case AOM_IMG_FMT_I42216: if (ctx->cfg.g_profile != (unsigned int)PROFILE_2) { ERROR("Invalid image format. I422 images not supported in profile."); } break; default: ERROR( "Invalid image format. Only YV12, NV12, I420, I422, I444 images are " "supported."); break; } if (img->d_w != ctx->cfg.g_w || img->d_h != ctx->cfg.g_h) ERROR("Image size must match encoder init configuration size"); #if CONFIG_TUNE_BUTTERAUGLI if (ctx->extra_cfg.tuning == AOM_TUNE_BUTTERAUGLI) { if (img->bit_depth > 8) { ERROR("Only 8 bit depth images supported in tune=butteraugli mode."); } if (img->mc != 0 && img->mc != AOM_CICP_MC_BT_709 && img->mc != AOM_CICP_MC_BT_601 && img->mc != AOM_CICP_MC_BT_470_B_G) { ERROR( "Only BT.709 and BT.601 matrix coefficients supported in " "tune=butteraugli mode. Identity matrix is treated as BT.601."); } } #endif return AOM_CODEC_OK; } int av1_get_image_bps(const aom_image_t *img) { switch (img->fmt) { case AOM_IMG_FMT_YV12: case AOM_IMG_FMT_NV12: case AOM_IMG_FMT_I420: return 12; case AOM_IMG_FMT_I422: return 16; case AOM_IMG_FMT_I444: return 24; case AOM_IMG_FMT_YV1216: case AOM_IMG_FMT_I42016: return 24; case AOM_IMG_FMT_I42216: return 32; case AOM_IMG_FMT_I44416: return 48; default: assert(0 && "Invalid image format"); break; } return 0; } // Set appropriate options to disable frame super-resolution. static void disable_superres(SuperResCfg *const superres_cfg) { superres_cfg->superres_mode = AOM_SUPERRES_NONE; superres_cfg->superres_scale_denominator = SCALE_NUMERATOR; superres_cfg->superres_kf_scale_denominator = SCALE_NUMERATOR; superres_cfg->superres_qthresh = 255; superres_cfg->superres_kf_qthresh = 255; } static void update_default_encoder_config(const cfg_options_t *cfg, struct av1_extracfg *extra_cfg) { extra_cfg->enable_cdef = (cfg->disable_cdef == 0) ? 1 : 0; extra_cfg->enable_restoration = (cfg->disable_lr == 0); extra_cfg->superblock_size = (cfg->super_block_size == 64) ? AOM_SUPERBLOCK_SIZE_64X64 : (cfg->super_block_size == 128) ? AOM_SUPERBLOCK_SIZE_128X128 : AOM_SUPERBLOCK_SIZE_DYNAMIC; extra_cfg->enable_warped_motion = (cfg->disable_warp_motion == 0); extra_cfg->enable_dist_wtd_comp = (cfg->disable_dist_wtd_comp == 0); extra_cfg->enable_diff_wtd_comp = (cfg->disable_diff_wtd_comp == 0); extra_cfg->enable_dual_filter = (cfg->disable_dual_filter == 0); extra_cfg->enable_angle_delta = (cfg->disable_intra_angle_delta == 0); extra_cfg->enable_rect_partitions = (cfg->disable_rect_partition_type == 0); extra_cfg->enable_ab_partitions = (cfg->disable_ab_partition_type == 0); extra_cfg->enable_1to4_partitions = (cfg->disable_1to4_partition_type == 0); extra_cfg->max_partition_size = cfg->max_partition_size; extra_cfg->min_partition_size = cfg->min_partition_size; extra_cfg->enable_intra_edge_filter = (cfg->disable_intra_edge_filter == 0); extra_cfg->enable_tx64 = (cfg->disable_tx_64x64 == 0); extra_cfg->enable_flip_idtx = (cfg->disable_flip_idtx == 0); extra_cfg->enable_masked_comp = (cfg->disable_masked_comp == 0); extra_cfg->enable_interintra_comp = (cfg->disable_inter_intra_comp == 0); extra_cfg->enable_smooth_interintra = (cfg->disable_smooth_inter_intra == 0); extra_cfg->enable_interinter_wedge = (cfg->disable_inter_inter_wedge == 0); extra_cfg->enable_interintra_wedge = (cfg->disable_inter_intra_wedge == 0); extra_cfg->enable_global_motion = (cfg->disable_global_motion == 0); extra_cfg->enable_filter_intra = (cfg->disable_filter_intra == 0); extra_cfg->enable_smooth_intra = (cfg->disable_smooth_intra == 0); extra_cfg->enable_paeth_intra = (cfg->disable_paeth_intra == 0); extra_cfg->enable_cfl_intra = (cfg->disable_cfl == 0); extra_cfg->enable_obmc = (cfg->disable_obmc == 0); extra_cfg->enable_palette = (cfg->disable_palette == 0); extra_cfg->enable_intrabc = (cfg->disable_intrabc == 0); extra_cfg->disable_trellis_quant = cfg->disable_trellis_quant; extra_cfg->allow_ref_frame_mvs = (cfg->disable_ref_frame_mv == 0); extra_cfg->enable_ref_frame_mvs = (cfg->disable_ref_frame_mv == 0); extra_cfg->enable_onesided_comp = (cfg->disable_one_sided_comp == 0); extra_cfg->enable_reduced_reference_set = cfg->reduced_reference_set; extra_cfg->reduced_tx_type_set = cfg->reduced_tx_type_set; } static void set_encoder_config(AV1EncoderConfig *oxcf, const aom_codec_enc_cfg_t *cfg, struct av1_extracfg *extra_cfg) { if (cfg->encoder_cfg.init_by_cfg_file) { update_default_encoder_config(&cfg->encoder_cfg, extra_cfg); } TuneCfg *const tune_cfg = &oxcf->tune_cfg; FrameDimensionCfg *const frm_dim_cfg = &oxcf->frm_dim_cfg; TileConfig *const tile_cfg = &oxcf->tile_cfg; ResizeCfg *const resize_cfg = &oxcf->resize_cfg; GFConfig *const gf_cfg = &oxcf->gf_cfg; PartitionCfg *const part_cfg = &oxcf->part_cfg; IntraModeCfg *const intra_mode_cfg = &oxcf->intra_mode_cfg; TxfmSizeTypeCfg *const txfm_cfg = &oxcf->txfm_cfg; CompoundTypeCfg *const comp_type_cfg = &oxcf->comp_type_cfg; SuperResCfg *const superres_cfg = &oxcf->superres_cfg; KeyFrameCfg *const kf_cfg = &oxcf->kf_cfg; DecoderModelCfg *const dec_model_cfg = &oxcf->dec_model_cfg; RateControlCfg *const rc_cfg = &oxcf->rc_cfg; QuantizationCfg *const q_cfg = &oxcf->q_cfg; ColorCfg *const color_cfg = &oxcf->color_cfg; InputCfg *const input_cfg = &oxcf->input_cfg; AlgoCfg *const algo_cfg = &oxcf->algo_cfg; ToolCfg *const tool_cfg = &oxcf->tool_cfg; const int is_vbr = cfg->rc_end_usage == AOM_VBR; oxcf->profile = cfg->g_profile; oxcf->max_threads = (int)cfg->g_threads; switch (cfg->g_usage) { case AOM_USAGE_REALTIME: oxcf->mode = REALTIME; break; case AOM_USAGE_ALL_INTRA: oxcf->mode = ALLINTRA; break; default: oxcf->mode = GOOD; break; } // Set frame-dimension related configuration. frm_dim_cfg->width = cfg->g_w; frm_dim_cfg->height = cfg->g_h; frm_dim_cfg->forced_max_frame_width = cfg->g_forced_max_frame_width; frm_dim_cfg->forced_max_frame_height = cfg->g_forced_max_frame_height; frm_dim_cfg->render_width = extra_cfg->render_width; frm_dim_cfg->render_height = extra_cfg->render_height; // Set input video related configuration. input_cfg->input_bit_depth = cfg->g_input_bit_depth; // guess a frame rate if out of whack, use 30 input_cfg->init_framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num; if (cfg->g_pass >= AOM_RC_SECOND_PASS) { const size_t packet_sz = sizeof(FIRSTPASS_STATS); const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz); input_cfg->limit = n_packets - 1; } else { input_cfg->limit = cfg->g_limit; } input_cfg->chroma_subsampling_x = extra_cfg->chroma_subsampling_x; input_cfg->chroma_subsampling_y = extra_cfg->chroma_subsampling_y; if (input_cfg->init_framerate > 180) { input_cfg->init_framerate = 30; dec_model_cfg->timing_info_present = 0; } // Set Decoder model configuration. if (extra_cfg->timing_info_type == AOM_TIMING_EQUAL || extra_cfg->timing_info_type == AOM_TIMING_DEC_MODEL) { dec_model_cfg->timing_info_present = 1; dec_model_cfg->timing_info.num_units_in_display_tick = cfg->g_timebase.num; dec_model_cfg->timing_info.time_scale = cfg->g_timebase.den; dec_model_cfg->timing_info.num_ticks_per_picture = 1; } else { dec_model_cfg->timing_info_present = 0; } if (extra_cfg->timing_info_type == AOM_TIMING_EQUAL) { dec_model_cfg->timing_info.equal_picture_interval = 1; dec_model_cfg->decoder_model_info_present_flag = 0; dec_model_cfg->display_model_info_present_flag = 1; } else if (extra_cfg->timing_info_type == AOM_TIMING_DEC_MODEL) { dec_model_cfg->num_units_in_decoding_tick = cfg->g_timebase.num; dec_model_cfg->timing_info.equal_picture_interval = 0; dec_model_cfg->decoder_model_info_present_flag = 1; dec_model_cfg->display_model_info_present_flag = 1; } oxcf->pass = cfg->g_pass; // For backward compatibility, assume that if extra_cfg->passes==-1, then // passes = 1 or 2. if (extra_cfg->passes == -1) { if (cfg->g_pass == AOM_RC_ONE_PASS) { oxcf->passes = 1; } else { oxcf->passes = 2; } } else { oxcf->passes = extra_cfg->passes; } // Set Rate Control configuration. rc_cfg->max_intra_bitrate_pct = extra_cfg->rc_max_intra_bitrate_pct; rc_cfg->max_inter_bitrate_pct = extra_cfg->rc_max_inter_bitrate_pct; rc_cfg->gf_cbr_boost_pct = extra_cfg->gf_cbr_boost_pct; rc_cfg->mode = cfg->rc_end_usage; rc_cfg->min_cr = extra_cfg->min_cr; rc_cfg->best_allowed_q = extra_cfg->lossless ? 0 : av1_quantizer_to_qindex(cfg->rc_min_quantizer); rc_cfg->worst_allowed_q = extra_cfg->lossless ? 0 : av1_quantizer_to_qindex(cfg->rc_max_quantizer); rc_cfg->cq_level = av1_quantizer_to_qindex(extra_cfg->cq_level); rc_cfg->under_shoot_pct = cfg->rc_undershoot_pct; rc_cfg->over_shoot_pct = cfg->rc_overshoot_pct; rc_cfg->maximum_buffer_size_ms = is_vbr ? 240000 : cfg->rc_buf_sz; rc_cfg->starting_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_initial_sz; rc_cfg->optimal_buffer_level_ms = is_vbr ? 60000 : cfg->rc_buf_optimal_sz; // Convert target bandwidth from Kbit/s to Bit/s rc_cfg->target_bandwidth = 1000 * cfg->rc_target_bitrate; rc_cfg->drop_frames_water_mark = cfg->rc_dropframe_thresh; rc_cfg->vbr_corpus_complexity_lap = extra_cfg->vbr_corpus_complexity_lap; rc_cfg->vbrbias = cfg->rc_2pass_vbr_bias_pct; rc_cfg->vbrmin_section = cfg->rc_2pass_vbr_minsection_pct; rc_cfg->vbrmax_section = cfg->rc_2pass_vbr_maxsection_pct; // Set Toolset related configuration. tool_cfg->bit_depth = cfg->g_bit_depth; tool_cfg->cdef_control = (CDEF_CONTROL)extra_cfg->enable_cdef; tool_cfg->enable_restoration = (cfg->g_usage == AOM_USAGE_REALTIME) ? 0 : extra_cfg->enable_restoration; tool_cfg->force_video_mode = extra_cfg->force_video_mode; tool_cfg->enable_palette = extra_cfg->enable_palette; // FIXME(debargha): Should this be: // tool_cfg->enable_ref_frame_mvs = extra_cfg->allow_ref_frame_mvs & // extra_cfg->enable_order_hint ? // Disallow using temporal MVs while large_scale_tile = 1. tool_cfg->enable_ref_frame_mvs = extra_cfg->allow_ref_frame_mvs && !cfg->large_scale_tile; tool_cfg->superblock_size = extra_cfg->superblock_size; tool_cfg->enable_monochrome = cfg->monochrome; tool_cfg->full_still_picture_hdr = cfg->full_still_picture_hdr != 0; tool_cfg->enable_dual_filter = extra_cfg->enable_dual_filter; tool_cfg->enable_order_hint = extra_cfg->enable_order_hint; tool_cfg->enable_interintra_comp = extra_cfg->enable_interintra_comp; tool_cfg->ref_frame_mvs_present = extra_cfg->enable_ref_frame_mvs & extra_cfg->enable_order_hint; // Explicitly disable global motion in a few cases: // * For realtime mode, we never search global motion, and disabling // it here prevents later code from allocating buffers we don't need // * For large scale tile mode, some of the intended use cases expect // all frame headers to be identical. This breaks if global motion is // used, since global motion data is stored in the frame header. // eg, see test/lightfield_test.sh, which checks that all frame headers // are the same. tool_cfg->enable_global_motion = extra_cfg->enable_global_motion && cfg->g_usage != AOM_USAGE_REALTIME && !cfg->large_scale_tile; tool_cfg->error_resilient_mode = cfg->g_error_resilient | extra_cfg->error_resilient_mode; tool_cfg->frame_parallel_decoding_mode = extra_cfg->frame_parallel_decoding_mode; // Set Quantization related configuration. q_cfg->using_qm = extra_cfg->enable_qm; q_cfg->qm_minlevel = extra_cfg->qm_min; q_cfg->qm_maxlevel = extra_cfg->qm_max; q_cfg->quant_b_adapt = extra_cfg->quant_b_adapt; q_cfg->enable_chroma_deltaq = extra_cfg->enable_chroma_deltaq; q_cfg->aq_mode = extra_cfg->aq_mode; q_cfg->deltaq_mode = extra_cfg->deltaq_mode; q_cfg->deltaq_strength = extra_cfg->deltaq_strength; q_cfg->use_fixed_qp_offsets = cfg->use_fixed_qp_offsets && (rc_cfg->mode == AOM_Q); q_cfg->enable_hdr_deltaq = (q_cfg->deltaq_mode == DELTA_Q_HDR) && (cfg->g_bit_depth == AOM_BITS_10) && (extra_cfg->color_primaries == AOM_CICP_CP_BT_2020); tool_cfg->enable_deltalf_mode = (q_cfg->deltaq_mode != NO_DELTA_Q) && extra_cfg->deltalf_mode; // Set cost update frequency configuration. oxcf->cost_upd_freq.coeff = (COST_UPDATE_TYPE)extra_cfg->coeff_cost_upd_freq; oxcf->cost_upd_freq.mode = (COST_UPDATE_TYPE)extra_cfg->mode_cost_upd_freq; // Avoid MV cost update for allintra encoding mode. oxcf->cost_upd_freq.mv = (cfg->kf_max_dist != 0) ? (COST_UPDATE_TYPE)extra_cfg->mv_cost_upd_freq : COST_UPD_OFF; oxcf->cost_upd_freq.dv = (COST_UPDATE_TYPE)extra_cfg->dv_cost_upd_freq; // Set frame resize mode configuration. resize_cfg->resize_mode = (RESIZE_MODE)cfg->rc_resize_mode; resize_cfg->resize_scale_denominator = (uint8_t)cfg->rc_resize_denominator; resize_cfg->resize_kf_scale_denominator = (uint8_t)cfg->rc_resize_kf_denominator; if (resize_cfg->resize_mode == RESIZE_FIXED && resize_cfg->resize_scale_denominator == SCALE_NUMERATOR && resize_cfg->resize_kf_scale_denominator == SCALE_NUMERATOR) resize_cfg->resize_mode = RESIZE_NONE; // Set encoder algorithm related configuration. algo_cfg->enable_overlay = extra_cfg->enable_overlay; algo_cfg->disable_trellis_quant = extra_cfg->disable_trellis_quant; algo_cfg->sharpness = extra_cfg->sharpness; algo_cfg->arnr_max_frames = extra_cfg->arnr_max_frames; algo_cfg->arnr_strength = extra_cfg->arnr_strength; algo_cfg->cdf_update_mode = (uint8_t)extra_cfg->cdf_update_mode; // TODO(any): Fix and Enable TPL for resize-mode > 0 algo_cfg->enable_tpl_model = resize_cfg->resize_mode ? 0 : extra_cfg->enable_tpl_model; algo_cfg->loopfilter_control = extra_cfg->loopfilter_control; algo_cfg->skip_postproc_filtering = extra_cfg->skip_postproc_filtering; // Set two-pass stats configuration. oxcf->twopass_stats_in = cfg->rc_twopass_stats_in; if (extra_cfg->two_pass_output) oxcf->two_pass_output = extra_cfg->two_pass_output; oxcf->second_pass_log = extra_cfg->second_pass_log; // Set Key frame configuration. kf_cfg->fwd_kf_enabled = cfg->fwd_kf_enabled; kf_cfg->auto_key = cfg->kf_mode == AOM_KF_AUTO && cfg->kf_min_dist != cfg->kf_max_dist; kf_cfg->key_freq_min = cfg->kf_min_dist; kf_cfg->key_freq_max = cfg->kf_max_dist; kf_cfg->sframe_dist = cfg->sframe_dist; kf_cfg->sframe_mode = cfg->sframe_mode; kf_cfg->enable_sframe = extra_cfg->s_frame_mode; kf_cfg->enable_keyframe_filtering = extra_cfg->enable_keyframe_filtering; kf_cfg->fwd_kf_dist = extra_cfg->fwd_kf_dist; // Disable key frame filtering in all intra mode. if (cfg->kf_max_dist == 0) { kf_cfg->enable_keyframe_filtering = 0; } kf_cfg->enable_intrabc = extra_cfg->enable_intrabc; oxcf->speed = extra_cfg->cpu_used; // TODO(yunqingwang, any) In REALTIME mode, 1080p performance at speed 5 & 6 // is quite bad. Force to use speed 7 for now. Will investigate it when we // work on rd path optimization later. if (oxcf->mode == REALTIME && AOMMIN(cfg->g_w, cfg->g_h) >= 1080 && oxcf->speed < 7) oxcf->speed = 7; // Set Color related configuration. color_cfg->color_primaries = extra_cfg->color_primaries; color_cfg->transfer_characteristics = extra_cfg->transfer_characteristics; color_cfg->matrix_coefficients = extra_cfg->matrix_coefficients; color_cfg->color_range = extra_cfg->color_range; color_cfg->chroma_sample_position = extra_cfg->chroma_sample_position; // Set Group of frames configuration. // Force lag_in_frames to 0 for REALTIME mode gf_cfg->lag_in_frames = (oxcf->mode == REALTIME) ? 0 : clamp(cfg->g_lag_in_frames, 0, MAX_LAG_BUFFERS); gf_cfg->enable_auto_arf = extra_cfg->enable_auto_alt_ref; gf_cfg->enable_auto_brf = extra_cfg->enable_auto_bwd_ref; gf_cfg->min_gf_interval = extra_cfg->min_gf_interval; gf_cfg->max_gf_interval = extra_cfg->max_gf_interval; gf_cfg->gf_min_pyr_height = extra_cfg->gf_min_pyr_height; gf_cfg->gf_max_pyr_height = extra_cfg->gf_max_pyr_height; // Set tune related configuration. tune_cfg->tuning = extra_cfg->tuning; tune_cfg->vmaf_model_path = extra_cfg->vmaf_model_path; tune_cfg->content = extra_cfg->content; if (cfg->large_scale_tile) { tune_cfg->film_grain_test_vector = 0; tune_cfg->film_grain_table_filename = NULL; } else { tune_cfg->film_grain_test_vector = extra_cfg->film_grain_test_vector; tune_cfg->film_grain_table_filename = extra_cfg->film_grain_table_filename; } tune_cfg->dist_metric = extra_cfg->dist_metric; #if CONFIG_DENOISE oxcf->noise_level = extra_cfg->noise_level; oxcf->noise_block_size = extra_cfg->noise_block_size; oxcf->enable_dnl_denoising = extra_cfg->enable_dnl_denoising; #endif #if CONFIG_AV1_TEMPORAL_DENOISING // Temporal denoiser is for nonrd pickmode so disable it for speed < 7. // Also disable it for speed 7 for now since it needs to be modified for // the check_partition_merge_mode feature. if (cfg->g_bit_depth == AOM_BITS_8 && oxcf->speed > 7) { oxcf->noise_sensitivity = extra_cfg->noise_sensitivity; } else { oxcf->noise_sensitivity = 0; } #endif // Set Tile related configuration. tile_cfg->num_tile_groups = extra_cfg->num_tg; // In large-scale tile encoding mode, num_tile_groups is always 1. if (cfg->large_scale_tile) tile_cfg->num_tile_groups = 1; tile_cfg->mtu = extra_cfg->mtu_size; tile_cfg->enable_large_scale_tile = cfg->large_scale_tile; tile_cfg->enable_single_tile_decoding = (tile_cfg->enable_large_scale_tile) ? extra_cfg->single_tile_decoding : 0; tile_cfg->tile_columns = extra_cfg->tile_columns; tile_cfg->tile_rows = extra_cfg->tile_rows; tile_cfg->tile_width_count = AOMMIN(cfg->tile_width_count, MAX_TILE_COLS); tile_cfg->tile_height_count = AOMMIN(cfg->tile_height_count, MAX_TILE_ROWS); for (int i = 0; i < tile_cfg->tile_width_count; i++) { tile_cfg->tile_widths[i] = cfg->tile_widths[i]; } for (int i = 0; i < tile_cfg->tile_height_count; i++) { tile_cfg->tile_heights[i] = cfg->tile_heights[i]; } tile_cfg->enable_ext_tile_debug = extra_cfg->ext_tile_debug; if (tile_cfg->enable_large_scale_tile) { // The superblock_size can only be AOM_SUPERBLOCK_SIZE_64X64 or // AOM_SUPERBLOCK_SIZE_128X128 while tile_cfg->enable_large_scale_tile = 1. // If superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC, hard set it to // AOM_SUPERBLOCK_SIZE_64X64(default value in large_scale_tile). if (extra_cfg->superblock_size != AOM_SUPERBLOCK_SIZE_64X64 && extra_cfg->superblock_size != AOM_SUPERBLOCK_SIZE_128X128) tool_cfg->superblock_size = AOM_SUPERBLOCK_SIZE_64X64; } // Set reference frame related configuration. oxcf->ref_frm_cfg.max_reference_frames = extra_cfg->max_reference_frames; oxcf->ref_frm_cfg.enable_reduced_reference_set = extra_cfg->enable_reduced_reference_set; oxcf->ref_frm_cfg.enable_onesided_comp = extra_cfg->enable_onesided_comp; oxcf->row_mt = extra_cfg->row_mt; oxcf->fp_mt = extra_cfg->fp_mt; // Set motion mode related configuration. oxcf->motion_mode_cfg.enable_obmc = extra_cfg->enable_obmc; oxcf->motion_mode_cfg.enable_warped_motion = extra_cfg->enable_warped_motion; #if !CONFIG_REALTIME_ONLY if (cfg->g_usage == AOM_USAGE_REALTIME && oxcf->speed >= 7 && oxcf->tune_cfg.content == AOM_CONTENT_SCREEN) { // TODO(marpan): warped motion is causing a crash for RT mode with screen // in nonrd (speed >= 7), for non-realtime build. // Re-enable/allow when the issue is fixed. oxcf->motion_mode_cfg.enable_warped_motion = 0; oxcf->motion_mode_cfg.allow_warped_motion = 0; } else { oxcf->motion_mode_cfg.allow_warped_motion = (extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion); } #else oxcf->motion_mode_cfg.allow_warped_motion = (cfg->g_usage == AOM_USAGE_REALTIME && oxcf->speed >= 7) ? false : (extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion); #endif // Set partition related configuration. part_cfg->enable_rect_partitions = extra_cfg->enable_rect_partitions; part_cfg->enable_ab_partitions = extra_cfg->enable_ab_partitions; part_cfg->enable_1to4_partitions = extra_cfg->enable_1to4_partitions; part_cfg->min_partition_size = extra_cfg->min_partition_size; part_cfg->max_partition_size = extra_cfg->max_partition_size; // Set intra mode configuration. intra_mode_cfg->enable_angle_delta = extra_cfg->enable_angle_delta; intra_mode_cfg->enable_intra_edge_filter = extra_cfg->enable_intra_edge_filter; intra_mode_cfg->enable_filter_intra = extra_cfg->enable_filter_intra; intra_mode_cfg->enable_smooth_intra = extra_cfg->enable_smooth_intra; intra_mode_cfg->enable_paeth_intra = extra_cfg->enable_paeth_intra; intra_mode_cfg->enable_cfl_intra = extra_cfg->enable_cfl_intra; intra_mode_cfg->enable_directional_intra = extra_cfg->enable_directional_intra; intra_mode_cfg->enable_diagonal_intra = extra_cfg->enable_diagonal_intra; intra_mode_cfg->auto_intra_tools_off = extra_cfg->auto_intra_tools_off; // Set transform size/type configuration. txfm_cfg->enable_tx64 = extra_cfg->enable_tx64; txfm_cfg->enable_flip_idtx = extra_cfg->enable_flip_idtx; txfm_cfg->enable_rect_tx = extra_cfg->enable_rect_tx; txfm_cfg->reduced_tx_type_set = extra_cfg->reduced_tx_type_set; txfm_cfg->use_intra_dct_only = extra_cfg->use_intra_dct_only; txfm_cfg->use_inter_dct_only = extra_cfg->use_inter_dct_only; txfm_cfg->use_intra_default_tx_only = extra_cfg->use_intra_default_tx_only; txfm_cfg->enable_tx_size_search = extra_cfg->enable_tx_size_search; // Set compound type configuration. comp_type_cfg->enable_dist_wtd_comp = extra_cfg->enable_dist_wtd_comp & extra_cfg->enable_order_hint; comp_type_cfg->enable_masked_comp = extra_cfg->enable_masked_comp; comp_type_cfg->enable_diff_wtd_comp = extra_cfg->enable_masked_comp & extra_cfg->enable_diff_wtd_comp; comp_type_cfg->enable_interinter_wedge = extra_cfg->enable_masked_comp & extra_cfg->enable_interinter_wedge; comp_type_cfg->enable_smooth_interintra = extra_cfg->enable_interintra_comp && extra_cfg->enable_smooth_interintra; comp_type_cfg->enable_interintra_wedge = extra_cfg->enable_interintra_comp & extra_cfg->enable_interintra_wedge; // Set Super-resolution mode configuration. if (extra_cfg->lossless || cfg->large_scale_tile) { disable_superres(superres_cfg); } else { superres_cfg->superres_mode = cfg->rc_superres_mode; superres_cfg->superres_scale_denominator = (uint8_t)cfg->rc_superres_denominator; superres_cfg->superres_kf_scale_denominator = (uint8_t)cfg->rc_superres_kf_denominator; superres_cfg->superres_qthresh = av1_quantizer_to_qindex(cfg->rc_superres_qthresh); superres_cfg->superres_kf_qthresh = av1_quantizer_to_qindex(cfg->rc_superres_kf_qthresh); if (superres_cfg->superres_mode == AOM_SUPERRES_FIXED && superres_cfg->superres_scale_denominator == SCALE_NUMERATOR && superres_cfg->superres_kf_scale_denominator == SCALE_NUMERATOR) { disable_superres(superres_cfg); } if (superres_cfg->superres_mode == AOM_SUPERRES_QTHRESH && superres_cfg->superres_qthresh == 255 && superres_cfg->superres_kf_qthresh == 255) { disable_superres(superres_cfg); } } superres_cfg->enable_superres = (superres_cfg->superres_mode != AOM_SUPERRES_NONE) && extra_cfg->enable_superres; if (!superres_cfg->enable_superres) { disable_superres(superres_cfg); } if (input_cfg->limit == 1) { // still picture mode, display model and timing is meaningless dec_model_cfg->display_model_info_present_flag = 0; dec_model_cfg->timing_info_present = 0; } oxcf->save_as_annexb = cfg->save_as_annexb; // Set unit test related configuration. oxcf->unit_test_cfg.motion_vector_unit_test = extra_cfg->motion_vector_unit_test; oxcf->unit_test_cfg.sb_multipass_unit_test = extra_cfg->sb_multipass_unit_test; oxcf->border_in_pixels = av1_get_enc_border_size(av1_is_resize_needed(oxcf), (oxcf->kf_cfg.key_freq_max == 0), BLOCK_128X128); memcpy(oxcf->target_seq_level_idx, extra_cfg->target_seq_level_idx, sizeof(oxcf->target_seq_level_idx)); oxcf->tier_mask = extra_cfg->tier_mask; oxcf->partition_info_path = extra_cfg->partition_info_path; oxcf->enable_rate_guide_deltaq = extra_cfg->enable_rate_guide_deltaq; oxcf->rate_distribution_info = extra_cfg->rate_distribution_info; oxcf->strict_level_conformance = extra_cfg->strict_level_conformance; oxcf->kf_max_pyr_height = extra_cfg->kf_max_pyr_height; oxcf->sb_qp_sweep = extra_cfg->sb_qp_sweep; oxcf->global_motion_method = extra_cfg->global_motion_method; } AV1EncoderConfig av1_get_encoder_config(const aom_codec_enc_cfg_t *cfg) { AV1EncoderConfig oxcf; struct av1_extracfg extra_cfg = default_extra_cfg; set_encoder_config(&oxcf, cfg, &extra_cfg); return oxcf; } static aom_codec_err_t encoder_set_config(aom_codec_alg_priv_t *ctx, const aom_codec_enc_cfg_t *cfg) { InitialDimensions *const initial_dimensions = &ctx->ppi->cpi->initial_dimensions; aom_codec_err_t res; int force_key = 0; if (cfg->g_w != ctx->cfg.g_w || cfg->g_h != ctx->cfg.g_h) { if (cfg->g_lag_in_frames > 1 || cfg->g_pass != AOM_RC_ONE_PASS) ERROR("Cannot change width or height after initialization"); if (!valid_ref_frame_size(ctx->cfg.g_w, ctx->cfg.g_h, cfg->g_w, cfg->g_h) || (initial_dimensions->width && (int)cfg->g_w > initial_dimensions->width) || (initial_dimensions->height && (int)cfg->g_h > initial_dimensions->height)) force_key = 1; } // Prevent increasing lag_in_frames. This check is stricter than it needs // to be -- the limit is not increasing past the first lag_in_frames // value, but we don't track the initial config, only the last successful // config. if (cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames) ERROR("Cannot increase lag_in_frames"); // Prevent changing lag_in_frames if Lookahead Processing is enabled if (cfg->g_lag_in_frames != ctx->cfg.g_lag_in_frames && ctx->num_lap_buffers > 0) ERROR("Cannot change lag_in_frames if LAP is enabled"); res = validate_config(ctx, cfg, &ctx->extra_cfg); if (res == AOM_CODEC_OK) { ctx->cfg = *cfg; set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); // On profile change, request a key frame force_key |= ctx->ppi->seq_params.profile != ctx->oxcf.profile; bool is_sb_size_changed = false; av1_change_config_seq(ctx->ppi, &ctx->oxcf, &is_sb_size_changed); for (int i = 0; i < ctx->ppi->num_fp_contexts; i++) { av1_change_config(ctx->ppi->parallel_cpi[i], &ctx->oxcf, is_sb_size_changed); } if (ctx->ppi->cpi_lap != NULL) { av1_change_config(ctx->ppi->cpi_lap, &ctx->oxcf, is_sb_size_changed); } } if (force_key) ctx->next_frame_flags |= AOM_EFLAG_FORCE_KF; return res; } static aom_fixed_buf_t *encoder_get_global_headers(aom_codec_alg_priv_t *ctx) { return av1_get_global_headers(ctx->ppi); } static aom_codec_err_t ctrl_get_quantizer(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; *arg = av1_get_quantizer(ctx->ppi->cpi); return AOM_CODEC_OK; } static aom_codec_err_t ctrl_get_quantizer64(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; *arg = av1_qindex_to_quantizer(av1_get_quantizer(ctx->ppi->cpi)); return AOM_CODEC_OK; } static aom_codec_err_t ctrl_get_loopfilter_level(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; *arg = ctx->ppi->cpi->common.lf.filter_level[0]; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_get_baseline_gf_interval(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; *arg = ctx->ppi->p_rc.baseline_gf_interval; return AOM_CODEC_OK; } static aom_codec_err_t update_extra_cfg(aom_codec_alg_priv_t *ctx, const struct av1_extracfg *extra_cfg) { const aom_codec_err_t res = validate_config(ctx, &ctx->cfg, extra_cfg); if (res == AOM_CODEC_OK) { ctx->extra_cfg = *extra_cfg; set_encoder_config(&ctx->oxcf, &ctx->cfg, &ctx->extra_cfg); av1_check_fpmt_config(ctx->ppi, &ctx->oxcf); bool is_sb_size_changed = false; av1_change_config_seq(ctx->ppi, &ctx->oxcf, &is_sb_size_changed); for (int i = 0; i < ctx->ppi->num_fp_contexts; i++) { av1_change_config(ctx->ppi->parallel_cpi[i], &ctx->oxcf, is_sb_size_changed); } if (ctx->ppi->cpi_lap != NULL) { av1_change_config(ctx->ppi->cpi_lap, &ctx->oxcf, is_sb_size_changed); } } return res; } static aom_codec_err_t ctrl_set_cpuused(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.cpu_used = CAST(AOME_SET_CPUUSED, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_auto_alt_ref(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_auto_alt_ref = CAST(AOME_SET_ENABLEAUTOALTREF, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_auto_bwd_ref(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_auto_bwd_ref = CAST(AOME_SET_ENABLEAUTOBWDREF, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_noise_sensitivity(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.noise_sensitivity = CAST(AV1E_SET_NOISE_SENSITIVITY, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_sharpness(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.sharpness = CAST(AOME_SET_SHARPNESS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_static_thresh(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.static_thresh = CAST(AOME_SET_STATIC_THRESHOLD, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_row_mt(aom_codec_alg_priv_t *ctx, va_list args) { unsigned int row_mt = CAST(AV1E_SET_ROW_MT, args); if (row_mt == ctx->extra_cfg.row_mt) return AOM_CODEC_OK; struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.row_mt = row_mt; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_tile_columns(aom_codec_alg_priv_t *ctx, va_list args) { unsigned int tile_columns = CAST(AV1E_SET_TILE_COLUMNS, args); if (tile_columns == ctx->extra_cfg.tile_columns) return AOM_CODEC_OK; struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.tile_columns = tile_columns; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_tile_rows(aom_codec_alg_priv_t *ctx, va_list args) { unsigned int tile_rows = CAST(AV1E_SET_TILE_ROWS, args); if (tile_rows == ctx->extra_cfg.tile_rows) return AOM_CODEC_OK; struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.tile_rows = tile_rows; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_tpl_model(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const unsigned int tpl_model_arg = CAST(AV1E_SET_ENABLE_TPL_MODEL, args); #if CONFIG_REALTIME_ONLY if (tpl_model_arg) { ERROR("TPL model can't be turned on in realtime only build."); } #endif extra_cfg.enable_tpl_model = tpl_model_arg; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_keyframe_filtering( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_keyframe_filtering = CAST(AV1E_SET_ENABLE_KEYFRAME_FILTERING, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_arnr_max_frames(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.arnr_max_frames = CAST(AOME_SET_ARNR_MAXFRAMES, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_arnr_strength(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.arnr_strength = CAST(AOME_SET_ARNR_STRENGTH, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_tuning(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.tuning = CAST(AOME_SET_TUNING, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_cq_level(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.cq_level = CAST(AOME_SET_CQ_LEVEL, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_rc_max_intra_bitrate_pct( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.rc_max_intra_bitrate_pct = CAST(AOME_SET_MAX_INTRA_BITRATE_PCT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_rc_max_inter_bitrate_pct( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.rc_max_inter_bitrate_pct = CAST(AOME_SET_MAX_INTER_BITRATE_PCT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_rc_gf_cbr_boost_pct(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.gf_cbr_boost_pct = CAST(AV1E_SET_GF_CBR_BOOST_PCT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_lossless(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.lossless = CAST(AV1E_SET_LOSSLESS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_cdef(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_cdef = CAST(AV1E_SET_ENABLE_CDEF, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_restoration(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const unsigned int restoration_arg = CAST(AV1E_SET_ENABLE_RESTORATION, args); #if CONFIG_REALTIME_ONLY if (restoration_arg) { ERROR("Restoration can't be turned on in realtime only build."); } #endif extra_cfg.enable_restoration = restoration_arg; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_force_video_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.force_video_mode = CAST(AV1E_SET_FORCE_VIDEO_MODE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_obmc(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const unsigned int obmc_arg = CAST(AV1E_SET_ENABLE_OBMC, args); #if CONFIG_REALTIME_ONLY if (obmc_arg) { ERROR("OBMC can't be enabled in realtime only build."); } #endif extra_cfg.enable_obmc = obmc_arg; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_disable_trellis_quant(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.disable_trellis_quant = CAST(AV1E_SET_DISABLE_TRELLIS_QUANT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_qm(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_qm = CAST(AV1E_SET_ENABLE_QM, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_qm_y(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.qm_y = CAST(AV1E_SET_QM_Y, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_qm_u(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.qm_u = CAST(AV1E_SET_QM_U, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_qm_v(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.qm_v = CAST(AV1E_SET_QM_V, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_qm_min(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.qm_min = CAST(AV1E_SET_QM_MIN, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_qm_max(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.qm_max = CAST(AV1E_SET_QM_MAX, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.num_tg = CAST(AV1E_SET_NUM_TG, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_mtu(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.mtu_size = CAST(AV1E_SET_MTU, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_timing_info_type(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.timing_info_type = CAST(AV1E_SET_TIMING_INFO_TYPE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_dual_filter(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_dual_filter = CAST(AV1E_SET_ENABLE_DUAL_FILTER, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_chroma_deltaq(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_chroma_deltaq = CAST(AV1E_SET_ENABLE_CHROMA_DELTAQ, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_rect_partitions( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_rect_partitions = CAST(AV1E_SET_ENABLE_RECT_PARTITIONS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_ab_partitions(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_ab_partitions = CAST(AV1E_SET_ENABLE_AB_PARTITIONS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_1to4_partitions( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_1to4_partitions = CAST(AV1E_SET_ENABLE_1TO4_PARTITIONS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_min_partition_size(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.min_partition_size = CAST(AV1E_SET_MIN_PARTITION_SIZE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_max_partition_size(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.max_partition_size = CAST(AV1E_SET_MAX_PARTITION_SIZE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_intra_edge_filter( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_intra_edge_filter = CAST(AV1E_SET_ENABLE_INTRA_EDGE_FILTER, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_order_hint(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_order_hint = CAST(AV1E_SET_ENABLE_ORDER_HINT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_tx64(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_tx64 = CAST(AV1E_SET_ENABLE_TX64, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_flip_idtx(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_flip_idtx = CAST(AV1E_SET_ENABLE_FLIP_IDTX, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_rect_tx(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_rect_tx = CAST(AV1E_SET_ENABLE_RECT_TX, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_dist_wtd_comp(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_dist_wtd_comp = CAST(AV1E_SET_ENABLE_DIST_WTD_COMP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_max_reference_frames(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.max_reference_frames = CAST(AV1E_SET_MAX_REFERENCE_FRAMES, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_reduced_reference_set( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_reduced_reference_set = CAST(AV1E_SET_REDUCED_REFERENCE_SET, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_ref_frame_mvs(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_ref_frame_mvs = CAST(AV1E_SET_ENABLE_REF_FRAME_MVS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_allow_ref_frame_mvs(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.allow_ref_frame_mvs = CAST(AV1E_SET_ALLOW_REF_FRAME_MVS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_masked_comp(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_masked_comp = CAST(AV1E_SET_ENABLE_MASKED_COMP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_onesided_comp(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_onesided_comp = CAST(AV1E_SET_ENABLE_ONESIDED_COMP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_interintra_comp( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_interintra_comp = CAST(AV1E_SET_ENABLE_INTERINTRA_COMP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_smooth_interintra( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_smooth_interintra = CAST(AV1E_SET_ENABLE_SMOOTH_INTERINTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_diff_wtd_comp(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_diff_wtd_comp = CAST(AV1E_SET_ENABLE_DIFF_WTD_COMP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_interinter_wedge( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_interinter_wedge = CAST(AV1E_SET_ENABLE_INTERINTER_WEDGE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_interintra_wedge( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_interintra_wedge = CAST(AV1E_SET_ENABLE_INTERINTRA_WEDGE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_global_motion(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const int global_motion_arg = CAST(AV1E_SET_ENABLE_GLOBAL_MOTION, args); #if CONFIG_REALTIME_ONLY if (global_motion_arg) { ERROR("Global motion can't be enabled in realtime only build."); } #endif extra_cfg.enable_global_motion = global_motion_arg; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_warped_motion(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const int warped_motion_arg = CAST(AV1E_SET_ENABLE_WARPED_MOTION, args); #if CONFIG_REALTIME_ONLY if (warped_motion_arg) { ERROR("Warped motion can't be enabled in realtime only build."); } #endif extra_cfg.enable_warped_motion = warped_motion_arg; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_allow_warped_motion(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.allow_warped_motion = CAST(AV1E_SET_ALLOW_WARPED_MOTION, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_filter_intra(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_filter_intra = CAST(AV1E_SET_ENABLE_FILTER_INTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_smooth_intra(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_smooth_intra = CAST(AV1E_SET_ENABLE_SMOOTH_INTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_directional_intra( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_directional_intra = CAST(AV1E_SET_ENABLE_DIRECTIONAL_INTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_diagonal_intra(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_diagonal_intra = CAST(AV1E_SET_ENABLE_DIAGONAL_INTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_paeth_intra(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_paeth_intra = CAST(AV1E_SET_ENABLE_PAETH_INTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_cfl_intra(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_cfl_intra = CAST(AV1E_SET_ENABLE_CFL_INTRA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_superres(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_superres = CAST(AV1E_SET_ENABLE_SUPERRES, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_overlay(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_overlay = CAST(AV1E_SET_ENABLE_OVERLAY, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_palette(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_palette = CAST(AV1E_SET_ENABLE_PALETTE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_intrabc(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_intrabc = CAST(AV1E_SET_ENABLE_INTRABC, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_angle_delta(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_angle_delta = CAST(AV1E_SET_ENABLE_ANGLE_DELTA, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_error_resilient_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.error_resilient_mode = CAST(AV1E_SET_ERROR_RESILIENT_MODE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_s_frame_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.s_frame_mode = CAST(AV1E_SET_S_FRAME_MODE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_frame_parallel_decoding_mode( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.frame_parallel_decoding_mode = CAST(AV1E_SET_FRAME_PARALLEL_DECODING, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_single_tile_decoding(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.single_tile_decoding = CAST(AV1E_SET_SINGLE_TILE_DECODING, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_aq_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.aq_mode = CAST(AV1E_SET_AQ_MODE, args); // Skip AQ mode if using fixed QP for current frame. if (ctx->ppi->cpi->rc.use_external_qp_one_pass) extra_cfg.aq_mode = 0; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_reduced_tx_type_set(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.reduced_tx_type_set = CAST(AV1E_SET_REDUCED_TX_TYPE_SET, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_intra_dct_only(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.use_intra_dct_only = CAST(AV1E_SET_INTRA_DCT_ONLY, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_inter_dct_only(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.use_inter_dct_only = CAST(AV1E_SET_INTER_DCT_ONLY, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_intra_default_tx_only(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.use_intra_default_tx_only = CAST(AV1E_SET_INTRA_DEFAULT_TX_ONLY, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_enable_tx_size_search(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_tx_size_search = CAST(AV1E_SET_ENABLE_TX_SIZE_SEARCH, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_quant_b_adapt(aom_codec_alg_priv_t *ctx, va_list args) { #if CONFIG_REALTIME_ONLY (void)ctx; (void)args; return AOM_CODEC_INCAPABLE; #else struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.quant_b_adapt = CAST(AV1E_SET_QUANT_B_ADAPT, args); return update_extra_cfg(ctx, &extra_cfg); #endif } static aom_codec_err_t ctrl_set_vbr_corpus_complexity_lap( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.vbr_corpus_complexity_lap = CAST(AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_coeff_cost_upd_freq(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.coeff_cost_upd_freq = CAST(AV1E_SET_COEFF_COST_UPD_FREQ, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_mode_cost_upd_freq(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.mode_cost_upd_freq = CAST(AV1E_SET_MODE_COST_UPD_FREQ, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_mv_cost_upd_freq(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.mv_cost_upd_freq = CAST(AV1E_SET_MV_COST_UPD_FREQ, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_dv_cost_upd_freq(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.dv_cost_upd_freq = CAST(AV1E_SET_DV_COST_UPD_FREQ, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_vmaf_model_path(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const char *str = CAST(AV1E_SET_VMAF_MODEL_PATH, args); const aom_codec_err_t ret = allocate_and_set_string( str, default_extra_cfg.vmaf_model_path, &extra_cfg.vmaf_model_path, ctx->ppi->error.detail); if (ret != AOM_CODEC_OK) return ret; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_partition_info_path(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const char *str = CAST(AV1E_SET_PARTITION_INFO_PATH, args); const aom_codec_err_t ret = allocate_and_set_string( str, default_extra_cfg.partition_info_path, &extra_cfg.partition_info_path, ctx->ppi->error.detail); if (ret != AOM_CODEC_OK) return ret; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_enable_rate_guide_deltaq(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_rate_guide_deltaq = CAST(AV1E_ENABLE_RATE_GUIDE_DELTAQ, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_rate_distribution_info( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const char *str = CAST(AV1E_SET_RATE_DISTRIBUTION_INFO, args); const aom_codec_err_t ret = allocate_and_set_string( str, default_extra_cfg.rate_distribution_info, &extra_cfg.rate_distribution_info, ctx->ppi->error.detail); if (ret != AOM_CODEC_OK) return ret; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_film_grain_test_vector( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.film_grain_test_vector = CAST(AV1E_SET_FILM_GRAIN_TEST_VECTOR, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_film_grain_table(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const char *str = CAST(AV1E_SET_FILM_GRAIN_TABLE, args); if (str == NULL) { // this parameter allows NULL as its value extra_cfg.film_grain_table_filename = str; } else { const aom_codec_err_t ret = allocate_and_set_string( str, default_extra_cfg.film_grain_table_filename, &extra_cfg.film_grain_table_filename, ctx->ppi->error.detail); if (ret != AOM_CODEC_OK) return ret; } return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_denoise_noise_level(aom_codec_alg_priv_t *ctx, va_list args) { #if !CONFIG_DENOISE (void)ctx; (void)args; return AOM_CODEC_INCAPABLE; #else struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.noise_level = ((float)CAST(AV1E_SET_DENOISE_NOISE_LEVEL, args)) / 10.0f; return update_extra_cfg(ctx, &extra_cfg); #endif } static aom_codec_err_t ctrl_set_denoise_block_size(aom_codec_alg_priv_t *ctx, va_list args) { #if !CONFIG_DENOISE (void)ctx; (void)args; return AOM_CODEC_INCAPABLE; #else struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.noise_block_size = CAST(AV1E_SET_DENOISE_BLOCK_SIZE, args); return update_extra_cfg(ctx, &extra_cfg); #endif } static aom_codec_err_t ctrl_set_enable_dnl_denoising(aom_codec_alg_priv_t *ctx, va_list args) { #if !CONFIG_DENOISE (void)ctx; (void)args; return AOM_CODEC_INCAPABLE; #else struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.enable_dnl_denoising = CAST(AV1E_SET_ENABLE_DNL_DENOISING, args); return update_extra_cfg(ctx, &extra_cfg); #endif } static aom_codec_err_t ctrl_set_deltaq_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const DELTAQ_MODE deltaq_arg = CAST(AV1E_SET_DELTAQ_MODE, args); #if CONFIG_REALTIME_ONLY if (deltaq_arg > NO_DELTA_Q) { ERROR("Delta Q mode can't be enabled in realtime only build."); } #endif extra_cfg.deltaq_mode = deltaq_arg; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_deltaq_strength(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.deltaq_strength = CAST(AV1E_SET_DELTAQ_STRENGTH, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_deltalf_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.deltalf_mode = CAST(AV1E_SET_DELTALF_MODE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_min_gf_interval(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.min_gf_interval = CAST(AV1E_SET_MIN_GF_INTERVAL, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_max_gf_interval(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.max_gf_interval = CAST(AV1E_SET_MAX_GF_INTERVAL, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_gf_min_pyr_height(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.gf_min_pyr_height = CAST(AV1E_SET_GF_MIN_PYRAMID_HEIGHT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_gf_max_pyr_height(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.gf_max_pyr_height = CAST(AV1E_SET_GF_MAX_PYRAMID_HEIGHT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_frame_periodic_boost(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.frame_periodic_boost = CAST(AV1E_SET_FRAME_PERIODIC_BOOST, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_enable_motion_vector_unit_test( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.motion_vector_unit_test = CAST(AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_enable_fpmt_unit_test(aom_codec_alg_priv_t *ctx, va_list args) { #if !CONFIG_FPMT_TEST (void)args; (void)ctx; return AOM_CODEC_INCAPABLE; #else struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.fpmt_unit_test = CAST(AV1E_SET_FP_MT_UNIT_TEST, args); ctx->ppi->fpmt_unit_test_cfg = (extra_cfg.fpmt_unit_test == 1) ? PARALLEL_ENCODE : PARALLEL_SIMULATION_ENCODE; return update_extra_cfg(ctx, &extra_cfg); #endif } static aom_codec_err_t ctrl_enable_ext_tile_debug(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.ext_tile_debug = CAST(AV1E_ENABLE_EXT_TILE_DEBUG, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_target_seq_level_idx(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; const int val = CAST(AV1E_SET_TARGET_SEQ_LEVEL_IDX, args); const int level = val % 100; const int operating_point_idx = val / 100; if (operating_point_idx < 0 || operating_point_idx >= MAX_NUM_OPERATING_POINTS) { char *const err_string = ctx->ppi->error.detail; snprintf(err_string, ARG_ERR_MSG_MAX_LEN, "Invalid operating point index: %d", operating_point_idx); ctx->base.err_detail = err_string; return AOM_CODEC_INVALID_PARAM; } extra_cfg.target_seq_level_idx[operating_point_idx] = (AV1_LEVEL)level; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_tier_mask(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.tier_mask = CAST(AV1E_SET_TIER_MASK, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_min_cr(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.min_cr = CAST(AV1E_SET_MIN_CR, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_enable_sb_multipass_unit_test( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.sb_multipass_unit_test = CAST(AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_enable_sb_qp_sweep(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.sb_qp_sweep = CAST(AV1E_ENABLE_SB_QP_SWEEP, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_external_partition(aom_codec_alg_priv_t *ctx, va_list args) { AV1_COMP *const cpi = ctx->ppi->cpi; aom_ext_part_funcs_t funcs = *CAST(AV1E_SET_EXTERNAL_PARTITION, args); aom_ext_part_config_t config; // TODO(chengchen): verify the sb_size has been set at this point. config.superblock_size = cpi->common.seq_params->sb_size; const aom_codec_err_t status = av1_ext_part_create(funcs, config, &cpi->ext_part_controller); return status; } static aom_codec_err_t ctrl_set_loopfilter_control(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.loopfilter_control = CAST(AV1E_SET_LOOPFILTER_CONTROL, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_skip_postproc_filtering( aom_codec_alg_priv_t *ctx, va_list args) { // Skipping the application of post-processing filters is allowed only // for ALLINTRA mode. if (ctx->cfg.g_usage != AOM_USAGE_ALL_INTRA) return AOM_CODEC_INCAPABLE; struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.skip_postproc_filtering = CAST(AV1E_SET_SKIP_POSTPROC_FILTERING, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_rtc_external_rc(aom_codec_alg_priv_t *ctx, va_list args) { ctx->ppi->cpi->rc.rtc_external_ratectrl = CAST(AV1E_SET_RTC_EXTERNAL_RC, args); return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_quantizer_one_pass(aom_codec_alg_priv_t *ctx, va_list args) { const int qp = CAST(AV1E_SET_QUANTIZER_ONE_PASS, args); if (qp < 0 || qp > 63) return AOM_CODEC_INVALID_PARAM; aom_codec_enc_cfg_t *cfg = &ctx->cfg; struct av1_extracfg extra_cfg = ctx->extra_cfg; cfg->rc_min_quantizer = cfg->rc_max_quantizer = qp; extra_cfg.aq_mode = 0; ctx->ppi->cpi->rc.use_external_qp_one_pass = 1; return update_extra_cfg(ctx, &extra_cfg); } #if !CONFIG_REALTIME_ONLY aom_codec_err_t av1_create_stats_buffer(FIRSTPASS_STATS **frame_stats_buffer, STATS_BUFFER_CTX *stats_buf_context, int num_lap_buffers) { aom_codec_err_t res = AOM_CODEC_OK; int size = get_stats_buf_size(num_lap_buffers, MAX_LAG_BUFFERS); *frame_stats_buffer = (FIRSTPASS_STATS *)aom_calloc(size, sizeof(FIRSTPASS_STATS)); if (*frame_stats_buffer == NULL) return AOM_CODEC_MEM_ERROR; stats_buf_context->stats_in_start = *frame_stats_buffer; stats_buf_context->stats_in_end = stats_buf_context->stats_in_start; stats_buf_context->stats_in_buf_end = stats_buf_context->stats_in_start + size; stats_buf_context->total_left_stats = aom_calloc(1, sizeof(FIRSTPASS_STATS)); if (stats_buf_context->total_left_stats == NULL) return AOM_CODEC_MEM_ERROR; av1_twopass_zero_stats(stats_buf_context->total_left_stats); stats_buf_context->total_stats = aom_calloc(1, sizeof(FIRSTPASS_STATS)); if (stats_buf_context->total_stats == NULL) return AOM_CODEC_MEM_ERROR; av1_twopass_zero_stats(stats_buf_context->total_stats); return res; } #endif aom_codec_err_t av1_create_context_and_bufferpool(AV1_PRIMARY *ppi, AV1_COMP **p_cpi, BufferPool **p_buffer_pool, const AV1EncoderConfig *oxcf, COMPRESSOR_STAGE stage, int lap_lag_in_frames) { aom_codec_err_t res = AOM_CODEC_OK; BufferPool *buffer_pool = *p_buffer_pool; if (buffer_pool == NULL) { buffer_pool = (BufferPool *)aom_calloc(1, sizeof(BufferPool)); if (buffer_pool == NULL) return AOM_CODEC_MEM_ERROR; buffer_pool->num_frame_bufs = (oxcf->mode == ALLINTRA) ? FRAME_BUFFERS_ALLINTRA : FRAME_BUFFERS; buffer_pool->frame_bufs = (RefCntBuffer *)aom_calloc( buffer_pool->num_frame_bufs, sizeof(*buffer_pool->frame_bufs)); if (buffer_pool->frame_bufs == NULL) { buffer_pool->num_frame_bufs = 0; aom_free(buffer_pool); return AOM_CODEC_MEM_ERROR; } #if CONFIG_MULTITHREAD if (pthread_mutex_init(&buffer_pool->pool_mutex, NULL)) { aom_free(buffer_pool->frame_bufs); buffer_pool->frame_bufs = NULL; buffer_pool->num_frame_bufs = 0; aom_free(buffer_pool); return AOM_CODEC_MEM_ERROR; } #endif *p_buffer_pool = buffer_pool; } *p_cpi = av1_create_compressor(ppi, oxcf, buffer_pool, stage, lap_lag_in_frames); if (*p_cpi == NULL) res = AOM_CODEC_MEM_ERROR; return res; } static aom_codec_err_t ctrl_set_fp_mt(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.fp_mt = CAST(AV1E_SET_FP_MT, args); const aom_codec_err_t result = update_extra_cfg(ctx, &extra_cfg); int num_fp_contexts = 1; if (ctx->ppi->num_fp_contexts == 1) { num_fp_contexts = av1_compute_num_fp_contexts(ctx->ppi, &ctx->ppi->parallel_cpi[0]->oxcf); if (num_fp_contexts > 1) { int i; for (i = 1; i < num_fp_contexts; i++) { int res = av1_create_context_and_bufferpool( ctx->ppi, &ctx->ppi->parallel_cpi[i], &ctx->buffer_pool, &ctx->oxcf, ENCODE_STAGE, -1); if (res != AOM_CODEC_OK) { return res; } #if !CONFIG_REALTIME_ONLY ctx->ppi->parallel_cpi[i]->twopass_frame.stats_in = ctx->ppi->twopass.stats_buf_ctx->stats_in_start; #endif } } } ctx->ppi->num_fp_contexts = num_fp_contexts; return result; } static aom_codec_err_t ctrl_set_auto_intra_tools_off(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.auto_intra_tools_off = CAST(AV1E_SET_AUTO_INTRA_TOOLS_OFF, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t encoder_init(aom_codec_ctx_t *ctx) { aom_codec_err_t res = AOM_CODEC_OK; if (ctx->priv == NULL) { aom_codec_alg_priv_t *const priv = aom_calloc(1, sizeof(*priv)); if (priv == NULL) return AOM_CODEC_MEM_ERROR; ctx->priv = (aom_codec_priv_t *)priv; ctx->priv->init_flags = ctx->init_flags; // Update the reference to the config structure to an internal copy. assert(ctx->config.enc); priv->cfg = *ctx->config.enc; ctx->config.enc = &priv->cfg; priv->extra_cfg = default_extra_cfg; // Special handling: // By default, if omitted, --enable-cdef = 1. // Here we set its default value to 0 when --allintra is turned on. // However, if users set --enable-cdef = 1 from command line, // The encoder still respects it. if (priv->cfg.g_usage == ALLINTRA) { priv->extra_cfg.enable_cdef = 0; } av1_initialize_enc(priv->cfg.g_usage, priv->cfg.rc_end_usage); res = validate_config(priv, &priv->cfg, &priv->extra_cfg); if (res == AOM_CODEC_OK) { int *num_lap_buffers = &priv->num_lap_buffers; int lap_lag_in_frames = 0; *num_lap_buffers = 0; priv->timestamp_ratio.den = priv->cfg.g_timebase.den; priv->timestamp_ratio.num = (int64_t)priv->cfg.g_timebase.num * TICKS_PER_SEC; reduce_ratio(&priv->timestamp_ratio); set_encoder_config(&priv->oxcf, &priv->cfg, &priv->extra_cfg); if (priv->oxcf.rc_cfg.mode != AOM_CBR && priv->oxcf.pass == AOM_RC_ONE_PASS && priv->oxcf.mode == GOOD) { // Enable look ahead - enabled for AOM_Q, AOM_CQ, AOM_VBR *num_lap_buffers = AOMMIN((int)priv->cfg.g_lag_in_frames, AOMMIN(MAX_LAP_BUFFERS, priv->oxcf.kf_cfg.key_freq_max + SCENE_CUT_KEY_TEST_INTERVAL)); if ((int)priv->cfg.g_lag_in_frames - (*num_lap_buffers) >= LAP_LAG_IN_FRAMES) { lap_lag_in_frames = LAP_LAG_IN_FRAMES; } } priv->oxcf.use_highbitdepth = (ctx->init_flags & AOM_CODEC_USE_HIGHBITDEPTH) ? 1 : 0; priv->ppi = av1_create_primary_compressor(&priv->pkt_list.head, *num_lap_buffers, &priv->oxcf); if (!priv->ppi) return AOM_CODEC_MEM_ERROR; #if !CONFIG_REALTIME_ONLY res = av1_create_stats_buffer(&priv->frame_stats_buffer, &priv->stats_buf_context, *num_lap_buffers); if (res != AOM_CODEC_OK) return AOM_CODEC_MEM_ERROR; assert(MAX_LAP_BUFFERS >= MAX_LAG_BUFFERS); int size = get_stats_buf_size(*num_lap_buffers, MAX_LAG_BUFFERS); for (int i = 0; i < size; i++) priv->ppi->twopass.frame_stats_arr[i] = &priv->frame_stats_buffer[i]; priv->ppi->twopass.stats_buf_ctx = &priv->stats_buf_context; #endif assert(priv->ppi->num_fp_contexts >= 1); res = av1_create_context_and_bufferpool( priv->ppi, &priv->ppi->parallel_cpi[0], &priv->buffer_pool, &priv->oxcf, ENCODE_STAGE, -1); if (res != AOM_CODEC_OK) { return res; } #if !CONFIG_REALTIME_ONLY priv->ppi->parallel_cpi[0]->twopass_frame.stats_in = priv->ppi->twopass.stats_buf_ctx->stats_in_start; #endif priv->ppi->cpi = priv->ppi->parallel_cpi[0]; // Create another compressor if look ahead is enabled if (res == AOM_CODEC_OK && *num_lap_buffers) { res = av1_create_context_and_bufferpool( priv->ppi, &priv->ppi->cpi_lap, &priv->buffer_pool_lap, &priv->oxcf, LAP_STAGE, clamp(lap_lag_in_frames, 0, MAX_LAG_BUFFERS)); } } } return res; } void av1_destroy_context_and_bufferpool(AV1_COMP *cpi, BufferPool **p_buffer_pool) { av1_remove_compressor(cpi); if (*p_buffer_pool) { av1_free_ref_frame_buffers(*p_buffer_pool); #if CONFIG_MULTITHREAD pthread_mutex_destroy(&(*p_buffer_pool)->pool_mutex); #endif aom_free(*p_buffer_pool); *p_buffer_pool = NULL; } } void av1_destroy_stats_buffer(STATS_BUFFER_CTX *stats_buf_context, FIRSTPASS_STATS *frame_stats_buffer) { aom_free(stats_buf_context->total_left_stats); aom_free(stats_buf_context->total_stats); aom_free(frame_stats_buffer); } static void check_and_free_string(const char *default_str, const char **ptr) { if (*ptr == default_str) { // Default should be a literal. Do not free. return; } aom_free((void *)*ptr); *ptr = NULL; } static void destroy_extra_config(struct av1_extracfg *extra_cfg) { #if CONFIG_TUNE_VMAF check_and_free_string(default_extra_cfg.vmaf_model_path, &extra_cfg->vmaf_model_path); #endif check_and_free_string(default_extra_cfg.two_pass_output, &extra_cfg->two_pass_output); check_and_free_string(default_extra_cfg.two_pass_output, &extra_cfg->second_pass_log); check_and_free_string(default_extra_cfg.partition_info_path, &extra_cfg->partition_info_path); check_and_free_string(default_extra_cfg.rate_distribution_info, &extra_cfg->rate_distribution_info); check_and_free_string(default_extra_cfg.film_grain_table_filename, &extra_cfg->film_grain_table_filename); } static aom_codec_err_t encoder_destroy(aom_codec_alg_priv_t *ctx) { free(ctx->cx_data); destroy_extra_config(&ctx->extra_cfg); if (ctx->ppi) { AV1_PRIMARY *ppi = ctx->ppi; for (int i = 0; i < MAX_PARALLEL_FRAMES - 1; i++) { if (ppi->parallel_frames_data[i].cx_data) { free(ppi->parallel_frames_data[i].cx_data); } } #if CONFIG_ENTROPY_STATS print_entropy_stats(ppi); #endif #if CONFIG_INTERNAL_STATS print_internal_stats(ppi); #endif for (int i = 0; i < MAX_PARALLEL_FRAMES; i++) { av1_destroy_context_and_bufferpool(ppi->parallel_cpi[i], &ctx->buffer_pool); } ppi->cpi = NULL; if (ppi->cpi_lap) { av1_destroy_context_and_bufferpool(ppi->cpi_lap, &ctx->buffer_pool_lap); } av1_remove_primary_compressor(ppi); } av1_destroy_stats_buffer(&ctx->stats_buf_context, ctx->frame_stats_buffer); aom_free(ctx); return AOM_CODEC_OK; } static aom_codec_frame_flags_t get_frame_pkt_flags(const AV1_COMP *cpi, unsigned int lib_flags) { aom_codec_frame_flags_t flags = lib_flags << 16; if (lib_flags & FRAMEFLAGS_KEY) flags |= AOM_FRAME_IS_KEY; if (lib_flags & FRAMEFLAGS_INTRAONLY) flags |= AOM_FRAME_IS_INTRAONLY; if (lib_flags & FRAMEFLAGS_SWITCH) flags |= AOM_FRAME_IS_SWITCH; if (lib_flags & FRAMEFLAGS_ERROR_RESILIENT) flags |= AOM_FRAME_IS_ERROR_RESILIENT; if (cpi->droppable) flags |= AOM_FRAME_IS_DROPPABLE; return flags; } static INLINE int get_src_border_in_pixels(AV1_COMP *cpi, BLOCK_SIZE sb_size) { if (cpi->oxcf.mode != REALTIME || av1_is_resize_needed(&cpi->oxcf)) return cpi->oxcf.border_in_pixels; const int sb_size_in_pixels_log2 = mi_size_wide_log2[sb_size] + MI_SIZE_LOG2; const int sb_aligned_width = ALIGN_POWER_OF_TWO(cpi->oxcf.frm_dim_cfg.width, sb_size_in_pixels_log2); const int sb_aligned_height = ALIGN_POWER_OF_TWO(cpi->oxcf.frm_dim_cfg.height, sb_size_in_pixels_log2); // Align the border pixels to a multiple of 32. const int border_pixels_width = ALIGN_POWER_OF_TWO(sb_aligned_width - cpi->oxcf.frm_dim_cfg.width, 5); const int border_pixels_height = ALIGN_POWER_OF_TWO(sb_aligned_height - cpi->oxcf.frm_dim_cfg.height, 5); const int border_in_pixels = AOMMAX(AOMMAX(border_pixels_width, border_pixels_height), 32); return border_in_pixels; } // TODO(Mufaddal): Check feasibility of abstracting functions related to LAP // into a separate function. static aom_codec_err_t encoder_encode(aom_codec_alg_priv_t *ctx, const aom_image_t *img, aom_codec_pts_t pts, unsigned long duration, aom_enc_frame_flags_t enc_flags) { const size_t kMinCompressedSize = 8192; volatile aom_codec_err_t res = AOM_CODEC_OK; AV1_PRIMARY *const ppi = ctx->ppi; volatile aom_codec_pts_t ptsvol = pts; AV1_COMP_DATA cpi_data = { 0 }; cpi_data.timestamp_ratio = &ctx->timestamp_ratio; cpi_data.flush = !img; // LAP context AV1_COMP *cpi_lap = ppi->cpi_lap; if (ppi->cpi == NULL) return AOM_CODEC_INVALID_PARAM; if (ppi->lap_enabled && cpi_lap == NULL && ppi->cpi->oxcf.pass == AOM_RC_ONE_PASS) return AOM_CODEC_INVALID_PARAM; if (img != NULL) { res = validate_img(ctx, img); if (res == AOM_CODEC_OK) { const size_t uncompressed_frame_sz = ALIGN_POWER_OF_TWO_UNSIGNED(ctx->cfg.g_w, 5) * ALIGN_POWER_OF_TWO_UNSIGNED(ctx->cfg.g_h, 5) * av1_get_image_bps(img) / 8; // Due to the presence of no-show frames, the ctx->cx_data buffer holds // compressed data corresponding to multiple frames. As no-show frames are // not possible for all intra frame encoding with no forward key frames, // the buffer is allocated with a smaller size in this case. // // For pseudo random input, the compressed frame size is seen to exceed // the uncompressed frame size, but is less than 2 times the uncompressed // frame size. Hence the size of the buffer is chosen as 2 times the // uncompressed frame size. int multiplier = 8; if (ppi->cpi->oxcf.kf_cfg.key_freq_max == 0 && !ppi->cpi->oxcf.kf_cfg.fwd_kf_enabled) multiplier = 2; size_t data_sz = uncompressed_frame_sz * multiplier; if (data_sz < kMinCompressedSize) data_sz = kMinCompressedSize; if (ctx->cx_data == NULL || ctx->cx_data_sz < data_sz) { ctx->cx_data_sz = data_sz; free(ctx->cx_data); ctx->cx_data = (unsigned char *)malloc(ctx->cx_data_sz); if (ctx->cx_data == NULL) { ctx->cx_data_sz = 0; return AOM_CODEC_MEM_ERROR; } } for (int i = 0; i < ppi->num_fp_contexts - 1; i++) { if (ppi->parallel_frames_data[i].cx_data == NULL) { ppi->parallel_frames_data[i].cx_data_sz = uncompressed_frame_sz; ppi->parallel_frames_data[i].frame_display_order_hint = -1; ppi->parallel_frames_data[i].frame_size = 0; ppi->parallel_frames_data[i].cx_data = (unsigned char *)malloc(ppi->parallel_frames_data[i].cx_data_sz); if (ppi->parallel_frames_data[i].cx_data == NULL) { ppi->parallel_frames_data[i].cx_data_sz = 0; return AOM_CODEC_MEM_ERROR; } } } } } aom_codec_pkt_list_init(&ctx->pkt_list); volatile aom_enc_frame_flags_t flags = enc_flags; // The jmp_buf is valid only for the duration of the function that calls // setjmp(). Therefore, this function must reset the 'setjmp' field to 0 // before it returns. if (setjmp(ppi->error.jmp)) { ppi->error.setjmp = 0; res = update_error_state(ctx, &ppi->error); return res; } ppi->error.setjmp = 1; if (ppi->use_svc && ppi->cpi->svc.use_flexible_mode == 0 && flags == 0) av1_set_svc_fixed_mode(ppi->cpi); // Note(yunqing): While applying encoding flags, always start from enabling // all, and then modifying according to the flags. Previous frame's flags are // overwritten. av1_apply_encoding_flags(ppi->cpi, flags); if (cpi_lap != NULL) { av1_apply_encoding_flags(cpi_lap, flags); } #if CONFIG_TUNE_VMAF if (ctx->extra_cfg.tuning >= AOM_TUNE_VMAF_WITH_PREPROCESSING && ctx->extra_cfg.tuning <= AOM_TUNE_VMAF_NEG_MAX_GAIN) { aom_init_vmaf_model(&ppi->cpi->vmaf_info.vmaf_model, ppi->cpi->oxcf.tune_cfg.vmaf_model_path); } #endif // Handle fixed keyframe intervals if (is_stat_generation_stage(ppi->cpi) || is_one_pass_rt_params(ppi->cpi)) { if (ctx->cfg.kf_mode == AOM_KF_AUTO && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) { if (ppi->cpi->common.spatial_layer_id == 0 && ++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) { flags |= AOM_EFLAG_FORCE_KF; ctx->fixed_kf_cntr = 1; } } } if (res == AOM_CODEC_OK) { AV1_COMP *cpi = ppi->cpi; // Set up internal flags if (ctx->base.init_flags & AOM_CODEC_USE_PSNR) ppi->b_calculate_psnr = 1; if (img != NULL) { if (!ctx->pts_offset_initialized) { ctx->pts_offset = ptsvol; ctx->pts_offset_initialized = 1; } ptsvol -= ctx->pts_offset; int64_t src_time_stamp = timebase_units_to_ticks(cpi_data.timestamp_ratio, ptsvol); int64_t src_end_time_stamp = timebase_units_to_ticks(cpi_data.timestamp_ratio, ptsvol + duration); YV12_BUFFER_CONFIG sd; res = image2yuvconfig(img, &sd); // When generating a monochrome stream, make |sd| a monochrome image. if (ctx->cfg.monochrome) { sd.u_buffer = sd.v_buffer = NULL; sd.uv_stride = 0; sd.monochrome = 1; } int use_highbitdepth = (sd.flags & YV12_FLAG_HIGHBITDEPTH) != 0; int subsampling_x = sd.subsampling_x; int subsampling_y = sd.subsampling_y; if (!ppi->lookahead) { int lag_in_frames = cpi_lap != NULL ? cpi_lap->oxcf.gf_cfg.lag_in_frames : cpi->oxcf.gf_cfg.lag_in_frames; AV1EncoderConfig *oxcf = &cpi->oxcf; const BLOCK_SIZE sb_size = av1_select_sb_size( oxcf, oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height, ppi->number_spatial_layers); oxcf->border_in_pixels = av1_get_enc_border_size(av1_is_resize_needed(oxcf), oxcf->kf_cfg.key_freq_max == 0, sb_size); for (int i = 0; i < ppi->num_fp_contexts; i++) { ppi->parallel_cpi[i]->oxcf.border_in_pixels = oxcf->border_in_pixels; } const int src_border_in_pixels = get_src_border_in_pixels(cpi, sb_size); ppi->lookahead = av1_lookahead_init( cpi->oxcf.frm_dim_cfg.width, cpi->oxcf.frm_dim_cfg.height, subsampling_x, subsampling_y, use_highbitdepth, lag_in_frames, src_border_in_pixels, cpi->common.features.byte_alignment, ctx->num_lap_buffers, (cpi->oxcf.kf_cfg.key_freq_max == 0), cpi->image_pyramid_levels); } if (!ppi->lookahead) aom_internal_error(&ppi->error, AOM_CODEC_MEM_ERROR, "Failed to allocate lag buffers"); for (int i = 0; i < ppi->num_fp_contexts; i++) { av1_check_initial_width(ppi->parallel_cpi[i], use_highbitdepth, subsampling_x, subsampling_y); } if (cpi_lap != NULL) { av1_check_initial_width(cpi_lap, use_highbitdepth, subsampling_x, subsampling_y); } // Store the original flags in to the frame buffer. Will extract the // key frame flag when we actually encode this frame. if (av1_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, src_time_stamp, src_end_time_stamp)) { res = update_error_state(ctx, cpi->common.error); } ctx->next_frame_flags = 0; } cpi_data.cx_data = ctx->cx_data; cpi_data.cx_data_sz = ctx->cx_data_sz; /* Any pending invisible frames? */ if (ctx->pending_cx_data_sz) { cpi_data.cx_data += ctx->pending_cx_data_sz; cpi_data.cx_data_sz -= ctx->pending_cx_data_sz; /* TODO: this is a minimal check, the underlying codec doesn't respect * the buffer size anyway. */ if (cpi_data.cx_data_sz < ctx->cx_data_sz / 2) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, "Compressed data buffer too small"); } } int is_frame_visible = 0; int has_no_show_keyframe = 0; int num_workers = 0; if (cpi->oxcf.pass == AOM_RC_FIRST_PASS) { #if !CONFIG_REALTIME_ONLY num_workers = ppi->p_mt_info.num_mod_workers[MOD_FP] = av1_fp_compute_num_enc_workers(cpi); #endif } else { av1_compute_num_workers_for_mt(cpi); num_workers = av1_get_max_num_workers(cpi); } if ((num_workers > 1) && (ppi->p_mt_info.num_workers == 0)) { // Obtain the maximum no. of frames that can be supported in a parallel // encode set. if (is_stat_consumption_stage(cpi)) { ppi->num_fp_contexts = av1_compute_num_fp_contexts(ppi, &cpi->oxcf); } av1_create_workers(ppi, num_workers); av1_init_tile_thread_data(ppi, cpi->oxcf.pass == AOM_RC_FIRST_PASS); #if CONFIG_MULTITHREAD for (int i = 0; i < ppi->num_fp_contexts; i++) { av1_init_mt_sync(ppi->parallel_cpi[i], ppi->parallel_cpi[i]->oxcf.pass == AOM_RC_FIRST_PASS); } if (cpi_lap != NULL) { av1_init_mt_sync(cpi_lap, 1); } #endif // CONFIG_MULTITHREAD } // Re-allocate thread data if workers for encoder multi-threading stage // exceeds prev_num_enc_workers. const int num_enc_workers = av1_get_num_mod_workers_for_alloc(&ppi->p_mt_info, MOD_ENC); if (ppi->p_mt_info.prev_num_enc_workers < num_enc_workers && num_enc_workers <= ppi->p_mt_info.num_workers) { free_thread_data(ppi); for (int j = 0; j < ppi->num_fp_contexts; j++) aom_free(ppi->parallel_cpi[j]->td.tctx); av1_init_tile_thread_data(ppi, cpi->oxcf.pass == AOM_RC_FIRST_PASS); } for (int i = 0; i < ppi->num_fp_contexts; i++) { av1_init_frame_mt(ppi, ppi->parallel_cpi[i]); } if (cpi_lap != NULL) { av1_init_frame_mt(ppi, cpi_lap); } // Call for LAP stage if (cpi_lap != NULL) { AV1_COMP_DATA cpi_lap_data = { 0 }; cpi_lap_data.flush = !img; cpi_lap_data.timestamp_ratio = &ctx->timestamp_ratio; const int status = av1_get_compressed_data(cpi_lap, &cpi_lap_data); if (status != -1) { if (status != AOM_CODEC_OK) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); } } av1_post_encode_updates(cpi_lap, &cpi_lap_data); } // Recalculate the maximum number of frames that can be encoded in // parallel at the beginning of sub gop. if (is_stat_consumption_stage(cpi) && ppi->gf_group.size > 0 && cpi->gf_frame_index == ppi->gf_group.size) { ppi->num_fp_contexts = av1_compute_num_fp_contexts(ppi, &cpi->oxcf); } // Reset gf_frame_index in case it reaches MAX_STATIC_GF_GROUP_LENGTH for // real time encoding. if (is_one_pass_rt_params(cpi) && cpi->gf_frame_index == MAX_STATIC_GF_GROUP_LENGTH) cpi->gf_frame_index = 0; // Get the next visible frame. Invisible frames get packed with the next // visible frame. while (cpi_data.cx_data_sz >= ctx->cx_data_sz / 2 && !is_frame_visible) { int simulate_parallel_frame = 0; int status = -1; cpi->do_frame_data_update = true; cpi->ref_idx_to_skip = INVALID_IDX; cpi->ref_refresh_index = INVALID_IDX; cpi->refresh_idx_available = false; #if CONFIG_FPMT_TEST simulate_parallel_frame = cpi->ppi->fpmt_unit_test_cfg == PARALLEL_SIMULATION_ENCODE ? 1 : 0; if (simulate_parallel_frame) { if (ppi->num_fp_contexts > 1 && ppi->gf_group.size > 1) { if (cpi->gf_frame_index < ppi->gf_group.size) { calc_frame_data_update_flag(&ppi->gf_group, cpi->gf_frame_index, &cpi->do_frame_data_update); } } status = av1_get_compressed_data(cpi, &cpi_data); } #endif // CONFIG_FPMT_TEST if (!simulate_parallel_frame) { if (ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] == 0) { status = av1_get_compressed_data(cpi, &cpi_data); } else if (ppi->gf_group.frame_parallel_level[cpi->gf_frame_index] == 1) { status = av1_compress_parallel_frames(ppi, &cpi_data); } else { cpi = av1_get_parallel_frame_enc_data(ppi, &cpi_data); status = AOM_CODEC_OK; } } if (status == -1) break; if (status != AOM_CODEC_OK) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); } if (ppi->num_fp_contexts > 0 && frame_is_intra_only(&cpi->common)) { av1_init_sc_decisions(ppi); } ppi->seq_params_locked = 1; av1_post_encode_updates(cpi, &cpi_data); #if CONFIG_ENTROPY_STATS if (ppi->cpi->oxcf.pass != 1 && !cpi->common.show_existing_frame) av1_accumulate_frame_counts(&ppi->aggregate_fc, &cpi->counts); #endif #if CONFIG_INTERNAL_STATS if (ppi->cpi->oxcf.pass != 1) { ppi->total_time_compress_data += cpi->time_compress_data; ppi->total_recode_hits += cpi->frame_recode_hits; ppi->total_bytes += cpi->bytes; for (int i = 0; i < MAX_MODES; i++) { ppi->total_mode_chosen_counts[i] += cpi->mode_chosen_counts[i]; } } #endif // CONFIG_INTERNAL_STATS if (!cpi_data.frame_size) continue; assert(cpi_data.cx_data != NULL && cpi_data.cx_data_sz != 0); const int write_temporal_delimiter = !cpi->common.spatial_layer_id && !ctx->pending_cx_data_sz; if (write_temporal_delimiter) { uint32_t obu_header_size = 1; const uint32_t obu_payload_size = 0; const size_t length_field_size = aom_uleb_size_in_bytes(obu_payload_size); const size_t move_offset = obu_header_size + length_field_size; memmove(ctx->cx_data + move_offset, ctx->cx_data, cpi_data.frame_size); obu_header_size = av1_write_obu_header(&ppi->level_params, &cpi->frame_header_count, OBU_TEMPORAL_DELIMITER, 0, ctx->cx_data); // OBUs are preceded/succeeded by an unsigned leb128 coded integer. if (av1_write_uleb_obu_size(obu_header_size, obu_payload_size, ctx->cx_data) != AOM_CODEC_OK) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); } cpi_data.frame_size += obu_header_size + obu_payload_size + length_field_size; } if (ctx->oxcf.save_as_annexb) { size_t curr_frame_size = cpi_data.frame_size; if (av1_convert_sect5obus_to_annexb(cpi_data.cx_data, &curr_frame_size) != AOM_CODEC_OK) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); } cpi_data.frame_size = curr_frame_size; // B_PRIME (add frame size) const size_t length_field_size = aom_uleb_size_in_bytes(cpi_data.frame_size); memmove(cpi_data.cx_data + length_field_size, cpi_data.cx_data, cpi_data.frame_size); if (av1_write_uleb_obu_size(0, (uint32_t)cpi_data.frame_size, cpi_data.cx_data) != AOM_CODEC_OK) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); } cpi_data.frame_size += length_field_size; } ctx->pending_cx_data_sz += cpi_data.frame_size; cpi_data.cx_data += cpi_data.frame_size; cpi_data.cx_data_sz -= cpi_data.frame_size; is_frame_visible = cpi->common.show_frame; has_no_show_keyframe |= (!is_frame_visible && cpi->common.current_frame.frame_type == KEY_FRAME); } if (is_frame_visible) { // Add the frame packet to the list of returned packets. aom_codec_cx_pkt_t pkt; // decrement frames_left counter ppi->frames_left = AOMMAX(0, ppi->frames_left - 1); if (ctx->oxcf.save_as_annexb) { // B_PRIME (add TU size) size_t tu_size = ctx->pending_cx_data_sz; const size_t length_field_size = aom_uleb_size_in_bytes(tu_size); memmove(ctx->cx_data + length_field_size, ctx->cx_data, tu_size); if (av1_write_uleb_obu_size(0, (uint32_t)tu_size, ctx->cx_data) != AOM_CODEC_OK) { aom_internal_error(&ppi->error, AOM_CODEC_ERROR, NULL); } ctx->pending_cx_data_sz += length_field_size; } pkt.kind = AOM_CODEC_CX_FRAME_PKT; pkt.data.frame.buf = ctx->cx_data; pkt.data.frame.sz = ctx->pending_cx_data_sz; pkt.data.frame.partition_id = -1; pkt.data.frame.vis_frame_size = cpi_data.frame_size; pkt.data.frame.pts = ticks_to_timebase_units(cpi_data.timestamp_ratio, cpi_data.ts_frame_start) + ctx->pts_offset; pkt.data.frame.flags = get_frame_pkt_flags(cpi, cpi_data.lib_flags); if (has_no_show_keyframe) { // If one of the invisible frames in the packet is a keyframe, set // the delayed random access point flag. pkt.data.frame.flags |= AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT; } pkt.data.frame.duration = (uint32_t)ticks_to_timebase_units( cpi_data.timestamp_ratio, cpi_data.ts_frame_end - cpi_data.ts_frame_start); aom_codec_pkt_list_add(&ctx->pkt_list.head, &pkt); ctx->pending_cx_data_sz = 0; } } ppi->error.setjmp = 0; return res; } static const aom_codec_cx_pkt_t *encoder_get_cxdata(aom_codec_alg_priv_t *ctx, aom_codec_iter_t *iter) { return aom_codec_pkt_list_get(&ctx->pkt_list.head, iter); } static aom_codec_err_t ctrl_set_reference(aom_codec_alg_priv_t *ctx, va_list args) { av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); if (frame != NULL) { YV12_BUFFER_CONFIG sd; image2yuvconfig(&frame->img, &sd); av1_set_reference_enc(ctx->ppi->cpi, frame->idx, &sd); return AOM_CODEC_OK; } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_copy_reference(aom_codec_alg_priv_t *ctx, va_list args) { if (ctx->ppi->cpi->oxcf.algo_cfg.skip_postproc_filtering) return AOM_CODEC_INCAPABLE; av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); if (frame != NULL) { YV12_BUFFER_CONFIG sd; image2yuvconfig(&frame->img, &sd); av1_copy_reference_enc(ctx->ppi->cpi, frame->idx, &sd); return AOM_CODEC_OK; } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_get_reference(aom_codec_alg_priv_t *ctx, va_list args) { if (ctx->ppi->cpi->oxcf.algo_cfg.skip_postproc_filtering) return AOM_CODEC_INCAPABLE; av1_ref_frame_t *const frame = va_arg(args, av1_ref_frame_t *); if (frame != NULL) { YV12_BUFFER_CONFIG *fb = get_ref_frame(&ctx->ppi->cpi->common, frame->idx); if (fb == NULL) return AOM_CODEC_ERROR; yuvconfig2image(&frame->img, fb, NULL); return AOM_CODEC_OK; } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_get_new_frame_image(aom_codec_alg_priv_t *ctx, va_list args) { aom_image_t *const new_img = va_arg(args, aom_image_t *); if (new_img != NULL) { YV12_BUFFER_CONFIG new_frame; if (av1_get_last_show_frame(ctx->ppi->cpi, &new_frame) == 0) { yuvconfig2image(new_img, &new_frame, NULL); return AOM_CODEC_OK; } else { return AOM_CODEC_ERROR; } } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_copy_new_frame_image(aom_codec_alg_priv_t *ctx, va_list args) { aom_image_t *const new_img = va_arg(args, aom_image_t *); if (new_img != NULL) { YV12_BUFFER_CONFIG new_frame; if (av1_get_last_show_frame(ctx->ppi->cpi, &new_frame) == 0) { YV12_BUFFER_CONFIG sd; image2yuvconfig(new_img, &sd); return av1_copy_new_frame_enc(&ctx->ppi->cpi->common, &new_frame, &sd); } else { return AOM_CODEC_ERROR; } } else { return AOM_CODEC_INVALID_PARAM; } } static aom_image_t *encoder_get_preview(aom_codec_alg_priv_t *ctx) { YV12_BUFFER_CONFIG sd; if (av1_get_preview_raw_frame(ctx->ppi->cpi, &sd) == 0) { yuvconfig2image(&ctx->preview_img, &sd, NULL); return &ctx->preview_img; } else { return NULL; } } static aom_codec_err_t ctrl_use_reference(aom_codec_alg_priv_t *ctx, va_list args) { const int reference_flag = va_arg(args, int); av1_use_as_reference(&ctx->ppi->cpi->ext_flags.ref_frame_flags, reference_flag); return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_roi_map(aom_codec_alg_priv_t *ctx, va_list args) { (void)ctx; (void)args; // TODO(yaowu): Need to re-implement and test for AV1. return AOM_CODEC_INVALID_PARAM; } static aom_codec_err_t ctrl_set_active_map(aom_codec_alg_priv_t *ctx, va_list args) { aom_active_map_t *const map = va_arg(args, aom_active_map_t *); if (map) { if (!av1_set_active_map(ctx->ppi->cpi, map->active_map, (int)map->rows, (int)map->cols)) return AOM_CODEC_OK; else return AOM_CODEC_INVALID_PARAM; } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_get_active_map(aom_codec_alg_priv_t *ctx, va_list args) { aom_active_map_t *const map = va_arg(args, aom_active_map_t *); if (map) { if (!av1_get_active_map(ctx->ppi->cpi, map->active_map, (int)map->rows, (int)map->cols)) return AOM_CODEC_OK; else return AOM_CODEC_INVALID_PARAM; } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_set_scale_mode(aom_codec_alg_priv_t *ctx, va_list args) { aom_scaling_mode_t *const mode = va_arg(args, aom_scaling_mode_t *); if (mode) { const int res = av1_set_internal_size( &ctx->ppi->cpi->oxcf, &ctx->ppi->cpi->resize_pending_params, mode->h_scaling_mode, mode->v_scaling_mode); av1_check_fpmt_config(ctx->ppi, &ctx->ppi->cpi->oxcf); return (res == 0) ? AOM_CODEC_OK : AOM_CODEC_INVALID_PARAM; } else { return AOM_CODEC_INVALID_PARAM; } } static aom_codec_err_t ctrl_set_spatial_layer_id(aom_codec_alg_priv_t *ctx, va_list args) { const int spatial_layer_id = va_arg(args, int); if (spatial_layer_id >= MAX_NUM_SPATIAL_LAYERS) return AOM_CODEC_INVALID_PARAM; ctx->ppi->cpi->common.spatial_layer_id = spatial_layer_id; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_number_spatial_layers(aom_codec_alg_priv_t *ctx, va_list args) { const int number_spatial_layers = va_arg(args, int); if (number_spatial_layers > MAX_NUM_SPATIAL_LAYERS) return AOM_CODEC_INVALID_PARAM; ctx->ppi->number_spatial_layers = number_spatial_layers; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_layer_id(aom_codec_alg_priv_t *ctx, va_list args) { aom_svc_layer_id_t *const data = va_arg(args, aom_svc_layer_id_t *); ctx->ppi->cpi->common.spatial_layer_id = data->spatial_layer_id; ctx->ppi->cpi->common.temporal_layer_id = data->temporal_layer_id; ctx->ppi->cpi->svc.spatial_layer_id = data->spatial_layer_id; ctx->ppi->cpi->svc.temporal_layer_id = data->temporal_layer_id; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_svc_params(aom_codec_alg_priv_t *ctx, va_list args) { AV1_PRIMARY *const ppi = ctx->ppi; AV1_COMP *const cpi = ppi->cpi; AV1_COMMON *const cm = &cpi->common; AV1EncoderConfig *oxcf = &cpi->oxcf; aom_svc_params_t *const params = va_arg(args, aom_svc_params_t *); int64_t target_bandwidth = 0; ppi->number_spatial_layers = params->number_spatial_layers; ppi->number_temporal_layers = params->number_temporal_layers; cpi->svc.number_spatial_layers = params->number_spatial_layers; cpi->svc.number_temporal_layers = params->number_temporal_layers; if (ppi->number_spatial_layers > 1 || ppi->number_temporal_layers > 1) { unsigned int sl, tl; ctx->ppi->use_svc = 1; const int num_layers = ppi->number_spatial_layers * ppi->number_temporal_layers; for (int layer = 0; layer < num_layers; ++layer) { if (params->max_quantizers[layer] > 63 || params->min_quantizers[layer] < 0 || params->min_quantizers[layer] > params->max_quantizers[layer]) { return AOM_CODEC_INVALID_PARAM; } } if (!av1_alloc_layer_context(cpi, num_layers)) return AOM_CODEC_MEM_ERROR; for (sl = 0; sl < ppi->number_spatial_layers; ++sl) { for (tl = 0; tl < ppi->number_temporal_layers; ++tl) { const int layer = LAYER_IDS_TO_IDX(sl, tl, ppi->number_temporal_layers); LAYER_CONTEXT *lc = &cpi->svc.layer_context[layer]; lc->max_q = params->max_quantizers[layer]; lc->min_q = params->min_quantizers[layer]; lc->scaling_factor_num = params->scaling_factor_num[sl]; lc->scaling_factor_den = params->scaling_factor_den[sl]; lc->layer_target_bitrate = 1000 * params->layer_target_bitrate[layer]; lc->framerate_factor = params->framerate_factor[tl]; if (tl == ppi->number_temporal_layers - 1) target_bandwidth += lc->layer_target_bitrate; } } if (cm->current_frame.frame_number == 0) { if (!cpi->ppi->seq_params_locked) { SequenceHeader *const seq_params = &ppi->seq_params; seq_params->operating_points_cnt_minus_1 = ppi->number_spatial_layers * ppi->number_temporal_layers - 1; av1_init_seq_coding_tools(ppi, &cpi->oxcf, 1); } av1_init_layer_context(cpi); } oxcf->rc_cfg.target_bandwidth = target_bandwidth; set_primary_rc_buffer_sizes(oxcf, cpi->ppi); av1_update_layer_context_change_config(cpi, target_bandwidth); check_reset_rc_flag(cpi); } av1_check_fpmt_config(ctx->ppi, &ctx->ppi->cpi->oxcf); return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_svc_ref_frame_config(aom_codec_alg_priv_t *ctx, va_list args) { AV1_COMP *const cpi = ctx->ppi->cpi; aom_svc_ref_frame_config_t *const data = va_arg(args, aom_svc_ref_frame_config_t *); cpi->ppi->rtc_ref.set_ref_frame_config = 1; for (unsigned int i = 0; i < INTER_REFS_PER_FRAME; ++i) { cpi->ppi->rtc_ref.reference[i] = data->reference[i]; cpi->ppi->rtc_ref.ref_idx[i] = data->ref_idx[i]; } for (unsigned int i = 0; i < REF_FRAMES; ++i) cpi->ppi->rtc_ref.refresh[i] = data->refresh[i]; cpi->svc.use_flexible_mode = 1; cpi->svc.ksvc_fixed_mode = 0; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_svc_ref_frame_comp_pred( aom_codec_alg_priv_t *ctx, va_list args) { AV1_COMP *const cpi = ctx->ppi->cpi; aom_svc_ref_frame_comp_pred_t *const data = va_arg(args, aom_svc_ref_frame_comp_pred_t *); cpi->ppi->rtc_ref.ref_frame_comp[0] = data->use_comp_pred[0]; cpi->ppi->rtc_ref.ref_frame_comp[1] = data->use_comp_pred[1]; cpi->ppi->rtc_ref.ref_frame_comp[2] = data->use_comp_pred[2]; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_set_tune_content(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.content = CAST(AV1E_SET_TUNE_CONTENT, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_cdf_update_mode(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.cdf_update_mode = CAST(AV1E_SET_CDF_UPDATE_MODE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_color_primaries(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.color_primaries = CAST(AV1E_SET_COLOR_PRIMARIES, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_transfer_characteristics( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.transfer_characteristics = CAST(AV1E_SET_TRANSFER_CHARACTERISTICS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_matrix_coefficients(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.matrix_coefficients = CAST(AV1E_SET_MATRIX_COEFFICIENTS, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_chroma_sample_position( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.chroma_sample_position = CAST(AV1E_SET_CHROMA_SAMPLE_POSITION, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_color_range(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.color_range = CAST(AV1E_SET_COLOR_RANGE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_render_size(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; int *const render_size = va_arg(args, int *); extra_cfg.render_width = render_size[0]; extra_cfg.render_height = render_size[1]; return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_superblock_size(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.superblock_size = CAST(AV1E_SET_SUPERBLOCK_SIZE, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_chroma_subsampling_x(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.chroma_subsampling_x = CAST(AV1E_SET_CHROMA_SUBSAMPLING_X, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_set_chroma_subsampling_y(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; extra_cfg.chroma_subsampling_y = CAST(AV1E_SET_CHROMA_SUBSAMPLING_Y, args); return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t encoder_set_option(aom_codec_alg_priv_t *ctx, const char *name, const char *value) { if (ctx == NULL || name == NULL || value == NULL) return AOM_CODEC_INVALID_PARAM; struct av1_extracfg extra_cfg = ctx->extra_cfg; // Used to mock the argv with just one string "--{name}={value}" char *argv[2] = { NULL, "" }; size_t len = strlen(name) + strlen(value) + 4; char *const err_string = ctx->ppi->error.detail; #if __STDC_VERSION__ >= 201112L // We use the keyword _Static_assert because clang-cl does not allow the // convenience macro static_assert to be used in function scope. See // https://bugs.llvm.org/show_bug.cgi?id=48904. _Static_assert(sizeof(ctx->ppi->error.detail) >= ARG_ERR_MSG_MAX_LEN, "The size of the err_msg buffer for arg_match_helper must be " "at least ARG_ERR_MSG_MAX_LEN"); #else assert(sizeof(ctx->ppi->error.detail) >= ARG_ERR_MSG_MAX_LEN); #endif argv[0] = aom_malloc(len * sizeof(argv[1][0])); if (!argv[0]) return AOM_CODEC_MEM_ERROR; snprintf(argv[0], len, "--%s=%s", name, value); struct arg arg; aom_codec_err_t err = AOM_CODEC_OK; int match = 1; if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_keyframe_filtering, argv, err_string)) { extra_cfg.enable_keyframe_filtering = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.min_gf_interval, argv, err_string)) { extra_cfg.min_gf_interval = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_gf_interval, argv, err_string)) { extra_cfg.max_gf_interval = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.gf_min_pyr_height, argv, err_string)) { extra_cfg.gf_min_pyr_height = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.gf_max_pyr_height, argv, err_string)) { extra_cfg.gf_max_pyr_height = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cpu_used_av1, argv, err_string)) { extra_cfg.cpu_used = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.auto_altref, argv, err_string)) { extra_cfg.enable_auto_alt_ref = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.noise_sens, argv, err_string)) { extra_cfg.noise_sensitivity = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.sharpness, argv, err_string)) { extra_cfg.sharpness = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.static_thresh, argv, err_string)) { extra_cfg.static_thresh = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.rowmtarg, argv, err_string)) { extra_cfg.row_mt = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.fpmtarg, argv, err_string)) { extra_cfg.fp_mt = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tile_cols, argv, err_string)) { extra_cfg.tile_columns = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tile_rows, argv, err_string)) { extra_cfg.tile_rows = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_tpl_model, argv, err_string)) { extra_cfg.enable_tpl_model = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.arnr_maxframes, argv, err_string)) { extra_cfg.arnr_max_frames = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.arnr_strength, argv, err_string)) { extra_cfg.arnr_strength = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tune_metric, argv, err_string)) { extra_cfg.tuning = arg_parse_enum_helper(&arg, err_string); } #if CONFIG_TUNE_VMAF else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.vmaf_model_path, argv, err_string)) { err = allocate_and_set_string(value, default_extra_cfg.vmaf_model_path, &extra_cfg.vmaf_model_path, err_string); } #endif else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.partition_info_path, argv, err_string)) { err = allocate_and_set_string(value, default_extra_cfg.partition_info_path, &extra_cfg.partition_info_path, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_rate_guide_deltaq, argv, err_string)) { extra_cfg.enable_rate_guide_deltaq = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.rate_distribution_info, argv, err_string)) { err = allocate_and_set_string(value, default_extra_cfg.rate_distribution_info, &extra_cfg.rate_distribution_info, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.dist_metric, argv, err_string)) { extra_cfg.dist_metric = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cq_level, argv, err_string)) { extra_cfg.cq_level = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_intra_rate_pct, argv, err_string)) { extra_cfg.rc_max_intra_bitrate_pct = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_inter_rate_pct, argv, err_string)) { extra_cfg.rc_max_inter_bitrate_pct = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.gf_cbr_boost_pct, argv, err_string)) { extra_cfg.gf_cbr_boost_pct = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.lossless, argv, err_string)) { extra_cfg.lossless = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_cdef, argv, err_string)) { extra_cfg.enable_cdef = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_restoration, argv, err_string)) { extra_cfg.enable_restoration = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.force_video_mode, argv, err_string)) { extra_cfg.force_video_mode = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_obmc, argv, err_string)) { extra_cfg.enable_obmc = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.disable_trellis_quant, argv, err_string)) { extra_cfg.disable_trellis_quant = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_qm, argv, err_string)) { extra_cfg.enable_qm = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.qm_max, argv, err_string)) { extra_cfg.qm_max = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.qm_min, argv, err_string)) { extra_cfg.qm_min = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.num_tg, argv, err_string)) { extra_cfg.num_tg = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.mtu_size, argv, err_string)) { extra_cfg.mtu_size = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.timing_info, argv, err_string)) { extra_cfg.timing_info_type = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.frame_parallel_decoding, argv, err_string)) { extra_cfg.frame_parallel_decoding_mode = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_dual_filter, argv, err_string)) { extra_cfg.enable_dual_filter = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_chroma_deltaq, argv, err_string)) { extra_cfg.enable_chroma_deltaq = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.aq_mode, argv, err_string)) { extra_cfg.aq_mode = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.deltaq_mode, argv, err_string)) { extra_cfg.deltaq_mode = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.deltaq_strength, argv, err_string)) { extra_cfg.deltaq_strength = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.deltalf_mode, argv, err_string)) { extra_cfg.deltalf_mode = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.frame_periodic_boost, argv, err_string)) { extra_cfg.frame_periodic_boost = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tune_content, argv, err_string)) { extra_cfg.content = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.input_color_primaries, argv, err_string)) { extra_cfg.color_primaries = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper( &arg, &g_av1_codec_arg_defs.input_transfer_characteristics, argv, err_string)) { extra_cfg.transfer_characteristics = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.input_matrix_coefficients, argv, err_string)) { extra_cfg.matrix_coefficients = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper( &arg, &g_av1_codec_arg_defs.input_chroma_sample_position, argv, err_string)) { extra_cfg.chroma_sample_position = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.superblock_size, argv, err_string)) { extra_cfg.superblock_size = arg_parse_enum_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.error_resilient_mode, argv, err_string)) { extra_cfg.error_resilient_mode = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.sframe_mode, argv, err_string)) { extra_cfg.s_frame_mode = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.film_grain_test, argv, err_string)) { extra_cfg.film_grain_test_vector = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.film_grain_table, argv, err_string)) { if (value == NULL) { // this parameter allows NULL as its value extra_cfg.film_grain_table_filename = value; } else { err = allocate_and_set_string( value, default_extra_cfg.film_grain_table_filename, &extra_cfg.film_grain_table_filename, err_string); } } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.cdf_update_mode, argv, err_string)) { extra_cfg.cdf_update_mode = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_rect_partitions, argv, err_string)) { extra_cfg.enable_rect_partitions = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_ab_partitions, argv, err_string)) { extra_cfg.enable_ab_partitions = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_1to4_partitions, argv, err_string)) { extra_cfg.enable_1to4_partitions = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.min_partition_size, argv, err_string)) { extra_cfg.min_partition_size = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_partition_size, argv, err_string)) { extra_cfg.max_partition_size = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_intra_edge_filter, argv, err_string)) { extra_cfg.enable_intra_edge_filter = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_order_hint, argv, err_string)) { extra_cfg.enable_order_hint = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_tx64, argv, err_string)) { extra_cfg.enable_tx64 = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_flip_idtx, argv, err_string)) { extra_cfg.enable_flip_idtx = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_rect_tx, argv, err_string)) { extra_cfg.enable_rect_tx = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_dist_wtd_comp, argv, err_string)) { extra_cfg.enable_dist_wtd_comp = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.max_reference_frames, argv, err_string)) { extra_cfg.max_reference_frames = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.reduced_reference_set, argv, err_string)) { extra_cfg.enable_reduced_reference_set = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_ref_frame_mvs, argv, err_string)) { extra_cfg.enable_ref_frame_mvs = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_masked_comp, argv, err_string)) { extra_cfg.enable_masked_comp = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_onesided_comp, argv, err_string)) { extra_cfg.enable_onesided_comp = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_interintra_comp, argv, err_string)) { extra_cfg.enable_interintra_comp = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_smooth_interintra, argv, err_string)) { extra_cfg.enable_smooth_interintra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_diff_wtd_comp, argv, err_string)) { extra_cfg.enable_diff_wtd_comp = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_interinter_wedge, argv, err_string)) { extra_cfg.enable_interinter_wedge = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_interintra_wedge, argv, err_string)) { extra_cfg.enable_interintra_wedge = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_global_motion, argv, err_string)) { extra_cfg.enable_global_motion = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_warped_motion, argv, err_string)) { extra_cfg.enable_warped_motion = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_filter_intra, argv, err_string)) { extra_cfg.enable_filter_intra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_smooth_intra, argv, err_string)) { extra_cfg.enable_smooth_intra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_paeth_intra, argv, err_string)) { extra_cfg.enable_paeth_intra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_cfl_intra, argv, err_string)) { extra_cfg.enable_cfl_intra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_directional_intra, argv, err_string)) { extra_cfg.enable_directional_intra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_diagonal_intra, argv, err_string)) { extra_cfg.enable_diagonal_intra = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_overlay, argv, err_string)) { extra_cfg.enable_overlay = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_palette, argv, err_string)) { extra_cfg.enable_palette = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_intrabc, argv, err_string)) { extra_cfg.enable_intrabc = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_angle_delta, argv, err_string)) { extra_cfg.enable_angle_delta = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.reduced_tx_type_set, argv, err_string)) { extra_cfg.reduced_tx_type_set = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.use_intra_dct_only, argv, err_string)) { extra_cfg.use_intra_dct_only = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.use_inter_dct_only, argv, err_string)) { extra_cfg.use_inter_dct_only = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.use_intra_default_tx_only, argv, err_string)) { extra_cfg.use_intra_default_tx_only = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.quant_b_adapt, argv, err_string)) { extra_cfg.quant_b_adapt = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.vbr_corpus_complexity_lap, argv, err_string)) { extra_cfg.vbr_corpus_complexity_lap = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.set_tier_mask, argv, err_string)) { extra_cfg.tier_mask = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.set_min_cr, argv, err_string)) { extra_cfg.min_cr = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.coeff_cost_upd_freq, argv, err_string)) { extra_cfg.coeff_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.mode_cost_upd_freq, argv, err_string)) { extra_cfg.mode_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.mv_cost_upd_freq, argv, err_string)) { extra_cfg.mv_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.dv_cost_upd_freq, argv, err_string)) { extra_cfg.dv_cost_upd_freq = arg_parse_uint_helper(&arg, err_string); } #if CONFIG_DENOISE else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.denoise_noise_level, argv, err_string)) { extra_cfg.noise_level = (float)arg_parse_int_helper(&arg, err_string) / 10.0f; } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.denoise_block_size, argv, err_string)) { extra_cfg.noise_block_size = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_dnl_denoising, argv, err_string)) { extra_cfg.enable_dnl_denoising = arg_parse_uint_helper(&arg, err_string); } #endif else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.target_seq_level_idx, argv, err_string)) { const int val = arg_parse_int_helper(&arg, err_string); const int level = val % 100; const int operating_point_idx = val / 100; if (operating_point_idx < 0 || operating_point_idx >= MAX_NUM_OPERATING_POINTS) { snprintf(err_string, ARG_ERR_MSG_MAX_LEN, "Invalid operating point index: %d", operating_point_idx); err = AOM_CODEC_INVALID_PARAM; } else { extra_cfg.target_seq_level_idx[operating_point_idx] = (AV1_LEVEL)level; } } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.input_chroma_subsampling_x, argv, err_string)) { extra_cfg.chroma_subsampling_x = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.input_chroma_subsampling_y, argv, err_string)) { extra_cfg.chroma_subsampling_y = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.passes, argv, err_string)) { extra_cfg.passes = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.fwd_kf_dist, argv, err_string)) { extra_cfg.fwd_kf_dist = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.two_pass_output, argv, err_string)) { err = allocate_and_set_string(value, default_extra_cfg.two_pass_output, &extra_cfg.two_pass_output, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.second_pass_log, argv, err_string)) { err = allocate_and_set_string(value, default_extra_cfg.second_pass_log, &extra_cfg.second_pass_log, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.loopfilter_control, argv, err_string)) { extra_cfg.loopfilter_control = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.auto_intra_tools_off, argv, err_string)) { extra_cfg.auto_intra_tools_off = arg_parse_uint_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.strict_level_conformance, argv, err_string)) { extra_cfg.strict_level_conformance = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.sb_qp_sweep, argv, err_string)) { extra_cfg.sb_qp_sweep = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.kf_max_pyr_height, argv, err_string)) { extra_cfg.kf_max_pyr_height = arg_parse_int_helper(&arg, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tile_width, argv, err_string)) { ctx->cfg.tile_width_count = arg_parse_list_helper( &arg, ctx->cfg.tile_widths, MAX_TILE_WIDTHS, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.tile_height, argv, err_string)) { ctx->cfg.tile_height_count = arg_parse_list_helper( &arg, ctx->cfg.tile_heights, MAX_TILE_HEIGHTS, err_string); } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.global_motion_method, argv, err_string)) { extra_cfg.global_motion_method = arg_parse_enum_helper(&arg, err_string); } else { match = 0; snprintf(err_string, ARG_ERR_MSG_MAX_LEN, "Cannot find aom option %s", name); } aom_free(argv[0]); if (err != AOM_CODEC_OK) { ctx->base.err_detail = err_string; return err; } if (strlen(err_string) != 0) { ctx->base.err_detail = err_string; return AOM_CODEC_INVALID_PARAM; } ctx->base.err_detail = NULL; if (!match) { return AOM_CODEC_INVALID_PARAM; } return update_extra_cfg(ctx, &extra_cfg); } static aom_codec_err_t ctrl_get_seq_level_idx(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; return av1_get_seq_level_idx(&ctx->ppi->seq_params, &ctx->ppi->level_params, arg); } static aom_codec_err_t ctrl_get_target_seq_level_idx(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; return av1_get_target_seq_level_idx(&ctx->ppi->seq_params, &ctx->ppi->level_params, arg); } static aom_codec_err_t ctrl_get_num_operating_points(aom_codec_alg_priv_t *ctx, va_list args) { int *const arg = va_arg(args, int *); if (arg == NULL) return AOM_CODEC_INVALID_PARAM; *arg = ctx->ppi->seq_params.operating_points_cnt_minus_1 + 1; return AOM_CODEC_OK; } static aom_codec_err_t ctrl_get_luma_cdef_strength(aom_codec_alg_priv_t *ctx, va_list args) { int *arg = va_arg(args, int *); AV1_COMMON const *cm = &ctx->ppi->cpi->common; if (arg == NULL) return AOM_CODEC_INVALID_PARAM; memcpy(arg, cm->cdef_info.cdef_strengths, CDEF_MAX_STRENGTHS * sizeof(*arg)); return AOM_CODEC_OK; } static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = { { AV1_COPY_REFERENCE, ctrl_copy_reference }, { AOME_USE_REFERENCE, ctrl_use_reference }, // Setters { AV1_SET_REFERENCE, ctrl_set_reference }, { AOME_SET_ROI_MAP, ctrl_set_roi_map }, { AOME_SET_ACTIVEMAP, ctrl_set_active_map }, { AOME_SET_SCALEMODE, ctrl_set_scale_mode }, { AOME_SET_SPATIAL_LAYER_ID, ctrl_set_spatial_layer_id }, { AOME_SET_CPUUSED, ctrl_set_cpuused }, { AOME_SET_ENABLEAUTOALTREF, ctrl_set_enable_auto_alt_ref }, { AOME_SET_ENABLEAUTOBWDREF, ctrl_set_enable_auto_bwd_ref }, { AOME_SET_SHARPNESS, ctrl_set_sharpness }, { AOME_SET_STATIC_THRESHOLD, ctrl_set_static_thresh }, { AV1E_SET_ROW_MT, ctrl_set_row_mt }, { AV1E_SET_FP_MT, ctrl_set_fp_mt }, { AV1E_SET_TILE_COLUMNS, ctrl_set_tile_columns }, { AV1E_SET_TILE_ROWS, ctrl_set_tile_rows }, { AV1E_SET_ENABLE_TPL_MODEL, ctrl_set_enable_tpl_model }, { AV1E_SET_ENABLE_KEYFRAME_FILTERING, ctrl_set_enable_keyframe_filtering }, { AOME_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames }, { AOME_SET_ARNR_STRENGTH, ctrl_set_arnr_strength }, { AOME_SET_TUNING, ctrl_set_tuning }, { AOME_SET_CQ_LEVEL, ctrl_set_cq_level }, { AOME_SET_MAX_INTRA_BITRATE_PCT, ctrl_set_rc_max_intra_bitrate_pct }, { AOME_SET_NUMBER_SPATIAL_LAYERS, ctrl_set_number_spatial_layers }, { AV1E_SET_MAX_INTER_BITRATE_PCT, ctrl_set_rc_max_inter_bitrate_pct }, { AV1E_SET_GF_CBR_BOOST_PCT, ctrl_set_rc_gf_cbr_boost_pct }, { AV1E_SET_LOSSLESS, ctrl_set_lossless }, { AV1E_SET_ENABLE_CDEF, ctrl_set_enable_cdef }, { AV1E_SET_ENABLE_RESTORATION, ctrl_set_enable_restoration }, { AV1E_SET_FORCE_VIDEO_MODE, ctrl_set_force_video_mode }, { AV1E_SET_ENABLE_OBMC, ctrl_set_enable_obmc }, { AV1E_SET_DISABLE_TRELLIS_QUANT, ctrl_set_disable_trellis_quant }, { AV1E_SET_ENABLE_QM, ctrl_set_enable_qm }, { AV1E_SET_QM_Y, ctrl_set_qm_y }, { AV1E_SET_QM_U, ctrl_set_qm_u }, { AV1E_SET_QM_V, ctrl_set_qm_v }, { AV1E_SET_QM_MIN, ctrl_set_qm_min }, { AV1E_SET_QM_MAX, ctrl_set_qm_max }, { AV1E_SET_NUM_TG, ctrl_set_num_tg }, { AV1E_SET_MTU, ctrl_set_mtu }, { AV1E_SET_TIMING_INFO_TYPE, ctrl_set_timing_info_type }, { AV1E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode }, { AV1E_SET_ERROR_RESILIENT_MODE, ctrl_set_error_resilient_mode }, { AV1E_SET_S_FRAME_MODE, ctrl_set_s_frame_mode }, { AV1E_SET_ENABLE_RECT_PARTITIONS, ctrl_set_enable_rect_partitions }, { AV1E_SET_ENABLE_AB_PARTITIONS, ctrl_set_enable_ab_partitions }, { AV1E_SET_ENABLE_1TO4_PARTITIONS, ctrl_set_enable_1to4_partitions }, { AV1E_SET_MIN_PARTITION_SIZE, ctrl_set_min_partition_size }, { AV1E_SET_MAX_PARTITION_SIZE, ctrl_set_max_partition_size }, { AV1E_SET_ENABLE_DUAL_FILTER, ctrl_set_enable_dual_filter }, { AV1E_SET_ENABLE_CHROMA_DELTAQ, ctrl_set_enable_chroma_deltaq }, { AV1E_SET_ENABLE_INTRA_EDGE_FILTER, ctrl_set_enable_intra_edge_filter }, { AV1E_SET_ENABLE_ORDER_HINT, ctrl_set_enable_order_hint }, { AV1E_SET_ENABLE_TX64, ctrl_set_enable_tx64 }, { AV1E_SET_ENABLE_FLIP_IDTX, ctrl_set_enable_flip_idtx }, { AV1E_SET_ENABLE_RECT_TX, ctrl_set_enable_rect_tx }, { AV1E_SET_ENABLE_DIST_WTD_COMP, ctrl_set_enable_dist_wtd_comp }, { AV1E_SET_MAX_REFERENCE_FRAMES, ctrl_set_max_reference_frames }, { AV1E_SET_REDUCED_REFERENCE_SET, ctrl_set_enable_reduced_reference_set }, { AV1E_SET_ENABLE_REF_FRAME_MVS, ctrl_set_enable_ref_frame_mvs }, { AV1E_SET_ALLOW_REF_FRAME_MVS, ctrl_set_allow_ref_frame_mvs }, { AV1E_SET_ENABLE_MASKED_COMP, ctrl_set_enable_masked_comp }, { AV1E_SET_ENABLE_ONESIDED_COMP, ctrl_set_enable_onesided_comp }, { AV1E_SET_ENABLE_INTERINTRA_COMP, ctrl_set_enable_interintra_comp }, { AV1E_SET_ENABLE_SMOOTH_INTERINTRA, ctrl_set_enable_smooth_interintra }, { AV1E_SET_ENABLE_DIFF_WTD_COMP, ctrl_set_enable_diff_wtd_comp }, { AV1E_SET_ENABLE_INTERINTER_WEDGE, ctrl_set_enable_interinter_wedge }, { AV1E_SET_ENABLE_INTERINTRA_WEDGE, ctrl_set_enable_interintra_wedge }, { AV1E_SET_ENABLE_GLOBAL_MOTION, ctrl_set_enable_global_motion }, { AV1E_SET_ENABLE_WARPED_MOTION, ctrl_set_enable_warped_motion }, { AV1E_SET_ALLOW_WARPED_MOTION, ctrl_set_allow_warped_motion }, { AV1E_SET_ENABLE_FILTER_INTRA, ctrl_set_enable_filter_intra }, { AV1E_SET_ENABLE_SMOOTH_INTRA, ctrl_set_enable_smooth_intra }, { AV1E_SET_ENABLE_PAETH_INTRA, ctrl_set_enable_paeth_intra }, { AV1E_SET_ENABLE_CFL_INTRA, ctrl_set_enable_cfl_intra }, { AV1E_SET_ENABLE_DIRECTIONAL_INTRA, ctrl_set_enable_directional_intra }, { AV1E_SET_ENABLE_DIAGONAL_INTRA, ctrl_set_enable_diagonal_intra }, { AV1E_SET_ENABLE_SUPERRES, ctrl_set_enable_superres }, { AV1E_SET_ENABLE_OVERLAY, ctrl_set_enable_overlay }, { AV1E_SET_ENABLE_PALETTE, ctrl_set_enable_palette }, { AV1E_SET_ENABLE_INTRABC, ctrl_set_enable_intrabc }, { AV1E_SET_ENABLE_ANGLE_DELTA, ctrl_set_enable_angle_delta }, { AV1E_SET_AQ_MODE, ctrl_set_aq_mode }, { AV1E_SET_REDUCED_TX_TYPE_SET, ctrl_set_reduced_tx_type_set }, { AV1E_SET_INTRA_DCT_ONLY, ctrl_set_intra_dct_only }, { AV1E_SET_INTER_DCT_ONLY, ctrl_set_inter_dct_only }, { AV1E_SET_INTRA_DEFAULT_TX_ONLY, ctrl_set_intra_default_tx_only }, { AV1E_SET_QUANT_B_ADAPT, ctrl_set_quant_b_adapt }, { AV1E_SET_COEFF_COST_UPD_FREQ, ctrl_set_coeff_cost_upd_freq }, { AV1E_SET_MODE_COST_UPD_FREQ, ctrl_set_mode_cost_upd_freq }, { AV1E_SET_MV_COST_UPD_FREQ, ctrl_set_mv_cost_upd_freq }, { AV1E_SET_DELTAQ_MODE, ctrl_set_deltaq_mode }, { AV1E_SET_DELTAQ_STRENGTH, ctrl_set_deltaq_strength }, { AV1E_SET_DELTALF_MODE, ctrl_set_deltalf_mode }, { AV1E_SET_FRAME_PERIODIC_BOOST, ctrl_set_frame_periodic_boost }, { AV1E_SET_TUNE_CONTENT, ctrl_set_tune_content }, { AV1E_SET_CDF_UPDATE_MODE, ctrl_set_cdf_update_mode }, { AV1E_SET_COLOR_PRIMARIES, ctrl_set_color_primaries }, { AV1E_SET_TRANSFER_CHARACTERISTICS, ctrl_set_transfer_characteristics }, { AV1E_SET_MATRIX_COEFFICIENTS, ctrl_set_matrix_coefficients }, { AV1E_SET_CHROMA_SAMPLE_POSITION, ctrl_set_chroma_sample_position }, { AV1E_SET_COLOR_RANGE, ctrl_set_color_range }, { AV1E_SET_NOISE_SENSITIVITY, ctrl_set_noise_sensitivity }, { AV1E_SET_MIN_GF_INTERVAL, ctrl_set_min_gf_interval }, { AV1E_SET_MAX_GF_INTERVAL, ctrl_set_max_gf_interval }, { AV1E_SET_GF_MIN_PYRAMID_HEIGHT, ctrl_set_gf_min_pyr_height }, { AV1E_SET_GF_MAX_PYRAMID_HEIGHT, ctrl_set_gf_max_pyr_height }, { AV1E_SET_RENDER_SIZE, ctrl_set_render_size }, { AV1E_SET_SUPERBLOCK_SIZE, ctrl_set_superblock_size }, { AV1E_SET_SINGLE_TILE_DECODING, ctrl_set_single_tile_decoding }, { AV1E_SET_VMAF_MODEL_PATH, ctrl_set_vmaf_model_path }, { AV1E_SET_PARTITION_INFO_PATH, ctrl_set_partition_info_path }, { AV1E_ENABLE_RATE_GUIDE_DELTAQ, ctrl_enable_rate_guide_deltaq }, { AV1E_SET_RATE_DISTRIBUTION_INFO, ctrl_set_rate_distribution_info }, { AV1E_SET_FILM_GRAIN_TEST_VECTOR, ctrl_set_film_grain_test_vector }, { AV1E_SET_FILM_GRAIN_TABLE, ctrl_set_film_grain_table }, { AV1E_SET_DENOISE_NOISE_LEVEL, ctrl_set_denoise_noise_level }, { AV1E_SET_DENOISE_BLOCK_SIZE, ctrl_set_denoise_block_size }, { AV1E_SET_ENABLE_DNL_DENOISING, ctrl_set_enable_dnl_denoising }, { AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, ctrl_enable_motion_vector_unit_test }, { AV1E_SET_FP_MT_UNIT_TEST, ctrl_enable_fpmt_unit_test }, { AV1E_ENABLE_EXT_TILE_DEBUG, ctrl_enable_ext_tile_debug }, { AV1E_SET_TARGET_SEQ_LEVEL_IDX, ctrl_set_target_seq_level_idx }, { AV1E_SET_TIER_MASK, ctrl_set_tier_mask }, { AV1E_SET_MIN_CR, ctrl_set_min_cr }, { AV1E_SET_SVC_LAYER_ID, ctrl_set_layer_id }, { AV1E_SET_SVC_PARAMS, ctrl_set_svc_params }, { AV1E_SET_SVC_REF_FRAME_CONFIG, ctrl_set_svc_ref_frame_config }, { AV1E_SET_SVC_REF_FRAME_COMP_PRED, ctrl_set_svc_ref_frame_comp_pred }, { AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, ctrl_set_vbr_corpus_complexity_lap }, { AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST, ctrl_enable_sb_multipass_unit_test }, { AV1E_ENABLE_SB_QP_SWEEP, ctrl_enable_sb_qp_sweep }, { AV1E_SET_DV_COST_UPD_FREQ, ctrl_set_dv_cost_upd_freq }, { AV1E_SET_EXTERNAL_PARTITION, ctrl_set_external_partition }, { AV1E_SET_ENABLE_TX_SIZE_SEARCH, ctrl_set_enable_tx_size_search }, { AV1E_SET_LOOPFILTER_CONTROL, ctrl_set_loopfilter_control }, { AV1E_SET_SKIP_POSTPROC_FILTERING, ctrl_set_skip_postproc_filtering }, { AV1E_SET_AUTO_INTRA_TOOLS_OFF, ctrl_set_auto_intra_tools_off }, { AV1E_SET_RTC_EXTERNAL_RC, ctrl_set_rtc_external_rc }, { AV1E_SET_QUANTIZER_ONE_PASS, ctrl_set_quantizer_one_pass }, // Getters { AOME_GET_LAST_QUANTIZER, ctrl_get_quantizer }, { AOME_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64 }, { AOME_GET_LOOPFILTER_LEVEL, ctrl_get_loopfilter_level }, { AV1_GET_REFERENCE, ctrl_get_reference }, { AV1E_GET_ACTIVEMAP, ctrl_get_active_map }, { AV1_GET_NEW_FRAME_IMAGE, ctrl_get_new_frame_image }, { AV1_COPY_NEW_FRAME_IMAGE, ctrl_copy_new_frame_image }, { AV1E_SET_CHROMA_SUBSAMPLING_X, ctrl_set_chroma_subsampling_x }, { AV1E_SET_CHROMA_SUBSAMPLING_Y, ctrl_set_chroma_subsampling_y }, { AV1E_GET_SEQ_LEVEL_IDX, ctrl_get_seq_level_idx }, { AV1E_GET_BASELINE_GF_INTERVAL, ctrl_get_baseline_gf_interval }, { AV1E_GET_TARGET_SEQ_LEVEL_IDX, ctrl_get_target_seq_level_idx }, { AV1E_GET_NUM_OPERATING_POINTS, ctrl_get_num_operating_points }, { AV1E_GET_LUMA_CDEF_STRENGTH, ctrl_get_luma_cdef_strength }, CTRL_MAP_END, }; static const aom_codec_enc_cfg_t encoder_usage_cfg[] = { #if !CONFIG_REALTIME_ONLY { // NOLINT AOM_USAGE_GOOD_QUALITY, // g_usage - non-realtime usage 0, // g_threads 0, // g_profile 320, // g_w 240, // g_h 0, // g_limit 0, // g_forced_max_frame_width 0, // g_forced_max_frame_height AOM_BITS_8, // g_bit_depth 8, // g_input_bit_depth { 1, 30 }, // g_timebase 0, // g_error_resilient AOM_RC_ONE_PASS, // g_pass 35, // g_lag_in_frames 0, // rc_dropframe_thresh RESIZE_NONE, // rc_resize_mode SCALE_NUMERATOR, // rc_resize_denominator SCALE_NUMERATOR, // rc_resize_kf_denominator AOM_SUPERRES_NONE, // rc_superres_mode SCALE_NUMERATOR, // rc_superres_denominator SCALE_NUMERATOR, // rc_superres_kf_denominator 63, // rc_superres_qthresh 32, // rc_superres_kf_qthresh AOM_VBR, // rc_end_usage { NULL, 0 }, // rc_twopass_stats_in { NULL, 0 }, // rc_firstpass_mb_stats_in 256, // rc_target_bitrate 0, // rc_min_quantizer 63, // rc_max_quantizer 25, // rc_undershoot_pct 25, // rc_overshoot_pct 6000, // rc_max_buffer_size 4000, // rc_buffer_initial_size 5000, // rc_buffer_optimal_size 50, // rc_two_pass_vbrbias 0, // rc_two_pass_vbrmin_section 2000, // rc_two_pass_vbrmax_section // keyframing settings (kf) 0, // fwd_kf_enabled AOM_KF_AUTO, // kf_mode 0, // kf_min_dist 9999, // kf_max_dist 0, // sframe_dist 1, // sframe_mode 0, // large_scale_tile 0, // monochrome 0, // full_still_picture_hdr 0, // save_as_annexb 0, // tile_width_count 0, // tile_height_count { 0 }, // tile_widths { 0 }, // tile_heights 0, // use_fixed_qp_offsets { -1, -1, -1, -1, -1 }, // fixed_qp_offsets { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg }, #endif // !CONFIG_REALTIME_ONLY { // NOLINT AOM_USAGE_REALTIME, // g_usage - real-time usage 0, // g_threads 0, // g_profile 320, // g_w 240, // g_h 0, // g_limit 0, // g_forced_max_frame_width 0, // g_forced_max_frame_height AOM_BITS_8, // g_bit_depth 8, // g_input_bit_depth { 1, 30 }, // g_timebase 0, // g_error_resilient AOM_RC_ONE_PASS, // g_pass 0, // g_lag_in_frames 0, // rc_dropframe_thresh RESIZE_NONE, // rc_resize_mode SCALE_NUMERATOR, // rc_resize_denominator SCALE_NUMERATOR, // rc_resize_kf_denominator AOM_SUPERRES_NONE, // rc_superres_mode SCALE_NUMERATOR, // rc_superres_denominator SCALE_NUMERATOR, // rc_superres_kf_denominator 63, // rc_superres_qthresh 32, // rc_superres_kf_qthresh AOM_CBR, // rc_end_usage { NULL, 0 }, // rc_twopass_stats_in { NULL, 0 }, // rc_firstpass_mb_stats_in 256, // rc_target_bitrate 0, // rc_min_quantizer 63, // rc_max_quantizer 25, // rc_undershoot_pct 25, // rc_overshoot_pct 6000, // rc_max_buffer_size 4000, // rc_buffer_initial_size 5000, // rc_buffer_optimal_size 50, // rc_two_pass_vbrbias 0, // rc_two_pass_vbrmin_section 2000, // rc_two_pass_vbrmax_section // keyframing settings (kf) 0, // fwd_kf_enabled AOM_KF_AUTO, // kf_mode 0, // kf_min_dist 9999, // kf_max_dist 0, // sframe_dist 1, // sframe_mode 0, // large_scale_tile 0, // monochrome 0, // full_still_picture_hdr 0, // save_as_annexb 0, // tile_width_count 0, // tile_height_count { 0 }, // tile_widths { 0 }, // tile_heights 0, // use_fixed_qp_offsets { -1, -1, -1, -1, -1 }, // fixed_qp_offsets { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg }, #if !CONFIG_REALTIME_ONLY { // NOLINT AOM_USAGE_ALL_INTRA, // g_usage - all intra usage 0, // g_threads 0, // g_profile 320, // g_w 240, // g_h 0, // g_limit 0, // g_forced_max_frame_width 0, // g_forced_max_frame_height AOM_BITS_8, // g_bit_depth 8, // g_input_bit_depth { 1, 30 }, // g_timebase 0, // g_error_resilient AOM_RC_ONE_PASS, // g_pass 0, // g_lag_in_frames 0, // rc_dropframe_thresh RESIZE_NONE, // rc_resize_mode SCALE_NUMERATOR, // rc_resize_denominator SCALE_NUMERATOR, // rc_resize_kf_denominator AOM_SUPERRES_NONE, // rc_superres_mode SCALE_NUMERATOR, // rc_superres_denominator SCALE_NUMERATOR, // rc_superres_kf_denominator 63, // rc_superres_qthresh 32, // rc_superres_kf_qthresh AOM_Q, // rc_end_usage { NULL, 0 }, // rc_twopass_stats_in { NULL, 0 }, // rc_firstpass_mb_stats_in 256, // rc_target_bitrate 0, // rc_min_quantizer 63, // rc_max_quantizer 25, // rc_undershoot_pct 25, // rc_overshoot_pct 6000, // rc_max_buffer_size 4000, // rc_buffer_initial_size 5000, // rc_buffer_optimal_size 50, // rc_two_pass_vbrbias 0, // rc_two_pass_vbrmin_section 2000, // rc_two_pass_vbrmax_section // keyframing settings (kf) 0, // fwd_kf_enabled AOM_KF_DISABLED, // kf_mode 0, // kf_min_dist 0, // kf_max_dist 0, // sframe_dist 1, // sframe_mode 0, // large_scale_tile 0, // monochrome 0, // full_still_picture_hdr 0, // save_as_annexb 0, // tile_width_count 0, // tile_height_count { 0 }, // tile_widths { 0 }, // tile_heights 0, // use_fixed_qp_offsets { -1, -1, -1, -1, -1 }, // fixed_qp_offsets { 0, 128, 128, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // cfg }, #endif // !CONFIG_REALTIME_ONLY }; // This data structure and function are exported in aom/aomcx.h #ifndef VERSION_STRING #define VERSION_STRING #endif aom_codec_iface_t aom_codec_av1_cx_algo = { "AOMedia Project AV1 Encoder" VERSION_STRING, AOM_CODEC_INTERNAL_ABI_VERSION, AOM_CODEC_CAP_HIGHBITDEPTH | AOM_CODEC_CAP_ENCODER | AOM_CODEC_CAP_PSNR, // aom_codec_caps_t encoder_init, // aom_codec_init_fn_t encoder_destroy, // aom_codec_destroy_fn_t encoder_ctrl_maps, // aom_codec_ctrl_fn_map_t { // NOLINT NULL, // aom_codec_peek_si_fn_t NULL, // aom_codec_get_si_fn_t NULL, // aom_codec_decode_fn_t NULL, // aom_codec_get_frame_fn_t NULL // aom_codec_set_fb_fn_t }, { // NOLINT NELEMENTS(encoder_usage_cfg), // cfg_count encoder_usage_cfg, // aom_codec_enc_cfg_t encoder_encode, // aom_codec_encode_fn_t encoder_get_cxdata, // aom_codec_get_cx_data_fn_t encoder_set_config, // aom_codec_enc_config_set_fn_t encoder_get_global_headers, // aom_codec_get_global_headers_fn_t encoder_get_preview // aom_codec_get_preview_frame_fn_t }, encoder_set_option // aom_codec_set_option_fn_t }; aom_codec_iface_t *aom_codec_av1_cx(void) { return &aom_codec_av1_cx_algo; }
42063b9e14a98e1e21d421ab40331c404beec90e
89db60818afeb3dc7c3b7abe9ceae155f074f7f2
/src/libdraw/debug.c
3a6788a83e3abb110cf031aed4be78a7ba8ba70b
[ "bzip2-1.0.6", "LPL-1.02", "MIT" ]
permissive
9fans/plan9port
63c3d01928c6f8a8617d3ea6ecc05bac72391132
65c090346a38a8c30cb242d345aa71060116340c
refs/heads/master
2023-08-25T17:14:26.233105
2023-08-23T13:21:37
2023-08-23T18:47:08
26,095,474
1,645
468
NOASSERTION
2023-09-05T16:55:41
2014-11-02T22:40:13
C
UTF-8
C
false
false
206
c
debug.c
#include <u.h> #include <libc.h> #include <draw.h> void drawsetdebug(int v) { uchar *a; a = bufimage(display, 1+1); if(a == 0){ fprint(2, "drawsetdebug: %r\n"); return; } a[0] = 'D'; a[1] = v; }
2961c96acee5e77805c7bd1b22d11dc6b51565bc
2bf5a47a8610a9b7839d321805932abc9112665d
/lib/ext_menu.h
8f4ebd8245f9caced83e95c84bce82ddfccc917f
[ "MIT" ]
permissive
johanberntsson/PunyInform
8c6edd0a5550fc11212860e9930027ccdca1c327
7882f8efa98e3a6f7309a2dec1567257b5cff639
refs/heads/master
2023-08-30T23:18:16.174998
2023-08-27T10:42:50
2023-08-27T10:42:50
166,382,779
148
23
MIT
2023-09-12T09:22:43
2019-01-18T09:50:57
C
UTF-8
C
false
false
5,306
h
ext_menu.h
! This PunyInform extension offers a way to present menus that, from the ! programmer's perspective, work the same on any Z-machine version. The ! presentation on z5+ is like the DoMenu extension described in DM3 and ! which is currently part of the Inform 6 standard library. On z3 the ! presentation is simpler, but still fully functional. ! ! This extension deviates from the standard DoMenu implementation in one ! respect - when assigning a value to the variable item_width, this value ! should be the full width of the item, e.g. if the item title is "Help", ! item_width should be set to 4, whereas in the standard library it should ! be set to half the width of the item, e.g. 2 in this case. ! If you're writing a game which should be compilable with both PunyInform ! and the standard library, it may be more convenient to have ext_menu ! use the same logic for item_width as DoMenu in the standard library does. ! To get that behaviour, define the constant EXT_MENU_STDLIB_MODE before ! including the extension. System_file; Constant EXT_MENU = 1; #Ifdef EXT_MENU_STDLIB_MODE; #Endif; Global menu_item; Global item_width; Global item_name; Global menu_nesting; #IfV3; [ DoMenu menu_choices EntryR ChoiceR lines main_title i j; menu_choices = 0; ! Avoid warning menu_nesting++; ._v3_redisplay_menu; menu_item = 0; lines = indirect(EntryR); main_title = item_name; print "--- "; print (string) main_title; print " ---^^"; !if (menu_choices ofclass Routine) menu_choices.call(); !else print (string) menu_choices; print "There is information provided on the following:^^"; for(i = 1: i <= lines: i++) { menu_item = i; indirect(EntryR); print i, ": ", (string) item_name, "^"; } if(menu_nesting == 1) { print "q: Resume the game^"; } else { print "q: Previous menu^"; } for (::) { print "^Select 1 to ", lines, " or ENTER to show the options again.^"; print "> "; _ReadPlayerInput(true); j = parse->1; ! number of words if (j == 0) jump _v3_redisplay_menu; i = parse-->1; if(i == 'q//') { menu_nesting--; if (menu_nesting > 0) rfalse; if (deadflag == 0) <<Look>>; rfalse; } i = TryNumber(1); if (i < 1 || i > lines) continue; menu_item = i; j = indirect(EntryR); print "^--- "; print (string) item_name; print " ---^^"; j = indirect(ChoiceR); if (j == 2) jump _v3_redisplay_menu; if (j == 3) rfalse; } ]; #IfNot; ! v5+ Constant NKEY__TX = "N = next subject"; Constant PKEY__TX = "P = previous"; Constant QKEY1__TX = " Q = resume game"; Constant QKEY2__TX = "Q = previous menu"; Constant RKEY__TX = "RETURN = read subject"; Constant NKEY1__KY = 'N'; Constant NKEY2__KY = 'n'; Constant PKEY1__KY = 'P'; Constant PKEY2__KY = 'p'; Constant QKEY1__KY = 'Q'; Constant QKEY2__KY = 'q'; [ DoMenu menu_choices EntryR ChoiceR lines main_title main_wid cl i j oldcl pkey ch y x; menu_nesting++; menu_item = 0; lines = indirect(EntryR); main_title = item_name; main_wid = item_width; cl = 7; ._redisplay_menu; oldcl = 0; @erase_window $ffff; ch = 1; i = ch * (lines+7); @split_window i; i = HDR_SCREENWCHARS->0; if (i == 0) i = 80; @set_window 1; @set_cursor 1 1; style reverse; FastSpaces(i); #Ifdef EXT_MENU_STDLIB_MODE; j=1+(i/2-main_wid); #Ifnot; j=1+(i-main_wid)/2; #Endif; @set_cursor 1 j; print (string) main_title; y=1+ch; @set_cursor y 1; FastSpaces(i); x=1+1; @set_cursor y x; print (string) NKEY__TX; j=1+i-13; @set_cursor y j; print (string) PKEY__TX; y=y+ch; @set_cursor y 1; FastSpaces(i); @set_cursor y x; print (string) RKEY__TX; j=1+i-18; @set_cursor y j; if (menu_nesting == 1) print (string) QKEY1__TX; else print (string) QKEY2__TX; style roman; y = y+2*ch; @set_cursor y x; font off; if (menu_choices ofclass String) print (string) menu_choices; else menu_choices.call(); x = 1+3; for (::) { if (cl ~= oldcl) { if (oldcl>0) { y=1+(oldcl-1)*ch; @set_cursor y x; print " "; } y=1+(cl-1)*ch; @set_cursor y x; print ">"; } oldcl = cl; @read_char 1 -> pkey; if (pkey == NKEY1__KY or NKEY2__KY or 130) { cl++; if (cl == 7+lines) cl = 7; continue; } if (pkey == PKEY1__KY or PKEY2__KY or 129) { cl--; if (cl == 6) cl = 6+lines; continue; } if (pkey == QKEY1__KY or QKEY2__KY or 27 or 131) break; if (pkey == 10 or 13 or 132) { @set_window 0; font on; new_line; new_line; new_line; menu_item = cl-6; EntryR.call(); @erase_window $ffff; @split_window ch; @set_window 1; @set_cursor 1 1; style reverse; FastSpaces(i); #Ifdef EXT_MENU_STDLIB_MODE; j=1+(i/2-item_width); #Ifnot; j=1+(i-item_width)/2; #Endif; @set_cursor 1 j; print (string) item_name; style roman; @set_window 0; new_line; i = ChoiceR.call(); if (i == 2) jump _redisplay_menu; if (i == 3) break; print "^[Please press SPACE.]"; @read_char 1 -> pkey; jump _redisplay_menu; } } menu_nesting--; if (menu_nesting > 0) rfalse; font on; @set_cursor 1 1; @erase_window -1; @set_window 0; #IfDef PUNYINFORM_MAJOR_VERSION; statusline_current_height = 0; #IfNot; gg_statuswin_cursize = 0; #EndIf; new_line; new_line; new_line; if (deadflag == 0) <<Look>>; ]; #EndIf;
d883d4d04f3cf091105e2ee2e849304f940904c3
85ccd32aa73eecf274a937f1fc3b6f4d484b77da
/test cases/unit/17 prebuilt shared/another_visitor.c
18e5f150eb985f37c0e77c45ac0a03b2d2e069fe
[ "Apache-2.0" ]
permissive
mesonbuild/meson
48321cf4235dfcc0194fed90ff43a57367592bf7
cf5adf0c646474f0259d123fad60ca5ed38ec891
refs/heads/master
2023-09-01T05:58:50.807952
2023-03-17T20:27:37
2023-08-31T11:52:41
19,784,232
5,122
1,848
Apache-2.0
2023-09-14T15:47:23
2014-05-14T15:08:16
Python
UTF-8
C
false
false
263
c
another_visitor.c
#include<alexandria.h> #include<stdio.h> int main(int argc, char **argv) { printf("Ahh, another visitor. Stay a while.\n"); printf("You enter the library.\n\n"); alexandria_visit(); printf("\nYou decided not to stay forever.\n"); return 0; }
41450c80186d8463e2fd62f97f031a3f1c156657
fae867d62224cdf27ceb85654525a311fb8c4226
/rp-api/api-hw/src/i2c.h
9afbb9d9141dfcb13afa935f87e160ab6614e2c3
[ "BSD-3-Clause" ]
permissive
RedPitaya/RedPitaya
a4a9b0bda0d1806e39b90ee9f3164e2e0dee0ab6
69826707f78c764e5835f3197e61f68ced90f77b
refs/heads/master
2023-09-01T12:25:51.370133
2023-07-26T03:51:31
2023-07-26T03:51:31
17,261,658
447
601
NOASSERTION
2023-07-27T04:07:43
2014-02-27T19:38:52
C
UTF-8
C
false
false
1,049
h
i2c.h
/** * $Id: $ * * @brief Red Pitaya I2C Module. * * @Author Red Pitaya * * (c) Red Pitaya http://www.redpitaya.com * * This part of code is written in C programming language. * Please visit http://en.wikipedia.org/wiki/C_(programming_language) * for more details on the language used herein. */ #ifndef __I2C_H #define __I2C_H #include "rp_hw.h" int i2c_InitDevice(const char *_device,uint8_t addr); int i2c_setForceMode(bool force); bool i2c_getForceMode(); int i2c_getDevAddress(); int i2c_SMBUS_Read(uint8_t reg,uint8_t *value); int i2c_SMBUS_ReadWord(uint8_t reg,uint16_t *value); int i2c_SMBUS_ReadCommand(uint8_t *value); int i2c_SMBUS_ReadBuffer(uint8_t reg, uint8_t *buffer, int *len); int i2c_SMBUS_Write(uint8_t reg,uint8_t value); int i2c_SMBUS_WriteWord(uint8_t reg,uint16_t value); int i2c_SMBUS_WriteCommand(uint8_t value); int i2c_SMBUS_WriteBuffer(uint8_t reg, uint8_t *buffer, int len); int i2c_IOCTL_ReadBuffer(uint8_t *buffer, int len); int i2c_IOCTL_WriteBuffer(uint8_t *buffer, int len); #endif
9063b4fe7fdc56a5d82dd3fc6a48c0ded3b9f089
de3521f03ac554b25e91015eb2f0d7e434a92519
/Programs/Preprocessors/m-tx/source/files.c
bd080211a97acecdd1e11f574f30bd1835daad35
[ "MIT" ]
permissive
MiKTeX/miktex
5336dca6bbc09b121b5bd42e484e5b5ef1488017
60a5fd73f8a5e0654f1bbf9c68d9c1b8e777c6cd
refs/heads/next
2023-09-04T02:20:14.229772
2023-08-07T15:16:13
2023-08-07T15:16:13
61,892,189
727
107
NOASSERTION
2023-08-07T05:30:11
2016-06-24T15:00:19
C
UTF-8
C
false
false
8,433
c
files.c
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "files.pas" */ #include "p2c.h" #define FILES_G #include "files.h" #ifndef CONTROL_H #include "control.h" #endif #ifndef STRINGS_H #include "strings.h" #endif #ifndef UTILITY_H #include "utility.h" #endif #define param_leader '-' Static Char stylefilename[256] = "mtxstyle.txt"; Static short teststyle; boolean endOfInfile(void) { return (eofAll()); } Static void putTeXlines(Char *s_) { Char s[256]; short p; Char STR1[256], STR3[256]; strcpy(s, s_); p = pos1('\n', s); while (p > 0) { sprintf(STR3, "\\%s\\", substr_(STR1, s, 1, p - 1)); putLine(STR3); predelete(s, p); p = pos1('\n', s); } if (*s != '\0') { sprintf(STR3, "\\%s\\", s); putLine(STR3); } } void TeXtype2(Char *s) { Char STR2[256]; if (!pmx_preamble_done) { putLine(s); return; } if (s[0] == '%') { putLine(s); return; } if (first_paragraph) putTeXlines(s); else { sprintf(STR2, "\\\\%s\\", s); putLine(STR2); } } void putLine(Char *line) { if (outlen + strlen(line) >= PMXlinelength) putc('\n', outfile); fprintf(outfile, "%s\n", line); outlen = 0; } void put(Char *line_, boolean putspace_) { Char line[256]; short l; Char STR1[256]; strcpy(line, line_); l = strlen(line); if (l > PMXlinelength) error("Item longer than PMX line length", print); if (outlen + l >= PMXlinelength) { putLine(""); put(line, false); return; } if (putspace_ && outlen > 0 && line[0] != ' ') sprintf(line, " %s", strcpy(STR1, line)); fputs(line, outfile); outlen += l; } boolean styleFileFound(void) { return (teststyle != 0); } Static void helpmessage(void) { printf("Usage: prepmx [-bcfnhimtuvwDH0123456789] MTXFILE [TEXDIR] [STYLEFILE]\n"); } Static void bighelpmessage(void) { helpmessage(); printf("\nMTXFILE: name of .mtx file without its extension\n"); printf("TEXDIR: directory where the TeX file made by PMX goes, default is ./\n"); printf("STYLEFILE: name of a file containing style definitions. Default is\n"); printf(" mtxstyle.txt. This feature is now deprecated; use Include: STYLEFILE\n"); printf(" in the preamble of the .mtx file instead.\n"); printf("Options: (can also be entered separately: -b -c ...)\n"); printf(" -b: disable unbeamVocal\n"); printf(" -c: disable doChords\n"); printf(" -f: enable solfaNoteNames\n"); printf(" -h: display this message and quit\n"); printf(" -i: enable ignoreErrors\n"); printf(" -m: disable doLyrics\n"); printf(" -n: enable instrumentNames\n"); printf(" -t: disable doUptext\n"); printf(" -u: disable uptextOnRests\n"); printf(" -v: enable beVerbose\n"); printf(" -w: enable pedanticWarnings\n"); printf(" -D: enable debugMode\n"); printf(" -0123456789: select Case\n"); printf(" -H: print enabled status of all options\n"); printf("All the above, and some other, options can be enabled or disabled\n"); printf(" in the preamble. What you do there overrides what you do here.\n"); } void processOption(Char j) { switch (j) { case 'b': setFeature("unbeamVocal", false); break; case 'c': setFeature("doChords", false); break; case 'f': setFeature("solfaNoteNames", true); break; case 'h': bighelpmessage(); _Escape(255); break; case 'i': setFeature("ignoreErrors", true); break; case 'm': setFeature("doLyrics", false); break; case 'n': setFeature("instrumentNames", true); break; case 't': setFeature("doUptext", false); break; case 'u': setFeature("uptextOnRests", false); break; case 'v': setFeature("beVerbose", true); break; case 'w': setFeature("pedanticWarnings", true); break; case 'D': setFeature("debugMode", true); break; case 'H': printFeatures(true); break; default: if (isdigit(j)) choice = j; else { putchar(j); error(": invalid option", !print); } break; } } /* Local variables for OpenFiles: */ struct LOC_OpenFiles { short testin; Char basename[256]; } ; Local void checkExistingFile(struct LOC_OpenFiles *LINK) { FILE *tryfile; Char tryfile_NAME[_FNSIZE]; strcpy(tryfile_NAME, LINK->basename); tryfile = fopen(tryfile_NAME, "r+b"); _SETIO(tryfile != NULL, FileNotFound); LINK->testin = P_ioresult; if (LINK->testin != 0) return; if (tryfile != NULL) fclose(tryfile); printf("There exists a file named %s. I am treating this\n", LINK->basename); error(" as a fatal error unless you specify -i", !print); } void OpenFiles(void) { struct LOC_OpenFiles V; short i, j, l; short fileid = 0; Char infilename[256], outfilename[256], param[256], ext[256]; short FORLIM1; Char STR3[256]; line_no = 0; paragraph_no = 0; for (i = 1; i <= P_argc - 1; i++) { strcpy(param, P_argv[i]); if (param[0] == param_leader) { FORLIM1 = strlen(param); for (j = 1; j <= FORLIM1 - 1; j++) processOption(param[j]); } else if (fileid == 0) fileid = i; else if (*texdir == '\0') strcpy(texdir, param); else strcpy(stylefilename, param); } if (fileid == 0) { helpmessage(); printf("Try \"prepmx -h\" for more information.\n"); _Escape(255); } strcpy(V.basename, P_argv[fileid]); l = strlen(V.basename); if (l > 4 && V.basename[l-4] == '.') { substr_(ext, V.basename, l - 2, 3); toUpper(ext); if (!strcmp(ext, "MTX")) { warning(".mtx extension deleted from basename", !print); shorten(V.basename, l - 4); } } if (pos1('.', V.basename) > 0) checkExistingFile(&V); sprintf(infilename, "%s.mtx", V.basename); sprintf(outfilename, "%s.pmx", V.basename); pushFile(infilename); strcpy(outfile_NAME, outfilename); if (outfile != NULL) outfile = freopen(outfile_NAME, "w", outfile); else outfile = fopen(outfile_NAME, "w"); _SETIO(outfile != NULL, FileNotFound); strcpy(stylefile_NAME, stylefilename); if (stylefile != NULL) stylefile = freopen(stylefile_NAME, "r", stylefile); else stylefile = fopen(stylefile_NAME, "r"); _SETIO(stylefile != NULL, FileNotFound); teststyle = P_ioresult; if (teststyle != 0 && strcmp(stylefilename, "mtxstyle.txt")) _SETIO(printf("Can't read %s\n", stylefilename) >= 0, FileWriteError); if (fileError()) { sprintf(STR3, "Input file %s not found", infilename); fatalerror(STR3); } outfile_open = true; printf("Writing to %s.pmx\n", V.basename); } void CloseFiles(void) { if (outfile != NULL) fclose(outfile); outfile = NULL; closeAll(); if (teststyle != 0) return; if (stylefile != NULL) fclose(stylefile); stylefile = NULL; } void readParagraph(Char (*P)[256], short *no, paragraph_index0 *L) { boolean another; Char filename[256], buffer[256]; Char STR1[256], STR3[256]; *L = 0; readData(buffer); line_no = currentLineNo(); if (isEmpty(buffer)) return; if (debugMode()) printf(">>>> %s\n", buffer); paragraph_no++; /* Handle directives affecting the processing of the input file */ do { another = false; if (startsWithIgnoreCase(buffer, "SUSPEND")) { ignore_input = true; another = true; if (beVerbose()) printf("-->> Suspending input file %s at line %d\n", currentFilename(STR3), line_no); } if (startsWithIgnoreCase(buffer, "RESUME")) { ignore_input = false; another = true; if (beVerbose()) printf("-->> Resuming input file %s at line %d\n", currentFilename(STR1), line_no); } if (startsWithIgnoreCase(buffer, "INCLUDE:")) { predelete(buffer, 8); NextWord(filename, buffer, ' ', ' '); pushFile(filename); another = true; } if (another) { readLine(buffer); line_no = currentLineNo(); } } while (another); /* Normal paragraph input*/ do { if (*L < lines_in_paragraph) { (*L)++; strcpy(P[*L - 1], buffer); *buffer = '\0'; no[*L - 1] = line_no; } else warning("Paragraph too long: skipping line", !print); readLine(buffer); line_no = currentLineNo(); if (debugMode()) printf("%d >> %s\n", line_no, buffer); } while (!isEmpty(buffer)); skipBlanks(); /* needed to identify final paragraph */ } /* End. */
55b782fb488775127152e547e602e2ee0988154e
1231e1bf4117cfaaa54bd4752cca1bdb71290cec
/ext/stub/builtin/intmethods.zep.c
b573864dcddb751a5bf5d3734aa23aa72e69bb4b
[ "MIT" ]
permissive
zephir-lang/zephir
ac53ec68e35d19860a4d80224d94f38a6a5e04b5
6773f19d9b272cafee96b9a30f9b152c28e982ea
refs/heads/development
2023-08-31T10:33:38.621586
2023-02-28T10:27:43
2023-02-28T10:27:43
11,478,636
291
47
MIT
2023-08-28T22:07:11
2013-07-17T14:49:27
PHP
UTF-8
C
false
true
9,007
c
intmethods.zep.c
#ifdef HAVE_CONFIG_H #include "../../ext_config.h" #endif #include <php.h> #include "../../php_ext.h" #include "../../ext.h" #include <Zend/zend_operators.h> #include <Zend/zend_exceptions.h> #include <Zend/zend_interfaces.h> #include "kernel/main.h" #include "kernel/memory.h" #include "kernel/fcall.h" #include "kernel/operators.h" #include "kernel/object.h" #include "math.h" ZEPHIR_INIT_CLASS(Stub_BuiltIn_IntMethods) { ZEPHIR_REGISTER_CLASS(Stub\\BuiltIn, IntMethods, stub, builtin_intmethods, stub_builtin_intmethods_method_entry, 0); return SUCCESS; } PHP_METHOD(Stub_BuiltIn_IntMethods, getAbs) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, _0, _1; zend_long num, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 9, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getAbs1) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZVAL_LONG(&_0, -5); ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 9, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getBinary) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, _0, _1; zend_long num, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); ZEPHIR_CALL_FUNCTION(&_1, "decbin", NULL, 10, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getHex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, _0, _1; zend_long num, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); ZEPHIR_CALL_FUNCTION(&_1, "dechex", NULL, 11, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getOctal) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, _0, _1; zend_long num, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); ZEPHIR_CALL_FUNCTION(&_1, "decoct", NULL, 12, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getPow) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, *exp_param = NULL, _0, _1, _2; zend_long num, exp; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(num) Z_PARAM_LONG(exp) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &num_param, &exp_param); num = zephir_get_intval(num_param); exp = zephir_get_intval(exp_param); ZEPHIR_INIT_VAR(&_0); ZVAL_LONG(&_1, num); ZVAL_LONG(&_2, exp); zephir_pow_function(&_0, &_1, &_2); RETURN_CCTOR(&_0); } PHP_METHOD(Stub_BuiltIn_IntMethods, getSqrt) { zval *num_param = NULL, _0; zend_long num; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); RETURN_DOUBLE(sqrt(num)); } PHP_METHOD(Stub_BuiltIn_IntMethods, getExp) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, _0, _1; zend_long num, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); ZEPHIR_CALL_FUNCTION(&_1, "exp", NULL, 2, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getSin) { zval *num_param = NULL, _0; zend_long num; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); RETURN_DOUBLE(sin(num)); } PHP_METHOD(Stub_BuiltIn_IntMethods, getCos) { zval *num_param = NULL, _0; zend_long num; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); RETURN_DOUBLE(cos(num)); } PHP_METHOD(Stub_BuiltIn_IntMethods, getTan) { zval *num_param = NULL, _0; zend_long num; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); RETURN_DOUBLE(tan(num)); } PHP_METHOD(Stub_BuiltIn_IntMethods, getAsin) { zval *num_param = NULL, _0; zend_long num; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); RETURN_DOUBLE(asin(num)); } PHP_METHOD(Stub_BuiltIn_IntMethods, getAcos) { zval *num_param = NULL, _0; zend_long num; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); RETURN_DOUBLE(acos(num)); } PHP_METHOD(Stub_BuiltIn_IntMethods, getAtan) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, _0, _1; zend_long num, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(num) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &num_param); num = zephir_get_intval(num_param); ZVAL_LONG(&_0, num); ZEPHIR_CALL_FUNCTION(&_1, "atan", NULL, 13, &_0); zephir_check_call_status(); RETURN_CCTOR(&_1); } PHP_METHOD(Stub_BuiltIn_IntMethods, getLog) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *num_param = NULL, *base_param = NULL, _0$$3, _1$$3, _2, _3, _4; zend_long num, base, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_LONG(num) Z_PARAM_OPTIONAL Z_PARAM_LONG(base) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &num_param, &base_param); num = zephir_get_intval(num_param); if (!base_param) { base = -1; } else { base = zephir_get_intval(base_param); } if (base == -1) { ZVAL_LONG(&_0$$3, num); ZEPHIR_CALL_FUNCTION(&_1$$3, "log", NULL, 14, &_0$$3); zephir_check_call_status(); RETURN_CCTOR(&_1$$3); } ZVAL_LONG(&_2, num); ZVAL_LONG(&_3, base); ZEPHIR_CALL_FUNCTION(&_4, "log", NULL, 14, &_2, &_3); zephir_check_call_status(); RETURN_CCTOR(&_4); }
c09ab2cffa451a5ef6111b6ed0bf1bd864517366
3486cc637780720add3e8229baef01121cc781fd
/WtInject/targetver.h
e2bad52e0eb60f30b1c92fe978d940293973d844
[ "MIT" ]
permissive
leafOfTree/WindowTabs
e573fbe61291098a10528dfdfdb8936196575fea
256a2f662665834ca4274660ec8de22597857842
refs/heads/master
2022-03-08T01:21:51.541434
2022-02-26T12:05:37
2022-02-26T12:05:37
195,219,873
360
48
MIT
2019-07-04T10:19:52
2019-07-04T10:19:51
null
UTF-8
C
false
false
102
h
targetver.h
#pragma once #include <WinSDKVer.h> #define _WIN32_WINNT _WIN32_WINNT_WIN7 #include <SDKDDKVer.h>
30a55766f57b34412ae911e0e40ce5e7281bdf20
a45c0c63999ba4a6489812d68fd0be4350726761
/chapter1/page35/finalexercise.c
d252f0f6029f0d0dab8668e5021b0042980af3a8
[]
no_license
dogriffiths/HeadFirstC
4320bd5436aac55018f6dc1be78b4f03b4cdb967
4d06df0675124c96183c6a7caca39262e789d69e
refs/heads/master
2023-08-31T04:06:56.898582
2023-08-07T13:14:17
2023-08-07T13:14:17
5,558,835
164
110
null
2023-08-07T13:14:18
2012-08-26T09:13:00
C
UTF-8
C
false
false
1,910
c
finalexercise.c
/** * THIS PROGRAM IS DIFFERENT TO THE ONE IN THE BOOK! * * We all make mistakes. After the book was published, one keen-eyed * spotted that there was a problem with the program published on * page 35/37 in the book. * * In the original version of the program the while loop * checked the value of the card_name[0] *before* anything * had been entered into the card_name array. What's the problem * with that? In C, local variables are not set to any specific * value when they're first created. That means that * that theoretically the card_name[0] might have *any* char * value. And that's bad. * * Instead, we've slightly re-written the code so that instead of * using a while{} loop, it now uses a do-while{} loop. * * A do-while{} loop checks the loop condition at the *end* of the * loop, and by the time we get to the end of the loop the * card_name array has been set to whatever the typed in at the keyboard. * * The coder responsible for this error has been warned that a * terrible vengeance that will be wrought against them. */ #include <stdio.h> #include <stdlib.h> int main() { char card_name[2]; int count = 0; do { puts("Enter the card_name: "); scanf("%s", card_name); int val = 0; switch(card_name[0]) { case 'K': case 'Q': case 'J': val = 10; break; case 'A': val = 11; break; case 'X': continue; default: val = atoi(card_name); if ((val < 1) || (val > 10)) { puts("I don't understand that value!"); continue; } } if ((val > 2) && (val < 7)) { count++; } else if (val == 10) { count--; } printf("Current count: %i\n", count); } while (card_name[0] != 'X'); return 0; }
93e6cbab5fb1a1a9845f941f45b06150dcfd22fb
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/cbmc/incomplete-structs/types3.c
d3e0617b18014c9a14817e726f9c0774c4615a90
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-4-Clause" ]
permissive
diffblue/cbmc
975a074ac445febb3b5715f8792beb545522dc18
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
refs/heads/develop
2023-08-31T05:52:05.342195
2023-08-30T13:31:51
2023-08-30T13:31:51
51,877,056
589
309
NOASSERTION
2023-09-14T18:49:17
2016-02-16T23:03:52
C++
UTF-8
C
false
false
143
c
types3.c
struct T { int i; }; struct S { struct T *t; struct U *u; }; int bar(struct S *); int foo(struct S *s) { return bar(s) + s->t->i; }
39950ca10051ad95a755b8db877615767165e793
bb38c44037a99d0a12a12d92059678f2faebbc80
/src/include/catalog/pg_amproc.h
138c7d54ea780cee2dfcee5652649e5df16b9de7
[ "LicenseRef-scancode-mulanpsl-2.0-en", "LicenseRef-scancode-unknown-license-reference", "PostgreSQL", "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-unicode", "LicenseRef-scancode-warranty-disclaimer", "curl", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LGPL-2.1-only", "CC-BY-4.0", "LicenseRef-scancode-protobuf", "OpenSSL", "LicenseRef-scancode-generic-export-compliance", "X11-distribute-modifications-variant", "LicenseRef-scancode-other-permissive", "MIT", "NCSA", "Python-2.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "CC-BY-3.0", "LicenseRef-scancode-other-copyleft", "GPL-2.0-only", "BSL-1.0", "Apache-2.0", "LGPL-2.0-only", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Zlib" ]
permissive
opengauss-mirror/openGauss-server
a9c5a62908643492347830826c56da49f0942796
310e84631c68c8bf37b004148b66f94064f701e4
refs/heads/master
2023-07-26T19:29:12.495484
2023-07-17T12:23:32
2023-07-17T12:23:32
276,117,477
591
208
MulanPSL-2.0
2023-04-28T12:30:18
2020-06-30T14:08:59
C++
UTF-8
C
false
false
25,465
h
pg_amproc.h
/* ------------------------------------------------------------------------- * * pg_amproc.h * definition of the system "amproc" relation (pg_amproc) * along with the relation's initial contents. * * The amproc table identifies support procedures associated with index * operator families and classes. These procedures can't be listed in pg_amop * since they are not the implementation of any indexable operator. * * The primary key for this table is <amprocfamily, amproclefttype, * amprocrighttype, amprocnum>. The "default" support functions for a * particular opclass within the family are those with amproclefttype = * amprocrighttype = opclass's opcintype. These are the ones loaded into the * relcache for an index and typically used for internal index operations. * Other support functions are typically used to handle cross-type indexable * operators with oprleft/oprright matching the entry's amproclefttype and * amprocrighttype. The exact behavior depends on the index AM, however, and * some don't pay attention to non-default functions at all. * * * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * src/include/catalog/pg_amproc.h * * NOTES * the genbki.pl script reads this file and generates .bki * information from the DATA() statements. * * ------------------------------------------------------------------------- */ #ifndef PG_AMPROC_H #define PG_AMPROC_H #include "catalog/genbki.h" /* ---------------- * pg_amproc definition. cpp turns this into * typedef struct FormData_pg_amproc * ---------------- */ #define AccessMethodProcedureRelationId 2603 #define AccessMethodProcedureRelation_Rowtype_Id 10920 CATALOG(pg_amproc,2603) BKI_SCHEMA_MACRO { Oid amprocfamily; /* the index opfamily this entry is for */ Oid amproclefttype; /* procedure's left input data type */ Oid amprocrighttype; /* procedure's right input data type */ int2 amprocnum; /* support procedure index */ regproc amproc; /* OID of the proc */ } FormData_pg_amproc; /* ---------------- * Form_pg_amproc corresponds to a pointer to a tuple with * the format of pg_amproc relation. * ---------------- */ typedef FormData_pg_amproc *Form_pg_amproc; /* ---------------- * compiler constants for pg_amproc * ---------------- */ #define Natts_pg_amproc 5 #define Anum_pg_amproc_amprocfamily 1 #define Anum_pg_amproc_amproclefttype 2 #define Anum_pg_amproc_amprocrighttype 3 #define Anum_pg_amproc_amprocnum 4 #define Anum_pg_amproc_amproc 5 /* ---------------- * initial contents of pg_amproc * ---------------- */ /* btree */ DATA(insert ( 397 2277 2277 1 382 )); DATA(insert ( 421 702 702 1 357 )); DATA(insert ( 423 1560 1560 1 1596 )); DATA(insert ( 423 1560 1560 3 4609 )); DATA(insert ( 424 16 16 1 1693 )); DATA(insert ( 424 16 16 3 4609 )); DATA(insert ( 426 1042 1042 1 1078 )); DATA(insert ( 426 1042 1042 2 3256 )); DATA(insert ( 426 1042 1042 3 4608 )); DATA(insert ( 428 17 17 1 1954 )); DATA(insert ( 428 17 17 2 3452 )); DATA(insert ( 428 17 17 3 4609 )); DATA(insert ( 429 18 18 1 358 )); DATA(insert ( 429 18 18 3 4609 )); DATA(insert ( 434 1082 1082 1 1092 )); DATA(insert ( 434 1082 1082 2 3136 )); DATA(insert ( 434 1082 1082 3 4609 )); DATA(insert ( 434 1082 1114 1 2344 )); DATA(insert ( 434 1082 1184 1 2357 )); DATA(insert ( 434 1114 1114 1 2045 )); DATA(insert ( 434 1114 1114 2 3137 )); DATA(insert ( 434 1114 1114 3 4609 )); DATA(insert ( 434 1114 1082 1 2370 )); DATA(insert ( 434 1114 1184 1 2526 )); DATA(insert ( 434 1184 1184 1 1314 )); DATA(insert ( 434 1184 1184 2 3137 )); DATA(insert ( 434 1184 1184 3 4609 )); DATA(insert ( 434 1184 1082 1 2383 )); DATA(insert ( 434 1184 1114 1 2533 )); DATA(insert ( 436 4402 4402 1 4418 )); DATA(insert ( 436 4402 4402 2 3452 )); DATA(insert ( 1970 700 700 1 354 )); DATA(insert ( 1970 700 700 2 3132 )); DATA(insert ( 1970 700 701 1 2194 )); DATA(insert ( 1970 701 701 1 355 )); DATA(insert ( 1970 701 701 2 3133 )); DATA(insert ( 1970 701 700 1 2195 )); DATA(insert ( 1974 869 869 1 926 )); DATA(insert ( 1974 869 869 3 4609 )); DATA(insert ( 1976 21 21 1 350 )); DATA(insert ( 1976 21 21 2 3129 )); DATA(insert ( 1976 21 21 3 4609 )); DATA(insert ( 1976 21 23 1 2190 )); DATA(insert ( 1976 21 20 1 2192 )); DATA(insert ( 1976 23 23 1 351 )); DATA(insert ( 1976 23 23 2 3130 )); DATA(insert ( 1976 23 23 3 4609 )); DATA(insert ( 1976 23 20 1 2188 )); DATA(insert ( 1976 23 21 1 2191 )); DATA(insert ( 1976 20 20 1 842 )); DATA(insert ( 1976 20 20 2 3131 )); DATA(insert ( 1976 20 20 3 4609 )); DATA(insert ( 1976 20 23 1 2189 )); DATA(insert ( 1976 20 21 1 2193 )); DATA(insert ( 1976 3272 3272 1 6544)); DATA(insert ( 1976 3272 3272 2 6538)); DATA(insert ( 1976 3272 23 1 6545)); DATA(insert ( 1976 23 3272 1 6543)); DATA(insert ( 1976 3272 20 1 6546)); DATA(insert ( 1976 20 3272 1 6547)); DATA(insert ( 1976 3272 21 1 6549)); DATA(insert ( 1976 21 3272 1 6548)); DATA(insert ( 1982 1186 1186 1 1315 )); DATA(insert ( 1982 1186 1186 3 4609 )); DATA(insert ( 1984 829 829 1 836 )); DATA(insert ( 1984 829 829 3 4609 )); DATA(insert ( 1986 19 19 1 359 )); DATA(insert ( 1986 19 19 2 3135 )); DATA(insert ( 1986 19 19 3 4608 )); DATA(insert ( 1988 1700 1700 1 1769 )); DATA(insert ( 1988 1700 1700 2 3283 )); DATA(insert ( 1989 26 26 1 356 )); DATA(insert ( 1989 26 26 2 3134 )); DATA(insert ( 1989 26 26 3 4609 )); DATA(insert ( 1991 30 30 1 404 )); DATA(insert ( 1991 30 30 3 4609 )); DATA(insert ( 2994 2249 2249 1 2987 )); DATA(insert ( 1994 25 25 1 360 )); DATA(insert ( 1994 25 25 2 3255 )); DATA(insert ( 1994 25 25 3 4608 )); DATA(insert ( 1996 1083 1083 1 1107 )); DATA(insert ( 1996 1083 1083 3 4609 )); DATA(insert ( 2000 1266 1266 1 1358 )); DATA(insert ( 2000 1266 1266 3 4609 )); DATA(insert ( 2002 1562 1562 1 1672 )); DATA(insert ( 2002 1562 1562 3 4609 )); DATA(insert ( 2095 25 25 1 2166 )); DATA(insert ( 2095 25 25 3 4609 )); DATA(insert ( 2097 1042 1042 1 2180 )); DATA(insert ( 2097 1042 1042 3 4609 )); DATA(insert ( 2099 790 790 1 377 )); DATA(insert ( 2099 790 790 3 4609 )); DATA(insert ( 2233 703 703 1 380 )); DATA(insert ( 2234 704 704 1 381 )); DATA(insert ( 2789 27 27 1 2794 )); DATA(insert ( 2789 27 27 3 4609 )); DATA(insert ( 2968 2950 2950 1 2960 )); DATA(insert ( 2968 2950 2950 3 4609 )); DATA(insert ( 3522 3500 3500 1 3514 )); DATA(insert ( 3806 86 86 1 3475 )); DATA(insert ( 3807 86 86 1 456 )); DATA(insert ( 4033 3802 3802 1 3417 )); DATA(insert ( 5535 5545 5545 1 5519 )); DATA(insert ( 5536 5545 5545 1 5520 )); /* hash */ DATA(insert ( 427 1042 1042 1 1080 )); DATA(insert ( 431 18 18 1 454 )); DATA(insert ( 435 1082 1082 1 450 )); DATA(insert ( 627 2277 2277 1 626 )); DATA(insert ( 1971 700 700 1 451 )); DATA(insert ( 1971 701 701 1 452 )); DATA(insert ( 1975 869 869 1 422 )); DATA(insert ( 1977 21 21 1 449 )); DATA(insert ( 1977 23 23 1 450 )); DATA(insert ( 1977 20 20 1 949 )); DATA(insert ( 1977 3272 3272 1 3294 )); DATA(insert ( 1983 1186 1186 1 1697 )); DATA(insert ( 1985 829 829 1 399 )); DATA(insert ( 1987 19 19 1 455 )); DATA(insert ( 1990 26 26 1 453 )); DATA(insert ( 1992 30 30 1 457 )); DATA(insert ( 1995 25 25 1 400 )); DATA(insert ( 1995 3272 3272 1 3297 )); DATA(insert ( 1997 1083 1083 1 1688 )); DATA(insert ( 1998 1700 1700 1 432 )); DATA(insert ( 1999 1184 1184 1 2039 )); DATA(insert ( 2001 1266 1266 1 1696 )); DATA(insert ( 2040 1114 1114 1 2039 )); DATA(insert ( 2222 16 16 1 454 )); DATA(insert ( 2223 17 17 1 456 )); DATA(insert ( 4470 4402 4402 1 456 )); DATA(insert ( 2224 22 22 1 398 )); DATA(insert ( 2225 28 28 1 949 )); DATA(insert ( 2226 29 29 1 450 )); DATA(insert ( 2227 702 702 1 450 )); DATA(insert ( 2228 703 703 1 450 )); DATA(insert ( 2229 25 25 1 400 )); DATA(insert ( 2231 1042 1042 1 1080 )); DATA(insert ( 2232 31 31 1 450 )); DATA(insert ( 2235 1033 1033 1 329 )); DATA(insert ( 2969 2950 2950 1 2963 )); DATA(insert ( 3523 3500 3500 1 3515 )); DATA(insert ( 4034 3802 3802 1 3430 )); DATA(insert ( 8646 3272 3272 1 3297 )); /* gist */ DATA(insert ( 2593 603 603 1 2578 )); DATA(insert ( 2593 603 603 2 2583 )); DATA(insert ( 2593 603 603 3 2579 )); DATA(insert ( 2593 603 603 4 2580 )); DATA(insert ( 2593 603 603 5 2581 )); DATA(insert ( 2593 603 603 6 2582 )); DATA(insert ( 2593 603 603 7 2584 )); DATA(insert ( 2594 604 604 1 2585 )); DATA(insert ( 2594 604 604 2 2583 )); DATA(insert ( 2594 604 604 3 2586 )); DATA(insert ( 2594 604 604 4 2580 )); DATA(insert ( 2594 604 604 5 2581 )); DATA(insert ( 2594 604 604 6 2582 )); DATA(insert ( 2594 604 604 7 2584 )); DATA(insert ( 2595 718 718 1 2591 )); DATA(insert ( 2595 718 718 2 2583 )); DATA(insert ( 2595 718 718 3 2592 )); DATA(insert ( 2595 718 718 4 2580 )); DATA(insert ( 2595 718 718 5 2581 )); DATA(insert ( 2595 718 718 6 2582 )); DATA(insert ( 2595 718 718 7 2584 )); DATA(insert ( 3655 3614 3614 1 3654 )); DATA(insert ( 3655 3614 3614 2 3651 )); DATA(insert ( 3655 3614 3614 3 3648 )); DATA(insert ( 3655 3614 3614 4 3649 )); DATA(insert ( 3655 3614 3614 5 3653 )); DATA(insert ( 3655 3614 3614 6 3650 )); DATA(insert ( 3655 3614 3614 7 3652 )); DATA(insert ( 3702 3615 3615 1 3701 )); DATA(insert ( 3702 3615 3615 2 3698 )); DATA(insert ( 3702 3615 3615 3 3695 )); DATA(insert ( 3702 3615 3615 4 3696 )); DATA(insert ( 3702 3615 3615 5 3700 )); DATA(insert ( 3702 3615 3615 6 3697 )); DATA(insert ( 3702 3615 3615 7 3699 )); DATA(insert ( 1029 600 600 1 2179 )); DATA(insert ( 1029 600 600 2 2583 )); DATA(insert ( 1029 600 600 3 1030 )); DATA(insert ( 1029 600 600 4 2580 )); DATA(insert ( 1029 600 600 5 2581 )); DATA(insert ( 1029 600 600 6 2582 )); DATA(insert ( 1029 600 600 7 2584 )); DATA(insert ( 1029 600 600 8 3064 )); /* gin */ DATA(insert ( 2745 1007 1007 1 351 )); DATA(insert ( 2745 1007 1007 2 2743 )); DATA(insert ( 2745 1007 1007 3 2774 )); DATA(insert ( 2745 1007 1007 4 2744 )); DATA(insert ( 2745 1007 1007 6 3920 )); DATA(insert ( 2745 1009 1009 1 360 )); DATA(insert ( 2745 1009 1009 2 2743 )); DATA(insert ( 2745 1009 1009 3 2774 )); DATA(insert ( 2745 1009 1009 4 2744 )); DATA(insert ( 2745 1009 1009 6 3920 )); DATA(insert ( 2745 1015 1015 1 360 )); DATA(insert ( 2745 1015 1015 2 2743 )); DATA(insert ( 2745 1015 1015 3 2774 )); DATA(insert ( 2745 1015 1015 4 2744 )); DATA(insert ( 2745 1015 1015 6 3920 )); DATA(insert ( 2745 1023 1023 1 357 )); DATA(insert ( 2745 1023 1023 2 2743 )); DATA(insert ( 2745 1023 1023 3 2774 )); DATA(insert ( 2745 1023 1023 4 2744 )); DATA(insert ( 2745 1023 1023 6 3920 )); DATA(insert ( 2745 1561 1561 1 1596 )); DATA(insert ( 2745 1561 1561 2 2743 )); DATA(insert ( 2745 1561 1561 3 2774 )); DATA(insert ( 2745 1561 1561 4 2744 )); DATA(insert ( 2745 1561 1561 6 3920 )); DATA(insert ( 2745 1000 1000 1 1693 )); DATA(insert ( 2745 1000 1000 2 2743 )); DATA(insert ( 2745 1000 1000 3 2774 )); DATA(insert ( 2745 1000 1000 4 2744 )); DATA(insert ( 2745 1000 1000 6 3920 )); DATA(insert ( 2745 1014 1014 1 1078 )); DATA(insert ( 2745 1014 1014 2 2743 )); DATA(insert ( 2745 1014 1014 3 2774 )); DATA(insert ( 2745 1014 1014 4 2744 )); DATA(insert ( 2745 1014 1014 6 3920 )); DATA(insert ( 2745 1001 1001 1 1954 )); DATA(insert ( 2745 1001 1001 2 2743 )); DATA(insert ( 2745 1001 1001 3 2774 )); DATA(insert ( 2745 1001 1001 4 2744 )); DATA(insert ( 2745 1001 1001 6 3920 )); DATA(insert ( 2745 1002 1002 1 358 )); DATA(insert ( 2745 1002 1002 2 2743 )); DATA(insert ( 2745 1002 1002 3 2774 )); DATA(insert ( 2745 1002 1002 4 2744 )); DATA(insert ( 2745 1002 1002 6 3920 )); DATA(insert ( 2745 1182 1182 1 1092 )); DATA(insert ( 2745 1182 1182 2 2743 )); DATA(insert ( 2745 1182 1182 3 2774 )); DATA(insert ( 2745 1182 1182 4 2744 )); DATA(insert ( 2745 1182 1182 6 3920 )); DATA(insert ( 2745 1021 1021 1 354 )); DATA(insert ( 2745 1021 1021 2 2743 )); DATA(insert ( 2745 1021 1021 3 2774 )); DATA(insert ( 2745 1021 1021 4 2744 )); DATA(insert ( 2745 1021 1021 6 3920 )); DATA(insert ( 2745 1022 1022 1 355 )); DATA(insert ( 2745 1022 1022 2 2743 )); DATA(insert ( 2745 1022 1022 3 2774 )); DATA(insert ( 2745 1022 1022 4 2744 )); DATA(insert ( 2745 1022 1022 6 3920 )); DATA(insert ( 2745 1041 1041 1 926 )); DATA(insert ( 2745 1041 1041 2 2743 )); DATA(insert ( 2745 1041 1041 3 2774 )); DATA(insert ( 2745 1041 1041 4 2744 )); DATA(insert ( 2745 1041 1041 6 3920 )); DATA(insert ( 2745 651 651 1 926 )); DATA(insert ( 2745 651 651 2 2743 )); DATA(insert ( 2745 651 651 3 2774 )); DATA(insert ( 2745 651 651 4 2744 )); DATA(insert ( 2745 651 651 6 3920 )); DATA(insert ( 2745 1005 1005 1 350 )); DATA(insert ( 2745 1005 1005 2 2743 )); DATA(insert ( 2745 1005 1005 3 2774 )); DATA(insert ( 2745 1005 1005 4 2744 )); DATA(insert ( 2745 1005 1005 6 3920 )); DATA(insert ( 2745 1016 1016 1 842 )); DATA(insert ( 2745 1016 1016 2 2743 )); DATA(insert ( 2745 1016 1016 3 2774 )); DATA(insert ( 2745 1016 1016 4 2744 )); DATA(insert ( 2745 1016 1016 6 3920 )); DATA(insert ( 2745 1187 1187 1 1315 )); DATA(insert ( 2745 1187 1187 2 2743 )); DATA(insert ( 2745 1187 1187 3 2774 )); DATA(insert ( 2745 1187 1187 4 2744 )); DATA(insert ( 2745 1187 1187 6 3920 )); DATA(insert ( 2745 1040 1040 1 836 )); DATA(insert ( 2745 1040 1040 2 2743 )); DATA(insert ( 2745 1040 1040 3 2774 )); DATA(insert ( 2745 1040 1040 4 2744 )); DATA(insert ( 2745 1040 1040 6 3920 )); DATA(insert ( 2745 1003 1003 1 359 )); DATA(insert ( 2745 1003 1003 2 2743 )); DATA(insert ( 2745 1003 1003 3 2774 )); DATA(insert ( 2745 1003 1003 4 2744 )); DATA(insert ( 2745 1003 1003 6 3920 )); DATA(insert ( 2745 1231 1231 1 1769 )); DATA(insert ( 2745 1231 1231 2 2743 )); DATA(insert ( 2745 1231 1231 3 2774 )); DATA(insert ( 2745 1231 1231 4 2744 )); DATA(insert ( 2745 1231 1231 6 3920 )); DATA(insert ( 2745 1028 1028 1 356 )); DATA(insert ( 2745 1028 1028 2 2743 )); DATA(insert ( 2745 1028 1028 3 2774 )); DATA(insert ( 2745 1028 1028 4 2744 )); DATA(insert ( 2745 1028 1028 6 3920 )); DATA(insert ( 2745 1013 1013 1 404 )); DATA(insert ( 2745 1013 1013 2 2743 )); DATA(insert ( 2745 1013 1013 3 2774 )); DATA(insert ( 2745 1013 1013 4 2744 )); DATA(insert ( 2745 1013 1013 6 3920 )); DATA(insert ( 2745 1183 1183 1 1107 )); DATA(insert ( 2745 1183 1183 2 2743 )); DATA(insert ( 2745 1183 1183 3 2774 )); DATA(insert ( 2745 1183 1183 4 2744 )); DATA(insert ( 2745 1183 1183 6 3920 )); DATA(insert ( 2745 1185 1185 1 1314 )); DATA(insert ( 2745 1185 1185 2 2743 )); DATA(insert ( 2745 1185 1185 3 2774 )); DATA(insert ( 2745 1185 1185 4 2744 )); DATA(insert ( 2745 1185 1185 6 3920 )); DATA(insert ( 2745 1270 1270 1 1358 )); DATA(insert ( 2745 1270 1270 2 2743 )); DATA(insert ( 2745 1270 1270 3 2774 )); DATA(insert ( 2745 1270 1270 4 2744 )); DATA(insert ( 2745 1270 1270 6 3920 )); DATA(insert ( 2745 1563 1563 1 1672 )); DATA(insert ( 2745 1563 1563 2 2743 )); DATA(insert ( 2745 1563 1563 3 2774 )); DATA(insert ( 2745 1563 1563 4 2744 )); DATA(insert ( 2745 1563 1563 6 3920 )); DATA(insert ( 2745 1115 1115 1 2045 )); DATA(insert ( 2745 1115 1115 2 2743 )); DATA(insert ( 2745 1115 1115 3 2774 )); DATA(insert ( 2745 1115 1115 4 2744 )); DATA(insert ( 2745 1115 1115 6 3920 )); DATA(insert ( 2745 791 791 1 377 )); DATA(insert ( 2745 791 791 2 2743 )); DATA(insert ( 2745 791 791 3 2774 )); DATA(insert ( 2745 791 791 4 2744 )); DATA(insert ( 2745 791 791 6 3920 )); DATA(insert ( 2745 1024 1024 1 380 )); DATA(insert ( 2745 1024 1024 2 2743 )); DATA(insert ( 2745 1024 1024 3 2774 )); DATA(insert ( 2745 1024 1024 4 2744 )); DATA(insert ( 2745 1024 1024 6 3920 )); DATA(insert ( 2745 1025 1025 1 381 )); DATA(insert ( 2745 1025 1025 2 2743 )); DATA(insert ( 2745 1025 1025 3 2774 )); DATA(insert ( 2745 1025 1025 4 2744 )); DATA(insert ( 2745 1025 1025 6 3920 )); DATA(insert ( 3659 3614 3614 1 3724 )); DATA(insert ( 3659 3614 3614 2 3656 )); DATA(insert ( 3659 3614 3614 3 3657 )); DATA(insert ( 3659 3614 3614 4 3658 )); DATA(insert ( 3659 3614 3614 5 2700 )); DATA(insert ( 3659 3614 3614 6 3921 )); DATA(insert ( 3626 3614 3614 1 3622 )); DATA(insert ( 3683 3615 3615 1 3668 )); DATA(insert ( 3901 3831 3831 1 3870 )); DATA(insert ( 3903 3831 3831 1 3902 )); DATA(insert ( 3919 3831 3831 1 3875 )); DATA(insert ( 3919 3831 3831 2 3876 )); DATA(insert ( 3919 3831 3831 3 3877 )); DATA(insert ( 3919 3831 3831 4 3878 )); DATA(insert ( 3919 3831 3831 5 3879 )); DATA(insert ( 3919 3831 3831 6 3880 )); DATA(insert ( 3919 3831 3831 7 3881 )); DATA(insert ( 4036 3802 3802 1 3498 )); DATA(insert ( 4036 3802 3802 2 3482 )); DATA(insert ( 4036 3802 3802 3 3493 )); DATA(insert ( 4036 3802 3802 4 3497 )); DATA(insert ( 4036 3802 3802 6 3494 )); DATA(insert ( 4037 3802 3802 1 351 )); DATA(insert ( 4037 3802 3802 2 3492 )); DATA(insert ( 4037 3802 3802 3 3486 )); DATA(insert ( 4037 3802 3802 4 3487 )); DATA(insert ( 4037 3802 3802 6 3495 )); /* cgin */ DATA(insert ( 4446 3614 3614 1 3724 )); DATA(insert ( 4446 3614 3614 2 3656 )); DATA(insert ( 4446 3614 3614 3 3657 )); DATA(insert ( 4446 3614 3614 4 3658 )); DATA(insert ( 4446 3614 3614 5 2700 )); DATA(insert ( 4446 3614 3614 6 3921 )); /* sp-gist */ DATA(insert ( 4015 600 600 1 4018 )); DATA(insert ( 4015 600 600 2 4019 )); DATA(insert ( 4015 600 600 3 4020 )); DATA(insert ( 4015 600 600 4 4021 )); DATA(insert ( 4015 600 600 5 4022 )); DATA(insert ( 4016 600 600 1 4023 )); DATA(insert ( 4016 600 600 2 4024 )); DATA(insert ( 4016 600 600 3 4025 )); DATA(insert ( 4016 600 600 4 4026 )); DATA(insert ( 4016 600 600 5 4022 )); DATA(insert ( 4017 25 25 1 4027 )); DATA(insert ( 4017 25 25 2 4028 )); DATA(insert ( 4017 25 25 3 4029 )); DATA(insert ( 4017 25 25 4 4030 )); DATA(insert ( 4017 25 25 5 4031 )); DATA(insert ( 5570 9003 9003 1 5586 )); DATA(insert ( 5571 9003 9003 1 5587 )); /* psort, fake data just make index work */ DATA(insert ( 4050 21 21 1 350)); DATA(insert ( 4050 21 23 1 2190)); DATA(insert ( 4050 21 20 1 2192)); DATA(insert ( 4050 23 23 1 351)); DATA(insert ( 4050 23 20 1 2188)); DATA(insert ( 4050 23 21 1 2191)); DATA(insert ( 4050 20 20 1 842)); DATA(insert ( 4050 20 23 1 2189)); DATA(insert ( 4050 20 21 1 2193)); DATA(insert ( 4051 26 26 1 356)); DATA(insert ( 4052 1082 1082 1 1092)); DATA(insert ( 4052 1082 1114 1 2344)); DATA(insert ( 4052 1082 1184 1 2357)); DATA(insert ( 4052 1114 1114 1 2045)); DATA(insert ( 4052 1114 1082 1 2370)); DATA(insert ( 4052 1114 1184 1 2526)); DATA(insert ( 4052 1184 1184 1 1314)); DATA(insert ( 4052 1184 1082 1 2383)); DATA(insert ( 4052 1184 1114 1 2533)); DATA(insert ( 4053 700 700 1 354)); DATA(insert ( 4053 700 701 1 2194)); DATA(insert ( 4053 701 701 1 355)); DATA(insert ( 4053 701 700 1 2195)); DATA(insert ( 4054 1700 1700 1 1769)); DATA(insert ( 4055 25 25 1 360)); DATA(insert ( 4056 1042 1042 1 1078)); DATA(insert ( 4057 1083 1083 1 1107)); DATA(insert ( 4058 1266 1266 1 1358)); DATA(insert ( 4059 790 790 1 377)); DATA(insert ( 4060 1186 1186 1 1315)); DATA(insert ( 4061 704 704 1 381)); DATA(insert ( 4062 5545 5545 1 5519)); DATA(insert ( 4063 16 16 1 1693)); DATA(insert ( 4064 9003 9003 1 5586)); /* cbtree, fake data just make index work */ DATA(insert ( 4250 21 21 1 350)); DATA(insert ( 4250 21 23 1 2190)); DATA(insert ( 4250 21 20 1 2192)); DATA(insert ( 4250 23 23 1 351)); DATA(insert ( 4250 23 20 1 2188)); DATA(insert ( 4250 23 21 1 2191)); DATA(insert ( 4250 20 20 1 842)); DATA(insert ( 4250 20 23 1 2189)); DATA(insert ( 4250 20 21 1 2193)); DATA(insert ( 4251 26 26 1 356)); DATA(insert ( 4252 1082 1082 1 1092)); DATA(insert ( 4252 1082 1114 1 2344)); DATA(insert ( 4252 1082 1184 1 2357)); DATA(insert ( 4252 1114 1114 1 2045)); DATA(insert ( 4252 1114 1082 1 2370)); DATA(insert ( 4252 1114 1184 1 2526)); DATA(insert ( 4252 1184 1184 1 1314)); DATA(insert ( 4252 1184 1082 1 2383)); DATA(insert ( 4252 1184 1114 1 2533)); DATA(insert ( 4253 700 700 1 354)); DATA(insert ( 4253 700 701 1 2194)); DATA(insert ( 4253 701 701 1 355)); DATA(insert ( 4253 701 700 1 2195)); DATA(insert ( 4254 1700 1700 1 1769)); DATA(insert ( 4255 25 25 1 360)); DATA(insert ( 4256 1042 1042 1 1078)); DATA(insert ( 4257 1083 1083 1 1107)); DATA(insert ( 4258 1266 1266 1 1358)); DATA(insert ( 4259 790 790 1 377)); DATA(insert ( 4260 1186 1186 1 1315)); DATA(insert ( 4261 704 704 1 381)); DATA(insert ( 4262 5545 5545 1 5519)); DATA(insert ( 4263 16 16 1 1693)); DATA(insert ( 4264 9003 9003 1 5586)); /* ubtree */ DATA(insert ( 5397 2277 2277 1 382 )); DATA(insert ( 5421 702 702 1 357 )); DATA(insert ( 5423 1560 1560 1 1596 )); DATA(insert ( 5423 1560 1560 3 4609 )); DATA(insert ( 5424 16 16 1 1693 )); DATA(insert ( 5424 16 16 3 4609 )); DATA(insert ( 5426 1042 1042 1 1078 )); DATA(insert ( 5426 1042 1042 2 3256 )); DATA(insert ( 5426 1042 1042 3 4608 )); DATA(insert ( 5428 17 17 1 1954 )); DATA(insert ( 5428 17 17 2 3452 )); DATA(insert ( 5428 17 17 3 4609 )); DATA(insert ( 5429 18 18 1 358 )); DATA(insert ( 5429 18 18 3 4609 )); DATA(insert ( 5434 1082 1082 1 1092 )); DATA(insert ( 5434 1082 1082 2 3136 )); DATA(insert ( 5434 1082 1082 3 4609 )); DATA(insert ( 5434 1082 1114 1 2344 )); DATA(insert ( 5434 1082 1184 1 2357 )); DATA(insert ( 5434 1114 1114 1 2045 )); DATA(insert ( 5434 1114 1114 2 3137 )); DATA(insert ( 5434 1114 1114 3 4609 )); DATA(insert ( 5434 1114 1082 1 2370 )); DATA(insert ( 5434 1114 1184 1 2526 )); DATA(insert ( 5434 1184 1184 1 1314 )); DATA(insert ( 5434 1184 1184 2 3137 )); DATA(insert ( 5434 1184 1184 3 4609 )); DATA(insert ( 5434 1184 1082 1 2383 )); DATA(insert ( 5434 1184 1114 1 2533 )); DATA(insert ( 5436 4402 4402 1 4418 )); DATA(insert ( 5436 4402 4402 2 3452 )); DATA(insert ( 6970 700 700 1 354 )); DATA(insert ( 6970 700 700 2 3132 )); DATA(insert ( 6970 700 701 1 2194 )); DATA(insert ( 6970 701 701 1 355 )); DATA(insert ( 6970 701 701 2 3133 )); DATA(insert ( 6970 701 700 1 2195 )); DATA(insert ( 6974 869 869 1 926 )); DATA(insert ( 6974 869 869 3 4609 )); DATA(insert ( 6976 21 21 1 350 )); DATA(insert ( 6976 21 21 2 3129 )); DATA(insert ( 6976 21 21 3 4609 )); DATA(insert ( 6976 21 23 1 2190 )); DATA(insert ( 6976 21 20 1 2192 )); DATA(insert ( 6976 23 23 1 351 )); DATA(insert ( 6976 23 23 2 3130 )); DATA(insert ( 6976 23 23 3 4609 )); DATA(insert ( 6976 23 20 1 2188 )); DATA(insert ( 6976 23 21 1 2191 )); DATA(insert ( 6976 20 20 1 842 )); DATA(insert ( 6976 20 20 2 3131 )); DATA(insert ( 6976 20 20 3 4609 )); DATA(insert ( 6976 20 23 1 2189 )); DATA(insert ( 6976 20 21 1 2193 )); DATA(insert ( 6976 3272 3272 1 6544)); DATA(insert ( 6976 3272 3272 2 6538)); DATA(insert ( 6976 3272 23 1 6545)); DATA(insert ( 6976 23 3272 1 6543)); DATA(insert ( 6976 3272 20 1 6546)); DATA(insert ( 6976 20 3272 1 6547)); DATA(insert ( 6976 3272 21 1 6549)); DATA(insert ( 6976 21 3272 1 6548)); DATA(insert ( 6982 1186 1186 1 1315 )); DATA(insert ( 6982 1186 1186 3 4609 )); DATA(insert ( 6984 829 829 1 836 )); DATA(insert ( 6984 829 829 3 4609 )); DATA(insert ( 6986 19 19 1 359 )); DATA(insert ( 6986 19 19 2 3135 )); DATA(insert ( 6986 19 19 3 4608 )); DATA(insert ( 6988 1700 1700 1 1769 )); DATA(insert ( 6988 1700 1700 2 3283 )); DATA(insert ( 6989 26 26 1 356 )); DATA(insert ( 6989 26 26 2 3134 )); DATA(insert ( 6989 26 26 3 4609 )); DATA(insert ( 6991 30 30 1 404 )); DATA(insert ( 6991 30 30 3 4609 )); DATA(insert ( 7994 2249 2249 1 2987 )); DATA(insert ( 6994 25 25 1 360 )); DATA(insert ( 6994 25 25 2 3255 )); DATA(insert ( 6994 25 25 3 4608 )); DATA(insert ( 6996 1083 1083 1 1107 )); DATA(insert ( 6996 1083 1083 3 4609 )); DATA(insert ( 7000 1266 1266 1 1358 )); DATA(insert ( 7000 1266 1266 3 4609 )); DATA(insert ( 7002 1562 1562 1 1672 )); DATA(insert ( 7002 1562 1562 3 4609 )); DATA(insert ( 7095 25 25 1 2166 )); DATA(insert ( 7095 25 25 3 4609 )); DATA(insert ( 7097 1042 1042 1 2180 )); DATA(insert ( 7097 1042 1042 3 4609 )); DATA(insert ( 7099 790 790 1 377 )); DATA(insert ( 7099 790 790 3 4609 )); DATA(insert ( 7233 703 703 1 380 )); DATA(insert ( 7234 704 704 1 381 )); DATA(insert ( 7789 27 27 1 2794 )); DATA(insert ( 7789 27 27 3 4609 )); DATA(insert ( 7968 2950 2950 1 2960 )); DATA(insert ( 7968 2950 2950 3 4609 )); DATA(insert ( 8522 3500 3500 1 3514 )); DATA(insert ( 8806 86 86 1 3475 )); DATA(insert ( 9535 5545 5545 1 5519 )); DATA(insert ( 9570 9003 9003 1 5586 )); DATA(insert ( 8901 3831 3831 1 3870 )); DATA(insert ( 8626 3614 3614 1 3622 )); DATA(insert ( 8683 3615 3615 1 3668 )); #endif /* PG_AMPROC_H */
751050f90466d5d42f23a57bcdb1bdd9aaa44261
77fee94c58cd5b6305eef2f13d74b488db428c59
/litex/soc/software/liblitesdcard/sdcard.h
b6e25833e01ba5205233f2ed39ef851987bf6b57
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
enjoy-digital/litex
de5919d649c1b884c47a5e0364c2a9a584ebd614
405296b7fd99764af21fffd94afa5075c22affa8
refs/heads/master
2023-08-31T23:52:33.895792
2023-08-31T17:34:55
2023-08-31T17:36:21
45,734,719
2,351
524
NOASSERTION
2023-09-14T21:26:26
2015-11-07T12:02:12
C
UTF-8
C
false
false
3,793
h
sdcard.h
// This file is Copyright (c) 2017 Florent Kermarrec <florent@enjoy-digital.fr> // License: BSD #ifndef __SDCARD_H #define __SDCARD_H #ifdef __cplusplus extern "C" { #endif #include <generated/csr.h> #define CLKGEN_STATUS_BUSY 0x1 #define CLKGEN_STATUS_PROGDONE 0x2 #define CLKGEN_STATUS_LOCKED 0x4 #ifdef CSR_SDCARD_CORE_BASE #define SD_CMD_RESPONSE_SIZE 16 #define SD_OK 0 #define SD_CRCERROR 1 #define SD_TIMEOUT 2 #define SD_WRITEERROR 3 #define SD_SWITCH_CHECK 0 #define SD_SWITCH_SWITCH 1 #define SD_SPEED_SDR12 0 #define SD_SPEED_SDR25 1 #define SD_SPEED_SDR50 2 #define SD_SPEED_SDR104 3 #define SD_SPEED_DDR50 4 #define SD_DRIVER_STRENGTH_B 0 #define SD_DRIVER_STRENGTH_A 1 #define SD_DRIVER_STRENGTH_C 2 #define SD_DRIVER_STRENGTH_D 3 #define SD_GROUP_ACCESSMODE 0 #define SD_GROUP_COMMANDSYSTEM 1 #define SD_GROUP_DRIVERSTRENGTH 2 #define SD_GROUP_POWERLIMIT 3 #define SDCARD_STREAM_STATUS_OK 0b000 #define SDCARD_STREAM_STATUS_TIMEOUT 0b001 #define SDCARD_STREAM_STATUS_DATAACCEPTED 0b010 #define SDCARD_STREAM_STATUS_CRCERROR 0b101 #define SDCARD_STREAM_STATUS_WRITEERROR 0b110 #define SDCARD_CTRL_DATA_TRANSFER_NONE 0 #define SDCARD_CTRL_DATA_TRANSFER_READ 1 #define SDCARD_CTRL_DATA_TRANSFER_WRITE 2 #define SDCARD_CTRL_RESPONSE_NONE 0 #define SDCARD_CTRL_RESPONSE_SHORT 1 #define SDCARD_CTRL_RESPONSE_LONG 2 #define SDCARD_CTRL_RESPONSE_SHORT_BUSY 3 /*-----------------------------------------------------------------------*/ /* SDCard command helpers */ /*-----------------------------------------------------------------------*/ int sdcard_wait_cmd_done(void); int sdcard_wait_data_done(void); int sdcard_wait_response(void); /*-----------------------------------------------------------------------*/ /* SDCard clocker functions */ /*-----------------------------------------------------------------------*/ void sdcard_set_clk_freq(unsigned long clk_freq, int show); /*-----------------------------------------------------------------------*/ /* SDCard commands functions */ /*-----------------------------------------------------------------------*/ int sdcard_go_idle(void); int sdcard_send_ext_csd(void); int sdcard_app_cmd(uint16_t rca); int sdcard_app_send_op_cond(int hcs); int sdcard_all_send_cid(void); int sdcard_set_relative_address(void); int sdcard_send_cid(uint16_t rca); int sdcard_send_csd(uint16_t rca); int sdcard_select_card(uint16_t rca); int sdcard_app_set_bus_width(void); int sdcard_switch(unsigned int mode, unsigned int group, unsigned int value); int sdcard_app_send_scr(void); int sdcard_app_set_blocklen(unsigned int blocklen); int sdcard_write_single_block(unsigned int blockaddr); int sdcard_write_multiple_block(unsigned int blockaddr, unsigned int blockcnt); int sdcard_read_single_block(unsigned int blockaddr); int sdcard_read_multiple_block(unsigned int blockaddr, unsigned int blockcnt); int sdcard_stop_transmission(void); int sdcard_send_status(uint16_t rca); int sdcard_set_block_count(unsigned int blockcnt); uint16_t sdcard_decode_rca(void); void sdcard_decode_cid(void); void sdcard_decode_csd(void); /*-----------------------------------------------------------------------*/ /* SDCard user functions */ /*-----------------------------------------------------------------------*/ int sdcard_init(void); void sdcard_read(uint32_t sector, uint32_t count, uint8_t* buf); void sdcard_write(uint32_t sector, uint32_t count, uint8_t* buf); void fatfs_set_ops_sdcard(void); #endif /* CSR_SDCARD_CORE_BASE */ #ifdef __cplusplus } #endif #endif /* __SDCARD_H */
7967c7a454897364cfaadc644c052d48442a8e5f
7b7ac5102a2ba4326dbe431cacd72c3c19d87273
/Tools/hviokit.h
bd72eff4bda868a21afa056ffd0566082def7c29
[ "BSD-3-Clause" ]
permissive
acidanthera/MacHyperVSupport
4f55dadcc2c5880c77a007c0ba2e4b1358de7ba2
975f779216dd14227a96fb82324c7c75cda4bf04
refs/heads/master
2023-08-03T04:42:43.766673
2023-06-15T21:19:08
2023-06-15T21:19:08
370,101,450
469
51
BSD-3-Clause
2023-01-01T15:49:59
2021-05-23T16:25:01
C++
UTF-8
C
false
false
394
h
hviokit.h
// // hviokit.h // Hyper-V userspace I/O Kit support // // Copyright © 2022 Goldfish64. All rights reserved. // #ifndef hviokit_h #define hviokit_h #include <mach/mach_port.h> #include <IOKit/IOKitLib.h> void hvIOKitNotificationHandler(io_connect_t connection, CFMachPortRef port, void *msg, CFIndex size, void *info); IOReturn hvIOKitSetupIOKitNotifications(const char *name); #endif
04a9c0d1bba1aba462a7c2faf39098b5d88a3d16
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/cprover/cstrings/strlen1.c
2260045fb517f1de10d83aae76c3473418e43a11
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-4-Clause" ]
permissive
diffblue/cbmc
975a074ac445febb3b5715f8792beb545522dc18
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
refs/heads/develop
2023-08-31T05:52:05.342195
2023-08-30T13:31:51
2023-08-30T13:31:51
51,877,056
589
309
NOASSERTION
2023-09-14T18:49:17
2016-02-16T23:03:52
C++
UTF-8
C
false
false
535
c
strlen1.c
__CPROVER_size_t my_strlen(const char *p) // clang-format off __CPROVER_requires(__CPROVER_is_cstring(p)) __CPROVER_ensures(__CPROVER_return_value == __CPROVER_cstrlen(p)) // clang-format on { __CPROVER_size_t result = 0; while(*p != 0) // clang-format off __CPROVER_loop_invariant(__CPROVER_is_cstring(p)) __CPROVER_loop_invariant(p - __CPROVER_old(p) == result) __CPROVER_loop_invariant(result <= __CPROVER_cstrlen(__CPROVER_old(p))) { p++; result++; } // clang-format on return result; }
0316a24a09d52ac78d9440610560320df5ee86ae
56df6683865fd9319b389afd6dd4a922299da593
/source/detours/funchook_detour/source/funchook_detour.c
9d028c8bed6bd497d27b16f3782cc85d9808b047
[ "Python-2.0", "GPL-2.0-or-later", "MPL-1.1", "NCSA", "LicenseRef-scancode-proprietary-license", "GPL-1.0-or-later", "BSD-3-Clause", "MPL-2.0", "Ruby", "BSD-2-Clause", "MIT", "Apache-2.0" ]
permissive
metacall/core
4f36fe0b13924853aab6d0f053285b649398cc1d
419ffb573b17501c91662f0f161032bb19ea1ab3
refs/heads/develop
2023-08-23T10:19:30.898387
2023-08-10T18:39:08
2023-08-10T18:39:08
163,221,062
1,391
167
Apache-2.0
2023-09-13T23:49:43
2018-12-26T22:02:57
C
UTF-8
C
false
false
1,137
c
funchook_detour.c
/* * Detour Library by Parra Studios * Copyright (C) 2016 - 2022 Vicente Eduardo Ferrer Garcia <vic798@gmail.com> * * A cross-platform library providing detours, function hooks and trampolines. * */ /* -- Headers -- */ #include <metacall/metacall_version.h> #include <funchook_detour/funchook_detour.h> #include <funchook_detour/funchook_detour_impl.h> /* -- Methods -- */ detour_interface funchook_detour_impl_interface_singleton(void) { static struct detour_interface_type interface_instance_funchook = { &funchook_detour_impl_initialize, &funchook_detour_impl_install, &funchook_detour_impl_uninstall, &funchook_detour_impl_destroy }; return &interface_instance_funchook; } const char *funchook_detour_print_info(void) { static const char funchook_detour_info[] = "FuncHook Detour Plugin " METACALL_VERSION "\n" "Copyright (C) 2016 - 2022 Vicente Eduardo Ferrer Garcia <vic798@gmail.com>\n" #ifdef FUNCHOOK_DETOUR_STATIC_DEFINE "Compiled as static library type\n" #else "Compiled as shared library type\n" #endif "\n"; return funchook_detour_info; }
f9dcab95aa4f75cc7e4acf8a4748e20827bc35d0
a5f3b0001cdb692aeffc444a16f79a0c4422b9d0
/main/store/inc/store/types.h
367fe06219299e97fe52fe8011e9058cb6e59c45
[ "Apache-2.0", "CPL-1.0", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "Zlib", "LZMA-exception", "LGPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-philippe-de-muyter", "OFL-1.1", "LGPL-2.1-only", "MPL-1.1", "X11", "LGPL-2.1-or-later", "GPL-2.0-only", "OpenSSL", "LicenseRef-scancode-cpl-0.5", "GPL-1.0-or-later", "NPL-1.1", "MIT", "MPL-2.0", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-unknown-license-reference", "MPL-1.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows", "BSL-1.0", "LicenseRef-scancode-docbook", "LicenseRef-scancode-mit-old-style", "Python-2.0", "BSD-3-Clause", "IJG", "LicenseRef-scancode-warranty-disclaimer", "GPL-2.0-or-later", "LGPL-2.0-only", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown", "BSD-2-Clause", "Autoconf-exception-generic", "PSF-2.0", "NTP", "LicenseRef-scancode-python-cwi", "Afmparse", "W3C", "W3C-19980720", "curl", "LicenseRef-scancode-x11-xconsortium-veillard", "Bitstream-Vera", "HPND-sell-variant", "ICU" ]
permissive
apache/openoffice
b9518e36d784898c6c2ea3ebd44458a5e47825bb
681286523c50f34f13f05f7b87ce0c70e28295de
refs/heads/trunk
2023-08-30T15:25:48.357535
2023-08-28T19:50:26
2023-08-28T19:50:26
14,357,669
907
379
Apache-2.0
2023-08-16T20:49:37
2013-11-13T08:00:13
C++
UTF-8
C
false
false
3,539
h
types.h
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #ifndef _STORE_TYPES_H_ #define _STORE_TYPES_H_ "$Revision$" #include <sal/types.h> #include <rtl/ustring.h> #ifdef __cplusplus extern "C" { #endif /** PageSize (recommended) default. @see store_openFile() */ #define STORE_DEFAULT_PAGESIZE ((sal_uInt16)0x0400) /** PageSize (enforced) limits. @see store_openFile() */ #define STORE_MINIMUM_PAGESIZE ((sal_uInt16)0x0200) #define STORE_MAXIMUM_PAGESIZE ((sal_uInt16)0x8000) /** NameSize (enforced) limit. @see any param pName @see store_E_NameTooLong */ #define STORE_MAXIMUM_NAMESIZE 256 /** Attributes (predefined). @see store_attrib() */ #define STORE_ATTRIB_ISLINK ((sal_uInt32)0x10000000) #define STORE_ATTRIB_ISDIR ((sal_uInt32)0x20000000) #define STORE_ATTRIB_ISFILE ((sal_uInt32)0x40000000) /** Access Mode enumeration. @see store_openFile() @see store_openDirectory() @see store_openStream() */ enum __store_AccessMode { store_AccessCreate, store_AccessReadCreate, store_AccessReadWrite, store_AccessReadOnly, store_Access_FORCE_EQUAL_SIZE = SAL_MAX_ENUM }; /** Access Mode type. */ typedef enum __store_AccessMode storeAccessMode; /** Error Code enumeration. */ enum __store_Error { store_E_None = 0, store_E_AccessViolation, store_E_LockingViolation, store_E_CantSeek, store_E_CantRead, store_E_CantWrite, store_E_InvalidAccess, store_E_InvalidHandle, store_E_InvalidParameter, store_E_InvalidChecksum, store_E_AlreadyExists, store_E_NotExists, store_E_NotDirectory, store_E_NotFile, store_E_NoMoreFiles, store_E_NameTooLong, store_E_OutOfMemory, store_E_OutOfSpace, store_E_Pending, store_E_WrongFormat, store_E_WrongVersion, store_E_Unknown, store_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM }; /** Error Code type. */ typedef enum __store_Error storeError; /** Find Data structure. @see store_findFirst() @see store_findNext() */ struct __store_FindData { /** Name. @see m_nLength */ sal_Unicode m_pszName[STORE_MAXIMUM_NAMESIZE]; /** Name Length. @see m_pszName */ sal_Int32 m_nLength; /** Attributes. @see store_attrib() */ sal_uInt32 m_nAttrib; /** Size. @see store_getStreamSize() @see store_setStreamSize() */ sal_uInt32 m_nSize; /** Reserved for internal use. */ sal_uInt32 m_nReserved; }; /** Find Data type. */ typedef struct __store_FindData storeFindData; /*======================================================================== * * The End. * *======================================================================*/ #ifdef __cplusplus } #endif #endif /* _STORE_TYPES_H_ */
b01dd24429218afc452b57e258fcca4ac8210f3a
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/prep/include/pmap.h
e307189a88adc3c897214c00d68f97552fb88f76
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
86
h
pmap.h
/* $NetBSD: pmap.h,v 1.5 2003/02/03 17:10:12 matt Exp $ */ #include <powerpc/pmap.h>
bfff6e16649e6203c2fec22e7e48cc52c3b01b03
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_0017/AKWF_1678.h
70ab75048a92e8840d2b55b1199958850e8a0bdd
[ "CC0-1.0" ]
permissive
KristofferKarlAxelEkstrand/AKWF-FREE
b2defa1a2d389d309be6dd2e9f968923daf80d1b
cf8171df36e9fec25416b5f568b72a6e2cb69194
refs/heads/master
2023-07-23T18:22:36.939705
2023-07-10T17:14:40
2023-07-10T17:14:40
145,817,187
359
59
CC0-1.0
2023-07-10T17:14:41
2018-08-23T07:26:56
null
UTF-8
C
false
false
4,672
h
AKWF_1678.h
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library * * Adventure Kid Waveforms(AKWF) Open waveforms library * https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/ * * This code is in the public domain, CC0 1.0 Universal (CC0 1.0) * https://creativecommons.org/publicdomain/zero/1.0/ * * Converted by Brad Roy, https://github.com/prosper00 */ /* AKWF_1678 256 samples +-----------------------------------------------------------------------------------------------------------------+ | *** * | | ** * ** | | *** * **** *** | | ** * **** *** ** ** * | |** * ********* *** * * ** * | |* * ******** ** * * ** * | |* ********* *** * ** ** * * | | ** * ********** * * **| | * * * ** ** * | | *** * *** *** | | ** * **** | | * ** | | * ********* | | * * | | * ******** | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_1678 [] = { 33115, 34903, 37279, 39463, 41762, 43471, 45136, 46357, 47546, 48496, 49273, 50198, 50330, 53441, 56895, 56556, 57384, 57472, 57909, 58185, 58321, 58793, 58617, 59345, 58789, 59903, 58783, 60619, 58283, 62549, 48103, 29437, 33339, 31345, 32743, 31905, 32590, 32218, 32547, 32429, 32545, 32579, 32560, 32688, 32584, 32765, 32609, 32816, 32633, 32840, 32759, 37091, 37510, 37470, 37445, 37485, 37432, 37465, 37419, 37431, 37400, 37380, 37373, 37313, 37339, 37225, 37306, 37120, 41124, 41931, 41606, 41697, 41542, 41537, 41425, 41370, 41269, 41183, 41075, 40974, 40836, 40739, 40529, 40498, 40080, 43763, 44850, 44139, 44196, 43688, 43553, 43072, 42779, 42278, 41811, 41249, 40565, 39890, 38915, 38042, 36649, 35443, 33325, 31759, 33169, 31208, 28704, 27105, 25095, 24039, 22452, 21884, 20620, 20600, 19656, 24676, 37551, 43502, 45295, 45865, 46150, 46370, 47036, 46619, 49413, 51402, 49658, 48618, 46590, 44726, 42396, 40127, 37946, 36094, 34572, 33221, 32121, 31158, 30254, 29714, 28590, 30552, 33052, 31797, 31889, 31235, 31094, 30765, 30440, 30412, 29863, 30179, 29314, 30087, 28708, 30262, 27704, 31738, 17100, 0, 1980, 0, 1085, 116, 678, 202, 423, 222, 247, 213, 117, 192, 27, 167, 1, 141, 0, 108, 6, 4328, 4735, 4696, 4670, 4718, 4677, 4727, 4708, 4741, 4750, 4764, 4809, 4796, 4885, 4831, 4991, 4875, 8976, 9870, 9654, 9855, 9828, 9954, 9986, 10095, 10160, 10271, 10353, 10491, 10572, 10764, 10811, 11129, 11014, 15116, 16569, 16362, 16876, 16977, 17415, 17674, 18120, 18531, 19029, 19616, 20221, 21033, 21818, 22941, 24022, 25627, 27196, 29977, 36589, 39258, 41345, 43327, 44954, 46384, 47603, 48524, 49457, 49775, 50458, 45651, 32612, 26766, 24950, 24306, 24222, 23627, 23618, 22757, 26011, 29130, 29503, 31336, };
fd673de04589276da9951eaa9422d1d48668ec39
1b90be9561c10508eea59cb36c1f1665d0ef947f
/lib/sundials_6.1.1/include/idas/idas_spils.h
64575fe816b3b4373403ddecc8fe392a0b9773d8
[ "BSD-3-Clause", "GPL-2.0-only", "Apache-2.0" ]
permissive
stan-dev/math
473e7c1eaf11f84eaf2032c2455e12ba65feef39
bdf281f4e7f8034f47974d14dea7f09e600ac02a
refs/heads/develop
2023-08-31T09:02:59.224115
2023-08-29T15:17:01
2023-08-29T15:17:01
38,388,440
732
240
BSD-3-Clause
2023-09-14T19:44:20
2015-07-01T18:40:54
C++
UTF-8
C
false
false
5,486
h
idas_spils.h
/* ----------------------------------------------------------------- * Programmer(s): Daniel R. Reynolds @ SMU * ----------------------------------------------------------------- * SUNDIALS Copyright Start * Copyright (c) 2002-2022, Lawrence Livermore National Security * and Southern Methodist University. * All rights reserved. * * See the top-level LICENSE and NOTICE files for details. * * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- * Header file for the deprecated Scaled, Preconditioned Iterative * Linear Solver interface in IDAS; these routines now just wrap * the updated IDA generic linear solver interface in idas_ls.h. * -----------------------------------------------------------------*/ #ifndef _IDASSPILS_H #define _IDASSPILS_H #include <idas/idas_ls.h> #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif /*=============================================================== Function Types (typedefs for equivalent types in idas_ls.h) ===============================================================*/ typedef IDALsPrecSetupFn IDASpilsPrecSetupFn; typedef IDALsPrecSolveFn IDASpilsPrecSolveFn; typedef IDALsJacTimesSetupFn IDASpilsJacTimesSetupFn; typedef IDALsJacTimesVecFn IDASpilsJacTimesVecFn; typedef IDALsPrecSetupFnB IDASpilsPrecSetupFnB; typedef IDALsPrecSetupFnBS IDASpilsPrecSetupFnBS; typedef IDALsPrecSolveFnB IDASpilsPrecSolveFnB; typedef IDALsPrecSolveFnBS IDASpilsPrecSolveFnBS; typedef IDALsJacTimesSetupFnB IDASpilsJacTimesSetupFnB; typedef IDALsJacTimesSetupFnBS IDASpilsJacTimesSetupFnBS; typedef IDALsJacTimesVecFnB IDASpilsJacTimesVecFnB; typedef IDALsJacTimesVecFnBS IDASpilsJacTimesVecFnBS; /*==================================================================== Exported Functions (wrappers for equivalent routines in idas_ls.h) ====================================================================*/ SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetLinearSolver instead") int IDASpilsSetLinearSolver(void *ida_mem, SUNLinearSolver LS); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetPreconditioner instead") int IDASpilsSetPreconditioner(void *ida_mem, IDASpilsPrecSetupFn pset, IDASpilsPrecSolveFn psolve); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetJacTimes instead") int IDASpilsSetJacTimes(void *ida_mem, IDASpilsJacTimesSetupFn jtsetup, IDASpilsJacTimesVecFn jtimes); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetEpsLin instead") int IDASpilsSetEpsLin(void *ida_mem, realtype eplifac); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetIncrementFactor instead") int IDASpilsSetIncrementFactor(void *ida_mem, realtype dqincfac); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetLinWorkSpace instead") int IDASpilsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumPrecEvals instead") int IDASpilsGetNumPrecEvals(void *ida_mem, long int *npevals); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumPrecSolves instead") int IDASpilsGetNumPrecSolves(void *ida_mem, long int *npsolves); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumLinIters instead") int IDASpilsGetNumLinIters(void *ida_mem, long int *nliters); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumLinConvFails instead") int IDASpilsGetNumConvFails(void *ida_mem, long int *nlcfails); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumJTSetupEvals instead") int IDASpilsGetNumJTSetupEvals(void *ida_mem, long int *njtsetups); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumJtimesEvals instead") int IDASpilsGetNumJtimesEvals(void *ida_mem, long int *njvevals); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetNumLinResEvals instead") int IDASpilsGetNumResEvals(void *ida_mem, long int *nrevalsLS); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetLastLinFlag instead") int IDASpilsGetLastFlag(void *ida_mem, long int *flag); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDAGetLinReturnFlagName instead") char *IDASpilsGetReturnFlagName(long int flag); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetLinearSolverB instead") int IDASpilsSetLinearSolverB(void *ida_mem, int which, SUNLinearSolver LS); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetEpsLinB instead") int IDASpilsSetEpsLinB(void *ida_mem, int which, realtype eplifacB); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetIncrementFactorB instead") int IDASpilsSetIncrementFactorB(void *ida_mem, int which, realtype dqincfacB); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetPreconditionerB instead") int IDASpilsSetPreconditionerB(void *ida_mem, int which, IDASpilsPrecSetupFnB psetB, IDASpilsPrecSolveFnB psolveB); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetPreconditionerBS instead") int IDASpilsSetPreconditionerBS(void *ida_mem, int which, IDASpilsPrecSetupFnBS psetBS, IDASpilsPrecSolveFnBS psolveBS); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetJacTimesB instead") int IDASpilsSetJacTimesB(void *ida_mem, int which, IDASpilsJacTimesSetupFnB jtsetupB, IDASpilsJacTimesVecFnB jtimesB); SUNDIALS_DEPRECATED_EXPORT_MSG("use IDASetJacTimesBS instead") int IDASpilsSetJacTimesBS(void *ida_mem, int which, IDASpilsJacTimesSetupFnBS jtsetupBS, IDASpilsJacTimesVecFnBS jtimesBS); #ifdef __cplusplus } #endif #endif
ba41944b343a82ea7032f2d36033588b180c0d26
7a5b1039d9dd2e488c361b3141226f6ae5bf76f3
/rsb_depth_check/pmu.h
94236b7bc1997c165a22dd32737ba23b3b25de9f
[]
no_license
comsec-group/retbleed
39066af14fb1adf7ef82754c36002f2bf1cf871f
32e1eecd7c7a9cb9174c1ae7ce8614a60d39b11d
refs/heads/master
2023-03-07T11:40:42.759042
2022-08-25T22:47:01
2022-08-25T22:47:01
505,872,974
112
10
null
2022-07-27T18:41:03
2022-06-21T14:15:23
C
UTF-8
C
false
false
1,057
h
pmu.h
#include <linux/perf_event.h> #include <linux/hw_breakpoint.h> #include <string.h> #include <sys/types.h> #include <syscall.h> #include <unistd.h> #include <stdio.h> #define ARR_SZ(a) (sizeof(a)/sizeof(a[0])) // umask<<8 | event #ifdef INTEL #define PE_BA_CLEARS__ANY 0x1e6 #define PE_BR_MISP_RETIRED__ALL_BRANCHES 0xc5 #define PE_BR_MISP_RETIRED__ALL_BRANCHES_PEBS 0x4c5 #define PE_BR_MISP_RETIRED__CONDITIONAL 0x1c5 #define PE_BR_MISP_RETIRED__NEAR_CALL 0x2c5 #define PE_BR_MISP_RETIRED__NEAR_TAKEN 0x20c5 #define PE_INT_MISC__CLEAR_RESTEER_CYCLES 0x80d #endif struct pmu_desc { int nconfs; struct pmu_conf *pmu_confs; }; struct pmu_conf { long event; char name[0x40]; int fd; long count; long diff; // save total of everything long diff_sum; unsigned long min; }; int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags) ; int pmu_init(struct pmu_desc *ctx); void pmu_sample(struct pmu_desc *ctx, int end); void pmu_print(struct pmu_desc *ctx);
0ea91af8210030c16533e03294f79556b423cf4b
eecd5e4c50d8b78a769bcc2675250576bed34066
/src/dm/impls/plex/tests/ex8.c
2e8c3f67a3ee411b21e94cb5a54a0fc76a4a2bfc
[ "BSD-2-Clause" ]
permissive
petsc/petsc
3b1a04fea71858e0292f9fd4d04ea11618c50969
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
refs/heads/main
2023-08-17T20:51:16.507070
2023-08-17T16:08:06
2023-08-17T16:08:06
8,691,401
341
169
NOASSERTION
2023-03-29T11:02:58
2013-03-10T20:55:21
C
UTF-8
C
false
false
32,549
c
ex8.c
static char help[] = "Tests for cell geometry\n\n"; #include <petscdmplex.h> typedef enum { RUN_REFERENCE, RUN_HEX_CURVED, RUN_FILE, RUN_DISPLAY } RunType; typedef struct { DM dm; RunType runType; /* Type of mesh to use */ PetscBool transform; /* Use random coordinate transformations */ /* Data for input meshes */ PetscReal *v0, *J, *invJ, *detJ; /* FEM data */ PetscReal *centroid, *normal, *vol; /* FVM data */ } AppCtx; static PetscErrorCode ReadMesh(MPI_Comm comm, AppCtx *user, DM *dm) { PetscFunctionBegin; PetscCall(DMCreate(comm, dm)); PetscCall(DMSetType(*dm, DMPLEX)); PetscCall(DMSetFromOptions(*dm)); PetscCall(DMSetApplicationContext(*dm, user)); PetscCall(PetscObjectSetName((PetscObject)*dm, "Input Mesh")); PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view")); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options) { const char *runTypes[4] = {"reference", "hex_curved", "file", "display"}; PetscInt run; PetscFunctionBeginUser; options->runType = RUN_REFERENCE; options->transform = PETSC_FALSE; PetscOptionsBegin(comm, "", "Geometry Test Options", "DMPLEX"); run = options->runType; PetscCall(PetscOptionsEList("-run_type", "The run type", "ex8.c", runTypes, 3, runTypes[options->runType], &run, NULL)); options->runType = (RunType)run; PetscCall(PetscOptionsBool("-transform", "Use random transforms", "ex8.c", options->transform, &options->transform, NULL)); if (options->runType == RUN_FILE) { PetscInt dim, cStart, cEnd, numCells, n; PetscBool flg, feFlg; PetscCall(ReadMesh(PETSC_COMM_WORLD, options, &options->dm)); PetscCall(DMGetDimension(options->dm, &dim)); PetscCall(DMPlexGetHeightStratum(options->dm, 0, &cStart, &cEnd)); numCells = cEnd - cStart; PetscCall(PetscMalloc4(numCells * dim, &options->v0, numCells * dim * dim, &options->J, numCells * dim * dim, &options->invJ, numCells, &options->detJ)); PetscCall(PetscMalloc1(numCells * dim, &options->centroid)); PetscCall(PetscMalloc1(numCells * dim, &options->normal)); PetscCall(PetscMalloc1(numCells, &options->vol)); n = numCells * dim; PetscCall(PetscOptionsRealArray("-v0", "Input v0 for each cell", "ex8.c", options->v0, &n, &feFlg)); PetscCheck(!feFlg || n == numCells * dim, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of v0 %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells * dim); n = numCells * dim * dim; PetscCall(PetscOptionsRealArray("-J", "Input Jacobian for each cell", "ex8.c", options->J, &n, &flg)); PetscCheck(!flg || n == numCells * dim * dim, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of J %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells * dim * dim); n = numCells * dim * dim; PetscCall(PetscOptionsRealArray("-invJ", "Input inverse Jacobian for each cell", "ex8.c", options->invJ, &n, &flg)); PetscCheck(!flg || n == numCells * dim * dim, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of invJ %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells * dim * dim); n = numCells; PetscCall(PetscOptionsRealArray("-detJ", "Input Jacobian determinant for each cell", "ex8.c", options->detJ, &n, &flg)); PetscCheck(!flg || n == numCells, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of detJ %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells); n = numCells * dim; if (!feFlg) { PetscCall(PetscFree4(options->v0, options->J, options->invJ, options->detJ)); options->v0 = options->J = options->invJ = options->detJ = NULL; } PetscCall(PetscOptionsRealArray("-centroid", "Input centroid for each cell", "ex8.c", options->centroid, &n, &flg)); PetscCheck(!flg || n == numCells * dim, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of centroid %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells * dim); if (!flg) { PetscCall(PetscFree(options->centroid)); options->centroid = NULL; } n = numCells * dim; PetscCall(PetscOptionsRealArray("-normal", "Input normal for each cell", "ex8.c", options->normal, &n, &flg)); PetscCheck(!flg || n == numCells * dim, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of normal %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells * dim); if (!flg) { PetscCall(PetscFree(options->normal)); options->normal = NULL; } n = numCells; PetscCall(PetscOptionsRealArray("-vol", "Input volume for each cell", "ex8.c", options->vol, &n, &flg)); PetscCheck(!flg || n == numCells, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Invalid size of vol %" PetscInt_FMT " should be %" PetscInt_FMT, n, numCells); if (!flg) { PetscCall(PetscFree(options->vol)); options->vol = NULL; } } else if (options->runType == RUN_DISPLAY) { PetscCall(ReadMesh(PETSC_COMM_WORLD, options, &options->dm)); } PetscOptionsEnd(); if (options->transform) PetscCall(PetscPrintf(comm, "Using random transforms\n")); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode ChangeCoordinates(DM dm, PetscInt spaceDim, PetscScalar vertexCoords[]) { PetscSection coordSection; Vec coordinates; PetscScalar *coords; PetscInt vStart, vEnd, v, d, coordSize; PetscFunctionBegin; PetscCall(DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd)); PetscCall(DMGetCoordinateSection(dm, &coordSection)); PetscCall(PetscSectionSetNumFields(coordSection, 1)); PetscCall(PetscSectionSetFieldComponents(coordSection, 0, spaceDim)); PetscCall(PetscSectionSetChart(coordSection, vStart, vEnd)); for (v = vStart; v < vEnd; ++v) { PetscCall(PetscSectionSetDof(coordSection, v, spaceDim)); PetscCall(PetscSectionSetFieldDof(coordSection, v, 0, spaceDim)); } PetscCall(PetscSectionSetUp(coordSection)); PetscCall(PetscSectionGetStorageSize(coordSection, &coordSize)); PetscCall(VecCreate(PETSC_COMM_SELF, &coordinates)); PetscCall(PetscObjectSetName((PetscObject)coordinates, "coordinates")); PetscCall(VecSetSizes(coordinates, coordSize, PETSC_DETERMINE)); PetscCall(VecSetFromOptions(coordinates)); PetscCall(VecGetArray(coordinates, &coords)); for (v = vStart; v < vEnd; ++v) { PetscInt off; PetscCall(PetscSectionGetOffset(coordSection, v, &off)); for (d = 0; d < spaceDim; ++d) coords[off + d] = vertexCoords[(v - vStart) * spaceDim + d]; } PetscCall(VecRestoreArray(coordinates, &coords)); PetscCall(DMSetCoordinateDim(dm, spaceDim)); PetscCall(DMSetCoordinatesLocal(dm, coordinates)); PetscCall(VecDestroy(&coordinates)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); PetscFunctionReturn(PETSC_SUCCESS); } #define RelativeError(a, b) PetscAbs(a - b) / (1.0 + PetscMax(PetscAbs(a), PetscAbs(b))) static PetscErrorCode CheckFEMGeometry(DM dm, PetscInt cell, PetscInt spaceDim, PetscReal v0Ex[], PetscReal JEx[], PetscReal invJEx[], PetscReal detJEx) { PetscReal v0[3], J[9], invJ[9], detJ; PetscInt d, i, j; PetscFunctionBegin; PetscCall(DMPlexComputeCellGeometryFEM(dm, cell, NULL, v0, J, invJ, &detJ)); for (d = 0; d < spaceDim; ++d) { if (v0[d] != v0Ex[d]) { switch (spaceDim) { case 2: SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid v0 (%g, %g) != (%g, %g)", (double)v0[0], (double)v0[1], (double)v0Ex[0], (double)v0Ex[1]); case 3: SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid v0 (%g, %g, %g) != (%g, %g, %g)", (double)v0[0], (double)v0[1], (double)v0[2], (double)v0Ex[0], (double)v0Ex[1], (double)v0Ex[2]); default: SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid space dimension %" PetscInt_FMT, spaceDim); } } } for (i = 0; i < spaceDim; ++i) { for (j = 0; j < spaceDim; ++j) { PetscCheck(RelativeError(J[i * spaceDim + j], JEx[i * spaceDim + j]) < 10 * PETSC_SMALL, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid J[%" PetscInt_FMT ",%" PetscInt_FMT "]: %g != %g", i, j, (double)J[i * spaceDim + j], (double)JEx[i * spaceDim + j]); PetscCheck(RelativeError(invJ[i * spaceDim + j], invJEx[i * spaceDim + j]) < 10 * PETSC_SMALL, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid invJ[%" PetscInt_FMT ",%" PetscInt_FMT "]: %g != %g", i, j, (double)invJ[i * spaceDim + j], (double)invJEx[i * spaceDim + j]); } } PetscCheck(RelativeError(detJ, detJEx) < 10 * PETSC_SMALL, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid |J| = %g != %g diff %g", (double)detJ, (double)detJEx, (double)(detJ - detJEx)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode CheckFVMGeometry(DM dm, PetscInt cell, PetscInt spaceDim, PetscReal centroidEx[], PetscReal normalEx[], PetscReal volEx) { PetscReal tol = PetscMax(10 * PETSC_SMALL, 1e-10); PetscReal centroid[3], normal[3], vol; PetscInt d; PetscFunctionBegin; PetscCall(DMPlexComputeCellGeometryFVM(dm, cell, volEx ? &vol : NULL, centroidEx ? centroid : NULL, normalEx ? normal : NULL)); for (d = 0; d < spaceDim; ++d) { if (centroidEx) PetscCheck(RelativeError(centroid[d], centroidEx[d]) < tol, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Cell %" PetscInt_FMT ", Invalid centroid[%" PetscInt_FMT "]: %g != %g diff %g", cell, d, (double)centroid[d], (double)centroidEx[d], (double)(centroid[d] - centroidEx[d])); if (normalEx) PetscCheck(RelativeError(normal[d], normalEx[d]) < tol, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Cell %" PetscInt_FMT ", Invalid normal[%" PetscInt_FMT "]: %g != %g", cell, d, (double)normal[d], (double)normalEx[d]); } if (volEx) PetscCheck(RelativeError(volEx, vol) < tol, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Cell %" PetscInt_FMT ", Invalid volume = %g != %g diff %g", cell, (double)vol, (double)volEx, (double)(vol - volEx)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode CheckGaussLaw(DM dm, PetscInt cell) { DMPolytopeType ct; PetscReal tol = PetscMax(10 * PETSC_SMALL, 1e-10); PetscReal normal[3], integral[3] = {0., 0., 0.}, area; const PetscInt *cone, *ornt; PetscInt coneSize, f, dim, cdim, d; PetscFunctionBegin; PetscCall(DMGetDimension(dm, &dim)); PetscCall(DMGetCoordinateDim(dm, &cdim)); if (dim != cdim) PetscFunctionReturn(PETSC_SUCCESS); PetscCall(DMPlexGetCellType(dm, cell, &ct)); if (ct == DM_POLYTOPE_TRI_PRISM_TENSOR) PetscFunctionReturn(PETSC_SUCCESS); PetscCall(DMPlexGetConeSize(dm, cell, &coneSize)); PetscCall(DMPlexGetCone(dm, cell, &cone)); PetscCall(DMPlexGetConeOrientation(dm, cell, &ornt)); for (f = 0; f < coneSize; ++f) { const PetscInt sgn = dim == 1 ? (f == 0 ? -1 : 1) : (ornt[f] < 0 ? -1 : 1); PetscCall(DMPlexComputeCellGeometryFVM(dm, cone[f], &area, NULL, normal)); for (d = 0; d < cdim; ++d) integral[d] += sgn * area * normal[d]; } for (d = 0; d < cdim; ++d) PetscCheck(PetscAbsReal(integral[d]) < tol, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Cell %" PetscInt_FMT " Surface integral for component %" PetscInt_FMT ": %g != 0. as it should be for a constant field", cell, d, (double)integral[d]); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode CheckCell(DM dm, PetscInt cell, PetscBool transform, PetscReal v0Ex[], PetscReal JEx[], PetscReal invJEx[], PetscReal detJEx, PetscReal centroidEx[], PetscReal normalEx[], PetscReal volEx, PetscReal faceCentroidEx[], PetscReal faceNormalEx[], PetscReal faceVolEx[]) { const PetscInt *cone; PetscInt coneSize, c; PetscInt dim, depth, cdim; PetscFunctionBegin; PetscCall(DMPlexGetDepth(dm, &depth)); PetscCall(DMGetDimension(dm, &dim)); PetscCall(DMGetCoordinateDim(dm, &cdim)); if (v0Ex) PetscCall(CheckFEMGeometry(dm, cell, cdim, v0Ex, JEx, invJEx, detJEx)); if (dim == depth && centroidEx) { PetscCall(CheckFVMGeometry(dm, cell, cdim, centroidEx, normalEx, volEx)); PetscCall(CheckGaussLaw(dm, cell)); if (faceCentroidEx) { PetscCall(DMPlexGetConeSize(dm, cell, &coneSize)); PetscCall(DMPlexGetCone(dm, cell, &cone)); for (c = 0; c < coneSize; ++c) PetscCall(CheckFVMGeometry(dm, cone[c], dim, &faceCentroidEx[c * dim], &faceNormalEx[c * dim], faceVolEx[c])); } } if (transform) { Vec coordinates; PetscSection coordSection; PetscScalar *coords = NULL, *origCoords, *newCoords; PetscReal *v0ExT, *JExT, *invJExT, detJExT = 0, *centroidExT, *normalExT, volExT = 0; PetscReal *faceCentroidExT, *faceNormalExT, faceVolExT; PetscRandom r, ang, ang2; PetscInt coordSize, numCorners, t; PetscCall(DMGetCoordinatesLocal(dm, &coordinates)); PetscCall(DMGetCoordinateSection(dm, &coordSection)); PetscCall(DMPlexVecGetClosure(dm, coordSection, coordinates, cell, &coordSize, &coords)); PetscCall(PetscMalloc2(coordSize, &origCoords, coordSize, &newCoords)); PetscCall(PetscMalloc5(cdim, &v0ExT, cdim * cdim, &JExT, cdim * cdim, &invJExT, cdim, &centroidExT, cdim, &normalExT)); PetscCall(PetscMalloc2(cdim, &faceCentroidExT, cdim, &faceNormalExT)); for (c = 0; c < coordSize; ++c) origCoords[c] = coords[c]; PetscCall(DMPlexVecRestoreClosure(dm, coordSection, coordinates, cell, &coordSize, &coords)); numCorners = coordSize / cdim; PetscCall(PetscRandomCreate(PETSC_COMM_SELF, &r)); PetscCall(PetscRandomSetFromOptions(r)); PetscCall(PetscRandomSetInterval(r, 0.0, 10.0)); PetscCall(PetscRandomCreate(PETSC_COMM_SELF, &ang)); PetscCall(PetscRandomSetFromOptions(ang)); PetscCall(PetscRandomSetInterval(ang, 0.0, 2 * PETSC_PI)); PetscCall(PetscRandomCreate(PETSC_COMM_SELF, &ang2)); PetscCall(PetscRandomSetFromOptions(ang2)); PetscCall(PetscRandomSetInterval(ang2, 0.0, PETSC_PI)); for (t = 0; t < 1; ++t) { PetscScalar trans[3]; PetscReal R[9], rot[3], rotM[9]; PetscReal scale, phi, theta, psi = 0.0, norm; PetscInt d, e, f, p; for (c = 0; c < coordSize; ++c) newCoords[c] = origCoords[c]; PetscCall(PetscRandomGetValueReal(r, &scale)); PetscCall(PetscRandomGetValueReal(ang, &phi)); PetscCall(PetscRandomGetValueReal(ang2, &theta)); for (d = 0; d < cdim; ++d) PetscCall(PetscRandomGetValue(r, &trans[d])); switch (cdim) { case 2: R[0] = PetscCosReal(phi); R[1] = -PetscSinReal(phi); R[2] = PetscSinReal(phi); R[3] = PetscCosReal(phi); break; case 3: { const PetscReal ct = PetscCosReal(theta), st = PetscSinReal(theta); const PetscReal cp = PetscCosReal(phi), sp = PetscSinReal(phi); const PetscReal cs = PetscCosReal(psi), ss = PetscSinReal(psi); R[0] = ct * cs; R[1] = sp * st * cs - cp * ss; R[2] = sp * ss + cp * st * cs; R[3] = ct * ss; R[4] = cp * cs + sp * st * ss; R[5] = cp * st * ss - sp * cs; R[6] = -st; R[7] = sp * ct; R[8] = cp * ct; break; } default: SETERRQ(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_WRONG, "Invalid coordinate dimension %" PetscInt_FMT, cdim); } if (v0Ex) { detJExT = detJEx; for (d = 0; d < cdim; ++d) { v0ExT[d] = v0Ex[d]; for (e = 0; e < cdim; ++e) { JExT[d * cdim + e] = JEx[d * cdim + e]; invJExT[d * cdim + e] = invJEx[d * cdim + e]; } } for (d = 0; d < cdim; ++d) { v0ExT[d] *= scale; v0ExT[d] += PetscRealPart(trans[d]); /* Only scale dimensions in the manifold */ for (e = 0; e < dim; ++e) { JExT[d * cdim + e] *= scale; invJExT[d * cdim + e] /= scale; } if (d < dim) detJExT *= scale; } /* Do scaling and translation before rotation, so that we can leave out the normal dimension for lower dimensional manifolds */ for (d = 0; d < cdim; ++d) { for (e = 0, rot[d] = 0.0; e < cdim; ++e) rot[d] += R[d * cdim + e] * v0ExT[e]; } for (d = 0; d < cdim; ++d) v0ExT[d] = rot[d]; for (d = 0; d < cdim; ++d) { for (e = 0; e < cdim; ++e) { for (f = 0, rotM[d * cdim + e] = 0.0; f < cdim; ++f) rotM[d * cdim + e] += R[d * cdim + f] * JExT[f * cdim + e]; } } for (d = 0; d < cdim; ++d) { for (e = 0; e < cdim; ++e) JExT[d * cdim + e] = rotM[d * cdim + e]; } for (d = 0; d < cdim; ++d) { for (e = 0; e < cdim; ++e) { for (f = 0, rotM[d * cdim + e] = 0.0; f < cdim; ++f) rotM[d * cdim + e] += invJExT[d * cdim + f] * R[e * cdim + f]; } } for (d = 0; d < cdim; ++d) { for (e = 0; e < cdim; ++e) invJExT[d * cdim + e] = rotM[d * cdim + e]; } } if (centroidEx) { volExT = volEx; for (d = 0; d < cdim; ++d) { centroidExT[d] = centroidEx[d]; normalExT[d] = normalEx[d]; } for (d = 0; d < cdim; ++d) { centroidExT[d] *= scale; centroidExT[d] += PetscRealPart(trans[d]); normalExT[d] /= scale; /* Only scale dimensions in the manifold */ if (d < dim) volExT *= scale; } /* Do scaling and translation before rotation, so that we can leave out the normal dimension for lower dimensional manifolds */ for (d = 0; d < cdim; ++d) { for (e = 0, rot[d] = 0.0; e < cdim; ++e) rot[d] += R[d * cdim + e] * centroidExT[e]; } for (d = 0; d < cdim; ++d) centroidExT[d] = rot[d]; for (d = 0; d < cdim; ++d) { for (e = 0, rot[d] = 0.0; e < cdim; ++e) rot[d] += R[d * cdim + e] * normalExT[e]; } for (d = 0; d < cdim; ++d) normalExT[d] = rot[d]; for (d = 0, norm = 0.0; d < cdim; ++d) norm += PetscSqr(normalExT[d]); norm = PetscSqrtReal(norm); if (norm != 0.) for (d = 0; d < cdim; ++d) normalExT[d] /= norm; } for (d = 0; d < cdim; ++d) { for (p = 0; p < numCorners; ++p) { newCoords[p * cdim + d] *= scale; newCoords[p * cdim + d] += trans[d]; } } for (p = 0; p < numCorners; ++p) { for (d = 0; d < cdim; ++d) { for (e = 0, rot[d] = 0.0; e < cdim; ++e) rot[d] += R[d * cdim + e] * PetscRealPart(newCoords[p * cdim + e]); } for (d = 0; d < cdim; ++d) newCoords[p * cdim + d] = rot[d]; } PetscCall(ChangeCoordinates(dm, cdim, newCoords)); if (v0Ex) PetscCall(CheckFEMGeometry(dm, 0, cdim, v0ExT, JExT, invJExT, detJExT)); if (dim == depth && centroidEx) { PetscCall(CheckFVMGeometry(dm, cell, cdim, centroidExT, normalExT, volExT)); PetscCall(CheckGaussLaw(dm, cell)); if (faceCentroidEx) { PetscCall(DMPlexGetConeSize(dm, cell, &coneSize)); PetscCall(DMPlexGetCone(dm, cell, &cone)); for (c = 0; c < coneSize; ++c) { PetscInt off = c * cdim; faceVolExT = faceVolEx[c]; for (d = 0; d < cdim; ++d) { faceCentroidExT[d] = faceCentroidEx[off + d]; faceNormalExT[d] = faceNormalEx[off + d]; } for (d = 0; d < cdim; ++d) { faceCentroidExT[d] *= scale; faceCentroidExT[d] += PetscRealPart(trans[d]); faceNormalExT[d] /= scale; /* Only scale dimensions in the manifold */ if (d < dim - 1) faceVolExT *= scale; } for (d = 0; d < cdim; ++d) { for (e = 0, rot[d] = 0.0; e < cdim; ++e) rot[d] += R[d * cdim + e] * faceCentroidExT[e]; } for (d = 0; d < cdim; ++d) faceCentroidExT[d] = rot[d]; for (d = 0; d < cdim; ++d) { for (e = 0, rot[d] = 0.0; e < cdim; ++e) rot[d] += R[d * cdim + e] * faceNormalExT[e]; } for (d = 0; d < cdim; ++d) faceNormalExT[d] = rot[d]; for (d = 0, norm = 0.0; d < cdim; ++d) norm += PetscSqr(faceNormalExT[d]); norm = PetscSqrtReal(norm); for (d = 0; d < cdim; ++d) faceNormalExT[d] /= norm; PetscCall(CheckFVMGeometry(dm, cone[c], cdim, faceCentroidExT, faceNormalExT, faceVolExT)); } } } } PetscCall(PetscRandomDestroy(&r)); PetscCall(PetscRandomDestroy(&ang)); PetscCall(PetscRandomDestroy(&ang2)); PetscCall(PetscFree2(origCoords, newCoords)); PetscCall(PetscFree5(v0ExT, JExT, invJExT, centroidExT, normalExT)); PetscCall(PetscFree2(faceCentroidExT, faceNormalExT)); } PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TestTriangle(MPI_Comm comm, PetscBool transform) { DM dm; PetscFunctionBegin; PetscCall(DMPlexCreateReferenceCell(comm, DM_POLYTOPE_TRIANGLE, &dm)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); /* Check reference geometry: determinant is scaled by reference volume (2.0) */ { PetscReal v0Ex[2] = {-1.0, -1.0}; PetscReal JEx[4] = {1.0, 0.0, 0.0, 1.0}; PetscReal invJEx[4] = {1.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; PetscReal centroidEx[2] = {-((PetscReal)1.) / ((PetscReal)3.), -((PetscReal)1.) / ((PetscReal)3.)}; PetscReal normalEx[2] = {0.0, 0.0}; PetscReal volEx = 2.0; PetscCall(CheckCell(dm, 0, transform, v0Ex, JEx, invJEx, detJEx, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } /* Move to 3D: Check reference geometry: determinant is scaled by reference volume (2.0) */ { PetscScalar vertexCoords[9] = {-1.0, -1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0}; PetscReal v0Ex[3] = {-1.0, -1.0, 0.0}; PetscReal JEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal invJEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; PetscReal centroidEx[3] = {-((PetscReal)1.) / ((PetscReal)3.), -((PetscReal)1.) / ((PetscReal)3.), 0.0}; PetscReal normalEx[3] = {0.0, 0.0, 1.0}; PetscReal volEx = 2.0; PetscCall(ChangeCoordinates(dm, 3, vertexCoords)); PetscCall(CheckCell(dm, 0, transform, v0Ex, JEx, invJEx, detJEx, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } /* Cleanup */ PetscCall(DMDestroy(&dm)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TestQuadrilateral(MPI_Comm comm, PetscBool transform) { DM dm; PetscFunctionBegin; PetscCall(DMPlexCreateReferenceCell(comm, DM_POLYTOPE_QUADRILATERAL, &dm)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); /* Check reference geometry: determinant is scaled by reference volume (2.0) */ { PetscReal v0Ex[2] = {-1.0, -1.0}; PetscReal JEx[4] = {1.0, 0.0, 0.0, 1.0}; PetscReal invJEx[4] = {1.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; PetscReal centroidEx[2] = {0.0, 0.0}; PetscReal normalEx[2] = {0.0, 0.0}; PetscReal volEx = 4.0; PetscCall(CheckCell(dm, 0, transform, v0Ex, JEx, invJEx, detJEx, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } /* Move to 3D: Check reference geometry: determinant is scaled by reference volume (4.0) */ { PetscScalar vertexCoords[12] = {-1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, 1.0, 0.0}; PetscReal v0Ex[3] = {-1.0, -1.0, 0.0}; PetscReal JEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal invJEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; PetscReal centroidEx[3] = {0.0, 0.0, 0.0}; PetscReal normalEx[3] = {0.0, 0.0, 1.0}; PetscReal volEx = 4.0; PetscCall(ChangeCoordinates(dm, 3, vertexCoords)); PetscCall(CheckCell(dm, 0, transform, v0Ex, JEx, invJEx, detJEx, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } /* Cleanup */ PetscCall(DMDestroy(&dm)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TestTetrahedron(MPI_Comm comm, PetscBool transform) { DM dm; PetscFunctionBegin; PetscCall(DMPlexCreateReferenceCell(comm, DM_POLYTOPE_TETRAHEDRON, &dm)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); /* Check reference geometry: determinant is scaled by reference volume (4/3) */ { PetscReal v0Ex[3] = {-1.0, -1.0, -1.0}; PetscReal JEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal invJEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; PetscReal centroidEx[3] = {-0.5, -0.5, -0.5}; PetscReal normalEx[3] = {0.0, 0.0, 0.0}; PetscReal volEx = (PetscReal)4.0 / (PetscReal)3.0; PetscCall(CheckCell(dm, 0, transform, v0Ex, JEx, invJEx, detJEx, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } /* Cleanup */ PetscCall(DMDestroy(&dm)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TestHexahedron(MPI_Comm comm, PetscBool transform) { DM dm; PetscFunctionBegin; PetscCall(DMPlexCreateReferenceCell(comm, DM_POLYTOPE_HEXAHEDRON, &dm)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); /* Check reference geometry: determinant is scaled by reference volume 8.0 */ { PetscReal v0Ex[3] = {-1.0, -1.0, -1.0}; PetscReal JEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal invJEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; PetscReal centroidEx[3] = {0.0, 0.0, 0.0}; PetscReal normalEx[3] = {0.0, 0.0, 0.0}; PetscReal volEx = 8.0; PetscCall(CheckCell(dm, 0, transform, v0Ex, JEx, invJEx, detJEx, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } /* Cleanup */ PetscCall(DMDestroy(&dm)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TestHexahedronCurved(MPI_Comm comm) { DM dm; PetscScalar coords[24] = {-1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.1, 1.0, -1.0, 1.0, 1.0, 1.0, 1.1, -1.0, 1.0, 1.0}; PetscFunctionBegin; PetscCall(DMPlexCreateReferenceCell(comm, DM_POLYTOPE_HEXAHEDRON, &dm)); PetscCall(ChangeCoordinates(dm, 3, coords)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); { PetscReal centroidEx[3] = {0.0, 0.0, 0.016803278688524603}; PetscReal normalEx[3] = {0.0, 0.0, 0.0}; PetscReal volEx = 8.1333333333333346; PetscCall(CheckCell(dm, 0, PETSC_FALSE, NULL, NULL, NULL, 0.0, centroidEx, normalEx, volEx, NULL, NULL, NULL)); } PetscCall(DMDestroy(&dm)); PetscFunctionReturn(PETSC_SUCCESS); } /* This wedge is a tensor product cell, rather than a normal wedge */ static PetscErrorCode TestWedge(MPI_Comm comm, PetscBool transform) { DM dm; PetscFunctionBegin; PetscCall(DMPlexCreateReferenceCell(comm, DM_POLYTOPE_TRI_PRISM_TENSOR, &dm)); PetscCall(DMViewFromOptions(dm, NULL, "-dm_view")); /* Check reference geometry: determinant is scaled by reference volume 4.0 */ { #if 0 /* FEM geometry is not functional for wedges */ PetscReal v0Ex[3] = {-1.0, -1.0, -1.0}; PetscReal JEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal invJEx[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; PetscReal detJEx = 1.0; #endif { PetscReal centroidEx[3] = {-((PetscReal)1.) / ((PetscReal)3.), -((PetscReal)1.) / ((PetscReal)3.), 0.0}; PetscReal normalEx[3] = {0.0, 0.0, 0.0}; PetscReal volEx = 4.0; PetscReal faceVolEx[5] = {2.0, 2.0, 4.0, PETSC_SQRT2 * 4.0, 4.0}; PetscReal faceNormalEx[15] = {0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, PETSC_SQRT2 / 2.0, PETSC_SQRT2 / 2.0, 0.0, -1.0, 0.0, 0.0}; PetscReal faceCentroidEx[15] = {-((PetscReal)1.) / ((PetscReal)3.), -((PetscReal)1.) / ((PetscReal)3.), -1.0, -((PetscReal)1.) / ((PetscReal)3.), -((PetscReal)1.) / ((PetscReal)3.), 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0}; PetscCall(CheckCell(dm, 0, transform, NULL, NULL, NULL, 0.0, centroidEx, normalEx, volEx, faceCentroidEx, faceNormalEx, faceVolEx)); } } /* Cleanup */ PetscCall(DMDestroy(&dm)); PetscFunctionReturn(PETSC_SUCCESS); } int main(int argc, char **argv) { AppCtx user; PetscFunctionBeginUser; PetscCall(PetscInitialize(&argc, &argv, NULL, help)); PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user)); if (user.runType == RUN_REFERENCE) { PetscCall(TestTriangle(PETSC_COMM_SELF, user.transform)); PetscCall(TestQuadrilateral(PETSC_COMM_SELF, user.transform)); PetscCall(TestTetrahedron(PETSC_COMM_SELF, user.transform)); PetscCall(TestHexahedron(PETSC_COMM_SELF, user.transform)); PetscCall(TestWedge(PETSC_COMM_SELF, user.transform)); } else if (user.runType == RUN_HEX_CURVED) { PetscCall(TestHexahedronCurved(PETSC_COMM_SELF)); } else if (user.runType == RUN_FILE) { PetscInt dim, cStart, cEnd, c; PetscCall(DMGetDimension(user.dm, &dim)); PetscCall(DMPlexGetHeightStratum(user.dm, 0, &cStart, &cEnd)); for (c = 0; c < cEnd - cStart; ++c) { PetscReal *v0 = user.v0 ? &user.v0[c * dim] : NULL; PetscReal *J = user.J ? &user.J[c * dim * dim] : NULL; PetscReal *invJ = user.invJ ? &user.invJ[c * dim * dim] : NULL; PetscReal detJ = user.detJ ? user.detJ[c] : 0.0; PetscReal *centroid = user.centroid ? &user.centroid[c * dim] : NULL; PetscReal *normal = user.normal ? &user.normal[c * dim] : NULL; PetscReal vol = user.vol ? user.vol[c] : 0.0; PetscCall(CheckCell(user.dm, c + cStart, PETSC_FALSE, v0, J, invJ, detJ, centroid, normal, vol, NULL, NULL, NULL)); } PetscCall(PetscFree4(user.v0, user.J, user.invJ, user.detJ)); PetscCall(PetscFree(user.centroid)); PetscCall(PetscFree(user.normal)); PetscCall(PetscFree(user.vol)); PetscCall(DMDestroy(&user.dm)); } else if (user.runType == RUN_DISPLAY) { DM gdm, dmCell; Vec cellgeom, facegeom; const PetscScalar *cgeom; PetscInt dim, d, cStart, cEnd, cEndInterior, c; PetscCall(DMGetCoordinateDim(user.dm, &dim)); PetscCall(DMPlexConstructGhostCells(user.dm, NULL, NULL, &gdm)); if (gdm) { PetscCall(DMDestroy(&user.dm)); user.dm = gdm; } PetscCall(DMPlexComputeGeometryFVM(user.dm, &cellgeom, &facegeom)); PetscCall(DMPlexGetHeightStratum(user.dm, 0, &cStart, &cEnd)); PetscCall(DMPlexGetCellTypeStratum(user.dm, DM_POLYTOPE_FV_GHOST, &cEndInterior, NULL)); if (cEndInterior >= 0) cEnd = cEndInterior; PetscCall(VecGetDM(cellgeom, &dmCell)); PetscCall(VecGetArrayRead(cellgeom, &cgeom)); for (c = 0; c < cEnd - cStart; ++c) { PetscFVCellGeom *cg; PetscCall(DMPlexPointLocalRead(dmCell, c, cgeom, &cg)); PetscCall(PetscPrintf(PETSC_COMM_SELF, "Cell %4" PetscInt_FMT ": Centroid (", c)); for (d = 0; d < dim; ++d) { if (d > 0) PetscCall(PetscPrintf(PETSC_COMM_SELF, ", ")); PetscCall(PetscPrintf(PETSC_COMM_SELF, "%12.2g", (double)cg->centroid[d])); } PetscCall(PetscPrintf(PETSC_COMM_SELF, ") Vol %12.2g\n", (double)cg->volume)); } PetscCall(VecRestoreArrayRead(cellgeom, &cgeom)); PetscCall(VecDestroy(&cellgeom)); PetscCall(VecDestroy(&facegeom)); PetscCall(DMDestroy(&user.dm)); } PetscCall(PetscFinalize()); return 0; } /*TEST test: suffix: 1 args: -dm_view ascii::ascii_info_detail test: suffix: 2 args: -run_type hex_curved test: suffix: 3 args: -transform test: suffix: 4 requires: exodusii args: -run_type file -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/simpleblock-100.exo -dm_view ascii::ascii_info_detail -v0 -1.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,0.5 -J 0.0,0.0,0.5,0.0,0.5,0.0,-0.5,0.0,0.0,0.0,0.0,0.5,0.0,0.5,0.0,-0.5,0.0,0.0,0.0,0.0,0.5,0.0,0.5,0.0,-0.5,0.0,0.0 -invJ 0.0,0.0,-2.0,0.0,2.0,0.0,2.0,0.0,0.0,0.0,0.0,-2.0,0.0,2.0,0.0,2.0,0.0,0.0,0.0,0.0,-2.0,0.0,2.0,0.0,2.0,0.0,0.0 -detJ 0.125,0.125,0.125 -centroid -1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0 -normal 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 -vol 1.0,1.0,1.0 test: suffix: 5 args: -run_type file -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 3,1,1 -dm_plex_box_lower -1.5,-0.5,-0.5 -dm_plex_box_upper 1.5,0.5,0.5 -dm_view ascii::ascii_info_detail -centroid -1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0 -normal 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 -vol 1.0,1.0,1.0 test: suffix: 6 args: -run_type file -dm_plex_dim 1 -dm_plex_simplex 0 -dm_plex_box_faces 3 -dm_plex_box_lower -1.5 -dm_plex_box_upper 1.5 -dm_view ascii::ascii_info_detail -centroid -1.0,0.0,1.0 -vol 1.0,1.0,1.0 TEST*/
89f9ef7b1298d9b5705d38feb20ae29c48f71ba6
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/third_party/opus/src/src/mlp_data.c
ae4178df764ebde472ba24955dde9a5fae011846
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "BSD-3-Clause-Clear" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C
false
false
24,097
c
mlp_data.c
/*This file is automatically generated from a Keras model*/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "mlp.h" static const opus_int8 layer0_weights[800] = { -30, -9, 2, -12, 5, -1, 8, 9, 9, 8, -13, 18, -17, -34, -5, 17, -11, 0, -4, 10, 2, 10, 15, -8, 2, -1, 0, 5, 13, -3, -16, 1, -5, 3, 7, -28, -13, 6, 36, -3, 19, -60, -17, -28, 7, -11, -30, -7, 2, -42, -21, -3, 6, -22, 33, -9, 7, -30, 21, -14, 24, -11, -20, -18, -5, -12, 12, -49, -50, -49, 16, 9, -37, -1, 9, 34, -13, -31, -31, 12, 16, 44, -42, 2, -9, 8, -18, -6, 9, 36, 19, 11, 13, 12, -21, 3, -28, -12, 3, 33, 25, -14, 11, 1, -94, -39, 18, -12, -11, -15, -7, 49, 52, 10, -43, 9, 57, 8, 21, -6, 14, -15, 44, -8, 7, -30, -13, -2, -9, 25, -2, -127, 18, -11, -52, 26, -27, 27, 10, -10, 7, 43, 6, -24, 41, 10, -18, -27, 10, 17, 9, 10, -17, -10, 20, -6, 22, 55, 35, -80, 36, 25, -24, -36, 15, 9, -19, 88, 19, 64, -51, -35, 17, 0, -7, 41, -16, 27, 4, 15, -1, 18, -16, 47, -39, -54, -8, 13, -25, -20, 102, -18, -5, 44, 11, -28, 71, 2, -51, -5, 5, 2, -83, -9, -29, 8, 21, -53, 58, -37, -7, 13, 38, 9, 34, -1, -41, 21, 4, -24, -36, -33, -21, 32, 75, -2, 1, -68, -1, 47, -29, 32, 20, 12, -65, -87, 5, 16, -12, 24, 40, 15, 7, 19, -26, -17, 17, 6, -2, -37, -30, -9, 32, -127, -39, 0, -31, -27, 4, -22, 23, -6, -77, 35, -61, 32, -37, -24, 13, -11, -1, -40, -3, 17, -7, 13, 11, 59, -19, 10, 6, -18, 0, 13, 3, -6, -23, 19, 11, -17, 13, -1, -80, 40, -53, 69, -29, -54, 0, -4, 33, -25, -2, 38, 35, 36, -15, 46, 2, -13, -16, -8, -8, 12, -24, -9, -55, -5, -9, 32, 11, 7, 12, -18, -10, -86, -38, 54, 37, -25, 18, -43, 7, -27, -27, -54, 13, 9, 22, 70, 6, 35, -7, 23, -15, -44, -6, 7, -66, -85, 32, 40, -19, -9, -7, 12, -15, 7, 2, 6, -35, 11, 28, 0, 26, 14, 1, 1, 4, 12, 18, 35, 22, -18, -3, 14, -1, 7, 14, -8, -14, -3, 4, -3, -19, -7, -1, -25, -27, 25, -26, -2, 33, -22, -27, -25, 4, -9, 7, 21, 26, -30, 10, -9, -20, 11, 27, 10, 5, -18, 14, -4, 2, -17, -5, -7, -9, -13, 15, 29, 1, -10, -16, -10, 35, 36, -7, -22, -44, 17, 30, 22, 21, -1, 22, -11, 32, -8, -7, 5, -10, 5, 30, -20, 29, -20, -34, 12, -4, -6, 6, -13, 10, -5, -68, -1, 24, 9, 19, -24, -64, 31, 19, 27, -26, 75, -45, 41, 39, -42, 8, 6, 23, -30, 16, -25, 30, 34, 8, -38, -3, 18, 16, -31, 22, -4, -9, 1, 20, 9, 38, -32, 0, -45, 0, -6, -13, 11, -25, -32, -22, 31, -24, -11, -11, -4, -4, 20, -34, 22, 20, 9, -25, 27, -5, 28, -29, 29, 6, 21, -6, -18, 54, 4, -46, 23, 21, -14, -31, 36, -41, -24, 4, 22, 10, 11, 7, 36, -32, -13, -52, -17, 24, 28, -37, -36, -1, 24, 9, -38, 35, 48, 18, 2, -1, 45, 10, 39, 24, -38, 13, 8, -16, 8, 25, 11, 7, -29, -11, 7, 20, -30, -38, -45, 14, -18, -28, -9, 65, 61, 22, -53, -38, -16, 36, 46, 20, -39, 32, -61, -6, -6, -36, -33, -18, -28, 56, 101, 45, 11, -28, -23, -29, -61, 20, -47, 2, 48, 27, -17, 1, 40, 1, 3, -51, 15, 35, 28, 22, 35, 53, -61, -29, 12, -6, -21, 10, 3, -20, 2, -25, 1, -6, 31, 11, -3, 1, -10, -52, 6, 126, -105, 122, 127, -128, 127, 127, -128, 127, 108, 12, 127, 48, -128, -36, -128, 127, 127, -128, -128, 127, 89, -128, 127, -128, -128, -128, 127, 127, -128, -128, -93, -82, 20, 125, 65, -82, 127, 38, -74, 81, 88, -88, 79, 51, -47, -111, -26, 14, 83, -88, -112, 24, 35, -101, 98, -99, -48, -45, 46, 83, -60, -79, 45, -20, -41, 9, 4, 52, 54, 93, -10, 4, 13, 3, 123, 6, 94, -111, -69, -14, -31, 10, 12, 53, -79, -11, -21, -2, -44, -72, 92, 65, -57, 56, -38, 127, -56, -128, 127, 127, -128, 86, 117, -75, -128, 127, -19, -99, -112, 127, -128, 127, -48, 114, 118, -128, -128, 117, -17, -6, 121, -128, 127, -128, 82, 54, -106, 127, 127, -33, 100, -39, -23, 18, -78, -34, -29, -1, -30, 127, -26, 127, -128, 126, -128, 27, -23, -79, -120, -127, 127, 72, 66, 29, 7, -66, -56, -117, -128 }; static const opus_int8 layer0_bias[32] = { 51, -16, 1, 13, -5, -6, -16, -7, 11, -6, 106, 26, 28, -14, 21, -29, 7, 18, -18, -17, 21, -17, -9, 20, -25, -3, -34, 48, 11, -13, -31, -20 }; static const opus_int8 layer1_weights[2304] = { 22, -1, -7, 7, 29, -27, -31, -17, -13, 33, 44, -8, 11, 33, 24, 78, 15, 19, 30, -2, -24, 5, 49, 5, 36, 29, -14, -11, -48, -33, 21, -42, -38, -12, 55, -37, 54, -8, 1, 36, 17, 0, 51, 31, 59, 7, -12, 53, 4, 32, -14, 48, 5, -10, -16, -8, 1, -16, -56, -24, -6, 18, -2, 23, 6, 46, -6, -10, 20, 35, -44, -15, -49, 36, 16, 5, -7, -79, -67, 12, 70, -3, -79, -54, -85, -24, 47, -22, 33, 21, 69, -1, 11, 22, 14, -16, -16, -22, -28, -11, 11, -41, 31, -26, -33, -19, -4, 27, 32, -50, 5, -10, -38, -22, -8, 35, -31, 1, -41, -15, -11, 44, 28, -17, -41, -23, 17, 2, -23, -26, -13, -13, -17, 6, 14, -31, -25, 9, -19, 39, -8, 4, 31, -1, -45, -11, -28, -92, -46, -15, 21, 118, -22, 45, -51, 11, -20, -20, -15, 13, -21, -97, -29, -32, -23, -42, 94, 1, 23, -8, 63, -3, -46, 19, -26, 32, -40, -74, -26, 26, -4, -13, 30, -20, -30, -25, -14, -31, -45, -43, 4, -60, -48, -12, -34, 2, 2, 3, 13, 15, 11, 16, 5, 46, -9, -55, -16, -57, 29, 14, 38, -50, -2, -44, -11, -8, 52, -27, -38, -7, 20, 47, 17, -59, 0, 47, 46, -63, 35, -17, 19, 33, 68, -19, 2, 15, -16, 28, -16, -103, 26, -35, 47, -39, -60, 30, 31, -23, -52, -13, 116, 47, -25, 30, 40, 30, -22, 2, 12, -27, -18, 31, -10, 27, -8, -66, 12, 14, 4, -26, -28, -13, 3, 13, -26, -51, 37, 5, 2, -21, 47, 3, 13, 25, -41, -27, -8, -4, 5, -76, -33, 28, 10, 9, -46, -74, 19, 28, 25, 31, 54, -55, 68, 38, -24, -32, 2, 4, 68, 11, -1, 99, 5, 16, -2, -74, 40, 26, -26, 33, 31, -1, -68, 14, -6, 25, 9, 29, 60, 61, 7, -7, 0, -24, 7, 77, 4, -1, 16, -7, 13, -15, -19, 28, -31, -24, -16, 37, 24, 13, 30, 10, -30, 11, 11, -10, 22, 60, 28, 45, -3, -40, -62, -5, -102, 9, -32, -27, -54, 21, 15, -5, 37, -43, -11, 37, -19, 47, -64, -128, -27, -114, 21, -66, 59, 46, -3, -12, -87, -9, 4, 19, -113, -36, 78, 57, -26, -38, -77, -10, 6, 6, -75, 25, -97, -11, 33, -46, 1, 13, -21, -33, -20, 16, -6, -3, -11, -4, -27, 38, 8, -41, -2, -33, 18, 19, -26, 1, -29, -22, -4, -14, -55, -11, -80, -3, 11, 34, 90, 51, 11, 17, 43, 36, 127, -32, 29, 103, 9, 27, 13, 64, 56, 70, -14, 3, -12, 10, 37, 3, 12, -22, -10, 46, 28, 10, 20, 26, -24, 18, 9, 7, 14, 34, -5, -7, 31, -14, -56, 11, -18, -8, -17, -7, -10, -40, 10, -33, -32, -43, 5, 9, 11, -4, 10, 50, -12, -5, 46, 9, 7, 1, 11, 15, 91, -17, 7, -50, 23, 6, -30, -99, 0, -17, 14, 8, -10, -25, -30, -69, -62, 31, 127, 114, -23, 101, -5, -54, -6, -22, 7, -56, 39, 18, -29, 0, 46, 8, -79, 4, -21, 18, -32, 62, -12, -8, -12, -58, 31, -32, 17, 6, -24, 25, 24, 9, -4, -19, 45, 6, 17, -14, 5, -27, 16, -4, -41, 25, -36, 5, 15, 12, 50, 27, 25, 23, -44, -69, -9, -19, -48, -8, 4, 12, -6, 13, -19, -30, -36, 26, 37, -1, -3, -30, -42, -14, -10, -20, 26, -54, -27, -44, 4, 73, -26, 90, 32, -69, -29, -16, 3, 103, 15, -17, 37, 24, -23, -31, 33, -37, -64, 25, 13, -81, -28, -32, 27, 5, -35, -23, 15, -22, 19, -7, 9, 30, 19, -23, 27, -13, 43, 29, -29, -6, 9, -40, -33, -33, -32, 9, 11, -48, -8, -23, -52, 46, 17, -22, -42, 35, -15, -41, 16, 34, 31, -42, -19, -11, 55, 7, -39, 89, -11, -33, 20, -14, 22, 32, 3, -17, -6, 14, 34, 1, 55, -21, -90, -8, 18, 27, 13, -29, 21, 15, -33, -51, -9, -11, 4, -16, -18, 23, -4, -4, 48, 1, 7, 29, -14, -12, -16, 17, 35, 8, 0, -7, -2, 9, 8, 17, -6, 53, -32, -21, -50, 5, 99, -60, -5, -53, 10, -31, 12, -5, 7, 80, 36, 18, -31, 9, 98, 36, -63, -35, 4, -13, -28, -24, 28, -13, 18, 16, -1, -18, -34, 10, 20, 7, 4, 29, 11, 25, -7, 36, 14, 45, 24, 1, -16, 30, 6, 35, -6, -11, -24, 13, -1, 27, 39, 20, 48, -11, -4, -13, 28, 11, -31, -18, 31, -29, 22, -2, -20, -16, 5, 30, -12, -28, -3, 93, -16, 23, 18, -29, 6, -54, -37, 28, -3, -3, -47, -3, -36, -55, -3, 41, -10, 47, -2, 23, 42, -7, -71, -27, 83, -64, 7, -24, 8, 26, -17, 15, 12, 31, -30, -38, -13, -33, -56, 4, -17, 20, 18, 1, -30, -5, -6, -31, -14, -37, 0, 22, 10, -30, 37, -17, 18, 6, 5, 23, -36, -32, 14, 18, -13, -61, -52, -69, 44, -30, 16, 18, -4, -25, 14, 81, 26, -8, -23, -59, 52, -104, 17, 119, -32, 26, 17, 1, 23, 45, 29, -64, -57, -14, 73, 21, -13, -13, 9, -68, -7, -52, 3, 24, -39, 44, -15, 27, 14, 19, -9, -28, -11, 5, 3, -34, -2, 2, 22, -6, -23, 4, 3, 13, -22, -13, -10, -18, 29, 6, 44, -13, -24, -8, 2, 30, 14, 43, 6, 17, -73, -6, -7, 20, -80, -7, -7, -28, 15, -69, -38, -5, -100, -35, 15, -79, 23, 29, -18, -27, 21, -66, -37, 8, -22, -39, 48, 4, -13, 1, -9, 11, -29, 22, 6, -49, 32, -14, 47, -18, -4, 44, -52, -74, 43, 30, 23, -14, 5, 0, -27, 4, -7, 10, -4, 10, 1, -16, 11, -18, -2, -5, 2, -11, 0, -20, -4, 38, 74, 59, 39, 64, -10, 26, -3, -40, -68, 3, -30, -51, 8, -19, -27, -46, 51, 52, 54, 36, 90, 92, 14, 13, -5, 0, 16, -62, 16, 11, -47, -37, -6, -5, 21, 54, -57, 32, 42, -6, 62, -9, 16, 21, 24, 9, -10, -4, 33, 50, 13, -15, 1, -35, -48, 18, -11, -17, -67, -13, 21, 38, -44, 36, -16, 29, 17, 5, -10, 18, 17, -32, 2, 8, 22, -56, -15, -32, 40, 43, 19, 46, -7, -100, -96, 19, 53, 24, 21, -26, -48, -101, -82, 61, 38, -85, -28, -34, -1, 63, -5, -5, 39, 39, -38, 32, -12, -28, 20, 40, -8, 2, 31, 12, -35, -13, 20, -25, 30, 8, 3, -13, -9, -20, 2, -13, 24, 37, -10, 33, 6, 20, -16, -24, -6, -6, -19, -5, 22, 21, 10, 11, -4, -39, -1, 6, 49, 41, -15, -57, 21, -62, 77, -69, -13, 0, -74, 1, -7, -38, -8, 6, 63, 28, 4, 26, -52, 82, 63, 13, 45, -33, 44, -52, -65, -21, -46, -49, 64, -17, 32, 24, 68, -39, -16, -5, -26, 28, 5, -61, -28, 2, 24, 11, -12, -33, 9, -37, -3, -28, 22, -37, -12, 19, 0, -18, -2, 14, 1, 4, 8, -9, -2, 43, -17, -2, -66, -31, 56, -40, -87, -36, -2, -4, -42, -45, -1, 31, -43, -15, 27, 63, -11, 32, -10, -33, 27, -19, 4, 15, -26, -34, 29, -4, -39, -65, 14, -20, -21, -17, -36, 13, 59, 47, -38, -33, 13, -37, -8, -37, -7, -6, -76, -31, -12, -46, 7, 24, -21, -30, -14, 9, 15, -12, -13, 47, -27, -25, -1, -39, 0, 20, -9, 6, 7, 4, 3, 7, 39, 50, 22, -7, 14, -20, 1, 70, -28, 29, -41, 10, -16, -5, -28, -2, -37, 32, -18, 17, 62, -11, -20, -50, 36, 21, -62, -12, -56, 52, 50, 17, 3, 48, 44, -41, -25, 3, 16, -3, 0, 33, -6, 15, 27, 34, -25, 22, 9, 17, -11, 36, 16, -2, 12, 21, -52, 45, -2, -10, 46, 21, -18, 67, -28, -13, 30, 37, 42, 16, -9, 11, 75, 7, -64, -40, -10, 29, 57, -23, 5, 53, -77, 3, -17, -5, 47, -55, -35, -36, -13, 52, -53, -71, 52, -111, -23, -26, -28, 29, -43, 55, -19, 43, -19, 54, -12, -33, -44, -39, -19, -10, -31, -10, 21, 38, -57, -20, 2, -25, 8, -6, 50, 12, 15, 25, -25, 15, -30, -6, 9, 25, 37, 19, -4, 31, -22, 2, 4, 2, 36, 7, 3, -34, -80, 36, -10, -2, -5, 31, -36, 49, -70, 20, -36, 21, 24, 25, -46, -51, 36, -58, -48, -40, -10, 55, 71, 47, 10, -1, 1, 2, -46, -68, 16, 13, 0, -74, -29, 73, -52, -18, -11, 7, -44, -82, -32, -70, -28, -1, -39, -68, -6, -41, 12, -22, -16, 40, -11, -25, 51, -9, 21, 4, 4, -34, 7, -78, 16, 6, -38, -30, -2, -44, 32, 0, 22, 64, 5, -72, -2, -14, -10, -16, -8, -25, 12, 102, -58, 37, -10, -23, 15, 49, 7, -7, 2, -20, -32, 45, -6, 48, 28, 30, 33, -1, 22, -6, 30, 65, -17, 29, 74, 37, -26, -10, 15, -24, 19, -66, 22, -10, -31, -1, -18, -9, 11, 37, -4, 45, 5, 41, 17, 1, 1, 24, -58, 41, 5, -51, 14, 8, 43, 16, -10, -1, 45, 32, -64, 3, -33, -25, -3, -27, -68, 12, 23, -11, -13, -37, -40, 4, -21, -12, 32, -23, -19, 76, 41, -23, -24, -44, -65, -1, -15, 1, 71, 63, 5, 20, -3, 21, -23, 31, -32, 18, -2, 27, 31, 46, -5, -39, -5, -35, 18, -18, -40, -10, 3, 12, 2, -2, -22, 40, 5, -6, 60, 36, 3, 29, -27, 10, 25, -54, 5, 26, 39, 35, -24, -37, 30, -91, 28, -4, -21, -27, -39, -6, 5, 12, -128, 38, -16, 29, -95, -29, 82, -2, 35, 2, 12, 8, -22, 10, 80, -47, 2, -25, -73, -79, 16, -30, -32, -66, 48, 21, -45, -11, -47, 14, -27, -17, -7, 15, -44, -14, -44, -26, -32, 26, -23, 17, -7, -28, 26, -6, 28, 6, -26, 2, 13, -14, -23, -14, 19, 46, 16, 2, -33, -21, 28, -17, -42, 44, -37, 1, -39, 28, 84, -46, 15, 10, 13, -44, 72, -26, 26, 32, -28, -12, -83, 2, 10, -30, -44, -10, -28, 53, 45, 65, 0, -25, 57, 36, -33, 6, 29, 44, -53, 11, 19, -2, -27, 35, 32, 49, 4, 23, 38, 36, 24, 10, 51, -39, 4, -7, 26, 37, -35, 11, -47, -18, 28, 16, -35, 42, 17, -21, -41, 28, 14, -12, 11, -45, 7, -43, -15, 18, -5, 38, -40, -50, -30, -21, 9, -98, 13, 12, 23, 75, -56, -7, -3, -4, -1, -34, 12, -49, 11, 26, -18, -28, -17, 33, 13, -14, 40, 24, -72, -37, 10, 17, -6, 22, 16, 16, -6, -12, -30, -14, 10, 40, -23, 12, 15, -3, -15, 13, -56, -4, -30, 1, -3, -17, 27, 50, -5, 64, -36, -19, 7, 29, 22, 25, 9, -16, -58, -69, -40, -61, -71, -14, 42, 93, 26, 11, -6, -58, -11, 70, -52, 19, 9, -30, -33, 11, -37, -47, -21, -22, -40, 10, 47, 4, -23, 17, 48, 41, -48, 14, 10, 15, 34, -23, -2, -47, 23, -32, -13, -10, -26, -26, -4, 16, 38, -14, 0, -12, -7, -7, 20, 44, -1, -32, -27, -16, 4, -6, -18, 14, 5, 4, -29, 28, 7, -7, 15, -11, -20, -45, -36, 16, 84, 34, -59, -30, 22, 126, 8, 68, 79, -17, 21, -68, 37, 5, 15, 63, 49, 127, -90, 85, 43, 7, 16, 9, 6, -45, -57, -43, 57, 11, -23, -11, -29, 60, -26, 0, 7, 42, -24, 10, 23, -25, 8, -7, -40, 19, -17, 35, 4, 27, -39, -91, 27, -36, 34, 2, 16, -24, 25, 7, -21, 5, 17, 10, -22, -30, 9, -17, -61, -26, 33, 21, 58, -51, -14, 69, -38, 20, 7, 80, -4, -65, -6, -27, 53, -12, 47, -1, -15, 1, 60, 102, -79, -4, 12, 9, 22, 37, -8, -4, 37, 2, -3, -15, -16, -11, -5, 19, -6, -43, 20, -25, -18, 10, -27, 0, -28, -27, -11, 10, -18, -2, -4, -16, 26, 14, -6, 7, -6, 1, 53, -2, -29, 23, 9, -30, -6, -4, -6, 56, 70, 0, -33, -20, -17, -9, -24, 46, -5, -105, 47, -46, -51, 20, 20, -53, -81, -1, -7, 75, -5, -21, -65, 12, -52, 22, -50, -12, 49, 54, 76, -81, 10, 45, -41, -59, 18, -19, 25, 14, -31, -53, -5, 12, 31, 84, -23, 2, 7, 2, 10, -32, 39, -2, -12, 1, -9, 0, -10, -11, 9, 15, -8, -2, 2, -1, 10, 14, -5, -40, 19, -7, -7, 26, -4, 2, 1, -27, 35, 32, 21, -31, 26, 43, -9, 4, -32, 40, -62, -52, 36, 22, 38, 22, 36, -96, 6, -10, -23, -49, 15, -33, -18, -3, 0, 41, 21, -19, 21, 23, -39, -23, -6, 6, 47, 56, 4, 74, 0, -98, 29, -47, -14, -36, 21, -22, 22, 16, 13, 12, 16, -5, 13, 17, -13, -15, 1, -34, -26, 26, 12, 32, 27, 13, -67, 27, 2, 8, 10, 18, 16, 20, -17, -17, 57, -64, 5, 14, 19, 31, -18, -44, -46, -16, 4, -25, 17, -126, -24, 39, 4, 8, 55, -25, -34, 39, -16, 3, 9, 71, 72, -31, -55, 6, 10, -25, 32, -85, -21, 18, -8, 15, 12, -27, -7, 1, -21, -2, -5, 48, -16, 18, 1, -22, -26, 16, 14, -31, 27, -6, -15, -21, 4, -14, 18, -36 }; static const opus_int8 layer1_recur_weights[1728] = { 20, 67, -99, 12, 41, -25, 49, -44, 35, 81, 110, 47, 34, -66, -14, 14, -60, 34, 29, -73, 10, 41, 35, 89, 7, -35, 22, 7, 27, -20, -6, 56, 26, 66, 6, 33, -55, 53, 1, -21, 14, 17, 68, 55, 59, 0, 18, -9, 5, -41, 6, -5, -114, -12, 29, 42, -23, 10, 81, -27, 20, -53, -30, -62, 40, 95, 25, -4, 3, 18, -8, -15, -29, -82, 2, -57, -3, -61, -29, -29, 49, 2, -55, 5, -69, -99, -49, -51, 6, -25, 12, 89, 44, -33, 5, 41, 1, 23, -37, -37, -28, -48, 3, 4, -41, -30, -57, -35, -39, -1, -13, -56, -5, 50, 49, 41, -4, -4, 33, -22, -1, 33, 34, 18, 40, -42, 12, 1, -6, -2, 18, 17, 39, 44, 11, 65, -60, -45, 10, 91, 21, 9, -62, -11, 8, 69, 37, 24, -30, 21, 26, -27, 1, -28, 24, 66, -8, 6, -71, 34, 24, 44, 58, -78, -19, 57, 17, -60, 1, 12, -3, -1, -40, 22, 11, -5, 25, 12, 1, 72, 79, 7, -50, 23, 18, 13, 21, -11, -20, 5, 77, -94, 24, 15, 57, -51, 3, 36, 53, -1, 4, 14, 30, -31, 22, 40, 32, -11, -34, -36, -59, 58, 25, 21, -54, -23, 40, 46, 18, 0, 12, 54, -96, -99, -59, 5, 119, -38, 50, 55, 12, -16, 67, 0, 34, 35, 39, 35, -1, 69, 24, 27, -30, -35, -4, -70, 2, -44, -7, -6, 19, -9, 60, 44, -21, -10, 37, 43, -16, -3, 30, -15, -65, 31, -55, 18, -98, 76, 64, 25, 24, -18, -7, -68, -10, 38, 27, -60, 36, 33, 16, 30, 34, -39, -37, 31, 12, 53, -54, 14, -26, -49, -128, -13, -5, -22, -11, -85, 55, -8, -51, -11, -33, -10, -31, -76, -41, 23, 44, -40, -54, -127, -101, 19, -23, -15, 15, 27, 58, -60, 8, 14, -33, 1, 48, -9, -11, -123, 3, 53, 23, 4, -28, 22, 2, -29, -67, 36, 12, 7, 55, -21, 88, 20, -1, -21, -17, 3, 41, 32, -10, -14, -5, -57, 67, 57, 21, 23, -2, -27, -73, -24, 120, 21, 18, -35, 42, -7, 3, -45, -25, 76, -34, 50, 11, -54, -91, 3, -113, -20, -5, 47, 15, -47, 17, 27, -3, -26, -7, 10, 7, 74, -40, 64, -7, -5, -24, -49, -24, -3, -10, 27, -17, -8, -3, 14, -27, 33, 13, 39, 28, -7, -38, 29, 16, 44, 19, 55, -3, 9, -13, -57, 43, 43, 31, 0, -93, -17, 19, -56, 4, -12, -25, 37, -85, -13, -118, 33, -17, 56, 71, -80, -4, 6, -11, -18, 47, -52, 25, 9, 48, -107, 1, 21, 20, -3, 10, -16, -4, 24, 17, 31, -61, -18, -50, 24, -10, 12, 71, 26, 11, -3, 4, 1, 0, -7, -40, 18, 38, -34, 38, 17, 8, -34, 2, 21, 123, -32, -26, 43, 14, -34, -1, -9, 37, -16, 6, -17, -62, 68, 22, 17, 11, -75, 33, -80, 62, -9, -75, 76, 36, -41, -8, -40, -11, -71, 40, -39, 62, -49, -81, 16, -9, -52, 52, 61, 17, -103, -27, -10, -8, -54, -57, 21, 23, -16, -52, 36, 18, 10, -5, 8, 15, -29, 5, -19, -37, 8, -53, 6, 19, -37, 38, -17, 48, 10, 0, 81, 46, 70, -29, 101, 11, 44, -44, -3, 24, 11, 3, 14, -9, 11, 14, -45, 13, 46, -3, -57, 68, 44, 63, 98, 25, -28, -23, 15, 32, -10, 53, -6, -2, -9, -6, 16, -107, -11, -11, -28, 59, 57, -22, 38, 42, 83, 27, 5, 29, -30, 12, -21, -13, 31, 38, -21, 58, -10, -10, -15, -2, -5, 11, 12, -73, -28, -38, 22, 2, -25, 73, -52, -12, -55, 32, -63, 21, 51, 33, 52, -26, 55, -26, -26, 57, -32, -4, -52, -61, 21, -33, -91, -51, 69, -90, -53, -38, -44, 12, -76, -20, 77, -45, -7, 86, 43, -109, -33, -105, -40, -121, -10, 0, -72, 45, -51, -75, -49, -38, -1, -62, 18, -1, 30, -44, -14, -10, -67, 40, -10, -34, 46, -64, -32, 29, -13, 33, 3, -32, -5, 28, -27, -25, 93, 24, 68, -40, 57, 23, -3, -21, -58, 17, -39, -17, -22, -89, 11, 18, -46, 27, 24, 46, 127, 61, 87, 31, 127, -36, 47, -23, 47, 127, -24, 110, 122, 30, 100, 0, 96, -12, 6, 50, 44, -13, 73, 4, 55, -11, -15, 49, 42, -6, 20, -35, 58, 18, 38, 42, 72, 19, -21, 11, 9, -37, 7, 29, 31, 16, -17, 13, -50, 19, 5, -23, 51, -16, -5, 4, -24, 76, 10, -53, -28, -7, -65, 74, 40, -16, -29, 32, -16, -49, -35, -3, 59, -96, -50, -43, -43, -61, -15, -8, -36, -34, -33, -14, 11, -3, -39, 4, -114, -123, -11, -49, -21, 14, -56, 1, 43, -63, 26, 40, 18, -10, -26, -14, -15, -35, -35, -11, 32, -44, -67, 2, 22, 7, 3, -9, -30, -51, -28, 28, 6, -22, 16, 34, -25, -52, -54, -8, -6, 5, 8, 20, -16, -17, -44, 27, 3, 31, -5, -48, -1, -3, 116, 11, 71, -31, -47, 109, 50, -22, -12, -57, 32, 66, 8, -25, -93, -54, -10, 19, -76, -34, 97, 48, -36, -18, -30, -39, -26, -12, 28, 14, 12, -12, -31, 38, 2, 10, 4, -40, 20, 16, -61, 2, 64, 39, 5, 15, 33, 40, -61, -49, 93, -10, 33, 28, -11, -27, -18, 39, -62, -6, -6, 62, 11, -8, 38, -67, 12, 27, 39, -27, 123, -18, -6, -65, 83, -64, 20, 19, -11, 33, 24, 17, 56, 78, 7, -15, 54, -101, -9, 115, -96, 50, 51, 35, 34, 27, 37, -40, -11, 8, -36, 42, -45, 2, -23, 0, 67, -8, -9, -13, 50, -14, -27, 4, 0, -8, -14, 30, -9, 29, 15, 9, -38, 37, -8, 50, -46, 54, 41, -11, -8, -11, -26, 39, 45, 14, -26, -17, -27, 69, 38, 39, 98, 66, 0, 42, 123, -101, -19, -83, 117, -32, 56, 10, 12, -88, 79, -53, 56, 63, 95, -62, 9, 36, -13, -79, -16, 37, -46, 35, -34, 14, 17, -54, 5, 21, -7, 7, 63, 56, 15, 27, -76, -25, 4, -26, -63, 28, -67, -52, 43, -47, -70, 40, -12, 40, -66, -37, 0, 35, 37, -53, 4, -17, -51, 11, 21, 14, -34, -4, 24, -42, 29, 22, 7, 28, 12, 37, 39, -39, -19, 65, -60, -50, -2, 1, 82, 39, 19, -23, -43, -22, -67, -35, -34, 32, 102, 81, 127, 36, 67, -45, 1, -67, -52, -4, 35, 20, 28, 71, 86, -35, -9, -83, -34, 12, 9, -23, 2, 14, 28, -23, 7, -25, 45, 7, 17, -37, 0, -19, 31, 26, 40, -27, -16, 17, 5, -21, 23, 24, 96, -55, 52, -19, -14, -6, 1, 50, -34, 86, -53, 38, 2, -52, -36, -13, 60, -85, -120, 32, 7, -12, 22, 70, -7, -94, 38, -76, -31, -20, 15, -28, 7, 6, 40, 53, 88, 3, 38, 18, -8, -22, -23, 51, 37, -9, 13, -32, 25, -21, 27, 31, 20, 18, -9, -13, 1, 21, -24, -13, 39, 15, -11, -29, -36, 18, 15, 8, 27, 21, -94, -1, -22, 49, 66, -1, 6, -3, -40, -18, 6, 28, 12, 33, -59, 62, 60, -48, 90, -1, 108, 9, 18, -2, 27, 77, -65, 82, -48, -38, -19, -11, 127, 50, 66, 18, -13, -22, 60, -38, 40, -14, -26, -13, 38, 67, 57, 30, 33, 26, 36, 38, -17, 27, -28, 20, 12, -64, 18, 5, -33, -27, 13, -26, 32, 35, -5, -48, -14, 92, 43, -47, -14, 40, 11, 51, 66, 22, -63, -16, -61, 4, -28, 27, 20, -33, -30, -21, -29, -53, 31, -40, 24, 43, -4, -19, 21, 67, 20, 100, -16, -93, 78, -6, -18, -52, -37, -9, 66, -31, -8, 26, 18, 4, 24, -22, 17, -2, -13, 27, 0, 8, -18, -25, 5, -21, -24, -7, 18, -93, 21, 7, 2, -75, 69, 50, -5, -15, -17, 60, -42, 55, 1, -4, 3, 10, 46, 16, -13, 45, -7, -10, -44, -108, 49, 2, -15, -64, -12, -72, 32, -38, -45, 10, -54, 13, -13, -27, -36, -64, 58, -62, -101, 88, -86, -71, -39, -9, -128, 32, 15, -4, 54, -16, -39, -26, -36, 46, 48, -64, -10, 19, 30, -13, 34, -8, 50, 60, -22, -6, -11, -30, 5, 50, 32, 56, 0, 25, 6, 68, 11, -29, 45, -9, -12, 4, 1, 18, -49, 0, -38, -19, 90, 29, 35, 51, 8, -48, 96, -1, -12, -9, -32, -63, -65, -7, 38, 89, 28, -85, -28, -23, -25, -128, 56, 79, -36, 99, -6, -37, 7, -13, -69, -46, -29, 25, 64, -21, 17, 1, 42, -66, 1, 80, 26, -32, 21, 15, 15, 6, 6, -10, 15, 127, 5, 38, 27, 87, -57, -25, 11, 72, -21, -5, 11, -13, -66, 78, 36, -3, 41, -21, 8, -33, 23, 73, 28, 57, -25, -5, 4, -22, -47, 15, 4, -57, -72, 33, 1, 18, 2, 53, -71, -99, -21, -3, -111, 108, 71, -14, 82, 25, 61, -48, 5, 9, -51, -20, -25, -3, 14, -33, 14, -3, -34, 22, 12, -19, -38, -16, 2, 21, 16, 26, -31, 75, 44, -31, 16, 26, 66, 17, -9, -22, -22, 22, -44, 22, 27, 2, 58, -14, 10, -73, -42, 55, -25, -61, 72, -1, 30, -58, -25, 63, 26, -48, -40, 26, -30, 60, 8, -17, -1, -18, -20, 43, -20, -4, -28, 127, -106, 29, 70, 64, -27, 39, -33, -5, -88, -40, -52, 26, 44, -17, 23, 2, -49, 22, -9, -8, 86, 49, -43, -60, 1, 10, 45, 36, -53, -4, 33, 38, 48, -72, 1, 19, 21, -65, 4, -5, -62, 27, -25, 17, -6, 6, -45, -39, -46, 4, 26, 127, -9, 18, -33, -18, -3, 33, 2, -5, 15, -26, -22, -117, -63, -17, -59, 61, -74, 7, -47, -58, -128, -67, 15, -16, -128, 12, 2, 20, 9, -48, -40, 43, 3, -40, -16, -38, -6, -22, -28, -16, -59, -22, 6, -5, 11, -12, -66, -40, 27, -62, -44, -19, 38, -3, 39, -8, 40, -24, 13, 21, 50, -60, -22, 53, -29, -6, 1, 22, -59, 0, 17, -39, 115 }; static const opus_int8 layer1_bias[72] = { -42, 20, 16, 0, 105, 60, 1, -97, 24, 60, 18, 13, 62, 25, 127, 34, 79, 55, 118, 127, 95, 31, -4, 87, 21, 12, 2, -14, 18, 23, 8, 17, -1, -8, 5, 4, 24, 37, 21, 13, 36, 13, 17, 18, 37, 30, 33, 1, 8, -16, -11, -5, -31, -3, -5, 0, 6, 3, 58, -7, -1, -16, 5, -13, 16, 10, -2, -14, 11, -4, 3, -11 }; static const opus_int8 layer2_weights[48] = { -113, -88, 31, -128, -126, -61, 85, -35, 118, -128, -61, 127, -128, -17, -128, 127, 104, -9, -128, 33, 45, 127, 5, 83, 84, -128, -85, -128, -45, 48, -53, -128, 46, 127, -17, 125, 117, -41, -117, -91, -127, -68, -1, -89, -80, 32, 106, 7 }; static const opus_int8 layer2_bias[2] = { 14, 117 }; const DenseLayer layer0 = { layer0_bias, layer0_weights, 25, 32, 0 }; const GRULayer layer1 = { layer1_bias, layer1_weights, layer1_recur_weights, 32, 24 }; const DenseLayer layer2 = { layer2_bias, layer2_weights, 24, 2, 1 };
fb39e4d7a9af526ca831cfb32dd5188863ba407a
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/sys/arch/hpcsh/include/setjmp.h
52283518169fe2445ce13f435daff177d5f10977
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
166
h
setjmp.h
/* $NetBSD: setjmp.h,v 1.2 2001/01/28 03:31:32 uch Exp $ */ #ifndef _HPCSH_SETJMP_H_ #define _HPCSH_SETJMP_H_ #include <sh3/setjmp.h> #endif /* _HPCSH_SETJMP_H_ */
649f4fe8d4fda54168fc02e5cf12de0745385b47
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/apollo2/board/smbus.c
7437b68ffa3027a2f47ad30af443fbca1693a829
[ "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
5,682
c
smbus.c
/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2017-12-04 Haley the first version */ #include <rtthread.h> #include <rtdevice.h> #include "am_mcu_apollo.h" #ifdef RT_USING_SMBUS #define SMBUS_GPIO_SDA 5 #define SMBUS_GPIO_SCL 6 #define mSDA_LOW() am_hal_gpio_out_bit_clear(SMBUS_GPIO_SDA) /* Clear SDA line */ #define mSDA_HIGH() am_hal_gpio_out_bit_set(SMBUS_GPIO_SDA) /* Set SDA line */ #define mSCL_LOW() am_hal_gpio_out_bit_clear(SMBUS_GPIO_SCL) /* Clear SCL line */ #define mSCL_HIGH() am_hal_gpio_out_bit_set(SMBUS_GPIO_SCL) /* Set SCL line */ #define mSDA_READ() am_hal_gpio_input_bit_read(SMBUS_GPIO_SDA) /* Read SDA line */ #define mSDA_IN() am_hal_gpio_pin_config(SMBUS_GPIO_SDA, AM_HAL_GPIO_INPUT | AM_HAL_GPIO_PULL6K) /* Set SDA as Input */ #define mSDA_OUT() am_hal_gpio_pin_config(SMBUS_GPIO_SDA, AM_HAL_GPIO_OUTPUT) /* Set SDA as Output */ #define mSCL_OUT() am_hal_gpio_pin_config(SMBUS_GPIO_SCL, AM_HAL_GPIO_OUTPUT) /* Set SCL as Output */ #define ACK 0 #define NACK 1 /* SCL keep time */ static void keep_delay(void) { int i; for(i = 0; i < 30; i++) __nop(); } static void few_delay(void) { __nop(); __nop(); } static rt_uint8_t am_smbus_send_bit(rt_uint8_t send_bit) { mSDA_OUT(); few_delay(); if(send_bit) /* Send a bit */ mSDA_HIGH(); else mSDA_LOW(); mSCL_HIGH(); /* High Level of Clock Pulse */ keep_delay(); mSCL_LOW(); keep_delay(); return 0; } static rt_uint8_t am_smbus_read_bit(void) { rt_uint8_t read_bit; mSDA_IN(); few_delay(); mSCL_HIGH(); /* High Level of Clock Pulse */ keep_delay(); read_bit = mSDA_READ(); /* Read a bit, save it in Read_bit */ mSCL_LOW(); keep_delay(); return read_bit; } static void am_smbus_start_bit(void) { mSDA_OUT(); mSDA_HIGH(); /* Generate bus free time between Stop */ keep_delay(); mSCL_HIGH(); keep_delay(); mSDA_LOW(); /* Hold time after (Repeated) Start */ keep_delay(); mSCL_LOW(); keep_delay(); } static void am_smbus_stop_bit(void) { mSDA_OUT(); mSDA_HIGH(); /* Generate bus free time between Stop */ keep_delay(); mSCL_LOW(); keep_delay(); mSDA_LOW(); /* Hold time after Stop */ keep_delay(); mSCL_HIGH(); /* For sleep mode(SCL needs to be high during Sleep.) */ keep_delay(); } static rt_uint8_t am_smbus_tx_byte(rt_uint8_t tx_byte) { int i; rt_uint8_t ack_bit; rt_uint8_t bit_out; for(i = 0; i < 8; i++) { if(tx_byte&0x80) bit_out = 1; /* If the current bit of Tx_buffer is 1 set bit_out */ else bit_out = 0; /* else clear bit_out */ am_smbus_send_bit(bit_out); /* Send the current bit on SDA */ tx_byte <<= 1; /* Get next bit for checking */ } ack_bit = am_smbus_read_bit(); /* Get acknowledgment bit */ return ack_bit; } static rt_uint8_t am_smbus_rx_byte(rt_uint8_t ack_nack) { int i; rt_uint8_t rx_byte; for(i = 0; i < 8; i++) { if(am_smbus_read_bit()) /* Get a bit from the SDA line */ { rx_byte <<= 1; /* If the bit is HIGH save 1 in RX_buffer */ rx_byte |=0x01; } else { rx_byte <<= 1; /* If the bit is LOW save 0 in RX_buffer */ rx_byte &=0xfe; } } am_smbus_send_bit(ack_nack); /* Sends acknowledgment bit */ return rx_byte; } rt_uint8_t am_smbus_tx_then_tx(rt_uint8_t SlaveAddress, rt_uint8_t command, rt_uint8_t* pBuffer, rt_uint16_t bytesNumber) { int i; am_smbus_start_bit(); /* Start condition */ if(am_smbus_tx_byte(SlaveAddress)) /* Send SlaveAddress and write */ return 1; if(am_smbus_tx_byte(command)) /* Send command */ return 1; for(i = 0; i < bytesNumber; i++) { am_smbus_tx_byte(pBuffer[i]); /* Write data, slave must send ACK */ } am_smbus_stop_bit(); /* Stop condition */ return 0; } rt_uint8_t am_smbus_tx_then_rx(rt_uint8_t SlaveAddress, rt_uint8_t command, rt_uint8_t* pBuffer, rt_uint16_t bytesNumber) { int i; am_smbus_start_bit(); /* Start condition */ if(am_smbus_tx_byte(SlaveAddress)) /* Send SlaveAddress and write */ return 1; if(am_smbus_tx_byte(command)) /* Send command */ return 1; am_smbus_start_bit(); /* Repeated Start condition */ if(am_smbus_tx_byte(SlaveAddress | 0x01)) /* Send SlaveAddress and read */ return 1; for(i = 0; i < bytesNumber; i++) { pBuffer[i] = am_smbus_rx_byte(ACK); /* Read data, master must send ACK */ } am_smbus_stop_bit(); /* Stop condition */ return 0; } void am_smbus_scl_high(void) { mSCL_HIGH(); /* For sleep mode(SCL needs to be high during Sleep.) */ keep_delay(); } void am_smbus_scl_low(void) { mSCL_LOW(); /* For sleep mode(SCL needs to be high during Sleep.) */ keep_delay(); } int rt_hw_smbus_init(void) { mSDA_OUT(); mSCL_OUT(); mSDA_HIGH(); /* bus free */ mSCL_HIGH(); return 0; } #ifdef RT_USING_COMPONENTS_INIT INIT_BOARD_EXPORT(rt_hw_smbus_init); #endif #endif /*@}*/
e4203223b60ed8b38254caade511bb6f1c1c6547
e22fd36933c9114a9df1694e7a6274bf059de2a6
/third_party/acados/acados_template/c_templates_tera/matlab_templates/main_mex.in.c
851a3cc04f6fd3eb56ded446b9b7c836a2850618
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
commaai/openpilot
66dfb7f31290bc8f58c9ead95d56697a52b45afb
a0b49d54222c52ff0112c402bc0e0d9262e77a66
refs/heads/master
2023-09-05T21:34:14.076796
2023-09-05T21:15:18
2023-09-05T21:15:18
74,627,617
46,071
9,878
MIT
2023-09-14T21:51:23
2016-11-24T01:33:30
Python
UTF-8
C
false
false
6,070
c
main_mex.in.c
/* * Copyright (c) The acados authors. * * This file is part of acados. * * The 2-Clause BSD License * * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.; */ // standard #include <stdio.h> #include <stdlib.h> // acados #include "acados/utils/print.h" #include "acados/utils/math.h" #include "acados_c/ocp_nlp_interface.h" #include "acados_solver_{{ model.name }}.h" // mex #include "mex.h" /* auxilary mex */ // prints a matrix in column-major format (exponential notation) void MEX_print_exp_mat(int m, int n, double *A, int lda) { for (int i=0; i<m; i++) { for (int j=0; j<n; j++) { mexPrintf("%e\t", A[i+lda*j]); } mexPrintf("\n"); } mexPrintf("\n"); } // prints the transposed of a matrix in column-major format (exponential notation) void MEX_print_exp_tran_mat(int row, int col, double *A, int lda) { for (int j=0; j<col; j++) { for (int i=0; i<row; i++) { mexPrintf("%e\t", A[i+lda*j]); } mexPrintf("\n"); } mexPrintf("\n"); } void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int status = 0; status = {{ model.name }}_acados_create(); if (status) { mexPrintf("{{ model.name }}_acados_create() returned status %d. Exiting.\n", status); exit(1); } // get pointers to nlp solver related objects ocp_nlp_config *nlp_config = {{ model.name }}_acados_get_nlp_config(); ocp_nlp_dims *nlp_dims = {{ model.name }}_acados_get_nlp_dims(); ocp_nlp_in *nlp_in = {{ model.name }}_acados_get_nlp_in(); ocp_nlp_out *nlp_out = {{ model.name }}_acados_get_nlp_out(); ocp_nlp_solver *nlp_solver = {{ model.name }}_acados_get_nlp_solver(); void *nlp_opts = {{ model.name }}_acados_get_nlp_opts(); // initial condition int idxbx0[{{ dims.nbx_0 }}]; {% for i in range(end=dims.nbx_0) %} idxbx0[{{ i }}] = {{ constraints.idxbx_0[i] }}; {%- endfor %} double lbx0[{{ dims.nbx_0 }}]; double ubx0[{{ dims.nbx_0 }}]; {% for i in range(end=dims.nbx_0) %} lbx0[{{ i }}] = {{ constraints.lbx_0[i] }}; ubx0[{{ i }}] = {{ constraints.ubx_0[i] }}; {%- endfor %} ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "idxbx", idxbx0); ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "lbx", lbx0); ocp_nlp_constraints_model_set(nlp_config, nlp_dims, nlp_in, 0, "ubx", ubx0); // initialization for state values double x_init[{{ dims.nx }}]; {%- for i in range(end=dims.nx) %} x_init[{{ i }}] = 0.0; {%- endfor %} // initial value for control input double u0[{{ dims.nu }}]; {%- for i in range(end=dims.nu) %} u0[{{ i }}] = 0.0; {%- endfor %} // prepare evaluation int NTIMINGS = 10; double min_time = 1e12; double kkt_norm_inf; double elapsed_time; int sqp_iter; double xtraj[{{ dims.nx }} * ({{ dims.N }}+1)]; double utraj[{{ dims.nu }} * ({{ dims.N }})]; // solve ocp in loop for (int ii = 0; ii < NTIMINGS; ii++) { // initialize primal solution for (int i = 0; i <= nlp_dims->N; i++) { ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "x", x_init); ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, i, "u", u0); } status = {{ model.name }}_acados_solve(); ocp_nlp_get(nlp_config, nlp_solver, "time_tot", &elapsed_time); min_time = MIN(elapsed_time, min_time); } /* print solution and statistics */ for (int ii = 0; ii <= nlp_dims->N; ii++) ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "x", &xtraj[ii*{{ dims.nx }}]); for (int ii = 0; ii < nlp_dims->N; ii++) ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, ii, "u", &utraj[ii*{{ dims.nu }}]); mexPrintf("\n--- xtraj ---\n"); MEX_print_exp_tran_mat( {{ dims.nx }}, {{ dims.N }}+1, xtraj, {{ dims.nx }} ); mexPrintf("\n--- utraj ---\n"); MEX_print_exp_tran_mat( {{ dims.nu }}, {{ dims.N }}, utraj, {{ dims.nu }} ); mexPrintf("\nsolved ocp %d times, solution printed above\n\n", NTIMINGS); if (status == ACADOS_SUCCESS) mexPrintf("{{ model.name }}_acados_solve(): SUCCESS!\n"); else mexPrintf("{{ model.name }}_acados_solve() failed with status %d.\n", status); // get solution ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "kkt_norm_inf", &kkt_norm_inf); ocp_nlp_get(nlp_config, nlp_solver, "sqp_iter", &sqp_iter); mexPrintf("\nSolver info:\n"); mexPrintf(" SQP iterations %2d\n minimum time for 1 solve %f [ms]\n KKT %e\n", sqp_iter, min_time*1000, kkt_norm_inf); // free solver status = {{ model.name }}_acados_free(); if (status) { mexPrintf("{{ model.name }}_acados_free() returned status %d.\n", status); } return; }
8d098022148850376270b55d295c2c3b0c2a2825
88ae8695987ada722184307301e221e1ba3cc2fa
/native_client/tests/irt_ext/libc/libc_test.h
a75971d83e5595e86163b9839b6ec589a4f29d75
[ "BSD-3-Clause", "Zlib", "Classpath-exception-2.0", "BSD-Source-Code", "LZMA-exception", "LicenseRef-scancode-unicode", "LGPL-3.0-only", "LGPL-2.0-or-later", "LicenseRef-scancode-philippe-de-muyter", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-intel-osl-1993", "HPND-sell-variant", "ICU", "LicenseRef-scancode-protobuf", "bzip2-1.0.6", "Spencer-94", "NCSA", "LicenseRef-scancode-nilsson-historical", "CC0-1.0", "LicenseRef-scancode-proprietary-license", "LGPL-2.1-only", "LicenseRef-scancode-other-copyleft", "GPL-2.0-or-later", "NTP", "GPL-2.0-only", "LicenseRef-scancode-other-permissive", "GPL-3.0-only", "GFDL-1.1-only", "W3C", "LicenseRef-scancode-python-cwi", "GCC-exception-3.1", "BSL-1.0", "Python-2.0", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LicenseRef-scancode-unknown-license-reference", "CPL-1.0", "GFDL-1.1-or-later", "W3C-19980720", "LGPL-2.0-only", "LicenseRef-scancode-amd-historical", "LicenseRef-scancode-ietf", "SAX-PD", "LicenseRef-scancode-x11-hanson", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "dtoa", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "PSF-2.0", "LicenseRef-scancode-newlib-historical", "LicenseRef-scancode-generic-exception", "SMLNJ", "HP-1986", "LicenseRef-scancode-free-unknown", "SunPro", "MPL-1.1" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
2,230
h
libc_test.h
/* * Copyright (c) 2014 The Native Client Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef NATIVE_CLIENT_TESTS_IRT_EXT_LIBC_TEST_H #define NATIVE_CLIENT_TESTS_IRT_EXT_LIBC_TEST_H #include "native_client/src/include/nacl_macros.h" #include "native_client/tests/irt_ext/error_report.h" /* * This macro is used to expand macros for declaring and running the test * functions. It also serves as a central location where all the tests are * listed out. The test names must match the test name when defining tests * using the "DEFINE_TEST" macro below. * * For example, having listed OP(Basic), we expect to have in another * compiled .c file somewhere DEFINE_TEST(Basic, ...). */ #define EXPAND_TEST_OPERATION(OP) \ OP(Basic); \ OP(File); \ OP(Mem); \ OP(Thread); /* This macro specifies the format of our test function name. */ #define TEST_FUNC_NAME(TEST_NAME) run_##TEST_NAME##_tests /* This macro is used to define the test body. */ #define DEFINE_TEST(TEST_NAME, TEST_FUNCS_ARRAY, ENV_TYPE, \ SETUP_FUNC, TEARDOWN_FUNC) \ int TEST_FUNC_NAME(TEST_NAME)(void) { \ ENV_TYPE env_desc; \ int num_success = 0; \ irt_ext_test_print("Running %d " #TEST_NAME " Tests...\n", \ NACL_ARRAY_SIZE(TEST_FUNCS_ARRAY)); \ for (int i = 0; i < NACL_ARRAY_SIZE(TEST_FUNCS_ARRAY); i++) { \ SETUP_FUNC(&env_desc); \ if (0 == TEST_FUNCS_ARRAY[i](&env_desc)) { \ num_success++; \ } \ TEARDOWN_FUNC(); \ } \ irt_ext_test_print(#TEST_NAME " Tests results - %d/%d succeeded.\n", \ num_success, NACL_ARRAY_SIZE(TEST_FUNCS_ARRAY)); \ if (num_success < NACL_ARRAY_SIZE(TEST_FUNCS_ARRAY)) { \ irt_ext_test_print(#TEST_NAME " Test has Failed.\n"); \ } \ return NACL_ARRAY_SIZE(TEST_FUNCS_ARRAY) - num_success; \ } /* The actual declaration of the test functions. */ #define TEST_DECLARATION(TEST_NAME) int TEST_FUNC_NAME(TEST_NAME)(void) EXPAND_TEST_OPERATION(TEST_DECLARATION) #endif /* NATIVE_CLIENT_TESTS_IRT_EXT_LIBC_TEST_H */
2774c467ef0cb8d58137c34e9eea1b41431dcd84
830a933656a9fed035e1c0ca26b725051a2987f8
/src/simdpackedselect.c
e81f66adfdcab35a422ad967773230f7fa12c669
[ "GPL-1.0-or-later", "MIT", "BSD-3-Clause" ]
permissive
lemire/simdcomp
c528b8a1336e20c31564e0f17b5cad9e8bdae3fb
009c67807670d16f8984c0534aef0e630e5465a4
refs/heads/master
2023-08-28T16:59:08.851170
2023-08-18T18:34:43
2023-08-18T18:34:43
16,556,373
437
52
BSD-3-Clause
2023-08-18T18:34:45
2014-02-05T19:57:38
C
UTF-8
C
false
false
387,768
c
simdpackedselect.c
/** * This code is released under a BSD License. */ #ifdef __SSE4_1__ #include "simdintegratedbitpacking.h" #include <smmintrin.h> SIMDCOMP_ALIGNED(16) int8_t shuffle_mask_bytes[256] = { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const __m128i *shuffle_mask = (__m128i *)shuffle_mask_bytes; uint32_t branchlessextract(__m128i out, int i) { return _mm_cvtsi128_si32(_mm_shuffle_epi8(out, shuffle_mask[i])); } #define PrefixSum(ret, curr, prev) \ do { \ const __m128i _tmp1 = _mm_add_epi32(_mm_slli_si128(curr, 8), curr); \ const __m128i _tmp2 = _mm_add_epi32(_mm_slli_si128(_tmp1, 4), _tmp1); \ ret = _mm_add_epi32(_tmp2, _mm_shuffle_epi32(prev, 0xff)); \ } while (0) #define CHECK_AND_INCREMENT(i, out, slot) \ i += 4; \ if (i > slot) { \ return branchlessextract(out, slot - (i - 4)); \ } static uint32_t iunpackselect1(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 1) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect2(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 2) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect3(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 3) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 3 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 3 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect4(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 4) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect5(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 5) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect6(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 6) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect7(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 7) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect8(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 8) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect9(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 9) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect10(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 10) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect11(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 11) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect12(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 12) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect13(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 13) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect14(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 14) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect15(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 15) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect16(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 16) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect17(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 17) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect18(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 18) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect19(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 19) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect20(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 20) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect21(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 21) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect22(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 22) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect23(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 23) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect24(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 24) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect25(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 25) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect26(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 26) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect27(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 27) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 25), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect28(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 28) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect29(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 29) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 25), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 27), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect30(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 30) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect31(__m128i *initOffset, const __m128i *in, int slot) { int i = 0; __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 31) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 30), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 29), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 27), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 25), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 7); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 5); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 3); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 2); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); tmp = _mm_srli_epi32(InReg, 1); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; CHECK_AND_INCREMENT(i, out, slot); return (0); } static uint32_t iunpackselect32(__m128i *initOffset, const __m128i *in, int slot) { uint32_t *begin = (uint32_t *)in; *initOffset = _mm_load_si128(in + 31); return begin[slot]; } uint32_t simdselectd1(uint32_t init, const __m128i *in, uint32_t bit, int slot) { __m128i vecinitOffset = _mm_set1_epi32(init); __m128i *initOffset = &vecinitOffset; slot &= 127; /* to avoid problems */ switch (bit) { case 0: return _mm_extract_epi32(*initOffset, 3); break; case 1: return iunpackselect1(initOffset, in, slot); break; case 2: return iunpackselect2(initOffset, in, slot); break; case 3: return iunpackselect3(initOffset, in, slot); break; case 4: return iunpackselect4(initOffset, in, slot); break; case 5: return iunpackselect5(initOffset, in, slot); break; case 6: return iunpackselect6(initOffset, in, slot); break; case 7: return iunpackselect7(initOffset, in, slot); break; case 8: return iunpackselect8(initOffset, in, slot); break; case 9: return iunpackselect9(initOffset, in, slot); break; case 10: return iunpackselect10(initOffset, in, slot); break; case 11: return iunpackselect11(initOffset, in, slot); break; case 12: return iunpackselect12(initOffset, in, slot); break; case 13: return iunpackselect13(initOffset, in, slot); break; case 14: return iunpackselect14(initOffset, in, slot); break; case 15: return iunpackselect15(initOffset, in, slot); break; case 16: return iunpackselect16(initOffset, in, slot); break; case 17: return iunpackselect17(initOffset, in, slot); break; case 18: return iunpackselect18(initOffset, in, slot); break; case 19: return iunpackselect19(initOffset, in, slot); break; case 20: return iunpackselect20(initOffset, in, slot); break; case 21: return iunpackselect21(initOffset, in, slot); break; case 22: return iunpackselect22(initOffset, in, slot); break; case 23: return iunpackselect23(initOffset, in, slot); break; case 24: return iunpackselect24(initOffset, in, slot); break; case 25: return iunpackselect25(initOffset, in, slot); break; case 26: return iunpackselect26(initOffset, in, slot); break; case 27: return iunpackselect27(initOffset, in, slot); break; case 28: return iunpackselect28(initOffset, in, slot); break; case 29: return iunpackselect29(initOffset, in, slot); break; case 30: return iunpackselect30(initOffset, in, slot); break; case 31: return iunpackselect31(initOffset, in, slot); break; case 32: return iunpackselect32(initOffset, in, slot); break; default: break; } return (-1); } static void iunpackscan1(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 1) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan2(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 2) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan3(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 3) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 3 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 3 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan4(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 4) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan5(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 5) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 5 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan6(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 6) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 6 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan7(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 7) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 7 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan8(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 8) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan9(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 9) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 9 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan10(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 10) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 10 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan11(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 11) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 11 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan12(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 12) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 12 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan13(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 13) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 13 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan14(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 14) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 14 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan15(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 15) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 15 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan16(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 16) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan17(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 17) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 17 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan18(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 18) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 18 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan19(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 19) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 19 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan20(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 20) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 20 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan21(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 21) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 21 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan22(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 22) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 22 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan23(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 23) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 23 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan24(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 24) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 24 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan25(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 25) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 25 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan26(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 26) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 26 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan27(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 27) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 25), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 27 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan28(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 28) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 28 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan29(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 29) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 25), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 27), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 29 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan30(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 30) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = tmp; ++in; InReg = _mm_loadu_si128(in); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 30 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan31(__m128i *initOffset, const __m128i *in) { __m128i InReg = _mm_loadu_si128(in); __m128i out; __m128i tmp; __m128i mask = _mm_set1_epi32((1U << 31) - 1); tmp = InReg; out = _mm_and_si128(tmp, mask); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 31); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 30), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 30); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 29), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 29); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 28), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 28); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 27), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 27); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 26), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 26); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 25), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 25); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 24), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 24); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 23), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 23); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 22), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 22); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 21), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 21); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 20), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 20); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 19), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 19); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 18), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 18); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 17), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 17); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 16), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 16); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 15), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 15); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 14), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 14); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 13), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 13); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 12), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 12); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 11), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 11); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 10), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 10); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 9), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 9); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 8), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 8); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 7), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 7); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 6), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 6); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 5), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 5); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 4), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 4); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 3), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 3); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 2), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 2); out = tmp; ++in; InReg = _mm_loadu_si128(in); out = _mm_or_si128(out, _mm_and_si128(_mm_slli_epi32(InReg, 31 - 1), mask)); PrefixSum(out, out, *initOffset); *initOffset = out; tmp = _mm_srli_epi32(InReg, 1); out = tmp; PrefixSum(out, out, *initOffset); *initOffset = out; } static void iunpackscan32(__m128i *initOffset, const __m128i *in) { *initOffset = _mm_load_si128(in + 31); } void simdscand1(__m128i *initOffset, const __m128i *in, uint32_t bit) { switch (bit) { case 0: return; break; case 1: iunpackscan1(initOffset, in); break; case 2: iunpackscan2(initOffset, in); break; case 3: iunpackscan3(initOffset, in); break; case 4: iunpackscan4(initOffset, in); break; case 5: iunpackscan5(initOffset, in); break; case 6: iunpackscan6(initOffset, in); break; case 7: iunpackscan7(initOffset, in); break; case 8: iunpackscan8(initOffset, in); break; case 9: iunpackscan9(initOffset, in); break; case 10: iunpackscan10(initOffset, in); break; case 11: iunpackscan11(initOffset, in); break; case 12: iunpackscan12(initOffset, in); break; case 13: iunpackscan13(initOffset, in); break; case 14: iunpackscan14(initOffset, in); break; case 15: iunpackscan15(initOffset, in); break; case 16: iunpackscan16(initOffset, in); break; case 17: iunpackscan17(initOffset, in); break; case 18: iunpackscan18(initOffset, in); break; case 19: iunpackscan19(initOffset, in); break; case 20: iunpackscan20(initOffset, in); break; case 21: iunpackscan21(initOffset, in); break; case 22: iunpackscan22(initOffset, in); break; case 23: iunpackscan23(initOffset, in); break; case 24: iunpackscan24(initOffset, in); break; case 25: iunpackscan25(initOffset, in); break; case 26: iunpackscan26(initOffset, in); break; case 27: iunpackscan27(initOffset, in); break; case 28: iunpackscan28(initOffset, in); break; case 29: iunpackscan29(initOffset, in); break; case 30: iunpackscan30(initOffset, in); break; case 31: iunpackscan31(initOffset, in); break; case 32: iunpackscan32(initOffset, in); break; default: break; } return; } #endif
270480ecb487b6b1e91210576fb33bac006db85e
a7856278e39f6030eacbb0680ca66b57e30ca06b
/generation/Windows/um/oleauto/um-oleauto.h
fda9a6b10dc8d66a8aa24ee0ac2cdb56ea84cfcc
[ "MIT" ]
permissive
terrafx/terrafx.interop.windows
07f1ac52cbaea6c0f5f8f6147df7a8dd50345f49
fadce5a41fa5e6f0282e80e96f033d0a2c130991
refs/heads/main
2023-07-09T03:56:06.057946
2023-06-23T16:01:17
2023-06-23T16:01:17
192,857,891
208
46
MIT
2023-07-07T17:25:55
2019-06-20T05:58:46
C#
UTF-8
C
false
false
51
h
um-oleauto.h
#include "..\..\..\TerraFX.h" #include <oleauto.h>
1aa161fb35bd9c907718642a5fa4a93699e7434c
e929a84dec3a6e710351261a6de895308efa6d33
/code/game/anims.h
8ad06f5b818eeda6a92db901ef6e09476edb3ae9
[]
no_license
xLAva/JediAcademyLinux
570d85e1e24d950ab63e9297135248362d873dbd
1d31492a576106e104f49bd9b5fe7f7792a90e89
refs/heads/JediAcademyLinux
2021-01-18T21:23:43.164581
2014-11-29T13:52:49
2014-11-29T13:52:49
9,734,512
125
18
null
2013-09-24T19:02:36
2013-04-28T18:51:54
C++
UTF-8
C
false
false
82,985
h
anims.h
#ifndef __ANIMS_H__ #define __ANIMS_H__ // playerAnimations typedef enum //# animNumber_e { //================================================= //HEAD ANIMS //================================================= //# #sep Head-only anims FACE_TALK0, //# silent FACE_TALK1, //# quiet FACE_TALK2, //# semi-quiet FACE_TALK3, //# semi-loud FACE_TALK4, //# loud FACE_ALERT, //# FACE_SMILE, //# FACE_FROWN, //# FACE_DEAD, //# //================================================= //ANIMS IN WHICH UPPER AND LOWER OBJECTS ARE IN MD3 //================================================= //# #sep BOTH_ DEATHS BOTH_DEATH1, //# First Death anim BOTH_DEATH2, //# Second Death anim BOTH_DEATH3, //# Third Death anim BOTH_DEATH4, //# Fourth Death anim BOTH_DEATH5, //# Fifth Death anim BOTH_DEATH6, //# Sixth Death anim BOTH_DEATH7, //# Seventh Death anim BOTH_DEATH8, //# BOTH_DEATH9, //# BOTH_DEATH10, //# BOTH_DEATH11, //# BOTH_DEATH12, //# BOTH_DEATH13, //# BOTH_DEATH14, //# BOTH_DEATH15, //# BOTH_DEATH16, //# BOTH_DEATH17, //# BOTH_DEATH18, //# BOTH_DEATH19, //# BOTH_DEATH20, //# BOTH_DEATH21, //# BOTH_DEATH22, //# BOTH_DEATH23, //# BOTH_DEATH24, //# BOTH_DEATH25, //# BOTH_DEATHFORWARD1, //# First Death in which they get thrown forward BOTH_DEATHFORWARD2, //# Second Death in which they get thrown forward BOTH_DEATHFORWARD3, //# Tavion's falling in cin# 23 BOTH_DEATHBACKWARD1, //# First Death in which they get thrown backward BOTH_DEATHBACKWARD2, //# Second Death in which they get thrown backward BOTH_DEATH1IDLE, //# Idle while close to death BOTH_LYINGDEATH1, //# Death to play when killed lying down BOTH_STUMBLEDEATH1, //# Stumble forward and fall face first death BOTH_FALLDEATH1, //# Fall forward off a high cliff and splat death - start BOTH_FALLDEATH1INAIR, //# Fall forward off a high cliff and splat death - loop BOTH_FALLDEATH1LAND, //# Fall forward off a high cliff and splat death - hit bottom BOTH_DEATH_ROLL, //# Death anim from a roll BOTH_DEATH_FLIP, //# Death anim from a flip BOTH_DEATH_SPIN_90_R, //# Death anim when facing 90 degrees right BOTH_DEATH_SPIN_90_L, //# Death anim when facing 90 degrees left BOTH_DEATH_SPIN_180, //# Death anim when facing backwards BOTH_DEATH_LYING_UP, //# Death anim when lying on back BOTH_DEATH_LYING_DN, //# Death anim when lying on front BOTH_DEATH_FALLING_DN, //# Death anim when falling on face BOTH_DEATH_FALLING_UP, //# Death anim when falling on back BOTH_DEATH_CROUCHED, //# Death anim when crouched //# #sep BOTH_ DEAD POSES # Should be last frame of corresponding previous anims BOTH_DEAD1, //# First Death finished pose BOTH_DEAD2, //# Second Death finished pose BOTH_DEAD3, //# Third Death finished pose BOTH_DEAD4, //# Fourth Death finished pose BOTH_DEAD5, //# Fifth Death finished pose BOTH_DEAD6, //# Sixth Death finished pose BOTH_DEAD7, //# Seventh Death finished pose BOTH_DEAD8, //# BOTH_DEAD9, //# BOTH_DEAD10, //# BOTH_DEAD11, //# BOTH_DEAD12, //# BOTH_DEAD13, //# BOTH_DEAD14, //# BOTH_DEAD15, //# BOTH_DEAD16, //# BOTH_DEAD17, //# BOTH_DEAD18, //# BOTH_DEAD19, //# BOTH_DEAD20, //# BOTH_DEAD21, //# BOTH_DEAD22, //# BOTH_DEAD23, //# BOTH_DEAD24, //# BOTH_DEAD25, //# BOTH_DEADFORWARD1, //# First thrown forward death finished pose BOTH_DEADFORWARD2, //# Second thrown forward death finished pose BOTH_DEADBACKWARD1, //# First thrown backward death finished pose BOTH_DEADBACKWARD2, //# Second thrown backward death finished pose BOTH_LYINGDEAD1, //# Killed lying down death finished pose BOTH_STUMBLEDEAD1, //# Stumble forward death finished pose BOTH_FALLDEAD1LAND, //# Fall forward and splat death finished pose //# #sep BOTH_ DEAD TWITCH/FLOP # React to being shot from death poses BOTH_DEADFLOP1, //# React to being shot from First Death finished pose BOTH_DEADFLOP2, //# React to being shot from Second Death finished pose BOTH_DISMEMBER_HEAD1, //# BOTH_DISMEMBER_TORSO1, //# BOTH_DISMEMBER_LLEG, //# BOTH_DISMEMBER_RLEG, //# BOTH_DISMEMBER_RARM, //# BOTH_DISMEMBER_LARM, //# //# #sep BOTH_ PAINS BOTH_PAIN1, //# First take pain anim BOTH_PAIN2, //# Second take pain anim BOTH_PAIN3, //# Third take pain anim BOTH_PAIN4, //# Fourth take pain anim BOTH_PAIN5, //# Fifth take pain anim - from behind BOTH_PAIN6, //# Sixth take pain anim - from behind BOTH_PAIN7, //# Seventh take pain anim - from behind BOTH_PAIN8, //# Eigth take pain anim - from behind BOTH_PAIN9, //# BOTH_PAIN10, //# BOTH_PAIN11, //# BOTH_PAIN12, //# BOTH_PAIN13, //# BOTH_PAIN14, //# BOTH_PAIN15, //# BOTH_PAIN16, //# BOTH_PAIN17, //# BOTH_PAIN18, //# //# #sep BOTH_ ATTACKS BOTH_ATTACK1, //# Attack with stun baton BOTH_ATTACK2, //# Attack with one-handed pistol BOTH_ATTACK3, //# Attack with blaster rifle BOTH_ATTACK4, //# Attack with disruptor BOTH_ATTACK5, //# Another Rancor Attack BOTH_ATTACK6, //# Yet Another Rancor Attack BOTH_ATTACK7, //# Yet Another Rancor Attack BOTH_ATTACK10, //# Attack with thermal det BOTH_ATTACK11, //# "Attack" with tripmine and detpack BOTH_MELEE1, //# First melee attack BOTH_MELEE2, //# Second melee attack BOTH_THERMAL_READY, //# pull back with thermal BOTH_THERMAL_THROW, //# throw thermal //* #sep BOTH_ SABER ANIMS //Saber attack anims - power level 1 BOTH_A1_T__B_, //# Fast weak vertical attack top to bottom BOTH_A1__L__R, //# Fast weak horizontal attack left to right BOTH_A1__R__L, //# Fast weak horizontal attack right to left BOTH_A1_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A1_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A1_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A1_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T1_BR__R, //# Fast arc bottom right to right BOTH_T1_BR_TL, //# Fast weak spin bottom right to top left BOTH_T1_BR__L, //# Fast weak spin bottom right to left BOTH_T1_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T1__R_TR, //# Fast arc right to top right BOTH_T1__R_TL, //# Fast arc right to top left BOTH_T1__R__L, //# Fast weak spin right to left BOTH_T1__R_BL, //# Fast weak spin right to bottom left BOTH_T1_TR_BR, //# Fast arc top right to bottom right BOTH_T1_TR_TL, //# Fast arc top right to top left BOTH_T1_TR__L, //# Fast arc top right to left BOTH_T1_TR_BL, //# Fast weak spin top right to bottom left BOTH_T1_T__BR, //# Fast arc top to bottom right BOTH_T1_T___R, //# Fast arc top to right BOTH_T1_T__TR, //# Fast arc top to top right BOTH_T1_T__TL, //# Fast arc top to top left BOTH_T1_T___L, //# Fast arc top to left BOTH_T1_T__BL, //# Fast arc top to bottom left BOTH_T1_TL_BR, //# Fast weak spin top left to bottom right BOTH_T1_TL_BL, //# Fast arc top left to bottom left BOTH_T1__L_BR, //# Fast weak spin left to bottom right BOTH_T1__L__R, //# Fast weak spin left to right BOTH_T1__L_TL, //# Fast arc left to top left BOTH_T1_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T1_BL__R, //# Fast weak spin bottom left to right BOTH_T1_BL_TR, //# Fast weak spin bottom left to top right BOTH_T1_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T1_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T1_TR_BR) BOTH_T1_BR_T_, //# Fast arc bottom right to top (use: BOTH_T1_T__BR) BOTH_T1__R_BR, //# Fast arc right to bottom right (use: BOTH_T1_BR__R) BOTH_T1__R_T_, //# Fast ar right to top (use: BOTH_T1_T___R) BOTH_T1_TR__R, //# Fast arc top right to right (use: BOTH_T1__R_TR) BOTH_T1_TR_T_, //# Fast arc top right to top (use: BOTH_T1_T__TR) BOTH_T1_TL__R, //# Fast arc top left to right (use: BOTH_T1__R_TL) BOTH_T1_TL_TR, //# Fast arc top left to top right (use: BOTH_T1_TR_TL) BOTH_T1_TL_T_, //# Fast arc top left to top (use: BOTH_T1_T__TL) BOTH_T1_TL__L, //# Fast arc top left to left (use: BOTH_T1__L_TL) BOTH_T1__L_TR, //# Fast arc left to top right (use: BOTH_T1_TR__L) BOTH_T1__L_T_, //# Fast arc left to top (use: BOTH_T1_T___L) BOTH_T1__L_BL, //# Fast arc left to bottom left (use: BOTH_T1_BL__L) BOTH_T1_BL_T_, //# Fast arc bottom left to top (use: BOTH_T1_T__BL) BOTH_T1_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T1_TL_BL) //Saber Attack Start Transitions BOTH_S1_S1_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S1_S1__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S1_S1__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S1_S1_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S1_S1_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S1_S1_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S1_S1_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R1_B__S1, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R1__L_S1, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R1__R_S1, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R1_TL_S1, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R1_BR_S1, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R1_BL_S1, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R1_TR_S1, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B1_BR___, //# Bounce-back if attack from BR is blocked BOTH_B1__R___, //# Bounce-back if attack from R is blocked BOTH_B1_TR___, //# Bounce-back if attack from TR is blocked BOTH_B1_T____, //# Bounce-back if attack from T is blocked BOTH_B1_TL___, //# Bounce-back if attack from TL is blocked BOTH_B1__L___, //# Bounce-back if attack from L is blocked BOTH_B1_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D1_BR___, //# Deflection toward BR BOTH_D1__R___, //# Deflection toward R BOTH_D1_TR___, //# Deflection toward TR BOTH_D1_TL___, //# Deflection toward TL BOTH_D1__L___, //# Deflection toward L BOTH_D1_BL___, //# Deflection toward BL BOTH_D1_B____, //# Deflection toward B //Saber attack anims - power level 2 BOTH_A2_T__B_, //# Fast weak vertical attack top to bottom BOTH_A2__L__R, //# Fast weak horizontal attack left to right BOTH_A2__R__L, //# Fast weak horizontal attack right to left BOTH_A2_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A2_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A2_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A2_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T2_BR__R, //# Fast arc bottom right to right BOTH_T2_BR_TL, //# Fast weak spin bottom right to top left BOTH_T2_BR__L, //# Fast weak spin bottom right to left BOTH_T2_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T2__R_TR, //# Fast arc right to top right BOTH_T2__R_TL, //# Fast arc right to top left BOTH_T2__R__L, //# Fast weak spin right to left BOTH_T2__R_BL, //# Fast weak spin right to bottom left BOTH_T2_TR_BR, //# Fast arc top right to bottom right BOTH_T2_TR_TL, //# Fast arc top right to top left BOTH_T2_TR__L, //# Fast arc top right to left BOTH_T2_TR_BL, //# Fast weak spin top right to bottom left BOTH_T2_T__BR, //# Fast arc top to bottom right BOTH_T2_T___R, //# Fast arc top to right BOTH_T2_T__TR, //# Fast arc top to top right BOTH_T2_T__TL, //# Fast arc top to top left BOTH_T2_T___L, //# Fast arc top to left BOTH_T2_T__BL, //# Fast arc top to bottom left BOTH_T2_TL_BR, //# Fast weak spin top left to bottom right BOTH_T2_TL_BL, //# Fast arc top left to bottom left BOTH_T2__L_BR, //# Fast weak spin left to bottom right BOTH_T2__L__R, //# Fast weak spin left to right BOTH_T2__L_TL, //# Fast arc left to top left BOTH_T2_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T2_BL__R, //# Fast weak spin bottom left to right BOTH_T2_BL_TR, //# Fast weak spin bottom left to top right BOTH_T2_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T2_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T2_TR_BR) BOTH_T2_BR_T_, //# Fast arc bottom right to top (use: BOTH_T2_T__BR) BOTH_T2__R_BR, //# Fast arc right to bottom right (use: BOTH_T2_BR__R) BOTH_T2__R_T_, //# Fast ar right to top (use: BOTH_T2_T___R) BOTH_T2_TR__R, //# Fast arc top right to right (use: BOTH_T2__R_TR) BOTH_T2_TR_T_, //# Fast arc top right to top (use: BOTH_T2_T__TR) BOTH_T2_TL__R, //# Fast arc top left to right (use: BOTH_T2__R_TL) BOTH_T2_TL_TR, //# Fast arc top left to top right (use: BOTH_T2_TR_TL) BOTH_T2_TL_T_, //# Fast arc top left to top (use: BOTH_T2_T__TL) BOTH_T2_TL__L, //# Fast arc top left to left (use: BOTH_T2__L_TL) BOTH_T2__L_TR, //# Fast arc left to top right (use: BOTH_T2_TR__L) BOTH_T2__L_T_, //# Fast arc left to top (use: BOTH_T2_T___L) BOTH_T2__L_BL, //# Fast arc left to bottom left (use: BOTH_T2_BL__L) BOTH_T2_BL_T_, //# Fast arc bottom left to top (use: BOTH_T2_T__BL) BOTH_T2_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T2_TL_BL) //Saber Attack Start Transitions BOTH_S2_S1_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S2_S1__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S2_S1__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S2_S1_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S2_S1_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S2_S1_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S2_S1_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R2_B__S1, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R2__L_S1, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R2__R_S1, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R2_TL_S1, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R2_BR_S1, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R2_BL_S1, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R2_TR_S1, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B2_BR___, //# Bounce-back if attack from BR is blocked BOTH_B2__R___, //# Bounce-back if attack from R is blocked BOTH_B2_TR___, //# Bounce-back if attack from TR is blocked BOTH_B2_T____, //# Bounce-back if attack from T is blocked BOTH_B2_TL___, //# Bounce-back if attack from TL is blocked BOTH_B2__L___, //# Bounce-back if attack from L is blocked BOTH_B2_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D2_BR___, //# Deflection toward BR BOTH_D2__R___, //# Deflection toward R BOTH_D2_TR___, //# Deflection toward TR BOTH_D2_TL___, //# Deflection toward TL BOTH_D2__L___, //# Deflection toward L BOTH_D2_BL___, //# Deflection toward BL BOTH_D2_B____, //# Deflection toward B //Saber attack anims - power level 3 BOTH_A3_T__B_, //# Fast weak vertical attack top to bottom BOTH_A3__L__R, //# Fast weak horizontal attack left to right BOTH_A3__R__L, //# Fast weak horizontal attack right to left BOTH_A3_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A3_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A3_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A3_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T3_BR__R, //# Fast arc bottom right to right BOTH_T3_BR_TL, //# Fast weak spin bottom right to top left BOTH_T3_BR__L, //# Fast weak spin bottom right to left BOTH_T3_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T3__R_TR, //# Fast arc right to top right BOTH_T3__R_TL, //# Fast arc right to top left BOTH_T3__R__L, //# Fast weak spin right to left BOTH_T3__R_BL, //# Fast weak spin right to bottom left BOTH_T3_TR_BR, //# Fast arc top right to bottom right BOTH_T3_TR_TL, //# Fast arc top right to top left BOTH_T3_TR__L, //# Fast arc top right to left BOTH_T3_TR_BL, //# Fast weak spin top right to bottom left BOTH_T3_T__BR, //# Fast arc top to bottom right BOTH_T3_T___R, //# Fast arc top to right BOTH_T3_T__TR, //# Fast arc top to top right BOTH_T3_T__TL, //# Fast arc top to top left BOTH_T3_T___L, //# Fast arc top to left BOTH_T3_T__BL, //# Fast arc top to bottom left BOTH_T3_TL_BR, //# Fast weak spin top left to bottom right BOTH_T3_TL_BL, //# Fast arc top left to bottom left BOTH_T3__L_BR, //# Fast weak spin left to bottom right BOTH_T3__L__R, //# Fast weak spin left to right BOTH_T3__L_TL, //# Fast arc left to top left BOTH_T3_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T3_BL__R, //# Fast weak spin bottom left to right BOTH_T3_BL_TR, //# Fast weak spin bottom left to top right BOTH_T3_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T3_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T3_TR_BR) BOTH_T3_BR_T_, //# Fast arc bottom right to top (use: BOTH_T3_T__BR) BOTH_T3__R_BR, //# Fast arc right to bottom right (use: BOTH_T3_BR__R) BOTH_T3__R_T_, //# Fast ar right to top (use: BOTH_T3_T___R) BOTH_T3_TR__R, //# Fast arc top right to right (use: BOTH_T3__R_TR) BOTH_T3_TR_T_, //# Fast arc top right to top (use: BOTH_T3_T__TR) BOTH_T3_TL__R, //# Fast arc top left to right (use: BOTH_T3__R_TL) BOTH_T3_TL_TR, //# Fast arc top left to top right (use: BOTH_T3_TR_TL) BOTH_T3_TL_T_, //# Fast arc top left to top (use: BOTH_T3_T__TL) BOTH_T3_TL__L, //# Fast arc top left to left (use: BOTH_T3__L_TL) BOTH_T3__L_TR, //# Fast arc left to top right (use: BOTH_T3_TR__L) BOTH_T3__L_T_, //# Fast arc left to top (use: BOTH_T3_T___L) BOTH_T3__L_BL, //# Fast arc left to bottom left (use: BOTH_T3_BL__L) BOTH_T3_BL_T_, //# Fast arc bottom left to top (use: BOTH_T3_T__BL) BOTH_T3_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T3_TL_BL) //Saber Attack Start Transitions BOTH_S3_S1_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S3_S1__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S3_S1__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S3_S1_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S3_S1_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S3_S1_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S3_S1_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R3_B__S1, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R3__L_S1, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R3__R_S1, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R3_TL_S1, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R3_BR_S1, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R3_BL_S1, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R3_TR_S1, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B3_BR___, //# Bounce-back if attack from BR is blocked BOTH_B3__R___, //# Bounce-back if attack from R is blocked BOTH_B3_TR___, //# Bounce-back if attack from TR is blocked BOTH_B3_T____, //# Bounce-back if attack from T is blocked BOTH_B3_TL___, //# Bounce-back if attack from TL is blocked BOTH_B3__L___, //# Bounce-back if attack from L is blocked BOTH_B3_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D3_BR___, //# Deflection toward BR BOTH_D3__R___, //# Deflection toward R BOTH_D3_TR___, //# Deflection toward TR BOTH_D3_TL___, //# Deflection toward TL BOTH_D3__L___, //# Deflection toward L BOTH_D3_BL___, //# Deflection toward BL BOTH_D3_B____, //# Deflection toward B //Saber attack anims - power level 4 - Desann's BOTH_A4_T__B_, //# Fast weak vertical attack top to bottom BOTH_A4__L__R, //# Fast weak horizontal attack left to right BOTH_A4__R__L, //# Fast weak horizontal attack right to left BOTH_A4_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A4_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A4_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A4_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T4_BR__R, //# Fast arc bottom right to right BOTH_T4_BR_TL, //# Fast weak spin bottom right to top left BOTH_T4_BR__L, //# Fast weak spin bottom right to left BOTH_T4_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T4__R_TR, //# Fast arc right to top right BOTH_T4__R_TL, //# Fast arc right to top left BOTH_T4__R__L, //# Fast weak spin right to left BOTH_T4__R_BL, //# Fast weak spin right to bottom left BOTH_T4_TR_BR, //# Fast arc top right to bottom right BOTH_T4_TR_TL, //# Fast arc top right to top left BOTH_T4_TR__L, //# Fast arc top right to left BOTH_T4_TR_BL, //# Fast weak spin top right to bottom left BOTH_T4_T__BR, //# Fast arc top to bottom right BOTH_T4_T___R, //# Fast arc top to right BOTH_T4_T__TR, //# Fast arc top to top right BOTH_T4_T__TL, //# Fast arc top to top left BOTH_T4_T___L, //# Fast arc top to left BOTH_T4_T__BL, //# Fast arc top to bottom left BOTH_T4_TL_BR, //# Fast weak spin top left to bottom right BOTH_T4_TL_BL, //# Fast arc top left to bottom left BOTH_T4__L_BR, //# Fast weak spin left to bottom right BOTH_T4__L__R, //# Fast weak spin left to right BOTH_T4__L_TL, //# Fast arc left to top left BOTH_T4_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T4_BL__R, //# Fast weak spin bottom left to right BOTH_T4_BL_TR, //# Fast weak spin bottom left to top right BOTH_T4_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T4_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T4_TR_BR) BOTH_T4_BR_T_, //# Fast arc bottom right to top (use: BOTH_T4_T__BR) BOTH_T4__R_BR, //# Fast arc right to bottom right (use: BOTH_T4_BR__R) BOTH_T4__R_T_, //# Fast ar right to top (use: BOTH_T4_T___R) BOTH_T4_TR__R, //# Fast arc top right to right (use: BOTH_T4__R_TR) BOTH_T4_TR_T_, //# Fast arc top right to top (use: BOTH_T4_T__TR) BOTH_T4_TL__R, //# Fast arc top left to right (use: BOTH_T4__R_TL) BOTH_T4_TL_TR, //# Fast arc top left to top right (use: BOTH_T4_TR_TL) BOTH_T4_TL_T_, //# Fast arc top left to top (use: BOTH_T4_T__TL) BOTH_T4_TL__L, //# Fast arc top left to left (use: BOTH_T4__L_TL) BOTH_T4__L_TR, //# Fast arc left to top right (use: BOTH_T4_TR__L) BOTH_T4__L_T_, //# Fast arc left to top (use: BOTH_T4_T___L) BOTH_T4__L_BL, //# Fast arc left to bottom left (use: BOTH_T4_BL__L) BOTH_T4_BL_T_, //# Fast arc bottom left to top (use: BOTH_T4_T__BL) BOTH_T4_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T4_TL_BL) //Saber Attack Start Transitions BOTH_S4_S1_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S4_S1__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S4_S1__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S4_S1_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S4_S1_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S4_S1_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S4_S1_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R4_B__S1, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R4__L_S1, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R4__R_S1, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R4_TL_S1, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R4_BR_S1, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R4_BL_S1, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R4_TR_S1, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B4_BR___, //# Bounce-back if attack from BR is blocked BOTH_B4__R___, //# Bounce-back if attack from R is blocked BOTH_B4_TR___, //# Bounce-back if attack from TR is blocked BOTH_B4_T____, //# Bounce-back if attack from T is blocked BOTH_B4_TL___, //# Bounce-back if attack from TL is blocked BOTH_B4__L___, //# Bounce-back if attack from L is blocked BOTH_B4_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D4_BR___, //# Deflection toward BR BOTH_D4__R___, //# Deflection toward R BOTH_D4_TR___, //# Deflection toward TR BOTH_D4_TL___, //# Deflection toward TL BOTH_D4__L___, //# Deflection toward L BOTH_D4_BL___, //# Deflection toward BL BOTH_D4_B____, //# Deflection toward B //Saber attack anims - power level 5 - Tavion's BOTH_A5_T__B_, //# Fast weak vertical attack top to bottom BOTH_A5__L__R, //# Fast weak horizontal attack left to right BOTH_A5__R__L, //# Fast weak horizontal attack right to left BOTH_A5_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A5_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A5_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A5_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T5_BR__R, //# Fast arc bottom right to right BOTH_T5_BR_TL, //# Fast weak spin bottom right to top left BOTH_T5_BR__L, //# Fast weak spin bottom right to left BOTH_T5_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T5__R_TR, //# Fast arc right to top right BOTH_T5__R_TL, //# Fast arc right to top left BOTH_T5__R__L, //# Fast weak spin right to left BOTH_T5__R_BL, //# Fast weak spin right to bottom left BOTH_T5_TR_BR, //# Fast arc top right to bottom right BOTH_T5_TR_TL, //# Fast arc top right to top left BOTH_T5_TR__L, //# Fast arc top right to left BOTH_T5_TR_BL, //# Fast weak spin top right to bottom left BOTH_T5_T__BR, //# Fast arc top to bottom right BOTH_T5_T___R, //# Fast arc top to right BOTH_T5_T__TR, //# Fast arc top to top right BOTH_T5_T__TL, //# Fast arc top to top left BOTH_T5_T___L, //# Fast arc top to left BOTH_T5_T__BL, //# Fast arc top to bottom left BOTH_T5_TL_BR, //# Fast weak spin top left to bottom right BOTH_T5_TL_BL, //# Fast arc top left to bottom left BOTH_T5__L_BR, //# Fast weak spin left to bottom right BOTH_T5__L__R, //# Fast weak spin left to right BOTH_T5__L_TL, //# Fast arc left to top left BOTH_T5_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T5_BL__R, //# Fast weak spin bottom left to right BOTH_T5_BL_TR, //# Fast weak spin bottom left to top right BOTH_T5_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T5_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T5_TR_BR) BOTH_T5_BR_T_, //# Fast arc bottom right to top (use: BOTH_T5_T__BR) BOTH_T5__R_BR, //# Fast arc right to bottom right (use: BOTH_T5_BR__R) BOTH_T5__R_T_, //# Fast ar right to top (use: BOTH_T5_T___R) BOTH_T5_TR__R, //# Fast arc top right to right (use: BOTH_T5__R_TR) BOTH_T5_TR_T_, //# Fast arc top right to top (use: BOTH_T5_T__TR) BOTH_T5_TL__R, //# Fast arc top left to right (use: BOTH_T5__R_TL) BOTH_T5_TL_TR, //# Fast arc top left to top right (use: BOTH_T5_TR_TL) BOTH_T5_TL_T_, //# Fast arc top left to top (use: BOTH_T5_T__TL) BOTH_T5_TL__L, //# Fast arc top left to left (use: BOTH_T5__L_TL) BOTH_T5__L_TR, //# Fast arc left to top right (use: BOTH_T5_TR__L) BOTH_T5__L_T_, //# Fast arc left to top (use: BOTH_T5_T___L) BOTH_T5__L_BL, //# Fast arc left to bottom left (use: BOTH_T5_BL__L) BOTH_T5_BL_T_, //# Fast arc bottom left to top (use: BOTH_T5_T__BL) BOTH_T5_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T5_TL_BL) //Saber Attack Start Transitions BOTH_S5_S1_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S5_S1__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S5_S1__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S5_S1_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S5_S1_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S5_S1_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S5_S1_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R5_B__S1, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R5__L_S1, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R5__R_S1, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R5_TL_S1, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R5_BR_S1, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R5_BL_S1, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R5_TR_S1, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B5_BR___, //# Bounce-back if attack from BR is blocked BOTH_B5__R___, //# Bounce-back if attack from R is blocked BOTH_B5_TR___, //# Bounce-back if attack from TR is blocked BOTH_B5_T____, //# Bounce-back if attack from T is blocked BOTH_B5_TL___, //# Bounce-back if attack from TL is blocked BOTH_B5__L___, //# Bounce-back if attack from L is blocked BOTH_B5_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D5_BR___, //# Deflection toward BR BOTH_D5__R___, //# Deflection toward R BOTH_D5_TR___, //# Deflection toward TR BOTH_D5_TL___, //# Deflection toward TL BOTH_D5__L___, //# Deflection toward L BOTH_D5_BL___, //# Deflection toward BL BOTH_D5_B____, //# Deflection toward B //Saber attack anims - power level 6 BOTH_A6_T__B_, //# Fast weak vertical attack top to bottom BOTH_A6__L__R, //# Fast weak horizontal attack left to right BOTH_A6__R__L, //# Fast weak horizontal attack right to left BOTH_A6_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A6_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A6_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A6_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T6_BR__R, //# Fast arc bottom right to right BOTH_T6_BR_TL, //# Fast weak spin bottom right to top left BOTH_T6_BR__L, //# Fast weak spin bottom right to left BOTH_T6_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T6__R_TR, //# Fast arc right to top right BOTH_T6__R_TL, //# Fast arc right to top left BOTH_T6__R__L, //# Fast weak spin right to left BOTH_T6__R_BL, //# Fast weak spin right to bottom left BOTH_T6_TR_BR, //# Fast arc top right to bottom right BOTH_T6_TR_TL, //# Fast arc top right to top left BOTH_T6_TR__L, //# Fast arc top right to left BOTH_T6_TR_BL, //# Fast weak spin top right to bottom left BOTH_T6_T__BR, //# Fast arc top to bottom right BOTH_T6_T___R, //# Fast arc top to right BOTH_T6_T__TR, //# Fast arc top to top right BOTH_T6_T__TL, //# Fast arc top to top left BOTH_T6_T___L, //# Fast arc top to left BOTH_T6_T__BL, //# Fast arc top to bottom left BOTH_T6_TL_BR, //# Fast weak spin top left to bottom right BOTH_T6_TL_BL, //# Fast arc top left to bottom left BOTH_T6__L_BR, //# Fast weak spin left to bottom right BOTH_T6__L__R, //# Fast weak spin left to right BOTH_T6__L_TL, //# Fast arc left to top left BOTH_T6_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T6_BL__R, //# Fast weak spin bottom left to right BOTH_T6_BL_TR, //# Fast weak spin bottom left to top right BOTH_T6_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T6_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T6_TR_BR) BOTH_T6_BR_T_, //# Fast arc bottom right to top (use: BOTH_T6_T__BR) BOTH_T6__R_BR, //# Fast arc right to bottom right (use: BOTH_T6_BR__R) BOTH_T6__R_T_, //# Fast ar right to top (use: BOTH_T6_T___R) BOTH_T6_TR__R, //# Fast arc top right to right (use: BOTH_T6__R_TR) BOTH_T6_TR_T_, //# Fast arc top right to top (use: BOTH_T6_T__TR) BOTH_T6_TL__R, //# Fast arc top left to right (use: BOTH_T6__R_TL) BOTH_T6_TL_TR, //# Fast arc top left to top right (use: BOTH_T6_TR_TL) BOTH_T6_TL_T_, //# Fast arc top left to top (use: BOTH_T6_T__TL) BOTH_T6_TL__L, //# Fast arc top left to left (use: BOTH_T6__L_TL) BOTH_T6__L_TR, //# Fast arc left to top right (use: BOTH_T6_TR__L) BOTH_T6__L_T_, //# Fast arc left to top (use: BOTH_T6_T___L) BOTH_T6__L_BL, //# Fast arc left to bottom left (use: BOTH_T6_BL__L) BOTH_T6_BL_T_, //# Fast arc bottom left to top (use: BOTH_T6_T__BL) BOTH_T6_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T6_TL_BL) //Saber Attack Start Transitions BOTH_S6_S6_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S6_S6__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S6_S6__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S6_S6_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S6_S6_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S6_S6_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S6_S6_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R6_B__S6, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R6__L_S6, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R6__R_S6, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R6_TL_S6, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R6_BR_S6, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R6_BL_S6, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R6_TR_S6, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B6_BR___, //# Bounce-back if attack from BR is blocked BOTH_B6__R___, //# Bounce-back if attack from R is blocked BOTH_B6_TR___, //# Bounce-back if attack from TR is blocked BOTH_B6_T____, //# Bounce-back if attack from T is blocked BOTH_B6_TL___, //# Bounce-back if attack from TL is blocked BOTH_B6__L___, //# Bounce-back if attack from L is blocked BOTH_B6_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D6_BR___, //# Deflection toward BR BOTH_D6__R___, //# Deflection toward R BOTH_D6_TR___, //# Deflection toward TR BOTH_D6_TL___, //# Deflection toward TL BOTH_D6__L___, //# Deflection toward L BOTH_D6_BL___, //# Deflection toward BL BOTH_D6_B____, //# Deflection toward B //Saber attack anims - power level 7 BOTH_A7_T__B_, //# Fast weak vertical attack top to bottom BOTH_A7__L__R, //# Fast weak horizontal attack left to right BOTH_A7__R__L, //# Fast weak horizontal attack right to left BOTH_A7_TL_BR, //# Fast weak diagonal attack top left to botom right BOTH_A7_BR_TL, //# Fast weak diagonal attack top left to botom right BOTH_A7_BL_TR, //# Fast weak diagonal attack bottom left to top right BOTH_A7_TR_BL, //# Fast weak diagonal attack bottom left to right //Saber Arc and Spin Transitions BOTH_T7_BR__R, //# Fast arc bottom right to right BOTH_T7_BR_TL, //# Fast weak spin bottom right to top left BOTH_T7_BR__L, //# Fast weak spin bottom right to left BOTH_T7_BR_BL, //# Fast weak spin bottom right to bottom left BOTH_T7__R_TR, //# Fast arc right to top right BOTH_T7__R_TL, //# Fast arc right to top left BOTH_T7__R__L, //# Fast weak spin right to left BOTH_T7__R_BL, //# Fast weak spin right to bottom left BOTH_T7_TR_BR, //# Fast arc top right to bottom right BOTH_T7_TR_TL, //# Fast arc top right to top left BOTH_T7_TR__L, //# Fast arc top right to left BOTH_T7_TR_BL, //# Fast weak spin top right to bottom left BOTH_T7_T__BR, //# Fast arc top to bottom right BOTH_T7_T___R, //# Fast arc top to right BOTH_T7_T__TR, //# Fast arc top to top right BOTH_T7_T__TL, //# Fast arc top to top left BOTH_T7_T___L, //# Fast arc top to left BOTH_T7_T__BL, //# Fast arc top to bottom left BOTH_T7_TL_BR, //# Fast weak spin top left to bottom right BOTH_T7_TL_BL, //# Fast arc top left to bottom left BOTH_T7__L_BR, //# Fast weak spin left to bottom right BOTH_T7__L__R, //# Fast weak spin left to right BOTH_T7__L_TL, //# Fast arc left to top left BOTH_T7_BL_BR, //# Fast weak spin bottom left to bottom right BOTH_T7_BL__R, //# Fast weak spin bottom left to right BOTH_T7_BL_TR, //# Fast weak spin bottom left to top right BOTH_T7_BL__L, //# Fast arc bottom left to left //Saber Arc Transitions that use existing animations played backwards BOTH_T7_BR_TR, //# Fast arc bottom right to top right (use: BOTH_T7_TR_BR) BOTH_T7_BR_T_, //# Fast arc bottom right to top (use: BOTH_T7_T__BR) BOTH_T7__R_BR, //# Fast arc right to bottom right (use: BOTH_T7_BR__R) BOTH_T7__R_T_, //# Fast ar right to top (use: BOTH_T7_T___R) BOTH_T7_TR__R, //# Fast arc top right to right (use: BOTH_T7__R_TR) BOTH_T7_TR_T_, //# Fast arc top right to top (use: BOTH_T7_T__TR) BOTH_T7_TL__R, //# Fast arc top left to right (use: BOTH_T7__R_TL) BOTH_T7_TL_TR, //# Fast arc top left to top right (use: BOTH_T7_TR_TL) BOTH_T7_TL_T_, //# Fast arc top left to top (use: BOTH_T7_T__TL) BOTH_T7_TL__L, //# Fast arc top left to left (use: BOTH_T7__L_TL) BOTH_T7__L_TR, //# Fast arc left to top right (use: BOTH_T7_TR__L) BOTH_T7__L_T_, //# Fast arc left to top (use: BOTH_T7_T___L) BOTH_T7__L_BL, //# Fast arc left to bottom left (use: BOTH_T7_BL__L) BOTH_T7_BL_T_, //# Fast arc bottom left to top (use: BOTH_T7_T__BL) BOTH_T7_BL_TL, //# Fast arc bottom left to top left (use: BOTH_T7_TL_BL) //Saber Attack Start Transitions BOTH_S7_S7_T_, //# Fast plain transition from stance1 to top-to-bottom Fast weak attack BOTH_S7_S7__L, //# Fast plain transition from stance1 to left-to-right Fast weak attack BOTH_S7_S7__R, //# Fast plain transition from stance1 to right-to-left Fast weak attack BOTH_S7_S7_TL, //# Fast plain transition from stance1 to top-left-to-bottom-right Fast weak attack BOTH_S7_S7_BR, //# Fast plain transition from stance1 to bottom-right-to-top-left Fast weak attack BOTH_S7_S7_BL, //# Fast plain transition from stance1 to bottom-left-to-top-right Fast weak attack BOTH_S7_S7_TR, //# Fast plain transition from stance1 to top-right-to-bottom-left Fast weak attack //Saber Attack Return Transitions BOTH_R7_B__S7, //# Fast plain transition from top-to-bottom Fast weak attack to stance1 BOTH_R7__L_S7, //# Fast plain transition from left-to-right Fast weak attack to stance1 BOTH_R7__R_S7, //# Fast plain transition from right-to-left Fast weak attack to stance1 BOTH_R7_TL_S7, //# Fast plain transition from top-left-to-bottom-right Fast weak attack to stance1 BOTH_R7_BR_S7, //# Fast plain transition from bottom-right-to-top-left Fast weak attack to stance1 BOTH_R7_BL_S7, //# Fast plain transition from bottom-left-to-top-right Fast weak attack to stance1 BOTH_R7_TR_S7, //# Fast plain transition from top-right-to-bottom-left Fast weak attack //Saber Attack Bounces (first 4 frames of an attack, played backwards) BOTH_B7_BR___, //# Bounce-back if attack from BR is blocked BOTH_B7__R___, //# Bounce-back if attack from R is blocked BOTH_B7_TR___, //# Bounce-back if attack from TR is blocked BOTH_B7_T____, //# Bounce-back if attack from T is blocked BOTH_B7_TL___, //# Bounce-back if attack from TL is blocked BOTH_B7__L___, //# Bounce-back if attack from L is blocked BOTH_B7_BL___, //# Bounce-back if attack from BL is blocked //Saber Attack Deflections (last 4 frames of an attack) BOTH_D7_BR___, //# Deflection toward BR BOTH_D7__R___, //# Deflection toward R BOTH_D7_TR___, //# Deflection toward TR BOTH_D7_TL___, //# Deflection toward TL BOTH_D7__L___, //# Deflection toward L BOTH_D7_BL___, //# Deflection toward BL BOTH_D7_B____, //# Deflection toward B //Saber parry anims BOTH_P1_S1_T_, //# Block shot/saber top BOTH_P1_S1_TR, //# Block shot/saber top right BOTH_P1_S1_TL, //# Block shot/saber top left BOTH_P1_S1_BL, //# Block shot/saber bottom left BOTH_P1_S1_BR, //# Block shot/saber bottom right //Saber knockaway BOTH_K1_S1_T_, //# knockaway saber top BOTH_K1_S1_TR, //# knockaway saber top right BOTH_K1_S1_TL, //# knockaway saber top left BOTH_K1_S1_BL, //# knockaway saber bottom left BOTH_K1_S1_B_, //# knockaway saber bottom BOTH_K1_S1_BR, //# knockaway saber bottom right //Saber attack knocked away BOTH_V1_BR_S1, //# BR attack knocked away BOTH_V1__R_S1, //# R attack knocked away BOTH_V1_TR_S1, //# TR attack knocked away BOTH_V1_T__S1, //# T attack knocked away BOTH_V1_TL_S1, //# TL attack knocked away BOTH_V1__L_S1, //# L attack knocked away BOTH_V1_BL_S1, //# BL attack knocked away BOTH_V1_B__S1, //# B attack knocked away //Saber parry broken BOTH_H1_S1_T_, //# saber knocked down from top parry BOTH_H1_S1_TR, //# saber knocked down-left from TR parry BOTH_H1_S1_TL, //# saber knocked down-right from TL parry BOTH_H1_S1_BL, //# saber knocked up-right from BL parry BOTH_H1_S1_B_, //# saber knocked up over head from ready? BOTH_H1_S1_BR, //# saber knocked up-left from BR parry //Dual Saber parry anims BOTH_P6_S6_T_, //# Block shot/saber top BOTH_P6_S6_TR, //# Block shot/saber top right BOTH_P6_S6_TL, //# Block shot/saber top left BOTH_P6_S6_BL, //# Block shot/saber bottom left BOTH_P6_S6_BR, //# Block shot/saber bottom right //Dual Saber knockaway BOTH_K6_S6_T_, //# knockaway saber top BOTH_K6_S6_TR, //# knockaway saber top right BOTH_K6_S6_TL, //# knockaway saber top left BOTH_K6_S6_BL, //# knockaway saber bottom left BOTH_K6_S6_B_, //# knockaway saber bottom BOTH_K6_S6_BR, //# knockaway saber bottom right //Dual Saber attack knocked away BOTH_V6_BR_S6, //# BR attack knocked away BOTH_V6__R_S6, //# R attack knocked away BOTH_V6_TR_S6, //# TR attack knocked away BOTH_V6_T__S6, //# T attack knocked away BOTH_V6_TL_S6, //# TL attack knocked away BOTH_V6__L_S6, //# L attack knocked away BOTH_V6_BL_S6, //# BL attack knocked away BOTH_V6_B__S6, //# B attack knocked away //Dual Saber parry broken BOTH_H6_S6_T_, //# saber knocked down from top parry BOTH_H6_S6_TR, //# saber knocked down-left from TR parry BOTH_H6_S6_TL, //# saber knocked down-right from TL parry BOTH_H6_S6_BL, //# saber knocked up-right from BL parry BOTH_H6_S6_B_, //# saber knocked up over head from ready? BOTH_H6_S6_BR, //# saber knocked up-left from BR parry //SaberStaff parry anims BOTH_P7_S7_T_, //# Block shot/saber top BOTH_P7_S7_TR, //# Block shot/saber top right BOTH_P7_S7_TL, //# Block shot/saber top left BOTH_P7_S7_BL, //# Block shot/saber bottom left BOTH_P7_S7_BR, //# Block shot/saber bottom right //SaberStaff knockaway BOTH_K7_S7_T_, //# knockaway saber top BOTH_K7_S7_TR, //# knockaway saber top right BOTH_K7_S7_TL, //# knockaway saber top left BOTH_K7_S7_BL, //# knockaway saber bottom left BOTH_K7_S7_B_, //# knockaway saber bottom BOTH_K7_S7_BR, //# knockaway saber bottom right //SaberStaff attack knocked away BOTH_V7_BR_S7, //# BR attack knocked away BOTH_V7__R_S7, //# R attack knocked away BOTH_V7_TR_S7, //# TR attack knocked away BOTH_V7_T__S7, //# T attack knocked away BOTH_V7_TL_S7, //# TL attack knocked away BOTH_V7__L_S7, //# L attack knocked away BOTH_V7_BL_S7, //# BL attack knocked away BOTH_V7_B__S7, //# B attack knocked away //SaberStaff parry broken BOTH_H7_S7_T_, //# saber knocked down from top parry BOTH_H7_S7_TR, //# saber knocked down-left from TR parry BOTH_H7_S7_TL, //# saber knocked down-right from TL parry BOTH_H7_S7_BL, //# saber knocked up-right from BL parry BOTH_H7_S7_B_, //# saber knocked up over head from ready? BOTH_H7_S7_BR, //# saber knocked up-left from BR parry //Sabers locked anims //* #sep BOTH_ SABER LOCKED ANIMS //BOTH_(DL, S, ST)_(DL, S, ST)_(T, S)_(L, B, SB)_1(_W, _L) //===Single locks================================================================== //SINGLE vs. DUAL //side locks - I'm using a single and they're using dual BOTH_LK_S_DL_S_B_1_L, //normal break I lost BOTH_LK_S_DL_S_B_1_W, //normal break I won BOTH_LK_S_DL_S_L_1, //lock if I'm using single vs. a dual BOTH_LK_S_DL_S_SB_1_L, //super break I lost BOTH_LK_S_DL_S_SB_1_W, //super break I won //top locks BOTH_LK_S_DL_T_B_1_L, //normal break I lost BOTH_LK_S_DL_T_B_1_W, //normal break I won BOTH_LK_S_DL_T_L_1, //lock if I'm using single vs. a dual BOTH_LK_S_DL_T_SB_1_L, //super break I lost BOTH_LK_S_DL_T_SB_1_W, //super break I won //SINGLE vs. STAFF //side locks BOTH_LK_S_ST_S_B_1_L, //normal break I lost BOTH_LK_S_ST_S_B_1_W, //normal break I won BOTH_LK_S_ST_S_L_1, //lock if I'm using single vs. a staff BOTH_LK_S_ST_S_SB_1_L, //super break I lost BOTH_LK_S_ST_S_SB_1_W, //super break I won //top locks BOTH_LK_S_ST_T_B_1_L, //normal break I lost BOTH_LK_S_ST_T_B_1_W, //normal break I won BOTH_LK_S_ST_T_L_1, //lock if I'm using single vs. a staff BOTH_LK_S_ST_T_SB_1_L, //super break I lost BOTH_LK_S_ST_T_SB_1_W, //super break I won //SINGLE vs. SINGLE //side locks BOTH_LK_S_S_S_B_1_L, //normal break I lost BOTH_LK_S_S_S_B_1_W, //normal break I won BOTH_LK_S_S_S_L_1, //lock if I'm using single vs. a single and I initiated BOTH_LK_S_S_S_SB_1_L, //super break I lost BOTH_LK_S_S_S_SB_1_W, //super break I won //top locks BOTH_LK_S_S_T_B_1_L, //normal break I lost BOTH_LK_S_S_T_B_1_W, //normal break I won BOTH_LK_S_S_T_L_1, //lock if I'm using single vs. a single and I initiated BOTH_LK_S_S_T_SB_1_L, //super break I lost BOTH_LK_S_S_T_SB_1_W, //super break I won //===Dual Saber locks================================================================== //DUAL vs. DUAL //side locks BOTH_LK_DL_DL_S_B_1_L, //normal break I lost BOTH_LK_DL_DL_S_B_1_W, //normal break I won BOTH_LK_DL_DL_S_L_1, //lock if I'm using dual vs. dual and I initiated BOTH_LK_DL_DL_S_SB_1_L, //super break I lost BOTH_LK_DL_DL_S_SB_1_W, //super break I won //top locks BOTH_LK_DL_DL_T_B_1_L, //normal break I lost BOTH_LK_DL_DL_T_B_1_W, //normal break I won BOTH_LK_DL_DL_T_L_1, //lock if I'm using dual vs. dual and I initiated BOTH_LK_DL_DL_T_SB_1_L, //super break I lost BOTH_LK_DL_DL_T_SB_1_W, //super break I won //DUAL vs. STAFF //side locks BOTH_LK_DL_ST_S_B_1_L, //normal break I lost BOTH_LK_DL_ST_S_B_1_W, //normal break I won BOTH_LK_DL_ST_S_L_1, //lock if I'm using dual vs. a staff BOTH_LK_DL_ST_S_SB_1_L, //super break I lost BOTH_LK_DL_ST_S_SB_1_W, //super break I won //top locks BOTH_LK_DL_ST_T_B_1_L, //normal break I lost BOTH_LK_DL_ST_T_B_1_W, //normal break I won BOTH_LK_DL_ST_T_L_1, //lock if I'm using dual vs. a staff BOTH_LK_DL_ST_T_SB_1_L, //super break I lost BOTH_LK_DL_ST_T_SB_1_W, //super break I won //DUAL vs. SINGLE //side locks BOTH_LK_DL_S_S_B_1_L, //normal break I lost BOTH_LK_DL_S_S_B_1_W, //normal break I won BOTH_LK_DL_S_S_L_1, //lock if I'm using dual vs. a single BOTH_LK_DL_S_S_SB_1_L, //super break I lost BOTH_LK_DL_S_S_SB_1_W, //super break I won //top locks BOTH_LK_DL_S_T_B_1_L, //normal break I lost BOTH_LK_DL_S_T_B_1_W, //normal break I won BOTH_LK_DL_S_T_L_1, //lock if I'm using dual vs. a single BOTH_LK_DL_S_T_SB_1_L, //super break I lost BOTH_LK_DL_S_T_SB_1_W, //super break I won //===Saber Staff locks================================================================== //STAFF vs. DUAL //side locks BOTH_LK_ST_DL_S_B_1_L, //normal break I lost BOTH_LK_ST_DL_S_B_1_W, //normal break I won BOTH_LK_ST_DL_S_L_1, //lock if I'm using staff vs. dual BOTH_LK_ST_DL_S_SB_1_L, //super break I lost BOTH_LK_ST_DL_S_SB_1_W, //super break I won //top locks BOTH_LK_ST_DL_T_B_1_L, //normal break I lost BOTH_LK_ST_DL_T_B_1_W, //normal break I won BOTH_LK_ST_DL_T_L_1, //lock if I'm using staff vs. dual BOTH_LK_ST_DL_T_SB_1_L, //super break I lost BOTH_LK_ST_DL_T_SB_1_W, //super break I won //STAFF vs. STAFF //side locks BOTH_LK_ST_ST_S_B_1_L, //normal break I lost BOTH_LK_ST_ST_S_B_1_W, //normal break I won BOTH_LK_ST_ST_S_L_1, //lock if I'm using staff vs. a staff and I initiated BOTH_LK_ST_ST_S_SB_1_L, //super break I lost BOTH_LK_ST_ST_S_SB_1_W, //super break I won //top locks BOTH_LK_ST_ST_T_B_1_L, //normal break I lost BOTH_LK_ST_ST_T_B_1_W, //normal break I won BOTH_LK_ST_ST_T_L_1, //lock if I'm using staff vs. a staff and I initiated BOTH_LK_ST_ST_T_SB_1_L, //super break I lost BOTH_LK_ST_ST_T_SB_1_W, //super break I won //STAFF vs. SINGLE //side locks BOTH_LK_ST_S_S_B_1_L, //normal break I lost BOTH_LK_ST_S_S_B_1_W, //normal break I won BOTH_LK_ST_S_S_L_1, //lock if I'm using staff vs. a single BOTH_LK_ST_S_S_SB_1_L, //super break I lost BOTH_LK_ST_S_S_SB_1_W, //super break I won //top locks BOTH_LK_ST_S_T_B_1_L, //normal break I lost BOTH_LK_ST_S_T_B_1_W, //normal break I won BOTH_LK_ST_S_T_L_1, //lock if I'm using staff vs. a single BOTH_LK_ST_S_T_SB_1_L, //super break I lost BOTH_LK_ST_S_T_SB_1_W, //super break I won //Special cases for same saber style vs. each other (won't fit in nice 5-anim size lists above) BOTH_LK_S_S_S_L_2, //lock if I'm using single vs. a single and other intitiated BOTH_LK_S_S_T_L_2, //lock if I'm using single vs. a single and other initiated BOTH_LK_DL_DL_S_L_2, //lock if I'm using dual vs. dual and other initiated BOTH_LK_DL_DL_T_L_2, //lock if I'm using dual vs. dual and other initiated BOTH_LK_ST_ST_S_L_2, //lock if I'm using staff vs. a staff and other initiated BOTH_LK_ST_ST_T_L_2, //lock if I'm using staff vs. a staff and other initiated //===End Saber locks================================================================== //old locks BOTH_BF2RETURN, //# BOTH_BF2BREAK, //# BOTH_BF2LOCK, //# BOTH_BF1RETURN, //# BOTH_BF1BREAK, //# BOTH_BF1LOCK, //# BOTH_CWCIRCLE_R2__R_S1, //# BOTH_CCWCIRCLE_R2__L_S1, //# BOTH_CWCIRCLE_A2__L__R, //# BOTH_CCWCIRCLE_A2__R__L, //# BOTH_CWCIRCLEBREAK, //# BOTH_CCWCIRCLEBREAK, //# BOTH_CWCIRCLELOCK, //# BOTH_CCWCIRCLELOCK, //# //other saber anims //* #sep BOTH_ SABER MISC ANIMS BOTH_SABERFAST_STANCE, BOTH_SABERSLOW_STANCE, BOTH_SABERDUAL_STANCE, BOTH_SABERSTAFF_STANCE, BOTH_A2_STABBACK1, //# Stab saber backward BOTH_ATTACK_BACK, //# Swing around backwards and attack BOTH_JUMPFLIPSLASHDOWN1,//# BOTH_JUMPFLIPSTABDOWN,//# BOTH_FORCELEAP2_T__B_,//# BOTH_LUNGE2_B__T_,//# BOTH_CROUCHATTACKBACK1,//# //New specials for JKA: BOTH_JUMPATTACK6,//# BOTH_JUMPATTACK7,//# BOTH_SPINATTACK6,//# BOTH_SPINATTACK7,//# BOTH_S1_S6,//# From stand1 to saberdual stance - turning on your dual sabers BOTH_S6_S1,//# From dualstaff stance to stand1 - turning off your dual sabers BOTH_S1_S7,//# From stand1 to saberstaff stance - turning on your saberstaff BOTH_S7_S1,//# From saberstaff stance to stand1 - turning off your saberstaff BOTH_FORCELONGLEAP_START, BOTH_FORCELONGLEAP_ATTACK, BOTH_FORCELONGLEAP_LAND, BOTH_FORCEWALLRUNFLIP_START, BOTH_FORCEWALLRUNFLIP_END, BOTH_FORCEWALLRUNFLIP_ALT, BOTH_FORCEWALLREBOUND_FORWARD, BOTH_FORCEWALLREBOUND_LEFT, BOTH_FORCEWALLREBOUND_BACK, BOTH_FORCEWALLREBOUND_RIGHT, BOTH_FORCEWALLHOLD_FORWARD, BOTH_FORCEWALLHOLD_LEFT, BOTH_FORCEWALLHOLD_BACK, BOTH_FORCEWALLHOLD_RIGHT, BOTH_FORCEWALLRELEASE_FORWARD, BOTH_FORCEWALLRELEASE_LEFT, BOTH_FORCEWALLRELEASE_BACK, BOTH_FORCEWALLRELEASE_RIGHT, BOTH_A7_KICK_F, BOTH_A7_KICK_B, BOTH_A7_KICK_R, BOTH_A7_KICK_L, BOTH_A7_KICK_S, BOTH_A7_KICK_BF, BOTH_A7_KICK_BF_STOP, BOTH_A7_KICK_RL, BOTH_A7_KICK_F_AIR, BOTH_A7_KICK_B_AIR, BOTH_A7_KICK_R_AIR, BOTH_A7_KICK_L_AIR, BOTH_FLIP_ATTACK7, BOTH_FLIP_HOLD7, BOTH_FLIP_LAND, BOTH_PULL_IMPALE_STAB, BOTH_PULL_IMPALE_SWING, BOTH_PULLED_INAIR_B, BOTH_PULLED_INAIR_F, BOTH_STABDOWN, BOTH_STABDOWN_STAFF, BOTH_STABDOWN_DUAL, BOTH_A6_SABERPROTECT, BOTH_A7_SOULCAL, BOTH_A1_SPECIAL, BOTH_A2_SPECIAL, BOTH_A3_SPECIAL, BOTH_ROLL_STAB, //# #sep BOTH_ STANDING BOTH_STAND1, //# Standing idle, no weapon, hands down BOTH_STAND1IDLE1, //# Random standing idle BOTH_STAND2, //# Standing idle with a saber BOTH_STAND2IDLE1, //# Random standing idle BOTH_STAND2IDLE2, //# Random standing idle BOTH_STAND3, //# Standing idle with 2-handed weapon BOTH_STAND3IDLE1, //# Random standing idle BOTH_STAND4, //# hands clasp behind back BOTH_STAND5, //# standing idle, no weapon, hand down, back straight BOTH_STAND5IDLE1, //# Random standing idle BOTH_STAND6, //# one handed, gun at side, relaxed stand BOTH_STAND8, //# both hands on hips (male) BOTH_STAND1TO2, //# Transition from stand1 to stand2 BOTH_STAND2TO1, //# Transition from stand2 to stand1 BOTH_STAND2TO4, //# Transition from stand2 to stand4 BOTH_STAND4TO2, //# Transition from stand4 to stand2 BOTH_STAND4TOATTACK2, //# relaxed stand to 1-handed pistol ready BOTH_STANDUP2, //# Luke standing up from his meditation platform (cin # 37) BOTH_STAND5TOSIT3, //# transition from stand 5 to sit 3 BOTH_STAND1TOSTAND5, //# Transition from stand1 to stand5 BOTH_STAND5TOSTAND1, //# Transition from stand5 to stand1 BOTH_STAND5TOAIM, //# Transition of Kye aiming his gun at Desann (cin #9) BOTH_STAND5STARTLEDLOOKLEFT, //# Kyle turning to watch the bridge drop (cin #9) BOTH_STARTLEDLOOKLEFTTOSTAND5, //# Kyle returning to stand 5 from watching the bridge drop (cin #9) BOTH_STAND5TOSTAND8, //# Transition from stand5 to stand8 BOTH_STAND7TOSTAND8, //# Tavion putting hands on back of chair (cin #11) BOTH_STAND8TOSTAND5, //# Transition from stand8 to stand5 BOTH_STAND9, //# Kyle's standing idle, no weapon, hands down BOTH_STAND9IDLE1, //# Kyle's random standing idle BOTH_STAND5SHIFTWEIGHT, //# Weightshift from stand5 to side and back to stand5 BOTH_STAND5SHIFTWEIGHTSTART, //# From stand5 to side BOTH_STAND5SHIFTWEIGHTSTOP, //# From side to stand5 BOTH_STAND5TURNLEFTSTART, //# Start turning left from stand5 BOTH_STAND5TURNLEFTSTOP, //# Stop turning left from stand5 BOTH_STAND5TURNRIGHTSTART, //# Start turning right from stand5 BOTH_STAND5TURNRIGHTSTOP, //# Stop turning right from stand5 BOTH_STAND5LOOK180LEFTSTART, //# Start looking over left shoulder (cin #17) BOTH_STAND5LOOK180LEFTSTOP, //# Stop looking over left shoulder (cin #17) BOTH_CONSOLE1START, //# typing at a console BOTH_CONSOLE1, //# typing at a console BOTH_CONSOLE1STOP, //# typing at a console BOTH_CONSOLE2START, //# typing at a console with comm link in hand (cin #5) BOTH_CONSOLE2, //# typing at a console with comm link in hand (cin #5) BOTH_CONSOLE2STOP, //# typing at a console with comm link in hand (cin #5) BOTH_CONSOLE2HOLDCOMSTART, //# lean in to type at console while holding comm link in hand (cin #5) BOTH_CONSOLE2HOLDCOMSTOP, //# lean away after typing at console while holding comm link in hand (cin #5) BOTH_GUARD_LOOKAROUND1, //# Cradling weapon and looking around BOTH_GUARD_IDLE1, //# Cradling weapon and standing BOTH_GESTURE1, //# Generic gesture, non-specific BOTH_GESTURE2, //# Generic gesture, non-specific BOTH_WALK1TALKCOMM1, //# Talking into coom link while walking BOTH_TALK1, //# Generic talk anim BOTH_TALK2, //# Generic talk anim BOTH_TALKCOMM1START, //# Start talking into a comm link BOTH_TALKCOMM1, //# Talking into a comm link BOTH_TALKCOMM1STOP, //# Stop talking into a comm link BOTH_TALKGESTURE1, //# Generic talk anim BOTH_HEADTILTLSTART, //# Head tilt to left BOTH_HEADTILTLSTOP, //# Head tilt to left BOTH_HEADTILTRSTART, //# Head tilt to right BOTH_HEADTILTRSTOP, //# Head tilt to right BOTH_HEADNOD, //# Head shake YES BOTH_HEADSHAKE, //# Head shake NO BOTH_SIT2HEADTILTLSTART, //# Head tilt to left from seated position 2 BOTH_SIT2HEADTILTLSTOP, //# Head tilt to left from seated position 2 BOTH_REACH1START, //# Monmothma reaching for crystal BOTH_REACH1STOP, //# Monmothma reaching for crystal BOTH_COME_ON1, //# Jan gesturing to Kyle (cin #32a) BOTH_STEADYSELF1, //# Jan trying to keep footing (cin #32a) BOTH_STEADYSELF1END, //# Return hands to side from STEADSELF1 Kyle (cin#5) BOTH_SILENCEGESTURE1, //# Luke silencing Kyle with a raised hand (cin #37) BOTH_REACHFORSABER1, //# Luke holding hand out for Kyle's saber (cin #37) BOTH_SABERKILLER1, //# Tavion about to strike Jan with saber (cin #9) BOTH_SABERKILLEE1, //# Jan about to be struck by Tavion with saber (cin #9) BOTH_HUGGER1, //# Kyle hugging Jan (cin #29) BOTH_HUGGERSTOP1, //# Kyle stop hugging Jan but don't let her go (cin #29) BOTH_HUGGEE1, //# Jan being hugged (cin #29) BOTH_HUGGEESTOP1, //# Jan stop being hugged but don't let go (cin #29) BOTH_SABERTHROW1START, //# Desann throwing his light saber (cin #26) BOTH_SABERTHROW1STOP, //# Desann throwing his light saber (cin #26) BOTH_SABERTHROW2START, //# Kyle throwing his light saber (cin #32) BOTH_SABERTHROW2STOP, //# Kyle throwing his light saber (cin #32) //# #sep BOTH_ SITTING/CROUCHING BOTH_SIT1, //# Normal chair sit. BOTH_SIT2, //# Lotus position. BOTH_SIT3, //# Sitting in tired position, elbows on knees BOTH_SIT2TOSTAND5, //# Transition from sit 2 to stand 5 BOTH_STAND5TOSIT2, //# Transition from stand 5 to sit 2 BOTH_SIT2TOSIT4, //# Trans from sit2 to sit4 (cin #12) Luke leaning back from lotus position. BOTH_SIT3TOSTAND5, //# transition from sit 3 to stand 5 BOTH_CROUCH1, //# Transition from standing to crouch BOTH_CROUCH1IDLE, //# Crouching idle BOTH_CROUCH1WALK, //# Walking while crouched BOTH_CROUCH1WALKBACK, //# Walking while crouched BOTH_UNCROUCH1, //# Transition from crouch to standing BOTH_CROUCH2TOSTAND1, //# going from crouch2 to stand1 BOTH_CROUCH3, //# Desann crouching down to Kyle (cin 9) BOTH_UNCROUCH3, //# Desann uncrouching down to Kyle (cin 9) BOTH_CROUCH4, //# Slower version of crouch1 for cinematics BOTH_UNCROUCH4, //# Slower version of uncrouch1 for cinematics BOTH_GUNSIT1, //# sitting on an emplaced gun. // Swoop Vehicle animations. //* #sep BOTH_ SWOOP ANIMS BOTH_VS_MOUNT_L, //# Mount from left BOTH_VS_DISMOUNT_L, //# Dismount to left BOTH_VS_MOUNT_R, //# Mount from right (symmetry) BOTH_VS_DISMOUNT_R, //# DISMOUNT TO RIGHT (SYMMETRY) BOTH_VS_MOUNTJUMP_L, //# BOTH_VS_MOUNTTHROW, //# Land on an occupied vehicle & throw off current pilot BOTH_VS_MOUNTTHROW_L, //# Land on an occupied vehicle & throw off current pilot BOTH_VS_MOUNTTHROW_R, //# Land on an occupied vehicle & throw off current pilot BOTH_VS_MOUNTTHROWEE, //# Current pilot getting thrown off by another guy BOTH_VS_LOOKLEFT, //# Turn & Look behind and to the left (no weapon) BOTH_VS_LOOKRIGHT, //# Turn & Look behind and to the right (no weapon) BOTH_VS_TURBO, //# Hit The Turbo Button BOTH_VS_REV, //# Player looks back as swoop reverses BOTH_VS_AIR, //# Player stands up when swoop is airborn BOTH_VS_AIR_G, //# "" with Gun BOTH_VS_AIR_SL, //# "" with Saber Left BOTH_VS_AIR_SR, //# "" with Saber Right BOTH_VS_LAND, //# Player bounces down when swoop lands BOTH_VS_LAND_G, //# "" with Gun BOTH_VS_LAND_SL, //# "" with Saber Left BOTH_VS_LAND_SR, //# "" with Saber Right BOTH_VS_IDLE, //# Sit BOTH_VS_IDLE_G, //# Sit (gun) BOTH_VS_IDLE_SL, //# Sit (saber left) BOTH_VS_IDLE_SR, //# Sit (saber right) BOTH_VS_LEANL, //# Lean left BOTH_VS_LEANL_G, //# Lean left (gun) BOTH_VS_LEANL_SL, //# Lean left (saber left) BOTH_VS_LEANL_SR, //# Lean left (saber right) BOTH_VS_LEANR, //# Lean right BOTH_VS_LEANR_G, //# Lean right (gun) BOTH_VS_LEANR_SL, //# Lean right (saber left) BOTH_VS_LEANR_SR, //# Lean right (saber right) BOTH_VS_ATL_S, //# Attack left with saber BOTH_VS_ATR_S, //# Attack right with saber BOTH_VS_ATR_TO_L_S, //# Attack toss saber from right to left hand BOTH_VS_ATL_TO_R_S, //# Attack toss saber from left to right hand BOTH_VS_ATR_G, //# Attack right with gun (90) BOTH_VS_ATL_G, //# Attack left with gun (90) BOTH_VS_ATF_G, //# Attack forward with gun BOTH_VS_PAIN1, //# Pain // Added 12/04/02 by Aurelio. //* #sep BOTH_ TAUNTAUN ANIMS BOTH_VT_MOUNT_L, //# Mount from left BOTH_VT_MOUNT_R, //# Mount from right BOTH_VT_MOUNT_B, //# Mount from air, behind BOTH_VT_DISMOUNT, //# Dismount for tauntaun BOTH_VT_DISMOUNT_L, //# Dismount to tauntauns left BOTH_VT_DISMOUNT_R, //# Dismount to tauntauns right (symmetry) BOTH_VT_WALK_FWD, //# Walk forward BOTH_VT_WALK_REV, //# Walk backward BOTH_VT_WALK_FWD_L, //# walk lean left BOTH_VT_WALK_FWD_R, //# Walk lean right BOTH_VT_RUN_FWD, //# Run forward BOTH_VT_RUN_REV, //# Look backwards while running (not weapon specific) BOTH_VT_RUN_FWD_L, //# Run lean left BOTH_VT_RUN_FWD_R, //# Run lean right BOTH_VT_SLIDEF, //# Tauntaun slides forward with abrupt stop BOTH_VT_AIR, //# Tauntaun jump BOTH_VT_ATB, //# Tauntaun tail swipe BOTH_VT_PAIN1, //# Pain BOTH_VT_DEATH1, //# Die BOTH_VT_STAND, //# Stand still and breath BOTH_VT_BUCK, //# Tauntaun bucking loop animation BOTH_VT_LAND, //# Player bounces down when tauntaun lands BOTH_VT_TURBO, //# Hit The Turbo Button BOTH_VT_IDLE_SL, //# Sit (saber left) BOTH_VT_IDLE_SR, //# Sit (saber right) BOTH_VT_IDLE, //# Sit with no weapon selected BOTH_VT_IDLE1, //# Sit with no weapon selected BOTH_VT_IDLE_S, //# Sit with saber selected BOTH_VT_IDLE_G, //# Sit with gun selected BOTH_VT_IDLE_T, //# Sit with thermal grenade selected BOTH_VT_ATL_S, //# Attack left with saber BOTH_VT_ATR_S, //# Attack right with saber BOTH_VT_ATR_TO_L_S, //# Attack toss saber from right to left hand BOTH_VT_ATL_TO_R_S, //# Attack toss saber from left to right hand BOTH_VT_ATR_G, //# Attack right with gun (90) BOTH_VT_ATL_G, //# Attack left with gun (90) BOTH_VT_ATF_G, //# Attack forward with gun // Added 2/26/02 by Aurelio. //* #sep BOTH_ FIGHTER ANIMS BOTH_GEARS_OPEN, BOTH_GEARS_CLOSE, BOTH_WINGS_OPEN, BOTH_WINGS_CLOSE, BOTH_DEATH14_UNGRIP, //# Desann's end death (cin #35) BOTH_DEATH14_SITUP, //# Tavion sitting up after having been thrown (cin #23) BOTH_KNEES1, //# Tavion on her knees BOTH_KNEES2, //# Tavion on her knees looking down BOTH_KNEES2TO1, //# Transition of KNEES2 to KNEES1 //# #sep BOTH_ MOVING BOTH_WALK1, //# Normal walk BOTH_WALK2, //# Normal walk BOTH_WALK_STAFF, //# Walk with saberstaff turned on BOTH_WALKBACK_STAFF, //# Walk backwards with saberstaff turned on BOTH_WALK_DUAL, //# Walk with dual turned on BOTH_WALKBACK_DUAL, //# Walk backwards with dual turned on BOTH_WALK5, //# Tavion taunting Kyle (cin 22) BOTH_WALK6, //# Slow walk for Luke (cin 12) BOTH_WALK7, //# Fast walk BOTH_RUN1, //# Full run BOTH_RUN1START, //# Start into full run1 BOTH_RUN1STOP, //# Stop from full run1 BOTH_RUN2, //# Full run BOTH_RUN1TORUN2, //# Wampa run anim transition BOTH_RUN2TORUN1, //# Wampa run anim transition BOTH_RUN4, //# Jawa Run BOTH_RUN_STAFF, //# Run with saberstaff turned on BOTH_RUNBACK_STAFF, //# Run backwards with saberstaff turned on BOTH_RUN_DUAL, //# Run with dual turned on BOTH_RUNBACK_DUAL, //# Run backwards with dual turned on BOTH_STRAFE_LEFT1, //# Sidestep left, should loop BOTH_STRAFE_RIGHT1, //# Sidestep right, should loop BOTH_RUNSTRAFE_LEFT1, //# Sidestep left, should loop BOTH_RUNSTRAFE_RIGHT1, //# Sidestep right, should loop BOTH_TURN_LEFT1, //# Turn left, should loop BOTH_TURN_RIGHT1, //# Turn right, should loop BOTH_TURNSTAND1, //# Turn from STAND1 position BOTH_TURNSTAND2, //# Turn from STAND2 position BOTH_TURNSTAND3, //# Turn from STAND3 position BOTH_TURNSTAND4, //# Turn from STAND4 position BOTH_TURNSTAND5, //# Turn from STAND5 position BOTH_TURNCROUCH1, //# Turn from CROUCH1 position BOTH_WALKBACK1, //# Walk1 backwards BOTH_WALKBACK2, //# Walk2 backwards BOTH_RUNBACK1, //# Run1 backwards BOTH_RUNBACK2, //# Run1 backwards //# #sep BOTH_ JUMPING BOTH_JUMP1, //# Jump - wind-up and leave ground BOTH_INAIR1, //# In air loop (from jump) BOTH_LAND1, //# Landing (from in air loop) BOTH_LAND2, //# Landing Hard (from a great height) BOTH_JUMPBACK1, //# Jump backwards - wind-up and leave ground BOTH_INAIRBACK1, //# In air loop (from jump back) BOTH_LANDBACK1, //# Landing backwards(from in air loop) BOTH_JUMPLEFT1, //# Jump left - wind-up and leave ground BOTH_INAIRLEFT1, //# In air loop (from jump left) BOTH_LANDLEFT1, //# Landing left(from in air loop) BOTH_JUMPRIGHT1, //# Jump right - wind-up and leave ground BOTH_INAIRRIGHT1, //# In air loop (from jump right) BOTH_LANDRIGHT1, //# Landing right(from in air loop) BOTH_FORCEJUMP1, //# Jump - wind-up and leave ground BOTH_FORCEINAIR1, //# In air loop (from jump) BOTH_FORCELAND1, //# Landing (from in air loop) BOTH_FORCEJUMPBACK1, //# Jump backwards - wind-up and leave ground BOTH_FORCEINAIRBACK1, //# In air loop (from jump back) BOTH_FORCELANDBACK1, //# Landing backwards(from in air loop) BOTH_FORCEJUMPLEFT1, //# Jump left - wind-up and leave ground BOTH_FORCEINAIRLEFT1, //# In air loop (from jump left) BOTH_FORCELANDLEFT1, //# Landing left(from in air loop) BOTH_FORCEJUMPRIGHT1, //# Jump right - wind-up and leave ground BOTH_FORCEINAIRRIGHT1, //# In air loop (from jump right) BOTH_FORCELANDRIGHT1, //# Landing right(from in air loop) //# #sep BOTH_ ACROBATICS BOTH_FLIP_F, //# Flip forward BOTH_FLIP_B, //# Flip backwards BOTH_FLIP_L, //# Flip left BOTH_FLIP_R, //# Flip right BOTH_ROLL_F, //# Roll forward BOTH_ROLL_B, //# Roll backward BOTH_ROLL_L, //# Roll left BOTH_ROLL_R, //# Roll right BOTH_HOP_F, //# quickstep forward BOTH_HOP_B, //# quickstep backwards BOTH_HOP_L, //# quickstep left BOTH_HOP_R, //# quickstep right BOTH_DODGE_FL, //# lean-dodge forward left BOTH_DODGE_FR, //# lean-dodge forward right BOTH_DODGE_BL, //# lean-dodge backwards left BOTH_DODGE_BR, //# lean-dodge backwards right BOTH_DODGE_L, //# lean-dodge left BOTH_DODGE_R, //# lean-dodge right BOTH_DODGE_HOLD_FL, //# lean-dodge pose forward left BOTH_DODGE_HOLD_FR, //# lean-dodge pose forward right BOTH_DODGE_HOLD_BL, //# lean-dodge pose backwards left BOTH_DODGE_HOLD_BR, //# lean-dodge pose backwards right BOTH_DODGE_HOLD_L, //# lean-dodge pose left BOTH_DODGE_HOLD_R, //# lean-dodge pose right //MP taunt anims BOTH_ENGAGETAUNT, BOTH_BOW, BOTH_MEDITATE, BOTH_MEDITATE_END, BOTH_SHOWOFF_FAST, BOTH_SHOWOFF_MEDIUM, BOTH_SHOWOFF_STRONG, BOTH_SHOWOFF_DUAL, BOTH_SHOWOFF_STAFF, BOTH_VICTORY_FAST, BOTH_VICTORY_MEDIUM, BOTH_VICTORY_STRONG, BOTH_VICTORY_DUAL, BOTH_VICTORY_STAFF, //other saber/acro anims BOTH_ARIAL_LEFT, //# BOTH_ARIAL_RIGHT, //# BOTH_CARTWHEEL_LEFT, //# BOTH_CARTWHEEL_RIGHT, //# BOTH_FLIP_LEFT, //# BOTH_FLIP_BACK1, //# BOTH_FLIP_BACK2, //# BOTH_FLIP_BACK3, //# BOTH_BUTTERFLY_LEFT, //# BOTH_BUTTERFLY_RIGHT, //# BOTH_WALL_RUN_RIGHT, //# BOTH_WALL_RUN_RIGHT_FLIP,//# BOTH_WALL_RUN_RIGHT_STOP,//# BOTH_WALL_RUN_LEFT, //# BOTH_WALL_RUN_LEFT_FLIP,//# BOTH_WALL_RUN_LEFT_STOP,//# BOTH_WALL_FLIP_RIGHT, //# BOTH_WALL_FLIP_LEFT, //# BOTH_KNOCKDOWN1, //# knocked backwards BOTH_KNOCKDOWN2, //# knocked backwards hard BOTH_KNOCKDOWN3, //# knocked forwards BOTH_KNOCKDOWN4, //# knocked backwards from crouch BOTH_KNOCKDOWN5, //# dupe of 3 - will be removed BOTH_GETUP1, //# BOTH_GETUP2, //# BOTH_GETUP3, //# BOTH_GETUP4, //# BOTH_GETUP5, //# BOTH_GETUP_CROUCH_F1, //# BOTH_GETUP_CROUCH_B1, //# BOTH_FORCE_GETUP_F1, //# BOTH_FORCE_GETUP_F2, //# BOTH_FORCE_GETUP_B1, //# BOTH_FORCE_GETUP_B2, //# BOTH_FORCE_GETUP_B3, //# BOTH_FORCE_GETUP_B4, //# BOTH_FORCE_GETUP_B5, //# BOTH_FORCE_GETUP_B6, //# BOTH_GETUP_BROLL_B, //# BOTH_GETUP_BROLL_F, //# BOTH_GETUP_BROLL_L, //# BOTH_GETUP_BROLL_R, //# BOTH_GETUP_FROLL_B, //# BOTH_GETUP_FROLL_F, //# BOTH_GETUP_FROLL_L, //# BOTH_GETUP_FROLL_R, //# BOTH_WALL_FLIP_BACK1, //# BOTH_WALL_FLIP_BACK2, //# BOTH_SPIN1, //# BOTH_CEILING_CLING, //# clinging to ceiling BOTH_CEILING_DROP, //# dropping from ceiling cling //TESTING BOTH_FJSS_TR_BL, //# jump spin slash tr to bl BOTH_FJSS_TL_BR, //# jump spin slash bl to tr BOTH_RIGHTHANDCHOPPEDOFF,//# BOTH_DEFLECTSLASH__R__L_FIN,//# BOTH_BASHED1,//# BOTH_ARIAL_F1,//# BOTH_BUTTERFLY_FR1,//# BOTH_BUTTERFLY_FL1,//# //NEW SABER/JEDI/FORCE ANIMS BOTH_BACK_FLIP_UP, //# back flip up Bonus Animation!!!! BOTH_LOSE_SABER, //# player losing saber (pulled from hand by force pull 4 - Kyle?) BOTH_STAFF_TAUNT, //# taunt saberstaff BOTH_DUAL_TAUNT, //# taunt dual BOTH_A6_FB, //# dual attack front/back BOTH_A6_LR, //# dual attack left/right BOTH_A7_HILT, //# saber knock (alt + stand still) //Alora BOTH_ALORA_SPIN, //#jump spin attack death ballet BOTH_ALORA_FLIP_1, //# gymnast move 1 BOTH_ALORA_FLIP_2, //# gymnast move 2 BOTH_ALORA_FLIP_3, //# gymnast move3 BOTH_ALORA_FLIP_B, //# gymnast move back BOTH_ALORA_SPIN_THROW, //# dual saber throw BOTH_ALORA_SPIN_SLASH, //# spin slash special bonus animation!! :) BOTH_ALORA_TAUNT, //# special taunt //Rosh (Kothos battle) BOTH_ROSH_PAIN, //# hurt animation (exhausted) BOTH_ROSH_HEAL, //# healed/rejuvenated //Tavion BOTH_TAVION_SCEPTERGROUND, //# stabbing ground with sith sword shoots electricity everywhere BOTH_TAVION_SWORDPOWER,//# Tavion doing the He-Man(tm) thing BOTH_SCEPTER_START, //#Point scepter and attack start BOTH_SCEPTER_HOLD, //#Point scepter and attack hold BOTH_SCEPTER_STOP, //#Point scepter and attack stop //Kyle Boss BOTH_KYLE_GRAB, //# grab BOTH_KYLE_MISS, //# miss BOTH_KYLE_PA_1, //# hold 1 BOTH_PLAYER_PA_1, //# player getting held 1 BOTH_KYLE_PA_2, //# hold 2 BOTH_PLAYER_PA_2, //# player getting held 2 BOTH_PLAYER_PA_FLY, //# player getting knocked back from punch at end of hold 1 BOTH_KYLE_PA_3, //# hold 3 BOTH_PLAYER_PA_3, //# player getting held 3 BOTH_PLAYER_PA_3_FLY,//# player getting thrown at end of hold 3 //Rancor BOTH_BUCK_RIDER, //# Rancor bucks when someone is on him //WAMPA Grabbing enemy BOTH_HOLD_START, //# BOTH_HOLD_MISS, //# BOTH_HOLD_IDLE, //# BOTH_HOLD_END, //# BOTH_HOLD_ATTACK, //# BOTH_HOLD_SNIFF, //# Sniff the guy you're holding BOTH_HOLD_DROP, //# just drop 'em //BEING GRABBED BY WAMPA BOTH_GRABBED, //# BOTH_RELEASED, //# BOTH_HANG_IDLE, //# BOTH_HANG_ATTACK, //# BOTH_HANG_PAIN, //# //# #sep BOTH_ MISC MOVEMENT BOTH_HIT1, //# Kyle hit by crate in cin #9 BOTH_LADDER_UP1, //# Climbing up a ladder with rungs at 16 unit intervals BOTH_LADDER_DWN1, //# Climbing down a ladder with rungs at 16 unit intervals BOTH_LADDER_IDLE, //# Just sitting on the ladder //# #sep BOTH_ FLYING IDLE BOTH_FLY_SHIELDED, //# For sentry droid, shields in //# #sep BOTH_ SWIMMING BOTH_SWIM_IDLE1, //# Swimming Idle 1 BOTH_SWIMFORWARD, //# Swim forward loop BOTH_SWIMBACKWARD, //# Swim backward loop //# #sep BOTH_ LYING BOTH_SLEEP1, //# laying on back-rknee up-rhand on torso BOTH_SLEEP6START, //# Kyle leaning back to sleep (cin 20) BOTH_SLEEP6STOP, //# Kyle waking up and shaking his head (cin 21) BOTH_SLEEP1GETUP, //# alarmed and getting up out of sleep1 pose to stand BOTH_SLEEP1GETUP2, //# BOTH_CHOKE1START, //# tavion in force grip choke BOTH_CHOKE1STARTHOLD, //# loop of tavion in force grip choke BOTH_CHOKE1, //# tavion in force grip choke BOTH_CHOKE2, //# tavion recovering from force grip choke BOTH_CHOKE3, //# left-handed choke (for people still holding a weapon) //# #sep BOTH_ HUNTER-SEEKER BOT-SPECIFIC BOTH_POWERUP1, //# Wakes up BOTH_TURNON, //# Protocol Droid wakes up BOTH_TURNOFF, //# Protocol Droid shuts off BOTH_BUTTON1, //# Single button push with right hand BOTH_BUTTON2, //# Single button push with left finger BOTH_BUTTON_HOLD, //# Single button hold with left hand BOTH_BUTTON_RELEASE, //# Single button release with left hand //# JEDI-SPECIFIC //# #sep BOTH_ FORCE ANIMS BOTH_RESISTPUSH, //# plant yourself to resist force push/pulls. BOTH_FORCEPUSH, //# Use off-hand to do force power. BOTH_FORCEPULL, //# Use off-hand to do force power. BOTH_MINDTRICK1, //# Use off-hand to do mind trick BOTH_MINDTRICK2, //# Use off-hand to do distraction BOTH_FORCELIGHTNING, //# Use off-hand to do lightning BOTH_FORCELIGHTNING_START, //# Use off-hand to do lightning - start BOTH_FORCELIGHTNING_HOLD, //# Use off-hand to do lightning - hold BOTH_FORCELIGHTNING_RELEASE,//# Use off-hand to do lightning - release BOTH_FORCEHEAL_START, //# Healing meditation pose start BOTH_FORCEHEAL_STOP, //# Healing meditation pose end BOTH_FORCEHEAL_QUICK, //# Healing meditation gesture BOTH_SABERPULL, //# Use off-hand to do force power. BOTH_FORCEGRIP1, //# force-gripping (no anim?) BOTH_FORCEGRIP3, //# force-gripping (right hand) BOTH_FORCEGRIP3THROW, //# throwing while force-gripping (right hand) BOTH_FORCEGRIP_HOLD, //# Use off-hand to do grip - hold BOTH_FORCEGRIP_RELEASE,//# Use off-hand to do grip - release BOTH_TOSS1, //# throwing to left after force gripping BOTH_TOSS2, //# throwing to right after force gripping //NEW force anims for JKA: BOTH_FORCE_RAGE, BOTH_FORCE_2HANDEDLIGHTNING, BOTH_FORCE_2HANDEDLIGHTNING_START, BOTH_FORCE_2HANDEDLIGHTNING_HOLD, BOTH_FORCE_2HANDEDLIGHTNING_RELEASE, BOTH_FORCE_DRAIN, BOTH_FORCE_DRAIN_START, BOTH_FORCE_DRAIN_HOLD, BOTH_FORCE_DRAIN_RELEASE, BOTH_FORCE_DRAIN_GRAB_START, BOTH_FORCE_DRAIN_GRAB_HOLD, BOTH_FORCE_DRAIN_GRAB_END, BOTH_FORCE_DRAIN_GRABBED, BOTH_FORCE_ABSORB, BOTH_FORCE_ABSORB_START, BOTH_FORCE_ABSORB_END, BOTH_FORCE_PROTECT, BOTH_FORCE_PROTECT_FAST, BOTH_WIND, BOTH_STAND_TO_KNEEL, BOTH_KNEEL_TO_STAND, BOTH_TUSKENATTACK1, BOTH_TUSKENATTACK2, BOTH_TUSKENATTACK3, BOTH_TUSKENLUNGE1, BOTH_TUSKENTAUNT1, BOTH_COWER1_START, //# cower start BOTH_COWER1, //# cower loop BOTH_COWER1_STOP, //# cower stop BOTH_SONICPAIN_START, BOTH_SONICPAIN_HOLD, BOTH_SONICPAIN_END, //new anim slots per Jarrod's request BOTH_STAND10, BOTH_STAND10_TALK1, BOTH_STAND10_TALK2, BOTH_STAND10TOSTAND1, BOTH_STAND1_TALK1, BOTH_STAND1_TALK2, BOTH_STAND1_TALK3, BOTH_SIT4, BOTH_SIT5, BOTH_SIT5_TALK1, BOTH_SIT5_TALK2, BOTH_SIT5_TALK3, BOTH_SIT6, BOTH_SIT7, //================================================= //ANIMS IN WHICH ONLY THE UPPER OBJECTS ARE IN MD3 //================================================= //# #sep TORSO_ WEAPON-RELATED TORSO_DROPWEAP1, //# Put weapon away TORSO_DROPWEAP4, //# Put weapon away TORSO_RAISEWEAP1, //# Draw Weapon TORSO_RAISEWEAP4, //# Draw Weapon TORSO_WEAPONREADY1, //# Ready to fire stun baton TORSO_WEAPONREADY2, //# Ready to fire one-handed blaster pistol TORSO_WEAPONREADY3, //# Ready to fire blaster rifle TORSO_WEAPONREADY4, //# Ready to fire sniper rifle TORSO_WEAPONREADY10, //# Ready to fire thermal det TORSO_WEAPONIDLE2, //# Holding one-handed blaster TORSO_WEAPONIDLE3, //# Holding blaster rifle TORSO_WEAPONIDLE4, //# Holding sniper rifle TORSO_WEAPONIDLE10, //# Holding thermal det //# #sep TORSO_ MISC TORSO_SURRENDER_START, //# arms up TORSO_SURRENDER_STOP, //# arms back down TORSO_CHOKING1, //# TEMP TORSO_HANDSIGNAL1, TORSO_HANDSIGNAL2, TORSO_HANDSIGNAL3, TORSO_HANDSIGNAL4, TORSO_HANDSIGNAL5, //================================================= //ANIMS IN WHICH ONLY THE LOWER OBJECTS ARE IN MD3 //================================================= //# #sep Legs-only anims LEGS_TURN1, //# What legs do when you turn your lower body to match your upper body facing LEGS_TURN2, //# Leg turning from stand2 LEGS_LEAN_LEFT1, //# Lean left LEGS_LEAN_RIGHT1, //# Lean Right LEGS_CHOKING1, //# TEMP LEGS_LEFTUP1, //# On a slope with left foot 4 higher than right LEGS_LEFTUP2, //# On a slope with left foot 8 higher than right LEGS_LEFTUP3, //# On a slope with left foot 12 higher than right LEGS_LEFTUP4, //# On a slope with left foot 16 higher than right LEGS_LEFTUP5, //# On a slope with left foot 20 higher than right LEGS_RIGHTUP1, //# On a slope with RIGHT foot 4 higher than left LEGS_RIGHTUP2, //# On a slope with RIGHT foot 8 higher than left LEGS_RIGHTUP3, //# On a slope with RIGHT foot 12 higher than left LEGS_RIGHTUP4, //# On a slope with RIGHT foot 16 higher than left LEGS_RIGHTUP5, //# On a slope with RIGHT foot 20 higher than left LEGS_S1_LUP1, LEGS_S1_LUP2, LEGS_S1_LUP3, LEGS_S1_LUP4, LEGS_S1_LUP5, LEGS_S1_RUP1, LEGS_S1_RUP2, LEGS_S1_RUP3, LEGS_S1_RUP4, LEGS_S1_RUP5, LEGS_S3_LUP1, LEGS_S3_LUP2, LEGS_S3_LUP3, LEGS_S3_LUP4, LEGS_S3_LUP5, LEGS_S3_RUP1, LEGS_S3_RUP2, LEGS_S3_RUP3, LEGS_S3_RUP4, LEGS_S3_RUP5, LEGS_S4_LUP1, LEGS_S4_LUP2, LEGS_S4_LUP3, LEGS_S4_LUP4, LEGS_S4_LUP5, LEGS_S4_RUP1, LEGS_S4_RUP2, LEGS_S4_RUP3, LEGS_S4_RUP4, LEGS_S4_RUP5, LEGS_S5_LUP1, LEGS_S5_LUP2, LEGS_S5_LUP3, LEGS_S5_LUP4, LEGS_S5_LUP5, LEGS_S5_RUP1, LEGS_S5_RUP2, LEGS_S5_RUP3, LEGS_S5_RUP4, LEGS_S5_RUP5, LEGS_S6_LUP1, LEGS_S6_LUP2, LEGS_S6_LUP3, LEGS_S6_LUP4, LEGS_S6_LUP5, LEGS_S6_RUP1, LEGS_S6_RUP2, LEGS_S6_RUP3, LEGS_S6_RUP4, LEGS_S6_RUP5, LEGS_S7_LUP1, LEGS_S7_LUP2, LEGS_S7_LUP3, LEGS_S7_LUP4, LEGS_S7_LUP5, LEGS_S7_RUP1, LEGS_S7_RUP2, LEGS_S7_RUP3, LEGS_S7_RUP4, LEGS_S7_RUP5, //New anim as per Jarrod's request LEGS_TURN180, //====================================================== //cinematic anims //====================================================== //# #sep BOTH_ CINEMATIC-ONLY BOTH_CIN_1, //# Level specific cinematic 1 BOTH_CIN_2, //# Level specific cinematic 2 BOTH_CIN_3, //# Level specific cinematic 3 BOTH_CIN_4, //# Level specific cinematic 4 BOTH_CIN_5, //# Level specific cinematic 5 BOTH_CIN_6, //# Level specific cinematic 6 BOTH_CIN_7, //# Level specific cinematic 7 BOTH_CIN_8, //# Level specific cinematic 8 BOTH_CIN_9, //# Level specific cinematic 9 BOTH_CIN_10, //# Level specific cinematic 10 BOTH_CIN_11, //# Level specific cinematic 11 BOTH_CIN_12, //# Level specific cinematic 12 BOTH_CIN_13, //# Level specific cinematic 13 BOTH_CIN_14, //# Level specific cinematic 14 BOTH_CIN_15, //# Level specific cinematic 15 BOTH_CIN_16, //# Level specific cinematic 16 BOTH_CIN_17, //# Level specific cinematic 17 BOTH_CIN_18, //# Level specific cinematic 18 BOTH_CIN_19, //# Level specific cinematic 19 BOTH_CIN_20, //# Level specific cinematic 20 BOTH_CIN_21, //# Level specific cinematic 21 BOTH_CIN_22, //# Level specific cinematic 22 BOTH_CIN_23, //# Level specific cinematic 23 BOTH_CIN_24, //# Level specific cinematic 24 BOTH_CIN_25, //# Level specific cinematic 25 BOTH_CIN_26, //# Level specific cinematic BOTH_CIN_27, //# Level specific cinematic BOTH_CIN_28, //# Level specific cinematic BOTH_CIN_29, //# Level specific cinematic BOTH_CIN_30, //# Level specific cinematic BOTH_CIN_31, //# Level specific cinematic BOTH_CIN_32, //# Level specific cinematic BOTH_CIN_33, //# Level specific cinematic BOTH_CIN_34, //# Level specific cinematic BOTH_CIN_35, //# Level specific cinematic BOTH_CIN_36, //# Level specific cinematic BOTH_CIN_37, //# Level specific cinematic BOTH_CIN_38, //# Level specific cinematic BOTH_CIN_39, //# Level specific cinematic BOTH_CIN_40, //# Level specific cinematic BOTH_CIN_41, //# Level specific cinematic BOTH_CIN_42, //# Level specific cinematic BOTH_CIN_43, //# Level specific cinematic BOTH_CIN_44, //# Level specific cinematic BOTH_CIN_45, //# Level specific cinematic BOTH_CIN_46, //# Level specific cinematic BOTH_CIN_47, //# Level specific cinematic BOTH_CIN_48, //# Level specific cinematic BOTH_CIN_49, //# Level specific cinematic BOTH_CIN_50, //# Level specific cinematic //# #eol MAX_ANIMATIONS, MAX_TOTALANIMATIONS, } animNumber_t; #define SABER_ANIM_GROUP_SIZE (BOTH_A2_T__B_ - BOTH_A1_T__B_) #endif// #ifndef __ANIMS_H__
af3979555d2b184d661298bd9bd982c33d7aee0f
83e7dc1281874779c46dfadcc15b2bb66d8e599c
/tests/src/lv_test_conf.h
03632128a1a5c0d717e4003ecf37c8537603478d
[ "MIT" ]
permissive
lvgl/lvgl
7d51d6774d6ac71df7101fc7ded56fea4b70be01
5c984b4a5364b6455966eb3a860153806c51626f
refs/heads/master
2023-08-30T22:39:20.283922
2023-08-30T19:55:29
2023-08-30T19:55:29
60,667,730
9,296
2,218
MIT
2023-09-14T17:59:34
2016-06-08T04:14:34
C
UTF-8
C
false
false
2,501
h
lv_test_conf.h
/** * @file lv_test_conf.h * */ #ifndef LV_TEST_CONF_H #define LV_TEST_CONF_H #define LV_CONF_SUPPRESS_DEFINE_CHECK 1 #ifdef __cplusplus extern "C" { #endif /*********************** * PLATFORM CONFIGS ***********************/ #ifdef LVGL_CI_USING_SYS_HEAP #define LV_USE_STDLIB_MALLOC LV_STDLIB_CLIB #define LV_USE_STDLIB_STRING LV_STDLIB_CLIB #define LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB #define LV_USE_OS LV_OS_PTHREAD #define LV_OBJ_STYLE_CACHE 0 #endif #ifdef LVGL_CI_USING_DEF_HEAP #define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN #define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN #define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN #define LV_OBJ_STYLE_CACHE 1 #endif #ifdef MICROPYTHON #define LV_USE_BUILTIN_MALLOC 0 #define LV_USE_BUILTIN_MEMCPY 1 #define LV_USE_BUILTIN_SNPRINTF 1 #define LV_STDLIB_INCLUDE "include/lv_mp_mem_custom_include.h" #define LV_MALLOC m_malloc #define LV_REALLOC m_realloc #define LV_FREE m_free #define LV_MEMSET lv_memset_builtin #define LV_MEMCPY lv_memcpy_builtin #define LV_SNPRINTF lv_snprintf_builtin #define LV_VSNPRINTF lv_vsnprintf_builtin #define LV_STRLEN lv_strlen_builtin #define LV_STRNCPY lv_strncpy_builtin #define LV_ENABLE_GC 1 #define LV_GC_INCLUDE "py/mpstate.h" #define LV_GC_ROOT(x) MP_STATE_PORT(x) #endif void lv_test_assert_fail(void); #define LV_ASSERT_HANDLER lv_test_assert_fail(); typedef void * lv_user_data_t; /*********************** * TEST CONFIGS ***********************/ #define LV_USE_DEV_VERSION #if !(defined(LV_TEST_OPTION)) || LV_TEST_OPTION == 5 #define LV_COLOR_DEPTH 32 #define LV_DPI_DEF 160 #include "lv_test_conf_full.h" #elif LV_TEST_OPTION == 4 #define LV_COLOR_DEPTH 24 #define LV_DPI_DEF 120 #elif LV_TEST_OPTION == 3 #define LV_COLOR_DEPTH 16 #define LV_DPI_DEF 90 #include "lv_test_conf_minimal.h" #elif LV_TEST_OPTION == 2 #define LV_COLOR_DEPTH 8 #define LV_DPI_DEF 60 #include "lv_test_conf_minimal.h" #elif LV_TEST_OPTION == 1 #define LV_COLOR_DEPTH 1 #define LV_DPI_DEF 30 #include "lv_test_conf_minimal.h" #endif #if defined(LVGL_CI_USING_SYS_HEAP) || defined(LVGL_CI_USING_DEF_HEAP) #undef LV_LOG_PRINTF /*For screenshots*/ #undef LV_USE_PERF_MONITOR #undef LV_USE_MEM_MONITOR #undef LV_DPI_DEF #define LV_DPI_DEF 130 #endif #ifdef __cplusplus } /*extern "C"*/ #endif #endif /*LV_TEST_CONF_H*/
850bf9108ab5eebbb3e25622f30fb2d369bbf0df
e1cddfd754d952134e72dfd03522c5ea4fb6008e
/src/plugins/geneve/geneve_api.c
5a983948c264522422e14d65580d3a848e1cab0b
[ "Apache-2.0" ]
permissive
FDio/vpp
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
f234b0d4626d7e686422cc9dfd25958584f4931e
refs/heads/master
2023-08-31T16:09:04.068646
2022-03-14T09:49:15
2023-08-31T09:50:00
96,556,718
1,048
630
Apache-2.0
2023-06-21T05:39:17
2017-07-07T16:29:40
C
UTF-8
C
false
false
6,923
c
geneve_api.c
/* * Copyright (c) 2017 SUSE LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *------------------------------------------------------------------ */ #include <vnet/vnet.h> #include <vlibmemory/api.h> #include <vnet/interface.h> #include <vnet/api_errno.h> #include <vnet/feature/feature.h> #include <vnet/fib/fib_table.h> #include <vnet/ip/ip_types_api.h> #include <geneve/geneve.h> /* define message IDs */ #include <vnet/format_fns.h> #include <geneve/geneve.api_enum.h> #include <geneve/geneve.api_types.h> /** * Base message ID fot the plugin */ static u32 geneve_base_msg_id; #define REPLY_MSG_ID_BASE geneve_base_msg_id #include <vlibapi/api_helper_macros.h> static void vl_api_sw_interface_set_geneve_bypass_t_handler (vl_api_sw_interface_set_geneve_bypass_t * mp) { vl_api_sw_interface_set_geneve_bypass_reply_t *rmp; int rv = 0; u32 sw_if_index = ntohl (mp->sw_if_index); VALIDATE_SW_IF_INDEX (mp); vnet_int_geneve_bypass_mode (sw_if_index, mp->is_ipv6, mp->enable); BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_SW_INTERFACE_SET_GENEVE_BYPASS_REPLY); } static void vl_api_geneve_add_del_tunnel_t_handler (vl_api_geneve_add_del_tunnel_t * mp) { vl_api_geneve_add_del_tunnel_reply_t *rmp; int rv = 0; ip4_main_t *im = &ip4_main; uword *p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id)); if (!p) { rv = VNET_API_ERROR_NO_SUCH_FIB; goto out; } vnet_geneve_add_del_tunnel_args_t a = { .is_add = mp->is_add, .is_ip6 = mp->remote_address.af, .mcast_sw_if_index = ntohl (mp->mcast_sw_if_index), .encap_fib_index = p[0], .decap_next_index = ntohl (mp->decap_next_index), .vni = ntohl (mp->vni), }; ip_address_decode (&mp->remote_address, &a.remote); ip_address_decode (&mp->local_address, &a.local); /* Check src & dst are different */ if (ip46_address_cmp (&a.remote, &a.local) == 0) { rv = VNET_API_ERROR_SAME_SRC_DST; goto out; } if (ip46_address_is_multicast (&a.remote) && !vnet_sw_if_index_is_api_valid (a.mcast_sw_if_index)) { rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; goto out; } u32 sw_if_index = ~0; rv = vnet_geneve_add_del_tunnel (&a, &sw_if_index); out: /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_GENEVE_ADD_DEL_TUNNEL_REPLY, ({ rmp->sw_if_index = ntohl (sw_if_index); })); /* *INDENT-ON* */ } static void vl_api_geneve_add_del_tunnel2_t_handler (vl_api_geneve_add_del_tunnel2_t * mp) { vl_api_geneve_add_del_tunnel2_reply_t *rmp; int rv = 0; ip4_main_t *im = &ip4_main; uword *p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id)); if (!p) { rv = VNET_API_ERROR_NO_SUCH_FIB; goto out; } vnet_geneve_add_del_tunnel_args_t a = { .is_add = mp->is_add, .is_ip6 = mp->remote_address.af, .mcast_sw_if_index = ntohl (mp->mcast_sw_if_index), .encap_fib_index = p[0], .decap_next_index = ntohl (mp->decap_next_index), .vni = ntohl (mp->vni), .l3_mode = mp->l3_mode, }; ip_address_decode (&mp->remote_address, &a.remote); ip_address_decode (&mp->local_address, &a.local); /* Check src & dst are different */ if (ip46_address_cmp (&a.remote, &a.local) == 0) { rv = VNET_API_ERROR_SAME_SRC_DST; goto out; } if (ip46_address_is_multicast (&a.remote) && !vnet_sw_if_index_is_api_valid (a.mcast_sw_if_index)) { rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; goto out; } u32 sw_if_index = ~0; rv = vnet_geneve_add_del_tunnel (&a, &sw_if_index); out: /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_GENEVE_ADD_DEL_TUNNEL2_REPLY, ({ rmp->sw_if_index = ntohl (sw_if_index); })); /* *INDENT-ON* */ } static void send_geneve_tunnel_details (geneve_tunnel_t * t, vl_api_registration_t * reg, u32 context) { vl_api_geneve_tunnel_details_t *rmp; ip4_main_t *im4 = &ip4_main; ip6_main_t *im6 = &ip6_main; u8 is_ipv6 = !ip46_address_is_ip4 (&t->remote); rmp = vl_msg_api_alloc (sizeof (*rmp)); clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_GENEVE_TUNNEL_DETAILS + REPLY_MSG_ID_BASE); ip_address_encode (&t->local, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4, &rmp->src_address); ip_address_encode (&t->remote, is_ipv6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4, &rmp->dst_address); rmp->encap_vrf_id = htonl (is_ipv6 ? im6->fibs[t->encap_fib_index]. ft_table_id : im4->fibs[t->encap_fib_index].ft_table_id); rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index); rmp->vni = htonl (t->vni); rmp->decap_next_index = htonl (t->decap_next_index); rmp->sw_if_index = htonl (t->sw_if_index); rmp->context = context; vl_api_send_msg (reg, (u8 *) rmp); } static void vl_api_geneve_tunnel_dump_t_handler (vl_api_geneve_tunnel_dump_t * mp) { vl_api_registration_t *reg; geneve_main_t *vxm = &geneve_main; geneve_tunnel_t *t; u32 sw_if_index; reg = vl_api_client_index_to_registration (mp->client_index); if (!reg) return; sw_if_index = ntohl (mp->sw_if_index); if (~0 == sw_if_index) { /* *INDENT-OFF* */ pool_foreach (t, vxm->tunnels) { send_geneve_tunnel_details(t, reg, mp->context); } /* *INDENT-ON* */ } else { if ((sw_if_index >= vec_len (vxm->tunnel_index_by_sw_if_index)) || (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index])) { return; } t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]]; send_geneve_tunnel_details (t, reg, mp->context); } } /* * geneve_api_hookup * Add geneve's API message handlers to the table. */ /* API definitions */ #include <vnet/format_fns.h> #include <geneve/geneve.api.c> static clib_error_t * geneve_api_hookup (vlib_main_t * vm) { api_main_t *am = vlibapi_get_main (); /* * Set up the (msg_name, crc, message-id) table */ geneve_base_msg_id = setup_message_id_table (); vl_api_increase_msg_trace_size ( am, VL_API_GENEVE_ADD_DEL_TUNNEL + REPLY_MSG_ID_BASE, 16 * sizeof (u32)); return 0; } VLIB_API_INIT_FUNCTION (geneve_api_hookup); #include <vlib/unix/plugin.h> #include <vpp/app/version.h> /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, .description = "GENEVE Tunnels", }; /* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */
bb282410768b96a6a3b261eefb9a9aa0f6935319
883bba35d3074b1836efe5f96e2682e2ae2d8cae
/UniversalWindowsPlatformSamples/CSharpProjectExample/bin/Il2CppOutputProject/Source/il2cppOutput/WindowsRuntimeMetadata_CodeGen.c
f1867527309efc93498655492ae1b79bf9a2e9af
[ "MIT" ]
permissive
Unity-Technologies/DesktopSamples
3dabe5cbafae64479d87c3ed993630f6a755e3a2
835e350c2517ddd65302159053447f35ad50666e
refs/heads/master
2023-07-18T19:45:01.327055
2022-03-04T00:42:41
2022-03-04T00:42:41
218,365,346
200
84
MIT
2020-02-12T01:05:53
2019-10-29T19:17:52
C++
UTF-8
C
false
false
39,053
c
WindowsRuntimeMetadata_CodeGen.c
#include "pch-c.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include "codegen/il2cpp-codegen-metadata.h" // 0x00000001 Windows.Foundation.Collections.IIterator`1<T> Windows.Foundation.Collections.IIterable`1::First() // 0x00000002 T Windows.Foundation.Collections.IIterator`1::get_Current() // 0x00000003 System.Boolean Windows.Foundation.Collections.IIterator`1::get_HasCurrent() // 0x00000004 System.Boolean Windows.Foundation.Collections.IIterator`1::MoveNext() // 0x00000005 System.UInt32 Windows.Foundation.Collections.IIterator`1::GetMany(T[]) // 0x00000006 K Windows.Foundation.Collections.IKeyValuePair`2::get_Key() // 0x00000007 V Windows.Foundation.Collections.IKeyValuePair`2::get_Value() // 0x00000008 V Windows.Foundation.Collections.IMapView`2::Lookup(K) // 0x00000009 System.UInt32 Windows.Foundation.Collections.IMapView`2::get_Size() // 0x0000000A System.Boolean Windows.Foundation.Collections.IMapView`2::HasKey(K) // 0x0000000B System.Void Windows.Foundation.Collections.IMapView`2::Split(System.Collections.Generic.IReadOnlyDictionary`2<K,V>&,System.Collections.Generic.IReadOnlyDictionary`2<K,V>&) // 0x0000000C V Windows.Foundation.Collections.IMap`2::Lookup(K) // 0x0000000D System.UInt32 Windows.Foundation.Collections.IMap`2::get_Size() // 0x0000000E System.Boolean Windows.Foundation.Collections.IMap`2::HasKey(K) // 0x0000000F System.Collections.Generic.IReadOnlyDictionary`2<K,V> Windows.Foundation.Collections.IMap`2::GetView() // 0x00000010 System.Boolean Windows.Foundation.Collections.IMap`2::Insert(K,V) // 0x00000011 System.Void Windows.Foundation.Collections.IMap`2::Remove(K) // 0x00000012 System.Void Windows.Foundation.Collections.IMap`2::Clear() // 0x00000013 T Windows.Foundation.Collections.IVectorView`1::GetAt(System.UInt32) // 0x00000014 System.UInt32 Windows.Foundation.Collections.IVectorView`1::get_Size() // 0x00000015 System.Boolean Windows.Foundation.Collections.IVectorView`1::IndexOf(T,System.UInt32&) // 0x00000016 System.UInt32 Windows.Foundation.Collections.IVectorView`1::GetMany(System.UInt32,T[]) // 0x00000017 T Windows.Foundation.Collections.IVector`1::GetAt(System.UInt32) // 0x00000018 System.UInt32 Windows.Foundation.Collections.IVector`1::get_Size() // 0x00000019 System.Collections.Generic.IReadOnlyList`1<T> Windows.Foundation.Collections.IVector`1::GetView() // 0x0000001A System.Boolean Windows.Foundation.Collections.IVector`1::IndexOf(T,System.UInt32&) // 0x0000001B System.Void Windows.Foundation.Collections.IVector`1::SetAt(System.UInt32,T) // 0x0000001C System.Void Windows.Foundation.Collections.IVector`1::InsertAt(System.UInt32,T) // 0x0000001D System.Void Windows.Foundation.Collections.IVector`1::RemoveAt(System.UInt32) // 0x0000001E System.Void Windows.Foundation.Collections.IVector`1::Append(T) // 0x0000001F System.Void Windows.Foundation.Collections.IVector`1::RemoveAtEnd() // 0x00000020 System.Void Windows.Foundation.Collections.IVector`1::Clear() // 0x00000021 System.UInt32 Windows.Foundation.Collections.IVector`1::GetMany(System.UInt32,T[]) // 0x00000022 System.Void Windows.Foundation.Collections.IVector`1::ReplaceAll(T[]) // 0x00000023 System.Void Windows.Foundation.EventHandler`1::.ctor(System.Object,System.IntPtr) // 0x00000024 System.Void Windows.Foundation.EventHandler`1::Invoke(System.Object,T) // 0x00000025 System.Void Windows.Foundation.IAsyncAction::$__Stripped0_put_Completed() // 0x00000026 System.Void Windows.Foundation.IAsyncAction::$__Stripped1_get_Completed() // 0x00000027 System.Void Windows.Foundation.IAsyncAction::$__Stripped2_GetResults() // 0x00000028 System.Void Windows.Foundation.IAsyncInfo::$__Stripped0_get_Id() // 0x00000029 System.Void Windows.Foundation.IAsyncInfo::$__Stripped1_get_Status() // 0x0000002A System.Void Windows.Foundation.IAsyncInfo::$__Stripped2_get_ErrorCode() // 0x0000002B System.Void Windows.Foundation.IAsyncInfo::$__Stripped3_Cancel() // 0x0000002C System.Void Windows.Foundation.IAsyncInfo::$__Stripped4_Close() // 0x0000002D System.Void Windows.Foundation.IClosable::Close() extern void IClosable_Close_m7DE2119A960C4E3898E6E5D03245D047BF113999 (void); // 0x0000002E Windows.Foundation.PropertyType Windows.Foundation.IPropertyValue::get_Type() extern void IPropertyValue_get_Type_m2BC440F5119A133BE4DD895657519ADAA3B34272 (void); // 0x0000002F System.Boolean Windows.Foundation.IPropertyValue::get_IsNumericScalar() extern void IPropertyValue_get_IsNumericScalar_mC8DE97926668A5F2EA3F4A9B128E966CBC7B0D60 (void); // 0x00000030 System.Byte Windows.Foundation.IPropertyValue::GetUInt8() extern void IPropertyValue_GetUInt8_m25D96C5F9AC133BF7B682C59FE83EE05A0075B05 (void); // 0x00000031 System.Int16 Windows.Foundation.IPropertyValue::GetInt16() extern void IPropertyValue_GetInt16_mBE4A7DC8A2B92F83EE058AE7515E84DADFA206AE (void); // 0x00000032 System.UInt16 Windows.Foundation.IPropertyValue::GetUInt16() extern void IPropertyValue_GetUInt16_mCF513D800195CA7050FD5AFB4E710FB0CFB531B5 (void); // 0x00000033 System.Int32 Windows.Foundation.IPropertyValue::GetInt32() extern void IPropertyValue_GetInt32_mDE5543C20D3D3C9E773CB6EDBDBC789D12CC59BA (void); // 0x00000034 System.UInt32 Windows.Foundation.IPropertyValue::GetUInt32() extern void IPropertyValue_GetUInt32_mD48C2097876EAE6D1E218D9123F58F168B374205 (void); // 0x00000035 System.Int64 Windows.Foundation.IPropertyValue::GetInt64() extern void IPropertyValue_GetInt64_m4BAC154BEC3584DF3E34EDA6033EEF3DB6D4132E (void); // 0x00000036 System.UInt64 Windows.Foundation.IPropertyValue::GetUInt64() extern void IPropertyValue_GetUInt64_m981379F85C0C44EDBDD830A293693BE0BB3F62CA (void); // 0x00000037 System.Single Windows.Foundation.IPropertyValue::GetSingle() extern void IPropertyValue_GetSingle_mED031D57B17B0F7BD3B4B250821D070155889F1F (void); // 0x00000038 System.Double Windows.Foundation.IPropertyValue::GetDouble() extern void IPropertyValue_GetDouble_mA0880A7E89CE09C2639D6F8065B18E8F77EB082F (void); // 0x00000039 System.Char Windows.Foundation.IPropertyValue::GetChar16() extern void IPropertyValue_GetChar16_m7B2226E30F72B0CCAE54B8EDB1AC4ACF1BE860A8 (void); // 0x0000003A System.Boolean Windows.Foundation.IPropertyValue::GetBoolean() extern void IPropertyValue_GetBoolean_m21FCEEA690B32CD86A36D40FB837FC7D894D5587 (void); // 0x0000003B System.String Windows.Foundation.IPropertyValue::GetString() extern void IPropertyValue_GetString_m8D5702E4E1C67366D65DA23CA2812D6572DF819C (void); // 0x0000003C System.Guid Windows.Foundation.IPropertyValue::GetGuid() extern void IPropertyValue_GetGuid_m885F2850B49DB4B046564BC5FE414256801D9A11 (void); // 0x0000003D System.DateTimeOffset Windows.Foundation.IPropertyValue::GetDateTime() extern void IPropertyValue_GetDateTime_m023A766ED6FC58B347CF6F777F5C18C6AE246A3C (void); // 0x0000003E System.TimeSpan Windows.Foundation.IPropertyValue::GetTimeSpan() extern void IPropertyValue_GetTimeSpan_m063CE76264EDAF37A1DA3CA5C9CF4AF85D8FC239 (void); // 0x0000003F Windows.Foundation.Point Windows.Foundation.IPropertyValue::GetPoint() extern void IPropertyValue_GetPoint_m014D5E859273BA28DE642E38438EDCC64AB5C41B (void); // 0x00000040 Windows.Foundation.Size Windows.Foundation.IPropertyValue::GetSize() extern void IPropertyValue_GetSize_m0A952D186E59BEA03E6185EDEBAC26D544AFADAC (void); // 0x00000041 Windows.Foundation.Rect Windows.Foundation.IPropertyValue::GetRect() extern void IPropertyValue_GetRect_m0A96600149C7E6A493B8420CB316938AEF9A1A06 (void); // 0x00000042 System.Void Windows.Foundation.IPropertyValue::GetUInt8Array(System.Byte[]&) extern void IPropertyValue_GetUInt8Array_m540E0503D8CFAE2579D449884B6AA883509C79D1 (void); // 0x00000043 System.Void Windows.Foundation.IPropertyValue::GetInt16Array(System.Int16[]&) extern void IPropertyValue_GetInt16Array_m279C289854DE8A2D45A6B6B09112DD9D2F0DF849 (void); // 0x00000044 System.Void Windows.Foundation.IPropertyValue::GetUInt16Array(System.UInt16[]&) extern void IPropertyValue_GetUInt16Array_m090AA712F6BB39F869BCC5CB90236377EE8673B1 (void); // 0x00000045 System.Void Windows.Foundation.IPropertyValue::GetInt32Array(System.Int32[]&) extern void IPropertyValue_GetInt32Array_mADF499B8CD16185128795A7B74D63E8CFE692B9A (void); // 0x00000046 System.Void Windows.Foundation.IPropertyValue::GetUInt32Array(System.UInt32[]&) extern void IPropertyValue_GetUInt32Array_m9B44B8D2EA2907A9A96ED653ACEF04873D9483F8 (void); // 0x00000047 System.Void Windows.Foundation.IPropertyValue::GetInt64Array(System.Int64[]&) extern void IPropertyValue_GetInt64Array_m9A04AC5F477463928280B42E2C40F13B15A1D564 (void); // 0x00000048 System.Void Windows.Foundation.IPropertyValue::GetUInt64Array(System.UInt64[]&) extern void IPropertyValue_GetUInt64Array_m776484C9C41D5A03991D89401FF84F9D425D6A5E (void); // 0x00000049 System.Void Windows.Foundation.IPropertyValue::GetSingleArray(System.Single[]&) extern void IPropertyValue_GetSingleArray_m1E9CE76FA942B3AFA8995FBAE605E84733917B57 (void); // 0x0000004A System.Void Windows.Foundation.IPropertyValue::GetDoubleArray(System.Double[]&) extern void IPropertyValue_GetDoubleArray_m5DAB086BEB4816CAF7553E325B91A4B0B07953A5 (void); // 0x0000004B System.Void Windows.Foundation.IPropertyValue::GetChar16Array(System.Char[]&) extern void IPropertyValue_GetChar16Array_m2C69248F68D7705FE44FA8F777B061FA77C706A1 (void); // 0x0000004C System.Void Windows.Foundation.IPropertyValue::GetBooleanArray(System.Boolean[]&) extern void IPropertyValue_GetBooleanArray_m083CB5579BC465B4D1BD84CE8382CB747A9FCC8C (void); // 0x0000004D System.Void Windows.Foundation.IPropertyValue::GetStringArray(System.String[]&) extern void IPropertyValue_GetStringArray_m680617C6226187D28C4978B710AFBB8581AAC98F (void); // 0x0000004E System.Void Windows.Foundation.IPropertyValue::GetInspectableArray(System.Object[]&) extern void IPropertyValue_GetInspectableArray_m6DCBE370A8CAC129E6D6BD91C6503D14A8109F79 (void); // 0x0000004F System.Void Windows.Foundation.IPropertyValue::GetGuidArray(System.Guid[]&) extern void IPropertyValue_GetGuidArray_mE9983D9B5EE9AC1935C3EBD2F9E82DC7188E1D07 (void); // 0x00000050 System.Void Windows.Foundation.IPropertyValue::GetDateTimeArray(System.DateTimeOffset[]&) extern void IPropertyValue_GetDateTimeArray_mEECFC6C321405CDBC425D321E2A8EF3E7BC306A7 (void); // 0x00000051 System.Void Windows.Foundation.IPropertyValue::GetTimeSpanArray(System.TimeSpan[]&) extern void IPropertyValue_GetTimeSpanArray_mEAF3CA18AA928DAF3046F0F530B9324711650167 (void); // 0x00000052 System.Void Windows.Foundation.IPropertyValue::GetPointArray(Windows.Foundation.Point[]&) extern void IPropertyValue_GetPointArray_mD4ACB0F49C7BFEC1C03A4EE4263B23B2040CECD0 (void); // 0x00000053 System.Void Windows.Foundation.IPropertyValue::GetSizeArray(Windows.Foundation.Size[]&) extern void IPropertyValue_GetSizeArray_m3C079B4191330FAC3B2131D308C825BC72A5F0DC (void); // 0x00000054 System.Void Windows.Foundation.IPropertyValue::GetRectArray(Windows.Foundation.Rect[]&) extern void IPropertyValue_GetRectArray_m09598924D31716E1E653AE941186F8B16EA11A87 (void); // 0x00000055 T[] Windows.Foundation.IReferenceArray`1::get_Value() // 0x00000056 T Windows.Foundation.IReference`1::get_Value() // 0x00000057 System.String Windows.Foundation.IStringable::ToString() extern void IStringable_ToString_mAACC01E89FA76E5F4B95116FDC1CF4DBE2ECC692 (void); // 0x00000058 System.Void Windows.Foundation.Metadata.ActivatableAttribute::.ctor(System.Type,System.UInt32,System.String) extern void ActivatableAttribute__ctor_mD46F484204EAC5CFA97A677EEA9E3057B7EB0A1D (void); // 0x00000059 System.Void Windows.Foundation.Metadata.AllowMultipleAttribute::.ctor() extern void AllowMultipleAttribute__ctor_m38B472E44C36B692E88FB0E3371F49F89190B767 (void); // 0x0000005A System.Void Windows.Foundation.Metadata.ApiContractAttribute::.ctor() extern void ApiContractAttribute__ctor_mA1DC183FCECA2802E9B2A8784EEB2CDDCDB499AE (void); // 0x0000005B System.Void Windows.Foundation.Metadata.AttributeNameAttribute::.ctor(System.String) extern void AttributeNameAttribute__ctor_m7A11A1D60B4EB01C76419064CE4D848B01940844 (void); // 0x0000005C System.Void Windows.Foundation.Metadata.AttributeUsageAttribute::.ctor(System.AttributeTargets) extern void AttributeUsageAttribute__ctor_m5750318D560E5564D46D234B358B09886EA21FA7 (void); // 0x0000005D System.Void Windows.Foundation.Metadata.ContractVersionAttribute::.ctor(System.UInt32) extern void ContractVersionAttribute__ctor_m7105FB71D69F6B212C5EF0FC82B2FF1AD6278822 (void); // 0x0000005E System.Void Windows.Foundation.Metadata.ContractVersionAttribute::.ctor(System.Type,System.UInt32) extern void ContractVersionAttribute__ctor_mA259C171AB6F3483FBEBBA7095A5764E1C34F6D2 (void); // 0x0000005F System.Void Windows.Foundation.Metadata.ContractVersionAttribute::.ctor(System.String,System.UInt32) extern void ContractVersionAttribute__ctor_mA7901265471AF7521D3B4F1CDC61EFD4D8F67ADE (void); // 0x00000060 System.Void Windows.Foundation.Metadata.DefaultAttribute::.ctor() extern void DefaultAttribute__ctor_m4354570F424E2E8EFA55798F175E9ED96F73B73F (void); // 0x00000061 System.Void Windows.Foundation.Metadata.DualApiPartitionAttribute::.ctor() extern void DualApiPartitionAttribute__ctor_m9CDBECBCF7007920F8904A4454A42116AFA721C1 (void); // 0x00000062 System.Void Windows.Foundation.Metadata.ExclusiveToAttribute::.ctor(System.Type) extern void ExclusiveToAttribute__ctor_m4B131B7E52F8AEB7771DA727EE9AA091DFE26F61 (void); // 0x00000063 System.Void Windows.Foundation.Metadata.GuidAttribute::.ctor(System.UInt32,System.UInt16,System.UInt16,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte,System.Byte) extern void GuidAttribute__ctor_mF2EF6CA62F02E1EA45916B732D379377C761A3A7 (void); // 0x00000064 System.Void Windows.Foundation.Metadata.LengthIsAttribute::.ctor(System.Int32) extern void LengthIsAttribute__ctor_mAF7D4E8E12B5FE659DE4B33FD4894E8029ADC46E (void); // 0x00000065 System.Void Windows.Foundation.Metadata.MarshalingBehaviorAttribute::.ctor(Windows.Foundation.Metadata.MarshalingType) extern void MarshalingBehaviorAttribute__ctor_m86B470D1DE8EC24E115185A6E2B7BF37F581C9E0 (void); // 0x00000066 System.Void Windows.Foundation.Metadata.StaticAttribute::.ctor(System.Type,System.UInt32,System.String) extern void StaticAttribute__ctor_mF97BB39BD47CAEF0DBBA6BC0C73E5A8EB2D413DD (void); // 0x00000067 System.Void Windows.Foundation.Metadata.ThreadingAttribute::.ctor(Windows.Foundation.Metadata.ThreadingModel) extern void ThreadingAttribute__ctor_m0B875434197471A46358686EE66D4D1A7BAF8C48 (void); // 0x00000068 System.Void Windows.Foundation.Metadata.WebHostHiddenAttribute::.ctor() extern void WebHostHiddenAttribute__ctor_m682515FD2F960F1DD70B4A60AE35D02187FFE00A (void); // 0x00000069 Windows.ApplicationModel.Activation.ActivationKind Windows.ApplicationModel.Activation.IActivatedEventArgs::get_Kind() extern void IActivatedEventArgs_get_Kind_m73BC5142E2C7ACF55FF10C526DFBF0FD838D64DB (void); // 0x0000006A Windows.ApplicationModel.Activation.ApplicationExecutionState Windows.ApplicationModel.Activation.IActivatedEventArgs::get_PreviousExecutionState() extern void IActivatedEventArgs_get_PreviousExecutionState_m82E28EFF709D256E076C432EC6778A070BC2E1D1 (void); // 0x0000006B System.Void Windows.ApplicationModel.Activation.IActivatedEventArgs::$__Stripped0_get_SplashScreen() // 0x0000006C System.Void Windows.ApplicationModel.Activation.IActivatedEventArgsWithUser::$__Stripped0_get_User() // 0x0000006D System.Void Windows.ApplicationModel.Activation.IApplicationViewActivatedEventArgs::$__Stripped0_get_CurrentlyShownApplicationViewId() // 0x0000006E System.Uri Windows.ApplicationModel.Activation.IProtocolActivatedEventArgs::get_Uri() extern void IProtocolActivatedEventArgs_get_Uri_mAAB4DD042BD82651187C3A3DDF750B6AF2246AA6 (void); // 0x0000006F System.Void Windows.ApplicationModel.Activation.IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData::$__Stripped0_get_CallerPackageFamilyName() // 0x00000070 System.Void Windows.ApplicationModel.Activation.IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData::$__Stripped1_get_Data() // 0x00000071 System.Void Windows.ApplicationModel.Activation.IViewSwitcherProvider::$__Stripped0_get_ViewSwitcher() // 0x00000072 System.Uri Windows.ApplicationModel.Activation.ProtocolActivatedEventArgs::get_Uri() extern void ProtocolActivatedEventArgs_get_Uri_m5A17C77CB881E850E73CE949ABFEE9A149800041 (void); // 0x00000073 Windows.ApplicationModel.Activation.ActivationKind Windows.ApplicationModel.Activation.ProtocolActivatedEventArgs::get_Kind() extern void ProtocolActivatedEventArgs_get_Kind_m18D53BFB387CD918D825115ADD9A1B562FE1F35F (void); // 0x00000074 Windows.ApplicationModel.Activation.ApplicationExecutionState Windows.ApplicationModel.Activation.ProtocolActivatedEventArgs::get_PreviousExecutionState() extern void ProtocolActivatedEventArgs_get_PreviousExecutionState_m5B46957C4849A64AB7BD0DEC30B87B396D0C734B (void); // 0x00000075 System.Void Windows.ApplicationModel.Activation.ProtocolActivatedEventArgs::Finalize() extern void ProtocolActivatedEventArgs_Finalize_mAB843542D0132A72347771D13D52CCC777D1FA63 (void); // 0x00000076 System.String Windows.Foundation.IUriEscapeStatics::UnescapeComponent(System.String) // 0x00000077 System.String Windows.Foundation.IUriEscapeStatics::EscapeComponent(System.String) // 0x00000078 System.String Windows.Foundation.IUriRuntimeClass::get_AbsoluteUri() // 0x00000079 System.String Windows.Foundation.IUriRuntimeClass::get_DisplayUri() // 0x0000007A System.String Windows.Foundation.IUriRuntimeClass::get_Domain() // 0x0000007B System.String Windows.Foundation.IUriRuntimeClass::get_Extension() // 0x0000007C System.String Windows.Foundation.IUriRuntimeClass::get_Fragment() // 0x0000007D System.String Windows.Foundation.IUriRuntimeClass::get_Host() // 0x0000007E System.String Windows.Foundation.IUriRuntimeClass::get_Password() // 0x0000007F System.String Windows.Foundation.IUriRuntimeClass::get_Path() // 0x00000080 System.String Windows.Foundation.IUriRuntimeClass::get_Query() // 0x00000081 Windows.Foundation.WwwFormUrlDecoder Windows.Foundation.IUriRuntimeClass::get_QueryParsed() // 0x00000082 System.String Windows.Foundation.IUriRuntimeClass::get_RawUri() extern void IUriRuntimeClass_get_RawUri_mA70F86F9BE3F3D07D4BBB8D5079D13A60D194891 (void); // 0x00000083 System.String Windows.Foundation.IUriRuntimeClass::get_SchemeName() // 0x00000084 System.String Windows.Foundation.IUriRuntimeClass::get_UserName() // 0x00000085 System.Int32 Windows.Foundation.IUriRuntimeClass::get_Port() // 0x00000086 System.Boolean Windows.Foundation.IUriRuntimeClass::get_Suspicious() // 0x00000087 System.Boolean Windows.Foundation.IUriRuntimeClass::Equals(System.Uri) // 0x00000088 System.Uri Windows.Foundation.IUriRuntimeClass::CombineUri(System.String) // 0x00000089 System.Uri Windows.Foundation.IUriRuntimeClassFactory::CreateUri(System.String) // 0x0000008A System.Uri Windows.Foundation.IUriRuntimeClassFactory::CreateWithRelativeUri(System.String,System.String) // 0x0000008B System.String Windows.Foundation.IUriRuntimeClassWithAbsoluteCanonicalUri::get_AbsoluteCanonicalUri() // 0x0000008C System.String Windows.Foundation.IUriRuntimeClassWithAbsoluteCanonicalUri::get_DisplayIri() // 0x0000008D System.Void Windows.Foundation.IWwwFormUrlDecoderEntry::$__Stripped0_get_Name() // 0x0000008E System.Void Windows.Foundation.IWwwFormUrlDecoderEntry::$__Stripped1_get_Value() // 0x0000008F System.Void Windows.Foundation.IWwwFormUrlDecoderRuntimeClass::$__Stripped0_GetFirstValueByName() // 0x00000090 System.Void Windows.Foundation.IWwwFormUrlDecoderRuntimeClassFactory::$__Stripped0_CreateWwwFormUrlDecoder() // 0x00000091 System.Void Windows.Foundation.Uri::.ctor(System.String) extern void Uri__ctor_m0D439C7728FEE1D4F2B88E215C2D59A58C5FBE65 (void); // 0x00000092 System.Void Windows.Foundation.Uri::.ctor(System.String,System.String) extern void Uri__ctor_m41548CFDC457565BE64EC6CF236A0D08D1ED2500 (void); // 0x00000093 System.String Windows.Foundation.Uri::get_AbsoluteUri() extern void Uri_get_AbsoluteUri_mBD430BA219541014CC78A817674F7E63FFD6439E (void); // 0x00000094 System.String Windows.Foundation.Uri::get_DisplayUri() extern void Uri_get_DisplayUri_mC840108DF8A1051D01E3CF7D3D3D311EFF19B654 (void); // 0x00000095 System.String Windows.Foundation.Uri::get_Domain() extern void Uri_get_Domain_m35368704392605936428C37AFE157E9CE5413937 (void); // 0x00000096 System.String Windows.Foundation.Uri::get_Extension() extern void Uri_get_Extension_m8142ECBA0B93DC4AEC1810E7F40B3594D3E640E6 (void); // 0x00000097 System.String Windows.Foundation.Uri::get_Fragment() extern void Uri_get_Fragment_mF20EFE395740FD3CC9D5F7ACCAE6BDFB69797E7D (void); // 0x00000098 System.String Windows.Foundation.Uri::get_Host() extern void Uri_get_Host_m07327214CF731421F1B74B2BFF29EFE140F595A5 (void); // 0x00000099 System.String Windows.Foundation.Uri::get_Password() extern void Uri_get_Password_mFB9F08FC30386D1C5D9AF21E18F76E8BD1ED6933 (void); // 0x0000009A System.String Windows.Foundation.Uri::get_Path() extern void Uri_get_Path_m4EBFEC3B98C08E5B0BFB759C3517980CBD42CF7B (void); // 0x0000009B System.String Windows.Foundation.Uri::get_Query() extern void Uri_get_Query_mA89D787B4617536BCC50D367D1ECD586989722F1 (void); // 0x0000009C Windows.Foundation.WwwFormUrlDecoder Windows.Foundation.Uri::get_QueryParsed() extern void Uri_get_QueryParsed_mAF4520F289FD311BDA5E2002FCDE57445E89840D (void); // 0x0000009D System.String Windows.Foundation.Uri::get_RawUri() extern void Uri_get_RawUri_m0F1B0FA3F111F707620C43083ECEB89851D1B5A5 (void); // 0x0000009E System.String Windows.Foundation.Uri::get_SchemeName() extern void Uri_get_SchemeName_m97AC67427E5EA0CBB76899709108D110088723DC (void); // 0x0000009F System.String Windows.Foundation.Uri::get_UserName() extern void Uri_get_UserName_m826B8707FD4FBEF72C3B1CA82A504C213EB89C6E (void); // 0x000000A0 System.Int32 Windows.Foundation.Uri::get_Port() extern void Uri_get_Port_mFBAAAB48EE34DF72F1BF2EE645B71CC58254FC9F (void); // 0x000000A1 System.Boolean Windows.Foundation.Uri::get_Suspicious() extern void Uri_get_Suspicious_mD493F8FE1FC1AAC6E12339862503C11BCC2E8FD2 (void); // 0x000000A2 System.Boolean Windows.Foundation.Uri::Equals(System.Uri) extern void Uri_Equals_m559A85A0315D7546E7094024EEDBCAC9F619D2FF (void); // 0x000000A3 System.Uri Windows.Foundation.Uri::CombineUri(System.String) extern void Uri_CombineUri_mBD3BF069E31739C01F855B60ECA8B183930ED355 (void); // 0x000000A4 System.String Windows.Foundation.Uri::get_AbsoluteCanonicalUri() extern void Uri_get_AbsoluteCanonicalUri_m3415A1854346950B0AC7B6D19D31B0394C0CF007 (void); // 0x000000A5 System.String Windows.Foundation.Uri::get_DisplayIri() extern void Uri_get_DisplayIri_mFB2216CA1CC976FC636B460D4C7D66C6836CF1B8 (void); // 0x000000A6 System.String Windows.Foundation.Uri::ToString() extern void Uri_ToString_m38F6D46B11B7C342DE117A4968556878798E1715 (void); // 0x000000A7 System.String Windows.Foundation.Uri::UnescapeComponent(System.String) extern void Uri_UnescapeComponent_m9AB29B6D922AC549CEE1D3A9BABC8AF9761624F7 (void); // 0x000000A8 System.String Windows.Foundation.Uri::EscapeComponent(System.String) extern void Uri_EscapeComponent_m6C43EC4D66038917B17FA8042996E6EC121306D0 (void); // 0x000000A9 System.Void Windows.Foundation.Uri::Finalize() extern void Uri_Finalize_mD72FB8446BDF1951EA6D00D6941227EC7EA55EFC (void); // 0x000000AA Windows.Foundation.Collections.IIterator`1<Windows.Foundation.IWwwFormUrlDecoderEntry> Windows.Foundation.WwwFormUrlDecoder::First() extern void WwwFormUrlDecoder_First_m402CD9BC9D8F20A9B49743322372E692B4F8D9A7 (void); // 0x000000AB Windows.Foundation.IWwwFormUrlDecoderEntry Windows.Foundation.WwwFormUrlDecoder::GetAt(System.UInt32) extern void WwwFormUrlDecoder_GetAt_m6EC28555D3ECAC154EA9FA6485D3572B3FC76273 (void); // 0x000000AC System.UInt32 Windows.Foundation.WwwFormUrlDecoder::get_Size() extern void WwwFormUrlDecoder_get_Size_m9EE99853ED73DCC48EE325AC2C2DA858685198EF (void); // 0x000000AD System.Boolean Windows.Foundation.WwwFormUrlDecoder::IndexOf(Windows.Foundation.IWwwFormUrlDecoderEntry,System.UInt32&) extern void WwwFormUrlDecoder_IndexOf_m7D62504C835C82E535B5DFCFB5F2128806A8530B (void); // 0x000000AE System.UInt32 Windows.Foundation.WwwFormUrlDecoder::GetMany(System.UInt32,Windows.Foundation.IWwwFormUrlDecoderEntry[]) extern void WwwFormUrlDecoder_GetMany_m12617350BC8A57EB640495FF4DCED20CD4D3C485 (void); // 0x000000AF Windows.Foundation.IWwwFormUrlDecoderEntry Windows.Foundation.WwwFormUrlDecoder::get_Item(System.Int32) extern void WwwFormUrlDecoder_get_Item_m072111AF890B87246DD97B8ADF71ABCD8D789E33 (void); // 0x000000B0 System.Int32 Windows.Foundation.WwwFormUrlDecoder::get_Count() extern void WwwFormUrlDecoder_get_Count_m74493F6CB4386919E81FDEBB70FC0290B2FC0D6E (void); // 0x000000B1 System.Collections.Generic.IEnumerator`1<Windows.Foundation.IWwwFormUrlDecoderEntry> Windows.Foundation.WwwFormUrlDecoder::GetEnumerator() extern void WwwFormUrlDecoder_GetEnumerator_mDFB83E5A9C72B432B3A99A74D2F7EA88CFED181F (void); // 0x000000B2 System.Collections.IEnumerator Windows.Foundation.WwwFormUrlDecoder::GetEnumerator() extern void WwwFormUrlDecoder_GetEnumerator_mEF61B02DF829B59C8C0A800A60B9B6A205EE656D (void); // 0x000000B3 System.Void Windows.Foundation.WwwFormUrlDecoder::Finalize() extern void WwwFormUrlDecoder_Finalize_mD114EB5595C6225FBC7C65433DB5A1202685E864 (void); // 0x000000B4 Windows.UI.Xaml.Interop.IBindableIterator Windows.UI.Xaml.Interop.IBindableIterable::First() extern void IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7 (void); // 0x000000B5 System.Object Windows.UI.Xaml.Interop.IBindableIterator::get_Current() extern void IBindableIterator_get_Current_m53A4B6F2DECC874908CA9335785007A39D6FC93E (void); // 0x000000B6 System.Boolean Windows.UI.Xaml.Interop.IBindableIterator::get_HasCurrent() extern void IBindableIterator_get_HasCurrent_m4FD33F7F3A504A8F4A4C7DE3965342B19EA3A974 (void); // 0x000000B7 System.Boolean Windows.UI.Xaml.Interop.IBindableIterator::MoveNext() extern void IBindableIterator_MoveNext_mA70DABC057BE3ED9199D4E0E6FEBDF6ED3570A75 (void); // 0x000000B8 System.Object Windows.UI.Xaml.Interop.IBindableVector::GetAt(System.UInt32) extern void IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED (void); // 0x000000B9 System.UInt32 Windows.UI.Xaml.Interop.IBindableVector::get_Size() extern void IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9 (void); // 0x000000BA Windows.UI.Xaml.Interop.IBindableVectorView Windows.UI.Xaml.Interop.IBindableVector::GetView() extern void IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38 (void); // 0x000000BB System.Boolean Windows.UI.Xaml.Interop.IBindableVector::IndexOf(System.Object,System.UInt32&) extern void IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4 (void); // 0x000000BC System.Void Windows.UI.Xaml.Interop.IBindableVector::SetAt(System.UInt32,System.Object) extern void IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213 (void); // 0x000000BD System.Void Windows.UI.Xaml.Interop.IBindableVector::InsertAt(System.UInt32,System.Object) extern void IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5 (void); // 0x000000BE System.Void Windows.UI.Xaml.Interop.IBindableVector::RemoveAt(System.UInt32) extern void IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0 (void); // 0x000000BF System.Void Windows.UI.Xaml.Interop.IBindableVector::Append(System.Object) extern void IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F (void); // 0x000000C0 System.Void Windows.UI.Xaml.Interop.IBindableVector::RemoveAtEnd() extern void IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3 (void); // 0x000000C1 System.Void Windows.UI.Xaml.Interop.IBindableVector::Clear() extern void IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF (void); // 0x000000C2 System.Object Windows.UI.Xaml.Interop.IBindableVectorView::GetAt(System.UInt32) extern void IBindableVectorView_GetAt_mB119DB25AF57A337D2C7112063778434CE0F5CF5 (void); // 0x000000C3 System.UInt32 Windows.UI.Xaml.Interop.IBindableVectorView::get_Size() extern void IBindableVectorView_get_Size_m4F48139B27CB215D7E728F77E748FA6573F7DA09 (void); // 0x000000C4 System.Boolean Windows.UI.Xaml.Interop.IBindableVectorView::IndexOf(System.Object,System.UInt32&) extern void IBindableVectorView_IndexOf_mD85EC41D34BC2E450FA0133CC802906157D765F2 (void); static Il2CppMethodPointer s_methodPointers[196] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, IClosable_Close_m7DE2119A960C4E3898E6E5D03245D047BF113999, IPropertyValue_get_Type_m2BC440F5119A133BE4DD895657519ADAA3B34272, IPropertyValue_get_IsNumericScalar_mC8DE97926668A5F2EA3F4A9B128E966CBC7B0D60, IPropertyValue_GetUInt8_m25D96C5F9AC133BF7B682C59FE83EE05A0075B05, IPropertyValue_GetInt16_mBE4A7DC8A2B92F83EE058AE7515E84DADFA206AE, IPropertyValue_GetUInt16_mCF513D800195CA7050FD5AFB4E710FB0CFB531B5, IPropertyValue_GetInt32_mDE5543C20D3D3C9E773CB6EDBDBC789D12CC59BA, IPropertyValue_GetUInt32_mD48C2097876EAE6D1E218D9123F58F168B374205, IPropertyValue_GetInt64_m4BAC154BEC3584DF3E34EDA6033EEF3DB6D4132E, IPropertyValue_GetUInt64_m981379F85C0C44EDBDD830A293693BE0BB3F62CA, IPropertyValue_GetSingle_mED031D57B17B0F7BD3B4B250821D070155889F1F, IPropertyValue_GetDouble_mA0880A7E89CE09C2639D6F8065B18E8F77EB082F, IPropertyValue_GetChar16_m7B2226E30F72B0CCAE54B8EDB1AC4ACF1BE860A8, IPropertyValue_GetBoolean_m21FCEEA690B32CD86A36D40FB837FC7D894D5587, IPropertyValue_GetString_m8D5702E4E1C67366D65DA23CA2812D6572DF819C, IPropertyValue_GetGuid_m885F2850B49DB4B046564BC5FE414256801D9A11, IPropertyValue_GetDateTime_m023A766ED6FC58B347CF6F777F5C18C6AE246A3C, IPropertyValue_GetTimeSpan_m063CE76264EDAF37A1DA3CA5C9CF4AF85D8FC239, IPropertyValue_GetPoint_m014D5E859273BA28DE642E38438EDCC64AB5C41B, IPropertyValue_GetSize_m0A952D186E59BEA03E6185EDEBAC26D544AFADAC, IPropertyValue_GetRect_m0A96600149C7E6A493B8420CB316938AEF9A1A06, IPropertyValue_GetUInt8Array_m540E0503D8CFAE2579D449884B6AA883509C79D1, IPropertyValue_GetInt16Array_m279C289854DE8A2D45A6B6B09112DD9D2F0DF849, IPropertyValue_GetUInt16Array_m090AA712F6BB39F869BCC5CB90236377EE8673B1, IPropertyValue_GetInt32Array_mADF499B8CD16185128795A7B74D63E8CFE692B9A, IPropertyValue_GetUInt32Array_m9B44B8D2EA2907A9A96ED653ACEF04873D9483F8, IPropertyValue_GetInt64Array_m9A04AC5F477463928280B42E2C40F13B15A1D564, IPropertyValue_GetUInt64Array_m776484C9C41D5A03991D89401FF84F9D425D6A5E, IPropertyValue_GetSingleArray_m1E9CE76FA942B3AFA8995FBAE605E84733917B57, IPropertyValue_GetDoubleArray_m5DAB086BEB4816CAF7553E325B91A4B0B07953A5, IPropertyValue_GetChar16Array_m2C69248F68D7705FE44FA8F777B061FA77C706A1, IPropertyValue_GetBooleanArray_m083CB5579BC465B4D1BD84CE8382CB747A9FCC8C, IPropertyValue_GetStringArray_m680617C6226187D28C4978B710AFBB8581AAC98F, IPropertyValue_GetInspectableArray_m6DCBE370A8CAC129E6D6BD91C6503D14A8109F79, IPropertyValue_GetGuidArray_mE9983D9B5EE9AC1935C3EBD2F9E82DC7188E1D07, IPropertyValue_GetDateTimeArray_mEECFC6C321405CDBC425D321E2A8EF3E7BC306A7, IPropertyValue_GetTimeSpanArray_mEAF3CA18AA928DAF3046F0F530B9324711650167, IPropertyValue_GetPointArray_mD4ACB0F49C7BFEC1C03A4EE4263B23B2040CECD0, IPropertyValue_GetSizeArray_m3C079B4191330FAC3B2131D308C825BC72A5F0DC, IPropertyValue_GetRectArray_m09598924D31716E1E653AE941186F8B16EA11A87, NULL, NULL, IStringable_ToString_mAACC01E89FA76E5F4B95116FDC1CF4DBE2ECC692, ActivatableAttribute__ctor_mD46F484204EAC5CFA97A677EEA9E3057B7EB0A1D, AllowMultipleAttribute__ctor_m38B472E44C36B692E88FB0E3371F49F89190B767, ApiContractAttribute__ctor_mA1DC183FCECA2802E9B2A8784EEB2CDDCDB499AE, AttributeNameAttribute__ctor_m7A11A1D60B4EB01C76419064CE4D848B01940844, AttributeUsageAttribute__ctor_m5750318D560E5564D46D234B358B09886EA21FA7, ContractVersionAttribute__ctor_m7105FB71D69F6B212C5EF0FC82B2FF1AD6278822, ContractVersionAttribute__ctor_mA259C171AB6F3483FBEBBA7095A5764E1C34F6D2, ContractVersionAttribute__ctor_mA7901265471AF7521D3B4F1CDC61EFD4D8F67ADE, DefaultAttribute__ctor_m4354570F424E2E8EFA55798F175E9ED96F73B73F, DualApiPartitionAttribute__ctor_m9CDBECBCF7007920F8904A4454A42116AFA721C1, ExclusiveToAttribute__ctor_m4B131B7E52F8AEB7771DA727EE9AA091DFE26F61, GuidAttribute__ctor_mF2EF6CA62F02E1EA45916B732D379377C761A3A7, LengthIsAttribute__ctor_mAF7D4E8E12B5FE659DE4B33FD4894E8029ADC46E, MarshalingBehaviorAttribute__ctor_m86B470D1DE8EC24E115185A6E2B7BF37F581C9E0, StaticAttribute__ctor_mF97BB39BD47CAEF0DBBA6BC0C73E5A8EB2D413DD, ThreadingAttribute__ctor_m0B875434197471A46358686EE66D4D1A7BAF8C48, WebHostHiddenAttribute__ctor_m682515FD2F960F1DD70B4A60AE35D02187FFE00A, IActivatedEventArgs_get_Kind_m73BC5142E2C7ACF55FF10C526DFBF0FD838D64DB, IActivatedEventArgs_get_PreviousExecutionState_m82E28EFF709D256E076C432EC6778A070BC2E1D1, NULL, NULL, NULL, IProtocolActivatedEventArgs_get_Uri_mAAB4DD042BD82651187C3A3DDF750B6AF2246AA6, NULL, NULL, NULL, ProtocolActivatedEventArgs_get_Uri_m5A17C77CB881E850E73CE949ABFEE9A149800041, ProtocolActivatedEventArgs_get_Kind_m18D53BFB387CD918D825115ADD9A1B562FE1F35F, ProtocolActivatedEventArgs_get_PreviousExecutionState_m5B46957C4849A64AB7BD0DEC30B87B396D0C734B, ProtocolActivatedEventArgs_Finalize_mAB843542D0132A72347771D13D52CCC777D1FA63, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, IUriRuntimeClass_get_RawUri_mA70F86F9BE3F3D07D4BBB8D5079D13A60D194891, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, Uri__ctor_m0D439C7728FEE1D4F2B88E215C2D59A58C5FBE65, Uri__ctor_m41548CFDC457565BE64EC6CF236A0D08D1ED2500, Uri_get_AbsoluteUri_mBD430BA219541014CC78A817674F7E63FFD6439E, Uri_get_DisplayUri_mC840108DF8A1051D01E3CF7D3D3D311EFF19B654, Uri_get_Domain_m35368704392605936428C37AFE157E9CE5413937, Uri_get_Extension_m8142ECBA0B93DC4AEC1810E7F40B3594D3E640E6, Uri_get_Fragment_mF20EFE395740FD3CC9D5F7ACCAE6BDFB69797E7D, Uri_get_Host_m07327214CF731421F1B74B2BFF29EFE140F595A5, Uri_get_Password_mFB9F08FC30386D1C5D9AF21E18F76E8BD1ED6933, Uri_get_Path_m4EBFEC3B98C08E5B0BFB759C3517980CBD42CF7B, Uri_get_Query_mA89D787B4617536BCC50D367D1ECD586989722F1, Uri_get_QueryParsed_mAF4520F289FD311BDA5E2002FCDE57445E89840D, Uri_get_RawUri_m0F1B0FA3F111F707620C43083ECEB89851D1B5A5, Uri_get_SchemeName_m97AC67427E5EA0CBB76899709108D110088723DC, Uri_get_UserName_m826B8707FD4FBEF72C3B1CA82A504C213EB89C6E, Uri_get_Port_mFBAAAB48EE34DF72F1BF2EE645B71CC58254FC9F, Uri_get_Suspicious_mD493F8FE1FC1AAC6E12339862503C11BCC2E8FD2, Uri_Equals_m559A85A0315D7546E7094024EEDBCAC9F619D2FF, Uri_CombineUri_mBD3BF069E31739C01F855B60ECA8B183930ED355, Uri_get_AbsoluteCanonicalUri_m3415A1854346950B0AC7B6D19D31B0394C0CF007, Uri_get_DisplayIri_mFB2216CA1CC976FC636B460D4C7D66C6836CF1B8, Uri_ToString_m38F6D46B11B7C342DE117A4968556878798E1715, Uri_UnescapeComponent_m9AB29B6D922AC549CEE1D3A9BABC8AF9761624F7, Uri_EscapeComponent_m6C43EC4D66038917B17FA8042996E6EC121306D0, Uri_Finalize_mD72FB8446BDF1951EA6D00D6941227EC7EA55EFC, WwwFormUrlDecoder_First_m402CD9BC9D8F20A9B49743322372E692B4F8D9A7, WwwFormUrlDecoder_GetAt_m6EC28555D3ECAC154EA9FA6485D3572B3FC76273, WwwFormUrlDecoder_get_Size_m9EE99853ED73DCC48EE325AC2C2DA858685198EF, WwwFormUrlDecoder_IndexOf_m7D62504C835C82E535B5DFCFB5F2128806A8530B, WwwFormUrlDecoder_GetMany_m12617350BC8A57EB640495FF4DCED20CD4D3C485, WwwFormUrlDecoder_get_Item_m072111AF890B87246DD97B8ADF71ABCD8D789E33, WwwFormUrlDecoder_get_Count_m74493F6CB4386919E81FDEBB70FC0290B2FC0D6E, WwwFormUrlDecoder_GetEnumerator_mDFB83E5A9C72B432B3A99A74D2F7EA88CFED181F, WwwFormUrlDecoder_GetEnumerator_mEF61B02DF829B59C8C0A800A60B9B6A205EE656D, WwwFormUrlDecoder_Finalize_mD114EB5595C6225FBC7C65433DB5A1202685E864, IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7, IBindableIterator_get_Current_m53A4B6F2DECC874908CA9335785007A39D6FC93E, IBindableIterator_get_HasCurrent_m4FD33F7F3A504A8F4A4C7DE3965342B19EA3A974, IBindableIterator_MoveNext_mA70DABC057BE3ED9199D4E0E6FEBDF6ED3570A75, IBindableVector_GetAt_m33D2170810828C01473D9BDC22745A0354FA4FED, IBindableVector_get_Size_m45347BCD42A1FE180ED2B377BB9C88C7B50CD7D9, IBindableVector_GetView_m9736FE93BC8979E0CBF8ED26090D1FE54C2E1A38, IBindableVector_IndexOf_m2F1A64750D19C5A03E9B65880F4A04275E6AABF4, IBindableVector_SetAt_mD4C84EC02EAD7F636873B77E6D48E7132055A213, IBindableVector_InsertAt_m19A0C885F7C7A7FFA257A46218D7232317E022B5, IBindableVector_RemoveAt_m1AC6E54165809374E91F456B9922A9B24F8652B0, IBindableVector_Append_mCA138F8E4026725AC867B607FA63709B6752BB7F, IBindableVector_RemoveAtEnd_mB3178911995D4CC7BAC0EA43720C1280267E54E3, IBindableVector_Clear_mEF05B40EFF6D42CBB5A5E336B0946FECE7A4A6EF, IBindableVectorView_GetAt_mB119DB25AF57A337D2C7112063778434CE0F5CF5, IBindableVectorView_get_Size_m4F48139B27CB215D7E728F77E748FA6573F7DA09, IBindableVectorView_IndexOf_mD85EC41D34BC2E450FA0133CC802906157D765F2, }; static const int32_t s_InvokerIndices[196] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1384, 1384, 1384, 1384, 1384, 1384, 1384, 1384, 1384, 1341, 1372, 1372, 1340, 1340, 1341, 1341, 1342, 1342, 1375, 1334, 1340, 1372, 1351, 1338, 1331, 1378, 1358, 1376, 1364, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, -1, -1, 1351, 475, 1384, 1384, 1186, 1176, 1176, 752, 752, 1384, 1384, 1186, 3, 1176, 1176, 475, 1176, 1384, 1341, 1341, 1384, 1384, 1384, 1351, 1384, 1384, 1384, 1351, 1341, 1341, 1384, 959, 959, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1341, 1372, 1056, 959, 959, 563, 1351, 1351, 1384, 1384, 1384, 1384, 1186, 755, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1351, 1341, 1372, 1056, 959, 1351, 1351, 1351, 2106, 2106, 1384, 1351, 956, 1341, 618, 527, 956, 1341, 1351, 1351, 1384, 1351, 1351, 1372, 1372, 956, 1341, 1351, 618, 703, 703, 1176, 1186, 1384, 1384, 956, 1341, 618, }; extern const CustomAttributesCacheGenerator g_WindowsRuntimeMetadata_AttributeGenerators[]; IL2CPP_EXTERN_C const Il2CppCodeGenModule g_WindowsRuntimeMetadata_CodeGenModule; const Il2CppCodeGenModule g_WindowsRuntimeMetadata_CodeGenModule = { "WindowsRuntimeMetadata", 196, s_methodPointers, 0, NULL, s_InvokerIndices, 0, NULL, 0, NULL, 0, NULL, NULL, g_WindowsRuntimeMetadata_AttributeGenerators, NULL, // module initializer, NULL, NULL, NULL, };
ed2be5cfcef288360ad099d02436b7dbfaae0573
fbe68d84e97262d6d26dd65c704a7b50af2b3943
/third_party/virtualbox/src/VBox/Devices/EFI/Firmware/SecurityPkg/Include/Guid/UserProfileManagerHii.h
fefa348a9ac72fb59b9d98ad695143c55f650509
[ "MIT", "GPL-2.0-only", "LicenseRef-scancode-unknown-license-reference", "CDDL-1.0", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later", "LGPL-2.1-or-later", "GPL-2.0-or-later", "MPL-1.0", "LicenseRef-scancode-generic-exception", "Apache-2.0", "OpenSSL", "BSD-2-Clause" ]
permissive
thalium/icebox
c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb
6f78952d58da52ea4f0e55b2ab297f28e80c1160
refs/heads/master
2022-08-14T00:19:36.984579
2022-02-22T13:10:31
2022-02-22T13:10:31
190,019,914
585
109
MIT
2022-01-13T20:58:15
2019-06-03T14:18:12
C++
UTF-8
C
false
false
831
h
UserProfileManagerHii.h
/** @file GUID used as HII FormSet and HII Package list GUID in UserProfileManagerDxe driver. Copyright (c) 2011, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef __USER_PROFILE_MANAGER_HII_H__ #define __USER_PROFILE_MANAGER_HII_H__ #define USER_PROFILE_MANAGER_GUID \ { \ 0xc35f272c, 0x97c2, 0x465a, { 0xa2, 0x16, 0x69, 0x6b, 0x66, 0x8a, 0x8c, 0xfe } \ } extern EFI_GUID gUserProfileManagerGuid; #endif
567dab571b6e3f57257c46eaa5e8cdfd076136d1
a0838b4cd2ce8a2862a6a82dc2e75a701447c28b
/components/mhz19b/mhz19b.h
67c3c7c95e568ad55b940475fdf401a453371385
[ "BSD-3-Clause" ]
permissive
UncleRus/esp-idf-lib
bfa97226f6df9313dd01f56de1b8bef1824ad642
9dd86b23aff2445b905da63d3c6481474e430a10
refs/heads/master
2023-08-31T06:04:48.102658
2023-08-30T15:57:59
2023-08-30T15:57:59
126,475,029
1,117
394
null
2023-09-01T06:25:56
2018-03-23T11:17:22
C
UTF-8
C
false
false
9,383
h
mhz19b.h
/* * Copyright (c) 2020 Erriez <https://github.com/Erriez> * Copyright (c) 2021 David Douard <david.douard@sdfa3.org> * * 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 copyright holder nor the names of itscontributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /** * @file mhz19b.h * @defgroup mhz19b mhz19b * @{ * * ESP-IDF driver for MH-Z19B NDIR CO2 sensor connected to UART * * Inspired from https://github.com/Erriez/ErriezMHZ19B * * Copyright (c) 2020 Erriez <https://github.com/Erriez>\n * Copyright (c) 2021 David Douard <david.douard@sdfa3.org> * * BSD Licensed as described in the file LICENSE */ #ifndef __MHZ19B_H__ #define __MHZ19B_H__ #include <stdbool.h> #include <driver/uart.h> #include <driver/gpio.h> #include <esp_err.h> #ifdef __cplusplus extern "C" { #endif /** * @brief MHZ19B sensor device data structure */ typedef struct { uart_port_t uart_port; ///< UART port used to communicate uint8_t *buf; ///< read buffer attached to this device int16_t last_value; ///< last read value int64_t last_ts; ///< timestamp of the last sensor co2 level reading } mhz19b_dev_t; //! 3 minutes warming-up time after power-on before valid data returned #define MHZ19B_WARMING_UP_TIME_MS (3UL * 60000UL) #define MHZ19B_WARMING_UP_TIME_US (3UL * 60000UL * 1000UL) //! Minimum response time between CO2 reads (EXPERIMENTALLY DEFINED) #define MHZ19B_READ_INTERVAL_MS (5UL * 1000UL) //! Fixed 9 Bytes response #define MHZ19B_SERIAL_RX_BYTES 9 //! 128 is the minimal value the UART driver will accept (at least on esp32) #define MHZ19B_SERIAL_BUF_LEN 128 //! Response timeout between 15..120 ms at 9600 baud works reliable for all commands #define MHZ19B_SERIAL_RX_TIMEOUT_MS 120 // Documented commands #define MHZ19B_CMD_SET_AUTO_CAL 0x79 ///< set auto calibration on/off #define MHZ19B_CMD_READ_CO2 0x86 ///< read CO2 concentration #define MHZ19B_CMD_CAL_ZERO_POINT 0x87 ///< calibrate zero point at 400ppm #define MHZ19B_CMD_CAL_SPAN_PIONT 0x88 ///< calibrate span point (NOT IMPLEMENTED) #define MHZ19B_CMD_SET_RANGE 0x99 ///< set detection range // Not documented commands #define MHZ19B_CMD_GET_AUTO_CAL 0x7D ///< get auto calibration status (NOT DOCUMENTED) #define MHZ19B_CMD_GET_RANGE 0x9B ///< get range detection (NOT DOCUMENTED) #define MHZ19B_CMD_GET_VERSION 0xA0 ///< get firmware version (NOT DOCUMENTED) /** * @brief PPM range */ typedef enum { MHZ19B_RANGE_2000 = 2000, ///< 2000 ppm MHZ19B_RANGE_5000 = 5000, ///< 5000 ppm (Default) } mhz19b_range_t; /** * @brief Initialize device descriptor * * @param dev Pointer to the sensor device data structure * @param uart_port UART poert number * @param tx_gpio GPIO pin number for TX * @param rx_gpio GPIO pin number for RX * * @return ESP_OK on success */ esp_err_t mhz19b_init(mhz19b_dev_t *dev, uart_port_t uart_port, gpio_num_t tx_gpio, gpio_num_t rx_gpio); /** * @brief Free device descriptor * * @param dev Pointer to the sensor device data structure * * @return ESP_OK on success */ esp_err_t mhz19b_free(mhz19b_dev_t *dev); /** * @brief Detect sensor by checking range response * * @param dev Pointer to the sensor device data structure * * @return true if sensor is detected */ bool mhz19b_detect(mhz19b_dev_t *dev); /** * @brief Check if sensor is warming up * * @param dev Pointer to the sensor device data structure * @param smart_warming_up Smart check * * @return true if sensor is warming up */ bool mhz19b_is_warming_up(mhz19b_dev_t *dev, bool smart_warming_up); /** * @brief Check minimum interval between CO2 reads * * Not described in the datasheet, but it is the same frequency as the built-in LED blink. * * @param dev Pointer to the sensor device data structure * * @return true if ready to call ::mhz19b_read_co2() */ bool mhz19b_is_ready(mhz19b_dev_t *dev); /** * @brief Read CO2 from sensor * * @param dev Pointer to the sensor device data structure * @param[out] co2 CO2 level * - < 0: MH-Z19B response error codes. * - 0..399 ppm: Incorrect values. Minimum value starts at 400ppm outdoor fresh air. * - 400..1000 ppm: Concentrations typical of occupied indoor spaces with good air exchange. * - 1000..2000 ppm: Complaints of drowsiness and poor air quality. Ventilation is required. * - 2000..5000 ppm: Headaches, sleepiness and stagnant, stale, stuffy air. Poor concentration, loss of * attention, increased heart rate and slight nausea may also be present. * - Higher values are extremely dangerous and cannot be measured. * * @return ESP_OK on success */ esp_err_t mhz19b_read_co2(mhz19b_dev_t *dev, int16_t *co2); /** * @brief Get firmware version (NOT DOCUMENTED) * * @details * This is an undocumented command, but most sensors returns ASCII "0430 or "0443". * * @param dev Pointer to the sensor device data structure * @param[out] version * Returned character pointer to version (must be at least 5 Bytes)\n * Only valid when return is set to ESP_OK. * * @return ESP_OK on success */ esp_err_t mhz19b_get_version(mhz19b_dev_t *dev, char *version); /** * @brief Set CO2 range * * @param dev Pointer to the sensor device data structure * @param range Range of the sensor (2000 or 5000, in ppm) * * @return ESP_OK on success */ esp_err_t mhz19b_set_range(mhz19b_dev_t *dev, mhz19b_range_t range); /** * @brief Get CO2 range in PPM (NOT DOCUMENTED) * * @details * This function verifies valid read ranges of 2000 or 5000 ppm.\n * Note: Other ranges may be returned, but are undocumented and marked as invalid. * * @param dev Pointer to the sensor device data structure * @param range Current value of the range of the sensor (output) * * @return ESP_OK on success */ esp_err_t mhz19b_get_range(mhz19b_dev_t *dev, uint16_t *range); /** * @brief Enable or disable automatic calibration * * @param dev Pointer to the sensor device data structure * @param calibration_on * - true: Automatic calibration on. * - false: Automatic calibration off. * * @return ESP_OK on success */ esp_err_t mhz19b_set_auto_calibration(mhz19b_dev_t *dev, bool calibration_on); /** * @brief Get status of automatic calibration (NOT DOCUMENTED) * * @param dev Pointer to the sensor device data structure * @param[out] calibration_on Automatic calibration status * * @return ESP_OK on success */ esp_err_t mhz19b_get_auto_calibration( mhz19b_dev_t *dev, bool *calibration_on); // (NOT DOCUMENTED) /** * @brief Start Zero Point Calibration manually at 400ppm * * @details * The sensor must be powered-up for at least 20 minutes in fresh air at 400ppm room * temperature. Then call this function once to execute self calibration.\n * Recommended to use this function when auto calibration is off. * * @param dev Pointer to the sensor device data structure * * @return ESP_OK on success */ esp_err_t mhz19b_start_calibration(mhz19b_dev_t *dev); /** * @brief Send serial command to sensor and read response * * @details * Send command to sensor and read response, protected with a receive timeout.\n * Result is available in the device descriptor buffer. * * @param dev Pointer to the sensor device data structure * @param cmd Command Byte * @param b3 Byte 3 (default 0) * @param b4 Byte 4 (default 0) * @param b5 Byte 5 (default 0) * @param b6 Byte 6 (default 0) * @param b7 Byte 7 (default 0) */ esp_err_t mhz19b_send_command(mhz19b_dev_t *dev, uint8_t cmd, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7); /** * @brief Calculate CRC on 8 data Bytes buffer * * @param data Buffer pointer to calculate CRC. * @return Calculated 8-bit CRC. */ uint8_t mhz19b_calc_crc(uint8_t *data); #ifdef __cplusplus } #endif /* End of CPP guard */ /**@}*/ #endif /* __MHZ19B_H__ */
87dba8e1590ebe0680d0d45a9b31111062afbf4e
a11e4bdd6157b22067288d860507fa20abea033d
/src/bin/e_scale.h
6468c33598282ba966a4ca6f6713025a5b086b0e
[ "BSD-2-Clause" ]
permissive
JeffHoogland/moksha
85a0f39dc97daa61d35e64a511013d21552db288
c56013644d8cd8e32101bb38a8d1e4ebd9d47f37
refs/heads/master
2023-08-24T05:39:13.415948
2023-08-22T19:49:32
2023-08-22T19:49:32
34,704,822
179
51
NOASSERTION
2023-09-06T14:41:31
2015-04-28T02:59:19
C
UTF-8
C
false
false
207
h
e_scale.h
#ifdef E_TYPEDEFS #else #ifndef E_SCALE_H #define E_SCALE_H EINTERN int e_scale_init(void); EINTERN int e_scale_shutdown(void); EAPI void e_scale_update(void); extern EAPI double e_scale; #endif #endif
2d341195690a368d88102fd5cb1dd41e1a4523ab
55540f3e86f1d5d86ef6b5d295a63518e274efe3
/toolchain/riscv/Linux/lib/gcc/riscv64-unknown-elf/10.2.0/plugin/include/config.h
aa6dd6bbbd61219f1e916f0f38d5323a784a56ce
[ "Apache-2.0" ]
permissive
bouffalolab/bl_iot_sdk
bc5eaf036b70f8c65dd389439062b169f8d09daa
b90664de0bd4c1897a9f1f5d9e360a9631d38b34
refs/heads/master
2023-08-31T03:38:03.369853
2023-08-16T08:50:33
2023-08-18T09:13:27
307,347,250
244
101
Apache-2.0
2023-08-28T06:29:02
2020-10-26T11:16:30
C
UTF-8
C
false
false
217
h
config.h
#ifndef GCC_CONFIG_H #define GCC_CONFIG_H #ifdef GENERATOR_FILE #error config.h is for the host, not build, machine. #endif #include "auto-host.h" #ifdef IN_GCC # include "ansidecl.h" #endif #endif /* GCC_CONFIG_H */
7f8766daca6379d2838e797aaca45b1f58151f26
d61b532db0d3e08818338cfaac530a1ced1ffe3b
/lang/m2/m2mm/file_list.h
f4204cc1b079704d033c3c10cb31c8df80bbda73
[ "LicenseRef-scancode-other-permissive" ]
permissive
davidgiven/ack
61049c7a8e95ff61a77b1edd3c22bb290720e276
db5a32c68c4a60ca26a3927a799ea662b5b2b0e5
refs/heads/default
2023-08-29T07:33:12.771205
2023-07-08T20:17:27
2023-07-08T20:17:27
37,686,316
376
74
NOASSERTION
2023-07-08T20:17:28
2015-06-18T21:33:42
C
UTF-8
C
false
false
713
h
file_list.h
/* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". * * Author: Ceriel J.H. Jacobs */ /* F I L E L I S T S T R U C T U R E */ struct file_list { char *a_filename; /* name of file */ char *a_dir; /* directory in which it resides */ struct idf *a_idf; /* its idf-structure */ struct file_list *a_next; /* next in list */ char a_notfound; /* could not open ... */ }; #define f_walk(list, ctrl) \ for (ctrl = (list); ctrl; ctrl = ctrl->a_next) #define f_filename(a) ((a)->a_filename) #define f_idf(a) ((a)->a_idf) #define f_dir(a) ((a)->a_dir) #define f_notfound(a) ((a)->a_notfound)
6fe1525c226da4e3ddcf68392fcd86836614b753
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/arm/src/samv7/sam_gpio.h
3da6508b8ff0de533ba41a049feb4e6019bb1b24
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
13,580
h
sam_gpio.h
/**************************************************************************** * arch/arm/src/samv7/sam_gpio.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * ****************************************************************************/ #ifndef __ARCH_ARM_SRC_SAMV7_SAM_GPIO_H #define __ARCH_ARM_SRC_SAMV7_SAM_GPIO_H /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <stdint.h> #include <stdbool.h> #include <assert.h> #include <arch/samv7/chip.h> /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* Bit-encoded input to sam_configgpio() ************************************/ /* 32-bit Encoding: * * .... .... MMMC CCCC IIIV D... PPPB BBBB */ /* Input/Output mode: * * .... .... MMM. .... .... .... .... .... */ #define GPIO_MODE_SHIFT (21) /* Bits 21-23: GPIO mode */ #define GPIO_MODE_MASK (7 << GPIO_MODE_SHIFT) # define GPIO_ALTERNATE (0 << GPIO_MODE_SHIFT) /* PIO alternate function */ # define GPIO_INPUT (1 << GPIO_MODE_SHIFT) /* PIO Input */ # define GPIO_OUTPUT (2 << GPIO_MODE_SHIFT) /* PIO Output */ # define GPIO_PERIPHA (3 << GPIO_MODE_SHIFT) /* Controlled by periph A signal */ # define GPIO_PERIPHB (4 << GPIO_MODE_SHIFT) /* Controlled by periph B signal */ # define GPIO_PERIPHC (5 << GPIO_MODE_SHIFT) /* Controlled by periph C signal */ # define GPIO_PERIPHD (6 << GPIO_MODE_SHIFT) /* Controlled by periph D signal */ /* These bits set the configuration of the pin: * NOTE: No definitions for parallel capture mode * * .... .... ...C CCCC .... .... .... .... */ #define GPIO_CFG_SHIFT (16) /* Bits 16-20: GPIO configuration bits */ #define GPIO_CFG_MASK (31 << GPIO_CFG_SHIFT) # define GPIO_CFG_DEFAULT (0 << GPIO_CFG_SHIFT) /* Default, no attribute */ # define GPIO_CFG_PULLUP (1 << GPIO_CFG_SHIFT) /* Bit 16: Internal pull-up */ # define GPIO_CFG_PULLDOWN (2 << GPIO_CFG_SHIFT) /* Bit 17: Internal pull-down */ # define GPIO_CFG_DEGLITCH (4 << GPIO_CFG_SHIFT) /* Bit 18: Internal glitch filter */ # define GPIO_CFG_OPENDRAIN (8 << GPIO_CFG_SHIFT) /* Bit 19: Open drain */ # define GPIO_CFG_SCHMITT (16 << GPIO_CFG_SHIFT) /* Bit 20: Schmitt trigger */ /* Additional interrupt modes: * * .... .... .... .... III. .... .... .... */ #define GPIO_INT_SHIFT (13) /* Bits 13-15: GPIO interrupt bits */ #define GPIO_INT_MASK (7 << GPIO_INT_SHIFT) # define _GIO_INT_AIM (1 << 15) /* Bit 15: Additional Interrupt modes */ # define _GPIO_INT_LEVEL (1 << 14) /* Bit 14: Level detection interrupt */ # define _GPIO_INT_EDGE (0) /* (vs. Edge detection interrupt) */ # define _GPIO_INT_RH (1 << 13) /* Bit 13: Rising edge/High level detection interrupt */ # define _GPIO_INT_FL (0) /* (vs. Falling edge/Low level detection interrupt) */ # define GPIO_INT_HIGHLEVEL (_GIO_INT_AIM | _GPIO_INT_LEVEL | _GPIO_INT_RH) # define GPIO_INT_LOWLEVEL (_GIO_INT_AIM | _GPIO_INT_LEVEL | _GPIO_INT_FL) # define GPIO_INT_RISING (_GIO_INT_AIM | _GPIO_INT_EDGE | _GPIO_INT_RH) # define GPIO_INT_FALLING (_GIO_INT_AIM | _GPIO_INT_EDGE | _GPIO_INT_FL) # define GPIO_INT_BOTHEDGES (0) /* If the pin is an GPIO output, then this identifies the initial output * value: * * .... .... .... .... ...V .... .... .... */ #define GPIO_OUTPUT_SET (1 << 12) /* Bit 12: Initial value of output */ #define GPIO_OUTPUT_CLEAR (0) /* If the pin is an GPIO output, then this identifies the output drive * strength: * * .... .... .... .... .... D... .... .... */ #define GPIO_OUTPUT_DRIVE (1 << 11) /* Bit 11: Initial value of output */ # define GPIO_OUTPUT_HIGH_DRIVE (1 << 11) # define GPIO_OUTPUT_LOW_DRIVE (0) /* This identifies the GPIO port: * * .... .... .... .... .... PPP. .... */ #define GPIO_PORT_SHIFT (5) /* Bit 5-7: Port number */ #define GPIO_PORT_MASK (7 << GPIO_PORT_SHIFT) # define GPIO_PORT_PIOA (0 << GPIO_PORT_SHIFT) # define GPIO_PORT_PIOB (1 << GPIO_PORT_SHIFT) # define GPIO_PORT_PIOC (2 << GPIO_PORT_SHIFT) # define GPIO_PORT_PIOD (3 << GPIO_PORT_SHIFT) # define GPIO_PORT_PIOE (4 << GPIO_PORT_SHIFT) /* This identifies the bit in the port: * * ..... .... ... .... .... ...B BBBB */ #define GPIO_PIN_SHIFT (0) /* Bits 0-4: GPIO number: 0-31 */ #define GPIO_PIN_MASK (31 << GPIO_PIN_SHIFT) #define GPIO_PIN0 (0 << GPIO_PIN_SHIFT) #define GPIO_PIN1 (1 << GPIO_PIN_SHIFT) #define GPIO_PIN2 (2 << GPIO_PIN_SHIFT) #define GPIO_PIN3 (3 << GPIO_PIN_SHIFT) #define GPIO_PIN4 (4 << GPIO_PIN_SHIFT) #define GPIO_PIN5 (5 << GPIO_PIN_SHIFT) #define GPIO_PIN6 (6 << GPIO_PIN_SHIFT) #define GPIO_PIN7 (7 << GPIO_PIN_SHIFT) #define GPIO_PIN8 (8 << GPIO_PIN_SHIFT) #define GPIO_PIN9 (9 << GPIO_PIN_SHIFT) #define GPIO_PIN10 (10 << GPIO_PIN_SHIFT) #define GPIO_PIN11 (11 << GPIO_PIN_SHIFT) #define GPIO_PIN12 (12 << GPIO_PIN_SHIFT) #define GPIO_PIN13 (13 << GPIO_PIN_SHIFT) #define GPIO_PIN14 (14 << GPIO_PIN_SHIFT) #define GPIO_PIN15 (15 << GPIO_PIN_SHIFT) #define GPIO_PIN16 (16 << GPIO_PIN_SHIFT) #define GPIO_PIN17 (17 << GPIO_PIN_SHIFT) #define GPIO_PIN18 (18 << GPIO_PIN_SHIFT) #define GPIO_PIN19 (19 << GPIO_PIN_SHIFT) #define GPIO_PIN20 (20 << GPIO_PIN_SHIFT) #define GPIO_PIN21 (21 << GPIO_PIN_SHIFT) #define GPIO_PIN22 (22 << GPIO_PIN_SHIFT) #define GPIO_PIN23 (23 << GPIO_PIN_SHIFT) #define GPIO_PIN24 (24 << GPIO_PIN_SHIFT) #define GPIO_PIN25 (25 << GPIO_PIN_SHIFT) #define GPIO_PIN26 (26 << GPIO_PIN_SHIFT) #define GPIO_PIN27 (27 << GPIO_PIN_SHIFT) #define GPIO_PIN28 (28 << GPIO_PIN_SHIFT) #define GPIO_PIN29 (29 << GPIO_PIN_SHIFT) #define GPIO_PIN30 (30 << GPIO_PIN_SHIFT) #define GPIO_PIN31 (31 << GPIO_PIN_SHIFT) /**************************************************************************** * Public Types ****************************************************************************/ #ifndef __ASSEMBLY__ /* Must be big enough to hold the 32-bit encoding */ typedef uint32_t gpio_pinset_t; /**************************************************************************** * Public Data ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" extern "C" { #else #define EXTERN extern #endif EXTERN const uintptr_t g_portbase[SAMV7_NPIO]; /**************************************************************************** * Inline Functions ****************************************************************************/ /**************************************************************************** * Name: sam_gpio_base * * Description: * Return the base address of the GPIO register set * ****************************************************************************/ static inline uintptr_t sam_gpio_base(gpio_pinset_t cfgset) { int port = (cfgset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; DEBUGASSERT(port < SAMV7_NPIO); return g_portbase[port]; } /**************************************************************************** * Name: sam_gpio_port * * Description: * Return the PIO port number * ****************************************************************************/ static inline int sam_gpio_port(gpio_pinset_t cfgset) { return (cfgset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; } /**************************************************************************** * Name: sam_gpio_pin * * Description: * Return the PIO pin number * ****************************************************************************/ static inline int sam_gpio_pin(gpio_pinset_t cfgset) { return (cfgset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT; } /**************************************************************************** * Name: sam_gpio_pinmask * * Description: * Return the PIO pin bit maskt * ****************************************************************************/ static inline int sam_gpio_pinmask(gpio_pinset_t cfgset) { return 1 << ((cfgset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT); } /**************************************************************************** * Public Function Prototypes ****************************************************************************/ /**************************************************************************** * Function: sam_gpioinit * * Description: * Based on configuration within the .config file, it does: * - Remaps positions of alternative functions for GPIO. * * Typically called from sam_start(). * ****************************************************************************/ #if !defined(CONFIG_SAMV7_ERASE_ENABLE) || \ !defined(CONFIG_SAMV7_JTAG_FULL_ENABLE) void sam_gpioinit(void); #else # define sam_gpioinit() #endif /**************************************************************************** * Name: sam_gpioirqinitialize * * Description: * Initialize logic to support a second level of interrupt decoding for * GPIO pins. * ****************************************************************************/ #ifdef CONFIG_SAMV7_GPIO_IRQ void sam_gpioirqinitialize(void); #else # define sam_gpioirqinitialize() #endif /**************************************************************************** * Name: sam_configgpio * * Description: * Configure a GPIO pin based on bit-encoded description of the pin. * ****************************************************************************/ int sam_configgpio(gpio_pinset_t cfgset); /**************************************************************************** * Name: sam_gpiowrite * * Description: * Write one or zero to the selected GPIO pin * ****************************************************************************/ void sam_gpiowrite(gpio_pinset_t pinset, bool value); /**************************************************************************** * Name: sam_gpioread * * Description: * Read one or zero from the selected GPIO pin * ****************************************************************************/ bool sam_gpioread(gpio_pinset_t pinset); /**************************************************************************** * Name: sam_gpioirq * * Description: * Configure an interrupt for the specified GPIO pin. * ****************************************************************************/ #ifdef CONFIG_SAMV7_GPIO_IRQ void sam_gpioirq(gpio_pinset_t pinset); #else # define sam_gpioirq(pinset) #endif /**************************************************************************** * Name: sam_gpioirqenable * * Description: * Enable the interrupt for specified GPIO IRQ * ****************************************************************************/ #ifdef CONFIG_SAMV7_GPIO_IRQ void sam_gpioirqenable(int irq); #else # define sam_gpioirqenable(irq) #endif /**************************************************************************** * Name: sam_gpioirqdisable * * Description: * Disable the interrupt for specified GPIO IRQ * ****************************************************************************/ #ifdef CONFIG_SAMV7_GPIO_IRQ void sam_gpioirqdisable(int irq); #else # define sam_gpioirqdisable(irq) #endif /**************************************************************************** * Function: sam_dumpgpio * * Description: * Dump all GPIO registers associated with the base address of the provided * pinset. * ****************************************************************************/ #ifdef CONFIG_DEBUG_GPIO_INFO int sam_dumpgpio(uint32_t pinset, const char *msg); #else # define sam_dumpgpio(p,m) #endif #undef EXTERN #if defined(__cplusplus) } #endif #endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_SRC_SAMV7_SAM_GPIO_H */
c045e23ac0ad9d26459251532bd96534936fe246
4e32ea5b4a215f427af04630e01b1312ffd31a55
/test/programs/simple/irrelevant-if.c
6eeecca8d941e6fc74df4423f1ebc30b383c06aa
[ "Apache-2.0", "GPL-1.0-or-later" ]
permissive
sosy-lab/cpachecker
1add74cb774316dd6e1aea3fb1f352c8141466b7
1822761867d106301bda0bc99ed3cc0a25c529aa
refs/heads/trunk
2023-08-31T14:47:22.284597
2023-08-31T14:20:58
2023-08-31T14:20:58
20,107,238
186
90
Apache-2.0
2021-07-27T14:24:30
2014-05-23T16:57:37
SWIG
UTF-8
C
false
false
813
c
irrelevant-if.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 int a, b; int main() { if((!(a==33) || (b==33)) && !(a==32)){ } return 1; }
3ea390c1d241a36fdc0c16051dd20717d558e8ae
d6518411f2d602cef8f4d8651f7f6e3e386442c6
/tests/vn_str_cmp_test.c
92b435f71424a6a68906059ede93aecadd9273bd
[ "MIT" ]
permissive
tinylcy/vino
7e92915918eb16426c1dfaeff2224616dd570000
70279865b49bd134e52a66f532d65b44cdc40b9c
refs/heads/master
2021-08-30T00:33:56.301578
2017-12-15T11:28:16
2017-12-15T11:28:16
66,211,939
182
31
MIT
2018-04-23T10:52:13
2016-08-21T17:39:07
C
UTF-8
C
false
false
539
c
vn_str_cmp_test.c
#include <stdio.h> #include <stdlib.h> #include "../src/util.h" int main(void) { int rv; vn_str str1; char *str2; str1.p = "chenyang"; str1.len = 8; str2 = "chenyang"; rv = vn_str_cmp(&str1, str2); printf("%s cmp %s = %d\n", str1.p, str2, rv); str2 = "chenyangli"; rv = vn_str_cmp(&str1, str2); printf("%s cmp %s = %d\n", str1.p, str2, rv); str1.p = "chenyangll"; str1.len = 10; rv = vn_str_cmp(&str1, str2); printf("%s cmp %s = %d\n", str1.p, str2, rv); return 0; }
2e2e48f745ff2e0ac9627d977075b8d40917ca98
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/security/py-kerberos/files/extra-patch-src_kerberosgss.c
4ab02b2f5b492a4bdbbabd24368f62d56baf7add
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
1,543
c
extra-patch-src_kerberosgss.c
--- src/kerberosgss.c.orig 2016-01-25 17:51:33 UTC +++ src/kerberosgss.c @@ -43,7 +43,7 @@ char* server_principal_details(const cha int code; krb5_context kcontext; krb5_keytab kt = NULL; - krb5_kt_cursor cursor = NULL; + krb5_kt_cursor cursor; krb5_keytab_entry entry; char* pname = NULL; @@ -98,13 +98,13 @@ char* server_principal_details(const cha goto end; } strcpy(result, pname); - krb5_free_unparsed_name(kcontext, pname); - krb5_free_keytab_entry_contents(kcontext, &entry); + krb5_xfree(pname); + krb5_kt_free_entry(kcontext, &entry); break; } - krb5_free_unparsed_name(kcontext, pname); - krb5_free_keytab_entry_contents(kcontext, &entry); + krb5_xfree(pname); + krb5_kt_free_entry(kcontext, &entry); } if (result == NULL) { @@ -115,9 +115,7 @@ char* server_principal_details(const cha } end: - if (cursor) { - krb5_kt_end_seq_get(kcontext, kt, &cursor); - } + krb5_kt_end_seq_get(kcontext, kt, &cursor); if (kt) { krb5_kt_close(kcontext, kt); } @@ -150,7 +148,7 @@ int authenticate_gss_client_init( name_token.value = (char *)service; maj_stat = gss_import_name( - &min_stat, &name_token, gss_krb5_nt_service_name, &state->server_name + &min_stat, &name_token, GSS_C_NT_HOSTBASED_SERVICE, &state->server_name ); if (GSS_ERROR(maj_stat)) {
11bbb779932958ee40e7db4026bc6e5755a748bf
eecd5e4c50d8b78a769bcc2675250576bed34066
/src/tao/bound/impls/bqnls/bqnls.c
8114b08eecd2409f0d9bdccf0fe45510442109c2
[ "BSD-2-Clause" ]
permissive
petsc/petsc
3b1a04fea71858e0292f9fd4d04ea11618c50969
9c5460f9064ca60dd71a234a1f6faf93e7a6b0c9
refs/heads/main
2023-08-17T20:51:16.507070
2023-08-17T16:08:06
2023-08-17T16:08:06
8,691,401
341
169
NOASSERTION
2023-03-29T11:02:58
2013-03-10T20:55:21
C
UTF-8
C
false
false
4,593
c
bqnls.c
#include <../src/tao/bound/impls/bqnk/bqnk.h> static const char *BNK_AS[64] = {"none", "bertsekas"}; static PetscErrorCode TaoBQNLSComputeHessian(Tao tao) { TAO_BNK *bnk = (TAO_BNK *)tao->data; TAO_BQNK *bqnk = (TAO_BQNK *)bnk->ctx; PetscReal gnorm2, delta; PetscFunctionBegin; /* Compute the initial scaling and update the approximation */ gnorm2 = bnk->gnorm * bnk->gnorm; if (gnorm2 == 0.0) gnorm2 = PETSC_MACHINE_EPSILON; if (bnk->f == 0.0) delta = 2.0 / gnorm2; else delta = 2.0 * PetscAbsScalar(bnk->f) / gnorm2; PetscCall(MatLMVMSymBroydenSetDelta(bqnk->B, delta)); PetscCall(MatLMVMUpdate(bqnk->B, tao->solution, bnk->unprojected_gradient)); PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TaoBQNLSComputeStep(Tao tao, PetscBool shift, KSPConvergedReason *ksp_reason, PetscInt *step_type) { TAO_BNK *bnk = (TAO_BNK *)tao->data; TAO_BQNK *bqnk = (TAO_BQNK *)bnk->ctx; PetscInt nupdates; PetscFunctionBegin; PetscCall(MatSolve(bqnk->B, tao->gradient, tao->stepdirection)); PetscCall(VecScale(tao->stepdirection, -1.0)); PetscCall(TaoBNKBoundStep(tao, bnk->as_type, tao->stepdirection)); *ksp_reason = KSP_CONVERGED_ATOL; PetscCall(MatLMVMGetUpdateCount(bqnk->B, &nupdates)); if (nupdates == 0) *step_type = BNK_SCALED_GRADIENT; else *step_type = BNK_BFGS; PetscFunctionReturn(PETSC_SUCCESS); } static PetscErrorCode TaoSetFromOptions_BQNLS(Tao tao, PetscOptionItems *PetscOptionsObject) { TAO_BNK *bnk = (TAO_BNK *)tao->data; TAO_BQNK *bqnk = (TAO_BQNK *)bnk->ctx; PetscBool is_set, is_spd; PetscFunctionBegin; PetscOptionsHeadBegin(PetscOptionsObject, "Quasi-Newton-Krylov method for bound constrained optimization"); PetscCall(PetscOptionsEList("-tao_bnk_as_type", "active set estimation method", "", BNK_AS, BNK_AS_TYPES, BNK_AS[bnk->as_type], &bnk->as_type, NULL)); PetscCall(PetscOptionsReal("-tao_bnk_epsilon", "(developer) tolerance used when computing actual and predicted reduction", "", bnk->epsilon, &bnk->epsilon, NULL)); PetscCall(PetscOptionsReal("-tao_bnk_as_tol", "(developer) initial tolerance used when estimating actively bounded variables", "", bnk->as_tol, &bnk->as_tol, NULL)); PetscCall(PetscOptionsReal("-tao_bnk_as_step", "(developer) step length used when estimating actively bounded variables", "", bnk->as_step, &bnk->as_step, NULL)); PetscCall(PetscOptionsInt("-tao_bnk_max_cg_its", "number of BNCG iterations to take for each Newton step", "", bnk->max_cg_its, &bnk->max_cg_its, NULL)); PetscOptionsHeadEnd(); PetscCall(TaoSetOptionsPrefix(bnk->bncg, ((PetscObject)(tao))->prefix)); PetscCall(TaoAppendOptionsPrefix(bnk->bncg, "tao_bnk_")); PetscCall(TaoSetFromOptions(bnk->bncg)); PetscCall(MatSetOptionsPrefix(bqnk->B, ((PetscObject)tao)->prefix)); PetscCall(MatAppendOptionsPrefix(bqnk->B, "tao_bqnls_")); PetscCall(MatSetFromOptions(bqnk->B)); PetscCall(MatIsSPDKnown(bqnk->B, &is_set, &is_spd)); PetscCheck(is_set && is_spd, PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_INCOMP, "LMVM matrix must be symmetric positive-definite"); PetscFunctionReturn(PETSC_SUCCESS); } /*MC TAOBQNLS - Bounded Quasi-Newton Line Search method for nonlinear minimization with bound constraints. This method approximates the action of the inverse-Hessian with a limited memory quasi-Newton formula. The quasi-Newton matrix and its options are accessible via the prefix `-tao_bqnls_` Options Database Keys: + -tao_bnk_max_cg_its - maximum number of bounded conjugate-gradient iterations taken in each Newton loop . -tao_bnk_as_type - active-set estimation method ("none", "bertsekas") . -tao_bnk_epsilon - (developer) tolerance for small pred/actual ratios that trigger automatic step acceptance . -tao_bnk_as_tol - (developer) initial tolerance used in estimating bounded active variables (-as_type bertsekas) - -tao_bnk_as_step - (developer) trial step length used in estimating bounded active variables (-as_type bertsekas) Level: beginner .seealso: `TAOBNK` M*/ PETSC_EXTERN PetscErrorCode TaoCreate_BQNLS(Tao tao) { TAO_BNK *bnk; TAO_BQNK *bqnk; PetscFunctionBegin; PetscCall(TaoCreate_BQNK(tao)); tao->ops->setfromoptions = TaoSetFromOptions_BQNLS; bnk = (TAO_BNK *)tao->data; bnk->update_type = BNK_UPDATE_STEP; bnk->computehessian = TaoBQNLSComputeHessian; bnk->computestep = TaoBQNLSComputeStep; bqnk = (TAO_BQNK *)bnk->ctx; bqnk->solve = TaoSolve_BNLS; PetscCall(MatSetType(bqnk->B, MATLMVMBFGS)); PetscFunctionReturn(PETSC_SUCCESS); }
95480d945de660bb6946d98729c62cfa0d17f681
9a93716eed42f3bd3cae461aed0b0a84a9b90b1b
/source/icdab_avx/icdab_avx/advanced_instructions.c
bae59ba5d45871628d55d1cfd853bb2d223ab3a8
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
faisalmemon/ios-crash-dump-analysis-book
cd4ea70f87f86596a0db06b5c720004bab60d036
a6b59e1f2f49b72bbf8584294118ca52f13b80cb
refs/heads/master
2023-04-16T06:41:00.392066
2023-03-19T21:50:04
2023-03-19T21:50:29
139,962,740
562
88
NOASSERTION
2021-12-24T01:52:41
2018-07-06T09:20:48
Objective-C
UTF-8
C
false
false
1,804
c
advanced_instructions.c
// // advanced_instructions.c // icdab_avx // // Created by Faisal Memon on 06/10/2020. // /* https://www.codeproject.com/Articles/874396/Crunching-Numbers-with-AVX-and-AVX This function is uses an unsafe practice of not checking whether the platform supports the instructions it wants to execute beforehand. Ideally, a higher level library, such as the Accelerate Framework should be used. For this project, our non-default settings are: Build Active Architecture Only set to YES for both Debug and Release. - This stops an ARM-64 version being build from an Intel Mac. Enable Additional Vector Extensions set to "AVX" - This allows the _mm256_* instructions to be compiled. We perform Product > Archive but from an Intel Mac. The app is then run on an Apple Silicon Mac. It will crash. */ #include "advanced_instructions.h" #include <immintrin.h> #include <stdio.h> #include <sys/sysctl.h> #include <unistd.h> #include <errno.h> void compute_delta() { /* Initialize the two argument vectors */ __m256 evens = _mm256_set_ps(2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0); __m256 odds = _mm256_set_ps(1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0); /* Compute the difference between the two vectors */ __m256 result = _mm256_sub_ps(evens, odds); /* Display the elements of the result vector */ float* f = (float*)&result; printf("%f %f %f %f %f %f %f %f\n", f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]); return; } bool avx_v1_supported() { int ret = 0; size_t size = sizeof(ret); if (sysctlbyname("hw.optional.avx1_0", &ret, &size, NULL, 0) == -1) { if (errno == ENOENT) return false; return false; } bool supported = (ret != 0); return supported; }
32be7ac6554fa99222d4765b9ac0a8c37ee2ecab
407c96d904cf46a5f95217e44071f999783698a3
/trezor-crypto/crypto/base58.c
1a007a2cbc0a8b6cb288fcb5977c09da0ea90913
[ "BSD-3-Clause", "LicenseRef-scancode-protobuf", "LGPL-2.1-only", "Swift-exception", "MIT", "BSL-1.0", "Apache-2.0" ]
permissive
trustwallet/wallet-core
dfeb276ddf1e3faf46c82f0a0cda2551e9c873f6
0c8e2e58aa8eb1360e4a6b03df91fb2de97e3caa
refs/heads/master
2023-08-21T11:58:43.983035
2023-08-18T10:51:13
2023-08-18T10:51:13
170,738,310
2,311
1,283
Apache-2.0
2023-09-08T11:26:39
2019-02-14T18:25:54
C++
UTF-8
C
false
false
8,469
c
base58.c
/** * Copyright (c) 2012-2014 Luke Dashjr * Copyright (c) 2013-2014 Pavol Rusnak * * 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. */ #include <TrezorCrypto/base58.h> #include <stdbool.h> #include <string.h> #include <TrezorCrypto/memzero.h> #include <TrezorCrypto/ripemd160.h> #include <TrezorCrypto/sha2.h> const char b58digits_ordered[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; const int8_t b58digits_map[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, 9, 10, 11, 12, 13, 14, 15, 16, -1, 17, 18, 19, 20, 21, -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, -1, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, }; typedef uint64_t b58_maxint_t; typedef uint32_t b58_almostmaxint_t; #define b58_almostmaxint_bits (sizeof(b58_almostmaxint_t) * 8) const b58_almostmaxint_t b58_almostmaxint_mask = ((((b58_maxint_t)1) << b58_almostmaxint_bits) - 1); // Decodes a null-terminated Base58 string `b58` to binary and writes the result // at the end of the buffer `bin` of size `*binszp`. On success `*binszp` is set // to the number of valid bytes at the end of the buffer. bool b58tobin(void *bin, size_t *binszp, const char *b58) { size_t binsz = *binszp; if (binsz == 0) { return false; } const unsigned char *b58u = (const unsigned char *)b58; unsigned char *binu = bin; size_t outisz = (binsz + sizeof(b58_almostmaxint_t) - 1) / sizeof(b58_almostmaxint_t); b58_almostmaxint_t outi[outisz]; b58_maxint_t t = 0; b58_almostmaxint_t c = 0; size_t i = 0, j = 0; uint8_t bytesleft = binsz % sizeof(b58_almostmaxint_t); b58_almostmaxint_t zeromask = bytesleft ? (b58_almostmaxint_mask << (bytesleft * 8)) : 0; unsigned zerocount = 0; size_t b58sz = strlen(b58); memzero(outi, sizeof(outi)); // Leading zeros, just count for (i = 0; i < b58sz && b58u[i] == '1'; ++i) ++zerocount; for (; i < b58sz; ++i) { if (b58u[i] & 0x80) // High-bit set on invalid digit return false; if (b58digits_map[b58u[i]] == -1) // Invalid base58 digit return false; c = (unsigned)b58digits_map[b58u[i]]; for (j = outisz; j--;) { t = ((b58_maxint_t)outi[j]) * 58 + c; c = t >> b58_almostmaxint_bits; outi[j] = t & b58_almostmaxint_mask; } if (c) // Output number too big (carry to the next int32) return false; if (outi[0] & zeromask) // Output number too big (last int32 filled too far) return false; } j = 0; if (bytesleft) { for (i = bytesleft; i > 0; --i) { *(binu++) = (outi[0] >> (8 * (i - 1))) & 0xff; } ++j; } for (; j < outisz; ++j) { for (i = sizeof(*outi); i > 0; --i) { *(binu++) = (outi[j] >> (8 * (i - 1))) & 0xff; } } // locate the most significant byte binu = bin; for (i = 0; i < binsz; ++i) { if (binu[i]) break; } // prepend the correct number of null-bytes if (zerocount > i) { /* result too large */ return false; } *binszp = binsz - i + zerocount; return true; } int b58check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str) { unsigned char buf[32] = {0}; const uint8_t *binc = bin; unsigned i = 0; if (binsz < 4) return -4; hasher_Raw(hasher_type, bin, binsz - 4, buf); if (memcmp(&binc[binsz - 4], buf, 4)) return -1; // Check number of zeros is correct AFTER verifying checksum (to avoid // possibility of accessing base58str beyond the end) for (i = 0; binc[i] == '\0' && base58str[i] == '1'; ++i) { } // Just finding the end of zeros, nothing to do in loop if (binc[i] == '\0' || base58str[i] == '1') return -3; return binc[0]; } bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz) { const uint8_t *bin = data; int carry = 0; size_t i = 0, j = 0, high = 0, zcount = 0; size_t size = 0; while (zcount < binsz && !bin[zcount]) ++zcount; size = (binsz - zcount) * 138 / 100 + 1; uint8_t buf[size]; memzero(buf, size); for (i = zcount, high = size - 1; i < binsz; ++i, high = j) { for (carry = bin[i], j = size - 1; (j > high) || carry; --j) { carry += 256 * buf[j]; buf[j] = carry % 58; carry /= 58; if (!j) { // Otherwise j wraps to maxint which is > high break; } } } for (j = 0; j < size && !buf[j]; ++j) ; if (*b58sz <= zcount + size - j) { *b58sz = zcount + size - j + 1; return false; } if (zcount) memset(b58, '1', zcount); for (i = zcount; j < size; ++i, ++j) b58[i] = b58digits_ordered[buf[j]]; b58[i] = '\0'; *b58sz = i + 1; return true; } int base58_encode_check(const uint8_t *data, int datalen, HasherType hasher_type, char *str, int strsize) { if (datalen > 128) { return 0; } uint8_t buf[datalen + 32]; memset(buf, 0, sizeof(buf)); uint8_t *hash = buf + datalen; memcpy(buf, data, datalen); hasher_Raw(hasher_type, data, datalen, hash); size_t res = strsize; bool success = b58enc(str, &res, buf, datalen + 4); memzero(buf, sizeof(buf)); return success ? res : 0; } int base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen) { if (datalen > 128) { return 0; } uint8_t d[datalen + 4]; memset(d, 0, sizeof(d)); size_t res = datalen + 4; if (b58tobin(d, &res, str) != true) { return 0; } uint8_t *nd = d + datalen + 4 - res; if (b58check(nd, res, hasher_type, str) < 0) { return 0; } memcpy(data, nd, res - 4); return res - 4; } #if USE_GRAPHENE int b58gphcheck(const void *bin, size_t binsz, const char *base58str) { unsigned char buf[32] = {0}; const uint8_t *binc = bin; unsigned i = 0; if (binsz < 4) return -4; ripemd160(bin, binsz - 4, buf); // No double SHA256, but a single RIPEMD160 if (memcmp(&binc[binsz - 4], buf, 4)) return -1; // Check number of zeros is correct AFTER verifying checksum (to avoid // possibility of accessing base58str beyond the end) for (i = 0; binc[i] == '\0' && base58str[i] == '1'; ++i) { } // Just finding the end of zeros, nothing to do in loop if (binc[i] == '\0' || base58str[i] == '1') return -3; return binc[0]; } int base58gph_encode_check(const uint8_t *data, int datalen, char *str, int strsize) { if (datalen > 128) { return 0; } uint8_t buf[datalen + 32]; memset(buf, 0, sizeof(buf)); uint8_t *hash = buf + datalen; memcpy(buf, data, datalen); ripemd160(data, datalen, hash); // No double SHA256, but a single RIPEMD160 size_t res = strsize; bool success = b58enc(str, &res, buf, datalen + 4); memzero(buf, sizeof(buf)); return success ? res : 0; } int base58gph_decode_check(const char *str, uint8_t *data, int datalen) { if (datalen > 128) { return 0; } uint8_t d[datalen + 4]; memset(d, 0, sizeof(d)); size_t res = datalen + 4; if (b58tobin(d, &res, str) != true) { return 0; } uint8_t *nd = d + datalen + 4 - res; if (b58gphcheck(nd, res, str) < 0) { return 0; } memcpy(data, nd, res - 4); return res - 4; } #endif
7df8684a7170e72cf97a6d7cf082a6d368cdcb27
fc93b954a786f638be22ef0ba144e2ae77547ff0
/src/AdafruitIO_WiFi.h
4ab00c8d16370399e0206a280798daa2cb4d69cd
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
adafruit/Adafruit_IO_Arduino
d8bb2c05bed9b3c671fc5f8348222cf7def88216
4d87df25287483f811996e7358cbc08af465b6e5
refs/heads/master
2023-08-04T18:47:18.778052
2023-07-21T14:53:13
2023-07-21T14:53:13
36,833,107
214
133
NOASSERTION
2023-07-21T14:52:56
2015-06-03T22:02:19
C++
UTF-8
C
false
false
1,466
h
AdafruitIO_WiFi.h
/*! * @file AdafruitIO_WiFi.h * * This is part of the Adafruit IO library for the Arduino platform. * * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing * products from Adafruit! * * Written by Tony DiCola, Todd Treece for Adafruit Industries * * MIT license, all text here must be included in any redistribution. * */ #ifndef ADAFRUITIO_WIFI_H #define ADAFRUITIO_WIFI_H #if defined(ARDUINO_SAMD_MKR1000) #include "wifi/AdafruitIO_MKR1000.h" typedef AdafruitIO_MKR1000 AdafruitIO_WiFi; #elif defined(ARDUINO_SAMD_MKR1010) #include "wifi/AdafruitIO_MKR1010.h" typedef AdafruitIO_MKR1010 AdafruitIO_WiFi; #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \ defined(USE_AIRLIFT) #include "wifi/AdafruitIO_AIRLIFT.h" typedef AdafruitIO_AIRLIFT AdafruitIO_WiFi; #elif defined(USE_WINC1500) #include "wifi/AdafruitIO_WINC1500.h" typedef AdafruitIO_WINC1500 AdafruitIO_WiFi; #elif defined(ARDUINO_ARCH_ESP32) #include "wifi/AdafruitIO_ESP32.h" typedef AdafruitIO_ESP32 AdafruitIO_WiFi; #elif defined(ESP8266) #include "wifi/AdafruitIO_ESP8266.h" typedef AdafruitIO_ESP8266 AdafruitIO_WiFi; #elif defined(ARDUINO_STM32_FEATHER) #include "wifi/AdafruitIO_WICED.h" typedef AdafruitIO_WICED AdafruitIO_WiFi; #else #warning "Must define USE_AIRLIFT or USE_WINC1500 before including this file." #endif #endif // ADAFRUITIO_WIFI_H
bd64f29f1cf676eaee11c528a134b6585f1cd242
6432ea7a083ff6ba21ea17af9ee47b9c371760f7
/stage0/stdlib/Lean/Meta/Tactic/Replace.c
095dd4c3573367c93fec3a6eba9af01f4bd6f988
[ "Apache-2.0", "LLVM-exception", "NCSA", "LGPL-3.0-only", "LicenseRef-scancode-inner-net-2.0", "BSD-3-Clause", "LGPL-2.0-or-later", "Spencer-94", "LGPL-2.1-or-later", "HPND", "LicenseRef-scancode-pcre", "ISC", "LGPL-2.1-only", "LicenseRef-scancode-other-permissive", "SunPro", "CMU-Mach" ]
permissive
leanprover/lean4
4bdf9790294964627eb9be79f5e8f6157780b4cc
f1f9dc0f2f531af3312398999d8b8303fa5f096b
refs/heads/master
2023-08-30T01:57:45.786981
2023-08-29T23:14:28
2023-08-29T23:14:28
129,571,436
2,827
311
Apache-2.0
2023-09-14T18:29:16
2018-04-15T02:49:20
Lean
UTF-8
C
false
false
136,897
c
Replace.c
// Lean compiler output // Module: Lean.Meta.Tactic.Replace // Imports: Init Lean.Util.ForEachExpr Lean.Meta.AppBuilder Lean.Meta.MatchUtil Lean.Meta.Tactic.Util Lean.Meta.Tactic.Revert Lean.Meta.Tactic.Intro Lean.Meta.Tactic.Clear Lean.Meta.Tactic.Assert #include <lean/lean.h> #if defined(__clang__) #pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-label" #elif defined(__GNUC__) && !defined(__CLANG__) #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-label" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #ifdef __cplusplus extern "C" { #endif lean_object* l_Lean_Expr_const___override(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_changeLocalDecl(lean_object*, lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetDefEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_throwTacticEx___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_mk_empty_array_with_capacity(lean_object*); lean_object* l_Lean_mkAppN(lean_object*, lean_object*); static lean_object* l_Lean_MVarId_replaceTargetEq___lambda__1___closed__2; static lean_object* l_Lean_MVarId_replaceTargetEq___closed__1; lean_object* l_Lean_Meta_mkFreshExprMVarAt(lean_object*, lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDeclDefEq___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_MVarId_checkNotAssigned(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_isExprDefEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_change___lambda__2___closed__3; lean_object* lean_array_push(lean_object*, lean_object*); static lean_object* l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__2; LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDeclDefEq___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_replaceTargetEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_replaceLocalDeclDefEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_mkExpectedTypeHint(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_modifyTarget___closed__2; lean_object* l_Lean_MVarId_getTag(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_fvarId_x21(lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__3; lean_object* l_Lean_LocalDecl_setType(lean_object*, lean_object*); lean_object* l_Lean_stringToMessageData(lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_replaceLocalDecl(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_LocalDecl_index(lean_object*); lean_object* l_Lean_HashMap_insert___at_Lean_ForEachExpr_visit___spec__3(lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_change___lambda__2___closed__4; LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1(lean_object*, lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_PersistentArray_set___rarg(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_mkEqMP(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_change___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__1; static lean_object* l_Lean_MVarId_changeLocalDecl___closed__2; LEAN_EXPORT lean_object* l_Lean_Meta_changeLocalDecl___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_local_ctx_find(lean_object*, lean_object*); lean_object* lean_st_ref_take(lean_object*, lean_object*); uint8_t lean_expr_eqv(lean_object*, lean_object*); lean_object* l_Lean_PersistentHashMap_insert___at_Lean_LocalContext_mkLocalDecl___spec__1(lean_object*, lean_object*, lean_object*); lean_object* l_Lean_MVarId_getType(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_SavedState_restore(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTargetEqLHS___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTarget___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_getLevel(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_FVarId_getDecl(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_forallE___override(lean_object*, lean_object*, lean_object*, uint8_t); static lean_object* l_Lean_MVarId_change___lambda__2___closed__2; lean_object* lean_st_ref_get(lean_object*, lean_object*); lean_object* lean_st_mk_ref(lean_object*, lean_object*); lean_object* l_Lean_Meta_mkEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2; lean_object* l_Lean_MVarId_assertAfter(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_replaceTargetEq___lambda__1___closed__4; lean_object* l_Lean_MVarId_revert(lean_object*, lean_object*, uint8_t, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_HashMapImp_find_x3f___at_Lean_ForEachExpr_visit___spec__1(lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDecl(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_FVarId_getType(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_modifyTargetEqLHS(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_letE___override(lean_object*, lean_object*, lean_object*, lean_object*, uint8_t); LEAN_EXPORT lean_object* l_Lean_Meta_replaceTargetDefEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Name_str___override(lean_object*, lean_object*); lean_object* l_Lean_MVarId_clear(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___closed__3; LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetEq___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_saveState___rarg(lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_LocalDecl_fvarId(lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetDefEq___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___closed__1; LEAN_EXPORT lean_object* l_Lean_Meta_change(lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__2; lean_object* l_Lean_LocalDecl_userName(lean_object*); static lean_object* l_Lean_MVarId_replaceTargetEq___closed__2; lean_object* l_Lean_Meta_introNCore(lean_object*, lean_object*, lean_object*, uint8_t, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_change___lambda__2___closed__1; LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_replaceTargetEq___lambda__1___closed__1; static lean_object* l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__1; LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_MVarId_getDecl(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); uint8_t lean_nat_dec_lt(lean_object*, lean_object*); lean_object* l_Lean_Meta_getLocalInstances(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Name_mkStr2(lean_object*, lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___closed__4; lean_object* l_Lean_indentExpr(lean_object*); static lean_object* l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__4; LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl(lean_object*, lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_change___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_change(lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_change___lambda__2___closed__6; LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___closed__1; lean_object* l_Lean_mkHashMapImp___rarg(lean_object*); uint8_t l_Lean_Expr_hasFVar(lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_fvar___override(lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTarget(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_st_ref_set(lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_Meta_modifyTarget(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_replaceTargetDefEq___closed__1; static lean_object* l_Lean_MVarId_replaceTargetEq___lambda__1___closed__3; static lean_object* l_Lean_MVarId_replaceTargetDefEq___closed__2; LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTargetEqLHS(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Meta_mkFreshExprSyntheticOpaqueMVar(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* lean_array_get_size(lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDeclDefEq(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__2(lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___closed__5; uint8_t l_Lean_Expr_isFVar(lean_object*); static lean_object* l_Lean_MVarId_modifyTarget___closed__1; LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); lean_object* l_Lean_Expr_mvarId_x21(lean_object*); static lean_object* l_Lean_MVarId_changeLocalDecl___closed__3; static lean_object* l_Lean_MVarId_change___lambda__2___closed__5; lean_object* l_Lean_Meta_matchEq_x3f(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*); static lean_object* _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("Eq", 2); return x_1; } } static lean_object* _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__2() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("mpr", 3); return x_1; } } static lean_object* _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__3() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = l_Lean_MVarId_replaceTargetEq___lambda__1___closed__1; x_2 = l_Lean_MVarId_replaceTargetEq___lambda__1___closed__2; x_3 = l_Lean_Name_mkStr2(x_1, x_2); return x_3; } } static lean_object* _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__4() { _start: { lean_object* x_1; lean_object* x_2; x_1 = lean_unsigned_to_nat(4u); x_2 = lean_mk_empty_array_with_capacity(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetEq___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; lean_inc(x_7); lean_inc(x_5); lean_inc(x_1); x_10 = l_Lean_MVarId_checkNotAssigned(x_1, x_2, x_5, x_6, x_7, x_8, x_9); if (lean_obj_tag(x_10) == 0) { lean_object* x_11; lean_object* x_12; x_11 = lean_ctor_get(x_10, 1); lean_inc(x_11); lean_dec(x_10); lean_inc(x_1); x_12 = l_Lean_MVarId_getTag(x_1, x_5, x_6, x_7, x_8, x_11); if (lean_obj_tag(x_12) == 0) { lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; x_13 = lean_ctor_get(x_12, 0); lean_inc(x_13); x_14 = lean_ctor_get(x_12, 1); lean_inc(x_14); lean_dec(x_12); lean_inc(x_5); lean_inc(x_3); x_15 = l_Lean_Meta_mkFreshExprSyntheticOpaqueMVar(x_3, x_13, x_5, x_6, x_7, x_8, x_14); x_16 = lean_ctor_get(x_15, 0); lean_inc(x_16); x_17 = lean_ctor_get(x_15, 1); lean_inc(x_17); lean_dec(x_15); lean_inc(x_1); x_18 = l_Lean_MVarId_getType(x_1, x_5, x_6, x_7, x_8, x_17); if (lean_obj_tag(x_18) == 0) { lean_object* x_19; lean_object* x_20; lean_object* x_21; x_19 = lean_ctor_get(x_18, 0); lean_inc(x_19); x_20 = lean_ctor_get(x_18, 1); lean_inc(x_20); lean_dec(x_18); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_19); x_21 = l_Lean_Meta_getLevel(x_19, x_5, x_6, x_7, x_8, x_20); if (lean_obj_tag(x_21) == 0) { lean_object* x_22; lean_object* x_23; lean_object* x_24; x_22 = lean_ctor_get(x_21, 0); lean_inc(x_22); x_23 = lean_ctor_get(x_21, 1); lean_inc(x_23); lean_dec(x_21); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_3); lean_inc(x_19); x_24 = l_Lean_Meta_mkEq(x_19, x_3, x_5, x_6, x_7, x_8, x_23); if (lean_obj_tag(x_24) == 0) { lean_object* x_25; lean_object* x_26; lean_object* x_27; x_25 = lean_ctor_get(x_24, 0); lean_inc(x_25); x_26 = lean_ctor_get(x_24, 1); lean_inc(x_26); lean_dec(x_24); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_27 = l_Lean_Meta_mkExpectedTypeHint(x_4, x_25, x_5, x_6, x_7, x_8, x_26); if (lean_obj_tag(x_27) == 0) { lean_object* x_28; lean_object* x_29; lean_object* x_30; lean_object* x_31; lean_object* x_32; lean_object* x_33; lean_object* x_34; lean_object* x_35; lean_object* x_36; lean_object* x_37; lean_object* x_38; lean_object* x_39; lean_object* x_40; uint8_t x_41; x_28 = lean_ctor_get(x_27, 0); lean_inc(x_28); x_29 = lean_ctor_get(x_27, 1); lean_inc(x_29); lean_dec(x_27); x_30 = lean_box(0); x_31 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_31, 0, x_22); lean_ctor_set(x_31, 1, x_30); x_32 = l_Lean_MVarId_replaceTargetEq___lambda__1___closed__3; x_33 = l_Lean_Expr_const___override(x_32, x_31); x_34 = l_Lean_MVarId_replaceTargetEq___lambda__1___closed__4; x_35 = lean_array_push(x_34, x_19); x_36 = lean_array_push(x_35, x_3); x_37 = lean_array_push(x_36, x_28); lean_inc(x_16); x_38 = lean_array_push(x_37, x_16); x_39 = l_Lean_mkAppN(x_33, x_38); x_40 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_1, x_39, x_5, x_6, x_7, x_8, x_29); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); x_41 = !lean_is_exclusive(x_40); if (x_41 == 0) { lean_object* x_42; lean_object* x_43; x_42 = lean_ctor_get(x_40, 0); lean_dec(x_42); x_43 = l_Lean_Expr_mvarId_x21(x_16); lean_ctor_set(x_40, 0, x_43); return x_40; } else { lean_object* x_44; lean_object* x_45; lean_object* x_46; x_44 = lean_ctor_get(x_40, 1); lean_inc(x_44); lean_dec(x_40); x_45 = l_Lean_Expr_mvarId_x21(x_16); x_46 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_46, 0, x_45); lean_ctor_set(x_46, 1, x_44); return x_46; } } else { uint8_t x_47; lean_dec(x_22); lean_dec(x_19); lean_dec(x_16); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_1); x_47 = !lean_is_exclusive(x_27); if (x_47 == 0) { return x_27; } else { lean_object* x_48; lean_object* x_49; lean_object* x_50; x_48 = lean_ctor_get(x_27, 0); x_49 = lean_ctor_get(x_27, 1); lean_inc(x_49); lean_inc(x_48); lean_dec(x_27); x_50 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_50, 0, x_48); lean_ctor_set(x_50, 1, x_49); return x_50; } } } else { uint8_t x_51; lean_dec(x_22); lean_dec(x_19); lean_dec(x_16); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_51 = !lean_is_exclusive(x_24); if (x_51 == 0) { return x_24; } else { lean_object* x_52; lean_object* x_53; lean_object* x_54; x_52 = lean_ctor_get(x_24, 0); x_53 = lean_ctor_get(x_24, 1); lean_inc(x_53); lean_inc(x_52); lean_dec(x_24); x_54 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_54, 0, x_52); lean_ctor_set(x_54, 1, x_53); return x_54; } } } else { uint8_t x_55; lean_dec(x_19); lean_dec(x_16); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_55 = !lean_is_exclusive(x_21); if (x_55 == 0) { return x_21; } else { lean_object* x_56; lean_object* x_57; lean_object* x_58; x_56 = lean_ctor_get(x_21, 0); x_57 = lean_ctor_get(x_21, 1); lean_inc(x_57); lean_inc(x_56); lean_dec(x_21); x_58 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_58, 0, x_56); lean_ctor_set(x_58, 1, x_57); return x_58; } } } else { uint8_t x_59; lean_dec(x_16); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_59 = !lean_is_exclusive(x_18); if (x_59 == 0) { return x_18; } else { lean_object* x_60; lean_object* x_61; lean_object* x_62; x_60 = lean_ctor_get(x_18, 0); x_61 = lean_ctor_get(x_18, 1); lean_inc(x_61); lean_inc(x_60); lean_dec(x_18); x_62 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_62, 0, x_60); lean_ctor_set(x_62, 1, x_61); return x_62; } } } else { uint8_t x_63; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_63 = !lean_is_exclusive(x_12); if (x_63 == 0) { return x_12; } else { lean_object* x_64; lean_object* x_65; lean_object* x_66; x_64 = lean_ctor_get(x_12, 0); x_65 = lean_ctor_get(x_12, 1); lean_inc(x_65); lean_inc(x_64); lean_dec(x_12); x_66 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_66, 0, x_64); lean_ctor_set(x_66, 1, x_65); return x_66; } } } else { uint8_t x_67; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_67 = !lean_is_exclusive(x_10); if (x_67 == 0) { return x_10; } else { lean_object* x_68; lean_object* x_69; lean_object* x_70; x_68 = lean_ctor_get(x_10, 0); x_69 = lean_ctor_get(x_10, 1); lean_inc(x_69); lean_inc(x_68); lean_dec(x_10); x_70 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_70, 0, x_68); lean_ctor_set(x_70, 1, x_69); return x_70; } } } } static lean_object* _init_l_Lean_MVarId_replaceTargetEq___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("replaceTarget", 13); return x_1; } } static lean_object* _init_l_Lean_MVarId_replaceTargetEq___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_Lean_MVarId_replaceTargetEq___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetEq(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_object* x_10; lean_object* x_11; x_9 = l_Lean_MVarId_replaceTargetEq___closed__2; lean_inc(x_1); x_10 = lean_alloc_closure((void*)(l_Lean_MVarId_replaceTargetEq___lambda__1), 9, 4); lean_closure_set(x_10, 0, x_1); lean_closure_set(x_10, 1, x_9); lean_closure_set(x_10, 2, x_2); lean_closure_set(x_10, 3, x_3); x_11 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_10, x_4, x_5, x_6, x_7, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Lean_Meta_replaceTargetEq(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; x_9 = l_Lean_MVarId_replaceTargetEq(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8); return x_9; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetDefEq___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_inc(x_6); lean_inc(x_4); lean_inc(x_1); x_9 = l_Lean_MVarId_checkNotAssigned(x_1, x_2, x_4, x_5, x_6, x_7, x_8); if (lean_obj_tag(x_9) == 0) { lean_object* x_10; lean_object* x_11; x_10 = lean_ctor_get(x_9, 1); lean_inc(x_10); lean_dec(x_9); lean_inc(x_1); x_11 = l_Lean_MVarId_getType(x_1, x_4, x_5, x_6, x_7, x_10); if (lean_obj_tag(x_11) == 0) { uint8_t x_12; x_12 = !lean_is_exclusive(x_11); if (x_12 == 0) { lean_object* x_13; lean_object* x_14; uint8_t x_15; x_13 = lean_ctor_get(x_11, 0); x_14 = lean_ctor_get(x_11, 1); x_15 = lean_expr_eqv(x_13, x_3); if (x_15 == 0) { lean_object* x_16; lean_free_object(x_11); lean_inc(x_1); x_16 = l_Lean_MVarId_getTag(x_1, x_4, x_5, x_6, x_7, x_14); if (lean_obj_tag(x_16) == 0) { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; x_17 = lean_ctor_get(x_16, 0); lean_inc(x_17); x_18 = lean_ctor_get(x_16, 1); lean_inc(x_18); lean_dec(x_16); lean_inc(x_4); x_19 = l_Lean_Meta_mkFreshExprSyntheticOpaqueMVar(x_3, x_17, x_4, x_5, x_6, x_7, x_18); x_20 = lean_ctor_get(x_19, 0); lean_inc(x_20); x_21 = lean_ctor_get(x_19, 1); lean_inc(x_21); lean_dec(x_19); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_20); x_22 = l_Lean_Meta_mkExpectedTypeHint(x_20, x_13, x_4, x_5, x_6, x_7, x_21); if (lean_obj_tag(x_22) == 0) { lean_object* x_23; lean_object* x_24; lean_object* x_25; uint8_t x_26; x_23 = lean_ctor_get(x_22, 0); lean_inc(x_23); x_24 = lean_ctor_get(x_22, 1); lean_inc(x_24); lean_dec(x_22); x_25 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_1, x_23, x_4, x_5, x_6, x_7, x_24); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); x_26 = !lean_is_exclusive(x_25); if (x_26 == 0) { lean_object* x_27; lean_object* x_28; x_27 = lean_ctor_get(x_25, 0); lean_dec(x_27); x_28 = l_Lean_Expr_mvarId_x21(x_20); lean_ctor_set(x_25, 0, x_28); return x_25; } else { lean_object* x_29; lean_object* x_30; lean_object* x_31; x_29 = lean_ctor_get(x_25, 1); lean_inc(x_29); lean_dec(x_25); x_30 = l_Lean_Expr_mvarId_x21(x_20); x_31 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_31, 0, x_30); lean_ctor_set(x_31, 1, x_29); return x_31; } } else { uint8_t x_32; lean_dec(x_20); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_32 = !lean_is_exclusive(x_22); if (x_32 == 0) { return x_22; } else { lean_object* x_33; lean_object* x_34; lean_object* x_35; x_33 = lean_ctor_get(x_22, 0); x_34 = lean_ctor_get(x_22, 1); lean_inc(x_34); lean_inc(x_33); lean_dec(x_22); x_35 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_35, 0, x_33); lean_ctor_set(x_35, 1, x_34); return x_35; } } } else { uint8_t x_36; lean_dec(x_13); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_36 = !lean_is_exclusive(x_16); if (x_36 == 0) { return x_16; } else { lean_object* x_37; lean_object* x_38; lean_object* x_39; x_37 = lean_ctor_get(x_16, 0); x_38 = lean_ctor_get(x_16, 1); lean_inc(x_38); lean_inc(x_37); lean_dec(x_16); x_39 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_39, 0, x_37); lean_ctor_set(x_39, 1, x_38); return x_39; } } } else { lean_dec(x_13); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_ctor_set(x_11, 0, x_1); return x_11; } } else { lean_object* x_40; lean_object* x_41; uint8_t x_42; x_40 = lean_ctor_get(x_11, 0); x_41 = lean_ctor_get(x_11, 1); lean_inc(x_41); lean_inc(x_40); lean_dec(x_11); x_42 = lean_expr_eqv(x_40, x_3); if (x_42 == 0) { lean_object* x_43; lean_inc(x_1); x_43 = l_Lean_MVarId_getTag(x_1, x_4, x_5, x_6, x_7, x_41); if (lean_obj_tag(x_43) == 0) { lean_object* x_44; lean_object* x_45; lean_object* x_46; lean_object* x_47; lean_object* x_48; lean_object* x_49; x_44 = lean_ctor_get(x_43, 0); lean_inc(x_44); x_45 = lean_ctor_get(x_43, 1); lean_inc(x_45); lean_dec(x_43); lean_inc(x_4); x_46 = l_Lean_Meta_mkFreshExprSyntheticOpaqueMVar(x_3, x_44, x_4, x_5, x_6, x_7, x_45); x_47 = lean_ctor_get(x_46, 0); lean_inc(x_47); x_48 = lean_ctor_get(x_46, 1); lean_inc(x_48); lean_dec(x_46); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_47); x_49 = l_Lean_Meta_mkExpectedTypeHint(x_47, x_40, x_4, x_5, x_6, x_7, x_48); if (lean_obj_tag(x_49) == 0) { lean_object* x_50; lean_object* x_51; lean_object* x_52; lean_object* x_53; lean_object* x_54; lean_object* x_55; lean_object* x_56; x_50 = lean_ctor_get(x_49, 0); lean_inc(x_50); x_51 = lean_ctor_get(x_49, 1); lean_inc(x_51); lean_dec(x_49); x_52 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_1, x_50, x_4, x_5, x_6, x_7, x_51); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); x_53 = lean_ctor_get(x_52, 1); lean_inc(x_53); if (lean_is_exclusive(x_52)) { lean_ctor_release(x_52, 0); lean_ctor_release(x_52, 1); x_54 = x_52; } else { lean_dec_ref(x_52); x_54 = lean_box(0); } x_55 = l_Lean_Expr_mvarId_x21(x_47); if (lean_is_scalar(x_54)) { x_56 = lean_alloc_ctor(0, 2, 0); } else { x_56 = x_54; } lean_ctor_set(x_56, 0, x_55); lean_ctor_set(x_56, 1, x_53); return x_56; } else { lean_object* x_57; lean_object* x_58; lean_object* x_59; lean_object* x_60; lean_dec(x_47); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_57 = lean_ctor_get(x_49, 0); lean_inc(x_57); x_58 = lean_ctor_get(x_49, 1); lean_inc(x_58); if (lean_is_exclusive(x_49)) { lean_ctor_release(x_49, 0); lean_ctor_release(x_49, 1); x_59 = x_49; } else { lean_dec_ref(x_49); x_59 = lean_box(0); } if (lean_is_scalar(x_59)) { x_60 = lean_alloc_ctor(1, 2, 0); } else { x_60 = x_59; } lean_ctor_set(x_60, 0, x_57); lean_ctor_set(x_60, 1, x_58); return x_60; } } else { lean_object* x_61; lean_object* x_62; lean_object* x_63; lean_object* x_64; lean_dec(x_40); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_61 = lean_ctor_get(x_43, 0); lean_inc(x_61); x_62 = lean_ctor_get(x_43, 1); lean_inc(x_62); if (lean_is_exclusive(x_43)) { lean_ctor_release(x_43, 0); lean_ctor_release(x_43, 1); x_63 = x_43; } else { lean_dec_ref(x_43); x_63 = lean_box(0); } if (lean_is_scalar(x_63)) { x_64 = lean_alloc_ctor(1, 2, 0); } else { x_64 = x_63; } lean_ctor_set(x_64, 0, x_61); lean_ctor_set(x_64, 1, x_62); return x_64; } } else { lean_object* x_65; lean_dec(x_40); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); x_65 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_65, 0, x_1); lean_ctor_set(x_65, 1, x_41); return x_65; } } } else { uint8_t x_66; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_66 = !lean_is_exclusive(x_11); if (x_66 == 0) { return x_11; } else { lean_object* x_67; lean_object* x_68; lean_object* x_69; x_67 = lean_ctor_get(x_11, 0); x_68 = lean_ctor_get(x_11, 1); lean_inc(x_68); lean_inc(x_67); lean_dec(x_11); x_69 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_69, 0, x_67); lean_ctor_set(x_69, 1, x_68); return x_69; } } } else { uint8_t x_70; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_70 = !lean_is_exclusive(x_9); if (x_70 == 0) { return x_9; } else { lean_object* x_71; lean_object* x_72; lean_object* x_73; x_71 = lean_ctor_get(x_9, 0); x_72 = lean_ctor_get(x_9, 1); lean_inc(x_72); lean_inc(x_71); lean_dec(x_9); x_73 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_73, 0, x_71); lean_ctor_set(x_73, 1, x_72); return x_73; } } } } static lean_object* _init_l_Lean_MVarId_replaceTargetDefEq___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("change", 6); return x_1; } } static lean_object* _init_l_Lean_MVarId_replaceTargetDefEq___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_Lean_MVarId_replaceTargetDefEq___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceTargetDefEq(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; lean_object* x_9; lean_object* x_10; x_8 = l_Lean_MVarId_replaceTargetDefEq___closed__2; lean_inc(x_1); x_9 = lean_alloc_closure((void*)(l_Lean_MVarId_replaceTargetDefEq___lambda__1), 8, 3); lean_closure_set(x_9, 0, x_1); lean_closure_set(x_9, 1, x_8); lean_closure_set(x_9, 2, x_2); x_10 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_9, x_3, x_4, x_5, x_6, x_7); return x_10; } } LEAN_EXPORT lean_object* l_Lean_Meta_replaceTargetDefEq(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Lean_MVarId_replaceTargetDefEq(x_1, x_2, x_3, x_4, x_5, x_6, x_7); return x_8; } } LEAN_EXPORT lean_object* l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; lean_object* x_11; lean_object* x_22; uint8_t x_23; x_22 = lean_st_ref_get(x_3, x_9); x_23 = !lean_is_exclusive(x_22); if (x_23 == 0) { lean_object* x_24; lean_object* x_25; lean_object* x_26; x_24 = lean_ctor_get(x_22, 0); x_25 = lean_ctor_get(x_22, 1); lean_inc(x_2); x_26 = l_Lean_HashMapImp_find_x3f___at_Lean_ForEachExpr_visit___spec__1(x_24, x_2); if (lean_obj_tag(x_26) == 0) { lean_object* x_27; lean_free_object(x_22); lean_inc(x_1); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_2); x_27 = lean_apply_7(x_1, x_2, x_4, x_5, x_6, x_7, x_8, x_25); if (lean_obj_tag(x_27) == 0) { lean_object* x_28; uint8_t x_29; x_28 = lean_ctor_get(x_27, 0); lean_inc(x_28); x_29 = lean_unbox(x_28); lean_dec(x_28); if (x_29 == 0) { lean_object* x_30; lean_object* x_31; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_30 = lean_ctor_get(x_27, 1); lean_inc(x_30); lean_dec(x_27); x_31 = lean_box(0); x_10 = x_31; x_11 = x_30; goto block_21; } else { switch (lean_obj_tag(x_2)) { case 5: { lean_object* x_32; lean_object* x_33; lean_object* x_34; lean_object* x_35; x_32 = lean_ctor_get(x_27, 1); lean_inc(x_32); lean_dec(x_27); x_33 = lean_ctor_get(x_2, 0); lean_inc(x_33); x_34 = lean_ctor_get(x_2, 1); lean_inc(x_34); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_35 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_33, x_3, x_4, x_5, x_6, x_7, x_8, x_32); if (lean_obj_tag(x_35) == 0) { lean_object* x_36; lean_object* x_37; x_36 = lean_ctor_get(x_35, 1); lean_inc(x_36); lean_dec(x_35); x_37 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_34, x_3, x_4, x_5, x_6, x_7, x_8, x_36); if (lean_obj_tag(x_37) == 0) { lean_object* x_38; lean_object* x_39; x_38 = lean_ctor_get(x_37, 0); lean_inc(x_38); x_39 = lean_ctor_get(x_37, 1); lean_inc(x_39); lean_dec(x_37); x_10 = x_38; x_11 = x_39; goto block_21; } else { uint8_t x_40; lean_dec(x_2); x_40 = !lean_is_exclusive(x_37); if (x_40 == 0) { return x_37; } else { lean_object* x_41; lean_object* x_42; lean_object* x_43; x_41 = lean_ctor_get(x_37, 0); x_42 = lean_ctor_get(x_37, 1); lean_inc(x_42); lean_inc(x_41); lean_dec(x_37); x_43 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_43, 0, x_41); lean_ctor_set(x_43, 1, x_42); return x_43; } } } else { uint8_t x_44; lean_dec(x_34); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_44 = !lean_is_exclusive(x_35); if (x_44 == 0) { return x_35; } else { lean_object* x_45; lean_object* x_46; lean_object* x_47; x_45 = lean_ctor_get(x_35, 0); x_46 = lean_ctor_get(x_35, 1); lean_inc(x_46); lean_inc(x_45); lean_dec(x_35); x_47 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_47, 0, x_45); lean_ctor_set(x_47, 1, x_46); return x_47; } } } case 6: { lean_object* x_48; lean_object* x_49; lean_object* x_50; lean_object* x_51; x_48 = lean_ctor_get(x_27, 1); lean_inc(x_48); lean_dec(x_27); x_49 = lean_ctor_get(x_2, 1); lean_inc(x_49); x_50 = lean_ctor_get(x_2, 2); lean_inc(x_50); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_51 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_49, x_3, x_4, x_5, x_6, x_7, x_8, x_48); if (lean_obj_tag(x_51) == 0) { lean_object* x_52; lean_object* x_53; x_52 = lean_ctor_get(x_51, 1); lean_inc(x_52); lean_dec(x_51); x_53 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_50, x_3, x_4, x_5, x_6, x_7, x_8, x_52); if (lean_obj_tag(x_53) == 0) { lean_object* x_54; lean_object* x_55; x_54 = lean_ctor_get(x_53, 0); lean_inc(x_54); x_55 = lean_ctor_get(x_53, 1); lean_inc(x_55); lean_dec(x_53); x_10 = x_54; x_11 = x_55; goto block_21; } else { uint8_t x_56; lean_dec(x_2); x_56 = !lean_is_exclusive(x_53); if (x_56 == 0) { return x_53; } else { lean_object* x_57; lean_object* x_58; lean_object* x_59; x_57 = lean_ctor_get(x_53, 0); x_58 = lean_ctor_get(x_53, 1); lean_inc(x_58); lean_inc(x_57); lean_dec(x_53); x_59 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_59, 0, x_57); lean_ctor_set(x_59, 1, x_58); return x_59; } } } else { uint8_t x_60; lean_dec(x_50); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_60 = !lean_is_exclusive(x_51); if (x_60 == 0) { return x_51; } else { lean_object* x_61; lean_object* x_62; lean_object* x_63; x_61 = lean_ctor_get(x_51, 0); x_62 = lean_ctor_get(x_51, 1); lean_inc(x_62); lean_inc(x_61); lean_dec(x_51); x_63 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_63, 0, x_61); lean_ctor_set(x_63, 1, x_62); return x_63; } } } case 7: { lean_object* x_64; lean_object* x_65; lean_object* x_66; lean_object* x_67; x_64 = lean_ctor_get(x_27, 1); lean_inc(x_64); lean_dec(x_27); x_65 = lean_ctor_get(x_2, 1); lean_inc(x_65); x_66 = lean_ctor_get(x_2, 2); lean_inc(x_66); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_67 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_65, x_3, x_4, x_5, x_6, x_7, x_8, x_64); if (lean_obj_tag(x_67) == 0) { lean_object* x_68; lean_object* x_69; x_68 = lean_ctor_get(x_67, 1); lean_inc(x_68); lean_dec(x_67); x_69 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_66, x_3, x_4, x_5, x_6, x_7, x_8, x_68); if (lean_obj_tag(x_69) == 0) { lean_object* x_70; lean_object* x_71; x_70 = lean_ctor_get(x_69, 0); lean_inc(x_70); x_71 = lean_ctor_get(x_69, 1); lean_inc(x_71); lean_dec(x_69); x_10 = x_70; x_11 = x_71; goto block_21; } else { uint8_t x_72; lean_dec(x_2); x_72 = !lean_is_exclusive(x_69); if (x_72 == 0) { return x_69; } else { lean_object* x_73; lean_object* x_74; lean_object* x_75; x_73 = lean_ctor_get(x_69, 0); x_74 = lean_ctor_get(x_69, 1); lean_inc(x_74); lean_inc(x_73); lean_dec(x_69); x_75 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_75, 0, x_73); lean_ctor_set(x_75, 1, x_74); return x_75; } } } else { uint8_t x_76; lean_dec(x_66); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_76 = !lean_is_exclusive(x_67); if (x_76 == 0) { return x_67; } else { lean_object* x_77; lean_object* x_78; lean_object* x_79; x_77 = lean_ctor_get(x_67, 0); x_78 = lean_ctor_get(x_67, 1); lean_inc(x_78); lean_inc(x_77); lean_dec(x_67); x_79 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_79, 0, x_77); lean_ctor_set(x_79, 1, x_78); return x_79; } } } case 8: { lean_object* x_80; lean_object* x_81; lean_object* x_82; lean_object* x_83; lean_object* x_84; x_80 = lean_ctor_get(x_27, 1); lean_inc(x_80); lean_dec(x_27); x_81 = lean_ctor_get(x_2, 1); lean_inc(x_81); x_82 = lean_ctor_get(x_2, 2); lean_inc(x_82); x_83 = lean_ctor_get(x_2, 3); lean_inc(x_83); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_84 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_81, x_3, x_4, x_5, x_6, x_7, x_8, x_80); if (lean_obj_tag(x_84) == 0) { lean_object* x_85; lean_object* x_86; x_85 = lean_ctor_get(x_84, 1); lean_inc(x_85); lean_dec(x_84); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_86 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_82, x_3, x_4, x_5, x_6, x_7, x_8, x_85); if (lean_obj_tag(x_86) == 0) { lean_object* x_87; lean_object* x_88; x_87 = lean_ctor_get(x_86, 1); lean_inc(x_87); lean_dec(x_86); x_88 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_83, x_3, x_4, x_5, x_6, x_7, x_8, x_87); if (lean_obj_tag(x_88) == 0) { lean_object* x_89; lean_object* x_90; x_89 = lean_ctor_get(x_88, 0); lean_inc(x_89); x_90 = lean_ctor_get(x_88, 1); lean_inc(x_90); lean_dec(x_88); x_10 = x_89; x_11 = x_90; goto block_21; } else { uint8_t x_91; lean_dec(x_2); x_91 = !lean_is_exclusive(x_88); if (x_91 == 0) { return x_88; } else { lean_object* x_92; lean_object* x_93; lean_object* x_94; x_92 = lean_ctor_get(x_88, 0); x_93 = lean_ctor_get(x_88, 1); lean_inc(x_93); lean_inc(x_92); lean_dec(x_88); x_94 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_94, 0, x_92); lean_ctor_set(x_94, 1, x_93); return x_94; } } } else { uint8_t x_95; lean_dec(x_83); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_95 = !lean_is_exclusive(x_86); if (x_95 == 0) { return x_86; } else { lean_object* x_96; lean_object* x_97; lean_object* x_98; x_96 = lean_ctor_get(x_86, 0); x_97 = lean_ctor_get(x_86, 1); lean_inc(x_97); lean_inc(x_96); lean_dec(x_86); x_98 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_98, 0, x_96); lean_ctor_set(x_98, 1, x_97); return x_98; } } } else { uint8_t x_99; lean_dec(x_83); lean_dec(x_82); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_99 = !lean_is_exclusive(x_84); if (x_99 == 0) { return x_84; } else { lean_object* x_100; lean_object* x_101; lean_object* x_102; x_100 = lean_ctor_get(x_84, 0); x_101 = lean_ctor_get(x_84, 1); lean_inc(x_101); lean_inc(x_100); lean_dec(x_84); x_102 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_102, 0, x_100); lean_ctor_set(x_102, 1, x_101); return x_102; } } } case 10: { lean_object* x_103; lean_object* x_104; lean_object* x_105; x_103 = lean_ctor_get(x_27, 1); lean_inc(x_103); lean_dec(x_27); x_104 = lean_ctor_get(x_2, 1); lean_inc(x_104); x_105 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_104, x_3, x_4, x_5, x_6, x_7, x_8, x_103); if (lean_obj_tag(x_105) == 0) { lean_object* x_106; lean_object* x_107; x_106 = lean_ctor_get(x_105, 0); lean_inc(x_106); x_107 = lean_ctor_get(x_105, 1); lean_inc(x_107); lean_dec(x_105); x_10 = x_106; x_11 = x_107; goto block_21; } else { uint8_t x_108; lean_dec(x_2); x_108 = !lean_is_exclusive(x_105); if (x_108 == 0) { return x_105; } else { lean_object* x_109; lean_object* x_110; lean_object* x_111; x_109 = lean_ctor_get(x_105, 0); x_110 = lean_ctor_get(x_105, 1); lean_inc(x_110); lean_inc(x_109); lean_dec(x_105); x_111 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_111, 0, x_109); lean_ctor_set(x_111, 1, x_110); return x_111; } } } case 11: { lean_object* x_112; lean_object* x_113; lean_object* x_114; x_112 = lean_ctor_get(x_27, 1); lean_inc(x_112); lean_dec(x_27); x_113 = lean_ctor_get(x_2, 2); lean_inc(x_113); x_114 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_113, x_3, x_4, x_5, x_6, x_7, x_8, x_112); if (lean_obj_tag(x_114) == 0) { lean_object* x_115; lean_object* x_116; x_115 = lean_ctor_get(x_114, 0); lean_inc(x_115); x_116 = lean_ctor_get(x_114, 1); lean_inc(x_116); lean_dec(x_114); x_10 = x_115; x_11 = x_116; goto block_21; } else { uint8_t x_117; lean_dec(x_2); x_117 = !lean_is_exclusive(x_114); if (x_117 == 0) { return x_114; } else { lean_object* x_118; lean_object* x_119; lean_object* x_120; x_118 = lean_ctor_get(x_114, 0); x_119 = lean_ctor_get(x_114, 1); lean_inc(x_119); lean_inc(x_118); lean_dec(x_114); x_120 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_120, 0, x_118); lean_ctor_set(x_120, 1, x_119); return x_120; } } } default: { lean_object* x_121; lean_object* x_122; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_121 = lean_ctor_get(x_27, 1); lean_inc(x_121); lean_dec(x_27); x_122 = lean_box(0); x_10 = x_122; x_11 = x_121; goto block_21; } } } } else { uint8_t x_123; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_123 = !lean_is_exclusive(x_27); if (x_123 == 0) { return x_27; } else { lean_object* x_124; lean_object* x_125; lean_object* x_126; x_124 = lean_ctor_get(x_27, 0); x_125 = lean_ctor_get(x_27, 1); lean_inc(x_125); lean_inc(x_124); lean_dec(x_27); x_126 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_126, 0, x_124); lean_ctor_set(x_126, 1, x_125); return x_126; } } } else { lean_object* x_127; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_127 = lean_ctor_get(x_26, 0); lean_inc(x_127); lean_dec(x_26); lean_ctor_set(x_22, 0, x_127); return x_22; } } else { lean_object* x_128; lean_object* x_129; lean_object* x_130; x_128 = lean_ctor_get(x_22, 0); x_129 = lean_ctor_get(x_22, 1); lean_inc(x_129); lean_inc(x_128); lean_dec(x_22); lean_inc(x_2); x_130 = l_Lean_HashMapImp_find_x3f___at_Lean_ForEachExpr_visit___spec__1(x_128, x_2); if (lean_obj_tag(x_130) == 0) { lean_object* x_131; lean_inc(x_1); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_2); x_131 = lean_apply_7(x_1, x_2, x_4, x_5, x_6, x_7, x_8, x_129); if (lean_obj_tag(x_131) == 0) { lean_object* x_132; uint8_t x_133; x_132 = lean_ctor_get(x_131, 0); lean_inc(x_132); x_133 = lean_unbox(x_132); lean_dec(x_132); if (x_133 == 0) { lean_object* x_134; lean_object* x_135; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_134 = lean_ctor_get(x_131, 1); lean_inc(x_134); lean_dec(x_131); x_135 = lean_box(0); x_10 = x_135; x_11 = x_134; goto block_21; } else { switch (lean_obj_tag(x_2)) { case 5: { lean_object* x_136; lean_object* x_137; lean_object* x_138; lean_object* x_139; x_136 = lean_ctor_get(x_131, 1); lean_inc(x_136); lean_dec(x_131); x_137 = lean_ctor_get(x_2, 0); lean_inc(x_137); x_138 = lean_ctor_get(x_2, 1); lean_inc(x_138); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_139 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_137, x_3, x_4, x_5, x_6, x_7, x_8, x_136); if (lean_obj_tag(x_139) == 0) { lean_object* x_140; lean_object* x_141; x_140 = lean_ctor_get(x_139, 1); lean_inc(x_140); lean_dec(x_139); x_141 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_138, x_3, x_4, x_5, x_6, x_7, x_8, x_140); if (lean_obj_tag(x_141) == 0) { lean_object* x_142; lean_object* x_143; x_142 = lean_ctor_get(x_141, 0); lean_inc(x_142); x_143 = lean_ctor_get(x_141, 1); lean_inc(x_143); lean_dec(x_141); x_10 = x_142; x_11 = x_143; goto block_21; } else { lean_object* x_144; lean_object* x_145; lean_object* x_146; lean_object* x_147; lean_dec(x_2); x_144 = lean_ctor_get(x_141, 0); lean_inc(x_144); x_145 = lean_ctor_get(x_141, 1); lean_inc(x_145); if (lean_is_exclusive(x_141)) { lean_ctor_release(x_141, 0); lean_ctor_release(x_141, 1); x_146 = x_141; } else { lean_dec_ref(x_141); x_146 = lean_box(0); } if (lean_is_scalar(x_146)) { x_147 = lean_alloc_ctor(1, 2, 0); } else { x_147 = x_146; } lean_ctor_set(x_147, 0, x_144); lean_ctor_set(x_147, 1, x_145); return x_147; } } else { lean_object* x_148; lean_object* x_149; lean_object* x_150; lean_object* x_151; lean_dec(x_138); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_148 = lean_ctor_get(x_139, 0); lean_inc(x_148); x_149 = lean_ctor_get(x_139, 1); lean_inc(x_149); if (lean_is_exclusive(x_139)) { lean_ctor_release(x_139, 0); lean_ctor_release(x_139, 1); x_150 = x_139; } else { lean_dec_ref(x_139); x_150 = lean_box(0); } if (lean_is_scalar(x_150)) { x_151 = lean_alloc_ctor(1, 2, 0); } else { x_151 = x_150; } lean_ctor_set(x_151, 0, x_148); lean_ctor_set(x_151, 1, x_149); return x_151; } } case 6: { lean_object* x_152; lean_object* x_153; lean_object* x_154; lean_object* x_155; x_152 = lean_ctor_get(x_131, 1); lean_inc(x_152); lean_dec(x_131); x_153 = lean_ctor_get(x_2, 1); lean_inc(x_153); x_154 = lean_ctor_get(x_2, 2); lean_inc(x_154); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_155 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_153, x_3, x_4, x_5, x_6, x_7, x_8, x_152); if (lean_obj_tag(x_155) == 0) { lean_object* x_156; lean_object* x_157; x_156 = lean_ctor_get(x_155, 1); lean_inc(x_156); lean_dec(x_155); x_157 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_154, x_3, x_4, x_5, x_6, x_7, x_8, x_156); if (lean_obj_tag(x_157) == 0) { lean_object* x_158; lean_object* x_159; x_158 = lean_ctor_get(x_157, 0); lean_inc(x_158); x_159 = lean_ctor_get(x_157, 1); lean_inc(x_159); lean_dec(x_157); x_10 = x_158; x_11 = x_159; goto block_21; } else { lean_object* x_160; lean_object* x_161; lean_object* x_162; lean_object* x_163; lean_dec(x_2); x_160 = lean_ctor_get(x_157, 0); lean_inc(x_160); x_161 = lean_ctor_get(x_157, 1); lean_inc(x_161); if (lean_is_exclusive(x_157)) { lean_ctor_release(x_157, 0); lean_ctor_release(x_157, 1); x_162 = x_157; } else { lean_dec_ref(x_157); x_162 = lean_box(0); } if (lean_is_scalar(x_162)) { x_163 = lean_alloc_ctor(1, 2, 0); } else { x_163 = x_162; } lean_ctor_set(x_163, 0, x_160); lean_ctor_set(x_163, 1, x_161); return x_163; } } else { lean_object* x_164; lean_object* x_165; lean_object* x_166; lean_object* x_167; lean_dec(x_154); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_164 = lean_ctor_get(x_155, 0); lean_inc(x_164); x_165 = lean_ctor_get(x_155, 1); lean_inc(x_165); if (lean_is_exclusive(x_155)) { lean_ctor_release(x_155, 0); lean_ctor_release(x_155, 1); x_166 = x_155; } else { lean_dec_ref(x_155); x_166 = lean_box(0); } if (lean_is_scalar(x_166)) { x_167 = lean_alloc_ctor(1, 2, 0); } else { x_167 = x_166; } lean_ctor_set(x_167, 0, x_164); lean_ctor_set(x_167, 1, x_165); return x_167; } } case 7: { lean_object* x_168; lean_object* x_169; lean_object* x_170; lean_object* x_171; x_168 = lean_ctor_get(x_131, 1); lean_inc(x_168); lean_dec(x_131); x_169 = lean_ctor_get(x_2, 1); lean_inc(x_169); x_170 = lean_ctor_get(x_2, 2); lean_inc(x_170); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_171 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_169, x_3, x_4, x_5, x_6, x_7, x_8, x_168); if (lean_obj_tag(x_171) == 0) { lean_object* x_172; lean_object* x_173; x_172 = lean_ctor_get(x_171, 1); lean_inc(x_172); lean_dec(x_171); x_173 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_170, x_3, x_4, x_5, x_6, x_7, x_8, x_172); if (lean_obj_tag(x_173) == 0) { lean_object* x_174; lean_object* x_175; x_174 = lean_ctor_get(x_173, 0); lean_inc(x_174); x_175 = lean_ctor_get(x_173, 1); lean_inc(x_175); lean_dec(x_173); x_10 = x_174; x_11 = x_175; goto block_21; } else { lean_object* x_176; lean_object* x_177; lean_object* x_178; lean_object* x_179; lean_dec(x_2); x_176 = lean_ctor_get(x_173, 0); lean_inc(x_176); x_177 = lean_ctor_get(x_173, 1); lean_inc(x_177); if (lean_is_exclusive(x_173)) { lean_ctor_release(x_173, 0); lean_ctor_release(x_173, 1); x_178 = x_173; } else { lean_dec_ref(x_173); x_178 = lean_box(0); } if (lean_is_scalar(x_178)) { x_179 = lean_alloc_ctor(1, 2, 0); } else { x_179 = x_178; } lean_ctor_set(x_179, 0, x_176); lean_ctor_set(x_179, 1, x_177); return x_179; } } else { lean_object* x_180; lean_object* x_181; lean_object* x_182; lean_object* x_183; lean_dec(x_170); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_180 = lean_ctor_get(x_171, 0); lean_inc(x_180); x_181 = lean_ctor_get(x_171, 1); lean_inc(x_181); if (lean_is_exclusive(x_171)) { lean_ctor_release(x_171, 0); lean_ctor_release(x_171, 1); x_182 = x_171; } else { lean_dec_ref(x_171); x_182 = lean_box(0); } if (lean_is_scalar(x_182)) { x_183 = lean_alloc_ctor(1, 2, 0); } else { x_183 = x_182; } lean_ctor_set(x_183, 0, x_180); lean_ctor_set(x_183, 1, x_181); return x_183; } } case 8: { lean_object* x_184; lean_object* x_185; lean_object* x_186; lean_object* x_187; lean_object* x_188; x_184 = lean_ctor_get(x_131, 1); lean_inc(x_184); lean_dec(x_131); x_185 = lean_ctor_get(x_2, 1); lean_inc(x_185); x_186 = lean_ctor_get(x_2, 2); lean_inc(x_186); x_187 = lean_ctor_get(x_2, 3); lean_inc(x_187); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_188 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_185, x_3, x_4, x_5, x_6, x_7, x_8, x_184); if (lean_obj_tag(x_188) == 0) { lean_object* x_189; lean_object* x_190; x_189 = lean_ctor_get(x_188, 1); lean_inc(x_189); lean_dec(x_188); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_1); x_190 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_186, x_3, x_4, x_5, x_6, x_7, x_8, x_189); if (lean_obj_tag(x_190) == 0) { lean_object* x_191; lean_object* x_192; x_191 = lean_ctor_get(x_190, 1); lean_inc(x_191); lean_dec(x_190); x_192 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_187, x_3, x_4, x_5, x_6, x_7, x_8, x_191); if (lean_obj_tag(x_192) == 0) { lean_object* x_193; lean_object* x_194; x_193 = lean_ctor_get(x_192, 0); lean_inc(x_193); x_194 = lean_ctor_get(x_192, 1); lean_inc(x_194); lean_dec(x_192); x_10 = x_193; x_11 = x_194; goto block_21; } else { lean_object* x_195; lean_object* x_196; lean_object* x_197; lean_object* x_198; lean_dec(x_2); x_195 = lean_ctor_get(x_192, 0); lean_inc(x_195); x_196 = lean_ctor_get(x_192, 1); lean_inc(x_196); if (lean_is_exclusive(x_192)) { lean_ctor_release(x_192, 0); lean_ctor_release(x_192, 1); x_197 = x_192; } else { lean_dec_ref(x_192); x_197 = lean_box(0); } if (lean_is_scalar(x_197)) { x_198 = lean_alloc_ctor(1, 2, 0); } else { x_198 = x_197; } lean_ctor_set(x_198, 0, x_195); lean_ctor_set(x_198, 1, x_196); return x_198; } } else { lean_object* x_199; lean_object* x_200; lean_object* x_201; lean_object* x_202; lean_dec(x_187); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_199 = lean_ctor_get(x_190, 0); lean_inc(x_199); x_200 = lean_ctor_get(x_190, 1); lean_inc(x_200); if (lean_is_exclusive(x_190)) { lean_ctor_release(x_190, 0); lean_ctor_release(x_190, 1); x_201 = x_190; } else { lean_dec_ref(x_190); x_201 = lean_box(0); } if (lean_is_scalar(x_201)) { x_202 = lean_alloc_ctor(1, 2, 0); } else { x_202 = x_201; } lean_ctor_set(x_202, 0, x_199); lean_ctor_set(x_202, 1, x_200); return x_202; } } else { lean_object* x_203; lean_object* x_204; lean_object* x_205; lean_object* x_206; lean_dec(x_187); lean_dec(x_186); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_203 = lean_ctor_get(x_188, 0); lean_inc(x_203); x_204 = lean_ctor_get(x_188, 1); lean_inc(x_204); if (lean_is_exclusive(x_188)) { lean_ctor_release(x_188, 0); lean_ctor_release(x_188, 1); x_205 = x_188; } else { lean_dec_ref(x_188); x_205 = lean_box(0); } if (lean_is_scalar(x_205)) { x_206 = lean_alloc_ctor(1, 2, 0); } else { x_206 = x_205; } lean_ctor_set(x_206, 0, x_203); lean_ctor_set(x_206, 1, x_204); return x_206; } } case 10: { lean_object* x_207; lean_object* x_208; lean_object* x_209; x_207 = lean_ctor_get(x_131, 1); lean_inc(x_207); lean_dec(x_131); x_208 = lean_ctor_get(x_2, 1); lean_inc(x_208); x_209 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_208, x_3, x_4, x_5, x_6, x_7, x_8, x_207); if (lean_obj_tag(x_209) == 0) { lean_object* x_210; lean_object* x_211; x_210 = lean_ctor_get(x_209, 0); lean_inc(x_210); x_211 = lean_ctor_get(x_209, 1); lean_inc(x_211); lean_dec(x_209); x_10 = x_210; x_11 = x_211; goto block_21; } else { lean_object* x_212; lean_object* x_213; lean_object* x_214; lean_object* x_215; lean_dec(x_2); x_212 = lean_ctor_get(x_209, 0); lean_inc(x_212); x_213 = lean_ctor_get(x_209, 1); lean_inc(x_213); if (lean_is_exclusive(x_209)) { lean_ctor_release(x_209, 0); lean_ctor_release(x_209, 1); x_214 = x_209; } else { lean_dec_ref(x_209); x_214 = lean_box(0); } if (lean_is_scalar(x_214)) { x_215 = lean_alloc_ctor(1, 2, 0); } else { x_215 = x_214; } lean_ctor_set(x_215, 0, x_212); lean_ctor_set(x_215, 1, x_213); return x_215; } } case 11: { lean_object* x_216; lean_object* x_217; lean_object* x_218; x_216 = lean_ctor_get(x_131, 1); lean_inc(x_216); lean_dec(x_131); x_217 = lean_ctor_get(x_2, 2); lean_inc(x_217); x_218 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_217, x_3, x_4, x_5, x_6, x_7, x_8, x_216); if (lean_obj_tag(x_218) == 0) { lean_object* x_219; lean_object* x_220; x_219 = lean_ctor_get(x_218, 0); lean_inc(x_219); x_220 = lean_ctor_get(x_218, 1); lean_inc(x_220); lean_dec(x_218); x_10 = x_219; x_11 = x_220; goto block_21; } else { lean_object* x_221; lean_object* x_222; lean_object* x_223; lean_object* x_224; lean_dec(x_2); x_221 = lean_ctor_get(x_218, 0); lean_inc(x_221); x_222 = lean_ctor_get(x_218, 1); lean_inc(x_222); if (lean_is_exclusive(x_218)) { lean_ctor_release(x_218, 0); lean_ctor_release(x_218, 1); x_223 = x_218; } else { lean_dec_ref(x_218); x_223 = lean_box(0); } if (lean_is_scalar(x_223)) { x_224 = lean_alloc_ctor(1, 2, 0); } else { x_224 = x_223; } lean_ctor_set(x_224, 0, x_221); lean_ctor_set(x_224, 1, x_222); return x_224; } } default: { lean_object* x_225; lean_object* x_226; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_225 = lean_ctor_get(x_131, 1); lean_inc(x_225); lean_dec(x_131); x_226 = lean_box(0); x_10 = x_226; x_11 = x_225; goto block_21; } } } } else { lean_object* x_227; lean_object* x_228; lean_object* x_229; lean_object* x_230; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_227 = lean_ctor_get(x_131, 0); lean_inc(x_227); x_228 = lean_ctor_get(x_131, 1); lean_inc(x_228); if (lean_is_exclusive(x_131)) { lean_ctor_release(x_131, 0); lean_ctor_release(x_131, 1); x_229 = x_131; } else { lean_dec_ref(x_131); x_229 = lean_box(0); } if (lean_is_scalar(x_229)) { x_230 = lean_alloc_ctor(1, 2, 0); } else { x_230 = x_229; } lean_ctor_set(x_230, 0, x_227); lean_ctor_set(x_230, 1, x_228); return x_230; } } else { lean_object* x_231; lean_object* x_232; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_231 = lean_ctor_get(x_130, 0); lean_inc(x_231); lean_dec(x_130); x_232 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_232, 0, x_231); lean_ctor_set(x_232, 1, x_129); return x_232; } } block_21: { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; uint8_t x_17; x_12 = lean_st_ref_take(x_3, x_11); x_13 = lean_ctor_get(x_12, 0); lean_inc(x_13); x_14 = lean_ctor_get(x_12, 1); lean_inc(x_14); lean_dec(x_12); lean_inc(x_10); x_15 = l_Lean_HashMap_insert___at_Lean_ForEachExpr_visit___spec__3(x_13, x_2, x_10); x_16 = lean_st_ref_set(x_3, x_15, x_14); x_17 = !lean_is_exclusive(x_16); if (x_17 == 0) { lean_object* x_18; x_18 = lean_ctor_get(x_16, 0); lean_dec(x_18); lean_ctor_set(x_16, 0, x_10); return x_16; } else { lean_object* x_19; lean_object* x_20; x_19 = lean_ctor_get(x_16, 1); lean_inc(x_19); lean_dec(x_16); x_20 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_20, 0, x_10); lean_ctor_set(x_20, 1, x_19); return x_20; } } } } LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { uint8_t x_8; x_8 = l_Lean_Expr_isFVar(x_1); if (x_8 == 0) { uint8_t x_9; lean_object* x_10; lean_object* x_11; lean_dec(x_3); x_9 = l_Lean_Expr_hasFVar(x_1); lean_dec(x_1); x_10 = lean_box(x_9); x_11 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_11, 0, x_10); lean_ctor_set(x_11, 1, x_7); return x_11; } else { lean_object* x_12; lean_object* x_13; x_12 = l_Lean_Expr_fvarId_x21(x_1); x_13 = l_Lean_FVarId_getDecl(x_12, x_3, x_4, x_5, x_6, x_7); if (lean_obj_tag(x_13) == 0) { lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; uint8_t x_21; x_14 = lean_ctor_get(x_13, 0); lean_inc(x_14); x_15 = lean_ctor_get(x_13, 1); lean_inc(x_15); lean_dec(x_13); x_16 = lean_st_ref_take(x_2, x_15); x_17 = lean_ctor_get(x_16, 0); lean_inc(x_17); x_18 = lean_ctor_get(x_16, 1); lean_inc(x_18); lean_dec(x_16); x_19 = l_Lean_LocalDecl_index(x_17); x_20 = l_Lean_LocalDecl_index(x_14); x_21 = lean_nat_dec_lt(x_19, x_20); lean_dec(x_20); lean_dec(x_19); if (x_21 == 0) { lean_object* x_22; uint8_t x_23; lean_dec(x_14); x_22 = lean_st_ref_set(x_2, x_17, x_18); x_23 = !lean_is_exclusive(x_22); if (x_23 == 0) { lean_object* x_24; uint8_t x_25; lean_object* x_26; x_24 = lean_ctor_get(x_22, 0); lean_dec(x_24); x_25 = 0; x_26 = lean_box(x_25); lean_ctor_set(x_22, 0, x_26); return x_22; } else { lean_object* x_27; uint8_t x_28; lean_object* x_29; lean_object* x_30; x_27 = lean_ctor_get(x_22, 1); lean_inc(x_27); lean_dec(x_22); x_28 = 0; x_29 = lean_box(x_28); x_30 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_30, 0, x_29); lean_ctor_set(x_30, 1, x_27); return x_30; } } else { lean_object* x_31; uint8_t x_32; lean_dec(x_17); x_31 = lean_st_ref_set(x_2, x_14, x_18); x_32 = !lean_is_exclusive(x_31); if (x_32 == 0) { lean_object* x_33; uint8_t x_34; lean_object* x_35; x_33 = lean_ctor_get(x_31, 0); lean_dec(x_33); x_34 = 0; x_35 = lean_box(x_34); lean_ctor_set(x_31, 0, x_35); return x_31; } else { lean_object* x_36; uint8_t x_37; lean_object* x_38; lean_object* x_39; x_36 = lean_ctor_get(x_31, 1); lean_inc(x_36); lean_dec(x_31); x_37 = 0; x_38 = lean_box(x_37); x_39 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_39, 0, x_38); lean_ctor_set(x_39, 1, x_36); return x_39; } } } else { uint8_t x_40; x_40 = !lean_is_exclusive(x_13); if (x_40 == 0) { return x_13; } else { lean_object* x_41; lean_object* x_42; lean_object* x_43; x_41 = lean_ctor_get(x_13, 0); x_42 = lean_ctor_get(x_13, 1); lean_inc(x_42); lean_inc(x_41); lean_dec(x_13); x_43 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_43, 0, x_41); lean_ctor_set(x_43, 1, x_42); return x_43; } } } } } static lean_object* _init_l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__1() { _start: { lean_object* x_1; lean_object* x_2; x_1 = lean_unsigned_to_nat(8u); x_2 = l_Lean_mkHashMapImp___rarg(x_1); return x_2; } } static lean_object* _init_l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__2() { _start: { lean_object* x_1; x_1 = lean_alloc_closure((void*)(l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___lambda__1___boxed), 7, 0); return x_1; } } LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; x_8 = l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__1; x_9 = lean_st_mk_ref(x_8, x_7); x_10 = lean_ctor_get(x_9, 0); lean_inc(x_10); x_11 = lean_ctor_get(x_9, 1); lean_inc(x_11); lean_dec(x_9); x_12 = l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__2; x_13 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_12, x_1, x_10, x_2, x_3, x_4, x_5, x_6, x_11); if (lean_obj_tag(x_13) == 0) { lean_object* x_14; lean_object* x_15; lean_object* x_16; uint8_t x_17; x_14 = lean_ctor_get(x_13, 0); lean_inc(x_14); x_15 = lean_ctor_get(x_13, 1); lean_inc(x_15); lean_dec(x_13); x_16 = lean_st_ref_get(x_10, x_15); lean_dec(x_10); x_17 = !lean_is_exclusive(x_16); if (x_17 == 0) { lean_object* x_18; x_18 = lean_ctor_get(x_16, 0); lean_dec(x_18); lean_ctor_set(x_16, 0, x_14); return x_16; } else { lean_object* x_19; lean_object* x_20; x_19 = lean_ctor_get(x_16, 1); lean_inc(x_19); lean_dec(x_16); x_20 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_20, 0, x_14); lean_ctor_set(x_20, 1, x_19); return x_20; } } else { uint8_t x_21; lean_dec(x_10); x_21 = !lean_is_exclusive(x_13); if (x_21 == 0) { return x_13; } else { lean_object* x_22; lean_object* x_23; lean_object* x_24; x_22 = lean_ctor_get(x_13, 0); x_23 = lean_ctor_get(x_13, 1); lean_inc(x_23); lean_inc(x_22); lean_dec(x_13); x_24 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_24, 0, x_22); lean_ctor_set(x_24, 1, x_23); return x_24; } } } } LEAN_EXPORT lean_object* l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; x_10 = l_Lean_ForEachExpr_visit___at___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___spec__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9); lean_dec(x_3); return x_10; } } LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); return x_8; } } LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; lean_inc(x_5); lean_inc(x_1); x_10 = l_Lean_FVarId_getDecl(x_1, x_5, x_6, x_7, x_8, x_9); if (lean_obj_tag(x_10) == 0) { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; x_11 = lean_ctor_get(x_10, 0); lean_inc(x_11); x_12 = lean_ctor_get(x_10, 1); lean_inc(x_12); lean_dec(x_10); lean_inc(x_1); x_13 = l_Lean_Expr_fvar___override(x_1); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_14 = l_Lean_Meta_mkEqMP(x_2, x_13, x_5, x_6, x_7, x_8, x_12); if (lean_obj_tag(x_14) == 0) { lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; x_15 = lean_ctor_get(x_14, 0); lean_inc(x_15); x_16 = lean_ctor_get(x_14, 1); lean_inc(x_16); lean_dec(x_14); lean_inc(x_11); x_17 = lean_st_mk_ref(x_11, x_16); x_18 = lean_ctor_get(x_17, 0); lean_inc(x_18); x_19 = lean_ctor_get(x_17, 1); lean_inc(x_19); lean_dec(x_17); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_18); lean_inc(x_3); x_20 = l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar(x_3, x_18, x_5, x_6, x_7, x_8, x_19); if (lean_obj_tag(x_20) == 0) { lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; x_21 = lean_ctor_get(x_20, 1); lean_inc(x_21); lean_dec(x_20); x_22 = lean_st_ref_get(x_18, x_21); lean_dec(x_18); x_23 = lean_ctor_get(x_22, 0); lean_inc(x_23); x_24 = lean_ctor_get(x_22, 1); lean_inc(x_24); lean_dec(x_22); x_25 = l_Lean_LocalDecl_fvarId(x_23); lean_dec(x_23); x_26 = l_Lean_LocalDecl_userName(x_11); lean_dec(x_11); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_27 = l_Lean_MVarId_assertAfter(x_4, x_25, x_26, x_3, x_15, x_5, x_6, x_7, x_8, x_24); if (lean_obj_tag(x_27) == 0) { lean_object* x_28; lean_object* x_29; lean_object* x_30; lean_object* x_31; lean_object* x_32; lean_object* x_33; lean_object* x_34; lean_object* x_35; lean_object* x_36; x_28 = lean_ctor_get(x_27, 0); lean_inc(x_28); x_29 = lean_ctor_get(x_27, 1); lean_inc(x_29); lean_dec(x_27); x_30 = lean_ctor_get(x_28, 0); lean_inc(x_30); x_31 = lean_ctor_get(x_28, 1); lean_inc(x_31); x_32 = lean_ctor_get(x_28, 2); lean_inc(x_32); x_33 = l_Lean_Meta_saveState___rarg(x_6, x_7, x_8, x_29); x_34 = lean_ctor_get(x_33, 0); lean_inc(x_34); x_35 = lean_ctor_get(x_33, 1); lean_inc(x_35); lean_dec(x_33); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_36 = l_Lean_MVarId_clear(x_31, x_1, x_5, x_6, x_7, x_8, x_35); if (lean_obj_tag(x_36) == 0) { uint8_t x_37; lean_dec(x_34); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); x_37 = !lean_is_exclusive(x_28); if (x_37 == 0) { lean_object* x_38; lean_object* x_39; lean_object* x_40; uint8_t x_41; x_38 = lean_ctor_get(x_28, 2); lean_dec(x_38); x_39 = lean_ctor_get(x_28, 1); lean_dec(x_39); x_40 = lean_ctor_get(x_28, 0); lean_dec(x_40); x_41 = !lean_is_exclusive(x_36); if (x_41 == 0) { lean_object* x_42; x_42 = lean_ctor_get(x_36, 0); lean_ctor_set(x_28, 1, x_42); lean_ctor_set(x_36, 0, x_28); return x_36; } else { lean_object* x_43; lean_object* x_44; lean_object* x_45; x_43 = lean_ctor_get(x_36, 0); x_44 = lean_ctor_get(x_36, 1); lean_inc(x_44); lean_inc(x_43); lean_dec(x_36); lean_ctor_set(x_28, 1, x_43); x_45 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_45, 0, x_28); lean_ctor_set(x_45, 1, x_44); return x_45; } } else { lean_object* x_46; lean_object* x_47; lean_object* x_48; lean_object* x_49; lean_object* x_50; lean_dec(x_28); x_46 = lean_ctor_get(x_36, 0); lean_inc(x_46); x_47 = lean_ctor_get(x_36, 1); lean_inc(x_47); if (lean_is_exclusive(x_36)) { lean_ctor_release(x_36, 0); lean_ctor_release(x_36, 1); x_48 = x_36; } else { lean_dec_ref(x_36); x_48 = lean_box(0); } x_49 = lean_alloc_ctor(0, 3, 0); lean_ctor_set(x_49, 0, x_30); lean_ctor_set(x_49, 1, x_46); lean_ctor_set(x_49, 2, x_32); if (lean_is_scalar(x_48)) { x_50 = lean_alloc_ctor(0, 2, 0); } else { x_50 = x_48; } lean_ctor_set(x_50, 0, x_49); lean_ctor_set(x_50, 1, x_47); return x_50; } } else { lean_object* x_51; lean_object* x_52; uint8_t x_53; lean_dec(x_32); lean_dec(x_30); x_51 = lean_ctor_get(x_36, 1); lean_inc(x_51); lean_dec(x_36); x_52 = l_Lean_Meta_SavedState_restore(x_34, x_5, x_6, x_7, x_8, x_51); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_34); x_53 = !lean_is_exclusive(x_52); if (x_53 == 0) { lean_object* x_54; x_54 = lean_ctor_get(x_52, 0); lean_dec(x_54); lean_ctor_set(x_52, 0, x_28); return x_52; } else { lean_object* x_55; lean_object* x_56; x_55 = lean_ctor_get(x_52, 1); lean_inc(x_55); lean_dec(x_52); x_56 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_56, 0, x_28); lean_ctor_set(x_56, 1, x_55); return x_56; } } } else { uint8_t x_57; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_1); x_57 = !lean_is_exclusive(x_27); if (x_57 == 0) { return x_27; } else { lean_object* x_58; lean_object* x_59; lean_object* x_60; x_58 = lean_ctor_get(x_27, 0); x_59 = lean_ctor_get(x_27, 1); lean_inc(x_59); lean_inc(x_58); lean_dec(x_27); x_60 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_60, 0, x_58); lean_ctor_set(x_60, 1, x_59); return x_60; } } } else { uint8_t x_61; lean_dec(x_18); lean_dec(x_15); lean_dec(x_11); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_61 = !lean_is_exclusive(x_20); if (x_61 == 0) { return x_20; } else { lean_object* x_62; lean_object* x_63; lean_object* x_64; x_62 = lean_ctor_get(x_20, 0); x_63 = lean_ctor_get(x_20, 1); lean_inc(x_63); lean_inc(x_62); lean_dec(x_20); x_64 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_64, 0, x_62); lean_ctor_set(x_64, 1, x_63); return x_64; } } } else { uint8_t x_65; lean_dec(x_11); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_65 = !lean_is_exclusive(x_14); if (x_65 == 0) { return x_14; } else { lean_object* x_66; lean_object* x_67; lean_object* x_68; x_66 = lean_ctor_get(x_14, 0); x_67 = lean_ctor_get(x_14, 1); lean_inc(x_67); lean_inc(x_66); lean_dec(x_14); x_68 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_68, 0, x_66); lean_ctor_set(x_68, 1, x_67); return x_68; } } } else { uint8_t x_69; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_69 = !lean_is_exclusive(x_10); if (x_69 == 0) { return x_10; } else { lean_object* x_70; lean_object* x_71; lean_object* x_72; x_70 = lean_ctor_get(x_10, 0); x_71 = lean_ctor_get(x_10, 1); lean_inc(x_71); lean_inc(x_70); lean_dec(x_10); x_72 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_72, 0, x_70); lean_ctor_set(x_72, 1, x_71); return x_72; } } } } LEAN_EXPORT lean_object* l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; lean_object* x_11; lean_inc(x_1); x_10 = lean_alloc_closure((void*)(l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore___lambda__1), 9, 4); lean_closure_set(x_10, 0, x_2); lean_closure_set(x_10, 1, x_4); lean_closure_set(x_10, 2, x_3); lean_closure_set(x_10, 3, x_1); x_11 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_10, x_5, x_6, x_7, x_8, x_9); return x_11; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDecl(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; x_10 = l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Lean_Meta_replaceLocalDecl(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; x_10 = l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDeclDefEq___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_inc(x_4); lean_inc(x_1); x_9 = l_Lean_FVarId_getType(x_1, x_4, x_5, x_6, x_7, x_8); if (lean_obj_tag(x_9) == 0) { uint8_t x_10; x_10 = !lean_is_exclusive(x_9); if (x_10 == 0) { lean_object* x_11; lean_object* x_12; uint8_t x_13; x_11 = lean_ctor_get(x_9, 0); x_12 = lean_ctor_get(x_9, 1); x_13 = lean_expr_eqv(x_2, x_11); lean_dec(x_11); if (x_13 == 0) { lean_object* x_14; lean_free_object(x_9); lean_inc(x_3); x_14 = l_Lean_MVarId_getDecl(x_3, x_4, x_5, x_6, x_7, x_12); if (lean_obj_tag(x_14) == 0) { lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; x_15 = lean_ctor_get(x_14, 0); lean_inc(x_15); x_16 = lean_ctor_get(x_14, 1); lean_inc(x_16); lean_dec(x_14); x_17 = lean_ctor_get(x_4, 1); lean_inc(x_17); x_18 = l_Lean_Meta_getLocalInstances(x_4, x_5, x_6, x_7, x_16); x_19 = lean_ctor_get(x_17, 0); lean_inc(x_19); x_20 = lean_ctor_get(x_17, 1); lean_inc(x_20); lean_inc(x_17); x_21 = lean_local_ctx_find(x_17, x_1); if (lean_obj_tag(x_21) == 0) { lean_object* x_22; lean_object* x_23; lean_object* x_24; uint8_t x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; lean_object* x_29; lean_object* x_30; lean_object* x_31; uint8_t x_32; lean_dec(x_20); lean_dec(x_19); lean_dec(x_2); x_22 = lean_ctor_get(x_18, 0); lean_inc(x_22); x_23 = lean_ctor_get(x_18, 1); lean_inc(x_23); lean_dec(x_18); x_24 = lean_ctor_get(x_15, 2); lean_inc(x_24); x_25 = lean_ctor_get_uint8(x_15, sizeof(void*)*7); x_26 = lean_ctor_get(x_15, 0); lean_inc(x_26); lean_dec(x_15); x_27 = lean_unsigned_to_nat(0u); x_28 = l_Lean_Meta_mkFreshExprMVarAt(x_17, x_22, x_24, x_25, x_26, x_27, x_4, x_5, x_6, x_7, x_23); x_29 = lean_ctor_get(x_28, 0); lean_inc(x_29); x_30 = lean_ctor_get(x_28, 1); lean_inc(x_30); lean_dec(x_28); lean_inc(x_29); x_31 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_3, x_29, x_4, x_5, x_6, x_7, x_30); lean_dec(x_4); x_32 = !lean_is_exclusive(x_31); if (x_32 == 0) { lean_object* x_33; lean_object* x_34; x_33 = lean_ctor_get(x_31, 0); lean_dec(x_33); x_34 = l_Lean_Expr_mvarId_x21(x_29); lean_ctor_set(x_31, 0, x_34); return x_31; } else { lean_object* x_35; lean_object* x_36; lean_object* x_37; x_35 = lean_ctor_get(x_31, 1); lean_inc(x_35); lean_dec(x_31); x_36 = l_Lean_Expr_mvarId_x21(x_29); x_37 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_37, 0, x_36); lean_ctor_set(x_37, 1, x_35); return x_37; } } else { uint8_t x_38; x_38 = !lean_is_exclusive(x_17); if (x_38 == 0) { lean_object* x_39; lean_object* x_40; uint8_t x_41; x_39 = lean_ctor_get(x_17, 1); lean_dec(x_39); x_40 = lean_ctor_get(x_17, 0); lean_dec(x_40); x_41 = !lean_is_exclusive(x_21); if (x_41 == 0) { lean_object* x_42; lean_object* x_43; lean_object* x_44; lean_object* x_45; lean_object* x_46; lean_object* x_47; lean_object* x_48; lean_object* x_49; lean_object* x_50; uint8_t x_51; lean_object* x_52; lean_object* x_53; lean_object* x_54; lean_object* x_55; lean_object* x_56; lean_object* x_57; uint8_t x_58; x_42 = lean_ctor_get(x_21, 0); x_43 = lean_ctor_get(x_18, 0); lean_inc(x_43); x_44 = lean_ctor_get(x_18, 1); lean_inc(x_44); lean_dec(x_18); x_45 = l_Lean_LocalDecl_setType(x_42, x_2); x_46 = l_Lean_LocalDecl_fvarId(x_45); lean_inc(x_45); x_47 = l_Lean_PersistentHashMap_insert___at_Lean_LocalContext_mkLocalDecl___spec__1(x_19, x_46, x_45); x_48 = l_Lean_LocalDecl_index(x_45); lean_ctor_set(x_21, 0, x_45); x_49 = l_Lean_PersistentArray_set___rarg(x_20, x_48, x_21); lean_dec(x_48); lean_ctor_set(x_17, 1, x_49); lean_ctor_set(x_17, 0, x_47); x_50 = lean_ctor_get(x_15, 2); lean_inc(x_50); x_51 = lean_ctor_get_uint8(x_15, sizeof(void*)*7); x_52 = lean_ctor_get(x_15, 0); lean_inc(x_52); lean_dec(x_15); x_53 = lean_unsigned_to_nat(0u); x_54 = l_Lean_Meta_mkFreshExprMVarAt(x_17, x_43, x_50, x_51, x_52, x_53, x_4, x_5, x_6, x_7, x_44); x_55 = lean_ctor_get(x_54, 0); lean_inc(x_55); x_56 = lean_ctor_get(x_54, 1); lean_inc(x_56); lean_dec(x_54); lean_inc(x_55); x_57 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_3, x_55, x_4, x_5, x_6, x_7, x_56); lean_dec(x_4); x_58 = !lean_is_exclusive(x_57); if (x_58 == 0) { lean_object* x_59; lean_object* x_60; x_59 = lean_ctor_get(x_57, 0); lean_dec(x_59); x_60 = l_Lean_Expr_mvarId_x21(x_55); lean_ctor_set(x_57, 0, x_60); return x_57; } else { lean_object* x_61; lean_object* x_62; lean_object* x_63; x_61 = lean_ctor_get(x_57, 1); lean_inc(x_61); lean_dec(x_57); x_62 = l_Lean_Expr_mvarId_x21(x_55); x_63 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_63, 0, x_62); lean_ctor_set(x_63, 1, x_61); return x_63; } } else { lean_object* x_64; lean_object* x_65; lean_object* x_66; lean_object* x_67; lean_object* x_68; lean_object* x_69; lean_object* x_70; lean_object* x_71; lean_object* x_72; lean_object* x_73; uint8_t x_74; lean_object* x_75; lean_object* x_76; lean_object* x_77; lean_object* x_78; lean_object* x_79; lean_object* x_80; lean_object* x_81; lean_object* x_82; lean_object* x_83; lean_object* x_84; x_64 = lean_ctor_get(x_21, 0); lean_inc(x_64); lean_dec(x_21); x_65 = lean_ctor_get(x_18, 0); lean_inc(x_65); x_66 = lean_ctor_get(x_18, 1); lean_inc(x_66); lean_dec(x_18); x_67 = l_Lean_LocalDecl_setType(x_64, x_2); x_68 = l_Lean_LocalDecl_fvarId(x_67); lean_inc(x_67); x_69 = l_Lean_PersistentHashMap_insert___at_Lean_LocalContext_mkLocalDecl___spec__1(x_19, x_68, x_67); x_70 = l_Lean_LocalDecl_index(x_67); x_71 = lean_alloc_ctor(1, 1, 0); lean_ctor_set(x_71, 0, x_67); x_72 = l_Lean_PersistentArray_set___rarg(x_20, x_70, x_71); lean_dec(x_70); lean_ctor_set(x_17, 1, x_72); lean_ctor_set(x_17, 0, x_69); x_73 = lean_ctor_get(x_15, 2); lean_inc(x_73); x_74 = lean_ctor_get_uint8(x_15, sizeof(void*)*7); x_75 = lean_ctor_get(x_15, 0); lean_inc(x_75); lean_dec(x_15); x_76 = lean_unsigned_to_nat(0u); x_77 = l_Lean_Meta_mkFreshExprMVarAt(x_17, x_65, x_73, x_74, x_75, x_76, x_4, x_5, x_6, x_7, x_66); x_78 = lean_ctor_get(x_77, 0); lean_inc(x_78); x_79 = lean_ctor_get(x_77, 1); lean_inc(x_79); lean_dec(x_77); lean_inc(x_78); x_80 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_3, x_78, x_4, x_5, x_6, x_7, x_79); lean_dec(x_4); x_81 = lean_ctor_get(x_80, 1); lean_inc(x_81); if (lean_is_exclusive(x_80)) { lean_ctor_release(x_80, 0); lean_ctor_release(x_80, 1); x_82 = x_80; } else { lean_dec_ref(x_80); x_82 = lean_box(0); } x_83 = l_Lean_Expr_mvarId_x21(x_78); if (lean_is_scalar(x_82)) { x_84 = lean_alloc_ctor(0, 2, 0); } else { x_84 = x_82; } lean_ctor_set(x_84, 0, x_83); lean_ctor_set(x_84, 1, x_81); return x_84; } } else { lean_object* x_85; lean_object* x_86; lean_object* x_87; lean_object* x_88; lean_object* x_89; lean_object* x_90; lean_object* x_91; lean_object* x_92; lean_object* x_93; lean_object* x_94; lean_object* x_95; lean_object* x_96; uint8_t x_97; lean_object* x_98; lean_object* x_99; lean_object* x_100; lean_object* x_101; lean_object* x_102; lean_object* x_103; lean_object* x_104; lean_object* x_105; lean_object* x_106; lean_object* x_107; lean_dec(x_17); x_85 = lean_ctor_get(x_21, 0); lean_inc(x_85); if (lean_is_exclusive(x_21)) { lean_ctor_release(x_21, 0); x_86 = x_21; } else { lean_dec_ref(x_21); x_86 = lean_box(0); } x_87 = lean_ctor_get(x_18, 0); lean_inc(x_87); x_88 = lean_ctor_get(x_18, 1); lean_inc(x_88); lean_dec(x_18); x_89 = l_Lean_LocalDecl_setType(x_85, x_2); x_90 = l_Lean_LocalDecl_fvarId(x_89); lean_inc(x_89); x_91 = l_Lean_PersistentHashMap_insert___at_Lean_LocalContext_mkLocalDecl___spec__1(x_19, x_90, x_89); x_92 = l_Lean_LocalDecl_index(x_89); if (lean_is_scalar(x_86)) { x_93 = lean_alloc_ctor(1, 1, 0); } else { x_93 = x_86; } lean_ctor_set(x_93, 0, x_89); x_94 = l_Lean_PersistentArray_set___rarg(x_20, x_92, x_93); lean_dec(x_92); x_95 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_95, 0, x_91); lean_ctor_set(x_95, 1, x_94); x_96 = lean_ctor_get(x_15, 2); lean_inc(x_96); x_97 = lean_ctor_get_uint8(x_15, sizeof(void*)*7); x_98 = lean_ctor_get(x_15, 0); lean_inc(x_98); lean_dec(x_15); x_99 = lean_unsigned_to_nat(0u); x_100 = l_Lean_Meta_mkFreshExprMVarAt(x_95, x_87, x_96, x_97, x_98, x_99, x_4, x_5, x_6, x_7, x_88); x_101 = lean_ctor_get(x_100, 0); lean_inc(x_101); x_102 = lean_ctor_get(x_100, 1); lean_inc(x_102); lean_dec(x_100); lean_inc(x_101); x_103 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_3, x_101, x_4, x_5, x_6, x_7, x_102); lean_dec(x_4); x_104 = lean_ctor_get(x_103, 1); lean_inc(x_104); if (lean_is_exclusive(x_103)) { lean_ctor_release(x_103, 0); lean_ctor_release(x_103, 1); x_105 = x_103; } else { lean_dec_ref(x_103); x_105 = lean_box(0); } x_106 = l_Lean_Expr_mvarId_x21(x_101); if (lean_is_scalar(x_105)) { x_107 = lean_alloc_ctor(0, 2, 0); } else { x_107 = x_105; } lean_ctor_set(x_107, 0, x_106); lean_ctor_set(x_107, 1, x_104); return x_107; } } } else { uint8_t x_108; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_108 = !lean_is_exclusive(x_14); if (x_108 == 0) { return x_14; } else { lean_object* x_109; lean_object* x_110; lean_object* x_111; x_109 = lean_ctor_get(x_14, 0); x_110 = lean_ctor_get(x_14, 1); lean_inc(x_110); lean_inc(x_109); lean_dec(x_14); x_111 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_111, 0, x_109); lean_ctor_set(x_111, 1, x_110); return x_111; } } } else { lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); lean_ctor_set(x_9, 0, x_3); return x_9; } } else { lean_object* x_112; lean_object* x_113; uint8_t x_114; x_112 = lean_ctor_get(x_9, 0); x_113 = lean_ctor_get(x_9, 1); lean_inc(x_113); lean_inc(x_112); lean_dec(x_9); x_114 = lean_expr_eqv(x_2, x_112); lean_dec(x_112); if (x_114 == 0) { lean_object* x_115; lean_inc(x_3); x_115 = l_Lean_MVarId_getDecl(x_3, x_4, x_5, x_6, x_7, x_113); if (lean_obj_tag(x_115) == 0) { lean_object* x_116; lean_object* x_117; lean_object* x_118; lean_object* x_119; lean_object* x_120; lean_object* x_121; lean_object* x_122; x_116 = lean_ctor_get(x_115, 0); lean_inc(x_116); x_117 = lean_ctor_get(x_115, 1); lean_inc(x_117); lean_dec(x_115); x_118 = lean_ctor_get(x_4, 1); lean_inc(x_118); x_119 = l_Lean_Meta_getLocalInstances(x_4, x_5, x_6, x_7, x_117); x_120 = lean_ctor_get(x_118, 0); lean_inc(x_120); x_121 = lean_ctor_get(x_118, 1); lean_inc(x_121); lean_inc(x_118); x_122 = lean_local_ctx_find(x_118, x_1); if (lean_obj_tag(x_122) == 0) { lean_object* x_123; lean_object* x_124; lean_object* x_125; uint8_t x_126; lean_object* x_127; lean_object* x_128; lean_object* x_129; lean_object* x_130; lean_object* x_131; lean_object* x_132; lean_object* x_133; lean_object* x_134; lean_object* x_135; lean_object* x_136; lean_dec(x_121); lean_dec(x_120); lean_dec(x_2); x_123 = lean_ctor_get(x_119, 0); lean_inc(x_123); x_124 = lean_ctor_get(x_119, 1); lean_inc(x_124); lean_dec(x_119); x_125 = lean_ctor_get(x_116, 2); lean_inc(x_125); x_126 = lean_ctor_get_uint8(x_116, sizeof(void*)*7); x_127 = lean_ctor_get(x_116, 0); lean_inc(x_127); lean_dec(x_116); x_128 = lean_unsigned_to_nat(0u); x_129 = l_Lean_Meta_mkFreshExprMVarAt(x_118, x_123, x_125, x_126, x_127, x_128, x_4, x_5, x_6, x_7, x_124); x_130 = lean_ctor_get(x_129, 0); lean_inc(x_130); x_131 = lean_ctor_get(x_129, 1); lean_inc(x_131); lean_dec(x_129); lean_inc(x_130); x_132 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_3, x_130, x_4, x_5, x_6, x_7, x_131); lean_dec(x_4); x_133 = lean_ctor_get(x_132, 1); lean_inc(x_133); if (lean_is_exclusive(x_132)) { lean_ctor_release(x_132, 0); lean_ctor_release(x_132, 1); x_134 = x_132; } else { lean_dec_ref(x_132); x_134 = lean_box(0); } x_135 = l_Lean_Expr_mvarId_x21(x_130); if (lean_is_scalar(x_134)) { x_136 = lean_alloc_ctor(0, 2, 0); } else { x_136 = x_134; } lean_ctor_set(x_136, 0, x_135); lean_ctor_set(x_136, 1, x_133); return x_136; } else { lean_object* x_137; lean_object* x_138; lean_object* x_139; lean_object* x_140; lean_object* x_141; lean_object* x_142; lean_object* x_143; lean_object* x_144; lean_object* x_145; lean_object* x_146; lean_object* x_147; lean_object* x_148; lean_object* x_149; uint8_t x_150; lean_object* x_151; lean_object* x_152; lean_object* x_153; lean_object* x_154; lean_object* x_155; lean_object* x_156; lean_object* x_157; lean_object* x_158; lean_object* x_159; lean_object* x_160; if (lean_is_exclusive(x_118)) { lean_ctor_release(x_118, 0); lean_ctor_release(x_118, 1); x_137 = x_118; } else { lean_dec_ref(x_118); x_137 = lean_box(0); } x_138 = lean_ctor_get(x_122, 0); lean_inc(x_138); if (lean_is_exclusive(x_122)) { lean_ctor_release(x_122, 0); x_139 = x_122; } else { lean_dec_ref(x_122); x_139 = lean_box(0); } x_140 = lean_ctor_get(x_119, 0); lean_inc(x_140); x_141 = lean_ctor_get(x_119, 1); lean_inc(x_141); lean_dec(x_119); x_142 = l_Lean_LocalDecl_setType(x_138, x_2); x_143 = l_Lean_LocalDecl_fvarId(x_142); lean_inc(x_142); x_144 = l_Lean_PersistentHashMap_insert___at_Lean_LocalContext_mkLocalDecl___spec__1(x_120, x_143, x_142); x_145 = l_Lean_LocalDecl_index(x_142); if (lean_is_scalar(x_139)) { x_146 = lean_alloc_ctor(1, 1, 0); } else { x_146 = x_139; } lean_ctor_set(x_146, 0, x_142); x_147 = l_Lean_PersistentArray_set___rarg(x_121, x_145, x_146); lean_dec(x_145); if (lean_is_scalar(x_137)) { x_148 = lean_alloc_ctor(0, 2, 0); } else { x_148 = x_137; } lean_ctor_set(x_148, 0, x_144); lean_ctor_set(x_148, 1, x_147); x_149 = lean_ctor_get(x_116, 2); lean_inc(x_149); x_150 = lean_ctor_get_uint8(x_116, sizeof(void*)*7); x_151 = lean_ctor_get(x_116, 0); lean_inc(x_151); lean_dec(x_116); x_152 = lean_unsigned_to_nat(0u); x_153 = l_Lean_Meta_mkFreshExprMVarAt(x_148, x_140, x_149, x_150, x_151, x_152, x_4, x_5, x_6, x_7, x_141); x_154 = lean_ctor_get(x_153, 0); lean_inc(x_154); x_155 = lean_ctor_get(x_153, 1); lean_inc(x_155); lean_dec(x_153); lean_inc(x_154); x_156 = l_Lean_MVarId_assign___at_Lean_Meta_getLevel___spec__1(x_3, x_154, x_4, x_5, x_6, x_7, x_155); lean_dec(x_4); x_157 = lean_ctor_get(x_156, 1); lean_inc(x_157); if (lean_is_exclusive(x_156)) { lean_ctor_release(x_156, 0); lean_ctor_release(x_156, 1); x_158 = x_156; } else { lean_dec_ref(x_156); x_158 = lean_box(0); } x_159 = l_Lean_Expr_mvarId_x21(x_154); if (lean_is_scalar(x_158)) { x_160 = lean_alloc_ctor(0, 2, 0); } else { x_160 = x_158; } lean_ctor_set(x_160, 0, x_159); lean_ctor_set(x_160, 1, x_157); return x_160; } } else { lean_object* x_161; lean_object* x_162; lean_object* x_163; lean_object* x_164; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_161 = lean_ctor_get(x_115, 0); lean_inc(x_161); x_162 = lean_ctor_get(x_115, 1); lean_inc(x_162); if (lean_is_exclusive(x_115)) { lean_ctor_release(x_115, 0); lean_ctor_release(x_115, 1); x_163 = x_115; } else { lean_dec_ref(x_115); x_163 = lean_box(0); } if (lean_is_scalar(x_163)) { x_164 = lean_alloc_ctor(1, 2, 0); } else { x_164 = x_163; } lean_ctor_set(x_164, 0, x_161); lean_ctor_set(x_164, 1, x_162); return x_164; } } else { lean_object* x_165; lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_165 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_165, 0, x_3); lean_ctor_set(x_165, 1, x_113); return x_165; } } } else { uint8_t x_166; lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_166 = !lean_is_exclusive(x_9); if (x_166 == 0) { return x_9; } else { lean_object* x_167; lean_object* x_168; lean_object* x_169; x_167 = lean_ctor_get(x_9, 0); x_168 = lean_ctor_get(x_9, 1); lean_inc(x_168); lean_inc(x_167); lean_dec(x_9); x_169 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_169, 0, x_167); lean_ctor_set(x_169, 1, x_168); return x_169; } } } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDeclDefEq(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_object* x_10; lean_inc(x_1); x_9 = lean_alloc_closure((void*)(l_Lean_MVarId_replaceLocalDeclDefEq___lambda__1___boxed), 8, 3); lean_closure_set(x_9, 0, x_2); lean_closure_set(x_9, 1, x_3); lean_closure_set(x_9, 2, x_1); x_10 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_9, x_4, x_5, x_6, x_7, x_8); return x_10; } } LEAN_EXPORT lean_object* l_Lean_MVarId_replaceLocalDeclDefEq___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; x_9 = l_Lean_MVarId_replaceLocalDeclDefEq___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); return x_9; } } LEAN_EXPORT lean_object* l_Lean_Meta_replaceLocalDeclDefEq(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; x_9 = l_Lean_MVarId_replaceLocalDeclDefEq(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8); return x_9; } } LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; x_9 = l_Lean_MVarId_replaceTargetDefEq(x_1, x_2, x_4, x_5, x_6, x_7, x_8); return x_9; } } static lean_object* _init_l_Lean_MVarId_change___lambda__2___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("given type", 10); return x_1; } } static lean_object* _init_l_Lean_MVarId_change___lambda__2___closed__2() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_MVarId_change___lambda__2___closed__1; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } static lean_object* _init_l_Lean_MVarId_change___lambda__2___closed__3() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("\nis not definitionally equal to", 31); return x_1; } } static lean_object* _init_l_Lean_MVarId_change___lambda__2___closed__4() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_MVarId_change___lambda__2___closed__3; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } static lean_object* _init_l_Lean_MVarId_change___lambda__2___closed__5() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("", 0); return x_1; } } static lean_object* _init_l_Lean_MVarId_change___lambda__2___closed__6() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_MVarId_change___lambda__2___closed__5; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__2(lean_object* x_1, lean_object* x_2, uint8_t x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_inc(x_1); x_9 = l_Lean_MVarId_getType(x_1, x_4, x_5, x_6, x_7, x_8); if (lean_obj_tag(x_9) == 0) { if (x_3 == 0) { lean_object* x_10; lean_object* x_11; x_10 = lean_ctor_get(x_9, 1); lean_inc(x_10); lean_dec(x_9); x_11 = l_Lean_MVarId_replaceTargetDefEq(x_1, x_2, x_4, x_5, x_6, x_7, x_10); return x_11; } else { lean_object* x_12; lean_object* x_13; lean_object* x_14; x_12 = lean_ctor_get(x_9, 0); lean_inc(x_12); x_13 = lean_ctor_get(x_9, 1); lean_inc(x_13); lean_dec(x_9); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_2); lean_inc(x_12); x_14 = l_Lean_Meta_isExprDefEq(x_12, x_2, x_4, x_5, x_6, x_7, x_13); if (lean_obj_tag(x_14) == 0) { lean_object* x_15; uint8_t x_16; x_15 = lean_ctor_get(x_14, 0); lean_inc(x_15); x_16 = lean_unbox(x_15); lean_dec(x_15); if (x_16 == 0) { lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; uint8_t x_29; x_17 = lean_ctor_get(x_14, 1); lean_inc(x_17); lean_dec(x_14); x_18 = l_Lean_indentExpr(x_2); x_19 = l_Lean_MVarId_change___lambda__2___closed__2; x_20 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_20, 0, x_19); lean_ctor_set(x_20, 1, x_18); x_21 = l_Lean_MVarId_change___lambda__2___closed__4; x_22 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_22, 0, x_20); lean_ctor_set(x_22, 1, x_21); x_23 = l_Lean_indentExpr(x_12); x_24 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_24, 0, x_22); lean_ctor_set(x_24, 1, x_23); x_25 = l_Lean_MVarId_change___lambda__2___closed__6; x_26 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_26, 0, x_24); lean_ctor_set(x_26, 1, x_25); x_27 = l_Lean_MVarId_replaceTargetDefEq___closed__2; x_28 = l_Lean_Meta_throwTacticEx___rarg(x_27, x_1, x_26, x_4, x_5, x_6, x_7, x_17); lean_dec(x_7); lean_dec(x_5); x_29 = !lean_is_exclusive(x_28); if (x_29 == 0) { return x_28; } else { lean_object* x_30; lean_object* x_31; lean_object* x_32; x_30 = lean_ctor_get(x_28, 0); x_31 = lean_ctor_get(x_28, 1); lean_inc(x_31); lean_inc(x_30); lean_dec(x_28); x_32 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_32, 0, x_30); lean_ctor_set(x_32, 1, x_31); return x_32; } } else { lean_object* x_33; lean_object* x_34; lean_dec(x_12); x_33 = lean_ctor_get(x_14, 1); lean_inc(x_33); lean_dec(x_14); x_34 = l_Lean_MVarId_replaceTargetDefEq(x_1, x_2, x_4, x_5, x_6, x_7, x_33); return x_34; } } else { uint8_t x_35; lean_dec(x_12); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_35 = !lean_is_exclusive(x_14); if (x_35 == 0) { return x_14; } else { lean_object* x_36; lean_object* x_37; lean_object* x_38; x_36 = lean_ctor_get(x_14, 0); x_37 = lean_ctor_get(x_14, 1); lean_inc(x_37); lean_inc(x_36); lean_dec(x_14); x_38 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_38, 0, x_36); lean_ctor_set(x_38, 1, x_37); return x_38; } } } } else { uint8_t x_39; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_2); lean_dec(x_1); x_39 = !lean_is_exclusive(x_9); if (x_39 == 0) { return x_9; } else { lean_object* x_40; lean_object* x_41; lean_object* x_42; x_40 = lean_ctor_get(x_9, 0); x_41 = lean_ctor_get(x_9, 1); lean_inc(x_41); lean_inc(x_40); lean_dec(x_9); x_42 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_42, 0, x_40); lean_ctor_set(x_42, 1, x_41); return x_42; } } } } LEAN_EXPORT lean_object* l_Lean_MVarId_change(lean_object* x_1, lean_object* x_2, uint8_t x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_object* x_10; lean_object* x_11; x_9 = lean_box(x_3); lean_inc(x_1); x_10 = lean_alloc_closure((void*)(l_Lean_MVarId_change___lambda__2___boxed), 8, 3); lean_closure_set(x_10, 0, x_1); lean_closure_set(x_10, 1, x_2); lean_closure_set(x_10, 2, x_9); x_11 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_10, x_4, x_5, x_6, x_7, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; x_9 = l_Lean_MVarId_change___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8); lean_dec(x_3); return x_9; } } LEAN_EXPORT lean_object* l_Lean_MVarId_change___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { uint8_t x_9; lean_object* x_10; x_9 = lean_unbox(x_3); lean_dec(x_3); x_10 = l_Lean_MVarId_change___lambda__2(x_1, x_2, x_9, x_4, x_5, x_6, x_7, x_8); return x_10; } } LEAN_EXPORT lean_object* l_Lean_MVarId_change___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { uint8_t x_9; lean_object* x_10; x_9 = lean_unbox(x_3); lean_dec(x_3); x_10 = l_Lean_MVarId_change(x_1, x_2, x_9, x_4, x_5, x_6, x_7, x_8); return x_10; } } LEAN_EXPORT lean_object* l_Lean_Meta_change(lean_object* x_1, lean_object* x_2, uint8_t x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_object* x_10; lean_object* x_11; x_9 = lean_box(x_3); lean_inc(x_1); x_10 = lean_alloc_closure((void*)(l_Lean_MVarId_change___boxed), 8, 3); lean_closure_set(x_10, 0, x_1); lean_closure_set(x_10, 1, x_2); lean_closure_set(x_10, 2, x_9); x_11 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_10, x_4, x_5, x_6, x_7, x_8); return x_11; } } LEAN_EXPORT lean_object* l_Lean_Meta_change___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { uint8_t x_9; lean_object* x_10; x_9 = lean_unbox(x_3); lean_dec(x_3); x_10 = l_Lean_Meta_change(x_1, x_2, x_9, x_4, x_5, x_6, x_7, x_8); return x_10; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("changeHypothesis", 16); return x_1; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__3() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("unexpected auxiliary target", 27); return x_1; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__4() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__3; x_2 = lean_alloc_ctor(3, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__5() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__4; x_2 = lean_alloc_ctor(0, 1, 0); lean_ctor_set(x_2, 0, x_1); return x_2; } } LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, uint8_t x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; lean_inc(x_1); x_10 = l_Lean_MVarId_getType(x_1, x_5, x_6, x_7, x_8, x_9); if (lean_obj_tag(x_10) == 0) { lean_object* x_11; x_11 = lean_ctor_get(x_10, 0); lean_inc(x_11); switch (lean_obj_tag(x_11)) { case 7: { lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; uint8_t x_16; uint8_t x_17; x_12 = lean_ctor_get(x_10, 1); lean_inc(x_12); lean_dec(x_10); x_13 = lean_ctor_get(x_11, 0); lean_inc(x_13); x_14 = lean_ctor_get(x_11, 1); lean_inc(x_14); x_15 = lean_ctor_get(x_11, 2); lean_inc(x_15); x_16 = lean_ctor_get_uint8(x_11, sizeof(void*)*3 + 8); lean_dec(x_11); if (x_4 == 0) { uint8_t x_68; x_68 = 0; x_17 = x_68; goto block_67; } else { uint8_t x_69; x_69 = 1; x_17 = x_69; goto block_67; } block_67: { lean_object* x_18; if (x_17 == 0) { lean_dec(x_14); x_18 = x_12; goto block_42; } else { lean_object* x_43; lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_14); lean_inc(x_2); x_43 = l_Lean_Meta_isExprDefEq(x_2, x_14, x_5, x_6, x_7, x_8, x_12); if (lean_obj_tag(x_43) == 0) { lean_object* x_44; uint8_t x_45; x_44 = lean_ctor_get(x_43, 0); lean_inc(x_44); x_45 = lean_unbox(x_44); lean_dec(x_44); if (x_45 == 0) { lean_object* x_46; lean_object* x_47; lean_object* x_48; lean_object* x_49; lean_object* x_50; lean_object* x_51; lean_object* x_52; lean_object* x_53; lean_object* x_54; lean_object* x_55; lean_object* x_56; lean_object* x_57; uint8_t x_58; lean_dec(x_15); lean_dec(x_13); lean_dec(x_3); x_46 = lean_ctor_get(x_43, 1); lean_inc(x_46); lean_dec(x_43); x_47 = l_Lean_indentExpr(x_2); x_48 = l_Lean_MVarId_change___lambda__2___closed__2; x_49 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_49, 0, x_48); lean_ctor_set(x_49, 1, x_47); x_50 = l_Lean_MVarId_change___lambda__2___closed__4; x_51 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_51, 0, x_49); lean_ctor_set(x_51, 1, x_50); x_52 = l_Lean_indentExpr(x_14); x_53 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_53, 0, x_51); lean_ctor_set(x_53, 1, x_52); x_54 = l_Lean_MVarId_change___lambda__2___closed__6; x_55 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_55, 0, x_53); lean_ctor_set(x_55, 1, x_54); x_56 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2; x_57 = l_Lean_Meta_throwTacticEx___rarg(x_56, x_1, x_55, x_5, x_6, x_7, x_8, x_46); lean_dec(x_8); lean_dec(x_6); x_58 = !lean_is_exclusive(x_57); if (x_58 == 0) { return x_57; } else { lean_object* x_59; lean_object* x_60; lean_object* x_61; x_59 = lean_ctor_get(x_57, 0); x_60 = lean_ctor_get(x_57, 1); lean_inc(x_60); lean_inc(x_59); lean_dec(x_57); x_61 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_61, 0, x_59); lean_ctor_set(x_61, 1, x_60); return x_61; } } else { lean_object* x_62; lean_dec(x_14); x_62 = lean_ctor_get(x_43, 1); lean_inc(x_62); lean_dec(x_43); x_18 = x_62; goto block_42; } } else { uint8_t x_63; lean_dec(x_15); lean_dec(x_14); lean_dec(x_13); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_63 = !lean_is_exclusive(x_43); if (x_63 == 0) { return x_43; } else { lean_object* x_64; lean_object* x_65; lean_object* x_66; x_64 = lean_ctor_get(x_43, 0); x_65 = lean_ctor_get(x_43, 1); lean_inc(x_65); lean_inc(x_64); lean_dec(x_43); x_66 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_66, 0, x_64); lean_ctor_set(x_66, 1, x_65); return x_66; } } } block_42: { lean_object* x_19; lean_object* x_20; x_19 = l_Lean_Expr_forallE___override(x_13, x_2, x_15, x_16); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_20 = l_Lean_MVarId_replaceTargetDefEq(x_1, x_19, x_5, x_6, x_7, x_8, x_18); if (lean_obj_tag(x_20) == 0) { lean_object* x_21; lean_object* x_22; lean_object* x_23; uint8_t x_24; uint8_t x_25; lean_object* x_26; x_21 = lean_ctor_get(x_20, 0); lean_inc(x_21); x_22 = lean_ctor_get(x_20, 1); lean_inc(x_22); lean_dec(x_20); x_23 = lean_box(0); x_24 = 0; x_25 = 1; x_26 = l_Lean_Meta_introNCore(x_21, x_3, x_23, x_24, x_25, x_5, x_6, x_7, x_8, x_22); if (lean_obj_tag(x_26) == 0) { uint8_t x_27; x_27 = !lean_is_exclusive(x_26); if (x_27 == 0) { lean_object* x_28; lean_object* x_29; x_28 = lean_ctor_get(x_26, 0); x_29 = lean_ctor_get(x_28, 1); lean_inc(x_29); lean_dec(x_28); lean_ctor_set(x_26, 0, x_29); return x_26; } else { lean_object* x_30; lean_object* x_31; lean_object* x_32; lean_object* x_33; x_30 = lean_ctor_get(x_26, 0); x_31 = lean_ctor_get(x_26, 1); lean_inc(x_31); lean_inc(x_30); lean_dec(x_26); x_32 = lean_ctor_get(x_30, 1); lean_inc(x_32); lean_dec(x_30); x_33 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_33, 0, x_32); lean_ctor_set(x_33, 1, x_31); return x_33; } } else { uint8_t x_34; x_34 = !lean_is_exclusive(x_26); if (x_34 == 0) { return x_26; } else { lean_object* x_35; lean_object* x_36; lean_object* x_37; x_35 = lean_ctor_get(x_26, 0); x_36 = lean_ctor_get(x_26, 1); lean_inc(x_36); lean_inc(x_35); lean_dec(x_26); x_37 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_37, 0, x_35); lean_ctor_set(x_37, 1, x_36); return x_37; } } } else { uint8_t x_38; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); x_38 = !lean_is_exclusive(x_20); if (x_38 == 0) { return x_20; } else { lean_object* x_39; lean_object* x_40; lean_object* x_41; x_39 = lean_ctor_get(x_20, 0); x_40 = lean_ctor_get(x_20, 1); lean_inc(x_40); lean_inc(x_39); lean_dec(x_20); x_41 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_41, 0, x_39); lean_ctor_set(x_41, 1, x_40); return x_41; } } } } } case 8: { lean_object* x_70; lean_object* x_71; lean_object* x_72; lean_object* x_73; lean_object* x_74; uint8_t x_75; x_70 = lean_ctor_get(x_10, 1); lean_inc(x_70); lean_dec(x_10); x_71 = lean_ctor_get(x_11, 0); lean_inc(x_71); x_72 = lean_ctor_get(x_11, 1); lean_inc(x_72); x_73 = lean_ctor_get(x_11, 2); lean_inc(x_73); x_74 = lean_ctor_get(x_11, 3); lean_inc(x_74); lean_dec(x_11); if (x_4 == 0) { uint8_t x_126; x_126 = 0; x_75 = x_126; goto block_125; } else { uint8_t x_127; x_127 = 1; x_75 = x_127; goto block_125; } block_125: { lean_object* x_76; if (x_75 == 0) { lean_dec(x_72); x_76 = x_70; goto block_100; } else { lean_object* x_101; lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_72); lean_inc(x_2); x_101 = l_Lean_Meta_isExprDefEq(x_2, x_72, x_5, x_6, x_7, x_8, x_70); if (lean_obj_tag(x_101) == 0) { lean_object* x_102; uint8_t x_103; x_102 = lean_ctor_get(x_101, 0); lean_inc(x_102); x_103 = lean_unbox(x_102); lean_dec(x_102); if (x_103 == 0) { lean_object* x_104; lean_object* x_105; lean_object* x_106; lean_object* x_107; lean_object* x_108; lean_object* x_109; lean_object* x_110; lean_object* x_111; lean_object* x_112; lean_object* x_113; lean_object* x_114; lean_object* x_115; uint8_t x_116; lean_dec(x_74); lean_dec(x_73); lean_dec(x_71); lean_dec(x_3); x_104 = lean_ctor_get(x_101, 1); lean_inc(x_104); lean_dec(x_101); x_105 = l_Lean_indentExpr(x_2); x_106 = l_Lean_MVarId_change___lambda__2___closed__2; x_107 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_107, 0, x_106); lean_ctor_set(x_107, 1, x_105); x_108 = l_Lean_MVarId_change___lambda__2___closed__4; x_109 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_109, 0, x_107); lean_ctor_set(x_109, 1, x_108); x_110 = l_Lean_indentExpr(x_72); x_111 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_111, 0, x_109); lean_ctor_set(x_111, 1, x_110); x_112 = l_Lean_MVarId_change___lambda__2___closed__6; x_113 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_113, 0, x_111); lean_ctor_set(x_113, 1, x_112); x_114 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2; x_115 = l_Lean_Meta_throwTacticEx___rarg(x_114, x_1, x_113, x_5, x_6, x_7, x_8, x_104); lean_dec(x_8); lean_dec(x_6); x_116 = !lean_is_exclusive(x_115); if (x_116 == 0) { return x_115; } else { lean_object* x_117; lean_object* x_118; lean_object* x_119; x_117 = lean_ctor_get(x_115, 0); x_118 = lean_ctor_get(x_115, 1); lean_inc(x_118); lean_inc(x_117); lean_dec(x_115); x_119 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_119, 0, x_117); lean_ctor_set(x_119, 1, x_118); return x_119; } } else { lean_object* x_120; lean_dec(x_72); x_120 = lean_ctor_get(x_101, 1); lean_inc(x_120); lean_dec(x_101); x_76 = x_120; goto block_100; } } else { uint8_t x_121; lean_dec(x_74); lean_dec(x_73); lean_dec(x_72); lean_dec(x_71); lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_121 = !lean_is_exclusive(x_101); if (x_121 == 0) { return x_101; } else { lean_object* x_122; lean_object* x_123; lean_object* x_124; x_122 = lean_ctor_get(x_101, 0); x_123 = lean_ctor_get(x_101, 1); lean_inc(x_123); lean_inc(x_122); lean_dec(x_101); x_124 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_124, 0, x_122); lean_ctor_set(x_124, 1, x_123); return x_124; } } } block_100: { uint8_t x_77; lean_object* x_78; lean_object* x_79; x_77 = 0; x_78 = l_Lean_Expr_letE___override(x_71, x_2, x_73, x_74, x_77); lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_79 = l_Lean_MVarId_replaceTargetDefEq(x_1, x_78, x_5, x_6, x_7, x_8, x_76); if (lean_obj_tag(x_79) == 0) { lean_object* x_80; lean_object* x_81; lean_object* x_82; uint8_t x_83; lean_object* x_84; x_80 = lean_ctor_get(x_79, 0); lean_inc(x_80); x_81 = lean_ctor_get(x_79, 1); lean_inc(x_81); lean_dec(x_79); x_82 = lean_box(0); x_83 = 1; x_84 = l_Lean_Meta_introNCore(x_80, x_3, x_82, x_77, x_83, x_5, x_6, x_7, x_8, x_81); if (lean_obj_tag(x_84) == 0) { uint8_t x_85; x_85 = !lean_is_exclusive(x_84); if (x_85 == 0) { lean_object* x_86; lean_object* x_87; x_86 = lean_ctor_get(x_84, 0); x_87 = lean_ctor_get(x_86, 1); lean_inc(x_87); lean_dec(x_86); lean_ctor_set(x_84, 0, x_87); return x_84; } else { lean_object* x_88; lean_object* x_89; lean_object* x_90; lean_object* x_91; x_88 = lean_ctor_get(x_84, 0); x_89 = lean_ctor_get(x_84, 1); lean_inc(x_89); lean_inc(x_88); lean_dec(x_84); x_90 = lean_ctor_get(x_88, 1); lean_inc(x_90); lean_dec(x_88); x_91 = lean_alloc_ctor(0, 2, 0); lean_ctor_set(x_91, 0, x_90); lean_ctor_set(x_91, 1, x_89); return x_91; } } else { uint8_t x_92; x_92 = !lean_is_exclusive(x_84); if (x_92 == 0) { return x_84; } else { lean_object* x_93; lean_object* x_94; lean_object* x_95; x_93 = lean_ctor_get(x_84, 0); x_94 = lean_ctor_get(x_84, 1); lean_inc(x_94); lean_inc(x_93); lean_dec(x_84); x_95 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_95, 0, x_93); lean_ctor_set(x_95, 1, x_94); return x_95; } } } else { uint8_t x_96; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); x_96 = !lean_is_exclusive(x_79); if (x_96 == 0) { return x_79; } else { lean_object* x_97; lean_object* x_98; lean_object* x_99; x_97 = lean_ctor_get(x_79, 0); x_98 = lean_ctor_get(x_79, 1); lean_inc(x_98); lean_inc(x_97); lean_dec(x_79); x_99 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_99, 0, x_97); lean_ctor_set(x_99, 1, x_98); return x_99; } } } } } default: { lean_object* x_128; lean_object* x_129; lean_object* x_130; lean_object* x_131; lean_dec(x_11); lean_dec(x_3); lean_dec(x_2); x_128 = lean_ctor_get(x_10, 1); lean_inc(x_128); lean_dec(x_10); x_129 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2; x_130 = l_Lean_MVarId_changeLocalDecl___lambda__1___closed__5; x_131 = l_Lean_Meta_throwTacticEx___rarg(x_129, x_1, x_130, x_5, x_6, x_7, x_8, x_128); lean_dec(x_8); lean_dec(x_6); return x_131; } } } else { uint8_t x_132; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_132 = !lean_is_exclusive(x_10); if (x_132 == 0) { return x_10; } else { lean_object* x_133; lean_object* x_134; lean_object* x_135; x_133 = lean_ctor_get(x_10, 0); x_134 = lean_ctor_get(x_10, 1); lean_inc(x_134); lean_inc(x_133); lean_dec(x_10); x_135 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_135, 0, x_133); lean_ctor_set(x_135, 1, x_134); return x_135; } } } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("changeLocalDecl", 15); return x_1; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_Lean_MVarId_changeLocalDecl___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_Lean_MVarId_changeLocalDecl___closed__3() { _start: { lean_object* x_1; lean_object* x_2; x_1 = lean_unsigned_to_nat(1u); x_2 = lean_mk_empty_array_with_capacity(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl(lean_object* x_1, lean_object* x_2, lean_object* x_3, uint8_t x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; lean_object* x_11; x_10 = l_Lean_MVarId_changeLocalDecl___closed__2; lean_inc(x_7); lean_inc(x_5); lean_inc(x_1); x_11 = l_Lean_MVarId_checkNotAssigned(x_1, x_10, x_5, x_6, x_7, x_8, x_9); if (lean_obj_tag(x_11) == 0) { lean_object* x_12; lean_object* x_13; lean_object* x_14; uint8_t x_15; uint8_t x_16; lean_object* x_17; x_12 = lean_ctor_get(x_11, 1); lean_inc(x_12); lean_dec(x_11); x_13 = l_Lean_MVarId_changeLocalDecl___closed__3; x_14 = lean_array_push(x_13, x_2); x_15 = 1; x_16 = 0; lean_inc(x_8); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); x_17 = l_Lean_MVarId_revert(x_1, x_14, x_15, x_16, x_5, x_6, x_7, x_8, x_12); if (lean_obj_tag(x_17) == 0) { lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; x_18 = lean_ctor_get(x_17, 0); lean_inc(x_18); x_19 = lean_ctor_get(x_17, 1); lean_inc(x_19); lean_dec(x_17); x_20 = lean_ctor_get(x_18, 0); lean_inc(x_20); x_21 = lean_ctor_get(x_18, 1); lean_inc(x_21); lean_dec(x_18); x_22 = lean_array_get_size(x_20); lean_dec(x_20); x_23 = lean_box(x_4); lean_inc(x_21); x_24 = lean_alloc_closure((void*)(l_Lean_MVarId_changeLocalDecl___lambda__1___boxed), 9, 4); lean_closure_set(x_24, 0, x_21); lean_closure_set(x_24, 1, x_3); lean_closure_set(x_24, 2, x_22); lean_closure_set(x_24, 3, x_23); x_25 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_21, x_24, x_5, x_6, x_7, x_8, x_19); return x_25; } else { uint8_t x_26; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); x_26 = !lean_is_exclusive(x_17); if (x_26 == 0) { return x_17; } else { lean_object* x_27; lean_object* x_28; lean_object* x_29; x_27 = lean_ctor_get(x_17, 0); x_28 = lean_ctor_get(x_17, 1); lean_inc(x_28); lean_inc(x_27); lean_dec(x_17); x_29 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_29, 0, x_27); lean_ctor_set(x_29, 1, x_28); return x_29; } } } else { uint8_t x_30; lean_dec(x_8); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_30 = !lean_is_exclusive(x_11); if (x_30 == 0) { return x_11; } else { lean_object* x_31; lean_object* x_32; lean_object* x_33; x_31 = lean_ctor_get(x_11, 0); x_32 = lean_ctor_get(x_11, 1); lean_inc(x_32); lean_inc(x_31); lean_dec(x_11); x_33 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_33, 0, x_31); lean_ctor_set(x_33, 1, x_32); return x_33; } } } } LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { uint8_t x_10; lean_object* x_11; x_10 = lean_unbox(x_4); lean_dec(x_4); x_11 = l_Lean_MVarId_changeLocalDecl___lambda__1(x_1, x_2, x_3, x_10, x_5, x_6, x_7, x_8, x_9); return x_11; } } LEAN_EXPORT lean_object* l_Lean_MVarId_changeLocalDecl___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { uint8_t x_10; lean_object* x_11; x_10 = lean_unbox(x_4); lean_dec(x_4); x_11 = l_Lean_MVarId_changeLocalDecl(x_1, x_2, x_3, x_10, x_5, x_6, x_7, x_8, x_9); return x_11; } } LEAN_EXPORT lean_object* l_Lean_Meta_changeLocalDecl(lean_object* x_1, lean_object* x_2, lean_object* x_3, uint8_t x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { lean_object* x_10; x_10 = l_Lean_MVarId_changeLocalDecl(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9); return x_10; } } LEAN_EXPORT lean_object* l_Lean_Meta_changeLocalDecl___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8, lean_object* x_9) { _start: { uint8_t x_10; lean_object* x_11; x_10 = lean_unbox(x_4); lean_dec(x_4); x_11 = l_Lean_Meta_changeLocalDecl(x_1, x_2, x_3, x_10, x_5, x_6, x_7, x_8, x_9); return x_11; } } LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTarget___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_inc(x_6); lean_inc(x_4); lean_inc(x_1); x_9 = l_Lean_MVarId_checkNotAssigned(x_1, x_2, x_4, x_5, x_6, x_7, x_8); if (lean_obj_tag(x_9) == 0) { lean_object* x_10; lean_object* x_11; x_10 = lean_ctor_get(x_9, 1); lean_inc(x_10); lean_dec(x_9); lean_inc(x_1); x_11 = l_Lean_MVarId_getType(x_1, x_4, x_5, x_6, x_7, x_10); if (lean_obj_tag(x_11) == 0) { lean_object* x_12; lean_object* x_13; lean_object* x_14; x_12 = lean_ctor_get(x_11, 0); lean_inc(x_12); x_13 = lean_ctor_get(x_11, 1); lean_inc(x_13); lean_dec(x_11); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); x_14 = lean_apply_6(x_3, x_12, x_4, x_5, x_6, x_7, x_13); if (lean_obj_tag(x_14) == 0) { lean_object* x_15; lean_object* x_16; uint8_t x_17; lean_object* x_18; x_15 = lean_ctor_get(x_14, 0); lean_inc(x_15); x_16 = lean_ctor_get(x_14, 1); lean_inc(x_16); lean_dec(x_14); x_17 = 0; x_18 = l_Lean_MVarId_change(x_1, x_15, x_17, x_4, x_5, x_6, x_7, x_16); return x_18; } else { uint8_t x_19; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_1); x_19 = !lean_is_exclusive(x_14); if (x_19 == 0) { return x_14; } else { lean_object* x_20; lean_object* x_21; lean_object* x_22; x_20 = lean_ctor_get(x_14, 0); x_21 = lean_ctor_get(x_14, 1); lean_inc(x_21); lean_inc(x_20); lean_dec(x_14); x_22 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_22, 0, x_20); lean_ctor_set(x_22, 1, x_21); return x_22; } } } else { uint8_t x_23; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_23 = !lean_is_exclusive(x_11); if (x_23 == 0) { return x_11; } else { lean_object* x_24; lean_object* x_25; lean_object* x_26; x_24 = lean_ctor_get(x_11, 0); x_25 = lean_ctor_get(x_11, 1); lean_inc(x_25); lean_inc(x_24); lean_dec(x_11); x_26 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_26, 0, x_24); lean_ctor_set(x_26, 1, x_25); return x_26; } } } else { uint8_t x_27; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_1); x_27 = !lean_is_exclusive(x_9); if (x_27 == 0) { return x_9; } else { lean_object* x_28; lean_object* x_29; lean_object* x_30; x_28 = lean_ctor_get(x_9, 0); x_29 = lean_ctor_get(x_9, 1); lean_inc(x_29); lean_inc(x_28); lean_dec(x_9); x_30 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_30, 0, x_28); lean_ctor_set(x_30, 1, x_29); return x_30; } } } } static lean_object* _init_l_Lean_MVarId_modifyTarget___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("modifyTarget", 12); return x_1; } } static lean_object* _init_l_Lean_MVarId_modifyTarget___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_Lean_MVarId_modifyTarget___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTarget(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; lean_object* x_9; lean_object* x_10; x_8 = l_Lean_MVarId_modifyTarget___closed__2; lean_inc(x_1); x_9 = lean_alloc_closure((void*)(l_Lean_MVarId_modifyTarget___lambda__1), 8, 3); lean_closure_set(x_9, 0, x_1); lean_closure_set(x_9, 1, x_8); lean_closure_set(x_9, 2, x_2); x_10 = l_Lean_MVarId_withContext___at___private_Lean_Meta_SynthInstance_0__Lean_Meta_synthPendingImp___spec__2___rarg(x_1, x_9, x_3, x_4, x_5, x_6, x_7); return x_10; } } LEAN_EXPORT lean_object* l_Lean_Meta_modifyTarget(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Lean_MVarId_modifyTarget(x_1, x_2, x_3, x_4, x_5, x_6, x_7); return x_8; } } static lean_object* _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__1() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("modifyTargetEqLHS", 17); return x_1; } } static lean_object* _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__2() { _start: { lean_object* x_1; lean_object* x_2; lean_object* x_3; x_1 = lean_box(0); x_2 = l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__1; x_3 = l_Lean_Name_str___override(x_1, x_2); return x_3; } } static lean_object* _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__3() { _start: { lean_object* x_1; x_1 = lean_mk_string_from_bytes("equality expected", 17); return x_1; } } static lean_object* _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__4() { _start: { lean_object* x_1; lean_object* x_2; x_1 = l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__3; x_2 = l_Lean_stringToMessageData(x_1); return x_2; } } LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTargetEqLHS___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) { _start: { lean_object* x_9; lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); lean_inc(x_3); x_9 = l_Lean_Meta_matchEq_x3f(x_3, x_4, x_5, x_6, x_7, x_8); if (lean_obj_tag(x_9) == 0) { lean_object* x_10; x_10 = lean_ctor_get(x_9, 0); lean_inc(x_10); if (lean_obj_tag(x_10) == 0) { lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_dec(x_2); x_11 = lean_ctor_get(x_9, 1); lean_inc(x_11); lean_dec(x_9); x_12 = l_Lean_indentExpr(x_3); x_13 = l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__4; x_14 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_14, 0, x_13); lean_ctor_set(x_14, 1, x_12); x_15 = l_Lean_MVarId_change___lambda__2___closed__6; x_16 = lean_alloc_ctor(7, 2, 0); lean_ctor_set(x_16, 0, x_14); lean_ctor_set(x_16, 1, x_15); x_17 = l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__2; x_18 = l_Lean_Meta_throwTacticEx___rarg(x_17, x_1, x_16, x_4, x_5, x_6, x_7, x_11); lean_dec(x_7); lean_dec(x_5); return x_18; } else { lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_dec(x_3); lean_dec(x_1); x_19 = lean_ctor_get(x_10, 0); lean_inc(x_19); lean_dec(x_10); x_20 = lean_ctor_get(x_19, 1); lean_inc(x_20); lean_dec(x_19); x_21 = lean_ctor_get(x_9, 1); lean_inc(x_21); lean_dec(x_9); x_22 = lean_ctor_get(x_20, 0); lean_inc(x_22); x_23 = lean_ctor_get(x_20, 1); lean_inc(x_23); lean_dec(x_20); lean_inc(x_7); lean_inc(x_6); lean_inc(x_5); lean_inc(x_4); x_24 = lean_apply_6(x_2, x_22, x_4, x_5, x_6, x_7, x_21); if (lean_obj_tag(x_24) == 0) { lean_object* x_25; lean_object* x_26; lean_object* x_27; x_25 = lean_ctor_get(x_24, 0); lean_inc(x_25); x_26 = lean_ctor_get(x_24, 1); lean_inc(x_26); lean_dec(x_24); x_27 = l_Lean_Meta_mkEq(x_25, x_23, x_4, x_5, x_6, x_7, x_26); return x_27; } else { uint8_t x_28; lean_dec(x_23); lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); x_28 = !lean_is_exclusive(x_24); if (x_28 == 0) { return x_24; } else { lean_object* x_29; lean_object* x_30; lean_object* x_31; x_29 = lean_ctor_get(x_24, 0); x_30 = lean_ctor_get(x_24, 1); lean_inc(x_30); lean_inc(x_29); lean_dec(x_24); x_31 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_31, 0, x_29); lean_ctor_set(x_31, 1, x_30); return x_31; } } } } else { uint8_t x_32; lean_dec(x_7); lean_dec(x_6); lean_dec(x_5); lean_dec(x_4); lean_dec(x_3); lean_dec(x_2); lean_dec(x_1); x_32 = !lean_is_exclusive(x_9); if (x_32 == 0) { return x_9; } else { lean_object* x_33; lean_object* x_34; lean_object* x_35; x_33 = lean_ctor_get(x_9, 0); x_34 = lean_ctor_get(x_9, 1); lean_inc(x_34); lean_inc(x_33); lean_dec(x_9); x_35 = lean_alloc_ctor(1, 2, 0); lean_ctor_set(x_35, 0, x_33); lean_ctor_set(x_35, 1, x_34); return x_35; } } } } LEAN_EXPORT lean_object* l_Lean_MVarId_modifyTargetEqLHS(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; lean_object* x_9; lean_inc(x_1); x_8 = lean_alloc_closure((void*)(l_Lean_MVarId_modifyTargetEqLHS___lambda__1), 8, 2); lean_closure_set(x_8, 0, x_1); lean_closure_set(x_8, 1, x_2); x_9 = l_Lean_MVarId_modifyTarget(x_1, x_8, x_3, x_4, x_5, x_6, x_7); return x_9; } } LEAN_EXPORT lean_object* l_Lean_Meta_modifyTargetEqLHS(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7) { _start: { lean_object* x_8; x_8 = l_Lean_MVarId_modifyTargetEqLHS(x_1, x_2, x_3, x_4, x_5, x_6, x_7); return x_8; } } lean_object* initialize_Init(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Util_ForEachExpr(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_AppBuilder(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_MatchUtil(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_Tactic_Util(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_Tactic_Revert(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_Tactic_Intro(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_Tactic_Clear(uint8_t builtin, lean_object*); lean_object* initialize_Lean_Meta_Tactic_Assert(uint8_t builtin, lean_object*); static bool _G_initialized = false; LEAN_EXPORT lean_object* initialize_Lean_Meta_Tactic_Replace(uint8_t builtin, lean_object* w) { lean_object * res; if (_G_initialized) return lean_io_result_mk_ok(lean_box(0)); _G_initialized = true; res = initialize_Init(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Util_ForEachExpr(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_AppBuilder(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_MatchUtil(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_Tactic_Util(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_Tactic_Revert(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_Tactic_Intro(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_Tactic_Clear(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); res = initialize_Lean_Meta_Tactic_Assert(builtin, lean_io_mk_world()); if (lean_io_result_is_error(res)) return res; lean_dec_ref(res); l_Lean_MVarId_replaceTargetEq___lambda__1___closed__1 = _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__1(); lean_mark_persistent(l_Lean_MVarId_replaceTargetEq___lambda__1___closed__1); l_Lean_MVarId_replaceTargetEq___lambda__1___closed__2 = _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__2(); lean_mark_persistent(l_Lean_MVarId_replaceTargetEq___lambda__1___closed__2); l_Lean_MVarId_replaceTargetEq___lambda__1___closed__3 = _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__3(); lean_mark_persistent(l_Lean_MVarId_replaceTargetEq___lambda__1___closed__3); l_Lean_MVarId_replaceTargetEq___lambda__1___closed__4 = _init_l_Lean_MVarId_replaceTargetEq___lambda__1___closed__4(); lean_mark_persistent(l_Lean_MVarId_replaceTargetEq___lambda__1___closed__4); l_Lean_MVarId_replaceTargetEq___closed__1 = _init_l_Lean_MVarId_replaceTargetEq___closed__1(); lean_mark_persistent(l_Lean_MVarId_replaceTargetEq___closed__1); l_Lean_MVarId_replaceTargetEq___closed__2 = _init_l_Lean_MVarId_replaceTargetEq___closed__2(); lean_mark_persistent(l_Lean_MVarId_replaceTargetEq___closed__2); l_Lean_MVarId_replaceTargetDefEq___closed__1 = _init_l_Lean_MVarId_replaceTargetDefEq___closed__1(); lean_mark_persistent(l_Lean_MVarId_replaceTargetDefEq___closed__1); l_Lean_MVarId_replaceTargetDefEq___closed__2 = _init_l_Lean_MVarId_replaceTargetDefEq___closed__2(); lean_mark_persistent(l_Lean_MVarId_replaceTargetDefEq___closed__2); l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__1 = _init_l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__1(); lean_mark_persistent(l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__1); l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__2 = _init_l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__2(); lean_mark_persistent(l___private_Lean_Meta_Tactic_Replace_0__Lean_Meta_replaceLocalDeclCore_findMaxFVar___closed__2); l_Lean_MVarId_change___lambda__2___closed__1 = _init_l_Lean_MVarId_change___lambda__2___closed__1(); lean_mark_persistent(l_Lean_MVarId_change___lambda__2___closed__1); l_Lean_MVarId_change___lambda__2___closed__2 = _init_l_Lean_MVarId_change___lambda__2___closed__2(); lean_mark_persistent(l_Lean_MVarId_change___lambda__2___closed__2); l_Lean_MVarId_change___lambda__2___closed__3 = _init_l_Lean_MVarId_change___lambda__2___closed__3(); lean_mark_persistent(l_Lean_MVarId_change___lambda__2___closed__3); l_Lean_MVarId_change___lambda__2___closed__4 = _init_l_Lean_MVarId_change___lambda__2___closed__4(); lean_mark_persistent(l_Lean_MVarId_change___lambda__2___closed__4); l_Lean_MVarId_change___lambda__2___closed__5 = _init_l_Lean_MVarId_change___lambda__2___closed__5(); lean_mark_persistent(l_Lean_MVarId_change___lambda__2___closed__5); l_Lean_MVarId_change___lambda__2___closed__6 = _init_l_Lean_MVarId_change___lambda__2___closed__6(); lean_mark_persistent(l_Lean_MVarId_change___lambda__2___closed__6); l_Lean_MVarId_changeLocalDecl___lambda__1___closed__1 = _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__1(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___lambda__1___closed__1); l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2 = _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___lambda__1___closed__2); l_Lean_MVarId_changeLocalDecl___lambda__1___closed__3 = _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__3(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___lambda__1___closed__3); l_Lean_MVarId_changeLocalDecl___lambda__1___closed__4 = _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__4(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___lambda__1___closed__4); l_Lean_MVarId_changeLocalDecl___lambda__1___closed__5 = _init_l_Lean_MVarId_changeLocalDecl___lambda__1___closed__5(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___lambda__1___closed__5); l_Lean_MVarId_changeLocalDecl___closed__1 = _init_l_Lean_MVarId_changeLocalDecl___closed__1(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___closed__1); l_Lean_MVarId_changeLocalDecl___closed__2 = _init_l_Lean_MVarId_changeLocalDecl___closed__2(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___closed__2); l_Lean_MVarId_changeLocalDecl___closed__3 = _init_l_Lean_MVarId_changeLocalDecl___closed__3(); lean_mark_persistent(l_Lean_MVarId_changeLocalDecl___closed__3); l_Lean_MVarId_modifyTarget___closed__1 = _init_l_Lean_MVarId_modifyTarget___closed__1(); lean_mark_persistent(l_Lean_MVarId_modifyTarget___closed__1); l_Lean_MVarId_modifyTarget___closed__2 = _init_l_Lean_MVarId_modifyTarget___closed__2(); lean_mark_persistent(l_Lean_MVarId_modifyTarget___closed__2); l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__1 = _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__1(); lean_mark_persistent(l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__1); l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__2 = _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__2(); lean_mark_persistent(l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__2); l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__3 = _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__3(); lean_mark_persistent(l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__3); l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__4 = _init_l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__4(); lean_mark_persistent(l_Lean_MVarId_modifyTargetEqLHS___lambda__1___closed__4); return lean_io_result_mk_ok(lean_box(0)); } #ifdef __cplusplus } #endif
7374542344c67998dfaa30795f3b052a32cda0bb
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/apollo2/libraries/drivers/hal/am_hal_tpiu.c
151b0ce21dec3f9e0ee9abb1d55468e7a2fe402d
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
11,415
c
am_hal_tpiu.c
//***************************************************************************** // // am_hal_tpiu.c //! @file //! //! @brief Support functions for the ARM TPIU module //! //! Provides support functions for configuring the ARM TPIU module //! //! @addtogroup tpiu2 Trace Port Interface Unit (TPIU) //! @ingroup apollo2hal //! @{ // //***************************************************************************** //***************************************************************************** // // Copyright (c) 2017, Ambiq Micro // 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. // // This is part of revision 1.2.11 of the AmbiqSuite Development Package. // //***************************************************************************** #include <stdint.h> #include <stdbool.h> #include "am_mcu_apollo.h" //***************************************************************************** // //! @brief Enable the clock to the TPIU module. //! //! This function enables the clock to the TPIU module. //! //! @return None. // //***************************************************************************** void am_hal_tpiu_clock_enable(void) { // // Enable the TPIU clock // AM_REG(MCUCTRL, TPIUCTRL) |= AM_REG_MCUCTRL_TPIUCTRL_ENABLE_M; } //***************************************************************************** // //! @brief Disable the clock to the TPIU module. //! //! This function disables the clock to the TPIU module. //! //! @return None. // //***************************************************************************** void am_hal_tpiu_clock_disable(void) { // // Disable the TPIU clock // AM_REG(MCUCTRL, TPIUCTRL) &= ~AM_REG_MCUCTRL_TPIUCTRL_ENABLE_M; } //***************************************************************************** // //! @brief Set the output port width of the TPIU //! //! @param ui32PortWidth - The desired port width (in bits) //! //! This function uses the TPIU_CSPSR register to set the desired output port //! width of the TPIU. //! //! @return None. // //***************************************************************************** void am_hal_tpiu_port_width_set(uint32_t ui32PortWidth) { AM_REG(TPIU, CSPSR) = 1 << (ui32PortWidth - 1); } //***************************************************************************** // //! @brief Read the supported_output port width of the TPIU //! //! This function uses the \e TPIU_SSPSR register to set the supported output //! port widths of the TPIU. //! //! @return Current width of the TPIU output port // //***************************************************************************** uint32_t am_hal_tpiu_supported_port_width_get(void) { uint32_t i, ui32WidthValue; // // Read the supported width register. // ui32WidthValue = AM_REG(TPIU, SSPSR); // // The register value is encoded in a one-hot format, so the position of // the single set bit determines the actual width of the port. // for (i = 1; i < 32; i++) { // // Check each bit for a '1'. When we find it, our current loop index // will be equal to the port width. // if (ui32WidthValue == (0x1 << (i - 1))) { return i; } } // // We should never get here, but if we do, just return the smallest // possible value for a supported trace port width. // return 1; } //***************************************************************************** // //! @brief Read the output port width of the TPIU //! //! This function uses the \e TPIU_CSPSR register to set the desired output //! port width of the TPIU. //! //! @return Current width of the TPIU output port // //***************************************************************************** uint32_t am_hal_tpiu_port_width_get(void) { uint32_t ui32Temp; uint32_t ui32Width; ui32Width = 1; ui32Temp = AM_REG(TPIU, CSPSR); while ( !(ui32Temp & 1) ) { ui32Temp = ui32Temp >> 1; ui32Width++; if (ui32Width > 32) { ui32Width = 0; break; } } // // Current width of the TPIU output port. // return ui32Width; } //***************************************************************************** // //! @brief Configure the TPIU based on the values in the configuration struct. //! //! @param psConfig - pointer to an am_hal_tpiu_config_t structure containing //! the desired configuration information. //! //! This function reads the provided configuration structure, and sets the //! relevant TPIU registers to achieve the desired configuration. //! //! @return None. // //***************************************************************************** void am_hal_tpiu_configure(am_hal_tpiu_config_t *psConfig) { // // Set the clock freq in the MCUCTRL register. // AM_REG(MCUCTRL, TPIUCTRL) |= psConfig->ui32TraceClkIn; // // Set the desired protocol. // AM_REG(TPIU, SPPR) = psConfig->ui32PinProtocol; // // Set the parallel port width. This may be redundant if the user has // selected a serial protocol, but we'll set it anyway. // AM_REG(TPIU, CSPSR) = (1 << (psConfig->ui32ParallelPortSize - 1)); // // Set the clock prescaler. // AM_REG(TPIU, ACPR) = psConfig->ui32ClockPrescaler; } //***************************************************************************** // //! @brief Enables the TPIU //! //! This function enables the ARM TPIU by setting the TPIU registers and then //! enabling the TPIU clock source in MCU control register. //! //! @param psConfig - structure for configuration. //! If ui32SetItmBaud, the other structure members are used to set the //! TPIU configuration. //! But for simplicity, ui32SetItmBaud can be set to one of the //! following, in which case all other structure members are ignored. //! In this case, the given BAUD rate is based on a div-by-8 HFRC clock. //! AM_HAL_TPIU_BAUD_57600 //! AM_HAL_TPIU_BAUD_115200 //! AM_HAL_TPIU_BAUD_230400 //! AM_HAL_TPIU_BAUD_460800 //! AM_HAL_TPIU_BAUD_500000 //! AM_HAL_TPIU_BAUD_1M //! //! @return None. // //***************************************************************************** void am_hal_tpiu_enable(am_hal_tpiu_config_t *psConfig) { uint32_t ui32HFRC, ui32SWOscaler, ui32ITMbitrate; ui32ITMbitrate = psConfig->ui32SetItmBaud; // // TPIU formatter & flush control register. // AM_REG(TPIU, FFCR) = 0; if ( ui32ITMbitrate ) { // // Set the Current Parallel Port Size (note - only 1 bit can be set). // AM_REG(TPIU, CSPSR) = AM_REG_TPIU_CSPSR_CWIDTH_1BIT; // // Use some default assumptions to set the ITM frequency. // if ( (ui32ITMbitrate < AM_HAL_TPIU_BAUD_57600 ) || (ui32ITMbitrate > AM_HAL_TPIU_BAUD_2M ) ) { ui32ITMbitrate = AM_HAL_TPIU_BAUD_DEFAULT; } // // Get the current HFRC frequency. // ui32HFRC = am_hal_clkgen_sysclk_get(); // // Compute the SWO scaler value. // if ( ui32HFRC != 0xFFFFFFFF ) { ui32SWOscaler = ((ui32HFRC / 8) / ui32ITMbitrate) - 1; } else { ui32SWOscaler = ( (AM_HAL_CLKGEN_FREQ_MAX_HZ / 8) / AM_HAL_TPIU_BAUD_DEFAULT ) - 1; } // // Set the scaler value. // AM_REG(TPIU, ACPR) = AM_REG_TPIU_ACPR_SWOSCALER(ui32SWOscaler); // // Set for UART mode // AM_REG(TPIU, SPPR) = AM_REG_TPIU_SPPR_TXMODE_UART; // // Make sure we are not in test mode (important for proper deep sleep // operation). // AM_REG(TPIU, ITCTRL) = AM_REG_TPIU_ITCTRL_MODE_NORMAL; // // Enable the TPIU clock source in MCU control. // Set TPIU clock for HFRC/8 (6 or 3 MHz) operation. // AM_REGn(MCUCTRL, 0, TPIUCTRL) = AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_HFRC_DIV_8 | AM_REG_MCUCTRL_TPIUCTRL_ENABLE_EN; } else { // // Set the configuration according to the structure values. // // // Set the Asynchronous Clock Prescaler Register. // AM_REG(TPIU, ACPR) = psConfig->ui32ClockPrescaler; // // Set the Selected Pin Protocol Register. // e.g. AM_REG_TPIU_SPPR_TXMODE_UART // AM_REG(TPIU, SPPR) = psConfig->ui32PinProtocol; // // Set the Current Parallel Port Size (note - only 1 bit can be set). // This may be redundant if the user has selected a serial protocol, // but we'll set it anyway. // AM_REG(TPIU, CSPSR) = (1 << (psConfig->ui32ParallelPortSize - 1)); // // Set the clock freq in the MCUCTRL register. // AM_REG(MCUCTRL, TPIUCTRL) |= psConfig->ui32TraceClkIn; } // // Wait for 50us for the data to flush out. // am_hal_flash_delay(FLASH_CYCLES_US(50)); } //***************************************************************************** // //! @brief Disables the TPIU //! //! This function disables the ARM TPIU by disabling the TPIU clock source //! in MCU control register. //! //! @return None. // //***************************************************************************** void am_hal_tpiu_disable(void) { // // Disable the TPIU clock source in MCU control. // AM_REG(MCUCTRL, TPIUCTRL) = AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_0MHz | AM_REG_MCUCTRL_TPIUCTRL_ENABLE_DIS; } //***************************************************************************** // // End Doxygen group. //! @} // //*****************************************************************************
ad1be73c3e1f108e23ccb632b2e412dc0ac944b3
c31767d5d5d7f9267a2607bbddd261a72cc9a6f6
/runtime/tmplib/uaccess.h
02e155f8ab27a7e8bb775f4b53c9e090602416df
[ "LicenseRef-scancode-bsd-3-clause-jtag", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
keystone-enclave/keystone
39986d7d4d7f1f651a77ccf338ac0ebaf2744a55
9b9dd5a015cc77725b3576441f589c3ea2c7ced0
refs/heads/master
2023-09-03T15:18:31.943293
2023-08-30T02:28:55
2023-08-30T02:28:55
137,123,646
409
136
NOASSERTION
2023-09-09T00:28:40
2018-06-12T20:23:19
C
UTF-8
C
false
false
1,382
h
uaccess.h
#ifndef _UACCESS_H_ #define _UACCESS_H_ #include <asm/asm.h> #include <asm/csr.h> /* This is a limited set of the features from linux uaccess, only the ones we need for now */ extern unsigned long __asm_copy_to_user(void *to, const void *from, unsigned long n); extern unsigned long __asm_copy_from_user(void *to, const void *from, unsigned long n); static inline unsigned long copy_to_user(void *to, const void *from, unsigned long n) { return __asm_copy_to_user(to, from, n); } static inline unsigned long copy_from_user(void *to, const void *from, unsigned long n) { return __asm_copy_from_user(to, from, n); } /* Dangerous feature needed for a few things (ex: strlen on usermemory) */ #define ALLOW_USER_ACCESS(x) \ { \ unsigned long tmp_storage; \ __asm__ volatile("li %0, %1" : "=r"(tmp_storage) : "i"(SR_SUM)); \ __asm__ volatile("csrs sstatus, %0" : "=r"(tmp_storage)); \ (x); \ __asm__ volatile("li %0, %1" : "=r"(tmp_storage) : "i"(SR_SUM)); \ __asm__ volatile("csrc sstatus, %0" : "=r"(tmp_storage)); \ } #endif /* _UACCESS_H_ */
6e754335cf0733f535c48ff8d92f8a18ea84b793
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/lang/newsqueak/patches/patch-squint_lex.c
5dcfbc5944c6b1129d18da9b6f47df44c828a7e3
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
840
c
patch-squint_lex.c
$NetBSD: patch-squint_lex.c,v 1.1 2015/04/25 19:58:32 dholland Exp $ Use $PREFIX instead of Rob's homedir. Muck with fmtinstall to avoid doing undefined/illegal things with va_list. --- squint/lex.c.orig 2000-02-11 17:04:41.000000000 +0000 +++ squint/lex.c @@ -349,7 +349,7 @@ newfile(char *s, int stdin) char buf[1024]; fd=open(s, 0); if(fd<0 && s[0]!='/' && s[0]!='.'){ - sprint(buf, "/usr/rob/src/squint/include/%s", s); + sprint(buf, PREFIX "/share/squint/include/%s", s); fd=open(buf, 0); } if(fd<0) @@ -381,14 +381,14 @@ printfileline(char *buf, File *f, int l, } int -zconv(va_list *va, Fconv *f) +zconv(struct va_wrap *va, Fconv *f) { int o; char buf[4096]; SET(o); if(f->chr == 'Z') - o = va_arg(*va, int); + o = va_arg(va->ap, int); if(initializing) strcpy(buf, "squint: "); else{
8e7dd33cdfdf51a6a456ee0678567460ea547d0a
5fdaec353b93b273d117c5ef1ca7d2352f4bad4b
/test/largebounds.c
6d97ded69b60dcdd34def116590cb7b40c119f03
[ "MIT" ]
permissive
bondhugula/pluto
1ddf0bf53dc8a9c50f895018b2810558441e85f3
eddc38537d61cd49d55e454831086848d51473d7
refs/heads/master
2023-07-21T19:53:05.377621
2023-06-21T09:22:57
2023-07-15T03:50:17
76,021,818
242
68
MIT
2023-07-15T03:50:18
2016-12-09T09:35:40
C
UTF-8
C
false
false
601
c
largebounds.c
#pragma scop for (x = 0; x < 10000; x = x + 1) { for (y = 0; y < 10000; y = y + 1) { green[x][y] = x + y; } } for (x = 0; x < 10000; x = x + 1) { for (y = 0; y < 10000; y = y + 1) { red[x][y] = x + y; } } for (x = 0; x < 10000; x = x + 1) { for (y = 0; y < 10000; y = y + 1) { red[x][y] = diff(red[x][y], green[x][y]); } } for (x = 1; x < 4999; x += 1) { for (y = 1; y < 4999; y += 1) { red[2 * x + 1][2 * y + 1] = RBK_3x3_1(red[2 * x][2 * y], red[2 * x][2 * y + 2], red[2 * x + 2][2 * y], red[2 * x + 2][2 * y + 2]); } } #pragma endscop
6c73a6c63b6f916862806e62e1849415e8572237
f4ea6db9183b38e0cb1af1d317b0a02db24455d1
/test/t-0000486.c
9fbb5baca9a827143aeb38798f51789fe78ef8d2
[ "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
ldmud/ldmud
1446ff7101f5a47ee1dfa4cfb97d5a326f2edcce
f1cfc9a8d911412d854055058889bb32432da2db
refs/heads/master
2023-05-25T00:36:28.318383
2023-02-14T21:07:35
2023-02-18T10:20:44
1,085,012
124
71
NOASSERTION
2023-09-01T16:54:48
2010-11-16T12:13:17
C
UTF-8
C
false
false
485
c
t-0000486.c
#include "/inc/base.inc" #include "/inc/gc.inc" #include "/inc/client.inc" /* These functions are for the blueprint (the virtual player that sends us the commands). */ void run_server() { catch(efun::input_to("bla",4,({1}),({2}))); start_gc(#'shutdown); return 0; } void run_test() { msg("\nRunning test for #0000486:\n" "--------------------------\n"); connect_self("run_server", 0); } string *epilog(int eflag) { run_test(); return 0; }
22cf71ac86e4d4c28241c4563e57a30e1c4374ba
ea9ac7578bc8a8fc83377f651b80e19920338fda
/src/mesa/drivers/dri/i965/gen7_l3_state.c
8c6c4c47481ec34ab1d90e571e8befe036059dc5
[]
no_license
yuq/mesa-lima
9d263945e23118c7aa997bb9fcb87ae6bf7ddf0d
2adeaa87e813644dcf70f903c0ac909d65ef2972
refs/heads/lima-18.1
2021-01-25T11:03:44.405200
2018-05-27T12:53:15
2018-05-27T12:53:15
93,909,976
186
21
null
2018-06-05T01:32:44
2017-06-10T02:07:43
C
UTF-8
C
false
false
13,727
c
gen7_l3_state.c
/* * Copyright (c) 2015 Intel Corporation * * 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 (including the next * paragraph) 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. */ #include "common/gen_l3_config.h" #include "brw_context.h" #include "brw_defines.h" #include "brw_state.h" #include "intel_batchbuffer.h" /** * Calculate the desired L3 partitioning based on the current state of the * pipeline. For now this simply returns the conservative defaults calculated * by get_default_l3_weights(), but we could probably do better by gathering * more statistics from the pipeline state (e.g. guess of expected URB usage * and bound surfaces), or by using feed-back from performance counters. */ static struct gen_l3_weights get_pipeline_state_l3_weights(const struct brw_context *brw) { const struct brw_stage_state *stage_states[] = { [MESA_SHADER_VERTEX] = &brw->vs.base, [MESA_SHADER_TESS_CTRL] = &brw->tcs.base, [MESA_SHADER_TESS_EVAL] = &brw->tes.base, [MESA_SHADER_GEOMETRY] = &brw->gs.base, [MESA_SHADER_FRAGMENT] = &brw->wm.base, [MESA_SHADER_COMPUTE] = &brw->cs.base }; bool needs_dc = false, needs_slm = false; for (unsigned i = 0; i < ARRAY_SIZE(stage_states); i++) { const struct gl_program *prog = brw->ctx._Shader->CurrentProgram[stage_states[i]->stage]; const struct brw_stage_prog_data *prog_data = stage_states[i]->prog_data; needs_dc |= (prog && (prog->sh.data->NumAtomicBuffers || prog->sh.data->NumShaderStorageBlocks || prog->info.num_images)) || (prog_data && prog_data->total_scratch); needs_slm |= prog_data && prog_data->total_shared; } return gen_get_default_l3_weights(&brw->screen->devinfo, needs_dc, needs_slm); } /** * Program the hardware to use the specified L3 configuration. */ static void setup_l3_config(struct brw_context *brw, const struct gen_l3_config *cfg) { const struct gen_device_info *devinfo = &brw->screen->devinfo; const bool has_dc = cfg->n[GEN_L3P_DC] || cfg->n[GEN_L3P_ALL]; const bool has_is = cfg->n[GEN_L3P_IS] || cfg->n[GEN_L3P_RO] || cfg->n[GEN_L3P_ALL]; const bool has_c = cfg->n[GEN_L3P_C] || cfg->n[GEN_L3P_RO] || cfg->n[GEN_L3P_ALL]; const bool has_t = cfg->n[GEN_L3P_T] || cfg->n[GEN_L3P_RO] || cfg->n[GEN_L3P_ALL]; const bool has_slm = cfg->n[GEN_L3P_SLM]; /* According to the hardware docs, the L3 partitioning can only be changed * while the pipeline is completely drained and the caches are flushed, * which involves a first PIPE_CONTROL flush which stalls the pipeline... */ brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DATA_CACHE_FLUSH | PIPE_CONTROL_CS_STALL); /* ...followed by a second pipelined PIPE_CONTROL that initiates * invalidation of the relevant caches. Note that because RO invalidation * happens at the top of the pipeline (i.e. right away as the PIPE_CONTROL * command is processed by the CS) we cannot combine it with the previous * stalling flush as the hardware documentation suggests, because that * would cause the CS to stall on previous rendering *after* RO * invalidation and wouldn't prevent the RO caches from being polluted by * concurrent rendering before the stall completes. This intentionally * doesn't implement the SKL+ hardware workaround suggesting to enable CS * stall on PIPE_CONTROLs with the texture cache invalidation bit set for * GPGPU workloads because the previous and subsequent PIPE_CONTROLs * already guarantee that there is no concurrent GPGPU kernel execution * (see SKL HSD 2132585). */ brw_emit_pipe_control_flush(brw, PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | PIPE_CONTROL_CONST_CACHE_INVALIDATE | PIPE_CONTROL_INSTRUCTION_INVALIDATE | PIPE_CONTROL_STATE_CACHE_INVALIDATE); /* Now send a third stalling flush to make sure that invalidation is * complete when the L3 configuration registers are modified. */ brw_emit_pipe_control_flush(brw, PIPE_CONTROL_DATA_CACHE_FLUSH | PIPE_CONTROL_CS_STALL); if (devinfo->gen >= 8) { assert(!cfg->n[GEN_L3P_IS] && !cfg->n[GEN_L3P_C] && !cfg->n[GEN_L3P_T]); const unsigned imm_data = ((has_slm ? GEN8_L3CNTLREG_SLM_ENABLE : 0) | SET_FIELD(cfg->n[GEN_L3P_URB], GEN8_L3CNTLREG_URB_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_RO], GEN8_L3CNTLREG_RO_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_DC], GEN8_L3CNTLREG_DC_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_ALL], GEN8_L3CNTLREG_ALL_ALLOC)); /* Set up the L3 partitioning. */ brw_load_register_imm32(brw, GEN8_L3CNTLREG, imm_data); } else { assert(!cfg->n[GEN_L3P_ALL]); /* When enabled SLM only uses a portion of the L3 on half of the banks, * the matching space on the remaining banks has to be allocated to a * client (URB for all validated configurations) set to the * lower-bandwidth 2-bank address hashing mode. */ const bool urb_low_bw = has_slm && !devinfo->is_baytrail; assert(!urb_low_bw || cfg->n[GEN_L3P_URB] == cfg->n[GEN_L3P_SLM]); /* Minimum number of ways that can be allocated to the URB. */ const unsigned n0_urb = (devinfo->is_baytrail ? 32 : 0); assert(cfg->n[GEN_L3P_URB] >= n0_urb); BEGIN_BATCH(7); OUT_BATCH(MI_LOAD_REGISTER_IMM | (7 - 2)); /* Demote any clients with no ways assigned to LLC. */ OUT_BATCH(GEN7_L3SQCREG1); OUT_BATCH((devinfo->is_haswell ? HSW_L3SQCREG1_SQGHPCI_DEFAULT : devinfo->is_baytrail ? VLV_L3SQCREG1_SQGHPCI_DEFAULT : IVB_L3SQCREG1_SQGHPCI_DEFAULT) | (has_dc ? 0 : GEN7_L3SQCREG1_CONV_DC_UC) | (has_is ? 0 : GEN7_L3SQCREG1_CONV_IS_UC) | (has_c ? 0 : GEN7_L3SQCREG1_CONV_C_UC) | (has_t ? 0 : GEN7_L3SQCREG1_CONV_T_UC)); /* Set up the L3 partitioning. */ OUT_BATCH(GEN7_L3CNTLREG2); OUT_BATCH((has_slm ? GEN7_L3CNTLREG2_SLM_ENABLE : 0) | SET_FIELD(cfg->n[GEN_L3P_URB] - n0_urb, GEN7_L3CNTLREG2_URB_ALLOC) | (urb_low_bw ? GEN7_L3CNTLREG2_URB_LOW_BW : 0) | SET_FIELD(cfg->n[GEN_L3P_ALL], GEN7_L3CNTLREG2_ALL_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_RO], GEN7_L3CNTLREG2_RO_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_DC], GEN7_L3CNTLREG2_DC_ALLOC)); OUT_BATCH(GEN7_L3CNTLREG3); OUT_BATCH(SET_FIELD(cfg->n[GEN_L3P_IS], GEN7_L3CNTLREG3_IS_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_C], GEN7_L3CNTLREG3_C_ALLOC) | SET_FIELD(cfg->n[GEN_L3P_T], GEN7_L3CNTLREG3_T_ALLOC)); ADVANCE_BATCH(); if (can_do_hsw_l3_atomics(brw->screen)) { /* Enable L3 atomics on HSW if we have a DC partition, otherwise keep * them disabled to avoid crashing the system hard. */ BEGIN_BATCH(5); OUT_BATCH(MI_LOAD_REGISTER_IMM | (5 - 2)); OUT_BATCH(HSW_SCRATCH1); OUT_BATCH(has_dc ? 0 : HSW_SCRATCH1_L3_ATOMIC_DISABLE); OUT_BATCH(HSW_ROW_CHICKEN3); OUT_BATCH(REG_MASK(HSW_ROW_CHICKEN3_L3_ATOMIC_DISABLE) | (has_dc ? 0 : HSW_ROW_CHICKEN3_L3_ATOMIC_DISABLE)); ADVANCE_BATCH(); } } } /** * Update the URB size in the context state for the specified L3 * configuration. */ static void update_urb_size(struct brw_context *brw, const struct gen_l3_config *cfg) { const struct gen_device_info *devinfo = &brw->screen->devinfo; const unsigned sz = gen_get_l3_config_urb_size(devinfo, cfg); if (brw->urb.size != sz) { brw->urb.size = sz; brw->ctx.NewDriverState |= BRW_NEW_URB_SIZE; /* If we change the total URB size, reset the individual stage sizes to * zero so that, even if there is no URB size change, gen7_upload_urb * still re-emits 3DSTATE_URB_*. */ brw->urb.vsize = 0; brw->urb.gsize = 0; brw->urb.hsize = 0; brw->urb.dsize = 0; } } static void emit_l3_state(struct brw_context *brw) { const struct gen_l3_weights w = get_pipeline_state_l3_weights(brw); const float dw = gen_diff_l3_weights(w, gen_get_l3_config_weights(brw->l3.config)); /* The distance between any two compatible weight vectors cannot exceed two * due to the triangle inequality. */ const float large_dw_threshold = 2.0; /* Somewhat arbitrary, simply makes sure that there will be no repeated * transitions to the same L3 configuration, could probably do better here. */ const float small_dw_threshold = 0.5; /* If we're emitting a new batch the caches should already be clean and the * transition should be relatively cheap, so it shouldn't hurt much to use * the smaller threshold. Otherwise use the larger threshold so that we * only reprogram the L3 mid-batch if the most recently programmed * configuration is incompatible with the current pipeline state. */ const float dw_threshold = (brw->ctx.NewDriverState & BRW_NEW_BATCH ? small_dw_threshold : large_dw_threshold); if (dw > dw_threshold && can_do_pipelined_register_writes(brw->screen)) { const struct gen_l3_config *const cfg = gen_get_l3_config(&brw->screen->devinfo, w); setup_l3_config(brw, cfg); update_urb_size(brw, cfg); brw->l3.config = cfg; if (unlikely(INTEL_DEBUG & DEBUG_L3)) { fprintf(stderr, "L3 config transition (%f > %f): ", dw, dw_threshold); gen_dump_l3_config(cfg, stderr); } } } const struct brw_tracked_state gen7_l3_state = { .dirty = { .mesa = 0, .brw = BRW_NEW_BATCH | BRW_NEW_BLORP | BRW_NEW_CS_PROG_DATA | BRW_NEW_FS_PROG_DATA | BRW_NEW_GS_PROG_DATA | BRW_NEW_TCS_PROG_DATA | BRW_NEW_TES_PROG_DATA | BRW_NEW_VS_PROG_DATA, }, .emit = emit_l3_state }; /** * Hack to restore the default L3 configuration. * * This will be called at the end of every batch in order to reset the L3 * configuration to the default values for the time being until the kernel is * fixed. Until kernel commit 6702cf16e0ba8b0129f5aa1b6609d4e9c70bc13b * (included in v4.1) we would set the MI_RESTORE_INHIBIT bit when submitting * batch buffers for the default context used by the DDX, which meant that any * context state changed by the GL would leak into the DDX, the assumption * being that the DDX would initialize any state it cares about manually. The * DDX is however not careful enough to program an L3 configuration * explicitly, and it makes assumptions about it (URB size) which won't hold * and cause it to misrender if we let our L3 set-up to leak into the DDX. * * Since v4.1 of the Linux kernel the default context is saved and restored * normally, so it's far less likely for our L3 programming to interfere with * other contexts -- In fact restoring the default L3 configuration at the end * of the batch will be redundant most of the time. A kind of state leak is * still possible though if the context making assumptions about L3 state is * created immediately after our context was active (e.g. without the DDX * default context being scheduled in between) because at present the DRM * doesn't fully initialize the contents of newly created contexts and instead * sets the MI_RESTORE_INHIBIT flag causing it to inherit the state from the * last active context. * * It's possible to realize such a scenario if, say, an X server (or a GL * application using an outdated non-L3-aware Mesa version) is started while * another GL application is running and happens to have modified the L3 * configuration, or if no X server is running at all and a GL application * using a non-L3-aware Mesa version is started after another GL application * ran and modified the L3 configuration -- The latter situation can actually * be reproduced easily on IVB in our CI system. */ void gen7_restore_default_l3_config(struct brw_context *brw) { const struct gen_device_info *devinfo = &brw->screen->devinfo; const struct gen_l3_config *const cfg = gen_get_default_l3_config(devinfo); if (cfg != brw->l3.config && can_do_pipelined_register_writes(brw->screen)) { setup_l3_config(brw, cfg); update_urb_size(brw, cfg); brw->l3.config = cfg; } }
dbbd40adc7764ee96c05af1e96d35f0a254847ef
544a8f2110fc156ec0bc7554e3857cc1b431084f
/rflib/rflib_m0.c
dbd5bfc79eb93aa7a819f6b8e2def64296ddfbc4
[]
no_license
rad1o/f1rmware
7288bf3714f12da7829008853e011ce5b32c673c
eda4f0b9095be4dabb8476de9cef21d9614f16fb
refs/heads/master
2022-11-03T20:20:30.220203
2022-10-26T20:01:13
2022-10-26T20:01:31
37,091,288
190
135
null
2022-10-26T19:57:25
2015-06-08T20:34:46
C
UTF-8
C
false
false
8,008
c
rflib_m0.c
/******************************************************************************* * RFlib_M0 * * interface for RF handling, uses M0 core for offloading lots of operations. * * (c) 2015 Hans-Werner Hilse (@hilse) * * This program 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 2, 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #include <string.h> #include <libopencm3/lpc43xx/m4/nvic.h> #include <libopencm3/lpc43xx/ipc.h> #include <libopencm3/lpc43xx/creg.h> #include <libopencm3/cm3/vector.h> #include <r0ketlib/display.h> #include <rad1olib/pins.h> #include <libopencm3/lpc43xx/scu.h> #include <libopencm3/lpc43xx/gpio.h> #include "m0_bin.h" #include "m0/m0rxtx.h" /* this flag will get set back to false when a transfer is finished */ static volatile bool transmitting = false; /* this flag indicates which mode should be started when a transfer is finished */ static volatile uint32_t mode_after_transmit = MODE_STANDBY; /* handler function to call for rx data */ static void (*rx_handler)() = NULL; /* this flag will indicate that RF setup is due, using the SPI bus * (amongst others), so this can be used to avoid with M4 code using * the same chipset devices. */ static volatile bool in_rf_setup = false; /* flag that indicates whether we await M0 core acknowledgement */ static volatile bool m0_wait_for_ack = false; /* send a command to the M0 core * * do not wait for acknowledgement when this is called from ISR context, since * the acknowledgement will be delivered using the same interrupt mechanism * that is still handling the previous interrupt request, so it would * deadlock. */ static void send_cmd(const uint32_t cmd, const uint32_t arg, const uint32_t arg2, const uint32_t arg3, const bool wait_for_ack) { *m0_command = cmd; *m0_arg = arg; *m0_arg2 = arg2; *m0_arg3 = arg3; m0_wait_for_ack = wait_for_ack; /* send an interrupt to the other core(s) */ __asm volatile("dsb \n sev" : : : "memory"); while(m0_wait_for_ack == true) { /* wait until command has been handled */ __asm__ volatile ("nop"); } } /* interrupt handler: */ static void rflib_m0_isr() { CREG_M0TXEVENT = 0; /* clear interrupt flag */ nvic_clear_pending_irq(NVIC_M0CORE_IRQ); switch(*m0_ack) { case ACK_NOTIFY_RX: if(rx_handler != NULL) (*rx_handler)(); break; case ACK_TX_DONE: transmitting = false; if(mode_after_transmit != MODE_STANDBY) { in_rf_setup = true; } send_cmd(CMD_SET_MODE, mode_after_transmit, 0, 0, false); break; case ACK_TX_ABORTED: /* this will happen when switching to another mode * during TX, so don't set the after-transmit mode * here */ transmitting = false; break; case ACK_RF_SETUP: in_rf_setup = false; break; case ACK_COMMAND_DONE: m0_wait_for_ack = false; break; } } void rflib_wait_for_rfsetup() { while(in_rf_setup) { __asm__ volatile("nop"); } } void rflib_lcdDisplay() { while(in_rf_setup) { __asm__ volatile("nop"); } lcdDisplay(); } void rflib_set_freq(const int64_t freq) { const uint32_t f2 = freq & 0xFFFFFFFF; const uint32_t f1 = freq >> 32; send_cmd(CMD_SET_FREQ, f1, f2, 0, true); } void rflib_set_bbamp(const int lna_gain_db, const int vga_gain_db, const int txvga_gain_db) { send_cmd(CMD_SET_BBAMP, lna_gain_db, vga_gain_db, txvga_gain_db, true); } void rflib_set_rxlna(const int enable) { send_cmd(CMD_SET_RXLNA, enable, 0, 0, true); } void rflib_set_txlna(const int enable) { send_cmd(CMD_SET_TXLNA, enable, 0, 0, true); } void rflib_set_rxsamplerate(const int samplerate) { send_cmd(CMD_SET_RXSAMPLERATE, samplerate, 0, 0, true); } void rflib_set_rxdecimation(const int decimation) { send_cmd(CMD_SET_RXDECIMATION, decimation, 0, 0, true); } void rflib_set_rxbandwidth(const int bandwidth) { send_cmd(CMD_SET_RXBANDWIDTH, bandwidth, 0, 0, true); } void rflib_set_txsamplerate(const int samplerate) { send_cmd(CMD_SET_TXSAMPLERATE, samplerate, 0, 0, true); } void rflib_set_txbandwidth(const int bandwidth) { send_cmd(CMD_SET_TXBANDWIDTH, bandwidth, 0, 0, true); } /********************************* BFSK **********************************/ /* interrupt handler: * * M0 signals that there's RX data ready to be read */ static volatile bool rx_pkg_flag = false; int rflib_bfsk_get_packet(uint8_t* const data, const int max_len) { if(!rx_pkg_flag) return -1; rx_pkg_flag = false; int read_len = ((uint8_t*)*rx_bank_ready)[0]; if(read_len > max_len) read_len = max_len; memcpy(data, (uint8_t*)*rx_bank_ready + 1, max_len); return read_len; } static void rxlib_receive_handler() { rx_pkg_flag = true; } void rflib_bfsk_init() { rflib_set_rxsamplerate(1000000); rflib_set_rxdecimation(2); rflib_set_rxbandwidth(1750000); rflib_set_txsamplerate(4000000); rflib_set_txbandwidth(1750000); } void rflib_bfsk_receive() { while(transmitting) { __asm__ volatile ("nop"); }; rx_handler = rxlib_receive_handler; in_rf_setup = true; send_cmd(CMD_SET_MODE, MODE_RECEIVE_BFSK, 0, 0, true); } void rflib_bfsk_transmit(uint8_t* const data, const uint16_t length, const bool continue_receive) { /* wait for completion of last transfer */ while(transmitting) { __asm__ volatile ("nop"); }; transmitting = true; if(continue_receive) { mode_after_transmit = MODE_RECEIVE_BFSK; rx_handler = rxlib_receive_handler; } /* copy packet data to M0 handled buffer */ memcpy((uint8_t*) tx_data, data, length); tx_len[0] = length; in_rf_setup = true; send_cmd(CMD_SET_MODE, MODE_TRANSMIT_BFSK, 0, 0, true); } /*************************************************************************/ int rflib_get_data(int16_t* const data, const int max_len) { if(!rx_pkg_flag) return -1; rx_pkg_flag = false; int read_len = RX_BANK_SIZE; if(RX_BANK_SIZE > max_len) read_len = max_len; memcpy((uint8_t*) data, (uint8_t*) *rx_bank_ready, read_len); return read_len; } void rflib_freq_receive() { while(transmitting) { __asm__ volatile ("nop"); }; rx_handler = rxlib_receive_handler; in_rf_setup = true; send_cmd(CMD_SET_MODE, MODE_RECEIVE_FREQ, 0, 0, true); } void rflib_raw_receive() { while(transmitting) { __asm__ volatile ("nop"); }; rx_handler = rxlib_receive_handler; in_rf_setup = true; send_cmd(CMD_SET_MODE, MODE_RECEIVE, 0, 0, true); } /*************************************************************************/ void rflib_init() { vector_table.irq[NVIC_M0CORE_IRQ] = rflib_m0_isr; nvic_set_priority(NVIC_M0CORE_IRQ, 1); nvic_enable_irq(NVIC_M0CORE_IRQ); ipc_halt_m0(); m0_wait_for_ack = true; unsigned char *cm0 = (unsigned char*) cm0_exec_baseaddr; for(int i=0; i<m0_bin_size; i++) cm0[i] = m0_bin[i]; ipc_start_m0((uintptr_t)cm0_exec_baseaddr); while(m0_wait_for_ack == true) { /* wait until command has been handled */ __asm__ volatile ("nop"); } } void rflib_shutdown() { send_cmd(CMD_SET_MODE, MODE_OFF, 0, 0, true); nvic_disable_irq(NVIC_M0CORE_IRQ); ipc_halt_m0(); }
a81c6ba535b1d7ee4c79db0e86c354fe1f254c12
30c2631ed046d7662476b94fb7f5286c47377f60
/test/api/src/FixedHierarchies.c
5a1b481ca2c184d6e0b70386eb572f2983330c99
[ "MIT" ]
permissive
SanderMertens/flecs
a840093340f0d1eb2bd30ec1585296f81f2aab39
41fb856c4e1162f44b59d7881ef508d64d56bf10
refs/heads/master
2023-08-24T16:21:41.790084
2023-08-24T08:38:57
2023-08-24T08:49:52
146,155,284
4,731
456
MIT
2023-09-05T16:01:58
2018-08-26T05:53:05
C
UTF-8
C
false
false
149,910
c
FixedHierarchies.c
#include <api.h> void FixedHierarchies_make_fixed_1_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_w_init(void) { ecs_world_t *world = ecs_init(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_w_init_comp(void) { ecs_world_t *world = ecs_init(); ECS_COMPONENT(world, Position); ecs_set_hooks(world, Position, { .ctor = ecs_default_ctor }); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1_1, Position, {10, 20}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2_1, Position, {30, 40}); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); { const Position *p = ecs_get(world, p_1_1, Position); test_assert(p != NULL); test_int(p->x, 10); test_int(p->y, 20); } { const Position *p = ecs_get(world, p_2_1, Position); test_assert(p != NULL); test_int(p->x, 30); test_int(p->y, 40); } ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_w_init_comp_after_tree_fixed(void) { ecs_world_t *world = ecs_init(); ECS_COMPONENT(world, Position); ecs_set_hooks(world, Position, { .ctor = ecs_default_ctor }); ecs_entity_t rel = ecs_new_id(world); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1_1, Position, {10, 20}); ecs_set_pair_second(world, p_1_1, rel, Position, {100, 200}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2_1, Position, {30, 40}); ecs_set_pair_second(world, p_2_1, rel, Position, {300, 400}); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); { const Position *p = ecs_get(world, p_1_1, Position); test_assert(p != NULL); test_int(p->x, 10); test_int(p->y, 20); } { const Position *p = ecs_get(world, p_2_1, Position); test_assert(p != NULL); test_int(p->x, 30); test_int(p->y, 40); } ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_2_entities(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_2 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_2 = ecs_new_w_pair(world, EcsChildOf, p_2); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_1_2)); test_assert(ecs_get_table(world, p_2_1) == ecs_get_table(world, p_2_2)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_2, EcsChildOf, 0) == p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_1_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_2)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_2, EcsChildOf, 0) == p_2); ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_2_tables(void) { ecs_world_t *world = ecs_mini(); ECS_TAG(world, Tag); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_2 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_add(world, p_1_2, Tag); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_2 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_add(world, p_2_2, Tag); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_2) != ecs_get_table(world, p_2_2)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_2, EcsChildOf, 0) == p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_2) == ecs_get_table(world, p_2_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_1_2)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_2, EcsChildOf, 0) == p_2); test_assert(ecs_has(world, p_1_2, Tag)); test_assert(ecs_has(world, p_2_2, Tag)); ecs_fini(world); } void FixedHierarchies_make_fixed_2_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); ecs_fini(world); } void FixedHierarchies_make_fixed_2_lvl_2_tables(void) { ecs_world_t *world = ecs_mini(); ECS_TAG(world, Tag); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_1_1_2 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_add(world, p_1_1_2, Tag); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_entity_t p_2_1_2 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_add(world, p_2_1_2, Tag); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_1_2)); test_assert(ecs_get_table(world, p_2_1_1) != ecs_get_table(world, p_2_1_2)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_2) == ecs_get_table(world, p_2_1_2)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_1_2)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_has(world, p_1_1_2, Tag)); test_assert(ecs_has(world, p_2_1_2, Tag)); ecs_fini(world); } void FixedHierarchies_make_fixed_3_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_1_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_entity_t p_2_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1_1); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); ecs_fini(world); } void FixedHierarchies_make_fixed_3_lvl_w_name(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_1_1 = ecs_new_entity(world, "p._1._1._1"); ecs_entity_t p_1_1_1_1 = ecs_new_entity(world, "p._1._1._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_entity_t p_2_1_1 = ecs_new_entity(world, "p._2._1._1"); ecs_entity_t p_2_1_1_1 = ecs_new_entity(world, "p._2._1._1._1"); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); ecs_fini(world); } void FixedHierarchies_make_fixed_3_2_lvl_w_name(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_1_1 = ecs_new_entity(world, "p._1._1._1"); ecs_entity_t p_1_1_1_1 = ecs_new_entity(world, "p._1._1._1._1"); ecs_entity_t p_1_1_2 = ecs_new_entity(world, "p._1._1._2"); ecs_entity_t p_1_1_2_1 = ecs_new_entity(world, "p._1._1._2._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_entity_t p_2_1_1 = ecs_new_entity(world, "p._2._1._1"); ecs_entity_t p_2_1_1_1 = ecs_new_entity(world, "p._2._1._1._1"); ecs_entity_t p_2_1_2 = ecs_new_entity(world, "p._2._1._2"); ecs_entity_t p_2_1_2_1 = ecs_new_entity(world, "p._2._1._2._1"); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1_1) != ecs_get_table(world, p_1_1_2_1)); test_assert(ecs_get_table(world, p_2_1_1_1) != ecs_get_table(world, p_2_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_1_1_2_1, EcsChildOf, 0) == p_1_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); test_assert(ecs_get_target(world, p_2_1_2_1, EcsChildOf, 0) == p_2_1_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1_1) == ecs_get_table(world, p_1_1_2_1)); test_assert(ecs_get_table(world, p_2_1_1_1) == ecs_get_table(world, p_2_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_1_1_2_1, EcsChildOf, 0) == p_1_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); test_assert(ecs_get_target(world, p_2_1_2_1, EcsChildOf, 0) == p_2_1_2); ecs_fini(world); } void FixedHierarchies_make_fixed_2_lvl_nested(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_1_1 = ecs_new_entity(world, "p._1._1._1"); ecs_entity_t p_1_1_2 = ecs_new_entity(world, "p._1._1._2"); ecs_entity_t p_1_2 = ecs_new_entity(world, "p._1._2"); ecs_entity_t p_1_2_1 = ecs_new_entity(world, "p._1._2._1"); ecs_entity_t p_1_2_2 = ecs_new_entity(world, "p._1._2._2"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_entity_t p_2_1_1 = ecs_new_entity(world, "p._2._1._1"); ecs_entity_t p_2_1_2 = ecs_new_entity(world, "p._2._1._2"); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_1_2)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_2_2) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_2_1, EcsChildOf, 0) == p_1_2); test_assert(ecs_get_target(world, p_1_2_2, EcsChildOf, 0) == p_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p_1), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_1_2)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_2_2) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_2_1, EcsChildOf, 0) == p_1_2); test_assert(ecs_get_target(world, p_1_2_2, EcsChildOf, 0) == p_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_1_2)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_2_2) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_2_1, EcsChildOf, 0) == p_1_2); test_assert(ecs_get_target(world, p_1_2_2, EcsChildOf, 0) == p_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); ecs_fini(world); } void FixedHierarchies_make_fixed_3_lvl_nested(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_1_1 = ecs_new_entity(world, "p._1._1._1"); ecs_entity_t p_1_1_1_1 = ecs_new_entity(world, "p._1._1._1._1"); ecs_entity_t p_1_1_2 = ecs_new_entity(world, "p._1._1._2"); ecs_entity_t p_1_1_2_1 = ecs_new_entity(world, "p._1._1._2._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_entity_t p_2_1_1 = ecs_new_entity(world, "p._2._1._1"); ecs_entity_t p_2_1_1_1 = ecs_new_entity(world, "p._2._1._1._1"); ecs_entity_t p_2_1_2 = ecs_new_entity(world, "p._2._1._2"); ecs_entity_t p_2_1_2_1 = ecs_new_entity(world, "p._2._1._2._1"); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1_1) != ecs_get_table(world, p_1_1_2_1)); test_assert(ecs_get_table(world, p_2_1_1_1) != ecs_get_table(world, p_2_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_1_1_2_1, EcsChildOf, 0) == p_1_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); test_assert(ecs_get_target(world, p_2_1_2_1, EcsChildOf, 0) == p_2_1_2); ecs_flatten(world, ecs_pair(EcsChildOf, p_1_1), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1_1) == ecs_get_table(world, p_1_1_2_1)); test_assert(ecs_get_table(world, p_2_1_1_1) != ecs_get_table(world, p_2_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_1_1_2_1, EcsChildOf, 0) == p_1_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); test_assert(ecs_get_target(world, p_2_1_2_1, EcsChildOf, 0) == p_2_1_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1_1) == ecs_get_table(world, p_1_1_2_1)); test_assert(ecs_get_table(world, p_2_1_1_1) == ecs_get_table(world, p_2_1_2_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_2, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_1_1_2_1, EcsChildOf, 0) == p_1_1_2); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_2, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); test_assert(ecs_get_target(world, p_2_1_2_1, EcsChildOf, 0) == p_2_1_2); ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_after_delete(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_2 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_3 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_4 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_delete(world, p_1_3); ecs_delete(world, p_1_4); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); test_assert(!ecs_is_alive(world, p_1_3)); test_assert(!ecs_is_alive(world, p_1_4)); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_2, EcsChildOf, 0) == p_1); ecs_fini(world); } void FixedHierarchies_get_target_1_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_uint(ecs_get_target(world, p, EcsChildOf, 0), 0); test_uint(ecs_get_target(world, p_1, EcsChildOf, 0), p); test_uint(ecs_get_target(world, p_2, EcsChildOf, 0), p); test_uint(ecs_get_target(world, p_1_1, EcsChildOf, 0), p_1); test_uint(ecs_get_target(world, p_2_1, EcsChildOf, 0), p_2); ecs_fini(world); } void FixedHierarchies_get_target_2_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_uint(ecs_get_target(world, p, EcsChildOf, 0), 0); test_uint(ecs_get_target(world, p_1, EcsChildOf, 0), p); test_uint(ecs_get_target(world, p_2, EcsChildOf, 0), p); test_uint(ecs_get_target(world, p_1_1, EcsChildOf, 0), p_1); test_uint(ecs_get_target(world, p_2_1, EcsChildOf, 0), p_2); test_uint(ecs_get_target(world, p_1_1_1, EcsChildOf, 0), p_1_1); test_uint(ecs_get_target(world, p_2_1_1, EcsChildOf, 0), p_2_1); ecs_fini(world); } void FixedHierarchies_get_depth_1_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_int(ecs_get_depth(world, p, EcsChildOf), 0); test_int(ecs_get_depth(world, p_1, EcsChildOf), 1); test_int(ecs_get_depth(world, p_2, EcsChildOf), 1); test_int(ecs_get_depth(world, p_1_1, EcsChildOf), 2); test_int(ecs_get_depth(world, p_2_1, EcsChildOf), 2); ecs_fini(world); } void FixedHierarchies_get_depth_2_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_int(ecs_get_depth(world, p, EcsChildOf), 0); test_int(ecs_get_depth(world, p_1, EcsChildOf), 1); test_int(ecs_get_depth(world, p_2, EcsChildOf), 1); test_int(ecs_get_depth(world, p_1_1, EcsChildOf), 2); test_int(ecs_get_depth(world, p_2_1, EcsChildOf), 2); test_int(ecs_get_depth(world, p_1_1_1, EcsChildOf), 3); test_int(ecs_get_depth(world, p_2_1_1, EcsChildOf), 3); ecs_fini(world); } void FixedHierarchies_get_depth_after_reparent_root(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_int(ecs_get_depth(world, p, EcsChildOf), 0); test_int(ecs_get_depth(world, p_1, EcsChildOf), 1); test_int(ecs_get_depth(world, p_2, EcsChildOf), 1); test_int(ecs_get_depth(world, p_1_1, EcsChildOf), 2); test_int(ecs_get_depth(world, p_2_1, EcsChildOf), 2); ecs_entity_t gp = ecs_new_id(world); ecs_add_pair(world, p, EcsChildOf, gp); test_int(ecs_get_depth(world, p, EcsChildOf), 1); test_int(ecs_get_depth(world, p_1, EcsChildOf), 2); test_int(ecs_get_depth(world, p_2, EcsChildOf), 2); test_int(ecs_get_depth(world, p_1_1, EcsChildOf), 3); test_int(ecs_get_depth(world, p_2_1, EcsChildOf), 3); ecs_fini(world); } void FixedHierarchies_delete_fixed_1_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_delete(world, p); test_assert(!ecs_is_alive(world, p_1)); test_assert(!ecs_is_alive(world, p_1_1)); test_assert(!ecs_is_alive(world, p_2)); test_assert(!ecs_is_alive(world, p_2_1)); ecs_fini(world); } void FixedHierarchies_delete_fixed_2_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_delete(world, p); test_assert(!ecs_is_alive(world, p_1)); test_assert(!ecs_is_alive(world, p_1_1)); test_assert(!ecs_is_alive(world, p_1_1_1)); test_assert(!ecs_is_alive(world, p_2)); test_assert(!ecs_is_alive(world, p_2_1)); test_assert(!ecs_is_alive(world, p_2_1_1)); ecs_fini(world); } void FixedHierarchies_delete_with_fixed_1_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_delete_with(world, ecs_pair(EcsChildOf, p)); test_assert(!ecs_is_alive(world, p_1)); test_assert(!ecs_is_alive(world, p_1_1)); test_assert(!ecs_is_alive(world, p_2)); test_assert(!ecs_is_alive(world, p_2_1)); ecs_fini(world); } void FixedHierarchies_delete_with_fixed_2_lvl(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_delete_with(world, ecs_pair(EcsChildOf, p)); test_assert(!ecs_is_alive(world, p_1)); test_assert(!ecs_is_alive(world, p_1_1)); test_assert(!ecs_is_alive(world, p_1_1_1)); test_assert(!ecs_is_alive(world, p_2)); test_assert(!ecs_is_alive(world, p_2_1)); test_assert(!ecs_is_alive(world, p_2_1_1)); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_1_lvl(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_1_lvl_w_init(void) { ecs_world_t *world = ecs_init(); /* Registers metadata/ctor for TreeFixed */ ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_1_lvl_w_init_comp_after_tree_fixed(void) { ecs_world_t *world = ecs_init(); /* Registers metadata/ctor for TreeFixed */ ECS_COMPONENT(world, Position); ecs_set_hooks(world, Position, { .ctor = ecs_default_ctor }); ecs_entity_t rel = ecs_new_id(world); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set_pair_second(world, p_1_1, rel, Position, {1115, 2115}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_set_pair_second(world, p_2_1, rel, Position, {1215, 2215}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_pair(rel, ecs_id(Position)) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(0, it.sources[1]); test_uint(p_1, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *rp = ecs_field(&it, Position, 2); test_int(rp[0].x, 1115); test_int(rp[0].y, 2115); Position *pp = ecs_field(&it, Position, 3); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(0, it.sources[1]); test_uint(p_2, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *rp = ecs_field(&it, Position, 2); test_int(rp[0].x, 1215); test_int(rp[0].y, 2215); Position *pp = ecs_field(&it, Position, 3); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_2_lvl(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_set(world, p_2_1_1, Position, {1211, 2211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1211); test_int(p[0].y, 2211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 121); test_int(pp[0].y, 221); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_cascade_field_2_lvl(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_set(world, p_2_1_1, Position, {1211, 2211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1211); test_int(p[0].y, 2211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 121); test_int(pp[0].y, 221); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_1_fixed_1_regular(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ECS_COMPONENT(world, Velocity); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_set(world, p, Velocity, {3, 4}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, { .id = ecs_id(Velocity), .src.flags = EcsParent } }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); test_uint(p, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); test_uint(p, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); test_uint(p, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_only_fixed_1_lvls(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_assert(p != NULL); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_assert(p != NULL); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_fixed_1_lvls_no_match(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1_1, Position, {111, 211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); test_bool(ecs_query_next(&it), false); it = ecs_query_iter(world, q); test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_fixed_1_lvls_2_no_match(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_fixed_1_lvls_no_match_match(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_assert(p != NULL); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_fixed_1_lvls_match_no_match(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_assert(p != NULL); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_field_2_fixed_2_lvls(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Mass); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_set(world, p, Velocity, {3, 4}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1, Mass, {5}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2, Mass, {6}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_set(world, p_2_1_1, Position, {1211, 2211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, { .id = ecs_id(Velocity), .src.flags = EcsParent }, { .id = ecs_id(Mass), .src.flags = EcsSelf|EcsParent } }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); test_uint(p, it.sources[2]); test_uint(0, it.sources[3]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); Mass *mp = ecs_field(&it, Mass, 4); test_int(mp[0], 5); test_int(mp[1], 6); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); test_uint(p, it.sources[2]); test_uint(p_1, it.sources[3]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); Mass *mp = ecs_field(&it, Mass, 4); test_int(mp[0], 5); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2_1, it.sources[1]); test_uint(p, it.sources[2]); test_uint(p_2, it.sources[3]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1211); test_int(p[0].y, 2211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 121); test_int(pp[0].y, 221); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); Mass *mp = ecs_field(&it, Mass, 4); test_int(mp[0], 6); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); test_uint(p, it.sources[2]); test_uint(p_1, it.sources[3]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); Mass *mp = ecs_field(&it, Mass, 4); test_int(mp[0], 5); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); test_uint(p, it.sources[2]); test_uint(p_2, it.sources[3]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); Mass *mp = ecs_field(&it, Mass, 4); test_int(mp[0], 6); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_next_table(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next_table(&it), false); ecs_fini(world); } void FixedHierarchies_query_next_table_1_elem(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } test_bool(ecs_query_next_table(&it), false); ecs_fini(world); } void FixedHierarchies_query_next_table_1_elem_no_match(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1_1, Position, {111, 211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterNext); test_uint(0, it.count); } test_bool(ecs_query_next_table(&it), false); ecs_fini(world); } void FixedHierarchies_query_nested_make_fixed(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_2 = ecs_new_entity(world, "p._1._2"); ecs_set(world, p, Position, {1, 2}); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_2, Position, {112, 212}); ecs_flatten(world, ecs_pair(EcsChildOf, p_1), NULL); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_uint(2, it.count); test_uint(p_1_1, it.entities[0]); test_uint(p_1_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); test_int(p[1].x, 112); test_int(p[1].y, 212); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } test_bool(ecs_query_next_table(&it), false); ecs_fini(world); } void FixedHierarchies_query_nested_make_fixed_w_optional(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .oper = EcsOptional, .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_2 = ecs_new_entity(world, "p._1._2"); ecs_set(world, p, Position, {1, 2}); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_2, Position, {112, 212}); ecs_flatten(world, ecs_pair(EcsChildOf, p_1), NULL); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p, it.entities[0]); test_uint(0, it.sources[0]); test_uint(0, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1); test_int(p[0].y, 2); Position *pp = ecs_field(&it, Position, 2); test_assert(pp == NULL); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1_1, it.entities[0]); test_uint(p_1_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); test_int(p[1].x, 112); test_int(p[1].y, 212); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_nested_make_fixed_w_optional_match_children_only(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .oper = EcsOptional, .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_2 = ecs_new_entity(world, "p._1._2"); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_2, Position, {112, 212}); ecs_flatten(world, ecs_pair(EcsChildOf, p_1), NULL); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1_1, it.entities[0]); test_uint(p_1_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(0, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); test_int(p[1].x, 112); test_int(p[1].y, 212); Position *pp = ecs_field(&it, Position, 2); test_assert(pp == NULL); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_nested_w_2_parents_make_fixed(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .oper = EcsOptional, .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_1_1 = ecs_new_entity(world, "p._1._1._1"); ecs_entity_t p_1_2 = ecs_new_entity(world, "p._1._2"); ecs_entity_t p_1_2_1 = ecs_new_entity(world, "p._1._2._1"); ecs_entity_t p_1_2_2 = ecs_new_entity(world, "p._1._2._2"); ecs_set(world, p, Position, {1, 2}); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_set(world, p_1_2, Position, {112, 212}); ecs_set(world, p_1_2_1, Position, {1121, 2121}); ecs_set(world, p_1_2_2, Position, {1122, 2122}); ecs_flatten(world, ecs_pair(EcsChildOf, p_1), NULL); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_2)); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_2)); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p, it.entities[0]); test_uint(0, it.sources[0]); test_uint(0, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1); test_int(p[0].y, 2); Position *pp = ecs_field(&it, Position, 2); test_assert(pp == NULL); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1_1, it.entities[0]); test_uint(p_1_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); test_int(p[1].x, 112); test_int(p[1].y, 212); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); } { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1_2_1, it.entities[0]); test_uint(p_1_2_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p_1_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1121); test_int(p[0].y, 2121); test_int(p[1].x, 1122); test_int(p[1].y, 2122); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 112); test_int(pp[0].y, 212); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_table_w_3_parents(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .oper = EcsOptional, .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_1_1_1 = ecs_new_entity(world, "p._1._1._1"); ecs_entity_t p_1_1_2 = ecs_new_entity(world, "p._1._1._2"); ecs_entity_t p_1_1_3 = ecs_new_entity(world, "p._1._1._3"); ecs_entity_t p_1_2 = ecs_new_entity(world, "p._1._2"); ecs_entity_t p_1_2_1 = ecs_new_entity(world, "p._1._2._1"); ecs_entity_t p_1_2_2 = ecs_new_entity(world, "p._1._2._2"); ecs_entity_t p_1_3 = ecs_new_entity(world, "p._1._3"); ecs_entity_t p_1_3_1 = ecs_new_entity(world, "p._1._3._1"); ecs_set(world, p, Position, {1, 2}); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_set(world, p_1_1_2, Position, {1112, 2112}); ecs_set(world, p_1_1_3, Position, {1113, 2113}); ecs_set(world, p_1_2, Position, {112, 212}); ecs_set(world, p_1_2_1, Position, {1121, 2121}); ecs_set(world, p_1_2_2, Position, {1122, 2122}); ecs_set(world, p_1_3, Position, {113, 213}); ecs_set(world, p_1_3_1, Position, {1131, 2131}); ecs_flatten(world, ecs_pair(EcsChildOf, p_1), NULL); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_2)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_3_1)); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_2_2)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_3_1)); ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p, it.entities[0]); test_uint(0, it.sources[0]); test_uint(0, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1); test_int(p[0].y, 2); Position *pp = ecs_field(&it, Position, 2); test_assert(pp == NULL); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(3, it.count); test_uint(p_1_1, it.entities[0]); test_uint(p_1_2, it.entities[1]); test_uint(p_1_3, it.entities[2]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); test_int(p[1].x, 112); test_int(p[1].y, 212); test_int(p[2].x, 113); test_int(p[2].y, 213); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(3, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(p_1_1_2, it.entities[1]); test_uint(p_1_1_3, it.entities[2]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); test_int(p[1].x, 1112); test_int(p[1].y, 2112); test_int(p[2].x, 1113); test_int(p[2].y, 2113); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); } { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1_2_1, it.entities[0]); test_uint(p_1_2_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p_1_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1121); test_int(p[0].y, 2121); test_int(p[1].x, 1122); test_int(p[1].y, 2122); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 112); test_int(pp[0].y, 212); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_3_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_3, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1131); test_int(p[0].y, 2131); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 113); test_int(pp[0].y, 213); } test_bool(ecs_query_next(&it), false); ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_1st(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_1, Position, {22, 42}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_2nd(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_2, Position, {24, 44}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 24); test_int(pp->y, 44); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_iter_twice(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_1, Position, {22, 42}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_iter_twice_each_parent(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_1, Position, {22, 42}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_2, Position, {24, 44}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, false) == EcsIterYield); test_bool(ecs_query_changed(NULL, &it), false); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, false) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 24); test_int(pp->y, 44); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_1st_populate_when_changed(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, true) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_1, Position, {22, 42}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, true) == EcsIterNext); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_2nd_populate_when_changed(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, true) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_2, Position, {24, 44}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterNextYield); test_bool(ecs_query_changed(NULL, &it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 24); test_int(pp->y, 44); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_iter_twice_populate_when_changed(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, true) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_1, Position, {22, 42}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, true) == EcsIterNext); } test_bool(ecs_query_next_table(&it), false); } { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterNext); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_query_w_parent_change_detection_iter_twice_each_parent_populate_when_changed(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Velocity); ECS_COMPONENT(world, Position); ecs_query_t *q = ecs_query(world, { .filter.terms = {{ .id = ecs_id(Position), .inout = EcsIn }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade, .inout = EcsIn }, }, .filter.instanced = true }); ecs_entity_t p = ecs_new_entity(world, "p"); ecs_entity_t p_1 = ecs_new_entity(world, "p._1"); ecs_entity_t p_1_1 = ecs_new_entity(world, "p._1._1"); ecs_entity_t p_2 = ecs_new_entity(world, "p._2"); ecs_entity_t p_2_1 = ecs_new_entity(world, "p._2._1"); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); // offset the column of Position to verify change detection is testing // againt the right one. ecs_add(world, p_2, Velocity); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 11); test_int(pp->y, 21); } { test_assert(ecs_query_populate(&it, true) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 12); test_int(pp->y, 22); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_1, Position, {22, 42}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterYield); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 22); test_int(pp->y, 42); } { test_assert(ecs_query_populate(&it, true) == EcsIterNext); } test_bool(ecs_query_next_table(&it), false); } ecs_set(world, p_2, Position, {24, 44}); { ecs_iter_t it = ecs_query_iter(world, q); { test_bool(ecs_query_next_table(&it), true); test_assert(ecs_query_populate(&it, true) == EcsIterNextYield); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_assert(pp != NULL); test_int(pp->x, 24); test_int(pp->y, 44); } test_bool(ecs_query_next_table(&it), false); } ecs_fini(world); } void FixedHierarchies_staged_query_w_parent_field_1_lvl(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_world_t *stage = ecs_get_stage(world, 0); ecs_readonly_begin(world); ecs_iter_t it = ecs_query_iter(stage, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_readonly_end(world); ecs_fini(world); } void FixedHierarchies_staged_query_w_parent_field_2_lvl(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_set(world, p_2_1_1, Position, {1211, 2211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, }, .filter.instanced = true }); ecs_world_t *stage = ecs_get_stage(world, 0); ecs_readonly_begin(world); ecs_iter_t it = ecs_query_iter(stage, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1211); test_int(p[0].y, 2211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 121); test_int(pp[0].y, 221); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } test_bool(ecs_query_next(&it), false); ecs_readonly_end(world); ecs_fini(world); } void FixedHierarchies_staged_query_w_parent_field_1_fixed_1_regular(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ECS_COMPONENT(world, Velocity); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_set(world, p, Velocity, {3, 4}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent }, { .id = ecs_id(Velocity), .src.flags = EcsParent } }, .filter.instanced = true }); ecs_world_t *stage = ecs_get_stage(world, 0); ecs_readonly_begin(world); ecs_iter_t it = ecs_query_iter(stage, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); test_uint(p, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); test_uint(p, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); test_uint(p, it.sources[2]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); Velocity *vp = ecs_field(&it, Velocity, 3); test_int(vp[0].x, 3); test_int(vp[0].y, 4); } test_bool(ecs_query_next(&it), false); ecs_readonly_end(world); ecs_fini(world); } void FixedHierarchies_staged_query_w_cascade_field_2_lvl(void) { ecs_world_t *world = ecs_mini(); ECS_COMPONENT(world, Position); ecs_entity_t p = ecs_set(world, 0, Position, {1, 2}); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set(world, p_1, Position, {11, 21}); ecs_set(world, p_1_1, Position, {111, 211}); ecs_set(world, p_1_1_1, Position, {1111, 2111}); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set(world, p_2, Position, {12, 22}); ecs_set(world, p_2_1, Position, {121, 221}); ecs_set(world, p_2_1_1, Position, {1211, 2211}); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); ecs_query_t *q = ecs_query(world, { .filter.terms = { { .id = ecs_id(Position) }, { .id = ecs_id(Position), .src.flags = EcsParent|EcsCascade }, }, .filter.instanced = true }); ecs_world_t *stage = ecs_get_stage(world, 0); ecs_readonly_begin(world); ecs_iter_t it = ecs_query_iter(stage, q); { test_bool(ecs_query_next(&it), true); test_uint(2, it.count); test_uint(p_1, it.entities[0]); test_uint(p_2, it.entities[1]); test_uint(0, it.sources[0]); test_uint(p, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 11); test_int(p[0].y, 21); test_int(p[1].x, 12); test_int(p[1].y, 22); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 1); test_int(pp[0].y, 2); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 111); test_int(p[0].y, 211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 11); test_int(pp[0].y, 21); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 121); test_int(p[0].y, 221); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 12); test_int(pp[0].y, 22); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_1_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_1_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1111); test_int(p[0].y, 2111); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 111); test_int(pp[0].y, 211); } { test_bool(ecs_query_next(&it), true); test_uint(1, it.count); test_uint(p_2_1_1, it.entities[0]); test_uint(0, it.sources[0]); test_uint(p_2_1, it.sources[1]); Position *p = ecs_field(&it, Position, 1); test_int(p[0].x, 1211); test_int(p[0].y, 2211); Position *pp = ecs_field(&it, Position, 2); test_int(pp[0].x, 121); test_int(pp[0].y, 221); } test_bool(ecs_query_next(&it), false); ecs_readonly_end(world); ecs_fini(world); } void FixedHierarchies_add_to_fixed(void) { install_test_abort(); ecs_world_t *world = ecs_mini(); ECS_TAG(world, Tag); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_expect_abort(); ecs_add(world, p_1_1, Tag); } void FixedHierarchies_remove_from_fixed(void) { install_test_abort(); ecs_world_t *world = ecs_mini(); ECS_TAG(world, Tag); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_add(world, p_1_1, Tag); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_expect_abort(); ecs_remove(world, p_1_1, Tag); } void FixedHierarchies_delete_fixed(void) { install_test_abort(); ecs_world_t *world = ecs_mini(); ECS_TAG(world, Tag); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_expect_abort(); ecs_delete(world, p_1_1); } void FixedHierarchies_clear_fixed(void) { install_test_abort(); ecs_world_t *world = ecs_mini(); ECS_TAG(world, Tag); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_expect_abort(); ecs_clear(world, p_1_1); } void FixedHierarchies_make_fixed_1_lvl_w_name(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_set_name(world, p, "p"); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_1, "name_1"); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set_name(world, p_1_1, "child_1"); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_2, "name_2"); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set_name(world, p_2_1, "child_1"); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_lookup_fullpath(world, "p.name_1") == p_1); test_assert(ecs_lookup_fullpath(world, "p.name_2") == p_2); test_assert(ecs_lookup_fullpath(world, "p.name_1.child_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_2.child_1") == 0); test_str(ecs_get_name(world, p_1), "name_1"); test_str(ecs_get_name(world, p_2), "name_2"); test_str(ecs_get_name(world, p_1_1), NULL); test_str(ecs_get_name(world, p_2_1), NULL); ecs_fini(world); } void FixedHierarchies_make_fixed_2_lvl_w_name(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_set_name(world, p, "p"); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_1, "name_1"); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set_name(world, p_1_1, "child_1"); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set_name(world, p_1_1_1, "child_1_1"); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_2, "name_2"); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set_name(world, p_2_1, "child_1"); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set_name(world, p_2_1_1, "child_1_1"); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_lookup_fullpath(world, "p.name_1") == p_1); test_assert(ecs_lookup_fullpath(world, "p.name_2") == p_2); test_assert(ecs_lookup_fullpath(world, "p.name_1.child_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_2.child_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_1.child_1.child_1_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_2.child_1.child_1_1") == 0); test_str(ecs_get_name(world, p_1), "name_1"); test_str(ecs_get_name(world, p_2), "name_2"); test_str(ecs_get_name(world, p_1_1), NULL); test_str(ecs_get_name(world, p_2_1), NULL); test_str(ecs_get_name(world, p_1_1_1), NULL); test_str(ecs_get_name(world, p_2_1_1), NULL); ecs_fini(world); } void FixedHierarchies_make_fixed_1_lvl_w_name_keep_name(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_set_name(world, p, "p"); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_1, "name_1"); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set_name(world, p_1_1, "child_1_1"); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_2, "name_2"); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set_name(world, p_2_1, "child_2_1"); ecs_flatten(world, ecs_pair(EcsChildOf, p), &(ecs_flatten_desc_t){ .keep_names = true }); test_assert(ecs_lookup_fullpath(world, "p.name_1") == p_1); test_assert(ecs_lookup_fullpath(world, "p.name_2") == p_2); test_assert(ecs_lookup_fullpath(world, "p.name_1.child_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_2.child_1") == 0); test_str(ecs_get_name(world, p_1), "name_1"); test_str(ecs_get_name(world, p_2), "name_2"); test_str(ecs_get_name(world, p_1_1), "child_1_1"); test_str(ecs_get_name(world, p_2_1), "child_2_1"); ecs_fini(world); } void FixedHierarchies_make_fixed_2_lvl_w_name_keep_name(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_set_name(world, p, "p"); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_1, "name_1"); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_set_name(world, p_1_1, "child_1_1"); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_set_name(world, p_1_1_1, "child_1_1_1"); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_set_name(world, p_2, "name_2"); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_set_name(world, p_2_1, "child_2_1"); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_set_name(world, p_2_1_1, "child_2_1_1"); ecs_flatten(world, ecs_pair(EcsChildOf, p), &(ecs_flatten_desc_t){ .keep_names = true }); test_assert(ecs_lookup_fullpath(world, "p.name_1") == p_1); test_assert(ecs_lookup_fullpath(world, "p.name_2") == p_2); test_assert(ecs_lookup_fullpath(world, "p.name_1.child_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_2.child_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_1.child_1.child_1_1") == 0); test_assert(ecs_lookup_fullpath(world, "p.name_2.child_1.child_1_1") == 0); test_str(ecs_get_name(world, p_1), "name_1"); test_str(ecs_get_name(world, p_2), "name_2"); test_str(ecs_get_name(world, p_1_1), "child_1_1"); test_str(ecs_get_name(world, p_2_1), "child_2_1"); test_str(ecs_get_name(world, p_1_1_1), "child_1_1_1"); test_str(ecs_get_name(world, p_2_1_1), "child_2_1_1"); ecs_fini(world); } void FixedHierarchies_make_fixed_2_lvl_lose_depth(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), &(ecs_flatten_desc_t){ .lose_depth = true }); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_1_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); ecs_fini(world); } void FixedHierarchies_make_fixed_3_lvl_lose_depth(void) { ecs_world_t *world = ecs_mini(); ecs_entity_t p = ecs_new_id(world); ecs_entity_t p_1 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1); ecs_entity_t p_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1); ecs_entity_t p_1_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_1_1_1); ecs_entity_t p_2 = ecs_new_w_pair(world, EcsChildOf, p); ecs_entity_t p_2_1 = ecs_new_w_pair(world, EcsChildOf, p_2); ecs_entity_t p_2_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1); ecs_entity_t p_2_1_1_1 = ecs_new_w_pair(world, EcsChildOf, p_2_1_1); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) != ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); ecs_flatten(world, ecs_pair(EcsChildOf, p), NULL); test_assert(ecs_get_table(world, p_1) == ecs_get_table(world, p_2)); test_assert(ecs_get_table(world, p_1_1) == ecs_get_table(world, p_2_1)); test_assert(ecs_get_table(world, p_1_1_1) == ecs_get_table(world, p_2_1_1)); test_assert(ecs_get_table(world, p_1_1_1) != ecs_get_table(world, p_1_1)); test_assert(ecs_get_target(world, p_1, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_1_1, EcsChildOf, 0) == p_1); test_assert(ecs_get_target(world, p_1_1_1, EcsChildOf, 0) == p_1_1); test_assert(ecs_get_target(world, p_1_1_1_1, EcsChildOf, 0) == p_1_1_1); test_assert(ecs_get_target(world, p_2, EcsChildOf, 0) == p); test_assert(ecs_get_target(world, p_2_1, EcsChildOf, 0) == p_2); test_assert(ecs_get_target(world, p_2_1_1, EcsChildOf, 0) == p_2_1); test_assert(ecs_get_target(world, p_2_1_1_1, EcsChildOf, 0) == p_2_1_1); ecs_fini(world); }
cceb3590f8813c6ef61af1ca0fdf850143331957
fb47ab6337a71029dee71933e449cf7f6805fc0f
/platform/stm32f0xx/gpio.c
cf5cc09c64062abcfcd8c8ae060b434c24479f70
[ "MIT" ]
permissive
littlekernel/lk
7e7ba50b87b1f2e0b6e2f052c59249825c91975b
30dc320054f70910e1c1ee40a6948ee99672acec
refs/heads/master
2023-09-02T00:47:52.203963
2023-06-21T22:42:35
2023-06-21T22:42:35
3,058,456
3,077
618
MIT
2023-08-30T09:41:31
2011-12-27T19:19:36
C
UTF-8
C
false
false
4,644
c
gpio.c
/* * Copyright (c) 2012 Travis Geiselbrecht * Copyright (c) 2016 Erik Gilling * * Use of this source code is governed by a MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT */ #include <assert.h> #include <lk/debug.h> #include <dev/gpio.h> #include <platform/gpio.h> #include <platform/rcc.h> #include <platform/stm32.h> #include <stm32f0xx.h> typedef GPIO_TypeDef stm32_gpio_t; typedef enum { STM32_GPIO_SPEED_2_MHZ = 0x0, STM32_GPIO_SPEED_20_MHZ = 0x1, STM32_GPIO_SPEED_50_MHZ = 0x3, } stm32_goio_speed_t; typedef enum { STM32_GPIO_OTYPE_PP = 0x0, STM32_GPIO_OTYPE_OD = 0x1, } stm32_gpio_otype_t; typedef enum { STM32_GPIO_MODE_IN = 0x0, STM32_GPIO_MODE_OUT = 0x1, STM32_GPIO_MODE_AF = 0x2, STM32_GPIO_MODE_AN = 0x3, } stm32_gpio_mode_t; typedef enum { STM32_GPIO_PUPD_NONE = 0x0, STM32_GPIO_PUPD_UP = 0x1, STM32_GPIO_PUPD_DOWN = 0x2, } stm32_gpio_pupd_t; static stm32_gpio_t *stm32_gpio_port_to_pointer(unsigned int port) { switch (port) { default: #ifdef GPIOA case GPIO_PORT_A: return GPIOA; #endif #ifdef GPIOB case GPIO_PORT_B: return GPIOB; #endif #ifdef GPIOC case GPIO_PORT_C: return GPIOC; #endif #ifdef GPIOD case GPIO_PORT_D: return GPIOD; #endif #ifdef GPIOE case GPIO_PORT_E: return GPIOE; #endif #ifdef GPIOF case GPIO_PORT_F: return GPIOF; #endif } } static void stm32_gpio_enable_port(unsigned int port) { DEBUG_ASSERT(port <= GPIO_PORT_F); switch (port) { default: #ifdef GPIOA case GPIO_PORT_A: stm32_rcc_set_enable(STM32_RCC_CLK_IOPA, true); break; #endif #ifdef GPIOB case GPIO_PORT_B: stm32_rcc_set_enable(STM32_RCC_CLK_IOPB, true); break; #endif #ifdef GPIOC case GPIO_PORT_C: stm32_rcc_set_enable(STM32_RCC_CLK_IOPC, true); break; #endif #ifdef GPIOD case GPIO_PORT_D: stm32_rcc_set_enable(STM32_RCC_CLK_IOPD, true); break; #endif #ifdef GPIOE case GPIO_PORT_E: stm32_rcc_set_enable(STM32_RCC_CLK_IOPE, true); break; #endif #ifdef GPIOF case GPIO_PORT_F: stm32_rcc_set_enable(STM32_RCC_CLK_IOPF, true); break; #endif } } void stm32_gpio_early_init(void) { } static void stm32_gpio_af_config(stm32_gpio_t *gpio, uint32_t pin, uint32_t af_num) { // 8 AF entries per register uint32_t reg_index = pin >> 3; uint32_t entry_shift = (pin & 0x7) * 4; gpio->AFR[reg_index] &= ~(0xf << entry_shift); gpio->AFR[reg_index] |= (af_num & 0xf) << entry_shift; } int gpio_config(unsigned nr, unsigned flags) { uint32_t port = GPIO_PORT(nr); uint32_t pin = GPIO_PIN(nr); stm32_gpio_t *gpio = stm32_gpio_port_to_pointer(port); assert(pin < 16); stm32_gpio_enable_port(port); if (flags & GPIO_STM32_AF) { stm32_gpio_af_config(gpio, pin, GPIO_AFNUM(flags)); } if ((flags & GPIO_OUTPUT) || (flags & GPIO_STM32_AF)) { // All pins configured to 50MHz. gpio->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pin * 2)); gpio->OSPEEDR |= STM32_GPIO_SPEED_50_MHZ << (pin * 2); // Output mode configuration gpio->OTYPER &= ~((GPIO_OTYPER_OT_0) << pin); if (flags & GPIO_STM32_OD) { gpio->OTYPER |= STM32_GPIO_OTYPE_OD << pin; } else { gpio->OTYPER |= STM32_GPIO_OTYPE_PP << pin; } } stm32_gpio_mode_t mode; if (flags & GPIO_OUTPUT) { mode = STM32_GPIO_MODE_OUT; } else if (flags & GPIO_STM32_AF) { mode = STM32_GPIO_MODE_AF; } else { mode = STM32_GPIO_MODE_IN; } gpio->MODER &= ~(GPIO_MODER_MODER0 << (pin * 2)); gpio->MODER |= (mode << (pin * 2)); stm32_gpio_pupd_t pupd = STM32_GPIO_PUPD_NONE; if (flags & GPIO_PULLUP) { pupd = STM32_GPIO_PUPD_UP; } else if (flags & GPIO_PULLDOWN) { pupd = STM32_GPIO_PUPD_DOWN; } gpio->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << (pin * 2)); gpio->PUPDR |= pupd << (pin * 2); return 0; } void gpio_set(unsigned nr, unsigned on) { stm32_gpio_t *gpio = stm32_gpio_port_to_pointer(GPIO_PORT(nr)); if (on) { gpio->BSRR = 1 << GPIO_PIN(nr); } else { gpio->BRR = 1 << GPIO_PIN(nr); } } int gpio_get(unsigned nr) { stm32_gpio_t *gpio = stm32_gpio_port_to_pointer(GPIO_PORT(nr)); return (gpio->IDR & (1 << GPIO_PIN(nr))) != 0; }
7ed76131076141602ede20c412ddeb4fadd648de
d0dc556f8b1d18ecbadef182bafd97b632dd3104
/common/esp-idf-lib/components/tca9548/tca9548.h
86c806bf85fd429ca9be7006f97e99cfc206f225
[ "BSD-2-Clause", "MIT" ]
permissive
PacktPublishing/Internet-of-Things-with-ESP32
da3f2c57e2bd871b134b22841fd275c51f88d487
3ada8b905e53961940511636991a839059de7cd1
refs/heads/main
2023-02-08T13:58:32.585403
2023-01-30T10:03:23
2023-01-30T10:03:23
315,618,086
114
36
null
null
null
null
UTF-8
C
false
false
1,935
h
tca9548.h
/** * @file tca9548.h * @defgroup tca9548 tca9548 * @{ * * ESP-IDF driver for low-voltage 8-channel I2C switch TCA9548/PCA9548 * * Copyright (C) 2020 Ruslan V. Uss <unclerus@gmail.com> * * BSD Licensed as described in the file LICENSE */ #ifndef __TCA9548_H__ #define __TCA9548_H__ #include <stdbool.h> #include <i2cdev.h> #include <esp_err.h> #ifdef __cplusplus extern "C" { #endif #define TCA9548_ADDR_0 0x70 #define TCA9548_ADDR_1 0x71 #define TCA9548_ADDR_2 0x72 #define TCA9548_ADDR_3 0x73 #define TCA9548_ADDR_4 0x74 #define TCA9548_ADDR_5 0x75 #define TCA9548_ADDR_6 0x76 #define TCA9548_ADDR_7 0x77 #ifndef BV #define BV(x) (1 << (x)) #endif #define TCA9548_CHANNEL0 BV(0) #define TCA9548_CHANNEL1 BV(1) #define TCA9548_CHANNEL2 BV(2) #define TCA9548_CHANNEL3 BV(3) #define TCA9548_CHANNEL4 BV(4) #define TCA9548_CHANNEL5 BV(5) #define TCA9548_CHANNEL6 BV(6) #define TCA9548_CHANNEL7 BV(7) /** * Initialize device descriptior * @param dev Device descriptor * @param port I2C port * @param addr Device address * @param sda_gpio SDA GPIO pin * @param scl_gpio SCL GPIO pin * @return `ESP_OK` on success */ esp_err_t tca9548_init_desc(i2c_dev_t *dev, i2c_port_t port, uint8_t addr, gpio_num_t sda_gpio, gpio_num_t scl_gpio); /** * Free device descriptor * @param dev Device descriptor * @return `ESP_OK` on success */ esp_err_t tca9548_free_desc(i2c_dev_t *dev); /** * Switch channels * @param dev Device descriptor * @param channels Channel flags, combination of TCA9548_CHANNELn * @return `ESP_OK` on success */ esp_err_t tca9548_set_channels(i2c_dev_t *dev, uint8_t channels); /** * Read current channels configuration * @param dev Device descriptor * @param[out] channels Channel flags, combination of TCA9548_CHANNELn * @return `ESP_OK` on success */ esp_err_t tca9548_get_channels(i2c_dev_t *dev, uint8_t *channels); #ifdef __cplusplus } #endif /**@}*/ #endif /* __TCA9548_H__ */
101780541eb06e8cf96c031c5c4eeeb9bd62d2a4
8838eb997879add5759b6dfb23f9a646464e53ca
/src/compat/libc/locale/locale_stub.c
3e0d91a785b82d73bdc9cff160ca0d179c71d081
[ "BSD-2-Clause" ]
permissive
embox/embox
d6aacec876978522f01cdc4b8de37a668c6f4c80
98e3c06e33f3fdac10a29c069c20775568e0a6d1
refs/heads/master
2023-09-04T03:02:20.165042
2023-09-02T14:55:31
2023-09-02T14:55:31
33,078,138
1,087
325
BSD-2-Clause
2023-09-14T16:58:34
2015-03-29T15:27:48
C
UTF-8
C
false
false
259
c
locale_stub.c
/** * @file * * @date Oct 28, 2020 * @author Anton Bondarev */ #include <stddef.h> #include <locale.h> char *setlocale(int category, const char *locale) { (void)category; (void)locale; return NULL; } struct lconv *localeconv(void) { return NULL; }
47da1d2fd84b24d8fa92222459e83bec76d467de
ed98b77f3f09b392e68a0d59c48eec299e883bb9
/src/scip/pub_event.h
f687a55595e69512d44232cb4f51dfa018cae6a4
[ "Apache-2.0" ]
permissive
scipopt/scip
c8ddbe7cdec0a3af5a230c04b74b76ffacbdcc33
dc856a4c966ea50bd5f52c58d7be4fea33706f4c
refs/heads/master
2023-08-19T11:39:12.578790
2023-08-15T20:05:58
2023-08-15T20:05:58
342,522,859
262
46
NOASSERTION
2023-08-03T07:37:45
2021-02-26T09:16:17
C
UTF-8
C
false
false
9,152
h
pub_event.h
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the program and library */ /* SCIP --- Solving Constraint Integer Programs */ /* */ /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ /* You may obtain a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, software */ /* distributed under the License is distributed on an "AS IS" BASIS, */ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ /* See the License for the specific language governing permissions and */ /* limitations under the License. */ /* */ /* You should have received a copy of the Apache-2.0 license */ /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**@file pub_event.h * @ingroup PUBLICCOREAPI * @brief public methods for managing events * @author Tobias Achterberg */ /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ #ifndef __SCIP_PUB_EVENT_H__ #define __SCIP_PUB_EVENT_H__ #include "scip/def.h" #include "scip/type_event.h" #include "scip/type_lp.h" #include "scip/type_sol.h" #include "scip/type_tree.h" #include "scip/type_var.h" /* In optimized mode, some function calls are overwritten by defines to reduce the number of function calls and * speed up the algorithms. For this, we need to include struct_event.h. */ #ifdef NDEBUG #include "scip/struct_event.h" #endif #ifdef __cplusplus extern "C" { #endif /* * Event handler methods */ /**@addtogroup PublicEventHandlerMethods * * @{ */ /** gets name of event handler */ SCIP_EXPORT const char* SCIPeventhdlrGetName( SCIP_EVENTHDLR* eventhdlr /**< event handler */ ); /** gets user data of event handler */ SCIP_EXPORT SCIP_EVENTHDLRDATA* SCIPeventhdlrGetData( SCIP_EVENTHDLR* eventhdlr /**< event handler */ ); /** sets user data of event handler; user has to free old data in advance! */ SCIP_EXPORT void SCIPeventhdlrSetData( SCIP_EVENTHDLR* eventhdlr, /**< event handler */ SCIP_EVENTHDLRDATA* eventhdlrdata /**< new event handler user data */ ); /** is event handler initialized? */ SCIP_EXPORT SCIP_Bool SCIPeventhdlrIsInitialized( SCIP_EVENTHDLR* eventhdlr /**< event handler */ ); /** gets time in seconds used in this event handler for setting up for next stages */ SCIP_EXPORT SCIP_Real SCIPeventhdlrGetSetupTime( SCIP_EVENTHDLR* eventhdlr /**< event handler */ ); /** gets time in seconds used in this event handler */ SCIP_EXPORT SCIP_Real SCIPeventhdlrGetTime( SCIP_EVENTHDLR* eventhdlr /**< event handler */ ); /** @} */ /* * Event methods */ /**@addtogroup PublicEventMethods * * @{ */ /** gets type of event */ SCIP_EXPORT SCIP_EVENTTYPE SCIPeventGetType( SCIP_EVENT* event /**< event */ ); /** gets variable for a variable event (var added, var deleted, var fixed, * objective value or domain change, domain hole added or removed) */ SCIP_EXPORT SCIP_VAR* SCIPeventGetVar( SCIP_EVENT* event /**< event */ ); /** gets old objective value for an objective value change event */ SCIP_EXPORT SCIP_Real SCIPeventGetOldobj( SCIP_EVENT* event /**< event */ ); /** gets new objective value for an objective value change event */ SCIP_EXPORT SCIP_Real SCIPeventGetNewobj( SCIP_EVENT* event /**< event */ ); /** gets old bound for a bound change event */ SCIP_EXPORT SCIP_Real SCIPeventGetOldbound( SCIP_EVENT* event /**< event */ ); /** gets new bound for a bound change event */ SCIP_EXPORT SCIP_Real SCIPeventGetNewbound( SCIP_EVENT* event /**< event */ ); /** gets old variable type for a variable type change event */ SCIP_EXPORT SCIP_VARTYPE SCIPeventGetOldtype( SCIP_EVENT* event /**< event */ ); /** gets new variable type for a variable type change event */ SCIP_EXPORT SCIP_VARTYPE SCIPeventGetNewtype( SCIP_EVENT* event /**< event */ ); /** gets node for a node or LP event */ SCIP_EXPORT SCIP_NODE* SCIPeventGetNode( SCIP_EVENT* event /**< event */ ); /** gets solution for a primal solution event */ SCIP_EXPORT SCIP_SOL* SCIPeventGetSol( SCIP_EVENT* event /**< event */ ); /** gets the left bound of open interval in the hole */ SCIP_EXPORT SCIP_Real SCIPeventGetHoleLeft( SCIP_EVENT* event /**< event */ ); /** gets the right bound of open interval in the hole */ SCIP_EXPORT SCIP_Real SCIPeventGetHoleRight( SCIP_EVENT* event /**< event */ ); /** gets row for a row event */ SCIP_EXPORT SCIP_ROW* SCIPeventGetRow( SCIP_EVENT* event /**< event */ ); /** gets column for a row change coefficient event */ SCIP_EXPORT SCIP_COL* SCIPeventGetRowCol( SCIP_EVENT* event /**< event */ ); /** gets old coefficient value for a row change coefficient event */ SCIP_EXPORT SCIP_Real SCIPeventGetRowOldCoefVal( SCIP_EVENT* event /**< event */ ); /** gets new coefficient value for a row change coefficient event */ SCIP_EXPORT SCIP_Real SCIPeventGetRowNewCoefVal( SCIP_EVENT* event /**< event */ ); /** gets old constant value for a row change constant event */ SCIP_EXPORT SCIP_Real SCIPeventGetRowOldConstVal( SCIP_EVENT* event /**< event */ ); /** gets new constant value for a row change constant event */ SCIP_EXPORT SCIP_Real SCIPeventGetRowNewConstVal( SCIP_EVENT* event /**< event */ ); /** gets side for a row change side event */ SCIP_EXPORT SCIP_SIDETYPE SCIPeventGetRowSide( SCIP_EVENT* event /**< event */ ); /** gets old side value for a row change side event */ SCIP_EXPORT SCIP_Real SCIPeventGetRowOldSideVal( SCIP_EVENT* event /**< event */ ); /** gets new side value for a row change side event */ SCIP_EXPORT SCIP_Real SCIPeventGetRowNewSideVal( SCIP_EVENT* event /**< event */ ); #ifdef NDEBUG /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and * speed up the algorithms. */ #define SCIPeventGetType(event) ((event)->eventtype) #define SCIPeventGetOldobj(event) ((event)->data.eventobjchg.oldobj) #define SCIPeventGetNewobj(event) ((event)->data.eventobjchg.newobj) #define SCIPeventGetOldbound(event) ((event)->data.eventbdchg.oldbound) #define SCIPeventGetNewbound(event) ((event)->data.eventbdchg.newbound) #define SCIPeventGetOldtype(event) ((event)->data.eventtypechg.oldtype) #define SCIPeventGetNewtype(event) ((event)->data.eventtypechg.newtype) #define SCIPeventGetNode(event) ((event)->data.node) #define SCIPeventGetSol(event) ((event)->data.sol) #define SCIPeventGetRowCol(event) ((event)->data.eventrowcoefchanged.col) #define SCIPeventGetRowOldCoefVal(event) ((event)->data.eventrowcoefchanged.oldval) #define SCIPeventGetRowNewCoefVal(event) ((event)->data.eventrowcoefchanged.newval) #define SCIPeventGetRowOldConstVal(event) ((event)->data.eventrowconstchanged.oldval) #define SCIPeventGetRowNewConstVal(event) ((event)->data.eventrowconstchanged.newval) #define SCIPeventGetRowSide(event) ((event)->data.eventrowsidechanged.side) #define SCIPeventGetRowOldSideVal(event) ((event)->data.eventrowsidechanged.oldval) #define SCIPeventGetRowNewSideVal(event) ((event)->data.eventrowsidechanged.newval) #endif /** @} */ #ifdef __cplusplus } #endif #endif
bcf471da496b9a8c236629d948e99b2ff6202d3d
b841b8c0f5a66831d9b71822821031786f53a9fb
/SourceEngineUnlocker/SourceEngineUnlocker.h
dfd7dfff9f0fae9800d2fd4cb34c481cfedfa8e0
[ "MIT" ]
permissive
UniversalSplitScreen/UniversalSplitScreen
2d2fef0f98ba0008bf35e21f83d96aa3a309857d
d0618b8bfb9dd2a9e034609014ffea6fac607a4b
refs/heads/develop
2022-12-10T10:20:20.358090
2020-04-25T13:49:41
2020-04-25T13:49:41
188,645,347
619
29
MIT
2022-12-08T14:44:00
2019-05-26T05:50:04
C#
UTF-8
C
false
false
123
h
SourceEngineUnlocker.h
#pragma once #include "stdafx.h" #include <winternl.h> extern "C" __declspec(dllexport) int SourceEngineUnlock(int pid);
182a7e18a89f658fb701d53a0b27e73085b1a17f
b36f34b6a24d019d624d1cc74f5b29062eef2ba4
/frameworks/3rd/luaopenssl/xstore.c
6dbb6fbd97b69b359c096483dbd62842dabaa366
[ "OpenSSL", "MIT", "LicenseRef-scancode-openssl" ]
permissive
zhongfq/cocos-lua
f49c1639f2c9a2a7678f9ed67e58114986ac882f
c2cf0f36ac0f0c91fb3456b555cacd8e8587be46
refs/heads/main
2023-08-17T17:13:05.705639
2023-08-17T06:06:36
2023-08-17T06:06:36
192,316,318
165
63
MIT
2023-08-14T23:59:30
2019-06-17T09:27:37
C
UTF-8
C
false
false
7,822
c
xstore.c
/*** Provide x509_store as lua object, create and manage x509 store object @module x509.store @usage store = require'openssl'.x509.store */ #include "openssl.h" #include "private.h" /*** create or generate a new x509_store object. @function new @tparam table certs array of x509 objects, all x509 object will add to store, certs can be empty but not nil @tparam[opt] table crls array of x509_crl objects, all crl object will add to store @treturn x509_store object @see x509_store */ static int openssl_xstore_new(lua_State*L) { X509_STORE* ctx = X509_STORE_new(); int i, n; if (!lua_isnoneornil(L, 1)) { luaL_checktable(L, 1); n = lua_rawlen(L, 1); for (i = 0; i < n; i++) { X509* x; lua_rawgeti(L, 1, i + 1); luaL_argcheck(L, auxiliar_getclassudata(L, "openssl.x509", -1), 1, "only contains x509 object"); x = CHECK_OBJECT(-1, X509, "openssl.x509"); lua_pop(L, 1); X509_STORE_add_cert(ctx, x); } } if (!lua_isnoneornil(L, 2)) { luaL_checktable(L, 2); n = lua_rawlen(L, 2); for (i = 0; i < n; i++) { X509_CRL* c; lua_rawgeti(L, 2, i + 1); c = CHECK_OBJECT(-1, X509_CRL, "openssl.x509_crl"); lua_pop(L, 1); X509_STORE_add_crl(ctx, c); } }; PUSH_OBJECT(ctx, "openssl.x509_store"); return 1; }; static luaL_Reg R[] = { {"new", openssl_xstore_new}, {NULL, NULL}, }; /*** openssl.x509_store object @type x509_store */ void openssl_xstore_free(X509_STORE* ctx) { /* hack openssl bugs */ #if OPENSSL_VERSION_NUMBER < 0x10100000L if (ctx->references > 1) CRYPTO_add(&ctx->references, -1, CRYPTO_LOCK_X509_STORE); else X509_STORE_free(ctx); #else X509_STORE_free(ctx); #endif } static int openssl_xstore_gc(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); openssl_xstore_free(ctx); return 0; } /*** add lookup path for store @function add_lookup @tparam string path file or dir path to add @tparam[opt='file'] mode only 'file' or 'dir' @tparam[opt='default'] format only 'pem', 'der' or 'default' @treturn boolean result */ static int openssl_xstore_add_lookup(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); const char* path = luaL_checkstring(L, 2); const static char* sMode[] = {"file", "dir", NULL}; int mode = luaL_checkoption(L, 3, "file", sMode); const static char* sFormat[] = {"pem", "asn1", "default", NULL}; int iFormat[] = {X509_FILETYPE_PEM, X509_FILETYPE_ASN1, X509_FILETYPE_DEFAULT, -1}; int fmt = auxiliar_checkoption(L, 4, "default", sFormat, iFormat); int ret = 0; X509_LOOKUP *lookup = NULL; if (mode == 0) { lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file()); if (lookup) { ret = X509_LOOKUP_load_file(lookup, path, fmt); } } else { lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir()); if (lookup) { ret = X509_LOOKUP_add_dir(lookup, path, fmt); } } return openssl_pushresult(L, ret); } /*** set verify depth of certificate chains @function depth @tparam number depth @treturn boolean result */ static int openssl_xstore_depth(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); int depth = luaL_checkint(L, 2); int ret = X509_STORE_set_depth(ctx, depth); return openssl_pushresult(L, ret); } /*** set verify flags of certificate chains @function flags @tparam number flags @treturn boolean result */ static int openssl_xstore_flags(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); int flags = luaL_checkint(L, 2); int ret = X509_STORE_set_flags(ctx, flags); return openssl_pushresult(L, ret); } /*** set prupose of x509 store @function purpose @tparam integer purpose @treturn boolean result */ static int openssl_xstore_purpose(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); int purpose = luaL_checkint(L, 2); int ret = X509_STORE_set_purpose(ctx, purpose); return openssl_pushresult(L, ret); } /*** set as trust x509 store @function trust @tparam boolean trust @treturn boolean result */ static int openssl_xstore_trust(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); int trust = auxiliar_checkboolean(L, 2); int ret = X509_STORE_set_trust(ctx, trust); return openssl_pushresult(L, ret); } /*** load certificate from file or dir,not given any paramater will load from defaults path @function load @tparam[opt] string filepath @tparam[opt] string dirpath @treturn boolean result */ static int openssl_xstore_load(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); const char* file = luaL_optstring(L, 2, NULL); const char* dir = luaL_optstring(L, 3, NULL); int ret; if (file || dir) { #if (OPENSSL_VERSION_NUMBER >= 0x30000000L) ret = !(file == NULL && dir == NULL); if (file != NULL) ret = X509_STORE_load_file(ctx, file); if (ret == 1 && dir != NULL) ret = X509_STORE_load_path(ctx, dir); #else ret = X509_STORE_load_locations (ctx, file, dir); #endif } else ret = X509_STORE_set_default_paths(ctx); return openssl_pushresult(L, ret); } /*** add x509 certificate or crl to store @param ... support x509 object,x509_crl object or array contains x509,x509_crl object @function add @treturn boolean result */ static int openssl_xstore_add(lua_State* L) { X509_STORE* ctx = CHECK_OBJECT(1, X509_STORE, "openssl.x509_store"); int n = lua_gettop(L); int i; int ret = 0; for (i = 2; i <= n; i++) { if (lua_istable(L, i)) { int k = lua_rawlen(L, i); int j; for (j = 1; j <= k; j++) { lua_rawgeti(L, i, j); if (auxiliar_getclassudata(L, "openssl.x509", -1)) { X509* x = CHECK_OBJECT(-1, X509, "openssl.x509"); ret = X509_STORE_add_cert(ctx, x); } else if (auxiliar_getclassudata(L, "openssl.x509_crl", -1)) { X509_CRL* c = CHECK_OBJECT(-1, X509_CRL, "openssl.x509_crl"); ret = X509_STORE_add_crl(ctx, c); } else { luaL_argerror(L, i, "only accept table with x509 or x509_crl object"); } lua_pop(L, 1); } } else if (auxiliar_getclassudata(L, "openssl.x509", i)) { X509* x = CHECK_OBJECT(i, X509, "openssl.x509"); ret = X509_STORE_add_cert(ctx, x); } else if (auxiliar_getclassudata(L, "openssl.x509_crl", i)) { X509_CRL* c = CHECK_OBJECT(i, X509_CRL, "openssl.x509_crl"); ret = X509_STORE_add_crl(ctx, c); } else { luaL_argerror(L, i, "only accept x509 or x509_crl object or table with x509 or x509_crl object"); } if (ret == 0) break; } return openssl_pushresult(L, ret); } static luaL_Reg xname_funcs[] = { {"flags", openssl_xstore_flags}, {"purpose", openssl_xstore_purpose}, {"depth", openssl_xstore_depth}, {"trust", openssl_xstore_trust}, {"load", openssl_xstore_load}, {"add", openssl_xstore_add}, {"add_lookup", openssl_xstore_add_lookup}, /* {"certs", openssl_xstore_certs}, {"crls", openssl_xstore_crls}, {"param", openssl_xstore_param}, {"verify_cb", openssl_xstore_verify_cb}, {"verify", openssl_xstore_verify}, {"lookup_crls_cb", openssl_xstore_lookup_crls_cb}, */ {"__tostring", auxiliar_tostring}, {"__gc", openssl_xstore_gc}, {NULL, NULL}, }; int openssl_register_xstore(lua_State*L) { auxiliar_newclass(L, "openssl.x509_store", xname_funcs); lua_newtable(L); luaL_setfuncs(L, R, 0); return 1; }
5efb06768143132636b4301293d2c3ef071a8c38
d38ed5f31d74a79a054ed55dd9123a8d615283b9
/third_party/libgit2/tests/merge/workdir/analysis.c
27d7dba8442e0047931f245a0de6b4eb217f96ee
[ "GPL-2.0-only", "LicenseRef-scancode-public-domain", "GCC-exception-2.0", "LGPL-2.0-or-later", "Zlib", "LGPL-2.1-or-later", "LGPL-2.1-only", "ISC", "MIT", "Apache-2.0" ]
permissive
chigraph/chigraph
8ff76a14337da29fa2b2a84d5c35f2eac4156c6e
6981bdd6763db54edfe284c1f7d223193584c69a
refs/heads/master
2022-12-21T13:46:57.273039
2022-12-17T18:41:19
2022-12-17T18:41:19
60,776,831
364
65
Apache-2.0
2019-12-13T14:46:43
2016-06-09T13:27:37
C++
UTF-8
C
false
false
5,410
c
analysis.c
#include "clar_libgit2.h" #include "git2/repository.h" #include "git2/merge.h" #include "git2/annotated_commit.h" #include "git2/sys/index.h" #include "merge.h" #include "../merge_helpers.h" #include "refs.h" #include "posix.h" static git_repository *repo; static git_index *repo_index; #define TEST_REPO_PATH "merge-resolve" #define TEST_INDEX_PATH TEST_REPO_PATH "/.git/index" #define UPTODATE_BRANCH "master" #define PREVIOUS_BRANCH "previous" #define FASTFORWARD_BRANCH "ff_branch" #define FASTFORWARD_ID "fd89f8cffb663ac89095a0f9764902e93ceaca6a" #define NOFASTFORWARD_BRANCH "branch" #define NOFASTFORWARD_ID "7cb63eed597130ba4abb87b3e544b85021905520" /* Fixture setup and teardown */ void test_merge_workdir_analysis__initialize(void) { repo = cl_git_sandbox_init(TEST_REPO_PATH); git_repository_index(&repo_index, repo); } void test_merge_workdir_analysis__cleanup(void) { git_index_free(repo_index); cl_git_sandbox_cleanup(); } static void analysis_from_branch( git_merge_analysis_t *merge_analysis, git_merge_preference_t *merge_pref, const char *our_branchname, const char *their_branchname) { git_buf our_refname = GIT_BUF_INIT; git_buf their_refname = GIT_BUF_INIT; git_reference *our_ref; git_reference *their_ref; git_annotated_commit *their_head; if (our_branchname != NULL) { cl_git_pass(git_buf_printf(&our_refname, "%s%s", GIT_REFS_HEADS_DIR, our_branchname)); cl_git_pass(git_reference_lookup(&our_ref, repo, git_buf_cstr(&our_refname))); } else { cl_git_pass(git_reference_lookup(&our_ref, repo, GIT_HEAD_FILE)); } cl_git_pass(git_buf_printf(&their_refname, "%s%s", GIT_REFS_HEADS_DIR, their_branchname)); cl_git_pass(git_reference_lookup(&their_ref, repo, git_buf_cstr(&their_refname))); cl_git_pass(git_annotated_commit_from_ref(&their_head, repo, their_ref)); cl_git_pass(git_merge_analysis_for_ref(merge_analysis, merge_pref, repo, our_ref, (const git_annotated_commit **)&their_head, 1)); git_buf_dispose(&our_refname); git_buf_dispose(&their_refname); git_annotated_commit_free(their_head); git_reference_free(our_ref); git_reference_free(their_ref); } void test_merge_workdir_analysis__fastforward(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; analysis_from_branch(&merge_analysis, &merge_pref, NULL, FASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL|GIT_MERGE_ANALYSIS_FASTFORWARD, merge_analysis); } void test_merge_workdir_analysis__no_fastforward(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; analysis_from_branch(&merge_analysis, &merge_pref, NULL, NOFASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, merge_analysis); } void test_merge_workdir_analysis__uptodate(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; analysis_from_branch(&merge_analysis, &merge_pref, NULL, UPTODATE_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__uptodate_merging_prev_commit(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; analysis_from_branch(&merge_analysis, &merge_pref, NULL, PREVIOUS_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__unborn(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; git_buf master = GIT_BUF_INIT; git_buf_joinpath(&master, git_repository_path(repo), "refs/heads/master"); p_unlink(git_buf_cstr(&master)); analysis_from_branch(&merge_analysis, &merge_pref, NULL, NOFASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_FASTFORWARD|GIT_MERGE_ANALYSIS_UNBORN, merge_analysis); git_buf_dispose(&master); } void test_merge_workdir_analysis__fastforward_with_config_noff(void) { git_config *config; git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; git_repository_config(&config, repo); git_config_set_string(config, "merge.ff", "false"); analysis_from_branch(&merge_analysis, &merge_pref, NULL, FASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL|GIT_MERGE_ANALYSIS_FASTFORWARD, merge_analysis); cl_assert_equal_i(GIT_MERGE_PREFERENCE_NO_FASTFORWARD, (merge_pref & GIT_MERGE_PREFERENCE_NO_FASTFORWARD)); } void test_merge_workdir_analysis__no_fastforward_with_config_ffonly(void) { git_config *config; git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; git_repository_config(&config, repo); git_config_set_string(config, "merge.ff", "only"); analysis_from_branch(&merge_analysis, &merge_pref, NULL, NOFASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, merge_analysis); cl_assert_equal_i(GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY, (merge_pref & GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY)); } void test_merge_workdir_analysis__between_uptodate_refs(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; analysis_from_branch(&merge_analysis, &merge_pref, NOFASTFORWARD_BRANCH, PREVIOUS_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_UP_TO_DATE, merge_analysis); } void test_merge_workdir_analysis__between_noff_refs(void) { git_merge_analysis_t merge_analysis; git_merge_preference_t merge_pref; analysis_from_branch(&merge_analysis, &merge_pref, "branch", FASTFORWARD_BRANCH); cl_assert_equal_i(GIT_MERGE_ANALYSIS_NORMAL, merge_analysis); }
323ee271dca8f80304ba066b16595e4b7f252ce6
af59fd7f438cfb2f46d48b93b097053cde238723
/pd/utils.h
cf333bc70aec843761c36cc8e205d06105ff5d77
[ "MIT" ]
permissive
glmcdona/Process-Dump
8a9a3f152969d0bc6343b95875245f585369891b
1d91e0eb7b9b2ba21136bf3903eb107b5004120d
refs/heads/main
2023-08-27T02:32:48.188628
2023-08-04T21:30:56
2023-08-04T21:30:56
46,630,078
1,497
277
MIT
2023-08-04T21:30:57
2015-11-21T19:25:28
C
UTF-8
C
false
false
1,594
h
utils.h
#pragma once static bool test_read( unsigned char* buffer, SIZE_T length, unsigned char* read_ptr, SIZE_T read_length ) { return read_ptr >= buffer && read_ptr + read_length <= buffer + length; }; static bool write_memory(HANDLE ph, unsigned __int64 address, unsigned __int64 value) { SIZE_T num_written = 0; return WriteProcessMemory(ph, (LPVOID) address, &value, sizeof(value), &num_written) && num_written == sizeof(value); }; static bool write_memory(HANDLE ph, unsigned __int64 address, unsigned __int32 value) { SIZE_T num_written = 0; return WriteProcessMemory(ph, (LPVOID)address, &value, sizeof(value), &num_written) && num_written == sizeof(value); }; static bool read_memory(HANDLE ph, unsigned __int64 address, unsigned __int64* value) { SIZE_T num_read = 0; return ReadProcessMemory(ph, (LPVOID)address, value, sizeof(*value), &num_read) && num_read == sizeof(*value); }; static bool read_memory(HANDLE ph, unsigned __int64 address, unsigned __int32* value) { SIZE_T num_read = 0; return ReadProcessMemory(ph, (LPVOID)address, value, sizeof(*value), &num_read) && num_read == sizeof(*value); }; static bool read_memory(HANDLE ph, unsigned __int64 address, void** value) { SIZE_T num_read = 0; return ReadProcessMemory(ph, (LPVOID)address, value, sizeof(*value), &num_read) && num_read == sizeof(*value); }; static bool read_memory(HANDLE ph, unsigned __int64 address, DWORD* value) { SIZE_T num_read = 0; return ReadProcessMemory(ph, (LPVOID)address, value, sizeof(*value), &num_read) && num_read == sizeof(*value); };
ee589f6195314119c0a68c6c9b0ab73edbeb67e4
8a51a96f61699f0318315ccc89cef39f6866f2b5
/src/bin/pg_dump/compress_zstd.c
82e3310100fe257533e480e644122a433410dde1
[ "PostgreSQL" ]
permissive
postgres/postgres
979febf2b41c00090d1256228f768f33e7ef3b6f
b5934bfd6071fed3a38cea0cfaa93afda63d9c0c
refs/heads/master
2023-08-31T00:10:01.373472
2023-08-30T23:07:48
2023-08-30T23:07:48
927,442
13,691
4,807
NOASSERTION
2023-09-09T13:59:15
2010-09-21T11:35:45
C
UTF-8
C
false
false
13,173
c
compress_zstd.c
/*------------------------------------------------------------------------- * * compress_zstd.c * Routines for archivers to write a Zstd compressed data stream. * * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION * src/bin/pg_dump/compress_zstd.c * *------------------------------------------------------------------------- */ #include "postgres_fe.h" #include "pg_backup_utils.h" #include "compress_zstd.h" #ifndef USE_ZSTD void InitCompressorZstd(CompressorState *cs, const pg_compress_specification compression_spec) { pg_fatal("this build does not support compression with %s", "ZSTD"); } void InitCompressFileHandleZstd(CompressFileHandle *CFH, const pg_compress_specification compression_spec) { pg_fatal("this build does not support compression with %s", "ZSTD"); } #else #include <zstd.h> typedef struct ZstdCompressorState { /* This is a normal file to which we read/write compressed data */ FILE *fp; ZSTD_CStream *cstream; ZSTD_DStream *dstream; ZSTD_outBuffer output; ZSTD_inBuffer input; /* pointer to a static string like from strerror(), for Zstd_write() */ const char *zstderror; } ZstdCompressorState; static ZSTD_CStream *_ZstdCStreamParams(pg_compress_specification compress); static void EndCompressorZstd(ArchiveHandle *AH, CompressorState *cs); static void WriteDataToArchiveZstd(ArchiveHandle *AH, CompressorState *cs, const void *data, size_t dLen); static void ReadDataFromArchiveZstd(ArchiveHandle *AH, CompressorState *cs); static void _Zstd_CCtx_setParam_or_die(ZSTD_CStream *cstream, ZSTD_cParameter param, int value, char *paramname) { size_t res; res = ZSTD_CCtx_setParameter(cstream, param, value); if (ZSTD_isError(res)) pg_fatal("could not set compression parameter \"%s\": %s", paramname, ZSTD_getErrorName(res)); } /* Return a compression stream with parameters set per argument */ static ZSTD_CStream * _ZstdCStreamParams(pg_compress_specification compress) { ZSTD_CStream *cstream; cstream = ZSTD_createCStream(); if (cstream == NULL) pg_fatal("could not initialize compression library"); _Zstd_CCtx_setParam_or_die(cstream, ZSTD_c_compressionLevel, compress.level, "level"); if (compress.options & PG_COMPRESSION_OPTION_LONG_DISTANCE) _Zstd_CCtx_setParam_or_die(cstream, ZSTD_c_enableLongDistanceMatching, compress.long_distance, "long"); return cstream; } /* Helper function for WriteDataToArchiveZstd and EndCompressorZstd */ static void _ZstdWriteCommon(ArchiveHandle *AH, CompressorState *cs, bool flush) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) cs->private_data; ZSTD_inBuffer *input = &zstdcs->input; ZSTD_outBuffer *output = &zstdcs->output; /* Loop while there's any input or until flushed */ while (input->pos != input->size || flush) { size_t res; output->pos = 0; res = ZSTD_compressStream2(zstdcs->cstream, output, input, flush ? ZSTD_e_end : ZSTD_e_continue); if (ZSTD_isError(res)) pg_fatal("could not compress data: %s", ZSTD_getErrorName(res)); /* * Extra paranoia: avoid zero-length chunks, since a zero length chunk * is the EOF marker in the custom format. This should never happen * but... */ if (output->pos > 0) cs->writeF(AH, output->dst, output->pos); if (res == 0) break; /* End of frame or all input consumed */ } } static void EndCompressorZstd(ArchiveHandle *AH, CompressorState *cs) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) cs->private_data; if (cs->readF != NULL) { Assert(zstdcs->cstream == NULL); ZSTD_freeDStream(zstdcs->dstream); pg_free(unconstify(void *, zstdcs->input.src)); } else if (cs->writeF != NULL) { Assert(zstdcs->dstream == NULL); _ZstdWriteCommon(AH, cs, true); ZSTD_freeCStream(zstdcs->cstream); pg_free(zstdcs->output.dst); } pg_free(zstdcs); } static void WriteDataToArchiveZstd(ArchiveHandle *AH, CompressorState *cs, const void *data, size_t dLen) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) cs->private_data; zstdcs->input.src = data; zstdcs->input.size = dLen; zstdcs->input.pos = 0; _ZstdWriteCommon(AH, cs, false); } static void ReadDataFromArchiveZstd(ArchiveHandle *AH, CompressorState *cs) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) cs->private_data; ZSTD_outBuffer *output = &zstdcs->output; ZSTD_inBuffer *input = &zstdcs->input; size_t input_allocated_size = ZSTD_DStreamInSize(); size_t res; for (;;) { size_t cnt; /* * Read compressed data. Note that readF can resize the buffer; the * new size is tracked and used for future loops. */ input->size = input_allocated_size; cnt = cs->readF(AH, (char **) unconstify(void **, &input->src), &input->size); /* ensure that readF didn't *shrink* the buffer */ Assert(input->size >= input_allocated_size); input_allocated_size = input->size; input->size = cnt; input->pos = 0; if (cnt == 0) break; /* Now decompress */ while (input->pos < input->size) { output->pos = 0; res = ZSTD_decompressStream(zstdcs->dstream, output, input); if (ZSTD_isError(res)) pg_fatal("could not decompress data: %s", ZSTD_getErrorName(res)); /* * then write the decompressed data to the output handle */ ((char *) output->dst)[output->pos] = '\0'; ahwrite(output->dst, 1, output->pos, AH); if (res == 0) break; /* End of frame */ } } } /* Public routine that supports Zstd compressed data I/O */ void InitCompressorZstd(CompressorState *cs, const pg_compress_specification compression_spec) { ZstdCompressorState *zstdcs; cs->readData = ReadDataFromArchiveZstd; cs->writeData = WriteDataToArchiveZstd; cs->end = EndCompressorZstd; cs->compression_spec = compression_spec; zstdcs = (ZstdCompressorState *) pg_malloc0(sizeof(*zstdcs)); cs->private_data = zstdcs; /* We expect that exactly one of readF/writeF is specified */ Assert((cs->readF == NULL) != (cs->writeF == NULL)); if (cs->readF != NULL) { zstdcs->dstream = ZSTD_createDStream(); if (zstdcs->dstream == NULL) pg_fatal("could not initialize compression library"); zstdcs->input.size = ZSTD_DStreamInSize(); zstdcs->input.src = pg_malloc(zstdcs->input.size); /* * output.size is the buffer size we tell zstd it can output to. * Allocate an additional byte such that ReadDataFromArchiveZstd() can * call ahwrite() with a null-terminated string, which is an optimized * case in ExecuteSqlCommandBuf(). */ zstdcs->output.size = ZSTD_DStreamOutSize(); zstdcs->output.dst = pg_malloc(zstdcs->output.size + 1); } else if (cs->writeF != NULL) { zstdcs->cstream = _ZstdCStreamParams(cs->compression_spec); zstdcs->output.size = ZSTD_CStreamOutSize(); zstdcs->output.dst = pg_malloc(zstdcs->output.size); zstdcs->output.pos = 0; } } /* * Compressed stream API */ static bool Zstd_read(void *ptr, size_t size, size_t *rdsize, CompressFileHandle *CFH) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) CFH->private_data; ZSTD_inBuffer *input = &zstdcs->input; ZSTD_outBuffer *output = &zstdcs->output; size_t input_allocated_size = ZSTD_DStreamInSize(); size_t res, cnt; output->size = size; output->dst = ptr; output->pos = 0; for (;;) { Assert(input->pos <= input->size); Assert(input->size <= input_allocated_size); /* * If the input is completely consumed, start back at the beginning */ if (input->pos == input->size) { /* input->size is size produced by "fread" */ input->size = 0; /* input->pos is position consumed by decompress */ input->pos = 0; } /* read compressed data if we must produce more input */ if (input->pos == input->size) { cnt = fread(unconstify(void *, input->src), 1, input_allocated_size, zstdcs->fp); input->size = cnt; Assert(cnt <= input_allocated_size); /* If we have no more input to consume, we're done */ if (cnt == 0) break; } while (input->pos < input->size) { /* now decompress */ res = ZSTD_decompressStream(zstdcs->dstream, output, input); if (ZSTD_isError(res)) pg_fatal("could not decompress data: %s", ZSTD_getErrorName(res)); if (output->pos == output->size) break; /* No more room for output */ if (res == 0) break; /* End of frame */ } if (output->pos == output->size) break; /* We read all the data that fits */ } if (rdsize != NULL) *rdsize = output->pos; return true; } static bool Zstd_write(const void *ptr, size_t size, CompressFileHandle *CFH) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) CFH->private_data; ZSTD_inBuffer *input = &zstdcs->input; ZSTD_outBuffer *output = &zstdcs->output; size_t res, cnt; input->src = ptr; input->size = size; input->pos = 0; /* Consume all input, to be flushed later */ while (input->pos != input->size) { output->pos = 0; res = ZSTD_compressStream2(zstdcs->cstream, output, input, ZSTD_e_continue); if (ZSTD_isError(res)) { zstdcs->zstderror = ZSTD_getErrorName(res); return false; } cnt = fwrite(output->dst, 1, output->pos, zstdcs->fp); if (cnt != output->pos) { zstdcs->zstderror = strerror(errno); return false; } } return size; } static int Zstd_getc(CompressFileHandle *CFH) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) CFH->private_data; int ret; if (CFH->read_func(&ret, 1, NULL, CFH) != 1) { if (feof(zstdcs->fp)) pg_fatal("could not read from input file: end of file"); else pg_fatal("could not read from input file: %m"); } return ret; } static char * Zstd_gets(char *buf, int len, CompressFileHandle *CFH) { int i; Assert(len > 0); /* * Read one byte at a time until newline or EOF. This is only used to read * the list of LOs, and the I/O is buffered anyway. */ for (i = 0; i < len - 1; ++i) { size_t readsz; if (!CFH->read_func(&buf[i], 1, &readsz, CFH)) break; if (readsz != 1) break; if (buf[i] == '\n') { ++i; break; } } buf[i] = '\0'; return i > 0 ? buf : NULL; } static bool Zstd_close(CompressFileHandle *CFH) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) CFH->private_data; if (zstdcs->cstream) { size_t res, cnt; ZSTD_inBuffer *input = &zstdcs->input; ZSTD_outBuffer *output = &zstdcs->output; /* Loop until the compression buffers are fully consumed */ for (;;) { output->pos = 0; res = ZSTD_compressStream2(zstdcs->cstream, output, input, ZSTD_e_end); if (ZSTD_isError(res)) { zstdcs->zstderror = ZSTD_getErrorName(res); return false; } cnt = fwrite(output->dst, 1, output->pos, zstdcs->fp); if (cnt != output->pos) { zstdcs->zstderror = strerror(errno); return false; } if (res == 0) break; /* End of frame */ } ZSTD_freeCStream(zstdcs->cstream); pg_free(zstdcs->output.dst); } if (zstdcs->dstream) { ZSTD_freeDStream(zstdcs->dstream); pg_free(unconstify(void *, zstdcs->input.src)); } if (fclose(zstdcs->fp) != 0) return false; pg_free(zstdcs); return true; } static bool Zstd_eof(CompressFileHandle *CFH) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) CFH->private_data; return feof(zstdcs->fp); } static bool Zstd_open(const char *path, int fd, const char *mode, CompressFileHandle *CFH) { FILE *fp; ZstdCompressorState *zstdcs; if (fd >= 0) fp = fdopen(fd, mode); else fp = fopen(path, mode); if (fp == NULL) return false; zstdcs = (ZstdCompressorState *) pg_malloc0(sizeof(*zstdcs)); CFH->private_data = zstdcs; zstdcs->fp = fp; if (mode[0] == 'r') { zstdcs->input.src = pg_malloc0(ZSTD_DStreamInSize()); zstdcs->dstream = ZSTD_createDStream(); if (zstdcs->dstream == NULL) pg_fatal("could not initialize compression library"); } else if (mode[0] == 'w' || mode[0] == 'a') { zstdcs->output.size = ZSTD_CStreamOutSize(); zstdcs->output.dst = pg_malloc0(zstdcs->output.size); zstdcs->cstream = _ZstdCStreamParams(CFH->compression_spec); if (zstdcs->cstream == NULL) pg_fatal("could not initialize compression library"); } else pg_fatal("unhandled mode \"%s\"", mode); return true; } static bool Zstd_open_write(const char *path, const char *mode, CompressFileHandle *CFH) { char fname[MAXPGPATH]; sprintf(fname, "%s.zst", path); return CFH->open_func(fname, -1, mode, CFH); } static const char * Zstd_get_error(CompressFileHandle *CFH) { ZstdCompressorState *zstdcs = (ZstdCompressorState *) CFH->private_data; return zstdcs->zstderror; } void InitCompressFileHandleZstd(CompressFileHandle *CFH, const pg_compress_specification compression_spec) { CFH->open_func = Zstd_open; CFH->open_write_func = Zstd_open_write; CFH->read_func = Zstd_read; CFH->write_func = Zstd_write; CFH->gets_func = Zstd_gets; CFH->getc_func = Zstd_getc; CFH->close_func = Zstd_close; CFH->eof_func = Zstd_eof; CFH->get_error_func = Zstd_get_error; CFH->compression_spec = compression_spec; CFH->private_data = NULL; } #endif /* USE_ZSTD */
58278df8e5d51d60ddcbb46df3358e0f80819789
1661c43eaf9e44dfe7cce269cfaae62e336036f1
/blink/loader.h
15388b5f8a991cb454c957245985ff0f093c7307
[]
permissive
jart/blink
3354eaf084e3e85a50372f1a93fc75ff2b9488b1
312a027d0908c1b1f9d1e9ebba837da569606b82
refs/heads/master
2023-08-31T21:30:40.551686
2023-08-22T15:42:44
2023-08-22T15:42:44
561,183,031
6,089
192
ISC
2023-08-22T15:42:46
2022-11-03T06:07:09
C
UTF-8
C
false
false
504
h
loader.h
#ifndef BLINK_LOADER_H_ #define BLINK_LOADER_H_ #include "blink/elf.h" #include "blink/machine.h" bool CanEmulateExecutable(struct Machine *, char **, char ***); void BootProgram(struct Machine *, struct Elf *, u8); void LoadProgram(struct Machine *, char *, char *, char **, char **, const char *); void LoadDebugSymbols(struct System *); void LoadFileSymbols(struct System *, const char *, i64); bool IsSupportedExecutable(const char *, void *, size_t); #endif /* BLINK_LOADER_H_ */
e2a1278fd61436e62feb8c299fa4a2036272239d
0c4a079b5ac2fc627b91b48f4bcf6faa804d5a28
/third_party/wavpack/src/unpack_seek.c
f3ab081e8dc1c824be7e32bac5cd42d55b732425
[ "LGPL-2.0-or-later", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-synthesis-toolkit", "LicenseRef-scancode-public-domain" ]
permissive
ddiakopoulos/libnyquist
37eb768bcf31cb310c710ee43c76d33baa823282
767efd97cdd7a281d193296586e708490eb6e54f
refs/heads/master
2023-08-18T04:43:21.137134
2023-02-13T07:54:10
2023-02-13T07:54:10
32,698,321
515
77
BSD-2-Clause
2022-09-25T20:29:39
2015-03-22T22:15:11
C++
UTF-8
C
false
false
13,537
c
unpack_seek.c
//////////////////////////////////////////////////////////////////////////// // **** WAVPACK **** // // Hybrid Lossless Wavefile Compressor // // Copyright (c) 1998 - 2013 Conifer Software. // // All Rights Reserved. // // Distributed under the BSD Software License (see license.txt) // //////////////////////////////////////////////////////////////////////////// // unpack_seek.c // This module provides the high-level API for unpacking audio data from // a specific sample index (i.e., seeking). #ifndef NO_SEEKING #include <stdlib.h> #include <string.h> #include "wavpack_local.h" ///////////////////////////// executable code //////////////////////////////// static int64_t find_sample (WavpackContext *wpc, void *infile, int64_t header_pos, int64_t sample); // Seek to the specifed sample index, returning TRUE on success. Note that // files generated with version 4.0 or newer will seek almost immediately. // Older files can take quite long if required to seek through unplayed // portions of the file, but will create a seek map so that reverse seeks // (or forward seeks to already scanned areas) will be very fast. After a // FALSE return the file should not be accessed again (other than to close // it); this is a fatal error. int WavpackSeekSample (WavpackContext *wpc, uint32_t sample) { return WavpackSeekSample64 (wpc, sample); } int WavpackSeekSample64 (WavpackContext *wpc, int64_t sample) { WavpackStream *wps = wpc->streams ? wpc->streams [wpc->current_stream = 0] : NULL; uint32_t bcount, samples_to_skip, samples_to_decode = 0; int32_t *buffer; if (wpc->total_samples == -1 || sample >= wpc->total_samples || !wpc->reader->can_seek (wpc->wv_in) || (wpc->open_flags & OPEN_STREAMING) || (wpc->wvc_flag && !wpc->reader->can_seek (wpc->wvc_in))) return FALSE; #ifdef ENABLE_LEGACY if (wpc->stream3) return seek_sample3 (wpc, (uint32_t) sample); #endif #ifdef ENABLE_DSD if (wpc->decimation_context) { // the decimation code needs some context to be sample accurate if (sample < 16) { samples_to_decode = (uint32_t) sample; sample = 0; } else { samples_to_decode = 16; sample -= 16; } } #endif if (!wps->wphdr.block_samples || !(wps->wphdr.flags & INITIAL_BLOCK) || sample < GET_BLOCK_INDEX (wps->wphdr) || sample >= GET_BLOCK_INDEX (wps->wphdr) + wps->wphdr.block_samples) { free_streams (wpc); wpc->filepos = find_sample (wpc, wpc->wv_in, wpc->filepos, sample); if (wpc->filepos == -1) return FALSE; if (wpc->wvc_flag) { wpc->file2pos = find_sample (wpc, wpc->wvc_in, 0, sample); if (wpc->file2pos == -1) return FALSE; } } if (!wps->blockbuff) { wpc->reader->set_pos_abs (wpc->wv_in, wpc->filepos); wpc->reader->read_bytes (wpc->wv_in, &wps->wphdr, sizeof (WavpackHeader)); WavpackLittleEndianToNative (&wps->wphdr, WavpackHeaderFormat); wps->blockbuff = (unsigned char *)malloc (wps->wphdr.ckSize + 8); memcpy (wps->blockbuff, &wps->wphdr, sizeof (WavpackHeader)); if (wpc->reader->read_bytes (wpc->wv_in, wps->blockbuff + sizeof (WavpackHeader), wps->wphdr.ckSize - 24) != wps->wphdr.ckSize - 24) { free_streams (wpc); return FALSE; } // render corrupt blocks harmless if (!WavpackVerifySingleBlock (wps->blockbuff, !(wpc->open_flags & OPEN_NO_CHECKSUM))) { wps->wphdr.ckSize = sizeof (WavpackHeader) - 8; wps->wphdr.block_samples = 0; memcpy (wps->blockbuff, &wps->wphdr, 32); } SET_BLOCK_INDEX (wps->wphdr, GET_BLOCK_INDEX (wps->wphdr) - wpc->initial_index); memcpy (wps->blockbuff, &wps->wphdr, sizeof (WavpackHeader)); wps->init_done = FALSE; if (wpc->wvc_flag) { wpc->reader->set_pos_abs (wpc->wvc_in, wpc->file2pos); wpc->reader->read_bytes (wpc->wvc_in, &wps->wphdr, sizeof (WavpackHeader)); WavpackLittleEndianToNative (&wps->wphdr, WavpackHeaderFormat); wps->block2buff = (unsigned char *)malloc (wps->wphdr.ckSize + 8); memcpy (wps->block2buff, &wps->wphdr, sizeof (WavpackHeader)); if (wpc->reader->read_bytes (wpc->wvc_in, wps->block2buff + sizeof (WavpackHeader), wps->wphdr.ckSize - 24) != wps->wphdr.ckSize - 24) { free_streams (wpc); return FALSE; } // render corrupt blocks harmless if (!WavpackVerifySingleBlock (wps->block2buff, !(wpc->open_flags & OPEN_NO_CHECKSUM))) { wps->wphdr.ckSize = sizeof (WavpackHeader) - 8; wps->wphdr.block_samples = 0; memcpy (wps->block2buff, &wps->wphdr, 32); } SET_BLOCK_INDEX (wps->wphdr, GET_BLOCK_INDEX (wps->wphdr) - wpc->initial_index); memcpy (wps->block2buff, &wps->wphdr, sizeof (WavpackHeader)); } if (!wps->init_done && !unpack_init (wpc)) { free_streams (wpc); return FALSE; } wps->init_done = TRUE; } while (!wpc->reduced_channels && !(wps->wphdr.flags & FINAL_BLOCK)) { if (++wpc->current_stream == wpc->num_streams) { if (wpc->num_streams == wpc->max_streams) { free_streams (wpc); return FALSE; } wpc->streams = (WavpackStream **)realloc (wpc->streams, (wpc->num_streams + 1) * sizeof (wpc->streams [0])); wps = wpc->streams [wpc->num_streams++] = (WavpackStream *)malloc (sizeof (WavpackStream)); CLEAR (*wps); bcount = read_next_header (wpc->reader, wpc->wv_in, &wps->wphdr); if (bcount == (uint32_t) -1) { free_streams (wpc); return FALSE; } wps->blockbuff = (unsigned char *)malloc (wps->wphdr.ckSize + 8); memcpy (wps->blockbuff, &wps->wphdr, 32); if (wpc->reader->read_bytes (wpc->wv_in, wps->blockbuff + 32, wps->wphdr.ckSize - 24) != wps->wphdr.ckSize - 24) { free_streams (wpc); return FALSE; } // render corrupt blocks harmless if (!WavpackVerifySingleBlock (wps->blockbuff, !(wpc->open_flags & OPEN_NO_CHECKSUM))) { wps->wphdr.ckSize = sizeof (WavpackHeader) - 8; wps->wphdr.block_samples = 0; memcpy (wps->blockbuff, &wps->wphdr, 32); } wps->init_done = FALSE; if (wpc->wvc_flag && !read_wvc_block (wpc)) { free_streams (wpc); return FALSE; } if (!wps->init_done && !unpack_init (wpc)) { free_streams (wpc); return FALSE; } wps->init_done = TRUE; } else wps = wpc->streams [wpc->current_stream]; } if (sample < wps->sample_index) { for (wpc->current_stream = 0; wpc->current_stream < wpc->num_streams; wpc->current_stream++) if (!unpack_init (wpc)) return FALSE; else wpc->streams [wpc->current_stream]->init_done = TRUE; } samples_to_skip = (uint32_t) (sample - wps->sample_index); if (samples_to_skip > 131072) { free_streams (wpc); return FALSE; } if (samples_to_skip) { buffer = (int32_t *)malloc (samples_to_skip * 8); for (wpc->current_stream = 0; wpc->current_stream < wpc->num_streams; wpc->current_stream++) #ifdef ENABLE_DSD if (wpc->streams [wpc->current_stream]->wphdr.flags & DSD_FLAG) unpack_dsd_samples (wpc, buffer, samples_to_skip); else #endif unpack_samples (wpc, buffer, samples_to_skip); free (buffer); } wpc->current_stream = 0; #ifdef ENABLE_DSD if (wpc->decimation_context) decimate_dsd_reset (wpc->decimation_context); if (samples_to_decode) { buffer = (int32_t *)malloc (samples_to_decode * wpc->config.num_channels * 4); if (buffer) { WavpackUnpackSamples (wpc, buffer, samples_to_decode); free (buffer); } } #endif return TRUE; } // Find a valid WavPack header, searching either from the current file position // (or from the specified position if not -1) and store it (endian corrected) // at the specified pointer. The return value is the exact file position of the // header, although we may have actually read past it. Because this function // is used for seeking to a specific audio sample, it only considers blocks // that contain audio samples for the initial stream to be valid. #define BUFSIZE 4096 static int64_t find_header (WavpackStreamReader64 *reader, void *id, int64_t filepos, WavpackHeader *wphdr) { unsigned char *buffer = (unsigned char *)malloc (BUFSIZE), *sp = buffer, *ep = buffer; if (filepos != (uint32_t) -1 && reader->set_pos_abs (id, filepos)) { free (buffer); return -1; } while (1) { int bleft; if (sp < ep) { bleft = (int)(ep - sp); memcpy (buffer, sp, bleft); ep -= (sp - buffer); sp = buffer; } else { if (sp > ep) if (reader->set_pos_rel (id, (int32_t)(sp - ep), SEEK_CUR)) { free (buffer); return -1; } sp = ep = buffer; bleft = 0; } ep += reader->read_bytes (id, ep, BUFSIZE - bleft); if (ep - sp < 32) { free (buffer); return -1; } while (sp + 32 <= ep) if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' && !(*++sp & 1) && sp [2] < 16 && !sp [3] && (sp [2] || sp [1] || *sp >= 24) && sp [5] == 4 && sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff) && sp [18] < 3 && !sp [19]) { memcpy (wphdr, sp - 4, sizeof (*wphdr)); WavpackLittleEndianToNative (wphdr, WavpackHeaderFormat); if (wphdr->block_samples && (wphdr->flags & INITIAL_BLOCK)) { free (buffer); return reader->get_pos (id) - (ep - sp + 4); } if (wphdr->ckSize > 1024) sp += wphdr->ckSize - 1024; } } } // Find the WavPack block that contains the specified sample. If "header_pos" // is zero, then no information is assumed except the total number of samples // in the file and its size in bytes. If "header_pos" is non-zero then we // assume that it is the file position of the valid header image contained in // the first stream and we can limit our search to either the portion above // or below that point. If a .wvc file is being used, then this must be called // for that file also. static int64_t find_sample (WavpackContext *wpc, void *infile, int64_t header_pos, int64_t sample) { WavpackStream *wps = wpc->streams [wpc->current_stream]; int64_t file_pos1 = 0, file_pos2 = wpc->reader->get_length (infile); int64_t sample_pos1 = 0, sample_pos2 = wpc->total_samples; double ratio = 0.96; int file_skip = 0; if (sample >= wpc->total_samples) return -1; if (header_pos && wps->wphdr.block_samples) { if (GET_BLOCK_INDEX (wps->wphdr) > sample) { sample_pos2 = GET_BLOCK_INDEX (wps->wphdr); file_pos2 = header_pos; } else if (GET_BLOCK_INDEX (wps->wphdr) + wps->wphdr.block_samples <= sample) { sample_pos1 = GET_BLOCK_INDEX (wps->wphdr); file_pos1 = header_pos; } else return header_pos; } while (1) { double bytes_per_sample; int64_t seek_pos; bytes_per_sample = (double) file_pos2 - file_pos1; bytes_per_sample /= sample_pos2 - sample_pos1; seek_pos = file_pos1 + (file_skip ? 32 : 0); seek_pos += (int64_t)(bytes_per_sample * (sample - sample_pos1) * ratio); seek_pos = find_header (wpc->reader, infile, seek_pos, &wps->wphdr); if (seek_pos != (int64_t) -1) SET_BLOCK_INDEX (wps->wphdr, GET_BLOCK_INDEX (wps->wphdr) - wpc->initial_index); if (seek_pos == (int64_t) -1 || seek_pos >= file_pos2) { if (ratio > 0.0) { if ((ratio -= 0.24) < 0.0) ratio = 0.0; } else return -1; } else if (GET_BLOCK_INDEX (wps->wphdr) > sample) { sample_pos2 = GET_BLOCK_INDEX (wps->wphdr); file_pos2 = seek_pos; } else if (GET_BLOCK_INDEX (wps->wphdr) + wps->wphdr.block_samples <= sample) { if (seek_pos == file_pos1) file_skip = 1; else { sample_pos1 = GET_BLOCK_INDEX (wps->wphdr); file_pos1 = seek_pos; } } else return seek_pos; } } #endif
a976fa08e2fae80d8303542b49a5a4a3563ea714
431a5c28b8dfcc7d6ca6f4f97bf370cd770547a7
/src/tmx/Asn_J2735/include/asn_j2735_r63/RTCM-Revision.h
bc7ddf4f196c85a02645f80f2f9028ac27a296d2
[ "Apache-2.0" ]
permissive
usdot-fhwa-OPS/V2X-Hub
134061cfb55d8c83e871f7fd4bbfa5d8d3092eb0
aae33e6a16b8a30e1faee31a7ee863d191be06b8
refs/heads/develop
2023-08-26T10:10:59.989176
2023-08-24T14:58:21
2023-08-24T14:58:21
168,020,929
106
63
null
2023-09-11T20:24:45
2019-01-28T19:16:45
C
UTF-8
C
false
false
1,541
h
RTCM-Revision.h
/* * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) * From ASN.1 module "DSRC" * found in "J2735_201603_ASN_CC.asn" * `asn1c -gen-PER -fcompound-names -fincludes-quoted -fskeletons-copy` */ #ifndef _RTCM_Revision_H_ #define _RTCM_Revision_H_ #include "asn_application.h" /* Including external dependencies */ #include "NativeEnumerated.h" #ifdef __cplusplus extern "C" { #endif /* Dependencies */ typedef enum RTCM_Revision { RTCM_Revision_unknown = 0, RTCM_Revision_rtcmRev2 = 1, RTCM_Revision_rtcmRev3 = 2, RTCM_Revision_reserved = 3 /* * Enumeration is extensible */ } e_RTCM_Revision; /* RTCM-Revision */ typedef long RTCM_Revision_t; /* Implementation */ extern asn_per_constraints_t asn_PER_type_RTCM_Revision_constr_1; extern asn_TYPE_descriptor_t asn_DEF_RTCM_Revision; extern const asn_INTEGER_specifics_t asn_SPC_RTCM_Revision_specs_1; asn_struct_free_f RTCM_Revision_free; asn_struct_print_f RTCM_Revision_print; asn_constr_check_f RTCM_Revision_constraint; ber_type_decoder_f RTCM_Revision_decode_ber; der_type_encoder_f RTCM_Revision_encode_der; xer_type_decoder_f RTCM_Revision_decode_xer; xer_type_encoder_f RTCM_Revision_encode_xer; oer_type_decoder_f RTCM_Revision_decode_oer; oer_type_encoder_f RTCM_Revision_encode_oer; per_type_decoder_f RTCM_Revision_decode_uper; per_type_encoder_f RTCM_Revision_encode_uper; per_type_decoder_f RTCM_Revision_decode_aper; per_type_encoder_f RTCM_Revision_encode_aper; #ifdef __cplusplus } #endif #endif /* _RTCM_Revision_H_ */ #include "asn_internal.h"
c41cba99e40e4809232b6c47549eef3c6add1164
c582b12eacb3ab4b420616d3b93f77fc76eb323e
/src/utils.c
685bc1df1c1d245d98c44746cfe8f7548ee76692
[ "MIT" ]
permissive
hashcat/hashcat-utils
bcbe92d85f13523d8271d2f390e18ef6ceb95c4c
3452403c52638e1beb88ee6f45164ba028d5c66c
refs/heads/master
2023-08-20T19:26:10.661621
2023-07-26T18:20:00
2023-07-26T18:20:00
46,592,019
1,267
402
MIT
2023-09-09T10:37:40
2015-11-20T23:16:07
C
UTF-8
C
false
false
1,254
c
utils.c
typedef unsigned int uint; int super_chop (char *s, const int len_orig) { int len = len_orig; char *p = s + len - 1; while (len) { if (*p != '\n') break; *p-- = 0; len--; } while (len) { if (*p != '\r') break; *p-- = 0; len--; } return len; } int fgetl (FILE *fd, const size_t sz, char *buf) { if (feof (fd)) return -1; char *s = fgets (buf, sz - 1, fd); if (s == NULL) return -1; const int len = (const int) strlen (s); return super_chop (s, len); } #ifdef _WINDOWS uint get_random_num (const uint min, const uint max) { if (min == max) return (min); const uint low = max - min; if (low == 0) return (0); uint64_t r = rand () % low; r += min; if (r > 0xffffffff) { exit (-1); } return (uint) r; } #else uint get_random_num (const uint min, const uint max) { if (min == max) return (min); const uint low = max - min; if (low == 0) return (0); uint data; FILE *fp = fopen("/dev/urandom", "rb"); if (fp == NULL) exit (1); if ((fread (&data, 1, sizeof (uint), fp)) != sizeof (uint)) { exit (-1); } fclose (fp); uint64_t r = data % low; r += min; if (r > 0xffffffff) { exit (-1); } return (uint) r; } #endif
ccc3b9411308bd720d2b116d81ad76353be20515
540c04254075b9fb22685a73487531f4c0b3e3ac
/lib-h3/device/fb/h3_lcdc_dump.c
fd912b7569650159658dc91406af2b36a71d8b64
[ "MIT" ]
permissive
vanvught/rpidmx512
197573217fc2c0c3673d6727d199c10e528a9fac
f27ae141d14c1d1cb9e0b62a291356ae0780c99f
refs/heads/master
2023-08-08T02:06:52.200184
2023-05-19T12:44:48
2023-05-19T12:44:48
15,496,962
380
125
MIT
2023-05-19T12:47:24
2013-12-28T18:27:20
C++
UTF-8
C
false
false
1,899
c
h3_lcdc_dump.c
/** * @file h3_lcdc_dump.c * */ /* Copyright (C) 2020 by Arjan van Vught mailto:info@orangepi-dmx.nl * * 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. */ #include <stdio.h> extern int uart0_printf(const char* fmt, ...); #define printf uart0_printf #include "h3.h" /* * The LCD0 module is used for HDMI */ void h3_lcdc_dump(void) { printf("LCD0\n"); printf(" GCTL %p\n", H3_LCD0->GCTL); printf(" GINT0 %p\n", H3_LCD0->GINT0); printf(" GINT1 %p\n", H3_LCD0->GINT1); printf(" TCON1_CTL %p\n", H3_LCD0->TCON1_CTL); printf(" TCON1_BASIC0 %p\n", H3_LCD0->TCON1_BASIC0); printf(" TCON1_BASIC1 %p\n", H3_LCD0->TCON1_BASIC1); printf(" TCON1_BASIC2 %p\n", H3_LCD0->TCON1_BASIC2); printf(" TCON1_BASIC3 %p\n", H3_LCD0->TCON1_BASIC3); printf(" TCON1_BASIC4 %p\n", H3_LCD0->TCON1_BASIC4); printf(" TCON1_BASIC5 %p\n", H3_LCD0->TCON1_BASIC5); }
13fdcea6e8bd86353c090ed3062df5af32b98bfe
085242ce442d9d4ad0cf6df9464b3b35e54bbe4c
/src/libponyc/type/cap.h
4f52724d1937d70a2e9905039ae9d405a1ffd390
[ "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
ponylang/ponyc
4c0a0b4a138b4213b4d67424ed313f322d17a87a
c393500e8f8222d648f803f78a705baf452bce05
refs/heads/main
2023-08-19T03:26:37.611328
2023-08-18T13:22:12
2023-08-18T14:27:49
6,667,084
4,901
572
BSD-2-Clause
2023-09-12T18:17:34
2012-11-13T07:38:25
C
UTF-8
C
false
false
3,362
h
cap.h
#ifndef TYPE_CAP_H #define TYPE_CAP_H #include <platform.h> #include "../ast/ast.h" #include "../ast/frame.h" PONY_EXTERN_C_BEGIN /** * Normalizes the capability and alias modifier to apply aliasing * and remove unnecessary ephemeral modifiers. */ void cap_aliasing(token_id* cap, token_id* eph); /** * Every possible instantiation of sub is a subtype of every possible * instantiation of super. */ bool is_cap_sub_cap(token_id sub, token_id subalias, token_id super, token_id supalias); /** * Every possible instantiation of sub is a member of the set of every possible * instantiation of super. */ bool is_cap_sub_cap_constraint(token_id sub, token_id subalias, token_id super, token_id supalias); /** * Check subtyping when matching type params. * When comparing rcap constraints, this uses the knowledge that * the constraint is altered from the original. * * If either rcap is a specific/singular capability, use the same rule * as in is_cap_sub_cap: every possible instantiation of sub must be a * subtype of every possible instantiation of super. * * If both rcaps are generic/set capabilities, use the following rule: * every instantiation of the super rcap must be a supertype of some * instantiation of the sub rcap (but not necessarily the same instantiation */ bool is_cap_sub_cap_bound(token_id sub, token_id subalias, token_id super, token_id supalias); /** * Every possible instantiation of the left side is locally compatible with * every possible instantiation of the right side. This relationship is * symmetric. */ bool is_cap_compat_cap(token_id left_cap, token_id left_eph, token_id right_cap, token_id right_eph); /** * Get the capability ast for a nominal type or type parameter reference. */ ast_t* cap_fetch(ast_t* type); /** * Get the capability for a nominal type or type parameter reference. */ token_id cap_single(ast_t* type); /** * Get the capability that should be used for dispatch. */ token_id cap_dispatch(ast_t* type); /** * The receiver capability is ref for constructors and behaviours. For * functions, it is defined by the function signature. A field initialiser is * considered part of a constructor. */ token_id cap_for_this(typecheck_t* t); typedef enum { WRITE, EXTRACT } direction; bool cap_safetomove(token_id into, token_id cap, direction direction); /** * Returns the upper bounds of left->right. */ bool cap_view_upper(token_id left_cap, token_id left_eph, token_id* right_cap, token_id* right_eph); /** * Returns the lower bounds of left->right. */ bool cap_view_lower(token_id left_cap, token_id left_eph, token_id* right_cap, token_id* right_eph); bool cap_sendable(token_id cap); bool cap_immutable_or_opaque(token_id cap); bool cap_mutable(token_id cap); /** * For a temporary capability (iso/trn), returns * the capability with no isolation constraints */ token_id cap_unisolated(token_id cap); ast_t* unisolated(ast_t* type); /** * Reads/writes the given capability/ephemeral values * and returns true if they were changed */ typedef bool cap_mutation(token_id* cap, token_id* eph); /** * Returns a type whose outermost capability/ies have * been modified by the given function. * * In the case of arrows, this modifies each component */ ast_t* modified_cap(ast_t* type, cap_mutation* mut); PONY_EXTERN_C_END #endif
45d2641395661c5d8f09a5bc723713320e2a2d21
961024a89ad28f2b54f6f05139a55b772b0d1077
/include/starter_choose.h
7a4f6e967b8f6077ab124dc437d7ed8fdd12b089
[]
no_license
BuffelSaft/pokeemerald
61ac3140a2f7d85baa426671a3b10abb4c8bcb13
93e96730fb3c771f7f08f9623ae36f0643c52d3d
refs/heads/master
2023-04-13T03:57:24.336111
2022-12-16T08:12:24
2022-12-16T08:12:24
216,335,931
143
55
null
2022-11-05T23:39:10
2019-10-20T09:18:38
C
UTF-8
C
false
false
368
h
starter_choose.h
#ifndef GUARD_STARTER_CHOOSE_H #define GUARD_STARTER_CHOOSE_H extern const u16 gBirchBagGrassPal[2][16]; extern const u32 gBirchBagTilemap[]; extern const u32 gBirchGrassTilemap[]; extern const u32 gBirchHelpGfx[]; extern const u32 gPokeballSelection_Gfx[]; u16 GetStarterPokemon(u16 chosenStarterId); void CB2_ChooseStarter(void); #endif // GUARD_STARTER_CHOOSE_H
73f008c3245a1df660ee84d77f091d8c60a1dde4
488e6c9b8555a253df765edc2232e8750e8b3a1b
/firmware-src/sources/commands/max31855_cmd.c
44fc5db9dbac7401935cb5c2209b5a5f586c17f4
[ "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
devicehive/esp8266-firmware
32edadae1d919438fd13388b562979030cc4472a
eb8a61482035bfc93a343db386d4470d17fa13d6
refs/heads/develop
2021-01-01T16:44:57.970370
2019-03-28T12:48:43
2019-03-28T12:48:43
39,383,605
182
61
MIT
2018-05-07T20:43:14
2015-07-20T12:53:51
C
UTF-8
C
false
false
1,266
c
max31855_cmd.c
/** * @file * @brief MAX31855 command handlers. * @copyright 2016 [DeviceHive](http://devicehive.com) * @author Nikolay Khabarov */ #include "commands/max31855_cmd.h" #include "devices/max31855.h" #include "DH/spi.h" #include "DH/adc.h" #include "dhcommand_parser.h" #include <user_interface.h> #if defined(DH_COMMANDS_MAX31855) && defined(DH_DEVICE_MAX31855) /* * dh_handle_devices_max31855_read() implementation. */ void ICACHE_FLASH_ATTR dh_handle_devices_max31855_read(COMMAND_RESULT *cmd_res, const char *command, const char *params, unsigned int params_len) { gpio_command_params info; ALLOWED_FIELDS fields = 0; if (params_len) { const char *err_msg = parse_params_pins_set(params, params_len, &info, DH_ADC_SUITABLE_PINS, 0, AF_CS, &fields); if (err_msg != 0) { dh_command_fail(cmd_res, err_msg); return; // FAILED } } float temperature; const char *err_msg = max31855_read((fields & AF_CS) ? info.CS : DH_SPI_NO_PIN, &temperature); if (err_msg != 0) { dh_command_fail(cmd_res, err_msg); } else { cmd_res->callback(cmd_res->data, DHSTATUS_OK, RDT_FORMAT_JSON, "{\"temperature\":%f}", temperature); } } #endif /* DH_COMMANDS_MAX31855 && DH_DEVICE_MAX31855 */
1c5a2afde7d90518f1fddb623ee27caa40e409d9
b5a547a5fcfa417bd1c73d241d59d7918ddde668
/Tests/Pcap++Test/Common/PcapFileNamesDef.h
1f34d4abe683d78fa6c30818b731605bce266cd1
[ "Unlicense" ]
permissive
seladb/PcapPlusPlus
ae994498a11139753d320594e3aad2db6a31ab18
0725fa175ab2a7cb78a6c48d3b4d113eb7221810
refs/heads/master
2023-08-05T07:51:20.501998
2023-08-04T01:51:24
2023-08-04T01:51:24
24,911,519
2,464
700
Unlicense
2023-09-14T09:24:09
2014-10-07T21:04:05
C++
UTF-8
C
false
false
1,616
h
PcapFileNamesDef.h
#define EXAMPLE_PCAP_WRITE_PATH "PcapExamples/example_copy.pcap" #define EXAMPLE_PCAP_PATH "PcapExamples/example.pcap" #define EXAMPLE2_PCAP_PATH "PcapExamples/example2.pcap" #define EXAMPLE_PCAP_HTTP_REQUEST "PcapExamples/4KHttpRequests.pcap" #define EXAMPLE_PCAP_HTTP_RESPONSE "PcapExamples/650HttpResponses.pcap" #define EXAMPLE_PCAP_VLAN "PcapExamples/VlanPackets.pcap" #define EXAMPLE_PCAP_DNS "PcapExamples/DnsPackets.pcap" #define DPDK_PCAP_WRITE_PATH "PcapExamples/DpdkPackets.pcap" #define SLL_PCAP_WRITE_PATH "PcapExamples/sll_copy.pcap" #define SLL_PCAP_PATH "PcapExamples/sll.pcap" #define RAW_IP_PCAP_WRITE_PATH "PcapExamples/raw_ip_copy.pcap" #define RAW_IP_PCAP_PATH "PcapExamples/raw_ip.pcap" #define RAW_IP_PCAPNG_PATH "PcapExamples/raw_ip.pcapng" #define EXAMPLE_PCAPNG_PATH "PcapExamples/many_interfaces-1.pcapng" #define EXAMPLE2_PCAPNG_PATH "PcapExamples/pcapng-example.pcapng" #define EXAMPLE_PCAPNG_WRITE_PATH "PcapExamples/many_interfaces_copy.pcapng" #define EXAMPLE2_PCAPNG_WRITE_PATH "PcapExamples/pcapng-example-write.pcapng" #define EXAMPLE_PCAPNG_ZSTD_WRITE_PATH "PcapExamples/many_interfaces_copy.pcapng.zstd" #define EXAMPLE2_PCAPNG_ZSTD_WRITE_PATH "PcapExamples/pcapng-example-write.pcapng.zstd" #define EXAMPLE2_PCAPNG_ZST_WRITE_PATH "PcapExamples/pcapng-example-write.pcapng.zst" #define EXAMPLE_PCAP_GRE "PcapExamples/GrePackets.cap" #define EXAMPLE_PCAP_IGMP "PcapExamples/IgmpPackets.pcap" #define EXAMPLE_LINKTYPE_IPV6 "PcapExamples/linktype_ipv6.pcap" #define EXAMPLE_LINKTYPE_IPV4 "PcapExamples/linktype_ipv4.pcap" #define EXAMPLE_SOLARIS_SNOOP "PcapExamples/solaris.snoop"
9593a2b93281605a54c04dd7d1c0dbc7dc39a241
810237086aae7600b9ef87a610aec4777b1bf156
/Example/Pods/Headers/Private/SJVideoPlayer/SJSpeedupPlaybackPopupView.h
a85cadb2b0df778baef86c78052c3cc9551686d2
[ "MIT" ]
permissive
changsanjiang/SJVideoPlayer
f63f3156d5ad07ec107b0feb481110222dd45a85
bff75e1f7f033edc05e07c333ce3557cb289c95c
refs/heads/master
2022-12-20T22:47:04.095976
2022-12-10T08:57:46
2022-12-10T08:57:46
100,693,284
2,680
513
MIT
2022-11-02T11:04:42
2017-08-18T08:56:30
Objective-C
UTF-8
C
false
false
75
h
SJSpeedupPlaybackPopupView.h
../../../../../SJVideoPlayer/Common/Implements/SJSpeedupPlaybackPopupView.h
793f42e0c31973598489754eddae40baf3e6f923
5713b91dc763d497d2139e7467a9711df17dd98b
/res/fonts/forkawesome.h
4da837ff94e22b23cfebb8d8bf1cfc2a203f0b37
[ "BSD-3-Clause", "MIT" ]
permissive
crosire/reshade
f627a3323debef97ecd02b5d0eeec2a0e0dc32b9
9782cea39bcd0d8ae37a38798737f235ce680a5b
refs/heads/main
2023-09-01T06:50:48.074855
2023-08-20T13:09:53
2023-08-20T13:09:53
61,246,596
3,611
694
BSD-3-Clause
2023-09-14T19:11:04
2016-06-15T23:02:16
C++
UTF-8
C
false
false
808
h
forkawesome.h
//Header Generated with https://github.com/aiekick/ImGuiFontStudio //Based on https://github.com/juliettef/IconFontCppHeaders #pragma once #define FONT_ICON_BUFFER_NAME_FK FK_compressed_data_base85 #define FONT_ICON_BUFFER_SIZE_FK 0xc26 #define ICON_MIN_FK 0xf002 #define ICON_MAX_FK 0xf1c9 #define ICON_FK_CANCEL u8"\uf00d" #define ICON_FK_FILE u8"\uf016" #define ICON_FK_FILE_CODE u8"\uf1c9" #define ICON_FK_FILE_IMAGE u8"\uf1c5" #define ICON_FK_FLOPPY u8"\uf0c7" #define ICON_FK_FOLDER u8"\uf114" #define ICON_FK_FOLDER_OPEN u8"\uf115" #define ICON_FK_MINUS u8"\uf068" #define ICON_FK_OK u8"\uf00c" #define ICON_FK_PENCIL u8"\uf040" #define ICON_FK_PLUS u8"\uf067" #define ICON_FK_REFRESH u8"\uf021" #define ICON_FK_SEARCH u8"\uf002" #define ICON_FK_UNDO u8"\uf0e2" #define ICON_FK_WARNING u8"\uf071"
cd0ee033d9f1b77f8c2064052a4d00117ea7289d
28d0f8c01599f8f6c711bdde0b59f9c2cd221203
/usr.sbin/wakeonlan/wakeonlan.c
0086a9708484fc25d9f50b3c1ee3e72d84af3bd9
[]
no_license
NetBSD/src
1a9cbc22ed778be638b37869ed4fb5c8dd616166
23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c
refs/heads/trunk
2023-08-31T13:24:58.105962
2023-08-27T15:50:47
2023-08-27T15:50:47
88,439,547
656
348
null
2023-07-20T20:07:24
2017-04-16T20:03:43
null
UTF-8
C
false
false
5,316
c
wakeonlan.c
/* $NetBSD: wakeonlan.c,v 1.2 2012/12/15 04:40:33 jakllsch Exp $ */ /* * Copyright (C) 2006, 2007, 2008, 2009, 2010 Marc Balmer <marc@msys.ch> * Copyright (C) 2000 Eugene M. Kim. 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. Author's name may not be used endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ /* Send Wake on LAN packets to hosts on a local Ethernet network */ #include <sys/types.h> #include <sys/param.h> #include <sys/queue.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> #include <net/bpf.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_types.h> #include <netinet/in.h> #include <netinet/if_ether.h> #include <err.h> #include <errno.h> #include <fcntl.h> #include <ifaddrs.h> #include <limits.h> #include <paths.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sysexits.h> #include <unistd.h> #ifndef SYNC_LEN #define SYNC_LEN 6 #endif #ifndef DESTADDR_COUNT #define DESTADDR_COUNT 16 #endif __dead static void usage(void); static int wake(int, const char *); static int bind_if_to_bpf(char const *, int); static int find_ether(char *, size_t); static int get_ether(char const *, struct ether_addr *); static int send_wakeup(int, struct ether_addr const *); static void usage(void) { fprintf(stderr, "usage: %s [interface] lladdr [lladdr ...]\n", getprogname()); exit(EXIT_FAILURE); } static int wake(int bpf, const char *host) { struct ether_addr macaddr; if (get_ether(host, &macaddr) == -1) return -1; return send_wakeup(bpf, &macaddr); } static int bind_if_to_bpf(char const *ifname, int bpf) { struct ifreq ifr; u_int dlt; if (strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)) >= sizeof(ifr.ifr_name)) { errno = ENAMETOOLONG; return -1; } if (ioctl(bpf, BIOCSETIF, &ifr) == -1) return -1; if (ioctl(bpf, BIOCGDLT, &dlt) == -1) return -1; if (dlt != DLT_EN10MB) { errno = EOPNOTSUPP; return -1; } return 0; } static int find_ether(char *dst, size_t len) { struct ifaddrs *ifap, *ifa; struct sockaddr_dl *sdl = NULL; int nifs; if (dst == NULL || len == 0) return 0; if (getifaddrs(&ifap) != 0) return -1; /* XXX also check the link state */ for (nifs = 0, ifa = ifap; ifa; ifa = ifa->ifa_next) if (ifa->ifa_addr->sa_family == AF_LINK && ifa->ifa_flags & IFF_UP && ifa->ifa_flags & IFF_RUNNING) { sdl = (struct sockaddr_dl *)ifa->ifa_addr; if (sdl->sdl_type == IFT_ETHER) { strlcpy(dst, ifa->ifa_name, len); nifs++; } } freeifaddrs(ifap); return nifs == 1 ? 0 : -1; } static int get_ether(char const *text, struct ether_addr *addr) { struct ether_addr *paddr; paddr = ether_aton(text); if (paddr != NULL) { *addr = *paddr; return 0; } if (ether_hostton(text, addr)) return -1; return 0; } static int send_wakeup(int bpf, struct ether_addr const *addr) { struct { struct ether_header hdr; u_char data[SYNC_LEN + ETHER_ADDR_LEN * DESTADDR_COUNT]; } pkt; u_char *p; int i; ssize_t bw, len; memset(pkt.hdr.ether_dhost, 0xff, sizeof(pkt.hdr.ether_dhost)); memset(pkt.hdr.ether_shost, 0x00, sizeof(pkt.hdr.ether_shost)); pkt.hdr.ether_type = htons(0); memset(pkt.data, 0xff, SYNC_LEN); for (p = pkt.data + SYNC_LEN, i = 0; i < DESTADDR_COUNT; p += ETHER_ADDR_LEN, i++) memcpy(p, addr->ether_addr_octet, ETHER_ADDR_LEN); p = (u_char *)(void *)&pkt; len = sizeof(pkt); bw = 0; while (len) { if ((bw = write(bpf, p, len)) == -1) return -1; len -= bw; p += bw; } return 0; } int main(int argc, char *argv[]) { int bpf, n; char ifname[IF_NAMESIZE]; if (argc < 2) usage(); if ((bpf = open(_PATH_BPF, O_RDWR)) == -1) err(EXIT_FAILURE, "Cannot open bpf interface"); n = 2; if (bind_if_to_bpf(argv[1], bpf) == -1) { if (find_ether(ifname, sizeof(ifname))) err(EXIT_FAILURE, "Failed to determine ethernet " "interface"); if (bind_if_to_bpf(ifname, bpf) == -1) err(EXIT_FAILURE, "Cannot bind to interface `%s'", ifname); --n; } else strlcpy(ifname, argv[1], sizeof(ifname)); if (n >= argc) usage(); for (; n < argc; n++) if (wake(bpf, argv[n])) warn("Cannot send Wake on LAN frame over `%s' to `%s'", ifname, argv[n]); return EXIT_SUCCESS; }
b64df7efaa3796cff561b4c6af1774a820b27b0b
5816ae8b5fdfe9ab93b3653742b5d4c2a1567111
/hitcon-2018/abyss/src/kernel/mm/mmap.c
9b8ad5728c70da031eddfb32e3aedbd2b295b176
[]
no_license
david942j/ctf-writeups
6c2ff633d80809e422f0263b8ac9a69607d31e84
a4d086684a939000286d0876dd29463ccdceea2e
refs/heads/master
2022-09-07T00:27:23.594820
2021-12-14T10:50:47
2021-12-14T10:50:47
77,058,219
316
49
null
null
null
null
UTF-8
C
false
false
1,055
c
mmap.c
#include <mm/kmalloc.h> #include <mm/mmap.h> #include <mm/translate.h> #include <utils/errno.h> #include <utils/misc.h> #include <utils/panic.h> uint64_t brk_end; /* returns user-accessible page-aligned block * if addr == 0, use the last_mmapped address */ void *mmap(void *addr, uint64_t len, int prot) { if(len == 0 || len & 0xfff) panic("mmap.c: invalid length"); void *ret = kmalloc(len, MALLOC_PAGE_ALIGN); if(ret == 0) return 0; // no memory static void *last_mmapped = (void*) -1; /* no ASLR */ if(last_mmapped == (void*) -1) last_mmapped = (void*) 0x00007ffff7fff000ull - (random() % 0xfff7fff) * 0x1000; if(addr == 0) last_mmapped = addr = last_mmapped - len; for(uint64_t i = 0; i < len; i += 0x1000) add_trans_user(addr + i, ret + i, prot); return addr; } int mprotect(void *addr, uint64_t len, int prot) { if(!alignok(addr)) return -EINVAL; for(uint64_t i = 0; i < len; i += 0x1000) { if(!USER_MEM_RANGE_OK(addr + i) || modify_permission(addr + i, prot) != 0) return -EACCES; } return 0; }
0775d34d289c448912e0b8b99888d0952e878bba
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libunwind/include/unwind_arm_ehabi.h
6277a1457f8966012848302489915bf7298e10ec
[ "MIT", "NCSA", "Apache-2.0", "LLVM-exception" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C
false
false
5,596
h
unwind_arm_ehabi.h
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // // C++ ABI Level 1 ABI documented at: // https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst // //===----------------------------------------------------------------------===// #ifndef __ARM_EHABI_UNWIND_H__ #define __ARM_EHABI_UNWIND_H__ typedef uint32_t _Unwind_State; static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1; static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2; static const _Unwind_State _US_ACTION_MASK = 3; /* Undocumented flag for force unwinding. */ static const _Unwind_State _US_FORCE_UNWIND = 8; typedef uint32_t _Unwind_EHT_Header; struct _Unwind_Control_Block; typedef struct _Unwind_Control_Block _Unwind_Control_Block; #define _Unwind_Exception _Unwind_Control_Block /* Alias */ typedef uint8_t _Unwind_Exception_Class[8]; struct _Unwind_Control_Block { _Unwind_Exception_Class exception_class; void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*); /* Unwinder cache, private fields for the unwinder's use */ struct { uint32_t reserved1; /* init reserved1 to 0, then don't touch */ uint32_t reserved2; uint32_t reserved3; uint32_t reserved4; uint32_t reserved5; } unwinder_cache; /* Propagation barrier cache (valid after phase 1): */ struct { uint32_t sp; uint32_t bitpattern[5]; } barrier_cache; /* Cleanup cache (preserved over cleanup): */ struct { uint32_t bitpattern[4]; } cleanup_cache; /* Pr cache (for pr's benefit): */ struct { uint32_t fnstart; /* function start address */ _Unwind_EHT_Header* ehtp; /* pointer to EHT entry header word */ uint32_t additional; uint32_t reserved1; } pr_cache; long long int :0; /* Enforce the 8-byte alignment */ } __attribute__((__aligned__(8))); typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( _Unwind_State state, _Unwind_Exception *exceptionObject, struct _Unwind_Context *context); #ifdef __cplusplus extern "C" { #endif // // The following are the base functions documented by the C++ ABI // #ifdef __USING_SJLJ_EXCEPTIONS__ extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException(_Unwind_Exception *exception_object); extern void _Unwind_SjLj_Resume(_Unwind_Exception *exception_object); #else extern _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *exception_object); extern void _Unwind_Resume(_Unwind_Exception *exception_object); #endif extern void _Unwind_DeleteException(_Unwind_Exception *exception_object); typedef enum { _UVRSC_CORE = 0, /* integer register */ _UVRSC_VFP = 1, /* vfp */ _UVRSC_WMMXD = 3, /* Intel WMMX data register */ _UVRSC_WMMXC = 4, /* Intel WMMX control register */ _UVRSC_PSEUDO = 5 /* Special purpose pseudo register */ } _Unwind_VRS_RegClass; typedef enum { _UVRSD_UINT32 = 0, _UVRSD_VFPX = 1, _UVRSD_UINT64 = 3, _UVRSD_FLOAT = 4, _UVRSD_DOUBLE = 5 } _Unwind_VRS_DataRepresentation; typedef enum { _UVRSR_OK = 0, _UVRSR_NOT_IMPLEMENTED = 1, _UVRSR_FAILED = 2 } _Unwind_VRS_Result; extern void _Unwind_Complete(_Unwind_Exception* exception_object); extern _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, uint32_t regno, _Unwind_VRS_DataRepresentation representation, void *valuep); extern _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, uint32_t regno, _Unwind_VRS_DataRepresentation representation, void *valuep); extern _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, uint32_t discriminator, _Unwind_VRS_DataRepresentation representation); #if defined(_LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE) #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 extern #else #define _LIBUNWIND_EXPORT_UNWIND_LEVEL1 static __inline__ #endif // These are de facto helper functions for ARM, which delegate the function // calls to _Unwind_VRS_Get/Set(). These are not a part of ARM EHABI // specification, thus these function MUST be inlined. Please don't replace // these with the "extern" function declaration; otherwise, the program // including this <unwind.h> header won't be ABI compatible and will result in // link error when we are linking the program with libgcc. _LIBUNWIND_EXPORT_UNWIND_LEVEL1 uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) { uintptr_t value = 0; _Unwind_VRS_Get(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); return value; } _LIBUNWIND_EXPORT_UNWIND_LEVEL1 void _Unwind_SetGR(struct _Unwind_Context *context, int index, uintptr_t value) { _Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value); } _LIBUNWIND_EXPORT_UNWIND_LEVEL1 uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { // remove the thumb-bit before returning return _Unwind_GetGR(context, 15) & (~(uintptr_t)0x1); } _LIBUNWIND_EXPORT_UNWIND_LEVEL1 void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) { uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1); _Unwind_SetGR(context, 15, value | thumb_bit); } #ifdef __cplusplus } #endif #endif // __ARM_EHABI_UNWIND_H__
bf62d5db25460838eb1e9647a24c84a4cbf2933d
1577e1cf4e89584a125cffb855ca50a9654c6d55
/tcl/tcl_ext/incrtcl/incrTcl/itcl/generic/itclInt.h
b245f1309674275ebeca10b96c395aa96098cea7
[ "TCL" ]
permissive
apple-open-source/macos
a4188b5c2ef113d90281d03cd1b14e5ee52ebffb
2d2b15f13487673de33297e49f00ef94af743a9a
refs/heads/master
2023-08-01T11:03:26.870408
2023-03-27T00:00:00
2023-03-27T00:00:00
180,595,052
124
24
null
2022-12-27T14:54:09
2019-04-10T14:06:23
null
UTF-8
C
false
false
17,618
h
itclInt.h
/* * ------------------------------------------------------------------------ * PACKAGE: [incr Tcl] * DESCRIPTION: Object-Oriented Extensions to Tcl * * [incr Tcl] provides object-oriented extensions to Tcl, much as * C++ provides object-oriented extensions to C. It provides a means * of encapsulating related procedures together with their shared data * in a local namespace that is hidden from the outside world. It * promotes code re-use through inheritance. More than anything else, * it encourages better organization of Tcl applications through the * object-oriented paradigm, leading to code that is easier to * understand and maintain. * * ADDING [incr Tcl] TO A Tcl-BASED APPLICATION: * * To add [incr Tcl] facilities to a Tcl application, modify the * Tcl_AppInit() routine as follows: * * 1) Include this header file near the top of the file containing * Tcl_AppInit(): * * #include "itcl.h" * * 2) Within the body of Tcl_AppInit(), add the following lines: * * if (Itcl_Init(interp) == TCL_ERROR) { * return TCL_ERROR; * } * * 3) Link your application with libitcl.a * * NOTE: An example file "tclAppInit.c" containing the changes shown * above is included in this distribution. * * ======================================================================== * AUTHOR: Michael J. McLennan * Bell Labs Innovations for Lucent Technologies * mmclennan@lucent.com * http://www.tcltk.com/itcl * * RCS: $Id: itclInt.h,v 1.19 2008/12/15 20:02:58 andreas_kupries Exp $ * ======================================================================== * Copyright (c) 1993-1998 Lucent Technologies, Inc. * ------------------------------------------------------------------------ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef ITCLINT_H #define ITCLINT_H #include "tclInt.h" #include "itcl.h" #ifdef BUILD_itcl # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLEXPORT #endif /* * Handle hiding of errorLine in 8.6 */ #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6) #define ERRORLINE(interp) ((interp)->errorLine) #else #define ERRORLINE(interp) (Tcl_GetErrorLine(interp)) #endif #define ITCL_TCL_PRE_8_5 (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 5) #if !ITCL_TCL_PRE_8_5 #if defined(USE_TCL_STUBS) /* * Fix Tcl bug #803489 the right way. We need to always use the old Stub * slot positions, not the new broken ones part of TIP 127. I do like * that these functions have moved to the public space (about time), but * the slot change is the killer and is the painful side affect. */ # undef Tcl_CreateNamespace # define Tcl_CreateNamespace \ (tclIntStubsPtr->tcl_CreateNamespace) # undef Tcl_DeleteNamespace # define Tcl_DeleteNamespace \ (tclIntStubsPtr->tcl_DeleteNamespace) # undef Tcl_AppendExportList # define Tcl_AppendExportList \ (tclIntStubsPtr->tcl_AppendExportList) # undef Tcl_Export # define Tcl_Export \ (tclIntStubsPtr->tcl_Export) # undef Tcl_Import # define Tcl_Import \ (tclIntStubsPtr->tcl_Import) # undef Tcl_ForgetImport # define Tcl_ForgetImport \ (tclIntStubsPtr->tcl_ForgetImport) # undef Tcl_GetCurrentNamespace # define Tcl_GetCurrentNamespace \ (tclIntStubsPtr->tcl_GetCurrentNamespace) # undef Tcl_GetGlobalNamespace # define Tcl_GetGlobalNamespace \ (tclIntStubsPtr->tcl_GetGlobalNamespace) # undef Tcl_FindNamespace # define Tcl_FindNamespace \ (tclIntStubsPtr->tcl_FindNamespace) # undef Tcl_FindCommand # define Tcl_FindCommand \ (tclIntStubsPtr->tcl_FindCommand) # undef Tcl_GetCommandFromObj # define Tcl_GetCommandFromObj \ (tclIntStubsPtr->tcl_GetCommandFromObj) # undef Tcl_GetCommandFullName # define Tcl_GetCommandFullName \ (tclIntStubsPtr->tcl_GetCommandFullName) #endif /* use stubs */ /* * Use 8.5+ CallFrame */ #define ItclCallFrame CallFrame #define Itcl_CallFrame Tcl_CallFrame #define ItclInitVarFlags(varPtr) \ (varPtr)->flags = 0 #define ItclInitVarArgument(varPtr) \ (varPtr)->flags = VAR_ARGUMENT #define ItclVarHashCreateVar(tablePtr, key, newPtr) \ TclVarHashCreateVar((tablePtr), (key), (newPtr)) #define ItclVarRefCount(varPtr) VarHashRefCount(varPtr) #define ItclClearVarUndefined(varPtr) #define ItclNextLocal(varPtr) ((varPtr)++) #define ItclVarObjValue(varPtr) ((varPtr)->value.objPtr) #define itclVarInHashSize sizeof(VarInHash) #define itclVarLocalSize sizeof(Var) #else /* Compiling on Tcl8.x, x<5 */ /* * Redefine CallFrame to account for extra ClientData in 8.5. * Make sure that standard CallFrame comes first. */ typedef struct ItclCallFrame { Namespace *nsPtr; int isProcCallFrame; int objc; Tcl_Obj *CONST *objv; struct CallFrame *callerPtr; struct CallFrame *callerVarPtr; int level; Proc *procPtr; Tcl_HashTable *varTablePtr; int numCompiledLocals; Var* compiledLocals; ClientData clientData; struct localCache *localCachePtr; } ItclCallFrame; typedef struct Itcl_CallFrame { Tcl_Namespace *nsPtr; int dummy1; int dummy2; char *dummy3; char *dummy4; char *dummy5; int dummy6; char *dummy7; char *dummy8; int dummy9; char *dummy10; char *dummy11; char *dummy12; } Itcl_CallFrame; /* * Definition of runtime behaviour to be able to run irrespective of the Tcl * version. */ #define VarInHash Var #define TclVarHashTable Tcl_HashTable typedef struct ItclShortVar { int flags; union { Tcl_Obj *objPtr; TclVarHashTable *tablePtr; struct Var *linkPtr; } value; } ItclShortVar; typedef struct ItclVarInHash { ItclShortVar var; int refCount; Tcl_HashEntry entry; } ItclVarInHash; #define ItclOffset(type, field) ((int) ((char *) &((type *) 0)->field)) #define itclOldRuntime (itclVarFlagOffset!=0) extern int itclVarFlagOffset; extern int itclVarRefCountOffset; extern int itclVarInHashSize; extern int itclVarLocalSize; extern int itclVarValueOffset; /* * VarReform related macros: provide access to the Var fields with offsets * determined at load time, so that the same code copes with the different * structs in Tcl8.5 and previous Tcl. */ #define ItclNextLocal(varPtr) \ ((varPtr) = (Var *) (((char *)(varPtr))+itclVarLocalSize)) #define ItclVarObjValue(varPtr) \ (*((Tcl_Obj **) (((char *)(varPtr))+itclVarValueOffset))) #define ItclVarRefCount(varPtr) \ (*((int *) (((char *)(varPtr))+itclVarRefCountOffset))) #define ItclVarFlags(varPtr) \ (*((int *)(((char *)(varPtr))+itclVarFlagOffset))) /* Note that itclVarFlagOffset==0 exactly when we are running in Tcl8.5 */ #define ItclInitVarFlags(varPtr) \ if (itclOldRuntime) { \ (varPtr)->flags = (VAR_SCALAR | VAR_UNDEFINED | VAR_IN_HASHTABLE);\ } else { \ ((ItclShortVar *)(varPtr))->flags = 0;\ } /* This is used for CompiledLocal, not for Var & Co. That struct did not * change, but the correct flag init did! The flags bits themselves are * unchanged */ #define ItclInitVarArgument(varPtr) \ if (itclOldRuntime) { \ (varPtr)->flags = (VAR_SCALAR | VAR_ARGUMENT);\ } else { \ (varPtr)->flags = VAR_ARGUMENT;\ } #define TclIsVarNamespaceVar(varPtr) \ (ItclVarFlags(varPtr) & VAR_NAMESPACE_VAR) #define TclSetVarNamespaceVar(varPtr) \ if (!TclIsVarNamespaceVar(varPtr)) {\ ItclVarFlags(varPtr) |= VAR_NAMESPACE_VAR;\ ItclVarRefCount(varPtr)++;\ } #define ItclClearVarUndefined(varPtr) \ if (itclOldRuntime) { \ ItclVarFlags(varPtr) &= ~VAR_UNDEFINED;\ } #ifndef MODULE_SCOPE #define MODULE_SCOPE #endif MODULE_SCOPE Var * ItclVarHashCreateVar (TclVarHashTable * tablePtr, const char * key, int * newPtr); #endif /* Version dependent defs and macros */ #define ItclVarHashFindVar(tablePtr, key) \ ItclVarHashCreateVar((tablePtr), (key), NULL) /* * Some backward compatability adjustments. */ #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0 # define Tcl_GetString(obj) Tcl_GetStringFromObj((obj), NULL) # define TCL_DECLARE_MUTEX(mutexVar) # define Tcl_MutexLock(mutexVar) # define Tcl_MutexUnlock(mutexVar) # define Tcl_Panic panic #endif #define TCL_DOES_STUBS \ (TCL_MAJOR_VERSION > 8 || TCL_MAJOR_VERSION == 8 && (TCL_MINOR_VERSION > 1 || \ (TCL_MINOR_VERSION == 1 && TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE))) /* * Common info for managing all known objects. * Each interpreter has one of these data structures stored as * clientData in the "itcl" namespace. It is also accessible * as associated data via the key ITCL_INTERP_DATA. */ struct ItclObject; typedef struct ItclObjectInfo { Tcl_Interp *interp; /* interpreter that manages this info */ Tcl_HashTable objects; /* list of all known objects */ Itcl_Stack transparentFrames; /* stack of call frames that should be * treated transparently. When * Itcl_EvalMemberCode is invoked in * one of these contexts, it does an * "uplevel" to get past the transparent * frame and back to the calling context. */ Tcl_HashTable contextFrames; /* object contexts for active call frames */ int protection; /* protection level currently in effect */ Itcl_Stack cdefnStack; /* stack of class definitions currently * being parsed */ } ItclObjectInfo; #define ITCL_INTERP_DATA "itcl_data" /* * Representation for each [incr Tcl] class. */ typedef struct ItclClass { char *name; /* class name */ char *fullname; /* fully qualified class name */ Tcl_Interp *interp; /* interpreter that manages this info */ Tcl_Namespace *namesp; /* namespace representing class scope */ Tcl_Command accessCmd; /* access command for creating instances */ struct ItclObjectInfo *info; /* info about all known objects */ Itcl_List bases; /* list of base classes */ Itcl_List derived; /* list of all derived classes */ Tcl_HashTable heritage; /* table of all base classes. Look up * by pointer to class definition. This * provides fast lookup for inheritance * tests. */ Tcl_Obj *initCode; /* initialization code for new objs */ Tcl_HashTable variables; /* definitions for all data members in this class. Look up simple string names and get back ItclVarDefn* ptrs */ Tcl_HashTable functions; /* definitions for all member functions in this class. Look up simple string names and get back ItclMemberFunc* ptrs */ int numInstanceVars; /* number of instance vars in variables table */ Tcl_HashTable resolveVars; /* all possible names for variables in * this class (e.g., x, foo::x, etc.) */ Tcl_HashTable resolveCmds; /* all possible names for functions in * this class (e.g., x, foo::x, etc.) */ int unique; /* unique number for #auto generation */ int flags; /* maintains class status */ } ItclClass; typedef struct ItclHierIter { ItclClass *current; /* current position in hierarchy */ Itcl_Stack stack; /* stack used for traversal */ } ItclHierIter; /* * Representation for each [incr Tcl] object. */ typedef struct ItclObject { ItclClass *classDefn; /* most-specific class */ Tcl_Command accessCmd; /* object access command */ int dataSize; /* number of elements in data array */ Var** data; /* all object-specific data members */ Tcl_HashTable* constructed; /* temp storage used during construction */ Tcl_HashTable* destructed; /* temp storage used during destruction */ } ItclObject; #define ITCL_IGNORE_ERRS 0x002 /* useful for construction/destruction */ /* * Implementation for any code body in an [incr Tcl] class. */ typedef struct ItclMemberCode { int flags; /* flags describing implementation */ CompiledLocal *arglist; /* list of arg names and initial values */ int argcount; /* number of args in arglist */ Proc *procPtr; /* Tcl proc representation (needed to * handle compiled locals) */ union { Tcl_CmdProc *argCmd; /* (argc,argv) C implementation */ Tcl_ObjCmdProc *objCmd; /* (objc,objv) C implementation */ } cfunc; ClientData clientData; /* client data for C implementations */ } ItclMemberCode; #define Itcl_IsMemberCodeImplemented(mcode) \ (((mcode)->flags & ITCL_IMPLEMENT_NONE) == 0) /* * Basic representation for class members (commands/variables) */ typedef struct ItclMember { Tcl_Interp* interp; /* interpreter containing the class */ ItclClass* classDefn; /* class containing this member */ char* name; /* member name */ char* fullname; /* member name with "class::" qualifier */ int protection; /* protection level */ int flags; /* flags describing member (see below) */ ItclMemberCode *code; /* code associated with member */ } ItclMember; /* * Flag bits for ItclMemberCode and ItclMember: */ #define ITCL_IMPLEMENT_NONE 0x001 /* no implementation */ #define ITCL_IMPLEMENT_TCL 0x002 /* Tcl implementation */ #define ITCL_IMPLEMENT_ARGCMD 0x004 /* (argc,argv) C implementation */ #define ITCL_IMPLEMENT_OBJCMD 0x008 /* (objc,objv) C implementation */ #define ITCL_IMPLEMENT_C 0x00c /* either kind of C implementation */ #define ITCL_CONSTRUCTOR 0x010 /* non-zero => is a constructor */ #define ITCL_DESTRUCTOR 0x020 /* non-zero => is a destructor */ #define ITCL_COMMON 0x040 /* non-zero => is a "proc" */ #define ITCL_ARG_SPEC 0x080 /* non-zero => has an argument spec */ #define ITCL_OLD_STYLE 0x100 /* non-zero => old-style method * (process "config" argument) */ #define ITCL_THIS_VAR 0x200 /* non-zero => built-in "this" variable */ /* * Representation of member functions in an [incr Tcl] class. */ typedef struct ItclMemberFunc { ItclMember *member; /* basic member info */ Tcl_Command accessCmd; /* Tcl command installed for this function */ CompiledLocal *arglist; /* list of arg names and initial values */ int argcount; /* number of args in arglist */ } ItclMemberFunc; /* * Instance variables. */ typedef struct ItclVarDefn { ItclMember *member; /* basic member info */ char* init; /* initial value */ } ItclVarDefn; /* * Instance variable lookup entry. */ typedef struct ItclVarLookup { ItclVarDefn* vdefn; /* variable definition */ int usage; /* number of uses for this record */ int accessible; /* non-zero => accessible from class with * this lookup record in its resolveVars */ char *leastQualName; /* simplist name for this variable, with * the fewest qualifiers. This string is * taken from the resolveVars table, so * it shouldn't be freed. */ union { int index; /* index into virtual table (instance data) */ Tcl_Var common; /* variable (common data) */ } var; } ItclVarLookup; /* * Representation for the context in which a body of [incr Tcl] * code executes. In ordinary Tcl, this is a CallFrame. But for * [incr Tcl] code bodies, we must be careful to set up the * CallFrame properly, to plug in instance variables before * executing the code body. */ typedef struct ItclContext { ItclClass *classDefn; /* class definition */ ItclCallFrame frame; /* call frame for object context */ Var *compiledLocals; /* points to storage for compiled locals */ Var localStorage[20]; /* default storage for compiled locals */ } ItclContext; /* * Compatibility flags. Used to support small "hacks". These are stored * in the global variable named itclCompatFlags. */ extern int itclCompatFlags; #define ITCL_COMPAT_USECMDFLAGS 0x0001 /* Tcl8.4a1 introduced a different Command * structure, and we need to adapt * dynamically */ #define ITCL_COMPAT_USE_ISTATE_API 0x2 /* Tcl 8.5a2 added interp state APIs */ #include "itclIntDecls.h" /* * Since the Tcl/Tk distribution doesn't perform any asserts, * dynamic loading can fail to find the __assert function. * As a workaround, we'll include our own. */ #undef assert #ifndef DEBUG #define assert(EX) ((void)0) #else #define assert(EX) (void)((EX) || (Itcl_Assert(STRINGIFY(EX), __FILE__, __LINE__), 0)) #endif /* DEBUG */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT #endif /* ITCLINT_H */
5239e78672ca5dd06b4cc07c2bfcd8701a78c119
fff6d13af91db925a94b3e3474108fafd519bba0
/src/Platform/Common/stdEmbeddedRes.h
2c98a6d9102f38239e8b048eaee398cce00953d7
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
shinyquagsire23/OpenJKDF2
94f1364628924ac944466107606b91c6faeec3df
b79b8c210878b6f276ed3d1a5dad91d9219e6ce1
refs/heads/master
2023-07-08T16:41:38.986577
2023-06-28T08:47:39
2023-06-28T08:47:39
139,542,792
381
34
NOASSERTION
2023-06-28T08:47:40
2018-07-03T07:09:45
C
UTF-8
C
false
false
371
h
stdEmbeddedRes.h
#ifndef _PLATFORM_COMMON_EMBEDDED_RESOURCE_H #define _PLATFORM_COMMON_EMBEDDED_RESOURCE_H #ifdef __cplusplus extern "C" { #endif #include "types.h" char* stdEmbeddedRes_LoadOnlyInternal(const char* filepath, size_t* pOutSz); char* stdEmbeddedRes_Load(const char* filepath, size_t* pOutSz); #ifdef __cplusplus } #endif #endif // _PLATFORM_COMMON_EMBEDDED_RESOURCE_H
55ef7750727aa6cc2d604511ef858343ae2d69cb
35404d163c883a4e73b638b9c01096b67c6cafc7
/src/json.c
ed3fe375704d5656430f2eb0acfe691b22cfb480
[ "ISC" ]
permissive
jorisvink/kore
d7035e599827f1ad906f4281d587b0c319d44d44
92e1ffcc10845a78775e02c8fe4486a616cd137d
refs/heads/master
2023-04-28T21:45:41.821137
2023-04-15T08:03:31
2023-04-15T08:03:31
10,504,702
3,777
477
ISC
2023-04-06T05:57:45
2013-06-05T14:37:22
C
UTF-8
C
false
false
19,444
c
json.c
/* * Copyright (c) 2019-2022 Joris Vink <joris@coders.se> * * Permission to use, copy, modify, and 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 <sys/types.h> #include <float.h> #include <inttypes.h> #include <string.h> #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include "kore.h" static int json_guess_type(u_int8_t, u_int32_t *); static int json_next(struct kore_json *, u_int8_t *); static int json_peek(struct kore_json *, u_int8_t *); static int json_consume_whitespace(struct kore_json *); static int json_next_byte(struct kore_json *, u_int8_t *, int); static char *json_get_string(struct kore_json *); static int json_parse_array(struct kore_json *, struct kore_json_item *); static int json_parse_object(struct kore_json *, struct kore_json_item *); static int json_parse_string(struct kore_json *, struct kore_json_item *); static int json_parse_number(struct kore_json *, struct kore_json_item *); static int json_parse_literal(struct kore_json *, struct kore_json_item *); static struct kore_json_item *json_item_alloc(int, const char *, struct kore_json_item *); static struct kore_json_item *json_find_item(struct kore_json_item *, char **, u_int32_t, int); static u_int8_t json_null_literal[] = { 'n', 'u', 'l', 'l' }; static u_int8_t json_true_literal[] = { 't', 'r', 'u', 'e' }; static u_int8_t json_false_literal[] = { 'f', 'a', 'l', 's', 'e' }; static int json_errno = 0; static const char *json_errtab[] = { "no error", "invalid JSON object", "invalid JSON array", "invalid JSON string", "invalid JSON number", "invalid JSON literal", "too many nested items", "end of stream while parsing JSON", "invalid JSON", "invalid search query specified", "item not found", "item found, but not expected value" }; void kore_json_init(struct kore_json *json, const void *data, size_t len) { memset(json, 0, sizeof(*json)); json->data = data; json->length = len; kore_buf_init(&json->tmpbuf, 1024); } int kore_json_parse(struct kore_json *json) { u_int8_t ch; u_int32_t type; if (json->root) return (KORE_RESULT_OK); json_errno = 0; if (json_consume_whitespace(json) == -1) { json_errno = KORE_JSON_ERR_INVALID_JSON; return (KORE_RESULT_ERROR); } if (!json_peek(json, &ch)) return (KORE_RESULT_ERROR); if (!json_guess_type(ch, &type)) { json_errno = KORE_JSON_ERR_INVALID_JSON; return (KORE_RESULT_ERROR); } json->root = json_item_alloc(type, NULL, NULL); if (!json->root->parse(json, json->root)) { if (json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_JSON; return (KORE_RESULT_ERROR); } /* Don't allow garbage at the end. */ (void)json_consume_whitespace(json); if (json->offset != json->length) { json_errno = KORE_JSON_ERR_INVALID_JSON; return (KORE_RESULT_ERROR); } return (KORE_RESULT_OK); } struct kore_json_item * kore_json_find(struct kore_json_item *root, const char *path, u_int32_t type) { struct kore_json_item *item; char *copy; char *tokens[KORE_JSON_DEPTH_MAX + 1]; json_errno = 0; copy = kore_strdup(path); if (!kore_split_string(copy, "/", tokens, KORE_JSON_DEPTH_MAX)) { kore_free(copy); json_errno = KORE_JSON_ERR_INVALID_SEARCH; return (NULL); } item = json_find_item(root, tokens, type, 0); kore_free(copy); if (item == NULL && json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_SEARCH; return (item); } void kore_json_cleanup(struct kore_json *json) { if (json == NULL) return; kore_buf_cleanup(&json->tmpbuf); kore_json_item_free(json->root); } int kore_json_errno(void) { return (json_errno); } const char * kore_json_strerror(void) { if (json_errno >= 0 && json_errno <= KORE_JSON_ERR_LAST) return (json_errtab[json_errno]); return ("unknown JSON error"); } struct kore_json_item * kore_json_create_item(struct kore_json_item *parent, const char *name, u_int32_t type, ...) { const char *p; va_list args; struct kore_json_item *item; item = kore_calloc(1, sizeof(*item)); item->type = type; va_start(args, type); switch (item->type) { case KORE_JSON_TYPE_OBJECT: TAILQ_INIT(&item->data.items); break; case KORE_JSON_TYPE_ARRAY: TAILQ_INIT(&item->data.items); break; case KORE_JSON_TYPE_STRING: p = va_arg(args, const char *); item->data.string = kore_strdup(p); break; case KORE_JSON_TYPE_NUMBER: item->data.number = va_arg(args, double); break; case KORE_JSON_TYPE_INTEGER: item->data.integer = va_arg(args, int64_t); break; case KORE_JSON_TYPE_INTEGER_U64: item->data.u64 = va_arg(args, u_int64_t); break; case KORE_JSON_TYPE_LITERAL: item->data.literal = va_arg(args, int); break; default: fatal("%s: unknown type %d", __func__, item->type); } if (name) item->name = kore_strdup(name); if (parent) { if (parent->type != KORE_JSON_TYPE_OBJECT && parent->type != KORE_JSON_TYPE_ARRAY) { fatal("%s: invalid parent type (%d)", __func__, parent->type); } TAILQ_INSERT_TAIL(&parent->data.items, item, list); } va_end(args); return (item); } void kore_json_item_tobuf(struct kore_json_item *item, struct kore_buf *buf) { struct kore_json_item *nitem; if (item->name) kore_buf_appendf(buf, "\"%s\":", item->name); switch (item->type) { case KORE_JSON_TYPE_OBJECT: kore_buf_appendf(buf, "{"); TAILQ_FOREACH(nitem, &item->data.items, list) { kore_json_item_tobuf(nitem, buf); if (TAILQ_NEXT(nitem, list)) kore_buf_appendf(buf, ","); } kore_buf_appendf(buf, "}"); break; case KORE_JSON_TYPE_ARRAY: kore_buf_appendf(buf, "["); TAILQ_FOREACH(nitem, &item->data.items, list) { kore_json_item_tobuf(nitem, buf); if (TAILQ_NEXT(nitem, list)) kore_buf_appendf(buf, ","); } kore_buf_appendf(buf, "]"); break; case KORE_JSON_TYPE_STRING: kore_buf_appendf(buf, "\"%s\"", item->data.string); break; case KORE_JSON_TYPE_NUMBER: kore_buf_appendf(buf, "%f", item->data.number); break; case KORE_JSON_TYPE_INTEGER: kore_buf_appendf(buf, "%" PRId64, item->data.integer); break; case KORE_JSON_TYPE_INTEGER_U64: kore_buf_appendf(buf, "%" PRIu64, item->data.u64); break; case KORE_JSON_TYPE_LITERAL: switch (item->data.literal) { case KORE_JSON_TRUE: kore_buf_append(buf, json_true_literal, sizeof(json_true_literal)); break; case KORE_JSON_FALSE: kore_buf_append(buf, json_false_literal, sizeof(json_false_literal)); break; case KORE_JSON_NULL: kore_buf_append(buf, json_null_literal, sizeof(json_null_literal)); break; default: fatal("%s: unknown literal %d", __func__, item->data.literal); } break; default: fatal("%s: unknown type %d", __func__, item->type); } } void kore_json_item_attach(struct kore_json_item *parent, struct kore_json_item *item) { if (item->parent != NULL) fatal("%s: item already has parent", __func__); item->parent = parent; if (parent->type != KORE_JSON_TYPE_OBJECT && parent->type != KORE_JSON_TYPE_ARRAY) { fatal("%s: invalid parent type (%d)", __func__, parent->type); } TAILQ_INSERT_TAIL(&parent->data.items, item, list); } static struct kore_json_item * json_find_item(struct kore_json_item *object, char **tokens, u_int32_t type, int pos) { char *p, *str; struct kore_json_item *item, *nitem; int err, idx, spot; if (tokens[pos] == NULL) return (NULL); if (object->type != KORE_JSON_TYPE_OBJECT && object->type != KORE_JSON_TYPE_ARRAY) return (NULL); if ((str = strchr(tokens[pos], '[')) != NULL) { *(str)++ = '\0'; if ((p = strchr(str, ']')) == NULL) return (NULL); *p = '\0'; spot = kore_strtonum(str, 10, 0, USHRT_MAX, &err); if (err != KORE_RESULT_OK) return (NULL); } else { spot = -1; } item = NULL; TAILQ_FOREACH(item, &object->data.items, list) { if (item->name && strcmp(item->name, tokens[pos])) continue; if (item->type == KORE_JSON_TYPE_ARRAY && spot != -1) { idx = 0; nitem = NULL; TAILQ_FOREACH(nitem, &item->data.items, list) { if (idx++ == spot) break; } if (nitem == NULL) { json_errno = KORE_JSON_ERR_NOT_FOUND; return (NULL); } item = nitem; } if (tokens[pos + 1] == NULL) { /* * If an uint64 was required and we find an item * with the same name but marked as an integer check * if it can be represented as a uint64. * * If it can, reduce the type to integer so we match * on it as well. */ if (type == KORE_JSON_TYPE_INTEGER_U64 && item->type == KORE_JSON_TYPE_INTEGER) { if (item->data.integer >= 0) type = KORE_JSON_TYPE_INTEGER; } if (item->type == type) return (item); json_errno = KORE_JSON_ERR_TYPE_MISMATCH; return (NULL); } if (item->type == KORE_JSON_TYPE_OBJECT || item->type == KORE_JSON_TYPE_ARRAY) { item = json_find_item(item, tokens, type, pos + 1); } else { item = NULL; } break; } if (item == NULL && json_errno == 0) json_errno = KORE_JSON_ERR_NOT_FOUND; return (item); } void kore_json_item_free(struct kore_json_item *item) { struct kore_json_item *node; if (item == NULL) return; switch (item->type) { case KORE_JSON_TYPE_OBJECT: case KORE_JSON_TYPE_ARRAY: while ((node = TAILQ_FIRST(&item->data.items)) != NULL) { TAILQ_REMOVE(&item->data.items, node, list); kore_json_item_free(node); } break; case KORE_JSON_TYPE_STRING: kore_free(item->data.string); break; case KORE_JSON_TYPE_NUMBER: case KORE_JSON_TYPE_LITERAL: case KORE_JSON_TYPE_INTEGER: case KORE_JSON_TYPE_INTEGER_U64: break; default: fatal("%s: unknown type %d", __func__, item->type); } kore_free(item->name); kore_free(item); } static struct kore_json_item * json_item_alloc(int type, const char *name, struct kore_json_item *parent) { struct kore_json_item *item; item = kore_calloc(1, sizeof(*item)); item->type = type; item->parent = parent; switch (item->type) { case KORE_JSON_TYPE_OBJECT: TAILQ_INIT(&item->data.items); item->parse = json_parse_object; break; case KORE_JSON_TYPE_ARRAY: TAILQ_INIT(&item->data.items); item->parse = json_parse_array; break; case KORE_JSON_TYPE_STRING: item->parse = json_parse_string; break; case KORE_JSON_TYPE_NUMBER: case KORE_JSON_TYPE_INTEGER: case KORE_JSON_TYPE_INTEGER_U64: item->parse = json_parse_number; break; case KORE_JSON_TYPE_LITERAL: item->parse = json_parse_literal; break; default: fatal("%s: unknown type %d", __func__, item->type); } if (name) item->name = kore_strdup(name); if (parent) { if (parent->type != KORE_JSON_TYPE_OBJECT && parent->type != KORE_JSON_TYPE_ARRAY) { fatal("%s: invalid parent type (%d)", __func__, parent->type); } TAILQ_INSERT_TAIL(&parent->data.items, item, list); } return (item); } static int json_peek(struct kore_json *json, u_int8_t *ch) { return (json_next_byte(json, ch, 1)); } static int json_next(struct kore_json *json, u_int8_t *ch) { return (json_next_byte(json, ch, 0)); } static int json_next_byte(struct kore_json *json, u_int8_t *ch, int peek) { if (json->offset >= json->length) { json_errno = KORE_JSON_ERR_EOF; return (KORE_RESULT_ERROR); } *ch = json->data[json->offset]; if (peek == 0) json->offset++; return (KORE_RESULT_OK); } static int json_consume_whitespace(struct kore_json *json) { u_int8_t ch; for (;;) { if (!json_peek(json, &ch)) return (KORE_RESULT_ERROR); if (ch != ' ' && ch != '\n' && ch != '\r' && ch != '\t') break; json->offset++; } return (KORE_RESULT_OK); } static int json_guess_type(u_int8_t ch, u_int32_t *type) { if (ch == '-' || (ch >= '0' && ch <= '9')) { *type = KORE_JSON_TYPE_NUMBER; return (KORE_RESULT_OK); } switch (ch) { case '{': *type = KORE_JSON_TYPE_OBJECT; break; case '"': *type = KORE_JSON_TYPE_STRING; break; case '[': *type = KORE_JSON_TYPE_ARRAY; break; case 'f': case 'n': case 't': *type = KORE_JSON_TYPE_LITERAL; break; default: return (KORE_RESULT_ERROR); } return (KORE_RESULT_OK); } static int json_parse_object(struct kore_json *json, struct kore_json_item *object) { u_int8_t ch; u_int32_t type; char *key; struct kore_json_item *item; int ret, hasnext; if (json->depth++ >= KORE_JSON_DEPTH_MAX) { json_errno = KORE_JSON_ERR_DEPTH; return (KORE_RESULT_ERROR); } key = NULL; hasnext = 0; ret = KORE_RESULT_ERROR; if (!json_next(json, &ch)) goto cleanup; if (ch != '{') goto cleanup; for (;;) { if (!json_consume_whitespace(json)) goto cleanup; if (!json_peek(json, &ch)) goto cleanup; switch (ch) { case '}': if (hasnext) { json_errno = KORE_JSON_ERR_INVALID_JSON; goto cleanup; } json->offset++; ret = KORE_RESULT_OK; goto cleanup; case '"': if ((key = json_get_string(json)) == NULL) goto cleanup; break; default: goto cleanup; } if (!json_consume_whitespace(json)) goto cleanup; if (!json_next(json, &ch)) goto cleanup; if (ch != ':') goto cleanup; if (!json_consume_whitespace(json)) goto cleanup; if (!json_peek(json, &ch)) goto cleanup; if (!json_guess_type(ch, &type)) goto cleanup; item = json_item_alloc(type, key, object); if (!item->parse(json, item)) goto cleanup; key = NULL; if (!json_consume_whitespace(json)) goto cleanup; if (!json_next(json, &ch)) goto cleanup; if (ch == ',') { hasnext = 1; continue; } if (ch == '}') { ret = KORE_RESULT_OK; break; } break; } cleanup: if (ret == KORE_RESULT_ERROR && json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_OBJECT; json->depth--; return (ret); } static int json_parse_array(struct kore_json *json, struct kore_json_item *array) { u_int8_t ch; u_int32_t type; char *key; struct kore_json_item *item; int ret, hasnext; if (json->depth++ >= KORE_JSON_DEPTH_MAX) { json_errno = KORE_JSON_ERR_DEPTH; return (KORE_RESULT_ERROR); } key = NULL; hasnext = 0; ret = KORE_RESULT_ERROR; if (!json_next(json, &ch)) goto cleanup; if (ch != '[') goto cleanup; for (;;) { if (!json_consume_whitespace(json)) goto cleanup; if (!json_peek(json, &ch)) goto cleanup; if (ch == ']') { if (hasnext) { json_errno = KORE_JSON_ERR_INVALID_JSON; goto cleanup; } json->offset++; ret = KORE_RESULT_OK; goto cleanup; } if (!json_guess_type(ch, &type)) goto cleanup; item = json_item_alloc(type, key, array); if (!item->parse(json, item)) goto cleanup; key = NULL; if (!json_consume_whitespace(json)) goto cleanup; if (!json_next(json, &ch)) goto cleanup; if (ch == ',') { hasnext = 1; continue; } if (ch == ']') { ret = KORE_RESULT_OK; break; } break; } cleanup: if (ret == KORE_RESULT_ERROR && json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_ARRAY; json->depth--; return (ret); } static int json_parse_string(struct kore_json *json, struct kore_json_item *string) { char *value; if ((value = json_get_string(json)) == NULL) return (KORE_RESULT_ERROR); string->type = KORE_JSON_TYPE_STRING; string->data.string = kore_strdup(value); return (KORE_RESULT_OK); } static int json_parse_number(struct kore_json *json, struct kore_json_item *number) { u_int8_t ch; int ret; char *str; u_int32_t type; str = NULL; ret = KORE_RESULT_ERROR; kore_buf_reset(&json->tmpbuf); type = KORE_JSON_TYPE_NUMBER | KORE_JSON_TYPE_INTEGER | KORE_JSON_TYPE_INTEGER_U64; for (;;) { if (!json_peek(json, &ch)) break; switch (ch) { case 'e': case 'E': case '.': type = KORE_JSON_TYPE_NUMBER; kore_buf_append(&json->tmpbuf, &ch, sizeof(ch)); json->offset++; continue; case '-': if (json->tmpbuf.offset != 0) goto cleanup; type &= ~KORE_JSON_TYPE_INTEGER_U64; /* FALLTHROUGH */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '+': kore_buf_append(&json->tmpbuf, &ch, sizeof(ch)); json->offset++; continue; } break; } if (type & KORE_JSON_TYPE_INTEGER_U64) type = KORE_JSON_TYPE_INTEGER_U64; if (type & KORE_JSON_TYPE_INTEGER) type = KORE_JSON_TYPE_INTEGER; str = kore_buf_stringify(&json->tmpbuf, NULL); switch (type) { case KORE_JSON_TYPE_NUMBER: number->data.number = kore_strtodouble(str, -DBL_MAX, DBL_MAX, &ret); break; case KORE_JSON_TYPE_INTEGER: number->data.integer = (int64_t)kore_strtonum64(str, 1, &ret); break; case KORE_JSON_TYPE_INTEGER_U64: number->data.u64 = kore_strtonum64(str, 0, &ret); if (number->data.u64 <= INT64_MAX) { type = KORE_JSON_TYPE_INTEGER; number->data.integer = number->data.u64; } break; default: goto cleanup; } number->type = type; cleanup: if (ret == KORE_RESULT_ERROR && json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_NUMBER; return (ret); } static int json_parse_literal(struct kore_json *json, struct kore_json_item *literal) { size_t len, idx; int ret, val; u_int8_t ch, *tmpl; ret = KORE_RESULT_ERROR; if (!json_next(json, &ch)) goto cleanup; switch (ch) { case 'f': val = KORE_JSON_FALSE; tmpl = json_false_literal; len = sizeof(json_false_literal) - 1; break; case 'n': val = KORE_JSON_NULL; tmpl = json_null_literal; len = sizeof(json_null_literal) - 1; break; case 't': val = KORE_JSON_TRUE; tmpl = json_true_literal; len = sizeof(json_true_literal) - 1; break; default: goto cleanup; } for (idx = 0; idx < len; idx++) { if (!json_next(json, &ch)) goto cleanup; if (ch != tmpl[idx + 1]) goto cleanup; } literal->data.literal = val; literal->type = KORE_JSON_TYPE_LITERAL; ret = KORE_RESULT_OK; cleanup: if (ret == KORE_RESULT_ERROR && json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_LITERAL; return (ret); } static char * json_get_string(struct kore_json *json) { u_int8_t ch; char *res; res = NULL; if (!json_next(json, &ch)) goto cleanup; if (ch != '"') goto cleanup; kore_buf_reset(&json->tmpbuf); for (;;) { if (!json_next(json, &ch)) goto cleanup; if (ch == '"') break; if (ch <= 0x1f) goto cleanup; if (ch == '\\') { if (!json_next(json, &ch)) goto cleanup; switch (ch) { case '\"': case '\\': case '/': break; case 'b': ch = '\b'; break; case 'f': ch = '\f'; break; case 'n': ch = '\n'; break; case 'r': ch = '\r'; break; case 't': ch = '\t'; break; case 'u': default: /* XXX - not supported. */ goto cleanup; } } kore_buf_append(&json->tmpbuf, &ch, sizeof(ch)); } res = kore_buf_stringify(&json->tmpbuf, NULL); cleanup: if (res == NULL && json_errno == 0) json_errno = KORE_JSON_ERR_INVALID_STRING; return (res); }
bf23fc02a5385b055007cc6299435974e199c29f
52c8ed39b32ccc7c0673278c1adea3638797c9ff
/src/arch/arm32/mach-f1c500s/sys-clock.c
1d79fbde18db7d4042e95a47d5f2fb9a04c3fe85
[ "MIT" ]
permissive
xboot/xboot
0cab7b440b612aa0a4c366025598a53a7ec3adf1
6d6b93947b7fcb8c3924fedb0715c23877eedd5e
refs/heads/master
2023-08-20T05:56:25.149388
2023-07-12T07:38:29
2023-07-12T07:38:29
471,539
765
296
MIT
2023-05-25T09:39:01
2010-01-14T08:25:12
C
UTF-8
C
false
false
3,304
c
sys-clock.c
/* * sys-clock.c * * Copyright(c) 2007-2023 Jianjun Jiang <8192542@qq.com> * Official site: http://xboot.org * Mobile phone: +86-18665388956 * QQ: 8192542 * * 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. * */ #include <xboot.h> #include <f1c500s/reg-ccu.h> static inline void sdelay(int loops) { __asm__ __volatile__ ("1:\n" "subs %0, %1, #1\n" "bne 1b":"=r" (loops):"0"(loops)); } static void wait_pll_stable(u32_t base) { u32_t rval = 0; u32_t time = 0xfff; do { rval = read32(base); time--; } while(time && !(rval & (1 << 28))); } static void clock_set_pll_cpu(u32_t clk) { u32_t n, k, m, p; u32_t rval = 0; u32_t div = 0; if(clk > 720000000) clk = 720000000; if((clk % 24000000) == 0) { div = clk / 24000000; n = div - 1; k = 0; m = 0; p = 0; } else if((clk % 12000000) == 0) { m = 1; div = clk / 12000000; if((div % 3) == 0) k = 2; else if((div % 4) == 0) k = 3; else k = 1; n = (div / (k + 1)) - 1; p = 0; } else { div = clk / 24000000; n = div - 1; k = 0; m = 0; p = 0; } rval = read32(F1C500S_CCU_BASE + CCU_PLL_CPU_CTRL); rval &= ~((0x3 << 16) | (0x1f << 8) | (0x3 << 4) | (0x3 << 0)); rval |= (1U << 31) | (p << 16) | (n << 8) | (k << 4) | m; write32(F1C500S_CCU_BASE + CCU_PLL_CPU_CTRL, rval); wait_pll_stable(F1C500S_CCU_BASE + CCU_PLL_CPU_CTRL); } void sys_clock_init(void) { u32_t val; write32(F1C500S_CCU_BASE + CCU_PLL_STABLE_TIME0, 0x1ff); write32(F1C500S_CCU_BASE + CCU_PLL_STABLE_TIME1, 0x1ff); val = read32(F1C500S_CCU_BASE + CCU_CPU_CFG); val &= ~(0x3 << 16); val |= (0x1 << 16); write32(F1C500S_CCU_BASE + CCU_CPU_CFG, val); sdelay(100); write32(F1C500S_CCU_BASE + CCU_PLL_VIDEO_CTRL, 0x81003e03); sdelay(100); write32(F1C500S_CCU_BASE + CCU_PLL_PERIPH_CTRL, 0x80041800); sdelay(100); write32(F1C500S_CCU_BASE + CCU_AHB_APB_CFG, 0x00003180); sdelay(100); val = read32(F1C500S_CCU_BASE + CCU_DRAM_CLK_GATE); val |= (0x1 << 26) | (0x1 << 24) | (0x1 << 3) | (0x1 << 2) | (0x1 << 1) | (0x1 << 0); write32(F1C500S_CCU_BASE + CCU_DRAM_CLK_GATE, val); sdelay(100); clock_set_pll_cpu(408000000); val = read32(F1C500S_CCU_BASE + CCU_CPU_CFG); val &= ~(0x3 << 16); val |= (0x2 << 16); write32(F1C500S_CCU_BASE + CCU_CPU_CFG, val); sdelay(100); }
685e8ca29bfa289c3edc7909b8ea908ba606372c
fb47ab6337a71029dee71933e449cf7f6805fc0f
/external/platform/nrfx/drivers/include/nrfx_spim.h
ba2cdbe302a27df18a9ceb49b173b7356c77dfbc
[ "MIT", "BSD-3-Clause" ]
permissive
littlekernel/lk
7e7ba50b87b1f2e0b6e2f052c59249825c91975b
30dc320054f70910e1c1ee40a6948ee99672acec
refs/heads/master
2023-09-02T00:47:52.203963
2023-06-21T22:42:35
2023-06-21T22:42:35
3,058,456
3,077
618
MIT
2023-08-30T09:41:31
2011-12-27T19:19:36
C
UTF-8
C
false
false
18,713
h
nrfx_spim.h
/* * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA * 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #ifndef NRFX_SPIM_H__ #define NRFX_SPIM_H__ #include <nrfx.h> #include <hal/nrf_spim.h> #include <hal/nrf_gpio.h> #ifdef __cplusplus extern "C" { #endif /** * @defgroup nrfx_spim SPIM driver * @{ * @ingroup nrf_spim * @brief Serial Peripheral Interface Master with EasyDMA (SPIM) driver. */ /** @brief Data structure of the Serial Peripheral Interface Master with EasyDMA (SPIM) driver instance. */ typedef struct { NRF_SPIM_Type * p_reg; ///< Pointer to a structure with SPIM registers. uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only. } nrfx_spim_t; #ifndef __NRFX_DOXYGEN__ enum { #if NRFX_CHECK(NRFX_SPIM0_ENABLED) NRFX_SPIM0_INST_IDX, #endif #if NRFX_CHECK(NRFX_SPIM1_ENABLED) NRFX_SPIM1_INST_IDX, #endif #if NRFX_CHECK(NRFX_SPIM2_ENABLED) NRFX_SPIM2_INST_IDX, #endif #if NRFX_CHECK(NRFX_SPIM3_ENABLED) NRFX_SPIM3_INST_IDX, #endif #if NRFX_CHECK(NRFX_SPIM4_ENABLED) NRFX_SPIM4_INST_IDX, #endif NRFX_SPIM_ENABLED_COUNT }; #endif /** @brief Macro for creating an instance of the SPIM driver. */ #define NRFX_SPIM_INSTANCE(id) \ { \ .p_reg = NRFX_CONCAT_2(NRF_SPIM, id), \ .drv_inst_idx = NRFX_CONCAT_3(NRFX_SPIM, id, _INST_IDX), \ } /** * @brief This value can be provided instead of a pin number for signals MOSI, * MISO, and Slave Select to specify that the given signal is not used and * therefore does not need to be connected to a pin. */ #define NRFX_SPIM_PIN_NOT_USED 0xFF /** @brief Configuration structure of the SPIM driver instance. */ typedef struct { uint8_t sck_pin; ///< SCK pin number. uint8_t mosi_pin; ///< MOSI pin number (optional). /**< Set to @ref NRFX_SPIM_PIN_NOT_USED * if this signal is not needed. */ uint8_t miso_pin; ///< MISO pin number (optional). /**< Set to @ref NRFX_SPIM_PIN_NOT_USED * if this signal is not needed. */ uint8_t ss_pin; ///< Slave Select pin number (optional). /**< Set to @ref NRFX_SPIM_PIN_NOT_USED * if this signal is not needed. */ bool ss_active_high; ///< Polarity of the Slave Select pin during transmission. uint8_t irq_priority; ///< Interrupt priority. uint8_t orc; ///< Overrun character. /**< This character is used when all bytes from the TX buffer are sent, but the transfer continues due to RX. */ nrf_spim_frequency_t frequency; ///< SPIM frequency. nrf_spim_mode_t mode; ///< SPIM mode. nrf_spim_bit_order_t bit_order; ///< SPIM bit order. nrf_gpio_pin_pull_t miso_pull; ///< MISO pull up configuration. #if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__) uint8_t dcx_pin; ///< D/CX pin number (optional). uint8_t rx_delay; ///< Sample delay for input serial data on MISO. /**< The value specifies the delay, in number of 64 MHz clock cycles * (15.625 ns), from the the sampling edge of SCK (leading edge for * CONFIG.CPHA = 0, trailing edge for CONFIG.CPHA = 1) until * the input serial data is sampled. */ bool use_hw_ss; ///< Indication to use software or hardware controlled Slave Select pin. uint8_t ss_duration; ///< Slave Select duration before and after transmission. /**< Minimum duration between the edge of CSN and the edge of SCK. * Also, minimum duration of CSN inactivity between transactions. * The value is specified in number of 64 MHz clock cycles (15.625 ns). * Supported only for hardware-controlled Slave Select. */ #endif } nrfx_spim_config_t; #if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__) /** * @brief SPIM driver extended default configuration. * * This configuration sets up SPIM additional options with the following values: * - DCX pin disabled * - RX sampling delay: 2 clock cycles * - hardware SS disabled * - hardware SS duration before and after transmission: 2 clock cycles */ #define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \ .dcx_pin = NRFX_SPIM_PIN_NOT_USED, \ .rx_delay = 0x02, \ .use_hw_ss = false, \ .ss_duration = 0x02, #else #define NRFX_SPIM_DEFAULT_EXTENDED_CONFIG #endif /** * @brief SPIM driver default configuration. * * This configuration sets up SPIM with the following options: * - SS pin active low * - over-run character set to 0xFF * - clock frequency: 4 MHz * - mode: 0 (SCK active high, sample on leading edge of the clock signa;) * - MSB shifted out first * - MISO pull-up disabled * * @param[in] _pin_sck SCK pin. * @param[in] _pin_mosi MOSI pin. * @param[in] _pin_miso MISO pin. * @param[in] _pin_ss SS pin. */ #define NRFX_SPIM_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_ss) \ { \ .sck_pin = _pin_sck, \ .mosi_pin = _pin_mosi, \ .miso_pin = _pin_miso, \ .ss_pin = _pin_ss, \ .ss_active_high = false, \ .irq_priority = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \ .orc = 0xFF, \ .frequency = NRF_SPIM_FREQ_4M, \ .mode = NRF_SPIM_MODE_0, \ .bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST, \ .miso_pull = NRF_GPIO_PIN_NOPULL, \ NRFX_SPIM_DEFAULT_EXTENDED_CONFIG \ } /** @brief Flag indicating that TX buffer address will be incremented after transfer. */ #define NRFX_SPIM_FLAG_TX_POSTINC (1UL << 0) /** @brief Flag indicating that RX buffer address will be incremented after transfer. */ #define NRFX_SPIM_FLAG_RX_POSTINC (1UL << 1) /** @brief Flag indicating that the interrupt after each transfer will be suppressed, and the event handler will not be called. */ #define NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER (1UL << 2) /** @brief Flag indicating that the transfer will be set up, but not started. */ #define NRFX_SPIM_FLAG_HOLD_XFER (1UL << 3) /** @brief Flag indicating that the transfer will be executed multiple times. */ #define NRFX_SPIM_FLAG_REPEATED_XFER (1UL << 4) /** @brief Single transfer descriptor structure. */ typedef struct { uint8_t const * p_tx_buffer; ///< Pointer to TX buffer. size_t tx_length; ///< TX buffer length. uint8_t * p_rx_buffer; ///< Pointer to RX buffer. size_t rx_length; ///< RX buffer length. } nrfx_spim_xfer_desc_t; /** * @brief Macro for setting up single transfer descriptor. * * This macro is for internal use only. */ #define NRFX_SPIM_SINGLE_XFER(p_tx, tx_len, p_rx, rx_len) \ { \ .p_tx_buffer = (uint8_t const *)(p_tx), \ .tx_length = (tx_len), \ .p_rx_buffer = (p_rx), \ .rx_length = (rx_len), \ } /** @brief Macro for setting the duplex TX RX transfer. */ #define NRFX_SPIM_XFER_TRX(p_tx_buf, tx_length, p_rx_buf, rx_length) \ NRFX_SPIM_SINGLE_XFER(p_tx_buf, tx_length, p_rx_buf, rx_length) /** @brief Macro for setting the TX transfer. */ #define NRFX_SPIM_XFER_TX(p_buf, length) \ NRFX_SPIM_SINGLE_XFER(p_buf, length, NULL, 0) /** @brief Macro for setting the RX transfer. */ #define NRFX_SPIM_XFER_RX(p_buf, length) \ NRFX_SPIM_SINGLE_XFER(NULL, 0, p_buf, length) /** * @brief SPIM master driver event types, passed to the handler routine provided * during initialization. */ typedef enum { NRFX_SPIM_EVENT_DONE, ///< Transfer done. } nrfx_spim_evt_type_t; /** @brief SPIM event description with transmission details. */ typedef struct { nrfx_spim_evt_type_t type; ///< Event type. nrfx_spim_xfer_desc_t xfer_desc; ///< Transfer details. } nrfx_spim_evt_t; /** @brief SPIM driver event handler type. */ typedef void (* nrfx_spim_evt_handler_t)(nrfx_spim_evt_t const * p_event, void * p_context); /** * @brief Function for initializing the SPIM driver instance. * * This function configures and enables the specified peripheral. * * @param[in] p_instance Pointer to the driver instance structure. * @param[in] p_config Pointer to the structure with the initial configuration. * @param[in] handler Event handler provided by the user. If NULL, transfers * will be performed in blocking mode. * @param[in] p_context Context passed to event handler. * * @retval NRFX_SUCCESS Initialization was successful. * @retval NRFX_ERROR_INVALID_STATE The driver was already initialized. * @retval NRFX_ERROR_BUSY Some other peripheral with the same * instance ID is already in use. This is * possible only if @ref nrfx_prs module * is enabled. * @retval NRFX_ERROR_NOT_SUPPORTED Requested configuration is not supported * by the SPIM instance. */ nrfx_err_t nrfx_spim_init(nrfx_spim_t const * p_instance, nrfx_spim_config_t const * p_config, nrfx_spim_evt_handler_t handler, void * p_context); /** * @brief Function for uninitializing the SPIM driver instance. * * @param[in] p_instance Pointer to the driver instance structure. */ void nrfx_spim_uninit(nrfx_spim_t const * p_instance); /** * @brief Function for starting the SPIM data transfer. * * Additional options are provided using the @c flags parameter: * * - @ref NRFX_SPIM_FLAG_TX_POSTINC and @ref NRFX_SPIM_FLAG_RX_POSTINC - * Post-incrementation of buffer addresses. * - @ref NRFX_SPIM_FLAG_HOLD_XFER - Driver is not starting the transfer. Use this * flag if the transfer is triggered externally by PPI. Use * @ref nrfx_spim_start_task_get to get the address of the start task. * Chip select must be configured to @ref NRFX_SPIM_PIN_NOT_USED and managed outside the driver. * - @ref NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER - No user event handler after transfer * completion. This also means no interrupt at the end of the transfer. * If @ref NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER is used, the driver does not set the instance into * busy state, so you must ensure that the next transfers are set up when SPIM is not active. * @ref nrfx_spim_end_event_get function can be used to detect end of transfer. Option can be used * together with @ref NRFX_SPIM_FLAG_REPEATED_XFER to prepare a sequence of SPI transfers * without interruptions. * - @ref NRFX_SPIM_FLAG_REPEATED_XFER - Prepare for repeated transfers. You can set * up a number of transfers that will be triggered externally (for example by PPI). An example is * a TXRX transfer with the options @ref NRFX_SPIM_FLAG_RX_POSTINC, * @ref NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER, and @ref NRFX_SPIM_FLAG_REPEATED_XFER. After the * transfer is set up, a set of transfers can be triggered by PPI that will read, for example, * the same register of an external component and put it into a RAM buffer without any interrupts. * @ref nrfx_spim_end_event_get can be used to get the address of the END event, which can be * used to count the number of transfers. If @ref NRFX_SPIM_FLAG_REPEATED_XFER is used, * the driver does not set the instance into busy state, so you must ensure that the next * transfers are set up when SPIM is not active. * * @note Peripherals using EasyDMA (including SPIM) require the transfer buffers * to be placed in the Data RAM region. If this condition is not met, * this function will fail with the error code NRFX_ERROR_INVALID_ADDR. * * @param p_instance Pointer to the driver instance structure. * @param p_xfer_desc Pointer to the transfer descriptor. * @param flags Transfer options (0 for default settings). * * @retval NRFX_SUCCESS The procedure is successful. * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer. * @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported. * @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data * RAM region. */ nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * p_instance, nrfx_spim_xfer_desc_t const * p_xfer_desc, uint32_t flags); #if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) || defined(__NRFX_DOXYGEN__) /** * @brief Function for starting the SPIM data transfer with DCX control. * * See @ref nrfx_spim_xfer for description of additional options of transfer * provided by the @c flags parameter. * * @note Peripherals that use EasyDMA (including SPIM) require the transfer buffers * to be placed in the Data RAM region. If this condition is not met, * this function will fail with the error code NRFX_ERROR_INVALID_ADDR. * * @param p_instance Pointer to the driver instance structure. * @param p_xfer_desc Pointer to the transfer descriptor. * @param flags Transfer options (0 for default settings). * @param cmd_length Length of the command bytes preceding the data * bytes. The DCX line will be low during transmission * of command bytes and high during transmission of data bytes. * Maximum value available for dividing the transmitted bytes * into command bytes and data bytes is @ref NRF_SPIM_DCX_CNT_ALL_CMD - 1. * The @ref NRF_SPIM_DCX_CNT_ALL_CMD value passed as the * @c cmd_length parameter causes all transmitted bytes * to be marked as command bytes. * * @retval NRFX_SUCCESS The procedure is successful. * @retval NRFX_ERROR_BUSY The driver is not ready for a new transfer. * @retval NRFX_ERROR_NOT_SUPPORTED The provided parameters are not supported. * @retval NRFX_ERROR_INVALID_ADDR The provided buffers are not placed in the Data * RAM region. */ nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * p_instance, nrfx_spim_xfer_desc_t const * p_xfer_desc, uint32_t flags, uint8_t cmd_length); #endif /** * @brief Function for returning the address of a SPIM start task. * * This function is to be used if @ref nrfx_spim_xfer was called with the flag @ref NRFX_SPIM_FLAG_HOLD_XFER. * In that case, the transfer is not started by the driver, but it must be started externally by PPI. * * @param[in] p_instance Pointer to the driver instance structure. * * @return Start task address. */ uint32_t nrfx_spim_start_task_get(nrfx_spim_t const * p_instance); /** * @brief Function for returning the address of a END SPIM event. * * The END event can be used to detect the end of a transfer * if the @ref NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER option is used. * * @param[in] p_instance Pointer to the driver instance structure. * * @return END event address. */ uint32_t nrfx_spim_end_event_get(nrfx_spim_t const * p_instance); /** * @brief Function for aborting ongoing transfer. * * @param[in] p_instance Pointer to the driver instance structure. */ void nrfx_spim_abort(nrfx_spim_t const * p_instance); /** @} */ void nrfx_spim_0_irq_handler(void); void nrfx_spim_1_irq_handler(void); void nrfx_spim_2_irq_handler(void); void nrfx_spim_3_irq_handler(void); void nrfx_spim_4_irq_handler(void); #ifdef __cplusplus } #endif #endif // NRFX_SPIM_H__
37c7eea44e6b2ed2a3cb9ef2863f8c073f14ca17
966bc7834320e20f92fdd02fda4952e70e824e16
/juice/firmware/gateware.h
30bfb41afbe8bcd893379d0c64699f5823555ecb
[]
no_license
pa3gsb/Radioberry-2.x
475c2e57df38eead2deaf69b10b04e91e00713e9
72e6b5a4fa972db8a89f4f8c33786caa4dab8cfa
refs/heads/master
2023-08-17T01:30:47.517298
2023-08-05T17:57:56
2023-08-05T17:57:56
95,689,838
321
64
null
2022-08-04T14:44:00
2017-06-28T16:28:43
HTML
UTF-8
C
false
false
1,104
h
gateware.h
/* This module loads the gateware for the radioberry into the FPGA. The gateware is present in the radioberry.rbf file. This file will be read and will be transferred via the usb bus, ft2232 chip into the FPGA. */ #ifndef __RADIOBERRY_GATEWARE_LOADER_H__ #define __RADIOBERRY_GATEWARE_LOADER_H__ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include "ftd2xx.h" #include <sys/stat.h> #include <string.h> #include <errno.h> #include <stdbool.h> #ifndef _WIN32 #include <sys/time.h> #endif //FPGA Program Pin Information #define DCLK 0x01 //Pin #1 (DCLK) #define DATA0 0x02 //Pin #2 (DATA0) #define NCONFIG 0x04 //Pin #3 (NCONFIG) #define NSTATUS 0x08 //Pin #4 (NSTATUS) #define NCONF_DONE 0x10 //Pin #5 (NCONF_DONE) #define SET_DCLK(s,b) (s |= (b << 0)) #define SET_DATA0(s,b) (s |= (b << 1)) #define SET_NCONFIG(s,b) (s |= (b << 2)) #define CLEAR_DCLK(s) (s &= ~(1 << 0)) #define CLEAR_DATA0(s) (s &= ~(1 << 1)) #define CLEAR_NCONFIG(s) (s &= ~(1 << 2)) int load_gateware_image_into_fpga(void); unsigned long getFirmwareVersion(void); #endif
5e89dcce44074aa452945317c6a69235316274a6
35e28d7705773eed54345af4440700522c9d1863
/deps/libgdal/gdal/frmts/pcraster/libcsf/trackmm.c
eeeb1151ab43f42d8f723d96c9ea7c945d3a3ef2
[ "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-warranty-disclaimer", "MIT", "SunPro", "LicenseRef-scancode-info-zip-2005-02", "BSD-3-Clause" ]
permissive
naturalatlas/node-gdal
0ee3447861bf2d1abc48d4fbdbcf15aba5473a27
c83e7858a9ec566cc91d65db74fd07b99789c0f0
refs/heads/master
2023-09-03T00:11:41.576937
2022-03-12T20:41:59
2022-03-12T20:41:59
19,504,824
522
122
Apache-2.0
2022-06-04T20:03:43
2014-05-06T18:02:34
C++
UTF-8
C
false
false
765
c
trackmm.c
#include "csf.h" #include "csfimpl.h" /* global header (opt.) and trackmm's prototypes "" */ /* headers of this app. modules called */ /***************/ /* EXTERNALS */ /***************/ /**********************/ /* LOCAL DECLARATIONS */ /**********************/ /*********************/ /* LOCAL DEFINITIONS */ /*********************/ /******************/ /* IMPLEMENTATION */ /******************/ /* disable automatic tracking of minimum and maximum value * A call to RdontTrackMinMax disables the automatic tracking * of the min/max value in successive cell writes. * If used, one must always * use RputMinVal and RputMaxVal to set the correct values. */ void RdontTrackMinMax(MAP *m) /* map handle */ { m->minMaxStatus = MM_DONTKEEPTRACK; }
6993bfc51693ad290e8ebf672e01afc991fb737a
73b0f9c30d07993ad74f7f2bcbc0fe61f1d1a3ce
/native/iosTest/Pods/Headers/Public/RCT-Folly/folly/Math.h
93d4573f67b0399d705c9efe936fcd96c4ac4263
[ "MIT" ]
permissive
Nozbe/WatermelonDB
84771a637e2c93474220fadee442e5c4ade40f7e
fd41fe279e229e9b5013b1dddf777cd7919e1d2d
refs/heads/master
2023-08-16T18:24:04.893973
2023-08-11T11:44:46
2023-08-11T11:44:46
146,468,829
9,358
670
MIT
2023-09-10T08:04:55
2018-08-28T15:32:05
JavaScript
UTF-8
C
false
false
34
h
Math.h
../../../../RCT-Folly/folly/Math.h
872ec3df34d717663478cc71aa8ccb44fd91b106
9ceacf33fd96913cac7ef15492c126d96cae6911
/sys/net/if_vxlan.c
37311eb90b2833009ace71e8a6ad711779cacb5c
[ "BSD-3-Clause" ]
permissive
openbsd/src
ab97ef834fd2d5a7f6729814665e9782b586c130
9e79f3a0ebd11a25b4bff61e900cb6de9e7795e9
refs/heads/master
2023-09-02T18:54:56.624627
2023-09-02T15:16:12
2023-09-02T15:16:12
66,966,208
3,394
1,235
null
2023-08-08T02:42:25
2016-08-30T18:18:25
C
UTF-8
C
false
false
39,183
c
if_vxlan.c
/* $OpenBSD: if_vxlan.c,v 1.93 2023/08/03 09:49:08 mvs Exp $ */ /* * Copyright (c) 2021 David Gwynne <dlg@openbsd.org> * * Permission to use, copy, modify, and 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 "bpfilter.h" #include "pf.h" #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/timeout.h> #include <sys/pool.h> #include <sys/tree.h> #include <sys/refcnt.h> #include <sys/smr.h> #include <sys/socketvar.h> #include <net/if.h> #include <net/if_var.h> #include <net/if_dl.h> #include <net/if_media.h> #include <net/if_types.h> #include <net/route.h> #include <net/rtable.h> #include <netinet/in.h> #include <netinet/in_var.h> #include <netinet/if_ether.h> #include <netinet/ip.h> #include <netinet/udp.h> #include <netinet/in_pcb.h> #include <netinet/ip_var.h> #ifdef INET6 #include <netinet/ip6.h> #include <netinet6/ip6_var.h> #include <netinet6/in6_var.h> #endif /* for bridge stuff */ #include <net/if_bridge.h> #include <net/if_etherbridge.h> #if NBPFILTER > 0 #include <net/bpf.h> #endif /* * The protocol. */ #define VXLANMTU 1492 #define VXLAN_PORT 4789 struct vxlan_header { uint32_t vxlan_flags; #define VXLAN_F_I (1U << 27) uint32_t vxlan_id; #define VXLAN_VNI_SHIFT 8 #define VXLAN_VNI_MASK (0xffffffU << VXLAN_VNI_SHIFT) }; #define VXLAN_VNI_MAX 0x00ffffffU #define VXLAN_VNI_MIN 0x00000000U /* * The driver. */ union vxlan_addr { struct in_addr in4; struct in6_addr in6; }; struct vxlan_softc; struct vxlan_peer { RBT_ENTRY(vxlan_peer) p_entry; struct vxlan_header p_header; union vxlan_addr p_addr; struct vxlan_softc *p_sc; }; RBT_HEAD(vxlan_peers, vxlan_peer); struct vxlan_tep { TAILQ_ENTRY(vxlan_tep) vt_entry; sa_family_t vt_af; unsigned int vt_rdomain; union vxlan_addr vt_addr; #define vt_addr4 vt_addr.in4 #define vt_addr6 vt_addr.in6 in_port_t vt_port; struct socket *vt_so; struct mutex vt_mtx; struct vxlan_peers vt_peers; }; TAILQ_HEAD(vxlan_teps, vxlan_tep); enum vxlan_tunnel_mode { VXLAN_TMODE_UNSET, VXLAN_TMODE_P2P, /* unicast destination, no learning */ VXLAN_TMODE_LEARNING, /* multicast destination, learning */ VXLAN_TMODE_ENDPOINT, /* unset destination, no learning */ }; struct vxlan_softc { struct arpcom sc_ac; struct etherbridge sc_eb; unsigned int sc_rdomain; sa_family_t sc_af; union vxlan_addr sc_src; union vxlan_addr sc_dst; in_port_t sc_port; struct vxlan_header sc_header; unsigned int sc_if_index0; struct task sc_dtask; void *sc_inmulti; enum vxlan_tunnel_mode sc_mode; struct vxlan_peer *sc_ucast_peer; struct vxlan_peer *sc_mcast_peer; struct refcnt sc_refs; uint16_t sc_df; int sc_ttl; int sc_txhprio; int sc_rxhprio; struct task sc_send_task; }; void vxlanattach(int); static int vxlan_clone_create(struct if_clone *, int); static int vxlan_clone_destroy(struct ifnet *); static int vxlan_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); static int vxlan_enqueue(struct ifnet *, struct mbuf *); static void vxlan_start(struct ifqueue *); static void vxlan_send(void *); static int vxlan_ioctl(struct ifnet *, u_long, caddr_t); static int vxlan_up(struct vxlan_softc *); static int vxlan_down(struct vxlan_softc *); static int vxlan_addmulti(struct vxlan_softc *, struct ifnet *); static void vxlan_delmulti(struct vxlan_softc *); static struct mbuf * vxlan_input(void *, struct mbuf *, struct ip *, struct ip6_hdr *, void *, int); static int vxlan_set_rdomain(struct vxlan_softc *, const struct ifreq *); static int vxlan_get_rdomain(struct vxlan_softc *, struct ifreq *); static int vxlan_set_tunnel(struct vxlan_softc *, const struct if_laddrreq *); static int vxlan_get_tunnel(struct vxlan_softc *, struct if_laddrreq *); static int vxlan_del_tunnel(struct vxlan_softc *); static int vxlan_set_vnetid(struct vxlan_softc *, const struct ifreq *); static int vxlan_get_vnetid(struct vxlan_softc *, struct ifreq *); static int vxlan_del_vnetid(struct vxlan_softc *); static int vxlan_set_parent(struct vxlan_softc *, const struct if_parent *); static int vxlan_get_parent(struct vxlan_softc *, struct if_parent *); static int vxlan_del_parent(struct vxlan_softc *); static int vxlan_add_addr(struct vxlan_softc *, const struct ifbareq *); static int vxlan_del_addr(struct vxlan_softc *, const struct ifbareq *); static void vxlan_detach_hook(void *); static struct if_clone vxlan_cloner = IF_CLONE_INITIALIZER("vxlan", vxlan_clone_create, vxlan_clone_destroy); static int vxlan_eb_port_eq(void *, void *, void *); static void *vxlan_eb_port_take(void *, void *); static void vxlan_eb_port_rele(void *, void *); static size_t vxlan_eb_port_ifname(void *, char *, size_t, void *); static void vxlan_eb_port_sa(void *, struct sockaddr_storage *, void *); static const struct etherbridge_ops vxlan_etherbridge_ops = { vxlan_eb_port_eq, vxlan_eb_port_take, vxlan_eb_port_rele, vxlan_eb_port_ifname, vxlan_eb_port_sa, }; static struct rwlock vxlan_lock = RWLOCK_INITIALIZER("vteps"); static struct vxlan_teps vxlan_teps = TAILQ_HEAD_INITIALIZER(vxlan_teps); static struct pool vxlan_endpoint_pool; static inline int vxlan_peer_cmp(const struct vxlan_peer *, const struct vxlan_peer *); RBT_PROTOTYPE(vxlan_peers, vxlan_peer, p_entry, vxlan_peer_cmp); void vxlanattach(int count) { if_clone_attach(&vxlan_cloner); } static int vxlan_clone_create(struct if_clone *ifc, int unit) { struct vxlan_softc *sc; struct ifnet *ifp; int error; if (vxlan_endpoint_pool.pr_size == 0) { pool_init(&vxlan_endpoint_pool, sizeof(union vxlan_addr), 0, IPL_SOFTNET, 0, "vxlanep", NULL); } sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO|M_CANFAIL); if (sc == NULL) return (ENOMEM); ifp = &sc->sc_ac.ac_if; snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d", ifc->ifc_name, unit); error = etherbridge_init(&sc->sc_eb, ifp->if_xname, &vxlan_etherbridge_ops, sc); if (error == -1) { free(sc, M_DEVBUF, sizeof(*sc)); return (error); } sc->sc_af = AF_UNSPEC; sc->sc_txhprio = 0; sc->sc_rxhprio = IF_HDRPRIO_OUTER; sc->sc_df = 0; sc->sc_ttl = IP_DEFAULT_MULTICAST_TTL; task_set(&sc->sc_dtask, vxlan_detach_hook, sc); refcnt_init(&sc->sc_refs); task_set(&sc->sc_send_task, vxlan_send, sc); ifp->if_softc = sc; ifp->if_hardmtu = ETHER_MAX_HARDMTU_LEN; ifp->if_ioctl = vxlan_ioctl; ifp->if_output = vxlan_output; ifp->if_enqueue = vxlan_enqueue; ifp->if_qstart = vxlan_start; ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX; ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE; ether_fakeaddr(ifp); if_counters_alloc(ifp); if_attach(ifp); ether_ifattach(ifp); return (0); } static int vxlan_clone_destroy(struct ifnet *ifp) { struct vxlan_softc *sc = ifp->if_softc; NET_LOCK(); if (ISSET(ifp->if_flags, IFF_RUNNING)) vxlan_down(sc); NET_UNLOCK(); ether_ifdetach(ifp); if_detach(ifp); etherbridge_destroy(&sc->sc_eb); refcnt_finalize(&sc->sc_refs, "vxlanfini"); free(sc, M_DEVBUF, sizeof(*sc)); return (0); } static struct vxlan_softc * vxlan_take(struct vxlan_softc *sc) { refcnt_take(&sc->sc_refs); return (sc); } static void vxlan_rele(struct vxlan_softc *sc) { refcnt_rele_wake(&sc->sc_refs); } static struct mbuf * vxlan_encap(struct vxlan_softc *sc, struct mbuf *m, struct mbuf *(ip_encap)(struct vxlan_softc *sc, struct mbuf *, const union vxlan_addr *, uint8_t)) { struct ifnet *ifp = &sc->sc_ac.ac_if; struct m_tag *mtag; struct mbuf *m0; union vxlan_addr gateway; const union vxlan_addr *endpoint; struct vxlan_header *vh; struct udphdr *uh; int prio; uint8_t tos; if (sc->sc_mode == VXLAN_TMODE_UNSET) goto drop; if (sc->sc_mode == VXLAN_TMODE_P2P) endpoint = &sc->sc_dst; else { /* VXLAN_TMODE_LEARNING || VXLAN_TMODE_ENDPOINT */ struct ether_header *eh = mtod(m, struct ether_header *); smr_read_enter(); endpoint = etherbridge_resolve_ea(&sc->sc_eb, (struct ether_addr *)eh->ether_dhost); if (endpoint != NULL) { gateway = *endpoint; endpoint = &gateway; } smr_read_leave(); if (endpoint == NULL) { if (sc->sc_mode == VXLAN_TMODE_ENDPOINT) goto drop; /* "flood" to unknown destinations */ endpoint = &sc->sc_dst; } } /* force prepend mbuf because of payload alignment */ m0 = m_get(M_DONTWAIT, m->m_type); if (m0 == NULL) goto drop; m_align(m0, 0); m0->m_len = 0; M_MOVE_PKTHDR(m0, m); m0->m_next = m; m = m_prepend(m0, sizeof(*vh), M_DONTWAIT); if (m == NULL) return (NULL); vh = mtod(m, struct vxlan_header *); *vh = sc->sc_header; m = m_prepend(m, sizeof(*uh), M_DONTWAIT); if (m == NULL) return (NULL); uh = mtod(m, struct udphdr *); uh->uh_sport = sc->sc_port; /* XXX */ uh->uh_dport = sc->sc_port; htobem16(&uh->uh_ulen, m->m_pkthdr.len); uh->uh_sum = htons(0); SET(m->m_pkthdr.csum_flags, M_UDP_CSUM_OUT); mtag = m_tag_get(PACKET_TAG_GRE, sizeof(ifp->if_index), M_NOWAIT); if (mtag == NULL) goto drop; *(int *)(mtag + 1) = ifp->if_index; m_tag_prepend(m, mtag); prio = sc->sc_txhprio; if (prio == IF_HDRPRIO_PACKET) prio = m->m_pkthdr.pf.prio; tos = IFQ_PRIO2TOS(prio); CLR(m->m_flags, M_BCAST|M_MCAST); m->m_pkthdr.ph_rtableid = sc->sc_rdomain; #if NPF > 0 pf_pkt_addr_changed(m); #endif return ((*ip_encap)(sc, m, endpoint, tos)); drop: m_freem(m); return (NULL); } static struct mbuf * vxlan_encap_ipv4(struct vxlan_softc *sc, struct mbuf *m, const union vxlan_addr *endpoint, uint8_t tos) { struct ip *ip; m = m_prepend(m, sizeof(*ip), M_DONTWAIT); if (m == NULL) return (NULL); ip = mtod(m, struct ip *); ip->ip_v = IPVERSION; ip->ip_hl = sizeof(*ip) >> 2; ip->ip_off = sc->sc_df; ip->ip_tos = tos; ip->ip_len = htons(m->m_pkthdr.len); ip->ip_ttl = sc->sc_ttl; ip->ip_p = IPPROTO_UDP; ip->ip_src = sc->sc_src.in4; ip->ip_dst = endpoint->in4; return (m); } #ifdef INET6 static struct mbuf * vxlan_encap_ipv6(struct vxlan_softc *sc, struct mbuf *m, const union vxlan_addr *endpoint, uint8_t tos) { struct ip6_hdr *ip6; int len = m->m_pkthdr.len; m = m_prepend(m, sizeof(*ip6), M_DONTWAIT); if (m == NULL) return (NULL); ip6 = mtod(m, struct ip6_hdr *); ip6->ip6_flow = ISSET(m->m_pkthdr.csum_flags, M_FLOWID) ? htonl(m->m_pkthdr.ph_flowid) : 0; ip6->ip6_vfc |= IPV6_VERSION; ip6->ip6_flow |= htonl((uint32_t)tos << 20); ip6->ip6_plen = htons(len); ip6->ip6_nxt = IPPROTO_UDP; ip6->ip6_hlim = sc->sc_ttl; ip6->ip6_src = sc->sc_src.in6; ip6->ip6_dst = endpoint->in6; if (sc->sc_df) SET(m->m_pkthdr.csum_flags, M_IPV6_DF_OUT); return (m); } #endif /* INET6 */ static int vxlan_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt) { struct m_tag *mtag; mtag = NULL; while ((mtag = m_tag_find(m, PACKET_TAG_GRE, mtag)) != NULL) { if (*(int *)(mtag + 1) == ifp->if_index) { m_freem(m); return (EIO); } } return (ether_output(ifp, m, dst, rt)); } static int vxlan_enqueue(struct ifnet *ifp, struct mbuf *m) { struct vxlan_softc *sc = ifp->if_softc; struct ifqueue *ifq = &ifp->if_snd; if (ifq_enqueue(ifq, m) != 0) return (ENOBUFS); task_add(ifq->ifq_softnet, &sc->sc_send_task); return (0); } static void vxlan_start(struct ifqueue *ifq) { struct ifnet *ifp = ifq->ifq_if; struct vxlan_softc *sc = ifp->if_softc; task_add(ifq->ifq_softnet, &sc->sc_send_task); } static uint64_t vxlan_send_ipv4(struct vxlan_softc *sc, struct mbuf_list *ml) { struct ip_moptions imo; struct mbuf *m; uint64_t oerrors = 0; imo.imo_ifidx = sc->sc_if_index0; imo.imo_ttl = sc->sc_ttl; imo.imo_loop = 0; NET_LOCK(); while ((m = ml_dequeue(ml)) != NULL) { if (ip_output(m, NULL, NULL, IP_RAWOUTPUT, &imo, NULL, 0) != 0) oerrors++; } NET_UNLOCK(); return (oerrors); } #ifdef INET6 static uint64_t vxlan_send_ipv6(struct vxlan_softc *sc, struct mbuf_list *ml) { struct ip6_moptions im6o; struct mbuf *m; uint64_t oerrors = 0; im6o.im6o_ifidx = sc->sc_if_index0; im6o.im6o_hlim = sc->sc_ttl; im6o.im6o_loop = 0; NET_LOCK(); while ((m = ml_dequeue(ml)) != NULL) { if (ip6_output(m, NULL, NULL, 0, &im6o, NULL) != 0) oerrors++; } NET_UNLOCK(); return (oerrors); } #endif /* INET6 */ static void vxlan_send(void *arg) { struct vxlan_softc *sc = arg; struct ifnet *ifp = &sc->sc_ac.ac_if; struct mbuf *(*ip_encap)(struct vxlan_softc *, struct mbuf *, const union vxlan_addr *, uint8_t); uint64_t (*ip_send)(struct vxlan_softc *, struct mbuf_list *); struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct mbuf *m; uint64_t oerrors; if (!ISSET(ifp->if_flags, IFF_RUNNING)) return; switch (sc->sc_af) { case AF_INET: ip_encap = vxlan_encap_ipv4; ip_send = vxlan_send_ipv4; break; #ifdef INET6 case AF_INET6: ip_encap = vxlan_encap_ipv6; ip_send = vxlan_send_ipv6; break; #endif default: unhandled_af(sc->sc_af); /* NOTREACHED */ } while ((m = ifq_dequeue(&ifp->if_snd)) != NULL) { #if NBPFILTER > 0 caddr_t if_bpf = READ_ONCE(ifp->if_bpf); if (if_bpf != NULL) bpf_mtap_ether(if_bpf, m, BPF_DIRECTION_OUT); #endif m = vxlan_encap(sc, m, ip_encap); if (m == NULL) continue; ml_enqueue(&ml, m); } oerrors = (*ip_send)(sc, &ml); counters_add(ifp->if_counters, ifc_oerrors, oerrors); } static struct mbuf * vxlan_input(void *arg, struct mbuf *m, struct ip *ip, struct ip6_hdr *ip6, void *uhp, int hlen) { struct vxlan_tep *vt = arg; union vxlan_addr addr; struct vxlan_peer key, *p; struct udphdr *uh; struct vxlan_header *vh; struct ether_header *eh; int vhlen = hlen + sizeof(*vh); struct mbuf *n; int off; in_port_t port; struct vxlan_softc *sc = NULL; struct ifnet *ifp; int rxhprio; uint8_t tos; if (m->m_pkthdr.len < vhlen) goto drop; uh = uhp; port = uh->uh_sport; if (ip != NULL) { memset(&addr, 0, sizeof(addr)); addr.in4 = ip->ip_src; tos = ip->ip_tos; } #ifdef INET6 else { addr.in6 = ip6->ip6_src; tos = bemtoh32(&ip6->ip6_flow) >> 20; } #endif if (m->m_len < vhlen) { m = m_pullup(m, vhlen); if (m == NULL) return (NULL); } /* can't use ip/ip6/uh after this */ vh = (struct vxlan_header *)(mtod(m, caddr_t) + hlen); memset(&key, 0, sizeof(key)); key.p_addr = addr; key.p_header.vxlan_flags = vh->vxlan_flags & htonl(VXLAN_F_I); key.p_header.vxlan_id = vh->vxlan_id & htonl(VXLAN_VNI_MASK); mtx_enter(&vt->vt_mtx); p = RBT_FIND(vxlan_peers, &vt->vt_peers, &key); if (p == NULL) { memset(&key.p_addr, 0, sizeof(key.p_addr)); p = RBT_FIND(vxlan_peers, &vt->vt_peers, &key); } if (p != NULL) sc = vxlan_take(p->p_sc); mtx_leave(&vt->vt_mtx); if (sc == NULL) goto drop; ifp = &sc->sc_ac.ac_if; if (ISSET(ifp->if_flags, IFF_LINK0) && port != sc->sc_port) goto rele_drop; m_adj(m, vhlen); if (m->m_pkthdr.len < sizeof(*eh)) goto rele_drop; if (m->m_len < sizeof(*eh)) { m = m_pullup(m, sizeof(*eh)); if (m == NULL) goto rele; } n = m_getptr(m, sizeof(*eh), &off); if (n == NULL) goto rele_drop; if (!ALIGNED_POINTER(mtod(n, caddr_t) + off, uint32_t)) { n = m_dup_pkt(m, ETHER_ALIGN, M_NOWAIT); m_freem(m); if (n == NULL) goto rele; m = n; } if (sc->sc_mode == VXLAN_TMODE_LEARNING) { eh = mtod(m, struct ether_header *); etherbridge_map_ea(&sc->sc_eb, &addr, (struct ether_addr *)eh->ether_shost); } rxhprio = sc->sc_rxhprio; switch (rxhprio) { case IF_HDRPRIO_PACKET: /* nop */ break; case IF_HDRPRIO_OUTER: m->m_pkthdr.pf.prio = IFQ_TOS2PRIO(tos); break; default: m->m_pkthdr.pf.prio = rxhprio; break; \ } \ if_vinput(ifp, m); rele: vxlan_rele(sc); return (NULL); rele_drop: vxlan_rele(sc); drop: m_freem(m); return (NULL); } static int vxlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct vxlan_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ifbrparam *bparam = (struct ifbrparam *)data; int error = 0; switch (cmd) { case SIOCSIFADDR: break; case SIOCSIFFLAGS: if (ISSET(ifp->if_flags, IFF_UP)) { if (!ISSET(ifp->if_flags, IFF_RUNNING)) error = vxlan_up(sc); else error = 0; } else { if (ISSET(ifp->if_flags, IFF_RUNNING)) error = vxlan_down(sc); } break; case SIOCSLIFPHYRTABLE: error = vxlan_set_rdomain(sc, ifr); break; case SIOCGLIFPHYRTABLE: error = vxlan_get_rdomain(sc, ifr); break; case SIOCSLIFPHYADDR: error = vxlan_set_tunnel(sc, (const struct if_laddrreq *)data); break; case SIOCGLIFPHYADDR: error = vxlan_get_tunnel(sc, (struct if_laddrreq *)data); break; case SIOCDIFPHYADDR: error = vxlan_del_tunnel(sc); break; case SIOCSVNETID: error = vxlan_set_vnetid(sc, ifr); break; case SIOCGVNETID: error = vxlan_get_vnetid(sc, ifr); break; case SIOCDVNETID: error = vxlan_del_vnetid(sc); break; case SIOCSIFPARENT: error = vxlan_set_parent(sc, (struct if_parent *)data); break; case SIOCGIFPARENT: error = vxlan_get_parent(sc, (struct if_parent *)data); break; case SIOCDIFPARENT: error = vxlan_del_parent(sc); break; case SIOCSTXHPRIO: error = if_txhprio_l2_check(ifr->ifr_hdrprio); if (error != 0) break; sc->sc_txhprio = ifr->ifr_hdrprio; break; case SIOCGTXHPRIO: ifr->ifr_hdrprio = sc->sc_txhprio; break; case SIOCSRXHPRIO: error = if_rxhprio_l2_check(ifr->ifr_hdrprio); if (error != 0) break; sc->sc_rxhprio = ifr->ifr_hdrprio; break; case SIOCGRXHPRIO: ifr->ifr_hdrprio = sc->sc_rxhprio; break; case SIOCSLIFPHYDF: /* commit */ sc->sc_df = ifr->ifr_df ? htons(IP_DF) : htons(0); break; case SIOCGLIFPHYDF: ifr->ifr_df = sc->sc_df ? 1 : 0; break; case SIOCSLIFPHYTTL: if (ifr->ifr_ttl < 1 || ifr->ifr_ttl > 0xff) { error = EINVAL; break; } /* commit */ sc->sc_ttl = (uint8_t)ifr->ifr_ttl; break; case SIOCGLIFPHYTTL: ifr->ifr_ttl = (int)sc->sc_ttl; break; case SIOCBRDGSCACHE: error = etherbridge_set_max(&sc->sc_eb, bparam); break; case SIOCBRDGGCACHE: error = etherbridge_get_max(&sc->sc_eb, bparam); break; case SIOCBRDGSTO: error = etherbridge_set_tmo(&sc->sc_eb, bparam); break; case SIOCBRDGGTO: error = etherbridge_get_tmo(&sc->sc_eb, bparam); break; case SIOCBRDGRTS: error = etherbridge_rtfind(&sc->sc_eb, (struct ifbaconf *)data); break; case SIOCBRDGFLUSH: etherbridge_flush(&sc->sc_eb, ((struct ifbreq *)data)->ifbr_ifsflags); break; case SIOCBRDGSADDR: error = vxlan_add_addr(sc, (struct ifbareq *)data); break; case SIOCBRDGDADDR: error = vxlan_del_addr(sc, (struct ifbareq *)data); break; case SIOCADDMULTI: case SIOCDELMULTI: /* no hardware to program */ break; default: error = ether_ioctl(ifp, &sc->sc_ac, cmd, data); break; } if (error == ENETRESET) { /* no hardware to program */ error = 0; } return (error); } static struct vxlan_tep * vxlan_tep_get(struct vxlan_softc *sc, const union vxlan_addr *addr) { struct vxlan_tep *vt; TAILQ_FOREACH(vt, &vxlan_teps, vt_entry) { if (sc->sc_af == vt->vt_af && sc->sc_rdomain == vt->vt_rdomain && memcmp(addr, &vt->vt_addr, sizeof(*addr)) == 0 && sc->sc_port == vt->vt_port) return (vt); } return (NULL); } static int vxlan_tep_add_addr(struct vxlan_softc *sc, const union vxlan_addr *addr, struct vxlan_peer *p) { struct mbuf m; struct vxlan_tep *vt; struct socket *so; struct sockaddr_in *sin; #ifdef INET6 struct sockaddr_in6 *sin6; #endif int error; vt = vxlan_tep_get(sc, addr); if (vt != NULL) { struct vxlan_peer *op; mtx_enter(&vt->vt_mtx); op = RBT_INSERT(vxlan_peers, &vt->vt_peers, p); mtx_leave(&vt->vt_mtx); if (op != NULL) return (EADDRINUSE); return (0); } vt = malloc(sizeof(*vt), M_DEVBUF, M_NOWAIT|M_ZERO); if (vt == NULL) return (ENOMEM); vt->vt_af = sc->sc_af; vt->vt_rdomain = sc->sc_rdomain; vt->vt_addr = *addr; vt->vt_port = sc->sc_port; mtx_init(&vt->vt_mtx, IPL_SOFTNET); RBT_INIT(vxlan_peers, &vt->vt_peers); RBT_INSERT(vxlan_peers, &vt->vt_peers, p); error = socreate(vt->vt_af, &so, SOCK_DGRAM, IPPROTO_UDP); if (error != 0) goto free; solock(so); sotoinpcb(so)->inp_upcall = vxlan_input; sotoinpcb(so)->inp_upcall_arg = vt; sounlock(so); m_inithdr(&m); m.m_len = sizeof(vt->vt_rdomain); *mtod(&m, unsigned int *) = vt->vt_rdomain; error = sosetopt(so, SOL_SOCKET, SO_RTABLE, &m); if (error != 0) goto close; m_inithdr(&m); switch (vt->vt_af) { case AF_INET: sin = mtod(&m, struct sockaddr_in *); memset(sin, 0, sizeof(*sin)); sin->sin_len = sizeof(*sin); sin->sin_family = AF_INET; sin->sin_addr = addr->in4; sin->sin_port = vt->vt_port; m.m_len = sizeof(*sin); break; #ifdef INET6 case AF_INET6: sin6 = mtod(&m, struct sockaddr_in6 *); sin6->sin6_len = sizeof(*sin6); sin6->sin6_family = AF_INET6; in6_recoverscope(sin6, &addr->in6); sin6->sin6_port = sc->sc_port; m.m_len = sizeof(*sin6); break; #endif default: unhandled_af(vt->vt_af); } solock(so); error = sobind(so, &m, curproc); sounlock(so); if (error != 0) goto close; rw_assert_wrlock(&vxlan_lock); TAILQ_INSERT_TAIL(&vxlan_teps, vt, vt_entry); vt->vt_so = so; return (0); close: soclose(so, MSG_DONTWAIT); free: free(vt, M_DEVBUF, sizeof(*vt)); return (error); } static void vxlan_tep_del_addr(struct vxlan_softc *sc, const union vxlan_addr *addr, struct vxlan_peer *p) { struct vxlan_tep *vt; int empty; vt = vxlan_tep_get(sc, addr); if (vt == NULL) panic("unable to find vxlan_tep for peer %p (sc %p)", p, sc); mtx_enter(&vt->vt_mtx); RBT_REMOVE(vxlan_peers, &vt->vt_peers, p); empty = RBT_EMPTY(vxlan_peers, &vt->vt_peers); mtx_leave(&vt->vt_mtx); if (!empty) return; rw_assert_wrlock(&vxlan_lock); TAILQ_REMOVE(&vxlan_teps, vt, vt_entry); soclose(vt->vt_so, MSG_DONTWAIT); free(vt, M_DEVBUF, sizeof(*vt)); } static int vxlan_tep_up(struct vxlan_softc *sc) { struct vxlan_peer *up, *mp; int error; up = malloc(sizeof(*up), M_DEVBUF, M_NOWAIT|M_ZERO); if (up == NULL) return (ENOMEM); if (sc->sc_mode == VXLAN_TMODE_P2P) up->p_addr = sc->sc_dst; up->p_header = sc->sc_header; up->p_sc = vxlan_take(sc); error = vxlan_tep_add_addr(sc, &sc->sc_src, up); if (error != 0) goto freeup; sc->sc_ucast_peer = up; if (sc->sc_mode != VXLAN_TMODE_LEARNING) return (0); mp = malloc(sizeof(*mp), M_DEVBUF, M_NOWAIT|M_ZERO); if (mp == NULL) { error = ENOMEM; goto delup; } /* addr is multicast, leave it as 0s */ mp->p_header = sc->sc_header; mp->p_sc = vxlan_take(sc); /* destination address is a multicast group we want to join */ error = vxlan_tep_add_addr(sc, &sc->sc_dst, up); if (error != 0) goto freemp; sc->sc_mcast_peer = mp; return (0); freemp: vxlan_rele(mp->p_sc); free(mp, M_DEVBUF, sizeof(*mp)); delup: vxlan_tep_del_addr(sc, &sc->sc_src, up); freeup: vxlan_rele(up->p_sc); free(up, M_DEVBUF, sizeof(*up)); return (error); } static void vxlan_tep_down(struct vxlan_softc *sc) { struct vxlan_peer *up = sc->sc_ucast_peer; if (sc->sc_mode == VXLAN_TMODE_LEARNING) { struct vxlan_peer *mp = sc->sc_mcast_peer; vxlan_tep_del_addr(sc, &sc->sc_dst, mp); vxlan_rele(mp->p_sc); free(mp, M_DEVBUF, sizeof(*mp)); } vxlan_tep_del_addr(sc, &sc->sc_src, up); vxlan_rele(up->p_sc); free(up, M_DEVBUF, sizeof(*up)); } static int vxlan_up(struct vxlan_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; struct ifnet *ifp0 = NULL; int error; KASSERT(!ISSET(ifp->if_flags, IFF_RUNNING)); NET_ASSERT_LOCKED(); if (sc->sc_af == AF_UNSPEC) return (EDESTADDRREQ); KASSERT(sc->sc_mode != VXLAN_TMODE_UNSET); NET_UNLOCK(); error = rw_enter(&vxlan_lock, RW_WRITE|RW_INTR); if (error != 0) goto netlock; NET_LOCK(); if (ISSET(ifp->if_flags, IFF_RUNNING)) { /* something else beat us */ rw_exit(&vxlan_lock); return (0); } NET_UNLOCK(); if (sc->sc_mode != VXLAN_TMODE_P2P) { error = etherbridge_up(&sc->sc_eb); if (error != 0) goto unlock; } if (sc->sc_mode == VXLAN_TMODE_LEARNING) { ifp0 = if_get(sc->sc_if_index0); if (ifp0 == NULL) { error = ENXIO; goto down; } /* check again if multicast will work on top of the parent */ if (!ISSET(ifp0->if_flags, IFF_MULTICAST)) { error = EPROTONOSUPPORT; goto put; } error = vxlan_addmulti(sc, ifp0); if (error != 0) goto put; /* Register callback if parent wants to unregister */ if_detachhook_add(ifp0, &sc->sc_dtask); } else { if (sc->sc_if_index0 != 0) { error = EPROTONOSUPPORT; goto down; } } error = vxlan_tep_up(sc); if (error != 0) goto del; if_put(ifp0); NET_LOCK(); SET(ifp->if_flags, IFF_RUNNING); rw_exit(&vxlan_lock); return (0); del: if (sc->sc_mode == VXLAN_TMODE_LEARNING) { if (ifp0 != NULL) if_detachhook_del(ifp0, &sc->sc_dtask); vxlan_delmulti(sc); } put: if_put(ifp0); down: if (sc->sc_mode != VXLAN_TMODE_P2P) etherbridge_down(&sc->sc_eb); unlock: rw_exit(&vxlan_lock); netlock: NET_LOCK(); return (error); } static int vxlan_down(struct vxlan_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; struct ifnet *ifp0; int error; KASSERT(ISSET(ifp->if_flags, IFF_RUNNING)); NET_UNLOCK(); error = rw_enter(&vxlan_lock, RW_WRITE|RW_INTR); if (error != 0) { NET_LOCK(); return (error); } NET_LOCK(); if (!ISSET(ifp->if_flags, IFF_RUNNING)) { /* something else beat us */ rw_exit(&vxlan_lock); return (0); } NET_UNLOCK(); vxlan_tep_down(sc); if (sc->sc_mode == VXLAN_TMODE_LEARNING) { vxlan_delmulti(sc); ifp0 = if_get(sc->sc_if_index0); if (ifp0 != NULL) { if_detachhook_del(ifp0, &sc->sc_dtask); } if_put(ifp0); } if (sc->sc_mode != VXLAN_TMODE_P2P) etherbridge_down(&sc->sc_eb); taskq_del_barrier(ifp->if_snd.ifq_softnet, &sc->sc_send_task); NET_LOCK(); CLR(ifp->if_flags, IFF_RUNNING); rw_exit(&vxlan_lock); return (0); } static int vxlan_addmulti(struct vxlan_softc *sc, struct ifnet *ifp0) { int error = 0; NET_LOCK(); switch (sc->sc_af) { case AF_INET: sc->sc_inmulti = in_addmulti(&sc->sc_dst.in4, ifp0); if (sc->sc_inmulti == NULL) error = EADDRNOTAVAIL; break; #ifdef INET6 case AF_INET6: sc->sc_inmulti = in6_addmulti(&sc->sc_dst.in6, ifp0, &error); break; #endif default: unhandled_af(sc->sc_af); } NET_UNLOCK(); return (error); } static void vxlan_delmulti(struct vxlan_softc *sc) { NET_LOCK(); switch (sc->sc_af) { case AF_INET: in_delmulti(sc->sc_inmulti); break; #ifdef INET6 case AF_INET6: in6_delmulti(sc->sc_inmulti); break; #endif default: unhandled_af(sc->sc_af); } sc->sc_inmulti = NULL; /* keep it tidy */ NET_UNLOCK(); } static int vxlan_set_rdomain(struct vxlan_softc *sc, const struct ifreq *ifr) { struct ifnet *ifp = &sc->sc_ac.ac_if; if (ifr->ifr_rdomainid < 0 || ifr->ifr_rdomainid > RT_TABLEID_MAX) return (EINVAL); if (!rtable_exists(ifr->ifr_rdomainid)) return (EADDRNOTAVAIL); if (sc->sc_rdomain == ifr->ifr_rdomainid) return (0); if (ISSET(ifp->if_flags, IFF_RUNNING)) return (EBUSY); /* commit */ sc->sc_rdomain = ifr->ifr_rdomainid; etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); return (0); } static int vxlan_get_rdomain(struct vxlan_softc *sc, struct ifreq *ifr) { ifr->ifr_rdomainid = sc->sc_rdomain; return (0); } static int vxlan_set_tunnel(struct vxlan_softc *sc, const struct if_laddrreq *req) { struct ifnet *ifp = &sc->sc_ac.ac_if; struct sockaddr *src = (struct sockaddr *)&req->addr; struct sockaddr *dst = (struct sockaddr *)&req->dstaddr; struct sockaddr_in *src4, *dst4; #ifdef INET6 struct sockaddr_in6 *src6, *dst6; int error; #endif union vxlan_addr saddr, daddr; unsigned int mode = VXLAN_TMODE_ENDPOINT; in_port_t port = htons(VXLAN_PORT); memset(&saddr, 0, sizeof(saddr)); memset(&daddr, 0, sizeof(daddr)); /* validate */ switch (src->sa_family) { case AF_INET: src4 = (struct sockaddr_in *)src; if (in_nullhost(src4->sin_addr) || IN_MULTICAST(src4->sin_addr.s_addr)) return (EINVAL); if (src4->sin_port != htons(0)) port = src4->sin_port; if (dst->sa_family != AF_UNSPEC) { if (dst->sa_family != AF_INET) return (EINVAL); dst4 = (struct sockaddr_in *)dst; if (in_nullhost(dst4->sin_addr)) return (EINVAL); /* all good */ mode = IN_MULTICAST(dst4->sin_addr.s_addr) ? VXLAN_TMODE_LEARNING : VXLAN_TMODE_P2P; daddr.in4 = dst4->sin_addr; } saddr.in4 = src4->sin_addr; break; #ifdef INET6 case AF_INET6: src6 = (struct sockaddr_in6 *)src; if (IN6_IS_ADDR_UNSPECIFIED(&src6->sin6_addr) || IN6_IS_ADDR_MULTICAST(&src6->sin6_addr)) return (EINVAL); if (src6->sin6_port != htons(0)) port = src6->sin6_port; if (dst->sa_family != AF_UNSPEC) { if (dst->sa_family != AF_INET6) return (EINVAL); dst6 = (struct sockaddr_in6 *)dst; if (IN6_IS_ADDR_UNSPECIFIED(&dst6->sin6_addr)) return (EINVAL); if (src6->sin6_scope_id != dst6->sin6_scope_id) return (EINVAL); /* all good */ mode = IN6_IS_ADDR_MULTICAST(&dst6->sin6_addr) ? VXLAN_TMODE_LEARNING : VXLAN_TMODE_P2P; error = in6_embedscope(&daddr.in6, dst6, NULL); if (error != 0) return (error); } error = in6_embedscope(&saddr.in6, src6, NULL); if (error != 0) return (error); break; #endif default: return (EAFNOSUPPORT); } if (memcmp(&sc->sc_src, &saddr, sizeof(sc->sc_src)) == 0 && memcmp(&sc->sc_dst, &daddr, sizeof(sc->sc_dst)) == 0 && sc->sc_port == port) return (0); if (ISSET(ifp->if_flags, IFF_RUNNING)) return (EBUSY); /* commit */ sc->sc_af = src->sa_family; sc->sc_src = saddr; sc->sc_dst = daddr; sc->sc_port = port; sc->sc_mode = mode; etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); return (0); } static int vxlan_get_tunnel(struct vxlan_softc *sc, struct if_laddrreq *req) { struct sockaddr *dstaddr = (struct sockaddr *)&req->dstaddr; struct sockaddr_in *sin; #ifdef INET6 struct sockaddr_in6 *sin6; #endif if (sc->sc_af == AF_UNSPEC) return (EADDRNOTAVAIL); KASSERT(sc->sc_mode != VXLAN_TMODE_UNSET); memset(&req->addr, 0, sizeof(req->addr)); memset(&req->dstaddr, 0, sizeof(req->dstaddr)); /* default to endpoint */ dstaddr->sa_len = 2; dstaddr->sa_family = AF_UNSPEC; switch (sc->sc_af) { case AF_INET: sin = (struct sockaddr_in *)&req->addr; sin->sin_len = sizeof(*sin); sin->sin_family = AF_INET; sin->sin_addr = sc->sc_src.in4; sin->sin_port = sc->sc_port; if (sc->sc_mode == VXLAN_TMODE_ENDPOINT) break; sin = (struct sockaddr_in *)&req->dstaddr; sin->sin_len = sizeof(*sin); sin->sin_family = AF_INET; sin->sin_addr = sc->sc_dst.in4; break; #ifdef INET6 case AF_INET6: sin6 = (struct sockaddr_in6 *)&req->addr; sin6->sin6_len = sizeof(*sin6); sin6->sin6_family = AF_INET6; in6_recoverscope(sin6, &sc->sc_src.in6); sin6->sin6_port = sc->sc_port; if (sc->sc_mode == VXLAN_TMODE_ENDPOINT) break; sin6 = (struct sockaddr_in6 *)&req->dstaddr; sin6->sin6_len = sizeof(*sin6); sin6->sin6_family = AF_INET6; in6_recoverscope(sin6, &sc->sc_dst.in6); break; #endif default: unhandled_af(sc->sc_af); } return (0); } static int vxlan_del_tunnel(struct vxlan_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; if (sc->sc_af == AF_UNSPEC) return (0); if (ISSET(ifp->if_flags, IFF_RUNNING)) return (EBUSY); /* commit */ sc->sc_af = AF_UNSPEC; memset(&sc->sc_src, 0, sizeof(sc->sc_src)); memset(&sc->sc_dst, 0, sizeof(sc->sc_dst)); sc->sc_port = htons(0); sc->sc_mode = VXLAN_TMODE_UNSET; etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); return (0); } static int vxlan_set_vnetid(struct vxlan_softc *sc, const struct ifreq *ifr) { struct ifnet *ifp = &sc->sc_ac.ac_if; uint32_t vni; if (ifr->ifr_vnetid < VXLAN_VNI_MIN || ifr->ifr_vnetid > VXLAN_VNI_MAX) return (EINVAL); vni = htonl(ifr->ifr_vnetid << VXLAN_VNI_SHIFT); if (ISSET(sc->sc_header.vxlan_flags, htonl(VXLAN_F_I)) && sc->sc_header.vxlan_id == vni) return (0); if (ISSET(ifp->if_flags, IFF_RUNNING)) return (EBUSY); /* commit */ SET(sc->sc_header.vxlan_flags, htonl(VXLAN_F_I)); sc->sc_header.vxlan_id = vni; etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); return (0); } static int vxlan_get_vnetid(struct vxlan_softc *sc, struct ifreq *ifr) { uint32_t vni; if (!ISSET(sc->sc_header.vxlan_flags, htonl(VXLAN_F_I))) return (EADDRNOTAVAIL); vni = ntohl(sc->sc_header.vxlan_id); vni &= VXLAN_VNI_MASK; vni >>= VXLAN_VNI_SHIFT; ifr->ifr_vnetid = vni; return (0); } static int vxlan_del_vnetid(struct vxlan_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; if (!ISSET(sc->sc_header.vxlan_flags, htonl(VXLAN_F_I))) return (0); if (ISSET(ifp->if_flags, IFF_RUNNING)) return (EBUSY); /* commit */ CLR(sc->sc_header.vxlan_flags, htonl(VXLAN_F_I)); sc->sc_header.vxlan_id = htonl(0 << VXLAN_VNI_SHIFT); etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); return (0); } static int vxlan_set_parent(struct vxlan_softc *sc, const struct if_parent *p) { struct ifnet *ifp = &sc->sc_ac.ac_if; struct ifnet *ifp0; int error = 0; ifp0 = if_unit(p->ifp_parent); if (ifp0 == NULL) return (ENXIO); if (!ISSET(ifp0->if_flags, IFF_MULTICAST)) { error = ENXIO; goto put; } if (sc->sc_if_index0 == ifp0->if_index) goto put; if (ISSET(ifp->if_flags, IFF_RUNNING)) { error = EBUSY; goto put; } /* commit */ sc->sc_if_index0 = ifp0->if_index; etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); put: if_put(ifp0); return (error); } static int vxlan_get_parent(struct vxlan_softc *sc, struct if_parent *p) { struct ifnet *ifp0; int error = 0; ifp0 = if_get(sc->sc_if_index0); if (ifp0 == NULL) error = EADDRNOTAVAIL; else strlcpy(p->ifp_parent, ifp0->if_xname, sizeof(p->ifp_parent)); if_put(ifp0); return (error); } static int vxlan_del_parent(struct vxlan_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; if (sc->sc_if_index0 == 0) return (0); if (ISSET(ifp->if_flags, IFF_RUNNING)) return (EBUSY); /* commit */ sc->sc_if_index0 = 0; etherbridge_flush(&sc->sc_eb, IFBF_FLUSHALL); return (0); } static int vxlan_add_addr(struct vxlan_softc *sc, const struct ifbareq *ifba) { struct sockaddr_in *sin; #ifdef INET6 struct sockaddr_in6 *sin6; struct sockaddr_in6 src6 = { .sin6_len = sizeof(src6), .sin6_family = AF_UNSPEC, }; int error; #endif union vxlan_addr endpoint; unsigned int type; switch (sc->sc_mode) { case VXLAN_TMODE_UNSET: return (ENOPROTOOPT); case VXLAN_TMODE_P2P: return (EPROTONOSUPPORT); default: break; } /* ignore ifba_ifsname */ if (ISSET(ifba->ifba_flags, ~IFBAF_TYPEMASK)) return (EINVAL); switch (ifba->ifba_flags & IFBAF_TYPEMASK) { case IFBAF_DYNAMIC: type = EBE_DYNAMIC; break; case IFBAF_STATIC: type = EBE_STATIC; break; default: return (EINVAL); } memset(&endpoint, 0, sizeof(endpoint)); if (ifba->ifba_dstsa.ss_family != sc->sc_af) return (EAFNOSUPPORT); switch (ifba->ifba_dstsa.ss_family) { case AF_INET: sin = (struct sockaddr_in *)&ifba->ifba_dstsa; if (in_nullhost(sin->sin_addr) || IN_MULTICAST(sin->sin_addr.s_addr)) return (EADDRNOTAVAIL); if (sin->sin_port != htons(0)) return (EADDRNOTAVAIL); endpoint.in4 = sin->sin_addr; break; #ifdef INET6 case AF_INET6: sin6 = (struct sockaddr_in6 *)&ifba->ifba_dstsa; if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) || IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) return (EADDRNOTAVAIL); in6_recoverscope(&src6, &sc->sc_src.in6); if (src6.sin6_scope_id != sin6->sin6_scope_id) return (EADDRNOTAVAIL); if (sin6->sin6_port != htons(0)) return (EADDRNOTAVAIL); error = in6_embedscope(&endpoint.in6, sin6, NULL); if (error != 0) return (error); break; #endif default: /* AF_UNSPEC */ return (EADDRNOTAVAIL); } return (etherbridge_add_addr(&sc->sc_eb, &endpoint, &ifba->ifba_dst, type)); } static int vxlan_del_addr(struct vxlan_softc *sc, const struct ifbareq *ifba) { return (etherbridge_del_addr(&sc->sc_eb, &ifba->ifba_dst)); } void vxlan_detach_hook(void *arg) { struct vxlan_softc *sc = arg; struct ifnet *ifp = &sc->sc_ac.ac_if; if (ISSET(ifp->if_flags, IFF_RUNNING)) { vxlan_down(sc); CLR(ifp->if_flags, IFF_UP); } sc->sc_if_index0 = 0; } static int vxlan_eb_port_eq(void *arg, void *a, void *b) { const union vxlan_addr *va = a, *vb = b; size_t i; for (i = 0; i < nitems(va->in6.s6_addr32); i++) { if (va->in6.s6_addr32[i] != vb->in6.s6_addr32[i]) return (0); } return (1); } static void * vxlan_eb_port_take(void *arg, void *port) { union vxlan_addr *endpoint; endpoint = pool_get(&vxlan_endpoint_pool, PR_NOWAIT); if (endpoint == NULL) return (NULL); *endpoint = *(union vxlan_addr *)port; return (endpoint); } static void vxlan_eb_port_rele(void *arg, void *port) { union vxlan_addr *endpoint = port; pool_put(&vxlan_endpoint_pool, endpoint); } static size_t vxlan_eb_port_ifname(void *arg, char *dst, size_t len, void *port) { struct vxlan_softc *sc = arg; return (strlcpy(dst, sc->sc_ac.ac_if.if_xname, len)); } static void vxlan_eb_port_sa(void *arg, struct sockaddr_storage *ss, void *port) { struct vxlan_softc *sc = arg; union vxlan_addr *endpoint = port; switch (sc->sc_af) { case AF_INET: { struct sockaddr_in *sin = (struct sockaddr_in *)ss; sin->sin_len = sizeof(*sin); sin->sin_family = AF_INET; sin->sin_addr = endpoint->in4; break; } #ifdef INET6 case AF_INET6: { struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ss; sin6->sin6_len = sizeof(*sin6); sin6->sin6_family = AF_INET6; in6_recoverscope(sin6, &endpoint->in6); break; } #endif /* INET6 */ default: unhandled_af(sc->sc_af); } } static inline int vxlan_peer_cmp(const struct vxlan_peer *ap, const struct vxlan_peer *bp) { size_t i; if (ap->p_header.vxlan_id > bp->p_header.vxlan_id) return (1); if (ap->p_header.vxlan_id < bp->p_header.vxlan_id) return (-1); if (ap->p_header.vxlan_flags > bp->p_header.vxlan_flags) return (1); if (ap->p_header.vxlan_flags < bp->p_header.vxlan_flags) return (-1); for (i = 0; i < nitems(ap->p_addr.in6.s6_addr32); i++) { if (ap->p_addr.in6.s6_addr32[i] > bp->p_addr.in6.s6_addr32[i]) return (1); if (ap->p_addr.in6.s6_addr32[i] < bp->p_addr.in6.s6_addr32[i]) return (-1); } return (0); } RBT_GENERATE(vxlan_peers, vxlan_peer, p_entry, vxlan_peer_cmp);
c131ca05df619f0883df81646e811bdc22d78c93
a4d8fcfa8084c5d36a862aeb0978327ff4cfe50f
/include/system/mutex.h
2beead4e8b1cf95bea4497503c79b6cbc14b8829
[ "Artistic-2.0" ]
permissive
cahirwpz/demoscene
a0b548527d89a354b5b8dfd922f39d8b14d61643
cd4517ba69e26c96a69e505e305a6d0152972982
refs/heads/master
2023-03-17T13:06:43.731158
2023-03-13T19:48:47
2023-03-13T19:48:47
3,242,770
105
21
Artistic-2.0
2022-10-18T09:43:25
2012-01-22T23:03:06
C
UTF-8
C
false
false
651
h
mutex.h
#ifndef __SYSTEM_MUTEX_H__ #define __SYSTEM_MUTEX_H__ #include <types.h> #include <system/queue.h> struct Task; typedef struct Mutex { volatile struct Task *owner; TAILQ_HEAD(, Task) waitList; } MutexT; static inline void MutexInit(MutexT *mtx) { mtx->owner = NULL; TAILQ_INIT(&mtx->waitList); } #define MUTEX(name) \ MutexT name = (MutexT) { \ .owner = NULL, .waitList = TAILQ_HEAD_INITIALIZER(name.waitList) \ } void MutexLock(MutexT *mtx); void MutexUnlock(MutexT *mtx); #endif /* !__SYSTEM_MUTEX_H__ */
92d821b52414d6fa673c08cea17a56527ec55cd0
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/tools/fit_image.c
3ececf913ff4c4fe2c1c2457f3f5b5ccbfa195fb
[ "GPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
4,775
c
fit_image.c
/* * (C) Copyright 2008 Semihalf * * (C) Copyright 2000-2004 * DENX Software Engineering * Wolfgang Denk, wd@denx.de * * Updated-by: Prafulla Wadaskar <prafulla@marvell.com> * FIT image specific code abstracted from mkimage.c * some functions added to address abstraction * * All rights reserved. * * SPDX-License-Identifier: GPL-2.0+ */ #include "imagetool.h" #include "fit_common.h" #include "mkimage.h" #include <image.h> #include <u-boot/crc.h> static image_header_t header; static int fit_add_file_data(struct image_tool_params *params, size_t size_inc, const char *tmpfile) { int tfd, destfd = 0; void *dest_blob = NULL; off_t destfd_size = 0; struct stat sbuf; void *ptr; int ret = 0; tfd = mmap_fdt(params->cmdname, tmpfile, size_inc, &ptr, &sbuf, true); if (tfd < 0) return -EIO; if (params->keydest) { struct stat dest_sbuf; destfd = mmap_fdt(params->cmdname, params->keydest, size_inc, &dest_blob, &dest_sbuf, false); if (destfd < 0) { ret = -EIO; goto err_keydest; } destfd_size = dest_sbuf.st_size; } /* for first image creation, add a timestamp at offset 0 i.e., root */ if (params->datafile) ret = fit_set_timestamp(ptr, 0, sbuf.st_mtime); if (!ret) { ret = fit_add_verification_data(params->keydir, dest_blob, ptr, params->comment, params->require_keys); } if (dest_blob) { munmap(dest_blob, destfd_size); close(destfd); } err_keydest: munmap(ptr, sbuf.st_size); close(tfd); return ret; } /** * fit_handle_file - main FIT file processing function * * fit_handle_file() runs dtc to convert .its to .itb, includes * binary data, updates timestamp property and calculates hashes. * * datafile - .its file * imagefile - .itb file * * returns: * only on success, otherwise calls exit (EXIT_FAILURE); */ static int fit_handle_file(struct image_tool_params *params) { char tmpfile[MKIMAGE_MAX_TMPFILE_LEN]; char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN]; size_t size_inc; int ret; /* Flattened Image Tree (FIT) format handling */ debug ("FIT format handling\n"); /* call dtc to include binary properties into the tmp file */ if (strlen (params->imagefile) + strlen (MKIMAGE_TMPFILE_SUFFIX) + 1 > sizeof (tmpfile)) { fprintf (stderr, "%s: Image file name (%s) too long, " "can't create tmpfile", params->imagefile, params->cmdname); return (EXIT_FAILURE); } sprintf (tmpfile, "%s%s", params->imagefile, MKIMAGE_TMPFILE_SUFFIX); /* We either compile the source file, or use the existing FIT image */ if (params->datafile) { /* dtc -I dts -O dtb -p 500 datafile > tmpfile */ snprintf(cmd, sizeof(cmd), "%s %s %s > %s", MKIMAGE_DTC, params->dtc, params->datafile, tmpfile); debug("Trying to execute \"%s\"\n", cmd); } else { snprintf(cmd, sizeof(cmd), "cp %s %s", params->imagefile, tmpfile); } if (system (cmd) == -1) { fprintf (stderr, "%s: system(%s) failed: %s\n", params->cmdname, cmd, strerror(errno)); goto err_system; } /* * Set hashes for images in the blob. Unfortunately we may need more * space in either FDT, so keep trying until we succeed. * * Note: this is pretty inefficient for signing, since we must * calculate the signature every time. It would be better to calculate * all the data and then store it in a separate step. However, this * would be considerably more complex to implement. Generally a few * steps of this loop is enough to sign with several keys. */ for (size_inc = 0; size_inc < 64 * 1024; size_inc += 1024) { ret = fit_add_file_data(params, size_inc, tmpfile); if (!ret || ret != -ENOSPC) break; } if (ret) { fprintf(stderr, "%s Can't add hashes to FIT blob\n", params->cmdname); goto err_system; } if (rename (tmpfile, params->imagefile) == -1) { fprintf (stderr, "%s: Can't rename %s to %s: %s\n", params->cmdname, tmpfile, params->imagefile, strerror (errno)); unlink (tmpfile); unlink (params->imagefile); return EXIT_FAILURE; } return EXIT_SUCCESS; err_system: unlink(tmpfile); return -1; } static int fit_check_params(struct image_tool_params *params) { return ((params->dflag && (params->fflag || params->lflag)) || (params->fflag && (params->dflag || params->lflag)) || (params->lflag && (params->dflag || params->fflag))); } static struct image_type_params fitimage_params = { .name = "FIT Image support", .header_size = sizeof(image_header_t), .hdr = (void*)&header, .verify_header = fit_verify_header, .print_header = fit_print_contents, .check_image_type = fit_check_image_types, .fflag_handle = fit_handle_file, .set_header = NULL, /* FIT images use DTB header */ .check_params = fit_check_params, }; void init_fit_image_type (void) { register_image_type(&fitimage_params); }
d1439a72d72bd8b999c9ac66131f04a390cbf5cf
8a51a96f61699f0318315ccc89cef39f6866f2b5
/src/bin/pg_basebackup/pg_basebackup.c
1dc8efe0cb7be11dbe32e7f74ef1426e106c6cdf
[ "PostgreSQL" ]
permissive
postgres/postgres
979febf2b41c00090d1256228f768f33e7ef3b6f
b5934bfd6071fed3a38cea0cfaa93afda63d9c0c
refs/heads/master
2023-08-31T00:10:01.373472
2023-08-30T23:07:48
2023-08-30T23:07:48
927,442
13,691
4,807
NOASSERTION
2023-09-09T13:59:15
2010-09-21T11:35:45
C
UTF-8
C
false
false
79,552
c
pg_basebackup.c
/*------------------------------------------------------------------------- * * pg_basebackup.c - receive a base backup using streaming replication protocol * * Author: Magnus Hagander <magnus@hagander.net> * * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group * * IDENTIFICATION * src/bin/pg_basebackup/pg_basebackup.c *------------------------------------------------------------------------- */ #include "postgres_fe.h" #include <unistd.h> #include <dirent.h> #include <limits.h> #include <sys/select.h> #include <sys/stat.h> #include <sys/wait.h> #include <signal.h> #include <time.h> #ifdef HAVE_LIBZ #include <zlib.h> #endif #include "access/xlog_internal.h" #include "backup/basebackup.h" #include "bbstreamer.h" #include "common/compression.h" #include "common/file_perm.h" #include "common/file_utils.h" #include "common/logging.h" #include "fe_utils/option_utils.h" #include "fe_utils/recovery_gen.h" #include "getopt_long.h" #include "receivelog.h" #include "streamutil.h" #define ERRCODE_DATA_CORRUPTED "XX001" typedef struct TablespaceListCell { struct TablespaceListCell *next; char old_dir[MAXPGPATH]; char new_dir[MAXPGPATH]; } TablespaceListCell; typedef struct TablespaceList { TablespaceListCell *head; TablespaceListCell *tail; } TablespaceList; typedef struct ArchiveStreamState { int tablespacenum; pg_compress_specification *compress; bbstreamer *streamer; bbstreamer *manifest_inject_streamer; PQExpBuffer manifest_buffer; char manifest_filename[MAXPGPATH]; FILE *manifest_file; } ArchiveStreamState; typedef struct WriteTarState { int tablespacenum; bbstreamer *streamer; } WriteTarState; typedef struct WriteManifestState { char filename[MAXPGPATH]; FILE *file; } WriteManifestState; typedef void (*WriteDataCallback) (size_t nbytes, char *buf, void *callback_data); /* * pg_xlog has been renamed to pg_wal in version 10. This version number * should be compared with PQserverVersion(). */ #define MINIMUM_VERSION_FOR_PG_WAL 100000 /* * Temporary replication slots are supported from version 10. */ #define MINIMUM_VERSION_FOR_TEMP_SLOTS 100000 /* * Backup manifests are supported from version 13. */ #define MINIMUM_VERSION_FOR_MANIFESTS 130000 /* * Before v15, tar files received from the server will be improperly * terminated. */ #define MINIMUM_VERSION_FOR_TERMINATED_TARFILE 150000 /* * Different ways to include WAL */ typedef enum { NO_WAL, FETCH_WAL, STREAM_WAL } IncludeWal; /* * Different places to perform compression */ typedef enum { COMPRESS_LOCATION_UNSPECIFIED, COMPRESS_LOCATION_CLIENT, COMPRESS_LOCATION_SERVER } CompressionLocation; /* Global options */ static char *basedir = NULL; static TablespaceList tablespace_dirs = {NULL, NULL}; static char *xlog_dir = NULL; static char format = '\0'; /* p(lain)/t(ar) */ static char *label = "pg_basebackup base backup"; static bool noclean = false; static bool checksum_failure = false; static bool showprogress = false; static bool estimatesize = true; static int verbose = 0; static IncludeWal includewal = STREAM_WAL; static bool fastcheckpoint = false; static bool writerecoveryconf = false; static bool do_sync = true; static int standby_message_timeout = 10 * 1000; /* 10 sec = default */ static pg_time_t last_progress_report = 0; static int32 maxrate = 0; /* no limit by default */ static char *replication_slot = NULL; static bool temp_replication_slot = true; static char *backup_target = NULL; static bool create_slot = false; static bool no_slot = false; static bool verify_checksums = true; static bool manifest = true; static bool manifest_force_encode = false; static char *manifest_checksums = NULL; static bool success = false; static bool made_new_pgdata = false; static bool found_existing_pgdata = false; static bool made_new_xlogdir = false; static bool found_existing_xlogdir = false; static bool made_tablespace_dirs = false; static bool found_tablespace_dirs = false; /* Progress indicators */ static uint64 totalsize_kb; static uint64 totaldone; static int tablespacecount; static char *progress_filename = NULL; /* Pipe to communicate with background wal receiver process */ #ifndef WIN32 static int bgpipe[2] = {-1, -1}; #endif /* Handle to child process */ static pid_t bgchild = -1; static bool in_log_streamer = false; /* Flag to indicate if child process exited unexpectedly */ static volatile sig_atomic_t bgchild_exited = false; /* End position for xlog streaming, empty string if unknown yet */ static XLogRecPtr xlogendptr; #ifndef WIN32 static int has_xlogendptr = 0; #else static volatile LONG has_xlogendptr = 0; #endif /* Contents of configuration file to be generated */ static PQExpBuffer recoveryconfcontents = NULL; /* Function headers */ static void usage(void); static void verify_dir_is_empty_or_create(char *dirname, bool *created, bool *found); static void progress_update_filename(const char *filename); static void progress_report(int tablespacenum, bool force, bool finished); static bbstreamer *CreateBackupStreamer(char *archive_name, char *spclocation, bbstreamer **manifest_inject_streamer_p, bool is_recovery_guc_supported, bool expect_unterminated_tarfile, pg_compress_specification *compress); static void ReceiveArchiveStreamChunk(size_t r, char *copybuf, void *callback_data); static char GetCopyDataByte(size_t r, char *copybuf, size_t *cursor); static char *GetCopyDataString(size_t r, char *copybuf, size_t *cursor); static uint64 GetCopyDataUInt64(size_t r, char *copybuf, size_t *cursor); static void GetCopyDataEnd(size_t r, char *copybuf, size_t cursor); static void ReportCopyDataParseError(size_t r, char *copybuf); static void ReceiveTarFile(PGconn *conn, char *archive_name, char *spclocation, bool tablespacenum, pg_compress_specification *compress); static void ReceiveTarCopyChunk(size_t r, char *copybuf, void *callback_data); static void ReceiveBackupManifest(PGconn *conn); static void ReceiveBackupManifestChunk(size_t r, char *copybuf, void *callback_data); static void ReceiveBackupManifestInMemory(PGconn *conn, PQExpBuffer buf); static void ReceiveBackupManifestInMemoryChunk(size_t r, char *copybuf, void *callback_data); static void BaseBackup(char *compression_algorithm, char *compression_detail, CompressionLocation compressloc, pg_compress_specification *client_compress); static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished); static const char *get_tablespace_mapping(const char *dir); static void tablespace_list_append(const char *arg); static void cleanup_directories_atexit(void) { if (success || in_log_streamer) return; if (!noclean && !checksum_failure) { if (made_new_pgdata) { pg_log_info("removing data directory \"%s\"", basedir); if (!rmtree(basedir, true)) pg_log_error("failed to remove data directory"); } else if (found_existing_pgdata) { pg_log_info("removing contents of data directory \"%s\"", basedir); if (!rmtree(basedir, false)) pg_log_error("failed to remove contents of data directory"); } if (made_new_xlogdir) { pg_log_info("removing WAL directory \"%s\"", xlog_dir); if (!rmtree(xlog_dir, true)) pg_log_error("failed to remove WAL directory"); } else if (found_existing_xlogdir) { pg_log_info("removing contents of WAL directory \"%s\"", xlog_dir); if (!rmtree(xlog_dir, false)) pg_log_error("failed to remove contents of WAL directory"); } } else { if ((made_new_pgdata || found_existing_pgdata) && !checksum_failure) pg_log_info("data directory \"%s\" not removed at user's request", basedir); if (made_new_xlogdir || found_existing_xlogdir) pg_log_info("WAL directory \"%s\" not removed at user's request", xlog_dir); } if ((made_tablespace_dirs || found_tablespace_dirs) && !checksum_failure) pg_log_info("changes to tablespace directories will not be undone"); } static void disconnect_atexit(void) { if (conn != NULL) PQfinish(conn); } #ifndef WIN32 /* * If the bgchild exits prematurely and raises a SIGCHLD signal, we can abort * processing rather than wait until the backup has finished and error out at * that time. On Windows, we use a background thread which can communicate * without the need for a signal handler. */ static void sigchld_handler(SIGNAL_ARGS) { bgchild_exited = true; } /* * On windows, our background thread dies along with the process. But on * Unix, if we have started a subprocess, we want to kill it off so it * doesn't remain running trying to stream data. */ static void kill_bgchild_atexit(void) { if (bgchild > 0 && !bgchild_exited) kill(bgchild, SIGTERM); } #endif /* * Split argument into old_dir and new_dir and append to tablespace mapping * list. */ static void tablespace_list_append(const char *arg) { TablespaceListCell *cell = (TablespaceListCell *) pg_malloc0(sizeof(TablespaceListCell)); char *dst; char *dst_ptr; const char *arg_ptr; dst_ptr = dst = cell->old_dir; for (arg_ptr = arg; *arg_ptr; arg_ptr++) { if (dst_ptr - dst >= MAXPGPATH) pg_fatal("directory name too long"); if (*arg_ptr == '\\' && *(arg_ptr + 1) == '=') ; /* skip backslash escaping = */ else if (*arg_ptr == '=' && (arg_ptr == arg || *(arg_ptr - 1) != '\\')) { if (*cell->new_dir) pg_fatal("multiple \"=\" signs in tablespace mapping"); else dst = dst_ptr = cell->new_dir; } else *dst_ptr++ = *arg_ptr; } if (!*cell->old_dir || !*cell->new_dir) pg_fatal("invalid tablespace mapping format \"%s\", must be \"OLDDIR=NEWDIR\"", arg); /* * All tablespaces are created with absolute directories, so specifying a * non-absolute path here would just never match, possibly confusing * users. Since we don't know whether the remote side is Windows or not, * and it might be different than the local side, permit any path that * could be absolute under either set of rules. * * (There is little practical risk of confusion here, because someone * running entirely on Linux isn't likely to have a relative path that * begins with a backslash or something that looks like a drive * specification. If they do, and they also incorrectly believe that a * relative path is acceptable here, we'll silently fail to warn them of * their mistake, and the -T option will just not get applied, same as if * they'd specified -T for a nonexistent tablespace.) */ if (!is_nonwindows_absolute_path(cell->old_dir) && !is_windows_absolute_path(cell->old_dir)) pg_fatal("old directory is not an absolute path in tablespace mapping: %s", cell->old_dir); if (!is_absolute_path(cell->new_dir)) pg_fatal("new directory is not an absolute path in tablespace mapping: %s", cell->new_dir); /* * Comparisons done with these values should involve similarly * canonicalized path values. This is particularly sensitive on Windows * where path values may not necessarily use Unix slashes. */ canonicalize_path(cell->old_dir); canonicalize_path(cell->new_dir); if (tablespace_dirs.tail) tablespace_dirs.tail->next = cell; else tablespace_dirs.head = cell; tablespace_dirs.tail = cell; } static void usage(void) { printf(_("%s takes a base backup of a running PostgreSQL server.\n\n"), progname); printf(_("Usage:\n")); printf(_(" %s [OPTION]...\n"), progname); printf(_("\nOptions controlling the output:\n")); printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n")); printf(_(" -F, --format=p|t output format (plain (default), tar)\n")); printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n" " (in kB/s, or use suffix \"k\" or \"M\")\n")); printf(_(" -R, --write-recovery-conf\n" " write configuration for replication\n")); printf(_(" -t, --target=TARGET[:DETAIL]\n" " backup target (if other than client)\n")); printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n" " relocate tablespace in OLDDIR to NEWDIR\n")); printf(_(" --waldir=WALDIR location for the write-ahead log directory\n")); printf(_(" -X, --wal-method=none|fetch|stream\n" " include required WAL files with specified method\n")); printf(_(" -z, --gzip compress tar output\n")); printf(_(" -Z, --compress=[{client|server}-]METHOD[:DETAIL]\n" " compress on client or server as specified\n")); printf(_(" -Z, --compress=none do not compress tar output\n")); printf(_("\nGeneral options:\n")); printf(_(" -c, --checkpoint=fast|spread\n" " set fast or spread checkpointing\n")); printf(_(" -C, --create-slot create replication slot\n")); printf(_(" -l, --label=LABEL set backup label\n")); printf(_(" -n, --no-clean do not clean up after errors\n")); printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n")); printf(_(" -P, --progress show progress information\n")); printf(_(" -S, --slot=SLOTNAME replication slot to use\n")); printf(_(" -v, --verbose output verbose messages\n")); printf(_(" -V, --version output version information, then exit\n")); printf(_(" --manifest-checksums=SHA{224,256,384,512}|CRC32C|NONE\n" " use algorithm for manifest checksums\n")); printf(_(" --manifest-force-encode\n" " hex encode all file names in manifest\n")); printf(_(" --no-estimate-size do not estimate backup size in server side\n")); printf(_(" --no-manifest suppress generation of backup manifest\n")); printf(_(" --no-slot prevent creation of temporary replication slot\n")); printf(_(" --no-verify-checksums\n" " do not verify checksums\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_("\nConnection options:\n")); printf(_(" -d, --dbname=CONNSTR connection string\n")); printf(_(" -h, --host=HOSTNAME database server host or socket directory\n")); printf(_(" -p, --port=PORT database server port number\n")); printf(_(" -s, --status-interval=INTERVAL\n" " time between status packets sent to server (in seconds)\n")); printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -w, --no-password never prompt for password\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); printf(_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); } /* * Called in the background process every time data is received. * On Unix, we check to see if there is any data on our pipe * (which would mean we have a stop position), and if it is, check if * it is time to stop. * On Windows, we are in a single process, so we can just check if it's * time to stop. */ static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished) { if (!has_xlogendptr) { #ifndef WIN32 fd_set fds; struct timeval tv = {0}; int r; /* * Don't have the end pointer yet - check our pipe to see if it has * been sent yet. */ FD_ZERO(&fds); FD_SET(bgpipe[0], &fds); r = select(bgpipe[0] + 1, &fds, NULL, NULL, &tv); if (r == 1) { char xlogend[64] = {0}; uint32 hi, lo; r = read(bgpipe[0], xlogend, sizeof(xlogend) - 1); if (r < 0) pg_fatal("could not read from ready pipe: %m"); if (sscanf(xlogend, "%X/%X", &hi, &lo) != 2) pg_fatal("could not parse write-ahead log location \"%s\"", xlogend); xlogendptr = ((uint64) hi) << 32 | lo; has_xlogendptr = 1; /* * Fall through to check if we've reached the point further * already. */ } else { /* * No data received on the pipe means we don't know the end * position yet - so just say it's not time to stop yet. */ return false; } #else /* * On win32, has_xlogendptr is set by the main thread, so if it's not * set here, we just go back and wait until it shows up. */ return false; #endif } /* * At this point we have an end pointer, so compare it to the current * position to figure out if it's time to stop. */ if (segendpos >= xlogendptr) return true; /* * Have end pointer, but haven't reached it yet - so tell the caller to * keep streaming. */ return false; } typedef struct { PGconn *bgconn; XLogRecPtr startptr; char xlog[MAXPGPATH]; /* directory or tarfile depending on mode */ char *sysidentifier; int timeline; pg_compress_algorithm wal_compress_algorithm; int wal_compress_level; } logstreamer_param; static int LogStreamerMain(logstreamer_param *param) { StreamCtl stream = {0}; in_log_streamer = true; stream.startpos = param->startptr; stream.timeline = param->timeline; stream.sysidentifier = param->sysidentifier; stream.stream_stop = reached_end_position; #ifndef WIN32 stream.stop_socket = bgpipe[0]; #else stream.stop_socket = PGINVALID_SOCKET; #endif stream.standby_message_timeout = standby_message_timeout; stream.synchronous = false; /* fsync happens at the end of pg_basebackup for all data */ stream.do_sync = false; stream.mark_done = true; stream.partial_suffix = NULL; stream.replication_slot = replication_slot; if (format == 'p') stream.walmethod = CreateWalDirectoryMethod(param->xlog, PG_COMPRESSION_NONE, 0, stream.do_sync); else stream.walmethod = CreateWalTarMethod(param->xlog, param->wal_compress_algorithm, param->wal_compress_level, stream.do_sync); if (!ReceiveXlogStream(param->bgconn, &stream)) { /* * Any errors will already have been reported in the function process, * but we need to tell the parent that we didn't shutdown in a nice * way. */ #ifdef WIN32 /* * In order to signal the main thread of an ungraceful exit we set the * same flag that we use on Unix to signal SIGCHLD. */ bgchild_exited = true; #endif return 1; } if (!stream.walmethod->ops->finish(stream.walmethod)) { pg_log_error("could not finish writing WAL files: %m"); #ifdef WIN32 bgchild_exited = true; #endif return 1; } PQfinish(param->bgconn); stream.walmethod->ops->free(stream.walmethod); return 0; } /* * Initiate background process for receiving xlog during the backup. * The background stream will use its own database connection so we can * stream the logfile in parallel with the backups. */ static void StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier, pg_compress_algorithm wal_compress_algorithm, int wal_compress_level) { logstreamer_param *param; uint32 hi, lo; char statusdir[MAXPGPATH]; param = pg_malloc0(sizeof(logstreamer_param)); param->timeline = timeline; param->sysidentifier = sysidentifier; param->wal_compress_algorithm = wal_compress_algorithm; param->wal_compress_level = wal_compress_level; /* Convert the starting position */ if (sscanf(startpos, "%X/%X", &hi, &lo) != 2) pg_fatal("could not parse write-ahead log location \"%s\"", startpos); param->startptr = ((uint64) hi) << 32 | lo; /* Round off to even segment position */ param->startptr -= XLogSegmentOffset(param->startptr, WalSegSz); #ifndef WIN32 /* Create our background pipe */ if (pipe(bgpipe) < 0) pg_fatal("could not create pipe for background process: %m"); #endif /* Get a second connection */ param->bgconn = GetConnection(); if (!param->bgconn) /* Error message already written in GetConnection() */ exit(1); /* In post-10 cluster, pg_xlog has been renamed to pg_wal */ snprintf(param->xlog, sizeof(param->xlog), "%s/%s", basedir, PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal"); /* Temporary replication slots are only supported in 10 and newer */ if (PQserverVersion(conn) < MINIMUM_VERSION_FOR_TEMP_SLOTS) temp_replication_slot = false; /* * Create replication slot if requested */ if (temp_replication_slot && !replication_slot) replication_slot = psprintf("pg_basebackup_%d", (int) PQbackendPID(param->bgconn)); if (temp_replication_slot || create_slot) { if (!CreateReplicationSlot(param->bgconn, replication_slot, NULL, temp_replication_slot, true, true, false, false)) exit(1); if (verbose) { if (temp_replication_slot) pg_log_info("created temporary replication slot \"%s\"", replication_slot); else pg_log_info("created replication slot \"%s\"", replication_slot); } } if (format == 'p') { /* * Create pg_wal/archive_status or pg_xlog/archive_status (and thus * pg_wal or pg_xlog) depending on the target server so we can write * to basedir/pg_wal or basedir/pg_xlog as the directory entry in the * tar file may arrive later. */ snprintf(statusdir, sizeof(statusdir), "%s/%s/archive_status", basedir, PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal"); if (pg_mkdir_p(statusdir, pg_dir_create_mode) != 0 && errno != EEXIST) pg_fatal("could not create directory \"%s\": %m", statusdir); } /* * Start a child process and tell it to start streaming. On Unix, this is * a fork(). On Windows, we create a thread. */ #ifndef WIN32 bgchild = fork(); if (bgchild == 0) { /* in child process */ exit(LogStreamerMain(param)); } else if (bgchild < 0) pg_fatal("could not create background process: %m"); /* * Else we are in the parent process and all is well. */ atexit(kill_bgchild_atexit); #else /* WIN32 */ bgchild = _beginthreadex(NULL, 0, (void *) LogStreamerMain, param, 0, NULL); if (bgchild == 0) pg_fatal("could not create background thread: %m"); #endif } /* * Verify that the given directory exists and is empty. If it does not * exist, it is created. If it exists but is not empty, an error will * be given and the process ended. */ static void verify_dir_is_empty_or_create(char *dirname, bool *created, bool *found) { switch (pg_check_dir(dirname)) { case 0: /* * Does not exist, so create */ if (pg_mkdir_p(dirname, pg_dir_create_mode) == -1) pg_fatal("could not create directory \"%s\": %m", dirname); if (created) *created = true; return; case 1: /* * Exists, empty */ if (found) *found = true; return; case 2: case 3: case 4: /* * Exists, not empty */ pg_fatal("directory \"%s\" exists but is not empty", dirname); case -1: /* * Access problem */ pg_fatal("could not access directory \"%s\": %m", dirname); } } /* * Callback to update our notion of the current filename. * * No other code should modify progress_filename! */ static void progress_update_filename(const char *filename) { /* We needn't maintain this variable if not doing verbose reports. */ if (showprogress && verbose) { free(progress_filename); if (filename) progress_filename = pg_strdup(filename); else progress_filename = NULL; } } /* * Print a progress report based on the global variables. If verbose output * is enabled, also print the current file name. * * Progress report is written at maximum once per second, unless the force * parameter is set to true. * * If finished is set to true, this is the last progress report. The cursor * is moved to the next line. */ static void progress_report(int tablespacenum, bool force, bool finished) { int percent; char totaldone_str[32]; char totalsize_str[32]; pg_time_t now; if (!showprogress) return; now = time(NULL); if (now == last_progress_report && !force && !finished) return; /* Max once per second */ last_progress_report = now; percent = totalsize_kb ? (int) ((totaldone / 1024) * 100 / totalsize_kb) : 0; /* * Avoid overflowing past 100% or the full size. This may make the total * size number change as we approach the end of the backup (the estimate * will always be wrong if WAL is included), but that's better than having * the done column be bigger than the total. */ if (percent > 100) percent = 100; if (totaldone / 1024 > totalsize_kb) totalsize_kb = totaldone / 1024; snprintf(totaldone_str, sizeof(totaldone_str), UINT64_FORMAT, totaldone / 1024); snprintf(totalsize_str, sizeof(totalsize_str), UINT64_FORMAT, totalsize_kb); #define VERBOSE_FILENAME_LENGTH 35 if (verbose) { if (!progress_filename) /* * No filename given, so clear the status line (used for last * call) */ fprintf(stderr, ngettext("%*s/%s kB (100%%), %d/%d tablespace %*s", "%*s/%s kB (100%%), %d/%d tablespaces %*s", tablespacecount), (int) strlen(totalsize_str), totaldone_str, totalsize_str, tablespacenum, tablespacecount, VERBOSE_FILENAME_LENGTH + 5, ""); else { bool truncate = (strlen(progress_filename) > VERBOSE_FILENAME_LENGTH); fprintf(stderr, ngettext("%*s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)", "%*s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)", tablespacecount), (int) strlen(totalsize_str), totaldone_str, totalsize_str, percent, tablespacenum, tablespacecount, /* Prefix with "..." if we do leading truncation */ truncate ? "..." : "", truncate ? VERBOSE_FILENAME_LENGTH - 3 : VERBOSE_FILENAME_LENGTH, truncate ? VERBOSE_FILENAME_LENGTH - 3 : VERBOSE_FILENAME_LENGTH, /* Truncate filename at beginning if it's too long */ truncate ? progress_filename + strlen(progress_filename) - VERBOSE_FILENAME_LENGTH + 3 : progress_filename); } } else fprintf(stderr, ngettext("%*s/%s kB (%d%%), %d/%d tablespace", "%*s/%s kB (%d%%), %d/%d tablespaces", tablespacecount), (int) strlen(totalsize_str), totaldone_str, totalsize_str, percent, tablespacenum, tablespacecount); /* * Stay on the same line if reporting to a terminal and we're not done * yet. */ fputc((!finished && isatty(fileno(stderr))) ? '\r' : '\n', stderr); } static int32 parse_max_rate(char *src) { double result; char *after_num; char *suffix = NULL; errno = 0; result = strtod(src, &after_num); if (src == after_num) pg_fatal("transfer rate \"%s\" is not a valid value", src); if (errno != 0) pg_fatal("invalid transfer rate \"%s\": %m", src); if (result <= 0) { /* * Reject obviously wrong values here. */ pg_fatal("transfer rate must be greater than zero"); } /* * Evaluate suffix, after skipping over possible whitespace. Lack of * suffix means kilobytes. */ while (*after_num != '\0' && isspace((unsigned char) *after_num)) after_num++; if (*after_num != '\0') { suffix = after_num; if (*after_num == 'k') { /* kilobyte is the expected unit. */ after_num++; } else if (*after_num == 'M') { after_num++; result *= 1024.0; } } /* The rest can only consist of white space. */ while (*after_num != '\0' && isspace((unsigned char) *after_num)) after_num++; if (*after_num != '\0') pg_fatal("invalid --max-rate unit: \"%s\"", suffix); /* Valid integer? */ if ((uint64) result != (uint64) ((uint32) result)) pg_fatal("transfer rate \"%s\" exceeds integer range", src); /* * The range is checked on the server side too, but avoid the server * connection if a nonsensical value was passed. */ if (result < MAX_RATE_LOWER || result > MAX_RATE_UPPER) pg_fatal("transfer rate \"%s\" is out of range", src); return (int32) result; } /* * Basic parsing of a value specified for -Z/--compress. * * We're not concerned here with understanding exactly what behavior the * user wants, but we do need to know whether the user is requesting client * or server side compression or leaving it unspecified, and we need to * separate the name of the compression algorithm from the detail string. * * For instance, if the user writes --compress client-lz4:6, we want to * separate that into (a) client-side compression, (b) algorithm "lz4", * and (c) detail "6". Note, however, that all the client/server prefix is * optional, and so is the detail. The algorithm name is required, unless * the whole string is an integer, in which case we assume "gzip" as the * algorithm and use the integer as the detail. * * We're not concerned with validation at this stage, so if the user writes * --compress client-turkey:sandwich, the requested algorithm is "turkey" * and the detail string is "sandwich". We'll sort out whether that's legal * at a later stage. */ static void backup_parse_compress_options(char *option, char **algorithm, char **detail, CompressionLocation *locationres) { /* * Strip off any "client-" or "server-" prefix, calculating the location. */ if (strncmp(option, "server-", 7) == 0) { *locationres = COMPRESS_LOCATION_SERVER; option += 7; } else if (strncmp(option, "client-", 7) == 0) { *locationres = COMPRESS_LOCATION_CLIENT; option += 7; } else *locationres = COMPRESS_LOCATION_UNSPECIFIED; /* fallback to the common parsing for the algorithm and detail */ parse_compress_options(option, algorithm, detail); } /* * Read a stream of COPY data and invoke the provided callback for each * chunk. */ static void ReceiveCopyData(PGconn *conn, WriteDataCallback callback, void *callback_data) { PGresult *res; /* Get the COPY data stream. */ res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_COPY_OUT) pg_fatal("could not get COPY data stream: %s", PQerrorMessage(conn)); PQclear(res); /* Loop over chunks until done. */ while (1) { int r; char *copybuf; r = PQgetCopyData(conn, &copybuf, 0); if (r == -1) { /* End of chunk. */ break; } else if (r == -2) pg_fatal("could not read COPY data: %s", PQerrorMessage(conn)); if (bgchild_exited) pg_fatal("background process terminated unexpectedly"); (*callback) (r, copybuf, callback_data); PQfreemem(copybuf); } } /* * Figure out what to do with an archive received from the server based on * the options selected by the user. We may just write the results directly * to a file, or we might compress first, or we might extract the tar file * and write each member separately. This function doesn't do any of that * directly, but it works out what kind of bbstreamer we need to create so * that the right stuff happens when, down the road, we actually receive * the data. */ static bbstreamer * CreateBackupStreamer(char *archive_name, char *spclocation, bbstreamer **manifest_inject_streamer_p, bool is_recovery_guc_supported, bool expect_unterminated_tarfile, pg_compress_specification *compress) { bbstreamer *streamer = NULL; bbstreamer *manifest_inject_streamer = NULL; bool inject_manifest; bool is_tar, is_tar_gz, is_tar_lz4, is_tar_zstd, is_compressed_tar; bool must_parse_archive; int archive_name_len = strlen(archive_name); /* * Normally, we emit the backup manifest as a separate file, but when * we're writing a tarfile to stdout, we don't have that option, so * include it in the one tarfile we've got. */ inject_manifest = (format == 't' && strcmp(basedir, "-") == 0 && manifest); /* Is this a tar archive? */ is_tar = (archive_name_len > 4 && strcmp(archive_name + archive_name_len - 4, ".tar") == 0); /* Is this a .tar.gz archive? */ is_tar_gz = (archive_name_len > 7 && strcmp(archive_name + archive_name_len - 7, ".tar.gz") == 0); /* Is this a .tar.lz4 archive? */ is_tar_lz4 = (archive_name_len > 8 && strcmp(archive_name + archive_name_len - 8, ".tar.lz4") == 0); /* Is this a .tar.zst archive? */ is_tar_zstd = (archive_name_len > 8 && strcmp(archive_name + archive_name_len - 8, ".tar.zst") == 0); /* Is this any kind of compressed tar? */ is_compressed_tar = is_tar_gz || is_tar_lz4 || is_tar_zstd; /* * Injecting the manifest into a compressed tar file would be possible if * we decompressed it, parsed the tarfile, generated a new tarfile, and * recompressed it, but compressing and decompressing multiple times just * to inject the manifest seems inefficient enough that it's probably not * what the user wants. So, instead, reject the request and tell the user * to specify something more reasonable. */ if (inject_manifest && is_compressed_tar) { pg_log_error("cannot inject manifest into a compressed tar file"); pg_log_error_hint("Use client-side compression, send the output to a directory rather than standard output, or use %s.", "--no-manifest"); exit(1); } /* * We have to parse the archive if (1) we're suppose to extract it, or if * (2) we need to inject backup_manifest or recovery configuration into * it. However, we only know how to parse tar archives. */ must_parse_archive = (format == 'p' || inject_manifest || (spclocation == NULL && writerecoveryconf)); /* At present, we only know how to parse tar archives. */ if (must_parse_archive && !is_tar && !is_compressed_tar) { pg_log_error("cannot parse archive \"%s\"", archive_name); pg_log_error_detail("Only tar archives can be parsed."); if (format == 'p') pg_log_error_detail("Plain format requires pg_basebackup to parse the archive."); if (inject_manifest) pg_log_error_detail("Using - as the output directory requires pg_basebackup to parse the archive."); if (writerecoveryconf) pg_log_error_detail("The -R option requires pg_basebackup to parse the archive."); exit(1); } if (format == 'p') { const char *directory; /* * In plain format, we must extract the archive. The data for the main * tablespace will be written to the base directory, and the data for * other tablespaces will be written to the directory where they're * located on the server, after applying any user-specified tablespace * mappings. * * In the case of an in-place tablespace, spclocation will be a * relative path. We just convert it to an absolute path by prepending * basedir. */ if (spclocation == NULL) directory = basedir; else if (!is_absolute_path(spclocation)) directory = psprintf("%s/%s", basedir, spclocation); else directory = get_tablespace_mapping(spclocation); streamer = bbstreamer_extractor_new(directory, get_tablespace_mapping, progress_update_filename); } else { FILE *archive_file; char archive_filename[MAXPGPATH]; /* * In tar format, we just write the archive without extracting it. * Normally, we write it to the archive name provided by the caller, * but when the base directory is "-" that means we need to write to * standard output. */ if (strcmp(basedir, "-") == 0) { snprintf(archive_filename, sizeof(archive_filename), "-"); archive_file = stdout; } else { snprintf(archive_filename, sizeof(archive_filename), "%s/%s", basedir, archive_name); archive_file = NULL; } if (compress->algorithm == PG_COMPRESSION_NONE) streamer = bbstreamer_plain_writer_new(archive_filename, archive_file); else if (compress->algorithm == PG_COMPRESSION_GZIP) { strlcat(archive_filename, ".gz", sizeof(archive_filename)); streamer = bbstreamer_gzip_writer_new(archive_filename, archive_file, compress); } else if (compress->algorithm == PG_COMPRESSION_LZ4) { strlcat(archive_filename, ".lz4", sizeof(archive_filename)); streamer = bbstreamer_plain_writer_new(archive_filename, archive_file); streamer = bbstreamer_lz4_compressor_new(streamer, compress); } else if (compress->algorithm == PG_COMPRESSION_ZSTD) { strlcat(archive_filename, ".zst", sizeof(archive_filename)); streamer = bbstreamer_plain_writer_new(archive_filename, archive_file); streamer = bbstreamer_zstd_compressor_new(streamer, compress); } else { Assert(false); /* not reachable */ } /* * If we need to parse the archive for whatever reason, then we'll * also need to re-archive, because, if the output format is tar, the * only point of parsing the archive is to be able to inject stuff * into it. */ if (must_parse_archive) streamer = bbstreamer_tar_archiver_new(streamer); progress_update_filename(archive_filename); } /* * If we're supposed to inject the backup manifest into the results, it * should be done here, so that the file content can be injected directly, * without worrying about the details of the tar format. */ if (inject_manifest) manifest_inject_streamer = streamer; /* * If this is the main tablespace and we're supposed to write recovery * information, arrange to do that. */ if (spclocation == NULL && writerecoveryconf) { Assert(must_parse_archive); streamer = bbstreamer_recovery_injector_new(streamer, is_recovery_guc_supported, recoveryconfcontents); } /* * If we're doing anything that involves understanding the contents of the * archive, we'll need to parse it. If not, we can skip parsing it, but * old versions of the server send improperly terminated tarfiles, so if * we're talking to such a server we'll need to add the terminator here. */ if (must_parse_archive) streamer = bbstreamer_tar_parser_new(streamer); else if (expect_unterminated_tarfile) streamer = bbstreamer_tar_terminator_new(streamer); /* * If the user has requested a server compressed archive along with * archive extraction at client then we need to decompress it. */ if (format == 'p') { if (is_tar_gz) streamer = bbstreamer_gzip_decompressor_new(streamer); else if (is_tar_lz4) streamer = bbstreamer_lz4_decompressor_new(streamer); else if (is_tar_zstd) streamer = bbstreamer_zstd_decompressor_new(streamer); } /* Return the results. */ *manifest_inject_streamer_p = manifest_inject_streamer; return streamer; } /* * Receive all of the archives the server wants to send - and the backup * manifest if present - as a single COPY stream. */ static void ReceiveArchiveStream(PGconn *conn, pg_compress_specification *compress) { ArchiveStreamState state; /* Set up initial state. */ memset(&state, 0, sizeof(state)); state.tablespacenum = -1; state.compress = compress; /* All the real work happens in ReceiveArchiveStreamChunk. */ ReceiveCopyData(conn, ReceiveArchiveStreamChunk, &state); /* If we wrote the backup manifest to a file, close the file. */ if (state.manifest_file !=NULL) { fclose(state.manifest_file); state.manifest_file = NULL; } /* * If we buffered the backup manifest in order to inject it into the * output tarfile, do that now. */ if (state.manifest_inject_streamer != NULL && state.manifest_buffer != NULL) { bbstreamer_inject_file(state.manifest_inject_streamer, "backup_manifest", state.manifest_buffer->data, state.manifest_buffer->len); destroyPQExpBuffer(state.manifest_buffer); state.manifest_buffer = NULL; } /* If there's still an archive in progress, end processing. */ if (state.streamer != NULL) { bbstreamer_finalize(state.streamer); bbstreamer_free(state.streamer); state.streamer = NULL; } } /* * Receive one chunk of data sent by the server as part of a single COPY * stream that includes all archives and the manifest. */ static void ReceiveArchiveStreamChunk(size_t r, char *copybuf, void *callback_data) { ArchiveStreamState *state = callback_data; size_t cursor = 0; /* Each CopyData message begins with a type byte. */ switch (GetCopyDataByte(r, copybuf, &cursor)) { case 'n': { /* New archive. */ char *archive_name; char *spclocation; /* * We force a progress report at the end of each tablespace. A * new tablespace starts when the previous one ends, except in * the case of the very first one. */ if (++state->tablespacenum > 0) progress_report(state->tablespacenum, true, false); /* Sanity check. */ if (state->manifest_buffer != NULL || state->manifest_file !=NULL) pg_fatal("archives must precede manifest"); /* Parse the rest of the CopyData message. */ archive_name = GetCopyDataString(r, copybuf, &cursor); spclocation = GetCopyDataString(r, copybuf, &cursor); GetCopyDataEnd(r, copybuf, cursor); /* * Basic sanity checks on the archive name: it shouldn't be * empty, it shouldn't start with a dot, and it shouldn't * contain a path separator. */ if (archive_name[0] == '\0' || archive_name[0] == '.' || strchr(archive_name, '/') != NULL || strchr(archive_name, '\\') != NULL) pg_fatal("invalid archive name: \"%s\"", archive_name); /* * An empty spclocation is treated as NULL. We expect this * case to occur for the data directory itself, but not for * any archives that correspond to tablespaces. */ if (spclocation[0] == '\0') spclocation = NULL; /* End processing of any prior archive. */ if (state->streamer != NULL) { bbstreamer_finalize(state->streamer); bbstreamer_free(state->streamer); state->streamer = NULL; } /* * Create an appropriate backup streamer, unless a backup * target was specified. In that case, it's up to the server * to put the backup wherever it needs to go. */ if (backup_target == NULL) { /* * We know that recovery GUCs are supported, because this * protocol can only be used on v15+. */ state->streamer = CreateBackupStreamer(archive_name, spclocation, &state->manifest_inject_streamer, true, false, state->compress); } break; } case 'd': { /* Archive or manifest data. */ if (state->manifest_buffer != NULL) { /* Manifest data, buffer in memory. */ appendPQExpBuffer(state->manifest_buffer, copybuf + 1, r - 1); } else if (state->manifest_file !=NULL) { /* Manifest data, write to disk. */ if (fwrite(copybuf + 1, r - 1, 1, state->manifest_file) != 1) { /* * If fwrite() didn't set errno, assume that the * problem is that we're out of disk space. */ if (errno == 0) errno = ENOSPC; pg_fatal("could not write to file \"%s\": %m", state->manifest_filename); } } else if (state->streamer != NULL) { /* Archive data. */ bbstreamer_content(state->streamer, NULL, copybuf + 1, r - 1, BBSTREAMER_UNKNOWN); } else pg_fatal("unexpected payload data"); break; } case 'p': { /* * Progress report. * * The remainder of the message is expected to be an 8-byte * count of bytes completed. */ totaldone = GetCopyDataUInt64(r, copybuf, &cursor); GetCopyDataEnd(r, copybuf, cursor); /* * The server shouldn't send progress report messages too * often, so we force an update each time we receive one. */ progress_report(state->tablespacenum, true, false); break; } case 'm': { /* * Manifest data will be sent next. This message is not * expected to have any further payload data. */ GetCopyDataEnd(r, copybuf, cursor); /* * If a backup target was specified, figuring out where to put * the manifest is the server's problem. Otherwise, we need to * deal with it. */ if (backup_target == NULL) { /* * If we're supposed inject the manifest into the archive, * we prepare to buffer it in memory; otherwise, we * prepare to write it to a temporary file. */ if (state->manifest_inject_streamer != NULL) state->manifest_buffer = createPQExpBuffer(); else { snprintf(state->manifest_filename, sizeof(state->manifest_filename), "%s/backup_manifest.tmp", basedir); state->manifest_file = fopen(state->manifest_filename, "wb"); if (state->manifest_file == NULL) pg_fatal("could not create file \"%s\": %m", state->manifest_filename); } } break; } default: ReportCopyDataParseError(r, copybuf); break; } } /* * Get a single byte from a CopyData message. * * Bail out if none remain. */ static char GetCopyDataByte(size_t r, char *copybuf, size_t *cursor) { if (*cursor >= r) ReportCopyDataParseError(r, copybuf); return copybuf[(*cursor)++]; } /* * Get a NUL-terminated string from a CopyData message. * * Bail out if the terminating NUL cannot be found. */ static char * GetCopyDataString(size_t r, char *copybuf, size_t *cursor) { size_t startpos = *cursor; size_t endpos = startpos; while (1) { if (endpos >= r) ReportCopyDataParseError(r, copybuf); if (copybuf[endpos] == '\0') break; ++endpos; } *cursor = endpos + 1; return &copybuf[startpos]; } /* * Get an unsigned 64-bit integer from a CopyData message. * * Bail out if there are not at least 8 bytes remaining. */ static uint64 GetCopyDataUInt64(size_t r, char *copybuf, size_t *cursor) { uint64 result; if (*cursor + sizeof(uint64) > r) ReportCopyDataParseError(r, copybuf); memcpy(&result, &copybuf[*cursor], sizeof(uint64)); *cursor += sizeof(uint64); return pg_ntoh64(result); } /* * Bail out if we didn't parse the whole message. */ static void GetCopyDataEnd(size_t r, char *copybuf, size_t cursor) { if (r != cursor) ReportCopyDataParseError(r, copybuf); } /* * Report failure to parse a CopyData message from the server. Then exit. * * As a debugging aid, we try to give some hint about what kind of message * provoked the failure. Perhaps this is not detailed enough, but it's not * clear that it's worth expending any more code on what should be a * can't-happen case. */ static void ReportCopyDataParseError(size_t r, char *copybuf) { if (r == 0) pg_fatal("empty COPY message"); else pg_fatal("malformed COPY message of type %d, length %zu", copybuf[0], r); } /* * Receive raw tar data from the server, and stream it to the appropriate * location. If we're writing a single tarfile to standard output, also * receive the backup manifest and inject it into that tarfile. */ static void ReceiveTarFile(PGconn *conn, char *archive_name, char *spclocation, bool tablespacenum, pg_compress_specification *compress) { WriteTarState state; bbstreamer *manifest_inject_streamer; bool is_recovery_guc_supported; bool expect_unterminated_tarfile; /* Pass all COPY data through to the backup streamer. */ memset(&state, 0, sizeof(state)); is_recovery_guc_supported = PQserverVersion(conn) >= MINIMUM_VERSION_FOR_RECOVERY_GUC; expect_unterminated_tarfile = PQserverVersion(conn) < MINIMUM_VERSION_FOR_TERMINATED_TARFILE; state.streamer = CreateBackupStreamer(archive_name, spclocation, &manifest_inject_streamer, is_recovery_guc_supported, expect_unterminated_tarfile, compress); state.tablespacenum = tablespacenum; ReceiveCopyData(conn, ReceiveTarCopyChunk, &state); progress_update_filename(NULL); /* * The decision as to whether we need to inject the backup manifest into * the output at this stage is made by CreateBackupStreamer; if that is * needed, manifest_inject_streamer will be non-NULL; otherwise, it will * be NULL. */ if (manifest_inject_streamer != NULL) { PQExpBufferData buf; /* Slurp the entire backup manifest into a buffer. */ initPQExpBuffer(&buf); ReceiveBackupManifestInMemory(conn, &buf); if (PQExpBufferDataBroken(buf)) pg_fatal("out of memory"); /* Inject it into the output tarfile. */ bbstreamer_inject_file(manifest_inject_streamer, "backup_manifest", buf.data, buf.len); /* Free memory. */ termPQExpBuffer(&buf); } /* Cleanup. */ bbstreamer_finalize(state.streamer); bbstreamer_free(state.streamer); progress_report(tablespacenum, true, false); /* * Do not sync the resulting tar file yet, all files are synced once at * the end. */ } /* * Receive one chunk of tar-format data from the server. */ static void ReceiveTarCopyChunk(size_t r, char *copybuf, void *callback_data) { WriteTarState *state = callback_data; bbstreamer_content(state->streamer, NULL, copybuf, r, BBSTREAMER_UNKNOWN); totaldone += r; progress_report(state->tablespacenum, false, false); } /* * Retrieve tablespace path, either relocated or original depending on whether * -T was passed or not. */ static const char * get_tablespace_mapping(const char *dir) { TablespaceListCell *cell; char canon_dir[MAXPGPATH]; /* Canonicalize path for comparison consistency */ strlcpy(canon_dir, dir, sizeof(canon_dir)); canonicalize_path(canon_dir); for (cell = tablespace_dirs.head; cell; cell = cell->next) if (strcmp(canon_dir, cell->old_dir) == 0) return cell->new_dir; return dir; } /* * Receive the backup manifest file and write it out to a file. */ static void ReceiveBackupManifest(PGconn *conn) { WriteManifestState state; snprintf(state.filename, sizeof(state.filename), "%s/backup_manifest.tmp", basedir); state.file = fopen(state.filename, "wb"); if (state.file == NULL) pg_fatal("could not create file \"%s\": %m", state.filename); ReceiveCopyData(conn, ReceiveBackupManifestChunk, &state); fclose(state.file); } /* * Receive one chunk of the backup manifest file and write it out to a file. */ static void ReceiveBackupManifestChunk(size_t r, char *copybuf, void *callback_data) { WriteManifestState *state = callback_data; errno = 0; if (fwrite(copybuf, r, 1, state->file) != 1) { /* if write didn't set errno, assume problem is no disk space */ if (errno == 0) errno = ENOSPC; pg_fatal("could not write to file \"%s\": %m", state->filename); } } /* * Receive the backup manifest file and write it out to a file. */ static void ReceiveBackupManifestInMemory(PGconn *conn, PQExpBuffer buf) { ReceiveCopyData(conn, ReceiveBackupManifestInMemoryChunk, buf); } /* * Receive one chunk of the backup manifest file and write it out to a file. */ static void ReceiveBackupManifestInMemoryChunk(size_t r, char *copybuf, void *callback_data) { PQExpBuffer buf = callback_data; appendPQExpBuffer(buf, copybuf, r); } static void BaseBackup(char *compression_algorithm, char *compression_detail, CompressionLocation compressloc, pg_compress_specification *client_compress) { PGresult *res; char *sysidentifier; TimeLineID latesttli; TimeLineID starttli; char *basebkp; int i; char xlogstart[64]; char xlogend[64] = {0}; int minServerMajor, maxServerMajor; int serverVersion, serverMajor; int writing_to_stdout; bool use_new_option_syntax = false; PQExpBufferData buf; Assert(conn != NULL); initPQExpBuffer(&buf); /* * Check server version. BASE_BACKUP command was introduced in 9.1, so we * can't work with servers older than 9.1. */ minServerMajor = 901; maxServerMajor = PG_VERSION_NUM / 100; serverVersion = PQserverVersion(conn); serverMajor = serverVersion / 100; if (serverMajor < minServerMajor || serverMajor > maxServerMajor) { const char *serverver = PQparameterStatus(conn, "server_version"); pg_fatal("incompatible server version %s", serverver ? serverver : "'unknown'"); } if (serverMajor >= 1500) use_new_option_syntax = true; /* * If WAL streaming was requested, also check that the server is new * enough for that. */ if (includewal == STREAM_WAL && !CheckServerVersionForStreaming(conn)) { /* * Error message already written in CheckServerVersionForStreaming(), * but add a hint about using -X none. */ pg_log_error_hint("Use -X none or -X fetch to disable log streaming."); exit(1); } /* * Build contents of configuration file if requested */ if (writerecoveryconf) recoveryconfcontents = GenerateRecoveryConfig(conn, replication_slot); /* * Run IDENTIFY_SYSTEM so we can get the timeline */ if (!RunIdentifySystem(conn, &sysidentifier, &latesttli, NULL, NULL)) exit(1); /* * Start the actual backup */ AppendStringCommandOption(&buf, use_new_option_syntax, "LABEL", label); if (estimatesize) AppendPlainCommandOption(&buf, use_new_option_syntax, "PROGRESS"); if (includewal == FETCH_WAL) AppendPlainCommandOption(&buf, use_new_option_syntax, "WAL"); if (fastcheckpoint) { if (use_new_option_syntax) AppendStringCommandOption(&buf, use_new_option_syntax, "CHECKPOINT", "fast"); else AppendPlainCommandOption(&buf, use_new_option_syntax, "FAST"); } if (includewal != NO_WAL) { if (use_new_option_syntax) AppendIntegerCommandOption(&buf, use_new_option_syntax, "WAIT", 0); else AppendPlainCommandOption(&buf, use_new_option_syntax, "NOWAIT"); } if (maxrate > 0) AppendIntegerCommandOption(&buf, use_new_option_syntax, "MAX_RATE", maxrate); if (format == 't') AppendPlainCommandOption(&buf, use_new_option_syntax, "TABLESPACE_MAP"); if (!verify_checksums) { if (use_new_option_syntax) AppendIntegerCommandOption(&buf, use_new_option_syntax, "VERIFY_CHECKSUMS", 0); else AppendPlainCommandOption(&buf, use_new_option_syntax, "NOVERIFY_CHECKSUMS"); } if (manifest) { AppendStringCommandOption(&buf, use_new_option_syntax, "MANIFEST", manifest_force_encode ? "force-encode" : "yes"); if (manifest_checksums != NULL) AppendStringCommandOption(&buf, use_new_option_syntax, "MANIFEST_CHECKSUMS", manifest_checksums); } if (backup_target != NULL) { char *colon; if (serverMajor < 1500) pg_fatal("backup targets are not supported by this server version"); if (writerecoveryconf) pg_fatal("recovery configuration cannot be written when a backup target is used"); AppendPlainCommandOption(&buf, use_new_option_syntax, "TABLESPACE_MAP"); if ((colon = strchr(backup_target, ':')) == NULL) { AppendStringCommandOption(&buf, use_new_option_syntax, "TARGET", backup_target); } else { char *target; target = pnstrdup(backup_target, colon - backup_target); AppendStringCommandOption(&buf, use_new_option_syntax, "TARGET", target); AppendStringCommandOption(&buf, use_new_option_syntax, "TARGET_DETAIL", colon + 1); } } else if (serverMajor >= 1500) AppendStringCommandOption(&buf, use_new_option_syntax, "TARGET", "client"); if (compressloc == COMPRESS_LOCATION_SERVER) { if (!use_new_option_syntax) pg_fatal("server does not support server-side compression"); AppendStringCommandOption(&buf, use_new_option_syntax, "COMPRESSION", compression_algorithm); if (compression_detail != NULL) AppendStringCommandOption(&buf, use_new_option_syntax, "COMPRESSION_DETAIL", compression_detail); } if (verbose) pg_log_info("initiating base backup, waiting for checkpoint to complete"); if (showprogress && !verbose) { fprintf(stderr, _("waiting for checkpoint")); if (isatty(fileno(stderr))) fprintf(stderr, "\r"); else fprintf(stderr, "\n"); } if (use_new_option_syntax && buf.len > 0) basebkp = psprintf("BASE_BACKUP (%s)", buf.data); else basebkp = psprintf("BASE_BACKUP %s", buf.data); if (PQsendQuery(conn, basebkp) == 0) pg_fatal("could not send replication command \"%s\": %s", "BASE_BACKUP", PQerrorMessage(conn)); /* * Get the starting WAL location */ res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) pg_fatal("could not initiate base backup: %s", PQerrorMessage(conn)); if (PQntuples(res) != 1) pg_fatal("server returned unexpected response to BASE_BACKUP command; got %d rows and %d fields, expected %d rows and %d fields", PQntuples(res), PQnfields(res), 1, 2); strlcpy(xlogstart, PQgetvalue(res, 0, 0), sizeof(xlogstart)); if (verbose) pg_log_info("checkpoint completed"); /* * 9.3 and later sends the TLI of the starting point. With older servers, * assume it's the same as the latest timeline reported by * IDENTIFY_SYSTEM. */ if (PQnfields(res) >= 2) starttli = atoi(PQgetvalue(res, 0, 1)); else starttli = latesttli; PQclear(res); if (verbose && includewal != NO_WAL) pg_log_info("write-ahead log start point: %s on timeline %u", xlogstart, starttli); /* * Get the header */ res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) pg_fatal("could not get backup header: %s", PQerrorMessage(conn)); if (PQntuples(res) < 1) pg_fatal("no data returned from server"); /* * Sum up the total size, for progress reporting */ totalsize_kb = totaldone = 0; tablespacecount = PQntuples(res); for (i = 0; i < PQntuples(res); i++) { totalsize_kb += atol(PQgetvalue(res, i, 2)); /* * Verify tablespace directories are empty. Don't bother with the * first once since it can be relocated, and it will be checked before * we do anything anyway. * * Note that this is skipped for tar format backups and backups that * the server is storing to a target location, since in that case we * won't be storing anything into these directories and thus should * not create them. */ if (backup_target == NULL && format == 'p' && !PQgetisnull(res, i, 1)) { char *path = PQgetvalue(res, i, 1); if (is_absolute_path(path)) path = unconstify(char *, get_tablespace_mapping(path)); else { /* This is an in-place tablespace, so prepend basedir. */ path = psprintf("%s/%s", basedir, path); } verify_dir_is_empty_or_create(path, &made_tablespace_dirs, &found_tablespace_dirs); } } /* * When writing to stdout, require a single tablespace */ writing_to_stdout = format == 't' && basedir != NULL && strcmp(basedir, "-") == 0; if (writing_to_stdout && PQntuples(res) > 1) pg_fatal("can only write single tablespace to stdout, database has %d", PQntuples(res)); /* * If we're streaming WAL, start the streaming session before we start * receiving the actual data chunks. */ if (includewal == STREAM_WAL) { pg_compress_algorithm wal_compress_algorithm; int wal_compress_level; if (verbose) pg_log_info("starting background WAL receiver"); if (client_compress->algorithm == PG_COMPRESSION_GZIP) { wal_compress_algorithm = PG_COMPRESSION_GZIP; wal_compress_level = client_compress->level; } else { wal_compress_algorithm = PG_COMPRESSION_NONE; wal_compress_level = 0; } StartLogStreamer(xlogstart, starttli, sysidentifier, wal_compress_algorithm, wal_compress_level); } if (serverMajor >= 1500) { /* Receive a single tar stream with everything. */ ReceiveArchiveStream(conn, client_compress); } else { /* Receive a tar file for each tablespace in turn */ for (i = 0; i < PQntuples(res); i++) { char archive_name[MAXPGPATH]; char *spclocation; /* * If we write the data out to a tar file, it will be named * base.tar if it's the main data directory or <tablespaceoid>.tar * if it's for another tablespace. CreateBackupStreamer() will * arrange to add an extension to the archive name if * pg_basebackup is performing compression, depending on the * compression type. */ if (PQgetisnull(res, i, 0)) { strlcpy(archive_name, "base.tar", sizeof(archive_name)); spclocation = NULL; } else { snprintf(archive_name, sizeof(archive_name), "%s.tar", PQgetvalue(res, i, 0)); spclocation = PQgetvalue(res, i, 1); } ReceiveTarFile(conn, archive_name, spclocation, i, client_compress); } /* * Now receive backup manifest, if appropriate. * * If we're writing a tarfile to stdout, ReceiveTarFile will have * already processed the backup manifest and included it in the output * tarfile. Such a configuration doesn't allow for writing multiple * files. * * If we're talking to an older server, it won't send a backup * manifest, so don't try to receive one. */ if (!writing_to_stdout && manifest) ReceiveBackupManifest(conn); } if (showprogress) { progress_update_filename(NULL); progress_report(PQntuples(res), true, true); } PQclear(res); /* * Get the stop position */ res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) pg_fatal("backup failed: %s", PQerrorMessage(conn)); if (PQntuples(res) != 1) pg_fatal("no write-ahead log end position returned from server"); strlcpy(xlogend, PQgetvalue(res, 0, 0), sizeof(xlogend)); if (verbose && includewal != NO_WAL) pg_log_info("write-ahead log end point: %s", xlogend); PQclear(res); res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_COMMAND_OK) { const char *sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE); if (sqlstate && strcmp(sqlstate, ERRCODE_DATA_CORRUPTED) == 0) { pg_log_error("checksum error occurred"); checksum_failure = true; } else { pg_log_error("final receive failed: %s", PQerrorMessage(conn)); } exit(1); } if (bgchild > 0) { #ifndef WIN32 int status; pid_t r; #else DWORD status; /* * get a pointer sized version of bgchild to avoid warnings about * casting to a different size on WIN64. */ intptr_t bgchild_handle = bgchild; uint32 hi, lo; #endif if (verbose) pg_log_info("waiting for background process to finish streaming ..."); #ifndef WIN32 if (write(bgpipe[1], xlogend, strlen(xlogend)) != strlen(xlogend)) pg_fatal("could not send command to background pipe: %m"); /* Just wait for the background process to exit */ r = waitpid(bgchild, &status, 0); if (r == (pid_t) -1) pg_fatal("could not wait for child process: %m"); if (r != bgchild) pg_fatal("child %d died, expected %d", (int) r, (int) bgchild); if (status != 0) pg_fatal("%s", wait_result_to_str(status)); /* Exited normally, we're happy! */ #else /* WIN32 */ /* * On Windows, since we are in the same process, we can just store the * value directly in the variable, and then set the flag that says * it's there. */ if (sscanf(xlogend, "%X/%X", &hi, &lo) != 2) pg_fatal("could not parse write-ahead log location \"%s\"", xlogend); xlogendptr = ((uint64) hi) << 32 | lo; InterlockedIncrement(&has_xlogendptr); /* First wait for the thread to exit */ if (WaitForSingleObjectEx((HANDLE) bgchild_handle, INFINITE, FALSE) != WAIT_OBJECT_0) { _dosmaperr(GetLastError()); pg_fatal("could not wait for child thread: %m"); } if (GetExitCodeThread((HANDLE) bgchild_handle, &status) == 0) { _dosmaperr(GetLastError()); pg_fatal("could not get child thread exit status: %m"); } if (status != 0) pg_fatal("child thread exited with error %u", (unsigned int) status); /* Exited normally, we're happy */ #endif } /* Free the configuration file contents */ destroyPQExpBuffer(recoveryconfcontents); /* * End of copy data. Final result is already checked inside the loop. */ PQclear(res); PQfinish(conn); conn = NULL; /* * Make data persistent on disk once backup is completed. For tar format * sync the parent directory and all its contents as each tar file was not * synced after being completed. In plain format, all the data of the * base directory is synced, taking into account all the tablespaces. * Errors are not considered fatal. * * If, however, there's a backup target, we're not writing anything * locally, so in that case we skip this step. */ if (do_sync && backup_target == NULL) { if (verbose) pg_log_info("syncing data to disk ..."); if (format == 't') { if (strcmp(basedir, "-") != 0) (void) fsync_dir_recurse(basedir); } else { (void) fsync_pgdata(basedir, serverVersion); } } /* * After synchronizing data to disk, perform a durable rename of * backup_manifest.tmp to backup_manifest, if we wrote such a file. This * way, a failure or system crash before we reach this point will leave us * without a backup_manifest file, decreasing the chances that a directory * we leave behind will be mistaken for a valid backup. */ if (!writing_to_stdout && manifest && backup_target == NULL) { char tmp_filename[MAXPGPATH]; char filename[MAXPGPATH]; if (verbose) pg_log_info("renaming backup_manifest.tmp to backup_manifest"); snprintf(tmp_filename, MAXPGPATH, "%s/backup_manifest.tmp", basedir); snprintf(filename, MAXPGPATH, "%s/backup_manifest", basedir); if (do_sync) { /* durable_rename emits its own log message in case of failure */ if (durable_rename(tmp_filename, filename) != 0) exit(1); } else { if (rename(tmp_filename, filename) != 0) pg_fatal("could not rename file \"%s\" to \"%s\": %m", tmp_filename, filename); } } if (verbose) pg_log_info("base backup completed"); } int main(int argc, char **argv) { static struct option long_options[] = { {"help", no_argument, NULL, '?'}, {"version", no_argument, NULL, 'V'}, {"pgdata", required_argument, NULL, 'D'}, {"format", required_argument, NULL, 'F'}, {"checkpoint", required_argument, NULL, 'c'}, {"create-slot", no_argument, NULL, 'C'}, {"max-rate", required_argument, NULL, 'r'}, {"write-recovery-conf", no_argument, NULL, 'R'}, {"slot", required_argument, NULL, 'S'}, {"target", required_argument, NULL, 't'}, {"tablespace-mapping", required_argument, NULL, 'T'}, {"wal-method", required_argument, NULL, 'X'}, {"gzip", no_argument, NULL, 'z'}, {"compress", required_argument, NULL, 'Z'}, {"label", required_argument, NULL, 'l'}, {"no-clean", no_argument, NULL, 'n'}, {"no-sync", no_argument, NULL, 'N'}, {"dbname", required_argument, NULL, 'd'}, {"host", required_argument, NULL, 'h'}, {"port", required_argument, NULL, 'p'}, {"username", required_argument, NULL, 'U'}, {"no-password", no_argument, NULL, 'w'}, {"password", no_argument, NULL, 'W'}, {"status-interval", required_argument, NULL, 's'}, {"verbose", no_argument, NULL, 'v'}, {"progress", no_argument, NULL, 'P'}, {"waldir", required_argument, NULL, 1}, {"no-slot", no_argument, NULL, 2}, {"no-verify-checksums", no_argument, NULL, 3}, {"no-estimate-size", no_argument, NULL, 4}, {"no-manifest", no_argument, NULL, 5}, {"manifest-force-encode", no_argument, NULL, 6}, {"manifest-checksums", required_argument, NULL, 7}, {NULL, 0, NULL, 0} }; int c; int option_index; char *compression_algorithm = "none"; char *compression_detail = NULL; CompressionLocation compressloc = COMPRESS_LOCATION_UNSPECIFIED; pg_compress_specification client_compress; pg_logging_init(argv[0]); progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_basebackup")); if (argc > 1) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { usage(); exit(0); } else if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) { puts("pg_basebackup (PostgreSQL) " PG_VERSION); exit(0); } } atexit(cleanup_directories_atexit); while ((c = getopt_long(argc, argv, "c:Cd:D:F:h:l:nNp:Pr:Rs:S:t:T:U:vwWX:zZ:", long_options, &option_index)) != -1) { switch (c) { case 'c': if (pg_strcasecmp(optarg, "fast") == 0) fastcheckpoint = true; else if (pg_strcasecmp(optarg, "spread") == 0) fastcheckpoint = false; else pg_fatal("invalid checkpoint argument \"%s\", must be \"fast\" or \"spread\"", optarg); break; case 'C': create_slot = true; break; case 'd': connection_string = pg_strdup(optarg); break; case 'D': basedir = pg_strdup(optarg); break; case 'F': if (strcmp(optarg, "p") == 0 || strcmp(optarg, "plain") == 0) format = 'p'; else if (strcmp(optarg, "t") == 0 || strcmp(optarg, "tar") == 0) format = 't'; else pg_fatal("invalid output format \"%s\", must be \"plain\" or \"tar\"", optarg); break; case 'h': dbhost = pg_strdup(optarg); break; case 'l': label = pg_strdup(optarg); break; case 'n': noclean = true; break; case 'N': do_sync = false; break; case 'p': dbport = pg_strdup(optarg); break; case 'P': showprogress = true; break; case 'r': maxrate = parse_max_rate(optarg); break; case 'R': writerecoveryconf = true; break; case 's': if (!option_parse_int(optarg, "-s/--status-interval", 0, INT_MAX / 1000, &standby_message_timeout)) exit(1); standby_message_timeout *= 1000; break; case 'S': /* * When specifying replication slot name, use a permanent * slot. */ replication_slot = pg_strdup(optarg); temp_replication_slot = false; break; case 't': backup_target = pg_strdup(optarg); break; case 'T': tablespace_list_append(optarg); break; case 'U': dbuser = pg_strdup(optarg); break; case 'v': verbose++; break; case 'w': dbgetpassword = -1; break; case 'W': dbgetpassword = 1; break; case 'X': if (strcmp(optarg, "n") == 0 || strcmp(optarg, "none") == 0) { includewal = NO_WAL; } else if (strcmp(optarg, "f") == 0 || strcmp(optarg, "fetch") == 0) { includewal = FETCH_WAL; } else if (strcmp(optarg, "s") == 0 || strcmp(optarg, "stream") == 0) { includewal = STREAM_WAL; } else pg_fatal("invalid wal-method option \"%s\", must be \"fetch\", \"stream\", or \"none\"", optarg); break; case 'z': compression_algorithm = "gzip"; compression_detail = NULL; compressloc = COMPRESS_LOCATION_UNSPECIFIED; break; case 'Z': backup_parse_compress_options(optarg, &compression_algorithm, &compression_detail, &compressloc); break; case 1: xlog_dir = pg_strdup(optarg); break; case 2: no_slot = true; break; case 3: verify_checksums = false; break; case 4: estimatesize = false; break; case 5: manifest = false; break; case 6: manifest_force_encode = true; break; case 7: manifest_checksums = pg_strdup(optarg); break; default: /* getopt_long already emitted a complaint */ pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } } /* * Any non-option arguments? */ if (optind < argc) { pg_log_error("too many command-line arguments (first is \"%s\")", argv[optind]); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* * Setting the backup target to 'client' is equivalent to leaving out the * option. This logic allows us to assume elsewhere that the backup is * being stored locally if and only if backup_target == NULL. */ if (backup_target != NULL && strcmp(backup_target, "client") == 0) { pg_free(backup_target); backup_target = NULL; } /* * Can't use --format with --target. Without --target, default format is * tar. */ if (backup_target != NULL && format != '\0') { pg_log_error("cannot specify both format and backup target"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (format == '\0') format = 'p'; /* * Either directory or backup target should be specified, but not both */ if (basedir == NULL && backup_target == NULL) { pg_log_error("must specify output directory or backup target"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (basedir != NULL && backup_target != NULL) { pg_log_error("cannot specify both output directory and backup target"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* * If the user has not specified where to perform backup compression, * default to the client, unless the user specified --target, in which * case the server is the only choice. */ if (compressloc == COMPRESS_LOCATION_UNSPECIFIED) { if (backup_target == NULL) compressloc = COMPRESS_LOCATION_CLIENT; else compressloc = COMPRESS_LOCATION_SERVER; } /* * If any compression that we're doing is happening on the client side, we * must try to parse the compression algorithm and detail, but if it's all * on the server side, then we're just going to pass through whatever was * requested and let the server decide what to do. */ if (compressloc == COMPRESS_LOCATION_CLIENT) { pg_compress_algorithm alg; char *error_detail; if (!parse_compress_algorithm(compression_algorithm, &alg)) pg_fatal("unrecognized compression algorithm: \"%s\"", compression_algorithm); parse_compress_specification(alg, compression_detail, &client_compress); error_detail = validate_compress_specification(&client_compress); if (error_detail != NULL) pg_fatal("invalid compression specification: %s", error_detail); } else { Assert(compressloc == COMPRESS_LOCATION_SERVER); client_compress.algorithm = PG_COMPRESSION_NONE; client_compress.options = 0; } /* * Can't perform client-side compression if the backup is not being sent * to the client. */ if (backup_target != NULL && compressloc == COMPRESS_LOCATION_CLIENT) { pg_log_error("client-side compression is not possible when a backup target is specified"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* * Client-side compression doesn't make sense unless tar format is in use. */ if (format == 'p' && compressloc == COMPRESS_LOCATION_CLIENT && client_compress.algorithm != PG_COMPRESSION_NONE) { pg_log_error("only tar mode backups can be compressed"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* * Sanity checks for WAL method. */ if (backup_target != NULL && includewal == STREAM_WAL) { pg_log_error("WAL cannot be streamed when a backup target is specified"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (format == 't' && includewal == STREAM_WAL && strcmp(basedir, "-") == 0) { pg_log_error("cannot stream write-ahead logs in tar mode to stdout"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (replication_slot && includewal != STREAM_WAL) { pg_log_error("replication slots can only be used with WAL streaming"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* * Sanity checks for replication slot options. */ if (no_slot) { if (replication_slot) { pg_log_error("--no-slot cannot be used with slot name"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } temp_replication_slot = false; } if (create_slot) { if (!replication_slot) { pg_log_error("%s needs a slot to be specified using --slot", "--create-slot"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (no_slot) { pg_log_error("%s and %s are incompatible options", "--create-slot", "--no-slot"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } } /* * Sanity checks on WAL directory. */ if (xlog_dir) { if (backup_target != NULL) { pg_log_error("WAL directory location cannot be specified along with a backup target"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (format != 'p') { pg_log_error("WAL directory location can only be specified in plain mode"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* clean up xlog directory name, check it's absolute */ canonicalize_path(xlog_dir); if (!is_absolute_path(xlog_dir)) { pg_log_error("WAL directory location must be an absolute path"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } } /* * Sanity checks for progress reporting options. */ if (showprogress && !estimatesize) { pg_log_error("%s and %s are incompatible options", "--progress", "--no-estimate-size"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* * Sanity checks for backup manifest options. */ if (!manifest && manifest_checksums != NULL) { pg_log_error("%s and %s are incompatible options", "--no-manifest", "--manifest-checksums"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } if (!manifest && manifest_force_encode) { pg_log_error("%s and %s are incompatible options", "--no-manifest", "--manifest-force-encode"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } /* connection in replication mode to server */ conn = GetConnection(); if (!conn) { /* Error message already written in GetConnection() */ exit(1); } atexit(disconnect_atexit); #ifndef WIN32 /* * Trap SIGCHLD to be able to handle the WAL stream process exiting. There * is no SIGCHLD on Windows, there we rely on the background thread * setting the signal variable on unexpected but graceful exit. If the WAL * stream thread crashes on Windows it will bring down the entire process * as it's a thread, so there is nothing to catch should that happen. A * crash on UNIX will be caught by the signal handler. */ pqsignal(SIGCHLD, sigchld_handler); #endif /* * Set umask so that directories/files are created with the same * permissions as directories/files in the source data directory. * * pg_mode_mask is set to owner-only by default and then updated in * GetConnection() where we get the mode from the server-side with * RetrieveDataDirCreatePerm() and then call SetDataDirectoryCreatePerm(). */ umask(pg_mode_mask); /* Backup manifests are supported in 13 and newer versions */ if (PQserverVersion(conn) < MINIMUM_VERSION_FOR_MANIFESTS) manifest = false; /* * If an output directory was specified, verify that it exists, or create * it. Note that for a tar backup, an output directory of "-" means we are * writing to stdout, so do nothing in that case. */ if (basedir != NULL && (format == 'p' || strcmp(basedir, "-") != 0)) verify_dir_is_empty_or_create(basedir, &made_new_pgdata, &found_existing_pgdata); /* determine remote server's xlog segment size */ if (!RetrieveWalSegSize(conn)) exit(1); /* Create pg_wal symlink, if required */ if (xlog_dir) { char *linkloc; verify_dir_is_empty_or_create(xlog_dir, &made_new_xlogdir, &found_existing_xlogdir); /* * Form name of the place where the symlink must go. pg_xlog has been * renamed to pg_wal in post-10 clusters. */ linkloc = psprintf("%s/%s", basedir, PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal"); if (symlink(xlog_dir, linkloc) != 0) pg_fatal("could not create symbolic link \"%s\": %m", linkloc); free(linkloc); } BaseBackup(compression_algorithm, compression_detail, compressloc, &client_compress); success = true; return 0; }
a7fbe87fb034a813211ca26910cb058ffeb87ca4
b9dc55919b29da24c24f8ee367c5618c9532f56f
/Code_source/Compiled/signal/sfz~/sfizz/library/external/simde/test/x86/avx512/cvtt.c
47b2a566e0f98cabcb1dddca39a43feecf21f7a6
[ "BSD-3-Clause", "MIT-0", "ISC", "BSL-1.0", "Apache-2.0", "LGPL-2.0-or-later", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LGPL-2.1-only", "WTFPL", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-free-unknown" ]
permissive
porres/pd-else
075e8b7ac7a78f442055fbd30d6602cae49c887e
b30e8c13c88bb9752c08f78514d64c6206d6678b
refs/heads/master
2023-08-18T22:26:31.120893
2023-08-18T00:46:59
2023-08-18T00:46:59
56,870,805
238
42
WTFPL
2023-09-12T15:55:56
2016-04-22T16:45:29
C
UTF-8
C
false
false
9,036
c
cvtt.c
/* SPDX-License-Identifier: MIT * * 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. * * Copyright: * 2020 Evan Nemerson <evan@nemerson.com> * 2020 Himanshi Mathur <himanshi18037@iiitd.ac.in> * 2020 Hidayat Khan <huk2209@gmail.com> */ #define SIMDE_TEST_X86_AVX512_INSN cvtt #include <test/x86/avx512/test-avx512.h> #include <simde/x86/avx512/set.h> #include <simde/x86/avx512/cvtt.h> static int test_simde_mm_cvttpd_epi64 (SIMDE_MUNIT_TEST_ARGS) { #if 1 static const struct { const simde_float64 a[2]; const int64_t r[2]; } test_vec[] = { { { SIMDE_FLOAT64_C( 548.43), SIMDE_FLOAT64_C( -160.32) }, { INT64_C( 548), -INT64_C( 160) } }, { { SIMDE_FLOAT64_C( -665.23), SIMDE_FLOAT64_C( 909.86) }, { -INT64_C( 665), INT64_C( 909) } }, { { SIMDE_FLOAT64_C( 869.84), SIMDE_FLOAT64_C( -522.84) }, { INT64_C( 869), -INT64_C( 522) } }, { { SIMDE_FLOAT64_C( -396.75), SIMDE_FLOAT64_C( -885.22) }, { -INT64_C( 396), -INT64_C( 885) } }, { { SIMDE_FLOAT64_C( 670.62), SIMDE_FLOAT64_C( -665.50) }, { INT64_C( 670), -INT64_C( 665) } }, { { SIMDE_FLOAT64_C( 66.13), SIMDE_FLOAT64_C( 606.16) }, { INT64_C( 66), INT64_C( 606) } }, { { SIMDE_FLOAT64_C( -31.40), SIMDE_FLOAT64_C( -401.49) }, { -INT64_C( 31), -INT64_C( 401) } }, { { SIMDE_FLOAT64_C( 27.98), SIMDE_FLOAT64_C( 872.01) }, { INT64_C( 27), INT64_C( 872) } } }; for (size_t i = 0 ; i < (sizeof(test_vec) / sizeof(test_vec[0])) ; i++) { simde__m128d a = simde_mm_loadu_pd(test_vec[i].a); simde__m128i r = simde_mm_cvttpd_epi64(a); simde_test_x86_assert_equal_i64x2(r, simde_x_mm_loadu_epi64(test_vec[i].r)); } return 0; #else fputc('\n', stdout); for (int i = 0 ; i < 8 ; i++) { simde__m128d a = simde_test_x86_random_f64x2(-SIMDE_FLOAT64_C(1000.0), SIMDE_FLOAT64_C(1000.0)); simde__m128i r = simde_mm_cvttpd_epi64(a); simde_test_x86_write_f64x2(2, a, SIMDE_TEST_VEC_POS_FIRST); simde_test_x86_write_i64x2(2, r, SIMDE_TEST_VEC_POS_LAST); } return 1; #endif } static int test_simde_mm_mask_cvttpd_epi64 (SIMDE_MUNIT_TEST_ARGS) { #if 1 static const struct { const int64_t src[2]; const simde__mmask8 k; const simde_float64 a[2]; const int64_t r[2]; } test_vec[] = { { { -INT64_C( 361962842543030048), -INT64_C( 3474737081876049297) }, UINT8_C(108), { SIMDE_FLOAT64_C( 957.75), SIMDE_FLOAT64_C( 751.50) }, { -INT64_C( 361962842543030048), -INT64_C( 3474737081876049297) } }, { { INT64_C( 688050963011175950), -INT64_C( 7209247915320387714) }, UINT8_C( 81), { SIMDE_FLOAT64_C( -23.92), SIMDE_FLOAT64_C( -116.15) }, { -INT64_C( 23), -INT64_C( 7209247915320387714) } }, { { -INT64_C( 1696959715454980277), -INT64_C( 8986700034522357505) }, UINT8_C(136), { SIMDE_FLOAT64_C( 40.92), SIMDE_FLOAT64_C( -333.21) }, { -INT64_C( 1696959715454980277), -INT64_C( 8986700034522357505) } }, { { -INT64_C( 3906979509015529327), -INT64_C( 7568519742650574791) }, UINT8_C( 88), { SIMDE_FLOAT64_C( 414.99), SIMDE_FLOAT64_C( -679.12) }, { -INT64_C( 3906979509015529327), -INT64_C( 7568519742650574791) } }, { { INT64_C( 1324577026109679169), -INT64_C( 6354291571612128933) }, UINT8_C(219), { SIMDE_FLOAT64_C( 727.53), SIMDE_FLOAT64_C( -94.39) }, { INT64_C( 727), -INT64_C( 94) } }, { { INT64_C( 7972755038995392676), -INT64_C( 3786475889184342912) }, UINT8_C(133), { SIMDE_FLOAT64_C( -53.71), SIMDE_FLOAT64_C( 557.50) }, { -INT64_C( 53), -INT64_C( 3786475889184342912) } }, { { -INT64_C( 2204071043036436841), INT64_C( 6065779050755933240) }, UINT8_C(112), { SIMDE_FLOAT64_C( 377.02), SIMDE_FLOAT64_C( -369.85) }, { -INT64_C( 2204071043036436841), INT64_C( 6065779050755933240) } }, { { -INT64_C( 7696596639603648289), -INT64_C( 5674106389503363330) }, UINT8_C(151), { SIMDE_FLOAT64_C( -383.32), SIMDE_FLOAT64_C( 295.30) }, { -INT64_C( 383), INT64_C( 295) } } }; for (size_t i = 0 ; i < (sizeof(test_vec) / sizeof(test_vec[0])) ; i++) { simde__m128i src = simde_x_mm_loadu_epi64(test_vec[i].src); simde__m128d a = simde_mm_loadu_pd(test_vec[i].a); simde__m128i r = simde_mm_mask_cvttpd_epi64(src, test_vec[i].k, a); simde_test_x86_assert_equal_i64x2(r, simde_x_mm_loadu_epi64(test_vec[i].r)); } return 0; #else fputc('\n', stdout); for (int i = 0 ; i < 8 ; i++) { simde__m128i src = simde_test_x86_random_i64x2(); simde__mmask8 k = simde_test_x86_random_mmask8(); simde__m128d a = simde_test_x86_random_f64x2(-SIMDE_FLOAT64_C(1000.0), SIMDE_FLOAT64_C(1000.0)); simde__m128i r = simde_mm_mask_cvttpd_epi64(src, k, a); simde_test_x86_write_i64x2(2, src, SIMDE_TEST_VEC_POS_FIRST); simde_test_x86_write_mmask8(2, k, SIMDE_TEST_VEC_POS_MIDDLE); simde_test_x86_write_f64x2(2, a, SIMDE_TEST_VEC_POS_MIDDLE); simde_test_x86_write_i64x2(2, r, SIMDE_TEST_VEC_POS_LAST); } return 1; #endif } static int test_simde_mm_maskz_cvttpd_epi64 (SIMDE_MUNIT_TEST_ARGS) { #if 1 static const struct { const simde__mmask8 k; const simde_float64 a[2]; const int64_t r[2]; } test_vec[] = { { UINT8_C(120), { SIMDE_FLOAT64_C( -637.12), SIMDE_FLOAT64_C( 286.78) }, { INT64_C( 0), INT64_C( 0) } }, { UINT8_C(201), { SIMDE_FLOAT64_C( 14.68), SIMDE_FLOAT64_C( -536.46) }, { INT64_C( 14), INT64_C( 0) } }, { UINT8_C(194), { SIMDE_FLOAT64_C( 4.38), SIMDE_FLOAT64_C( -326.23) }, { INT64_C( 0), -INT64_C( 326) } }, { UINT8_C( 50), { SIMDE_FLOAT64_C( -618.60), SIMDE_FLOAT64_C( 303.92) }, { INT64_C( 0), INT64_C( 303) } }, { UINT8_C( 17), { SIMDE_FLOAT64_C( -934.04), SIMDE_FLOAT64_C( -855.69) }, { -INT64_C( 934), INT64_C( 0) } }, { UINT8_C(134), { SIMDE_FLOAT64_C( -621.04), SIMDE_FLOAT64_C( 304.82) }, { INT64_C( 0), INT64_C( 304) } }, { UINT8_C(182), { SIMDE_FLOAT64_C( -152.60), SIMDE_FLOAT64_C( 172.70) }, { INT64_C( 0), INT64_C( 172) } }, { UINT8_C(108), { SIMDE_FLOAT64_C( -737.88), SIMDE_FLOAT64_C( -401.93) }, { INT64_C( 0), INT64_C( 0) } } }; for (size_t i = 0 ; i < (sizeof(test_vec) / sizeof(test_vec[0])) ; i++) { simde__m128d a = simde_mm_loadu_pd(test_vec[i].a); simde__m128i r = simde_mm_maskz_cvttpd_epi64(test_vec[i].k, a); simde_test_x86_assert_equal_i64x2(r, simde_x_mm_loadu_epi64(test_vec[i].r)); } return 0; #else fputc('\n', stdout); for (int i = 0 ; i < 8 ; i++) { simde__mmask8 k = simde_test_x86_random_mmask8(); simde__m128d a = simde_test_x86_random_f64x2(-SIMDE_FLOAT64_C(1000.0), SIMDE_FLOAT64_C(1000.0)); simde__m128i r = simde_mm_maskz_cvttpd_epi64(k, a); simde_test_x86_write_mmask8(2, k, SIMDE_TEST_VEC_POS_FIRST); simde_test_x86_write_f64x2(2, a, SIMDE_TEST_VEC_POS_MIDDLE); simde_test_x86_write_i64x2(2, r, SIMDE_TEST_VEC_POS_LAST); } return 1; #endif } SIMDE_TEST_FUNC_LIST_BEGIN SIMDE_TEST_FUNC_LIST_ENTRY(mm_cvttpd_epi64) SIMDE_TEST_FUNC_LIST_ENTRY(mm_mask_cvttpd_epi64) SIMDE_TEST_FUNC_LIST_ENTRY(mm_maskz_cvttpd_epi64) SIMDE_TEST_FUNC_LIST_END #include <test/x86/avx512/test-avx512-footer.h>
1a545fc61b2d16e812fdaff805f682b0f3f7cb9b
6923f79f1eaaba0ab28b25337ba6cb56be97d32d
/NumericalRecipes3/interior.h
9c3ef807e17737f904093cda480985f8639e0d01
[]
no_license
burakbayramli/books
9fe7ba0cabf06e113eb125d62fe16d4946f4a4f0
5e9a0e03aa7ddf5e5ddf89943ccc68d94b539e95
refs/heads/master
2023-08-17T05:31:08.885134
2023-08-14T10:05:37
2023-08-14T10:05:37
72,460,321
223
174
null
2022-10-24T12:15:06
2016-10-31T17:24:00
Jupyter Notebook
UTF-8
C
false
false
5,086
h
interior.h
extern "C" { #include "ldl.h" #include "amd.h" } struct NRldl { Doub Info [AMD_INFO]; Int lnz,n,nz; VecInt PP,PPinv,PPattern,LLnz,LLp,PParent,FFlag,*LLi; VecDoub YY,DD,*LLx; Doub *Ax, *Lx, *B, *D, *X, *Y; Int *Ai, *Ap, *Li, *Lp, *P, *Pinv, *Flag,*Pattern, *Lnz, *Parent; NRldl(NRsparseMat &adat); void order(); void factorize(); void solve(VecDoub_O &y,VecDoub &rhs); ~NRldl(); }; Doub dotprod(VecDoub_I &x, VecDoub_I &y) { Doub sum=0.0; for (Int i=0;i<x.size();i++) sum += x[i]*y[i]; return sum; } Int intpt(const NRsparseMat &a, VecDoub_I &b, VecDoub_I &c, VecDoub_O &x) { const Int MAXITS=200; const Doub EPS=1.0e-6; const Doub SIGMA=0.9; const Doub DELTA=0.02; const Doub BIG=numeric_limits<Doub>::max(); Int i,j,iter,status; Int m=a.nrows; Int n=a.ncols; VecDoub y(m),z(n),ax(m),aty(n),rp(m),rd(n),d(n),dx(n),dy(m),dz(n), rhs(m),tempm(m),tempn(n); NRsparseMat at=a.transpose(); ADAT adat(a,at); NRldl solver(adat.ref()); solver.order(); Doub rpfact=1.0+sqrt(dotprod(b,b)); Doub rdfact=1.0+sqrt(dotprod(c,c)); for (j=0;j<n;j++) { x[j]=1000.0; z[j]=1000.0; } for (i=0;i<m;i++) { y[i]=1000.0; } Doub normrp_old=BIG; Doub normrd_old=BIG; cout << setw(4) << "iter" << setw(12) << "Primal obj." << setw(9) << "||r_p||" << setw(13) << "Dual obj." << setw(11) << "||r_d||" << setw(13) << "duality gap" << setw(16) << "normalized gap" << endl; cout << scientific << setprecision(4); for (iter=0;iter<MAXITS;iter++) { ax=a.ax(x); for (i=0;i<m;i++) rp[i]=ax[i]-b[i]; Doub normrp=sqrt(dotprod(rp,rp))/rpfact; aty=at.ax(y); for (j=0;j<n;j++) rd[j]=aty[j]+z[j]-c[j]; Doub normrd=sqrt(dotprod(rd,rd))/rdfact; Doub gamma=dotprod(x,z); Doub mu=DELTA*gamma/n; Doub primal_obj=dotprod(c,x); Doub dual_obj=dotprod(b,y); Doub gamma_norm=gamma/(1.0+abs(primal_obj)); cout << setw(3) << iter << setw(12) << primal_obj << setw(12) << normrp << setw(12) << dual_obj << setw(12) << normrd << setw(12) << gamma << setw(12) << gamma_norm<<endl; if (normrp < EPS && normrd < EPS && gamma_norm < EPS) return status=0; if (normrp > 1000*normrp_old && normrp > EPS) return status=1; if (normrd > 1000*normrd_old && normrd > EPS) return status=2; for (j=0;j<n;j++) d[j]=x[j]/z[j]; adat.updateD(d); solver.factorize(); for (j=0;j<n;j++) tempn[j]=x[j]-mu/z[j]-d[j]*rd[j]; tempm=a.ax(tempn); for (i=0;i<m;i++) rhs[i]=-rp[i]+tempm[i]; solver.solve(dy,rhs); tempn=at.ax(dy); for (j=0;j<n;j++) dz[j]=-tempn[j]-rd[j]; for (j=0;j<n;j++) dx[j]=-d[j]*dz[j]+mu/z[j]-x[j]; Doub alpha_p=1.0; for (j=0;j<n;j++) if (x[j]+alpha_p*dx[j] < 0.0) alpha_p=-x[j]/dx[j]; Doub alpha_d=1.0; for (j=0;j<n;j++) if (z[j]+alpha_d*dz[j] < 0.0) alpha_d=-z[j]/dz[j]; alpha_p = MIN(alpha_p*SIGMA,1.0); alpha_d = MIN(alpha_d*SIGMA,1.0); for (j=0;j<n;j++) { x[j]+=alpha_p*dx[j]; z[j]+=alpha_d*dz[j]; } for (i=0;i<m;i++) y[i]+=alpha_d*dy[i]; normrp_old=normrp; normrd_old=normrd; } return status=3; } NRldl::NRldl(NRsparseMat &adat) : n(adat.ncols), nz(adat.nvals), Ap(&adat.col_ptr[0]), Ai(&adat.row_ind[0]), Ax(&adat.val[0]), PP(n),PPinv(n),PPattern(n),LLnz(n),LLp(n+1),PParent(n),FFlag(n), YY(n),DD(n),Y(&YY[0]),D(&DD[0]),P(&PP[0]),Pinv(&PPinv[0]), Pattern(&PPattern[0]),Lnz(&LLnz[0]),Lp(&LLp[0]),Parent(&PParent[0]), Flag(&FFlag[0]) {} void NRldl::order() { if (amd_order (n, Ap, Ai, P, (Doub *) NULL, Info) != AMD_OK) throw("call to AMD failed"); amd_control ((Doub *) NULL); //amd_info (Info); ldl_symbolic (n, Ap, Ai, Lp, Parent, Lnz, Flag, P, Pinv); lnz = Lp [n]; /* find # of nonzeros in L, and flop count for ldl_numeric */ Doub flops = 0 ; for (Int j = 0 ; j < n ; j++) flops += ((Doub) Lnz [j]) * (Lnz [j] + 2) ; cout << "Nz in L: " << lnz << " Flop count: " << flops << endl; /* -------------------------------------------------------------- */ /* allocate remainder of L, of size lnz */ /* -------------------------------------------------------------- */ LLi=new VecInt(lnz); LLx=new VecDoub(lnz); Li=&(*LLi)[0]; Lx=&(*LLx)[0]; } void NRldl::factorize() { /* -------------------------------------------------------------- */ /* numeric factorization to get Li, Lx, and D */ /* -------------------------------------------------------------- */ Int dd = ldl_numeric (n, Ap, Ai, Ax, Lp, Parent, Lnz, Li, Lx, D, Y, Flag, Pattern, P, Pinv) ; if (dd != n) throw("Factorization failed since diagonal is zero."); } void NRldl::solve(VecDoub_O &y,VecDoub &rhs) { B=&rhs[0]; X=&y[0]; /* solve Ax=b */ /* the factorization is LDL' = PAP' */ ldl_perm (n, Y, B, P) ; /* y = Pb */ ldl_lsolve (n, Y, Lp, Li, Lx) ; /* y = L\y */ ldl_dsolve (n, Y, D) ; /* y = D\y */ ldl_ltsolve (n, Y, Lp, Li, Lx) ; /* y = L'\y */ ldl_permt (n, X, Y, P) ; /* x = P'y */ } NRldl::~NRldl() { delete LLx; delete LLi; }