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
|
---|---|---|---|---|---|---|---|
/* Returns: TRUE if @attribute matches @matcher. FALSE otherwise. */ | gboolean g_file_attribute_matcher_matches(GFileAttributeMatcher *matcher, const char *attribute) | /* Returns: TRUE if @attribute matches @matcher. FALSE otherwise. */
gboolean g_file_attribute_matcher_matches(GFileAttributeMatcher *matcher, const char *attribute) | {
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
if (matcher == NULL)
return FALSE;
if (matcher->all)
return TRUE;
return matcher_matches_id (matcher, lookup_attribute (attribute));
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Update the current system clock. This function will be invoked, when system clock has changed. */ | static void cmu_clock_update(uint32_t clock) | /* Update the current system clock. This function will be invoked, when system clock has changed. */
static void cmu_clock_update(uint32_t clock) | {
__system_clock = clock;
if (clock > 1000000)
ald_tick_init(TICK_INT_PRIORITY);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns CR_OK upon successful completion, an error code otherwise. */ | enum CRStatus cr_prop_list_get_prop(CRPropList *a_this, CRString **a_prop) | /* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_prop_list_get_prop(CRPropList *a_this, CRString **a_prop) | {
g_return_val_if_fail (a_this && PRIVATE (a_this)
&& a_prop, CR_BAD_PARAM_ERROR);
*a_prop = PRIVATE (a_this)->prop;
return CR_OK;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* %-EEXIST - A record associated with @key already exist. */ | int nilfs_bmap_insert(struct nilfs_bmap *bmap, unsigned long key, unsigned long rec) | /* %-EEXIST - A record associated with @key already exist. */
int nilfs_bmap_insert(struct nilfs_bmap *bmap, unsigned long key, unsigned long rec) | {
int ret;
down_write(&bmap->b_sem);
ret = nilfs_bmap_do_insert(bmap, key, rec);
up_write(&bmap->b_sem);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This routine is called from sys_reboot to actually turn off the machine */ | void machine_power_off(void) | /* This routine is called from sys_reboot to actually turn off the machine */
void machine_power_off(void) | {
if (chassis_power_off)
chassis_power_off();
pdc_soft_power_button(0);
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
printk(KERN_EMERG "System shut down completed.\n"
"Please power this system off now.");
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Performs sanity check for supplied partition. Offset and size are verified to be within valid range. Partition type is checked and either parts_validate_nor() or parts_validate_nand() is called with the argument of part. */ | static int part_validate(struct mtdids *id, struct part_info *part) | /* Performs sanity check for supplied partition. Offset and size are verified to be within valid range. Partition type is checked and either parts_validate_nor() or parts_validate_nand() is called with the argument of part. */
static int part_validate(struct mtdids *id, struct part_info *part) | {
if (part->size == SIZE_REMAINING)
part->size = id->size - part->offset;
if (part->offset > id->size) {
printf("%s: offset %08x beyond flash size %08x\n",
id->mtd_id, part->offset, id->size);
return 1;
}
if ((part->offset + part->size) <= part->offset) {
printf("%s%d: partition (%s) size too big\n",
MTD_DEV_TYPE(id->type), id->num, part->name);
return 1;
}
if (part->offset + part->size > id->size) {
printf("%s: partitioning exceeds flash size\n", id->mtd_id);
return 1;
}
return part_validate_eraseblock(id, part);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* The sqlite3_mutex_leave() routine exits a mutex that was previously entered by the same thread. The behavior is undefined if the mutex is not currently entered. If a NULL pointer is passed as an argument this function is a no-op. */ | SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *) | /* The sqlite3_mutex_leave() routine exits a mutex that was previously entered by the same thread. The behavior is undefined if the mutex is not currently entered. If a NULL pointer is passed as an argument this function is a no-op. */
SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *) | {
if( p ){
sqlite3GlobalConfig.mutex.xMutexLeave(p);
}
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Decrement the reference count on a GTS structure. Free the structure if the reference count goes to zero. */ | void gts_drop(struct gru_thread_state *gts) | /* Decrement the reference count on a GTS structure. Free the structure if the reference count goes to zero. */
void gts_drop(struct gru_thread_state *gts) | {
if (gts && atomic_dec_return(>s->ts_refcnt) == 0) {
if (gts->ts_gms)
gru_drop_mmu_notifier(gts->ts_gms);
kfree(gts);
STAT(gts_free);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return the pointer to register settings of specific SERCOM. */ | static const struct sercomspi_regs_cfg* _spi_get_regs(const uint32_t hw_addr) | /* Return the pointer to register settings of specific SERCOM. */
static const struct sercomspi_regs_cfg* _spi_get_regs(const uint32_t hw_addr) | {
uint8_t n = _sercom_get_hardware_index((const void *)hw_addr);
uint8_t i;
for (i = 0; i < sizeof(sercomspi_regs) / sizeof(struct sercomspi_regs_cfg); i++) {
if (sercomspi_regs[i].n == n) {
return &sercomspi_regs[i];
}
}
return NULL;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Handles the StartupAllAPs case where the timeout has occurred. */ | STATIC VOID ProcessStartupAllAPsTimeout(VOID) | /* Handles the StartupAllAPs case where the timeout has occurred. */
STATIC VOID ProcessStartupAllAPsTimeout(VOID) | {
CPU_AP_DATA *CpuData;
UINTN Index;
if (mCpuMpData.FailedList == NULL) {
return;
}
for (Index = 0; Index < mCpuMpData.NumberOfProcessors; Index++) {
CpuData = &mCpuMpData.CpuData[Index];
if (IsProcessorBSP (Index)) {
continue;
}
if (!IsProcessorEnabled (Index)) {
continue;
}
CpuData = &mCpuMpData.CpuData[Index];
AddProcessorToFailedList (Index, GetApState (CpuData));
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* f* bus_vcxk/vcxk_setbrightness FUNCTION set the display brightness PARAMETER side 1 set front side brightness 2 set back side brightness 3 set brightness for both sides brightness 0..1000 */ | void vcxk_setbrightness(unsigned int side, short brightness) | /* f* bus_vcxk/vcxk_setbrightness FUNCTION set the display brightness PARAMETER side 1 set front side brightness 2 set back side brightness 3 set brightness for both sides brightness 0..1000 */
void vcxk_setbrightness(unsigned int side, short brightness) | {
if (VC4K16) {
if ((side == 0) || (side & 0x1))
VC4K16_Bright1 = brightness + 23;
if ((side == 0) || (side & 0x2))
VC4K16_Bright2 = brightness + 23;
} else {
VC2K_Bright = (brightness >> 4) + 2;
VC8K_BrightH = (brightness + 23) >> 8;
VC8K_BrightL = (brightness + 23) & 0xFF;
}
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Disable the MMC Tx interrupt. The MMC tx interrupts are masked out as per the mask specified. */ | void synopGMAC_disable_mmc_tx_interrupt(synopGMACdevice *gmacdev, u32 mask) | /* Disable the MMC Tx interrupt. The MMC tx interrupts are masked out as per the mask specified. */
void synopGMAC_disable_mmc_tx_interrupt(synopGMACdevice *gmacdev, u32 mask) | {
synopGMACSetBits(gmacdev->MacBase, GmacMmcIntrMaskTx, mask);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Blink the LED in the given color.
Currently it is only possible to create colors by turning the three LEDs completely on or off. Proper mixing is not supported by the underlying API. */ | static int blink_color(const struct device *dev, bool r, bool g, bool b, uint32_t delay_on, uint32_t delay_off) | /* Blink the LED in the given color.
Currently it is only possible to create colors by turning the three LEDs completely on or off. Proper mixing is not supported by the underlying API. */
static int blink_color(const struct device *dev, bool r, bool g, bool b, uint32_t delay_on, uint32_t delay_off) | {
int ret;
if (r) {
ret = led_blink(dev, LED_R, delay_on, delay_off);
if (ret) {
LOG_ERR("Failed to set color.");
return ret;
}
}
if (g) {
ret = led_blink(dev, LED_G, delay_on, delay_off);
if (ret) {
LOG_ERR("Failed to set color.");
return ret;
}
}
if (b) {
ret = led_blink(dev, LED_B, delay_on, delay_off);
if (ret) {
LOG_ERR("Failed to set color.");
return ret;
}
}
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Function to retrieve the next bit stored in the given bit buffer. */ | bool BitBuffer_GetNextBit(BitBuffer_t *const Buffer) | /* Function to retrieve the next bit stored in the given bit buffer. */
bool BitBuffer_GetNextBit(BitBuffer_t *const Buffer) | {
bool Bit = ((*Buffer->Out.CurrentByte & Buffer->Out.ByteMask) != 0);
*Buffer->Out.CurrentByte &= ~Buffer->Out.ByteMask;
Buffer->Elements--;
if (Buffer->Out.ByteMask == (1 << 7))
{
if (Buffer->Out.CurrentByte != &Buffer->Data[sizeof(Buffer->Data) - 1])
Buffer->Out.CurrentByte++;
else
Buffer->Out.CurrentByte = Buffer->Data;
Buffer->Out.ByteMask = (1 << 0);
}
else
{
Buffer->Out.ByteMask <<= 1;
}
return Bit;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* param base asrc base pointer. param handle ASRC channel pair edma handle. param inSampleRate input sample rate. param outSampleRate output sample rate. param inSamples input sampleS size. retval output buffer size in byte. */ | uint32_t ASRC_GetOutSamplesSizeEDMA(ASRC_Type *base, asrc_edma_handle_t *handle, uint32_t inSampleRate, uint32_t outSampleRate, uint32_t inSamplesize) | /* param base asrc base pointer. param handle ASRC channel pair edma handle. param inSampleRate input sample rate. param outSampleRate output sample rate. param inSamples input sampleS size. retval output buffer size in byte. */
uint32_t ASRC_GetOutSamplesSizeEDMA(ASRC_Type *base, asrc_edma_handle_t *handle, uint32_t inSampleRate, uint32_t outSampleRate, uint32_t inSamplesize) | {
uint32_t outputSize = ASRC_GetOutSamplesSize(base, handle->channelPair, inSampleRate, outSampleRate, inSamplesize);
return outputSize - outputSize % handle->out.fifoThreshold;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables or disables the Internal High Speed oscillator (HSI). */ | void RCC_HSICmd(FunctionalState NewState) | /* Enables or disables the Internal High Speed oscillator (HSI). */
void RCC_HSICmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->CR |= RCC_CR_HSION;
}
else
{
RCC->CR &= ~RCC_CR_HSION;
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Input an Ethernet address and convert to binary. */ | int iw_ether_aton(const char *orig, struct ether_addr *eth) | /* Input an Ethernet address and convert to binary. */
int iw_ether_aton(const char *orig, struct ether_addr *eth) | {
int maclen;
maclen = iw_mac_aton(orig, (unsigned char *) eth, ETH_ALEN);
if((maclen > 0) && (maclen < ETH_ALEN))
{
errno = EINVAL;
maclen = 0;
}
return(maclen);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Sets a register field specified by the supplied mask to the given value. */ | void t3_set_reg_field(struct adapter *adapter, unsigned int addr, u32 mask, u32 val) | /* Sets a register field specified by the supplied mask to the given value. */
void t3_set_reg_field(struct adapter *adapter, unsigned int addr, u32 mask, u32 val) | {
u32 v = t3_read_reg(adapter, addr) & ~mask;
t3_write_reg(adapter, addr, v | val);
t3_read_reg(adapter, addr);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Change a thread's priority.
Unlike the normal k_thread_priority_set(), this custom syscall allows a user thread to raise its priority. */ | void z_impl_test_thread_priority_set(k_tid_t thread, int prio) | /* Change a thread's priority.
Unlike the normal k_thread_priority_set(), this custom syscall allows a user thread to raise its priority. */
void z_impl_test_thread_priority_set(k_tid_t thread, int prio) | {
extern void z_thread_priority_set(struct k_thread *thread, int prio);
z_thread_priority_set((struct k_thread *)thread, prio);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Updated the PTP system time with the Time Stamp Update register value. */ | void ETH_UpdatePtpTimeStamp(void) | /* Updated the PTP system time with the Time Stamp Update register value. */
void ETH_UpdatePtpTimeStamp(void) | {
ETH->PTPTSCTRL |= ETH_PTPTSCTRL_TSUPDT;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* configure the direction of data transfer on the channel */ | void dma_transfer_direction_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t direction) | /* configure the direction of data transfer on the channel */
void dma_transfer_direction_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t direction) | {
if(ERROR == dma_periph_and_channel_check(dma_periph, channelx)){
DMA_WRONG_HANDLE
}
if(DMA_PERIPHERAL_TO_MEMORY == direction){
DMA_CHCTL(dma_periph, channelx) &= ~DMA_CHXCTL_DIR;
} else {
DMA_CHCTL(dma_periph, channelx) |= DMA_CHXCTL_DIR;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Airpcap wrapper, used to get the channel of an airpcap adapter */ | gboolean airpcap_if_get_device_channel(PAirpcapHandle ah, guint *ch) | /* Airpcap wrapper, used to get the channel of an airpcap adapter */
gboolean airpcap_if_get_device_channel(PAirpcapHandle ah, guint *ch) | {
if (!AirpcapLoaded) return FALSE;
return g_PAirpcapGetDeviceChannel(ah,ch);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Writes and returns a new value to DR3. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */ | UINTN EFIAPI AsmWriteDr3(IN UINTN Value) | /* Writes and returns a new value to DR3. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */
UINTN EFIAPI AsmWriteDr3(IN UINTN Value) | {
_asm {
mov eax, Value
mov dr3, eax
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Write the config space of a given PCI device (both normal and extended). */ | STATIC RETURN_STATUS EFIAPI ProtoDevWriteConfig(IN PCI_CAP_DEV *PciDevice, IN UINT16 DestinationOffset, IN VOID *SourceBuffer, IN UINT16 Size) | /* Write the config space of a given PCI device (both normal and extended). */
STATIC RETURN_STATUS EFIAPI ProtoDevWriteConfig(IN PCI_CAP_DEV *PciDevice, IN UINT16 DestinationOffset, IN VOID *SourceBuffer, IN UINT16 Size) | {
PROTO_DEV *ProtoDev;
ProtoDev = PROTO_DEV_FROM_PCI_CAP_DEV (PciDevice);
return ProtoDevTransferConfig (
ProtoDev->PciIo,
ProtoDev->PciIo->Pci.Write,
DestinationOffset,
SourceBuffer,
Size
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* I2C Set the 10 bit Slave Address for the Peripheral.
This sets an address for Slave mode operation, in 10 bit form. */ | void i2c_set_own_10bit_slave_address(uint32_t i2c, uint16_t slave) | /* I2C Set the 10 bit Slave Address for the Peripheral.
This sets an address for Slave mode operation, in 10 bit form. */
void i2c_set_own_10bit_slave_address(uint32_t i2c, uint16_t slave) | {
I2C_OAR1(i2c) = (uint16_t)(I2C_OAR1_ADDMODE | slave);
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* I2C over AUX CH Send the address. If the I2C link is running, this 'restarts' the connection with the new address, this is used for doing a write followed by a read (as needed for DDC) */ | static int i2c_algo_dp_aux_address(struct i2c_adapter *adapter, u16 address, bool reading) | /* I2C over AUX CH Send the address. If the I2C link is running, this 'restarts' the connection with the new address, this is used for doing a write followed by a read (as needed for DDC) */
static int i2c_algo_dp_aux_address(struct i2c_adapter *adapter, u16 address, bool reading) | {
struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data;
int mode = MODE_I2C_START;
int ret;
if (reading)
mode |= MODE_I2C_READ;
else
mode |= MODE_I2C_WRITE;
algo_data->address = address;
algo_data->running = true;
ret = i2c_algo_dp_aux_transaction(adapter, mode, 0, NULL);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* initial settings for all BCM sockets to be set at socket creation time */ | static int bcm_init(struct sock *sk) | /* initial settings for all BCM sockets to be set at socket creation time */
static int bcm_init(struct sock *sk) | {
struct bcm_sock *bo = bcm_sk(sk);
bo->bound = 0;
bo->ifindex = 0;
bo->dropped_usr_msgs = 0;
bo->bcm_proc_read = NULL;
INIT_LIST_HEAD(&bo->tx_ops);
INIT_LIST_HEAD(&bo->rx_ops);
bo->notifier.notifier_call = bcm_notifier;
register_netdevice_notifier(&bo->notifier);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Function for changing the state of the TX state machine. */ | static void tx_sm_state_change(tx_state_t new_state) | /* Function for changing the state of the TX state machine. */
static void tx_sm_state_change(tx_state_t new_state) | {
m_tx_state = new_state;
tx_sm_event_handle(TX_EVENT_STATE_ENTRY);
} | labapart/polymcu | C++ | null | 201 |
/* Determine if a particular character is an alphanumeric character */ | int isalnum(int c) | /* Determine if a particular character is an alphanumeric character */
int isalnum(int c) | {
return ((('0' <= (c)) && ((c) <= '9')) ||
(('a' <= (c)) && ((c) <= 'z')) ||
(('A' <= (c)) && ((c) <= 'Z')));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Payload maintainer may make decision which HOB is need or needn't Then add the check logic in the function. */ | BOOLEAN IsHobNeed(EFI_PEI_HOB_POINTERS Hob) | /* Payload maintainer may make decision which HOB is need or needn't Then add the check logic in the function. */
BOOLEAN IsHobNeed(EFI_PEI_HOB_POINTERS Hob) | {
if (Hob.Header->HobType == EFI_HOB_TYPE_HANDOFF) {
return FALSE;
}
if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
if (CompareGuid (&Hob.MemoryAllocationModule->MemoryAllocationHeader.Name, &gEfiHobMemoryAllocModuleGuid)) {
return FALSE;
}
}
return TRUE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Flush all characters from the ttys characeter buffer put there by tty3270_put_char. */ | static void tty3270_flush_chars(struct tty_struct *tty) | /* Flush all characters from the ttys characeter buffer put there by tty3270_put_char. */
static void tty3270_flush_chars(struct tty_struct *tty) | {
struct tty3270 *tp;
tp = tty->driver_data;
if (!tp)
return;
if (tp->char_count > 0) {
tty3270_do_write(tp, tp->char_buf, tp->char_count);
tp->char_count = 0;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note that this will only take effect when the link state changes. */ | static int set_linkdowndefaultstate(struct ipath_devdata *dd, int sleep) | /* Note that this will only take effect when the link state changes. */
static int set_linkdowndefaultstate(struct ipath_devdata *dd, int sleep) | {
if (sleep)
dd->ipath_ibcctrl |= INFINIPATH_IBCC_LINKDOWNDEFAULTSTATE;
else
dd->ipath_ibcctrl &= ~INFINIPATH_IBCC_LINKDOWNDEFAULTSTATE;
ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl,
dd->ipath_ibcctrl);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Fills the LCD with the specified 16-bit color. */ | void lcdFillRGB(uint16_t data) | /* Fills the LCD with the specified 16-bit color. */
void lcdFillRGB(uint16_t data) | {
uint16_t i;
ssd1351SetCursor(0, 0);
CMD(SSD1351_CMD_WRITERAM);
for (i=1; i<=((ssd1351Properties.width)*(ssd1351Properties.height)) * 2;i++)
{
DATA(data >> 8);
DATA(data);
}
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* RETURNS: Pointer to allocated devres on success, NULL on failure. */ | void* devres_alloc(dr_release_t release, size_t size, gfp_t gfp) | /* RETURNS: Pointer to allocated devres on success, NULL on failure. */
void* devres_alloc(dr_release_t release, size_t size, gfp_t gfp) | {
struct devres *dr;
dr = alloc_dr(release, size, gfp);
if (unlikely(!dr))
return NULL;
return dr->data;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the RTC registers write protection. */ | void RTC_WriteProtectionCmd(FunctionalState NewState) | /* Enables or disables the RTC registers write protection. */
void RTC_WriteProtectionCmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RTC->WPR = RTC_WPR_EnableKey;
}
else
{
RTC->WPR = RTC_WPR_DisableKey1;
RTC->WPR = RTC_WPR_DisableKey2;
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Returns: the (possibly changed) start of the #GList */ | GList* g_list_delete_link(GList *list, GList *link_) | /* Returns: the (possibly changed) start of the #GList */
GList* g_list_delete_link(GList *list, GList *link_) | {
list = _g_list_remove_link (list, link_);
_g_list_free1 (link_);
return list;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Check for the channel element in the current channel position configuration. If it exists, make sure the appropriate element is allocated and map the channel order to match the internal FFmpeg channel layout. */ | static av_cold int che_configure(AACContext *ac, enum ChannelPosition che_pos[4][MAX_ELEM_ID], int type, int id, int *channels) | /* Check for the channel element in the current channel position configuration. If it exists, make sure the appropriate element is allocated and map the channel order to match the internal FFmpeg channel layout. */
static av_cold int che_configure(AACContext *ac, enum ChannelPosition che_pos[4][MAX_ELEM_ID], int type, int id, int *channels) | {
if (che_pos[type][id]) {
if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
return AVERROR(ENOMEM);
ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr);
if (type != TYPE_CCE) {
ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret;
if (type == TYPE_CPE ||
(type == TYPE_SCE && ac->m4ac.ps == 1)) {
ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret;
}
}
} else {
if (ac->che[type][id])
ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
av_freep(&ac->che[type][id]);
}
return 0;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* e1000_desc_unused - calculate if we have unused descriptors */ | static int e1000_desc_unused(struct e1000_ring *ring) | /* e1000_desc_unused - calculate if we have unused descriptors */
static int e1000_desc_unused(struct e1000_ring *ring) | {
if (ring->next_to_clean > ring->next_to_use)
return ring->next_to_clean - ring->next_to_use - 1;
return ring->count + ring->next_to_clean - ring->next_to_use - 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set Timer Option.
Set timer options register on TIM2 or TIM5, used for trigger remapping on TIM2, and similarly for TIM5 for oscillator calibration purposes. */ | void timer_set_option(uint32_t timer_peripheral, uint32_t option) | /* Set Timer Option.
Set timer options register on TIM2 or TIM5, used for trigger remapping on TIM2, and similarly for TIM5 for oscillator calibration purposes. */
void timer_set_option(uint32_t timer_peripheral, uint32_t option) | {
if (timer_peripheral == TIM2) {
TIM_OR(timer_peripheral) &= ~TIM2_OR_ITR1_RMP_MASK;
TIM_OR(timer_peripheral) |= option;
} else if (timer_peripheral == TIM5) {
TIM_OR(timer_peripheral) &= ~TIM5_OR_TI4_RMP_MASK;
TIM_OR(timer_peripheral) |= option;
}
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* param base eDMA peripheral base address. param channel eDMA channel number. param mask The mask of interrupt source to be set. Users need to use the defined edma_interrupt_enable_t type. */ | void EDMA_EnableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask) | /* param base eDMA peripheral base address. param channel eDMA channel number. param mask The mask of interrupt source to be set. Users need to use the defined edma_interrupt_enable_t type. */
void EDMA_EnableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask) | {
assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL);
if (0U != (mask & (uint32_t)kEDMA_ErrorInterruptEnable))
{
base->EEI |= ((uint32_t)0x1U << channel);
}
if (0U != (mask & (uint32_t)kEDMA_MajorInterruptEnable))
{
base->TCD[channel].CSR |= DMA_CSR_INTMAJOR_MASK;
}
if (0U != (mask & (uint32_t)kEDMA_HalfInterruptEnable))
{
base->TCD[channel].CSR |= DMA_CSR_INTHALF_MASK;
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Post an RCU bottom-half callback to be invoked after any subsequent quiescent state. */ | void call_rcu_bh(struct rcu_head *head, void(*func)(struct rcu_head *rcu)) | /* Post an RCU bottom-half callback to be invoked after any subsequent quiescent state. */
void call_rcu_bh(struct rcu_head *head, void(*func)(struct rcu_head *rcu)) | {
__call_rcu(head, func, &rcu_bh_ctrlblk);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* pm8001_find_ha_by_dev - from domain device which come from sas layer to find out our hba struct. @dev: the domain device which from sas layer. */ | static struct pm8001_hba_info* pm8001_find_ha_by_dev(struct domain_device *dev) | /* pm8001_find_ha_by_dev - from domain device which come from sas layer to find out our hba struct. @dev: the domain device which from sas layer. */
static struct pm8001_hba_info* pm8001_find_ha_by_dev(struct domain_device *dev) | {
struct sas_ha_struct *sha = dev->port->ha;
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
return pm8001_ha;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* pm_runtime_cancel_pending - Deactivate suspend timer and cancel requests. @dev: Device to handle. */ | static void pm_runtime_cancel_pending(struct device *dev) | /* pm_runtime_cancel_pending - Deactivate suspend timer and cancel requests. @dev: Device to handle. */
static void pm_runtime_cancel_pending(struct device *dev) | {
pm_runtime_deactivate_timer(dev);
dev->power.request = RPM_REQ_NONE;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* So, when pin_stack_pages() asks us to pin a page, we check if it's already in the page tables, and if not, we call demand_page() with error code 2 (meaning "write"). */ | void pin_page(struct lg_cpu *cpu, unsigned long vaddr) | /* So, when pin_stack_pages() asks us to pin a page, we check if it's already in the page tables, and if not, we call demand_page() with error code 2 (meaning "write"). */
void pin_page(struct lg_cpu *cpu, unsigned long vaddr) | {
if (!page_writable(cpu, vaddr) && !demand_page(cpu, vaddr, 2))
kill_guest(cpu, "bad stack page %#lx", vaddr);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the PLL. The PLL can not be disabled if it is used as system clock. */ | void RCC_PLLCmd(FunctionalState NewState) | /* Enables or disables the PLL. The PLL can not be disabled if it is used as system clock. */
void RCC_PLLCmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->CR |= 0x01000000;
}
else
{
RCC->CR &= 0xfeffffff;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The caller should ensure both socket addresses are AF_INET. */ | static int nfs_sockaddr_match_ipaddr4(const struct sockaddr *sa1, const struct sockaddr *sa2) | /* The caller should ensure both socket addresses are AF_INET. */
static int nfs_sockaddr_match_ipaddr4(const struct sockaddr *sa1, const struct sockaddr *sa2) | {
const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* terminate most inactive voice and give it as a pcm voice. */ | int snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw) | /* terminate most inactive voice and give it as a pcm voice. */
int snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw) | {
struct snd_emux *emu;
struct snd_emux_voice *vp;
struct best_voice best[V_END];
unsigned long flags;
int i;
emu = hw->synth;
spin_lock_irqsave(&emu->voice_lock, flags);
lookup_voices(emu, hw, best, 1);
for (i = 0; i < V_END; i++) {
if (best[i].voice >= 0) {
int ch;
vp = &emu->voices[best[i].voice];
if ((ch = vp->ch) < 0) {
continue;
}
vp->emu->num_voices--;
vp->ch = -1;
vp->state = SNDRV_EMUX_ST_OFF;
spin_unlock_irqrestore(&emu->voice_lock, flags);
return ch;
}
}
spin_unlock_irqrestore(&emu->voice_lock, flags);
return -ENOMEM;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Manual context switch. The first thing we do is save the registers so we can use a naked attribute. */ | void vPortYield(void) | /* Manual context switch. The first thing we do is save the registers so we can use a naked attribute. */
void vPortYield(void) | {
portSAVE_CONTEXT();
vTaskSwitchContext();
portRESTORE_CONTEXT();
asm volatile ( "ret" );
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Writes the base/extended device id from a device. */ | static void rio_local_set_device_id(struct rio_mport *port, u16 did) | /* Writes the base/extended device id from a device. */
static void rio_local_set_device_id(struct rio_mport *port, u16 did) | {
rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(port->sys_size,
did));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Programs a word at a specified address in program memory. */ | FLASH_Status FLASH_FastProgramWord(uint32_t Address, uint32_t Data) | /* Programs a word at a specified address in program memory. */
FLASH_Status FLASH_FastProgramWord(uint32_t Address, uint32_t Data) | {
FLASH_Status status = FLASH_COMPLETE;
assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);
if(status == FLASH_COMPLETE)
{
*(__IO uint32_t *)Address = Data;
status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);
}
return status;
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* Return Value: 1 if able to store, 0 otherwise */ | static int save_tx_buffer_request(struct mgsl_struct *info, const char *Buffer, unsigned int BufferSize) | /* Return Value: 1 if able to store, 0 otherwise */
static int save_tx_buffer_request(struct mgsl_struct *info, const char *Buffer, unsigned int BufferSize) | {
struct tx_holding_buffer *ptx;
if ( info->tx_holding_count >= info->num_tx_holding_buffers ) {
return 0;
}
ptx = &info->tx_holding_buffers[info->put_tx_holding_index];
ptx->buffer_size = BufferSize;
memcpy( ptx->buffer, Buffer, BufferSize);
++info->tx_holding_count;
if ( ++info->put_tx_holding_index >= info->num_tx_holding_buffers)
info->put_tx_holding_index=0;
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* special treatment of command port - on newer macbooks, it seems necessary to resend the command byte before polling the status again. Callers must hold applesmc_lock. */ | static int send_command(u8 cmd) | /* special treatment of command port - on newer macbooks, it seems necessary to resend the command byte before polling the status again. Callers must hold applesmc_lock. */
static int send_command(u8 cmd) | {
int us;
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
outb(cmd, APPLESMC_CMD_PORT);
udelay(us);
if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c)
return 0;
}
printk(KERN_WARNING "applesmc: command failed: %x -> %x\n",
cmd, inb(APPLESMC_CMD_PORT));
return -EIO;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* dma_region_sync_for_device - sync the IO bus' view of the buffer */ | void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len) | /* dma_region_sync_for_device - sync the IO bus' view of the buffer */
void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len) | {
int first, last;
unsigned long rem = 0;
if (!len)
len = 1;
first = dma_region_find(dma, offset, 0, &rem);
last = dma_region_find(dma, rem + len - 1, first, &rem);
pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first],
last - first + 1, dma->direction);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get the number of trackballs on a joystick */ | int SDL_JoystickNumBalls(SDL_Joystick *joystick) | /* Get the number of trackballs on a joystick */
int SDL_JoystickNumBalls(SDL_Joystick *joystick) | {
if (!SDL_PrivateJoystickValid(joystick)) {
return -1;
}
return joystick->nballs;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* this routine checks for available ethernet frames that the network interface might have received, and notifies the network stack */ | static int mcs7830_recv(struct eth_device *eth) | /* this routine checks for available ethernet frames that the network interface might have received, and notifies the network stack */
static int mcs7830_recv(struct eth_device *eth) | {
ALLOC_CACHE_ALIGN_BUFFER(uint8_t, buf, MCS7830_RX_URB_SIZE);
struct ueth_data *ueth = eth->priv;
int len;
len = mcs7830_recv_common(ueth, buf);
if (len >= 0) {
net_process_received_packet(buf, len);
return 0;
}
return len;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function get fault brake interrupt flag of selected source. */ | uint32_t PWM_GetFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource) | /* This function get fault brake interrupt flag of selected source. */
uint32_t PWM_GetFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource) | {
return (((pwm)->INTSTS1 & (0x3fUL << u32BrakeSource)) ? 1UL : 0UL);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Reset the ART Cache.
The ART cache must be disabled for this to have effect. */ | void flash_art_reset(void) | /* Reset the ART Cache.
The ART cache must be disabled for this to have effect. */
void flash_art_reset(void) | {
FLASH_ACR |= FLASH_ACR_ARTRST;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Clears out all files from the Fv buffer in memory */ | EFI_STATUS FvBufRemoveFileNew(IN OUT VOID *Fv, IN EFI_GUID *Name) | /* Clears out all files from the Fv buffer in memory */
EFI_STATUS FvBufRemoveFileNew(IN OUT VOID *Fv, IN EFI_GUID *Name) | {
EFI_STATUS Status;
EFI_FFS_FILE_HEADER* FileToRm;
UINTN FileToRmLength;
Status = FvBufFindFileByName(
Fv,
Name,
(VOID **)&FileToRm
);
if (EFI_ERROR (Status)) {
return Status;
}
FileToRmLength = FvBufGetFfsFileSize (FileToRm);
CommonLibBinderSetMem (
FileToRm,
FileToRmLength,
(((EFI_FIRMWARE_VOLUME_HEADER*)Fv)->Attributes & EFI_FVB2_ERASE_POLARITY)
? 0xFF : 0
);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set the pointer at the specified location to NULL. */ | void g_nullify_pointer(gpointer *nullify_location) | /* Set the pointer at the specified location to NULL. */
void g_nullify_pointer(gpointer *nullify_location) | {
g_return_if_fail (nullify_location != NULL);
*nullify_location = NULL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function may be called to determine the number of blocks in the EEPROM. Each block is the same size and the number of bytes of storage contained in a block may be determined by dividing the size of the device, obtained via a call to the */ | unsigned long EEPROMBlockCountGet(void) | /* This function may be called to determine the number of blocks in the EEPROM. Each block is the same size and the number of bytes of storage contained in a block may be determined by dividing the size of the device, obtained via a call to the */
unsigned long EEPROMBlockCountGet(void) | {
return(BLOCKS_FROM_EESIZE(HWREG(EEPROM_EESIZE)));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* NOTE..... If BIOS doesn't provide default routing, we assign: 9 for SCSI, 10 for LAN adapters, and 11 for everything else. If adapter is bridged, then we assign 11 to it and devices behind it. We also assign the same irq numbers for multi function devices. These are PIC mode, so shouldn't matter n.e.ways (hopefully) */ | static void assign_alt_irq(struct pci_func *cur_func, u8 class_code) | /* NOTE..... If BIOS doesn't provide default routing, we assign: 9 for SCSI, 10 for LAN adapters, and 11 for everything else. If adapter is bridged, then we assign 11 to it and devices behind it. We also assign the same irq numbers for multi function devices. These are PIC mode, so shouldn't matter n.e.ways (hopefully) */
static void assign_alt_irq(struct pci_func *cur_func, u8 class_code) | {
int j;
for (j = 0; j < 4; j++) {
if (cur_func->irq[j] == 0xff) {
switch (class_code) {
case PCI_BASE_CLASS_STORAGE:
cur_func->irq[j] = SCSI_IRQ;
break;
case PCI_BASE_CLASS_NETWORK:
cur_func->irq[j] = LAN_IRQ;
break;
default:
cur_func->irq[j] = OTHER_IRQ;
break;
}
}
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note: If the character array is too small (or absent), the print buffer becomes a null device that discards anything written to it. */ | void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size) | /* Note: If the character array is too small (or absent), the print buffer becomes a null device that discards anything written to it. */
void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size) | {
pb->buf = raw;
pb->crs = raw;
pb->size = size;
pb->echo = 0;
if (size < TIPC_PB_MIN_SIZE) {
pb->buf = NULL;
} else if (raw) {
pb->buf[0] = 0;
pb->buf[size - 1] = ~0;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Free an SSDT table previously created by the BuildSsdtSerialTable function. */ | EFI_STATUS EFIAPI FreeSsdtSerialPortTable(IN EFI_ACPI_DESCRIPTION_HEADER *Table) | /* Free an SSDT table previously created by the BuildSsdtSerialTable function. */
EFI_STATUS EFIAPI FreeSsdtSerialPortTable(IN EFI_ACPI_DESCRIPTION_HEADER *Table) | {
ASSERT (Table != NULL);
FreePool (Table);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sets the RPM of a FAN channel when in automatic mode. */ | void FanChannelRPMSet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulRPM) | /* Sets the RPM of a FAN channel when in automatic mode. */
void FanChannelRPMSet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulRPM) | {
ASSERT(ulBase == FAN0_BASE);
ASSERT(ulChannel <= 5);
ASSERT(ulRPM < 8192);
HWREG(ulBase + FAN_O_CMD0 + (ulChannel * 0x10)) = ulRPM;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* We do it from here because some times we cannot do it in the original context the command was sent (it is a const), so when we copy it to our staging buffer, we add the checksum there. */ | void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) | /* We do it from here because some times we cannot do it in the original context the command was sent (it is a const), so when we copy it to our staging buffer, we add the checksum there. */
void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) | {
if (i2400m_brh_get_use_checksum(cmd)) {
int i;
u32 checksum = 0;
const u32 *checksum_ptr = (void *) cmd->payload;
for (i = 0; i < cmd->data_size / 4; i++)
checksum += cpu_to_le32(*checksum_ptr++);
checksum += cmd->command + cmd->target_addr + cmd->data_size;
cmd->block_checksum = cpu_to_le32(checksum);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get the drag enable attribute of an object */ | bool lv_obj_get_drag(const lv_obj_t *obj) | /* Get the drag enable attribute of an object */
bool lv_obj_get_drag(const lv_obj_t *obj) | {
return obj->drag == 0 ? false : true;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Initialize the input controller module. This is called only once, when the decompression object is created. */ | jinit_input_controller(j_decompress_ptr cinfo) | /* Initialize the input controller module. This is called only once, when the decompression object is created. */
jinit_input_controller(j_decompress_ptr cinfo) | {
my_inputctl_ptr inputctl;
inputctl = (my_inputctl_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
SIZEOF(my_input_controller));
cinfo->inputctl = (struct jpeg_input_controller*) inputctl;
inputctl->pub.consume_input = consume_markers;
inputctl->pub.reset_input_controller = reset_input_controller;
inputctl->pub.start_input_pass = start_input_pass;
inputctl->pub.finish_input_pass = finish_input_pass;
inputctl->pub.has_multiple_scans = FALSE;
inputctl->pub.eoi_reached = FALSE;
inputctl->inheaders = TRUE;
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* free the USB host channel assigned by idx */ | uint8_t usb_host_freech(usb_core_instance *pdev, uint8_t idx) | /* free the USB host channel assigned by idx */
uint8_t usb_host_freech(usb_core_instance *pdev, uint8_t idx) | {
if (idx < USB_MAX_CH_NUM) {
pdev->host.channel[idx & (USB_MAX_TX_FIFOS - 1U)] &= HC_USED_MASK;
}
return (uint8_t)HSTATUS_OK;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables or disables the specified I2C software reset. */ | void I2C_SoftwareResetCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | /* Enables or disables the specified I2C software reset. */
void I2C_SoftwareResetCmd(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_SWRST;
}
else
{
I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_SWRST);
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* platform wakeup will becomes one of pds_wakeup source */ | BL_Err_Type GLB_Platform_Wakeup_Enable(void) | /* platform wakeup will becomes one of pds_wakeup source */
BL_Err_Type GLB_Platform_Wakeup_Enable(void) | {
uint32_t tmpVal;
tmpVal = BL_RD_REG(GLB_BASE, GLB_DIG32K_WAKEUP_CTRL);
tmpVal = BL_SET_REG_BIT(tmpVal, GLB_REG_EN_PLATFORM_WAKEUP);
BL_WR_REG(GLB_BASE, GLB_DIG32K_WAKEUP_CTRL, tmpVal);
return SUCCESS;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This is an internal worker function to get driver name from Component Name (2) protocol interface. */ | EFI_STATUS DriverHealthManagerGetDriverNameWorker(IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE DriverBindingHandle, OUT CHAR16 **DriverName) | /* This is an internal worker function to get driver name from Component Name (2) protocol interface. */
EFI_STATUS DriverHealthManagerGetDriverNameWorker(IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE DriverBindingHandle, OUT CHAR16 **DriverName) | {
EFI_STATUS Status;
CHAR8 *BestLanguage;
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
Status = DriverHealthManagerGetComponentNameWorker (
ProtocolGuid,
DriverBindingHandle,
&ComponentName,
&BestLanguage
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = ComponentName->GetDriverName (
ComponentName,
BestLanguage,
DriverName
);
FreePool (BestLanguage);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Add a msecs netlink attribute to a netlink message */ | int nla_put_msecs(struct nl_msg *n, int attrtype, unsigned long msecs) | /* Add a msecs netlink attribute to a netlink message */
int nla_put_msecs(struct nl_msg *n, int attrtype, unsigned long msecs) | {
return nla_put_u64(n, attrtype, msecs);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* GDB wants to call malloc() and free() to allocate memory for calling kernel functions directly from its command line */ | static void * malloc(size_t size) __maybe_unused | /* GDB wants to call malloc() and free() to allocate memory for calling kernel functions directly from its command line */
static void * malloc(size_t size) __maybe_unused | {
return kmalloc(size, GFP_ATOMIC);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Very simple control. Either it is on or off and is controlled by a gpio pin */ | static void stargate2_mci_setpower(struct device *dev, unsigned int vdd) | /* Very simple control. Either it is on or off and is controlled by a gpio pin */
static void stargate2_mci_setpower(struct device *dev, unsigned int vdd) | {
gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Please refer to the official documentation for function purpose and expected parameters. */ | int ph7_value_is_bool(ph7_value *pVal) | /* Please refer to the official documentation for function purpose and expected parameters. */
int ph7_value_is_bool(ph7_value *pVal) | {
return (pVal->iFlags & MEMOBJ_REAL) ? TRUE : FALSE;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Initialize master decompression control and select active modules. This is performed at the start of jpeg_start_decompress. */ | jinit_master_decompress(j_decompress_ptr cinfo) | /* Initialize master decompression control and select active modules. This is performed at the start of jpeg_start_decompress. */
jinit_master_decompress(j_decompress_ptr cinfo) | {
my_master_ptr master;
master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_decomp_master));
cinfo->master = (struct jpeg_decomp_master *) master;
master->pub.prepare_for_output_pass = prepare_for_output_pass;
master->pub.finish_output_pass = finish_output_pass;
master->pub.is_dummy_pass = FALSE;
master_selection(cinfo);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* The bit allocator trys to avoid single bit allocations except as a last resort. So in the case where a bitneed of 1 was passed over during the adsjustment phase 2 bits are now allocated. */ | INLINE OI_INT allocAdjustedBits(OI_UINT8 *dest, OI_INT bits, OI_INT excess) | /* The bit allocator trys to avoid single bit allocations except as a last resort. So in the case where a bitneed of 1 was passed over during the adsjustment phase 2 bits are now allocated. */
INLINE OI_INT allocAdjustedBits(OI_UINT8 *dest, OI_INT bits, OI_INT excess) | {
if(bits < 16)
{
if(bits > 1)
{
if(excess)
{
++bits;
--excess;
}
}
else
if((bits == 1) && (excess > 1))
{
bits = 2;
excess -= 2;
}
else
{
bits = 0;
}
}
else
{
bits = 16;
}
*dest = (OI_UINT8)bits;
return excess;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* The length will be 0 if the markeris located in OOB area. */ | static u32 add_marker_len(struct nand_bbt_descr *td) | /* The length will be 0 if the markeris located in OOB area. */
static u32 add_marker_len(struct nand_bbt_descr *td) | {
u32 len;
if (!(td->options & NAND_BBT_NO_OOB))
return 0;
len = td->len;
if (td->options & NAND_BBT_VERSION)
len++;
return len;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Allocate an empty cache based on type name */ | int nl_cache_alloc_name(const char *kind, struct nl_cache **result) | /* Allocate an empty cache based on type name */
int nl_cache_alloc_name(const char *kind, struct nl_cache **result) | {
struct nl_cache_ops *ops;
struct nl_cache *cache;
ops = nl_cache_ops_lookup(kind);
if (!ops)
return -NLE_NOCACHE;
if (!(cache = nl_cache_alloc(ops)))
return -NLE_NOMEM;
*result = cache;
return 0;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* @ubi: UBI device description object @fm_e: physical eraseblock to return @lnum: the last used logical eraseblock number for the PEB @torture: if this physical eraseblock has to be tortured */ | int ubi_wl_put_fm_peb(struct ubi_device *ubi, struct ubi_wl_entry *fm_e, int lnum, int torture) | /* @ubi: UBI device description object @fm_e: physical eraseblock to return @lnum: the last used logical eraseblock number for the PEB @torture: if this physical eraseblock has to be tortured */
int ubi_wl_put_fm_peb(struct ubi_device *ubi, struct ubi_wl_entry *fm_e, int lnum, int torture) | {
struct ubi_wl_entry *e;
int vol_id, pnum = fm_e->pnum;
dbg_wl("PEB %d", pnum);
ubi_assert(pnum >= 0);
ubi_assert(pnum < ubi->peb_count);
spin_lock(&ubi->wl_lock);
e = ubi->lookuptbl[pnum];
if (!e) {
e = fm_e;
ubi_assert(e->ec >= 0);
ubi->lookuptbl[pnum] = e;
}
spin_unlock(&ubi->wl_lock);
vol_id = lnum ? UBI_FM_DATA_VOLUME_ID : UBI_FM_SB_VOLUME_ID;
return schedule_erase(ubi, e, vol_id, lnum, torture);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Convert UINT16 data of the FDT blob to little-endian */ | UINT16 EFIAPI Fdt16ToCpu(IN UINT16 Value) | /* Convert UINT16 data of the FDT blob to little-endian */
UINT16 EFIAPI Fdt16ToCpu(IN UINT16 Value) | {
return fdt16_to_cpu (Value);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Flush any pending base64 character data out. If we have all three bytes are present, this will generate 4 characters, otherwise it may generate fewer. */ | static void base64_flush(struct jwt_builder *st) | /* Flush any pending base64 character data out. If we have all three bytes are present, this will generate 4 characters, otherwise it may generate fewer. */
static void base64_flush(struct jwt_builder *st) | {
if (st->pending < 1) {
return;
}
base64_outch(st, base64_char(st->wip[0] >> 2));
base64_outch(st, base64_char(((st->wip[0] & 0x03) << 4) |
(st->wip[1] >> 4)));
if (st->pending >= 2) {
base64_outch(st, base64_char(((st->wip[1] & 0x0f) << 2) |
(st->wip[2] >> 6)));
}
if (st->pending >= 3) {
base64_outch(st, base64_char(st->wip[2] & 0x3f));
}
st->pending = 0;
memset(st->wip, 0, 3);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Look up a leaf entry in a node-format leaf block. If this is an addname then the extrablk in state is a freespace block, otherwise it's a data block. */ | int xfs_dir2_leafn_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *indexp, xfs_da_state_t *state) | /* Look up a leaf entry in a node-format leaf block. If this is an addname then the extrablk in state is a freespace block, otherwise it's a data block. */
int xfs_dir2_leafn_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *indexp, xfs_da_state_t *state) | {
if (args->op_flags & XFS_DA_OP_ADDNAME)
return xfs_dir2_leafn_lookup_for_addname(bp, args, indexp,
state);
return xfs_dir2_leafn_lookup_for_entry(bp, args, indexp, state);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ufshcd_get_dme_attr_val - Get the value of attribute returned by UIC command */ | static u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba) | /* ufshcd_get_dme_attr_val - Get the value of attribute returned by UIC command */
static u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba) | {
return ufshcd_readl(hba, REG_UIC_COMMAND_ARG_3);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Draw a string in the currently set font.
The spacing between consequtive characters in the string is the fixed number of pixels of the character width of the current global font. */ | int stringColor(SDL_Surface *dst, Sint16 x, Sint16 y, const char *s, Uint32 color) | /* Draw a string in the currently set font.
The spacing between consequtive characters in the string is the fixed number of pixels of the character width of the current global font. */
int stringColor(SDL_Surface *dst, Sint16 x, Sint16 y, const char *s, Uint32 color) | {
int result = 0;
Sint16 curx = x;
Sint16 cury = y;
const char *curchar = s;
while (*curchar && !result) {
result |= characterColor(dst, curx, cury, *curchar, color);
switch (charRotation)
{
case 0:
curx += charWidthLocal;
break;
case 2:
curx -= charWidthLocal;
break;
case 1:
cury += charHeightLocal;
break;
case 3:
cury -= charHeightLocal;
break;
}
curchar++;
}
return (result);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Check if DMA channel is enabled.
The DMA channel is disabled when the DMA controller has finished a DMA cycle. */ | bool DMA_ChannelEnabled(unsigned int channel) | /* Check if DMA channel is enabled.
The DMA channel is disabled when the DMA controller has finished a DMA cycle. */
bool DMA_ChannelEnabled(unsigned int channel) | {
EFM_ASSERT(channel < DMA_CHAN_COUNT);
return (bool)((DMA->CHENS >> channel) & 1);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* This function returns a performance (4 - 128) out of a frequency within the boundaries (min/max). */ | static u32 get_performance(struct cpufreq_policy *policy, unsigned int target_freq) | /* This function returns a performance (4 - 128) out of a frequency within the boundaries (min/max). */
static u32 get_performance(struct cpufreq_policy *policy, unsigned int target_freq) | {
unsigned int perf = 0;
if(target_freq < policy->min)
target_freq = (u32)policy->min;
if(target_freq > policy->max)
target_freq = (u32)policy->max;
perf = (target_freq*0x80)/policy->cpuinfo.max_freq;
if (perf < 4)
perf = 4;
return perf;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Gets the cuurent sd card data transfer status. */ | SDTransferState SD_GetStatus(void) | /* Gets the cuurent sd card data transfer status. */
SDTransferState SD_GetStatus(void) | {
SDCardState cardstate = SD_CARD_TRANSFER;
cardstate = SD_GetState ();
if (cardstate == SD_CARD_TRANSFER) {
return (SD_TRANSFER_OK);
} else if (cardstate == SD_CARD_ERROR) {
return (SD_TRANSFER_ERROR);
} else {
return (SD_TRANSFER_BUSY);
}
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Get the XBARA instance from peripheral base address. */ | static uint32_t XBARA_GetInstance(XBARA_Type *base) | /* Get the XBARA instance from peripheral base address. */
static uint32_t XBARA_GetInstance(XBARA_Type *base) | {
uint32_t instance;
for (instance = 0; instance < ARRAY_SIZE(s_xbaraBases); instance++)
{
if (s_xbaraBases[instance] == base)
{
break;
}
}
assert(instance < ARRAY_SIZE(s_xbaraBases));
return instance;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Enables or disables the specified ADC DMA request. */ | void ADC_DMACmd(ADC_TypeDef *adc, FunctionalState state) | /* Enables or disables the specified ADC DMA request. */
void ADC_DMACmd(ADC_TypeDef *adc, FunctionalState state) | {
(state) ? (adc->ADCR |= ADC_CR_DMAEN) : (adc->ADCR &= ~ADC_CR_DMAEN);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check if the block range accessed is within current partition. */ | static status_t MMC_CheckBlockRange(mmc_card_t *card, uint32_t startBlock, uint32_t blockCount) | /* Check if the block range accessed is within current partition. */
static status_t MMC_CheckBlockRange(mmc_card_t *card, uint32_t startBlock, uint32_t blockCount) | {
assert(card);
assert(blockCount);
status_t error = kStatus_Success;
uint32_t partitionBlocks;
switch (card->currentPartition)
{
case kMMC_AccessPartitionUserAera:
{
partitionBlocks = card->userPartitionBlocks;
break;
}
case kMMC_AccessPartitionBoot1:
case kMMC_AccessPartitionBoot2:
{
partitionBlocks = card->bootPartitionBlocks;
break;
}
default:
error = kStatus_InvalidArgument;
break;
}
if ((error == kStatus_Success) && ((startBlock + blockCount) > partitionBlocks))
{
error = kStatus_InvalidArgument;
}
return error;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* @priv: private data of the video console @row: new row @col: new column */ | static void set_cursor_position(struct vidconsole_priv *priv, int row, int col) | /* @priv: private data of the video console @row: new row @col: new column */
static void set_cursor_position(struct vidconsole_priv *priv, int row, int col) | {
if (row >= priv->rows)
row = priv->rows - 1;
if (col >= priv->cols)
col = priv->cols - 1;
priv->ycur = row * priv->y_charsize;
priv->xcur_frac = priv->xstart_frac +
VID_TO_POS(col * priv->x_charsize);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* If a custom request handler was installed, this handler is called first. */ | BOOL USBHandleStandardRequest(TSetupPacket *pSetup, int *piLen, U8 **ppbData) | /* If a custom request handler was installed, this handler is called first. */
BOOL USBHandleStandardRequest(TSetupPacket *pSetup, int *piLen, U8 **ppbData) | {
if ((pfnHandleCustomReq != NULL) && pfnHandleCustomReq(pSetup, piLen, ppbData)) {
return TRUE;
}
switch (REQTYPE_GET_RECIP(pSetup->bmRequestType)) {
case REQTYPE_RECIP_DEVICE: return HandleStdDeviceReq(pSetup, piLen, ppbData);
case REQTYPE_RECIP_INTERFACE: return HandleStdInterfaceReq(pSetup, piLen, ppbData);
case REQTYPE_RECIP_ENDPOINT: return HandleStdEndPointReq(pSetup, piLen, ppbData);
default: return FALSE;
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* block_truncate_page can return an error, but we can't propagate it at all here. Leave a complaint + stack trace in the syslog because this could be bad. If it is bad, we need to propagate the error further. */ | STATIC void xfs_vn_truncate(struct inode *inode) | /* block_truncate_page can return an error, but we can't propagate it at all here. Leave a complaint + stack trace in the syslog because this could be bad. If it is bad, we need to propagate the error further. */
STATIC void xfs_vn_truncate(struct inode *inode) | {
int error;
error = block_truncate_page(inode->i_mapping, inode->i_size,
xfs_get_blocks);
WARN_ON(error);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return VA for a given PA or 0 if not mapped */ | unsigned long p_mapped_by_bats(phys_addr_t pa) | /* Return VA for a given PA or 0 if not mapped */
unsigned long p_mapped_by_bats(phys_addr_t pa) | {
int b;
for (b = 0; b < 4; ++b)
if (pa >= bat_addrs[b].phys
&& pa < (bat_addrs[b].limit-bat_addrs[b].start)
+bat_addrs[b].phys)
return bat_addrs[b].start+(pa-bat_addrs[b].phys);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */ | EFI_STATUS SdMmcHcPowerControl(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT8 PowerCtrl) | /* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */
EFI_STATUS SdMmcHcPowerControl(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT8 PowerCtrl) | {
EFI_STATUS Status;
PowerCtrl &= (UINT8) ~BIT0;
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_POWER_CTRL, FALSE, sizeof (PowerCtrl), &PowerCtrl);
if (EFI_ERROR (Status)) {
return Status;
}
PowerCtrl |= BIT0;
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_POWER_CTRL, FALSE, sizeof (PowerCtrl), &PowerCtrl);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek. */ | LIBC_ROM_TEXT_SECTION _LONG_CALL_ int _stratoi(const char *s) | /* This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek. */
LIBC_ROM_TEXT_SECTION _LONG_CALL_ int _stratoi(const char *s) | {
int num=0,flag=0;
u32 i;
for(i=0;i<=_strlen(s);i++)
{
if(s[i] >= '0' && s[i] <= '9')
num = num * 10 + s[i] -'0';
else if(s[0] == '-' && i==0)
flag =1;
else
break;
}
if(flag == 1)
num = num * -1;
return(num);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Calculates the CRC-16 of an array of words. */ | uint16_t Crc16Array(uint32_t ui32WordLen, const uint32_t *pui32Data) | /* Calculates the CRC-16 of an array of words. */
uint16_t Crc16Array(uint32_t ui32WordLen, const uint32_t *pui32Data) | {
return (Crc16(0, (const uint8_t *)pui32Data, ui32WordLen * 4));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* memSpace = IDMA memory window number from 0 to 7 trg_if = Target interface: 0x0 DRAM 0x1 Device Bus 0x2 Integrated SDRAM (or CPU bus 60x only) 0x3 PCI0 0x4 PCI1 attr = IDMA attributes (see MV datasheet) base_addr = Sets up memory window for transfers */ | int mvDmaSetMemorySpace(ulong, ulong, ulong, ulong, ulong) | /* memSpace = IDMA memory window number from 0 to 7 trg_if = Target interface: 0x0 DRAM 0x1 Device Bus 0x2 Integrated SDRAM (or CPU bus 60x only) 0x3 PCI0 0x4 PCI1 attr = IDMA attributes (see MV datasheet) base_addr = Sets up memory window for transfers */
int mvDmaSetMemorySpace(ulong, ulong, ulong, ulong, ulong) | {
ulong temp;
if (base_addr % size != 0)
return 0;
if (size >= 0x10000) {
size &= 0xffff0000;
base_addr = (base_addr & 0xffff0000);
GT_REG_WRITE (MV64460_DMA_BASE_ADDR_REG0 + memSpace * 8,
(base_addr | trg_if | attr));
GT_REG_WRITE ((MV64460_DMA_SIZE_REG0 + memSpace * 8),
(size - 1) & 0xffff0000);
temp = GTREGREAD (MV64460_DMA_BASE_ADDR_ENABLE_REG);
GT_REG_WRITE (DMA_BASE_ADDR_ENABLE_REG,
(temp & ~(BIT0 << memSpace)));
return 1;
}
return 0;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* The function to call when the LED1 FreeRTOS timer expires. */ | static void led_toggle_timer_callback(void *pvParameter) | /* The function to call when the LED1 FreeRTOS timer expires. */
static void led_toggle_timer_callback(void *pvParameter) | {
UNUSED_PARAMETER(pvParameter);
bsp_board_led_invert(BSP_BOARD_LED_1);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
Subsets and Splits