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 |
|---|---|---|---|---|---|---|---|
/* arch_hibernation_header_restore - read the architecture specific data from the hibernation image header @addr: address to read the data from */ | int arch_hibernation_header_restore(void *addr) | /* arch_hibernation_header_restore - read the architecture specific data from the hibernation image header @addr: address to read the data from */
int arch_hibernation_header_restore(void *addr) | {
struct restore_data_record *rdr = addr;
restore_jump_address = rdr->jump_address;
restore_cr3 = rdr->cr3;
return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* in active-backup mode, we know that bond->curr_active_slave is always valid if the bond has a usable interface. */ | static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) | /* in active-backup mode, we know that bond->curr_active_slave is always valid if the bond has a usable interface. */
static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) | {
struct bonding *bond = netdev_priv(bond_dev);
int res = 1;
read_lock(&bond->lock);
read_lock(&bond->curr_slave_lock);
if (!BOND_IS_OK(bond))
goto out;
if (!bond->curr_active_slave)
goto out;
res = bond_dev_queue_xmit(bond, skb, bond->curr_active_slave->dev);
out:
if (res)
dev_kfree_skb(skb);
read_unloc... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns 0 on success or a negative error code. */ | int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, const struct nla_policy *policy) | /* Returns 0 on success or a negative error code. */
int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len, const struct nla_policy *policy) | {
struct nlattr *nla;
int rem, err;
memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
nla_for_each_attr(nla, head, len, rem) {
u16 type = nla_type(nla);
if (type > 0 && type <= maxtype) {
if (policy) {
err = validate_nla(nla, maxtype, policy);
if (err < 0)
goto errout;
}
tb[type] = n... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns: a #gssize of the read stream, or %-1 on an error. */ | gssize g_buffered_input_stream_fill_finish(GBufferedInputStream *stream, GAsyncResult *result, GError **error) | /* Returns: a #gssize of the read stream, or %-1 on an error. */
gssize g_buffered_input_stream_fill_finish(GBufferedInputStream *stream, GAsyncResult *result, GError **error) | {
GBufferedInputStreamClass *class;
g_return_val_if_fail (G_IS_BUFFERED_INPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), -1);
if (g_async_result_legacy_propagate_error (result, error))
return -1;
else if (g_async_result_is_tagged (result, g_buffered_input_stream_fill_async))
... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function divides the 64-bit unsigned value Dividend by the 64-bit unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder is not NULL, then the 64-bit unsigned remainder is returned in Remainder. This function returns the 64-bit unsigned quotient. */ | UINT64 EFIAPI InternalMathDivRemU64x64(IN UINT64 Dividend, IN UINT64 Divisor, OUT UINT64 *Remainder OPTIONAL) | /* This function divides the 64-bit unsigned value Dividend by the 64-bit unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder is not NULL, then the 64-bit unsigned remainder is returned in Remainder. This function returns the 64-bit unsigned quotient. */
UINT64 EFIAPI InternalMathDivRemU64x64(... | {
if (Remainder != NULL) {
*Remainder = Dividend % Divisor;
}
return Dividend / Divisor;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Extend 15-bit time stamp from rx descriptor to a full 64-bit TSF using the current h/w TSF. */ | u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp) | /* Extend 15-bit time stamp from rx descriptor to a full 64-bit TSF using the current h/w TSF. */
u64 ath9k_hw_extend_tsf(struct ath_hw *ah, u32 rstamp) | {
u64 tsf;
tsf = ath9k_hw_gettsf64(ah);
if ((tsf & 0x7fff) < rstamp)
tsf -= 0x8000;
return (tsf & ~0x7fff) | rstamp;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Function for activating received Application image.
This function will move the received application image fram swap (bank 1) to application area (bank 0). */ | static uint32_t dfu_activate_app(void) | /* Function for activating received Application image.
This function will move the received application image fram swap (bank 1) to application area (bank 0). */
static uint32_t dfu_activate_app(void) | {
uint32_t err_code = NRF_SUCCESS;
dfu_update_status_t update_status;
memset(&update_status, 0, sizeof(dfu_update_status_t ));
update_status.status_code = DFU_UPDATE_APP_COMPLETE;
update_status.app_crc = m_image_crc;
update_status.app_size = m_start_packet.app_image_size;
b... | labapart/polymcu | C++ | null | 201 |
/* Change the source of the main system clock. */ | void sysclk_set_source(uint32_t src) | /* Change the source of the main system clock. */
void sysclk_set_source(uint32_t src) | {
irqflags_t flags;
Assert(src <= SYSCLK_SRC_RC1M);
flags = cpu_irq_save();
PM->PM_UNLOCK = PM_UNLOCK_KEY(0xAAu)
| PM_UNLOCK_ADDR((uint32_t)&PM->PM_MCCTRL - (uint32_t)PM);
PM->PM_MCCTRL = src;
cpu_irq_restore(flags);
} | memfault/zero-to-main | C++ | null | 200 |
/* A bram is used as a configuration memory cache. One frame of data can be stored in this "storage buffer". */ | static u32 buffer_icap_get_bram(void __iomem *base_address, u32 offset) | /* A bram is used as a configuration memory cache. One frame of data can be stored in this "storage buffer". */
static u32 buffer_icap_get_bram(void __iomem *base_address, u32 offset) | {
return in_be32(base_address + (offset << 2));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* protection_trees_destroy - destroy the protection RB-trees. @ubi: UBI device description object */ | static void protection_trees_destroy(struct ubi_device *ubi) | /* protection_trees_destroy - destroy the protection RB-trees. @ubi: UBI device description object */
static void protection_trees_destroy(struct ubi_device *ubi) | {
struct rb_node *rb;
struct ubi_wl_prot_entry *pe;
rb = ubi->prot.aec.rb_node;
while (rb) {
if (rb->rb_left)
rb = rb->rb_left;
else if (rb->rb_right)
rb = rb->rb_right;
else {
pe = rb_entry(rb, struct ubi_wl_prot_entry, rb_aec);
rb = rb_parent(rb);
if (rb) {
if (rb->rb_left == &pe->rb_aec)... | EmcraftSystems/u-boot | C++ | Other | 181 |
/* brief DMA instance 1, channel 5 IRQ handler. */ | void EDMA_1_CH5_DriverIRQHandler(void) | /* brief DMA instance 1, channel 5 IRQ handler. */
void EDMA_1_CH5_DriverIRQHandler(void) | {
EDMA_DriverIRQHandler(1U, 5U);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Restores the ac coefficients in block that have been changed by decide_ac_pred(). This function also restores s->block_last_index. */ | static void restore_ac_coeffs(MpegEncContext *s, DCTELEM block[6][64], const int dir[6], uint8_t *st[6], const int zigzag_last_index[6]) | /* Restores the ac coefficients in block that have been changed by decide_ac_pred(). This function also restores s->block_last_index. */
static void restore_ac_coeffs(MpegEncContext *s, DCTELEM block[6][64], const int dir[6], uint8_t *st[6], const int zigzag_last_index[6]) | {
int i, n;
memcpy(s->block_last_index, zigzag_last_index, sizeof(int)*6);
for(n=0; n<6; n++){
int16_t *ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
st[n]= s->intra_scantable.permutated;
if(dir[n]){
for(i=1; i<8; i++){
block[n][s->dsp.idct_permutatio... | DC-SWAT/DreamShell | C++ | null | 404 |
/* int sensor_static_calibrate(int axis, void *buf,void *para) { int ret =-1; if(buf == NULL||para == NULL) return -1; if(tag == TAG_DEV_ACC) { ret = sensor_static_calibrate_acc(axis,buf,para); } else { } return ret; } */ | int find_empty_obj() | /* int sensor_static_calibrate(int axis, void *buf,void *para) { int ret =-1; if(buf == NULL||para == NULL) return -1; if(tag == TAG_DEV_ACC) { ret = sensor_static_calibrate_acc(axis,buf,para); } else { } return ret; } */
int find_empty_obj() | {
for(int i = 0;i < MAX_SRNSOR_NUM; i++)
{
if(g_sensor_static_para[i].in_use==0)
return i;
}
return -1;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Returns the current device address in device mode. */ | uint32_t USBDevAddrGet(uint32_t ui32Base) | /* Returns the current device address in device mode. */
uint32_t USBDevAddrGet(uint32_t ui32Base) | {
ASSERT(ui32Base == USB0_BASE);
return(HWREGB(ui32Base + USB_O_FADDR));
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Gets the state of the watchdog timer lock mechanism. */ | tBoolean WatchdogLockState(unsigned long ulBase) | /* Gets the state of the watchdog timer lock mechanism. */
tBoolean WatchdogLockState(unsigned long ulBase) | {
ASSERT((ulBase == WDT_BASE));
return((HWREG(ulBase + WDT_O_LOCK) == WDT_LOCK_LOCKED) ? true : false);
} | micropython/micropython | C++ | Other | 18,334 |
/* Returns 0 if nothing goes wrong or -ENOMEM if it fails during the allocation of the new pair to add. */ | static int smk_set_access(struct smack_rule *srp) | /* Returns 0 if nothing goes wrong or -ENOMEM if it fails during the allocation of the new pair to add. */
static int smk_set_access(struct smack_rule *srp) | {
struct smack_rule *sp;
int ret = 0;
int found;
mutex_lock(&smack_list_lock);
found = 0;
list_for_each_entry_rcu(sp, &smack_rule_list, list) {
if (sp->smk_subject == srp->smk_subject &&
sp->smk_object == srp->smk_object) {
found = 1;
sp->smk_access = srp->smk_access;
break;
}
}
if (found == ... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* SYSCTRL I2C0 Bus Clock Enable and Reset Release. */ | void LL_SYSCTRL_I2C0_ClkEnRstRelease(void) | /* SYSCTRL I2C0 Bus Clock Enable and Reset Release. */
void LL_SYSCTRL_I2C0_ClkEnRstRelease(void) | {
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_I2C0BusClk_En(SYSCTRL);
__LL_SYSCTRL_I2C0SoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area. address: lpar address of cell_ext_os_area @size: size of cell_ext_os_area */ | int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size) | /* ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area. address: lpar address of cell_ext_os_area @size: size of cell_ext_os_area */
int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size) | {
int result;
*size = 0;
result = ps3_repository_read_boot_dat_address(lpar_addr);
return result ? result
: ps3_repository_read_boot_dat_size(size);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* ‘P n...=r...’ Writes the new value of n-th register received into the input buffer to the n-th register */ | VOID WriteNthRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer) | /* ‘P n...=r...’ Writes the new value of n-th register received into the input buffer to the n-th register */
VOID WriteNthRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer) | {
UINTN RegNumber;
CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE];
CHAR8 *RegNumBufPtr;
CHAR8 *InBufPtr;
InBufPtr = &InBuffer[1];
RegNumBufPtr = RegNumBuffer;
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
*RegNumBufPtr = '\0';
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
... | tianocore/edk2 | C++ | Other | 4,240 |
/* Return Value: TRUE if ok; FALSE if error. */ | BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength) | /* Return Value: TRUE if ok; FALSE if error. */
BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength) | {
DWORD dwCRC;
dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4);
if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) {
return FALSE;
}
return TRUE;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Help command helper function. Display commands specific to the 24LC32A and I2C interfaced memory. */ | static int32_t cn0414_help_memory_commands(struct cn0414_dev *dev, bool short_command) | /* Help command helper function. Display commands specific to the 24LC32A and I2C interfaced memory. */
static int32_t cn0414_help_memory_commands(struct cn0414_dev *dev, bool short_command) | {
if (!short_command)
return usr_uart_write_string(dev->uart_descriptor,
(uint8_t*)
" discover_eeprom - Discover EEPROM I2C addresses if there are any.\n");
else
return usr_uart_write_string(dev->uart_descriptor,
(uint8_t*)
" de - Discover EEPROM I2C... | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Return: 0 if all went well, else returns appropriate error value. */ | static int ti_sci_cmd_set_board_config_rm(const struct ti_sci_handle *handle, u64 addr, u32 size) | /* Return: 0 if all went well, else returns appropriate error value. */
static int ti_sci_cmd_set_board_config_rm(const struct ti_sci_handle *handle, u64 addr, u32 size) | {
return cmd_set_board_config_using_msg(handle,
TI_SCI_MSG_BOARD_CONFIG_RM,
addr, size);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Set the Frequency Selection value of a specific channel. */ | static int fdc2x1x_set_fin_sel(const struct device *dev, uint8_t chx, uint8_t fin_sel) | /* Set the Frequency Selection value of a specific channel. */
static int fdc2x1x_set_fin_sel(const struct device *dev, uint8_t chx, uint8_t fin_sel) | {
return fdc2x1x_reg_write_mask(dev,
FDC2X1X_CLOCK_DIVIDERS_CH0 + chx,
FDC2X1X_CLK_DIV_CHX_FIN_SEL_MSK,
FDC2X1X_CLK_DIV_CHX_FIN_SEL_SET(fin_sel));
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* First we have to put a SPU register name on the bus. Then we can either read from or write to that register. */ | static void spu_transaction_init(struct if_spi_card *card) | /* First we have to put a SPU register name on the bus. Then we can either read from or write to that register. */
static void spu_transaction_init(struct if_spi_card *card) | {
if (!time_after(jiffies, card->prev_xfer_time + 1)) {
ndelay(400);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets the priority grouping of the interrupt controller. */ | void xIntPriorityGroupingSet(unsigned long ulBits) | /* Sets the priority grouping of the interrupt controller. */
void xIntPriorityGroupingSet(unsigned long ulBits) | {
xASSERT(ulBits < NUM_PRIORITY);
xHWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | g_pulPriority[ulBits];
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* This function sets the update marker flag for volume @vol. Returns zero in case of success and a negative error code in case of failure. */ | static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol) | /* This function sets the update marker flag for volume @vol. Returns zero in case of success and a negative error code in case of failure. */
static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol) | {
int err;
struct ubi_vtbl_record vtbl_rec;
dbg_msg("set update marker for volume %d", vol->vol_id);
if (vol->upd_marker) {
ubi_assert(ubi->vtbl[vol->vol_id].upd_marker);
dbg_msg("already set");
return 0;
}
memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id],
sizeof(struct ubi_vtbl_record));
vtbl_rec.upd_mar... | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Convert string to long integer, but handle errors. */ | static int modem_atoi(const char *s, const int err_value, const char *desc, const char *func) | /* Convert string to long integer, but handle errors. */
static int modem_atoi(const char *s, const int err_value, const char *desc, const char *func) | {
int ret;
char *endptr;
ret = (int)strtol(s, &endptr, 10);
if (!endptr || *endptr != '\0') {
LOG_ERR("bad %s '%s' in %s", s, desc,
func);
return err_value;
}
return ret;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Remove all events that have been submitted for a given object, be it a gameport port or a driver. */ | static void gameport_remove_pending_events(void *object) | /* Remove all events that have been submitted for a given object, be it a gameport port or a driver. */
static void gameport_remove_pending_events(void *object) | {
struct list_head *node, *next;
struct gameport_event *event;
unsigned long flags;
spin_lock_irqsave(&gameport_event_lock, flags);
list_for_each_safe(node, next, &gameport_event_list) {
event = list_entry(node, struct gameport_event, node);
if (event->object == object) {
list_del_init(node);
gameport_fr... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* DisablePhyComa - Disable the Phy Coma Mode @etdev: pointer to our adapter structure */ | void DisablePhyComa(struct et131x_adapter *etdev) | /* DisablePhyComa - Disable the Phy Coma Mode @etdev: pointer to our adapter structure */
void DisablePhyComa(struct et131x_adapter *etdev) | {
u32 GlobalPmCSR;
GlobalPmCSR = readl(&etdev->regs->global.pm_csr);
GlobalPmCSR |= ET_PMCSR_INIT;
GlobalPmCSR &= ~ET_PM_PHY_SW_COMA;
writel(GlobalPmCSR, &etdev->regs->global.pm_csr);
etdev->AiForceSpeed = etdev->PoMgmt.PowerDownSpeed;
etdev->AiForceDpx = etdev->PoMgmt.PowerDownDuplex;
et131x_init_send(etdev);
... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Use this function to free a key list. */ | void free_key_list(GList *list) | /* Use this function to free a key list. */
void free_key_list(GList *list) | {
guint i,n;
decryption_key_t *curr_key;
if (list == NULL)
return;
n = g_list_length(list);
for(i = 0; i < n; i++)
{
curr_key = (decryption_key_t*)g_list_nth_data(list,i);
if (curr_key->key != NULL)
g_string_free(curr_key->key, TRUE);
if (curr_key->ssi... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Find a contiguous vram area that contains a given offset from vram start. */ | static int vmlfb_vram_offset(struct vml_info *vinfo, unsigned long offset) | /* Find a contiguous vram area that contains a given offset from vram start. */
static int vmlfb_vram_offset(struct vml_info *vinfo, unsigned long offset) | {
unsigned long aoffset;
unsigned i;
for (i = 0; i < vinfo->num_areas; ++i) {
aoffset = offset - (vinfo->vram[i].phys - vinfo->vram_start);
if (aoffset < vinfo->vram[i].size) {
return 0;
}
}
return -EINVAL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* IWDG Set Period in Milliseconds.
A delay of up to 5 clock cycles of the LSI clock (about 156 microseconds) can occasionally occur if the prescale or preload registers are currently busy loading a previous value. */ | void iwdg_set_period_ms(uint32_t period) | /* IWDG Set Period in Milliseconds.
A delay of up to 5 clock cycles of the LSI clock (about 156 microseconds) can occasionally occur if the prescale or preload registers are currently busy loading a previous value. */
void iwdg_set_period_ms(uint32_t period) | {
const int PRESCALER_MAX = 6;
uint8_t prescale = 0;
uint32_t count = period << 3;
if (count == 0) {
count = 1;
}
while ((count - 1) >> COUNT_LENGTH) {
count >>= 1;
prescale++;
}
count--;
if (prescale > PRESCALER_MAX) {
count = COUNT_MASK;
prescale = PRESCALER_MAX;
}
while (iwdg_prescaler_busy());
... | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Calculate temperature from raw temperature value BME280 datasheet, page 50. */ | static int16_t bme680_convert_temperature(bme680_sensor_t *dev, uint32_t raw_temperature) | /* Calculate temperature from raw temperature value BME280 datasheet, page 50. */
static int16_t bme680_convert_temperature(bme680_sensor_t *dev, uint32_t raw_temperature) | {
if (!dev) return 0;
bme680_calib_data_t* cd = &dev->calib_data;
int64_t var1;
int64_t var2;
int16_t temperature;
var1 = ((((raw_temperature >> 3) - ((int32_t)cd->par_t1 << 1))) *
((int32_t)cd->par_t2)) >> 11;
var2 = (((((raw_temperature >> 4) - ((int32_t)cd->par_t1)) *
... | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Finds modem context which owns the iface device. */ | struct modem_context* modem_context_from_iface_dev(const struct device *dev) | /* Finds modem context which owns the iface device. */
struct modem_context* modem_context_from_iface_dev(const struct device *dev) | {
int i;
for (i = 0; i < ARRAY_SIZE(contexts); i++) {
if (contexts[i] && contexts[i]->iface.dev == dev) {
return contexts[i];
}
}
return NULL;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This function writes the specified number of bytes to the file at the current file position. The current file position is advanced the actual number of bytes written, which is returned in BufferSize. Partial writes only occur when there has been a data error during the write attempt (such as "volume space full"). Th... | EFI_STATUS EFIAPI FileHandleWrite(IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer) | /* This function writes the specified number of bytes to the file at the current file position. The current file position is advanced the actual number of bytes written, which is returned in BufferSize. Partial writes only occur when there has been a data error during the write attempt (such as "volume space full"). Th... | {
if (FileHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
return (FileHandle->Write (FileHandle, BufferSize, Buffer));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Connect the selected parameter to the break input of TIM1. */ | void SYSCFG_BreakConfig(uint32_t SYSCFG_Break) | /* Connect the selected parameter to the break input of TIM1. */
void SYSCFG_BreakConfig(uint32_t SYSCFG_Break) | {
assert_param(IS_SYSCFG_LOCK_CONFIG(SYSCFG_Break));
SYSCFG->CFGR2 |= (uint32_t) SYSCFG_Break;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Draws a single pixel at the specified X/Y location. */ | void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) | /* Draws a single pixel at the specified X/Y location. */
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) | {
ili9328SetCursor(x, y);
ili9328WriteCmd(ILI9328_COMMANDS_WRITEDATATOGRAM);
ili9328WriteData(color);
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Scale and temperature compensate the raw pressure measurement value to Kilopascal. The formula is based on the Chapter 4.9.1 in the datasheet. */ | static void dps310_scale_pressure(const struct device *dev, int32_t tmp_raw, int32_t psr_raw) | /* Scale and temperature compensate the raw pressure measurement value to Kilopascal. The formula is based on the Chapter 4.9.1 in the datasheet. */
static void dps310_scale_pressure(const struct device *dev, int32_t tmp_raw, int32_t psr_raw) | {
struct dps310_data *data = dev->data;
const struct dps310_cal_coeff *comp = &data->comp;
float psr = ((float)psr_raw) / IFX_DPS310_SF_PSR;
float tmp = ((float)tmp_raw) / IFX_DPS310_SF_TMP;
float psr_final = comp->c00;
psr_final += psr * (comp->c10 + psr * (comp->c20 + psr * comp->c30));
psr_final += tmp * comp... | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* RETURN VALUES: 0 - success -EIO - i/o error. -ENOSPC - insufficient disk resources. */ | int extRecord(struct inode *ip, xad_t *xp) | /* RETURN VALUES: 0 - success -EIO - i/o error. -ENOSPC - insufficient disk resources. */
int extRecord(struct inode *ip, xad_t *xp) | {
int rc;
txBeginAnon(ip->i_sb);
mutex_lock(&JFS_IP(ip)->commit_mutex);
rc = xtUpdate(0, ip, xp);
mutex_unlock(&JFS_IP(ip)->commit_mutex);
return rc;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Insert an element after the given list element. */ | void list_insert_after(void *const after, void *const element) | /* Insert an element after the given list element. */
void list_insert_after(void *const after, void *const element) | {
((struct list_element *)element)->next = ((struct list_element *)after)->next;
((struct list_element *)after)->next = (struct list_element *)element;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* helper function for fat_flush_inodes. This writes both the inode and the file data blocks, waiting for in flight data blocks before the start of the call. It does not wait for any io started during the call */ | static int writeback_inode(struct inode *inode) | /* helper function for fat_flush_inodes. This writes both the inode and the file data blocks, waiting for in flight data blocks before the start of the call. It does not wait for any io started during the call */
static int writeback_inode(struct inode *inode) | {
int ret;
struct address_space *mapping = inode->i_mapping;
struct writeback_control wbc = {
.sync_mode = WB_SYNC_NONE,
.nr_to_write = 0,
};
ret = sync_inode(inode, &wbc);
if (!ret)
ret = filemap_fdatawrite(mapping);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Selects the clock source to output on MCO pin (PA8) and the corresponding prescsaler. */ | void RCC_MCOConfig(uint8_t RCC_MCOSource, uint32_t RCC_MCOPrescaler) | /* Selects the clock source to output on MCO pin (PA8) and the corresponding prescsaler. */
void RCC_MCOConfig(uint8_t RCC_MCOSource, uint32_t RCC_MCOPrescaler) | {
uint32_t tmpreg = 0;
assert_param(IS_RCC_MCO_SOURCE(RCC_MCOSource));
assert_param(IS_RCC_MCO_PRESCALER(RCC_MCOPrescaler));
tmpreg = RCC->CFGR;
tmpreg &= ~(RCC_CFGR_MCO_PRE | RCC_CFGR_MCO | RCC_CFGR_PLLNODIV);
tmpreg |= (RCC_MCOPrescaler | ((uint32_t)RCC_MCOSource << 24));
RCC->CFGR = tmpre... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* retval pmstatus Each bit position indicates the match status of corresponding bit slice. = 0 Match was detected. = 1 Match was not detected. */ | uint32_t PINT_PatternMatchResetDetectLogic(PINT_Type *base) | /* retval pmstatus Each bit position indicates the match status of corresponding bit slice. = 0 Match was detected. = 1 Match was not detected. */
uint32_t PINT_PatternMatchResetDetectLogic(PINT_Type *base) | {
uint32_t pmctrl;
uint32_t pmstatus;
uint32_t pmsrc;
pmctrl = base->PMCTRL;
pmstatus = pmctrl >> PINT_PMCTRL_PMAT_SHIFT;
if (pmstatus != 0UL)
{
pmsrc = base->PMSRC;
base->PMSRC = pmsrc;
}
return (pmstatus);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The @src is updated to point the first character after the @find if @src starts with @find. */ | static bool tomoyo_str_starts(char **src, const char *find) | /* The @src is updated to point the first character after the @find if @src starts with @find. */
static bool tomoyo_str_starts(char **src, const char *find) | {
const int len = strlen(find);
char *tmp = *src;
if (strncmp(tmp, find, len))
return false;
tmp += len;
*src = tmp;
return true;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* PE calls this function to Enable or Disable VCONN. */ | int port0_policy_cb_vconn_en(const struct device *dev, enum tc_cc_polarity pol, bool en) | /* PE calls this function to Enable or Disable VCONN. */
int port0_policy_cb_vconn_en(const struct device *dev, enum tc_cc_polarity pol, bool en) | {
struct port0_data_t *dpm_data = usbc_get_dpm_data(dev);
dpm_data->vconn_pol = pol;
if (en == false) {
vconn_ctrl_set(VCONN_OFF);
} else if (pol == TC_POLARITY_CC1) {
vconn_ctrl_set(VCONN1_ON);
} else {
vconn_ctrl_set(VCONN2_ON);
}
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Parse command line modifiers. Return error or number arg parsed. Modifiers must be at the beggining of command line. */ | static int parse_modifiers(char *args[], int count, __u16 *pout, const struct iwconfig_modifier modifier[], int modnum) | /* Parse command line modifiers. Return error or number arg parsed. Modifiers must be at the beggining of command line. */
static int parse_modifiers(char *args[], int count, __u16 *pout, const struct iwconfig_modifier modifier[], int modnum) | {
int i = 0;
int k = 0;
__u16 result = 0;
do
{
for(k = 0; k < modnum; k++)
{
if(!strcasecmp(args[i], modifier[k].cmd))
{
if(result & modifier[k].exclude)
{
errarg = i;
return(IWERR_ARG_CONFLICT);
}
result |= modifier[k].flag;
++i;
break;
}
}
... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This file is part of the Simba project. */ | int board_pin_string_to_device_index(const char *str_p) | /* This file is part of the Simba project. */
int board_pin_string_to_device_index(const char *str_p) | {
long pin;
if (std_strtol(&str_p[0], &pin) == NULL) {
return (-ENODEV);
}
if ((pin < 0) || (pin >= PIN_DEVICE_MAX)) {
return (-ENODEV);
}
return (pin);
} | eerimoq/simba | C++ | Other | 337 |
/* Builds a pdu frame as an RR response. */ | void llc_pdu_init_as_rr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr) | /* Builds a pdu frame as an RR response. */
void llc_pdu_init_as_rr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr) | {
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
pdu->ctrl_1 = LLC_PDU_TYPE_S;
pdu->ctrl_1 |= LLC_2_PDU_RSP_RR;
pdu->ctrl_2 = 0;
pdu->ctrl_2 |= f_bit & LLC_S_PF_BIT_MASK;
pdu->ctrl_1 &= 0x0F;
pdu->ctrl_2 |= (nr << 1) & 0xFE;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This is the top level routine of the printer. 'p' points to the ether header of the packet, 'h->len' is the length of the packet off the wire, and 'h->caplen' is the number of bytes actually captured. */ | u_int ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) | /* This is the top level routine of the printer. 'p' points to the ether header of the packet, 'h->len' is the length of the packet off the wire, and 'h->caplen' is the number of bytes actually captured. */
u_int ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) | {
return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This isn't an LRU system, it just frees up each context in turn (sort-of pseudo-random replacement :). This would be the place to implement an LRU scheme if anyone were motivated to do it. */ | void steal_context(void) | /* This isn't an LRU system, it just frees up each context in turn (sort-of pseudo-random replacement :). This would be the place to implement an LRU scheme if anyone were motivated to do it. */
void steal_context(void) | {
struct mm_struct *mm;
if (next_mmu_context < FIRST_CONTEXT)
next_mmu_context = FIRST_CONTEXT;
mm = context_mm[next_mmu_context];
flush_tlb_mm(mm);
destroy_context(mm);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Note: check the dirty flag before waiting, so we don't hold up the sync while mounting a device. (The newly mounted device won't need syncing.) */ | void sync_supers(void) | /* Note: check the dirty flag before waiting, so we don't hold up the sync while mounting a device. (The newly mounted device won't need syncing.) */
void sync_supers(void) | {
struct super_block *sb;
spin_lock(&sb_lock);
restart:
list_for_each_entry(sb, &super_blocks, s_list) {
if (sb->s_op->write_super && sb->s_dirt) {
sb->s_count++;
spin_unlock(&sb_lock);
down_read(&sb->s_umount);
if (sb->s_root && sb->s_dirt)
sb->s_op->write_super(sb);
up_read(&sb->s_umount);
... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Translates a 24-bit RGB color to a display driver-specific color. */ | static unsigned long Formike128x128x16ColorTranslate(void *pvDisplayData, unsigned long ulValue) | /* Translates a 24-bit RGB color to a display driver-specific color. */
static unsigned long Formike128x128x16ColorTranslate(void *pvDisplayData, unsigned long ulValue) | {
return(DPYCOLORTRANSLATE(ulValue));
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* This is a callback routine supplied to UNDI3.1 at undi_start time. New callbacks for 3.1: there won't be a virtual2physical callback for UNDI 3.1 because undi3.1 uses the MemMap call to map the required address by itself! */ | VOID EFIAPI SnpUndi32CallbackBlock(IN UINT64 UniqueId, IN UINT32 Enable) | /* This is a callback routine supplied to UNDI3.1 at undi_start time. New callbacks for 3.1: there won't be a virtual2physical callback for UNDI 3.1 because undi3.1 uses the MemMap call to map the required address by itself! */
VOID EFIAPI SnpUndi32CallbackBlock(IN UINT64 UniqueId, IN UINT32 Enable) | {
SNP_DRIVER *Snp;
Snp = (SNP_DRIVER *)(UINTN)UniqueId;
if (Enable != 0) {
EfiAcquireLock (&Snp->Lock);
} else {
EfiReleaseLock (&Snp->Lock);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Notice that "fork()" is implemented in terms of clone, with parameters (SIGCHLD, 0). */ | int alpha_clone(unsigned long clone_flags, unsigned long usp, int __user *parent_tid, int __user *child_tid, unsigned long tls_value, struct pt_regs *regs) | /* Notice that "fork()" is implemented in terms of clone, with parameters (SIGCHLD, 0). */
int alpha_clone(unsigned long clone_flags, unsigned long usp, int __user *parent_tid, int __user *child_tid, unsigned long tls_value, struct pt_regs *regs) | {
if (!usp)
usp = rdusp();
return do_fork(clone_flags, usp, regs, 0, parent_tid, child_tid);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Disable the MMC ipc rx checksum offload interrupt. The MMC ipc rx checksum offload interrupts are masked out as per the mask specified. */ | void synopGMAC_disable_mmc_ipc_rx_interrupt(synopGMACdevice *gmacdev, u32 mask) | /* Disable the MMC ipc rx checksum offload interrupt. The MMC ipc rx checksum offload interrupts are masked out as per the mask specified. */
void synopGMAC_disable_mmc_ipc_rx_interrupt(synopGMACdevice *gmacdev, u32 mask) | {
synopGMACSetBits(gmacdev->MacBase,GmacMmcRxIpcIntrMask,mask);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Register Proximity Reporter.
Register proximity reporter with the radio. Once the service is registered with radio the clients can avail its services. */ | ADI_BLER_RESULT adi_radio_Register_ProximityReporter(void) | /* Register Proximity Reporter.
Register proximity reporter with the radio. Once the service is registered with radio the clients can avail its services. */
ADI_BLER_RESULT adi_radio_Register_ProximityReporter(void) | {
ADI_BLER_RESULT bleResult;
ADI_BLE_LOGEVENT(LOGID_CMD_PROX_REPORTER_REG);
ADI_BLE_RADIO_CMD_START(CMD_PROX_REPORTER_REG);
bleResult = bler_process_cmd(CMD_PROX_REPORTER_REG, 0u, NULL, 0u);
if(bleResult == ADI_BLER_SUCCESS){
bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_RESP_SUCCESS,A... | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* For Td guest TDVMCALL_IO is invoked to write I/O port. */ | UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value) | /* For Td guest TDVMCALL_IO is invoked to write I/O port. */
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value) | {
BOOLEAN Flag;
ASSERT ((Port & 1) == 0);
Flag = FilterBeforeIoWrite (FilterWidth16, Port, &Value);
if (Flag) {
if (IsTdxGuest ()) {
TdIoWrite16 (Port, Value);
} else {
__asm__ __volatile__ ("outw %w0,%w1" : : "a" (Value), "d" ((UINT16)Port));
}
}
FilterAfterIoWrite (FilterWidth16, ... | tianocore/edk2 | C++ | Other | 4,240 |
/* This function removes the system exception interrupt handler from the vector table in SRAM. This function also masks off the system exception interrupt in the interrupt controller so that the interrupt handler is no longer called. */ | void SysExcIntUnregister(void) | /* This function removes the system exception interrupt handler from the vector table in SRAM. This function also masks off the system exception interrupt in the interrupt controller so that the interrupt handler is no longer called. */
void SysExcIntUnregister(void) | {
IntDisable(INT_SYSEXC);
IntUnregister(INT_SYSEXC);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* free buffer used from application by toggling the SW_BUF byte */ | void user_buffer_free(uint8_t ep_id, uint8_t dir) | /* free buffer used from application by toggling the SW_BUF byte */
void user_buffer_free(uint8_t ep_id, uint8_t dir) | {
if (DBUF_EP_OUT == dir) {
USBD_SWBUF_RX_TOGGLE(ep_id);
} else if (DBUF_EP_IN == dir) {
USBD_SWBUF_TX_TOGGLE(ep_id);
}
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* find_ino - find an entry on the size tree. */ | static struct size_entry* find_ino(struct ubifs_info *c, ino_t inum) | /* find_ino - find an entry on the size tree. */
static struct size_entry* find_ino(struct ubifs_info *c, ino_t inum) | {
struct rb_node *p = c->size_tree.rb_node;
struct size_entry *e;
while (p) {
e = rb_entry(p, struct size_entry, rb);
if (inum < e->inum)
p = p->rb_left;
else if (inum > e->inum)
p = p->rb_right;
else
return e;
}
return NULL;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Disable the irq on the all cores for chips that have the EN*_W1{S,C} registers. */ | static void octeon_irq_ciu1_disable_all_v2(unsigned int irq) | /* Disable the irq on the all cores for chips that have the EN*_W1{S,C} registers. */
static void octeon_irq_ciu1_disable_all_v2(unsigned int irq) | {
u64 mask = 1ull << (irq - OCTEON_IRQ_WDOG0);
int index;
int cpu;
for_each_online_cpu(cpu) {
index = octeon_coreid_for_cpu(cpu) * 2 + 1;
cvmx_write_csr(CVMX_CIU_INTX_EN1_W1C(index), mask);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Note: This function must only be called on a PHY that has not successfully been added using sas_phy_add(). */ | void sas_phy_free(struct sas_phy *phy) | /* Note: This function must only be called on a PHY that has not successfully been added using sas_phy_add(). */
void sas_phy_free(struct sas_phy *phy) | {
transport_destroy_device(&phy->dev);
put_device(&phy->dev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Save the nmi cpu registers for all cpus in the system. */ | void nmi_eframes_save(void) | /* Save the nmi cpu registers for all cpus in the system. */
void nmi_eframes_save(void) | {
cnodeid_t cnode;
for_each_online_node(cnode)
nmi_node_eframe_save(cnode);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* periodic_next_shadow - return "next" pointer on shadow list @periodic: host pointer to qh/itd/sitd @tag: hardware tag for type of this record */ | static union ehci_shadow* periodic_next_shadow(struct ehci_hcd *ehci, union ehci_shadow *periodic, __hc32 tag) | /* periodic_next_shadow - return "next" pointer on shadow list @periodic: host pointer to qh/itd/sitd @tag: hardware tag for type of this record */
static union ehci_shadow* periodic_next_shadow(struct ehci_hcd *ehci, union ehci_shadow *periodic, __hc32 tag) | {
switch (hc32_to_cpu(ehci, tag)) {
case Q_TYPE_QH:
return &periodic->qh->qh_next;
case Q_TYPE_FSTN:
return &periodic->fstn->fstn_next;
case Q_TYPE_ITD:
return &periodic->itd->itd_next;
default:
return &periodic->sitd->sitd_next;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get bit field value from the buffer and then set the value for the question. Note: Data type UINT32 can cover all the bit field value. */ | VOID GetBitsQuestionValue(IN HII_STATEMENT *Question, IN UINT8 *Buffer, OUT HII_STATEMENT_VALUE *QuestionValue) | /* Get bit field value from the buffer and then set the value for the question. Note: Data type UINT32 can cover all the bit field value. */
VOID GetBitsQuestionValue(IN HII_STATEMENT *Question, IN UINT8 *Buffer, OUT HII_STATEMENT_VALUE *QuestionValue) | {
UINTN StartBit;
UINTN EndBit;
UINT32 RetVal;
UINT32 BufferValue;
StartBit = Question->BitVarOffset % 8;
EndBit = StartBit + Question->BitStorageWidth - 1;
CopyMem ((UINT8 *)&BufferValue, Buffer, Question->StorageWidth);
RetVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
CopyMem ((UINT8... | tianocore/edk2 | C++ | Other | 4,240 |
/* Find a route cache with the dst and src. This is used by ICMP redirect message process. All kinds of redirect is treated as host redirect according to RFC1122. So, only route cache entries are modified according to the ICMP redirect message. */ | IP4_ROUTE_CACHE_ENTRY* Ip4FindRouteCache(IN IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Src) | /* Find a route cache with the dst and src. This is used by ICMP redirect message process. All kinds of redirect is treated as host redirect according to RFC1122. So, only route cache entries are modified according to the ICMP redirect message. */
IP4_ROUTE_CACHE_ENTRY* Ip4FindRouteCache(IN IP4_ROUTE_TABLE *RtTable, IN... | {
LIST_ENTRY *Entry;
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
UINT32 Index;
Index = IP4_ROUTE_CACHE_HASH (Dest, Src);
NET_LIST_FOR_EACH (Entry, &RtTable->Cache.CacheBucket[Index]) {
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link);
if ((RtCacheEntry->De... | tianocore/edk2 | C++ | Other | 4,240 |
/* Destroy the MTFTP6 service. The MTFTP6 service may be partly initialized, or partly destroyed. If a resource is destroyed, it is marked as such in case the destroy failed and is called again later. */ | VOID Mtftp6DestroyService(IN MTFTP6_SERVICE *Service) | /* Destroy the MTFTP6 service. The MTFTP6 service may be partly initialized, or partly destroyed. If a resource is destroyed, it is marked as such in case the destroy failed and is called again later. */
VOID Mtftp6DestroyService(IN MTFTP6_SERVICE *Service) | {
ASSERT (Service->ChildrenNum == 0);
if (Service->DummyUdpIo != NULL) {
UdpIoFreeIo (Service->DummyUdpIo);
}
if (Service->Timer != NULL) {
gBS->CloseEvent (Service->Timer);
}
FreePool (Service);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function is used to lock the temper control registers. This function should be used after calling API */ | void HibernateTamperLock(void) | /* This function is used to lock the temper control registers. This function should be used after calling API */
void HibernateTamperLock(void) | {
_HibernateWriteComplete();
HWREG(HIB_LOCK) = 0;
_HibernateWriteComplete();
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Set the some types info of the file into Buffer. */ | EFI_STATUS EFIAPI FatSetInfo(IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN UINTN BufferSize, IN VOID *Buffer) | /* Set the some types info of the file into Buffer. */
EFI_STATUS EFIAPI FatSetInfo(IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN UINTN BufferSize, IN VOID *Buffer) | {
return FatSetOrGetInfo (TRUE, FHand, Type, &BufferSize, Buffer);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* UART MSP Initialization This function configures the hardware resources used in this example. */ | void HAL_UART_MspInit(UART_HandleTypeDef *huart) | /* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart) | {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART2)
{
__HAL_RCC_USART2_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_F... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function handles PlatformInit task at the end of PEI */ | EFI_STATUS EFIAPI PlatformInitEndOfPei(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi) | /* This function handles PlatformInit task at the end of PEI */
EFI_STATUS EFIAPI PlatformInitEndOfPei(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi) | {
VOID *TcgEventLog;
TcgEventLog = GetFirstGuidHob (&gTcgEventEntryHobGuid);
if (TcgEventLog == NULL) {
TcgEventLog = GetFirstGuidHob (&gTcgEvent2EntryHobGuid);
}
if (TcgEventLog == NULL) {
return EFI_SUCCESS;
}
ConfigureTpmPlatformHierarchy ();
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Searches the whitelist to determine if the address is present in the whitelist. This is an internal API that only searches the link layer whitelist and does not care about the hardware whitelist */ | static int ble_ll_whitelist_search(const uint8_t *addr, uint8_t addr_type) | /* Searches the whitelist to determine if the address is present in the whitelist. This is an internal API that only searches the link layer whitelist and does not care about the hardware whitelist */
static int ble_ll_whitelist_search(const uint8_t *addr, uint8_t addr_type) | {
int i;
struct ble_ll_whitelist_entry *wl;
wl = &g_ble_ll_whitelist[0];
for (i = 0; i < BLE_LL_WHITELIST_SIZE; ++i) {
if ((wl->wl_valid) && (wl->wl_addr_type == addr_type) &&
(!memcmp(&wl->wl_dev_addr[0], addr, BLE_DEV_ADDR_LEN))) {
return i + 1;
}
++wl;
... | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Returns: -ENOMEM if buffer is too small, -EINVAL if attr.group is invalid, -EFAULT if copying to userspace failed, on success return number of stored interrupts */ | static int flic_get_all_irqs(KVMS390FLICState *flic, void *buf, int len) | /* Returns: -ENOMEM if buffer is too small, -EINVAL if attr.group is invalid, -EFAULT if copying to userspace failed, on success return number of stored interrupts */
static int flic_get_all_irqs(KVMS390FLICState *flic, void *buf, int len) | {
struct kvm_device_attr attr = {
.group = KVM_DEV_FLIC_GET_ALL_IRQS,
.addr = (uint64_t) buf,
.attr = len,
};
int rc;
rc = ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr);
return rc == -1 ? -errno : rc;
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* We don't care whether we support the comments in this file or not; if we can't, we'll offer the user the option of discarding the comments. */ | gboolean cf_can_save_as(capture_file *cf) | /* We don't care whether we support the comments in this file or not; if we can't, we'll offer the user the option of discarding the comments. */
gboolean cf_can_save_as(capture_file *cf) | {
if (wtap_dump_can_write(cf->linktypes, 0)) {
return TRUE;
}
if (cf->is_tempfile && !cf->unsaved_changes) {
return TRUE;
}
return FALSE;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and ... | UINT32 EFIAPI PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value) | /* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and ... | {
return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Execute necessary pin sense measurement and return its Presence Detect, Impedance, ELD Valid etc. status bits. */ | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) | /* Execute necessary pin sense measurement and return its Presence Detect, Impedance, ELD Valid etc. status bits. */
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) | {
u32 pincap;
if (!codec->no_trigger_sense) {
pincap = snd_hda_query_pin_caps(codec, nid);
if (pincap & AC_PINCAP_TRIG_REQ)
snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
}
return snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_PIN_SENSE, 0);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The kqueue thread will not start monitoring on it immediately, it should be bumped via its command file descriptor manually. See kqueue_thread() and _kqueue_thread_collect_fds() for details. */ | void _kqueue_thread_push_fd(int fd) | /* The kqueue thread will not start monitoring on it immediately, it should be bumped via its command file descriptor manually. See kqueue_thread() and _kqueue_thread_collect_fds() for details. */
void _kqueue_thread_push_fd(int fd) | {
G_LOCK (pick_up_lock);
g_queue_push_tail (&pick_up_fds_queue, GINT_TO_POINTER (fd));
G_UNLOCK (pick_up_lock);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Returns the total length of this FPDU under the assumption that a TCP segment carries only one FPDU. */ | static guint32 fpdu_total_length(struct tcpinfo *tcpinfo) | /* Returns the total length of this FPDU under the assumption that a TCP segment carries only one FPDU. */
static guint32 fpdu_total_length(struct tcpinfo *tcpinfo) | {
guint32 size = 0;
if (tcpinfo->seq < tcpinfo->nxtseq) {
size = tcpinfo->nxtseq - tcpinfo->seq;
}
if (tcpinfo->seq >= tcpinfo->nxtseq) {
size = tcpinfo->nxtseq + (TCP_MAX_SEQ - tcpinfo->seq);
}
return size;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* kgdb_skipexception - Bail out of KGDB when we've been triggered. */ | int kgdb_skipexception(int exception, struct pt_regs *regs) | /* kgdb_skipexception - Bail out of KGDB when we've been triggered. */
int kgdb_skipexception(int exception, struct pt_regs *regs) | {
if (exception == 3 && kgdb_isremovedbreak(regs->ip - 1)) {
regs->ip -= 1;
return 1;
}
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* fc_linkup() - Handler for transport linkup events @lport: The local port whose link is up */ | void fc_linkup(struct fc_lport *lport) | /* fc_linkup() - Handler for transport linkup events @lport: The local port whose link is up */
void fc_linkup(struct fc_lport *lport) | {
printk(KERN_INFO "host%d: libfc: Link up on port (%6x)\n",
lport->host->host_no, fc_host_port_id(lport->host));
mutex_lock(&lport->lp_mutex);
__fc_linkup(lport);
mutex_unlock(&lport->lp_mutex);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* this function is a POSIX compliant version, which will close a directory stream. */ | int closedir(DIR *d) | /* this function is a POSIX compliant version, which will close a directory stream. */
int closedir(DIR *d) | {
int result;
struct dfs_fd *fd;
fd = fd_get(d->fd);
if (fd == NULL)
{
rt_set_errno(-EBADF);
return -1;
}
result = dfs_file_close(fd);
fd_put(fd);
fd_put(fd);
rt_free(d);
if (result < 0)
{
rt_set_errno(result);
return -1;
}
else
... | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Helper function for nand_wait_ready used when needing to wait in interrupt context. */ | static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo) | /* Helper function for nand_wait_ready used when needing to wait in interrupt context. */
static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo) | {
struct nand_chip *chip = mtd->priv;
int i;
for (i = 0; i < timeo; i++) {
if (chip->dev_ready(mtd))
break;
touch_softlockup_watchdog();
mdelay(1);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Function to search the list of mappings for the node on the list based on the key. */ | SHELL_MAP_LIST* EFIAPI ShellCommandFindMapItem(IN CONST CHAR16 *MapKey) | /* Function to search the list of mappings for the node on the list based on the key. */
SHELL_MAP_LIST* EFIAPI ShellCommandFindMapItem(IN CONST CHAR16 *MapKey) | {
SHELL_MAP_LIST *MapListItem;
for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
; !IsNull (&gShellMapList.Link, &MapListItem->Link)
; MapListItem = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &MapListItem->Link)
)
{
if (gUnicodeCollation->StriColl (gUni... | tianocore/edk2 | C++ | Other | 4,240 |
/* Reads and returns the current value of DR4. 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 AsmReadDr4(VOID) | /* Reads and returns the current value of DR4. 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 AsmReadDr4(VOID) | {
UINTN Data;
__asm__ __volatile__ (
"movl %%dr4, %0"
: "=r" (Data)
);
return Data;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* The header checksum is just a very simple checksum over the header area. There is still a crc32 over the whole lot. */ | static uint16_t sfp_hdr_checksum(uint8_t *buf, unsigned char ver) | /* The header checksum is just a very simple checksum over the header area. There is still a crc32 over the whole lot. */
static uint16_t sfp_hdr_checksum(uint8_t *buf, unsigned char ver) | {
uint16_t ret = 0;
int len = sfp_hdr_size(ver) - sizeof(ret);
while (--len)
ret += *buf++;
return ret;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* ADC Set DMA to Terminate.
This must be set to allow DMA to terminate after the last conversion in the DMA sequence. This can avoid overrun errors. */ | void adc_set_dma_terminate(uint32_t adc) | /* ADC Set DMA to Terminate.
This must be set to allow DMA to terminate after the last conversion in the DMA sequence. This can avoid overrun errors. */
void adc_set_dma_terminate(uint32_t adc) | {
ADC_CR2(adc) &= ~ADC_CR2_DDS;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* If detected invokes the pcie_port_device_register() method for this port device. */ | static int __devinit pcie_portdrv_probe(struct pci_dev *dev, const struct pci_device_id *id) | /* If detected invokes the pcie_port_device_register() method for this port device. */
static int __devinit pcie_portdrv_probe(struct pci_dev *dev, const struct pci_device_id *id) | {
int status;
if (!pci_is_pcie(dev) ||
((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
(dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) &&
(dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)))
return -ENODEV;
if (!dev->irq && dev->pin) {
dev_warn(&dev->dev, "device [%04x:%04x] has invalid IRQ; "
"check vend... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This is __init_refok because we check for "initializing" before touching any of the __init sensitive things and "initializing" will be false after __init time. This can't be __init because it can be called whenever a disk is first accessed. */ | void __init_refok note_bootable_part(dev_t dev, int part, int goodness) | /* This is __init_refok because we check for "initializing" before touching any of the __init sensitive things and "initializing" will be false after __init time. This can't be __init because it can be called whenever a disk is first accessed. */
void __init_refok note_bootable_part(dev_t dev, int part, int goodness) | {
char *p;
if (!initializing)
return;
if ((goodness <= current_root_goodness) &&
ROOT_DEV != DEFAULT_ROOT_DEVICE)
return;
p = strstr(boot_command_line, "root=");
if (p != NULL && (p == boot_command_line || p[-1] == ' '))
return;
ROOT_DEV = dev + part;
current_root_goodness = goodness;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Retrieves the raw gyroscope data from the IMU. */ | void IMU_getGyroData(float gvec[3]) | /* Retrieves the raw gyroscope data from the IMU. */
void IMU_getGyroData(float gvec[3]) | {
if( IMU_state != IMU_STATE_READY ){
gvec[0] = 0;
gvec[1] = 0;
gvec[2] = 0;
return;
}
ICM20648_gyroDataRead( gvec );
return;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Returns the last data output value of the selected DAC cahnnel. */ | uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel) | /* Returns the last data output value of the selected DAC cahnnel. */
uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel) | {
__IO uint32_t tmp = 0;
assert_param(IS_DAC_CHANNEL(DAC_Channel));
tmp = (uint32_t) DAC_BASE ;
tmp += DOR_Offset + ((uint32_t)DAC_Channel >> 2);
return (uint16_t) (*(__IO uint32_t*) tmp);
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Disable autoreload register write completed interrupt (ARROKIE). @rmtoll IER ARROKIE LPTIM_DisableIT_ARROK. */ | void LPTIM_DisableIT_ARROK(LPTIM_Module *LPTIMx) | /* Disable autoreload register write completed interrupt (ARROKIE). @rmtoll IER ARROKIE LPTIM_DisableIT_ARROK. */
void LPTIM_DisableIT_ARROK(LPTIM_Module *LPTIMx) | {
CLEAR_BIT(LPTIMx->INTEN, LPTIM_INTEN_ARRUPDIE);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Get source offset used for getting runtime filter.
Runtime filters for each link are dynamically allocated as an array of filters for all domains in the link. In order to fetch link associated with given source an index in the array must be retrieved. */ | static uint32_t get_source_offset(const struct log_link *link, uint8_t rel_domain_id) | /* Get source offset used for getting runtime filter.
Runtime filters for each link are dynamically allocated as an array of filters for all domains in the link. In order to fetch link associated with given source an index in the array must be retrieved. */
static uint32_t get_source_offset(const struct log_link *lin... | {
uint32_t offset = 0;
for (uint8_t i = 0; i < rel_domain_id; i++) {
offset += log_link_sources_count(link, i);
}
return offset;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Read in the agi to initialise the per-ag data in the mount structure */ | int xfs_ialloc_pagi_init(xfs_mount_t *mp, xfs_trans_t *tp, xfs_agnumber_t agno) | /* Read in the agi to initialise the per-ag data in the mount structure */
int xfs_ialloc_pagi_init(xfs_mount_t *mp, xfs_trans_t *tp, xfs_agnumber_t agno) | {
xfs_buf_t *bp = NULL;
int error;
error = xfs_ialloc_read_agi(mp, tp, agno, &bp);
if (error)
return error;
if (bp)
xfs_trans_brelse(tp, bp);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable time stamp snapshot for IPV4 frames. When disabled, time stamp snapshot is not taken for IPV4 frames Reserved when "Advanced Time Stamp" is not selected */ | void synopGMAC_TS_IPV4_disable(synopGMACdevice *gmacdev) | /* Disable time stamp snapshot for IPV4 frames. When disabled, time stamp snapshot is not taken for IPV4 frames Reserved when "Advanced Time Stamp" is not selected */
void synopGMAC_TS_IPV4_disable(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase,GmacTSControl,GmacTSIPV4ENA);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Pre-write operation, currently only supporting strong pullups. Program the hardware for a strong pullup, if one has been requested and the hardware supports it. */ | static void w1_pre_write(struct w1_master *dev) | /* Pre-write operation, currently only supporting strong pullups. Program the hardware for a strong pullup, if one has been requested and the hardware supports it. */
static void w1_pre_write(struct w1_master *dev) | {
if (dev->pullup_duration &&
dev->enable_pullup && dev->bus_master->set_pullup) {
dev->bus_master->set_pullup(dev->bus_master->data,
dev->pullup_duration);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* SEQ OF BACnetDeviceObjectReference (accessed as an array) } */ | static guint fDoorMembers(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset) | /* SEQ OF BACnetDeviceObjectReference (accessed as an array) } */
static guint fDoorMembers(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset) | {
guint8 tag_no, tag_info;
guint32 lvt;
guint lastoffset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
lastoffset = offset;
fTagHeader(tvb, pinfo, offset, &tag_no, &tag_info, &lvt);
if (tag_is_closing(tag_info) ) {
return offset;
}
... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details. */ | EFI_STATUS EmmcPeimGetAllCid(IN EMMC_PEIM_HC_SLOT *Slot) | /* Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details. */
EFI_STATUS EmmcPeimGetAllCid(IN EMMC_PEIM_HC_SLOT *Slot) | {
EMMC_COMMAND_BLOCK EmmcCmdBlk;
EMMC_STATUS_BLOCK EmmcStatusBlk;
EMMC_COMMAND_PACKET Packet;
EFI_STATUS Status;
ZeroMem (&EmmcCmdBlk, sizeof (EmmcCmdBlk));
ZeroMem (&EmmcStatusBlk, sizeof (EmmcStatusBlk));
ZeroMem (&Packet, sizeof (Packet));
Packet.EmmcCmdBlk = &EmmcCmdBlk;
Packet.... | tianocore/edk2 | C++ | Other | 4,240 |
/* Get the element's address when read transmit buffer. */ | static uint32_t MCAN_GetTxBufferElementAddress(CAN_Type *base, uint8_t idx) | /* Get the element's address when read transmit buffer. */
static uint32_t MCAN_GetTxBufferElementAddress(CAN_Type *base, uint8_t idx) | {
assert(idx <= 31U);
uint32_t eSize;
eSize = (base->TXESC & CAN_TXESC_TBDS_MASK) >> CAN_TXESC_TBDS_SHIFT;
if (eSize < 5U)
{
eSize += 4U;
}
else
{
eSize = eSize * 4U - 10U;
}
return (base->TXBC & CAN_TXBC_TBSA_MASK) + idx * eSize * 4U;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* reset the audio format and release the buffer */ | static int snd_usb_hw_free(struct snd_pcm_substream *substream) | /* reset the audio format and release the buffer */
static int snd_usb_hw_free(struct snd_pcm_substream *substream) | {
struct snd_usb_substream *subs = substream->runtime->private_data;
subs->cur_audiofmt = NULL;
subs->cur_rate = 0;
subs->period_bytes = 0;
if (!subs->stream->chip->shutdown)
release_substream_urbs(subs, 0);
return snd_pcm_free_vmalloc_buffer(substream);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function frees the memory allocated to the q_vectors. In addition if NAPI is enabled it will delete any references to the NAPI struct prior to freeing the q_vector. */ | static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter) | /* This function frees the memory allocated to the q_vectors. In addition if NAPI is enabled it will delete any references to the NAPI struct prior to freeing the q_vector. */
static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter) | {
int q_idx, num_q_vectors;
if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED)
num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
else
num_q_vectors = 1;
for (q_idx = 0; q_idx < num_q_vectors; q_idx++) {
struct ixgbe_q_vector *q_vector = adapter->q_vector[q_idx];
adapter->q_vector[q_idx] = NULL;
netif_... | 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.