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
/* Maps @count pages from @pages into contiguous kernel virtual space. */
void* vmap(struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
/* Maps @count pages from @pages into contiguous kernel virtual space. */ void* vmap(struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
{ struct vm_struct *area; might_sleep(); if (count > totalram_pages) return NULL; area = get_vm_area_caller((count << PAGE_SHIFT), flags, __builtin_return_address(0)); if (!area) return NULL; if (map_vm_area(area, prot, &pages)) { vunmap(area->addr); return NULL; } return area->addr; }
robutest/uclinux
C++
GPL-2.0
60
/* CAN initialization function. Enables CAN peripheral, clocks and initializes CAN driver */
void CAN_0_init(void)
/* CAN initialization function. Enables CAN peripheral, clocks and initializes CAN driver */ void CAN_0_init(void)
{ hri_mclk_set_AHBMASK_CAN1_bit(MCLK); hri_gclk_write_PCHCTRL_reg(GCLK, CAN1_GCLK_ID, CONF_GCLK_CAN1_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); can_async_init(&CAN_0, CAN1); CAN_0_PORT_init(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read data out of VME space into a buffer. */
ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count, loff_t offset)
/* Read data out of VME space into a buffer. */ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count, loff_t offset)
{ struct vme_bridge *bridge = find_bridge(resource); struct vme_master_resource *image; size_t length; if (bridge->master_read == NULL) { printk("Reading from resource not supported\n"); return -EINVAL; } if (resource->type != VME_MASTER) { printk("Not a master resource\n"); return -EINVAL; } image = list_entry(resource->entry, struct vme_master_resource, list); length = vme_get_size(resource); if (offset > length) { printk("Invalid Offset\n"); return -EFAULT; } if ((offset + count) > length) count = length - offset; return bridge->master_read(image, buf, count, offset); }
robutest/uclinux
C++
GPL-2.0
60
/* This function writes a node to the orphan head from the orphan buffer. If atomic is not zero, then the write is done atomically. On success, %0 is returned, otherwise a negative error code is returned. */
static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
/* This function writes a node to the orphan head from the orphan buffer. If atomic is not zero, then the write is done atomically. On success, %0 is returned, otherwise a negative error code is returned. */ static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
{ int err = 0; if (atomic) { ubifs_assert(c->ohead_offs == 0); ubifs_prepare_node(c, c->orph_buf, len, 1); len = ALIGN(len, c->min_io_size); err = ubifs_leb_change(c, c->ohead_lnum, c->orph_buf, len, UBI_SHORTTERM); } else { if (c->ohead_offs == 0) { err = ubifs_leb_unmap(c, c->ohead_lnum); if (err) return err; } err = ubifs_write_node(c, c->orph_buf, len, c->ohead_lnum, c->ohead_offs, UBI_SHORTTERM); } return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Ring the door bell to notify XHCI there is a transaction to be executed. */
VOID XhcPeiRingDoorBell(IN PEI_XHC_DEV *Xhc, IN UINT8 SlotId, IN UINT8 Dci)
/* Ring the door bell to notify XHCI there is a transaction to be executed. */ VOID XhcPeiRingDoorBell(IN PEI_XHC_DEV *Xhc, IN UINT8 SlotId, IN UINT8 Dci)
{ if (SlotId == 0) { XhcPeiWriteDoorBellReg (Xhc, 0, 0); } else { XhcPeiWriteDoorBellReg (Xhc, SlotId * sizeof (UINT32), Dci); } }
tianocore/edk2
C++
Other
4,240
/* Fills each UART_InitStruct member with its default value. */
void UART_StructInit(UART_InitTypeDef *init_struct)
/* Fills each UART_InitStruct member with its default value. */ void UART_StructInit(UART_InitTypeDef *init_struct)
{ init_struct->BaudRate = 9600; init_struct->WordLength = UART_WordLength_8b; init_struct->StopBits = UART_StopBits_1; init_struct->Parity = UART_Parity_No; init_struct->Mode = UART_GCR_RX | UART_GCR_TX; init_struct->HWFlowControl = UART_HWFlowControl_None; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Writes and returns a new value to DR5. This function is only available on IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmWriteDr5(UINTN Dr5)
/* Writes and returns a new value to DR5. This function is only available on IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. */ UINTN EFIAPI AsmWriteDr5(UINTN Dr5)
{ __asm__ __volatile__ ( "movl %0, %%dr5" : : "r" (Dr5) ); return Dr5; }
tianocore/edk2
C++
Other
4,240
/* @pkt: packet received by dhcp_handler() @len: length of the packet received */
void efi_net_set_dhcp_ack(void *pkt, int len)
/* @pkt: packet received by dhcp_handler() @len: length of the packet received */ void efi_net_set_dhcp_ack(void *pkt, int len)
{ int maxsize = sizeof(*dhcp_ack); if (!dhcp_ack) dhcp_ack = malloc(maxsize); memcpy(dhcp_ack, pkt, min(len, maxsize)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* NOTE: we take the inode's blockdev's mapping's private_lock. Which assumes that all the buffers are against the blockdev. Not true for reiserfs. */
void invalidate_inode_buffers(struct inode *inode)
/* NOTE: we take the inode's blockdev's mapping's private_lock. Which assumes that all the buffers are against the blockdev. Not true for reiserfs. */ void invalidate_inode_buffers(struct inode *inode)
{ if (inode_has_buffers(inode)) { struct address_space *mapping = &inode->i_data; struct list_head *list = &mapping->private_list; struct address_space *buffer_mapping = mapping->assoc_mapping; spin_lock(&buffer_mapping->private_lock); while (!list_empty(list)) __remove_assoc_queue(BH_ENTRY(list->next)); spin_unlock(&buffer_mapping->private_lock); } }
robutest/uclinux
C++
GPL-2.0
60
/* If any reserved bits in Address are set, 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 PciSegmentBitFieldRead8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
/* If any reserved bits in Address are set, 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 PciSegmentBitFieldRead8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
{ UINTN Count; PCI_SEGMENT_INFO *SegmentInfo; SegmentInfo = GetPciSegmentInfo (&Count); return MmioBitFieldRead8 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), StartBit, EndBit); }
tianocore/edk2
C++
Other
4,240
/* With pci bus iommu support, we use a default pool of unmapped memory for memory we donnot need to DMA from/to and one pool per pcidev for memory accessed by the PCI chip. */
static m_addr_t ___mp0_getp(m_pool_s *mp)
/* With pci bus iommu support, we use a default pool of unmapped memory for memory we donnot need to DMA from/to and one pool per pcidev for memory accessed by the PCI chip. */ static m_addr_t ___mp0_getp(m_pool_s *mp)
{ m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER); if (m) ++mp->nump; return m; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: a pointer to the copy of @string within the #GStringChunk */
gchar* g_string_chunk_insert(GStringChunk *chunk, const gchar *string)
/* Returns: a pointer to the copy of @string within the #GStringChunk */ gchar* g_string_chunk_insert(GStringChunk *chunk, const gchar *string)
{ g_return_val_if_fail (chunk != NULL, NULL); return g_string_chunk_insert_len (chunk, string, -1); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* union object_pointer switch (boolean b) { case TRUE: object_data data; case FALSE: void nothing; } */
bool_t xdr_pointer(XDR *xdrs, char **objpp, unsigned int obj_size, xdrproc_t xdr_obj)
/* union object_pointer switch (boolean b) { case TRUE: object_data data; case FALSE: void nothing; } */ bool_t xdr_pointer(XDR *xdrs, char **objpp, unsigned int obj_size, xdrproc_t xdr_obj)
{ bool_t more_data; more_data = (*objpp != NULL); if (!xdr_bool(xdrs, &more_data)) { return (FALSE); } if (!more_data) { *objpp = NULL; return (TRUE); } return (xdr_reference(xdrs, objpp, obj_size, xdr_obj)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
EFI_STATUS EFIAPI PeiServicesFfsGetVolumeInfo(IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo)
/* This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */ EFI_STATUS EFIAPI PeiServicesFfsGetVolumeInfo(IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo)
{ return (*GetPeiServicesTablePointer ())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo); }
tianocore/edk2
C++
Other
4,240
/* This function will register an usb class driver to the class driver manager. */
rt_err_t rt_usbh_class_driver_register(ucd_t drv)
/* This function will register an usb class driver to the class driver manager. */ rt_err_t rt_usbh_class_driver_register(ucd_t drv)
{ if (drv == RT_NULL) return -RT_ERROR; rt_list_insert_after(&_driver_list, &(drv->list)); return RT_EOK; }
pikasTech/PikaPython
C++
MIT License
1,403
/* XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case. This probably warrants some sort of hashing. */
static struct resource * _sparc_find_resource(struct resource *r, unsigned long)
/* XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case. This probably warrants some sort of hashing. */ static struct resource * _sparc_find_resource(struct resource *r, unsigned long)
{ struct resource *tmp; for (tmp = root->child; tmp != 0; tmp = tmp->sibling) { if (tmp->start <= hit && tmp->end >= hit) return tmp; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Registers callback for the specified callback type. Associates the given callback function with the specified callback type. To enable the callback, the i2c_slave_enable_callback function must be used. */
void i2c_slave_register_callback(struct i2c_slave_module *const module, i2c_slave_callback_t callback, enum i2c_slave_callback callback_type)
/* Registers callback for the specified callback type. Associates the given callback function with the specified callback type. To enable the callback, the i2c_slave_enable_callback function must be used. */ void i2c_slave_register_callback(struct i2c_slave_module *const module, i2c_slave_callback_t callback, enum i2c_slave_callback callback_type)
{ Assert(module); Assert(module->hw); Assert(callback); module->callbacks[callback_type] = callback; module->registered_callback |= (1 << callback_type); }
memfault/zero-to-main
C++
null
200
/* Code generated for this function might be very inefficient for some CPUs. __div64_32() can be overridden by linking arch-specific assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. Iterative div/mod for use when dividend is not expected to be much bigger than divisor. */
u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
/* Code generated for this function might be very inefficient for some CPUs. __div64_32() can be overridden by linking arch-specific assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. Iterative div/mod for use when dividend is not expected to be much bigger than divisor. */ u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
{ return __iter_div_u64_rem(dividend, divisor, remainder); }
robutest/uclinux
C++
GPL-2.0
60
/* Fills each I2C_InitStruct member with its default value. */
void I2C_ConfigStructInit(I2C_Config_T *i2cConfig)
/* Fills each I2C_InitStruct member with its default value. */ void I2C_ConfigStructInit(I2C_Config_T *i2cConfig)
{ i2cConfig->clockSpeed = 5000; i2cConfig->mode = I2C_MODE_I2C; i2cConfig->dutyCycle = I2C_DUTYCYCLE_2; i2cConfig->ownAddress1 = 0; i2cConfig->ack = I2C_ACK_DISABLE; i2cConfig->ackAddress = I2C_ACK_ADDRESS_7BIT; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function does an erase of all user flash area. */
int8_t FLASH_If_Erase(uint32_t StartSector)
/* This function does an erase of all user flash area. */ int8_t FLASH_If_Erase(uint32_t StartSector)
{ uint32_t FlashAddress; FlashAddress = StartSector; if (FlashAddress <= (uint32_t) USER_FLASH_LAST_PAGE_ADDRESS) { FLASH_EraseInitTypeDef FLASH_EraseInitStruct; uint32_t sectornb = 0; FLASH_EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS; FLASH_EraseInitStruct.Sector = FLASH_SECTOR_5; FLASH_EraseInitStruct.NbSectors = 19; FLASH_EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3; if (HAL_FLASHEx_Erase(&FLASH_EraseInitStruct, &sectornb) != HAL_OK) return (1); } else { return (1); } return (0); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Read the 64-bits data from the specified OTP. */
int32_t FMC_Read_OTP(uint32_t otp_num, uint32_t *low_word, uint32_t *high_word)
/* Read the 64-bits data from the specified OTP. */ int32_t FMC_Read_OTP(uint32_t otp_num, uint32_t *low_word, uint32_t *high_word)
{ int32_t ret = 0; if (otp_num > 255UL) { ret = -2; } if (ret == 0) { FMC->ISPCMD = FMC_ISPCMD_READ_64; FMC->ISPADDR = FMC_OTP_BASE + otp_num * 8UL ; FMC->ISPDAT = 0x0UL; FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; while (FMC->ISPSTS & FMC_ISPSTS_ISPBUSY_Msk) { } if (FMC->ISPSTS & FMC_ISPSTS_ISPFF_Msk) { FMC->ISPSTS |= FMC_ISPSTS_ISPFF_Msk; ret = -1; } else { *low_word = FMC->MPDAT0; *high_word = FMC->MPDAT1; } } return ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Use the VMGEXIT support to report an unsupported event to the hypervisor. */
STATIC UINT64 UnsupportedExit(IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN CC_INSTRUCTION_DATA *InstructionData)
/* Use the VMGEXIT support to report an unsupported event to the hypervisor. */ STATIC UINT64 UnsupportedExit(IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN CC_INSTRUCTION_DATA *InstructionData)
{ UINT64 Status; Status = CcExitVmgExit (Ghcb, SVM_EXIT_UNSUPPORTED, Regs->ExceptionData, 0); if (Status == 0) { GHCB_EVENT_INJECTION Event; Event.Uint64 = 0; Event.Elements.Vector = GP_EXCEPTION; Event.Elements.Type = GHCB_EVENT_INJECTION_TYPE_EXCEPTION; Event.Elements.Valid = 1; Status = Event.Uint64; } return Status; }
tianocore/edk2
C++
Other
4,240
/* Converts a URI device path structure to its string representative. */
VOID DevPathToTextUri(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a URI device path structure to its string representative. */ VOID DevPathToTextUri(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ URI_DEVICE_PATH *Uri; UINTN UriLength; CHAR8 *UriStr; Uri = DevPath; UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH); UriStr = AllocatePool (UriLength + 1); ASSERT (UriStr != NULL); CopyMem (UriStr, Uri->Uri, UriLength); UriStr[UriLength] = '\0'; UefiDevicePathLibCatPrint (Str, L"Uri(%a)", UriStr); FreePool (UriStr); }
tianocore/edk2
C++
Other
4,240
/* Enable the output direction of the specified GPIO and set the GPIO to the specified value. */
int32_t gpio_direction_output(struct gpio_desc *desc, uint8_t value)
/* Enable the output direction of the specified GPIO and set the GPIO to the specified value. */ int32_t gpio_direction_output(struct gpio_desc *desc, uint8_t value)
{ ADI_GPIO_RESULT ret; if (!desc || !nb_gpio) return FAILURE; ret = adi_gpio_OutputEnable(PORT(desc->number), PIN(desc->number), true); if (ret != ADI_GPIO_SUCCESS) return FAILURE; if (value == 1) ret = adi_gpio_SetHigh(PORT(desc->number), PIN(desc->number)); else ret = adi_gpio_SetLow(PORT(desc->number), PIN(desc->number)); if (ret != ADI_GPIO_SUCCESS) return FAILURE; return SUCCESS; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Required for newer ESP32-series MCUs which violate the original SJA1000 8-bit register size. */
static void can_esp32_twai_write_reg32(const struct device *dev, uint8_t reg, uint32_t val)
/* Required for newer ESP32-series MCUs which violate the original SJA1000 8-bit register size. */ static void can_esp32_twai_write_reg32(const struct device *dev, uint8_t reg, uint32_t val)
{ const struct can_sja1000_config *sja1000_config = dev->config; const struct can_esp32_twai_config *twai_config = sja1000_config->custom; mm_reg_t addr = twai_config->base + reg * sizeof(uint32_t); sys_write32(val, addr); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND is returned. */
EFI_STATUS EFIAPI SdMmcPassThruGetNextSlot(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, IN OUT UINT8 *Slot)
/* If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND is returned. */ EFI_STATUS EFIAPI SdMmcPassThruGetNextSlot(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, IN OUT UINT8 *Slot)
{ SD_MMC_HC_PRIVATE_DATA *Private; UINT8 Index; if ((This == NULL) || (Slot == NULL)) { return EFI_INVALID_PARAMETER; } Private = SD_MMC_HC_PRIVATE_FROM_THIS (This); if (*Slot == 0xFF) { for (Index = 0; Index < SD_MMC_HC_MAX_SLOT; Index++) { if (Private->Slot[Index].Enable) { *Slot = Index; Private->PreviousSlot = Index; return EFI_SUCCESS; } } return EFI_NOT_FOUND; } else if (*Slot == Private->PreviousSlot) { for (Index = *Slot + 1; Index < SD_MMC_HC_MAX_SLOT; Index++) { if (Private->Slot[Index].Enable) { *Slot = Index; Private->PreviousSlot = Index; return EFI_SUCCESS; } } return EFI_NOT_FOUND; } else { return EFI_INVALID_PARAMETER; } }
tianocore/edk2
C++
Other
4,240
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_DA7212_SetMute(void *handle, uint32_t playChannel, bool isMute)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_DA7212_SetMute(void *handle, uint32_t playChannel, bool isMute)
{ assert(handle != NULL); return DA7212_SetChannelMute((da7212_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), playChannel, isMute); }
eclipse-threadx/getting-started
C++
Other
310
/* Loads the palette/gamma unit for the CRTC with the prepared values */
void intel_crtc_load_lut(struct drm_crtc *crtc)
/* Loads the palette/gamma unit for the CRTC with the prepared values */ void intel_crtc_load_lut(struct drm_crtc *crtc)
{ struct drm_device *dev = crtc->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); int palreg = (intel_crtc->pipe == 0) ? PALETTE_A : PALETTE_B; int i; if (!crtc->enabled) return; if (IS_IRONLAKE(dev)) palreg = (intel_crtc->pipe == 0) ? LGC_PALETTE_A : LGC_PALETTE_B; for (i = 0; i < 256; i++) { I915_WRITE(palreg + 4 * i, (intel_crtc->lut_r[i] << 16) | (intel_crtc->lut_g[i] << 8) | intel_crtc->lut_b[i]); } }
robutest/uclinux
C++
GPL-2.0
60
/* Is called by gcc-generated constructor code for each object file compiled with -fprofile-arcs. */
void __gcov_init(struct gcov_info *info)
/* Is called by gcc-generated constructor code for each object file compiled with -fprofile-arcs. */ void __gcov_init(struct gcov_info *info)
{ info->next = gcov_info_head; gcov_info_head = info; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Get the end address of the specified SMC chip. */
uint32_t EXMC_SMC_GetChipEndAddr(uint32_t u32Chip)
/* Get the end address of the specified SMC chip. */ uint32_t EXMC_SMC_GetChipEndAddr(uint32_t u32Chip)
{ uint32_t u32Mask; uint32_t u32Match; DDL_ASSERT(IS_EXMC_SMC_CHIP(u32Chip)); u32Mask = (READ_REG32_BIT(CM_SMC->CSCR0, SMC_CSCR0_ADDMSKx(u32Chip)) >> SMC_CSCR0_ADDMSKx_POS(u32Chip)); u32Match = (READ_REG32_BIT(CM_SMC->CSCR1, SMC_CSCR1_ADDMATx(u32Chip)) >> SMC_CSCR1_ADDMATx_POS(u32Chip)); return (~((u32Match ^ u32Mask) << 24U)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param handle Pointer to the flexio_mculcd_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_MCULCD_TransferCreateHandle(FLEXIO_MCULCD_Type *base, flexio_mculcd_handle_t *handle, flexio_mculcd_transfer_callback_t callback, void *userData)
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param handle Pointer to the flexio_mculcd_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ status_t FLEXIO_MCULCD_TransferCreateHandle(FLEXIO_MCULCD_Type *base, flexio_mculcd_handle_t *handle, flexio_mculcd_transfer_callback_t callback, void *userData)
{ assert(NULL != handle); IRQn_Type flexio_irqs[] = FLEXIO_IRQS; (void)memset(handle, 0, sizeof(*handle)); handle->state = (uint32_t)kFLEXIO_MCULCD_StateIdle; handle->completionCallback = callback; handle->userData = userData; (void)EnableIRQ(flexio_irqs[FLEXIO_GetInstance(base->flexioBase)]); return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_MCULCD_TransferHandleIRQ); }
eclipse-threadx/getting-started
C++
Other
310
/* Function for incrementing the sequence number counter for next reliable packet expected. */
static __INLINE void packet_number_expected_inc(void)
/* Function for incrementing the sequence number counter for next reliable packet expected. */ static __INLINE void packet_number_expected_inc(void)
{ ++m_packet_expected_seq_number; m_packet_expected_seq_number &= 0x07u; }
labapart/polymcu
C++
null
201
/* convert the colour format of a given tile to gray8 */
arm_fsm_rt_t arm_2dp_convert_colour_to_gray8(arm_2d_op_cl_convt_t *ptOP, const arm_2d_tile_t *ptSource, const arm_2d_tile_t *ptTarget)
/* convert the colour format of a given tile to gray8 */ arm_fsm_rt_t arm_2dp_convert_colour_to_gray8(arm_2d_op_cl_convt_t *ptOP, const arm_2d_tile_t *ptSource, const arm_2d_tile_t *ptTarget)
{ assert(NULL != ptSource); assert(NULL != ptTarget); ARM_2D_IMPL(arm_2d_op_cl_convt_t, ptOP); if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) { return arm_fsm_rt_on_going; } OP_CORE.ptOp = &ARM_2D_OP_CONVERT_TO_GRAY8; this.Target.ptTile = ptTarget; this.Target.ptRegion = NULL; this.Source.ptTile = ptSource; return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Deinitializes the WWDG peripheral registers to their default reset values. */
void WWDG_DeInit(void)
/* Deinitializes the WWDG peripheral registers to their default reset values. */ void WWDG_DeInit(void)
{ RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return if the controller in question is currently attached to the system, */
SDL_bool SDL_GameControllerGetAttached(SDL_GameController *gamecontroller)
/* Return if the controller in question is currently attached to the system, */ SDL_bool SDL_GameControllerGetAttached(SDL_GameController *gamecontroller)
{ if (!gamecontroller) return SDL_FALSE; return SDL_JoystickGetAttached(gamecontroller->joystick); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Enable the option to clear the counter on an AST alarm. */
void ast_enable_counter_clear_on_alarm(Ast *ast, uint8_t alarm_channel)
/* Enable the option to clear the counter on an AST alarm. */ void ast_enable_counter_clear_on_alarm(Ast *ast, uint8_t alarm_channel)
{ while (ast_is_busy(ast)) { } ast->AST_CR |= (alarm_channel ? 0 : AST_CR_CA0); while (ast_is_busy(ast)) { } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Returns a newly built URI or NULL in case of error */
URI* uri_parse(const char *str)
/* Returns a newly built URI or NULL in case of error */ URI* uri_parse(const char *str)
{ ret = rfc3986_parse_uri_reference(uri, str); if (ret) { uri_free(uri); return(NULL); } } return(uri); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Event handler for the library USB Connection event. */
void EVENT_USB_Device_Connect(void)
/* Event handler for the library USB Connection event. */ void EVENT_USB_Device_Connect(void)
{ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); TIMSK0 = (1 << OCIE0A); OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); TCCR0A = (1 << WGM01); TCCR0B = (1 << CS01); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Checks whether the specified ADC flag is set or not. */
uint8_t ADC_ReadStatusFlag(ADC_FLAG_T flag)
/* Checks whether the specified ADC flag is set or not. */ uint8_t ADC_ReadStatusFlag(ADC_FLAG_T flag)
{ uint32_t status; if ((uint32_t)(flag & 0x01000000)) { status = ADC->CTRL & 0xFEFFFFFF; } else { status = ADC->STS; } if ((status & flag) != (uint32_t)RESET) { return SET; } return RESET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Set empty cluster from 'entry' to the end of a file */
static int clear_fatent(fsdata *mydata, __u32 entry)
/* Set empty cluster from 'entry' to the end of a file */ static int clear_fatent(fsdata *mydata, __u32 entry)
{ __u32 fat_val; while (!CHECK_CLUST(entry, mydata->fatsize)) { fat_val = get_fatent(mydata, entry); if (fat_val != 0) set_fatent_value(mydata, entry, 0); else break; entry = fat_val; } if (flush_dirty_fat_buffer(mydata) < 0) return -1; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Displays a maximum of 20 char on the LCD. */
void LCD_DisplayStringLine(uint8_t Line, uint8_t *ptr)
/* Displays a maximum of 20 char on the LCD. */ void LCD_DisplayStringLine(uint8_t Line, uint8_t *ptr)
{ uint16_t refcolumn = LCD_PIXEL_WIDTH - 1; while ((*ptr != 0) & (((refcolumn + 1) & 0xFFFF) >= LCD_Currentfonts->Width)) { LCD_DisplayChar(Line, refcolumn, *ptr); refcolumn -= LCD_Currentfonts->Width; ptr++; } }
avem-labs/Avem
C++
MIT License
1,752
/* Checks whether the FLASH Read Out Protection Status is set or not. */
FlagStatus FLASH_GetReadOutProtectionSTS(void)
/* Checks whether the FLASH Read Out Protection Status is set or not. */ FlagStatus FLASH_GetReadOutProtectionSTS(void)
{ FlagStatus readoutstatus = RESET; if ((FLASH->OBR & RDPRTL1_MSK) != (uint32_t)RESET) { readoutstatus = SET; } else { readoutstatus = RESET; } return readoutstatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Function for possibly cleaning up after a failed pairing or encryption procedure. */
static void link_secure_failure(uint16_t conn_handle, pm_sec_error_code_t error, uint8_t error_src)
/* Function for possibly cleaning up after a failed pairing or encryption procedure. */ static void link_secure_failure(uint16_t conn_handle, pm_sec_error_code_t error, uint8_t error_src)
{ if (ble_conn_state_user_flag_get(conn_handle, m_smd.flag_id_sec_proc)) { pm_peer_id_t peer_id = im_peer_id_get_by_conn_handle(conn_handle); if (peer_id != PM_PEER_ID_INVALID) { if (ble_conn_state_user_flag_get(conn_handle, m_smd.flag_id_sec_proc_pairing)) { pairing_failure(conn_handle, peer_id, error, error_src); } else { encryption_failure(conn_handle, error, error_src); } } } }
labapart/polymcu
C++
null
201
/* Creates the metatables for the objects and registers the driver open method. */
LUASQL_API int luaopen_luasql_mysql(lua_State *L)
/* Creates the metatables for the objects and registers the driver open method. */ LUASQL_API int luaopen_luasql_mysql(lua_State *L)
{ {"mysql", create_environment}, {NULL, NULL}, }; create_metatables (L); luaL_openlib (L, LUASQL_TABLENAME, driver, 0); luasql_set_info (L); lua_pushliteral (L, "_MYSQLVERSION"); lua_pushliteral (L, MYSQL_SERVER_VERSION); lua_settable (L, -3); return 1; }
DC-SWAT/DreamShell
C++
null
404
/* Converts a text device path node to USB mass storage device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbMassStorage(CHAR16 *TextDeviceNode)
/* Converts a text device path node to USB mass storage device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbMassStorage(CHAR16 *TextDeviceNode)
{ USB_CLASS_TEXT UsbClassText; UsbClassText.ClassExist = FALSE; UsbClassText.Class = USB_CLASS_MASS_STORAGE; UsbClassText.SubClassExist = TRUE; return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); }
tianocore/edk2
C++
Other
4,240
/* Socket removal during an interrupt is now safe. */
static void ax25_cb_del(ax25_cb *ax25)
/* Socket removal during an interrupt is now safe. */ static void ax25_cb_del(ax25_cb *ax25)
{ if (!hlist_unhashed(&ax25->ax25_node)) { spin_lock_bh(&ax25_list_lock); hlist_del_init(&ax25->ax25_node); spin_unlock_bh(&ax25_list_lock); ax25_cb_put(ax25); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disable a module clock derived from the PBB clock. */
void sysclk_disable_pbb_module(uint32_t module_index)
/* Disable a module clock derived from the PBB clock. */ void sysclk_disable_pbb_module(uint32_t module_index)
{ irqflags_t flags; sysclk_priv_disable_module(PM_CLK_GRP_PBB, module_index); flags = cpu_irq_save(); if (PM->PM_PBBMASK == 0) { sysclk_disable_hsb_module(SYSCLK_PBB_BRIDGE); } cpu_irq_restore(flags); }
memfault/zero-to-main
C++
null
200
/* Table 4, Standard single precision floating-point arithmetic helper functions */
aeabi_float_t __aeabi_fadd(aeabi_float_t a, aeabi_float_t b)
/* Table 4, Standard single precision floating-point arithmetic helper functions */ aeabi_float_t __aeabi_fadd(aeabi_float_t a, aeabi_float_t b)
{ return f32_to_f (f32_add (f32_from_f (a), f32_from_f (b))); }
tianocore/edk2
C++
Other
4,240
/* Poll to receive incoming data and transmit outgoing segments. */
EFI_STATUS EFIAPI Tcp4Poll(IN EFI_TCP4_PROTOCOL *This)
/* Poll to receive incoming data and transmit outgoing segments. */ EFI_STATUS EFIAPI Tcp4Poll(IN EFI_TCP4_PROTOCOL *This)
{ SOCKET *Sock; EFI_STATUS Status; if (NULL == This) { return EFI_INVALID_PARAMETER; } Sock = SOCK_FROM_THIS (This); Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL); return Status; }
tianocore/edk2
C++
Other
4,240
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t bnx2x_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
/* This function is called after a PCI bus error affecting this device has been detected. */ static pci_ers_result_t bnx2x_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
{ struct net_device *dev = pci_get_drvdata(pdev); struct bnx2x *bp = netdev_priv(dev); rtnl_lock(); netif_device_detach(dev); if (state == pci_channel_io_perm_failure) { rtnl_unlock(); return PCI_ERS_RESULT_DISCONNECT; } if (netif_running(dev)) bnx2x_eeh_nic_unload(bp); pci_disable_device(pdev); rtnl_unlock(); return PCI_ERS_RESULT_NEED_RESET; }
robutest/uclinux
C++
GPL-2.0
60
/* Return value: 0 on success / other on failure */
static int ibmvfc_send_crq_init(struct ibmvfc_host *vhost)
/* Return value: 0 on success / other on failure */ static int ibmvfc_send_crq_init(struct ibmvfc_host *vhost)
{ ibmvfc_dbg(vhost, "Sending CRQ init\n"); return ibmvfc_send_crq(vhost, 0xC001000000000000LL, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Return the RF name. "????" is returned if the RF is unknown. Used for devices with external radios. */
static const char* ath9k_hw_rf_name(u16 rf_version)
/* Return the RF name. "????" is returned if the RF is unknown. Used for devices with external radios. */ static const char* ath9k_hw_rf_name(u16 rf_version)
{ int i; for (i=0; i<ARRAY_SIZE(ath_rf_names); i++) { if (ath_rf_names[i].version == rf_version) { return ath_rf_names[i].name; } } return "????"; }
robutest/uclinux
C++
GPL-2.0
60
/* User call for freeingTX buffers that are complete. */
void lpc_tx_reclaim(struct netif *netif)
/* User call for freeingTX buffers that are complete. */ void lpc_tx_reclaim(struct netif *netif)
{ lpc_tx_reclaim_st((struct lpc_enetdata *) netif->state, LPC_EMAC->TxConsumeIndex); }
ajhc/demo-cortex-m3
C++
null
38
/* Set the DMAC configuration register of the specified DMA Channel. */
void dmac_channel_set_configuration(Dmac *p_dmac, uint32_t ul_num, uint32_t ul_cfg)
/* Set the DMAC configuration register of the specified DMA Channel. */ void dmac_channel_set_configuration(Dmac *p_dmac, uint32_t ul_num, uint32_t ul_cfg)
{ Assert(p_dmac); Assert(ul_num<=3); p_dmac->DMAC_CH_NUM[ul_num].DMAC_CFG = ul_cfg; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function only works for AML NameStrings/pathnames. AML NameStrings/pathnames must be 4 chars long. */
BOOLEAN EFIAPI AmlIsNameSeg(IN CONST CHAR8 *AmlBuffer)
/* This function only works for AML NameStrings/pathnames. AML NameStrings/pathnames must be 4 chars long. */ BOOLEAN EFIAPI AmlIsNameSeg(IN CONST CHAR8 *AmlBuffer)
{ UINT32 Index; if (AmlBuffer == NULL) { return FALSE; } if (!AmlIsLeadNameChar (AmlBuffer[0])) { return FALSE; } for (Index = 1; Index < AML_NAME_SEG_SIZE; Index++) { if (!AmlIsNameChar (AmlBuffer[Index])) { return FALSE; } } return TRUE; }
tianocore/edk2
C++
Other
4,240
/* sys_sched_getparam - get the RT priority of a thread @pid: the pid in question. */
SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
/* sys_sched_getparam - get the RT priority of a thread @pid: the pid in question. */ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
{ struct sched_param lp; struct task_struct *p; int retval; if (!param || pid < 0) return -EINVAL; rcu_read_lock(); p = find_process_by_pid(pid); retval = -ESRCH; if (!p) goto out_unlock; retval = security_task_getscheduler(p); if (retval) goto out_unlock; lp.sched_priority = p->rt_priority; rcu_read_unlock(); retval = copy_to_user(param, &lp, sizeof(*param)) ? -EFAULT : 0; return retval; out_unlock: rcu_read_unlock(); return retval; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* set up the iterator to start reading from the cells list and return the first item */
static void * afs_proc_cells_start(struct seq_file *p, loff_t *pos)
/* set up the iterator to start reading from the cells list and return the first item */ static void * afs_proc_cells_start(struct seq_file *p, loff_t *pos)
{ down_read(&afs_proc_cells_sem); return seq_list_start_head(&afs_proc_cells, *_pos); }
robutest/uclinux
C++
GPL-2.0
60
/* Write a meaningful log entry to the kernel log in the event of an APM error. Note that this also handles (negative) kernel errors. */
static void apm_error(char *str, int err)
/* Write a meaningful log entry to the kernel log in the event of an APM error. Note that this also handles (negative) kernel errors. */ static void apm_error(char *str, int err)
{ int i; for (i = 0; i < ERROR_COUNT; i++) if (error_table[i].key == err) break; if (i < ERROR_COUNT) printk(KERN_NOTICE "apm: %s: %s\n", str, error_table[i].msg); else if (err < 0) printk(KERN_NOTICE "apm: %s: linux error code %i\n", str, err); else printk(KERN_NOTICE "apm: %s: unknown error code %#2.2x\n", str, err); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Common GPIO driver for STM32 MCUs. EXTI interrupt callback */
static void gpio_stm32_isr(int line, void *arg)
/* Common GPIO driver for STM32 MCUs. EXTI interrupt callback */ static void gpio_stm32_isr(int line, void *arg)
{ struct gpio_stm32_data *data = arg; gpio_fire_callbacks(&data->cb, data->dev, BIT(line)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Prepare and call a closing method. If status is CLOSEKTOP, the call to the closing method will be pushed at the top of the stack. Otherwise, values can be pushed right after the 'level' of the upvalue being closed, as everything after that won't be used again. */
static void prepcallclosemth(lua_State *L, StkId level, int status, int yy)
/* Prepare and call a closing method. If status is CLOSEKTOP, the call to the closing method will be pushed at the top of the stack. Otherwise, values can be pushed right after the 'level' of the upvalue being closed, as everything after that won't be used again. */ static void prepcallclosemth(lua_State *L, StkId level, int status, int yy)
{ errobj = s2v(level + 1); luaD_seterrorobj(L, status, level + 1); } callclosemethod(L, uv, errobj, yy); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Allocate and zero memory. If the allocation fails, make the mallocFailed flag in the connection pointer. */
SQLITE_PRIVATE void * sqlite3DbMallocZero(sqlite3 *, int)
/* Allocate and zero memory. If the allocation fails, make the mallocFailed flag in the connection pointer. */ SQLITE_PRIVATE void * sqlite3DbMallocZero(sqlite3 *, int)
{ void *p = sqlite3DbMallocRaw(db, n); if( p ){ memset(p, 0, n); } return p; }
DC-SWAT/DreamShell
C++
null
404
/* Initialize SD - Get Card ID, Set RCA, Frequency and bus width. */
int sd_init(uint32_t instance, int bus_width)
/* Initialize SD - Get Card ID, Set RCA, Frequency and bus width. */ int sd_init(uint32_t instance, int bus_width)
{ int status = FAIL; usdhc_printf("Get CID.\n"); if (card_get_cid(instance) == SUCCESS) { usdhc_printf("Get RCA.\n"); if (sd_get_rca(instance) == SUCCESS) { usdhc_printf("Set operating frequency.\n"); host_cfg_clock(instance, OPERATING_FREQ); if (bus_width == EIGHT) { bus_width = FOUR; } usdhc_printf("Enter transfer state.\n"); if (card_enter_trans(instance) == SUCCESS) { usdhc_printf("Set bus width.\n"); if (sd_set_bus_width(instance, bus_width) == SUCCESS) { host_set_bus_width(instance, bus_width); { status = SUCCESS; } } } } } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* there is only one AP station with id= IWL_AP_ID NOTE: mutex must be held before calling this function */
int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
/* there is only one AP station with id= IWL_AP_ID NOTE: mutex must be held before calling this function */ int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
{ struct ieee80211_sta *sta; struct ieee80211_sta_ht_cap ht_config; struct ieee80211_sta_ht_cap *cur_ht_config = NULL; u8 sta_id; if (priv->current_ht_config.is_ht) { rcu_read_lock(); sta = ieee80211_find_sta(priv->vif, addr); if (sta) { memcpy(&ht_config, &sta->ht_cap, sizeof(ht_config)); cur_ht_config = &ht_config; } rcu_read_unlock(); } sta_id = iwl_add_station(priv, addr, is_ap, CMD_SYNC, cur_ht_config); iwl_sta_init_lq(priv, addr, is_ap); return sta_id; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns zero on success, a negative error code otherwise. */
int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf, const u8 *oobbuf, int start, int nbytes)
/* Returns zero on success, a negative error code otherwise. */ int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf, const u8 *oobbuf, int start, int nbytes)
{ return mtd_ooblayout_get_bytes(mtd, databuf, oobbuf, start, nbytes, mtd_ooblayout_free); }
4ms/stm32mp1-baremetal
C++
Other
137
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
{ if(hi2c->Instance==I2C1) { __HAL_RCC_I2C1_CLK_DISABLE(); HAL_GPIO_DeInit(I2C1_SCL_GPIO_Port, I2C1_SCL_Pin); HAL_GPIO_DeInit(I2C1_SDA_GPIO_Port, I2C1_SDA_Pin); } else if(hi2c->Instance==I2C2) { __HAL_RCC_I2C2_CLK_DISABLE(); HAL_GPIO_DeInit(I2C2_SCL_GPIO_Port, I2C2_SCL_Pin); HAL_GPIO_DeInit(I2C2_SDA_GPIO_Port, I2C2_SDA_Pin); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) This function is always used in thread mode. */
unsigned long I2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) This function is always used in thread mode. */ unsigned long I2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); xASSERT(!(ucSlaveAddr & 0x80)); xI2CMasterWriteRequestS1(ulBase, ucSlaveAddr, ucData, xfalse); while (!(xHWREGB(ulBase + I2C_STATUS) & I2C_STATUS_IF)); ulStatus = xHWREGB(ulBase + I2C_STATUS); if(!(ulStatus == I2C_MASTER_EVENT_TX)) { ulStatus = xI2CMasterError(ulBase); I2CStopSend(ulBase); return ulStatus; } if(bEndTransmition) { I2CStopSend(ulBase); } return xI2C_MASTER_ERR_NONE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Apply stored offset values to sensor reading. This function applies stored calibration offsets to the "input" vector of magnetometer values (the magnetic field vector) and returns the modified values. The offsets are calculated based on sensitivity-adjusted readings, so this function should be used after the values that have been adjusted using hmc5883l_apply_sensitivity(). */
static void hmc5883l_apply_offset(vector3_t *input)
/* Apply stored offset values to sensor reading. This function applies stored calibration offsets to the "input" vector of magnetometer values (the magnetic field vector) and returns the modified values. The offsets are calculated based on sensitivity-adjusted readings, so this function should be used after the values that have been adjusted using hmc5883l_apply_sensitivity(). */ static void hmc5883l_apply_offset(vector3_t *input)
{ input->x -= cal_data.offsets.x; input->y -= cal_data.offsets.y; input->z -= cal_data.offsets.z; }
memfault/zero-to-main
C++
null
200
/* param src USB HS PHY PLL clock source. param freq The frequency specified by src. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */
bool CLOCK_EnableUsbhs0PhyPllClock(clock_usb_phy_src_t src, uint32_t freq)
/* param src USB HS PHY PLL clock source. param freq The frequency specified by src. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */ bool CLOCK_EnableUsbhs0PhyPllClock(clock_usb_phy_src_t src, uint32_t freq)
{ (void)src; (void)freq; const clock_usb_pll_config_t g_ccmConfigUsbPll = {.loopDivider = 0U}; if (CCM_ANALOG->PLL_USB1 & CCM_ANALOG_PLL_USB1_ENABLE_MASK) { CCM_ANALOG->PLL_USB1 |= CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK; } else { CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll); } USBPHY1->CTRL &= ~USBPHY_CTRL_SFTRST_MASK; USBPHY1->CTRL &= ~USBPHY_CTRL_CLKGATE_MASK; USBPHY1->PWD = 0; USBPHY1->CTRL |= USBPHY_CTRL_ENAUTOCLR_PHY_PWD_MASK | USBPHY_CTRL_ENAUTOCLR_CLKGATE_MASK | USBPHY_CTRL_ENUTMILEVEL2_MASK | USBPHY_CTRL_ENUTMILEVEL3_MASK; return true; }
nanoframework/nf-interpreter
C++
MIT License
293
/* ETH MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
/* ETH MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
{ if(heth->Instance==ETH) { __HAL_RCC_ETH_CLK_DISABLE(); __HAL_RCC_ETHTX_CLK_DISABLE(); __HAL_RCC_ETHRX_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOC, RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin); HAL_GPIO_DeInit(GPIOA, RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin); HAL_GPIO_DeInit(RMII_TXD1_GPIO_Port, RMII_TXD1_Pin); HAL_GPIO_DeInit(GPIOG, RMII_TXT_EN_Pin|RMI_TXD0_Pin); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ipc_ids.rw_mutex (as a writer) and the spinlock for this ID are held before this function is called, and remain locked on the exit. */
void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
/* ipc_ids.rw_mutex (as a writer) and the spinlock for this ID are held before this function is called, and remain locked on the exit. */ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
{ int lid = ipcid_to_idx(ipcp->id); idr_remove(&ids->ipcs_idr, lid); ids->in_use--; ipcp->deleted = 1; return; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* imx_dma_setup_progression_handler - setup i.MX DMA channel progression handlers @channel: i.MX DMA channel number @prog_handler: the pointer to the function called if the transfer progresses */
int imx_dma_setup_progression_handler(int channel, void(*prog_handler)(int, void *, struct scatterlist *))
/* imx_dma_setup_progression_handler - setup i.MX DMA channel progression handlers @channel: i.MX DMA channel number @prog_handler: the pointer to the function called if the transfer progresses */ int imx_dma_setup_progression_handler(int channel, void(*prog_handler)(int, void *, struct scatterlist *))
{ struct imx_dma_channel *imxdma = &imx_dma_channels[channel]; unsigned long flags; if (!imxdma->name) { printk(KERN_CRIT "%s: called for not allocated channel %d\n", __func__, channel); return -ENODEV; } local_irq_save(flags); imxdma->prog_handler = prog_handler; local_irq_restore(flags); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function parses the PCC Subspace type 5. */
STATIC VOID DumpPccSubspaceType5(IN UINT8 *Ptr, IN UINT8 Length)
/* This function parses the PCC Subspace type 5. */ STATIC VOID DumpPccSubspaceType5(IN UINT8 *Ptr, IN UINT8 Length)
{ ParseAcpi ( TRUE, 2, "Subspace Type 5", Ptr, Length, PARSER_PARAMS (PccSubspaceType5Parser) ); }
tianocore/edk2
C++
Other
4,240
/* g e t P r i m a l S o l u t i o n */
returnValue QProblem_getPrimalSolution(QProblem *_THIS, real_t *const xOpt)
/* g e t P r i m a l S o l u t i o n */ returnValue QProblem_getPrimalSolution(QProblem *_THIS, real_t *const xOpt)
{ int i; if ( ( QProblem_getStatus( _THIS ) == QPS_AUXILIARYQPSOLVED ) || ( QProblem_getStatus( _THIS ) == QPS_HOMOTOPYQPSOLVED ) || ( QProblem_getStatus( _THIS ) == QPS_SOLVED ) ) { for( i=0; i<QProblem_getNV( _THIS ); ++i ) xOpt[i] = _THIS->x[i]; return SUCCESSFUL_RETURN; } else { return RET_QP_NOT_SOLVED; } }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* Setup timer 1 compare match to generate a tick interrupt. */
static void prvSetupTimerInterrupt(void)
/* Setup timer 1 compare match to generate a tick interrupt. */ static void prvSetupTimerInterrupt(void)
{ const uint32_t ulCompareMatch = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) / portCLOCK_DIV; MSTPCR &= ~portMSTP13; TCR1 = portCLEAR_ON_TGRA_COMPARE_MATCH | portCLOCK_DIV_64; TGR1A = ulCompareMatch; TIER1 |= portTGRA_INTERRUPT_ENABLE; TSTR |= portTIMER_CHANNEL; }
labapart/polymcu
C++
null
201
/* Name: ddr3_tip_pbs_rx. Desc: PBS TX Args: TBD Notes: Returns: OK if success, other error code if fail. */
int ddr3_tip_pbs_rx(u32 uidev_num)
/* Name: ddr3_tip_pbs_rx. Desc: PBS TX Args: TBD Notes: Returns: OK if success, other error code if fail. */ int ddr3_tip_pbs_rx(u32 uidev_num)
{ return ddr3_tip_pbs(uidev_num, PBS_RX_MODE); }
4ms/stm32mp1-baremetal
C++
Other
137
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_slave_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_SPI_SlaveTransferCreateHandle(FLEXIO_SPI_Type *base, flexio_spi_slave_handle_t *handle, flexio_spi_slave_transfer_callback_t callback, void *userData)
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_slave_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ status_t FLEXIO_SPI_SlaveTransferCreateHandle(FLEXIO_SPI_Type *base, flexio_spi_slave_handle_t *handle, flexio_spi_slave_transfer_callback_t callback, void *userData)
{ assert(handle != NULL); IRQn_Type flexio_irqs[] = FLEXIO_IRQS; (void)memset(handle, 0, sizeof(*handle)); handle->callback = callback; handle->userData = userData; NVIC_ClearPendingIRQ(flexio_irqs[FLEXIO_SPI_GetInstance(base)]); (void)EnableIRQ(flexio_irqs[FLEXIO_SPI_GetInstance(base)]); return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_SPI_SlaveTransferHandleIRQ); }
eclipse-threadx/getting-started
C++
Other
310
/* Retrieve the amount of cycles to delay for the given amount of ms. */
static uint32_t _get_cycles_for_ms_internal(const uint16_t ms, const uint32_t freq, const uint8_t power)
/* Retrieve the amount of cycles to delay for the given amount of ms. */ static uint32_t _get_cycles_for_ms_internal(const uint16_t ms, const uint32_t freq, const uint8_t power)
{ switch (power) { case 8: return (ms * (freq / 100000) + 2) / 3 * 100; case 7: return (ms * (freq / 10000) + 2) / 3 * 10; case 6: return (ms * (freq / 1000) + 2) / 3; case 5: return (ms * (freq / 100) + 29) / 30; case 4: return (ms * (freq / 10) + 299) / 300; default: return (ms * (freq / 1) + 2999) / 3000; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: TRUE if a source was found and removed. */
gboolean g_source_remove_by_funcs_user_data(GSourceFuncs *funcs, gpointer user_data)
/* Returns: TRUE if a source was found and removed. */ gboolean g_source_remove_by_funcs_user_data(GSourceFuncs *funcs, gpointer user_data)
{ GSource *source; g_return_val_if_fail (funcs != NULL, FALSE); source = g_main_context_find_source_by_funcs_user_data (NULL, funcs, user_data); if (source) { g_source_destroy (source); return TRUE; } else return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Un-Register the Service C.1 and all its Characteristics... */
void service_c_1_1_remove(void)
/* Un-Register the Service C.1 and all its Characteristics... */ void service_c_1_1_remove(void)
{ bt_gatt_service_unregister(&service_c_1_1_svc); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* consistent_sync_page make a page are consistent. identical to consistent_sync, but takes a struct page instead of a virtual address */
void consistent_sync_page(struct page *page, unsigned long offset, size_t size, int direction)
/* consistent_sync_page make a page are consistent. identical to consistent_sync, but takes a struct page instead of a virtual address */ void consistent_sync_page(struct page *page, unsigned long offset, size_t size, int direction)
{ void *start; start = page_address(page) + offset; consistent_sync(start, size, direction); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* must only be called if ipath_pd is known to be allocated */
static void* ipath_get_egrbuf(struct ipath_devdata *dd, u32 bufnum)
/* must only be called if ipath_pd is known to be allocated */ static void* ipath_get_egrbuf(struct ipath_devdata *dd, u32 bufnum)
{ return dd->ipath_port0_skbinfo ? (void *) dd->ipath_port0_skbinfo[bufnum].skb->data : NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Attribute write call back for the Value V2 attribute. */
static ssize_t write_value_v2_6(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
/* Attribute write call back for the Value V2 attribute. */ static ssize_t write_value_v2_6(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
{ char *value = attr->user_data; if (offset >= sizeof(value_v2_6_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); if (offset + len > sizeof(value_v2_6_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); memcpy(value + offset, buf, len); return len; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* param base USDHC peripheral base address. param timeout Timeout to initialize card. retval true Set card active successfully. retval false Set card active failed. */
bool USDHC_SetCardActive(USDHC_Type *base, uint32_t timeout)
/* param base USDHC peripheral base address. param timeout Timeout to initialize card. retval true Set card active successfully. retval false Set card active failed. */ bool USDHC_SetCardActive(USDHC_Type *base, uint32_t timeout)
{ base->SYS_CTRL |= USDHC_SYS_CTRL_INITA_MASK; while ((base->SYS_CTRL & USDHC_SYS_CTRL_INITA_MASK) == USDHC_SYS_CTRL_INITA_MASK) { if (!timeout) { break; } timeout--; } return ((!timeout) ? false : true); }
nanoframework/nf-interpreter
C++
MIT License
293
/* In this example, user task fetches the sensor values every seconds. */
void user_task_periodic(void *pvParameters)
/* In this example, user task fetches the sensor values every seconds. */ void user_task_periodic(void *pvParameters)
{ uint16_t tvoc; uint16_t eco2; TickType_t last_wakeup = xTaskGetTickCount(); while (1) { if (ccs811_get_results (sensor, &tvoc, &eco2, 0, 0)) printf("%.3f CCS811 Sensor periodic: TVOC %d ppb, eCO2 %d ppm\n", (double)sdk_system_get_time()*1e-3, tvoc, eco2); vTaskDelayUntil(&last_wakeup, 1000 / portTICK_PERIOD_MS); } }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Read data with special length in master mode through the I2Cx peripheral under in-house IP. */
u8 I2C_MasterRead_Patch(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len)
/* Read data with special length in master mode through the I2Cx peripheral under in-house IP. */ u8 I2C_MasterRead_Patch(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len)
{ u8 cnt = 0; assert_param(IS_I2C_ALL_PERIPH(I2Cx)); for(cnt = 0; cnt < len; cnt++) { if(cnt >= len - 1) { I2Cx->IC_DATA_CMD = 0x0003 << 8; } else { I2Cx->IC_DATA_CMD = 0x0001 << 8; } while((I2C_CheckFlagState(I2Cx, BIT_IC_STATUS_RFNE)) == 0) { if(I2C_GetRawINT(I2Cx) & BIT_IC_RAW_INTR_STAT_TX_ABRT) { DBG_8195A(" TX_ABRT\n"); I2C_ClearAllINT(I2Cx); return cnt; } } *pBuf++ = (u8)I2Cx->IC_DATA_CMD; } return cnt; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* It is the caller's responsibility to check the NameSpaceRefNode has been removed from any list the node is part of. */
STATIC EFI_STATUS EFIAPI AmlDeleteNameSpaceRefNode(IN AML_NAMESPACE_REF_NODE *NameSpaceRefNode)
/* It is the caller's responsibility to check the NameSpaceRefNode has been removed from any list the node is part of. */ STATIC EFI_STATUS EFIAPI AmlDeleteNameSpaceRefNode(IN AML_NAMESPACE_REF_NODE *NameSpaceRefNode)
{ if (NameSpaceRefNode == NULL) { ASSERT (0); return EFI_INVALID_PARAMETER; } if (NameSpaceRefNode->RawAbsolutePath != NULL) { FreePool ((CHAR8 *)NameSpaceRefNode->RawAbsolutePath); } else { ASSERT (0); return EFI_INVALID_PARAMETER; } FreePool (NameSpaceRefNode); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT16 EFIAPI S3PciSegmentBitFieldRead16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT16 EFIAPI S3PciSegmentBitFieldRead16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit)
{ return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentBitFieldRead16 (Address, StartBit, EndBit)); }
tianocore/edk2
C++
Other
4,240
/* Minimum value of a q15 vector without index. */
void arm_min_no_idx_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult)
/* Minimum value of a q15 vector without index. */ void arm_min_no_idx_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult)
{ q15_t minVal1, out; uint32_t blkCnt; out = *pSrc++; blkCnt = (blockSize - 1U); while (blkCnt > 0U) { minVal1 = *pSrc++; if (out > minVal1) { out = minVal1; } blkCnt--; } *pResult = out; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Disables PCI-Express master access and verifies there are no pending requests. */
s32 e1000e_disable_pcie_master(struct e1000_hw *hw)
/* Disables PCI-Express master access and verifies there are no pending requests. */ s32 e1000e_disable_pcie_master(struct e1000_hw *hw)
{ u32 ctrl; s32 timeout = MASTER_DISABLE_TIMEOUT; ctrl = er32(CTRL); ctrl |= E1000_CTRL_GIO_MASTER_DISABLE; ew32(CTRL, ctrl); while (timeout) { if (!(er32(STATUS) & E1000_STATUS_GIO_MASTER_ENABLE)) break; udelay(100); timeout--; } if (!timeout) { e_dbg("Master requests are pending.\n"); return -E1000_ERR_MASTER_REQUESTS_PENDING; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Enable a expio pin's interrupt by clearing the bit in the imr. */
static void expio_unmask_irq(u32 irq)
/* Enable a expio pin's interrupt by clearing the bit in the imr. */ static void expio_unmask_irq(u32 irq)
{ u32 expio = MXC_IRQ_TO_EXPIO(irq); __raw_writew(1 << expio, PBC_INTMASK_SET_REG); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set a request's retransmit timeout based on the transport's default timeout parameters. Used by transports that don't adjust the retransmit timeout based on round-trip time estimation. */
void xprt_set_retrans_timeout_def(struct rpc_task *task)
/* Set a request's retransmit timeout based on the transport's default timeout parameters. Used by transports that don't adjust the retransmit timeout based on round-trip time estimation. */ void xprt_set_retrans_timeout_def(struct rpc_task *task)
{ task->tk_timeout = task->tk_rqstp->rq_timeout; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Allocate a memory block from a mail and set memory block to zero. */
void* osMailCAlloc(osMailQId queue_id, uint32_t millisec)
/* Allocate a memory block from a mail and set memory block to zero. */ void* osMailCAlloc(osMailQId queue_id, uint32_t millisec)
{ mem = sysMailAlloc(queue_id, millisec, 1U); } else { mem = __sysMailAlloc(queue_id, millisec, 0U); } pool = *(((void **)queue_id) + 1); rt_clr_box(pool, mem); return mem; }
labapart/polymcu
C++
null
201
/* Unregisters an interrupt handler for the DES module. */
void DESIntUnregister(uint32_t ui32Base)
/* Unregisters an interrupt handler for the DES module. */ void DESIntUnregister(uint32_t ui32Base)
{ ASSERT(ui32Base == DES_BASE); IntDisable(INT_DES0_TM4C129); IntUnregister(INT_DES0_TM4C129); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize RTC. This API is used to initialize the RTC to .97 ms per tick. */
void adi_RTCInit(void)
/* Initialize RTC. This API is used to initialize the RTC to .97 ms per tick. */ void adi_RTCInit(void)
{ ADI_RTC_RESULT eRTCResult; eRTCResult = adi_rtc_Open(ADI_RTC_DEVICE_NUM, aRtcDevMem, ADI_RTC_MEMORY_SIZE, &hDevice); if(eRTCResult == ADI_RTC_SUCCESS) { eRTCResult = adi_rtc_SetPreScale(hDevice, ADI_RTC_PRESCALAR); } if(eRTCResult == ADI_RTC_SUCCESS) { eRTCResult = adi_rtc_Enable(hDevice, true); } }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Same as for pxa_ep_enable, no physical endpoint configuration can be changed. Function flushes the endpoint and related requests. */
static int pxa_ep_disable(struct usb_ep *_ep)
/* Same as for pxa_ep_enable, no physical endpoint configuration can be changed. Function flushes the endpoint and related requests. */ static int pxa_ep_disable(struct usb_ep *_ep)
{ struct pxa_ep *ep; struct udc_usb_ep *udc_usb_ep; unsigned long flags; if (!_ep) return -EINVAL; udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); ep = udc_usb_ep->pxa_ep; if (!ep || is_ep0(ep) || !list_empty(&ep->queue)) return -EINVAL; spin_lock_irqsave(&ep->lock, flags); ep->enabled = 0; nuke(ep, -ESHUTDOWN); spin_unlock_irqrestore(&ep->lock, flags); pxa_ep_fifo_flush(_ep); udc_usb_ep->pxa_ep = NULL; ep_dbg(ep, "disabled\n"); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If hash digest is enabled, the function will update the hash while copying. Combining these two operations doesn't buy us a lot (yet), but in the future we could implement combined copy+crc, just way we do for network layer checksums. */
static int iscsi_tcp_segment_recv(struct iscsi_tcp_conn *tcp_conn, struct iscsi_segment *segment, const void *ptr, unsigned int len)
/* If hash digest is enabled, the function will update the hash while copying. Combining these two operations doesn't buy us a lot (yet), but in the future we could implement combined copy+crc, just way we do for network layer checksums. */ static int iscsi_tcp_segment_recv(struct iscsi_tcp_conn *tcp_conn, struct iscsi_segment *segment, const void *ptr, unsigned int len)
{ unsigned int copy = 0, copied = 0; while (!iscsi_tcp_segment_done(tcp_conn, segment, 1, copy)) { if (copied == len) { ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "copied %d bytes\n", len); break; } copy = min(len - copied, segment->size - segment->copied); ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "copying %d\n", copy); memcpy(segment->data + segment->copied, ptr + copied, copy); copied += copy; } return copied; }
robutest/uclinux
C++
GPL-2.0
60
/* This routine performs the special handling for LC HBA initialization. */
void lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
/* This routine performs the special handling for LC HBA initialization. */ void lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
{ int t; uint32_t *HashWorking; uint32_t *pwwnn = (uint32_t *) phba->wwnn; HashWorking = kcalloc(80, sizeof(uint32_t), GFP_KERNEL); if (!HashWorking) return; HashWorking[0] = HashWorking[78] = *pwwnn++; HashWorking[1] = HashWorking[79] = *pwwnn; for (t = 0; t < 7; t++) lpfc_challenge_key(phba->RandomData + t, HashWorking + t); lpfc_sha_init(hbainit); lpfc_sha_iterate(hbainit, HashWorking); kfree(HashWorking); }
robutest/uclinux
C++
GPL-2.0
60
/* Checks socket connection and wait if it is not connected. It should be called just after connect. */
static int Check_Connect_And_Wait_Connection(SOCKET sock, int connect_res)
/* Checks socket connection and wait if it is not connected. It should be called just after connect. */ static int Check_Connect_And_Wait_Connection(SOCKET sock, int connect_res)
{ struct timeval tmvTimeout = {DEFAULT_TCP_CONNECT_TIMEOUT, 0}; int result; fd_set fdSet; FD_ZERO(&fdSet); FD_SET(sock, &fdSet); if (connect_res < 0) { if (EINPROGRESS == errno ) { result = select(sock + 1, NULL, &fdSet, NULL, &tmvTimeout); if (result < 0) { return -1; } else if (result == 0) { return -1; } else { int valopt = 0; socklen_t len = sizeof(valopt); if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (void *) &valopt, &len) < 0) { return -1; } else if (valopt) { return -1; } } } } return 0; }
Nicholas3388/LuaNode
C++
Other
1,055
/* ZigBee Device Profile dissector for the permit joining response. */
void dissect_zbee_zdp_rsp_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the permit joining response. */ void dissect_zbee_zdp_rsp_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint8 status; status = zdp_parse_status(tree, tvb, &offset); zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Normally during a suspend, we allocate a new console and switch to it. When we resume, we switch back to the original console. This switch can be slow, so on systems where the framebuffer can handle restoration of video registers anyways, there's little point in doing the console switch. This function allows you to disable it by passing it '0'. */
void pm_set_vt_switch(int do_switch)
/* Normally during a suspend, we allocate a new console and switch to it. When we resume, we switch back to the original console. This switch can be slow, so on systems where the framebuffer can handle restoration of video registers anyways, there's little point in doing the console switch. This function allows you to disable it by passing it '0'. */ void pm_set_vt_switch(int do_switch)
{ acquire_console_sem(); disable_vt_switch = !do_switch; release_console_sem(); }
robutest/uclinux
C++
GPL-2.0
60