docstring stringlengths 22 576 | signature stringlengths 9 317 | prompt stringlengths 57 886 | code stringlengths 20 1.36k | repository stringclasses 49
values | language stringclasses 2
values | license stringclasses 9
values | stars int64 15 21.3k |
|---|---|---|---|---|---|---|---|
/* Lock/Unlock the Cfg registers, to prevent any RF write access.
Needs the I2C Password presentation to be effective. */ | int32_t BSP_NFCTAG_WriteLockCFG(uint32_t Instance, const ST25DV_LOCK_STATUS LockCfg) | /* Lock/Unlock the Cfg registers, to prevent any RF write access.
Needs the I2C Password presentation to be effective. */
int32_t BSP_NFCTAG_WriteLockCFG(uint32_t Instance, const ST25DV_LOCK_STATUS LockCfg) | {
UNUSED(Instance);
return ST25DV_WriteLockCFG(&NfcTagObj, LockCfg);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Change Logs: Date Author Notes Bernard first version */ | int finsh_init(struct finsh_parser *parser) | /* Change Logs: Date Author Notes Bernard first version */
int finsh_init(struct finsh_parser *parser) | {
finsh_parser_init(parser);
finsh_node_init();
finsh_var_init();
finsh_error_init();
finsh_heap_init();
return 0;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* This function is the same as 'ubifs_change_one_lp()' but @dirty is added to current dirty space, not substitutes it. */ | int ubifs_update_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, int flags_set, int flags_clean) | /* This function is the same as 'ubifs_change_one_lp()' but @dirty is added to current dirty space, not substitutes it. */
int ubifs_update_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, int flags_set, int flags_clean) | {
int err = 0, flags;
const struct ubifs_lprops *lp;
ubifs_get_lprops(c);
lp = ubifs_lpt_lookup_dirty(c, lnum);
if (IS_ERR(lp)) {
err = PTR_ERR(lp);
goto out;
}
flags = (lp->flags | flags_set) & ~flags_clean;
lp = ubifs_change_lp(c, lp, free, lp->dirty + dirty, flags, 0);
if (IS_ERR(lp))
err = PTR_ERR(lp);
out:
ubifs_release_lprops(c);
if (err)
ubifs_err("cannot update properties of LEB %d, error %d",
lnum, err);
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state param count Bytes sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */ | status_t FLEXIO_I2S_TransferGetSendCount(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, size_t *count) | /* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state param count Bytes sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */
status_t FLEXIO_I2S_TransferGetSendCount(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, size_t *count) | {
assert(handle);
status_t status = kStatus_Success;
if (handle->state != kFLEXIO_I2S_Busy)
{
status = kStatus_NoTransferInProgress;
}
else
{
*count = (handle->transferSize[handle->queueDriver] - handle->queue[handle->queueDriver].dataSize);
}
return status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This is used as the signal handler. This is called with the brand new stack (thanks to sigaltstack). We have to return, given that this is a signal handler and the sigmask and some other things are changed. */ | static void coroutine_trampoline(int signal) | /* This is used as the signal handler. This is called with the brand new stack (thanks to sigaltstack). We have to return, given that this is a signal handler and the sigmask and some other things are changed. */
static void coroutine_trampoline(int signal) | {
CoroutineUContext *self;
Coroutine *co;
CoroutineThreadState *coTS;
coTS = coroutine_get_thread_state();
self = coTS->tr_handler;
coTS->tr_called = 1;
co = &self->base;
if (!sigsetjmp(coTS->tr_reenter, 0)) {
return;
}
coroutine_bootstrap(self, co);
} | ve3wwg/teensy3_qemu | C | Other | 15 |
/* @acb: The adapter device to be updated @dcb: A newly created and intialised device instance to add. */ | static void adapter_add_device(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb) | /* @acb: The adapter device to be updated @dcb: A newly created and intialised device instance to add. */
static void adapter_add_device(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb) | {
dcb->acb = acb;
if (list_empty(&acb->dcb_list))
acb->dcb_run_robin = dcb;
list_add_tail(&dcb->list, &acb->dcb_list);
acb->dcb_map[dcb->target_id] |= (1 << dcb->target_lun);
acb->children[dcb->target_id][dcb->target_lun] = dcb;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the I2C slave byte control. */ | void I2C_SlaveByteControlCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | /* Enables or disables the I2C slave byte control. */
void I2C_SlaveByteControlCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | {
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->CR1 |= I2C_CR1_SBC;
}
else
{
I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_SBC);
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Clear the pending state of a given event */ | void stm32_exti_clear_pending(unsigned int line) | /* Clear the pending state of a given event */
void stm32_exti_clear_pending(unsigned int line) | {
if (line < STM32F2_EXTI_NUM_LINES)
KINETIS_EXTI->pr = (1 << line);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* @np: device node from which the property value is to be read. @propname: name of the property to be searched. @len: requested length of property value */ | static void* of_find_property_value_of_size(const struct device_node *np, const char *propname, u32 len) | /* @np: device node from which the property value is to be read. @propname: name of the property to be searched. @len: requested length of property value */
static void* of_find_property_value_of_size(const struct device_node *np, const char *propname, u32 len) | {
struct property *prop = of_find_property(np, propname, NULL);
if (!prop)
return ERR_PTR(-EINVAL);
if (!prop->value)
return ERR_PTR(-ENODATA);
if (len > prop->length)
return ERR_PTR(-EOVERFLOW);
return prop->value;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* i8042_start() is called by serio core when port is about to finish registering. It will mark port as existing so i8042_interrupt can start sending data through it. */ | static int i8042_start(struct serio *serio) | /* i8042_start() is called by serio core when port is about to finish registering. It will mark port as existing so i8042_interrupt can start sending data through it. */
static int i8042_start(struct serio *serio) | {
struct i8042_port *port = serio->port_data;
port->exists = true;
mb();
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Count leaf blocks given a range of extent records. */ | STATIC void xfs_bmap_count_leaves(xfs_ifork_t *ifp, xfs_extnum_t idx, int numrecs, int *count) | /* Count leaf blocks given a range of extent records. */
STATIC void xfs_bmap_count_leaves(xfs_ifork_t *ifp, xfs_extnum_t idx, int numrecs, int *count) | {
int b;
for (b = 0; b < numrecs; b++) {
xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, idx + b);
*count += xfs_bmbt_get_blockcount(frp);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) | /* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) | {
if(huart->Instance==USART2)
{
__HAL_RCC_USART2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
}
else if(huart->Instance==USART6)
{
__HAL_RCC_USART6_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* setup the xstate image representing the init state */ | static void __init setup_xstate_init(void) | /* setup the xstate image representing the init state */
static void __init setup_xstate_init(void) | {
init_xstate_buf = alloc_bootmem(xstate_size);
init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Enter a NVIC mask section.
When a NVIC mask section is entered, specified NVIC interrupts are disabled. */ | void CORE_EnterNvicMask(CORE_nvicMask_t *nvicState, const CORE_nvicMask_t *disable) | /* Enter a NVIC mask section.
When a NVIC mask section is entered, specified NVIC interrupts are disabled. */
void CORE_EnterNvicMask(CORE_nvicMask_t *nvicState, const CORE_nvicMask_t *disable) | {
CORE_CRITICAL_SECTION(
*nvicState = *(CORE_nvicMask_t*)((uint32_t)&NVIC->ICER[0]);
*(CORE_nvicMask_t*)((uint32_t)&NVIC->ICER[0]) = *disable;
)
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */ | void Vector17_handler(void) | /* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector17_handler(void) | {
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (17 * 2))
JMP 0,X
}
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* This internal function is utilized by the MPU driver to combine a given region attribute configuration and size and fill-in a driver-specific structure with the correct MPU region attribute configuration. */ | static void get_region_attr_from_mpu_partition_info(nxp_mpu_region_attr_t *p_attr, const k_mem_partition_attr_t *attr, uint32_t base, uint32_t size) | /* This internal function is utilized by the MPU driver to combine a given region attribute configuration and size and fill-in a driver-specific structure with the correct MPU region attribute configuration. */
static void get_region_attr_from_mpu_partition_info(nxp_mpu_region_attr_t *p_attr, const k_mem_partition_attr_t *attr, uint32_t base, uint32_t size) | {
(void) base;
(void) size;
p_attr->attr = attr->ap_attr;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* 6.. FMS Information Report On Change (Unconfirmed Service Id = 17) 6..1. Request Message Parameters */ | static void dissect_ff_msg_fms_info_report_change_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree) | /* 6.. FMS Information Report On Change (Unconfirmed Service Id = 17) 6..1. Request Message Parameters */
static void dissect_ff_msg_fms_info_report_change_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree) | {
proto_tree *sub_tree;
col_set_str(pinfo->cinfo, COL_INFO, "FMS Information Report On Change Request");
if (!tree) {
return;
}
sub_tree = proto_tree_add_subtree(tree, tvb, offset, length,
ett_ff_fms_info_report_on_change_req, NULL, "FMS Information Report On Change Request");
proto_tree_add_item(sub_tree,
hf_ff_fms_info_report_on_change_req_idx, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
length -= 4;
if (length) {
proto_tree_add_item(sub_tree, hf_ff_data, tvb, offset, length, ENC_NA);
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Break an event (as read from SAL) into useful pieces so we can decide what to do with it. */ | static int scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc) | /* Break an event (as read from SAL) into useful pieces so we can decide what to do with it. */
static int scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc) | {
char *desc_end;
*src = get_unaligned_be32(event);
event += 4;
*code = get_unaligned_be32(event);
event += 4;
if (*event++ != 2) {
return -1;
}
if (*event++ != IR_ARG_INT) {
return -1;
}
*esp_code = get_unaligned_be32(event);
event += 4;
if (*event++ != IR_ARG_ASCII) {
return -1;
}
event[CHUNKSIZE-1] = '\0';
event += 2;
desc_end = desc + sprintf(desc, "%s", event);
for (desc_end--;
(desc_end != desc) && ((*desc_end == 0xd) || (*desc_end == 0xa));
desc_end--) {
*desc_end = '\0';
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* get the SSL verifying depth of the SSL */ | int SSL_get_verify_depth(const SSL *ssl) | /* get the SSL verifying depth of the SSL */
int SSL_get_verify_depth(const SSL *ssl) | {
SSL_ASSERT1(ssl);
return ssl->param.depth;
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Run through a list for as long as possible. Returns the count of successful jobs. */ | static int process_jobs(struct list_head *jobs, struct dm_kcopyd_client *kc, int(*fn)(struct kcopyd_job *)) | /* Run through a list for as long as possible. Returns the count of successful jobs. */
static int process_jobs(struct list_head *jobs, struct dm_kcopyd_client *kc, int(*fn)(struct kcopyd_job *)) | {
struct kcopyd_job *job;
int r, count = 0;
while ((job = pop(jobs, kc))) {
r = fn(job);
if (r < 0) {
if (job->rw == WRITE)
job->write_err = (unsigned long) -1L;
else
job->read_err = 1;
push(&kc->complete_jobs, job);
break;
}
if (r > 0) {
push_head(jobs, job);
break;
}
count++;
}
return count;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Not much to do here except clear the PF Reset indication if there is one. */ | static s32 e1000_init_hw_vf(struct e1000_hw *hw) | /* Not much to do here except clear the PF Reset indication if there is one. */
static s32 e1000_init_hw_vf(struct e1000_hw *hw) | {
e1000_rar_set_vf(hw, hw->mac.addr, 0);
return E1000_SUCCESS;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the default UART line controls.
This routine sets the given UART's line controls to their default settings. */ | static void line_control_defaults_set(const struct device *dev) | /* Set the default UART line controls.
This routine sets the given UART's line controls to their default settings. */
static void line_control_defaults_set(const struct device *dev) | {
const struct uart_stellaris_config *config = dev->config;
config->uart->lcrh = LINE_CONTROL_DEFAULTS;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Loads the time stamp higher sec value from the value supplied */ | void synopGMAC_TS_load_timestamp_higher_val(synopGMACdevice *gmacdev, u32 higher_sec_val) | /* Loads the time stamp higher sec value from the value supplied */
void synopGMAC_TS_load_timestamp_higher_val(synopGMACdevice *gmacdev, u32 higher_sec_val) | {
synopGMACWriteReg(gmacdev->MacBase,GmacTSHighWord, (higher_sec_val & GmacTSHighWordMask));
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* regAdress: Address of the register that has to be updated mask: Masks the bits of the register that have to be updated Bits masked with value 1 are read Bits masked with value 0 are set 0 shift: Amount of bits the data byte is shifted (right) after being masked return: read and processed bits or -1 on fail */ | int16_t readByteBitfield(uint8_t regAddress, uint8_t mask, uint8_t shift) | /* regAdress: Address of the register that has to be updated mask: Masks the bits of the register that have to be updated Bits masked with value 1 are read Bits masked with value 0 are set 0 shift: Amount of bits the data byte is shifted (right) after being masked return: read and processed bits or -1 on fail */
int16_t readByteBitfield(uint8_t regAddress, uint8_t mask, uint8_t shift) | {
int16_t ret = readByte(regAddress);
if (ret < 0) {
return ret;
}
return (((uint8_t)ret) & mask) >> shift;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Puts a data element into the SSI transmit FIFO. */ | void SSIDataPut(uint32_t ui32Base, uint32_t ui32Data) | /* Puts a data element into the SSI transmit FIFO. */
void SSIDataPut(uint32_t ui32Base, uint32_t ui32Data) | {
ASSERT(_SSIBaseValid(ui32Base));
ASSERT((ui32Data & (0xfffffffe << (HWREG(ui32Base + SSI_O_CR0) &
SSI_CR0_DSS_M))) == 0);
while (!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF))
{
}
HWREG(ui32Base + SSI_O_DR) = ui32Data;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function will get the number of data in the data queue. */ | rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue) | /* This function will get the number of data in the data queue. */
rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue) | {
rt_base_t level;
rt_int16_t len;
RT_ASSERT(queue != RT_NULL);
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
if (queue->is_empty)
{
return 0;
}
level = rt_spin_lock_irqsave(&(queue->spinlock));
if (queue->put_index > queue->get_index)
{
len = queue->put_index - queue->get_index;
}
else
{
len = queue->size + queue->put_index - queue->get_index;
}
rt_spin_unlock_irqrestore(&(queue->spinlock), level);
return len;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read an image into a buffer friom a source. */ | EFI_STATUS HBufferImageRead(IN CONST CHAR16 *FileName, IN CONST CHAR16 *DiskName, IN UINTN DiskOffset, IN UINTN DiskSize, IN UINTN MemOffset, IN UINTN MemSize, IN EDIT_FILE_TYPE BufferType, IN BOOLEAN Recover) | /* Read an image into a buffer friom a source. */
EFI_STATUS HBufferImageRead(IN CONST CHAR16 *FileName, IN CONST CHAR16 *DiskName, IN UINTN DiskOffset, IN UINTN DiskSize, IN UINTN MemOffset, IN UINTN MemSize, IN EDIT_FILE_TYPE BufferType, IN BOOLEAN Recover) | {
EFI_STATUS Status;
EDIT_FILE_TYPE BufferTypeBackup;
Status = EFI_SUCCESS;
HBufferImage.BufferType = BufferType;
BufferTypeBackup = HBufferImage.BufferType;
switch (BufferType) {
case FileTypeFileBuffer:
Status = HFileImageRead (FileName, Recover);
break;
case FileTypeDiskBuffer:
Status = HDiskImageRead (DiskName, DiskOffset, DiskSize, Recover);
break;
case FileTypeMemBuffer:
Status = HMemImageRead (MemOffset, MemSize, Recover);
break;
default:
Status = EFI_NOT_FOUND;
break;
}
if (EFI_ERROR (Status)) {
HBufferImage.BufferType = BufferTypeBackup;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Send an event on all LSAPs attached to this LAP. */ | static void irlmp_do_all_lsap_event(hashbin_t *lsap_hashbin, IRLMP_EVENT event) | /* Send an event on all LSAPs attached to this LAP. */
static void irlmp_do_all_lsap_event(hashbin_t *lsap_hashbin, IRLMP_EVENT event) | {
struct lsap_cb *lsap;
struct lsap_cb *lsap_next;
lsap = (struct lsap_cb *) hashbin_get_first(lsap_hashbin);
while (NULL != hashbin_find_next(lsap_hashbin,
(long) lsap,
NULL,
(void *) &lsap_next) ) {
irlmp_do_lsap_event(lsap, event, NULL);
lsap = lsap_next;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Currently used to update mapped file statistics, but the routine can be generalized to update other statistics as well. */ | void mem_cgroup_update_file_mapped(struct page *page, int val) | /* Currently used to update mapped file statistics, but the routine can be generalized to update other statistics as well. */
void mem_cgroup_update_file_mapped(struct page *page, int val) | {
struct mem_cgroup *mem;
struct mem_cgroup_stat *stat;
struct mem_cgroup_stat_cpu *cpustat;
int cpu;
struct page_cgroup *pc;
pc = lookup_page_cgroup(page);
if (unlikely(!pc))
return;
lock_page_cgroup(pc);
mem = pc->mem_cgroup;
if (!mem)
goto done;
if (!PageCgroupUsed(pc))
goto done;
cpu = smp_processor_id();
stat = &mem->stat;
cpustat = &stat->cpustat[cpu];
__mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED, val);
done:
unlock_page_cgroup(pc);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */ | gboolean _g_freedesktop_dbus_call_list_activatable_names_sync(_GFreedesktopDBus *proxy, gchar ***out_activatable_names, GCancellable *cancellable, GError **error) | /* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */
gboolean _g_freedesktop_dbus_call_list_activatable_names_sync(_GFreedesktopDBus *proxy, gchar ***out_activatable_names, GCancellable *cancellable, GError **error) | {
GVariant *_ret;
_ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
"ListActivatableNames",
g_variant_new ("()"),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
error);
if (_ret == NULL)
goto _out;
g_variant_get (_ret,
"(^as)",
out_activatable_names);
g_variant_unref (_ret);
_out:
return _ret != NULL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries starts looking for a set of contiguous parameter RAMs from the "slot" that is passed as an argument to the API. On failure the API will try to find a set of contiguous Parameter RAM slots from the remaining Parameter RAM slots */ | int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count) | /* If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries starts looking for a set of contiguous parameter RAMs from the "slot" that is passed as an argument to the API. On failure the API will try to find a set of contiguous Parameter RAM slots from the remaining Parameter RAM slots */
int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count) | {
if ((id != EDMA_CONT_PARAMS_ANY) &&
(slot < edma_info[ctlr]->num_channels ||
slot >= edma_info[ctlr]->num_slots))
return -EINVAL;
if (count < 1 || count >
(edma_info[ctlr]->num_slots - edma_info[ctlr]->num_channels))
return -EINVAL;
switch (id) {
case EDMA_CONT_PARAMS_ANY:
return reserve_contiguous_slots(ctlr, id, count,
edma_info[ctlr]->num_channels);
case EDMA_CONT_PARAMS_FIXED_EXACT:
case EDMA_CONT_PARAMS_FIXED_NOT_EXACT:
return reserve_contiguous_slots(ctlr, id, count, slot);
default:
return -EINVAL;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Compute the hash for the isofs name corresponding to the dentry. */ | static int isofs_hash_common(struct dentry *dentry, struct qstr *qstr, int ms) | /* Compute the hash for the isofs name corresponding to the dentry. */
static int isofs_hash_common(struct dentry *dentry, struct qstr *qstr, int ms) | {
const char *name;
int len;
len = qstr->len;
name = qstr->name;
if (ms) {
while (len && name[len-1] == '.')
len--;
}
qstr->hash = full_name_hash(name, len);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable the ip checksum offloading in receive path. Ip checksum offloading is disabled in the receive path. */ | void synopGMAC_disable_rx_Ipchecksum_offload(synopGMACdevice *gmacdev) | /* Disable the ip checksum offloading in receive path. Ip checksum offloading is disabled in the receive path. */
void synopGMAC_disable_rx_Ipchecksum_offload(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase, GmacConfig, GmacRxIpcOffload);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* found_key(): Found key without value in parameter list (comma separated). */ | static bool found_key(const char *str, const char *key) | /* found_key(): Found key without value in parameter list (comma separated). */
static bool found_key(const char *str, const char *key) | {
char *k;
char *s, *strcopy;
bool result = false;
strcopy = strdup(str);
if (!strcopy)
return NULL;
s = strcopy;
while (s) {
k = strsep(&s, ",");
if (!k)
break;
if (strcmp(k, key) == 0) {
result = true;
break;
}
}
free(strcopy);
return result;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Stops the Low Level portion of the Host driver. */ | USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost) | /* Stops the Low Level portion of the Host driver. */
USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost) | {
HAL_HCD_Stop(phost->pData);
return USBH_OK;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* This function sets the FSP info header pointer. */ | VOID EFIAPI SetFspInfoHeader(FSP_INFO_HEADER *FspInfoHeader) | /* This function sets the FSP info header pointer. */
VOID EFIAPI SetFspInfoHeader(FSP_INFO_HEADER *FspInfoHeader) | {
GetFspGlobalDataPointer ()->FspInfoHeader = FspInfoHeader;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* RTC MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc) | /* RTC MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc) | {
__HAL_RCC_RTC_DISABLE();
}
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up. */ | int wake_up_process(struct task_struct *p) | /* It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up. */
int wake_up_process(struct task_struct *p) | {
return try_to_wake_up(p, TASK_ALL, 0);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Fills each canConfig member with its default value. */ | void CAN_ConfigStructInit(CAN_Config_T *canConfig) | /* Fills each canConfig member with its default value. */
void CAN_ConfigStructInit(CAN_Config_T *canConfig) | {
canConfig->timeTrigComMode = DISABLE;
canConfig->autoBusOffManage = DISABLE;
canConfig->autoWakeUpMode = DISABLE;
canConfig->nonAutoRetran = DISABLE;
canConfig->rxFIFOLockMode = DISABLE;
canConfig->txFIFOPriority = DISABLE;
canConfig->mode = CAN_MODE_NORMAL;
canConfig->syncJumpWidth = CAN_SJW_1;
canConfig->timeSegment1 = CAN_TIME_SEGMENT1_4;
canConfig->timeSegment2 = CAN_TIME_SEGMENT2_3;
canConfig->prescaler = 1;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* The tree may not be modified while iterating over it (you can't add/remove items). To remove all items matching a predicate, you need to add each item to a list in your #GTraverseFunc as you walk over the tree, then walk the list and remove each item. */ | void g_tree_foreach(GTree *tree, GTraverseFunc func, gpointer user_data) | /* The tree may not be modified while iterating over it (you can't add/remove items). To remove all items matching a predicate, you need to add each item to a list in your #GTraverseFunc as you walk over the tree, then walk the list and remove each item. */
void g_tree_foreach(GTree *tree, GTraverseFunc func, gpointer user_data) | {
GTreeNode *node;
g_return_if_fail (tree != NULL);
if (!tree->root)
return;
node = g_tree_first_node (tree);
while (node)
{
if ((*func) (node->key, node->value, user_data))
break;
node = g_tree_node_next (node);
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Stops the TIMER one pulse signal generation on the complementary output. in interrupt mode. */ | void ald_timer_one_pulse_n_stop_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch) | /* Stops the TIMER one pulse signal generation on the complementary output. in interrupt mode. */
void ald_timer_one_pulse_n_stop_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch) | {
ald_timer_ocn_stop_by_it(hperh, ch);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Helper method for drivers which have no PATA cable detection. */ | int ata_cable_unknown(struct ata_port *ap) | /* Helper method for drivers which have no PATA cable detection. */
int ata_cable_unknown(struct ata_port *ap) | {
return ATA_CBL_PATA_UNK;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Application entry point for IPC example on core 0. */ | int main(void) | /* Application entry point for IPC example on core 0. */
int main(void) | {
sysclk_init();
board_init();
configure_ipc();
configure_console();
puts(STRING_HEADER);
copy_core1_image_into_sram1();
rstc_deassert_reset_of_coprocessor(RSTC, RSTC_CPMR_CPROCEN);
while (1) {
if (is_core1_signal == true) {
is_core1_signal = false;
LED_Off(LED0);
printf("Got IRQ signal from core1 %d\r\n", (int)*cnt);
delay_s(1);
ipc_set_command(IPC1, IPC_INTERRUPT_SRC_IRQ0);
}
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* This file is part of the Simba project. */ | int mock_write_i2c_soft_module_init(int res) | /* This file is part of the Simba project. */
int mock_write_i2c_soft_module_init(int res) | {
harness_mock_write("i2c_soft_module_init()",
NULL,
0);
harness_mock_write("i2c_soft_module_init(): return (res)",
&res,
sizeof(res));
return (0);
} | eerimoq/simba | C++ | Other | 337 |
/* Prints out raw parameter using given format. Caller needs to do byte swapping if needed. */ | static void print_raw_param(const char *, abi_long, int) | /* Prints out raw parameter using given format. Caller needs to do byte swapping if needed. */
static void print_raw_param(const char *, abi_long, int) | {
char format[64];
(void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
gemu_log(format, param);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Returns extended filter start address in message RAM */ | struct fdcan_extended_filter* fdcan_get_flesa_addr(uint32_t canport) | /* Returns extended filter start address in message RAM */
struct fdcan_extended_filter* fdcan_get_flesa_addr(uint32_t canport) | {
struct fdcan_extended_filter *lfesa = (struct fdcan_extended_filter *)
(CAN_MSG_BASE + FDCAN_LFESA_OFFSET(canport));
return lfesa;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* If 32-bit I/O port operations are not supported, then ASSERT(). */ | UINT32 EFIAPI IoRead32(IN UINTN Port) | /* If 32-bit I/O port operations are not supported, then ASSERT(). */
UINT32 EFIAPI IoRead32(IN UINTN Port) | {
ASSERT ((Port & 3) == 0);
return (UINT32)IoReadWorker (Port, SMM_IO_UINT32);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This file is part of the Simba project. */ | int mock_write_dht_module_init(int res) | /* This file is part of the Simba project. */
int mock_write_dht_module_init(int res) | {
harness_mock_write("dht_module_init()",
NULL,
0);
harness_mock_write("dht_module_init(): return (res)",
&res,
sizeof(res));
return (0);
} | eerimoq/simba | C++ | Other | 337 |
/* Interrupt handler for the RTC. Refresh the display. */ | void RTC_Handler(void) | /* Interrupt handler for the RTC. Refresh the display. */
void RTC_Handler(void) | {
uint32_t ul_status = rtc_get_status(RTC);
if ((ul_status & RTC_SR_SEC) == RTC_SR_SEC) {
rtc_disable_interrupt(RTC, RTC_IDR_SECDIS);
refresh_display();
rtc_clear_status(RTC, RTC_SCCR_SECCLR);
rtc_enable_interrupt(RTC, RTC_IER_SECEN);
} else {
if ((ul_status & RTC_SR_ALARM) == RTC_SR_ALARM) {
rtc_disable_interrupt(RTC, RTC_IDR_ALRDIS);
gs_ul_alarm_triggered = 1;
refresh_display();
gs_ul_menu_shown = 0;
rtc_clear_status(RTC, RTC_SCCR_ALRCLR);
rtc_enable_interrupt(RTC, RTC_IER_ALREN);
}
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* For SD8385/SD8686, this function reads firmware status after the image is downloaded, or reads RX packet length when interrupt (with IF_SDIO_H_INT_UPLD bit set) is received. For SD8688, this function reads firmware status only. */ | static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err) | /* For SD8385/SD8686, this function reads firmware status after the image is downloaded, or reads RX packet length when interrupt (with IF_SDIO_H_INT_UPLD bit set) is received. For SD8688, this function reads firmware status only. */
static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err) | {
int ret;
u16 scratch;
scratch = sdio_readb(card->func, card->scratch_reg, &ret);
if (!ret)
scratch |= sdio_readb(card->func, card->scratch_reg + 1,
&ret) << 8;
if (err)
*err = ret;
if (ret)
return 0xffff;
return scratch;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* qt2_boxsetsw_flowctl - Turn software (XON/XOFF) flow control on for a hardware UART, and set the XON and XOFF characters. */ | static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber, unsigned char stop_char, unsigned char start_char) | /* qt2_boxsetsw_flowctl - Turn software (XON/XOFF) flow control on for a hardware UART, and set the XON and XOFF characters. */
static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber, unsigned char stop_char, unsigned char start_char) | {
__u16 nSWflowout;
nSWflowout = start_char << 8;
nSWflowout = (unsigned short)stop_char;
return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
QT2_SW_FLOW_CONTROL_MASK, 0x40, nSWflowout, UartNumber,
NULL, 0, 300);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get the MODBUS slave address from the hardware pins. */ | static int32_t modbus_setup_get_slave_addr(struct modbus_slave *dev, struct modbus_slave_init_param *init_param, uint8_t *id) | /* Get the MODBUS slave address from the hardware pins. */
static int32_t modbus_setup_get_slave_addr(struct modbus_slave *dev, struct modbus_slave_init_param *init_param, uint8_t *id) | {
int16_t i;
struct gpio_desc *temp_gpio;
uint16_t gpio_value;
int32_t ret;
*id = 0;
for(i = 0; i < SLAVE_ID_BITS_NUMBER; i++) {
ret = gpio_get(&temp_gpio, init_param->slave_id_gpio[i]);
if(ret < 0)
return ret;
ret = gpio_direction_input(temp_gpio);
if(ret < 0)
return ret;
ret = gpio_get_value(temp_gpio, &gpio_value);
if(ret < 0)
return ret;
if(gpio_value != GPIO_LOW)
*id |= (uint8_t)((uint8_t)1 << i);
else
continue;
ret = gpio_remove(temp_gpio);
if(ret < 0)
return ret;
}
*id += 1;
return ret;
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Internal function to determine if a command is a script only command. */ | BOOLEAN IsScriptOnlyCommand(IN CONST CHAR16 *CommandName) | /* Internal function to determine if a command is a script only command. */
BOOLEAN IsScriptOnlyCommand(IN CONST CHAR16 *CommandName) | {
if ( IsCommand (CommandName, L"for")
|| IsCommand (CommandName, L"endfor")
|| IsCommand (CommandName, L"if")
|| IsCommand (CommandName, L"else")
|| IsCommand (CommandName, L"endif")
|| IsCommand (CommandName, L"goto"))
{
return (TRUE);
}
return (FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Iterates over the entire list first, freeing all the values, then frees the list itself. Returns 0 on success or -EINVAL if the key can't be found. */ | int scsi_dev_info_remove_list(int key) | /* Iterates over the entire list first, freeing all the values, then frees the list itself. Returns 0 on success or -EINVAL if the key can't be found. */
int scsi_dev_info_remove_list(int key) | {
struct list_head *lh, *lh_next;
struct scsi_dev_info_list_table *devinfo_table =
scsi_devinfo_lookup_by_key(key);
if (IS_ERR(devinfo_table))
return -EINVAL;
list_del(&devinfo_table->node);
list_for_each_safe(lh, lh_next, &devinfo_table->scsi_dev_info_list) {
struct scsi_dev_info_list *devinfo;
devinfo = list_entry(lh, struct scsi_dev_info_list,
dev_info_list);
kfree(devinfo);
}
kfree(devinfo_table);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* It checks if Vbus is below the safe voltage threshold. */ | USBPD_StatusTypeDef USBPD_HW_IF_HR_CheckVbusVSafe0V(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole) | /* It checks if Vbus is below the safe voltage threshold. */
USBPD_StatusTypeDef USBPD_HW_IF_HR_CheckVbusVSafe0V(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole) | {
if (CurrentRole == USBPD_PORTPOWERROLE_SRC)
{
return USBPD_OK;
}
if (CurrentRole == USBPD_PORTPOWERROLE_SNK)
{
return STUSB1602_VBUS_Presence_Get(STUSB1602_I2C_Add(PortNum)) == VBUS_below_UVLO_threshold ? USBPD_OK : USBPD_BUSY;
}
return USBPD_ERROR;
} | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* Convert an Unix time to ADFS time. We only do this if the entry has a time/date stamp already. */ | static void adfs_unix2adfs_time(struct inode *inode, unsigned int secs) | /* Convert an Unix time to ADFS time. We only do this if the entry has a time/date stamp already. */
static void adfs_unix2adfs_time(struct inode *inode, unsigned int secs) | {
unsigned int high, low;
if (ADFS_I(inode)->stamped) {
low = (secs & 255) * 100;
high = (secs / 256) * 100 + (low >> 8) + 0x336e996a;
ADFS_I(inode)->loadaddr = (high >> 24) |
(ADFS_I(inode)->loadaddr & ~0xff);
ADFS_I(inode)->execaddr = (low & 255) | (high << 8);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns the newly created instance of #CRParser, or NULL if an error occured. */ | CRParser* cr_parser_new(CRTknzr *a_tknzr) | /* Returns the newly created instance of #CRParser, or NULL if an error occured. */
CRParser* cr_parser_new(CRTknzr *a_tknzr) | {
CRParser *result = NULL;
enum CRStatus status = CR_OK;
result = g_malloc0 (sizeof (CRParser));
PRIVATE (result) = g_malloc0 (sizeof (CRParserPriv));
if (a_tknzr) {
status = cr_parser_set_tknzr (result, a_tknzr);
}
g_return_val_if_fail (status == CR_OK, NULL);
return result;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* If Sha1Context is NULL, then return FALSE. If NewSha1Context is NULL, then return FALSE. */ | BOOLEAN EFIAPI Sha1Duplicate(IN CONST VOID *Sha1Context, OUT VOID *NewSha1Context) | /* If Sha1Context is NULL, then return FALSE. If NewSha1Context is NULL, then return FALSE. */
BOOLEAN EFIAPI Sha1Duplicate(IN CONST VOID *Sha1Context, OUT VOID *NewSha1Context) | {
if ((Sha1Context == NULL) || (NewSha1Context == NULL)) {
return FALSE;
}
mbedtls_sha1_clone (NewSha1Context, Sha1Context);
return TRUE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: the #GList element at the tail of the queue, or NULL if the queue is empty */ | GList* g_queue_pop_tail_link(GQueue *queue) | /* Returns: the #GList element at the tail of the queue, or NULL if the queue is empty */
GList* g_queue_pop_tail_link(GQueue *queue) | {
g_return_val_if_fail (queue != NULL, NULL);
if (queue->tail)
{
GList *node = queue->tail;
queue->tail = node->prev;
if (queue->tail)
{
queue->tail->next = NULL;
node->prev = NULL;
}
else
queue->head = NULL;
queue->length--;
return node;
}
return NULL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Retrieve capability information for the specified ISDN controller or (for @contr == 0) the number of installed controllers. Return value: CAPI result code */ | u16 capi20_get_profile(u32 contr, struct capi_profile *profp) | /* Retrieve capability information for the specified ISDN controller or (for @contr == 0) the number of installed controllers. Return value: CAPI result code */
u16 capi20_get_profile(u32 contr, struct capi_profile *profp) | {
struct capi_ctr *card;
if (contr == 0) {
profp->ncontroller = ncards;
return CAPI_NOERROR;
}
card = get_capi_ctr_by_nr(contr);
if (!card || card->cardstate != CARD_RUNNING)
return CAPI_REGNOTINSTALLED;
memcpy((void *) profp, &card->profile,
sizeof(struct capi_profile));
return CAPI_NOERROR;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Find a network profile through its' profile index. */ | WIFI_MGR_NETWORK_PROFILE* WifiMgrGetProfileByProfileIndex(IN UINT32 ProfileIndex, IN LIST_ENTRY *ProfileList) | /* Find a network profile through its' profile index. */
WIFI_MGR_NETWORK_PROFILE* WifiMgrGetProfileByProfileIndex(IN UINT32 ProfileIndex, IN LIST_ENTRY *ProfileList) | {
WIFI_MGR_NETWORK_PROFILE *Profile;
LIST_ENTRY *Entry;
if (ProfileList == NULL) {
return NULL;
}
NET_LIST_FOR_EACH (Entry, ProfileList) {
Profile = NET_LIST_USER_STRUCT_S (
Entry,
WIFI_MGR_NETWORK_PROFILE,
Link,
WIFI_MGR_PROFILE_SIGNATURE
);
if (Profile->ProfileIndex == ProfileIndex) {
return Profile;
}
}
return NULL;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function returns the current value of the SysTick counter, which is a value between the period - 1 and zero, inclusive. */ | uint32_t SysTickValueGet(void) | /* This function returns the current value of the SysTick counter, which is a value between the period - 1 and zero, inclusive. */
uint32_t SysTickValueGet(void) | {
return (HWREG(NVIC_ST_CURRENT));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Reads and returns the current value of CR3. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */ | UINTN EFIAPI AsmReadCr3(VOID) | /* Reads and returns the current value of CR3. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmReadCr3(VOID) | {
UINTN Data;
__asm__ __volatile__ (
"mov %%cr3, %0"
: "=r" (Data)
);
return Data;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* CATS uses soft-reboot by default, since hard reboots fail on early boards. */ | static void __init fixup_cats(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) | /* CATS uses soft-reboot by default, since hard reboots fail on early boards. */
static void __init fixup_cats(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) | {
screen_info.orig_video_lines = 25;
screen_info.orig_video_points = 16;
screen_info.orig_y = 24;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* open "/proc/fs/afs/<cell>/servers" which provides a summary of active servers */ | static int afs_proc_cell_servers_open(struct inode *inode, struct file *file) | /* open "/proc/fs/afs/<cell>/servers" which provides a summary of active servers */
static int afs_proc_cell_servers_open(struct inode *inode, struct file *file) | {
struct afs_cell *cell;
struct seq_file *m;
int ret;
cell = PDE(inode)->data;
if (!cell)
return -ENOENT;
ret = seq_open(file, &afs_proc_cell_servers_ops);
if (ret < 0)
return ret;
m = file->private_data;
m->private = cell;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Updates the CRC32 value in the table header. */ | VOID PartitionSetCrcAltSize(IN UINTN Size, IN OUT EFI_TABLE_HEADER *Hdr) | /* Updates the CRC32 value in the table header. */
VOID PartitionSetCrcAltSize(IN UINTN Size, IN OUT EFI_TABLE_HEADER *Hdr) | {
UINT32 Crc;
Hdr->CRC32 = 0;
gBS->CalculateCrc32 ((UINT8 *)Hdr, Size, &Crc);
Hdr->CRC32 = Crc;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Suspend execution for microsecond intervals.
See IEEE 1003.1 */ | int usleep(useconds_t useconds) | /* Suspend execution for microsecond intervals.
See IEEE 1003.1 */
int usleep(useconds_t useconds) | {
int32_t rem;
if (useconds >= USEC_PER_SEC) {
errno = EINVAL;
return -1;
}
rem = k_usleep(useconds);
__ASSERT_NO_MSG(rem >= 0);
if (rem > 0) {
errno = EINTR;
return -1;
}
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Check if the time is right and execute __pm_request_suspend() in that case. */ | static void pm_suspend_timer_fn(unsigned long data) | /* Check if the time is right and execute __pm_request_suspend() in that case. */
static void pm_suspend_timer_fn(unsigned long data) | {
struct device *dev = (struct device *)data;
unsigned long flags;
unsigned long expires;
spin_lock_irqsave(&dev->power.lock, flags);
expires = dev->power.timer_expires;
if (expires > 0 && !time_after(expires, jiffies)) {
dev->power.timer_expires = 0;
__pm_request_suspend(dev);
}
spin_unlock_irqrestore(&dev->power.lock, flags);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns a pointer the matching flow, or NULL if the flow does not exist. */ | static struct sep_flow_context_t* sep_find_flow_context(struct sep_device *sep, unsigned long flow_id) | /* Returns a pointer the matching flow, or NULL if the flow does not exist. */
static struct sep_flow_context_t* sep_find_flow_context(struct sep_device *sep, unsigned long flow_id) | {
int count;
for (count = 0; count < SEP_DRIVER_NUM_FLOWS; count++) {
if (sep->flows[count].flow_id == flow_id)
return &sep->flows[count];
}
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* return 1 if something has been received from hw */ | static int get_packets_from_hw(struct ipw_hardware *hw) | /* return 1 if something has been received from hw */
static int get_packets_from_hw(struct ipw_hardware *hw) | {
int received = 0;
unsigned long flags;
spin_lock_irqsave(&hw->lock, flags);
while (hw->rx_ready && !hw->blocking_rx) {
received = 1;
hw->rx_ready--;
spin_unlock_irqrestore(&hw->lock, flags);
do_receive_packet(hw);
spin_lock_irqsave(&hw->lock, flags);
}
spin_unlock_irqrestore(&hw->lock, flags);
return received;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Check authenticatedAttributes are provided or not provided consistently. */ | static int pkcs7_check_authattrs(struct pkcs7_message *msg) | /* Check authenticatedAttributes are provided or not provided consistently. */
static int pkcs7_check_authattrs(struct pkcs7_message *msg) | {
struct pkcs7_signed_info *sinfo;
bool want = false;
sinfo = msg->signed_infos;
if (!sinfo)
goto inconsistent;
if (sinfo->authattrs) {
want = true;
msg->have_authattrs = true;
}
for (sinfo = sinfo->next; sinfo; sinfo = sinfo->next)
if (!!sinfo->authattrs != want)
goto inconsistent;
return 0;
inconsistent:
pr_warn("Inconsistently supplied authAttrs\n");
return -EINVAL;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* The Mem.Read(), and Mem.Write() functions enable a driver to access PCI controller registers in the PCI root bridge memory space. The memory operations are carried out exactly as requested. The caller is responsible for satisfying any alignment and memory width restrictions that a PCI Root Bridge on a platform might require. */ | EFI_STATUS EFIAPI RootBridgeIoMemRead(IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, OUT VOID *Buffer) | /* The Mem.Read(), and Mem.Write() functions enable a driver to access PCI controller registers in the PCI root bridge memory space. The memory operations are carried out exactly as requested. The caller is responsible for satisfying any alignment and memory width restrictions that a PCI Root Bridge on a platform might require. */
EFI_STATUS EFIAPI RootBridgeIoMemRead(IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Count, OUT VOID *Buffer) | {
EFI_STATUS Status;
PCI_ROOT_BRIDGE_INSTANCE *RootBridge;
UINT64 Translation;
Status = RootBridgeIoCheckParameter (
This,
MemOperation,
Width,
Address,
Count,
Buffer
);
if (EFI_ERROR (Status)) {
return Status;
}
RootBridge = ROOT_BRIDGE_FROM_THIS (This);
Status = RootBridgeIoGetMemTranslationByAddress (RootBridge, Address, &Translation);
if (EFI_ERROR (Status)) {
return Status;
}
return mCpuIo->Mem.Read (
mCpuIo,
(EFI_CPU_IO_PROTOCOL_WIDTH)Width,
TO_HOST_ADDRESS (Address, Translation),
Count,
Buffer
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Initialize SDIO function.
Initializes SDIO card function. The card function will not be enabled, but after this call returns the SDIO function structure can be used to read and write data from the card. */ | int sdio_init_func(struct sd_card *card, struct sdio_func *func, enum sdio_func_num num) | /* Initialize SDIO function.
Initializes SDIO card function. The card function will not be enabled, but after this call returns the SDIO function structure can be used to read and write data from the card. */
int sdio_init_func(struct sd_card *card, struct sdio_func *func, enum sdio_func_num num) | {
func->num = num;
func->card = card;
func->block_size = 0;
return sdio_read_cis(func, cis_tuples, ARRAY_SIZE(cis_tuples));
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* dispose of a keyring list after the RCU grace period, freeing the unlinked key */ | static void keyring_unlink_rcu_disposal(struct rcu_head *rcu) | /* dispose of a keyring list after the RCU grace period, freeing the unlinked key */
static void keyring_unlink_rcu_disposal(struct rcu_head *rcu) | {
struct keyring_list *klist =
container_of(rcu, struct keyring_list, rcu);
key_put(klist->keys[klist->delkey]);
kfree(klist);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* remove_ino - remove an entry from the size tree. */ | static void remove_ino(struct ubifs_info *c, ino_t inum) | /* remove_ino - remove an entry from the size tree. */
static void remove_ino(struct ubifs_info *c, ino_t inum) | {
struct size_entry *e = find_ino(c, inum);
if (!e)
return;
rb_erase(&e->rb, &c->size_tree);
kfree(e);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Function called at completion of last byte transmission. */ | void USART_CharTransmitComplete_Callback(void) | /* Function called at completion of last byte transmission. */
void USART_CharTransmitComplete_Callback(void) | {
if(ubSend == sizeof(aStringToSend))
{
ubSend = 0;
LL_USART_DisableIT_TC(USART1);
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* write to a secondary register on the PASIC3 */ | void pasic3_write_register(struct device *dev, u32 reg, u8 val) | /* write to a secondary register on the PASIC3 */
void pasic3_write_register(struct device *dev, u32 reg, u8 val) | {
struct pasic3_data *asic = dev_get_drvdata(dev);
int bus_shift = asic->bus_shift;
void __iomem *addr = asic->mapping + (REG_ADDR << bus_shift);
void __iomem *data = asic->mapping + (REG_DATA << bus_shift);
__raw_writeb(~READ_MODE & reg, addr);
__raw_writeb(val, data);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ioc3_cb_post_ncs - called for some basic errors @port: port to use @ncs: event */ | static void ioc3_cb_post_ncs(struct uart_port *the_port, int ncs) | /* ioc3_cb_post_ncs - called for some basic errors @port: port to use @ncs: event */
static void ioc3_cb_post_ncs(struct uart_port *the_port, int ncs) | {
struct uart_icount *icount;
icount = &the_port->icount;
if (ncs & NCS_BREAK)
icount->brk++;
if (ncs & NCS_FRAMING)
icount->frame++;
if (ncs & NCS_OVERRUN)
icount->overrun++;
if (ncs & NCS_PARITY)
icount->parity++;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* MSS_GPIO_init See "mss_gpio.h" for details of how to use this function. */ | void MSS_GPIO_init(void) | /* MSS_GPIO_init See "mss_gpio.h" for details of how to use this function. */
void MSS_GPIO_init(void) | {
uint32_t i;
SYSREG->SOFT_RST_CR |= SYSREG_GPIO_SOFTRESET_MASK;
for ( i = 0U; i < NB_OF_GPIO; ++i )
{
NVIC_ClearPendingIRQ( g_gpio_irqn_lut[i] );
}
SYSREG->SOFT_RST_CR &= ~SYSREG_GPIO_SOFTRESET_MASK;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Cancel out the denominator and numerator of a fraction to get smaller numerator and denominator. */ | void cancel_out(u32 *num, u32 *den, u32 den_limit) | /* Cancel out the denominator and numerator of a fraction to get smaller numerator and denominator. */
void cancel_out(u32 *num, u32 *den, u32 den_limit) | {
do_cancel_out(num, den, 2);
do_cancel_out(num, den, 3);
do_cancel_out(num, den, 5);
do_cancel_out(num, den, 7);
do_cancel_out(num, den, 11);
do_cancel_out(num, den, 13);
do_cancel_out(num, den, 17);
while ((*den) > den_limit) {
*num /= 2;
*den = (*den + 1) / 2;
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Create a new buffer list and stores the old one to OldBufferList */ | VOID SaveBufferList(OUT LIST_ENTRY *OldBufferList) | /* Create a new buffer list and stores the old one to OldBufferList */
VOID SaveBufferList(OUT LIST_ENTRY *OldBufferList) | {
CopyMem (OldBufferList, &ShellInfoObject.BufferToFreeList.Link, sizeof (LIST_ENTRY));
InitializeListHead (&ShellInfoObject.BufferToFreeList.Link);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Disable The Timer counter as a timer capture. */ | void TimerCaptureDisable(unsigned long ulBase) | /* Disable The Timer counter as a timer capture. */
void TimerCaptureDisable(unsigned long ulBase) | {
xASSERT((ulBase == TIMER3_BASE) || (ulBase == TIMER2_BASE) ||
(ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE));
xHWREG(ulBase + TIMER_TEXCON) &= ~TIMER_TEXCON_TEXEN;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* This function will check if the specified TLS handshake was done. */ | BOOLEAN EFIAPI TlsInHandshake(IN VOID *Tls) | /* This function will check if the specified TLS handshake was done. */
BOOLEAN EFIAPI TlsInHandshake(IN VOID *Tls) | {
TLS_CONNECTION *TlsConn;
TlsConn = (TLS_CONNECTION *)Tls;
if ((TlsConn == NULL) || (TlsConn->Ssl == NULL)) {
return FALSE;
}
return !SSL_is_init_finished (TlsConn->Ssl);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get the MCAN instance from peripheral base address. */ | static uint32_t MCAN_GetInstance(CAN_Type *base) | /* Get the MCAN instance from peripheral base address. */
static uint32_t MCAN_GetInstance(CAN_Type *base) | {
uint32_t instance;
for (instance = 0; instance < ARRAY_SIZE(s_mcanBases); instance++)
{
if (s_mcanBases[instance] == base)
{
break;
}
}
assert(instance < ARRAY_SIZE(s_mcanBases));
return instance;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Deselect the chip.
This function deselects the specified chip by driving its CS line high. */ | static void _mx25l_chip_deselect(void) | /* Deselect the chip.
This function deselects the specified chip by driving its CS line high. */
static void _mx25l_chip_deselect(void) | {
port_pin_set_output_level(MX25L_SPI_PIN_CS, true);
} | memfault/zero-to-main | C++ | null | 200 |
/* Set External Trigger Prescaler for Slave.
Set the external trigger frequency division ratio. */ | void timer_slave_set_prescaler(uint32_t timer_peripheral, enum tim_ic_psc psc) | /* Set External Trigger Prescaler for Slave.
Set the external trigger frequency division ratio. */
void timer_slave_set_prescaler(uint32_t timer_peripheral, enum tim_ic_psc psc) | {
TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_ETPS_MASK;
TIM_SMCR(timer_peripheral) |= psc << 12;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Get the value of the local APIC version register. */ | UINT32 EFIAPI GetApicVersion(VOID) | /* Get the value of the local APIC version register. */
UINT32 EFIAPI GetApicVersion(VOID) | {
return ReadLocalApicReg (XAPIC_VERSION_OFFSET);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* For HIPPI we will actually use the lower 4 bytes of the hardware address as the I-FIELD rather than the actual hardware address. */ | int hippi_mac_addr(struct net_device *dev, void *p) | /* For HIPPI we will actually use the lower 4 bytes of the hardware address as the I-FIELD rather than the actual hardware address. */
int hippi_mac_addr(struct net_device *dev, void *p) | {
struct sockaddr *addr = p;
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Print the decimal signed DWORD to instruction content. */ | UINTN EdbPrintData32s(IN UINT32 Data32) | /* Print the decimal signed DWORD to instruction content. */
UINTN EdbPrintData32s(IN UINT32 Data32) | {
BOOLEAN Sign;
Sign = (BOOLEAN)(Data32 >> 31);
EDBSPrintWithOffset (
mInstructionString.Content,
EDB_INSTRUCTION_CONTENT_MAX_SIZE,
mInstructionContentOffset,
L"%s%d",
Sign ? L"-" : L"+",
(UINTN)(Data32 & 0x7FFFFFFF)
);
mInstructionContentOffset = mInstructionContentOffset + 1 + EdbGetBitWidth (Data32 & 0x7FFFFFFF);
return mInstructionContentOffset;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Converts a text device path node to ACPI HID device path structure. */ | EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextAcpi(IN CHAR16 *TextDeviceNode) | /* Converts a text device path node to ACPI HID device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextAcpi(IN CHAR16 *TextDeviceNode) | {
CHAR16 *HIDStr;
CHAR16 *UIDStr;
ACPI_HID_DEVICE_PATH *Acpi;
HIDStr = GetNextParamStr (&TextDeviceNode);
UIDStr = GetNextParamStr (&TextDeviceNode);
Acpi = (ACPI_HID_DEVICE_PATH *)CreateDeviceNode (
ACPI_DEVICE_PATH,
ACPI_DP,
(UINT16)sizeof (ACPI_HID_DEVICE_PATH)
);
Acpi->HID = EisaIdFromText (HIDStr);
Acpi->UID = (UINT32)Strtoi (UIDStr);
return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* param base PUF peripheral base address return Status of the zeroize operation. */ | status_t PUF_Zeroize(PUF_Type *base) | /* param base PUF peripheral base address return Status of the zeroize operation. */
status_t PUF_Zeroize(PUF_Type *base) | {
status_t status = kStatus_Fail;
base->CTRL = PUF_CTRL_ZEROIZE_MASK;
if ((0U != (base->STAT & PUF_STAT_ERROR_MASK)) && (0U == base->ALLOW))
{
status = kStatus_Success;
}
return status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* mux the pin to the "GPIO" peripheral role. */ | int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup) | /* mux the pin to the "GPIO" peripheral role. */
int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup) | {
at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
u32 mask;
if ((port < AT91_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
at91_set_pio_pullup(port, pin, use_pullup);
writel(mask, &pio->port[port].per);
}
return 0;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Read the next element as an unsigned int. 0 is success, < 0 is failure. */ | static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num) | /* Read the next element as an unsigned int. 0 is success, < 0 is failure. */
static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num) | {
int n = 0;
if (size < 1 || size > 8)
return AVERROR_INVALIDDATA;
*num = 0;
while (n++ < size)
*num = (*num << 8) | get_byte(pb);
return 0;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* For the SATA devices we need to handle recalibration/geometry differently */ | static void sil_sata_pre_reset(ide_drive_t *drive) | /* For the SATA devices we need to handle recalibration/geometry differently */
static void sil_sata_pre_reset(ide_drive_t *drive) | {
if (drive->media == ide_disk) {
drive->special_flags &=
~(IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note: This function must only be called on a PORT that has not successfully been added using sas_port_add(). */ | void sas_port_free(struct sas_port *port) | /* Note: This function must only be called on a PORT that has not successfully been added using sas_port_add(). */
void sas_port_free(struct sas_port *port) | {
transport_destroy_device(&port->dev);
put_device(&port->dev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Called by the PCI code when it removes an SCC PATA controller. */ | static void __devexit scc_remove(struct pci_dev *dev) | /* Called by the PCI code when it removes an SCC PATA controller. */
static void __devexit scc_remove(struct pci_dev *dev) | {
struct scc_ports *ports = pci_get_drvdata(dev);
struct ide_host *host = ports->host;
ide_host_remove(host);
iounmap((void*)ports->dma);
iounmap((void*)ports->ctl);
pci_release_selected_regions(dev, (1 << 2) - 1);
memset(ports, 0, sizeof(*ports));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Changing the baud clock source changes the baud rate generated by the UART. Therefore, the baud rate should be reconfigured after any change to the baud clock source. */ | void UARTClockSourceSet(uint32_t ui32Base, uint32_t ui32Source) | /* Changing the baud clock source changes the baud rate generated by the UART. Therefore, the baud rate should be reconfigured after any change to the baud clock source. */
void UARTClockSourceSet(uint32_t ui32Base, uint32_t ui32Source) | {
ASSERT(_UARTBaseValid(ui32Base));
ASSERT((ui32Source == UART_CLOCK_SYSTEM) ||
(ui32Source == UART_CLOCK_ALTCLK));
HWREG(ui32Base + UART_O_CC) = ui32Source;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function detect if OVMF have started via the PVH entry point. */ | BOOLEAN EFIAPI XenPvhDetected(VOID) | /* This function detect if OVMF have started via the PVH entry point. */
BOOLEAN EFIAPI XenPvhDetected(VOID) | {
EFI_XEN_INFO *XenInfo;
XenInfo = XenGetInfoHOB ();
return (XenInfo != NULL && XenInfo->RsdpPvh != NULL);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This file is part of the Simba project. */ | int mock_write_xbee_client_module_init(int res) | /* This file is part of the Simba project. */
int mock_write_xbee_client_module_init(int res) | {
harness_mock_write("xbee_client_module_init()",
NULL,
0);
harness_mock_write("xbee_client_module_init(): return (res)",
&res,
sizeof(res));
return (0);
} | eerimoq/simba | C++ | Other | 337 |
/* Error State. This state will be set when the Vport Creation fails due to errors like Dup WWN. In this state only operation allowed is a Vport Delete. */ | static void bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s *vport, enum bfa_fcs_vport_event event) | /* Error State. This state will be set when the Vport Creation fails due to errors like Dup WWN. In this state only operation allowed is a Vport Delete. */
static void bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s *vport, enum bfa_fcs_vport_event event) | {
bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
bfa_trc(__vport_fcs(vport), event);
switch (event) {
case BFA_FCS_VPORT_SM_DELETE:
bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
bfa_fcs_vport_free(vport);
break;
default:
bfa_trc(__vport_fcs(vport), event);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.