repo_name
stringlengths 2
55
| dataset
stringclasses 1
value | owner
stringlengths 3
31
| lang
stringclasses 10
values | func_name
stringlengths 1
104
| code
stringlengths 20
96.7k
| docstring
stringlengths 1
4.92k
| url
stringlengths 94
241
| sha
stringlengths 40
40
|
|---|---|---|---|---|---|---|---|---|
BugChecker
|
github_2023
|
vitoplantamura
|
c
|
put_bits
|
static inline void put_bits(limb_t *tab, limb_t len, slimb_t pos, limb_t val)
{
limb_t i;
int p;
i = pos >> LIMB_LOG2_BITS;
p = pos & (LIMB_BITS - 1);
if (i < len)
tab[i] |= val << p;
if (p != 0) {
i++;
if (i < len) {
tab[i] |= val >> (LIMB_BITS - p);
}
}
}
|
/***************************************************************/
/* Integer multiplication with FFT */
/* or LIMB_BITS at bit position 'pos' in tab */
|
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/BugChecker/QuickJS/libbf.c#L7241-L7256
|
8b81e76efe457b59be3a6e752efd43916ba0cabb
|
BugChecker
|
github_2023
|
vitoplantamura
|
c
|
ZyanBitsetPerformByteOperation
|
ZyanStatus ZyanBitsetPerformByteOperation(ZyanBitset* destination, const ZyanBitset* source,
ZyanBitsetByteOperation operation)
{
if (!destination || !source || !operation)
{
return ZYAN_STATUS_INVALID_ARGUMENT;
}
ZyanUSize s1;
ZyanUSize s2;
ZYAN_CHECK(ZyanVectorGetSize(&destination->bits, &s1));
ZYAN_CHECK(ZyanVectorGetSize(&source->bits, &s2));
const ZyanUSize min = ZYAN_MIN(s1, s2);
for (ZyanUSize i = 0; i < min; ++i)
{
ZyanU8* v1;
const ZyanU8* v2;
ZYAN_CHECK(ZyanVectorGetPointerMutable(&destination->bits, i, (void**)&v1));
ZYAN_CHECK(ZyanVectorGetPointer(&source->bits, i, (const void**)&v2));
ZYAN_ASSERT(v1);
ZYAN_ASSERT(v2);
ZYAN_CHECK(operation(v1, v2));
}
return ZYAN_STATUS_SUCCESS;
}
|
/* ---------------------------------------------------------------------------------------------- */
/* Logical operations */
/* ---------------------------------------------------------------------------------------------- */
|
https://github.com/vitoplantamura/BugChecker/blob/8b81e76efe457b59be3a6e752efd43916ba0cabb/dependencies/zydis/dependencies/zycore/src/Bitset.c#L196-L224
|
8b81e76efe457b59be3a6e752efd43916ba0cabb
|
LenovoLegionLinux
|
github_2023
|
johnfanv2
|
c
|
eval_gbmd
|
static int eval_gbmd(acpi_handle handle, unsigned long *res)
{
return eval_int(handle, "VPC0.GBMD", res);
}
|
//static int eval_qcho(acpi_handle handle, unsigned long *res)
//{
// // \_SB.PCI0.LPC0.EC0.QCHO
// return eval_int(handle, "QCHO", res);
//}
|
https://github.com/johnfanv2/LenovoLegionLinux/blob/ae96a82adb879e729c5727c8769888b47ee1181f/kernel_module/legion-laptop.c#L1391-L1394
|
ae96a82adb879e729c5727c8769888b47ee1181f
|
teddycloud
|
github_2023
|
toniebox-reverse-engineering
|
c
|
f_sync
|
FRESULT f_sync (
FIL* fp /* Open file to be synced */
)
{
FRESULT res;
FATFS *fs;
DWORD tm;
BYTE *dir;
res = validate(&fp->obj, &fs); /* Check validity of the file object */
if (res == FR_OK) {
if (fp->flag & FA_MODIFIED) { /* Is there any change to the file? */
#if !FF_FS_TINY
if (fp->flag & FA_DIRTY) { /* Write-back cached data if needed */
if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) LEAVE_FF(fs, FR_DISK_ERR);
fp->flag &= (BYTE)~FA_DIRTY;
}
#endif
/* Update the directory entry */
tm = GET_FATTIME(); /* Modified time */
#if FF_FS_EXFAT
if (fs->fs_type == FS_EXFAT) {
res = fill_first_frag(&fp->obj); /* Fill first fragment on the FAT if needed */
if (res == FR_OK) {
res = fill_last_frag(&fp->obj, fp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed */
}
if (res == FR_OK) {
DIR dj;
DEF_NAMBUF
INIT_NAMBUF(fs);
res = load_obj_xdir(&dj, &fp->obj); /* Load directory entry block */
if (res == FR_OK) {
fs->dirbuf[XDIR_Attr] |= AM_ARC; /* Set archive attribute to indicate that the file has been changed */
fs->dirbuf[XDIR_GenFlags] = fp->obj.stat | 1; /* Update file allocation information */
st_dword(fs->dirbuf + XDIR_FstClus, fp->obj.sclust); /* Update start cluster */
st_qword(fs->dirbuf + XDIR_FileSize, fp->obj.objsize); /* Update file size */
st_qword(fs->dirbuf + XDIR_ValidFileSize, fp->obj.objsize); /* (FatFs does not support Valid File Size feature) */
st_dword(fs->dirbuf + XDIR_ModTime, tm); /* Update modified time */
fs->dirbuf[XDIR_ModTime10] = 0;
st_dword(fs->dirbuf + XDIR_AccTime, 0);
res = store_xdir(&dj); /* Restore it to the directory */
if (res == FR_OK) {
res = sync_fs(fs);
fp->flag &= (BYTE)~FA_MODIFIED;
}
}
FREE_NAMBUF();
}
} else
#endif
{
res = move_window(fs, fp->dir_sect);
if (res == FR_OK) {
dir = fp->dir_ptr;
dir[DIR_Attr] |= AM_ARC; /* Set archive attribute to indicate that the file has been changed */
st_clust(fp->obj.fs, dir, fp->obj.sclust); /* Update file allocation information */
st_dword(dir + DIR_FileSize, (DWORD)fp->obj.objsize); /* Update file size */
st_dword(dir + DIR_ModTime, tm); /* Update modified time */
st_word(dir + DIR_LstAccDate, 0);
fs->wflag = 1;
res = sync_fs(fs); /* Restore it to the directory */
fp->flag &= (BYTE)~FA_MODIFIED;
}
}
}
}
LEAVE_FF(fs, res);
}
|
/*-----------------------------------------------------------------------*/
/* Synchronize the File */
/*-----------------------------------------------------------------------*/
|
https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L4135-L4205
|
83d3b29cbfc74e8f76f48f8782646c8e464055b2
|
teddycloud
|
github_2023
|
toniebox-reverse-engineering
|
c
|
putc_bfd
|
static void putc_bfd (putbuff* pb, TCHAR c)
{
UINT n;
int i, nc;
#if FF_USE_LFN && FF_LFN_UNICODE
WCHAR hs, wc;
#if FF_LFN_UNICODE == 2
DWORD dc;
const TCHAR* tp;
#endif
#endif
if (FF_USE_STRFUNC == 2 && c == '\n') { /* LF -> CRLF conversion */
putc_bfd(pb, '\r');
}
i = pb->idx; /* Write index of pb->buf[] */
if (i < 0) return; /* In write error? */
nc = pb->nchr; /* Write unit counter */
#if FF_USE_LFN && FF_LFN_UNICODE
#if FF_LFN_UNICODE == 1 /* UTF-16 input */
if (IsSurrogateH(c)) { /* Is this a high-surrogate? */
pb->hs = c; return; /* Save it for next */
}
hs = pb->hs; pb->hs = 0;
if (hs != 0) { /* Is there a leading high-surrogate? */
if (!IsSurrogateL(c)) hs = 0; /* Discard high-surrogate if not a surrogate pair */
} else {
if (IsSurrogateL(c)) return; /* Discard stray low-surrogate */
}
wc = c;
#elif FF_LFN_UNICODE == 2 /* UTF-8 input */
for (;;) {
if (pb->ct == 0) { /* Out of multi-byte sequence? */
pb->bs[pb->wi = 0] = (BYTE)c; /* Save 1st byte */
if ((BYTE)c < 0x80) break; /* Single byte code? */
if (((BYTE)c & 0xE0) == 0xC0) pb->ct = 1; /* 2-byte sequence? */
if (((BYTE)c & 0xF0) == 0xE0) pb->ct = 2; /* 3-byte sequence? */
if (((BYTE)c & 0xF8) == 0xF0) pb->ct = 3; /* 4-byte sequence? */
return; /* Wrong leading byte (discard it) */
} else { /* In the multi-byte sequence */
if (((BYTE)c & 0xC0) != 0x80) { /* Broken sequence? */
pb->ct = 0; continue; /* Discard the sequense */
}
pb->bs[++pb->wi] = (BYTE)c; /* Save the trailing byte */
if (--pb->ct == 0) break; /* End of the sequence? */
return;
}
}
tp = (const TCHAR*)pb->bs;
dc = tchar2uni(&tp); /* UTF-8 ==> UTF-16 */
if (dc == 0xFFFFFFFF) return; /* Wrong code? */
hs = (WCHAR)(dc >> 16);
wc = (WCHAR)dc;
#elif FF_LFN_UNICODE == 3 /* UTF-32 input */
if (IsSurrogate(c) || c >= 0x110000) return; /* Discard invalid code */
if (c >= 0x10000) { /* Out of BMP? */
hs = (WCHAR)(0xD800 | ((c >> 10) - 0x40)); /* Make high surrogate */
wc = 0xDC00 | (c & 0x3FF); /* Make low surrogate */
} else {
hs = 0;
wc = (WCHAR)c;
}
#endif
/* A code point in UTF-16 is available in hs and wc */
#if FF_STRF_ENCODE == 1 /* Write a code point in UTF-16LE */
if (hs != 0) { /* Surrogate pair? */
st_word(&pb->buf[i], hs);
i += 2;
nc++;
}
st_word(&pb->buf[i], wc);
i += 2;
#elif FF_STRF_ENCODE == 2 /* Write a code point in UTF-16BE */
if (hs != 0) { /* Surrogate pair? */
pb->buf[i++] = (BYTE)(hs >> 8);
pb->buf[i++] = (BYTE)hs;
nc++;
}
pb->buf[i++] = (BYTE)(wc >> 8);
pb->buf[i++] = (BYTE)wc;
#elif FF_STRF_ENCODE == 3 /* Write a code point in UTF-8 */
if (hs != 0) { /* 4-byte sequence? */
nc += 3;
hs = (hs & 0x3FF) + 0x40;
pb->buf[i++] = (BYTE)(0xF0 | hs >> 8);
pb->buf[i++] = (BYTE)(0x80 | (hs >> 2 & 0x3F));
pb->buf[i++] = (BYTE)(0x80 | (hs & 3) << 4 | (wc >> 6 & 0x0F));
pb->buf[i++] = (BYTE)(0x80 | (wc & 0x3F));
} else {
if (wc < 0x80) { /* Single byte? */
pb->buf[i++] = (BYTE)wc;
} else {
if (wc < 0x800) { /* 2-byte sequence? */
nc += 1;
pb->buf[i++] = (BYTE)(0xC0 | wc >> 6);
} else { /* 3-byte sequence */
nc += 2;
pb->buf[i++] = (BYTE)(0xE0 | wc >> 12);
pb->buf[i++] = (BYTE)(0x80 | (wc >> 6 & 0x3F));
}
pb->buf[i++] = (BYTE)(0x80 | (wc & 0x3F));
}
}
#else /* Write a code point in ANSI/OEM */
if (hs != 0) return;
wc = ff_uni2oem(wc, CODEPAGE); /* UTF-16 ==> ANSI/OEM */
if (wc == 0) return;
if (wc >= 0x100) {
pb->buf[i++] = (BYTE)(wc >> 8); nc++;
}
pb->buf[i++] = (BYTE)wc;
#endif
#else /* ANSI/OEM input (without re-encoding) */
pb->buf[i++] = (BYTE)c;
#endif
if (i >= (int)(sizeof pb->buf) - 4) { /* Write buffered characters to the file */
f_write(pb->fp, pb->buf, (UINT)i, &n);
i = (n == (UINT)i) ? 0 : -1;
}
pb->idx = i;
pb->nchr = nc + 1;
}
|
/* Buffered file write with code conversion */
|
https://github.com/toniebox-reverse-engineering/teddycloud/blob/83d3b29cbfc74e8f76f48f8782646c8e464055b2/fat/source/ff.c#L6578-L6704
|
83d3b29cbfc74e8f76f48f8782646c8e464055b2
|
flipper-zero-tutorials
|
github_2023
|
jamisonderek
|
c
|
gpio_7segment_disconnect_pin
|
void gpio_7segment_disconnect_pin(const GpioPin* pin) {
furi_hal_gpio_init(pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(pin, true);
}
|
// Disconnects a GpioPin via OutputOpenDrive, PushPullNo, output true.
// @pin pointer to GpioPin to disconnect.
|
https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/gpio/gpio_7segment/gpio_7segment_app.c#L171-L174
|
89716a9b00eacce7055a75fddb5a3adde93f265f
|
flipper-zero-tutorials
|
github_2023
|
jamisonderek
|
c
|
rgbleds_reset
|
void rgbleds_reset(RgbLeds* leds) {
for(int i = 0; i < leds->num_leds; i++) {
leds->color[i] = 0x000000;
}
}
|
/**
* @brief Resets the LEDs to their default color pattern (off).
* @details This method resets the LEDs data to their default color pattern (off).
* You must still call rgbleds_update to update the LEDs.
* @param leds The RgbLeds struct to reset.
*/
|
https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L52-L56
|
89716a9b00eacce7055a75fddb5a3adde93f265f
|
SBEMU
|
github_2023
|
crazii
|
c
|
ct_timer_interrupt
|
static void ct_timer_interrupt(void *data, unsigned int status)
{
struct ct_timer *timer = data;
/* Interval timer interrupt */
if ((status & IT_INT) && timer->ops->interrupt)
timer->ops->interrupt(timer);
}
|
/*
* timer manager
*/
|
https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cttimer.c#L405-L412
|
f0cbde063396deb2c1246c9b3108a37755c68e9a
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
curlx_uztosi
|
int curlx_uztosi(size_t uznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(uznum <= (size_t) CURL_MASK_SINT);
return (int)(uznum & (size_t) CURL_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
|
/*
** unsigned size_t to signed int
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/warnless.c#L181-L194
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
Curl_ipvalid
|
bool Curl_ipvalid(struct connectdata *conn)
{
if(conn->ip_version == CURL_IPRESOLVE_V6)
return Curl_ipv6works();
return TRUE;
}
|
/*
* Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
* been set and returns TRUE if they are OK.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/hostip6.c#L126-L131
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
Curl_infof
|
void Curl_infof(struct SessionHandle *data, const char *fmt, ...)
{
if(data && data->set.verbose) {
va_list ap;
size_t len;
char print_buffer[2048 + 1];
va_start(ap, fmt);
vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);
va_end(ap);
len = strlen(print_buffer);
Curl_debug(data, CURLINFO_TEXT, print_buffer, len, NULL);
}
}
|
/* CURL_DO_LINEEND_CONV */
/* Curl_infof() is for info message along the way */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/sendf.c#L136-L148
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
Curl_single_getsock
|
int Curl_single_getsock(const struct connectdata *conn,
curl_socket_t *sock, /* points to numsocks number
of sockets */
int numsocks)
{
const struct SessionHandle *data = conn->data;
int bitmap = GETSOCK_BLANK;
unsigned sockindex = 0;
if(conn->handler->perform_getsock)
return conn->handler->perform_getsock(conn, sock, numsocks);
if(numsocks < 2)
/* simple check but we might need two slots */
return GETSOCK_BLANK;
/* don't include HOLD and PAUSE connections */
if((data->req.keepon & KEEP_RECVBITS) == KEEP_RECV) {
DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD);
bitmap |= GETSOCK_READSOCK(sockindex);
sock[sockindex] = conn->sockfd;
}
/* don't include HOLD and PAUSE connections */
if((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) {
if((conn->sockfd != conn->writesockfd) ||
!(data->req.keepon & KEEP_RECV)) {
/* only if they are not the same socket or we didn't have a readable
one, we increase index */
if(data->req.keepon & KEEP_RECV)
sockindex++; /* increase index if we need two entries */
DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD);
sock[sockindex] = conn->writesockfd;
}
bitmap |= GETSOCK_WRITESOCK(sockindex);
}
return bitmap;
}
|
/*
* Curl_single_getsock() gets called by the multi interface code when the app
* has requested to get the sockets for the current connection. This function
* will then be called once for every connection that the multi interface
* keeps track of. This function will only be called for connections that are
* in the proper state to have this information available.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/transfer.c#L1148-L1192
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
Curl_close
|
CURLcode Curl_close(struct SessionHandle *data)
{
struct Curl_multi *m;
if(!data)
return CURLE_OK;
Curl_expire(data, 0); /* shut off timers */
m = data->multi;
if(m)
/* This handle is still part of a multi handle, take care of this first
and detach this handle from there. */
curl_multi_remove_handle(data->multi, data);
if(data->multi_easy)
/* when curl_easy_perform() is used, it creates its own multi handle to
use and this is the one */
curl_multi_cleanup(data->multi_easy);
/* Destroy the timeout list that is held in the easy handle. It is
/normally/ done by curl_multi_remove_handle() but this is "just in
case" */
if(data->state.timeoutlist) {
Curl_llist_destroy(data->state.timeoutlist, NULL);
data->state.timeoutlist = NULL;
}
data->magic = 0; /* force a clear AFTER the possibly enforced removal from
the multi handle, since that function uses the magic
field! */
if(data->state.rangestringalloc)
free(data->state.range);
/* Free the pathbuffer */
Curl_safefree(data->state.pathbuffer);
data->state.path = NULL;
Curl_safefree(data->state.proto.generic);
/* Close down all open SSL info and sessions */
Curl_ssl_close_all(data);
Curl_safefree(data->state.first_host);
Curl_safefree(data->state.scratch);
Curl_ssl_free_certinfo(data);
if(data->change.referer_alloc) {
Curl_safefree(data->change.referer);
data->change.referer_alloc = FALSE;
}
data->change.referer = NULL;
if(data->change.url_alloc) {
Curl_safefree(data->change.url);
data->change.url_alloc = FALSE;
}
data->change.url = NULL;
Curl_safefree(data->state.headerbuff);
Curl_flush_cookies(data, 1);
Curl_digest_cleanup(data);
Curl_safefree(data->info.contenttype);
Curl_safefree(data->info.wouldredirect);
/* this destroys the channel and we cannot use it anymore after this */
Curl_resolver_cleanup(data->state.resolver);
Curl_convert_close(data);
/* No longer a dirty share, if it exists */
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
data->share->dirty--;
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
}
Curl_freeset(data);
free(data);
return CURLE_OK;
}
|
/*
* This is the internal function curl_easy_cleanup() calls. This should
* cleanup and free all resources associated with this sessionhandle.
*
* NOTE: if we ever add something that attempts to write to a socket or
* similar here, we must ignore SIGPIPE first. It is currently only done
* when curl_easy_perform() is invoked.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/url.c#L366-L450
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
get_request
|
static int get_request(curl_socket_t sock, struct httprequest *req)
{
int error;
int fail = 0;
int done_processing = 0;
char *reqbuf = req->reqbuf;
ssize_t got = 0;
char *pipereq = NULL;
size_t pipereq_length = 0;
if(req->pipelining) {
pipereq = reqbuf + req->checkindex;
pipereq_length = req->offset - req->checkindex;
}
/*** Init the httprequest structure properly for the upcoming request ***/
req->checkindex = 0;
req->offset = 0;
req->testno = DOCNUMBER_NOTHING;
req->partno = 0;
req->open = TRUE;
req->auth_req = FALSE;
req->auth = FALSE;
req->cl = 0;
req->digest = FALSE;
req->ntlm = FALSE;
req->pipe = 0;
req->skip = 0;
req->rcmd = RCMD_NORMALREQ;
req->protocol = RPROT_NONE;
req->prot_version = 0;
req->pipelining = FALSE;
req->rtp_buffer = NULL;
req->rtp_buffersize = 0;
/*** end of httprequest init ***/
while(!done_processing && (req->offset < REQBUFSIZ-1)) {
if(pipereq_length && pipereq) {
memmove(reqbuf, pipereq, pipereq_length);
got = curlx_uztosz(pipereq_length);
pipereq_length = 0;
}
else {
if(req->skip)
/* we are instructed to not read the entire thing, so we make sure to only
read what we're supposed to and NOT read the enire thing the client
wants to send! */
got = sread(sock, reqbuf + req->offset, req->cl);
else
got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset);
}
if(got_exit_signal)
return 1;
if(got == 0) {
logmsg("Connection closed by client");
fail = 1;
}
else if(got < 0) {
error = SOCKERRNO;
logmsg("recv() returned error: (%d) %s", error, strerror(error));
fail = 1;
}
if(fail) {
/* dump the request received so far to the external file */
reqbuf[req->offset] = '\0';
storerequest(reqbuf, req->offset);
return 1;
}
logmsg("Read %zd bytes", got);
req->offset += (size_t)got;
reqbuf[req->offset] = '\0';
done_processing = ProcessRequest(req);
if(got_exit_signal)
return 1;
if(done_processing && req->pipe) {
logmsg("Waiting for another piped request");
done_processing = 0;
req->pipe--;
}
}
if((req->offset == REQBUFSIZ-1) && (got > 0)) {
logmsg("Request would overflow buffer, closing connection");
/* dump request received so far to external file anyway */
reqbuf[REQBUFSIZ-1] = '\0';
fail = 1;
}
else if(req->offset > REQBUFSIZ-1) {
logmsg("Request buffer overflow, closing connection");
/* dump request received so far to external file anyway */
reqbuf[REQBUFSIZ-1] = '\0';
fail = 1;
}
else
reqbuf[req->offset] = '\0';
/* dump the request to an external file */
storerequest(reqbuf, req->pipelining ? req->checkindex : req->offset);
if(got_exit_signal)
return 1;
return fail; /* return 0 on success */
}
|
/* return 0 on success, non-zero on failure */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/tests/server/rtspd.c#L772-L880
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
pkey_cb
|
static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
void *exarg)
{
/* Since the structure must still be valid use ASN1_OP_FREE_PRE */
if(operation == ASN1_OP_FREE_PRE) {
PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval;
if (key->pkey->value.octet_string)
OPENSSL_cleanse(key->pkey->value.octet_string->data,
key->pkey->value.octet_string->length);
}
return 1;
}
|
/* Minor tweak to operation: zero private key data */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/crypto/asn1/p8_pkey.c#L65-L76
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
asn1_do_lock
|
int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
{
const ASN1_AUX *aux;
int *lck, ret;
if ((it->itype != ASN1_ITYPE_SEQUENCE)
&& (it->itype != ASN1_ITYPE_NDEF_SEQUENCE))
return 0;
aux = it->funcs;
if (!aux || !(aux->flags & ASN1_AFLG_REFCOUNT))
return 0;
lck = offset2ptr(*pval, aux->ref_offset);
if (op == 0)
{
*lck = 1;
return 1;
}
ret = CRYPTO_add(lck, op, aux->ref_lock);
#ifdef REF_PRINT
fprintf(stderr, "%s: Reference Count: %d\n", it->sname, *lck);
#endif
#ifdef REF_CHECK
if (ret < 0)
fprintf(stderr, "%s, bad reference count\n", it->sname);
#endif
return ret;
}
|
/* Do reference counting. The value 'op' decides what to do.
* if it is +1 then the count is incremented. If op is 0 count is
* set to 1. If op is -1 count is decremented and the return value
* is the current refrence count or 0 if no reference count exists.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/crypto/asn1/tasn_utl.c#L101-L126
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
TS_RESP_CTX_cleanup
|
static void TS_RESP_CTX_cleanup(TS_RESP_CTX *ctx)
{
TS_REQ_free(ctx->request);
ctx->request = NULL;
TS_RESP_free(ctx->response);
ctx->response = NULL;
TS_TST_INFO_free(ctx->tst_info);
ctx->tst_info = NULL;
}
|
/* Cleans up the variable part of the context. */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/crypto/ts/ts_rsp_sign.c#L495-L503
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
X509_STORE_CTX_trusted_stack
|
void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
{
ctx->other_ctx = sk;
ctx->get_issuer = get_issuer_sk;
}
|
/* Set alternative lookup method: just a STACK of trusted certificates.
* This avoids X509_STORE nastiness where it isn't needed.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl/crypto/x509/x509_vfy.c#L2128-L2132
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
app_info_free
|
static void app_info_free(APP_INFO *inf)
{
if (--(inf->references) <= 0)
{
if (inf->next != NULL)
{
app_info_free(inf->next);
}
OPENSSL_free(inf);
}
}
|
/* Valid iff num_disable > 0.
* CRYPTO_LOCK_MALLOC2 is locked
* exactly in this case (by the
* thread named in disabling_thread).
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl_android/crypto/mem_dbg.c#L145-L155
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
asn1_collate_primitive
|
static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c)
{
ASN1_STRING *os=NULL;
BUF_MEM b;
int num;
b.length=0;
b.max=0;
b.data=NULL;
if (a == NULL)
{
c->error=ERR_R_PASSED_NULL_PARAMETER;
goto err;
}
num=0;
for (;;)
{
if (c->inf & 1)
{
c->eos=ASN1_const_check_infinite_end(&c->p,
(long)(c->max-c->p));
if (c->eos) break;
}
else
{
if (c->slen <= 0) break;
}
c->q=c->p;
if (d2i_ASN1_bytes(&os,&c->p,c->max-c->p,c->tag,c->xclass)
== NULL)
{
c->error=ERR_R_ASN1_LIB;
goto err;
}
if (!BUF_MEM_grow_clean(&b,num+os->length))
{
c->error=ERR_R_BUF_LIB;
goto err;
}
memcpy(&(b.data[num]),os->data,os->length);
if (!(c->inf & 1))
c->slen-=(c->p-c->q);
num+=os->length;
}
if (!asn1_const_Finish(c)) goto err;
a->length=num;
if (a->data != NULL) OPENSSL_free(a->data);
a->data=(unsigned char *)b.data;
if (os != NULL) ASN1_STRING_free(os);
return(1);
err:
ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE,c->error);
if (os != NULL) ASN1_STRING_free(os);
if (b.data != NULL) OPENSSL_free(b.data);
return(0);
}
|
/* We are about to parse 0..n d2i_ASN1_bytes objects, we are to collapse
* them into the one structure that is then returned */
/* There have been a few bug fixes for this function from
* Paul Keogh <[email protected]>, many thanks to him */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl_android/crypto/asn1/a_bytes.c#L252-L313
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
BN_POOL_init
|
static void BN_POOL_init(BN_POOL *p)
{
p->head = p->current = p->tail = NULL;
p->used = p->size = 0;
}
|
/***********/
/* BN_POOL */
/***********/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl_android/crypto/bn/bn_ctx.c#L360-L364
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
dynamic_data_ctx_free_func
|
static void dynamic_data_ctx_free_func(void *parent, void *ptr,
CRYPTO_EX_DATA *ad, int idx, long argl, void *argp)
{
if(ptr)
{
dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
if(ctx->dynamic_dso)
DSO_free(ctx->dynamic_dso);
if(ctx->DYNAMIC_LIBNAME)
OPENSSL_free((void*)ctx->DYNAMIC_LIBNAME);
if(ctx->engine_id)
OPENSSL_free((void*)ctx->engine_id);
if(ctx->dirs)
sk_pop_free(ctx->dirs, int_free_str);
OPENSSL_free(ctx);
}
}
|
/* Because our ex_data element may or may not get allocated depending on whether
* a "first-use" occurs before the ENGINE is freed, we have a memory leak
* problem to solve. We can't declare a "new" handler for the ex_data as we
* don't want a dynamic_data_ctx in *all* ENGINE structures of all types (this
* is a bug in the design of CRYPTO_EX_DATA). As such, we just declare a "free"
* handler and that will get called if an ENGINE is being destroyed and there
* was an ex_data element corresponding to our context type. */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/openssl_android/crypto/engine/eng_dyn.c#L164-L180
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
png_destroy_write_struct
|
void PNGAPI
png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{
png_debug(1, "in png_destroy_write_struct");
if (png_ptr_ptr != NULL)
{
png_structrp png_ptr = *png_ptr_ptr;
if (png_ptr != NULL) /* added in libpng 1.6.0 */
{
png_destroy_info_struct(png_ptr, info_ptr_ptr);
*png_ptr_ptr = NULL;
png_write_destroy(png_ptr);
png_destroy_png_struct(png_ptr);
}
}
}
|
/* Free all memory used by the write.
* In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for
* *png_ptr_ptr. Prior to 1.6.0 it would accept such a value and it would free
* the passed in info_structs but it would quietly fail to free any of the data
* inside them. In 1.6.0 it quietly does nothing (it has to be quiet because it
* has no png_ptr.)
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/png/pngwrite.c#L900-L918
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
png_write_pHYs
|
void /* PRIVATE */
png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit,
png_uint_32 y_pixels_per_unit,
int unit_type)
{
png_byte buf[9];
png_debug(1, "in png_write_pHYs");
if (unit_type >= PNG_RESOLUTION_LAST)
png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");
png_save_uint_32(buf, x_pixels_per_unit);
png_save_uint_32(buf + 4, y_pixels_per_unit);
buf[8] = (png_byte)unit_type;
png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
}
|
/* Write the pHYs chunk */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/png/pngwutil.c#L1887-L1904
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
writepng_encode_image
|
int writepng_encode_image(mainprog_info *mainprog_ptr)
{
png_structp png_ptr = (png_structp)mainprog_ptr->png_ptr;
png_infop info_ptr = (png_infop)mainprog_ptr->info_ptr;
/* as always, setjmp() must be called in every function that calls a
* PNG-writing libpng function */
if (setjmp(mainprog_ptr->jmpbuf)) {
png_destroy_write_struct(&png_ptr, &info_ptr);
mainprog_ptr->png_ptr = NULL;
mainprog_ptr->info_ptr = NULL;
return 2;
}
/* and now we just write the whole image; libpng takes care of interlacing
* for us */
png_write_image(png_ptr, mainprog_ptr->row_pointers);
/* since that's it, we also close out the end of the PNG file now--if we
* had any text or time info to write after the IDATs, second argument
* would be info_ptr, but we optimize slightly by sending NULL pointer: */
png_write_end(png_ptr, NULL);
return 0;
}
|
/* returns 0 for success, 2 for libpng (longjmp) problem */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/png/contrib/gregbook/writepng.c#L259-L289
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
gpc_sRGB
|
static void
gpc_sRGB(Pixel *out, const Pixel *in, const Background *back)
{
(void)back;
out->r = isRGB(in->r);
if (in->g == in->r)
{
out->g = out->r;
if (in->b == in->r)
out->b = out->r;
else
out->b = isRGB(in->b);
}
else
{
out->g = isRGB(in->g);
if (in->b == in->r)
out->b = out->r;
else if (in->b == in->g)
out->b = out->g;
else
out->b = isRGB(in->b);
}
out->a = 255;
}
|
/* 16-bit to 8-bit conversions */
/* sRGB: convert linear components to sRGB, alpha := 255 */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/png/contrib/libtests/pngstest.c#L1598-L1631
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
is_leap
|
static int
is_leap(int year)
{
/* Cast year to unsigned. The result is the same either way, but
* C can generate faster code for unsigned mod than for signed
* mod (especially for % 4 -- a good compiler should just grab
* the last 2 bits when the LHS is unsigned).
*/
const unsigned int ayear = (unsigned int)year;
return ayear % 4 == 0 && (ayear % 100 != 0 || ayear % 400 == 0);
}
|
/* year -> 1 if leap year, else 0. */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/python/Modules/datetimemodule.c#L176-L186
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
move_finalizers
|
static void
move_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers)
{
PyGC_Head *gc;
PyGC_Head *next;
/* March over unreachable. Move objects with finalizers into
* `finalizers`.
*/
for (gc = unreachable->gc.gc_next; gc != unreachable; gc = next) {
PyObject *op = FROM_GC(gc);
assert(IS_TENTATIVELY_UNREACHABLE(op));
next = gc->gc.gc_next;
if (has_finalizer(op)) {
gc_list_move(gc, finalizers);
gc->gc.gc_refs = GC_REACHABLE;
}
}
}
|
/* Move the objects in unreachable with __del__ methods into `finalizers`.
* Objects moved into `finalizers` have gc_refs set to GC_REACHABLE; the
* objects remaining in unreachable are left at GC_TENTATIVELY_UNREACHABLE.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/python/Modules/gcmodule.c#L536-L556
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
sha_transform
|
static void
sha_transform(SHAobject *sha_info)
{
int i;
SHA_INT32 T, A, B, C, D, E, W[80], *WP;
memcpy(W, sha_info->data, sizeof(sha_info->data));
longReverse(W, (int)sizeof(sha_info->data), sha_info->Endianness);
for (i = 16; i < 80; ++i) {
W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16];
/* extra rotation fix */
W[i] = R32(W[i], 1);
}
A = sha_info->digest[0];
B = sha_info->digest[1];
C = sha_info->digest[2];
D = sha_info->digest[3];
E = sha_info->digest[4];
WP = W;
#ifdef UNRAVEL
FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1); FC(1); FD(1);
FE(1); FT(1); FA(1); FB(1); FC(1); FD(1); FE(1); FT(1); FA(1); FB(1);
FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2); FE(2); FT(2);
FA(2); FB(2); FC(2); FD(2); FE(2); FT(2); FA(2); FB(2); FC(2); FD(2);
FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3); FA(3); FB(3);
FC(3); FD(3); FE(3); FT(3); FA(3); FB(3); FC(3); FD(3); FE(3); FT(3);
FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4); FC(4); FD(4);
FE(4); FT(4); FA(4); FB(4); FC(4); FD(4); FE(4); FT(4); FA(4); FB(4);
sha_info->digest[0] += E;
sha_info->digest[1] += T;
sha_info->digest[2] += A;
sha_info->digest[3] += B;
sha_info->digest[4] += C;
#else /* !UNRAVEL */
#ifdef UNROLL_LOOPS
FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1);
FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1); FG(1);
FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2);
FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2); FG(2);
FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3);
FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3); FG(3);
FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4);
FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4); FG(4);
#else /* !UNROLL_LOOPS */
for (i = 0; i < 20; ++i) { FG(1); }
for (i = 20; i < 40; ++i) { FG(2); }
for (i = 40; i < 60; ++i) { FG(3); }
for (i = 60; i < 80; ++i) { FG(4); }
#endif /* !UNROLL_LOOPS */
sha_info->digest[0] += A;
sha_info->digest[1] += B;
sha_info->digest[2] += C;
sha_info->digest[3] += D;
sha_info->digest[4] += E;
#endif /* !UNRAVEL */
}
|
/* do SHA transformation */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/python/Modules/shamodule.c#L160-L217
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
deflate_slow
|
local block_state deflate_slow(s, flush)
deflate_state *s;
int flush;
{
IPos hash_head = NIL; /* head of hash chain */
int bflush; /* set if current block must be flushed */
/* Process the input block. */
for (;;) {
/* Make sure that we always have enough lookahead, except
* at the end of the input file. We need MAX_MATCH bytes
* for the next match, plus MIN_MATCH bytes to insert the
* string following the next match.
*/
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
return need_more;
}
if (s->lookahead == 0) break; /* flush the current block */
}
/* Insert the string window[strstart .. strstart+2] in the
* dictionary, and set hash_head to the head of the hash chain:
*/
if (s->lookahead >= MIN_MATCH) {
INSERT_STRING(s, s->strstart, hash_head);
}
/* Find the longest match, discarding those <= prev_length.
*/
s->prev_length = s->match_length, s->prev_match = s->match_start;
s->match_length = MIN_MATCH-1;
if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
s->strstart - hash_head <= MAX_DIST(s)) {
/* To simplify the code, we prevent matches with the string
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
s->match_length = longest_match (s, hash_head);
} else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
s->match_length = longest_match_fast (s, hash_head);
}
/* longest_match() or longest_match_fast() sets match_start */
if (s->match_length <= 5 && (s->strategy == Z_FILTERED
#if TOO_FAR <= 32767
|| (s->match_length == MIN_MATCH &&
s->strstart - s->match_start > TOO_FAR)
#endif
)) {
/* If prev_match is also MIN_MATCH, match_start is garbage
* but we will ignore the current match anyway.
*/
s->match_length = MIN_MATCH-1;
}
}
/* If there was a match at the previous step and the current
* match is not better, output the previous match:
*/
if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
/* Do not insert strings in hash table beyond this. */
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
_tr_tally_dist(s, s->strstart -1 - s->prev_match,
s->prev_length - MIN_MATCH, bflush);
/* Insert in hash table all strings up to the end of the match.
* strstart-1 and strstart are already inserted. If there is not
* enough lookahead, the last two strings are not inserted in
* the hash table.
*/
s->lookahead -= s->prev_length-1;
s->prev_length -= 2;
do {
if (++s->strstart <= max_insert) {
INSERT_STRING(s, s->strstart, hash_head);
}
} while (--s->prev_length != 0);
s->match_available = 0;
s->match_length = MIN_MATCH-1;
s->strstart++;
if (bflush) FLUSH_BLOCK(s, 0);
} else if (s->match_available) {
/* If there was no match at the previous position, output a
* single literal. If there was a match but the current match
* is longer, truncate the previous match to a single literal.
*/
Tracevv((stderr,"%c", s->window[s->strstart-1]));
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
if (bflush) {
FLUSH_BLOCK_ONLY(s, 0);
}
s->strstart++;
s->lookahead--;
if (s->strm->avail_out == 0) return need_more;
} else {
/* There is no previous match to compare with, wait for
* the next step to decide.
*/
s->match_available = 1;
s->strstart++;
s->lookahead--;
}
}
Assert (flush != Z_NO_FLUSH, "no flush?");
if (s->match_available) {
Tracevv((stderr,"%c", s->window[s->strstart-1]));
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
s->match_available = 0;
}
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
}
|
/* ===========================================================================
* Same as above, but achieves better compression. We use a lazy
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/python/Modules/zlib/deflate.c#L1554-L1674
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
int_print
|
static int
int_print(PyIntObject *v, FILE *fp, int flags)
/* flags -- not used but required by interface */
{
long int_val = v->ob_ival;
Py_BEGIN_ALLOW_THREADS
fprintf(fp, "%ld", int_val);
Py_END_ALLOW_THREADS
return 0;
}
|
/* ARGSUSED */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/python/Objects/intobject.c#L442-L451
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
out_of_memory
|
LOCAL(void)
out_of_memory (j_common_ptr cinfo, int which)
/* Report an out-of-memory error and stop execution */
/* If we compiled MEM_STATS support, report alloc requests before dying */
{
#ifdef MEM_STATS
cinfo->err->trace_level = 2; /* force self_destruct to report stats */
#endif
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which);
}
|
/* MEM_STATS */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/python_modules/tools/jpeg-6b/jmemmgr.c#L216-L225
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
checkTreePage
|
static int checkTreePage(
IntegrityCk *pCheck, /* Context for the sanity check */
int iPage, /* Page number of the page to check */
char *zParentContext, /* Parent context */
i64 *pnParentMinKey,
i64 *pnParentMaxKey
){
MemPage *pPage;
int i, rc, depth, d2, pgno, cnt;
int hdr, cellStart;
int nCell;
u8 *data;
BtShared *pBt;
int usableSize;
char zContext[100];
char *hit = 0;
i64 nMinKey = 0;
i64 nMaxKey = 0;
sqlite3_snprintf(sizeof(zContext), zContext, "Page %d: ", iPage);
/* Check that the page exists
*/
pBt = pCheck->pBt;
usableSize = pBt->usableSize;
if( iPage==0 ) return 0;
if( checkRef(pCheck, iPage, zParentContext) ) return 0;
if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){
checkAppendMsg(pCheck, zContext,
"unable to get the page. error code=%d", rc);
return 0;
}
/* Clear MemPage.isInit to make sure the corruption detection code in
** btreeInitPage() is executed. */
pPage->isInit = 0;
if( (rc = btreeInitPage(pPage))!=0 ){
assert( rc==SQLITE_CORRUPT ); /* The only possible error from InitPage */
checkAppendMsg(pCheck, zContext,
"btreeInitPage() returns error code %d", rc);
releasePage(pPage);
return 0;
}
/* Check out all the cells.
*/
depth = 0;
for(i=0; i<pPage->nCell && pCheck->mxErr; i++){
u8 *pCell;
u32 sz;
CellInfo info;
/* Check payload overflow pages
*/
sqlite3_snprintf(sizeof(zContext), zContext,
"On tree page %d cell %d: ", iPage, i);
pCell = findCell(pPage,i);
btreeParseCellPtr(pPage, pCell, &info);
sz = info.nData;
if( !pPage->intKey ) sz += (int)info.nKey;
/* For intKey pages, check that the keys are in order.
*/
else if( i==0 ) nMinKey = nMaxKey = info.nKey;
else{
if( info.nKey <= nMaxKey ){
checkAppendMsg(pCheck, zContext,
"Rowid %lld out of order (previous was %lld)", info.nKey, nMaxKey);
}
nMaxKey = info.nKey;
}
assert( sz==info.nPayload );
if( (sz>info.nLocal)
&& (&pCell[info.iOverflow]<=&pPage->aData[pBt->usableSize])
){
int nPage = (sz - info.nLocal + usableSize - 5)/(usableSize - 4);
Pgno pgnoOvfl = get4byte(&pCell[info.iOverflow]);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pBt->autoVacuum ){
checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage, zContext);
}
#endif
checkList(pCheck, 0, pgnoOvfl, nPage, zContext);
}
/* Check sanity of left child page.
*/
if( !pPage->leaf ){
pgno = get4byte(pCell);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pBt->autoVacuum ){
checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext);
}
#endif
d2 = checkTreePage(pCheck, pgno, zContext, &nMinKey, i==0 ? NULL : &nMaxKey);
if( i>0 && d2!=depth ){
checkAppendMsg(pCheck, zContext, "Child page depth differs");
}
depth = d2;
}
}
if( !pPage->leaf ){
pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);
sqlite3_snprintf(sizeof(zContext), zContext,
"On page %d at right child: ", iPage);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pBt->autoVacuum ){
checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext);
}
#endif
checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey);
}
/* For intKey leaf pages, check that the min/max keys are in order
** with any left/parent/right pages.
*/
if( pPage->leaf && pPage->intKey ){
/* if we are a left child page */
if( pnParentMinKey ){
/* if we are the left most child page */
if( !pnParentMaxKey ){
if( nMaxKey > *pnParentMinKey ){
checkAppendMsg(pCheck, zContext,
"Rowid %lld out of order (max larger than parent min of %lld)",
nMaxKey, *pnParentMinKey);
}
}else{
if( nMinKey <= *pnParentMinKey ){
checkAppendMsg(pCheck, zContext,
"Rowid %lld out of order (min less than parent min of %lld)",
nMinKey, *pnParentMinKey);
}
if( nMaxKey > *pnParentMaxKey ){
checkAppendMsg(pCheck, zContext,
"Rowid %lld out of order (max larger than parent max of %lld)",
nMaxKey, *pnParentMaxKey);
}
*pnParentMinKey = nMaxKey;
}
/* else if we're a right child page */
} else if( pnParentMaxKey ){
if( nMinKey <= *pnParentMaxKey ){
checkAppendMsg(pCheck, zContext,
"Rowid %lld out of order (min less than parent max of %lld)",
nMinKey, *pnParentMaxKey);
}
}
}
/* Check for complete coverage of the page
*/
data = pPage->aData;
hdr = pPage->hdrOffset;
hit = sqlite3PageMalloc( pBt->pageSize );
if( hit==0 ){
pCheck->mallocFailed = 1;
}else{
u16 contentOffset = get2byte(&data[hdr+5]);
assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */
memset(hit+contentOffset, 0, usableSize-contentOffset);
memset(hit, 1, contentOffset);
nCell = get2byte(&data[hdr+3]);
cellStart = hdr + 12 - 4*pPage->leaf;
for(i=0; i<nCell; i++){
int pc = get2byte(&data[cellStart+i*2]);
u16 size = 1024;
int j;
if( pc<=usableSize-4 ){
size = cellSizePtr(pPage, &data[pc]);
}
if( (pc+size-1)>=usableSize ){
checkAppendMsg(pCheck, 0,
"Corruption detected in cell %d on page %d",i,iPage);
}else{
for(j=pc+size-1; j>=pc; j--) hit[j]++;
}
}
i = get2byte(&data[hdr+1]);
while( i>0 ){
int size, j;
assert( i<=usableSize-4 ); /* Enforced by btreeInitPage() */
size = get2byte(&data[i+2]);
assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */
for(j=i+size-1; j>=i; j--) hit[j]++;
j = get2byte(&data[i]);
assert( j==0 || j>i+size ); /* Enforced by btreeInitPage() */
assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */
i = j;
}
for(i=cnt=0; i<usableSize; i++){
if( hit[i]==0 ){
cnt++;
}else if( hit[i]>1 ){
checkAppendMsg(pCheck, 0,
"Multiple uses for byte %d of page %d", i, iPage);
break;
}
}
if( cnt!=data[hdr+7] ){
checkAppendMsg(pCheck, 0,
"Fragmentation of %d bytes reported as %d on page %d",
cnt, data[hdr+7], iPage);
}
}
sqlite3PageFree(hit);
releasePage(pPage);
return depth+1;
}
|
/*
** Do various sanity checks on a single page of a tree. Return
** the tree depth. Root pages return 0. Parents of root pages
** return 1, and so forth.
**
** These checks are done:
**
** 1. Make sure that cells and freeblocks do not overlap
** but combine to completely cover the page.
** NO 2. Make sure cell keys are in order.
** NO 3. Make sure no key is less than or equal to zLowerBound.
** NO 4. Make sure no key is greater than or equal to zUpperBound.
** 5. Check the integrity of overflow pages.
** 6. Recursively call checkTreePage on all children.
** 7. Verify that the depth of all children is the same.
** 8. Make sure this page is at least 33% full or else it is
** the root of the tree.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/sqlite/sqlite3.c#L45990-L46197
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
removeFromBlockedList
|
static void removeFromBlockedList(sqlite3 *db){
sqlite3 **pp;
assertMutexHeld();
for(pp=&sqlite3BlockedList; *pp; pp = &(*pp)->pNextBlocked){
if( *pp==db ){
*pp = (*pp)->pNextBlocked;
break;
}
}
}
|
/*
** Remove connection db from the blocked connections list. If connection
** db is not currently a part of the list, this function is a no-op.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/sqlite/sqlite3.c#L98900-L98909
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
fts3OffsetsFunc
|
static void fts3OffsetsFunc(
sqlite3_context *pContext, /* SQLite function call context */
int nVal, /* Size of argument array */
sqlite3_value **apVal /* Array of arguments */
){
Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
UNUSED_PARAMETER(nVal);
assert( nVal==1 );
if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return;
assert( pCsr );
if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
sqlite3Fts3Offsets(pContext, pCsr);
}
}
|
/*
** Implementation of the offsets() function for FTS3
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/sqlite/sqlite3.c#L102042-L102057
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
deflatePending
|
int ZEXPORT deflatePending (strm, pending, bits)
unsigned *pending;
int *bits;
z_streamp strm;
{
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
if (pending != Z_NULL)
*pending = strm->state->pending;
if (bits != Z_NULL)
*bits = strm->state->bi_valid;
return Z_OK;
}
|
/* ========================================================================= */
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/zip/deflate.c#L450-L461
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
gen_bitlen
|
local void gen_bitlen(s, desc)
deflate_state *s;
tree_desc *desc; /* the tree descriptor */
{
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
const ct_data *stree = desc->stat_desc->static_tree;
const intf *extra = desc->stat_desc->extra_bits;
int base = desc->stat_desc->extra_base;
int max_length = desc->stat_desc->max_length;
int h; /* heap index */
int n, m; /* iterate over the tree elements */
int bits; /* bit length */
int xbits; /* extra bits */
ush f; /* frequency */
int overflow = 0; /* number of elements with bit length too large */
for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
/* In a first pass, compute the optimal bit lengths (which may
* overflow in the case of the bit length tree).
*/
tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
n = s->heap[h];
bits = tree[tree[n].Dad].Len + 1;
if (bits > max_length) bits = max_length, overflow++;
tree[n].Len = (ush)bits;
/* We overwrite tree[n].Dad which is no longer needed */
if (n > max_code) continue; /* not a leaf node */
s->bl_count[bits]++;
xbits = 0;
if (n >= base) xbits = extra[n-base];
f = tree[n].Freq;
s->opt_len += (ulg)f * (bits + xbits);
if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
}
if (overflow == 0) return;
Trace((stderr,"\nbit length overflow\n"));
/* This happens for example on obj2 and pic of the Calgary corpus */
/* Find the first bit length which could increase: */
do {
bits = max_length-1;
while (s->bl_count[bits] == 0) bits--;
s->bl_count[bits]--; /* move one leaf down the tree */
s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
s->bl_count[max_length]--;
/* The brother of the overflow item also moves one step up,
* but this does not affect bl_count[max_length]
*/
overflow -= 2;
} while (overflow > 0);
/* Now recompute all bit lengths, scanning in increasing frequency.
* h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
* lengths instead of fixing only the wrong ones. This idea is taken
* from 'ar' written by Haruhiko Okumura.)
*/
for (bits = max_length; bits != 0; bits--) {
n = s->bl_count[bits];
while (n != 0) {
m = s->heap[--h];
if (m > max_code) continue;
if ((unsigned) tree[m].Len != (unsigned) bits) {
Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
s->opt_len += ((long)bits - (long)tree[m].Len)
*(long)tree[m].Freq;
tree[m].Len = (ush)bits;
}
n--;
}
}
}
|
/* ===========================================================================
* Compute the optimal bit lengths for a tree and update the total bit length
* for the current block.
* IN assertion: the fields freq and dad are set, heap[heap_max] and
* above are the tree nodes sorted by increasing frequency.
* OUT assertions: the field len is set to the optimal bit length, the
* array bl_count contains the frequencies for each bit length.
* The length opt_len is updated; static_len is also updated if stree is
* not null.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/zip/trees.c#L488-L565
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
BigWorld-Engine-14.4.1
|
github_2023
|
v2v3v4
|
c
|
inflate_table9
|
int inflate_table9(type, lens, codes, table, bits, work)
codetype type;
unsigned short FAR *lens;
unsigned codes;
code FAR * FAR *table;
unsigned FAR *bits;
unsigned short FAR *work;
{
unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */
unsigned min, max; /* minimum and maximum code lengths */
unsigned root; /* number of index bits for root table */
unsigned curr; /* number of index bits for current table */
unsigned drop; /* code bits to drop for sub-table */
int left; /* number of prefix codes available */
unsigned used; /* code entries in table used */
unsigned huff; /* Huffman code */
unsigned incr; /* for incrementing code, index */
unsigned fill; /* index for replicating entries */
unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */
code this; /* table entry for duplication */
code FAR *next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
int end; /* use base and extra for symbol > end */
unsigned short count[MAXBITS+1]; /* number of codes of each length */
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17,
19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115,
131, 163, 195, 227, 3, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 72, 78};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153};
static const unsigned short dext[32] = { /* Distance codes 0..31 extra */
128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132,
133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,
139, 139, 140, 140, 141, 141, 142, 142};
/*
Process a set of code lengths to create a canonical Huffman code. The
code lengths are lens[0..codes-1]. Each length corresponds to the
symbols 0..codes-1. The Huffman code is generated by first sorting the
symbols by length from short to long, and retaining the symbol order
for codes with equal lengths. Then the code starts with all zero bits
for the first code of the shortest length, and the codes are integer
increments for the same length, and zeros are appended as the length
increases. For the deflate format, these bits are stored backwards
from their more natural integer increment ordering, and so when the
decoding tables are built in the large loop below, the integer codes
are incremented backwards.
This routine assumes, but does not check, that all of the entries in
lens[] are in the range 0..MAXBITS. The caller must assure this.
1..MAXBITS is interpreted as that code length. zero means that that
symbol does not occur in this code.
The codes are sorted by computing a count of codes for each length,
creating from that a table of starting indices for each length in the
sorted table, and then entering the symbols in order in the sorted
table. The sorted table is work[], with that space being provided by
the caller.
The length counts are used for other purposes as well, i.e. finding
the minimum and maximum length codes, determining if there are any
codes at all, checking for a valid set of lengths, and looking ahead
at length counts to determine sub-table sizes when building the
decoding tables.
*/
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
for (len = 0; len <= MAXBITS; len++)
count[len] = 0;
for (sym = 0; sym < codes; sym++)
count[lens[sym]]++;
/* bound code lengths, force root to be within code lengths */
root = *bits;
for (max = MAXBITS; max >= 1; max--)
if (count[max] != 0) break;
if (root > max) root = max;
if (max == 0) return -1; /* no codes! */
for (min = 1; min <= MAXBITS; min++)
if (count[min] != 0) break;
if (root < min) root = min;
/* check for an over-subscribed or incomplete set of lengths */
left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= count[len];
if (left < 0) return -1; /* over-subscribed */
}
if (left > 0 && (type == CODES || max != 1))
return -1; /* incomplete set */
/* generate offsets into symbol table for each length for sorting */
offs[1] = 0;
for (len = 1; len < MAXBITS; len++)
offs[len + 1] = offs[len] + count[len];
/* sort symbols by length, by symbol order within each length */
for (sym = 0; sym < codes; sym++)
if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
/*
Create and fill in decoding tables. In this loop, the table being
filled is at next and has curr index bits. The code being used is huff
with length len. That code is converted to an index by dropping drop
bits off of the bottom. For codes where len is less than drop + curr,
those top drop + curr - len bits are incremented through all values to
fill the table with replicated entries.
root is the number of index bits for the root table. When len exceeds
root, sub-tables are created pointed to by the root entry with an index
of the low root bits of huff. This is saved in low to check for when a
new sub-table should be started. drop is zero when the root table is
being filled, and drop is root when sub-tables are being filled.
When a new sub-table is needed, it is necessary to look ahead in the
code lengths to determine what size sub-table is needed. The length
counts are used for this, and so count[] is decremented as codes are
entered in the tables.
used keeps track of how many table entries have been allocated from the
provided *table space. It is checked for LENS and DIST tables against
the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
the initial root table size constants. See the comments in inftree9.h
for more information.
sym increments through all symbols, and the loop terminates when
all codes of length max, i.e. all codes, have been processed. This
routine permits incomplete codes, so another loop after this one fills
in the rest of the decoding tables with invalid code markers.
*/
/* set up for code type */
switch (type) {
case CODES:
base = extra = work; /* dummy value--not used */
end = 19;
break;
case LENS:
base = lbase;
base -= 257;
extra = lext;
extra -= 257;
end = 256;
break;
default: /* DISTS */
base = dbase;
extra = dext;
end = -1;
}
/* initialize state for loop */
huff = 0; /* starting code */
sym = 0; /* starting code symbol */
len = min; /* starting code length */
next = *table; /* current table to fill in */
curr = root; /* current table index bits */
drop = 0; /* current bits to drop from code for index */
low = (unsigned)(-1); /* trigger new sub-table when len > root */
used = 1U << root; /* use root table entries */
mask = used - 1; /* mask for comparing low */
/* check available table space */
if ((type == LENS && used >= ENOUGH_LENS) ||
(type == DISTS && used >= ENOUGH_DISTS))
return 1;
/* process all codes and make table entries */
for (;;) {
/* create table entry */
this.bits = (unsigned char)(len - drop);
if ((int)(work[sym]) < end) {
this.op = (unsigned char)0;
this.val = work[sym];
}
else if ((int)(work[sym]) > end) {
this.op = (unsigned char)(extra[work[sym]]);
this.val = base[work[sym]];
}
else {
this.op = (unsigned char)(32 + 64); /* end of block */
this.val = 0;
}
/* replicate for those indices with low len bits equal to huff */
incr = 1U << (len - drop);
fill = 1U << curr;
do {
fill -= incr;
next[(huff >> drop) + fill] = this;
} while (fill != 0);
/* backwards increment the len-bit code huff */
incr = 1U << (len - 1);
while (huff & incr)
incr >>= 1;
if (incr != 0) {
huff &= incr - 1;
huff += incr;
}
else
huff = 0;
/* go to next symbol, update count, len */
sym++;
if (--(count[len]) == 0) {
if (len == max) break;
len = lens[work[sym]];
}
/* create new sub-table if needed */
if (len > root && (huff & mask) != low) {
/* if first time, transition to sub-tables */
if (drop == 0)
drop = root;
/* increment past last table */
next += 1U << curr;
/* determine length of next table */
curr = len - drop;
left = (int)(1 << curr);
while (curr + drop < max) {
left -= count[curr + drop];
if (left <= 0) break;
curr++;
left <<= 1;
}
/* check for enough space */
used += 1U << curr;
if ((type == LENS && used >= ENOUGH_LENS) ||
(type == DISTS && used >= ENOUGH_DISTS))
return 1;
/* point entry in root table to sub-table */
low = huff & mask;
(*table)[low].op = (unsigned char)curr;
(*table)[low].bits = (unsigned char)root;
(*table)[low].val = (unsigned short)(next - *table);
}
}
/*
Fill in rest of table for incomplete codes. This loop is similar to the
loop above in incrementing huff for table indices. It is assumed that
len is equal to curr + drop, so there is no loop needed to increment
through high index bits. When the current sub-table is filled, the loop
drops back to the root table to fill in any remaining entries there.
*/
this.op = (unsigned char)64; /* invalid code marker */
this.bits = (unsigned char)(len - drop);
this.val = (unsigned short)0;
while (huff != 0) {
/* when done with sub-table, drop back to root table */
if (drop != 0 && (huff & mask) != low) {
drop = 0;
len = root;
next = *table;
curr = root;
this.bits = (unsigned char)len;
}
/* put invalid code marker in table */
next[huff >> drop] = this;
/* backwards increment the len-bit code huff */
incr = 1U << (len - 1);
while (huff & incr)
incr >>= 1;
if (incr != 0) {
huff &= incr - 1;
huff += incr;
}
else
huff = 0;
}
/* set return parameters */
*table += used;
*bits = root;
return 0;
}
|
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
include such an acknowledgment, I would appreciate that you keep this
copyright string in the executable of your product.
*/
/*
Build a set of tables to decode the provided canonical Huffman code.
The code lengths are lens[0..codes-1]. The result starts at *table,
whose indices are 0..2^bits-1. work is a writable array of at least
lens shorts, which is used as a work area. type is the type of code
to be generated, CODES, LENS, or DISTS. On return, zero is success,
-1 is an invalid code, and +1 means that ENOUGH isn't enough. table
on return points to the next available entry's address. bits is the
requested root table index bits, and on return it is the actual root
table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code.
*/
|
https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/zip/contrib/infback9/inftree9.c#L32-L324
|
4389085c8ce35cff887a4cc18fc47d1133d89ffb
|
audioFlux
|
github_2023
|
libAudioFlux
|
c
|
_conv_direct
|
static int _conv_direct(float *vArr1,int length1,float *vArr2,int length2,
ConvModeType mode,float *vArr3){
int len=0;
int start=0;
if(mode==ConvMode_Full){
len=length1+length2-1;
start=-length2+1;
for(int i=start,n=0;i<length1;i++,n++){
for(int j=length2-1,k=i;j>=0;j--,k++){
float _value=0;
if(k>=0&&k<length1){
_value=vArr1[k];
}
vArr3[n]+=_value*vArr2[j];
}
}
}
else{
len=length1;
start=length2/2-(length2&1?0:1);
if(mode==ConvMode_Valid){
len=length1-length2+1;
start=0;
}
for(int i=-start,n=0;i<len-start;i++,n++){
for(int j=length2-1,k=i;j>=0;j--,k++){
float _value=0;
if(k>=0&&k<length1){
_value=vArr1[k];
}
vArr3[n]+=_value*vArr2[j];
}
}
}
return len;
}
|
/***
关于mode 以vArr1为准 N/M
full N+M-1
same N
valid N-M+1
****/
|
https://github.com/libAudioFlux/audioFlux/blob/824f76d5f19d0358779e513d708a987e4fb9224e/src/dsp/conv_algorithm.c#L214-L255
|
824f76d5f19d0358779e513d708a987e4fb9224e
|
fenster
|
github_2023
|
zserge
|
c
|
G_SecretExitLevel
|
void G_SecretExitLevel (void)
{
// IF NO WOLF3D LEVELS, NO SECRET EXIT!
if ( (gamemode == commercial)
&& (W_CheckNumForName("map31")<0))
secretexit = false;
else
secretexit = true;
gameaction = ga_completed;
}
|
// Here's for the german edition.
|
https://github.com/zserge/fenster/blob/e700581dfb7956dd161aee44fc0cff0663e789a1/examples/doom-c/g_game.c#L1335-L1344
|
e700581dfb7956dd161aee44fc0cff0663e789a1
|
fenster
|
github_2023
|
zserge
|
c
|
G_VanillaVersionCode
|
int G_VanillaVersionCode(void)
{
switch (gameversion)
{
case exe_doom_1_2:
I_Error("Doom 1.2 does not have a version code!");
case exe_doom_1_666:
return 106;
case exe_doom_1_7:
return 107;
case exe_doom_1_8:
return 108;
case exe_doom_1_9:
default: // All other versions are variants on v1.9:
return 109;
}
}
|
// Get the demo version code appropriate for the version set in gameversion.
|
https://github.com/zserge/fenster/blob/e700581dfb7956dd161aee44fc0cff0663e789a1/examples/doom-c/g_game.c#L2040-L2056
|
e700581dfb7956dd161aee44fc0cff0663e789a1
|
fenster
|
github_2023
|
zserge
|
c
|
I_InitScale
|
void I_InitScale(byte *_src_buffer, byte *_dest_buffer, int _dest_pitch)
{
src_buffer = _src_buffer;
dest_buffer = _dest_buffer;
dest_pitch = _dest_pitch;
}
|
// Called to set the source and destination buffers before doing the
// scale.
|
https://github.com/zserge/fenster/blob/e700581dfb7956dd161aee44fc0cff0663e789a1/examples/doom-c/i_scale.c#L61-L66
|
e700581dfb7956dd161aee44fc0cff0663e789a1
|
fenster
|
github_2023
|
zserge
|
c
|
P_FindLowestCeilingSurrounding
|
fixed_t
P_FindLowestCeilingSurrounding(sector_t* sec)
{
int i;
line_t* check;
sector_t* other;
fixed_t height = INT_MAX;
for (i=0 ;i < sec->linecount ; i++)
{
check = sec->lines[i];
other = getNextSector(check,sec);
if (!other)
continue;
if (other->ceilingheight < height)
height = other->ceilingheight;
}
return height;
}
|
//
// FIND LOWEST CEILING IN THE SURROUNDING SECTORS
//
|
https://github.com/zserge/fenster/blob/e700581dfb7956dd161aee44fc0cff0663e789a1/examples/doom-c/p_spec.c#L391-L411
|
e700581dfb7956dd161aee44fc0cff0663e789a1
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
unixOpen
|
static int unixOpen(
sqlite3_vfs *pVfs, /* The VFS for which this is the xOpen method */
const char *zPath, /* Pathname of file to be opened */
sqlite3_file *pFile, /* The file descriptor to be filled in */
int flags, /* Input flags to control the opening */
int *pOutFlags /* Output flags returned to SQLite core */
){
unixFile *p = (unixFile *)pFile;
int fd = -1; /* File descriptor returned by open() */
int openFlags = 0; /* Flags to pass to open() */
int eType = flags&0x0FFF00; /* Type of file to open */
int noLock; /* True to omit locking primitives */
int rc = SQLITE_OK; /* Function Return Code */
int ctrlFlags = 0; /* UNIXFILE_* flags */
int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE);
int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE);
int isCreate = (flags & SQLITE_OPEN_CREATE);
int isReadonly = (flags & SQLITE_OPEN_READONLY);
int isReadWrite = (flags & SQLITE_OPEN_READWRITE);
#if SQLITE_ENABLE_LOCKING_STYLE
int isAutoProxy = (flags & SQLITE_OPEN_AUTOPROXY);
#endif
#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
struct statfs fsInfo;
#endif
/* If creating a super- or main-file journal, this function will open
** a file-descriptor on the directory too. The first time unixSync()
** is called the directory file descriptor will be fsync()ed and close()d.
*/
int isNewJrnl = (isCreate && (
eType==SQLITE_OPEN_SUPER_JOURNAL
|| eType==SQLITE_OPEN_MAIN_JOURNAL
|| eType==SQLITE_OPEN_WAL
));
/* If argument zPath is a NULL pointer, this function is required to open
** a temporary file. Use this buffer to store the file name in.
*/
char zTmpname[MAX_PATHNAME+2];
const char *zName = zPath;
/* Check the following statements are true:
**
** (a) Exactly one of the READWRITE and READONLY flags must be set, and
** (b) if CREATE is set, then READWRITE must also be set, and
** (c) if EXCLUSIVE is set, then CREATE must also be set.
** (d) if DELETEONCLOSE is set, then CREATE must also be set.
*/
assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));
assert(isCreate==0 || isReadWrite);
assert(isExclusive==0 || isCreate);
assert(isDelete==0 || isCreate);
/* The main DB, main journal, WAL file and super-journal are never
** automatically deleted. Nor are they ever temporary files. */
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_SUPER_JOURNAL );
assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );
/* Assert that the upper layer has set one of the "file-type" flags. */
assert( eType==SQLITE_OPEN_MAIN_DB || eType==SQLITE_OPEN_TEMP_DB
|| eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL
|| eType==SQLITE_OPEN_SUBJOURNAL || eType==SQLITE_OPEN_SUPER_JOURNAL
|| eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
);
/* Detect a pid change and reset the PRNG. There is a race condition
** here such that two or more threads all trying to open databases at
** the same instant might all reset the PRNG. But multiple resets
** are harmless.
*/
if( randomnessPid!=osGetpid(0) ){
randomnessPid = osGetpid(0);
sqlite3_randomness(0,0);
}
memset(p, 0, sizeof(unixFile));
#ifdef SQLITE_ASSERT_NO_FILES
/* Applications that never read or write a persistent disk files */
assert( zName==0 );
#endif
if( eType==SQLITE_OPEN_MAIN_DB ){
UnixUnusedFd *pUnused;
pUnused = findReusableFd(zName, flags);
if( pUnused ){
fd = pUnused->fd;
}else{
pUnused = sqlite3_malloc64(sizeof(*pUnused));
if( !pUnused ){
return SQLITE_NOMEM_BKPT;
}
}
p->pPreallocatedUnused = pUnused;
/* Database filenames are double-zero terminated if they are not
** URIs with parameters. Hence, they can always be passed into
** sqlite3_uri_parameter(). */
assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
}else if( !zName ){
/* If zName is NULL, the upper layer is requesting a temp file. */
assert(isDelete && !isNewJrnl);
rc = unixGetTempname(pVfs->mxPathname, zTmpname);
if( rc!=SQLITE_OK ){
return rc;
}
zName = zTmpname;
/* Generated temporary filenames are always double-zero terminated
** for use by sqlite3_uri_parameter(). */
assert( zName[strlen(zName)+1]==0 );
}
/* Determine the value of the flags parameter passed to POSIX function
** open(). These must be calculated even if open() is not called, as
** they may be stored as part of the file handle and used by the
** 'conch file' locking functions later on. */
if( isReadonly ) openFlags |= O_RDONLY;
if( isReadWrite ) openFlags |= O_RDWR;
if( isCreate ) openFlags |= O_CREAT;
if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);
openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW);
if( fd<0 ){
mode_t openMode; /* Permissions to create file with */
uid_t uid; /* Userid for the file */
gid_t gid; /* Groupid for the file */
rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);
if( rc!=SQLITE_OK ){
assert( !p->pPreallocatedUnused );
assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );
return rc;
}
fd = robust_open(zName, openFlags, openMode);
OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags));
assert( !isExclusive || (openFlags & O_CREAT)!=0 );
if( fd<0 ){
if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){
/* If unable to create a journal because the directory is not
** writable, change the error code to indicate that. */
rc = SQLITE_READONLY_DIRECTORY;
}else if( errno!=EISDIR && isReadWrite ){
/* Failed to open the file for read/write access. Try read-only. */
UnixUnusedFd *pReadonly = 0;
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
openFlags &= ~(O_RDWR|O_CREAT);
flags |= SQLITE_OPEN_READONLY;
openFlags |= O_RDONLY;
isReadonly = 1;
pReadonly = findReusableFd(zName, flags);
if( pReadonly ){
fd = pReadonly->fd;
sqlite3_free(pReadonly);
}else{
fd = robust_open(zName, openFlags, openMode);
}
}
}
if( fd<0 ){
int rc2 = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
if( rc==SQLITE_OK ) rc = rc2;
goto open_finished;
}
/* The owner of the rollback journal or WAL file should always be the
** same as the owner of the database file. Try to ensure that this is
** the case. The chown() system call will be a no-op if the current
** process lacks root privileges, be we should at least try. Without
** this step, if a root process opens a database file, it can leave
** behinds a journal/WAL that is owned by root and hence make the
** database inaccessible to unprivileged processes.
**
** If openMode==0, then that means uid and gid are not set correctly
** (probably because SQLite is configured to use 8+3 filename mode) and
** in that case we do not want to attempt the chown().
*/
if( openMode && (flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL))!=0 ){
robustFchown(fd, uid, gid);
}
}
assert( fd>=0 );
if( pOutFlags ){
*pOutFlags = flags;
}
if( p->pPreallocatedUnused ){
p->pPreallocatedUnused->fd = fd;
p->pPreallocatedUnused->flags =
flags & (SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE);
}
if( isDelete ){
#if OS_VXWORKS
zPath = zName;
#elif defined(SQLITE_UNLINK_AFTER_CLOSE)
zPath = sqlite3_mprintf("%s", zName);
if( zPath==0 ){
robust_close(p, fd, __LINE__);
return SQLITE_NOMEM_BKPT;
}
#else
osUnlink(zName);
#endif
}
#if SQLITE_ENABLE_LOCKING_STYLE
else{
p->openFlags = openFlags;
}
#endif
#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
if( fstatfs(fd, &fsInfo) == -1 ){
storeLastErrno(p, errno);
robust_close(p, fd, __LINE__);
return SQLITE_IOERR_ACCESS;
}
if (0 == strncmp("msdos", fsInfo.f_fstypename, 5)) {
((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;
}
if (0 == strncmp("exfat", fsInfo.f_fstypename, 5)) {
((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;
}
#endif
/* Set up appropriate ctrlFlags */
if( isDelete ) ctrlFlags |= UNIXFILE_DELETE;
if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
noLock = eType!=SQLITE_OPEN_MAIN_DB;
if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
if( isNewJrnl ) ctrlFlags |= UNIXFILE_DIRSYNC;
if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
#if SQLITE_ENABLE_LOCKING_STYLE
#if SQLITE_PREFER_PROXY_LOCKING
isAutoProxy = 1;
#endif
if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){
char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING");
int useProxy = 0;
/* SQLITE_FORCE_PROXY_LOCKING==1 means force always use proxy, 0 means
** never use proxy, NULL means use proxy for non-local files only. */
if( envforce!=NULL ){
useProxy = atoi(envforce)>0;
}else{
useProxy = !(fsInfo.f_flags&MNT_LOCAL);
}
if( useProxy ){
rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
if( rc==SQLITE_OK ){
rc = proxyTransformUnixFile((unixFile*)pFile, ":auto:");
if( rc!=SQLITE_OK ){
/* Use unixClose to clean up the resources added in fillInUnixFile
** and clear all the structure's references. Specifically,
** pFile->pMethods will be NULL so sqlite3OsClose will be a no-op
*/
unixClose(pFile);
return rc;
}
}
goto open_finished;
}
}
#endif
assert( zPath==0 || zPath[0]=='/'
|| eType==SQLITE_OPEN_SUPER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL
);
rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
open_finished:
if( rc!=SQLITE_OK ){
sqlite3_free(p->pPreallocatedUnused);
}
return rc;
}
|
/*
** Open the file zPath.
**
** Previously, the SQLite OS layer used three functions in place of this
** one:
**
** sqlite3OsOpenReadWrite();
** sqlite3OsOpenReadOnly();
** sqlite3OsOpenExclusive();
**
** These calls correspond to the following combinations of flags:
**
** ReadWrite() -> (READWRITE | CREATE)
** ReadOnly() -> (READONLY)
** OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE)
**
** The old OpenExclusive() accepted a boolean argument - "delFlag". If
** true, the file was configured to be automatically deleted when the
** file handle closed. To achieve the same effect using this new
** interface, add the DELETEONCLOSE flag to those specified above for
** OpenExclusive().
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L44613-L44892
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
sqlite3PagerSetSpillsize
|
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager *pPager, int mxPage){
return sqlite3PcacheSetSpillsize(pPager->pPCache, mxPage);
}
|
/*
** Change the maximum number of in-memory pages that are allowed
** before attempting to spill pages to journal.
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L60624-L60626
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
sqlite3PagerSetFlags
|
SQLITE_PRIVATE void sqlite3PagerSetFlags(
Pager *pPager, /* The pager to set safety level for */
unsigned pgFlags /* Various flags */
){
unsigned level = pgFlags & PAGER_SYNCHRONOUS_MASK;
if( pPager->tempFile ){
pPager->noSync = 1;
pPager->fullSync = 0;
pPager->extraSync = 0;
}else{
pPager->noSync = level==PAGER_SYNCHRONOUS_OFF ?1:0;
pPager->fullSync = level>=PAGER_SYNCHRONOUS_FULL ?1:0;
pPager->extraSync = level==PAGER_SYNCHRONOUS_EXTRA ?1:0;
}
if( pPager->noSync ){
pPager->syncFlags = 0;
}else if( pgFlags & PAGER_FULLFSYNC ){
pPager->syncFlags = SQLITE_SYNC_FULL;
}else{
pPager->syncFlags = SQLITE_SYNC_NORMAL;
}
pPager->walSyncFlags = (pPager->syncFlags<<2);
if( pPager->fullSync ){
pPager->walSyncFlags |= pPager->syncFlags;
}
if( (pgFlags & PAGER_CKPT_FULLFSYNC) && !pPager->noSync ){
pPager->walSyncFlags |= (SQLITE_SYNC_FULL<<2);
}
if( pgFlags & PAGER_CACHESPILL ){
pPager->doNotSpill &= ~SPILLFLAG_OFF;
}else{
pPager->doNotSpill |= SPILLFLAG_OFF;
}
}
|
/*
** Adjust settings of the pager to those specified in the pgFlags parameter.
**
** The "level" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness
** of the database to damage due to OS crashes or power failures by
** changing the number of syncs()s when writing the journals.
** There are four levels:
**
** OFF sqlite3OsSync() is never called. This is the default
** for temporary and transient files.
**
** NORMAL The journal is synced once before writes begin on the
** database. This is normally adequate protection, but
** it is theoretically possible, though very unlikely,
** that an inopertune power failure could leave the journal
** in a state which would cause damage to the database
** when it is rolled back.
**
** FULL The journal is synced twice before writes begin on the
** database (with some additional information - the nRec field
** of the journal header - being written in between the two
** syncs). If we assume that writing a
** single disk sector is atomic, then this mode provides
** assurance that the journal will not be corrupted to the
** point of causing damage to the database during rollback.
**
** EXTRA This is like FULL except that is also syncs the directory
** that contains the rollback journal after the rollback
** journal is unlinked.
**
** The above is for a rollback-journal mode. For WAL mode, OFF continues
** to mean that no syncs ever occur. NORMAL means that the WAL is synced
** prior to the start of checkpoint and that the database file is synced
** at the conclusion of the checkpoint if the entire content of the WAL
** was written back into the database. But no sync operations occur for
** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL
** file is synced following each commit operation, in addition to the
** syncs associated with NORMAL. There is no difference between FULL
** and EXTRA for WAL mode.
**
** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL. The
** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync
** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an
** ordinary fsync() call. There is no difference between SQLITE_SYNC_FULL
** and SQLITE_SYNC_NORMAL on platforms other than MacOSX. But the
** synchronous=FULL versus synchronous=NORMAL setting determines when
** the xSync primitive is called and is relevant to all platforms.
**
** Numeric values associated with these states are OFF==1, NORMAL=2,
** and FULL=3.
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L60710-L60743
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
sqlite3WalWriteLock
|
SQLITE_PRIVATE int sqlite3WalWriteLock(Wal *pWal, int bLock){
int rc = SQLITE_OK;
assert( pWal->readLock<0 || bLock==0 );
if( bLock ){
assert( pWal->db );
if( walEnableBlocking(pWal) ){
rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
if( rc==SQLITE_OK ){
pWal->writeLock = 1;
}
walDisableBlocking(pWal);
}
}else if( pWal->writeLock ){
walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
pWal->writeLock = 0;
}
return rc;
}
|
/*
** If parameter bLock is true, attempt to enable blocking locks, take
** the WRITER lock, and then disable blocking locks. If blocking locks
** cannot be enabled, no attempt to obtain the WRITER lock is made. Return
** an SQLite error code if an error occurs, or SQLITE_OK otherwise. It is not
** an error if blocking locks can not be enabled.
**
** If the bLock parameter is false and the WRITER lock is held, release it.
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L66966-L66983
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
sqlite3VdbeAssertMayAbort
|
SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
int hasAbort = 0;
int hasFkCounter = 0;
int hasCreateTable = 0;
int hasCreateIndex = 0;
int hasInitCoroutine = 0;
Op *pOp;
VdbeOpIter sIter;
if( v==0 ) return 0;
memset(&sIter, 0, sizeof(sIter));
sIter.v = v;
while( (pOp = opIterNext(&sIter))!=0 ){
int opcode = pOp->opcode;
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
|| opcode==OP_VDestroy
|| opcode==OP_VCreate
|| opcode==OP_ParseSchema
|| opcode==OP_Function || opcode==OP_PureFunc
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
&& ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
){
hasAbort = 1;
break;
}
if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;
if( mayAbort ){
/* hasCreateIndex may also be set for some DELETE statements that use
** OP_Clear. So this routine may end up returning true in the case
** where a "DELETE FROM tbl" has a statement-journal but does not
** require one. This is not so bad - it is an inefficiency, not a bug. */
if( opcode==OP_CreateBtree && pOp->p3==BTREE_BLOBKEY ) hasCreateIndex = 1;
if( opcode==OP_Clear ) hasCreateIndex = 1;
}
if( opcode==OP_InitCoroutine ) hasInitCoroutine = 1;
#ifndef SQLITE_OMIT_FOREIGN_KEY
if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){
hasFkCounter = 1;
}
#endif
}
sqlite3DbFree(v->db, sIter.apSub);
/* Return true if hasAbort==mayAbort. Or if a malloc failure occurred.
** If malloc failed, then the while() loop above may not have iterated
** through all opcodes and hasAbort may be set incorrectly. Return
** true for this case to prevent the assert() in the callers frame
** from failing. */
return ( v->db->mallocFailed || hasAbort==mayAbort || hasFkCounter
|| (hasCreateTable && hasInitCoroutine) || hasCreateIndex
);
}
|
/*
** Check if the program stored in the VM associated with pParse may
** throw an ABORT exception (causing the statement, but not entire transaction
** to be rolled back). This condition is true if the main program or any
** sub-programs contains any of the following:
**
** * OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.
** * OP_Destroy
** * OP_VUpdate
** * OP_VCreate
** * OP_VRename
** * OP_FkCounter with P2==0 (immediate foreign key constraint)
** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine
** (for CREATE TABLE AS SELECT ...)
**
** Then check that the value of Parse.mayAbort is true if an
** ABORT may be thrown, or false otherwise. Return true if it does
** match, or false otherwise. This function is intended to be used as
** part of an assert statement in the compiler. Similar to:
**
** assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L85609-L85661
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
sessionStat1Sql
|
static int sessionStat1Sql(sqlite3 *db, SessionApplyCtx *p){
int rc = sessionSelectRow(db, "sqlite_stat1", p);
if( rc==SQLITE_OK ){
rc = sessionPrepare(db, &p->pInsert,
"INSERT INTO main.sqlite_stat1 VALUES(?1, "
"CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END, "
"?3)"
);
}
if( rc==SQLITE_OK ){
rc = sessionPrepare(db, &p->pDelete,
"DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS "
"CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END "
"AND (?4 OR stat IS ?3)"
);
}
return rc;
}
|
/*
** Prepare statements for applying changes to the sqlite_stat1 table.
** These are similar to those created by sessionSelectRow(),
** sessionInsertRow(), sessionUpdateRow() and sessionDeleteRow() for
** other tables.
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L229415-L229432
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
openvpn-ui
|
github_2023
|
d3vilh
|
c
|
fts5structEofMethod
|
static int fts5structEofMethod(sqlite3_vtab_cursor *cur){
Fts5StructVcsr *pCsr = (Fts5StructVcsr*)cur;
return pCsr->pStruct==0;
}
|
/*
** Return TRUE if the cursor has been moved off of the last
** row of output.
*/
|
https://github.com/d3vilh/openvpn-ui/blob/690f84df426c13ad4742b61fd23e52fcdc489aa0/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c#L249422-L249425
|
690f84df426c13ad4742b61fd23e52fcdc489aa0
|
Project-Alice
|
github_2023
|
schombert
|
c
|
ZSTD_findFrameCompressedSize
|
size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
{
return ZSTD_findFrameCompressedSize_advanced(src, srcSize, ZSTD_f_zstd1);
}
|
/** ZSTD_findFrameCompressedSize() :
* See docs in zstd.h
* Note: compatible with legacy mode */
|
https://github.com/schombert/Project-Alice/blob/ad0c795edf7aab314439dbf68afca7a9a4c24bfb/src/zstd/decompress/zstd_decompress.c#L807-L810
|
ad0c795edf7aab314439dbf68afca7a9a4c24bfb
|
Project-Alice
|
github_2023
|
schombert
|
c
|
ZSTD_resetDStream
|
size_t ZSTD_resetDStream(ZSTD_DStream* dctx)
{
DEBUGLOG(4, "ZSTD_resetDStream");
FORWARD_IF_ERROR(ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only), "");
return ZSTD_startingInputLength(dctx->format);
}
|
/* ZSTD_resetDStream() :
* return : expected size, aka ZSTD_startingInputLength().
* this function cannot fail */
|
https://github.com/schombert/Project-Alice/blob/ad0c795edf7aab314439dbf68afca7a9a4c24bfb/src/zstd/decompress/zstd_decompress.c#L1770-L1775
|
ad0c795edf7aab314439dbf68afca7a9a4c24bfb
|
Project-Alice
|
github_2023
|
schombert
|
c
|
COVER_best_destroy
|
void COVER_best_destroy(COVER_best_t *best) {
if (!best) {
return;
}
COVER_best_wait(best);
if (best->dict) {
free(best->dict);
}
ZSTD_pthread_mutex_destroy(&best->mutex);
ZSTD_pthread_cond_destroy(&best->cond);
}
|
/**
* Call COVER_best_wait() and then destroy the COVER_best_t.
*/
|
https://github.com/schombert/Project-Alice/blob/ad0c795edf7aab314439dbf68afca7a9a4c24bfb/src/zstd/dictBuilder/cover.c#L882-L892
|
ad0c795edf7aab314439dbf68afca7a9a4c24bfb
|
llvmbox
|
github_2023
|
rsms
|
c
|
fts_palloc
|
static int
fts_palloc(FTS *sp, size_t size)
{
char *new;
_DIAGASSERT(sp != NULL);
#ifdef __FTS_COMPAT_LENGTH
/* Protect against fts_pathlen overflow. */
if (size > USHRT_MAX + 1) {
errno = ENAMETOOLONG;
return (1);
}
#endif
size = fts_pow2(size);
new = realloc(sp->fts_path, size);
if (new == 0)
return (1);
sp->fts_path = new;
sp->fts_pathlen = fts_pathlen_truncate(size);
return (0);
}
|
/*
* Allow essentially unlimited paths; find, rm, ls should all work on any tree.
* Most systems will allow creation of paths much longer than MAXPATHLEN, even
* though the kernel won't resolve them. Round up the new size to a power of 2,
* so we don't realloc the path 2 bytes at a time.
*/
|
https://github.com/rsms/llvmbox/blob/45b9a5a62f556bf8ec92899c18091109a14bbe2d/musl-fts/fts.c#L1153-L1174
|
45b9a5a62f556bf8ec92899c18091109a14bbe2d
|
llvmbox
|
github_2023
|
rsms
|
c
|
__eqsf2
|
int __eqsf2(fp_t a, fp_t b) { return __lesf2(a, b); }
|
// The alias mechanism doesn't work on Windows except for MinGW, so emit
// wrapper functions.
|
https://github.com/rsms/llvmbox/blob/45b9a5a62f556bf8ec92899c18091109a14bbe2d/sysroots/compiler-rt/builtins/comparesf2.c#L73-L73
|
45b9a5a62f556bf8ec92899c18091109a14bbe2d
|
llvmbox
|
github_2023
|
rsms
|
c
|
csinhl
|
long double complex csinhl(long double complex z)
{
return csinh(z);
}
|
//FIXME
|
https://github.com/rsms/llvmbox/blob/45b9a5a62f556bf8ec92899c18091109a14bbe2d/sysroots/libc/musl/src/complex/csinhl.c#L4-L7
|
45b9a5a62f556bf8ec92899c18091109a14bbe2d
|
llvmbox
|
github_2023
|
rsms
|
c
|
tre_make_trans
|
static reg_errcode_t
tre_make_trans(tre_pos_and_tags_t *p1, tre_pos_and_tags_t *p2,
tre_tnfa_transition_t *transitions,
int *counts, int *offs)
{
tre_pos_and_tags_t *orig_p2 = p2;
tre_tnfa_transition_t *trans;
int i, j, k, l, dup, prev_p2_pos;
if (transitions != NULL)
while (p1->position >= 0)
{
p2 = orig_p2;
prev_p2_pos = -1;
while (p2->position >= 0)
{
/* Optimization: if this position was already handled, skip it. */
if (p2->position == prev_p2_pos)
{
p2++;
continue;
}
prev_p2_pos = p2->position;
/* Set `trans' to point to the next unused transition from
position `p1->position'. */
trans = transitions + offs[p1->position];
while (trans->state != NULL)
{
#if 0
/* If we find a previous transition from `p1->position' to
`p2->position', it is overwritten. This can happen only
if there are nested loops in the regexp, like in "((a)*)*".
In POSIX.2 repetition using the outer loop is always
preferred over using the inner loop. Therefore the
transition for the inner loop is useless and can be thrown
away. */
/* XXX - The same position is used for all nodes in a bracket
expression, so this optimization cannot be used (it will
break bracket expressions) unless I figure out a way to
detect it here. */
if (trans->state_id == p2->position)
{
break;
}
#endif
trans++;
}
if (trans->state == NULL)
(trans + 1)->state = NULL;
/* Use the character ranges, assertions, etc. from `p1' for
the transition from `p1' to `p2'. */
trans->code_min = p1->code_min;
trans->code_max = p1->code_max;
trans->state = transitions + offs[p2->position];
trans->state_id = p2->position;
trans->assertions = p1->assertions | p2->assertions
| (p1->class ? ASSERT_CHAR_CLASS : 0)
| (p1->neg_classes != NULL ? ASSERT_CHAR_CLASS_NEG : 0);
if (p1->backref >= 0)
{
assert((trans->assertions & ASSERT_CHAR_CLASS) == 0);
assert(p2->backref < 0);
trans->u.backref = p1->backref;
trans->assertions |= ASSERT_BACKREF;
}
else
trans->u.class = p1->class;
if (p1->neg_classes != NULL)
{
for (i = 0; p1->neg_classes[i] != (tre_ctype_t)0; i++);
trans->neg_classes =
xmalloc(sizeof(*trans->neg_classes) * (i + 1));
if (trans->neg_classes == NULL)
return REG_ESPACE;
for (i = 0; p1->neg_classes[i] != (tre_ctype_t)0; i++)
trans->neg_classes[i] = p1->neg_classes[i];
trans->neg_classes[i] = (tre_ctype_t)0;
}
else
trans->neg_classes = NULL;
/* Find out how many tags this transition has. */
i = 0;
if (p1->tags != NULL)
while(p1->tags[i] >= 0)
i++;
j = 0;
if (p2->tags != NULL)
while(p2->tags[j] >= 0)
j++;
/* If we are overwriting a transition, free the old tag array. */
if (trans->tags != NULL)
xfree(trans->tags);
trans->tags = NULL;
/* If there were any tags, allocate an array and fill it. */
if (i + j > 0)
{
trans->tags = xmalloc(sizeof(*trans->tags) * (i + j + 1));
if (!trans->tags)
return REG_ESPACE;
i = 0;
if (p1->tags != NULL)
while(p1->tags[i] >= 0)
{
trans->tags[i] = p1->tags[i];
i++;
}
l = i;
j = 0;
if (p2->tags != NULL)
while (p2->tags[j] >= 0)
{
/* Don't add duplicates. */
dup = 0;
for (k = 0; k < i; k++)
if (trans->tags[k] == p2->tags[j])
{
dup = 1;
break;
}
if (!dup)
trans->tags[l++] = p2->tags[j];
j++;
}
trans->tags[l] = -1;
}
p2++;
}
p1++;
}
else
/* Compute a maximum limit for the number of transitions leaving
from each state. */
while (p1->position >= 0)
{
p2 = orig_p2;
while (p2->position >= 0)
{
counts[p1->position]++;
p2++;
}
p1++;
}
return REG_OK;
}
|
/* Adds a transition from each position in `p1' to each position in `p2'. */
|
https://github.com/rsms/llvmbox/blob/45b9a5a62f556bf8ec92899c18091109a14bbe2d/sysroots/libc/musl/src/regex/regcomp.c#L2469-L2617
|
45b9a5a62f556bf8ec92899c18091109a14bbe2d
|
Flipper-Zero-RogueMaster-Firmware
|
github_2023
|
Kaliroot10
|
c
|
getRandomMove
|
Move getRandomMove(Position* position) {
Move moves[MAX_BRANCHING_FACTOR];
int totalMoves = legalMoves(moves, position, position->toMove);
int chosenMove = rand() % totalMoves;
return moves[chosenMove];
}
|
/* _WIN32 */
|
https://github.com/Kaliroot10/Flipper-Zero-RogueMaster-Firmware/blob/f8b6725eac77eb4c833293d2c3be0b89a8a1678f/applications/plugins/.chess/fast_chess.c#L2806-L2811
|
f8b6725eac77eb4c833293d2c3be0b89a8a1678f
|
Flipper-Zero-RogueMaster-Firmware
|
github_2023
|
Kaliroot10
|
c
|
rfalNfcDepPSL
|
ReturnCode rfalNfcDepPSL(uint8_t BRS, uint8_t FSL) {
ReturnCode ret;
uint16_t rxLen;
uint8_t msgIt;
uint8_t txBuf[NFCIP_PSLREQ_LEN + NFCIP_PSLPAY_LEN];
uint8_t rxBuf[NFCIP_PSLRES_LEN];
msgIt = NFCIP_PSLREQ_LEN;
txBuf[msgIt++] = BRS;
txBuf[msgIt++] = FSL;
/*******************************************************************************/
/* Send PSL REQ and wait for response */
/*******************************************************************************/
EXIT_ON_ERR(
ret,
nfcipTxRx(
NFCIP_CMD_PSL_REQ,
txBuf,
nfcipRWTActivation(),
&txBuf[NFCIP_PSLREQ_LEN],
(msgIt - NFCIP_PSLREQ_LEN),
rxBuf,
NFCIP_PSLRES_LEN,
&rxLen));
/*******************************************************************************/
/* PSL sent, check response */
/*******************************************************************************/
msgIt = 0;
rxLen = (uint16_t)(rxBuf[msgIt++]); /* use LEN byte */
if(rxLen < NFCIP_PSLRES_LEN) /* Checking length: LEN + RLS_RES */
{
return ERR_PROTO;
}
if(rxBuf[msgIt++] != NFCIP_RES) /* Checking if is a response */
{
return ERR_PROTO;
}
if(rxBuf[msgIt++] != (uint8_t)NFCIP_CMD_PSL_RES) /* Checking if is a PSL RES */
{
return ERR_PROTO;
}
if(rxBuf[msgIt++] != gNfcip.cfg.did) /* Checking DID */
{
return ERR_PROTO;
}
return ERR_NONE;
}
|
/*******************************************************************************/
|
https://github.com/Kaliroot10/Flipper-Zero-RogueMaster-Firmware/blob/f8b6725eac77eb4c833293d2c3be0b89a8a1678f/lib/ST25RFAL002/source/rfal_nfcDep.c#L2078-L2132
|
f8b6725eac77eb4c833293d2c3be0b89a8a1678f
|
Flipper-Zero-RogueMaster-Firmware
|
github_2023
|
Kaliroot10
|
c
|
rfalST25xVPollerGetRandomNumber
|
ReturnCode rfalST25xVPollerGetRandomNumber(
uint8_t flags,
const uint8_t* uid,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
rfalFieldOff();
platformDelay(RFAL_ST25TV02K_TRF_OFF);
rfalNfcvPollerInitialize();
rfalFieldOnAndStartGT();
platformDelay(RFAL_ST25TV02K_TBOOT_RF);
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_GET_RANDOM_NUMBER,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
NULL,
0U,
rxBuf,
rxBufLen,
rcvLen);
}
|
/*******************************************************************************/
|
https://github.com/Kaliroot10/Flipper-Zero-RogueMaster-Firmware/blob/f8b6725eac77eb4c833293d2c3be0b89a8a1678f/lib/ST25RFAL002/source/rfal_st25xv.c#L733-L754
|
f8b6725eac77eb4c833293d2c3be0b89a8a1678f
|
Flipper-Zero-RogueMaster-Firmware
|
github_2023
|
Kaliroot10
|
c
|
rfalTransceiveRunBlockingTx
|
static ReturnCode rfalTransceiveRunBlockingTx(void) {
ReturnCode ret;
do {
rfalWorker();
ret = rfalGetTransceiveStatus();
} while(rfalIsTransceiveInTx() && (ret == ERR_BUSY));
if(rfalIsTransceiveInRx()) {
return ERR_NONE;
}
return ret;
}
|
/*******************************************************************************/
|
https://github.com/Kaliroot10/Flipper-Zero-RogueMaster-Firmware/blob/f8b6725eac77eb4c833293d2c3be0b89a8a1678f/lib/ST25RFAL002/source/st25r3916/rfal_rfst25r3916.c#L1560-L1573
|
f8b6725eac77eb4c833293d2c3be0b89a8a1678f
|
Flipper-Zero-RogueMaster-Firmware
|
github_2023
|
Kaliroot10
|
c
|
u8g2_SetupBuffer
|
void u8g2_SetupBuffer(
u8g2_t* u8g2,
uint8_t* buf,
uint8_t tile_buf_height,
u8g2_draw_ll_hvline_cb ll_hvline_cb,
const u8g2_cb_t* u8g2_cb) {
u8g2->font = NULL;
//u8g2->kerning = NULL;
//u8g2->get_kerning_cb = u8g2_GetNullKerning;
//u8g2->ll_hvline = u8g2_ll_hvline_vertical_top_lsb;
u8g2->ll_hvline = ll_hvline_cb;
u8g2->tile_buf_ptr = buf;
u8g2->tile_buf_height = tile_buf_height;
u8g2->tile_curr_row = 0;
u8g2->font_decode.is_transparent = 0; /* issue 443 */
u8g2->bitmap_transparency = 0;
u8g2->draw_color = 1;
u8g2->is_auto_page_clear = 1;
u8g2->cb = u8g2_cb;
u8g2->cb->update_dimension(u8g2);
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */
#else
u8g2->cb->update_page_win(u8g2);
#endif
u8g2_SetFontPosBaseline(u8g2); /* issue 195 */
#ifdef U8G2_WITH_FONT_ROTATION
u8g2->font_decode.dir = 0;
#endif
}
|
/*============================================*/
/*
This procedure is called after setting up the display (u8x8 structure).
--> This is the central init procedure for u8g2 object
*/
|
https://github.com/Kaliroot10/Flipper-Zero-RogueMaster-Firmware/blob/f8b6725eac77eb4c833293d2c3be0b89a8a1678f/lib/u8g2/u8g2_setup.c#L72-L109
|
f8b6725eac77eb4c833293d2c3be0b89a8a1678f
|
PaxOS-8
|
github_2023
|
paxo-phone
|
c
|
iscleared
|
static int iscleared (global_State *g, const GCObject *o) {
if (o == NULL) return 0; /* non-collectable value */
else if (novariant(o->tt) == LUA_TSTRING) {
markobject(g, o); /* strings are 'values', so are never weak */
return 0;
}
else return iswhite(o);
}
|
/*
** tells whether a key or value can be cleared from a weak
** table. Non-collectable objects are never removed from weak
** tables. Strings behave as 'values', so are never removed too. for
** other objects: if really collected, cannot keep them; for objects
** being finalized, keep them in keys, but not in values
*/
|
https://github.com/paxo-phone/PaxOS-8/blob/ffa7fcb96f42632a2d6d61e7137d53bf809e673a/src/lib/lua/lgc.c#L185-L192
|
ffa7fcb96f42632a2d6d61e7137d53bf809e673a
|
PaxOS-8
|
github_2023
|
paxo-phone
|
c
|
traverseLclosure
|
static int traverseLclosure (global_State *g, LClosure *cl) {
int i;
markobjectN(g, cl->p); /* mark its prototype */
for (i = 0; i < cl->nupvalues; i++) { /* visit its upvalues */
UpVal *uv = cl->upvals[i];
markobjectN(g, uv); /* mark upvalue */
}
return 1 + cl->nupvalues;
}
|
/*
** Traverse a Lua closure, marking its prototype and its upvalues.
** (Both can be NULL while closure is being created.)
*/
|
https://github.com/paxo-phone/PaxOS-8/blob/ffa7fcb96f42632a2d6d61e7137d53bf809e673a/src/lib/lua/lgc.c#L604-L612
|
ffa7fcb96f42632a2d6d61e7137d53bf809e673a
|
PaxOS-8
|
github_2023
|
paxo-phone
|
c
|
report
|
static int report (lua_State *L, int status) {
if (status != LUA_OK) {
const char *msg = lua_tostring(L, -1);
l_message(progname, msg);
lua_pop(L, 1); /* remove message */
}
return status;
}
|
/*
** Check whether 'status' is not OK and, if so, prints the error
** message on the top of the stack. It assumes that the error object
** is a string, as it was either generated by Lua or by 'msghandler'.
*/
|
https://github.com/paxo-phone/PaxOS-8/blob/ffa7fcb96f42632a2d6d61e7137d53bf809e673a/src/lib/lua/lua.c#L121-L128
|
ffa7fcb96f42632a2d6d61e7137d53bf809e673a
|
GateEngine
|
github_2023
|
STREGAsGate
|
c
|
vorbis_analysis_wrote
|
int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){
vorbis_info *vi=v->vi;
codec_setup_info *ci=vi->codec_setup;
if(vals<=0){
int order=32;
int i;
float *lpc=alloca(order*sizeof(*lpc));
/* if it wasn't done earlier (very short sample) */
if(!v->preextrapolate)
_preextrapolate_helper(v);
/* We're encoding the end of the stream. Just make sure we have
[at least] a few full blocks of zeroes at the end. */
/* actually, we don't want zeroes; that could drop a large
amplitude off a cliff, creating spread spectrum noise that will
suck to encode. Extrapolate for the sake of cleanliness. */
vorbis_analysis_buffer(v,ci->blocksizes[1]*3);
v->eofflag=v->pcm_current;
v->pcm_current+=ci->blocksizes[1]*3;
for(i=0;i<vi->channels;i++){
if(v->eofflag>order*2){
/* extrapolate with LPC to fill in */
long n;
/* make a predictor filter */
n=v->eofflag;
if(n>ci->blocksizes[1])n=ci->blocksizes[1];
vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order);
/* run the predictor filter */
vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order,
v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag);
}else{
/* not enough data to extrapolate (unlikely to happen due to
guarding the overlap, but bulletproof in case that
assumtion goes away). zeroes will do. */
memset(v->pcm[i]+v->eofflag,0,
(v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
}
}
}else{
if(v->pcm_current+vals>v->pcm_storage)
return(OV_EINVAL);
v->pcm_current+=vals;
/* we may want to reverse extrapolate the beginning of a stream
too... in case we're beginning on a cliff! */
/* clumsy, but simple. It only runs once, so simple is good. */
if(!v->preextrapolate && v->pcm_current-v->centerW>ci->blocksizes[1])
_preextrapolate_helper(v);
}
return(0);
}
|
/* call with val<=0 to set eof */
|
https://github.com/STREGAsGate/GateEngine/blob/f755456c313b7e1b8686fd6fd599c29fcc732d64/Dependencies/Vorbis/block.c#L460-L520
|
f755456c313b7e1b8686fd6fd599c29fcc732d64
|
bread
|
github_2023
|
Theldus
|
c
|
handle_gdb_write_register
|
static int handle_gdb_write_register(const char *buff, size_t len)
{
uint32_t reg_num_gdb, reg_num_rm;
const char *ptr, *dec;
union minibuf value;
static const int gdb_to_rm[] =
/* EAX. */ /* GS. */
{7,6,5,4,3,2,1,0,13,15,14,12,11,10,9,8};
ptr = buff;
expect_char('P', ptr, len);
reg_num_gdb = read_int(ptr, &len, &ptr, 16);
expect_char('=', ptr, len);
dec = decode_hex(ptr, 4);
memcpy(&value, dec, 4);
/* Validate register. */
if (reg_num_gdb >= 16)
{
send_gdb_error();
return (-1);
}
reg_num_rm = gdb_to_rm[reg_num_gdb];
/*
* Validate value: 16-bit registers should not
* receive values greater than 16-bit =)
*/
if (reg_num_rm >= 8 && value.b32 > ((1<<16)-1))
{
send_gdb_error();
return (-1);
}
/* Update our 'cache'. */
x86_regs.r32[reg_num_gdb] = value.b32;
/* Send to our serial device. */
send_serial_byte(SERIAL_STATE_REG_WRITE);
send_serial_byte(reg_num_rm);
send_serial_dword(value.b32);
return (0);
}
|
/**
* @brief Handles the 'write register (P)' GDB command;
*
* Please note the the segment registers and EIP,EFLAGS
* are 16-bit. An attempt to write a 32-bit value on them
* will emit an error.
*
* Also note that the mapping from what we receive from
* the serial device and the mapping expected by GDB
* differs, so there is a need to a conversion.
*
* @param buff Buffer to be parsed.
* @param len Buffer length.
*
* @return Returns 0 if the command is valid, -1 otherwise.
*/
|
https://github.com/Theldus/bread/blob/c4bb9efcae563481c31fa865b64e230d9888e627/gdb.c#L658-L704
|
c4bb9efcae563481c31fa865b64e230d9888e627
|
Hanshow-Auto-Updater
|
github_2023
|
MakersFunDuck
|
c
|
xTaskCheckForTimeOut
|
BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait )
{
BaseType_t xReturn;
configASSERT( pxTimeOut );
configASSERT( pxTicksToWait );
taskENTER_CRITICAL();
{
/* Minor optimisation. The tick count cannot change in this block. */
const TickType_t xConstTickCount = xTickCount;
const TickType_t xElapsedTime = xConstTickCount - pxTimeOut->xTimeOnEntering;
#if( INCLUDE_xTaskAbortDelay == 1 )
if( pxCurrentTCB->ucDelayAborted != ( uint8_t ) pdFALSE )
{
/* The delay was aborted, which is not the same as a time out,
but has the same result. */
pxCurrentTCB->ucDelayAborted = pdFALSE;
xReturn = pdTRUE;
}
else
#endif
#if ( INCLUDE_vTaskSuspend == 1 )
if( *pxTicksToWait == portMAX_DELAY )
{
/* If INCLUDE_vTaskSuspend is set to 1 and the block time
specified is the maximum block time then the task should block
indefinitely, and therefore never time out. */
xReturn = pdFALSE;
}
else
#endif
if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */
{
/* The tick count is greater than the time at which
vTaskSetTimeout() was called, but has also overflowed since
vTaskSetTimeOut() was called. It must have wrapped all the way
around and gone past again. This passed since vTaskSetTimeout()
was called. */
xReturn = pdTRUE;
}
else if( xElapsedTime < *pxTicksToWait ) /*lint !e961 Explicit casting is only redundant with some compilers, whereas others require it to prevent integer conversion errors. */
{
/* Not a genuine timeout. Adjust parameters for time remaining. */
*pxTicksToWait -= xElapsedTime;
vTaskInternalSetTimeOutState( pxTimeOut );
xReturn = pdFALSE;
}
else
{
*pxTicksToWait = 0;
xReturn = pdTRUE;
}
}
taskEXIT_CRITICAL();
return xReturn;
}
|
/*-----------------------------------------------------------*/
|
https://github.com/MakersFunDuck/Hanshow-Auto-Updater/blob/69306b53088f38eb913f933f63fce38946124457/ATC_TLSR_Paper-/Firmware/components/freertos/tasks.c#L3169-L3229
|
69306b53088f38eb913f933f63fce38946124457
|
Hanshow-Auto-Updater
|
github_2023
|
MakersFunDuck
|
c
|
MPU_xEventGroupSync
|
EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )
{
EventBits_t xReturn;
BaseType_t xRunningPrivileged = xPortRaisePrivilege();
xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
vPortResetPrivilege( xRunningPrivileged );
return xReturn;
}
|
/*-----------------------------------------------------------*/
|
https://github.com/MakersFunDuck/Hanshow-Auto-Updater/blob/69306b53088f38eb913f933f63fce38946124457/ATC_TLSR_Paper-/Firmware/components/freertos/portable/Common/mpu_wrappers.c#L1094-L1103
|
69306b53088f38eb913f933f63fce38946124457
|
WinDiskWriter
|
github_2023
|
TechUnRestricted
|
c
|
wimlib_export_image
|
WIMLIBAPI int
wimlib_export_image(WIMStruct *src_wim,
int src_image,
WIMStruct *dest_wim,
const tchar *dest_name,
const tchar *dest_description,
int export_flags)
{
int ret;
int start_src_image;
int end_src_image;
int orig_dest_image_count;
int image;
bool all_images = (src_image == WIMLIB_ALL_IMAGES);
/* Check for sane parameters. */
if (export_flags & ~(WIMLIB_EXPORT_FLAG_BOOT |
WIMLIB_EXPORT_FLAG_NO_NAMES |
WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS |
WIMLIB_EXPORT_FLAG_GIFT |
WIMLIB_EXPORT_FLAG_WIMBOOT))
return WIMLIB_ERR_INVALID_PARAM;
if (!src_wim || !dest_wim)
return WIMLIB_ERR_INVALID_PARAM;
if (!wim_has_metadata(src_wim) || !wim_has_metadata(dest_wim))
return WIMLIB_ERR_METADATA_NOT_FOUND;
if (all_images) {
/* Multi-image export. */
if ((!(export_flags & WIMLIB_EXPORT_FLAG_NO_NAMES) &&
dest_name) ||
(!(export_flags & WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS) &&
dest_description))
{
ERROR("Image name and description must be "
"left NULL for multi-image export");
return WIMLIB_ERR_INVALID_PARAM;
}
start_src_image = 1;
end_src_image = src_wim->hdr.image_count;
} else {
start_src_image = src_image;
end_src_image = src_image;
}
orig_dest_image_count = dest_wim->hdr.image_count;
/* We don't yet support having a single WIMStruct contain duplicate
* 'image_metadata' structures, so we must forbid this from happening.
* A duplication is possible if 'src_wim == dest_wim', if the same image
* is exported to the same destination WIMStruct multiple times, or if
* an image is exported in an A => B => A manner. */
for (src_image = start_src_image;
src_image <= end_src_image; src_image++)
{
const struct wim_image_metadata *src_imd =
src_wim->image_metadata[src_image - 1];
for (int i = 0; i < dest_wim->hdr.image_count; i++)
if (dest_wim->image_metadata[i] == src_imd)
return WIMLIB_ERR_DUPLICATE_EXPORTED_IMAGE;
}
/* Blob checksums must be known before proceeding. */
ret = wim_checksum_unhashed_blobs(src_wim);
if (ret)
return ret;
ret = wim_checksum_unhashed_blobs(dest_wim);
if (ret)
return ret;
/* Enable rollbacks */
for_blob_in_table(dest_wim->blob_table, blob_set_not_exported, NULL);
/* Forbid exports where the destination WIM already contains image(s)
* with the requested name(s). However, allow multi-image exports where
* there is a duplication among the source names only. */
if (!(export_flags & WIMLIB_EXPORT_FLAG_NO_NAMES)) {
for (src_image = start_src_image;
src_image <= end_src_image;
src_image++)
{
const tchar *name = dest_name ? dest_name :
wimlib_get_image_name(src_wim, src_image);
if (wimlib_image_name_in_use(dest_wim, name)) {
ERROR("There is already an image named \"%"TS"\" "
"in the destination WIM", name);
ret = WIMLIB_ERR_IMAGE_NAME_COLLISION;
goto out_rollback;
}
}
}
/* Export each requested image. */
for (src_image = start_src_image;
src_image <= end_src_image;
src_image++)
{
const tchar *next_dest_name, *next_dest_description;
struct wim_image_metadata *src_imd;
struct wim_inode *inode;
/* Determine destination image name and description. */
if (export_flags & WIMLIB_EXPORT_FLAG_NO_NAMES)
next_dest_name = NULL;
else if (dest_name)
next_dest_name = dest_name;
else
next_dest_name = wimlib_get_image_name(src_wim, src_image);
if (export_flags & WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS)
next_dest_description = NULL;
else if (dest_description)
next_dest_description = dest_description;
else
next_dest_description = wimlib_get_image_description(src_wim, src_image);
/* Load metadata for source image into memory. */
ret = select_wim_image(src_wim, src_image);
if (ret)
goto out_rollback;
src_imd = wim_get_current_image_metadata(src_wim);
/* Iterate through inodes in the source image and export their
* blobs into the destination WIM. */
image_for_each_inode(inode, src_imd) {
ret = inode_export_blobs(inode,
src_wim->blob_table,
dest_wim->blob_table,
export_flags & WIMLIB_EXPORT_FLAG_GIFT);
if (ret)
goto out_rollback;
}
/* Export XML information into the destination WIM. */
ret = xml_export_image(src_wim->xml_info, src_image,
dest_wim->xml_info, next_dest_name,
next_dest_description,
export_flags & WIMLIB_EXPORT_FLAG_WIMBOOT);
if (ret)
goto out_rollback;
/* Reference the source image metadata from the destination WIM.
*/
ret = append_image_metadata(dest_wim, src_imd);
if (ret)
goto out_rollback;
src_imd->refcnt++;
}
/* Image export complete. Finish by setting any needed special metadata
* on the destination WIM. */
if (src_wim->hdr.flags & WIM_HDR_FLAG_RP_FIX)
dest_wim->hdr.flags |= WIM_HDR_FLAG_RP_FIX;
for (src_image = start_src_image;
src_image <= end_src_image;
src_image++)
{
int dst_image = orig_dest_image_count + 1 +
(src_image - start_src_image);
if ((export_flags & WIMLIB_EXPORT_FLAG_BOOT) &&
(!all_images || src_image == src_wim->hdr.boot_idx))
dest_wim->hdr.boot_idx = dst_image;
}
return 0;
out_rollback:
while ((image = xml_get_image_count(dest_wim->xml_info))
> orig_dest_image_count)
{
xml_delete_image(dest_wim->xml_info, image);
}
while (dest_wim->hdr.image_count > orig_dest_image_count)
{
put_image_metadata(dest_wim->image_metadata[
--dest_wim->hdr.image_count]);
}
for_blob_in_table(dest_wim->blob_table, blob_rollback_export,
dest_wim->blob_table);
return ret;
}
|
/* API function documented in wimlib.h */
|
https://github.com/TechUnRestricted/WinDiskWriter/blob/86a003b84ecf0e3e4edd315b202eca3f01c6c0cc/WinDiskWriter/libs/wimlib/src/export_image.c#L108-L295
|
86a003b84ecf0e3e4edd315b202eca3f01c6c0cc
|
WinDiskWriter
|
github_2023
|
TechUnRestricted
|
c
|
lzms_remove_bits
|
static forceinline void
lzms_remove_bits(struct lzms_input_bitstream *is, unsigned num_bits)
{
is->bitbuf <<= num_bits;
is->bitsleft -= num_bits;
}
|
/* Remove @num_bits bits from the bitbuffer variable. */
|
https://github.com/TechUnRestricted/WinDiskWriter/blob/86a003b84ecf0e3e4edd315b202eca3f01c6c0cc/WinDiskWriter/libs/wimlib/src/lzms_decompress.c#L418-L423
|
86a003b84ecf0e3e4edd315b202eca3f01c6c0cc
|
WinDiskWriter
|
github_2023
|
TechUnRestricted
|
c
|
extract_encrypted_file
|
static int
extract_encrypted_file(const struct wim_dentry *dentry,
struct win32_apply_ctx *ctx)
{
void *rawctx;
DWORD err;
ULONG flags;
bool retried;
/* Temporarily build a Win32 path for OpenEncryptedFileRaw() */
build_win32_extraction_path(dentry, ctx);
flags = CREATE_FOR_IMPORT | OVERWRITE_HIDDEN;
if (dentry->d_inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY)
flags |= CREATE_FOR_DIR;
retried = false;
retry:
err = OpenEncryptedFileRaw(ctx->pathbuf.Buffer, flags, &rawctx);
if (err == ERROR_SHARING_VIOLATION && !retried) {
/* This can be caused by the handle we have open to the target
* directory. Try closing it temporarily. */
close_target_directory(ctx);
retried = true;
goto retry;
}
/* Restore the NT namespace path */
build_extraction_path(dentry, ctx);
if (err != ERROR_SUCCESS) {
win32_error(err, L"Can't open \"%ls\" for encrypted import",
current_path(ctx));
return WIMLIB_ERR_OPEN;
}
ctx->encrypted_offset = 0;
err = WriteEncryptedFileRaw(import_encrypted_data, ctx, rawctx);
CloseEncryptedFileRaw(rawctx);
if (err != ERROR_SUCCESS) {
win32_error(err, L"Can't import encrypted file \"%ls\"",
current_path(ctx));
return WIMLIB_ERR_WRITE;
}
return 0;
}
|
/*
* Write the raw encrypted data to the already-created file (or directory)
* corresponding to @dentry.
*
* The raw encrypted data is provided in ctx->data_buffer, and its size is
* ctx->encrypted_size.
*
* This function may close the target directory, in which case the caller needs
* to re-open it if needed.
*/
|
https://github.com/TechUnRestricted/WinDiskWriter/blob/86a003b84ecf0e3e4edd315b202eca3f01c6c0cc/WinDiskWriter/libs/wimlib/src/win32_apply.c#L2264-L2313
|
86a003b84ecf0e3e4edd315b202eca3f01c6c0cc
|
WinDiskWriter
|
github_2023
|
TechUnRestricted
|
c
|
generate_random_sid
|
static size_t
generate_random_sid(wimlib_SID *sid, struct generation_context *ctx)
{
u32 r = rand32();
sid->revision = 1;
if (r & 1) {
/* Common SID */
r = (r >> 1) % ARRAY_LEN(common_sids);
sid->sub_authority_count = common_sids[r].num_subauthorities;
for (int i = 0; i < 6; i++) {
sid->identifier_authority[i] =
common_sids[r].identifier_authority >> (40 - i * 8);
}
for (int i = 0; i < common_sids[r].num_subauthorities; i++)
sid->sub_authority[i] = cpu_to_le32(common_sids[r].subauthorities[i]);
} else {
/* Random SID */
sid->sub_authority_count = 1 + ((r >> 1) % 15);
for (int i = 0; i < 6; i++)
sid->identifier_authority[i] = rand8();
for (int i = 0; i < sid->sub_authority_count; i++)
sid->sub_authority[i] = cpu_to_le32(rand32());
}
return (u8 *)&sid->sub_authority[sid->sub_authority_count] - (u8 *)sid;
}
|
/* Generate a SID and return its size in bytes. */
|
https://github.com/TechUnRestricted/WinDiskWriter/blob/86a003b84ecf0e3e4edd315b202eca3f01c6c0cc/WinDiskWriter/libs/wimlib/src/test_support/test_support.c#L270-L300
|
86a003b84ecf0e3e4edd315b202eca3f01c6c0cc
|
rebar
|
github_2023
|
BurntSushi
|
c
|
show_parsed
|
static void show_parsed(compile_block *cb)
{
uint32_t *pptr = cb->parsed_pattern;
for (;;)
{
int max, min;
PCRE2_SIZE offset;
uint32_t i;
uint32_t length;
uint32_t meta_arg = META_DATA(*pptr);
fprintf(stderr, "+++ %02d %.8x ", (int)(pptr - cb->parsed_pattern), *pptr);
if (*pptr < META_END)
{
if (*pptr > 32 && *pptr < 128) fprintf(stderr, "%c", *pptr);
pptr++;
}
else switch (META_CODE(*pptr++))
{
default:
fprintf(stderr, "**** OOPS - unknown META value - giving up ****\n");
return;
case META_END:
fprintf(stderr, "META_END\n");
return;
case META_CAPTURE:
fprintf(stderr, "META_CAPTURE %d", meta_arg);
break;
case META_RECURSE:
GETOFFSET(offset, pptr);
fprintf(stderr, "META_RECURSE %d %zd", meta_arg, offset);
break;
case META_BACKREF:
if (meta_arg < 10)
offset = cb->small_ref_offset[meta_arg];
else
GETOFFSET(offset, pptr);
fprintf(stderr, "META_BACKREF %d %zd", meta_arg, offset);
break;
case META_ESCAPE:
if (meta_arg == ESC_P || meta_arg == ESC_p)
{
uint32_t ptype = *pptr >> 16;
uint32_t pvalue = *pptr++ & 0xffff;
fprintf(stderr, "META \\%c %d %d", (meta_arg == ESC_P)? 'P':'p',
ptype, pvalue);
}
else
{
uint32_t cc;
/* There's just one escape we might have here that isn't negated in the
escapes table. */
if (meta_arg == ESC_g) cc = CHAR_g;
else for (cc = ESCAPES_FIRST; cc <= ESCAPES_LAST; cc++)
{
if (meta_arg == (uint32_t)(-escapes[cc - ESCAPES_FIRST])) break;
}
if (cc > ESCAPES_LAST) cc = CHAR_QUESTION_MARK;
fprintf(stderr, "META \\%c", cc);
}
break;
case META_MINMAX:
min = *pptr++;
max = *pptr++;
if (max != REPEAT_UNLIMITED)
fprintf(stderr, "META {%d,%d}", min, max);
else
fprintf(stderr, "META {%d,}", min);
break;
case META_MINMAX_QUERY:
min = *pptr++;
max = *pptr++;
if (max != REPEAT_UNLIMITED)
fprintf(stderr, "META {%d,%d}?", min, max);
else
fprintf(stderr, "META {%d,}?", min);
break;
case META_MINMAX_PLUS:
min = *pptr++;
max = *pptr++;
if (max != REPEAT_UNLIMITED)
fprintf(stderr, "META {%d,%d}+", min, max);
else
fprintf(stderr, "META {%d,}+", min);
break;
case META_BIGVALUE: fprintf(stderr, "META_BIGVALUE %.8x", *pptr++); break;
case META_CIRCUMFLEX: fprintf(stderr, "META_CIRCUMFLEX"); break;
case META_COND_ASSERT: fprintf(stderr, "META_COND_ASSERT"); break;
case META_DOLLAR: fprintf(stderr, "META_DOLLAR"); break;
case META_DOT: fprintf(stderr, "META_DOT"); break;
case META_ASTERISK: fprintf(stderr, "META *"); break;
case META_ASTERISK_QUERY: fprintf(stderr, "META *?"); break;
case META_ASTERISK_PLUS: fprintf(stderr, "META *+"); break;
case META_PLUS: fprintf(stderr, "META +"); break;
case META_PLUS_QUERY: fprintf(stderr, "META +?"); break;
case META_PLUS_PLUS: fprintf(stderr, "META ++"); break;
case META_QUERY: fprintf(stderr, "META ?"); break;
case META_QUERY_QUERY: fprintf(stderr, "META ??"); break;
case META_QUERY_PLUS: fprintf(stderr, "META ?+"); break;
case META_ATOMIC: fprintf(stderr, "META (?>"); break;
case META_NOCAPTURE: fprintf(stderr, "META (?:"); break;
case META_LOOKAHEAD: fprintf(stderr, "META (?="); break;
case META_LOOKAHEADNOT: fprintf(stderr, "META (?!"); break;
case META_LOOKAHEAD_NA: fprintf(stderr, "META (*napla:"); break;
case META_SCRIPT_RUN: fprintf(stderr, "META (*sr:"); break;
case META_KET: fprintf(stderr, "META )"); break;
case META_ALT: fprintf(stderr, "META | %d", meta_arg); break;
case META_CLASS: fprintf(stderr, "META ["); break;
case META_CLASS_NOT: fprintf(stderr, "META [^"); break;
case META_CLASS_END: fprintf(stderr, "META ]"); break;
case META_CLASS_EMPTY: fprintf(stderr, "META []"); break;
case META_CLASS_EMPTY_NOT: fprintf(stderr, "META [^]"); break;
case META_RANGE_LITERAL: fprintf(stderr, "META - (literal)"); break;
case META_RANGE_ESCAPED: fprintf(stderr, "META - (escaped)"); break;
case META_POSIX: fprintf(stderr, "META_POSIX %d", *pptr++); break;
case META_POSIX_NEG: fprintf(stderr, "META_POSIX_NEG %d", *pptr++); break;
case META_ACCEPT: fprintf(stderr, "META (*ACCEPT)"); break;
case META_FAIL: fprintf(stderr, "META (*FAIL)"); break;
case META_COMMIT: fprintf(stderr, "META (*COMMIT)"); break;
case META_PRUNE: fprintf(stderr, "META (*PRUNE)"); break;
case META_SKIP: fprintf(stderr, "META (*SKIP)"); break;
case META_THEN: fprintf(stderr, "META (*THEN)"); break;
case META_OPTIONS: fprintf(stderr, "META_OPTIONS 0x%02x", *pptr++); break;
case META_LOOKBEHIND:
fprintf(stderr, "META (?<= %d offset=", meta_arg);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_LOOKBEHIND_NA:
fprintf(stderr, "META (*naplb: %d offset=", meta_arg);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_LOOKBEHINDNOT:
fprintf(stderr, "META (?<! %d offset=", meta_arg);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_CALLOUT_NUMBER:
fprintf(stderr, "META (?C%d) next=%d/%d", pptr[2], pptr[0],
pptr[1]);
pptr += 3;
break;
case META_CALLOUT_STRING:
{
uint32_t patoffset = *pptr++; /* Offset of next pattern item */
uint32_t patlength = *pptr++; /* Length of next pattern item */
fprintf(stderr, "META (?Cstring) length=%d offset=", *pptr++);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd next=%d/%d", offset, patoffset, patlength);
}
break;
case META_RECURSE_BYNAME:
fprintf(stderr, "META (?(&name) length=%d offset=", *pptr++);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_BACKREF_BYNAME:
fprintf(stderr, "META_BACKREF_BYNAME length=%d offset=", *pptr++);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_COND_NUMBER:
fprintf(stderr, "META_COND_NUMBER %d offset=", pptr[SIZEOFFSET]);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
pptr++;
break;
case META_COND_DEFINE:
fprintf(stderr, "META (?(DEFINE) offset=");
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_COND_VERSION:
fprintf(stderr, "META (?(VERSION%s", (*pptr++ == 0)? "=" : ">=");
fprintf(stderr, "%d.", *pptr++);
fprintf(stderr, "%d)", *pptr++);
break;
case META_COND_NAME:
fprintf(stderr, "META (?(<name>) length=%d offset=", *pptr++);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_COND_RNAME:
fprintf(stderr, "META (?(R&name) length=%d offset=", *pptr++);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
/* This is kept as a name, because it might be. */
case META_COND_RNUMBER:
fprintf(stderr, "META (?(Rnumber) length=%d offset=", *pptr++);
GETOFFSET(offset, pptr);
fprintf(stderr, "%zd", offset);
break;
case META_MARK:
fprintf(stderr, "META (*MARK:");
goto SHOWARG;
case META_COMMIT_ARG:
fprintf(stderr, "META (*COMMIT:");
goto SHOWARG;
case META_PRUNE_ARG:
fprintf(stderr, "META (*PRUNE:");
goto SHOWARG;
case META_SKIP_ARG:
fprintf(stderr, "META (*SKIP:");
goto SHOWARG;
case META_THEN_ARG:
fprintf(stderr, "META (*THEN:");
SHOWARG:
length = *pptr++;
for (i = 0; i < length; i++)
{
uint32_t cc = *pptr++;
if (cc > 32 && cc < 128) fprintf(stderr, "%c", cc);
else fprintf(stderr, "\\x{%x}", cc);
}
fprintf(stderr, ") length=%u", length);
break;
}
fprintf(stderr, "\n");
}
return;
}
|
/*************************************************
* Show the parsed pattern for debugging *
*************************************************/
/* For debugging the pre-scan, this code, which outputs the parsed data vector,
can be enabled. */
|
https://github.com/BurntSushi/rebar/blob/19aa8e8e3bd3a4bc0ef6e07774d900e5f4840fad/engines/pcre2/upstream/src/pcre2_compile.c#L922-L1181
|
19aa8e8e3bd3a4bc0ef6e07774d900e5f4840fad
|
rebar
|
github_2023
|
BurntSushi
|
c
|
convert_glob_char_in_class
|
static BOOL
convert_glob_char_in_class(int class_index, PCRE2_UCHAR c)
{
switch (class_index)
{
case 1: return isalnum(c);
case 2: return isalpha(c);
case 3: return 1;
case 4: return c == CHAR_HT || c == CHAR_SPACE;
case 5: return iscntrl(c);
case 6: return isdigit(c);
case 7: return isgraph(c);
case 8: return islower(c);
case 9: return isprint(c);
case 10: return ispunct(c);
case 11: return isspace(c);
case 12: return isupper(c);
case 13: return isalnum(c) || c == CHAR_UNDERSCORE;
default: return isxdigit(c);
}
}
|
/* Checks whether the character is in the class.
Arguments:
class_index class index
c character
Returns: !0 => character is found in the class
0 => otherwise
*/
|
https://github.com/BurntSushi/rebar/blob/19aa8e8e3bd3a4bc0ef6e07774d900e5f4840fad/engines/pcre2/upstream/src/pcre2_convert.c#L540-L560
|
19aa8e8e3bd3a4bc0ef6e07774d900e5f4840fad
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
arm_cmplx_mult_real_f32
|
void arm_cmplx_mult_real_f32(
float32_t * pSrcCmplx,
float32_t * pSrcReal,
float32_t * pCmplxDst,
uint32_t numSamples)
{
float32_t in; /* Temporary variable to store input value */
uint32_t blkCnt; /* loop counters */
#if defined (ARM_MATH_DSP)
/* Run the below code for Cortex-M4 and Cortex-M3 */
float32_t inA1, inA2, inA3, inA4; /* Temporary variables to hold input data */
float32_t inA5, inA6, inA7, inA8; /* Temporary variables to hold input data */
float32_t inB1, inB2, inB3, inB4; /* Temporary variables to hold input data */
float32_t out1, out2, out3, out4; /* Temporary variables to hold output data */
float32_t out5, out6, out7, out8; /* Temporary variables to hold output data */
/* loop Unrolling */
blkCnt = numSamples >> 2U;
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
** a second loop below computes the remaining 1 to 3 samples. */
while (blkCnt > 0U)
{
/* C[2 * i] = A[2 * i] * B[i]. */
/* C[2 * i + 1] = A[2 * i + 1] * B[i]. */
/* read input from complex input buffer */
inA1 = pSrcCmplx[0];
inA2 = pSrcCmplx[1];
/* read input from real input buffer */
inB1 = pSrcReal[0];
/* read input from complex input buffer */
inA3 = pSrcCmplx[2];
/* multiply complex buffer real input with real buffer input */
out1 = inA1 * inB1;
/* read input from complex input buffer */
inA4 = pSrcCmplx[3];
/* multiply complex buffer imaginary input with real buffer input */
out2 = inA2 * inB1;
/* read input from real input buffer */
inB2 = pSrcReal[1];
/* read input from complex input buffer */
inA5 = pSrcCmplx[4];
/* multiply complex buffer real input with real buffer input */
out3 = inA3 * inB2;
/* read input from complex input buffer */
inA6 = pSrcCmplx[5];
/* read input from real input buffer */
inB3 = pSrcReal[2];
/* multiply complex buffer imaginary input with real buffer input */
out4 = inA4 * inB2;
/* read input from complex input buffer */
inA7 = pSrcCmplx[6];
/* multiply complex buffer real input with real buffer input */
out5 = inA5 * inB3;
/* read input from complex input buffer */
inA8 = pSrcCmplx[7];
/* multiply complex buffer imaginary input with real buffer input */
out6 = inA6 * inB3;
/* read input from real input buffer */
inB4 = pSrcReal[3];
/* store result to destination bufer */
pCmplxDst[0] = out1;
/* multiply complex buffer real input with real buffer input */
out7 = inA7 * inB4;
/* store result to destination bufer */
pCmplxDst[1] = out2;
/* multiply complex buffer imaginary input with real buffer input */
out8 = inA8 * inB4;
/* store result to destination bufer */
pCmplxDst[2] = out3;
pCmplxDst[3] = out4;
pCmplxDst[4] = out5;
/* incremnet complex input buffer by 8 to process next samples */
pSrcCmplx += 8U;
/* store result to destination bufer */
pCmplxDst[5] = out6;
/* increment real input buffer by 4 to process next samples */
pSrcReal += 4U;
/* store result to destination bufer */
pCmplxDst[6] = out7;
pCmplxDst[7] = out8;
/* increment destination buffer by 8 to process next sampels */
pCmplxDst += 8U;
/* Decrement the numSamples loop counter */
blkCnt--;
}
/* If the numSamples is not a multiple of 4, compute any remaining output samples here.
** No loop unrolling is used. */
blkCnt = numSamples % 0x4U;
#else
/* Run the below code for Cortex-M0 */
blkCnt = numSamples;
#endif /* #if defined (ARM_MATH_DSP) */
while (blkCnt > 0U)
{
/* C[2 * i] = A[2 * i] * B[i]. */
/* C[2 * i + 1] = A[2 * i + 1] * B[i]. */
in = *pSrcReal++;
/* store the result in the destination buffer. */
*pCmplxDst++ = (*pSrcCmplx++) * (in);
*pCmplxDst++ = (*pSrcCmplx++) * (in);
/* Decrement the numSamples loop counter */
blkCnt--;
}
}
|
/**
* @ingroup groupCmplxMath
*/
/**
* @defgroup CmplxByRealMult Complex-by-Real Multiplication
*
* Multiplies a complex vector by a real vector and generates a complex result.
* The data in the complex arrays is stored in an interleaved fashion
* (real, imag, real, imag, ...).
* The parameter <code>numSamples</code> represents the number of complex
* samples processed. The complex arrays have a total of <code>2*numSamples</code>
* real values while the real array has a total of <code>numSamples</code>
* real values.
*
* The underlying algorithm is used:
*
* <pre>
* for(n=0; n<numSamples; n++) {
* pCmplxDst[(2*n)+0] = pSrcCmplx[(2*n)+0] * pSrcReal[n];
* pCmplxDst[(2*n)+1] = pSrcCmplx[(2*n)+1] * pSrcReal[n];
* }
* </pre>
*
* There are separate functions for floating-point, Q15, and Q31 data types.
*/
/**
* @addtogroup CmplxByRealMult
* @{
*/
/**
* @brief Floating-point complex-by-real multiplication
* @param[in] *pSrcCmplx points to the complex input vector
* @param[in] *pSrcReal points to the real input vector
* @param[out] *pCmplxDst points to the complex output vector
* @param[in] numSamples number of samples in each vector
* @return none.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/CMSIS/DSP/Source/ComplexMathFunctions/arm_cmplx_mult_real_f32.c#L73-L209
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_DCMI_EnableCrop
|
HAL_StatusTypeDef HAL_DCMI_EnableCrop(DCMI_HandleTypeDef *hdcmi)
{
/* Process Locked */
__HAL_LOCK(hdcmi);
/* Lock the DCMI peripheral state */
hdcmi->State = HAL_DCMI_STATE_BUSY;
/* Enable DCMI Crop feature */
hdcmi->Instance->CR |= (uint32_t)DCMI_CR_CROP;
/* Change the DCMI state*/
hdcmi->State = HAL_DCMI_STATE_READY;
/* Process Unlocked */
__HAL_UNLOCK(hdcmi);
return HAL_OK;
}
|
/**
* @brief Enable the Crop feature.
* @param hdcmi pointer to a DCMI_HandleTypeDef structure that contains
* the configuration information for DCMI.
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi.c#L795-L813
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_DSI_Start
|
HAL_StatusTypeDef HAL_DSI_Start(DSI_HandleTypeDef *hdsi)
{
/* Process locked */
__HAL_LOCK(hdsi);
/* Enable the DSI host */
__HAL_DSI_ENABLE(hdsi);
/* Enable the DSI wrapper */
__HAL_DSI_WRAPPER_ENABLE(hdsi);
/* Process unlocked */
__HAL_UNLOCK(hdsi);
return HAL_OK;
}
|
/**
* @brief Start the DSI module
* @param hdsi pointer to a DSI_HandleTypeDef structure that contains
* the configuration information for the DSI.
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dsi.c#L1452-L1467
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_FMPI2C_Master_Transmit_IT
|
HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData,
uint16_t Size)
{
uint32_t xfermode;
if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
{
if (__HAL_FMPI2C_GET_FLAG(hfmpi2c, FMPI2C_FLAG_BUSY) == SET)
{
return HAL_BUSY;
}
/* Process Locked */
__HAL_LOCK(hfmpi2c);
hfmpi2c->State = HAL_FMPI2C_STATE_BUSY_TX;
hfmpi2c->Mode = HAL_FMPI2C_MODE_MASTER;
hfmpi2c->ErrorCode = HAL_FMPI2C_ERROR_NONE;
/* Prepare transfer parameters */
hfmpi2c->pBuffPtr = pData;
hfmpi2c->XferCount = Size;
hfmpi2c->XferOptions = FMPI2C_NO_OPTION_FRAME;
hfmpi2c->XferISR = FMPI2C_Master_ISR_IT;
if (hfmpi2c->XferCount > MAX_NBYTE_SIZE)
{
hfmpi2c->XferSize = MAX_NBYTE_SIZE;
xfermode = FMPI2C_RELOAD_MODE;
}
else
{
hfmpi2c->XferSize = hfmpi2c->XferCount;
xfermode = FMPI2C_AUTOEND_MODE;
}
/* Send Slave Address */
/* Set NBYTES to write and reload if hfmpi2c->XferCount > MAX_NBYTE_SIZE */
FMPI2C_TransferConfig(hfmpi2c, DevAddress, (uint8_t)hfmpi2c->XferSize, xfermode, FMPI2C_GENERATE_START_WRITE);
/* Process Unlocked */
__HAL_UNLOCK(hfmpi2c);
/* Note : The FMPI2C interrupts must be enabled after unlocking current process
to avoid the risk of FMPI2C interrupt handle execution before current
process unlock */
/* Enable ERR, TC, STOP, NACK, TXI interrupt */
/* possible to enable all of these */
/* FMPI2C_IT_ERRI | FMPI2C_IT_TCI | FMPI2C_IT_STOPI | FMPI2C_IT_NACKI |
FMPI2C_IT_ADDRI | FMPI2C_IT_RXI | FMPI2C_IT_TXI */
FMPI2C_Enable_IRQ(hfmpi2c, FMPI2C_XFER_TX_IT);
return HAL_OK;
}
else
{
return HAL_BUSY;
}
}
|
/**
* @brief Transmit in master mode an amount of data in non-blocking mode with Interrupt
* @param hfmpi2c Pointer to a FMPI2C_HandleTypeDef structure that contains
* the configuration information for the specified FMPI2C.
* @param DevAddress Target device address: The device 7 bits address value
* in datasheet must be shifted to the left before calling the interface
* @param pData Pointer to data buffer
* @param Size Amount of data to be sent
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c.c#L1614-L1673
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_I2SEx_TransmitReceive_DMA
|
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s,
uint16_t *pTxData,
uint16_t *pRxData,
uint16_t Size)
{
uint32_t *tmp = NULL;
uint32_t tmp1 = 0U;
HAL_StatusTypeDef errorcode = HAL_OK;
if (hi2s->State != HAL_I2S_STATE_READY)
{
errorcode = HAL_BUSY;
goto error;
}
if ((pTxData == NULL) || (pRxData == NULL) || (Size == 0U))
{
return HAL_ERROR;
}
/* Process Locked */
__HAL_LOCK(hi2s);
hi2s->pTxBuffPtr = pTxData;
hi2s->pRxBuffPtr = pRxData;
tmp1 = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
/* Check the Data format: When a 16-bit data frame or a 16-bit data frame extended
is selected during the I2S configuration phase, the Size parameter means the number
of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data
frame is selected the Size parameter means the number of 16-bit data length. */
if ((tmp1 == I2S_DATAFORMAT_24B) || (tmp1 == I2S_DATAFORMAT_32B))
{
hi2s->TxXferSize = (Size << 1U);
hi2s->TxXferCount = (Size << 1U);
hi2s->RxXferSize = (Size << 1U);
hi2s->RxXferCount = (Size << 1U);
}
else
{
hi2s->TxXferSize = Size;
hi2s->TxXferCount = Size;
hi2s->RxXferSize = Size;
hi2s->RxXferCount = Size;
}
hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
hi2s->State = HAL_I2S_STATE_BUSY_TX_RX;
/* Set the I2S Rx DMA Half transfer complete callback */
hi2s->hdmarx->XferHalfCpltCallback = I2SEx_TxRxDMAHalfCplt;
/* Set the I2S Rx DMA transfer complete callback */
hi2s->hdmarx->XferCpltCallback = I2SEx_TxRxDMACplt;
/* Set the I2S Rx DMA error callback */
hi2s->hdmarx->XferErrorCallback = I2SEx_TxRxDMAError;
/* Set the I2S Tx DMA Half transfer complete callback as NULL */
hi2s->hdmatx->XferHalfCpltCallback = NULL;
/* Set the I2S Tx DMA transfer complete callback as NULL */
hi2s->hdmatx->XferCpltCallback = NULL;
/* Set the I2S Tx DMA error callback */
hi2s->hdmatx->XferErrorCallback = I2SEx_TxRxDMAError;
tmp1 = hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG;
/* Check if the I2S_MODE_MASTER_TX or I2S_MODE_SLAVE_TX Mode is selected */
if ((tmp1 == I2S_MODE_MASTER_TX) || (tmp1 == I2S_MODE_SLAVE_TX))
{
/* Enable the Rx DMA Stream */
tmp = (uint32_t *)&pRxData;
HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&I2SxEXT(hi2s->Instance)->DR, *(uint32_t *)tmp, hi2s->RxXferSize);
/* Enable Rx DMA Request */
SET_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_RXDMAEN);
/* Enable the Tx DMA Stream */
tmp = (uint32_t *)&pTxData;
HAL_DMA_Start_IT(hi2s->hdmatx, *(uint32_t *)tmp, (uint32_t)&hi2s->Instance->DR, hi2s->TxXferSize);
/* Enable Tx DMA Request */
SET_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
/* Check if the I2S is already enabled */
if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
{
/* Enable I2Sext(receiver) before enabling I2Sx peripheral */
__HAL_I2SEXT_ENABLE(hi2s);
/* Enable I2S peripheral after the I2Sext */
__HAL_I2S_ENABLE(hi2s);
}
}
else
{
/* Check if Master Receiver mode is selected */
if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX)
{
/* Clear the Overrun Flag by a read operation on the SPI_DR register followed by a read
access to the SPI_SR register. */
__HAL_I2S_CLEAR_OVRFLAG(hi2s);
}
/* Enable the Tx DMA Stream */
tmp = (uint32_t *)&pTxData;
HAL_DMA_Start_IT(hi2s->hdmatx, *(uint32_t *)tmp, (uint32_t)&I2SxEXT(hi2s->Instance)->DR, hi2s->TxXferSize);
/* Enable Tx DMA Request */
SET_BIT(I2SxEXT(hi2s->Instance)->CR2, SPI_CR2_TXDMAEN);
/* Enable the Rx DMA Stream */
tmp = (uint32_t *)&pRxData;
HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->DR, *(uint32_t *)tmp, hi2s->RxXferSize);
/* Enable Rx DMA Request */
SET_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
/* Check if the I2S is already enabled */
if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
{
/* Enable I2Sext(transmitter) before enabling I2Sx peripheral */
__HAL_I2SEXT_ENABLE(hi2s);
/* Enable I2S peripheral before the I2Sext */
__HAL_I2S_ENABLE(hi2s);
}
}
error :
__HAL_UNLOCK(hi2s);
return errorcode;
}
|
/**
* @brief Full-Duplex Transmit/Receive data in non-blocking mode using DMA
* @param hi2s pointer to a I2S_HandleTypeDef structure that contains
* the configuration information for I2S module
* @param pTxData a 16-bit pointer to the Transmit data buffer.
* @param pRxData a 16-bit pointer to the Receive data buffer.
* @param Size number of data sample to be sent:
* @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
* configuration phase, the Size parameter means the number of 16-bit data length
* in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
* the Size parameter means the number of 16-bit data length.
* @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
* between Master and Slave(example: audio streaming).
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s_ex.c#L541-L672
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_LTDC_EnableDither
|
HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
{
/* Process locked */
__HAL_LOCK(hltdc);
/* Change LTDC peripheral state */
hltdc->State = HAL_LTDC_STATE_BUSY;
/* Enable Dither by setting DTEN bit */
LTDC->GCR |= (uint32_t)LTDC_GCR_DEN;
/* Change the LTDC state*/
hltdc->State = HAL_LTDC_STATE_READY;
/* Process unlocked */
__HAL_UNLOCK(hltdc);
return HAL_OK;
}
|
/**
* @brief Enable Dither.
* @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
* the configuration information for the LTDC.
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_ltdc.c#L1059-L1077
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_PCCARD_ITCallback
|
__weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hpccard);
/* NOTE : This function Should not be modified, when the callback is needed,
the HAL_PCCARD_ITCallback could be implemented in the user file
*/
}
|
/**
* @brief PCCARD interrupt feature callback
* @param hpccard pointer to a PCCARD_HandleTypeDef structure that contains
* the configuration information for PCCARD module.
* @retval None
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pccard.c#L678-L685
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_PWREx_DisableMainRegulatorLowVoltage
|
void HAL_PWREx_DisableMainRegulatorLowVoltage(void)
{
*(__IO uint32_t *) CR_MRLVDS_BB = (uint32_t)DISABLE;
}
|
/**
* @brief Disables Main Regulator low voltage mode.
* @note This mode is only available for STM32F401xx/STM32F410xx/STM32F411xx/STM32F412Zx/STM32F412Rx/STM32F412Vx/STM32F412Cx/
* STM32F413xx/STM32F423xxdevices.
* @retval None
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c#L372-L375
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_RNG_ReadLastRandomNumber
|
uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng)
{
return (hrng->RandomNumber);
}
|
/**
* @brief Read latest generated random number.
* @param hrng pointer to a RNG_HandleTypeDef structure that contains
* the configuration information for RNG.
* @retval random value
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c#L771-L774
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_SMBUS_UnRegisterCallback
|
HAL_StatusTypeDef HAL_SMBUS_UnRegisterCallback(SMBUS_HandleTypeDef *hsmbus, HAL_SMBUS_CallbackIDTypeDef CallbackID)
{
HAL_StatusTypeDef status = HAL_OK;
/* Process locked */
__HAL_LOCK(hsmbus);
if (HAL_SMBUS_STATE_READY == hsmbus->State)
{
switch (CallbackID)
{
case HAL_SMBUS_MASTER_TX_COMPLETE_CB_ID :
hsmbus->MasterTxCpltCallback = HAL_SMBUS_MasterTxCpltCallback; /* Legacy weak MasterTxCpltCallback */
break;
case HAL_SMBUS_MASTER_RX_COMPLETE_CB_ID :
hsmbus->MasterRxCpltCallback = HAL_SMBUS_MasterRxCpltCallback; /* Legacy weak MasterRxCpltCallback */
break;
case HAL_SMBUS_SLAVE_TX_COMPLETE_CB_ID :
hsmbus->SlaveTxCpltCallback = HAL_SMBUS_SlaveTxCpltCallback; /* Legacy weak SlaveTxCpltCallback */
break;
case HAL_SMBUS_SLAVE_RX_COMPLETE_CB_ID :
hsmbus->SlaveRxCpltCallback = HAL_SMBUS_SlaveRxCpltCallback; /* Legacy weak SlaveRxCpltCallback */
break;
case HAL_SMBUS_LISTEN_COMPLETE_CB_ID :
hsmbus->ListenCpltCallback = HAL_SMBUS_ListenCpltCallback; /* Legacy weak ListenCpltCallback */
break;
case HAL_SMBUS_ERROR_CB_ID :
hsmbus->ErrorCallback = HAL_SMBUS_ErrorCallback; /* Legacy weak ErrorCallback */
break;
case HAL_SMBUS_ABORT_CB_ID :
hsmbus->AbortCpltCallback = HAL_SMBUS_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
break;
case HAL_SMBUS_MSPINIT_CB_ID :
hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit */
break;
case HAL_SMBUS_MSPDEINIT_CB_ID :
hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit */
break;
default :
/* Update the error code */
hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK;
/* Return error status */
status = HAL_ERROR;
break;
}
}
else if (HAL_SMBUS_STATE_RESET == hsmbus->State)
{
switch (CallbackID)
{
case HAL_SMBUS_MSPINIT_CB_ID :
hsmbus->MspInitCallback = HAL_SMBUS_MspInit; /* Legacy weak MspInit */
break;
case HAL_SMBUS_MSPDEINIT_CB_ID :
hsmbus->MspDeInitCallback = HAL_SMBUS_MspDeInit; /* Legacy weak MspDeInit */
break;
default :
/* Update the error code */
hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK;
/* Return error status */
status = HAL_ERROR;
break;
}
}
else
{
/* Update the error code */
hsmbus->ErrorCode |= HAL_SMBUS_ERROR_INVALID_CALLBACK;
/* Return error status */
status = HAL_ERROR;
}
/* Release Lock */
__HAL_UNLOCK(hsmbus);
return status;
}
|
/**
* @brief Unregister an SMBUS Callback
* SMBUS callback is redirected to the weak predefined callback
* @param hsmbus Pointer to a SMBUS_HandleTypeDef structure that contains
* the configuration information for the specified SMBUS.
* @param CallbackID ID of the callback to be unregistered
* This parameter can be one of the following values:
* This parameter can be one of the following values:
* @arg @ref HAL_SMBUS_MASTER_TX_COMPLETE_CB_ID Master Tx Transfer completed callback ID
* @arg @ref HAL_SMBUS_MASTER_RX_COMPLETE_CB_ID Master Rx Transfer completed callback ID
* @arg @ref HAL_SMBUS_SLAVE_TX_COMPLETE_CB_ID Slave Tx Transfer completed callback ID
* @arg @ref HAL_SMBUS_SLAVE_RX_COMPLETE_CB_ID Slave Rx Transfer completed callback ID
* @arg @ref HAL_SMBUS_LISTEN_COMPLETE_CB_ID Listen Complete callback ID
* @arg @ref HAL_SMBUS_ERROR_CB_ID Error callback ID
* @arg @ref HAL_SMBUS_ABORT_CB_ID Abort callback ID
* @arg @ref HAL_SMBUS_MSPINIT_CB_ID MspInit callback ID
* @arg @ref HAL_SMBUS_MSPDEINIT_CB_ID MspDeInit callback ID
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_smbus.c#L687-L776
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
LL_DMA_Init
|
uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Stream, LL_DMA_InitTypeDef *DMA_InitStruct)
{
/* Check the DMA Instance DMAx and Stream parameters*/
assert_param(IS_LL_DMA_ALL_STREAM_INSTANCE(DMAx, Stream));
/* Check the DMA parameters from DMA_InitStruct */
assert_param(IS_LL_DMA_DIRECTION(DMA_InitStruct->Direction));
assert_param(IS_LL_DMA_MODE(DMA_InitStruct->Mode));
assert_param(IS_LL_DMA_PERIPHINCMODE(DMA_InitStruct->PeriphOrM2MSrcIncMode));
assert_param(IS_LL_DMA_MEMORYINCMODE(DMA_InitStruct->MemoryOrM2MDstIncMode));
assert_param(IS_LL_DMA_PERIPHDATASIZE(DMA_InitStruct->PeriphOrM2MSrcDataSize));
assert_param(IS_LL_DMA_MEMORYDATASIZE(DMA_InitStruct->MemoryOrM2MDstDataSize));
assert_param(IS_LL_DMA_NBDATA(DMA_InitStruct->NbData));
assert_param(IS_LL_DMA_CHANNEL(DMA_InitStruct->Channel));
assert_param(IS_LL_DMA_PRIORITY(DMA_InitStruct->Priority));
assert_param(IS_LL_DMA_FIFO_MODE_STATE(DMA_InitStruct->FIFOMode));
/* Check the memory burst, peripheral burst and FIFO threshold parameters only
when FIFO mode is enabled */
if(DMA_InitStruct->FIFOMode != LL_DMA_FIFOMODE_DISABLE)
{
assert_param(IS_LL_DMA_FIFO_THRESHOLD(DMA_InitStruct->FIFOThreshold));
assert_param(IS_LL_DMA_MEMORY_BURST(DMA_InitStruct->MemBurst));
assert_param(IS_LL_DMA_PERIPHERAL_BURST(DMA_InitStruct->PeriphBurst));
}
/*---------------------------- DMAx SxCR Configuration ------------------------
* Configure DMAx_Streamy: data transfer direction, data transfer mode,
* peripheral and memory increment mode,
* data size alignment and priority level with parameters :
* - Direction: DMA_SxCR_DIR[1:0] bits
* - Mode: DMA_SxCR_CIRC bit
* - PeriphOrM2MSrcIncMode: DMA_SxCR_PINC bit
* - MemoryOrM2MDstIncMode: DMA_SxCR_MINC bit
* - PeriphOrM2MSrcDataSize: DMA_SxCR_PSIZE[1:0] bits
* - MemoryOrM2MDstDataSize: DMA_SxCR_MSIZE[1:0] bits
* - Priority: DMA_SxCR_PL[1:0] bits
*/
LL_DMA_ConfigTransfer(DMAx, Stream, DMA_InitStruct->Direction | \
DMA_InitStruct->Mode | \
DMA_InitStruct->PeriphOrM2MSrcIncMode | \
DMA_InitStruct->MemoryOrM2MDstIncMode | \
DMA_InitStruct->PeriphOrM2MSrcDataSize | \
DMA_InitStruct->MemoryOrM2MDstDataSize | \
DMA_InitStruct->Priority
);
if(DMA_InitStruct->FIFOMode != LL_DMA_FIFOMODE_DISABLE)
{
/*---------------------------- DMAx SxFCR Configuration ------------------------
* Configure DMAx_Streamy: fifo mode and fifo threshold with parameters :
* - FIFOMode: DMA_SxFCR_DMDIS bit
* - FIFOThreshold: DMA_SxFCR_FTH[1:0] bits
*/
LL_DMA_ConfigFifo(DMAx, Stream, DMA_InitStruct->FIFOMode, DMA_InitStruct->FIFOThreshold);
/*---------------------------- DMAx SxCR Configuration --------------------------
* Configure DMAx_Streamy: memory burst transfer with parameters :
* - MemBurst: DMA_SxCR_MBURST[1:0] bits
*/
LL_DMA_SetMemoryBurstxfer(DMAx,Stream,DMA_InitStruct->MemBurst);
/*---------------------------- DMAx SxCR Configuration --------------------------
* Configure DMAx_Streamy: peripheral burst transfer with parameters :
* - PeriphBurst: DMA_SxCR_PBURST[1:0] bits
*/
LL_DMA_SetPeriphBurstxfer(DMAx,Stream,DMA_InitStruct->PeriphBurst);
}
/*-------------------------- DMAx SxM0AR Configuration --------------------------
* Configure the memory or destination base address with parameter :
* - MemoryOrM2MDstAddress: DMA_SxM0AR_M0A[31:0] bits
*/
LL_DMA_SetMemoryAddress(DMAx, Stream, DMA_InitStruct->MemoryOrM2MDstAddress);
/*-------------------------- DMAx SxPAR Configuration ---------------------------
* Configure the peripheral or source base address with parameter :
* - PeriphOrM2MSrcAddress: DMA_SxPAR_PA[31:0] bits
*/
LL_DMA_SetPeriphAddress(DMAx, Stream, DMA_InitStruct->PeriphOrM2MSrcAddress);
/*--------------------------- DMAx SxNDTR Configuration -------------------------
* Configure the peripheral base address with parameter :
* - NbData: DMA_SxNDT[15:0] bits
*/
LL_DMA_SetDataLength(DMAx, Stream, DMA_InitStruct->NbData);
/*--------------------------- DMA SxCR_CHSEL Configuration ----------------------
* Configure the peripheral base address with parameter :
* - PeriphRequest: DMA_SxCR_CHSEL[2:0] bits
*/
LL_DMA_SetChannelSelection(DMAx, Stream, DMA_InitStruct->Channel);
return SUCCESS;
}
|
/**
* @brief Initialize the DMA registers according to the specified parameters in DMA_InitStruct.
* @note To convert DMAx_Streamy Instance to DMAx Instance and Streamy, use helper macros :
* @arg @ref __LL_DMA_GET_INSTANCE
* @arg @ref __LL_DMA_GET_STREAM
* @param DMAx DMAx Instance
* @param Stream This parameter can be one of the following values:
* @arg @ref LL_DMA_STREAM_0
* @arg @ref LL_DMA_STREAM_1
* @arg @ref LL_DMA_STREAM_2
* @arg @ref LL_DMA_STREAM_3
* @arg @ref LL_DMA_STREAM_4
* @arg @ref LL_DMA_STREAM_5
* @arg @ref LL_DMA_STREAM_6
* @arg @ref LL_DMA_STREAM_7
* @param DMA_InitStruct pointer to a @ref LL_DMA_InitTypeDef structure.
* @retval An ErrorStatus enumeration value:
* - SUCCESS: DMA registers are initialized
* - ERROR: Not applicable
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c#L285-L378
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
FMC_NAND_Init
|
HAL_StatusTypeDef FMC_NAND_Init(FMC_NAND_TypeDef *Device, FMC_NAND_InitTypeDef *Init)
{
uint32_t tmpr = 0U;
/* Check the parameters */
assert_param(IS_FMC_NAND_DEVICE(Device));
assert_param(IS_FMC_NAND_BANK(Init->NandBank));
assert_param(IS_FMC_WAIT_FEATURE(Init->Waitfeature));
assert_param(IS_FMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth));
assert_param(IS_FMC_ECC_STATE(Init->EccComputation));
assert_param(IS_FMC_ECCPAGE_SIZE(Init->ECCPageSize));
assert_param(IS_FMC_TCLR_TIME(Init->TCLRSetupTime));
assert_param(IS_FMC_TAR_TIME(Init->TARSetupTime));
if(Init->NandBank == FMC_NAND_BANK2)
{
/* Get the NAND bank 2 register value */
tmpr = Device->PCR2;
}
else
{
/* Get the NAND bank 3 register value */
tmpr = Device->PCR3;
}
/* Clear PWAITEN, PBKEN, PTYP, PWID, ECCEN, TCLR, TAR and ECCPS bits */
tmpr &= ((uint32_t)~(FMC_PCR2_PWAITEN | FMC_PCR2_PBKEN | FMC_PCR2_PTYP | \
FMC_PCR2_PWID | FMC_PCR2_ECCEN | FMC_PCR2_TCLR | \
FMC_PCR2_TAR | FMC_PCR2_ECCPS));
/* Set NAND device control parameters */
tmpr |= (uint32_t)(Init->Waitfeature |\
FMC_PCR_MEMORY_TYPE_NAND |\
Init->MemoryDataWidth |\
Init->EccComputation |\
Init->ECCPageSize |\
((Init->TCLRSetupTime) << 9U) |\
((Init->TARSetupTime) << 13U));
if(Init->NandBank == FMC_NAND_BANK2)
{
/* NAND bank 2 registers configuration */
Device->PCR2 = tmpr;
}
else
{
/* NAND bank 3 registers configuration */
Device->PCR3 = tmpr;
}
return HAL_OK;
}
|
/* defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) */
/** @defgroup HAL_FMC_NAND_Group1 Initialization/de-initialization functions
* @brief Initialization and Configuration functions
*
@verbatim
==============================================================================
##### Initialization and de_initialization functions #####
==============================================================================
[..]
This section provides functions allowing to:
(+) Initialize and configure the FMC NAND interface
(+) De-initialize the FMC NAND interface
(+) Configure the FMC clock and associated GPIOs
@endverbatim
* @{
*/
/**
* @brief Initializes the FMC_NAND device according to the specified
* control parameters in the FMC_NAND_HandleTypeDef
* @param Device Pointer to NAND device instance
* @param Init Pointer to NAND Initialization structure
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c#L754-L806
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
LL_LPTIM_StructInit
|
void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef *LPTIM_InitStruct)
{
/* Set the default configuration */
LPTIM_InitStruct->ClockSource = LL_LPTIM_CLK_SOURCE_INTERNAL;
LPTIM_InitStruct->Prescaler = LL_LPTIM_PRESCALER_DIV1;
LPTIM_InitStruct->Waveform = LL_LPTIM_OUTPUT_WAVEFORM_PWM;
LPTIM_InitStruct->Polarity = LL_LPTIM_OUTPUT_POLARITY_REGULAR;
}
|
/**
* @brief Set each fields of the LPTIM_InitStruct structure to its default
* value.
* @param LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure
* @retval None
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_lptim.c#L122-L129
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
USB_DisableGlobalInt
|
HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx)
{
USBx->GAHBCFG &= ~USB_OTG_GAHBCFG_GINT;
return HAL_OK;
}
|
/**
* @brief USB_DisableGlobalInt
* Disable the controller's Global Int in the AHB Config reg
* @param USBx Selected device
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c#L234-L238
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
USB_ResetPort
|
HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx)
{
uint32_t USBx_BASE = (uint32_t)USBx;
__IO uint32_t hprt0 = 0U;
hprt0 = USBx_HPRT0;
hprt0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |
USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG);
USBx_HPRT0 = (USB_OTG_HPRT_PRST | hprt0);
HAL_Delay(100U); /* See Note #1 */
USBx_HPRT0 = ((~USB_OTG_HPRT_PRST) & hprt0);
HAL_Delay(10U);
return HAL_OK;
}
|
/**
* @brief USB_OTG_ResetPort : Reset Host Port
* @param USBx Selected device
* @retval HAL status
* @note (1)The application must wait at least 10 ms
* before clearing the reset bit.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c#L1532-L1549
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
mpu_set_accel_fsr
|
int mpu_set_accel_fsr(unsigned char fsr)
{
unsigned char data;
if (!(st.chip_cfg.sensors))
return -1;
switch (fsr) {
case 2:
data = INV_FSR_2G << 3;
break;
case 4:
data = INV_FSR_4G << 3;
break;
case 8:
data = INV_FSR_8G << 3;
break;
case 16:
data = INV_FSR_16G << 3;
break;
default:
return -1;
}
if (st.chip_cfg.accel_fsr == (data >> 3))
return 0;
if (i2c_write( st.reg->accel_cfg, 1, &data))
return -1;
st.chip_cfg.accel_fsr = data >> 3;
return 0;
}
|
/**
* @brief Set the accel full-scale range.
* @param[in] fsr Desired full-scale range.
* @return 0 if successful.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/GearLL/Drivers/Devices/MPU6050/inv_mpu.c#L1248-L1278
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
mpu_set_int_level
|
int mpu_set_int_level(unsigned char active_low)
{
st.chip_cfg.active_low_int = active_low;
return 0;
}
|
/**
* @brief Set interrupt level.
* @param[in] active_low 1 for active low, 0 for active high.
* @return 0 if successful.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/GearLL/Drivers/Devices/MPU6050/inv_mpu.c#L1869-L1873
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
mpu_get_compass_fsr
|
int mpu_get_compass_fsr(unsigned short *fsr)
{
#ifdef AK89xx_SECONDARY
fsr[0] = st.hw->compass_fsr;
return 0;
#else
return -1;
#endif
}
|
/**
* @brief Get the compass full-scale range.
* @param[out] fsr Current full-scale range.
* @return 0 if successful.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/GearLL/Drivers/Devices/MPU6050/inv_mpu.c#L2590-L2598
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
SEGGER_SYSVIEW_RecordU32x4
|
void SEGGER_SYSVIEW_RecordU32x4(unsigned int EventID, U32 Para0, U32 Para1, U32 Para2, U32 Para3) {
U8* pPayload;
U8* pPayloadStart;
RECORD_START(SEGGER_SYSVIEW_INFO_SIZE + 4 * SEGGER_SYSVIEW_QUANTA_U32);
//
pPayload = pPayloadStart;
ENCODE_U32(pPayload, Para0);
ENCODE_U32(pPayload, Para1);
ENCODE_U32(pPayload, Para2);
ENCODE_U32(pPayload, Para3);
_SendPacket(pPayloadStart, pPayload, EventID);
RECORD_END();
}
|
/*********************************************************************
*
* SEGGER_SYSVIEW_RecordU32x4()
*
* Function description
* Formats and sends a SystemView packet containing 4 U32 parameter payload.
*
* Parameters
* EventID - SystemView event ID.
* Para0 - The 32-bit parameter encoded to SystemView packet payload.
* Para1 - The 32-bit parameter encoded to SystemView packet payload.
* Para2 - The 32-bit parameter encoded to SystemView packet payload.
* Para3 - The 32-bit parameter encoded to SystemView packet payload.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone-F4/Middlewares/SEGGER/SEGGER_SYSVIEW.c#L1389-L1401
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
I2C_MasterReceive_RXNE
|
static void I2C_MasterReceive_RXNE(I2C_HandleTypeDef *hi2c)
{
if (hi2c->State == HAL_I2C_STATE_BUSY_RX)
{
uint32_t tmp;
tmp = hi2c->XferCount;
if (tmp > 3U)
{
/* Read data from DR */
*hi2c->pBuffPtr = (uint8_t)hi2c->Instance->DR;
/* Increment Buffer pointer */
hi2c->pBuffPtr++;
/* Update counter */
hi2c->XferCount--;
if (hi2c->XferCount == (uint16_t)3)
{
/* Disable BUF interrupt, this help to treat correctly the last 4 bytes
on BTF subroutine */
/* Disable BUF interrupt */
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_BUF);
}
}
else if ((hi2c->XferOptions != I2C_FIRST_AND_NEXT_FRAME) && ((tmp == 1U) || (tmp == 0U)))
{
if (I2C_WaitOnSTOPRequestThroughIT(hi2c) == HAL_OK)
{
/* Disable Acknowledge */
CLEAR_BIT(hi2c->Instance->CR1, I2C_CR1_ACK);
/* Disable EVT, BUF and ERR interrupt */
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR);
/* Read data from DR */
*hi2c->pBuffPtr = (uint8_t)hi2c->Instance->DR;
/* Increment Buffer pointer */
hi2c->pBuffPtr++;
/* Update counter */
hi2c->XferCount--;
hi2c->State = HAL_I2C_STATE_READY;
if (hi2c->Mode == HAL_I2C_MODE_MEM)
{
hi2c->Mode = HAL_I2C_MODE_NONE;
hi2c->PreviousState = I2C_STATE_NONE;
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
hi2c->MemRxCpltCallback(hi2c);
#else
HAL_I2C_MemRxCpltCallback(hi2c);
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
}
else
{
hi2c->Mode = HAL_I2C_MODE_NONE;
hi2c->PreviousState = I2C_STATE_MASTER_BUSY_RX;
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
hi2c->MasterRxCpltCallback(hi2c);
#else
HAL_I2C_MasterRxCpltCallback(hi2c);
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
}
}
else
{
/* Disable EVT, BUF and ERR interrupt */
__HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR);
/* Read data from DR */
*hi2c->pBuffPtr = (uint8_t)hi2c->Instance->DR;
/* Increment Buffer pointer */
hi2c->pBuffPtr++;
/* Update counter */
hi2c->XferCount--;
hi2c->State = HAL_I2C_STATE_READY;
hi2c->Mode = HAL_I2C_MODE_NONE;
/* Call user error callback */
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
hi2c->ErrorCallback(hi2c);
#else
HAL_I2C_ErrorCallback(hi2c);
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
}
}
else
{
/* Do nothing */
}
}
}
|
/**
* @brief Handle RXNE flag for Master
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
* the configuration information for I2C module
* @retval None
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone_Lite/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c#L5615-L5715
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
UART_WaitOnFlagUntilTimeout
|
static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
{
/* Wait until flag is set */
while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status)
{
/* Check for the Timeout */
if (Timeout != HAL_MAX_DELAY)
{
if ((Timeout == 0U) || ((HAL_GetTick() - Tickstart) > Timeout))
{
/* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
huart->gState = HAL_UART_STATE_READY;
huart->RxState = HAL_UART_STATE_READY;
/* Process Unlocked */
__HAL_UNLOCK(huart);
return HAL_TIMEOUT;
}
}
}
return HAL_OK;
}
|
/**
* @brief This function handles UART Communication Timeout.
* @param huart Pointer to a UART_HandleTypeDef structure that contains
* the configuration information for the specified UART module.
* @param Flag specifies the UART flag to check.
* @param Status The new Flag status (SET or RESET).
* @param Tickstart Tick start value
* @param Timeout Timeout duration
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone_Lite/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c#L3167-L3192
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
SEGGER_RTT_WriteNoLock
|
unsigned SEGGER_RTT_WriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
unsigned Status;
unsigned Avail;
const char* pData;
SEGGER_RTT_BUFFER_UP* pRing;
pData = (const char *)pBuffer;
//
// Get "to-host" ring buffer.
//
pRing = &_SEGGER_RTT.aUp[BufferIndex];
//
// How we output depends upon the mode...
//
switch (pRing->Flags) {
case SEGGER_RTT_MODE_NO_BLOCK_SKIP:
//
// If we are in skip mode and there is no space for the whole
// of this output, don't bother.
//
Avail = _GetAvailWriteSpace(pRing);
if (Avail < NumBytes) {
Status = 0u;
} else {
Status = NumBytes;
_WriteNoCheck(pRing, pData, NumBytes);
}
break;
case SEGGER_RTT_MODE_NO_BLOCK_TRIM:
//
// If we are in trim mode, trim to what we can output without blocking.
//
Avail = _GetAvailWriteSpace(pRing);
Status = Avail < NumBytes ? Avail : NumBytes;
_WriteNoCheck(pRing, pData, Status);
break;
case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL:
//
// If we are in blocking mode, output everything.
//
Status = _WriteBlocking(pRing, pData, NumBytes);
break;
default:
Status = 0u;
break;
}
//
// Finish up.
//
return Status;
}
|
/*********************************************************************
*
* SEGGER_RTT_WriteNoLock
*
* Function description
* Stores a specified number of characters in SEGGER RTT
* control block which is then read by the host.
* SEGGER_RTT_WriteNoLock does not lock the application.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
*
* Return value
* Number of bytes which have been stored in the "Up"-buffer.
*
* Notes
* (1) Data is stored according to buffer flags.
* (2) For performance reasons this function does not call Init()
* and may only be called after RTT has been initialized.
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone_Lite/Middlewares/SEGGER/SEGGER_RTT.c#L895-L945
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
SEGGER_SYSVIEW_RecordU32x4
|
void SEGGER_SYSVIEW_RecordU32x4(unsigned int EventID, U32 Para0, U32 Para1, U32 Para2, U32 Para3) {
U8* pPayload;
U8* pPayloadStart;
RECORD_START(SEGGER_SYSVIEW_INFO_SIZE + 4 * SEGGER_SYSVIEW_QUANTA_U32);
//
pPayload = pPayloadStart;
ENCODE_U32(pPayload, Para0);
ENCODE_U32(pPayload, Para1);
ENCODE_U32(pPayload, Para2);
ENCODE_U32(pPayload, Para3);
_SendPacket(pPayloadStart, pPayload, EventID);
RECORD_END();
}
|
/*********************************************************************
*
* SEGGER_SYSVIEW_RecordU32x4()
*
* Function description
* Formats and sends a SystemView packet containing 4 U32 parameter payload.
*
* Parameters
* EventID - SystemView event ID.
* Para0 - The 32-bit parameter encoded to SystemView packet payload.
* Para1 - The 32-bit parameter encoded to SystemView packet payload.
* Para2 - The 32-bit parameter encoded to SystemView packet payload.
* Para3 - The 32-bit parameter encoded to SystemView packet payload.
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone_Lite/Middlewares/SEGGER/SEGGER_SYSVIEW.c#L1389-L1401
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
HAL_I2C_MspDeInit
|
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
{
if(hi2c->Instance==I2C1)
{
/* USER CODE BEGIN I2C1_MspDeInit 0 */
/* USER CODE END I2C1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_I2C1_CLK_DISABLE();
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
/* USER CODE BEGIN I2C1_MspDeInit 1 */
/* USER CODE END I2C1_MspDeInit 1 */
}
}
|
/**
* @brief I2C MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hi2c: I2C handle pointer
* @retval None
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARdrone_Lite/Src/stm32f1xx_hal_msp.c#L218-L241
|
489001958d76c251128a953a47555c68bfe65fd8
|
GEARdrones
|
github_2023
|
Excitablecell
|
c
|
I2C_WaitOnBTFFlagUntilTimeout
|
static HAL_StatusTypeDef I2C_WaitOnBTFFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Timeout, uint32_t Tickstart)
{
while (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_BTF) == RESET)
{
/* Check if a NACK is detected */
if (I2C_IsAcknowledgeFailed(hi2c) != HAL_OK)
{
return HAL_ERROR;
}
/* Check for the Timeout */
if (Timeout != HAL_MAX_DELAY)
{
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
{
hi2c->PreviousState = I2C_STATE_NONE;
hi2c->State = HAL_I2C_STATE_READY;
hi2c->Mode = HAL_I2C_MODE_NONE;
hi2c->ErrorCode |= HAL_I2C_ERROR_TIMEOUT;
/* Process Unlocked */
__HAL_UNLOCK(hi2c);
return HAL_ERROR;
}
}
}
return HAL_OK;
}
|
/**
* @brief This function handles I2C Communication Timeout for specific usage of BTF flag.
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
* the configuration information for the specified I2C.
* @param Timeout Timeout duration
* @param Tickstart Tick start value
* @retval HAL status
*/
|
https://github.com/Excitablecell/GEARdrones/blob/489001958d76c251128a953a47555c68bfe65fd8/Firmware/GEARremote/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c#L7412-L7440
|
489001958d76c251128a953a47555c68bfe65fd8
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.