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
/* fcoe_get_src_mac() - return the Ethernet source address for an lport @lport: libfc lport */
static u8 * fcoe_get_src_mac(struct fc_lport *)
/* fcoe_get_src_mac() - return the Ethernet source address for an lport @lport: libfc lport */ static u8 * fcoe_get_src_mac(struct fc_lport *)
{ struct fcoe_port *port = lport_priv(lport); return port->data_src_addr; }
robutest/uclinux
C++
GPL-2.0
60
/* sr_packet() is the entry point for the generic commands generated by the Uniform CD-ROM layer. */
static int sr_packet(struct cdrom_device_info *, struct packet_command *)
/* sr_packet() is the entry point for the generic commands generated by the Uniform CD-ROM layer. */ static int sr_packet(struct cdrom_device_info *, struct packet_command *)
{ if (cgc->timeout <= 0) cgc->timeout = IOCTL_TIMEOUT; sr_do_ioctl(cdi->handle, cgc); return cgc->stat; }
robutest/uclinux
C++
GPL-2.0
60
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM1) { __HAL_RCC_TIM1_CLK_ENABLE(); } else if(htim_base->Instance==TIM4) { __HAL_RCC_TIM4_CLK_ENABLE(); } else if(htim_base->Instance==TIM5) { __HAL_RCC_TIM5_CLK_ENABLE(); } else if(htim_base->Instance==TIM8) { __HAL_RCC_TIM8_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* journal buffers for data blocks are not included here, as DIO and fallocate do no need to journal data buffers. */
int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks)
/* journal buffers for data blocks are not included here, as DIO and fallocate do no need to journal data buffers. */ int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks)
{ return ext4_meta_trans_blocks(inode, nrblocks, 1); }
robutest/uclinux
C++
GPL-2.0
60
/* Get slider value. Returns the slider value, inverted if such behavior is configured. */
uint8_t wtk_slider_get_value(struct wtk_slider const *slider)
/* Get slider value. Returns the slider value, inverted if such behavior is configured. */ uint8_t wtk_slider_get_value(struct wtk_slider const *slider)
{ Assert(slider); if (slider->option & WTK_SLIDER_INVERT) { return slider->maximum - slider->value; } else { return slider->value; } }
memfault/zero-to-main
C++
null
200
/* Account for involuntary wait time. @steal: the cpu time spent in involuntary wait */
void account_steal_time(cputime_t cputime)
/* Account for involuntary wait time. @steal: the cpu time spent in involuntary wait */ void account_steal_time(cputime_t cputime)
{ struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; cputime64_t cputime64 = cputime_to_cputime64(cputime); cpustat->steal = cputime64_add(cpustat->steal, cputime64); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Performs a software reset of a peripheral. The */
void SysCtlPeripheralReset(unsigned long ulPeripheral)
/* Performs a software reset of a peripheral. The */ void SysCtlPeripheralReset(unsigned long ulPeripheral)
{ volatile unsigned long ulDelay; xASSERT(SysCtlPeripheralValid(ulPeripheral)); xHWREG(g_pulIPRSTRegs[SYSCTL_PERIPH_INDEX_R(ulPeripheral)]) |= SYSCTL_PERIPH_MASK_R(ulPeripheral); for(ulDelay = 0; ulDelay < 16; ulDelay++) { } xHWREG(g_pulIPRSTRegs[SYSCTL_PERIPH_INDEX_R(ulPeripheral)])...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* mux the pin to the gpio controller (instead of "A" or "B" peripheral), and configure it for an output. */
int at91_set_pio_output(unsigned port, u32 pin, int value)
/* mux the pin to the gpio controller (instead of "A" or "B" peripheral), and configure it for an output. */ int at91_set_pio_output(unsigned port, u32 pin, int value)
{ struct at91_port *at91_port = at91_pio_get_port(port); if (at91_port && (pin < GPIO_PER_BANK)) at91_set_port_output(at91_port, pin, value); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Routine: video_hw_init Description: Set up the GraphicDevice depending on sys_boot. */
void* video_hw_init(void)
/* Routine: video_hw_init Description: Set up the GraphicDevice depending on sys_boot. */ void* video_hw_init(void)
{ gdev.frameAdrs = 0x8f9c0000; gdev.winSizeX = 800; gdev.winSizeY = 480; gdev.gdfBytesPP = 2; gdev.gdfIndex = GDF_16BIT_565RGB; memset((void *)gdev.frameAdrs, 0, 0xbb800); return (void *) &gdev; }
4ms/stm32mp1-baremetal
C++
Other
137
/* vfork is a system call in i386 because of register-pressure - maybe we can remove it and handle it in libc but we put it here until then. */
asmlinkage int sys_vfork(long r10, long r11, long r12, long r13, long mof, long srp, struct pt_regs *regs)
/* vfork is a system call in i386 because of register-pressure - maybe we can remove it and handle it in libc but we put it here until then. */ asmlinkage int sys_vfork(long r10, long r11, long r12, long r13, long mof, long srp, struct pt_regs *regs)
{ return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, NULL, NULL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The task that controls access to the LCD. */
static void vPrintTask(void *pvParameter)
/* The task that controls access to the LCD. */ static void vPrintTask(void *pvParameter)
{ char *pcMessage; unsigned portBASE_TYPE uxLine = 0, uxRow = 0; for( ;; ) { xQueueReceive( xPrintQueue, &pcMessage, portMAX_DELAY ); uxRow++; uxLine++; OSRAMClear(); OSRAMStringDraw( pcMessage, uxLine & 0x3f, uxRow & 0x01); } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Get the IIS2MDC MAG data ready bit value. */
int32_t IIS2MDC_MAG_Get_DRDY_Status(IIS2MDC_Object_t *pObj, uint8_t *Status)
/* Get the IIS2MDC MAG data ready bit value. */ int32_t IIS2MDC_MAG_Get_DRDY_Status(IIS2MDC_Object_t *pObj, uint8_t *Status)
{ if (iis2mdc_mag_data_ready_get(&(pObj->Ctx), Status) != IIS2MDC_OK) { return IIS2MDC_ERROR; } return IIS2MDC_OK; }
eclipse-threadx/getting-started
C++
Other
310
/* Checks if a uDMA channel is enabled for operation. */
tBoolean uDMAChannelIsEnabled(unsigned long ulChannelNum)
/* Checks if a uDMA channel is enabled for operation. */ tBoolean uDMAChannelIsEnabled(unsigned long ulChannelNum)
{ ASSERT((ulChannelNum & 0xffff) < 32); return((HWREG(UDMA_ENASET) & (1 << (ulChannelNum & 0x1f))) ? true : false); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns 0 if success, error code on error */
static int cdns3_req_ep0_set_sel(struct cdns3_device *priv_dev, struct usb_ctrlrequest *ctrl_req)
/* Returns 0 if success, error code on error */ static int cdns3_req_ep0_set_sel(struct cdns3_device *priv_dev, struct usb_ctrlrequest *ctrl_req)
{ if (priv_dev->gadget.state < USB_STATE_ADDRESS) return -EINVAL; if (ctrl_req->wLength != 6) { dev_err(priv_dev->dev, "Set SEL should be 6 bytes, got %d\n", ctrl_req->wLength); return -EINVAL; } cdns3_ep0_run_transfer(priv_dev, priv_dev->setup_dma, 6, 1, 0); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* dca3_get_tag - return the dca tag to the requester device for the given cpu (new api) @dev - the device that wants dca service @cpu - the cpuid as returned by get_cpu() */
u8 dca3_get_tag(struct device *dev, int cpu)
/* dca3_get_tag - return the dca tag to the requester device for the given cpu (new api) @dev - the device that wants dca service @cpu - the cpuid as returned by get_cpu() */ u8 dca3_get_tag(struct device *dev, int cpu)
{ if (!dev) return -EFAULT; return dca_common_get_tag(dev, cpu); }
robutest/uclinux
C++
GPL-2.0
60
/* This function handles USB-On-The-Go HS global interrupt request. */
void OTG_HS_IRQHandler(void)
/* This function handles USB-On-The-Go HS global interrupt request. */ void OTG_HS_IRQHandler(void)
{ HAL_PCD_IRQHandler(&hpcd_HS); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Read response on I2C from PC. return Status */
enum status_code adp_interface_read_response(uint8_t *rx_buf, uint16_t length)
/* Read response on I2C from PC. return Status */ enum status_code adp_interface_read_response(uint8_t *rx_buf, uint16_t length)
{ enum status_code status = STATUS_ERR_IO; uint8_t data_len = 0; struct i2c_master_packet packet = { .address = TWI_EDBG_SLAVE_ADDR, .data_length = 1, .data = &data_len, }; i2c_master_read_packet_wait(&i2c_master_instance, &packet); if (data_len != 0) { packet.data_length = data_len; packet.data = rx_b...
memfault/zero-to-main
C++
null
200
/* A pointer to the urb with the incremented reference counter is returned. */
struct urb* usb_get_urb(struct urb *urb)
/* A pointer to the urb with the incremented reference counter is returned. */ struct urb* usb_get_urb(struct urb *urb)
{ if (urb) kref_get(&urb->kref); return urb; }
robutest/uclinux
C++
GPL-2.0
60
/* Packs utf8 string to the buffer at the offset requested. */
static int pack_utf8_str(const struct mqtt_utf8 *str, struct buf_ctx *buf)
/* Packs utf8 string to the buffer at the offset requested. */ static int pack_utf8_str(const struct mqtt_utf8 *str, struct buf_ctx *buf)
{ if ((buf->end - buf->cur) < GET_UT8STR_BUFFER_SIZE(str)) { return -ENOMEM; } NET_DBG(">> str_size:%08x cur:%p, end:%p", (uint32_t)GET_UT8STR_BUFFER_SIZE(str), (void *)buf->cur, (void *)buf->end); (void)pack_uint16(str->size, buf); memcpy(buf->cur, str->utf8, str->size); buf->cur += str->size; return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Return the enabled, voltage comparator interrupt status bits. This function returns the enabled interrupt status bits */
uint32_t am_hal_vcomp_int_enable_get(void)
/* Return the enabled, voltage comparator interrupt status bits. This function returns the enabled interrupt status bits */ uint32_t am_hal_vcomp_int_enable_get(void)
{ return AM_REG(VCOMP, INTEN); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Internal helper to update LastAddress if the Limit address of the Mem aperture is higher than the provided value. */
STATIC VOID UpdateLastAddressIfHigher(IN PCI_ROOT_BRIDGE_APERTURE *Mem, OUT UINT64 *LastAddress)
/* Internal helper to update LastAddress if the Limit address of the Mem aperture is higher than the provided value. */ STATIC VOID UpdateLastAddressIfHigher(IN PCI_ROOT_BRIDGE_APERTURE *Mem, OUT UINT64 *LastAddress)
{ if (Mem->Limit > *LastAddress) { *LastAddress = Mem->Limit; } }
tianocore/edk2
C++
Other
4,240
/* Enable or disable the specified interval response of TMR4 event. */
void TMR4_EVT_EventIntervalResponseCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16MaskType, en_functional_state_t enNewState)
/* Enable or disable the specified interval response of TMR4 event. */ void TMR4_EVT_EventIntervalResponseCmd(CM_TMR4_TypeDef *TMR4x, uint32_t u32Ch, uint16_t u16MaskType, en_functional_state_t enNewState)
{ __IO uint16_t *SCMR; DDL_ASSERT(IS_TMR4_UNIT(TMR4x)); DDL_ASSERT(IS_TMR4_EVT_CH(u32Ch)); DDL_ASSERT(IS_TMR4_EVT_MASK_TYPE(u16MaskType)); DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); SCMR = TMR4_SCMR(TMR4x, u32Ch); if (ENABLE == enNewState) { SET_REG16_BIT(*SCMR, u16MaskType); }...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */
void uart_unregister_callback(struct uart_module *module, enum uart_callback callback_type)
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */ void uart_unregister_callback(struct uart_module *module, enum uart_callback callback_type)
{ Assert(module); module->callback[callback_type] = NULL; module->callback_reg_mask &= ~(1 << callback_type); }
memfault/zero-to-main
C++
null
200
/* Sets the LCD orientation to horizontal and vertical. */
void lcdSetOrientation(lcdOrientation_t orientation)
/* Sets the LCD orientation to horizontal and vertical. */ void lcdSetOrientation(lcdOrientation_t orientation)
{ if(orientation == LCD_ORIENTATION_LANDSCAPE) { lcd_cmd(0x16, 0x00A8); hx8347dProperties.width = 320; hx8347dProperties.height = 240; } else { lcd_cmd(0x16, 0x00C8); hx8347dProperties.width = 240; hx8347dProperties.height = 320; } hx8347dPOrientation = orientation; lcd_area(0,...
microbuilder/LPC1343CodeBase
C++
Other
73
/* Reads and returns the current value of DR2. 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 AsmReadDr2(VOID)
/* Reads and returns the current value of DR2. 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 AsmReadDr2(VOID)
{ UINTN Data; __asm__ __volatile__ ( "movl %%dr2, %0" : "=r" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Output: void, will modify proto_tree if not null. */
static void dissect_hello_authentication_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
/* Output: void, will modify proto_tree if not null. */ static void dissect_hello_authentication_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
{ isis_dissect_authentication_clv(tree, pinfo, tvb, hf_isis_hello_authentication, &ei_isis_hello_authentication, offset, length); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The application-specific handler is called with a mask of pending GPIO interrupts. After processing pin interrupts, the application-specific handler may wish to use gpio_intr_pending to check for any additional pending interrupts before it returns. */
void gpio_intr_handler_register(void *fn, void *arg)
/* The application-specific handler is called with a mask of pending GPIO interrupts. After processing pin interrupts, the application-specific handler may wish to use gpio_intr_pending to check for any additional pending interrupts before it returns. */ void gpio_intr_handler_register(void *fn, void *arg)
{ _xt_isr_attach(ETS_GPIO_INUM, fn, arg); }
eerimoq/simba
C++
Other
337
/* Sets the device address to the given value. */
void USBD_SetAddress(unsigned char address)
/* Sets the device address to the given value. */ void USBD_SetAddress(unsigned char address)
{ TRACE_INFO_WP("SetAddr(%d) ", address); UDP->UDP_FADDR = UDP_FADDR_FEN | (address & UDP_FADDR_FADD_Msk); if (address == 0) { UDP->UDP_GLB_STAT = 0; deviceState = USBD_STATE_DEFAULT; } else { UDP->UDP_GLB_STAT = UDP_GLB_STAT_FADDEN; deviceState = USBD_STATE_ADDRESS; ...
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Interrupt request to the INT_SOURCE (25h) register mode (pulsed / latched) . */
int32_t lps22hb_int_notification_mode_set(stmdev_ctx_t *ctx, lps22hb_lir_t val)
/* Interrupt request to the INT_SOURCE (25h) register mode (pulsed / latched) . */ int32_t lps22hb_int_notification_mode_set(stmdev_ctx_t *ctx, lps22hb_lir_t val)
{ lps22hb_interrupt_cfg_t interrupt_cfg; int32_t ret; ret = lps22hb_read_reg(ctx, LPS22HB_INTERRUPT_CFG, (uint8_t*)&interrupt_cfg, 1); if(ret == 0){ interrupt_cfg.lir = (uint8_t)val; ret = lps22hb_write_reg(ctx, LPS22HB_INTERRUPT_CFG, (uint8_t*)&inter...
eclipse-threadx/getting-started
C++
Other
310
/* unsubscribe callback - disallow output to rawmidi device */
static int snd_virmidi_unsubscribe(void *private_data, struct snd_seq_port_subscribe *info)
/* unsubscribe callback - disallow output to rawmidi device */ static int snd_virmidi_unsubscribe(void *private_data, struct snd_seq_port_subscribe *info)
{ struct snd_virmidi_dev *rdev; rdev = private_data; rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE; module_put(rdev->card->module); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Output a single byte to the serial port. */
void pxa_putc_dev(unsigned int uart_index, const char c)
/* Output a single byte to the serial port. */ void pxa_putc_dev(unsigned int uart_index, const char c)
{ switch (uart_index) { case FFUART_INDEX: while ((FFLSR & LSR_TEMT) == 0) WATCHDOG_RESET (); FFTHR = c; break; case BTUART_INDEX: while ((BTLSR & LSR_TEMT ) == 0 ) WATCHDOG_RESET (); BTTHR = c; break; case STUART_INDEX: while ((STLSR & LSR_TEMT ) == 0 ) WATCHDOG_RESET (); STT...
EmcraftSystems/u-boot
C++
Other
181
/* The decompressor output side looks only at the saved quant tables, not at the current Q-table slots. */
latch_quant_tables(j_decompress_ptr cinfo)
/* The decompressor output side looks only at the saved quant tables, not at the current Q-table slots. */ latch_quant_tables(j_decompress_ptr cinfo)
{ int ci, qtblno; jpeg_component_info* compptr; JQUANT_TBL* qtbl; for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; if (compptr->quant_table != NULL) continue; qtblno = compptr->quant_tbl_no; if (qtblno < 0 || qtblno >= NUM_QU...
nanoframework/nf-interpreter
C++
MIT License
293
/* Enables or disables the USART's transmitter or receiver. */
void USART_DirectionModeCmd(USART_TypeDef *USARTx, uint32_t USART_DirectionMode, FunctionalState NewState)
/* Enables or disables the USART's transmitter or receiver. */ void USART_DirectionModeCmd(USART_TypeDef *USARTx, uint32_t USART_DirectionMode, FunctionalState NewState)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_USART_MODE(USART_DirectionMode)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { USARTx->CR1 |= USART_DirectionMode; } else { USARTx->CR1 &= (uint32_t)~USART_DirectionMode; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* configure the address of the USART in wake up by address match mode */
void usart_address_config(uint32_t usart_periph, uint8_t addr)
/* configure the address of the USART in wake up by address match mode */ void usart_address_config(uint32_t usart_periph, uint8_t addr)
{ USART_CTL1(usart_periph) &= ~(USART_CTL1_ADDR); USART_CTL1(usart_periph) |= (USART_CTL1_ADDR & addr); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will get the first network interface device in network interface device list by IP address. */
struct netdev* netdev_get_by_ipaddr(ip_addr_t *ip_addr)
/* This function will get the first network interface device in network interface device list by IP address. */ struct netdev* netdev_get_by_ipaddr(ip_addr_t *ip_addr)
{ rt_base_t level; rt_slist_t *node = RT_NULL; struct netdev *netdev = RT_NULL; if (netdev_list == RT_NULL) { return RT_NULL; } level = rt_hw_interrupt_disable(); for (node = &(netdev_list->list); node; node = rt_slist_next(node)) { netdev = rt_slist_entry(node, struc...
pikasTech/PikaPython
C++
MIT License
1,403
/* Read a value from a register in an OV7740 sensor device. */
uint32_t ov_read_reg(Twihs *const p_twi, twihs_packet_t *const p_packet)
/* Read a value from a register in an OV7740 sensor device. */ uint32_t ov_read_reg(Twihs *const p_twi, twihs_packet_t *const p_packet)
{ uint32_t ul_status; ul_status = twihs_master_read(p_twi, p_packet); return ul_status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function reads a "hashed" node defined by @zbr from the leaf node cache (in it is there) or from the hash media, in which case the node is also added to LNC. Returns zero in case of success or a negative negative error code in case of failure. */
static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr, void *node)
/* This function reads a "hashed" node defined by @zbr from the leaf node cache (in it is there) or from the hash media, in which case the node is also added to LNC. Returns zero in case of success or a negative negative error code in case of failure. */ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_z...
{ int err; ubifs_assert(is_hash_key(c, &zbr->key)); if (zbr->leaf) { ubifs_assert(zbr->len != 0); memcpy(node, zbr->leaf, zbr->len); return 0; } err = ubifs_tnc_read_node(c, zbr, node); if (err) return err; err = lnc_add(c, zbr, node); return err; }
EmcraftSystems/u-boot
C++
Other
181
/* Locking: Driver dependant. The default do_resize method takes the tty termios mutex and ctrl_lock. The console takes its own lock then calls into the default method. */
static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg)
/* Locking: Driver dependant. The default do_resize method takes the tty termios mutex and ctrl_lock. The console takes its own lock then calls into the default method. */ static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg)
{ struct winsize tmp_ws; if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) return -EFAULT; if (tty->ops->resize) return tty->ops->resize(tty, &tmp_ws); else return tty_do_resize(tty, &tmp_ws); }
robutest/uclinux
C++
GPL-2.0
60
/* Return the current maximum bitneed and clear it. */
OI_UINT8 OI_CODEC_SBC_GetMaxBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common)
/* Return the current maximum bitneed and clear it. */ OI_UINT8 OI_CODEC_SBC_GetMaxBitneed(OI_CODEC_SBC_COMMON_CONTEXT *common)
{ OI_UINT8 max = common->maxBitneed; common->maxBitneed = 0; return max; }
Nicholas3388/LuaNode
C++
Other
1,055
/* This function is called from the run method of all personalities that do not support bitmaps. It prints an error message and returns non-zero if mddev has a bitmap. Otherwise, it returns 0. */
int md_check_no_bitmap(mddev_t *mddev)
/* This function is called from the run method of all personalities that do not support bitmaps. It prints an error message and returns non-zero if mddev has a bitmap. Otherwise, it returns 0. */ int md_check_no_bitmap(mddev_t *mddev)
{ if (!mddev->bitmap_info.file && !mddev->bitmap_info.offset) return 0; printk(KERN_ERR "%s: bitmaps are not supported for %s\n", mdname(mddev), mddev->pers->name); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Check if Transmit is Ready. Check if data has been loaded in UART_THR and is waiting to be loaded in the Transmit Shift Register (TSR). */
uint32_t uart_is_tx_ready(Uart *p_uart)
/* Check if Transmit is Ready. Check if data has been loaded in UART_THR and is waiting to be loaded in the Transmit Shift Register (TSR). */ uint32_t uart_is_tx_ready(Uart *p_uart)
{ return (p_uart->UART_SR & UART_SR_TXRDY) > 0; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables or disables the SAI Block x DMA interface. */
void SAI_DMACmd(SAI_Block_TypeDef *SAI_Block_x, FunctionalState NewState)
/* Enables or disables the SAI Block x DMA interface. */ void SAI_DMACmd(SAI_Block_TypeDef *SAI_Block_x, FunctionalState NewState)
{ assert_param(IS_SAI_BLOCK_PERIPH(SAI_Block_x)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SAI_Block_x->CR1 |= SAI_xCR1_DMAEN; } else { SAI_Block_x->CR1 &= ~(SAI_xCR1_DMAEN); } }
MaJerle/stm32f429
C++
null
2,036
/* Fill page/offset/length into spd, if it can hold more pages. */
static int spd_fill_page(struct splice_pipe_desc *spd, struct page *page, unsigned int *len, unsigned int offset, struct sk_buff *skb, int linear, struct sock *sk)
/* Fill page/offset/length into spd, if it can hold more pages. */ static int spd_fill_page(struct splice_pipe_desc *spd, struct page *page, unsigned int *len, unsigned int offset, struct sk_buff *skb, int linear, struct sock *sk)
{ if (unlikely(spd->nr_pages == PIPE_BUFFERS)) return 1; if (linear) { page = linear_to_page(page, len, &offset, skb, sk); if (!page) return 1; } else get_page(page); spd->pages[spd->nr_pages] = page; spd->partial[spd->nr_pages].len = *len; spd->partial[spd->nr_pages].offset = offset; spd->nr_pages++;...
EmcraftSystems/linux-emcraft
C++
Other
266
/* The STATUS_SPIAux register is read by the auxiliary SPI.. */
int32_t lsm6dso_aux_status_reg_get(stmdev_ctx_t *ctx, lsm6dso_status_spiaux_t *val)
/* The STATUS_SPIAux register is read by the auxiliary SPI.. */ int32_t lsm6dso_aux_status_reg_get(stmdev_ctx_t *ctx, lsm6dso_status_spiaux_t *val)
{ int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_STATUS_SPIAUX, (uint8_t *) val, 1); return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Indicate the Comparator is busy or not . */
u32 CMP_Busy(void)
/* Indicate the Comparator is busy or not . */ u32 CMP_Busy(void)
{ CMP_TypeDef *comparator = COMPARATOR; if(comparator->COMP_BUSY_STS & BIT_COMP_BUSY_STS) return 1; else return 0; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Wait until system clock switched to given oscillator. */
void rcc_wait_for_sysclk_status(enum rcc_osc osc)
/* Wait until system clock switched to given oscillator. */ void rcc_wait_for_sysclk_status(enum rcc_osc osc)
{ uint32_t sws = 0; switch (osc) { case RCC_PLL: sws = RCC_CFGR_SWS_PLLRCLK; break; case RCC_HSE: sws = RCC_CFGR_SWS_HSE; break; case RCC_HSI: sws = RCC_CFGR_SWS_HSISYS; break; case RCC_LSI: sws = RCC_CFGR_SWS_LSI; break; case RCC_LSE: sws = RCC_CFGR_SWS_LSE; break; default: ...
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Select the chip. This function selects the specified chip by driving its CS line low. */
static void _mx25l_chip_select(void)
/* Select the chip. This function selects the specified chip by driving its CS line low. */ static void _mx25l_chip_select(void)
{ port_pin_set_output_level(MX25L_SPI_PIN_CS, false); }
memfault/zero-to-main
C++
null
200
/* Returns the interface ID which was allocated; or -ENODEV if no more interface IDs can be allocated. */
int __init usb_interface_id(struct usb_configuration *config, struct usb_function *function)
/* Returns the interface ID which was allocated; or -ENODEV if no more interface IDs can be allocated. */ int __init usb_interface_id(struct usb_configuration *config, struct usb_function *function)
{ unsigned id = config->next_interface_id; if (id < MAX_CONFIG_INTERFACES) { config->interface[id] = function; config->next_interface_id = id + 1; return id; } return -ENODEV; }
robutest/uclinux
C++
GPL-2.0
60
/* returns 0, with id set if drive is detected -1, if drive detection failed */
static int pcd_probe(struct pcd_unit *cd, int ms, char *id)
/* returns 0, with id set if drive is detected -1, if drive detection failed */ static int pcd_probe(struct pcd_unit *cd, int ms, char *id)
{ if (ms == -1) { for (cd->drive = 0; cd->drive <= 1; cd->drive++) if (!pcd_reset(cd) && !pcd_identify(cd, id)) return 0; } else { cd->drive = ms; if (!pcd_reset(cd) && !pcd_identify(cd, id)) return 0; } return -1; }
robutest/uclinux
C++
GPL-2.0
60
/* Read ADC at least twice and check the resuls. If regulator providing voltage on to measured point was just turned on, first reads might require time to stabilize. */
static int odroid_get_adc_val(unsigned int *adcval)
/* Read ADC at least twice and check the resuls. If regulator providing voltage on to measured point was just turned on, first reads might require time to stabilize. */ static int odroid_get_adc_val(unsigned int *adcval)
{ unsigned int adcval_prev = 0; int ret, retries = 20; ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, &adcval_prev); if (ret) return ret; while (retries--) { mdelay(5); ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, adcval); if (ret) return ret; if ((100 ...
4ms/stm32mp1-baremetal
C++
Other
137
/* Read then Measure and log an EFI variable, and extend the measurement result into a specific RTMR. */
EFI_STATUS ReadAndMeasureVariable(IN UINT32 MrIndex, IN TCG_EVENTTYPE EventType, IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, OUT UINTN *VarSize, OUT VOID **VarData)
/* Read then Measure and log an EFI variable, and extend the measurement result into a specific RTMR. */ EFI_STATUS ReadAndMeasureVariable(IN UINT32 MrIndex, IN TCG_EVENTTYPE EventType, IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, OUT UINTN *VarSize, OUT VOID **VarData)
{ EFI_STATUS Status; Status = GetVariable2 (VarName, VendorGuid, VarData, VarSize); if (EventType == EV_EFI_VARIABLE_DRIVER_CONFIG) { if (EFI_ERROR (Status)) { *VarData = NULL; *VarSize = 0; } } else { if (EFI_ERROR (Status)) { return EFI_NOT_FOUND; } } Status = MeasureVar...
tianocore/edk2
C++
Other
4,240
/* Unregisters an interrupt handler for the uDMA controller. */
void uDMAIntUnregister(uint32_t ui32IntChannel)
/* Unregisters an interrupt handler for the uDMA controller. */ void uDMAIntUnregister(uint32_t ui32IntChannel)
{ IntDisable(ui32IntChannel); IntUnregister(ui32IntChannel); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function is used to do initial Host Configuration. */
void XSdPs_HostConfig(XSdPs *InstancePtr)
/* This function is used to do initial Host Configuration. */ void XSdPs_HostConfig(XSdPs *InstancePtr)
{ XSdPs_ConfigPower(InstancePtr); XSdPs_ConfigDma(InstancePtr); XSdPs_ConfigInterrupt(InstancePtr); InstancePtr->TransferMode = XSDPS_TM_DMA_EN_MASK | XSDPS_TM_BLK_CNT_EN_MASK | XSDPS_TM_DAT_DIR_SEL_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, XSDPS_BLK_SIZE_OFFSET...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return version of the performance management protocol supported by SCP. firmware. */
STATIC EFI_STATUS PerformanceGetVersion(IN SCMI_PERFORMANCE_PROTOCOL *This, OUT UINT32 *Version)
/* Return version of the performance management protocol supported by SCP. firmware. */ STATIC EFI_STATUS PerformanceGetVersion(IN SCMI_PERFORMANCE_PROTOCOL *This, OUT UINT32 *Version)
{ return ScmiGetProtocolVersion (ScmiProtocolIdPerformance, Version); }
tianocore/edk2
C++
Other
4,240
/* Update an ARM MOVW/MOVT immediate instruction instruction pair. */
VOID ThumbMovwMovtImmediatePatch(IN OUT UINT16 *Instructions, IN UINT32 Address)
/* Update an ARM MOVW/MOVT immediate instruction instruction pair. */ VOID ThumbMovwMovtImmediatePatch(IN OUT UINT16 *Instructions, IN UINT32 Address)
{ UINT16 *Word; UINT16 *Top; Word = Instructions; Top = Word + 2; ThumbMovtImmediatePatch (Word, (UINT16)(Address & 0xffff)); ThumbMovtImmediatePatch (Top, (UINT16)(Address >> 16)); }
tianocore/edk2
C++
Other
4,240
/* Handle a timeout on transmit from the 3c527. This normally means bad things as the hardware handles cable timeouts and mess for us. */
static void mc32_timeout(struct net_device *dev)
/* Handle a timeout on transmit from the 3c527. This normally means bad things as the hardware handles cable timeouts and mess for us. */ static void mc32_timeout(struct net_device *dev)
{ pr_warning("%s: transmit timed out?\n", dev->name); netif_wake_queue(dev); }
robutest/uclinux
C++
GPL-2.0
60
/* Locking: see tty_set_ldisc, this function is just a helper */
static int tiocsetd(struct tty_struct *tty, int __user *p)
/* Locking: see tty_set_ldisc, this function is just a helper */ static int tiocsetd(struct tty_struct *tty, int __user *p)
{ int ldisc; int ret; if (get_user(ldisc, p)) return -EFAULT; ret = tty_set_ldisc(tty, ldisc); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* add_ino - add an entry to the size tree. */
static int add_ino(struct ubifs_info *c, ino_t inum, loff_t i_size, loff_t d_size, int exists)
/* add_ino - add an entry to the size tree. */ static int add_ino(struct ubifs_info *c, ino_t inum, loff_t i_size, loff_t d_size, int exists)
{ struct rb_node **p = &c->size_tree.rb_node, *parent = NULL; struct size_entry *e; while (*p) { parent = *p; e = rb_entry(parent, struct size_entry, rb); if (inum < e->inum) p = &(*p)->rb_left; else p = &(*p)->rb_right; } e = kzalloc(sizeof(struct size_entry), GFP_KERNEL); if (!e) return -ENOMEM;...
EmcraftSystems/u-boot
C++
Other
181
/* The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed, o...
EFI_STATUS EFIAPI RedfishConfigDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
/* The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed, o...
{ EFI_STATUS Status; if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) { RedfishConfigStopRedfishDiscovery (); } gBS->CloseProtocol ( ControllerHandle, &gEfiRedfishDiscoverProtocolGuid, gRedfishConfigData.Image, gRedfishConfigData.Image ); Status = ...
tianocore/edk2
C++
Other
4,240
/* Change Logs: Date Author Notes 勤为本 first version */
volatile unsigned int* gpio_get_cfg_reg(unsigned int gpio)
/* Change Logs: Date Author Notes 勤为本 first version */ volatile unsigned int* gpio_get_cfg_reg(unsigned int gpio)
{ volatile unsigned int *gpio_cfgx = NULL; unsigned int port = GPIO_GET_PORT(gpio); switch (port) { case 0: gpio_cfgx = (volatile unsigned int *)LS1B_GPIO_CFG0; break; case 1: gpio_cfgx = (volatile unsigned int *)LS1B_GPIO_CFG1; break; ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks whether the specified RCC flag is set or not. */
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
/* Checks whether the specified RCC flag is set or not. */ FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
{ uint32_t tmp = 0; uint32_t statusreg = 0; FlagStatus bitstatus = RESET; assert_param(IS_RCC_FLAG(RCC_FLAG)); tmp = RCC_FLAG >> 5; if (tmp == 1) { statusreg = RCC->CTRL; } else if (tmp == 2) { statusreg = RCC->BDCTRL; } else { status...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Note that during this, an embedded SW thread may call nsi_exit(), which would result in this function never returning. */
void nce_boot_cpu(void *this_arg, void(*start_routine)(void))
/* Note that during this, an embedded SW thread may call nsi_exit(), which would result in this function never returning. */ void nce_boot_cpu(void *this_arg, void(*start_routine)(void))
{ struct nce_status_t *this = (struct nce_status_t *)this_arg; NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_cpu)); this->cpu_halted = false; this->start_routine = start_routine; pthread_t sw_thread; NSI_SAFE_CALL(pthread_create(&sw_thread, NULL, sw_wrapper, this_arg)); while (this->cpu_halted == false) { pthrea...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Enables or disables the TIMx peripheral Preload register on CCDAT6. */
void TIM_ConfigOc6Preload(TIM_Module *TIMx, uint16_t TIM_OCPreload)
/* Enables or disables the TIMx peripheral Preload register on CCDAT6. */ void TIM_ConfigOc6Preload(TIM_Module *TIMx, uint16_t TIM_OCPreload)
{ uint16_t tmpccmr3 = 0; assert_param(IsTimList1Module(TIMx)); assert_param(IsTimOcPreLoadState(TIM_OCPreload)); tmpccmr3 = TIMx->CCMOD3; tmpccmr3 &= (uint16_t) ~((uint16_t)TIM_CCMOD3_OC6PEN); tmpccmr3 |= (uint16_t)(TIM_OCPreload << 8); TIMx->CCMOD3 = tmpccmr3; }
pikasTech/PikaPython
C++
MIT License
1,403
/* DAC Channel Disable. Disable a digital to analog converter channel. */
void dac_disable(data_channel dac_channel)
/* DAC Channel Disable. Disable a digital to analog converter channel. */ void dac_disable(data_channel dac_channel)
{ switch (dac_channel) { case CHANNEL_1: DAC_CR &= ~DAC_CR_EN1; break; case CHANNEL_2: DAC_CR &= ~DAC_CR_EN2; break; case CHANNEL_D: DAC_CR &= ~(DAC_CR_EN1 | DAC_CR_EN2); break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Performs a case-insensitive comparison of two Null-terminated strings. */
INTN EFIAPI EngStriColl(IN EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *Str1, IN CHAR16 *Str2)
/* Performs a case-insensitive comparison of two Null-terminated strings. */ INTN EFIAPI EngStriColl(IN EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *Str1, IN CHAR16 *Str2)
{ while (*Str1 != 0) { if (TO_UPPER (*Str1) != TO_UPPER (*Str2)) { break; } Str1 += 1; Str2 += 1; } return TO_UPPER (*Str1) - TO_UPPER (*Str2); }
tianocore/edk2
C++
Other
4,240
/* This function will stop a usb class driver. */
rt_err_t rt_usb_class_driver_stop(ucd_t drv, void *args)
/* This function will stop a usb class driver. */ rt_err_t rt_usb_class_driver_stop(ucd_t drv, void *args)
{ RT_ASSERT(drv != RT_NULL); if(drv->stop != RT_NULL) drv->stop(args); return RT_EOK; }
armink/FreeModbus_Slave-Master-RTT-STM32
C++
Other
1,477
/* This function is used to control power down entry condition */
void SysCtlPowerDownWaitCPUSet(xtBoolean bEnable)
/* This function is used to control power down entry condition */ void SysCtlPowerDownWaitCPUSet(xtBoolean bEnable)
{ SysCtlKeyAddrUnlock(); if(bEnable) { xHWREG(SYSCLK_PWRCON) |= SYSCLK_PWRCON_PD_WAIT_CPU; } else { xHWREG(SYSCLK_PWRCON) &= ~SYSCLK_PWRCON_PD_WAIT_CPU; } SysCtlKeyAddrLock(); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* write an existing inode back to the directory, and therefore the disk. The adfs-specific inode data has already been updated by adfs_notify_change() */
int adfs_write_inode(struct inode *inode, int wait)
/* write an existing inode back to the directory, and therefore the disk. The adfs-specific inode data has already been updated by adfs_notify_change() */ int adfs_write_inode(struct inode *inode, int wait)
{ struct super_block *sb = inode->i_sb; struct object_info obj; int ret; lock_kernel(); obj.file_id = inode->i_ino; obj.name_len = 0; obj.parent_id = ADFS_I(inode)->parent_id; obj.loadaddr = ADFS_I(inode)->loadaddr; obj.execaddr = ADFS_I(inode)->execaddr; obj.attr = ADFS_I(inode)->attr; obj.size = inode->i_s...
robutest/uclinux
C++
GPL-2.0
60
/* This function checks one DMA channel for reset completion */
int XAxiVdma_ResetNotDone(XAxiVdma *InstancePtr, u16 Direction)
/* This function checks one DMA channel for reset completion */ int XAxiVdma_ResetNotDone(XAxiVdma *InstancePtr, u16 Direction)
{ XAxiVdma_Channel *Channel; Channel = XAxiVdma_GetChannel(InstancePtr, Direction); if (!Channel) { return 1; } return XAxiVdma_ChannelResetNotDone(Channel); }
ua1arn/hftrx
C++
null
69
/* Calls the @complete_type_info function from the #GTypePluginClass of @plugin. There should be no need to use this function outside of the GObject type system itself. */
void g_type_plugin_complete_type_info(GTypePlugin *plugin, GType g_type, GTypeInfo *info, GTypeValueTable *value_table)
/* Calls the @complete_type_info function from the #GTypePluginClass of @plugin. There should be no need to use this function outside of the GObject type system itself. */ void g_type_plugin_complete_type_info(GTypePlugin *plugin, GType g_type, GTypeInfo *info, GTypeValueTable *value_table)
{ GTypePluginClass *iface; g_return_if_fail (G_IS_TYPE_PLUGIN (plugin)); g_return_if_fail (info != NULL); g_return_if_fail (value_table != NULL); iface = G_TYPE_PLUGIN_GET_CLASS (plugin); iface->complete_type_info (plugin, g_type, info, value_table); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* A pending message being re-assembled must store certain values to handle subsequent fragments correctly. The following functions help storing these values in unused, available fields in the pending message. This makes dynamic memory allocation unecessary. */
static void set_long_msg_seqno(struct sk_buff *buf, u32 seqno)
/* A pending message being re-assembled must store certain values to handle subsequent fragments correctly. The following functions help storing these values in unused, available fields in the pending message. This makes dynamic memory allocation unecessary. */ static void set_long_msg_seqno(struct sk_buff *buf, u32 s...
{ msg_set_seqno(buf_msg(buf), seqno); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get a Message or Wait for a Message from a Queue. */
os_InRegs osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
/* Get a Message or Wait for a Message from a Queue. */ os_InRegs osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
{ return isrMessageGet(queue_id, millisec); } else { return __svcMessageGet(queue_id, millisec); } }
ajhc/demo-cortex-m3
C++
null
38
/* The length of the hash result is dependent on the algorithm that is selected with the */
void SHAMD5HMACProcess(uint32_t ui32Base, uint32_t *pui32DataSrc, uint32_t ui32DataLength, uint32_t *pui32HashResult)
/* The length of the hash result is dependent on the algorithm that is selected with the */ void SHAMD5HMACProcess(uint32_t ui32Base, uint32_t *pui32DataSrc, uint32_t ui32DataLength, uint32_t *pui32HashResult)
{ ASSERT(ui32Base == SHAMD5_BASE); while ((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_CONTEXT_READY) == 0) { } SHAMD5HashLengthSet(ui32Base, ui32DataLength); _SHAMD5DataWriteMultiple(ui32Base, pui32DataSrc, ui32DataLength); while ((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SH...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This can be called from a LLD or iscsi_transport. */
struct iscsi_cls_session* iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport, int dd_size, unsigned int target_id)
/* This can be called from a LLD or iscsi_transport. */ struct iscsi_cls_session* iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport, int dd_size, unsigned int target_id)
{ struct iscsi_cls_session *session; session = iscsi_alloc_session(shost, transport, dd_size); if (!session) return NULL; if (iscsi_add_session(session, target_id)) { iscsi_free_session(session); return NULL; } return session; }
robutest/uclinux
C++
GPL-2.0
60
/* This API read fifo overrun from location 0Eh bit position 7. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_overrun(u8 *fifo_overrun_u8)
/* This API read fifo overrun from location 0Eh bit position 7. */ BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_overrun(u8 *fifo_overrun_u8)
{ BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR; u8 data_u8 = BMA2x2_INIT_VALUE; if (p_bma2x2 == BMA2x2_NULL) { return E_BMA2x2_NULL_PTR; } else { com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC( p_bma2x2->dev_addr, BMA2x2_FIFO_OVERRUN_S...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* pre: tracing must be suspended on the current cpu */
static void trace_bts_cpu(void *arg)
/* pre: tracing must be suspended on the current cpu */ static void trace_bts_cpu(void *arg)
{ struct trace_array *tr = (struct trace_array *)arg; const struct bts_trace *trace; unsigned char *at; if (unlikely(!tr)) return; if (unlikely(atomic_read(&tr->data[raw_smp_processor_id()]->disabled))) return; if (unlikely(!this_tracer)) return; trace = ds_read_bts(this_tracer); if (!trace) return; fo...
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function does an erase of all user flash area. */
uint32_t FLASH_If_Erase(uint32_t StartSector)
/* This function does an erase of all user flash area. */ uint32_t FLASH_If_Erase(uint32_t StartSector)
{ uint32_t UserStartSector; uint32_t SectorError; FLASH_EraseInitTypeDef pEraseInit; FLASH_If_Init(); UserStartSector = GetSector(APPLICATION_ADDRESS); pEraseInit.TypeErase = TYPEERASE_SECTORS; pEraseInit.Sector = UserStartSector; pEraseInit.NbSectors = 6; pEraseInit.VoltageRange = VOLTAGE_RANGE_3; ...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Registers an interrupt handler for the system exception interrupt. */
void SysExcIntRegister(void(*pfnHandler)(void))
/* Registers an interrupt handler for the system exception interrupt. */ void SysExcIntRegister(void(*pfnHandler)(void))
{ uint32_t ui32Int; ui32Int = _SysExcIntNumberGet(); ASSERT(ui32Int != 0); IntRegister(ui32Int, pfnHandler); IntEnable(ui32Int); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Convert an integer (30-bit words, little-endian) to unsigned little-endian encoding. The total encoding length is provided; all the destination bytes will be filled. */
static void le30_to_le8(unsigned char *dst, size_t len, const uint32_t *src)
/* Convert an integer (30-bit words, little-endian) to unsigned little-endian encoding. The total encoding length is provided; all the destination bytes will be filled. */ static void le30_to_le8(unsigned char *dst, size_t len, const uint32_t *src)
{ uint32_t acc; int acc_len; acc = 0; acc_len = 0; while (len -- > 0) { if (acc_len < 8) { uint32_t w; w = *src ++; *dst ++ = (unsigned char)(acc | (w << acc_len)); acc = w >> (8 - acc_len); acc_len += 22; } else { *dst ++ = (unsigned char)acc; acc >>= 8; acc_len -= 8; } } }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Finishes a function call: calls hook if necessary, removes CallInfo, moves current number of results to proper place; returns 0 iff call wanted multiple (variable number of) results. */
int luaD_poscall(lua_State *L, CallInfo *ci, StkId firstResult, int nres)
/* Finishes a function call: calls hook if necessary, removes CallInfo, moves current number of results to proper place; returns 0 iff call wanted multiple (variable number of) results. */ int luaD_poscall(lua_State *L, CallInfo *ci, StkId firstResult, int nres)
{ if (L->hookmask & LUA_MASKRET) { ptrdiff_t fr = savestack(L, firstResult); luaD_hook(L, LUA_HOOKRET, -1); firstResult = restorestack(L, fr); } L->oldpc = ci->previous->u.l.savedpc; } res = ci->func; L->ci = ci->previous; return moveresults(L, firstResult, res, nres, wanted); }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* This routine removes and returns the srb at the specified index */
struct srb* qla4xxx_del_from_active_array(struct scsi_qla_host *ha, uint32_t index)
/* This routine removes and returns the srb at the specified index */ struct srb* qla4xxx_del_from_active_array(struct scsi_qla_host *ha, uint32_t index)
{ struct srb *srb = NULL; struct scsi_cmnd *cmd; if (!(cmd = scsi_host_find_tag(ha->host, index))) return srb; if (!(srb = (struct srb *)cmd->host_scribble)) return srb; if (srb->flags & SRB_DMA_VALID) { ha->req_q_count += srb->iocb_cnt; ha->iocb_cnt -= srb->iocb_cnt; if (srb->cmd) srb->cmd->host_scri...
robutest/uclinux
C++
GPL-2.0
60
/* API to get type of service of the caller CPU. */
IfxSrc_Tos IfxCpu_Irq_getTos(IfxCpu_ResourceCpu coreId)
/* API to get type of service of the caller CPU. */ IfxSrc_Tos IfxCpu_Irq_getTos(IfxCpu_ResourceCpu coreId)
{ const IfxSrc_Tos tos[IFXCPU_NUM_MODULES] = { IfxSrc_Tos_cpu0, IfxSrc_Tos_cpu1, IfxSrc_Tos_cpu2, }; return tos[coreId]; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function checks the supported languages list for a target language, This only supports RFC 4646 Languages. */
EFI_STATUS EFIAPI IsLanguageSupported(IN CONST CHAR8 *SupportedLanguages, IN CONST CHAR8 *TargetLanguage)
/* This function checks the supported languages list for a target language, This only supports RFC 4646 Languages. */ EFI_STATUS EFIAPI IsLanguageSupported(IN CONST CHAR8 *SupportedLanguages, IN CONST CHAR8 *TargetLanguage)
{ UINTN Index; while (*SupportedLanguages != 0) { for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++) { } if ((AsciiStrnCmp (SupportedLanguages, TargetLanguage, Index) == 0) && (TargetLanguage[Index] == 0)) { return EFI_SUCCESS; } SupportedLanguage...
tianocore/edk2
C++
Other
4,240
/* Get the current frame that hardware is working on */
u32 XAxiVdma_CurrFrameStore(XAxiVdma *InstancePtr, u16 Direction)
/* Get the current frame that hardware is working on */ u32 XAxiVdma_CurrFrameStore(XAxiVdma *InstancePtr, u16 Direction)
{ u32 Rc; Rc = XAxiVdma_ReadReg(InstancePtr->BaseAddr, XAXIVDMA_PARKPTR_OFFSET); if (Direction == XAXIVDMA_READ) { Rc &= XAXIVDMA_PARKPTR_READSTR_MASK; return (Rc >> XAXIVDMA_READSTR_SHIFT); } else if (Direction == XAXIVDMA_WRITE) { Rc &= XAXIVDMA_PARKPTR_WRTSTR_MASK; return (Rc >> XAXIVDMA_WRTSTR_SHIFT); ...
ua1arn/hftrx
C++
null
69
/* retval kStatus_Success retval kStatus_I2S_Busy if all queue slots are occupied with unsent buffers. */
status_t I2S_TxTransferSendDMA(I2S_Type *base, i2s_dma_handle_t *handle, i2s_transfer_t transfer)
/* retval kStatus_Success retval kStatus_I2S_Busy if all queue slots are occupied with unsent buffers. */ status_t I2S_TxTransferSendDMA(I2S_Type *base, i2s_dma_handle_t *handle, i2s_transfer_t transfer)
{ status_t status; I2S_DisableDMAInterrupts(handle); status = I2S_EnqueueUserBuffer(base, handle, transfer); if (status != kStatus_Success) { I2S_EnableDMAInterrupts(handle); return status; } if (handle->state == (uint32_t)kI2S_DmaStateIdle) { handle->state = (uin...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform. */
VOID EFIAPI ArmVirtGetMemoryMap(OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap)
/* This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform. */ VOID EFIAPI ArmVirtGetMemoryMap(OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap)
{ EFI_PHYSICAL_ADDRESS TopOfAddressSpace; ASSERT (VirtualMemoryMap != NULL); TopOfAddressSpace = LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()); mVirtualMemoryTable[0].PhysicalBase = 0x0; mVirtualMemoryTable[0].VirtualBase = 0x0; mVirtualMemoryTable[0].Length = TopOfAddressSpace; mVirtualMemoryTab...
tianocore/edk2
C++
Other
4,240
/* Handle events for states that use the ccw request infrastructure. */
static void ccw_device_request_event(struct ccw_device *cdev, enum dev_event e)
/* Handle events for states that use the ccw request infrastructure. */ static void ccw_device_request_event(struct ccw_device *cdev, enum dev_event e)
{ switch (e) { case DEV_EVENT_NOTOPER: ccw_request_notoper(cdev); break; case DEV_EVENT_INTERRUPT: ccw_request_handler(cdev); break; case DEV_EVENT_TIMEOUT: ccw_request_timeout(cdev); break; default: break; } }
robutest/uclinux
C++
GPL-2.0
60
/* Return the path to the error node for the given device, or NULL on failure. If the value returned is non-NULL, then it is the caller's to kfree. */
static char* error_path(struct xenbus_device *dev)
/* Return the path to the error node for the given device, or NULL on failure. If the value returned is non-NULL, then it is the caller's to kfree. */ static char* error_path(struct xenbus_device *dev)
{ return kasprintf(GFP_KERNEL, "error/%s", dev->nodename); }
robutest/uclinux
C++
GPL-2.0
60
/* The algorithm is intended to only send "whole bytes", no bit-messing. */
void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen)
/* The algorithm is intended to only send "whole bytes", no bit-messing. */ void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen)
{ int positions[256]; int outpos; int pos; int i; outpos = pos = 0; for (i = 0; i < 256; positions[i++] = 0); while (outpos<destlen) { unsigned char value; int backoffs; int repeat; value = data_in[pos++]; cpage_out[outpos++] = value; repeat = data_in[pos++]; backoffs = positions[value]; position...
EmcraftSystems/u-boot
C++
Other
181
/* If any errors are generated while the protocol interfaces are being uninstalled, then the protocol interfaces uninstalled prior to the error will be reinstalled and EFI_INVALID_PARAMETER will be returned. */
EFI_STATUS EFIAPI CoreUninstallMultipleProtocolInterfaces(IN EFI_HANDLE Handle,...)
/* If any errors are generated while the protocol interfaces are being uninstalled, then the protocol interfaces uninstalled prior to the error will be reinstalled and EFI_INVALID_PARAMETER will be returned. */ EFI_STATUS EFIAPI CoreUninstallMultipleProtocolInterfaces(IN EFI_HANDLE Handle,...)
{ EFI_STATUS Status; VA_LIST Args; EFI_GUID *Protocol; VOID *Interface; UINTN Index; VA_START (Args, Handle); for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) { Protocol = VA_ARG (Args, EFI_GUID *); if (Protocol == NULL) { break; } Interface = ...
tianocore/edk2
C++
Other
4,240
/* Function called from I2C IRQ Handler when RXNE flag is set Function is in charge of retrieving received byte on I2C lines. */
void Slave_Reception_Callback(void)
/* Function called from I2C IRQ Handler when RXNE flag is set Function is in charge of retrieving received byte on I2C lines. */ void Slave_Reception_Callback(void)
{ aSlaveReceiveBuffer[ubSlaveReceiveIndex++] = LL_I2C_ReceiveData8(I2C1); if(Buffercmp8((uint8_t*)aSlaveReceiveBuffer, (uint8_t*)(aCommandCode[0][0]), (ubSlaveReceiveIndex-1)) == 0) { ubSlaveInfoIndex = SLAVE_CHIP_NAME; ubSlaveNbDataToTransmit = strlen(aSlaveInfo[ubSlaveInfoIndex]); pSlaveTransmitBuff...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Routine: reuse_atags Description: Reuse atags from previous bootloader. Reuse only only HW build, boot reason, boot mode and nolo */
static void reuse_atags(void)
/* Routine: reuse_atags Description: Reuse atags from previous bootloader. Reuse only only HW build, boot reason, boot mode and nolo */ static void reuse_atags(void)
{ struct tag *t = (struct tag *)gd->bd->bi_boot_params; if (t->hdr.tag != ATAG_CORE) return; if (!boot_reason_ptr || !hw_build_ptr) return; while (t->hdr.tag != ATAG_NONE) { switch (t->hdr.tag) { case ATAG_REVISION: memset(hw_build_ptr, 0, 12); sprintf(hw_build_ptr, "%x", t->u.revision.rev); break;...
4ms/stm32mp1-baremetal
C++
Other
137
/* Allocate a DMA with configurations. This function will allocate a proper channel for a DMA transfer request. */
enum status_code dma_allocate(struct dma_resource *resource, struct dma_resource_config *config)
/* Allocate a DMA with configurations. This function will allocate a proper channel for a DMA transfer request. */ enum status_code dma_allocate(struct dma_resource *resource, struct dma_resource_config *config)
{ uint8_t new_channel; if (!_dma_inst._dma_init) { system_peripheral_reset(PERIPHERAL_DMA); LPMCU_MISC_REGS0->IRQ_MUX_IO_SEL_3.bit.MUX_15 = LPMCU_MISC_REGS_IRQ_MUX_IO_SEL_3_MUX_15_16_Val; system_register_isr(31, (uint32_t)dma_isr_handler); _dma_inst._dma_init = true; } new_channel = _dma_find_first_free_cha...
memfault/zero-to-main
C++
null
200
/* This API sets the data in the sensor which in turn will be written to Mag. */
uint16_t bma4_set_mag_write_data(uint8_t mag_write_data, struct bma4_dev *dev)
/* This API sets the data in the sensor which in turn will be written to Mag. */ uint16_t bma4_set_mag_write_data(uint8_t mag_write_data, struct bma4_dev *dev)
{ uint16_t rslt = 0; if (dev == NULL) rslt |= BMA4_E_NULL_PTR; else rslt |= bma4_write_regs(BMA4_AUX_WR_DATA_ADDR, &mag_write_data, 1, dev); return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* This function is executed in case of error occurrence. */
static void Error_Handler(void)
/* This function is executed in case of error occurrence. */ static void Error_Handler(void)
{ BSP_LED_On(LED2); while(1) { } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Enables or disables the RTC reference clock detection. */
ErrorStatus RTC_EnableRefClock(FunctionalState Cmd)
/* Enables or disables the RTC reference clock detection. */ ErrorStatus RTC_EnableRefClock(FunctionalState Cmd)
{ ErrorStatus status = ERROR; assert_param(IS_FUNCTIONAL_STATE(Cmd)); RTC->WRP = 0xCA; RTC->WRP = 0x53; if (RTC_EnterInitMode() == ERROR) { status = ERROR; } else { if (Cmd != DISABLE) { RTC->CTRL |= RTC_CTRL_REFCLKEN; } else { ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* a <range> with size "len" starting at the return value is inside in the area defined by , but is otherwise randomized. */
unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len)
/* a <range> with size "len" starting at the return value is inside in the area defined by , but is otherwise randomized. */ unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len)
{ unsigned long range = end - len - start; if (end <= start + len) return 0; return PAGE_ALIGN(get_random_int() % range + start); }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the DMA Rx Desc end of ring. */
void ETH_EnableDmaRxDescEndOfRing(ETH_DMADescType *DMARxDesc, FunctionalState Cmd)
/* Enables or disables the DMA Rx Desc end of ring. */ void ETH_EnableDmaRxDescEndOfRing(ETH_DMADescType *DMARxDesc, FunctionalState Cmd)
{ assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { DMARxDesc->CtrlOrBufSize |= ETH_DMA_RX_DESC_RER; } else { DMARxDesc->CtrlOrBufSize &= (~(uint32_t)ETH_DMA_RX_DESC_RER); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This file is part of the Simba project. */
int mock_write_owi_init(struct pin_device_t *dev_p, struct owi_device_t *devices_p, size_t nmemb, int res)
/* This file is part of the Simba project. */ int mock_write_owi_init(struct pin_device_t *dev_p, struct owi_device_t *devices_p, size_t nmemb, int res)
{ harness_mock_write("owi_init(dev_p)", &dev_p, sizeof(dev_p)); harness_mock_write("owi_init(devices_p)", devices_p, sizeof(*devices_p)); harness_mock_write("owi_init(nmemb)", &nmemb, ...
eerimoq/simba
C++
Other
337
/* Writes a CAN message in the transmit buffer of the specified message channel. */
static HRESULT IxxatVciLibFuncCanChannelPostMessage(HANDLE hCanChn, PCANMSG pCanMsg)
/* Writes a CAN message in the transmit buffer of the specified message channel. */ static HRESULT IxxatVciLibFuncCanChannelPostMessage(HANDLE hCanChn, PCANMSG pCanMsg)
{ HRESULT result = VCI_E_UNEXPECTED; assert(ixxatVciLibFuncCanChannelPostMessagePtr != NULL); assert(ixxatVciDllHandle != NULL); if ((ixxatVciLibFuncCanChannelPostMessagePtr != NULL) && (ixxatVciDllHandle != NULL)) { result = ixxatVciLibFuncCanChannelPostMessagePtr(hCanChn, pCanMsg); } return result; ...
feaser/openblt
C++
GNU General Public License v3.0
601