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
/* Create a directory with the given prefix (e.g. "wireshark"). The path is created using g_get_tmp_dir and mkdtemp. */
const char* create_tempdir(char **namebuf, const char *pfx)
/* Create a directory with the given prefix (e.g. "wireshark"). The path is created using g_get_tmp_dir and mkdtemp. */ const char* create_tempdir(char **namebuf, const char *pfx)
{ static char *td_path[3]; static int td_path_len[3]; static int idx; const char *tmp_dir; idx = (idx + 1) % 3; if (td_path[idx] == NULL) { td_path_len[idx] = INITIAL_PATH_SIZE; td_path[idx] = (char *)g_malloc(td_path_len[idx]); } tmp_dir = g_get_tmp_dir(); while (g_snprintf(td_path[idx], td_path_len[idx], "%s%c%s" TMP_FILE_SUFFIX, tmp_dir, G_DIR_SEPARATOR, pfx) > td_path_len[idx]) { td_path_len[idx] *= 2; td_path[idx] = (char *)g_realloc(td_path[idx], td_path_len[idx]); } if (namebuf) { *namebuf = td_path[idx]; } return mkdtemp(td_path[idx]); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get a GUID identifying the RNG algorithm implementation. */
EFI_STATUS EFIAPI GetRngGuid(GUID *RngGuid)
/* Get a GUID identifying the RNG algorithm implementation. */ EFI_STATUS EFIAPI GetRngGuid(GUID *RngGuid)
{ if (RngGuid == NULL) { return EFI_INVALID_PARAMETER; } CopyMem (RngGuid, &gEdkiiRngAlgorithmUnSafe, sizeof (*RngGuid)); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* param handle WM8904 handle structure. param reg register address. param value value to read. return kStatus_Success, else failed. */
status_t WM8904_ReadRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t *value)
/* param handle WM8904 handle structure. param reg register address. param value value to read. return kStatus_Success, else failed. */ status_t WM8904_ReadRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t *value)
{ assert(handle->config != NULL); assert(handle->config->slaveAddress != 0U); status_t retval = 0; uint16_t readValue = 0U; retval = CODEC_I2C_Receive(handle->i2cHandle, handle->config->slaveAddress, (uint32_t)reg, 1U, (uint8_t *)&readValue, 2U); *value = (uint16_t)WM8904_SWAP_UINT16_BYTE_SEQUENCE(readValue); return retval; }
eclipse-threadx/getting-started
C++
Other
310
/* Gets the count of storage security devices that one specific driver detects. */
EFI_STATUS EFIAPI AhciStorageSecurityGetDeviceNo(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, OUT UINTN *NumberofDevices)
/* Gets the count of storage security devices that one specific driver detects. */ EFI_STATUS EFIAPI AhciStorageSecurityGetDeviceNo(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, OUT UINTN *NumberofDevices)
{ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private; if ((This == NULL) || (NumberofDevices == NULL)) { return EFI_INVALID_PARAMETER; } Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This); *NumberofDevices = Private->TrustComputingDevices; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* brief DMA instance 0, channel 11 IRQ handler. */
void EDMA_0_CH11_DriverIRQHandler(void)
/* brief DMA instance 0, channel 11 IRQ handler. */ void EDMA_0_CH11_DriverIRQHandler(void)
{ EDMA_DriverIRQHandler(0U, 11U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Print the contents of a SETTINGS structure to the UEFI console. */
STATIC VOID PrintSettings(IN CONST SETTINGS *Settings)
/* Print the contents of a SETTINGS structure to the UEFI console. */ STATIC VOID PrintSettings(IN CONST SETTINGS *Settings)
{ AsciiPrint ( "info: SetupMode=%d SecureBoot=%d SecureBootEnable=%d " "CustomMode=%d VendorKeys=%d\n", Settings->SetupMode, Settings->SecureBoot, Settings->SecureBootEnable, Settings->CustomMode, Settings->VendorKeys ); }
tianocore/edk2
C++
Other
4,240
/* Concatenate two pbufs (each may be a pbuf chain) and take over the caller's reference of the tail pbuf. */
void pbuf_cat(struct pbuf *h, struct pbuf *t)
/* Concatenate two pbufs (each may be a pbuf chain) and take over the caller's reference of the tail pbuf. */ void pbuf_cat(struct pbuf *h, struct pbuf *t)
{ struct pbuf *p; LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)", ((h != NULL) && (t != NULL)), return;); for (p = h; p->next != NULL; p = p->next) { p->tot_len = (u16_t)(p->tot_len + t->tot_len); } LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); LWIP_ASSERT("p->next == NULL", p->next == NULL); p->tot_len = (u16_t)(p->tot_len + t->tot_len); p->next = t; }
ua1arn/hftrx
C++
null
69
/* Note 2: xchg has side effect, so that attribute volatile is necessary, but generally the primitive is invalid, *ptr is output argument. */
static unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
/* Note 2: xchg has side effect, so that attribute volatile is necessary, but generally the primitive is invalid, *ptr is output argument. */ static unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
{ switch (size) { case 1: __asm__ __volatile__("xchgb %b0,%1" : "=q" (x) : "m" (*__xg(ptr)), "0" (x) : "memory"); break; case 2: __asm__ __volatile__("xchgw %w0,%1" : "=r" (x) : "m" (*__xg(ptr)), "0" (x) : "memory"); break; case 4: __asm__ __volatile__("xchgl %0,%1" : "=r" (x) : "m" (*__xg(ptr)), "0" (x) : "memory"); break; } return x; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Deinitializes the COMP peripheral registers to their default reset values. */
void COMP_DeInit(void)
/* Deinitializes the COMP peripheral registers to their default reset values. */ void COMP_DeInit(void)
{ RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_COMP, ENABLE); RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_COMP, DISABLE); RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_COMP_FILT, ENABLE); RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_COMP_FILT, DISABLE); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Unlocks the FLASH control register and program memory access. */
void FLASH_Unlock(void)
/* Unlocks the FLASH control register and program memory access. */ void FLASH_Unlock(void)
{ if((FLASH->CR & FLASH_CR_LOCK) != RESET) { FLASH->KEYR = FLASH_FKEY1; FLASH->KEYR = FLASH_FKEY2; } }
ajhc/demo-cortex-m3
C++
null
38
/* This helper function locates the shared comm buffer and assigns it to input pointers. */
STATIC EFI_STATUS InitMmCommonCommBuffer(IN OUT UINTN *BufferSize, OUT VOID **LocatedBuffer)
/* This helper function locates the shared comm buffer and assigns it to input pointers. */ STATIC EFI_STATUS InitMmCommonCommBuffer(IN OUT UINTN *BufferSize, OUT VOID **LocatedBuffer)
{ EFI_STATUS Status; Status = EFI_SUCCESS; if ((BufferSize == NULL) || (LocatedBuffer == NULL)) { return EFI_INVALID_PARAMETER; } *LocatedBuffer = AllocateRuntimePool (*BufferSize); if (*LocatedBuffer == NULL) { Status = EFI_OUT_OF_RESOURCES; *BufferSize = 0; } EfiInitializeLock (&mMmCommunicationLock, TPL_NOTIFY); return Status; }
tianocore/edk2
C++
Other
4,240
/* Enables SIR (IrDA) mode on the specified UART. */
void UARTEnableIrDA(unsigned long ulBase)
/* Enables SIR (IrDA) mode on the specified UART. */ void UARTEnableIrDA(unsigned long ulBase)
{ xASSERT(UARTBaseValid(ulBase)); xHWREG(ulBase + UART_FUN_SEL) |= (UART_FUN_SEL_IRDA_EN); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Get the number of samples of an audio frame. Return -1 on error. */
static int get_audio_frame_size(AVCodecContext *enc, int size)
/* Get the number of samples of an audio frame. Return -1 on error. */ static int get_audio_frame_size(AVCodecContext *enc, int size)
{ int frame_size; if(enc->codec_id == CODEC_ID_VORBIS) return -1; if (enc->frame_size <= 1) { int bits_per_sample = av_get_bits_per_sample(enc->codec_id); if (bits_per_sample) { if (enc->channels == 0) return -1; frame_size = (size << 3) / (bits_per_sample * enc->channels); } else { if (enc->bit_rate == 0) return -1; frame_size = ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate; } } else { frame_size = enc->frame_size; } return frame_size; }
DC-SWAT/DreamShell
C++
null
404
/* This function gets called by the common i/o layer and sets an adapter into state offline. */
static int zfcp_ccw_set_offline(struct ccw_device *cdev)
/* This function gets called by the common i/o layer and sets an adapter into state offline. */ static int zfcp_ccw_set_offline(struct ccw_device *cdev)
{ struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev); if (!adapter) return 0; zfcp_erp_adapter_shutdown(adapter, 0, "ccsoff1", NULL); zfcp_erp_wait(adapter); zfcp_ccw_adapter_put(adapter); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Works only for STM32F429-Discovery board or STM324x9-EVAL board */
int main(void)
/* Works only for STM32F429-Discovery board or STM324x9-EVAL board */ int main(void)
{ } else { } Delayms(2000); write = 1234; TM_SDRAM_Write16(0x3214, write); read = TM_SDRAM_Read16(0x3214); if (write == read) { TM_DISCO_LedOff(LED_GREEN | LED_RED); for (i = 0; i < 10; i++) { TM_DISCO_LedToggle(LED_GREEN | LED_RED); Delayms(100); } } while (1) { } }
MaJerle/stm32f429
C++
null
2,036
/* Checks if a string is an alias for another command. If yes, then it replaces the alias name with the correct command name. */
EFI_STATUS ShellConvertAlias(IN OUT CHAR16 **CommandString)
/* Checks if a string is an alias for another command. If yes, then it replaces the alias name with the correct command name. */ EFI_STATUS ShellConvertAlias(IN OUT CHAR16 **CommandString)
{ CONST CHAR16 *NewString; NewString = ShellInfoObject.NewEfiShellProtocol->GetAlias (*CommandString, NULL); if (NewString == NULL) { return (EFI_SUCCESS); } FreePool (*CommandString); *CommandString = AllocateCopyPool (StrSize (NewString), NewString); if (*CommandString == NULL) { return (EFI_OUT_OF_RESOURCES); } return (EFI_SUCCESS); }
tianocore/edk2
C++
Other
4,240
/* Populates the static data buffer for this PRM module. */
EFI_STATUS PopulateStaticDataBuffer(OUT STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *StaticDataBuffer)
/* Populates the static data buffer for this PRM module. */ EFI_STATUS PopulateStaticDataBuffer(OUT STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *StaticDataBuffer)
{ if (StaticDataBuffer == NULL) { return EFI_INVALID_PARAMETER; } StaticDataBuffer->Policy1Enabled = TRUE; StaticDataBuffer->Policy2Enabled = FALSE; SetMem (StaticDataBuffer->SomeValueArray, ARRAY_SIZE (StaticDataBuffer->SomeValueArray), 'D'); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Output: void, but we will add to proto tree if !NULL. */
static void dissect_neighbor_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length)
/* Output: void, but we will add to proto tree if !NULL. */ static void dissect_neighbor_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length)
{ while (length > 0) { if (length < 6) { proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1, "Short neighbor entry"); return; } proto_tree_add_item(tree, hf_nlsp_neighbor, tvb, offset, 6, ENC_NA); offset += 6; length -= 6; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Internal function to PciCfg2 read/write opcode to the table. */
EFI_STATUS BootScriptWritePciCfg2ReadWrite(IN VA_LIST Marker)
/* Internal function to PciCfg2 read/write opcode to the table. */ EFI_STATUS BootScriptWritePciCfg2ReadWrite(IN VA_LIST Marker)
{ S3_BOOT_SCRIPT_LIB_WIDTH Width; UINT16 Segment; UINT64 Address; UINT8 *Data; UINT8 *DataMask; Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); Segment = VA_ARG (Marker, UINT16); Address = VA_ARG (Marker, UINT64); Data = VA_ARG (Marker, UINT8 *); DataMask = VA_ARG (Marker, UINT8 *); return S3BootScriptSavePciCfg2ReadWrite (Width, Segment, Address, Data, DataMask); }
tianocore/edk2
C++
Other
4,240
/* Note we also need a hook for this on i2400mu_rx() */
static size_t i2400mu_rx_size_grow(struct i2400mu *i2400mu)
/* Note we also need a hook for this on i2400mu_rx() */ static size_t i2400mu_rx_size_grow(struct i2400mu *i2400mu)
{ struct device *dev = &i2400mu->usb_iface->dev; size_t rx_size; const size_t max_pkt_size = 512; rx_size = 2 * i2400mu->rx_size; if (rx_size % max_pkt_size == 0) { rx_size -= 8; d_printf(1, dev, "RX: expected size grew to %zu [adjusted -8] " "from %zu\n", rx_size, i2400mu->rx_size); } else d_printf(1, dev, "RX: expected size grew to %zu from %zu\n", rx_size, i2400mu->rx_size); return rx_size; }
robutest/uclinux
C++
GPL-2.0
60
/* Purge the entire contents of the dcache. The most efficient way to achieve this is to use alloco instructions on a region of unused memory equal in size to the cache, thereby causing the current contents to be discarded by natural eviction. The alternative, namely reading every tag, setting up a mapping for the corresponding page and doing an OCBP for the line, would be much more expensive. */
static void sh64_dcache_purge_all(void)
/* Purge the entire contents of the dcache. The most efficient way to achieve this is to use alloco instructions on a region of unused memory equal in size to the cache, thereby causing the current contents to be discarded by natural eviction. The alternative, namely reading every tag, setting up a mapping for the corresponding page and doing an OCBP for the line, would be much more expensive. */ static void sh64_dcache_purge_all(void)
{ sh64_dcache_purge_sets(0, cpu_data->dcache.sets); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable the Capture of the PWM module. The */
void PWMCAPEnable(unsigned long ulBase, unsigned long ulChannel)
/* Enable the Capture of the PWM module. The */ void PWMCAPEnable(unsigned long ulBase, unsigned long ulChannel)
{ unsigned long ulChannelTemp; ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4); xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE)); xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3))); xHWREG(ulBase + PWM_CCR0 + (ulChannelTemp >> 1)*4) |= (PWM_CCR0_CAPCH0EN << ((ulChannel % 2) ? 16 : 0)); xHWREG(ulBase + PWM_PCR) |= (PWM_PCR_CH0EN << (ulChannelTemp << 3)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Selects the clock source to output on MCO pin. */
void RCC_ConfigMco(uint8_t RCC_MCO)
/* Selects the clock source to output on MCO pin. */ void RCC_ConfigMco(uint8_t RCC_MCO)
{ uint32_t tmpregister = 0; assert_param(IS_RCC_MCO(RCC_MCO)); tmpregister = RCC->CFG; tmpregister &= ((uint32_t)0xF8FFFFFF); tmpregister |= ((uint32_t)(RCC_MCO << 24)); RCC->CFG = tmpregister; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Enables or disables the I2C 10-bit header only mode with read direction. */
void I2C_10BitAddressHeaderCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables the I2C 10-bit header only mode with read direction. */ void I2C_10BitAddressHeaderCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->CR2 |= I2C_CR2_HEAD10R; } else { I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_HEAD10R); } }
ajhc/demo-cortex-m3
C++
null
38
/* This function sets the EC curve to be used for TLS flows. */
EFI_STATUS EFIAPI TlsSetEcCurve(IN VOID *Tls, IN UINT8 *Data, IN UINTN DataSize)
/* This function sets the EC curve to be used for TLS flows. */ EFI_STATUS EFIAPI TlsSetEcCurve(IN VOID *Tls, IN UINT8 *Data, IN UINTN DataSize)
{ CALL_CRYPTO_SERVICE (TlsSetSignatureAlgoList, (Tls, Data, DataSize), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* Process a new point from LV_INDEV_TYPE_POINTER input device */
static void indev_pointer_proc(lv_indev_t *i, lv_indev_data_t *data)
/* Process a new point from LV_INDEV_TYPE_POINTER input device */ static void indev_pointer_proc(lv_indev_t *i, lv_indev_data_t *data)
{ if(i->cursor != NULL && (i->proc.types.pointer.last_point.x != data->point.x || i->proc.types.pointer.last_point.y != data->point.y)) { lv_obj_set_pos(i->cursor, data->point.x, data->point.y); } i->proc.types.pointer.act_point.x = data->point.x; i->proc.types.pointer.act_point.y = data->point.y; if(i->proc.state == LV_INDEV_STATE_PR) { indev_proc_press(&i->proc); } else { indev_proc_release(&i->proc); } i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x; i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Fills a target buffer with a 16-bit value, and returns the target buffer. */
VOID* EFIAPI InternalMemSetMem16(OUT VOID *Buffer, IN UINTN Length, IN UINT16 Value)
/* Fills a target buffer with a 16-bit value, and returns the target buffer. */ VOID* EFIAPI InternalMemSetMem16(OUT VOID *Buffer, IN UINTN Length, IN UINT16 Value)
{ for ( ; Length != 0; Length--) { ((UINT16 *)Buffer)[Length - 1] = Value; } return Buffer; }
tianocore/edk2
C++
Other
4,240
/* ADC Disable the EOC for Each Conversion. The EOC is set at the end of each sequence rather than after each conversion in the sequence. Overrun detection is enabled always. */
void adc_eoc_after_group(uint32_t adc)
/* ADC Disable the EOC for Each Conversion. The EOC is set at the end of each sequence rather than after each conversion in the sequence. Overrun detection is enabled always. */ void adc_eoc_after_group(uint32_t adc)
{ ADC_CR2(adc) &= ~ADC_CR2_EOCS; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Enable the FLASH Prefetch Buffer. Note carefully the clock restrictions under which the prefetch buffer may be enabled or disabled. Changes are normally made while the clock is running in the power-on low frequency mode before being set to a higher speed mode. See the reference manual for details. */
void flash_prefetch_buffer_enable(void)
/* Enable the FLASH Prefetch Buffer. Note carefully the clock restrictions under which the prefetch buffer may be enabled or disabled. Changes are normally made while the clock is running in the power-on low frequency mode before being set to a higher speed mode. See the reference manual for details. */ void flash_prefetch_buffer_enable(void)
{ FLASH_ACR |= FLASH_ACR_PRFTBE; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_set_break(mss_uart_instance_t *this_uart)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_set_break(mss_uart_instance_t *this_uart)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); if((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) { set_bit_reg8(&this_uart->hw_reg->LCR,SB); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* stop the USB host and clean up FIFO */
void usb_host_stop(usb_core_driver *pudev)
/* stop the USB host and clean up FIFO */ void usb_host_stop(usb_core_driver *pudev)
{ uint32_t i; __IO uint32_t pp_ctl = 0U; pudev->regs.hr->HACHINTEN = 0x0U; pudev->regs.hr->HACHINT = 0xFFFFFFFFU; for (i = 0U; i < pudev->bp.num_pipe; i++) { pp_ctl = pudev->regs.pr[i]->HCHCTL; pp_ctl &= ~(HCHCTL_CEN | HCHCTL_EPDIR); pp_ctl |= HCHCTL_CDIS; pudev->regs.pr[i]->HCHCTL = pp_ctl; } usb_rxfifo_flush (&pudev->regs); usb_txfifo_flush (&pudev->regs, 0x10U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return EFI_NOT_READY if there is no data available */
EFI_STATUS FastbootTransportUsbReceive(OUT UINTN *BufferSize, OUT VOID **Buffer)
/* Return EFI_NOT_READY if there is no data available */ EFI_STATUS FastbootTransportUsbReceive(OUT UINTN *BufferSize, OUT VOID **Buffer)
{ FASTBOOT_USB_PACKET_LIST *Entry; if (IsListEmpty (&mPacketList)) { return EFI_NOT_READY; } Entry = (FASTBOOT_USB_PACKET_LIST *)GetFirstNode (&mPacketList); *BufferSize = Entry->BufferSize; *Buffer = Entry->Buffer; RemoveEntryList (&Entry->Link); FreePool (Entry); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* msleep_interruptible - sleep waiting for signals @msecs: Time in milliseconds to sleep for */
unsigned long msleep_interruptible(unsigned int msecs)
/* msleep_interruptible - sleep waiting for signals @msecs: Time in milliseconds to sleep for */ unsigned long msleep_interruptible(unsigned int msecs)
{ unsigned long timeout = msecs_to_jiffies(msecs) + 1; while (timeout && !signal_pending(current)) timeout = schedule_timeout_interruptible(timeout); return jiffies_to_msecs(timeout); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sets the secid to contain a u32 version of the smack label. */
static void smack_task_getsecid(struct task_struct *p, u32 *secid)
/* Sets the secid to contain a u32 version of the smack label. */ static void smack_task_getsecid(struct task_struct *p, u32 *secid)
{ *secid = smack_to_secid(task_security(p)); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Determines if the USART is in mute mode or not. */
void USART_EnableRcvWakeUp(USART_Module *USARTx, FunctionalState Cmd)
/* Determines if the USART is in mute mode or not. */ void USART_EnableRcvWakeUp(USART_Module *USARTx, FunctionalState Cmd)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { USARTx->CTRL1 |= CTRL1_RCVWU_SET; } else { USARTx->CTRL1 &= CTRL1_RCVWU_RESET; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function is used to change the eMMC bus speed. */
s32 XSdPs_Change_MmcBusSpeed(XSdPs *InstancePtr)
/* This function is used to change the eMMC bus speed. */ s32 XSdPs_Change_MmcBusSpeed(XSdPs *InstancePtr)
{ s32 Status; u32 Arg; Status = XSdPs_CalcBusSpeed(InstancePtr, &Arg); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH; } Status = XSdPs_CmdTransfer(InstancePtr, CMD6, Arg, 0U); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH; } Status = XSdps_CheckTransferDone(InstancePtr); if (Status != XST_SUCCESS) { Status = XST_FAILURE; } Status = XST_SUCCESS; RETURN_PATH: return Status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Release a Mutex that was acquired by osMutexAcquire. */
osStatus_t osMutexRelease(osMutexId_t mutex_id)
/* Release a Mutex that was acquired by osMutexAcquire. */ osStatus_t osMutexRelease(osMutexId_t mutex_id)
{ EvrRtxMutexError(mutex_id, (int32_t)osErrorISR); status = osErrorISR; } else { status = __svcMutexRelease(mutex_id); } return status; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Allocate new Big Number and assign the provided value to it. */
VOID* EFIAPI BigNumFromBin(IN CONST UINT8 *Buf, IN UINTN Len)
/* Allocate new Big Number and assign the provided value to it. */ VOID* EFIAPI BigNumFromBin(IN CONST UINT8 *Buf, IN UINTN Len)
{ return BN_bin2bn (Buf, (INT32)Len, NULL); }
tianocore/edk2
C++
Other
4,240
/* This function is used to set whether to inverse the output. */
int tls_pwm_out_inverse_cmd(u8 channel, bool en)
/* This function is used to set whether to inverse the output. */ int tls_pwm_out_inverse_cmd(u8 channel, bool en)
{ if(channel > (PWM_CHANNEL_MAX_NUM - 1)) return WM_FAILED; if (4 == channel) { if (ENABLE == en) tls_reg_write32(HR_PWM_CH4_REG2, tls_reg_read32(HR_PWM_CH4_REG2) | BIT(0)); else tls_reg_write32(HR_PWM_CH4_REG2, tls_reg_read32(HR_PWM_CH4_REG2) & (~BIT(0))); } else { if (ENABLE == en) tls_reg_write32(HR_PWM_CTL, tls_reg_read32(HR_PWM_CTL) | BIT(2 + channel)); else tls_reg_write32(HR_PWM_CTL, tls_reg_read32(HR_PWM_CTL) & (~BIT(2 + channel))); } return WM_SUCCESS; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Register a callback function for events in the set @events related to the SID pair (@ssid, @tsid) and and the permissions @perms, interpreting @perms based on @tclass. Returns %0 on success or -ENOMEM if insufficient memory exists to add the callback. */
int avc_add_callback(int(*callback)(u32 event, u32 ssid, u32 tsid, u16 tclass, u32 perms, u32 *out_retained), u32 events, u32 ssid, u32 tsid, u16 tclass, u32 perms)
/* Register a callback function for events in the set @events related to the SID pair (@ssid, @tsid) and and the permissions @perms, interpreting @perms based on @tclass. Returns %0 on success or -ENOMEM if insufficient memory exists to add the callback. */ int avc_add_callback(int(*callback)(u32 event, u32 ssid, u32 tsid, u16 tclass, u32 perms, u32 *out_retained), u32 events, u32 ssid, u32 tsid, u16 tclass, u32 perms)
{ struct avc_callback_node *c; int rc = 0; c = kmalloc(sizeof(*c), GFP_ATOMIC); if (!c) { rc = -ENOMEM; goto out; } c->callback = callback; c->events = events; c->ssid = ssid; c->tsid = tsid; c->perms = perms; c->next = avc_callbacks; avc_callbacks = c; out: return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns: the address of the specific WPS attribute content found, or NULL */
u8* rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content)
/* Returns: the address of the specific WPS attribute content found, or NULL */ u8* rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content)
{ u8 *attr_ptr; u32 attr_len; if(len_content) *len_content = 0; attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len); if(attr_ptr && attr_len) { if(buf_content) _rtw_memcpy(buf_content, attr_ptr+4, attr_len-4); if(len_content) *len_content = attr_len-4; return attr_ptr+4; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* generate a list of extant virtual connections in /proc/net/rxrpc_conns */
static void* rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
/* generate a list of extant virtual connections in /proc/net/rxrpc_conns */ static void* rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
{ read_lock(&rxrpc_connection_lock); return seq_list_start_head(&rxrpc_connections, *_pos); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reference counter dropped to zero. Wake up waiter in dasd_delete_device. */
void dasd_put_device_wake(struct dasd_device *device)
/* Reference counter dropped to zero. Wake up waiter in dasd_delete_device. */ void dasd_put_device_wake(struct dasd_device *device)
{ wake_up(&dasd_delete_wq); }
robutest/uclinux
C++
GPL-2.0
60
/* Check if an ID string is repeated within a given sequence of bytes at specific repetition interval period (e.g., {0x20,0x01,0x7F,0x20} has a period of 3). This is a helper function for nand_id_len(). Returns non-zero if the repetition has a period of @period; otherwise, returns zero. */
static int nand_id_has_period(u8 *id_data, int arrlen, int period)
/* Check if an ID string is repeated within a given sequence of bytes at specific repetition interval period (e.g., {0x20,0x01,0x7F,0x20} has a period of 3). This is a helper function for nand_id_len(). Returns non-zero if the repetition has a period of @period; otherwise, returns zero. */ static int nand_id_has_period(u8 *id_data, int arrlen, int period)
{ int i, j; for (i = 0; i < period; i++) for (j = i + period; j < arrlen; j += period) if (id_data[i] != id_data[j]) return 0; return 1; }
4ms/stm32mp1-baremetal
C++
Other
137
/* retireves a port's VLAN membership table or TTI table */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet)
/* retireves a port's VLAN membership table or TTI table */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBVlanTableGet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet)
{ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_VLAN_QOS); IX_ETH_DB_CHECK_REFERENCE(vlanSet); memcpy(vlanSet, portVlanTable, sizeof (IxEthDBVlanSet)); return IX_ETH_DB_SUCCESS; }
EmcraftSystems/u-boot
C++
Other
181
/* Function for applying when there is no service registered. */
static __INLINE ret_code_t no_service_context_apply(dm_handle_t *p_handle)
/* Function for applying when there is no service registered. */ static __INLINE ret_code_t no_service_context_apply(dm_handle_t *p_handle)
{ DM_LOG("[DM]: --> no_service_context_apply\r\n"); DM_LOG("[DM]:[CI 0x%02X]: No Service context\r\n", p_handle->connection_id); return NRF_SUCCESS; }
labapart/polymcu
C++
null
201
/* Writes multiple words of data into the SHA/MD5 data registers. */
static void _SHAMD5DataWriteMultiple(uint32_t ui32Base, uint32_t *pui32DataSrc, uint32_t ui32DataLength)
/* Writes multiple words of data into the SHA/MD5 data registers. */ static void _SHAMD5DataWriteMultiple(uint32_t ui32Base, uint32_t *pui32DataSrc, uint32_t ui32DataLength)
{ uint32_t ui32Idx, ui32Count; ASSERT(ui32Base == SHAMD5_BASE); ui32Count = ui32DataLength / 64; for (ui32Idx = 0; ui32Idx < ui32Count; ui32Idx++) { SHAMD5DataWrite(ui32Base, pui32DataSrc); pui32DataSrc += 16; } ui32Count = ui32DataLength % 64; if (ui32Count) { while ((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY) == 0) { } for (ui32Idx = 0; ui32Idx < ui32Count; ui32Idx += 4) { HWREG(ui32Base + SHAMD5_O_DATA_0_IN + ui32Idx) = *pui32DataSrc++; } } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This is a way of ensuring that we have something in the system use fields that is compatible with Rock Ridge. Return zero on success. */
static int check_sp(struct rock_ridge *rr, struct inode *inode)
/* This is a way of ensuring that we have something in the system use fields that is compatible with Rock Ridge. Return zero on success. */ static int check_sp(struct rock_ridge *rr, struct inode *inode)
{ if (rr->u.SP.magic[0] != 0xbe) return -1; if (rr->u.SP.magic[1] != 0xef) return -1; ISOFS_SB(inode->i_sb)->s_rock_offset = rr->u.SP.skip; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: 0 on success, -ENOBUFS when we run out of space */
static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
/* Returns: 0 on success, -ENOBUFS when we run out of space */ static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
{ const struct gfs2_inode *ip = gl->gl_object; if (ip == NULL) return 0; gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu/%llu\n", (unsigned long long)ip->i_no_formal_ino, (unsigned long long)ip->i_no_addr, IF2DT(ip->i_inode.i_mode), ip->i_flags, (unsigned int)ip->i_diskflags, (unsigned long long)ip->i_inode.i_size, (unsigned long long)ip->i_disksize); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha384All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
/* If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI HmacSha384All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
{ return HmacMdAll (MBEDTLS_MD_SHA384, Data, DataSize, Key, KeySize, HmacValue); }
tianocore/edk2
C++
Other
4,240
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */
gboolean _g_freedesktop_dbus_call_add_match_finish(_GFreedesktopDBus *proxy, GAsyncResult *res, GError **error)
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */ gboolean _g_freedesktop_dbus_call_add_match_finish(_GFreedesktopDBus *proxy, GAsyncResult *res, GError **error)
{ GVariant *_ret; _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); if (_ret == NULL) goto _out; g_variant_get (_ret, "()"); g_variant_unref (_ret); _out: return _ret != NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Clear the SysTick pending. This function will Clear the SysTick pending. */
void xSysTickPendClr(void)
/* Clear the SysTick pending. This function will Clear the SysTick pending. */ void xSysTickPendClr(void)
{ xHWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTCLR; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Description: Return true if @tsk1's mems_allowed intersects the mems_allowed of @tsk2. Used by the OOM killer to determine if one of the task's memory usage might impact the memory available to the other. */
int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, const struct task_struct *tsk2)
/* Description: Return true if @tsk1's mems_allowed intersects the mems_allowed of @tsk2. Used by the OOM killer to determine if one of the task's memory usage might impact the memory available to the other. */ int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, const struct task_struct *tsk2)
{ return nodes_intersects(tsk1->mems_allowed, tsk2->mems_allowed); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* PE calls this function when it needs to set the Rp on CC. */
int port0_policy_cb_get_src_rp(const struct device *dev, enum tc_rp_value *rp)
/* PE calls this function when it needs to set the Rp on CC. */ int port0_policy_cb_get_src_rp(const struct device *dev, enum tc_rp_value *rp)
{ struct port0_data_t *dpm_data = usbc_get_dpm_data(dev); *rp = dpm_data->rp; return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Stops the sub-GHz interface and yields the radio (tells RF module to power down). */
static int ieee802154_cc13xx_cc26xx_subg_stop_if(const struct device *dev)
/* Stops the sub-GHz interface and yields the radio (tells RF module to power down). */ static int ieee802154_cc13xx_cc26xx_subg_stop_if(const struct device *dev)
{ struct ieee802154_cc13xx_cc26xx_subg_data *drv_data = dev->data; int ret; if (k_sem_take(&drv_data->lock, LOCK_TIMEOUT)) { return -EIO; } if (!drv_data->is_up) { ret = -EALREADY; goto out; } ret = drv_abort_commands(dev); if (ret) { goto out; } ret = drv_power_down(dev); if (ret) { goto out; } drv_data->is_up = false; out: k_sem_give(&drv_data->lock); return ret; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* this function is a POSIX compliant version, which shall request that all data for the open file descriptor named by fildes is to be transferred to the storage device associated with the file described by fildes. */
int fsync(int fildes)
/* this function is a POSIX compliant version, which shall request that all data for the open file descriptor named by fildes is to be transferred to the storage device associated with the file described by fildes. */ int fsync(int fildes)
{ int ret; struct dfs_file *d; d = fd_get(fildes); if (d == NULL) { rt_set_errno(-EBADF); return -1; } ret = dfs_file_flush(d); return ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns a negative error code if SERDES is disabled or the given device is not supported in the current SERDES protocol. */
int serdes_get_first_lane(enum srds_prtcl device)
/* Returns a negative error code if SERDES is disabled or the given device is not supported in the current SERDES protocol. */ int serdes_get_first_lane(enum srds_prtcl device)
{ u32 prtcl; const ccsr_gur_t *gur; gur = (typeof(gur))CONFIG_SYS_MPC85xx_GUTS_ADDR; if (unlikely((in_be32(&gur->rcwsr[5]) & 0x2000) == 0)) return -ENODEV; prtcl = (in_be32(&gur->rcwsr[4]) & FSL_CORENET_RCWSR4_SRDS_PRTCL) >> 26; return __serdes_get_first_lane(prtcl, device); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Fetch data from kernel space and fill in checksum if needed. */
static int ip_reply_glue_bits(void *dptr, char *to, int offset, int len, int odd, struct sk_buff *skb)
/* Fetch data from kernel space and fill in checksum if needed. */ static int ip_reply_glue_bits(void *dptr, char *to, int offset, int len, int odd, struct sk_buff *skb)
{ __wsum csum; csum = csum_partial_copy_nocheck(dptr+offset, to, len, 0); skb->csum = csum_block_add(skb->csum, csum, odd); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Only not moved into the core for the hardware ring buffer cases that are more sophisticated. */
static int max1363_ring_postenable(struct iio_dev *indio_dev)
/* Only not moved into the core for the hardware ring buffer cases that are more sophisticated. */ static int max1363_ring_postenable(struct iio_dev *indio_dev)
{ if (indio_dev->trig == NULL) return 0; return iio_trigger_attach_poll_func(indio_dev->trig, indio_dev->pollfunc); }
robutest/uclinux
C++
GPL-2.0
60
/* Task function of the user program application. Should be called continuously in the program loop. */
void AppTask(void)
/* Task function of the user program application. Should be called continuously in the program loop. */ void AppTask(void)
{ LedToggle(); NetTask(); BootComCheckActivationRequest(); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This frees the buffer pools created by hcd_buffer_create(). */
void hcd_buffer_destroy(struct usb_hcd *hcd)
/* This frees the buffer pools created by hcd_buffer_create(). */ void hcd_buffer_destroy(struct usb_hcd *hcd)
{ int i; for (i = 0; i < HCD_BUFFER_POOLS; i++) { struct dma_pool *pool = hcd->pool[i]; if (pool) { dma_pool_destroy(pool); hcd->pool[i] = NULL; } } }
robutest/uclinux
C++
GPL-2.0
60
/* ib_modify_port() changes a port's attributes as specified by the @port_modify_mask and @port_modify structure. */
int ib_modify_port(struct ib_device *device, u8 port_num, int port_modify_mask, struct ib_port_modify *port_modify)
/* ib_modify_port() changes a port's attributes as specified by the @port_modify_mask and @port_modify structure. */ int ib_modify_port(struct ib_device *device, u8 port_num, int port_modify_mask, struct ib_port_modify *port_modify)
{ if (port_num < start_port(device) || port_num > end_port(device)) return -EINVAL; return device->modify_port(device, port_num, port_modify_mask, port_modify); }
robutest/uclinux
C++
GPL-2.0
60
/* Compare two ROSE addresses for only mask digits, 0 == equal. */
int rosecmpm(rose_address *addr1, rose_address *addr2, unsigned short mask)
/* Compare two ROSE addresses for only mask digits, 0 == equal. */ int rosecmpm(rose_address *addr1, rose_address *addr2, unsigned short mask)
{ unsigned int i, j; if (mask > 10) return 1; for (i = 0; i < mask; i++) { j = i / 2; if ((i % 2) != 0) { if ((addr1->rose_addr[j] & 0x0F) != (addr2->rose_addr[j] & 0x0F)) return 1; } else { if ((addr1->rose_addr[j] & 0xF0) != (addr2->rose_addr[j] & 0xF0)) return 1; } } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Pushes the @data into the @queue. @data must not be NULL. */
void g_async_queue_push(GAsyncQueue *queue, gpointer data)
/* Pushes the @data into the @queue. @data must not be NULL. */ void g_async_queue_push(GAsyncQueue *queue, gpointer data)
{ g_return_if_fail (queue); g_return_if_fail (data); g_mutex_lock (&queue->mutex); g_async_queue_push_unlocked (queue, data); g_mutex_unlock (&queue->mutex); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Cause a EXTI Event trigger for a sample sequence of Injected channel. */
void ADCExtiEventInjecTrigger(unsigned long ulBase)
/* Cause a EXTI Event trigger for a sample sequence of Injected channel. */ void ADCExtiEventInjecTrigger(unsigned long ulBase)
{ xASSERT((ulBase == ADC1_BASE) || (ulBase == ADC2_BASE) || (ulBase == ADC3_BASE)); xHWREG(ulBase + ADC_CR2) |= ADC_CR2_JEXTTRIG; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* If SourceSize is less than BROTLI_SCRATCH_MAX, then ASSERT(). */
EFI_STATUS EFIAPI BrotliUefiDecompressGetInfo(IN CONST VOID *Source, IN UINT32 SourceSize, OUT UINT32 *DestinationSize, OUT UINT32 *ScratchSize)
/* If SourceSize is less than BROTLI_SCRATCH_MAX, then ASSERT(). */ EFI_STATUS EFIAPI BrotliUefiDecompressGetInfo(IN CONST VOID *Source, IN UINT32 SourceSize, OUT UINT32 *DestinationSize, OUT UINT32 *ScratchSize)
{ UINT64 GetSize; UINT8 MaxOffset; ASSERT (SourceSize >= BROTLI_SCRATCH_MAX); MaxOffset = BROTLI_DECODE_MAX; GetSize = BrGetDecodedSizeOfBuf ((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset); *DestinationSize = (UINT32)GetSize; MaxOffset = BROTLI_SCRATCH_MAX; GetSize = BrGetDecodedSizeOfBuf ((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset); *ScratchSize = (UINT32)GetSize; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This function is only available when the major and minor versions in the EfiShellProtocol are greater than or equal to 2 and 1, respectively. */
EFI_STATUS EFIAPI EfiShellGetGuidName(IN CONST EFI_GUID *Guid, OUT CONST CHAR16 **GuidName)
/* This function is only available when the major and minor versions in the EfiShellProtocol are greater than or equal to 2 and 1, respectively. */ EFI_STATUS EFIAPI EfiShellGetGuidName(IN CONST EFI_GUID *Guid, OUT CONST CHAR16 **GuidName)
{ CHAR16 *Name; if ((Guid == NULL) || (GuidName == NULL)) { return (EFI_INVALID_PARAMETER); } Name = GetStringNameFromGuid (Guid, NULL); if ((Name == NULL) || (StrLen (Name) == 0)) { SHELL_FREE_NON_NULL (Name); return (EFI_NOT_FOUND); } *GuidName = AddBufferToFreeList (Name); return (EFI_SUCCESS); }
tianocore/edk2
C++
Other
4,240
/* Programs the FLASH User Option Byte: IWDG_SW, RST_STOP, RST_STDBY, BOOT1 and VDDA ANALOG monitoring. */
FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER)
/* Programs the FLASH User Option Byte: IWDG_SW, RST_STOP, RST_STDBY, BOOT1 and VDDA ANALOG monitoring. */ FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER)
{ FLASH_Status status = FLASH_COMPLETE; status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if (status == FLASH_COMPLETE) { FLASH->CR |= FLASH_CR_OPTPG; OB->USER = OB_USER; status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if (status != FLASH_TIMEOUT) { FLASH->CR &= ~FLASH_CR_OPTPG; } } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Add the GIC Redistributor Information to the MADT Table. */
STATIC VOID AddGICRedistributorList(IN EFI_ACPI_6_5_GICR_STRUCTURE *Gicr, IN CONST CM_ARM_GIC_REDIST_INFO *GicRInfo, IN UINT32 GicRCount)
/* Add the GIC Redistributor Information to the MADT Table. */ STATIC VOID AddGICRedistributorList(IN EFI_ACPI_6_5_GICR_STRUCTURE *Gicr, IN CONST CM_ARM_GIC_REDIST_INFO *GicRInfo, IN UINT32 GicRCount)
{ ASSERT (Gicr != NULL); ASSERT (GicRInfo != NULL); while (GicRCount-- != 0) { AddGICRedistributor (Gicr++, GicRInfo++); } }
tianocore/edk2
C++
Other
4,240
/* This is only useful when the bootmem allocator has already been torn down, but we are still initializing the system. Pages are given directly to the page allocator, no bootmem metadata is updated because it is gone. */
void __init free_bootmem_late(unsigned long addr, unsigned long size)
/* This is only useful when the bootmem allocator has already been torn down, but we are still initializing the system. Pages are given directly to the page allocator, no bootmem metadata is updated because it is gone. */ void __init free_bootmem_late(unsigned long addr, unsigned long size)
{ unsigned long cursor, end; kmemleak_free_part(__va(addr), size); cursor = PFN_UP(addr); end = PFN_DOWN(addr + size); for (; cursor < end; cursor++) { __free_pages_bootmem(pfn_to_page(cursor), 0); totalram_pages++; } }
robutest/uclinux
C++
GPL-2.0
60
/* Retrieves the status of DAC channel end of conversion. Checks if the conversion is completed or not and returns boolean flag of status. */
bool dac_chan_is_end_of_conversion(struct dac_module *const module_inst, enum dac_channel channel)
/* Retrieves the status of DAC channel end of conversion. Checks if the conversion is completed or not and returns boolean flag of status. */ bool dac_chan_is_end_of_conversion(struct dac_module *const module_inst, enum dac_channel channel)
{ Assert(module_inst); Assert(module_inst->hw); Dac *const dac_module = module_inst->hw; if(dac_module->STATUS.reg & DAC_STATUS_EOC(channel + 1)) { return true; } else { return false; } }
memfault/zero-to-main
C++
null
200
/* Interrupt handler for the RTT. Get current RTT status. */
void RTT_Handler(void)
/* Interrupt handler for the RTT. Get current RTT status. */ void RTT_Handler(void)
{ uint32_t status; status = rtt_get_status(RTT); if ((status & RTT_SR_ALMS) == RTT_SR_ALMS) { } }
remotemcu/remcu-chip-sdks
C++
null
436
/* CRC algorithm parameters were taken from the "Checksum Calculation" section of the datasheet. */
static uint8_t shtcx_compute_crc(uint16_t value)
/* CRC algorithm parameters were taken from the "Checksum Calculation" section of the datasheet. */ static uint8_t shtcx_compute_crc(uint16_t value)
{ uint8_t buf[2]; sys_put_be16(value, buf); return crc8(buf, 2, 0x31, 0xFF, false); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* function to register callback to be called when AT_BLE_CHARACTERISTIC_CHANGED event triggered from stack */
void register_ble_characteristic_changed_cb(ble_characteristic_changed_callback_t char_changed_cb_fn)
/* function to register callback to be called when AT_BLE_CHARACTERISTIC_CHANGED event triggered from stack */ void register_ble_characteristic_changed_cb(ble_characteristic_changed_callback_t char_changed_cb_fn)
{ ble_char_changed_cb = char_changed_cb_fn; }
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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI S3MmioBitFieldWrite8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value)
/* 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT8 EFIAPI S3MmioBitFieldWrite8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value)
{ return InternalSaveMmioWrite8ValueToBootScript (Address, MmioBitFieldWrite8 (Address, StartBit, EndBit, Value)); }
tianocore/edk2
C++
Other
4,240
/* Check whether there is some group that the user space has not consumed yet. When the user space consumes a group, it sets it to -1. Cosuming could be reading data in case of RX and filling a buffer in case of TX. */
static int poch_channel_available(struct channel_info *channel)
/* Check whether there is some group that the user space has not consumed yet. When the user space consumes a group, it sets it to -1. Cosuming could be reading data in case of RX and filling a buffer in case of TX. */ static int poch_channel_available(struct channel_info *channel)
{ int available = 0; spin_lock_irq(&channel->group_offsets_lock); if (channel->consumed != channel->transfer) available = 1; spin_unlock_irq(&channel->group_offsets_lock); return available; }
robutest/uclinux
C++
GPL-2.0
60
/* Slave finish up a transfer. It would call back if there is callback function and set the state to idle. This is not a public API. */
static void LPSPI_SlaveTransferComplete(LPSPI_Type *base, lpspi_slave_handle_t *handle)
/* Slave finish up a transfer. It would call back if there is callback function and set the state to idle. This is not a public API. */ static void LPSPI_SlaveTransferComplete(LPSPI_Type *base, lpspi_slave_handle_t *handle)
{ assert(handle); status_t status = kStatus_Success; LPSPI_DisableInterrupts(base, (uint32_t)kLPSPI_AllInterruptEnable); if (handle->state == (uint8_t)kLPSPI_Error) { status = kStatus_LPSPI_Error; } else { status = kStatus_Success; } handle->state = (uint8_t)kLPSPI_Idle; if (handle->callback != NULL) { handle->callback(base, handle, status, handle->userData); } }
eclipse-threadx/getting-started
C++
Other
310
/* 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(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Stores data in the battery-backed memory of the Hibernation module. */
void HibernateDataSet(uint32_t *pui32Data, uint32_t ui32Count)
/* Stores data in the battery-backed memory of the Hibernation module. */ void HibernateDataSet(uint32_t *pui32Data, uint32_t ui32Count)
{ uint32_t ui32Idx; ASSERT(ui32Count <= 64); ASSERT(pui32Data != 0); for (ui32Idx = 0; ui32Idx < ui32Count; ui32Idx++) { HWREG(HIB_DATA + (ui32Idx * 4)) = pui32Data[ui32Idx]; _HibernateWriteComplete(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Turn off the ADC This will actually block if it needs to turn off a currently running conversion, as per ref man. */
void adc_power_off(uint32_t adc)
/* Turn off the ADC This will actually block if it needs to turn off a currently running conversion, as per ref man. */ void adc_power_off(uint32_t adc)
{ adc_power_off_async(adc); while (!adc_is_power_off(adc)); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This function checks whether a handle is a valid EFI_HII_HANDLE This is a internal function. */
BOOLEAN IsHiiHandleValid(EFI_HII_HANDLE Handle)
/* This function checks whether a handle is a valid EFI_HII_HANDLE This is a internal function. */ BOOLEAN IsHiiHandleValid(EFI_HII_HANDLE Handle)
{ HII_HANDLE *HiiHandle; HiiHandle = (HII_HANDLE *)Handle; if (HiiHandle == NULL) { return FALSE; } if (HiiHandle->Signature != HII_HANDLE_SIGNATURE) { return FALSE; } return TRUE; }
tianocore/edk2
C++
Other
4,240
/* Sets the designated bits in a 16-bit data word at the remote CPU system address */
uint16_t IPCLtoRSetBits(volatile tIpcController *psController, uint32_t ulAddress, uint32_t ulMask, uint16_t usLength, uint16_t bBlock)
/* Sets the designated bits in a 16-bit data word at the remote CPU system address */ uint16_t IPCLtoRSetBits(volatile tIpcController *psController, uint32_t ulAddress, uint32_t ulMask, uint16_t usLength, uint16_t bBlock)
{ uint16_t status; tIpcMessage sMessage; sMessage.ulcommand = IPC_SET_BITS; sMessage.uladdress = ulAddress; sMessage.uldataw1 = (uint32_t)usLength; sMessage.uldataw2 = ulMask; status = IpcPut (psController, &sMessage, bBlock); return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* rpc_init_rtt - Initialize an RPC RTT estimator context @rt: context to initialize @timeo: initial timeout value, in jiffies */
void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo)
/* rpc_init_rtt - Initialize an RPC RTT estimator context @rt: context to initialize @timeo: initial timeout value, in jiffies */ void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo)
{ unsigned long init = 0; unsigned i; rt->timeo = timeo; if (timeo > RPC_RTO_INIT) init = (timeo - RPC_RTO_INIT) << 3; for (i = 0; i < 5; i++) { rt->srtt[i] = init; rt->sdrtt[i] = RPC_RTO_INIT; rt->ntimeouts[i] = 0; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* IdleTask periodically calls strip_xmit, so even when we have no IP packets to send for an extended period of time, the watchdog processing still gets done to ensure that the radio stays in Starmode */
static void strip_IdleTask(unsigned long parameter)
/* IdleTask periodically calls strip_xmit, so even when we have no IP packets to send for an extended period of time, the watchdog processing still gets done to ensure that the radio stays in Starmode */ static void strip_IdleTask(unsigned long parameter)
{ strip_xmit(NULL, (struct net_device *) parameter); }
robutest/uclinux
C++
GPL-2.0
60
/* NOTE: SDIO address @addr is 17 bits long (SDIO address space is 128K). */
static struct device* ssb_sdio_dev(struct ssb_bus *bus)
/* NOTE: SDIO address @addr is 17 bits long (SDIO address space is 128K). */ static struct device* ssb_sdio_dev(struct ssb_bus *bus)
{ return &bus->host_sdio->dev; }
robutest/uclinux
C++
GPL-2.0
60
/* This file is part of the Simba project. */
int mock_write_sys_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_sys_module_init(int res)
{ harness_mock_write("sys_module_init()", NULL, 0); harness_mock_write("sys_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* we use this if we don't have any better idle routine */
static void default_idle(void)
/* we use this if we don't have any better idle routine */ static void default_idle(void)
{ local_irq_disable(); if (!need_resched()) safe_halt(); else local_irq_enable(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the count remaining for a non-blocking transaction. */
unsigned long EPINonBlockingReadCount(unsigned long ulBase, unsigned long ulChannel)
/* Get the count remaining for a non-blocking transaction. */ unsigned long EPINonBlockingReadCount(unsigned long ulBase, unsigned long ulChannel)
{ unsigned long ulOffset; ASSERT(ulBase == EPI0_BASE); ASSERT(ulChannel < 2); ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0); return(HWREG(ulBase + EPI_O_RPSTD0 + ulOffset)); }
watterott/WebRadio
C++
null
71
/* USART Disable TX pin active level inversion. TX pin signal works using the standard logic levels (VDD =1/idle, Gnd=0/mark) */
void usart_disable_tx_inversion(uint32_t usart)
/* USART Disable TX pin active level inversion. TX pin signal works using the standard logic levels (VDD =1/idle, Gnd=0/mark) */ void usart_disable_tx_inversion(uint32_t usart)
{ USART_CR2(usart) &= ~USART_CR2_TXINV; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* e1000_irq_enable - Enable default interrupt generation settings @adapter: board private structure */
static void e1000_irq_enable(struct e1000_adapter *adapter)
/* e1000_irq_enable - Enable default interrupt generation settings @adapter: board private structure */ static void e1000_irq_enable(struct e1000_adapter *adapter)
{ struct e1000_hw *hw = &adapter->hw; ew32(IMS, IMS_ENABLE_MASK); E1000_WRITE_FLUSH(); }
robutest/uclinux
C++
GPL-2.0
60
/* Get the actual frequency of USCI_SPI bus clock. Only available in Master mode. */
uint32_t USPI_GetBusClock(USPI_T *uspi)
/* Get the actual frequency of USCI_SPI bus clock. Only available in Master mode. */ uint32_t USPI_GetBusClock(USPI_T *uspi)
{ uint32_t u32BusClk = 0UL; uint32_t u32ClkDiv; u32ClkDiv = (uspi->BRGEN & USPI_BRGEN_CLKDIV_Msk) >> USPI_BRGEN_CLKDIV_Pos; if (uspi == USPI0) { u32BusClk = (uint32_t)(CLK_GetPCLK0Freq() / ((u32ClkDiv + 1ul) << 1)); } return u32BusClk; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Queries the memory controller for the possible regions that will support SMRAM. */
STATIC EFI_STATUS EFIAPI SmmAccess2DxeGetCapabilities(IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, IN OUT UINTN *SmramMapSize, IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap)
/* Queries the memory controller for the possible regions that will support SMRAM. */ STATIC EFI_STATUS EFIAPI SmmAccess2DxeGetCapabilities(IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, IN OUT UINTN *SmramMapSize, IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap)
{ return SmramAccessGetCapabilities ( This->LockState, This->OpenState, SmramMapSize, SmramMap ); }
tianocore/edk2
C++
Other
4,240
/* Return an allocated memory block back to a specific memory pool. */
osStatus_t osMemoryPoolFree(osMemoryPoolId_t mp_id, void *block)
/* Return an allocated memory block back to a specific memory pool. */ osStatus_t osMemoryPoolFree(osMemoryPoolId_t mp_id, void *block)
{ struct cv2_mslab *mslab = (struct cv2_mslab *)mp_id; if (mslab == NULL) { return osErrorParameter; } k_mem_slab_free((struct k_mem_slab *)(&mslab->z_mslab), (void *)block); return osOK; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Copies n bytes from memory area src to memory area dest. The memory areas should not overlap. */
static void MAC_memcpy(uint8_t *dest, const uint8_t *src, uint32_t n)
/* Copies n bytes from memory area src to memory area dest. The memory areas should not overlap. */ static void MAC_memcpy(uint8_t *dest, const uint8_t *src, uint32_t n)
{ uint8_t *d = dest; while( n > 0u ) { n--; d[n] = src[n]; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Calls a discover-all-characteristics proc's callback with the specified parameters. If the proc has no callback, this function is a no-op. */
static int ble_gattc_disc_all_chrs_cb(struct ble_gattc_proc *proc, int status, uint16_t att_handle, struct ble_gatt_chr *chr)
/* Calls a discover-all-characteristics proc's callback with the specified parameters. If the proc has no callback, this function is a no-op. */ static int ble_gattc_disc_all_chrs_cb(struct ble_gattc_proc *proc, int status, uint16_t att_handle, struct ble_gatt_chr *chr)
{ int rc; BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task()); BLE_HS_DBG_ASSERT(chr != NULL || status != 0); ble_gattc_dbg_assert_proc_not_inserted(proc); if (status != 0 && status != BLE_HS_EDONE) { STATS_INC(ble_gattc_stats, disc_all_chrs_fail); } if (proc->disc_all_chrs.cb == NULL) { rc = 0; } else { rc = proc->disc_all_chrs.cb(proc->conn_handle, ble_gattc_error(status, att_handle), chr, proc->disc_all_chrs.cb_arg); } return rc; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Useful for tracing that does not cross to other CPUs nor does it go through idle events. */
u64 notrace trace_clock_local(void)
/* Useful for tracing that does not cross to other CPUs nor does it go through idle events. */ u64 notrace trace_clock_local(void)
{ u64 clock; int resched; resched = ftrace_preempt_disable(); clock = sched_clock(); ftrace_preempt_enable(resched); return clock; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Responsible for different function parameters like TX Queue, wake-up filter, etc. */
static int32_t can_ctrl_con_reg_config(struct can_ctrl_dev *dev, struct can_ctrl_init_param *init_param)
/* Responsible for different function parameters like TX Queue, wake-up filter, etc. */ static int32_t can_ctrl_con_reg_config(struct can_ctrl_dev *dev, struct can_ctrl_init_param *init_param)
{ int32_t ret; uint32_t temp; ret = can_ctrl_sfr_word_read(dev, CAN_CTRL_REG_CON, &temp); if(ret != 0) return ret; temp &= ~(CON_TXQEN_MODE(WORD_MASK) | CON_STEF_MODE(WORD_MASK) | CON_ISOCRCEN_MODE(WORD_MASK) | CON_WAKFIL_MODE(WORD_MASK)); temp |= CON_TXQEN_MODE(init_param->con_txq_en) | CON_STEF_MODE(init_param->con_store_in_tef_en) | CON_ISOCRCEN_MODE(init_param->con_iso_crc_en) | CON_WAKFIL_MODE(true); return can_ctrl_sfr_word_write(dev, CAN_CTRL_REG_CON, temp); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Init ADC module This function can be used to configure ADC peripherals clock frequecy. */
void ADCInit(unsigned long ulBase, unsigned long ulRate)
/* Init ADC module This function can be used to configure ADC peripherals clock frequecy. */ void ADCInit(unsigned long ulBase, unsigned long ulRate)
{ unsigned long temp = 0; unsigned long ulClk = 0; xHWREG(ulBase + AD_CR) = 0; ulClk = SysCtlPeripheralClockGet(SYSCTL_PERIPH_ADC); temp = ulRate * 65; temp = (ulClk * 2 + temp)/(2 * temp) - 1; xHWREG(ulBase + AD_CR) = (temp<<CR_CLKDIV_S) | BIT_32_0; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This routine must be used to perform EEH initialization for PCI devices that were added after system boot (e.g. hotplug, dlpar). This routine must be called before any i/o is performed to the adapter (inluding any config-space i/o). Whether this actually enables EEH or not for this device depends on the CEC architecture, type of the device, on earlier boot command-line arguments & etc. */
static void eeh_add_device_early(struct device_node *dn)
/* This routine must be used to perform EEH initialization for PCI devices that were added after system boot (e.g. hotplug, dlpar). This routine must be called before any i/o is performed to the adapter (inluding any config-space i/o). Whether this actually enables EEH or not for this device depends on the CEC architecture, type of the device, on earlier boot command-line arguments & etc. */ static void eeh_add_device_early(struct device_node *dn)
{ struct pci_controller *phb; struct eeh_early_enable_info info; if (!dn || !PCI_DN(dn)) return; phb = PCI_DN(dn)->phb; if (NULL == phb || 0 == phb->buid) return; info.buid_hi = BUID_HI(phb->buid); info.buid_lo = BUID_LO(phb->buid); early_enable_eeh(dn, &info); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable Titan-e multicast addresses. Returns: VXGE_HW_OK on success. */
enum vxge_hw_status vxge_hw_vpath_mcast_enable(struct __vxge_hw_vpath_handle *vp)
/* Enable Titan-e multicast addresses. Returns: VXGE_HW_OK on success. */ enum vxge_hw_status vxge_hw_vpath_mcast_enable(struct __vxge_hw_vpath_handle *vp)
{ u64 val64; struct __vxge_hw_virtualpath *vpath; enum vxge_hw_status status = VXGE_HW_OK; if ((vp == NULL) || (vp->vpath->ringh == NULL)) { status = VXGE_HW_ERR_INVALID_HANDLE; goto exit; } vpath = vp->vpath; val64 = readq(&vpath->vp_reg->rxmac_vcfg0); if (!(val64 & VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN)) { val64 |= VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN; writeq(val64, &vpath->vp_reg->rxmac_vcfg0); } exit: return status; }
robutest/uclinux
C++
GPL-2.0
60