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
/* url syntax: udp://host:port option: 'ttl=n' : set the ttl value (for multicast only) 'localport=n' : set the local port 'pkt_size=n' : set max packet size 'reuse=1' : enable reusing the socket */
int udp_set_remote_url(URLContext *h, const char *uri)
/* url syntax: udp://host:port option: 'ttl=n' : set the ttl value (for multicast only) 'localport=n' : set the local port 'pkt_size=n' : set max packet size 'reuse=1' : enable reusing the socket */ int udp_set_remote_url(URLContext *h, const char *uri)
{ UDPContext *s = h->priv_data; char hostname[256]; int port; ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); s->dest_addr_len = udp_set_url(&s->dest_addr, hostname, port); if (s->dest_addr_len < 0) { return AVERROR(EIO); } s->is_multicast = is_mu...
DC-SWAT/DreamShell
C++
null
404
/* Get the number of messaged stored in a queue. */
uint32_t osMessageWaiting(osMessageQId queue_id)
/* Get the number of messaged stored in a queue. */ uint32_t osMessageWaiting(osMessageQId queue_id)
{ if (inHandlerMode()) { return uxQueueMessagesWaitingFromISR(queue_id); } else { return uxQueueMessagesWaiting(queue_id); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Unlocks the data memory and FLASH_PECR register access. */
void DATA_EEPROM_Unlock(void)
/* Unlocks the data memory and FLASH_PECR register access. */ void DATA_EEPROM_Unlock(void)
{ if((FLASH->PECR & FLASH_PECR_PELOCK) != RESET) { FLASH->PEKEYR = FLASH_PEKEY1; FLASH->PEKEYR = FLASH_PEKEY2; } }
avem-labs/Avem
C++
MIT License
1,752
/* param base Pointer to FLEXIO_I2C_Type structure. param handle Pointer to flexio_i2c_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_NoTransferInProgress There is ...
status_t FLEXIO_I2C_MasterTransferGetCount(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle, size_t *count)
/* param base Pointer to FLEXIO_I2C_Type structure. param handle Pointer to flexio_i2c_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_NoTransferInProgress There is ...
{ if (NULL == count) { return kStatus_InvalidArgument; } if (handle->state == (uint8_t)kFLEXIO_I2C_Idle) { *count = 0; return kStatus_NoTransferInProgress; } *count = handle->transferSize - handle->transfer.dataSize; return kStatus_Success; }
eclipse-threadx/getting-started
C++
Other
310
/* Enable OSCx module to control oscillator or external reference clock */
static void osc_enable(int osc)
/* Enable OSCx module to control oscillator or external reference clock */ static void osc_enable(int osc)
{ volatile struct kinetis_osc_regs *regs = (volatile struct kinetis_osc_regs *)kinetis_osc_base[osc]; if (osc == 1) kinetis_periph_enable(KINETIS_CG_OSC1, 1); regs->cr = KINETIS_OSC_CR_EREFSTEN_MSK | KINETIS_OSC_CR_ERCLKEN_MSK; }
EmcraftSystems/u-boot
C++
Other
181
/* Note: This is not the best behavior for an actual product because uninteresting peers could cause important bonds to be deleted. This is useful for demonstrations and sample apps. */
int ble_store_util_status_rr(struct ble_store_status_event *event, void *arg)
/* Note: This is not the best behavior for an actual product because uninteresting peers could cause important bonds to be deleted. This is useful for demonstrations and sample apps. */ int ble_store_util_status_rr(struct ble_store_status_event *event, void *arg)
{ switch (event->event_code) { case BLE_STORE_EVENT_OVERFLOW: switch (event->overflow.obj_type) { case BLE_STORE_OBJ_TYPE_OUR_SEC: case BLE_STORE_OBJ_TYPE_PEER_SEC: case BLE_STORE_OBJ_TYPE_CCCD: return ble_gap_unpair_oldest_peer(); default:...
Nicholas3388/LuaNode
C++
Other
1,055
/* Finalize the running hash to make digest. This function empties the internal buffer, adds padding bits, and generates final digest. */
static status_t dcp_hash_finalize(DCP_Type *base, dcp_hash_ctx_internal_t *ctxInternal)
/* Finalize the running hash to make digest. This function empties the internal buffer, adds padding bits, and generates final digest. */ static status_t dcp_hash_finalize(DCP_Type *base, dcp_hash_ctx_internal_t *ctxInternal)
{ status_t status; ctxInternal->ctrl0 |= kDCP_CONTROL0_HASH_TERM; status = dcp_hash_update(base, ctxInternal, &ctxInternal->blk.b[0], ctxInternal->blksz); return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: pointer to HBQ on success NULL on failure */
struct hbq_dmabuf* lpfc_els_hbq_alloc(struct lpfc_hba *phba)
/* Returns: pointer to HBQ on success NULL on failure */ struct hbq_dmabuf* lpfc_els_hbq_alloc(struct lpfc_hba *phba)
{ struct hbq_dmabuf *hbqbp; hbqbp = kmalloc(sizeof(struct hbq_dmabuf), GFP_KERNEL); if (!hbqbp) return NULL; hbqbp->dbuf.virt = pci_pool_alloc(phba->lpfc_hbq_pool, GFP_KERNEL, &hbqbp->dbuf.phys); if (!hbqbp->dbuf.virt) { kfree(hbqbp); return NULL; } hbqbp->size = LPFC_BPL_SIZE; return hbqbp; }
robutest/uclinux
C++
GPL-2.0
60
/* stb0899_calc_derot_time Compute the amount of time needed by the derotator to lock SymbolRate: Symbol rate return: derotator time constant (ms) */
static long stb0899_calc_derot_time(long srate)
/* stb0899_calc_derot_time Compute the amount of time needed by the derotator to lock SymbolRate: Symbol rate return: derotator time constant (ms) */ static long stb0899_calc_derot_time(long srate)
{ if (srate > 0) return (100000 / (srate / 1000)); else return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Set EMB release PWM condition for the specified event. */
void EMB_SetReleasePwmCond(CM_EMB_TypeDef *EMBx, uint32_t u32Event, uint32_t u32Cond)
/* Set EMB release PWM condition for the specified event. */ void EMB_SetReleasePwmCond(CM_EMB_TypeDef *EMBx, uint32_t u32Event, uint32_t u32Cond)
{ DDL_ASSERT(IS_EMB_GROUP(EMBx)); DDL_ASSERT(IS_EMB_MONITOR_EVT(u32Event)); DDL_ASSERT(IS_EMB_RELEASE_PWM_COND(u32Cond)); if (EMB_RELEASE_PWM_COND_FLAG_ZERO == u32Cond) { CLR_REG32_BIT(EMBx->RLSSEL, u32Event); } else { SET_REG32_BIT(EMBx->RLSSEL, u32Event); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciSegmentRead32(IN UINT64 Address)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciSegmentRead32(IN UINT64 Address)
{ ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3); return PeiPciSegmentLibPciCfg2ReadWorker (Address, EfiPeiPciCfgWidthUint32); }
tianocore/edk2
C++
Other
4,240
/* The kqueue thread will not stop monitoring on it immediately, it should be bumped via its command file descriptor manually. See kqueue_thread() and _kqueue_thread_collect_fds() for details. */
void _kqueue_thread_remove_fd(int fd)
/* The kqueue thread will not stop monitoring on it immediately, it should be bumped via its command file descriptor manually. See kqueue_thread() and _kqueue_thread_collect_fds() for details. */ void _kqueue_thread_remove_fd(int fd)
{ G_LOCK (remove_lock); remove_fds_list = g_slist_prepend (remove_fds_list, GINT_TO_POINTER (fd)); G_UNLOCK (remove_lock); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If the address is a multicast address has binary 0xFF at the start, it is not a valid unicast address. If the address is unspecified ::, it is not a valid unicast address to be assigned to any node. If the address is loopback address ::1, it is also not a valid unicast address to be assigned to any physical interfac...
BOOLEAN EFIAPI NetIp6IsValidUnicast(IN EFI_IPv6_ADDRESS *Ip6)
/* If the address is a multicast address has binary 0xFF at the start, it is not a valid unicast address. If the address is unspecified ::, it is not a valid unicast address to be assigned to any node. If the address is loopback address ::1, it is also not a valid unicast address to be assigned to any physical interfac...
{ UINT8 Byte; UINT8 Index; ASSERT (Ip6 != NULL); if (Ip6->Addr[0] == 0xFF) { return FALSE; } for (Index = 0; Index < 15; Index++) { if (Ip6->Addr[Index] != 0) { return TRUE; } } Byte = Ip6->Addr[Index]; if ((Byte == 0x0) || (Byte == 0x1)) { return FALSE; } return TRUE; }
tianocore/edk2
C++
Other
4,240
/* Disables a Generic Clock that was previously enabled. Stops the clock generation of a Generic Clock that was previously started via a call to */
void system_gclk_chan_disable(const uint8_t channel)
/* Disables a Generic Clock that was previously enabled. Stops the clock generation of a Generic Clock that was previously started via a call to */ void system_gclk_chan_disable(const uint8_t channel)
{ system_interrupt_enter_critical_section(); *((uint8_t*)&GCLK->CLKCTRL.reg) = channel; Assert(!GCLK->CLKCTRL.bit.WRTLOCK); uint32_t prev_gen_id = GCLK->CLKCTRL.bit.GEN; GCLK->CLKCTRL.bit.GEN = 0; GCLK->CLKCTRL.reg &= ~GCLK_CLKCTRL_CLKEN; while (GCLK->CLKCTRL.reg & GCLK_CLKCTRL_CLKEN) { } GCLK->CLKCTRL.bit.GEN...
memfault/zero-to-main
C++
null
200
/* set_irq_type - set the irq trigger type for an irq @irq: irq number @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h */
int set_irq_type(unsigned int irq, unsigned int type)
/* set_irq_type - set the irq trigger type for an irq @irq: irq number @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h */ int set_irq_type(unsigned int irq, unsigned int type)
{ struct irq_desc *desc = irq_to_desc(irq); unsigned long flags; int ret = -ENXIO; if (!desc) { printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq); return -ENODEV; } type &= IRQ_TYPE_SENSE_MASK; if (type == IRQ_TYPE_NONE) return 0; raw_spin_lock_irqsave(&desc->lock, flags); ret = __irq_set_trigge...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return TRUE if there are any higher priority status level messages pushed. Return FALSE otherwise. */
static void static gboolean higher_priority_status_level(int level)
/* Return TRUE if there are any higher priority status level messages pushed. Return FALSE otherwise. */ static void static gboolean higher_priority_status_level(int level)
{ int i; for (i = level + 1; i < NUM_STATUS_LEVELS; i++) { if (status_levels[i]) return TRUE; } return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Created on: 15 feb. 2019 Author: Daniel Mårtensson Add C = A+B with A size row_a x column_a and B have the size row_a x column_b and C have the size row_a x column_a */
void add(double *A, double *B, double *C, int row_a, int column_a, int column_b)
/* Created on: 15 feb. 2019 Author: Daniel Mårtensson Add C = A+B with A size row_a x column_a and B have the size row_a x column_b and C have the size row_a x column_a */ void add(double *A, double *B, double *C, int row_a, int column_a, int column_b)
{ for (int j = 0; j < columnMatrix; j++) { if (column_b == 1 && column_a > 1) *(C++) = *(A++) + *(B + i); else if (column_b > 1 && column_a == 1) *(C++) = *(A + i) + *(B++); else *(C++) = *(A++) + *(B++); } } }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* yaffs2_update_oldest_dirty_seq() Update the oldest dirty sequence number whenever we dirty a block. Only do this if the oldest_dirty_seq is actually being tracked. */
void yaffs2_update_oldest_dirty_seq(struct yaffs_dev *dev, unsigned block_no, struct yaffs_block_info *bi)
/* yaffs2_update_oldest_dirty_seq() Update the oldest dirty sequence number whenever we dirty a block. Only do this if the oldest_dirty_seq is actually being tracked. */ void yaffs2_update_oldest_dirty_seq(struct yaffs_dev *dev, unsigned block_no, struct yaffs_block_info *bi)
{ if (!dev->param.is_yaffs2) return; if (dev->oldest_dirty_seq) { if (dev->oldest_dirty_seq > bi->seq_number) { dev->oldest_dirty_seq = bi->seq_number; dev->oldest_dirty_block = block_no; } } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Check for damaged frame due to collision. Retruns true if rx frame was damaged due to late collision in half duplex mode. */
bool synopGMAC_is_rx_frame_collision(u32 status)
/* Check for damaged frame due to collision. Retruns true if rx frame was damaged due to late collision in half duplex mode. */ bool synopGMAC_is_rx_frame_collision(u32 status)
{ return ((status & DescRxCollision) == DescRxCollision); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Programs the FMC User Option Byte: WDT, STOP, STDBY, BOOT1 and VDDA ANALOG monitoring. */
FMC_STATE_T FMC_WriteOptionByteUser(uint8_t ob_user)
/* Programs the FMC User Option Byte: WDT, STOP, STDBY, BOOT1 and VDDA ANALOG monitoring. */ FMC_STATE_T FMC_WriteOptionByteUser(uint8_t ob_user)
{ FMC_STATE_T state; state = FMC_WaitForReady(FMC_DELAY_ERASE); if (state == FMC_STATE_COMPLETE) { FMC->CTRL2_B.OBP = BIT_SET; OB->USER = ob_user; state = FMC_WaitForReady(FMC_DELAY_ERASE); if (state != FMC_STATE_TIMEOUT) { FMC->CTRL2_B.OBP = BIT_RESET...
pikasTech/PikaPython
C++
MIT License
1,403
/* Sets the address of the UART Rx Address. */
void UART_SetRXAddress(UART_TypeDef *uart, u8 address)
/* Sets the address of the UART Rx Address. */ void UART_SetRXAddress(UART_TypeDef *uart, u8 address)
{ MODIFY_REG(uart->RXAR, UART_RXAR_ADDR, address); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Post the request to upper level. Don't use any pxa specific harware configuration capabilities */
static void pxa27x_change_configuration(struct pxa_udc *udc, int config)
/* Post the request to upper level. Don't use any pxa specific harware configuration capabilities */ static void pxa27x_change_configuration(struct pxa_udc *udc, int config)
{ struct usb_ctrlrequest req ; dev_dbg(udc->dev, "config=%d\n", config); udc->config = config; udc->last_interface = 0; udc->last_alternate = 0; req.bRequestType = 0; req.bRequest = USB_REQ_SET_CONFIGURATION; req.wValue = config; req.wIndex = 0; req.wLength = 0; set_ep0state(udc, WAIT_ACK_SET_CONF_INTERF); ...
robutest/uclinux
C++
GPL-2.0
60
/* megasas_disable_intr_ppc - Disable interrupt @regs: MFI register set */
static void megasas_disable_intr_ppc(struct megasas_register_set __iomem *regs)
/* megasas_disable_intr_ppc - Disable interrupt @regs: MFI register set */ static void megasas_disable_intr_ppc(struct megasas_register_set __iomem *regs)
{ u32 mask = 0xFFFFFFFF; writel(mask, &regs->outbound_intr_mask); readl(&regs->outbound_intr_mask); }
robutest/uclinux
C++
GPL-2.0
60
/* Caller doesn't need to free the returned JSON value because it will be released in corresponding */
REDFISH_SERVICE EFIAPI RedfishServiceInPayload(IN REDFISH_PAYLOAD Payload)
/* Caller doesn't need to free the returned JSON value because it will be released in corresponding */ REDFISH_SERVICE EFIAPI RedfishServiceInPayload(IN REDFISH_PAYLOAD Payload)
{ if (Payload == NULL) { return NULL; } return ((redfishPayload *)Payload)->service; }
tianocore/edk2
C++
Other
4,240
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and ...
UINT32 EFIAPI PciExpressBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and ...
{ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) { return (UINT32)-1; } return MmioBitFieldWrite32 ( GetPciExpressAddress (Address), StartBit, EndBit, Value ); }
tianocore/edk2
C++
Other
4,240
/* This function will provide the caller with the specified block device's media information. If the media changes, calling this function will update the media information accordingly. */
EFI_STATUS EFIAPI AtapiGetBlockDeviceMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
/* This function will provide the caller with the specified block device's media information. If the media changes, calling this function will update the media information accordingly. */ EFI_STATUS EFIAPI AtapiGetBlockDeviceMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN...
{ ATAPI_BLK_IO_DEV *AtapiBlkIoDev; EFI_STATUS Status; EFI_PEI_BLOCK_IO_MEDIA Media; AtapiBlkIoDev = NULL; if ((This == NULL) || (MediaInfo == NULL)) { return EFI_INVALID_PARAMETER; } AtapiBlkIoDev = PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS (This); Status = AtapiGetBlockDeviceMediaInf...
tianocore/edk2
C++
Other
4,240
/* Fix up length if there is too little space left in the a.g. Return 1 if ok, 0 if too little, should give up. */
STATIC int xfs_alloc_fix_minleft(xfs_alloc_arg_t *args)
/* Fix up length if there is too little space left in the a.g. Return 1 if ok, 0 if too little, should give up. */ STATIC int xfs_alloc_fix_minleft(xfs_alloc_arg_t *args)
{ xfs_agf_t *agf; int diff; if (args->minleft == 0) return 1; agf = XFS_BUF_TO_AGF(args->agbp); diff = be32_to_cpu(agf->agf_freeblks) + be32_to_cpu(agf->agf_flcount) - args->len - args->minleft; if (diff >= 0) return 1; args->len += diff; if (args->len >= args->minlen) return 1; args->agbno = NULLAG...
robutest/uclinux
C++
GPL-2.0
60
/* Return value: number of bytes printed to buffer */
static ssize_t pmcraid_show_log_level(struct device *dev, struct device_attribute *attr, char *buf)
/* Return value: number of bytes printed to buffer */ static ssize_t pmcraid_show_log_level(struct device *dev, struct device_attribute *attr, char *buf)
{ struct Scsi_Host *shost = class_to_shost(dev); struct pmcraid_instance *pinstance = (struct pmcraid_instance *)shost->hostdata; return snprintf(buf, PAGE_SIZE, "%d\n", pinstance->current_log_level); }
robutest/uclinux
C++
GPL-2.0
60
/* We want to regularly clean the cache, so we need to schedule some work ... */
static void do_cache_clean(struct work_struct *work)
/* We want to regularly clean the cache, so we need to schedule some work ... */ static void do_cache_clean(struct work_struct *work)
{ int delay = 5; if (cache_clean() == -1) delay = round_jiffies_relative(30*HZ); if (list_empty(&cache_list)) delay = 0; if (delay) schedule_delayed_work(&cache_cleaner, delay); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function is used to get touch sensor's irq status. */
int tls_touchsensor_irq_status_get(u32 sensorno)
/* This function is used to get touch sensor's irq status. */ int tls_touchsensor_irq_status_get(u32 sensorno)
{ u32 value = 0; if (sensorno && (sensorno <= 15)) { value = tls_reg_read32(HR_TC_INT_EN); return (value&(1<<(sensorno-1)))?1:0; } return -1; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Reset the RTC. We setting the date back to . We also enable the oscillator output on the SQW/OUT pin and program it for 32,768 Hz output. Note that according to the datasheet, turning on the square wave output increases the current drain on the backup battery to something between 480nA and 800nA. */
void rtc_reset(void)
/* Reset the RTC. We setting the date back to . We also enable the oscillator output on the SQW/OUT pin and program it for 32,768 Hz output. Note that according to the datasheet, turning on the square wave output increases the current drain on the backup battery to something between 480nA and 800nA. */ void rtc_reset(...
{ rtc_write (RTC_SEC_REG_ADDR, 0x00); rtc_write (RTC_CTL_REG_ADDR, RTC_CTL_BIT_SQWE | RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS0); }
4ms/stm32mp1-baremetal
C++
Other
137
/* we need to detect all attempts to write to the EBC entry point argument stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. */
EFI_STATUS VmWriteMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINTN Data)
/* we need to detect all attempts to write to the EBC entry point argument stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. */ EFI_STATUS VmWriteMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINTN Data)
{ EFI_STATUS Status; UINTN Index; Status = EFI_SUCCESS; Addr = ConvertStackAddr (VmPtr, Addr); if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINTN))) { *(UINTN *)Addr = Data; } else { for (Index = 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) { MemoryFence (); Status = VmWriteMem3...
tianocore/edk2
C++
Other
4,240
/* This subroutine gets the fixed point Q30 compass data after the soft iron transformation. */
void inv_get_compass_soft_iron_output_data(long *data)
/* This subroutine gets the fixed point Q30 compass data after the soft iron transformation. */ void inv_get_compass_soft_iron_output_data(long *data)
{ data[i] = sensors.soft_iron.trans[i]; } }
Luos-io/luos_engine
C++
MIT License
496
/* Airpcap wrapper, used to set the frequency of an airpcap adapter */
gboolean airpcap_if_set_device_channel_ex(PAirpcapHandle ah, AirpcapChannelInfo ChannelInfo)
/* Airpcap wrapper, used to set the frequency of an airpcap adapter */ gboolean airpcap_if_set_device_channel_ex(PAirpcapHandle ah, AirpcapChannelInfo ChannelInfo)
{ if (!AirpcapLoaded) return FALSE; if (airpcap_get_dll_state() == AIRPCAP_DLL_OLD){ gint channel = 0; channel = ieee80211_mhz_to_chan(ChannelInfo.Frequency); if (channel < 0){ return FALSE; } else { return airpcap_if_set_device_channel(ah, channel); ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Obtain a mask of pins that match all of the provided The caller must ensure that */
static gpio_port_pins_t get_pins_with_flags(const struct device *port, gpio_port_pins_t mask, gpio_flags_t flags)
/* Obtain a mask of pins that match all of the provided The caller must ensure that */ static gpio_port_pins_t get_pins_with_flags(const struct device *port, gpio_port_pins_t mask, gpio_flags_t flags)
{ size_t i; gpio_port_pins_t matched = 0; struct gpio_emul_data *drv_data = (struct gpio_emul_data *)port->data; const struct gpio_emul_config *config = (const struct gpio_emul_config *)port->config; for (i = 0; i < config->num_pins; ++i) { if ((drv_data->flags[i] & mask) == flags) { matched |= BIT(i); ...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* skb_split - Split fragmented skb to two parts at length len. @skb: the buffer to split @skb1: the buffer to receive the second part @len: new length for skb */
void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
/* skb_split - Split fragmented skb to two parts at length len. @skb: the buffer to split @skb1: the buffer to receive the second part @len: new length for skb */ void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
{ int pos = skb_headlen(skb); if (len < pos) skb_split_inside_header(skb, skb1, len, pos); else skb_split_no_header(skb, skb1, len, pos); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* ad1843_get_gain reads the specified register and extracts the gain value using the supplied gain type. It returns the gain in OSS format. */
static int ad1843_get_gain(lithium_t *lith, const ad1843_gain_t *gp)
/* ad1843_get_gain reads the specified register and extracts the gain value using the supplied gain type. It returns the gain in OSS format. */ static int ad1843_get_gain(lithium_t *lith, const ad1843_gain_t *gp)
{ int lg, rg; unsigned short mask = (1 << gp->lfield->nbits) - 1; ad1843_read_multi(lith, 2, gp->lfield, &lg, gp->rfield, &rg); if (gp->negative) { lg = mask - lg; rg = mask - rg; } lg = (lg * 100 + (mask >> 1)) / mask; rg = (rg * 100 + (mask >> 1)) / mask; return lg << 0 | rg << 8; }
robutest/uclinux
C++
GPL-2.0
60
/* General outline: remap really low stuff to SuperIO, stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) is mapped through the PCI IO window. Stuff with high bits (PXSEG) should be way beyond the window, and is used w/o translation for compatibility. */
unsigned char sh7751se_inb(unsigned long port)
/* General outline: remap really low stuff to SuperIO, stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) is mapped through the PCI IO window. Stuff with high bits (PXSEG) should be way beyond the window, and is used w/o translation for compatibility. */ unsigned char sh7751se_inb(unsigned long port)
{ if (PXSEG(port)) return *(volatile unsigned char *)port; else return (*port2adr(port)) & 0xff; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Method to dissect the Init Command Ack sent by the Responder in the connection. This packet is defined by Section 2.3.2 */
void dissect_ptpIP_init_command_ack(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 *offset)
/* Method to dissect the Init Command Ack sent by the Responder in the connection. This packet is defined by Section 2.3.2 */ void dissect_ptpIP_init_command_ack(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 *offset)
{ guint32 connectionNumber; col_set_str( pinfo->cinfo, COL_INFO, "Init Command Ack"); connectionNumber = tvb_get_letohl(tvb, *offset); proto_tree_add_item(tree, hf_ptpIP_connectionNumber, tvb, *offset, 4,ENC_LITTLE_ENDIAN); col_append_fstr( pinfo->cinfo, COL_I...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function returns the rate at which the SysTick counter wraps, which equates to the number of processor clocks between interrupts. */
uint32_t SysTickPeriodGet(void)
/* This function returns the rate at which the SysTick counter wraps, which equates to the number of processor clocks between interrupts. */ uint32_t SysTickPeriodGet(void)
{ return(HWREG(NVIC_ST_RELOAD) + 1); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */
void LL_mDelay(uint32_t Delay)
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */ void LL_mDelay(uint32_t Delay)
{ __IO uint32_t tmp = SysTick->CTRL; ((void)tmp); if(Delay < LL_MAX_DELAY) { Delay++; } while (Delay) { if((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) { Delay--; } } }
ua1arn/hftrx
C++
null
69
/* hinfo_to_cinfo - Convert new format hba info into old format @hinfo : New format, more comprehensive adapter info @cinfo : Old format adapter info to support mimd_t apps */
static void hinfo_to_cinfo(mraid_hba_info_t *, mcontroller_t *)
/* hinfo_to_cinfo - Convert new format hba info into old format @hinfo : New format, more comprehensive adapter info @cinfo : Old format adapter info to support mimd_t apps */ static void hinfo_to_cinfo(mraid_hba_info_t *, mcontroller_t *)
{ if (!hinfo || !cinfo) return; cinfo->base = hinfo->baseport; cinfo->irq = hinfo->irq; cinfo->numldrv = hinfo->num_ldrv; cinfo->pcibus = hinfo->pci_bus; cinfo->pcidev = hinfo->pci_slot; cinfo->pcifun = PCI_FUNC(hinfo->pci_dev_fn); cinfo->pciid = hinfo->pci_device_id; cinfo->pcivendor = hinfo->pci_ven...
robutest/uclinux
C++
GPL-2.0
60
/* Software reset. Restore the default values in user registers. */
int32_t lsm6dsl_reset_set(stmdev_ctx_t *ctx, uint8_t val)
/* Software reset. Restore the default values in user registers. */ int32_t lsm6dsl_reset_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dsl_ctrl3_c_t ctrl3_c; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t*)&ctrl3_c, 1); if(ret == 0){ ctrl3_c.sw_reset = val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t*)&ctrl3_c, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Change Logs: Date Author Notes bigmagic first version */
int main(int argc, char **argv)
/* Change Logs: Date Author Notes bigmagic first version */ int main(int argc, char **argv)
{ rt_kprintf("Hi, this is RT-Thread!!\n"); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function can't be called from interrupt context. Use uvc_queue_cancel() instead. */
int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
/* This function can't be called from interrupt context. Use uvc_queue_cancel() instead. */ int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
{ unsigned int i; int ret = 0; mutex_lock(&queue->mutex); if (enable) { if (uvc_queue_streaming(queue)) { ret = -EBUSY; goto done; } queue->sequence = 0; queue->flags |= UVC_QUEUE_STREAMING; queue->buf_used = 0; } else { uvc_queue_cancel(queue, 0); INIT_LIST_HEAD(&queue->mainqueue); for (i = ...
robutest/uclinux
C++
GPL-2.0
60
/* If the user_struct could not be found, return NULL. */
struct user_struct* find_user(uid_t uid)
/* If the user_struct could not be found, return NULL. */ struct user_struct* find_user(uid_t uid)
{ struct user_struct *ret; unsigned long flags; struct user_namespace *ns = current_user_ns(); spin_lock_irqsave(&uidhash_lock, flags); ret = uid_hash_find(uid, uidhashentry(ns, uid)); spin_unlock_irqrestore(&uidhash_lock, flags); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* vpif_poll: It is used for select/poll system call */
static unsigned int vpif_poll(struct file *filep, poll_table *wait)
/* vpif_poll: It is used for select/poll system call */ static unsigned int vpif_poll(struct file *filep, poll_table *wait)
{ struct vpif_fh *fh = filep->private_data; struct channel_obj *ch = fh->channel; struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; if (common->started) return videobuf_poll_stream(filep, &common->buffer_queue, wait); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Read two words of data from SPI Rx registers. */
void SPIBurstDataRead(unsigned long ulBase, unsigned long *pulData)
/* Read two words of data from SPI Rx registers. */ void SPIBurstDataRead(unsigned long ulBase, unsigned long *pulData)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) ); while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY)) { } pulData[0] = xHWREG(ulBase + SPI_RX0); pulData[1] = xHWREG(ulBase + SPI_RX1); xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Copy from userspace and compute checksum. If we catch an exception then zero the rest of the buffer. */
__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
/* Copy from userspace and compute checksum. If we catch an exception then zero the rest of the buffer. */ __wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
{ int missing; missing = copy_from_user(dst, src, len); if (missing) { memset(dst + len - missing, 0, missing); *err_ptr = -EFAULT; } return csum_partial(dst, len, sum); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Starts the reception of the HID mouse report. */
static void uhi_hid_mouse_start_trans_report(usb_add_t add)
/* Starts the reception of the HID mouse report. */ static void uhi_hid_mouse_start_trans_report(usb_add_t add)
{ uhd_ep_run(add, uhi_hid_mouse_dev.ep_in, true, uhi_hid_mouse_dev.report, uhi_hid_mouse_dev.report_size, 0, uhi_hid_mouse_report_reception); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function designates that b is between a and c or not (for example, 0 is between 127 and 1). Returns 1 if b is between a and c, 0 otherwise. */
u8 llc_circular_between(u8 a, u8 b, u8 c)
/* This function designates that b is between a and c or not (for example, 0 is between 127 and 1). Returns 1 if b is between a and c, 0 otherwise. */ u8 llc_circular_between(u8 a, u8 b, u8 c)
{ b = b - a; c = c - a; return b <= c; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reset Peripheral, pulsed. Reset particular peripheral, and restore to working state. */
void rcc_periph_reset_pulse(enum rcc_periph_rst rst)
/* Reset Peripheral, pulsed. Reset particular peripheral, and restore to working state. */ void rcc_periph_reset_pulse(enum rcc_periph_rst rst)
{ _RCC_REG(rst) |= _RCC_BIT(rst); _RCC_REG(rst) &= ~_RCC_BIT(rst); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Writes the received value from a characteristic write to the given destination. */
static int ble_svc_lls_chr_write(struct os_mbuf *om, uint16_t min_len, uint16_t max_len, void *dst, uint16_t *len)
/* Writes the received value from a characteristic write to the given destination. */ static int ble_svc_lls_chr_write(struct os_mbuf *om, uint16_t min_len, uint16_t max_len, void *dst, uint16_t *len)
{ uint16_t om_len; int rc; om_len = OS_MBUF_PKTLEN(om); if (om_len < min_len || om_len > max_len) { return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } rc = ble_hs_mbuf_to_flat(om, dst, max_len, len); if (rc != 0) { return BLE_ATT_ERR_UNLIKELY; } return 0; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Message: PortReqMessage Opcode: 0x014b Type: MediaControl Direction: pbx2dev VarLength: no */
static void handle_PortReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: PortReqMessage Opcode: 0x014b Type: MediaControl Direction: pbx2dev VarLength: no */ static void handle_PortReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN); si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)); ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_passThruPartyID, 4, ENC_LITTLE_ENDIAN); ptvcurso...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* brief Aborts the slave non-blocking transfers. note This API could be called at any time to stop slave for handling the bus events. param base The LPI2C peripheral base address. param handle Pointer to #lpi2c_slave_handle_t structure which stores the transfer state. retval #kStatus_Success retval #kStatus_LPI2C_Idle...
void LPI2C_SlaveTransferAbort(LPI2C_Type *base, lpi2c_slave_handle_t *handle)
/* brief Aborts the slave non-blocking transfers. note This API could be called at any time to stop slave for handling the bus events. param base The LPI2C peripheral base address. param handle Pointer to #lpi2c_slave_handle_t structure which stores the transfer state. retval #kStatus_Success retval #kStatus_LPI2C_Idle...
{ assert(NULL != handle); if (handle->isBusy) { LPI2C_SlaveDisableInterrupts(base, (uint32_t)kSlaveIrqFlags); base->STAR = LPI2C_STAR_TXNACK_MASK; (void)memset(&handle->transfer, 0, sizeof(handle->transfer)); handle->isBusy = false; } }
eclipse-threadx/getting-started
C++
Other
310
/* Local function to send a command to the USB protocol engine */
static void USBHwCmd(unsigned char bCmd)
/* Local function to send a command to the USB protocol engine */ static void USBHwCmd(unsigned char bCmd)
{ LPC_USB->USBDevIntClr = CDFULL | CCEMTY; LPC_USB->USBCmdCode = 0x00000500 | (bCmd << 16); Wait4DevInt(CCEMTY); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function walks the list of exchange manager(EM) anchors to select an EM for a new exchange allocation. */
static struct fc_exch* fc_exch_alloc(struct fc_lport *lport, struct fc_frame *fp)
/* This function walks the list of exchange manager(EM) anchors to select an EM for a new exchange allocation. */ static struct fc_exch* fc_exch_alloc(struct fc_lport *lport, struct fc_frame *fp)
{ struct fc_exch_mgr_anchor *ema; struct fc_exch *ep; list_for_each_entry(ema, &lport->ema_list, ema_list) { if (!ema->match || ema->match(fp)) { ep = fc_exch_em_alloc(lport, ema->mp); if (ep) return ep; } } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Get a sensor mode. These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent. */
bool sensor_get_state(sensor_t *sensor, sensor_state_t *mode)
/* Get a sensor mode. These execution states are not supported in all devices. The function return value will indicate whether or not the request could be processed. The result of the request, when supported, is device dependent. */ bool sensor_get_state(sensor_t *sensor, sensor_state_t *mode)
{ *mode = sensor->mod; return true; }
memfault/zero-to-main
C++
null
200
/* Function for finding an available record for write buffer allocation. */
static pdb_buffer_record_t* write_buffer_record_find_unused(void)
/* Function for finding an available record for write buffer allocation. */ static pdb_buffer_record_t* write_buffer_record_find_unused(void)
{ return write_buffer_record_find(PM_PEER_ID_INVALID, PM_PEER_DATA_ID_INVALID); }
labapart/polymcu
C++
null
201
/* s3c2412_calc_bank - calculate the bank divisor settings. @cfg: The current frequency configuration. @bt: The bank timing. */
static int s3c2412_calc_bank(struct s3c_cpufreq_config *cfg, struct s3c2412_iobank_timing *bt)
/* s3c2412_calc_bank - calculate the bank divisor settings. @cfg: The current frequency configuration. @bt: The bank timing. */ static int s3c2412_calc_bank(struct s3c_cpufreq_config *cfg, struct s3c2412_iobank_timing *bt)
{ unsigned int hclk = cfg->freq.hclk_tns; int err = 0; bt->smbidcyr = calc_timing(bt->idcy, hclk, &err); bt->smbwstrd = calc_timing(bt->wstrd, hclk, &err); bt->smbwstwr = calc_timing(bt->wstwr, hclk, &err); bt->smbwstoen = calc_timing(bt->wstoen, hclk, &err); bt->smbwstwen = calc_timing(bt->wstwen, hclk, &err); ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base UART peripheral base address. param handle UART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
status_t UART_TransferGetSendCountEDMA(UART_Type *base, uart_edma_handle_t *handle, uint32_t *count)
/* param base UART peripheral base address. param handle UART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */ status_t UART_TransferGetSendCountED...
{ assert(handle); assert(handle->txEdmaHandle); assert(count); if (kUART_TxIdle == handle->txState) { return kStatus_NoTransferInProgress; } *count = handle->txDataSizeAll - (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->txEdmaHandle-...
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Add a specified length protocal header to the start of data buffer hold by specified rtk_buffer. This function extends used data area of the buffer at the buffer start. */
uint8_t* RtbAddHead(RTK_BUFFER *RtkBuffer, uint32_t Length)
/* Add a specified length protocal header to the start of data buffer hold by specified rtk_buffer. This function extends used data area of the buffer at the buffer start. */ uint8_t* RtbAddHead(RTK_BUFFER *RtkBuffer, uint32_t Length)
{ if ((uint32_t)(RtkBuffer->Data - RtkBuffer->Head) >= Length) { RtkBuffer->Data -= Length; RtkBuffer->Length += Length; RtkBuffer->HeadRoom -= Length; return RtkBuffer->Data; } return NULL; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Get actual clock digital filter @rmtoll CFG CKFLT LPTIM_GetClockFilter. */
uint32_t LPTIM_GetClockFilter(LPTIM_Module *LPTIMx)
/* Get actual clock digital filter @rmtoll CFG CKFLT LPTIM_GetClockFilter. */ uint32_t LPTIM_GetClockFilter(LPTIM_Module *LPTIMx)
{ return (uint32_t)(READ_BIT(LPTIMx->CFG, LPTIM_CFG_CLKFLT)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Checks to see if a LE event has been disabled by the host. */
bool ble_ll_hci_is_le_event_enabled(unsigned int subev)
/* Checks to see if a LE event has been disabled by the host. */ bool ble_ll_hci_is_le_event_enabled(unsigned int subev)
{ if (g_ble_ll_hci_event_mask & (1ull << (BLE_HCI_EVCODE_LE_META - 1))) { return g_ble_ll_hci_le_event_mask & (1ull << (subev - 1)); } return false; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Hardcoded flash setup: Flash 0 is a non-CFI SST 39VF020 flash, 8 bit flash / 8 bit bus. Flash 1 is an Intel *16 flash using the CFI driver. */
ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
/* Hardcoded flash setup: Flash 0 is a non-CFI SST 39VF020 flash, 8 bit flash / 8 bit bus. Flash 1 is an Intel *16 flash using the CFI driver. */ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
{ if (banknum == 0) { info->portwidth = 1; info->chipwidth = 1; info->interface = FLASH_CFI_X8; return 1; } else return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Change Logs: Date Author Notes Jesven first version Shell Move part of the codes to C from asm in signal handling Shell Support a new backtrace framework */
int arch_set_thread_context(void(*exit)(void), void *new_thread_stack, void *user_stack, void **thread_sp)
/* Change Logs: Date Author Notes Jesven first version Shell Move part of the codes to C from asm in signal handling Shell Support a new backtrace framework */ int arch_set_thread_context(void(*exit)(void), void *new_thread_stack, void *user_stack, void **thread_sp)
{ struct rt_hw_exp_stack *syscall_frame; struct rt_hw_exp_stack *thread_frame; struct rt_hw_exp_stack *ori_syscall = rt_thread_self()->user_ctx.ctx; RT_ASSERT(ori_syscall != RT_NULL); thread_frame = (void *)((long)new_thread_stack - sizeof(struct rt_hw_exp_stack)); syscall_frame = (void *)((long...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables or disables the specified DAC peripheral Clock. */
void RCC_DAC_ClockCmd(DAC_TypeDef *peripheral, FunctionalState state)
/* Enables or disables the specified DAC peripheral Clock. */ void RCC_DAC_ClockCmd(DAC_TypeDef *peripheral, FunctionalState state)
{ if(DAC == peripheral) { (state) ? (RCC->APB1ENR |= RCC_APB1ENR_DAC) : (RCC->APB1ENR &= ~RCC_APB1ENR_DAC); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate ...
EFI_DEVICE_PATH_PROTOCOL* EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength)
/* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate ...
{ return UefiDevicePathLibCreateDeviceNode (NodeType, NodeSubType, NodeLength); }
tianocore/edk2
C++
Other
4,240
/* The PWMB default IRQ, declared in StartUp code. */
void PWM1CH1_IRQHandler(void)
/* The PWMB default IRQ, declared in StartUp code. */ void PWM1CH1_IRQHandler(void)
{ unsigned long ulPWMStastus; unsigned long ulBase = PWMB_BASE; ulPWMStastus = xHWREG(ulBase + PWM_INTSTS) & 0x02020202; xHWREG(ulBase + PWM_INTSTS) = ulPWMStastus; if (g_pfnPWMHandlerCallbacks[0] != 0) { if(ulPWMStastus & 0x0202) { g_pfnPWMHandlerCallbacks[1](0, PWM_...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Lemma to deal with race condition of write..read to epb regs */
static int epb_trans(struct ipath_devdata *dd, u16 reg, u64 i_val, u64 *o_vp)
/* Lemma to deal with race condition of write..read to epb regs */ static int epb_trans(struct ipath_devdata *dd, u16 reg, u64 i_val, u64 *o_vp)
{ int tries; u64 transval; ipath_write_kreg(dd, reg, i_val); transval = ipath_read_kreg64(dd, reg); for (tries = EPB_TRANS_TRIES; tries; --tries) { transval = ipath_read_kreg32(dd, reg); if (transval & EPB_TRANS_RDY) break; udelay(5); } if (transval & EPB_TRANS_ERR) return -1; if (tries > 0 && o_vp) ...
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the specified DAC flag is set or not. */
FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG)
/* Checks whether the specified DAC flag is set or not. */ FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG)
{ FlagStatus bitstatus = RESET; assert_param(IS_DAC_CHANNEL(DAC_Channel)); assert_param(IS_DAC_FLAG(DAC_FLAG)); if ((DAC->SR & (DAC_FLAG << DAC_Channel)) != (uint8_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
ajhc/demo-cortex-m3
C++
null
38
/* Calculate the crc value of data by byte. */
uint32_t ald_crc_calculate(ald_crc_handle_t *hperh, uint8_t *buf, uint32_t size)
/* Calculate the crc value of data by byte. */ uint32_t ald_crc_calculate(ald_crc_handle_t *hperh, uint8_t *buf, uint32_t size)
{ uint32_t i; uint32_t ret; assert_param(IS_CRC(hperh->perh)); if (buf == NULL || size == 0) return 0; __LOCK(hperh); MODIFY_REG(hperh->perh->CR, CRC_CR_DATLEN_MSK, ALD_CRC_DATASIZE_8 << CRC_CR_DATLEN_POSS); hperh->state = ALD_CRC_STATE_BUSY; for (i = 0; i < size; i++) *(...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Fills each TIM_ICInitStruct member with its default value. */
void TIM_ICStructInit(TIM_ICInitTypeDef *TIM_ICInitStruct)
/* Fills each TIM_ICInitStruct member with its default value. */ void TIM_ICStructInit(TIM_ICInitTypeDef *TIM_ICInitStruct)
{ TIM_ICInitStruct->TIM_Channel = TIM_Channel_1; TIM_ICInitStruct->TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStruct->TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStruct->TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStruct->TIM_ICFilter = 0x00; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Mark the attributes as stale, so that at the next call to ->getattr() they will be fetched from userspace */
void fuse_invalidate_attr(struct inode *inode)
/* Mark the attributes as stale, so that at the next call to ->getattr() they will be fetched from userspace */ void fuse_invalidate_attr(struct inode *inode)
{ get_fuse_inode(inode)->i_time = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Enable or disable the specified hardware start condition. */
void TMR2_HWStartCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState)
/* Enable or disable the specified hardware start condition. */ void TMR2_HWStartCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState)
{ DDL_ASSERT(IS_TMR2_UNIT(TMR2x)); DDL_ASSERT(IS_TMR2_CH(u32Ch)); DDL_ASSERT(IS_TMR2_START_COND(u32Cond)); DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); u32Cond <<= (u32Ch * TMR2_CH_OFFSET); if (enNewState == ENABLE) { SET_REG32_BIT(TMR2x->HCONR, u32Cond); } else { CLR_REG32_B...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* On successful return, the gadget is ready to respond to requests from the host, unless one of its components invokes usb_gadget_disconnect() while it was binding. That would usually be done in order to wait for some userspace participation. */
int usb_composite_register(struct usb_composite_driver *driver)
/* On successful return, the gadget is ready to respond to requests from the host, unless one of its components invokes usb_gadget_disconnect() while it was binding. That would usually be done in order to wait for some userspace participation. */ int usb_composite_register(struct usb_composite_driver *driver)
{ int res; if (!driver || !driver->dev || !driver->bind || composite) return -EINVAL; if (!driver->name) driver->name = "composite"; composite = driver; res = usb_gadget_register_driver(&composite_driver); if (res != 0) composite = NULL; return res; }
4ms/stm32mp1-baremetal
C++
Other
137
/* suppress jitter on some maestros when playing stereo */
static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es)
/* suppress jitter on some maestros when playing stereo */ static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es)
{ unsigned int cp1; unsigned int cp2; unsigned int diff; cp1 = __apu_get_register(chip, 0, 5); cp2 = __apu_get_register(chip, 1, 5); diff = (cp1 > cp2 ? cp1 - cp2 : cp2 - cp1); if (diff > 1) __maestro_write(chip, IDR0_DATA_PORT, cp1); }
robutest/uclinux
C++
GPL-2.0
60
/* Allocate and initialize mAvailableAlgoArray with the available Rng algorithms. Also update mAvailableAlgoArrayCount. */
EFI_STATUS EFIAPI GetAvailableAlgorithms(VOID)
/* Allocate and initialize mAvailableAlgoArray with the available Rng algorithms. Also update mAvailableAlgoArrayCount. */ EFI_STATUS EFIAPI GetAvailableAlgorithms(VOID)
{ mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Set the previous node pointer of a node. */
static void ramfs_node_set_prev(ramfs_ll_t *ll, ramfs_ll_node_t *act, ramfs_ll_node_t *prev)
/* Set the previous node pointer of a node. */ static void ramfs_node_set_prev(ramfs_ll_t *ll, ramfs_ll_node_t *act, ramfs_ll_node_t *prev)
{ memcpy(act + RAMFS_LL_PREV_OFFSET(ll), &prev, sizeof(ramfs_ll_node_t *)); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* The device sends a barker which tells the firmware loader which header in the BCF file has to be used. This does the matching. */
static unsigned i2400m_bcf_hdr_match(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf_hdr)
/* The device sends a barker which tells the firmware loader which header in the BCF file has to be used. This does the matching. */ static unsigned i2400m_bcf_hdr_match(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf_hdr)
{ u32 barker = le32_to_cpu(i2400m->barker->data[0]) & 0x7fffffff; u32 module_id = le32_to_cpu(bcf_hdr->module_id) & 0x7fffffff; if (barker == I2400M_SBOOT_BARKER && module_id == 0) return 1; if (module_id == barker) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* NOTE! Only a kernel-only process(ie the swapper or direct descendants who haven't done an "execve()") should use this: it will work within a system call from a "real" process, but the process memory space will not be freed until both the parent and the child have exited. */
int kernel_thread(int(*fn)(void *), void *arg, unsigned long flags)
/* NOTE! Only a kernel-only process(ie the swapper or direct descendants who haven't done an "execve()") should use this: it will work within a system call from a "real" process, but the process memory space will not be freed until both the parent and the child have exited. */ int kernel_thread(int(*fn)(void *), void ...
{ struct pt_regs regs; memset(&regs, 0, sizeof(regs)); regs.regs[2] = (unsigned long)arg; regs.regs[3] = (unsigned long)fn; regs.pc = (unsigned long)kernel_thread_helper; regs.sr = (1 << 30); return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Unlock the commit control of a special function pin. Unlocks the commit control of the given pin or group of pins. If a pin is a JTAG/SWD or NMI, the pin may then be reconfigured as a GPIO pin. If the pin is not locked by default, this has no effect. */
void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
/* Unlock the commit control of a special function pin. Unlocks the commit control of the given pin or group of pins. If a pin is a JTAG/SWD or NMI, the pin may then be reconfigured as a GPIO pin. If the pin is not locked by default, this has no effect. */ void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
{ GPIO_LOCK(gpioport) = GPIO_LOCK_UNLOCK_CODE; GPIO_CR(gpioport) |= gpios; GPIO_LOCK(gpioport) = ~GPIO_LOCK_UNLOCK_CODE; } /**@}
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* #GMutex is neither guaranteed to be recursive nor to be non-recursive. As such, calling g_mutex_lock() on a #GMutex that has already been locked by the same thread results in undefined behaviour (including but not limited to deadlocks). */
void g_mutex_lock(GMutex *mutex)
/* #GMutex is neither guaranteed to be recursive nor to be non-recursive. As such, calling g_mutex_lock() on a #GMutex that has already been locked by the same thread results in undefined behaviour (including but not limited to deadlocks). */ void g_mutex_lock(GMutex *mutex)
{ gint status; if G_UNLIKELY ((status = pthread_mutex_lock (g_mutex_get_impl (mutex))) != 0) g_thread_abort (status, "pthread_mutex_lock"); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Read RX data register using blocking method. This function polls the RX register, waits for the RX register full then read data from TX register. */
static void LPSCI_ReadNonBlocking(UART0_Type *base, uint8_t *data, size_t length)
/* Read RX data register using blocking method. This function polls the RX register, waits for the RX register full then read data from TX register. */ static void LPSCI_ReadNonBlocking(UART0_Type *base, uint8_t *data, size_t length)
{ assert(data); size_t i; for (i = 0; i < length; i++) { data[i] = base->D; } }
labapart/polymcu
C++
null
201
/* Send a master data transmit request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */
void xI2CMasterWriteRequestS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
/* Send a master data transmit request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */ void xI2CMasterWriteRequestS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) || (ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) || (ulBase == I2C4_BASE)); xHWREG(ulBase + I2C_DAT) = ucData; xHWREG(ulBase + I2C_CON) &= ~(I2C_CON_AA | I2C_CON_EI); if(bEndTransmition) { I2CStopSend(ulBase); ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Clear the Watchdog Timer Reset Flag of the WDT. */
void WDTResetFlagClear(void)
/* Clear the Watchdog Timer Reset Flag of the WDT. */ void WDTResetFlagClear(void)
{ xHWREG(WDT_WTCR) |= WDT_WTCR_WTRF; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Checks to make sure the sensor is valid. */
static int SDL_PrivateSensorValid(SDL_Sensor *sensor)
/* Checks to make sure the sensor is valid. */ static int SDL_PrivateSensorValid(SDL_Sensor *sensor)
{ int valid; if (sensor == NULL) { SDL_SetError("Sensor hasn't been opened yet"); valid = 0; } else { valid = 1; } return valid; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2 */
int wf_channel2mhz(uint ch, uint start_factor)
/* Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2 */ int wf_channel2mhz(uint ch, uint start_factor)
{ int freq; if ((start_factor == WF_CHAN_FACTOR_2_4_G && (ch < 1 || ch > 14)) || (ch > 200)) freq = -1; else if ((start_factor == WF_CHAN_FACTOR_2_4_G) && (ch == 14)) freq = 2484; else freq = ch * 5 + start_factor / 2; return freq; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Return: number of memory channels in operation Pass back: contents of the DCL0_LOW register */
static int k8_early_channel_count(struct amd64_pvt *pvt)
/* Return: number of memory channels in operation Pass back: contents of the DCL0_LOW register */ static int k8_early_channel_count(struct amd64_pvt *pvt)
{ int flag, err = 0; err = amd64_read_pci_cfg(pvt->dram_f2_ctl, F10_DCLR_0, &pvt->dclr0); if (err) return err; if ((boot_cpu_data.x86_model >> 4) >= K8_REV_F) { flag = pvt->dclr0 & F10_WIDTH_128; } else { flag = pvt->dclr0 & REVE_WIDTH_128; } pvt->dclr1 = 0; return (flag) ? 2 : 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Receives a fixed block from the open com port. Returns when the block is completely filled or the timeout period has passed */
int ReceiveComPortBlockComplete(ISP_ENVIRONMENT *IspEnvironment, void *block, size_t size, unsigned timeout)
/* Receives a fixed block from the open com port. Returns when the block is completely filled or the timeout period has passed */ int ReceiveComPortBlockComplete(ISP_ENVIRONMENT *IspEnvironment, void *block, size_t size, unsigned timeout)
{ unsigned long realsize = 0, read; char *result; char tmp_string[32]; result = (char*) block; SerialTimeoutSet(IspEnvironment, timeout); do { ReceiveComPortBlock(IspEnvironment, result + realsize, size - realsize, &read); realsize += read; } while ((realsize < size) && (...
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Get the wakeup pin Filter flag of the specified index. */
xtBoolean SysCtlWakeupPinFilterFlagGet(unsigned long ulFilterIndex)
/* Get the wakeup pin Filter flag of the specified index. */ xtBoolean SysCtlWakeupPinFilterFlagGet(unsigned long ulFilterIndex)
{ xtBoolean xtFlag = 0; xASSERT((ulFilterIndex >= 1 && ulFilterIndex <= 2)); xtFlag = (xHWREGB(LLWU_FILT1+ulFilterIndex/2) & LLWU_FILT1_FILTSEL_FILTF); if(xtFlag) { return xtrue; } else { return xfalse; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Get the SPI interrupt flag of the specified SPI port. */
unsigned long SPIIntFlagGet(unsigned long ulBase, xtBoolean xbMasked)
/* Get the SPI interrupt flag of the specified SPI port. */ unsigned long SPIIntFlagGet(unsigned long ulBase, xtBoolean xbMasked)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); xASSERT(xbMasked == xfalse); return (xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_IF); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Waits for completion of an SBP-2 access request. Returns nonzero if timed out or prematurely interrupted. */
static int sbp2util_access_timeout(struct sbp2_lu *lu, int timeout)
/* Waits for completion of an SBP-2 access request. Returns nonzero if timed out or prematurely interrupted. */ static int sbp2util_access_timeout(struct sbp2_lu *lu, int timeout)
{ long leftover; leftover = wait_event_interruptible_timeout( sbp2_access_wq, lu->access_complete, timeout); lu->access_complete = 0; return leftover <= 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Gets the states of the DTR and RTS modem control signals. */
unsigned long xUARTModemControlGet(unsigned long ulBase, unsigned long ulControl)
/* Gets the states of the DTR and RTS modem control signals. */ unsigned long xUARTModemControlGet(unsigned long ulBase, unsigned long ulControl)
{ return UARTModemControlGet(ulBase); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Initializes a Watchdog Timer configuration structure to defaults. The default configuration is as follows: */
void wdt_get_config_defaults(struct wdt_config *const config)
/* Initializes a Watchdog Timer configuration structure to defaults. The default configuration is as follows: */ void wdt_get_config_defaults(struct wdt_config *const config)
{ Assert(config); config->load_value = 0xFFFFFFFF; config->enable_reset = true; config->write_access = true; }
memfault/zero-to-main
C++
null
200
/* Returns: 0 on success, -EERROR value on error */
int __clk_mux_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
/* Returns: 0 on success, -EERROR value on error */ int __clk_mux_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
{ return clk_mux_determine_rate_flags(hw, req, 0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get's the resultant location of the cursor based on the relative movement of the Mouse. */
INT32 GetTextY(IN INT32 GuidY)
/* Get's the resultant location of the cursor based on the relative movement of the Mouse. */ INT32 GetTextY(IN INT32 GuidY)
{ INT32 Gap; MainEditor.MouseAccumulatorY += GuidY; Gap = (MainEditor.MouseAccumulatorY * (INT32)MainEditor.ScreenSize.Row) / (INT32)(50 * (INT32)MainEditor.MouseInterface->Mode->ResolutionY); MainEditor.MouseAccumulatorY = (MainEditor.MouseAccumulatorY * (INT32)MainEditor.ScreenSize...
tianocore/edk2
C++
Other
4,240
/* Ensures that all commands in the ring are finished before signalling the CPU */
static uint32_t i915_retire_commands(struct drm_device *dev)
/* Ensures that all commands in the ring are finished before signalling the CPU */ static uint32_t i915_retire_commands(struct drm_device *dev)
{ drm_i915_private_t *dev_priv = dev->dev_private; uint32_t cmd = MI_FLUSH | MI_NO_WRITE_FLUSH; uint32_t flush_domains = 0; RING_LOCALS; if (IS_I965G(dev)) flush_domains |= I915_GEM_DOMAIN_SAMPLER; BEGIN_LP_RING(2); OUT_RING(cmd); OUT_RING(0); ADVANCE_LP_RING(); return flush_domains; }
robutest/uclinux
C++
GPL-2.0
60
/* Latch interrupt request on INT1_SRC (31h), with INT1_SRC(31h) register cleared by reading INT1_SRC (31h) itself.. */
int32_t lis2dh12_int1_pin_notification_mode_get(stmdev_ctx_t *ctx, lis2dh12_lir_int1_t *val)
/* Latch interrupt request on INT1_SRC (31h), with INT1_SRC(31h) register cleared by reading INT1_SRC (31h) itself.. */ int32_t lis2dh12_int1_pin_notification_mode_get(stmdev_ctx_t *ctx, lis2dh12_lir_int1_t *val)
{ lis2dh12_ctrl_reg5_t ctrl_reg5; int32_t ret; ret = lis2dh12_read_reg(ctx, LIS2DH12_CTRL_REG5, (uint8_t *)&ctrl_reg5, 1); switch (ctrl_reg5.lir_int1) { case LIS2DH12_INT1_PULSED: *val = LIS2DH12_INT1_PULSED; break; case LIS2DH12_INT1_LATCHED: *val = LIS2DH1...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Return TRUE is we are currently receiving a frame */
static int nsc_ircc_is_receiving(struct nsc_ircc_cb *self)
/* Return TRUE is we are currently receiving a frame */ static int nsc_ircc_is_receiving(struct nsc_ircc_cb *self)
{ unsigned long flags; int status = FALSE; int iobase; __u8 bank; IRDA_ASSERT(self != NULL, return FALSE;); spin_lock_irqsave(&self->lock, flags); if (self->io.speed > 115200) { iobase = self->io.fir_base; bank = inb(iobase+BSR); switch_bank(iobase, BANK2); if ((inb(iobase+RXFLV) & 0x3f) != 0) { statu...
robutest/uclinux
C++
GPL-2.0
60