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
/* Message: UnregisterAckMessage Opcode: 0x0118 Type: RegistrationAndManagement Direction: pbx2dev VarLength: no */
static void handle_UnregisterAckMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: UnregisterAckMessage Opcode: 0x0118 Type: RegistrationAndManagement Direction: pbx2dev VarLength: no */ static void handle_UnregisterAckMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_status, 4, ENC_LITTLE_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This can only be called from code that is not holding cgroup_mutex (not nested in a cgroup_lock() call.) */
void rebuild_sched_domains(void)
/* This can only be called from code that is not holding cgroup_mutex (not nested in a cgroup_lock() call.) */ void rebuild_sched_domains(void)
{ do_rebuild_sched_domains(NULL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the driver name by ComponentName or ComponentName2 protocol according to the driver binding handle */
CHAR16* GetComponentName(IN EFI_HANDLE DriverBindingHandle)
/* Get the driver name by ComponentName or ComponentName2 protocol according to the driver binding handle */ CHAR16* GetComponentName(IN EFI_HANDLE DriverBindingHandle)
{ CHAR16 *DriverName; DriverName = GetComponentNameWorker (DriverBindingHandle, &gEfiComponentName2ProtocolGuid, L"PlatformLang"); if (DriverName == NULL) { DriverName = GetComponentNameWorker (DriverBindingHandle, &gEfiComponentNameProtocolGuid, L"Lang"); } return DriverName; }
tianocore/edk2
C++
Other
4,240
/* Rewinds the filedescriptor to the current buffer position and blows the file read ahead buffer. This is useful for third party uses of the scanners filedescriptor, which hooks onto the current scanning position. */
void g_scanner_sync_file_offset(GScanner *scanner)
/* Rewinds the filedescriptor to the current buffer position and blows the file read ahead buffer. This is useful for third party uses of the scanners filedescriptor, which hooks onto the current scanning position. */ void g_scanner_sync_file_offset(GScanner *scanner)
{ g_return_if_fail (scanner != NULL); if (scanner->input_fd >= 0 && scanner->text_end > scanner->text) { gint buffered; buffered = scanner->text_end - scanner->text; if (lseek (scanner->input_fd, - buffered, SEEK_CUR) >= 0) { scanner->text = NULL; scanner->text_end = NULL; } else errno = 0; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Locking: tty buffer lock. Driver locks in low latency mode. */
void tty_flip_buffer_push(struct tty_struct *tty)
/* Locking: tty buffer lock. Driver locks in low latency mode. */ void tty_flip_buffer_push(struct tty_struct *tty)
{ unsigned long flags; spin_lock_irqsave(&tty->buf.lock, flags); if (tty->buf.tail != NULL) tty->buf.tail->commit = tty->buf.tail->used; spin_unlock_irqrestore(&tty->buf.lock, flags); if (tty->low_latency) flush_to_ldisc(&tty->buf.work.work); else schedule_delayed_work(&tty->buf.work, 1); }
robutest/uclinux
C++
GPL-2.0
60
/* Clears a Stall condition on an endpoint of the Low Level Driver. */
USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
/* Clears a Stall condition on an endpoint of the Low Level Driver. */ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{ HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); return usb_status; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Set default values to timer fields and registers */
static void exynos4210_pwm_reset(DeviceState *d)
/* Set default values to timer fields and registers */ static void exynos4210_pwm_reset(DeviceState *d)
{ Exynos4210PWMState *s = EXYNOS4210_PWM(d); int i; s->reg_tcfg[0] = 0x0101; s->reg_tcfg[1] = 0x0; s->reg_tcon = 0; s->reg_tint_cstat = 0; for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { s->timer[i].reg_tcmpb = 0; s->timer[i].reg_tcntb = 0; exynos4210_pwm_update_freq(s, s->timer[i].id); ptimer_stop(s->timer[i].ptimer); } }
ve3wwg/teensy3_qemu
C++
Other
15
/* The generic unmapping function for on page in the DMA address space. */
static void dma_ops_domain_unmap(struct dma_ops_domain *dom, unsigned long address)
/* The generic unmapping function for on page in the DMA address space. */ static void dma_ops_domain_unmap(struct dma_ops_domain *dom, unsigned long address)
{ struct aperture_range *aperture; u64 *pte; if (address >= dom->aperture_size) return; aperture = dom->aperture[APERTURE_RANGE_INDEX(address)]; if (!aperture) return; pte = aperture->pte_pages[APERTURE_PAGE_INDEX(address)]; if (!pte) return; pte += PM_LEVEL_INDEX(0, address); WARN_ON(!*pte); *pte = 0ULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Convert a value to a string using an array; the macro tok2strary() in <netdissect.h> is the public interface to this function and ensures that the second argument is correct for bounds-checking. */
const char* tok2strary_internal(register const char **lp, int n, register const char *fmt, register int v)
/* Convert a value to a string using an array; the macro tok2strary() in <netdissect.h> is the public interface to this function and ensures that the second argument is correct for bounds-checking. */ const char* tok2strary_internal(register const char **lp, int n, register const char *fmt, register int v)
{ static char buf[TOKBUFSIZE]; if (v >= 0 && v < n && lp[v] != NULL) return lp[v]; if (fmt == NULL) fmt = "#%d"; (void)snprintf(buf, sizeof(buf), fmt, v); return (buf); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The function will check if IA32 PAE is supported. */
BOOLEAN IsIa32PaeSupported(VOID)
/* The function will check if IA32 PAE is supported. */ BOOLEAN IsIa32PaeSupported(VOID)
{ UINT32 RegEax; CPUID_VERSION_INFO_EDX RegEdx; AsmCpuid (CPUID_SIGNATURE, &RegEax, NULL, NULL, NULL); if (RegEax >= CPUID_VERSION_INFO) { AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &RegEdx.Uint32); if (RegEdx.Bits.PAE != 0) { return TRUE; } } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* diagnose code 0x210 - retrieve device information cc=0 normal completion, we have a real device cc=1 CP paging error cc=2 The virtual device exists, but is not associated with a real device cc=3 Invalid device address, or the virtual device does not exist */
static int get_urd_class(struct urdev *urd)
/* diagnose code 0x210 - retrieve device information cc=0 normal completion, we have a real device cc=1 CP paging error cc=2 The virtual device exists, but is not associated with a real device cc=3 Invalid device address, or the virtual device does not exist */ static int get_urd_class(struct urdev *urd)
{ static struct diag210 ur_diag210; int cc; ur_diag210.vrdcdvno = urd->dev_id.devno; ur_diag210.vrdclen = sizeof(struct diag210); cc = diag210(&ur_diag210); switch (cc) { case 0: return -EOPNOTSUPP; case 2: return ur_diag210.vrdcvcla; case 3: return -ENODEV; default: return -EIO; } }
robutest/uclinux
C++
GPL-2.0
60
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector28_handler(void)
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */ void Vector28_handler(void)
{ asm { LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (28 * 2)) JMP 0,X } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Compare the names @s1 and @s2 and return 'true' (1) if the names are identical, or 'false' (0) if they are not identical. If @ic is IGNORE_CASE, the @upcase table is used to performa a case insensitive comparison. */
bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic, const ntfschar *upcase, const u32 upcase_size)
/* Compare the names @s1 and @s2 and return 'true' (1) if the names are identical, or 'false' (0) if they are not identical. If @ic is IGNORE_CASE, the @upcase table is used to performa a case insensitive comparison. */ bool ntfs_are_names_equal(const ntfschar *s1, size_t s1_len, const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic, const ntfschar *upcase, const u32 upcase_size)
{ if (s1_len != s2_len) return false; if (ic == CASE_SENSITIVE) return !ntfs_ucsncmp(s1, s2, s1_len); return !ntfs_ucsncasecmp(s1, s2, s1_len, upcase, upcase_size); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns a pointer to the first element of dest (or the newly allocated copy) */
QEMUOptionParameter* append_option_parameters(QEMUOptionParameter *dest, QEMUOptionParameter *list)
/* Returns a pointer to the first element of dest (or the newly allocated copy) */ QEMUOptionParameter* append_option_parameters(QEMUOptionParameter *dest, QEMUOptionParameter *list)
{ size_t num_options, num_dest_options; num_options = count_option_parameters(dest); num_dest_options = num_options; num_options += count_option_parameters(list); dest = g_realloc(dest, (num_options + 1) * sizeof(QEMUOptionParameter)); dest[num_dest_options].name = NULL; while (list && list->name) { if (get_option_parameter(dest, list->name) == NULL) { dest[num_dest_options++] = *list; dest[num_dest_options].name = NULL; } list++; } return dest; }
ve3wwg/teensy3_qemu
C++
Other
15
/* Adds a new element at the head of the queue. */
void g_queue_push_head_link(GQueue *queue, GList *link)
/* Adds a new element at the head of the queue. */ void g_queue_push_head_link(GQueue *queue, GList *link)
{ g_return_if_fail (queue != NULL); g_return_if_fail (link != NULL); g_return_if_fail (link->prev == NULL); g_return_if_fail (link->next == NULL); link->next = queue->head; if (queue->head) queue->head->prev = link; else queue->tail = link; queue->head = link; queue->length++; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Neo specific way of turning on the receiver. Used as a way to un-enforce queue flow control when in hardware flow control mode. */
static void neo_enable_receiver(struct jsm_channel *ch)
/* Neo specific way of turning on the receiver. Used as a way to un-enforce queue flow control when in hardware flow control mode. */ static void neo_enable_receiver(struct jsm_channel *ch)
{ u8 tmp = readb(&ch->ch_neo_uart->ier); tmp |= (UART_IER_RDI); writeb(tmp, &ch->ch_neo_uart->ier); neo_pci_posting_flush(ch->ch_bd); }
robutest/uclinux
C++
GPL-2.0
60
/* Read the current ACPI tick counter using the counter address cached by this instance's constructor. */
UINT32 InternalAcpiGetTimerTick(VOID)
/* Read the current ACPI tick counter using the counter address cached by this instance's constructor. */ UINT32 InternalAcpiGetTimerTick(VOID)
{ return IoRead32 (BHYVE_ACPI_TIMER_IO_ADDR); }
tianocore/edk2
C++
Other
4,240
/* Triggers the update of the registers of one or several timers. */
void HRTIM_SoftwareUpdate(HRTIM_TypeDef *HRTIMx, uint32_t TimersToUpdate)
/* Triggers the update of the registers of one or several timers. */ void HRTIM_SoftwareUpdate(HRTIM_TypeDef *HRTIMx, uint32_t TimersToUpdate)
{ assert_param(IS_HRTIM_TIMERUPDATE(TimersToUpdate)); HRTIMx->HRTIM_COMMON.CR2 |= TimersToUpdate; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Reader for generic 'load' function: 'lua_load' uses the stack for internal stuff, so the reader cannot change the stack top. Instead, it keeps its resulting string in a reserved slot inside the stack. */
static const char* generic_reader(lua_State *L, void *ud, size_t *size)
/* Reader for generic 'load' function: 'lua_load' uses the stack for internal stuff, so the reader cannot change the stack top. Instead, it keeps its resulting string in a reserved slot inside the stack. */ static const char* generic_reader(lua_State *L, void *ud, size_t *size)
{ lua_pop(L, 1); *size = 0; return NULL; } else if (l_unlikely(!lua_isstring(L, -1))) luaL_error(L, "reader function must return a string"); lua_replace(L, RESERVEDSLOT); return lua_tolstring(L, RESERVEDSLOT, size); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Returns 1 if the list is empty, 0 if not empty and -1 in case of error */
int xmlListEmpty(xmlListPtr l)
/* Returns 1 if the list is empty, 0 if not empty and -1 in case of error */ int xmlListEmpty(xmlListPtr l)
{ if (l == NULL) return(-1); return (l->sentinel->next == l->sentinel); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* For Td guest TDVMCALL_IO is invoked to read I/O port. */
UINT16 EFIAPI IoRead16(IN UINTN Port)
/* For Td guest TDVMCALL_IO is invoked to read I/O port. */ UINT16 EFIAPI IoRead16(IN UINTN Port)
{ UINT16 Value; BOOLEAN Flag; ASSERT ((Port & 1) == 0); Flag = FilterBeforeIoRead (FilterWidth16, Port, &Value); if (Flag) { if (IsTdxGuest ()) { Value = TdIoRead16 (Port); } else { _ReadWriteBarrier (); Value = _inpw ((UINT16)Port); _ReadWriteBarrier (); } } FilterBeforeIoRead (FilterWidth16, Port, &Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* scsi_eh_ready_devs - check device ready state and recover if not. @shost: host to be recovered. @work_q: &list_head for pending commands. @done_q: &list_head for processed commands. */
void scsi_eh_ready_devs(struct Scsi_Host *shost, struct list_head *work_q, struct list_head *done_q)
/* scsi_eh_ready_devs - check device ready state and recover if not. @shost: host to be recovered. @work_q: &list_head for pending commands. @done_q: &list_head for processed commands. */ void scsi_eh_ready_devs(struct Scsi_Host *shost, struct list_head *work_q, struct list_head *done_q)
{ if (!scsi_eh_stu(shost, work_q, done_q)) if (!scsi_eh_bus_device_reset(shost, work_q, done_q)) if (!scsi_eh_target_reset(shost, work_q, done_q)) if (!scsi_eh_bus_reset(shost, work_q, done_q)) if (!scsi_eh_host_reset(work_q, done_q)) scsi_eh_offline_sdevs(work_q, done_q); }
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the specified HASH interrupt has occurred or not. */
ITStatus HASH_GetITStatus(uint32_t HASH_IT)
/* Checks whether the specified HASH interrupt has occurred or not. */ ITStatus HASH_GetITStatus(uint32_t HASH_IT)
{ ITStatus bitstatus = RESET; uint32_t tmpreg = 0; assert_param(IS_HASH_GET_IT(HASH_IT)); tmpreg = HASH->SR; if (((HASH->IMR & tmpreg) & HASH_IT) != RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
MaJerle/stm32f429
C++
null
2,036
/* Validates the given user key for flash erase APIs. */
static status_t flash_check_user_key(uint32_t key)
/* Validates the given user key for flash erase APIs. */ static status_t flash_check_user_key(uint32_t key)
{ if (key != kFLASH_apiEraseKey) { return kStatus_FLASH_EraseKeyError; } return kStatus_FLASH_Success; }
labapart/polymcu
C++
null
201
/* Notes wrt boundary cases: This function sets the OCR bits for all boundary voltages, for example range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_34_35 mask. */
u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
/* Notes wrt boundary cases: This function sets the OCR bits for all boundary voltages, for example range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_34_35 mask. */ u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
{ u32 mask = 0; if (vdd_max < vdd_min) return 0; vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false); if (vdd_max < 0) return 0; vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true); if (vdd_min < 0) return 0; while (vdd_max >= vdd_min) mask |= 1 << vdd_max--; return mask; }
robutest/uclinux
C++
GPL-2.0
60
/* zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO @qdio: pointer to struct zfcp_qdio @q_req: pointer to struct zfcp_queue_req Returns: 0 on success, error otherwise */
int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req)
/* zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO @qdio: pointer to struct zfcp_qdio @q_req: pointer to struct zfcp_queue_req Returns: 0 on success, error otherwise */ int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req)
{ struct zfcp_qdio_queue *req_q = &qdio->req_q; int first = q_req->sbal_first; int count = q_req->sbal_number; int retval; unsigned int qdio_flags = QDIO_FLAG_SYNC_OUTPUT; zfcp_qdio_account(qdio); retval = do_QDIO(qdio->adapter->ccw_device, qdio_flags, 0, first, count); if (unlikely(retval)) { zfcp_qdio_zero_sbals(req_q->sbal, first, count); return retval; } atomic_sub(count, &req_q->count); req_q->first += count; req_q->first %= QDIO_MAX_BUFFERS_PER_Q; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Calculate CRC32 value of the input memory. The read value must be complemented to match standard CRC32 implementations or kept non-inverted if used as starting point for subsequent CRC32 calculations. */
enum status_code dsu_crc32_cal(const uint32_t addr, const uint32_t len, uint32_t *pcrc32)
/* Calculate CRC32 value of the input memory. The read value must be complemented to match standard CRC32 implementations or kept non-inverted if used as starting point for subsequent CRC32 calculations. */ enum status_code dsu_crc32_cal(const uint32_t addr, const uint32_t len, uint32_t *pcrc32)
{ if (addr & 0x00000003) { return STATUS_ERR_BAD_ADDRESS; } DSU->DATA.reg = *pcrc32; DSU->ADDR.reg = addr; DSU->LENGTH.reg = len; DSU->CTRL.bit.CRC = 1; while ((DSU->STATUSA.reg & DSU_STATUSA_DONE) != 1) { } if (DSU->STATUSA.reg & DSU_STATUSA_BERR) { return STATUS_ERR_IO; } *pcrc32 = DSU->DATA.reg; DSU->STATUSA.reg = DSU_STATUSA_DONE; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Reads and returns the current value of MM4. This function is only available on IA-32 and x64. */
UINT64 EFIAPI AsmReadMm4(VOID)
/* Reads and returns the current value of MM4. This function is only available on IA-32 and x64. */ UINT64 EFIAPI AsmReadMm4(VOID)
{ _asm { push eax push eax movq [esp], mm4 pop eax pop edx emms } }
tianocore/edk2
C++
Other
4,240
/* Internal pulls feature: None, weak pull-up, weak pull-down, or repeater mode (both pulls enabled). We do not touch this field unless one or more of the DT booleans are set. If the no-bias boolean is set then disable internal pulls. If pull up and/or down is set enable the respective pull or both for what MCHP calls repeater(keeper) mode. */
static uint32_t prog_pud(uint32_t pcr1, uint32_t conf)
/* Internal pulls feature: None, weak pull-up, weak pull-down, or repeater mode (both pulls enabled). We do not touch this field unless one or more of the DT booleans are set. If the no-bias boolean is set then disable internal pulls. If pull up and/or down is set enable the respective pull or both for what MCHP calls repeater(keeper) mode. */ static uint32_t prog_pud(uint32_t pcr1, uint32_t conf)
{ if (conf & BIT(MCHP_XEC_NO_PUD_POS)) { pcr1 &= ~(MCHP_GPIO_CTRL_PUD_MASK); pcr1 |= MCHP_GPIO_CTRL_PUD_NONE; return pcr1; } if (conf & (BIT(MCHP_XEC_PU_POS) | BIT(MCHP_XEC_PD_POS))) { pcr1 &= ~(MCHP_GPIO_CTRL_PUD_MASK); if (conf & BIT(MCHP_XEC_PU_POS)) { pcr1 |= MCHP_GPIO_CTRL_PUD_PU; } if (conf & BIT(MCHP_XEC_PD_POS)) { pcr1 |= MCHP_GPIO_CTRL_PUD_PD; } } return pcr1; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Converts a SD (Secure Digital) device path structure to its string representative. */
VOID DevPathToTextSd(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a SD (Secure Digital) device path structure to its string representative. */ VOID DevPathToTextSd(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ SD_DEVICE_PATH *Sd; Sd = DevPath; UefiDevicePathLibCatPrint ( Str, L"SD(0x%x)", Sd->SlotNumber ); }
tianocore/edk2
C++
Other
4,240
/* The constructor function caches the PCI Express Base Address */
EFI_STATUS EFIAPI SmmPciExpressLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The constructor function caches the PCI Express Base Address */ EFI_STATUS EFIAPI SmmPciExpressLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ mSmmPciExpressLibPciExpressBaseAddress = (UINTN)PcdGet64 (PcdPciExpressBaseAddress); mSmmPciExpressLibPciExpressBaseSize = (UINTN)PcdGet64 (PcdPciExpressBaseSize); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI S3PciAnd32(IN UINTN Address, IN UINT32 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI S3PciAnd32(IN UINTN Address, IN UINT32 AndData)
{ return InternalSavePciWrite32ValueToBootScript (Address, PciAnd32 (Address, AndData)); }
tianocore/edk2
C++
Other
4,240
/* If this interface is not supported, then return FALSE. */
STATIC BOOLEAN HmacMdAll(IN CONST EVP_MD *Md, 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. */ STATIC BOOLEAN HmacMdAll(IN CONST EVP_MD *Md, IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
{ UINT32 Length; HMAC_CTX *Ctx; BOOLEAN RetVal; Ctx = HMAC_CTX_new (); if (Ctx == NULL) { return FALSE; } RetVal = (BOOLEAN)HMAC_CTX_reset (Ctx); if (!RetVal) { goto Done; } RetVal = (BOOLEAN)HMAC_Init_ex (Ctx, Key, (UINT32)KeySize, Md, NULL); if (!RetVal) { goto Done; } RetVal = (BOOLEAN)HMAC_Update (Ctx, Data, DataSize); if (!RetVal) { goto Done; } RetVal = (BOOLEAN)HMAC_Final (Ctx, HmacValue, &Length); if (!RetVal) { goto Done; } Done: HMAC_CTX_free (Ctx); return RetVal; }
tianocore/edk2
C++
Other
4,240
/* Returns: 0 if the DDP context was not configured */
static int fcoe_ddp_setup(struct fc_lport *, u16, struct scatterlist *, unsigned int)
/* Returns: 0 if the DDP context was not configured */ static int fcoe_ddp_setup(struct fc_lport *, u16, struct scatterlist *, unsigned int)
{ struct net_device *netdev = fcoe_netdev(lport); if (netdev->netdev_ops->ndo_fcoe_ddp_setup) return netdev->netdev_ops->ndo_fcoe_ddp_setup(netdev, xid, sgl, sgc); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This PDC call is meant to be used to check the integrity of the current contents of Stable Storage. */
int pdc_stable_verify_contents(void)
/* This PDC call is meant to be used to check the integrity of the current contents of Stable Storage. */ int pdc_stable_verify_contents(void)
{ int retval; unsigned long flags; spin_lock_irqsave(&pdc_lock, flags); retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_VERIFY_CONTENTS); spin_unlock_irqrestore(&pdc_lock, flags); return retval; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* See section 8.3.2.3.5 of the 1394-1995 spec, section 6.2 of the SBP-2 spec, and section 6.4 of the SBP-3 spec for further details. */
static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
/* See section 8.3.2.3.5 of the 1394-1995 spec, section 6.2 of the SBP-2 spec, and section 6.4 of the SBP-3 spec for further details. */ static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
{ struct fw_device *device = target_device(lu->tgt); __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, lu->tgt->node_id, lu->generation, device->max_speed, CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, &d, sizeof(d)); }
robutest/uclinux
C++
GPL-2.0
60
/* Attempt to connect a terminal emulator to the slave side of the pty If -attach_uart_cmd=<cmd> is provided as a command line option, <cmd> will be used. Otherwise, the default command, CONFIG_NATIVE_UART_AUTOATTACH_DEFAULT_CMD, will be used instead */
static void attach_to_tty(const char *slave_tty, const char *auto_attach_cmd)
/* Attempt to connect a terminal emulator to the slave side of the pty If -attach_uart_cmd=<cmd> is provided as a command line option, <cmd> will be used. Otherwise, the default command, CONFIG_NATIVE_UART_AUTOATTACH_DEFAULT_CMD, will be used instead */ static void attach_to_tty(const char *slave_tty, const char *auto_attach_cmd)
{ char command[strlen(auto_attach_cmd) + strlen(slave_tty) + 1]; sprintf(command, auto_attach_cmd, slave_tty); int ret = system(command); if (ret != 0) { WARN("Could not attach to the UART with \"%s\"\n", command); WARN("The command returned %i\n", WEXITSTATUS(ret)); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Determine if data message is last one for the parent call. */
bool rxrpc_kernel_is_data_last(struct sk_buff *skb)
/* Determine if data message is last one for the parent call. */ bool rxrpc_kernel_is_data_last(struct sk_buff *skb)
{ struct rxrpc_skb_priv *sp = rxrpc_skb(skb); ASSERTCMP(skb->mark, ==, RXRPC_SKB_MARK_DATA); return sp->hdr.flags & RXRPC_LAST_PACKET; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* ixgbe_atr_set_src_port_82599 - Sets the source port @input: input stream to modify @src_port: the source port to load */
s32 ixgbe_atr_set_src_port_82599(struct ixgbe_atr_input *input, u16 src_port)
/* ixgbe_atr_set_src_port_82599 - Sets the source port @input: input stream to modify @src_port: the source port to load */ s32 ixgbe_atr_set_src_port_82599(struct ixgbe_atr_input *input, u16 src_port)
{ input->byte_stream[IXGBE_ATR_SRC_PORT_OFFSET + 1] = src_port >> 8; input->byte_stream[IXGBE_ATR_SRC_PORT_OFFSET] = src_port & 0xff; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Registers an interrupt handler for the I2C module. */
void I2CIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
/* Registers an interrupt handler for the I2C module. */ void I2CIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
{ unsigned long ulInt; ASSERT(I2CMasterBaseValid(ulBase)); ulInt = I2CIntNumberGet(ulBase); IntRegister(ulInt, pfnHandler); IntEnable(ulInt); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* To exclude mutual BO access we rely on bo_reserve exclusion, as all function are calling it. */
static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo)
/* To exclude mutual BO access we rely on bo_reserve exclusion, as all function are calling it. */ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo)
{ struct radeon_bo *bo; bo = container_of(tbo, struct radeon_bo, tbo); mutex_lock(&bo->rdev->gem.mutex); list_del_init(&bo->list); mutex_unlock(&bo->rdev->gem.mutex); radeon_bo_clear_surface_reg(bo); kfree(bo); }
robutest/uclinux
C++
GPL-2.0
60
/* Proxies the old style dissector interface to the new style. */
static int dissect_ceph_old(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
/* Proxies the old style dissector interface to the new style. */ static int dissect_ceph_old(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{ dissect_ceph(tvb, pinfo, tree, data); return tvb_captured_length(tvb); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Handle an interrupt triggered when a pad is touched. Recognize what pad has been touched and save it in a table. */
static void tp_example_rtc_intr(void *arg)
/* Handle an interrupt triggered when a pad is touched. Recognize what pad has been touched and save it in a table. */ static void tp_example_rtc_intr(void *arg)
{ uint32_t pad_intr = touch_pad_get_status(); touch_pad_clear_status(); for (int i = 0; i < TOUCH_PAD_MAX; i++) { if ((pad_intr >> i) & 0x01) { s_pad_activated[i] = true; } } }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* and look at the resulting assemble code in serial.s. */
static void rs_sched_event(struct e100_serial *info, int event)
/* and look at the resulting assemble code in serial.s. */ static void rs_sched_event(struct e100_serial *info, int event)
{ if (info->event & (1 << event)) return; info->event |= 1 << event; schedule_work(&info->work); }
robutest/uclinux
C++
GPL-2.0
60
/* add all etch symbols from file to our symbol cache */
static void add_symbols_of_file(const char *filename)
/* add all etch symbols from file to our symbol cache */ static void add_symbols_of_file(const char *filename)
{ FILE *pFile; pFile = ws_fopen(filename, "r"); if (pFile != NULL) { char line[256]; while (fgets(line, sizeof line, pFile) != NULL) { unsigned int hash; size_t length, pos; length = strlen(line); if (length < 10) continue; pos = length - 1; while (pos > 0 && (line[pos] == 0xD || line[pos] == 0xA)) { pos--; } line[pos + 1] = '\0'; if (sscanf(&line[0], "%x", &hash) != 1) continue; pos = strcspn(line, ","); if ((line[pos] != '\0') && (line[pos+1] !='\0')) gbl_symbols_array_append(hash, g_strdup_printf("%." ETCH_MAX_SYMBOL_LENGTH "s", &line[pos+1])); } fclose(pFile); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Initialize a MTFTP protocol instance which is the child of MtftpSb. */
VOID Mtftp4InitProtocol(IN MTFTP4_SERVICE *MtftpSb, OUT MTFTP4_PROTOCOL *Instance)
/* Initialize a MTFTP protocol instance which is the child of MtftpSb. */ VOID Mtftp4InitProtocol(IN MTFTP4_SERVICE *MtftpSb, OUT MTFTP4_PROTOCOL *Instance)
{ ZeroMem (Instance, sizeof (MTFTP4_PROTOCOL)); Instance->Signature = MTFTP4_PROTOCOL_SIGNATURE; InitializeListHead (&Instance->Link); CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4)); Instance->State = MTFTP4_STATE_UNCONFIGED; Instance->Service = MtftpSb; InitializeListHead (&Instance->Blocks); }
tianocore/edk2
C++
Other
4,240
/* Currently, the intranode memory hole support assumes that each slot contains at least 32 MBytes of memory. We assume all bootmem data fits on the first slot. */
void __init prom_meminit(void)
/* Currently, the intranode memory hole support assumes that each slot contains at least 32 MBytes of memory. We assume all bootmem data fits on the first slot. */ void __init prom_meminit(void)
{ cnodeid_t node; mlreset(); szmem(); for (node = 0; node < MAX_COMPACT_NODES; node++) { if (node_online(node)) { node_mem_init(node); continue; } __node_data[node] = &null_node; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Escapes a string for use within an SQL statement. Returns a string with the escaped string. */
static int conn_escape(lua_State *L)
/* Escapes a string for use within an SQL statement. Returns a string with the escaped string. */ static int conn_escape(lua_State *L)
{ lua_pushlstring (L, to, len); return 1; } else return luasql_faildirect (L, PQerrorMessage (conn->pg_conn)); }
DC-SWAT/DreamShell
C++
null
404
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details. */
EFI_STATUS SdPeimHcStopClock(IN UINTN Bar)
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details. */ EFI_STATUS SdPeimHcStopClock(IN UINTN Bar)
{ EFI_STATUS Status; UINT32 PresentState; UINT16 ClockCtrl; Status = SdPeimHcWaitMmioSet ( Bar + SD_HC_PRESENT_STATE, sizeof (PresentState), BIT0 | BIT1, 0, SD_TIMEOUT ); if (EFI_ERROR (Status)) { return Status; } ClockCtrl = (UINT16) ~BIT2; Status = SdPeimHcAndMmio (Bar + SD_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl); return Status; }
tianocore/edk2
C++
Other
4,240
/* Starts the TIMER hall sensor interface in interrupt mode. */
void ald_timer_hall_sensor_start_by_it(ald_timer_handle_t *hperh)
/* Starts the TIMER hall sensor interface in interrupt mode. */ void ald_timer_hall_sensor_start_by_it(ald_timer_handle_t *hperh)
{ assert_param(IS_TIMER_XOR_INSTANCE(hperh->perh)); ald_timer_interrupt_config(hperh, ALD_TIMER_IT_CC1, ENABLE); timer_ccx_channel_cmd(hperh->perh, ALD_TIMER_CHANNEL_1, ENABLE); ALD_TIMER_ENABLE(hperh); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Frees the allocated memory (give it back to the request mempool). */
static void i2o_block_request_free(struct i2o_block_request *ireq)
/* Frees the allocated memory (give it back to the request mempool). */ static void i2o_block_request_free(struct i2o_block_request *ireq)
{ mempool_free(ireq, i2o_blk_req_pool.pool); }
robutest/uclinux
C++
GPL-2.0
60
/* unhash a timewait socket from established hash, if hashed. ehash lock must be held by caller. Returns 1 if caller should call inet_twsk_put() after lock release. */
int inet_twsk_unhash(struct inet_timewait_sock *tw)
/* unhash a timewait socket from established hash, if hashed. ehash lock must be held by caller. Returns 1 if caller should call inet_twsk_put() after lock release. */ int inet_twsk_unhash(struct inet_timewait_sock *tw)
{ if (hlist_nulls_unhashed(&tw->tw_node)) return 0; hlist_nulls_del_rcu(&tw->tw_node); sk_nulls_node_init(&tw->tw_node); return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the Gic version of am interrupt-controller node. */
EFI_STATUS EFIAPI GetGicVersion(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT UINT32 *GicVersion)
/* Get the Gic version of am interrupt-controller node. */ EFI_STATUS EFIAPI GetGicVersion(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT UINT32 *GicVersion)
{ if ((Fdt == NULL) || (GicVersion == NULL)) { ASSERT (0); return EFI_INVALID_PARAMETER; } if (FdtNodeIsCompatible (Fdt, IntcNode, &GicV2CompatibleInfo)) { *GicVersion = 2; } else if (FdtNodeIsCompatible (Fdt, IntcNode, &GicV3CompatibleInfo)) { *GicVersion = 3; } else { ASSERT (0); return EFI_UNSUPPORTED; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This function is intended for internal access for shell commands only. */
EFI_STATUS EFIAPI ShellInitialize(VOID)
/* This function is intended for internal access for shell commands only. */ EFI_STATUS EFIAPI ShellInitialize(VOID)
{ EFI_STATUS Status; if (PcdGetBool (PcdShellLibAutoInitialize) != 0) { return (EFI_SUCCESS); } Status = ShellLibDestructor (gImageHandle, gST); ASSERT_EFI_ERROR (Status); return (ShellLibConstructorWorker (gImageHandle, gST)); }
tianocore/edk2
C++
Other
4,240
/* Get the MCG external reference clock frequency. Get the current MCG external reference clock frequency in Hz. It is the frequency select by MCG_C7. This is an internal function. */
static uint32_t CLOCK_GetMcgExtClkFreq(void)
/* Get the MCG external reference clock frequency. Get the current MCG external reference clock frequency in Hz. It is the frequency select by MCG_C7. This is an internal function. */ static uint32_t CLOCK_GetMcgExtClkFreq(void)
{ uint32_t freq; switch (MCG_C7_OSCSEL_VAL) { case 0U: assert(g_xtal0Freq); freq = g_xtal0Freq; break; case 1U: assert(g_xtal32Freq); freq = g_xtal32Freq; break; case 2U: freq = MCG_INTERNAL_IRC_48M; break; default: freq = 0U; break; } return freq; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Do the transfer (low level): May use interrupt-driven or polling, depending on if an IRQ is presently registered. NOTE: Assumes data->lock is held. */
static enum pmcmsptwi_xfer_result pmcmsptwi_do_xfer(u32 reg, struct pmcmsptwi_data *data)
/* Do the transfer (low level): May use interrupt-driven or polling, depending on if an IRQ is presently registered. NOTE: Assumes data->lock is held. */ static enum pmcmsptwi_xfer_result pmcmsptwi_do_xfer(u32 reg, struct pmcmsptwi_data *data)
{ dev_dbg(&pmcmsptwi_adapter.dev, "Writing cmd reg 0x%08x\n", reg); pmcmsptwi_writel(reg, data->iobase + MSP_TWI_CMD_REG_OFFSET); if (data->irq) { unsigned long timeleft = wait_for_completion_timeout( &data->wait, MSP_IRQ_TIMEOUT); if (timeleft == 0) { dev_dbg(&pmcmsptwi_adapter.dev, "Result: IRQ timeout\n"); complete(&data->wait); data->last_result = MSP_TWI_XFER_TIMEOUT; } } else pmcmsptwi_poll_complete(data); return data->last_result; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the number of bytes written, or -1 if lack of space. The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable. */
static int UTF8ToUTF8(unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
/* Returns the number of bytes written, or -1 if lack of space. The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable. */ static int UTF8ToUTF8(unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
{ int len; if ((out == NULL) || (inb == NULL) || (outlen == NULL) || (inlenb == NULL)) return(-1); if (*outlen > *inlenb) { len = *inlenb; } else { len = *outlen; } if (len < 0) return(-1); memcpy(out, inb, len); *outlen = len; *inlenb = len; return(*outlen); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* release a list of pages, invalidating them first if need be */
static void read_cache_pages_invalidate_pages(struct address_space *mapping, struct list_head *pages)
/* release a list of pages, invalidating them first if need be */ static void read_cache_pages_invalidate_pages(struct address_space *mapping, struct list_head *pages)
{ struct page *victim; while (!list_empty(pages)) { victim = list_to_page(pages); list_del(&victim->lru); read_cache_pages_invalidate_page(mapping, victim); } }
robutest/uclinux
C++
GPL-2.0
60
/* Get reference to basic frame window. This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. */
struct win_window* wtk_basic_frame_as_child(struct wtk_basic_frame *basic_frame)
/* Get reference to basic frame window. This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. */ struct win_window* wtk_basic_frame_as_child(struct wtk_basic_frame *basic_frame)
{ Assert(basic_frame); return basic_frame->win; }
memfault/zero-to-main
C++
null
200
/* Returns NULL if not found, otherwise the xmlAttrPtr defining the ID */
xmlAttrPtr xmlGetID(xmlDocPtr doc, const xmlChar *ID)
/* Returns NULL if not found, otherwise the xmlAttrPtr defining the ID */ xmlAttrPtr xmlGetID(xmlDocPtr doc, const xmlChar *ID)
{ return(NULL); } if (ID == NULL) { return(NULL); } table = (xmlIDTablePtr) doc->ids; if (table == NULL) return(NULL); id = xmlHashLookup(table, ID); if (id == NULL) return(NULL); if (id->attr == NULL) { return((xmlAttrPtr) doc); } return(id->attr); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Discard all of the inodes for a given superblock. If the discard fails because there are busy inodes then a non zero value is returned. If the discard is successful all the inodes have been discarded. */
int invalidate_inodes(struct super_block *sb)
/* Discard all of the inodes for a given superblock. If the discard fails because there are busy inodes then a non zero value is returned. If the discard is successful all the inodes have been discarded. */ int invalidate_inodes(struct super_block *sb)
{ int busy; LIST_HEAD(throw_away); down_write(&iprune_sem); spin_lock(&inode_lock); inotify_unmount_inodes(&sb->s_inodes); fsnotify_unmount_inodes(&sb->s_inodes); busy = invalidate_list(&sb->s_inodes, &throw_away); spin_unlock(&inode_lock); dispose_list(&throw_away); up_write(&iprune_sem); return busy; }
robutest/uclinux
C++
GPL-2.0
60
/* The function is used to Enable BOD function. */
void SysCtlBODEnable(xtBoolean bEnable)
/* The function is used to Enable BOD function. */ void SysCtlBODEnable(xtBoolean bEnable)
{ SysCtlKeyAddrUnlock(); if(bEnable) { xHWREG(GCR_BODCR) |= GCR_BODCR_BOD_EN; } else { xHWREG(GCR_BODCR) &= GCR_BODCR_BOD_EN; } SysCtlKeyAddrLock(); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Disable RTC Timer wake-up function that chip can be waken up from power down mode by Time Tick or Alarm Match. */
void RTCWakeupDisable(void)
/* Disable RTC Timer wake-up function that chip can be waken up from power down mode by Time Tick or Alarm Match. */ void RTCWakeupDisable(void)
{ RTCWriteEnable(); xHWREG(RTC_TTR) &= ~RTC_TTR_TWKE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Writes N bytes of data in the Mailbox, starting from first Mailbox Address. */
int32_t BSP_NFCTAG_WriteMailboxData(uint32_t Instance, const uint8_t *const pData, const uint16_t NbByte)
/* Writes N bytes of data in the Mailbox, starting from first Mailbox Address. */ int32_t BSP_NFCTAG_WriteMailboxData(uint32_t Instance, const uint8_t *const pData, const uint16_t NbByte)
{ UNUSED(Instance); return ST25DV_WriteMailboxData(&NfcTagObj, pData, NbByte); }
eclipse-threadx/getting-started
C++
Other
310
/* Retrieve maximum EP size Function Called during EndPoint configuration Return Value: maximum size for given EP */
static int USBD_GetSizeEP(uint32_t EPNum)
/* Retrieve maximum EP size Function Called during EndPoint configuration Return Value: maximum size for given EP */ static int USBD_GetSizeEP(uint32_t EPNum)
{ case 0: return (64); case 1: case 2: return (512); case 3: case 4: return (64); case 5: case 6: return (1024); default: return (0); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* That one should not be called, macio isn't really a hotswap device, we don't expect one of those serial ports to go away... */
static int pmz_detach(struct macio_dev *mdev)
/* That one should not be called, macio isn't really a hotswap device, we don't expect one of those serial ports to go away... */ static int pmz_detach(struct macio_dev *mdev)
{ struct uart_pmac_port *uap = dev_get_drvdata(&mdev->ofdev.dev); if (!uap) return -ENODEV; if (uap->flags & PMACZILOG_FLAG_RSRC_REQUESTED) { macio_release_resources(uap->dev); uap->flags &= ~PMACZILOG_FLAG_RSRC_REQUESTED; } dev_set_drvdata(&mdev->ofdev.dev, NULL); uap->dev = NULL; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Set the TWI bus speed in conjunction with the clock frequency. */
status_code_t twim_set_speed(Twim *twim, uint32_t speed, uint32_t clk, uint8_t cycles)
/* Set the TWI bus speed in conjunction with the clock frequency. */ status_code_t twim_set_speed(Twim *twim, uint32_t speed, uint32_t clk, uint8_t cycles)
{ uint32_t f_prescaled; uint8_t cwgr_exp = 0; f_prescaled = (clk / speed / 2); while ((f_prescaled > 0xFF) && (cwgr_exp <= 0x7)) { cwgr_exp++; f_prescaled /= 2; } if (cwgr_exp > 0x7) { return ERR_INVALID_ARG; } twim->TWIM_CWGR = TWIM_CWGR_LOW(f_prescaled / 2) | TWIM_CWGR_HIGH(f_prescaled - f_prescaled / 2) | TWIM_CWGR_EXP(cwgr_exp) | TWIM_CWGR_DATA(cycles) | TWIM_CWGR_STASTO(f_prescaled); return STATUS_OK; }
remotemcu/remcu-chip-sdks
C++
null
436
/* The function is used to Enable low voltage reset. */
void SysCtlLowVoltRstEnable(xtBoolean bEnable)
/* The function is used to Enable low voltage reset. */ void SysCtlLowVoltRstEnable(xtBoolean bEnable)
{ SysCtlKeyAddrUnlock(); if(bEnable) { xHWREG(GCR_BODCR) |= GCR_BODCR_LVR_EN; } else { xHWREG(GCR_BODCR) &= GCR_BODCR_LVR_EN; } SysCtlKeyAddrLock(); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* When double tap recognition is enabled, this register expresses the maximum time between two consecutive detected taps to determine a double tap event. The default value of these bits is 0000b which corresponds to 16*ODR_XL time. If the DUR bits are set to a different value, 1LSB corresponds to 32*ODR_XL time.. */
int32_t lsm6dso_tap_dur_get(lsm6dso_ctx_t *ctx, uint8_t *val)
/* When double tap recognition is enabled, this register expresses the maximum time between two consecutive detected taps to determine a double tap event. The default value of these bits is 0000b which corresponds to 16*ODR_XL time. If the DUR bits are set to a different value, 1LSB corresponds to 32*ODR_XL time.. */ int32_t lsm6dso_tap_dur_get(lsm6dso_ctx_t *ctx, uint8_t *val)
{ lsm6dso_int_dur2_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)&reg, 1); *val = reg.dur; return ret; }
alexander-g-dean/ESF
C++
null
41
/* Decoding 10 bits and return the byte (Decoding 5B/4B) */
__STATIC_INLINE int16_t Decode10Bit(uint32_t value)
/* Decoding 10 bits and return the byte (Decoding 5B/4B) */ __STATIC_INLINE int16_t Decode10Bit(uint32_t value)
{ uint8_t v0,v1; v0 = decoding5b4b[(value >> 0) & 0x1F]; v1 = decoding5b4b[(value >> 5) & 0x1F]; if (v0 == CODE_5B_INVALID || v1 == CODE_5B_INVALID) { return -1; } return v0 | (v1<<4); }
st-one/X-CUBE-USB-PD
C++
null
110
/* This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set. */
BOOLEAN EFIAPI LogPerformanceMeasurementEnabled(IN CONST UINTN Type)
/* This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set. */ BOOLEAN EFIAPI LogPerformanceMeasurementEnabled(IN CONST UINTN Type)
{ if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Returns the UART hardware flow control mode currently in use. */
unsigned long UARTFlowControlGet(unsigned long ulBase)
/* Returns the UART hardware flow control mode currently in use. */ unsigned long UARTFlowControlGet(unsigned long ulBase)
{ ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL); ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) || (ulBase == UART2_BASE)); return(HWREG(ulBase + UART_O_CTL) & (UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)); }
watterott/WebRadio
C++
null
71
/* Execute FMC_ISPCMD_BLOCK_ERASE command to erase a flash block. The block size is 4 pages. */
int32_t FMC_Erase_Block(uint32_t u32BlockAddr)
/* Execute FMC_ISPCMD_BLOCK_ERASE command to erase a flash block. The block size is 4 pages. */ int32_t FMC_Erase_Block(uint32_t u32BlockAddr)
{ int32_t ret = 0; FMC->ISPCMD = FMC_ISPCMD_BLOCK_ERASE; FMC->ISPADDR = u32BlockAddr; FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) { } if (FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) { FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk; ret = -1; } return ret; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Called after an ethtool operation. Restore the chip back to D3 state if it isn't running. */
static void velocity_ethtool_down(struct net_device *dev)
/* Called after an ethtool operation. Restore the chip back to D3 state if it isn't running. */ static void velocity_ethtool_down(struct net_device *dev)
{ struct velocity_info *vptr = netdev_priv(dev); if (!netif_running(dev)) pci_set_power_state(vptr->pdev, PCI_D3hot); }
robutest/uclinux
C++
GPL-2.0
60
/* igbvf_watchdog - Timer Call-back @data: pointer to adapter cast into an unsigned long */
static void igbvf_watchdog(unsigned long data)
/* igbvf_watchdog - Timer Call-back @data: pointer to adapter cast into an unsigned long */ static void igbvf_watchdog(unsigned long data)
{ struct igbvf_adapter *adapter = (struct igbvf_adapter *) data; schedule_work(&adapter->watchdog_task); }
robutest/uclinux
C++
GPL-2.0
60
/* socket drivers are expected to use the following callbacks in their .drv struct: */
static int socket_early_resume(struct pcmcia_socket *skt)
/* socket drivers are expected to use the following callbacks in their .drv struct: */ static int socket_early_resume(struct pcmcia_socket *skt)
{ skt->socket = dead_socket; skt->ops->init(skt); skt->ops->set_socket(skt, &skt->socket); if (skt->state & SOCKET_PRESENT) skt->resume_status = socket_setup(skt, resume_delay); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* The number of days since January 1. (0 to 365) */
int rtc_year_days(unsigned int day, unsigned int month, unsigned int year)
/* The number of days since January 1. (0 to 365) */ int rtc_year_days(unsigned int day, unsigned int month, unsigned int year)
{ return rtc_ydays[is_leap_year(year)][month] + day - 1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* print the recorded route in an IP RR, LSRR or SSRR option. */
static int ip_printroute(netdissect_options *ndo, register const u_char *cp, u_int length)
/* print the recorded route in an IP RR, LSRR or SSRR option. */ static int ip_printroute(netdissect_options *ndo, register const u_char *cp, u_int length)
{ register u_int ptr; register u_int len; if (length < 3) { ND_PRINT((ndo, " [bad length %u]", length)); return (0); } if ((length + 1) & 3) ND_PRINT((ndo, " [bad length %u]", length)); ND_TCHECK(cp[2]); ptr = cp[2] - 1; if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1) ND_PRINT((ndo, " [bad ptr %u]", cp[2])); for (len = 3; len < length; len += 4) { ND_TCHECK2(cp[len], 4); ND_PRINT((ndo, " %s", ipaddr_string(ndo, &cp[len]))); if (ptr > len) ND_PRINT((ndo, ",")); } return (0); trunc: return (-1); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This file is part of the Simba project. */
int main()
/* This file is part of the Simba project. */ int main()
{ sys_start(); while (1) { log_object_print(NULL, LOG_INFO, OSTR("log_object_print(OSTR())\r\n")); log_object_print(NULL, LOG_INFO, FSTR("log_object_print(FSTR())\r\n")); std_printf(OSTR("std_printf(OSTR())\r\n")); std_printf(FSTR("std_printf(FSTR())\r\n")); chan_write(sys_get_stdout(), "chan_write()\r\n", 14); thrd_sleep(3); } return (0); }
eerimoq/simba
C++
Other
337
/* This reads the keyboard status port, and does the appropriate action. */
unsigned char handle_kbd_event(void)
/* This reads the keyboard status port, and does the appropriate action. */ unsigned char handle_kbd_event(void)
{ unsigned char status = kbd_read_status(); unsigned int work = 10000; while ((--work > 0) && (status & KBD_STAT_OBF)) { unsigned char scancode; scancode = kbd_read_input(); if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR))) { if (status & KBD_STAT_MOUSE_OBF) ; else handle_keyboard_event(scancode); } status = kbd_read_status(); } if (!work) PRINTF("pc_keyb: controller jammed (0x%02X).\n", status); return status; }
EmcraftSystems/u-boot
C++
Other
181
/* If HmacSha256Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha256SetKey(OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize)
/* If HmacSha256Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI HmacSha256SetKey(OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize)
{ CALL_CRYPTO_SERVICE (HmacSha256SetKey, (HmacSha256Context, Key, KeySize), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Used to catch tasks that attempt to return from their implementing function. */
static void prvTaskExitError(void)
/* Used to catch tasks that attempt to return from their implementing function. */ static void prvTaskExitError(void)
{ configASSERT( usCriticalNesting == ~0U ); portDISABLE_INTERRUPTS(); for( ;; ); }
labapart/polymcu
C++
null
201
/* The function is used to deinitialize nboot context data structure. Its contents are overwritten with random data so that any sensitive data does not remain in memory. */
nboot_status_t NBOOT_ContextDeinit(nboot_context_t *context)
/* The function is used to deinitialize nboot context data structure. Its contents are overwritten with random data so that any sensitive data does not remain in memory. */ nboot_status_t NBOOT_ContextDeinit(nboot_context_t *context)
{ assert(BOOTLOADER_API_TREE_POINTER); return BOOTLOADER_API_TREE_POINTER->nbootDriver->nboot_context_deinit(context); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Description: returns GPT header on success, NULL on error. Allocates and fills a GPT header starting at @ from @bdev. Note: remember to free gpt when finished with it. */
static gpt_header* alloc_read_gpt_header(struct block_device *bdev, u64 lba)
/* Description: returns GPT header on success, NULL on error. Allocates and fills a GPT header starting at @ from @bdev. Note: remember to free gpt when finished with it. */ static gpt_header* alloc_read_gpt_header(struct block_device *bdev, u64 lba)
{ gpt_header *gpt; unsigned ssz = bdev_logical_block_size(bdev); if (!bdev) return NULL; gpt = kzalloc(ssz, GFP_KERNEL); if (!gpt) return NULL; if (read_lba(bdev, lba, (u8 *) gpt, ssz) < ssz) { kfree(gpt); gpt=NULL; return NULL; } return gpt; }
robutest/uclinux
C++
GPL-2.0
60
/* Airpcap wrapper, used to get the decryption enabling of an airpcap adapter */
gboolean airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState PEnable)
/* Airpcap wrapper, used to get the decryption enabling of an airpcap adapter */ gboolean airpcap_if_get_decryption_state(PAirpcapHandle ah, PAirpcapDecryptionState PEnable)
{ if (!AirpcapLoaded) return FALSE; return g_PAirpcapGetDecryptionState(ah,PEnable); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* returns: 0/1 whether cookie points to some device in this group */
static int dev_is_stor(int type, struct device_info *di)
/* returns: 0/1 whether cookie points to some device in this group */ static int dev_is_stor(int type, struct device_info *di)
{ return (dev_stor_type(di->cookie) == type) ? 1 : 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font */
void lv_font_add(lv_font_t *child, lv_font_t *parent)
/* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font */ void lv_font_add(lv_font_t *child, lv_font_t *parent)
{ if(parent == NULL) return; while(parent->next_page != NULL) { parent = parent->next_page; } parent->next_page = child; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* This function fills in the function pointer into the cell in the state machine. */
void StateMachineSetAction(struct rt_state_machine *S, unsigned long St, unsigned long Msg, IN STATE_MACHINE_FUNC Func)
/* This function fills in the function pointer into the cell in the state machine. */ void StateMachineSetAction(struct rt_state_machine *S, unsigned long St, unsigned long Msg, IN STATE_MACHINE_FUNC Func)
{ unsigned long MsgIdx; MsgIdx = Msg - S->Base; if (St < S->NrState && MsgIdx < S->NrMsg) { S->TransFunc[St * S->NrMsg + MsgIdx] = Func; } }
robutest/uclinux
C++
GPL-2.0
60
/* Get the ETHERNET DMA Rx Overflow Missed Frame Counter value. */
uint32_t ETH_GetRxOverflowMissedFrameCounter(void)
/* Get the ETHERNET DMA Rx Overflow Missed Frame Counter value. */ uint32_t ETH_GetRxOverflowMissedFrameCounter(void)
{ return ((uint32_t)((ETH->DMAMFBOCNT & ETH_DMAMFBOCNT_OVFFRMCNT) >> ETH_DMA_RX_OVERFLOW_MISSEDFRAMES_COUNTER_SHIFT)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return value: 0 if caller is required to return it to free_pool. Returns 1 if caller need not worry about freeing command block as error handler will take care of that. */
static int _pmcraid_io_done(struct pmcraid_cmd *cmd, int reslen, int ioasc)
/* Return value: 0 if caller is required to return it to free_pool. Returns 1 if caller need not worry about freeing command block as error handler will take care of that. */ static int _pmcraid_io_done(struct pmcraid_cmd *cmd, int reslen, int ioasc)
{ struct scsi_cmnd *scsi_cmd = cmd->scsi_cmd; int rc = 0; scsi_set_resid(scsi_cmd, reslen); pmcraid_info("response(%d) CDB[0] = %x ioasc:result: %x:%x\n", le32_to_cpu(cmd->ioa_cb->ioarcb.response_handle) >> 2, cmd->ioa_cb->ioarcb.cdb[0], ioasc, scsi_cmd->result); if (PMCRAID_IOASC_SENSE_KEY(ioasc) != 0) rc = pmcraid_error_handler(cmd); if (rc == 0) { scsi_dma_unmap(scsi_cmd); scsi_cmd->scsi_done(scsi_cmd); } return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* Get data size in bytes based on the Data Length Code (DLC) option of a message. */
static uint8_t can_ctrl_dlc_to_size(enum can_ctrl_dlc dlc)
/* Get data size in bytes based on the Data Length Code (DLC) option of a message. */ static uint8_t can_ctrl_dlc_to_size(enum can_ctrl_dlc dlc)
{ switch(dlc) { case CAN_DLC_0: case CAN_DLC_1: case CAN_DLC_2: case CAN_DLC_3: case CAN_DLC_4: case CAN_DLC_5: case CAN_DLC_6: case CAN_DLC_7: case CAN_DLC_8: return dlc; case CAN_DLC_12: return 12; case CAN_DLC_16: return 16; case CAN_DLC_20: return 20; case CAN_DLC_24: return 24; case CAN_DLC_32: return 32; case CAN_DLC_48: return 48; case CAN_DLC_64: return 64; default: return 0; } }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Assert reset on every peripheral but L4WD0. Watchdog must be kept intact to prevent glitches and/or hangs. */
void socfpga_per_reset_all(void)
/* Assert reset on every peripheral but L4WD0. Watchdog must be kept intact to prevent glitches and/or hangs. */ void socfpga_per_reset_all(void)
{ const u32 l4wd0 = 1 << RSTMGR_RESET(SOCFPGA_RESET(L4WD0)); writel(~l4wd0, &reset_manager_base->per_mod_reset); writel(0xffffffff, &reset_manager_base->per2_mod_reset); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Sets a high output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs. */
void PIO_Set(const Pin *pin)
/* Sets a high output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs. */ void PIO_Set(const Pin *pin)
{ pin->pio->PIO_SODR = pin->mask; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* update the position of the given pipe. pipe->position is updated and wrapped within the buffer size. pipe->transferred is updated, too, but the size is not wrapped, so that the caller can check the total transferred size later (to call snd_pcm_period_elapsed). */
static int vx_update_pipe_position(struct vx_core *chip, struct snd_pcm_runtime *runtime, struct vx_pipe *pipe)
/* update the position of the given pipe. pipe->position is updated and wrapped within the buffer size. pipe->transferred is updated, too, but the size is not wrapped, so that the caller can check the total transferred size later (to call snd_pcm_period_elapsed). */ static int vx_update_pipe_position(struct vx_core *chip, struct snd_pcm_runtime *runtime, struct vx_pipe *pipe)
{ struct vx_rmh rmh; int err, update; u64 count; vx_init_rmh(&rmh, CMD_STREAM_SAMPLE_COUNT); vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); err = vx_send_msg(chip, &rmh); if (err < 0) return err; count = ((u64)(rmh.Stat[0] & 0xfffff) << 24) | (u64)rmh.Stat[1]; update = (int)(count - pipe->cur_count); pipe->cur_count = count; pipe->position += update; if (pipe->position >= (int)runtime->buffer_size) pipe->position %= runtime->buffer_size; pipe->transferred += update; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Check the status of the Rx buffer of the specified SPI port. */
xtBoolean SPIIsRxNotEmpty(unsigned long ulBase)
/* Check the status of the Rx buffer of the specified SPI port. */ xtBoolean SPIIsRxNotEmpty(unsigned long ulBase)
{ xASSERT((ulBase == SPI3_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)); return ((xHWREG(ulBase + SPI_SR) & SPI_SR_RXNE) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Initialize the SettingChangedFlag variable in the display form. */
VOID UpdateDataChangedFlag(VOID)
/* Initialize the SettingChangedFlag variable in the display form. */ VOID UpdateDataChangedFlag(VOID)
{ LIST_ENTRY *Link; FORM_BROWSER_FORMSET *LocalFormSet; gDisplayFormData.SettingChangedFlag = FALSE; if (IsNvUpdateRequiredForForm (gCurrentSelection->Form)) { gDisplayFormData.SettingChangedFlag = TRUE; return; } switch (gBrowserSettingScope) { case SystemLevel: Link = GetFirstNode (&gBrowserFormSetList); while (!IsNull (&gBrowserFormSetList, Link)) { LocalFormSet = FORM_BROWSER_FORMSET_FROM_LINK (Link); if (IsNvUpdateRequiredForFormSet (LocalFormSet)) { gDisplayFormData.SettingChangedFlag = TRUE; return; } Link = GetNextNode (&gBrowserFormSetList, Link); } break; case FormSetLevel: if (IsNvUpdateRequiredForFormSet (gCurrentSelection->FormSet)) { gDisplayFormData.SettingChangedFlag = TRUE; return; } break; default: break; } }
tianocore/edk2
C++
Other
4,240
/* Note: All these constants are defined in wpa.h For supplicant, there is only EAPOL Key message avaliable */
BOOLEAN WpaMsgTypeSubst(u8 EAPType, int *MsgType)
/* Note: All these constants are defined in wpa.h For supplicant, there is only EAPOL Key message avaliable */ BOOLEAN WpaMsgTypeSubst(u8 EAPType, int *MsgType)
{ switch (EAPType) { case EAPPacket: *MsgType = MT2_EAPPacket; break; case EAPOLStart: *MsgType = MT2_EAPOLStart; break; case EAPOLLogoff: *MsgType = MT2_EAPOLLogoff; break; case EAPOLKey: *MsgType = MT2_EAPOLKey; break; case EAPOLASFAlert: *MsgType = MT2_EAPOLASFAlert; break; default: return FALSE; } return TRUE; }
robutest/uclinux
C++
GPL-2.0
60
/* Function for resetting the internal state of the Peer Database module. */
static void internal_state_reset(pdb_t *pdb)
/* Function for resetting the internal state of the Peer Database module. */ static void internal_state_reset(pdb_t *pdb)
{ memset(pdb, 0, sizeof(pdb_t)); for (uint32_t i = 0; i < N_WRITE_BUFFER_RECORDS; i++) { write_buffer_record_invalidate(&pdb->write_buffer_records[i]); } }
labapart/polymcu
C++
null
201
/* Return protocol message attributes from SCP for a given protocol ID. */
EFI_STATUS ScmiGetProtocolMessageAttributes(IN SCMI_PROTOCOL_ID ProtocolId, OUT UINT32 **ReturnValues)
/* Return protocol message attributes from SCP for a given protocol ID. */ EFI_STATUS ScmiGetProtocolMessageAttributes(IN SCMI_PROTOCOL_ID ProtocolId, OUT UINT32 **ReturnValues)
{ return ScmiProtocolDiscoveryCommon ( ProtocolId, ScmiMessageIdProtocolMessageAttributes, ReturnValues ); }
tianocore/edk2
C++
Other
4,240
/* The minimum duration (LSb = 1/ODR) of the Interrupt 1 event to be recognized.. */
int32_t lis2dh12_int1_gen_duration_get(stmdev_ctx_t *ctx, uint8_t *val)
/* The minimum duration (LSb = 1/ODR) of the Interrupt 1 event to be recognized.. */ int32_t lis2dh12_int1_gen_duration_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lis2dh12_int1_duration_t int1_duration; int32_t ret; ret = lis2dh12_read_reg(ctx, LIS2DH12_INT1_DURATION, (uint8_t *)&int1_duration, 1); *val = (uint8_t)int1_duration.d; return ret; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019