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
/* write_undock - write method for "undock" file in sysfs */
static ssize_t write_undock(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
/* write_undock - write method for "undock" file in sysfs */ static ssize_t write_undock(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ int ret; struct dock_station *dock_station = dev->platform_data; if (!count) return -EINVAL; begin_undock(dock_station); ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); return ret ? ret: count; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: (element-type GIOModule) (transfer full): a list of #GIOModules loaded from the directory, All the modules are loaded into memory, if you want to unload them (enabling on-demand loading) you must call g_type_module_unuse() on all the modules. Free the list with g_list_free(). */
GList* g_io_modules_load_all_in_directory(const char *dirname)
/* Returns: (element-type GIOModule) (transfer full): a list of #GIOModules loaded from the directory, All the modules are loaded into memory, if you want to unload them (enabling on-demand loading) you must call g_type_module_unuse() on all the modules. Free the list with g_list_free(). */ GList* g_io_modules_load_all_in_directory(const char *dirname)
{ return g_io_modules_load_all_in_directory_with_scope (dirname, NULL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* fpga_add Add the device descriptor to the device table. */
int fpga_add(fpga_type devtype, void *desc)
/* fpga_add Add the device descriptor to the device table. */ int fpga_add(fpga_type devtype, void *desc)
{ int devnum = FPGA_INVALID_DEVICE; if (!desc) { printf("%s: NULL device descriptor\n", __func__); return devnum; } if (next_desc < 0) { printf("%s: FPGA support not initialized!\n", __func__); } else if ((devtype > fpga_min_type) && (devtype < fpga_undefined)) { if (next_desc < CONFIG_MAX_FPGA_DEVICES) { devnum = next_desc; desc_table[next_desc].devtype = devtype; desc_table[next_desc++].devdesc = desc; } else { printf("%s: Exceeded Max FPGA device count\n", __func__); } } else { printf("%s: Unsupported FPGA type %d\n", __func__, devtype); } return devnum; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function returns the interrupt number for the hibernate module. */
static uint32_t _HibernateIntNumberGet(void)
/* This function returns the interrupt number for the hibernate module. */ static uint32_t _HibernateIntNumberGet(void)
{ uint32_t ui32Int; if(CLASS_IS_TM4C129) { ui32Int = INT_HIBERNATE_TM4C129; } else { ui32Int = INT_HIBERNATE_TM4C123; } return(ui32Int); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */
int ZEXPORT unzStringFileNameCompare(char *fileName1, const char *fileName2, int iCaseSensitivity) const
/* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ int ZEXPORT unzStringFileNameCompare(char *fileName1, const char *fileName2, int iCaseSensitivity) const
{ if (iCaseSensitivity == 0) iCaseSensitivity = CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity == 1) return strcmp(fileName1, fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1, fileName2); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* used to setup a new base for disk images to use /foo/bar/disk as disk images you have to specify simscsi=/foo/bar/disk on the command line */
static int __init simscsi_setup(char *s)
/* used to setup a new base for disk images to use /foo/bar/disk as disk images you have to specify simscsi=/foo/bar/disk on the command line */ static int __init simscsi_setup(char *s)
{ if (strlen(s) > MAX_ROOT_LEN) { printk(KERN_ERR "simscsi_setup: prefix too long---using default %s\n", simscsi_root); } simscsi_root = s; return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The transition from "FP supporting" to "non-FP supporting" must be done atomically to avoid confusing the floating point logic used by z_swap(), so this routine locks interrupts to ensure that a context switch does not occur. The locking isn't really needed when the routine is called by a cooperative thread (since context switching can't occur), but it is harmless. */
int z_float_disable(struct k_thread *thread)
/* The transition from "FP supporting" to "non-FP supporting" must be done atomically to avoid confusing the floating point logic used by z_swap(), so this routine locks interrupts to ensure that a context switch does not occur. The locking isn't really needed when the routine is called by a cooperative thread (since context switching can't occur), but it is harmless. */ int z_float_disable(struct k_thread *thread)
{ unsigned int imask; imask = irq_lock(); thread->base.user_options &= ~_FP_USER_MASK; if (thread == _current) { z_FpAccessDisable(); _kernel.current_fp = (struct k_thread *)0; } else { if (_kernel.current_fp == thread) { _kernel.current_fp = (struct k_thread *)0; } } irq_unlock(imask); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* EC Point addition. EcPointResult = EcPointA + EcPointB. */
BOOLEAN EFIAPI EcPointAdd(IN CONST VOID *EcGroup, OUT VOID *EcPointResult, IN CONST VOID *EcPointA, IN CONST VOID *EcPointB, IN VOID *BnCtx)
/* EC Point addition. EcPointResult = EcPointA + EcPointB. */ BOOLEAN EFIAPI EcPointAdd(IN CONST VOID *EcGroup, OUT VOID *EcPointResult, IN CONST VOID *EcPointA, IN CONST VOID *EcPointB, IN VOID *BnCtx)
{ CALL_CRYPTO_SERVICE (EcPointAdd, (EcGroup, EcPointResult, EcPointA, EcPointB, BnCtx), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Gets the height in pixels of the LCD screen (varies depending on the current screen orientation) */
uint16_t lcdGetHeight(void)
/* Gets the height in pixels of the LCD screen (varies depending on the current screen orientation) */ uint16_t lcdGetHeight(void)
{ switch (lcdOrientation) { case LCD_ORIENTATION_PORTRAIT: return ili9325Properties.height; break; case LCD_ORIENTATION_LANDSCAPE: default: return ili9325Properties.width; } }
microbuilder/LPC1343CodeBase
C++
Other
73
/* onenand_memory_bbt - create a memory based bad block table */
static int onenand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
/* onenand_memory_bbt - create a memory based bad block table */ static int onenand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
{ unsigned char data_buf[MAX_ONENAND_PAGESIZE]; bd->options &= ~NAND_BBT_SCANEMPTY; return create_bbt(mtd, data_buf, bd, -1); }
EmcraftSystems/u-boot
C++
Other
181
/* Performs the necessary steps in preparation for invoking VMGEXIT. Must be called before setting any fields within the GHCB. */
VOID EFIAPI CcExitVmgInit(IN OUT GHCB *Ghcb, IN OUT BOOLEAN *InterruptState)
/* Performs the necessary steps in preparation for invoking VMGEXIT. Must be called before setting any fields within the GHCB. */ VOID EFIAPI CcExitVmgInit(IN OUT GHCB *Ghcb, IN OUT BOOLEAN *InterruptState)
{ *InterruptState = GetInterruptState (); if (*InterruptState) { DisableInterrupts (); } SetMem (&Ghcb->SaveArea, sizeof (Ghcb->SaveArea), 0); }
tianocore/edk2
C++
Other
4,240
/* Selects the USART WakeUp method from mute mode. */
void USART_MuteModeWakeUpConfig(USART_TypeDef *USARTx, uint32_t USART_WakeUp)
/* Selects the USART WakeUp method from mute mode. */ void USART_MuteModeWakeUpConfig(USART_TypeDef *USARTx, uint32_t USART_WakeUp)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_USART_MUTEMODE_WAKEUP(USART_WakeUp)); USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_WAKE); USARTx->CR1 |= USART_WakeUp; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* this function is a POSIX compliant version, which will set position of next directory structure in the directory stream. */
void seekdir(DIR *d, long offset)
/* this function is a POSIX compliant version, which will set position of next directory structure in the directory stream. */ void seekdir(DIR *d, long offset)
{ struct dfs_file *fd; fd = fd_get(d->fd); if (fd == NULL) { rt_set_errno(-EBADF); return ; } if (dfs_file_lseek(fd, offset) >= 0) d->num = d->cur = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize the boards on-board LEDs. The red LED is connected to pin PC3 */
static void leds_init(void)
/* Initialize the boards on-board LEDs. The red LED is connected to pin PC3 */ static void leds_init(void)
{ RCC->AHBENR |= RCC_AHBENR_GPIOCEN; LED_RED_PORT->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR3; LED_RED_PORT->OTYPER &= ~(GPIO_OTYPER_OT_3); LED_RED_PORT->MODER &= ~(GPIO_MODER_MODER3); LED_RED_PORT->MODER |= GPIO_MODER_MODER3_0; LED_RED_PORT->PUPDR &= ~(GPIO_PUPDR_PUPDR3); LED_RED_PORT->BRR = (1 << 3); }
labapart/polymcu
C++
null
201
/* Find the current Processor number by APIC ID. */
EFI_STATUS GetProcessorNumber(IN CPU_MP_DATA *CpuMpData, OUT UINTN *ProcessorNumber)
/* Find the current Processor number by APIC ID. */ EFI_STATUS GetProcessorNumber(IN CPU_MP_DATA *CpuMpData, OUT UINTN *ProcessorNumber)
{ UINTN TotalProcessorNumber; UINTN Index; CPU_INFO_IN_HOB *CpuInfoInHob; UINT32 CurrentApicId; CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; TotalProcessorNumber = CpuMpData->CpuCount; CurrentApicId = GetApicId (); for (Index = 0; Index < TotalProcessorNumber; Index++) { if (CpuInfoInHob[Index].ApicId == CurrentApicId) { *ProcessorNumber = Index; return EFI_SUCCESS; } } return EFI_NOT_FOUND; }
tianocore/edk2
C++
Other
4,240
/* Reads data from the file referred by the ulFileId parameter. Reads data from file ulOffset till length. Err if the file can't be used, is invalid, or if the read is out of bounds. nvmem_read */
INT32 nvmem_read(UINT32 ulFileId, UINT32 ulLength, UINT32 ulOffset, UINT8 *buff)
/* Reads data from the file referred by the ulFileId parameter. Reads data from file ulOffset till length. Err if the file can't be used, is invalid, or if the read is out of bounds. nvmem_read */ INT32 nvmem_read(UINT32 ulFileId, UINT32 ulLength, UINT32 ulOffset, UINT8 *buff)
{ UINT8 ucStatus = 0xFF; UINT8 *ptr; UINT8 *args; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); args = UINT32_TO_STREAM(args, ulFileId); args = UINT32_TO_STREAM(args, ulLength); args = UINT32_TO_STREAM(args, ulOffset); hci_command_send(HCI_CMND_NVMEM_READ, ptr, NVMEM_READ_PARAMS_LEN); SimpleLinkWaitEvent(HCI_CMND_NVMEM_READ, &ucStatus); SimpleLinkWaitData(buff, 0, 0); return(ucStatus); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Called when system detects that a skb timeout period has expired potentially due to a fault in the adapter in not being able to send it out on the wire. We teardown the TX channel assuming a hardware error and re-initialize the TX channel for hardware operation */
static void emac_dev_tx_timeout(struct emac_priv *priv)
/* Called when system detects that a skb timeout period has expired potentially due to a fault in the adapter in not being able to send it out on the wire. We teardown the TX channel assuming a hardware error and re-initialize the TX channel for hardware operation */ static void emac_dev_tx_timeout(struct emac_priv *priv)
{ rt_kprintf("emac tx timeout.\n"); priv->net_dev_stats.tx_errors++; emac_int_disable(priv); emac_stop_txch(priv, EMAC_DEF_TX_CH); emac_cleanup_txch(priv, EMAC_DEF_TX_CH); emac_init_txch(priv, EMAC_DEF_TX_CH); emac_write(EMAC_TXHDP(0), 0); emac_write(EMAC_TXINTMASKSET, BIT(EMAC_DEF_TX_CH)); emac_int_enable(priv); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* 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 VmWriteMem32(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT32 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 VmWriteMem32(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT32 Data)
{ EFI_STATUS Status; Addr = ConvertStackAddr (VmPtr, Addr); if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT32))) { *(UINT32 *)Addr = Data; } else { MemoryFence (); if ((Status = VmWriteMem16 (VmPtr, Addr, (UINT16)Data)) != EFI_SUCCESS) { return Status; } MemoryFence (); if ((Status = VmWriteMem16 (VmPtr, Addr + sizeof (UINT16), (UINT16)(Data >> 16))) != EFI_SUCCESS) { return Status; } MemoryFence (); } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This function will fill a formatted string to buffer */
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt,...)
/* This function will fill a formatted string to buffer */ rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt,...)
{ rt_int32_t n; va_list args; va_start(args, fmt); n = rt_vsnprintf(buf, size, fmt, args); va_end(args); return n; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Get the clock cycles of EMC clock. The function is used to calculate the multiple of the 16 EMCCLKs between the timer_Ns period. */
static uint32_t EMC_CalculateTimerCycles(EMC_Type *base, uint32_t timer_Ns, uint32_t plus)
/* Get the clock cycles of EMC clock. The function is used to calculate the multiple of the 16 EMCCLKs between the timer_Ns period. */ static uint32_t EMC_CalculateTimerCycles(EMC_Type *base, uint32_t timer_Ns, uint32_t plus)
{ uint32_t cycles; cycles = CLOCK_GetFreq(kCLOCK_EMC) / EMC_HZ_ONEMHZ * timer_Ns; cycles = EMC_DIV_ROUND_UP(cycles, EMC_MILLISECS_ONESEC); if (cycles >= plus) { cycles = cycles - plus; } else { cycles = 0; } return cycles; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: TRUE if the volume should be automatically mounted */
gboolean g_volume_should_automount(GVolume *volume)
/* Returns: TRUE if the volume should be automatically mounted */ gboolean g_volume_should_automount(GVolume *volume)
{ GVolumeIface *iface; g_return_val_if_fail (G_IS_VOLUME (volume), FALSE); iface = G_VOLUME_GET_IFACE (volume); if (iface->should_automount == NULL) return FALSE; return (* iface->should_automount) (volume); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* 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 AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI AsmMsrBitFieldAnd32(IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
/* 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 AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT32 EFIAPI AsmMsrBitFieldAnd32(IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
{ ASSERT (EndBit < sizeof (AndData) * 8); ASSERT (StartBit <= EndBit); return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData); }
tianocore/edk2
C++
Other
4,240
/* Returns -1 in case of error, the index in the stack otherwise */
int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
/* Returns -1 in case of error, the index in the stack otherwise */ int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
{ if (ctxt == NULL) return(0); if (ctxt->nodeNr >= ctxt->nodeMax) { xmlNodePtr *tmp; tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab, ctxt->nodeMax * 2 * sizeof(ctxt->nodeTab[0])); if (tmp == NULL) { xmlErrMemory(ctxt, NULL); return (-1); } ctxt->nodeTab = tmp; ctxt->nodeMax *= 2; } if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) && ((ctxt->options & XML_PARSE_HUGE) == 0)) { xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR, "Excessive depth in document: %d use XML_PARSE_HUGE option\n", xmlParserMaxDepth); xmlHaltParser(ctxt); return(-1); } ctxt->nodeTab[ctxt->nodeNr] = value; ctxt->node = value; return (ctxt->nodeNr++); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Delete all buffers on an &sk_buff list. Each buffer is removed from the list and one reference dropped. This function takes the list lock and is atomic with respect to other list locking functions. */
void skb_queue_purge(struct sk_buff_head *list)
/* Delete all buffers on an &sk_buff list. Each buffer is removed from the list and one reference dropped. This function takes the list lock and is atomic with respect to other list locking functions. */ void skb_queue_purge(struct sk_buff_head *list)
{ struct sk_buff *skb; while ((skb = skb_dequeue(list)) != NULL) kfree_skb(skb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Input from subdevice 1. Copied from the comedi_parport driver. */
static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
/* Input from subdevice 1. Copied from the comedi_parport driver. */ static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{ data[1] = 0; return 2; }
robutest/uclinux
C++
GPL-2.0
60
/* Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. The 8-bit value specified by Value is written. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. Value is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length in SmBusAddress is not zero, then ASSERT(). If any reserved bits of SmBusAddress are set, then ASSERT(). */
UINT8 EFIAPI S3SmBusWriteDataByte(IN UINTN SmBusAddress, IN UINT8 Value, OUT RETURN_STATUS *Status OPTIONAL)
/* Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. The 8-bit value specified by Value is written. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. Value is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length in SmBusAddress is not zero, then ASSERT(). If any reserved bits of SmBusAddress are set, then ASSERT(). */ UINT8 EFIAPI S3SmBusWriteDataByte(IN UINTN SmBusAddress, IN UINT8 Value, OUT RETURN_STATUS *Status OPTIONAL)
{ UINT8 Byte; Byte = SmBusWriteDataByte (SmBusAddress, Value, Status); InternalSaveSmBusExecToBootScript (EfiSmbusWriteByte, SmBusAddress, 1, &Byte); return Byte; }
tianocore/edk2
C++
Other
4,240
/* Free the root bridge instances array returned from */
VOID EFIAPI PciHostBridgeFreeRootBridges(PCI_ROOT_BRIDGE *Bridges, UINTN Count)
/* Free the root bridge instances array returned from */ VOID EFIAPI PciHostBridgeFreeRootBridges(PCI_ROOT_BRIDGE *Bridges, UINTN Count)
{ if ((Bridges == NULL) || (Count == 0)) { return; } ASSERT (Bridges != NULL || Count > 0); do { --Count; FreePool (Bridges[Count].DevicePath); } while (Count > 0); FreePool (Bridges); }
tianocore/edk2
C++
Other
4,240
/* Disable the watchdog timer on the receiver. When disabled, Gmac disabled watchdog timer, and can receive frames up to 16,384 bytes. */
void synopGMAC_wd_disable(synopGMACdevice *gmacdev)
/* Disable the watchdog timer on the receiver. When disabled, Gmac disabled watchdog timer, and can receive frames up to 16,384 bytes. */ void synopGMAC_wd_disable(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev -> MacBase, GmacConfig, GmacWatchdog); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* returns non zero, if multi-threading is enabled on at least one physical package. Due to hotplug cpu and (maxcpus=), all threads may not necessarily be enabled even though the processor supports multi-threading. */
int is_multithreading_enabled(void)
/* returns non zero, if multi-threading is enabled on at least one physical package. Due to hotplug cpu and (maxcpus=), all threads may not necessarily be enabled even though the processor supports multi-threading. */ int is_multithreading_enabled(void)
{ int i, j; for_each_present_cpu(i) { for_each_present_cpu(j) { if (j == i) continue; if ((cpu_data(j)->socket_id == cpu_data(i)->socket_id)) { if (cpu_data(j)->core_id == cpu_data(i)->core_id) return 1; } } } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns < 0 if off is not valid, 1 if window access is needed. 'off' is set to offset from CRB space in 128M pci map 0 if no window access is needed. 'off' is set to 2M addr In: 'off' is offset from base in 128M pci map */
static int netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter, ulong off, void __iomem **addr)
/* Returns < 0 if off is not valid, 1 if window access is needed. 'off' is set to offset from CRB space in 128M pci map 0 if no window access is needed. 'off' is set to 2M addr In: 'off' is offset from base in 128M pci map */ static int netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter, ulong off, void __iomem **addr)
{ crb_128M_2M_sub_block_map_t *m; if ((off >= NETXEN_CRB_MAX) || (off < NETXEN_PCI_CRBSPACE)) return -EINVAL; off -= NETXEN_PCI_CRBSPACE; m = &crb_128M_2M_map[CRB_BLK(off)].sub_block[CRB_SUBBLK(off)]; if (m->valid && (m->start_128M <= off) && (m->end_128M > off)) { *addr = adapter->ahw.pci_base0 + m->start_2M + (off - m->start_128M); return 0; } *addr = adapter->ahw.pci_base0 + CRB_INDIRECT_2M + (off & MASK(16)); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* IMSI is defined in 3GPP TS 23.003 Editor's note: IMSI coding will be defined in 3GPP TS 24.301 Editor's note: In the first release of GTPv2 spec (TS 29.274v8.0.0) n = 8. That is, the overall length of the IE is 11 octets. */
static void dissect_gtpv2_imsi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_, session_args_t *args _U_)
/* IMSI is defined in 3GPP TS 23.003 Editor's note: IMSI coding will be defined in 3GPP TS 24.301 Editor's note: In the first release of GTPv2 spec (TS 29.274v8.0.0) n = 8. That is, the overall length of the IE is 11 octets. */ static void dissect_gtpv2_imsi(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_item *item, guint16 length, guint8 message_type _U_, guint8 instance _U_, session_args_t *args _U_)
{ int offset = 0; const gchar *imsi_str; imsi_str = dissect_e212_imsi(tvb, pinfo, tree, offset, length, FALSE); proto_item_append_text(item, "%s", imsi_str); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).. */
int32_t lsm6dso_xl_offset_weight_get(lsm6dso_ctx_t *ctx, lsm6dso_usr_off_w_t *val)
/* Weight of XL user offset bits of registers X_OFS_USR (73h), Y_OFS_USR (74h), Z_OFS_USR (75h).. */ int32_t lsm6dso_xl_offset_weight_get(lsm6dso_ctx_t *ctx, lsm6dso_usr_off_w_t *val)
{ lsm6dso_ctrl6_c_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL6_C, (uint8_t*)&reg, 1); switch (reg.usr_off_w) { case LSM6DSO_LSb_1mg: *val = LSM6DSO_LSb_1mg; break; case LSM6DSO_LSb_16mg: *val = LSM6DSO_LSb_16mg; break; default: *val = LSM6DSO_LSb_1mg; break; } return ret; }
alexander-g-dean/ESF
C++
null
41
/* 0th order modified bessel function of the first kind. */
static double bessel(double x)
/* 0th order modified bessel function of the first kind. */ static double bessel(double x)
{ lastv=v; t *= x/(i*i); v += t; } return v; }
DC-SWAT/DreamShell
C++
null
404
/* Since 8259PIC was disabled on the board, the IDE device can not use the legacy IRQ, we need to let the IDE device work under native mode and use the interrupt line like other PCI devices. IRQ14 is a sideband interrupt from IDE device to CPU and we use this as the interrupt for IDE device. */
static void __devinit hpcd_quirk_uli5229(struct pci_dev *dev)
/* Since 8259PIC was disabled on the board, the IDE device can not use the legacy IRQ, we need to let the IDE device work under native mode and use the interrupt line like other PCI devices. IRQ14 is a sideband interrupt from IDE device to CPU and we use this as the interrupt for IDE device. */ static void __devinit hpcd_quirk_uli5229(struct pci_dev *dev)
{ unsigned char c; if (!machine_is(mpc86xx_hpcd)) return; pci_read_config_byte(dev, 0x4b, &c); c |= 0x10; pci_write_config_byte(dev, 0x4b, c); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Attach winbond IDE interfaces by scanning the ports it may occupy. */
static __init int winbond_init(void)
/* Attach winbond IDE interfaces by scanning the ports it may occupy. */ static __init int winbond_init(void)
{ static const unsigned long config[2] = { 0x130, 0x1B0 }; int ct = 0; int i; if (probe_winbond == 0) return -ENODEV; for (i = 0; i < 2; i++) { if (probe_winbond & (1<<i)) { int ret = 0; unsigned long port = config[i]; if (request_region(port, 2, "pata_winbond")) { ret = winbond_init_one(port); if (ret <= 0) release_region(port, 2); else ct+= ret; } } } if (ct != 0) return 0; return -ENODEV; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF before the Ethernet header. */
u_int netanalyzer_transparent_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
/* This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF before the Ethernet header. */ u_int netanalyzer_transparent_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{ if (h->len < 12 || h->caplen < 12) { ND_PRINT((ndo, "[|netanalyzer-transparent]")); return (h->caplen); } return (12 + ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL)); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Initialize the state of the SoftwareEnable bit in the Local APIC Spurious Interrupt Vector register. */
VOID EFIAPI InitializeLocalApicSoftwareEnable(IN BOOLEAN Enable)
/* Initialize the state of the SoftwareEnable bit in the Local APIC Spurious Interrupt Vector register. */ VOID EFIAPI InitializeLocalApicSoftwareEnable(IN BOOLEAN Enable)
{ LOCAL_APIC_SVR Svr; Svr.Uint32 = ReadLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET); if (Enable) { if (Svr.Bits.SoftwareEnable == 0) { Svr.Bits.SoftwareEnable = 1; WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); } } else { if (Svr.Bits.SoftwareEnable == 1) { Svr.Bits.SoftwareEnable = 0; WriteLocalApicReg (XAPIC_SPURIOUS_VECTOR_OFFSET, Svr.Uint32); } } }
tianocore/edk2
C++
Other
4,240
/* param base Pointer to the FLEXIO_CAMERA_Type. param handle Pointer to the flexio_camera_edma_handle_t structure. param xfer Camera eDMA transfer structure, see #flexio_camera_transfer_t. retval kStatus_Success if succeeded, others failed. retval kStatus_CAMERA_RxBusy Previous transfer on going. */
status_t FLEXIO_CAMERA_TransferReceiveEDMA(FLEXIO_CAMERA_Type *base, flexio_camera_edma_handle_t *handle, flexio_camera_transfer_t *xfer)
/* param base Pointer to the FLEXIO_CAMERA_Type. param handle Pointer to the flexio_camera_edma_handle_t structure. param xfer Camera eDMA transfer structure, see #flexio_camera_transfer_t. retval kStatus_Success if succeeded, others failed. retval kStatus_CAMERA_RxBusy Previous transfer on going. */ status_t FLEXIO_CAMERA_TransferReceiveEDMA(FLEXIO_CAMERA_Type *base, flexio_camera_edma_handle_t *handle, flexio_camera_transfer_t *xfer)
{ assert(handle->rxEdmaHandle); edma_transfer_config_t xferConfig; status_t status; if (kFLEXIO_CAMERA_RxBusy == handle->rxState) { status = kStatus_FLEXIO_CAMERA_RxBusy; } else { handle->rxState = kFLEXIO_CAMERA_RxBusy; EDMA_PrepareTransfer(&xferConfig, (void *)FLEXIO_CAMERA_GetRxBufferAddress(base), 32, (void *)xfer->dataAddress, 32, 32, xfer->dataNum, kEDMA_PeripheralToMemory); handle->nbytes = 32; EDMA_SubmitTransfer(handle->rxEdmaHandle, &xferConfig); EDMA_StartTransfer(handle->rxEdmaHandle); FLEXIO_CAMERA_EnableRxDMA(base, true); status = kStatus_Success; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will resume all suspended threads in the IPC object list, including the suspended list of IPC object, and private list of mailbox etc. */
rt_inline rt_err_t _ipc_list_resume_all(rt_list_t *list)
/* This function will resume all suspended threads in the IPC object list, including the suspended list of IPC object, and private list of mailbox etc. */ rt_inline rt_err_t _ipc_list_resume_all(rt_list_t *list)
{ struct rt_thread *thread; while (!rt_list_isempty(list)) { thread = rt_list_entry(list->next, struct rt_thread, tlist); thread->error = -RT_ERROR; rt_thread_resume(thread); } return RT_EOK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If 8-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI MmioBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
/* If 8-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT8 EFIAPI MmioBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
{ return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit); }
tianocore/edk2
C++
Other
4,240
/* This is a stub for the status callback. The stub is here in case the upper layers do not set the handler. */
void StubHandler(const void *CallBackRef, u32 Bank, u32 Status)
/* This is a stub for the status callback. The stub is here in case the upper layers do not set the handler. */ void StubHandler(const void *CallBackRef, u32 Bank, u32 Status)
{ (void) CallBackRef; (void) Bank; (void) Status; Xil_AssertVoidAlways(); } /** @}
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base LPSPI peripheral address. param handle LPSPI handle pointer to lpspi_master_handle_t. param callback DSPI callback. param userData callback function parameter. */
void LPSPI_MasterTransferCreateHandle(LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_master_transfer_callback_t callback, void *userData)
/* param base LPSPI peripheral address. param handle LPSPI handle pointer to lpspi_master_handle_t. param callback DSPI callback. param userData callback function parameter. */ void LPSPI_MasterTransferCreateHandle(LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_master_transfer_callback_t callback, void *userData)
{ assert(handle); memset(handle, 0, sizeof(*handle)); s_lpspiHandle[LPSPI_GetInstance(base)] = handle; s_lpspiMasterIsr = LPSPI_MasterTransferHandleIRQ; handle->callback = callback; handle->userData = userData; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64ToUintn(IN INT64 Operand, OUT UINTN *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt64ToUintn(IN INT64 Operand, OUT UINTN *Result)
{ return SafeInt64ToUint64 (Operand, (UINT64 *)Result); }
tianocore/edk2
C++
Other
4,240
/* Get the event buffer allocated to send the connection complete event when we are initiating. */
static uint8_t* ble_ll_init_get_conn_comp_ev(void)
/* Get the event buffer allocated to send the connection complete event when we are initiating. */ static uint8_t* ble_ll_init_get_conn_comp_ev(void)
{ uint8_t *evbuf; evbuf = g_ble_ll_conn_comp_ev; BLE_LL_ASSERT(evbuf != NULL); g_ble_ll_conn_comp_ev = NULL; return evbuf; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Rport is being deleted. FC-4s are offline. LOGO is being sent. */
static void bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport, enum rport_event event)
/* Rport is being deleted. FC-4s are offline. LOGO is being sent. */ static void bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport, enum rport_event event)
{ bfa_trc(rport->fcs, rport->pwwn); bfa_trc(rport->fcs, rport->pid); bfa_trc(rport->fcs, event); switch (event) { case RPSM_EVENT_FCXP_SENT: bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit); bfa_fcs_rport_free(rport); break; case RPSM_EVENT_SCN: case RPSM_EVENT_ADDRESS_CHANGE: break; case RPSM_EVENT_LOGO_RCVD: bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit); bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rport->fcxp_wqe); bfa_fcs_rport_free(rport); break; default: bfa_assert(0); } }
robutest/uclinux
C++
GPL-2.0
60
/* This will un-registers device and driver to the kernel, frees requested irq handler and de-allocates memory allocated for channel objects. */
static void vpif_cleanup(void)
/* This will un-registers device and driver to the kernel, frees requested irq handler and de-allocates memory allocated for channel objects. */ static void vpif_cleanup(void)
{ struct platform_device *pdev; struct resource *res; int irq_num; int i = 0; pdev = container_of(vpif_dev, struct platform_device, dev); while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, i))) { for (irq_num = res->start; irq_num <= res->end; irq_num++) free_irq(irq_num, (void *)(&vpif_obj.dev[i]->channel_id)); i++; } platform_driver_unregister(&vpif_driver); kfree(vpif_obj.sd); for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) kfree(vpif_obj.dev[i]); }
robutest/uclinux
C++
GPL-2.0
60
/* Commence loading the multicast list. This is called when the kernel changes the lists. It will override any pending list we are trying to load. */
static void mc32_set_multicast_list(struct net_device *dev)
/* Commence loading the multicast list. This is called when the kernel changes the lists. It will override any pending list we are trying to load. */ static void mc32_set_multicast_list(struct net_device *dev)
{ do_mc32_set_multicast_list(dev,0); }
robutest/uclinux
C++
GPL-2.0
60
/* SYSCTRL DFLASH Bus&Memory Clock Disable and Reset Assert. */
void LL_SYSCTRL_DFLASH_ClkDisRstAssert(void)
/* SYSCTRL DFLASH Bus&Memory Clock Disable and Reset Assert. */ void LL_SYSCTRL_DFLASH_ClkDisRstAssert(void)
{ __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); __LL_SYSCTRL_DFLASHBusClk_Dis(SYSCTRL); __LL_SYSCTRL_DFLASHMemClk_Dis(SYSCTRL); __LL_SYSCTRL_DFLASHSoftRst_Assert(SYSCTRL); __LL_SYSCTRL_Reg_Lock(SYSCTRL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* internal worker function to load and run an image in the current shell. */
EFI_STATUS InternalShellExecute(IN CONST CHAR16 *CommandLine OPTIONAL, IN CONST CHAR16 **Environment OPTIONAL, OUT EFI_STATUS *StartImageStatus OPTIONAL)
/* internal worker function to load and run an image in the current shell. */ EFI_STATUS InternalShellExecute(IN CONST CHAR16 *CommandLine OPTIONAL, IN CONST CHAR16 **Environment OPTIONAL, OUT EFI_STATUS *StartImageStatus OPTIONAL)
{ EFI_STATUS Status; EFI_STATUS CleanupStatus; LIST_ENTRY OrigEnvs; InitializeListHead (&OrigEnvs); if (Environment != NULL) { Status = GetEnvironmentVariableList (&OrigEnvs); if (!EFI_ERROR (Status)) { Status = SetEnvironmentVariables (Environment); } else { return Status; } } Status = RunShellCommand (CommandLine, StartImageStatus); if (!IsListEmpty (&OrigEnvs)) { CleanupStatus = SetEnvironmentVariableList (&OrigEnvs); ASSERT_EFI_ERROR (CleanupStatus); } return (Status); }
tianocore/edk2
C++
Other
4,240
/* Get an averaged function value. This utility returns the average of a specified number of function values. */
static int32_t average(func callback, T arg, int M=25)
/* Get an averaged function value. This utility returns the average of a specified number of function values. */ static int32_t average(func callback, T arg, int M=25)
{ float avg = 0; for (int j = M; j > 0; --j) { avg += callback(arg); delay_ms(5); } return (int32_t)((avg / M) + 0.5); }
memfault/zero-to-main
C++
null
200
/* Clear the Hash registers for the mac address pointed by AddressPtr. */
void XEmacPs_ClearHash(XEmacPs *InstancePtr)
/* Clear the Hash registers for the mac address pointed by AddressPtr. */ void XEmacPs_ClearHash(XEmacPs *InstancePtr)
{ Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY); XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_HASHL_OFFSET, 0x0U); XEmacPs_WriteReg(InstancePtr->Config.BaseAddress, XEMACPS_HASHH_OFFSET, 0x0U); }
ua1arn/hftrx
C++
null
69
/* Create or reuse a zero-terminated string, first checking in the cache (using the string address as a key). The cache can contain only zero-terminated strings, so it is safe to use 'strcmp' to check hits. */
TString* luaS_new(lua_State *L, const char *str)
/* Create or reuse a zero-terminated string, first checking in the cache (using the string address as a key). The cache can contain only zero-terminated strings, so it is safe to use 'strcmp' to check hits. */ TString* luaS_new(lua_State *L, const char *str)
{ if (strcmp(str, getstr(p[j])) == 0) return p[j]; } for (j = STRCACHE_M - 1; j > 0; j--) p[j] = p[j - 1]; p[0] = luaS_newlstr(L, str, strlen(str)); return p[0]; }
Nicholas3388/LuaNode
C++
Other
1,055
/* NOTE: using list_empty_careful() without synchronization can only be safe if the only activity that can happen to the list entry is list_del_init(). Eg. it cannot be used if another CPU could re-list_add() it. */
static int list_empty_careful(const struct list_head *head)
/* NOTE: using list_empty_careful() without synchronization can only be safe if the only activity that can happen to the list entry is list_del_init(). Eg. it cannot be used if another CPU could re-list_add() it. */ static int list_empty_careful(const struct list_head *head)
{ struct list_head *next = head->next; return (next == head) && (next == head->prev); }
robutest/uclinux
C++
GPL-2.0
60
/* Enable clock and set baud rate, parity etc. */
void pxa_setbrg_dev(uint32_t uart_index)
/* Enable clock and set baud rate, parity etc. */ void pxa_setbrg_dev(uint32_t uart_index)
{ struct pxa_uart_regs *uart_regs = pxa_uart_index_to_regs(uart_index); if (!uart_regs) panic("Failed getting UART registers\n"); pxa_setbrg_common(uart_regs, uart_index, gd->baudrate); }
4ms/stm32mp1-baremetal
C++
Other
137
/* megasas_enable_intr_skinny - Enables interrupts @regs: MFI register set */
static void megasas_enable_intr_skinny(struct megasas_register_set __iomem *regs)
/* megasas_enable_intr_skinny - Enables interrupts @regs: MFI register set */ static void megasas_enable_intr_skinny(struct megasas_register_set __iomem *regs)
{ writel(0xFFFFFFFF, &(regs)->outbound_intr_mask); writel(~MFI_SKINNY_ENABLE_INTERRUPT_MASK, &(regs)->outbound_intr_mask); readl(&regs->outbound_intr_mask); }
robutest/uclinux
C++
GPL-2.0
60
/* If the return value from GetPerformanceCounterProperties (TimerLib) is zero, this function will return 10 and attempt to assert. */
STATIC UINT32 CalculateMinimumDecentDelayInMicroseconds(VOID)
/* If the return value from GetPerformanceCounterProperties (TimerLib) is zero, this function will return 10 and attempt to assert. */ STATIC UINT32 CalculateMinimumDecentDelayInMicroseconds(VOID)
{ UINT64 CounterHz; CounterHz = GetPerformanceCounterProperties (NULL, NULL); if (CounterHz == 0) { ASSERT (CounterHz != 0); return DEFAULT_DELAY_TIME_IN_MICROSECONDS; } return (UINT32)(MAX (DivU64x64Remainder (1500000, CounterHz, NULL), 1)); }
tianocore/edk2
C++
Other
4,240
/* History X.25 001 Jonathan Naylor Started coding. X.25 002 Jonathan Naylor New timer architecture. Centralised disconnection processing. */
static void x25_heartbeat_expiry(unsigned long)
/* History X.25 001 Jonathan Naylor Started coding. X.25 002 Jonathan Naylor New timer architecture. Centralised disconnection processing. */ static void x25_heartbeat_expiry(unsigned long)
{ struct sock *sk = (struct sock *)param; bh_lock_sock(sk); if (sock_owned_by_user(sk)) goto restart_heartbeat; switch (x25_sk(sk)->state) { case X25_STATE_0: if (sock_flag(sk, SOCK_DESTROY) || (sk->sk_state == TCP_LISTEN && sock_flag(sk, SOCK_DEAD))) { bh_unlock_sock(sk); x25_destroy_socket_from_timer(sk); return; } break; case X25_STATE_3: x25_check_rbuf(sk); break; } restart_heartbeat: x25_start_heartbeat(sk); bh_unlock_sock(sk); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function calculates how much "real data" is stored in @buf and returnes the length. Continuous 0xFF bytes at the end of the buffer are not considered as "real data". */
int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length)
/* This function calculates how much "real data" is stored in @buf and returnes the length. Continuous 0xFF bytes at the end of the buffer are not considered as "real data". */ int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length)
{ int i; ubi_assert(!(length & (ubi->min_io_size - 1))); for (i = length - 1; i >= 0; i--) if (((const uint8_t *)buf)[i] != 0xFF) break; length = ALIGN(i + 1, ubi->min_io_size); return length; }
EmcraftSystems/u-boot
C++
Other
181
/* param base FlexIO I2S peripheral base address. param handle FlexIO I2S DMA handle pointer. param count Bytes sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */
status_t FLEXIO_I2S_TransferGetSendCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle, size_t *count)
/* param base FlexIO I2S peripheral base address. param handle FlexIO I2S DMA handle pointer. param count Bytes sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */ status_t FLEXIO_I2S_TransferGetSendCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle, size_t *count)
{ assert(handle != NULL); status_t status = kStatus_Success; if (handle->state != (uint32_t)kFLEXIO_I2S_Busy) { status = kStatus_NoTransferInProgress; } else { *count = handle->transferSize[handle->queueDriver] - (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->dmaHandle->base, handle->dmaHandle->channel); } return status; }
eclipse-threadx/getting-started
C++
Other
310
/* Registers an interrupt handler for the uDMA controller. */
void uDMAIntRegister(unsigned long ulIntChannel, void(*pfnHandler)(void))
/* Registers an interrupt handler for the uDMA controller. */ void uDMAIntRegister(unsigned long ulIntChannel, void(*pfnHandler)(void))
{ ASSERT(pfnHandler); ASSERT((ulIntChannel == UDMA_INT_SW) || (ulIntChannel == UDMA_INT_ERR)); IntRegister(ulIntChannel, pfnHandler); IntEnable(ulIntChannel); }
watterott/WebRadio
C++
null
71
/* Return: 0 if wait succeeded, -ve if error occurred */
static int aux_wait_ready(struct udevice *dev)
/* Return: 0 if wait succeeded, -ve if error occurred */ static int aux_wait_ready(struct udevice *dev)
{ int status; u32 timeout = 100; do { status = get_reg(dev, REG_INTERRUPT_SIG_STATE); if (!timeout--) return -ETIMEDOUT; udelay(20); } while (status & REPLY_STATUS_REPLY_IN_PROGRESS_MASK); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
{ return PciCf8AndThenOr32 (Address, AndData, OrData); }
tianocore/edk2
C++
Other
4,240
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeIntnAdd(IN INTN Augend, IN INTN Addend, OUT INTN *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeIntnAdd(IN INTN Augend, IN INTN Addend, OUT INTN *Result)
{ return SafeInt64ToIntn (((INT64)Augend) + ((INT64)Addend), Result); }
tianocore/edk2
C++
Other
4,240
/* Configures the MMC to stop rollover. Programs MMC interface so that counters will not rollover after reaching maximum value. */
void synopGMAC_mmc_counters_disable_rollover(synopGMACdevice *gmacdev)
/* Configures the MMC to stop rollover. Programs MMC interface so that counters will not rollover after reaching maximum value. */ void synopGMAC_mmc_counters_disable_rollover(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev->MacBase, GmacMmcCntrl, GmacMmcCounterStopRollover); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the interrupt number for a specified USB module. */
static uint32_t _USBIntNumberGet(uint32_t ui32Base)
/* Returns the interrupt number for a specified USB module. */ static uint32_t _USBIntNumberGet(uint32_t ui32Base)
{ uint32_t ui32Int; if(CLASS_IS_TM4C123) { ui32Int = INT_USB0_TM4C123; } else if(CLASS_IS_TM4C129) { ui32Int = INT_USB0_TM4C129; } else { ui32Int = 0; } return(ui32Int); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* get the lowest address of the multi-segment block. */
static unsigned long dcssblk_find_lowest_addr(struct dcssblk_dev_info *dev_info)
/* get the lowest address of the multi-segment block. */ static unsigned long dcssblk_find_lowest_addr(struct dcssblk_dev_info *dev_info)
{ int set_first; unsigned long lowest_addr; struct segment_info *entry; set_first = 0; lowest_addr = 0; list_for_each_entry(entry, &dev_info->seg_list, lh) { if (set_first == 0) { lowest_addr = entry->start; set_first = 1; } else { if (lowest_addr > entry->start) lowest_addr = entry->start; } } return lowest_addr; }
robutest/uclinux
C++
GPL-2.0
60
/* each gpio can serve for 4 different purposes . These are called "functions" and passed in the parameter func. Functions 0-2 are always some special things, function 3 is GPIO. If func == 3 dir specifies input or output, and with inv you can enable an inverter (independent of func). */
int __ns9360_gpio_configure(unsigned gpio, int dir, int inv, int func)
/* each gpio can serve for 4 different purposes . These are called "functions" and passed in the parameter func. Functions 0-2 are always some special things, function 3 is GPIO. If func == 3 dir specifies input or output, and with inv you can enable an inverter (independent of func). */ int __ns9360_gpio_configure(unsigned gpio, int dir, int inv, int func)
{ void __iomem *conf = ns9360_gpio_get_gconfaddr(gpio); u32 confval; confval = __raw_readl(conf); REGSETIM_IDX(confval, BBU_GCONFx, DIR, gpio & 7, dir); REGSETIM_IDX(confval, BBU_GCONFx, INV, gpio & 7, inv); REGSETIM_IDX(confval, BBU_GCONFx, FUNC, gpio & 7, func); __raw_writel(confval, conf); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Calculate SDTR code bytes , from period and offset. */
static void calc_sync_msg(unsigned int period, unsigned int offset, unsigned int fast, uchar msg[2])
/* Calculate SDTR code bytes , from period and offset. */ static void calc_sync_msg(unsigned int period, unsigned int offset, unsigned int fast, uchar msg[2])
{ period /= 4; if (offset && fast) period /= 2; msg[0] = period; msg[1] = offset; }
robutest/uclinux
C++
GPL-2.0
60
/* Sets up the SysTick timer for 1ms interrupts and initializes and starts the RTC timer. */
uint32_t UTIL_init(void)
/* Sets up the SysTick timer for 1ms interrupts and initializes and starts the RTC timer. */ uint32_t UTIL_init(void)
{ uint32_t stat; uint32_t ticks; ticks = CMU_ClockFreqGet( cmuClock_CORE ) / 1000; stat = SysTick_Config( ticks ); return stat; }
remotemcu/remcu-chip-sdks
C++
null
436
/* If 8-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI MmioBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
/* If 8-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT8 EFIAPI MmioBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
{ return MmioWrite8 ( Address, BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData) ); }
tianocore/edk2
C++
Other
4,240
/* Configures the number of data to transfer type(Even/Odd) for the DMA last transfers and for the selected SPI. */
void SPI_LastDMATransferCmd(SPI_TypeDef *SPIx, uint16_t SPI_LastDMATransfer)
/* Configures the number of data to transfer type(Even/Odd) for the DMA last transfers and for the selected SPI. */ void SPI_LastDMATransferCmd(SPI_TypeDef *SPIx, uint16_t SPI_LastDMATransfer)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_LAST_DMA_TRANSFER(SPI_LastDMATransfer)); SPIx->CR2 &= CR2_LDMA_MASK; SPIx->CR2 |= SPI_LastDMATransfer; }
ajhc/demo-cortex-m3
C++
null
38
/* Since fuse doesn't rely on the VM writeback tracking, this has to use some other means. */
static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
/* Since fuse doesn't rely on the VM writeback tracking, this has to use some other means. */ static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
{ struct fuse_inode *fi = get_fuse_inode(inode); wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index)); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* param base The I3C peripheral base address. param txBuff The pointer to the data to be transferred. param txSize The length in bytes of the data to be transferred. return Error or success status returned by API. */
status_t I3C_SlaveSend(I3C_Type *base, const void *txBuff, size_t txSize)
/* param base The I3C peripheral base address. param txBuff The pointer to the data to be transferred. param txSize The length in bytes of the data to be transferred. return Error or success status returned by API. */ status_t I3C_SlaveSend(I3C_Type *base, const void *txBuff, size_t txSize)
{ const uint8_t *buf = (const uint8_t *)((const void *)txBuff); status_t result = kStatus_Success; assert(NULL != txBuff); while (0UL != txSize--) { result = I3C_SlaveWaitForTxReady(base); if (kStatus_Success != result) { return result; } if (0UL != txSize) { base->SWDATAB = *buf++; } else { base->SWDATABE = *buf++; } } return result; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM1) { __HAL_RCC_TIM1_CLK_DISABLE(); } else if(htim_base->Instance==TIM4) { __HAL_RCC_TIM4_CLK_DISABLE(); } else if(htim_base->Instance==TIM5) { __HAL_RCC_TIM5_CLK_DISABLE(); } else if(htim_base->Instance==TIM8) { __HAL_RCC_TIM8_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Here we define a transistion notifier so that we can update all of our ports' baud rate when the peripheral clock changes. */
static int sci_notifier(struct notifier_block *self, unsigned long phase, void *p)
/* Here we define a transistion notifier so that we can update all of our ports' baud rate when the peripheral clock changes. */ static int sci_notifier(struct notifier_block *self, unsigned long phase, void *p)
{ struct sh_sci_priv *priv = container_of(self, struct sh_sci_priv, clk_nb); struct sci_port *sci_port; unsigned long flags; if ((phase == CPUFREQ_POSTCHANGE) || (phase == CPUFREQ_RESUMECHANGE)) { spin_lock_irqsave(&priv->lock, flags); list_for_each_entry(sci_port, &priv->ports, node) sci_port->port.uartclk = clk_get_rate(sci_port->dclk); spin_unlock_irqrestore(&priv->lock, flags); } return NOTIFY_OK; }
robutest/uclinux
C++
GPL-2.0
60
/* We have a separate function, don't assume that the chain can't be reused. */
int tsi148_dma_list_empty(struct vme_dma_list *)
/* We have a separate function, don't assume that the chain can't be reused. */ int tsi148_dma_list_empty(struct vme_dma_list *)
{ struct list_head *pos, *temp; struct tsi148_dma_entry *entry; list_for_each_safe(pos, temp, &(list->entries)) { list_del(pos); entry = list_entry(pos, struct tsi148_dma_entry, list); kfree(entry); } return (0); }
robutest/uclinux
C++
GPL-2.0
60
/* Enable I2C module of the specified I2C port. The */
void I2CEnable(unsigned long ulBase)
/* Enable I2C module of the specified I2C port. The */ void I2CEnable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE)); xHWREG(ulBase + I2C_O_CON) |= I2C_CON_ENS1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Use the VMGEXIT instruction to handle a MWAIT event. */
STATIC UINT64 MwaitExit(IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN CC_INSTRUCTION_DATA *InstructionData)
/* Use the VMGEXIT instruction to handle a MWAIT event. */ STATIC UINT64 MwaitExit(IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN CC_INSTRUCTION_DATA *InstructionData)
{ CcDecodeModRm (Regs, InstructionData); Ghcb->SaveArea.Rax = Regs->Rax; CcExitVmgSetOffsetValid (Ghcb, GhcbRax); Ghcb->SaveArea.Rcx = Regs->Rcx; CcExitVmgSetOffsetValid (Ghcb, GhcbRcx); return CcExitVmgExit (Ghcb, SVM_EXIT_MWAIT, 0, 0); }
tianocore/edk2
C++
Other
4,240
/* Configure the TPIU based on the values in the configuration struct. */
void am_hal_tpiu_configure(am_hal_tpiu_config_t *psConfig)
/* Configure the TPIU based on the values in the configuration struct. */ void am_hal_tpiu_configure(am_hal_tpiu_config_t *psConfig)
{ AM_REG(MCUCTRL, TPIUCTRL) |= psConfig->ui32TraceClkIn; AM_REG(TPIU, SPPR) = psConfig->ui32PinProtocol; AM_REG(TPIU, CSPSR) = (1 << (psConfig->ui32ParallelPortSize - 1)); AM_REG(TPIU, ACPR) = psConfig->ui32ClockPrescaler; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Gets the captured data for a sample sequence. */
int32_t ADCSequenceDataGet(uint32_t ui32Base, uint32_t ui32SequenceNum, uint32_t *pui32Buffer)
/* Gets the captured data for a sample sequence. */ int32_t ADCSequenceDataGet(uint32_t ui32Base, uint32_t ui32SequenceNum, uint32_t *pui32Buffer)
{ uint32_t ui32Count; ASSERT((ui32Base == ADC0_BASE) || (ui32Base == ADC1_BASE)); ASSERT(ui32SequenceNum < 4); ui32Base += ADC_SEQ + (ADC_SEQ_STEP * ui32SequenceNum); ui32Count = 0; while (!(HWREG(ui32Base + ADC_SSFSTAT) & ADC_SSFSTAT0_EMPTY) && (ui32Count < 8)) { *pui32Buffer++ = HWREG(ui32Base + ADC_SSFIFO); ui32Count++; } return (ui32Count); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable or disable the specified hardware capture condition. */
void TMR2_HWCaptureCondCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Cond, en_functional_state_t enNewState)
/* Enable or disable the specified hardware capture condition. */ void TMR2_HWCaptureCondCmd(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_CAPT_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_BIT(TMR2x->HCONR, u32Cond); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Search the most top object which fully covers an area */
static lv_obj_t * lv_refr_get_top_obj(const lv_area_t *area_p, lv_obj_t *obj)
/* Search the most top object which fully covers an area */ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t *area_p, lv_obj_t *obj)
{ lv_obj_t * i; lv_obj_t * found_p = NULL; if(lv_area_is_in(area_p, &obj->coords) && obj->hidden == 0) { LL_READ(obj->child_ll, i) { found_p = lv_refr_get_top_obj(area_p, i); if(found_p != NULL) { break; } } if(found_p == NULL) { lv_style_t * style = lv_obj_get_style(obj); if(style->body.opa == LV_OPA_COVER && obj->design_func(obj, area_p, LV_DESIGN_COVER_CHK) != false && lv_obj_get_opa_scale(obj) == LV_OPA_COVER) { found_p = obj; } } } return found_p; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Set user data to the specified Data Backup Register. */
void BAKPR_ConfigBackupRegister(BAKPR_DATA_T bakrData, uint16_t data)
/* Set user data to the specified Data Backup Register. */ void BAKPR_ConfigBackupRegister(BAKPR_DATA_T bakrData, uint16_t data)
{ __IOM uint32_t tmp = 0; tmp = (uint32_t)BAKPR_BASE; tmp += bakrData; *(__IOM uint32_t*) tmp = data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* lis2du12_handle_interrupt - handle the drdy event read data and call handler if registered any */
static void lis2du12_handle_interrupt(const struct device *dev)
/* lis2du12_handle_interrupt - handle the drdy event read data and call handler if registered any */ static void lis2du12_handle_interrupt(const struct device *dev)
{ struct lis2du12_data *lis2du12 = dev->data; const struct lis2du12_config *cfg = dev->config; stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; lis2du12_status_t status; while (1) { if (lis2du12_status_get(ctx, &status) < 0) { LOG_ERR("failed reading status reg"); return; } if (status.drdy_xl == 0) { break; } if ((status.drdy_xl) && (lis2du12->handler_drdy_acc != NULL)) { lis2du12->handler_drdy_acc(dev, lis2du12->trig_drdy_acc); } } gpio_pin_interrupt_configure_dt(lis2du12->drdy_gpio, GPIO_INT_EDGE_TO_ACTIVE); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* We don't want to start the secondary CPU yet nor do we have a nice probing feature in PMON so we just assume presence of the secondary core. */
static void __init yos_smp_setup(void)
/* We don't want to start the secondary CPU yet nor do we have a nice probing feature in PMON so we just assume presence of the secondary core. */ static void __init yos_smp_setup(void)
{ int i; cpus_clear(cpu_possible_map); for (i = 0; i < 2; i++) { cpu_set(i, cpu_possible_map); __cpu_number_map[i] = i; __cpu_logical_map[i] = i; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* convert_state() - Converts the peer's view of the cluster state to our point of view @ps: The state as seen by the peer. */
static union drbd_state convert_state(union drbd_state ps)
/* convert_state() - Converts the peer's view of the cluster state to our point of view @ps: The state as seen by the peer. */ static union drbd_state convert_state(union drbd_state ps)
{ union drbd_state ms; static enum drbd_conns c_tab[] = { [C_CONNECTED] = C_CONNECTED, [C_STARTING_SYNC_S] = C_STARTING_SYNC_T, [C_STARTING_SYNC_T] = C_STARTING_SYNC_S, [C_DISCONNECTING] = C_TEAR_DOWN, [C_VERIFY_S] = C_VERIFY_T, [C_MASK] = C_MASK, }; ms.i = ps.i; ms.conn = c_tab[ps.conn]; ms.peer = ps.role; ms.role = ps.peer; ms.pdsk = ps.disk; ms.disk = ps.pdsk; ms.peer_isp = (ps.aftr_isp | ps.user_isp); return ms; }
robutest/uclinux
C++
GPL-2.0
60
/* Check if Transmit buffer empty interrupt is enabled @rmtoll IER TXBEIE LL_SWPMI_IsEnabledIT_TXBE. */
uint32_t LL_SWPMI_IsEnabledIT_TXBE(SWPMI_TypeDef *SWPMIx)
/* Check if Transmit buffer empty interrupt is enabled @rmtoll IER TXBEIE LL_SWPMI_IsEnabledIT_TXBE. */ uint32_t LL_SWPMI_IsEnabledIT_TXBE(SWPMI_TypeDef *SWPMIx)
{ return ((READ_BIT(SWPMIx->IER, SWPMI_IER_TXBEIE) == (SWPMI_IER_TXBEIE)) ? 1UL : 0UL); }
remotemcu/remcu-chip-sdks
C++
null
436
/* If in the ESTABLISHED state, move to CLOSING. */
static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv, struct iw_cm_event *iw_event)
/* If in the ESTABLISHED state, move to CLOSING. */ static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv, struct iw_cm_event *iw_event)
{ unsigned long flags; spin_lock_irqsave(&cm_id_priv->lock, flags); if (cm_id_priv->state == IW_CM_STATE_ESTABLISHED) cm_id_priv->state = IW_CM_STATE_CLOSING; spin_unlock_irqrestore(&cm_id_priv->lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* acpiphp_max_busnr - return the highest reserved bus number under the given bus. @bus: bus to start search with */
static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
/* acpiphp_max_busnr - return the highest reserved bus number under the given bus. @bus: bus to start search with */ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
{ struct list_head *tmp; unsigned char max, n; max = bus->secondary; list_for_each(tmp, &bus->children) { n = pci_bus_max_busnr(pci_bus_b(tmp)); if (n > max) max = n; } return max; }
robutest/uclinux
C++
GPL-2.0
60
/* eeh_report_reset - tell device that slot has been reset */
static int eeh_report_reset(struct pci_dev *dev, void *userdata)
/* eeh_report_reset - tell device that slot has been reset */ static int eeh_report_reset(struct pci_dev *dev, void *userdata)
{ enum pci_ers_result rc, *res = userdata; struct pci_driver *driver = dev->driver; if (!driver) return 0; dev->error_state = pci_channel_io_normal; eeh_enable_irq(dev); if (!driver->err_handler || !driver->err_handler->slot_reset) return 0; rc = driver->err_handler->slot_reset(dev); if ((*res == PCI_ERS_RESULT_NONE) || (*res == PCI_ERS_RESULT_RECOVERED)) *res = rc; if (*res == PCI_ERS_RESULT_DISCONNECT && rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* We send to all registered managers regardless of failure We are happy with one success */
int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol)
/* We send to all registered managers regardless of failure We are happy with one success */ int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol)
{ int err = -EINVAL, acqret; struct xfrm_mgr *km; read_lock(&xfrm_km_lock); list_for_each_entry(km, &xfrm_km_list, list) { acqret = km->acquire(x, t, pol, XFRM_POLICY_OUT); if (!acqret) err = acqret; } read_unlock(&xfrm_km_lock); return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set up TTY audit state in @sig from current. @sig needs no locking. */
void tty_audit_fork(struct signal_struct *sig)
/* Set up TTY audit state in @sig from current. @sig needs no locking. */ void tty_audit_fork(struct signal_struct *sig)
{ spin_lock_irq(&current->sighand->siglock); sig->audit_tty = current->signal->audit_tty; spin_unlock_irq(&current->sighand->siglock); sig->tty_audit_buf = NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* ZSTD_initDDict() : Create a digested dictionary, to start decompression without startup delay. */
ZSTD_DDict* ZSTD_initDDict(const void *dict, size_t dictSize, void *workspace, size_t workspaceSize)
/* ZSTD_initDDict() : Create a digested dictionary, to start decompression without startup delay. */ ZSTD_DDict* ZSTD_initDDict(const void *dict, size_t dictSize, void *workspace, size_t workspaceSize)
{ ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); return ZSTD_createDDict_advanced(dict, dictSize, 1, stackMem); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details. */
EFI_STATUS EmmcSwitchToHS200(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN SD_MMC_BUS_SETTINGS *BusMode)
/* Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details. */ EFI_STATUS EmmcSwitchToHS200(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN SD_MMC_BUS_SETTINGS *BusMode)
{ EFI_STATUS Status; if ((BusMode->BusTiming != SdMmcMmcHs200) || ((BusMode->BusWidth != 4) && (BusMode->BusWidth != 8))) { return EFI_INVALID_PARAMETER; } Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, FALSE, BusMode->BusWidth); if (EFI_ERROR (Status)) { return Status; } Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength, BusMode->BusTiming, BusMode->ClockFreq); if (EFI_ERROR (Status)) { return Status; } Status = EmmcTuningClkForHs200 (PciIo, PassThru, Slot, BusMode->BusWidth); return Status; }
tianocore/edk2
C++
Other
4,240
/* Wait until DAC channel is ready to receive data. */
void dac_wait_on_ready(uint32_t dac, int channel)
/* Wait until DAC channel is ready to receive data. */ void dac_wait_on_ready(uint32_t dac, int channel)
{ while (!dac_is_ready(dac, channel)); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Set active to 1 if the dimension at position i is involved in the linear expression l. */
int* isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l)
/* Set active to 1 if the dimension at position i is involved in the linear expression l. */ int* isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l)
{ int i, j; isl_ctx *ctx; int *active = NULL; unsigned total; unsigned offset; ctx = isl_local_space_get_ctx(ls); total = isl_local_space_dim(ls, isl_dim_all); active = isl_calloc_array(ctx, int, total); if (!active) return NULL; for (i = 0; i < total; ++i) active[i] = !isl_int_is_zero(l[i]); offset = isl_local_space_offset(ls, isl_dim_div) - 1; for (i = ls->div->n_row - 1; i >= 0; --i) { if (!active[offset + i]) continue; for (j = 0; j < total; ++j) active[j] |= !isl_int_is_zero(ls->div->row[i][2 + j]); } return active; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The standard atomic.h primitives don't quite do what we want here: We need an atomic add-and-return-previous-value (which could be done with atomic_add_return and a decrement) and an atomic set/zero-and-return-previous-value (which can't really be done with the atomic.h primitives). And since this is MIPS MT, we can assume that we have LL/SC. */
static int atomic_postincrement(atomic_t *v)
/* The standard atomic.h primitives don't quite do what we want here: We need an atomic add-and-return-previous-value (which could be done with atomic_add_return and a decrement) and an atomic set/zero-and-return-previous-value (which can't really be done with the atomic.h primitives). And since this is MIPS MT, we can assume that we have LL/SC. */ static int atomic_postincrement(atomic_t *v)
{ unsigned long result; unsigned long temp; __asm__ __volatile__( "1: ll %0, %2 \n" " addu %1, %0, 1 \n" " sc %1, %2 \n" " beqz %1, 1b \n" __WEAK_LLSC_MB : "=&r" (result), "=&r" (temp), "=m" (v->counter) : "m" (v->counter) : "memory"); return result; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If 64-bit I/O port operations are not supported, then ASSERT(). */
UINT64 EFIAPI IoWrite64(IN UINTN Port, IN UINT64 Value)
/* If 64-bit I/O port operations are not supported, then ASSERT(). */ UINT64 EFIAPI IoWrite64(IN UINTN Port, IN UINT64 Value)
{ ASSERT ((Port & 7) == 0); return IoWriteWorker (Port, EfiCpuIoWidthUint64, Value); }
tianocore/edk2
C++
Other
4,240
/* USBH_MTP_SOFProcess The function is for managing SOF callback. */
static USBH_StatusTypeDef USBH_MTP_SOFProcess(USBH_HandleTypeDef *phost)
/* USBH_MTP_SOFProcess The function is for managing SOF callback. */ static USBH_StatusTypeDef USBH_MTP_SOFProcess(USBH_HandleTypeDef *phost)
{ UNUSED(phost); return USBH_OK; }
ua1arn/hftrx
C++
null
69
/* Find the IGMP_GROUP structure which contains the status of multicast group Address in this IGMP control block */
IGMP_GROUP* Ip4FindGroup(IN IGMP_SERVICE_DATA *IgmpCtrl, IN IP4_ADDR Address)
/* Find the IGMP_GROUP structure which contains the status of multicast group Address in this IGMP control block */ IGMP_GROUP* Ip4FindGroup(IN IGMP_SERVICE_DATA *IgmpCtrl, IN IP4_ADDR Address)
{ LIST_ENTRY *Entry; IGMP_GROUP *Group; NET_LIST_FOR_EACH (Entry, &IgmpCtrl->Groups) { Group = NET_LIST_USER_STRUCT (Entry, IGMP_GROUP, Link); if (Group->Address == Address) { return Group; } } return NULL; }
tianocore/edk2
C++
Other
4,240