type
stringclasses
5 values
content
stringlengths
9
163k
functions
void PyErr_WriteUnraisable(PyObject *obj) { printf("Unraisable Exception\n"); // PyObject *f, *t, *v, *tb; // PyErr_Fetch(&t, &v, &tb); // f = PySys_GetObject("stderr"); // if (f != NULL) { // PyFile_WriteString("Exception ", f); // if (t) { // PyFile_WriteObject(t, f, Py_PRINT_RAW); // if (v &&...
functions
int PyErr_Warn(PyObject *category, char *message) { PyObject *dict, *func = NULL; PyObject *warnings_module = PyModule_GetWarningsModule(); if (warnings_module != NULL) { dict = PyModule_GetDict(warnings_module); func = PyDict_GetItemString(dict, "warn"); }
includes
#include <include/lifecycle.h>
functions
void echo(lifecycle_Foo this, char* hook) { corto_state s = corto_stateof(this); char *stateStr = corto_ptr_str(&s, corto_state_o, 0); corto_info("callback: %s [%s]", hook, stateStr); free(stateStr); }
functions
int16_t lifecycle_Foo_construct( lifecycle_Foo this) { echo(this, "construct"); return 0; }
functions
void lifecycle_Foo_define( lifecycle_Foo this) { echo(this, "define"); }
functions
void lifecycle_Foo_deinit( lifecycle_Foo this) { echo(this, "deinit"); }
functions
void lifecycle_Foo_delete( lifecycle_Foo this) { echo(this, "delete"); }
functions
void lifecycle_Foo_destruct( lifecycle_Foo this) { echo(this, "destruct"); }
functions
int16_t lifecycle_Foo_init( lifecycle_Foo this) { echo(this, "init"); return 0; }
functions
void lifecycle_Foo_update( lifecycle_Foo this) { echo(this, "update"); }
functions
int16_t lifecycle_Foo_validate( lifecycle_Foo this) { echo(this, "validate"); return 0; }
functions
ICACHE_FLASH_ATTR coap_dumpHeader(coap_header_t *hdr) { shell_printf("Header:\n"); shell_printf(" ver 0x%02X\n", hdr->ver); shell_printf(" t 0x%02X\n", hdr->t); shell_printf(" tkl 0x%02X\n", hdr->tkl); shell_printf(" code 0x%02X\n", hdr->code); shell_printf(" id 0x%02X%02X\n",...
functions
ICACHE_FLASH_ATTR coap_dump(const uint8_t *buf, size_t buflen, bool bare) { if (bare) { while(buflen--) shell_printf("%02X%s", *buf++, (buflen > 0) ? " " : ""); }
functions
ICACHE_FLASH_ATTR coap_parseHeader(coap_header_t *hdr, const uint8_t *buf, size_t buflen) { if (buflen < 4) return COAP_ERR_HEADER_TOO_SHORT; hdr->ver = (buf[0] & 0xC0) >> 6; if (hdr->ver != 1) return COAP_ERR_VERSION_NOT_1; hdr->t = (buf[0] & 0x30) >> 4; hdr->tkl = buf[0] & ...
functions
ICACHE_FLASH_ATTR coap_parseToken(coap_buffer_t *tokbuf, const coap_header_t *hdr, const uint8_t *buf, size_t buflen) { if (hdr->tkl == 0) { tokbuf->p = NULL; tokbuf->len = 0; return 0; }
functions
else if (hdr->tkl <= 8) { if (4U + hdr->tkl > buflen) return COAP_ERR_TOKEN_TOO_SHORT; // tok bigger than packet tokbuf->p = buf+4; // past header tokbuf->len = hdr->tkl; return 0; }
functions
ICACHE_FLASH_ATTR coap_parseOption(coap_option_t *option, uint16_t *running_delta, const uint8_t **buf, size_t buflen) { const uint8_t *p = *buf; uint8_t headlen = 1; uint16_t len, delta; if (buflen < headlen) // too small return COAP_ERR_OPTION_TOO_SHORT_FOR_HEADER; delta = (p[0]...
functions
else if (delta == 14) { headlen += 2; if (buflen < headlen) return COAP_ERR_OPTION_TOO_SHORT_FOR_HEADER; delta = ((p[1] << 8) | p[2]) + 269; p+=2; }
functions
else if (len == 14) { headlen += 2; if (buflen < headlen) return COAP_ERR_OPTION_TOO_SHORT_FOR_HEADER; len = ((p[1] << 8) | p[2]) + 269; p+=2; }
functions
ICACHE_FLASH_ATTR coap_parseOptionsAndPayload(coap_option_t *options, uint8_t *numOptions, coap_buffer_t *payload, const coap_header_t *hdr, const uint8_t *buf, size_t buflen) { size_t optionIndex = 0; uint16_t delta = 0; const uint8_t *p = buf + 4 + hdr->tkl; const uint8_t *end = buf + buflen; ...
functions
ICACHE_FLASH_ATTR coap_dumpOptions(coap_option_t *opts, size_t numopt) { size_t i; shell_printf("Options:\n"); for (i=0;i<numopt;i++) { shell_printf(" 0x%02X [ ", opts[i].num); coap_dump(opts[i].buf.p, opts[i].buf.len, true); shell_printf(" ]\n"); }
functions
ICACHE_FLASH_ATTR coap_dumpPacket(coap_packet_t *pkt) { coap_dumpHeader(&pkt->hdr); coap_dumpOptions(pkt->opts, pkt->numopts); shell_printf("Payload: \n"); coap_dump(pkt->payload.p, pkt->payload.len, true); shell_printf("\n"); }
functions
ICACHE_FLASH_ATTR coap_parse(coap_packet_t *pkt, const uint8_t *buf, size_t buflen) { int rc; // coap_dump(buf, buflen, false); if (0 != (rc = coap_parseHeader(&pkt->hdr, buf, buflen))) return rc; // coap_dumpHeader(&hdr); if (0 != (rc = coap_parseToken(&pkt->tok, &pkt->hdr, buf, b...
functions
ICACHE_FLASH_ATTR coap_findOptions(const coap_packet_t *pkt, uint8_t num, uint8_t *count) { // FIXME, options is always sorted, can find faster than this size_t i; const coap_option_t *first = NULL; *count = 0; for (i=0;i<pkt->numopts;i++) { if (pkt->opts[i].num == num) ...
functions
ICACHE_FLASH_ATTR coap_buffer_to_string(char *strbuf, size_t strbuflen, const coap_buffer_t *buf) { if (buf->len+1 > strbuflen) return COAP_ERR_BUFFER_TOO_SMALL; memcpy(strbuf, buf->p, buf->len); strbuf[buf->len] = 0; return 0; }
functions
ICACHE_FLASH_ATTR coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt) { size_t opts_len = 0; size_t i; uint8_t *p; uint16_t running_delta = 0; // build header if (*buflen < (4U + pkt->hdr.tkl)) return COAP_ERR_BUFFER_TOO_SMALL; buf[0] = (pkt->hdr.ver & 0x0...
functions
else if (delta == 14) { *p++ = ((optDelta-269) >> 8); *p++ = (0xFF & (optDelta-269)); }
functions
else if (len == 14) { *p++ = (pkt->opts[i].buf.len >> 8); *p++ = (0xFF & (pkt->opts[i].buf.len-269)); }
functions
options if (pkt->payload.len > 0) { if (*buflen < 4 + 1 + pkt->payload.len + opts_len) return COAP_ERR_BUFFER_TOO_SMALL; buf[4 + opts_len] = 0xFF; // payload marker memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len); *buflen = opts_len + 5 + pkt->pay...
functions
ICACHE_FLASH_ATTR coap_option_nibble(uint32_t value, uint8_t *nibble) { if (value<13) { *nibble = (0xFF & value); }
functions
else if (value<=0xFF+13) { *nibble = 13; }
functions
else if (value<=0xFFFF+269) { *nibble = 14; }
functions
ICACHE_FLASH_ATTR coap_make_response(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const uint8_t *content, size_t content_len, uint8_t msgid_hi, uint8_t msgid_lo, const coap_buffer_t* tok, coap_responsecode_t rspcode, coap_content_type_t content_type) { pkt->hdr.ver = 0x01; pkt->hdr.t = COAP_TYPE_ACK; ...
functions
ICACHE_FLASH_ATTR coap_handle_req(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt) { const coap_option_t *opt; uint8_t count; int i; const coap_endpoint_t *ep = endpoints; while(NULL != ep->handler) { if (ep->method != inpkt->hdr.code) ...
functions
void coap_setup(void) { }
includes
#include <stdio.h>
includes
#include <stdlib.h>
includes
#include <string.h>
functions
else if ( flags & OUTPUT_FILE ) { if ( out_file == NULL ) { printf( "\nNo output file provided.\nQuitting\n\n" ); return EXIT_FAILURE; }
functions
Flag parse_args( int num_args, char* args[] ) { Flag flags = 0; short i, j; for ( i = 1; i < num_args; i++ ) { if ( strcmp( args[i], "--manpage" ) == 0 ) { print_man( args[0] ); exit( EXIT_SUCCESS ); }
functions
void print_man( char* prog_name ) { printf( "\nNAME\n\ttsl - generate test frames from a specification file\n" ); printf( "\nSYNOPSIS\n\ttsl [ --manpage ] [ -cs ] input_file [ -o output_file ]\n" ); printf( "\nDESCRIPTION\n\tThe TSL utility generates test frames from a specification file\n" ); printf( "...
functions
int cleanup( void ) { Choice* curr_choice; int total_size = 0; short i, j; for ( i = 0; i < tot_cats; i++ ) { total_size += sizeof( Category ); for ( j = 0; j < cats[i] -> num_choices; j++ ) { total_size += sizeof( Choice ); curr_cho...
functions
int free_expr( Expression* expr ) { int expr_size = sizeof( Expression ); if ( expr -> flags & EXPR_A ) expr_size += free_expr( expr -> exprA ); if ( expr -> flags & EXPR_B ) expr_size += free_expr( expr -> exprB ); free( expr ); return expr_size; }
main
int main( int argc, char* argv[] ) { Flag flags; /* program flags */ int num_frames; char filename[ 30 ], answer[ 5 ]; /* user response */ if ( argc == 1 ) { printf( "\nUSAGE: %s [ --manpage ] [ -cs ] input_file [ -o output_file ]\n\n", argv[0] ); ...
includes
#include <stdio.h>
includes
#include <stdlib.h>
includes
#include <unistd.h>
includes
#include <string.h>
includes
#include <errno.h>
includes
#include <fcntl.h>
includes
#include <sys/socket.h>
includes
#include <sys/stat.h>
includes
#include <aranea/aranea.h>
defines
#define CGI_EXT_LEN_ ((int)sizeof(CGI_EXT) - 1)
defines
#define CGI_BUFF g_buff
defines
#define CGI_ADD_ENV_(env, cnt, buf, ...) \
functions
int cgi_hit(const char *name, const int len) { if (len > CGI_EXT_LEN_) { if (memcmp(name + len - CGI_EXT_LEN_, CGI_EXT, CGI_EXT_LEN_) == 0) { return 1; }
functions
int cgi_is_executable(const char *path, struct client_t *client) { struct stat st; if (access(path, X_OK) != 0) { client->response.status_code = HTTP_STATUS_FORBIDDEN; return -1; }
functions
int cgi_gen_env(const struct request_t *req, char **env) { int cnt, len; char *buf; cnt = 0; buf = CGI_BUFF; #ifdef CGI_DOCUMENT_ROOT CGI_ADD_ENV_(env, cnt, buf, "DOCUMENT_ROOT=%s", g_config.root); #endif #ifdef CGI_REQUEST_METHOD CGI_ADD_ENV_(env, cnt, buf, "REQUEST_METHOD=%s", req->method); ...
functions
CGI_HTTP_COOKIE if (req->header[HEADER_COOKIE]) { CGI_ADD_ENV_(env, cnt, buf, "HTTP_COOKIE=%s", req->header[HEADER_COOKIE]); }
functions
int cgi_exec(const char *path, struct client_t *client) { char *argv[2]; char *envp[MAX_CGIENV_ITEM]; pid_t pid; int newio; /* set socket back to blocking */ newio = fcntl(client->remote_fd, F_GETFL, NULL); if (newio == -1 || fcntl(client->remote_fd, F_SETFL, newio & (~O_NONBLOC...
functions
int cgi_process(struct client_t *client, const char *path) { if (cgi_is_executable(path, client) != 0) { return -1; }
includes
#include <lcthw/darray_algos.h>
includes
#include <stdlib.h>
includes
#include <time.h>
includes
#include <limits.h>
functions
int intcmp(int **a, int **b) { return **a - **b; }
functions
int sintcmp(int *a, int *b) { return *a - *b; }
functions
int make_random(DArray *array, size_t n) { srand(time(NULL)); size_t i = 0; for(i = 0; i < n; i++) { int *random = DArray_new(array); *random = rand(); check(DArray_push(array, random) == 0, "Inserting random values failed."); }
functions
int is_sorted(DArray *array, DArray_compare cmp) { int i = 0; for(i = 0; i < DArray_count(array) - 1; i++) { if(cmp(DArray_get(array, i), DArray_get(array, i+1)) > 0) { return 0; }
includes
#include <common.h>
includes
#include <dm.h>
includes
#include <malloc.h>
includes
#include <sdhci.h>
includes
#include <fdtdec.h>
includes
#include <linux/libfdt.h>
includes
#include <asm/gpio.h>
includes
#include <asm/arch/mmc.h>
includes
#include <asm/arch/clk.h>
includes
#include <errno.h>
includes
#include <asm/arch/pinmux.h>
structs
struct s5p_sdhci_plat { struct mmc_config cfg; struct mmc mmc; };
functions
void s5p_sdhci_set_control_reg(struct sdhci_host *host) { unsigned long val, ctrl; /* * SELCLKPADDS[17:16] * 00 = 2mA * 01 = 4mA * 10 = 7mA * 11 = 9mA */ sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4); val = sdhci_readl(host, SDHCI_CONTROL2); val &= SDHCI_CTRL2_SELBASECLK_MASK(3); v...
functions
void s5p_set_clock(struct sdhci_host *host, u32 div) { /* ToDo : Use the Clock Framework */ set_mmc_clk(host->index, div); }
functions
int s5p_sdhci_core_init(struct sdhci_host *host) { host->name = S5P_NAME; host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; host->max_clk = 52000000; host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165...
functions
int s5p_sdhci_init(u32 regbase, int index, int bus_width) { struct sdhci_host *host = calloc(1, sizeof(struct sdhci_host)); if (!host) { printf("sdhci__host allocation fail!\n"); return -ENOMEM; }
functions
int do_sdhci_init(struct sdhci_host *host) { int dev_id, flag, ret; flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE; dev_id = host->index + PERIPH_ID_SDMMC0; ret = exynos_pinmux_config(dev_id, flag); if (ret) { printf("external SD not configured\n"); return ret; }
functions
int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) { int bus_width, dev_id; unsigned int base; /* Get device id */ dev_id = pinmux_decode_periph_id(blob, node); if (dev_id < PERIPH_ID_SDMMC0 || dev_id > PERIPH_ID_SDMMC3) { debug("MMC: Can't get device id\n"); return -EINVAL; }
functions
int process_nodes(const void *blob, int node_list[], int count) { struct sdhci_host *host; int i, node, ret; int failed = 0; debug("%s: count = %d\n", __func__, count); /* build sdhci_host[] for each controller */ for (i = 0; i < count; i++) { node = node_list[i]; if (node <= 0) continue; host = &sdhc...
functions
int exynos_mmc_init(const void *blob) { int count; int node_list[SDHCI_MAX_HOSTS]; count = fdtdec_find_aliases_for_id(blob, "mmc", COMPAT_SAMSUNG_EXYNOS_MMC, node_list, SDHCI_MAX_HOSTS); return process_nodes(blob, node_list, count); }
functions
int s5p_sdhci_probe(struct udevice *dev) { struct s5p_sdhci_plat *plat = dev_get_platdata(dev); struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct sdhci_host *host = dev_get_priv(dev); int ret; ret = sdhci_get_config(gd->fdt_blob, dev_of_offset(dev), host); if (ret) return ret; ret = do_sdhci_i...
functions
int s5p_sdhci_bind(struct udevice *dev) { struct s5p_sdhci_plat *plat = dev_get_platdata(dev); int ret; ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); if (ret) return ret; return 0; }
defines
#define __FIL_BUILDING_LOCKING__
functions
int _lock_init(PyFilLock *self, PyObject *args, PyObject *kwargs) { return 0; }
functions
void _lock_dealloc(PyFilLock *self) { assert(fil_waiterlist_empty(self->waiters)); PyObject_Del(self); }
functions
int __lock_acquire(PyFilLock *lock, int blocking, struct timespec *ts) { if (!lock->locked && fil_waiterlist_empty(lock->waiters)) { lock->locked = 1; return 0; }
functions
int __lock_release(PyFilLock *lock) { if (!lock->locked) { PyErr_SetString(PyExc_RuntimeError, "release without acquire"); return -1; }
functions
int __rlock_acquire(PyFilRLock *lock, int blocking, struct timespec *ts) { uint64_t owner; owner = fil_get_ident(); if (!lock->lock.locked && fil_waiterlist_empty(lock->lock.waiters)) { lock->lock.locked = 1; lock->owner = owner; lock->count = 1; return 0; }
functions
int __rlock_release(PyFilRLock *lock) { if (!lock->lock.locked || (fil_get_ident() != lock->owner)) { PyErr_SetString(PyExc_RuntimeError, "cannot release un-acquired lock"); return -1; }