type
stringclasses
5 values
content
stringlengths
9
163k
functions
int codec_bind_generic(struct hda_codec *codec) { if (codec->probe_id) return -ENODEV; if (is_likely_hdmi_codec(codec)) { codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; request_codec_module(codec); if (codec_probed(codec)) return 0; }
functions
int snd_hda_codec_configure(struct hda_codec *codec) { int err; if (is_generic_config(codec)) codec->probe_id = HDA_CODEC_ID_GENERIC; else codec->probe_id = 0; err = snd_hdac_device_register(&codec->core); if (err < 0) return err; if (!codec->preset) codec_bind_module(codec); if (!codec->preset) { e...
includes
#include <stdio.h>
defines
#define USECS_PER_SECOND (1000 * 1000)
defines
#define HZ (50)
functions
avr_cycle_count_t switch_auto( struct avr_t * avr, avr_cycle_count_t when, void * param) { ac_input_t * b = (ac_input_t *) param; b->value = !b->value; avr_raise_irq(b->irq + IRQ_AC_OUT, b->value); return when + avr_usec_to_cycles(avr, USECS_PER_SECOND / HZ); }
functions
void ac_input_init(avr_t *avr, ac_input_t *b) { b->irq = avr_alloc_irq(&avr->irq_pool, 0, IRQ_AC_COUNT, &name); b->avr = avr; b->value = 0; avr_cycle_timer_register_usec(avr, USECS_PER_SECOND / HZ, switch_auto, b); printf("ac_input_init period %duS or %d cycles\n", USECS_PER_SECOND / HZ, (int)avr_usec_to_cyc...
includes
#include <string.h>
includes
#include <stdio.h>
includes
#include <stdlib.h>
includes
#include <android/log.h>
includes
#include <windows.h>
includes
#include <unistd.h>
includes
#include <sys/wait.h>
includes
#include <signal.h>
includes
#include <signal.h>
defines
#define MEMENTO_FREELIST_MAX_SINGLE_BLOCK (MEMENTO_FREELIST_MAX/4)
defines
#define COMPILING_MEMENTO_C
defines
#define fprintf android_fprintf
defines
#define MEMENTO_STACKTRACE_METHOD 0
defines
#define fprintf windows_fprintf
defines
#define MEMENTO_STACKTRACE_METHOD 1
defines
#define MEMENTO_HAS_FORK
defines
#define MEMENTO_HAS_FORK
defines
#define MEMENTO_PTRSEARCH 65536
defines
#define MEMENTO_MAXPATTERN 0
defines
#define VALGRIND_MAKE_MEM_NOACCESS(p,s) do { } while (0==1)
defines
#define VALGRIND_MAKE_MEM_UNDEFINED(p,s) do { } while (0==1)
defines
#define VALGRIND_MAKE_MEM_DEFINED(p,s) do { } while (0==1)
defines
#define MEMENTO_SEARCH_SKIP (2*sizeof(void *))
defines
#define MEMENTO_SEARCH_SKIP 0
defines
#define MEMENTO_EXTRASIZE (sizeof(Memento_BlkHeader) + Memento_PostSize)
defines
#define MEMENTO_ROUNDUP(S,N) ((S + N-1)&~(N-1))
defines
#define MEMBLK_SIZE(s) MEMENTO_ROUNDUP(s + MEMENTO_EXTRASIZE, MEMENTO_MAXALIGN)
defines
#define MEMBLK_FROMBLK(B) (&((Memento_BlkHeader*)(void *)(B))[-1])
defines
#define MEMBLK_TOBLK(B) ((void*)(&((Memento_BlkHeader*)(void*)(B))[1]))
defines
#define MEMBLK_POSTPTR(B) \
defines
#define OPEN_MAX 10240
structs
struct Memento_BlkHeader { size_t rawsize; int sequence; int lastCheckedOK; int flags; Memento_BlkHeader *next; Memento_BlkHeader *parent; /* Only used while printing out nested list */ const char *label; /* Entries for ne...
functions
int android_fprintf(FILE *file, const char *fmt, ...) { va_list args; va_start(args, fmt); __android_log_vprint(ANDROID_LOG_ERROR,"memento", fmt, args); va_end(args); }
functions
int windows_fprintf(FILE *file, const char *fmt, ...) { va_list args; char text[4096]; int ret; va_start(args, fmt); ret = vfprintf(file, fmt, args); va_end(args); va_start(args, fmt); vsnprintf(text, 4096, fmt, args); OutputDebugStringA(text); va_end(args); return ret; }
functions
void Memento_breakpoint(void) { /* A handy externally visible function for breakpointing */ #if 0 /* Enable this to force automatic breakpointing */ #ifdef DEBUG #ifdef _MSC_VER __asm int 3; #endif #endif #endif }
functions
void Memento_addBlockHead(Memento_Blocks *blks, Memento_BlkHeader *b, int type) { if (blks->tail == &blks->head) { /* Adding into an empty list, means the tail changes too */ blks->tail = &b->next; }
functions
else if (type == 1) { /* free */ VALGRIND_MAKE_MEM_NOACCESS(MEMBLK_TOBLK(b), b->rawsize); }
functions
void Memento_addBlockTail(Memento_Blocks *blks, Memento_BlkHeader *b, int type) { VALGRIND_MAKE_MEM_DEFINED(blks->tail, sizeof(Memento_BlkHeader *)); *blks->tail = b; blks->tail = &b->next; b->next = NULL; VALGRIND_...
functions
else if (type == 1) { /* free */ VALGRIND_MAKE_MEM_NOACCESS(MEMBLK_TOBLK(b), b->rawsize); }
functions
int Memento_Internal_checkAllocedBlock(Memento_BlkHeader *b, void *arg) { #ifndef MEMENTO_LEAKONLY int i; char *p; int corrupt = 0; BlkCheckData *data = (BlkCheckData *)arg; p = b->preblk; i = Memento_PreSize; do { corrupt |= (*p++ ^ (char)MEMENTO_PREFILL...
functions
int Memento_Internal_checkFreedBlock(Memento_BlkHeader *b, void *arg) { #ifndef MEMENTO_LEAKONLY int i; char *p; BlkCheckData *data = (BlkCheckData *)arg; p = MEMBLK_TOBLK(b); i = b->rawsize; /* Attempt to speed this up by checking an (aligned) int at a time */ do { ...
functions
void Memento_removeBlock(Memento_Blocks *blks, Memento_BlkHeader *b) { Memento_BlkHeader *head = blks->head; Memento_BlkHeader *prev = NULL; while ((head) && (head != b)) { VALGRIND_MAKE_MEM_DEFINED(head, sizeof(*head)); prev = head; head = head->ne...
functions
int Memento_Internal_makeSpace(size_t space) { /* If too big, it can never go on the freelist */ if (space > MEMENTO_FREELIST_MAX_SINGLE_BLOCK) return 0; /* Pretend we added it on. */ globals.freeListSize += space; /* Ditch blocks until it fits within our limit */ while (globals.freeList...
functions
void showBlock(Memento_BlkHeader *b, int space) { fprintf(stderr, "0x%p:(size=%d,num=%d)", MEMBLK_TOBLK(b), (int)b->rawsize, b->sequence); if (b->label) fprintf(stderr, "%c(%s)", space, b->label); }
functions
void blockDisplay(Memento_BlkHeader *b, int n) { n++; while (n > 40) { fprintf(stderr, "*"); n -= 40; }
functions
int Memento_listBlock(Memento_BlkHeader *b, void *arg) { int *counts = (int *)arg; blockDisplay(b, 0); counts[0]++; counts[1]+= b->rawsize; return 0; }
functions
void doNestedDisplay(Memento_BlkHeader *b, int depth) { /* Try and avoid recursion if we can help it */ do { blockDisplay(b, depth); if (b->sibling) { if (b->child) doNestedDisplay(b->child, depth+1); b = b->sibling; }
functions
int ptrcmp(const void *a_, const void *b_) { const char **a = (const char **)a_; const char **b = (const char **)b_; return (int)(*a-*b); }
functions
int Memento_listBlocksNested(void) { int count, size, i; Memento_BlkHeader *b; void **blocks, *minptr, *maxptr; long mask; /* Count the blocks */ count = 0; size = 0; for (b = globals.used.head; b; b = b->next) { size += b->rawsize; count++; }
functions
void Memento_listBlocks(void) { fprintf(stderr, "Allocated blocks:\n"); if (Memento_listBlocksNested()) { int counts[2]; counts[0] = 0; counts[1] = 0; Memento_appBlocks(&globals.used, Memento_listBlock, &counts[0]); fprintf(stderr, " Total number of blocks = %d\n", co...
functions
int Memento_listNewBlock(Memento_BlkHeader *b, void *arg) { if (b->flags & Memento_Flag_OldBlock) return 0; b->flags |= Memento_Flag_OldBlock; return Memento_listBlock(b, arg); }
functions
void Memento_listNewBlocks(void) { int counts[2]; counts[0] = 0; counts[1] = 0; fprintf(stderr, "Blocks allocated and still extant since last list:\n"); Memento_appBlocks(&globals.used, Memento_listNewBlock, &counts[0]); fprintf(stderr, " Total number of blocks = %d\n", counts[0]); fprintf(...
functions
void Memento_endStats(void) { fprintf(stderr, "Total memory malloced = %u bytes\n", (unsigned int)globals.totalAlloc); fprintf(stderr, "Peak memory malloced = %u bytes\n", (unsigned int)globals.peakAlloc); fprintf(stderr, "%u mallocs, %u frees, %u reallocs\n", (unsigned int)globals.numMallocs, (...
functions
void Memento_stats(void) { fprintf(stderr, "Current memory malloced = %u bytes\n", (unsigned int)globals.alloc); Memento_endStats(); }
functions
void Memento_fin(void) { Memento_checkAllMemory(); Memento_endStats(); if (globals.used.head != NULL) { Memento_listBlocks(); Memento_breakpoint(); }
functions
else if (globals.squeezing) { if (globals.pattern == 0) fprintf(stderr, "Memory squeezing @ %d complete\n", globals.squeezeAt); else fprintf(stderr, "Memory squeezing @ %d (%d) complete\n", globals.squeezeAt, globals.pattern); }
functions
void Memento_inited(void) { /* A good place for a breakpoint */ }
functions
void Memento_init(void) { char *env; memset(&globals, 0, sizeof(globals)); globals.inited = 1; globals.used.head = NULL; globals.used.tail = &globals.used.head; globals.free.head = NULL; globals.free.tail = &globals.free.head; globals.sequence = 0; globals.countdown = 1024; ...
functions
void Memento_signal(void) { fprintf(stderr, "SEGV after Memory squeezing @ %d\n", globals.squeezeAt); #ifdef MEMENTO_STACKTRACE_METHOD #if MEMENTO_STACKTRACE_METHOD == 1 { void *array[100]; size_t size; size = backtrace(array, 100); fprintf(stderr, "------------------------------------...
functions
int squeeze(void) { pid_t pid; int i, status; if (globals.patternBit < 0) return 1; if (globals.squeezing && globals.patternBit >= MEMENTO_MAXPATTERN) return 1; if (globals.patternBit == 0) globals.squeezeAt = globals.sequence; if (!globals.squeezing) { fprintf...
functions
void Memento_signal(void) { globals.segv = 1; /* If we just return from this function the SEGV will be unhandled, and * we'll launch into whatever JIT debugging system the OS provides. At * least fprintf(stderr, something useful first. If MEMENTO_NOJIT is set, then * just exit to avoid the JIT (a...
functions
int squeeze(void) { fprintf(stderr, "Memento memory squeezing disabled as no fork!\n"); return 0; }
functions
void Memento_startFailing(void) { if (!globals.failing) { fprintf(stderr, "Starting to fail...\n"); fflush(stderr); globals.failing = 1; globals.failAt = globals.sequence; globals.nextFailAt = globals.sequence+1; globals.pattern = 0; globals.patternBit = 0; ...
functions
void Memento_event(void) { globals.sequence++; if ((globals.sequence >= globals.paranoidAt) && (globals.paranoidAt != 0)) { globals.paranoia = 1; globals.countdown = 1; }
functions
int Memento_breakAt(int event) { globals.breakAt = event; return event; }
functions
int Memento_failThisEvent(void) { int failThisOne; if (!globals.inited) Memento_init(); Memento_event(); if ((globals.sequence >= globals.failAt) && (globals.failAt != 0)) Memento_startFailing(); if ((globals.sequence >= globals.squeezeAt) && (globals.squeezeAt != 0)) { re...
functions
int checkBlock(Memento_BlkHeader *memblk, const char *action) { #ifndef MEMENTO_LEAKONLY BlkCheckData data; memset(&data, 0, sizeof(data)); Memento_appBlock(&globals.used, Memento_Internal_checkAllocedBlock, &data, memblk); if (!data.found) { /* Failure! */ fprintf(...
functions
else if (data.preCorrupt || data.postCorrupt) { fprintf(stderr, "Block "); showBlock(memblk, ' '); fprintf(stderr, " found to be corrupted on %s!\n", action); if (data.preCorrupt) { fprintf(stderr, "Preguard corrupted\n"); }
functions
void Memento_free(void *blk) { Memento_BlkHeader *memblk; if (!globals.inited) Memento_init(); Memento_event(); if (blk == NULL) return; memblk = MEMBLK_FROMBLK(blk); VALGRIND_MAKE_MEM_DEFINED(memblk, sizeof(*memblk)); if (checkBlock(memblk, "free")) return; ...
functions
int Memento_checkBlock(void *blk) { Memento_BlkHeader *memblk; if (blk == NULL) return 0; memblk = MEMBLK_FROMBLK(blk); return checkBlock(memblk, "check"); }
functions
int Memento_Internal_checkAllAlloced(Memento_BlkHeader *memblk, void *arg) { BlkCheckData *data = (BlkCheckData *)arg; Memento_Internal_checkAllocedBlock(memblk, data); if (data->preCorrupt || data->postCorrupt) { if ((data->found & 2) == 0) { fprintf(stderr, "Allocated blocks:\n"); ...
functions
int Memento_Internal_checkAllFreed(Memento_BlkHeader *memblk, void *arg) { BlkCheckData *data = (BlkCheckData *)arg; Memento_Internal_checkFreedBlock(memblk, data); if (data->preCorrupt || data->postCorrupt || data->freeCorrupt) { if ((data->found & 4) == 0) { fprintf(stderr, "Freed blo...
functions
int Memento_checkAllMemory(void) { #ifndef MEMENTO_LEAKONLY BlkCheckData data; memset(&data, 0, sizeof(data)); Memento_appBlocks(&globals.used, Memento_Internal_checkAllAlloced, &data); Memento_appBlocks(&globals.free, Memento_Internal_checkAllFreed, &data); if (data.found & 6) { Memento_br...
functions
int Memento_setParanoia(int i) { globals.paranoia = i; globals.countdown = globals.paranoia; return i; }
functions
int Memento_paranoidAt(int i) { globals.paranoidAt = i; return i; }
functions
int Memento_getBlockNum(void *b) { Memento_BlkHeader *memblk; if (b == NULL) return 0; memblk = MEMBLK_FROMBLK(b); return (memblk->sequence); }
functions
int Memento_check(void) { int result; fprintf(stderr, "Checking memory\n"); result = Memento_checkAllMemory(); fprintf(stderr, "Memory checked!\n"); return result; }
functions
int Memento_containsAddr(Memento_BlkHeader *b, void *arg) { findBlkData *data = (findBlkData *)arg; char *blkend = &((char *)MEMBLK_TOBLK(b))[b->rawsize]; if ((MEMBLK_TOBLK(b) <= data->addr) && ((void *)blkend > data->addr)) { data->blk = b; data->flag...
functions
int Memento_find(void *a) { findBlkData data; data.addr = a; data.blk = NULL; data.flags = 0; Memento_appBlocks(&globals.used, Memento_containsAddr, &data); if (data.blk != NULL) { fprintf(stderr, "Address 0x%p is in %sallocated block ", data.addr, (da...
functions
void Memento_breakOnFree(void *a) { findBlkData data; data.addr = a; data.blk = NULL; data.flags = 0; Memento_appBlocks(&globals.used, Memento_containsAddr, &data); if (data.blk != NULL) { fprintf(stderr, "Will stop when address 0x%p (in %sallocated block ", data.addr...
functions
void Memento_breakOnRealloc(void *a) { findBlkData data; data.addr = a; data.blk = NULL; data.flags = 0; Memento_appBlocks(&globals.used, Memento_containsAddr, &data); if (data.blk != NULL) { fprintf(stderr, "Will stop when address 0x%p (in %sallocated block ", data.a...
functions
int Memento_failAt(int i) { globals.failAt = i; if ((globals.sequence > globals.failAt) && (globals.failing != 0)) Memento_startFailing(); return i; }
functions
size_t Memento_setMax(size_t max) { globals.maxMemory = max; return max; }
functions
void Memento_free(void *b) { MEMENTO_UNDERLYING_FREE(b); }
functions
lapack_int LAPACKE_cherfsx( int matrix_order, char uplo, char equed, lapack_int n, lapack_int nrhs, const lapack_complex_float* a, lapack_int lda, const lapack_complex_float* af, lapack_int ldaf, const lapack...
includes
#include <complex.h>
functions
double creal(double complex z) { return z; }
includes
#include <sys/types.h>
includes
#include <stdio.h>
includes
#include <stdint.h>
includes
#include <stdbool.h>
includes
#include <errno.h>
includes
#include <ruby.h>