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 |
|---|---|---|---|---|---|---|---|
/* Obtains the number of items that are currently stored in the list. */ | size_t TbxListGetSize(tTbxList const *list) | /* Obtains the number of items that are currently stored in the list. */
size_t TbxListGetSize(tTbxList const *list) | {
size_t result = 0;
TBX_ASSERT(list != NULL);
if (list != NULL)
{
TbxCriticalSectionEnter();
result = list->nodeCount;
TbxCriticalSectionExit();
}
return result;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and starts the library USB task to begin the enumeration and USB management process. */ | void EVENT_USB_Host_DeviceAttached(void) | /* Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and starts the library USB task to begin the enumeration and USB management process. */
void EVENT_USB_Host_DeviceAttached(void) | {
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* This may release the path, and so you may lose any locks held at the time you call it. */ | int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) | /* This may release the path, and so you may lose any locks held at the time you call it. */
int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) | {
struct btrfs_key key;
struct btrfs_disk_key found_key;
int ret;
btrfs_item_key_to_cpu(path->nodes[0], &key, 0);
if (key.offset > 0)
key.offset--;
else if (key.type > 0)
key.type--;
else if (key.objectid > 0)
key.objectid--;
else
return 1;
btrfs_release_path(root, path);
ret = btrfs_search_slot(NULL,... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Converts a text device path node to File device path structure. */ | EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFilePath(CHAR16 *TextDeviceNode) | /* Converts a text device path node to File device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFilePath(CHAR16 *TextDeviceNode) | {
FILEPATH_DEVICE_PATH *File;
File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
MEDIA_DEVICE_PATH,
MEDIA_FILEPATH_DP,
(UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
... | tianocore/edk2 | C++ | Other | 4,240 |
/* Generates a write-0 or write-1 cycle. Only call if dev->bus_master->touch_bit is NULL */ | static void w1_write_bit(struct w1_master *dev, int bit) | /* Generates a write-0 or write-1 cycle. Only call if dev->bus_master->touch_bit is NULL */
static void w1_write_bit(struct w1_master *dev, int bit) | {
if (bit) {
dev->bus_master->write_bit(dev->bus_master->data, 0);
w1_delay(6);
dev->bus_master->write_bit(dev->bus_master->data, 1);
w1_delay(64);
} else {
dev->bus_master->write_bit(dev->bus_master->data, 0);
w1_delay(60);
dev->bus_master->write_bit(dev->bus_master->data, 1);
w1_delay(10);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function should be called in the open function of the device driver. */ | int open_candev(struct net_device *dev) | /* This function should be called in the open function of the device driver. */
int open_candev(struct net_device *dev) | {
struct can_priv *priv = netdev_priv(dev);
if (!priv->bittiming.tq && !priv->bittiming.bitrate) {
dev_err(dev->dev.parent, "bit-timing not yet defined\n");
return -EINVAL;
}
if (!netif_carrier_ok(dev))
netif_carrier_on(dev);
setup_timer(&priv->restart_timer, can_restart, (unsigned long)dev);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Main routine to manage the standard USB SETUP request. */ | static bool udc_reqstd(void) | /* Main routine to manage the standard USB SETUP request. */
static bool udc_reqstd(void) | {
if (USB_REQ_RECIP_DEVICE != Udd_setup_recipient()) {
return false;
}
if (Udd_setup_is_in()) {
switch (udd_g_ctrlreq.req.bRequest) {
case USB_REQ_GET_STATUS:
return udc_req_std_dev_get_status();
case USB_REQ_GET_DESCRIPTOR:
return udc_req_std_dev_get_descriptor();
case USB_REQ_GET_CONFIGURATION:
... | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Performs an atomic compare exchange operation to release semaphore. The compare exchange operation must be performed using MP safe mechanisms. */ | STATIC UINT32 InternalReleaseSemaphore(IN OUT volatile UINT32 *Sem) | /* Performs an atomic compare exchange operation to release semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
STATIC UINT32 InternalReleaseSemaphore(IN OUT volatile UINT32 *Sem) | {
UINT32 Value;
do {
Value = *Sem;
} while (Value + 1 != 0 &&
InterlockedCompareExchange32 (
(UINT32 *)Sem,
Value,
Value + 1
) != Value);
if (Value == MAX_UINT32) {
return Value;
}
return Value + 1;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Check if Transmit data register is empty (it means that Data written in transmit data register SWPMI_TDR has been transmitted and SWPMI_TDR can be written to again) @rmtoll ISR TXE LL_SWPMI_IsActiveFlag_TXE. */ | uint32_t LL_SWPMI_IsActiveFlag_TXE(SWPMI_TypeDef *SWPMIx) | /* Check if Transmit data register is empty (it means that Data written in transmit data register SWPMI_TDR has been transmitted and SWPMI_TDR can be written to again) @rmtoll ISR TXE LL_SWPMI_IsActiveFlag_TXE. */
uint32_t LL_SWPMI_IsActiveFlag_TXE(SWPMI_TypeDef *SWPMIx) | {
return ((READ_BIT(SWPMIx->ISR, SWPMI_ISR_TXE) == (SWPMI_ISR_TXE)) ? 1UL : 0UL);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Calculate remainder: BnRes = BnA % BnB. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */ | BOOLEAN EFIAPI CryptoServiceBigNumMod(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes) | /* Calculate remainder: BnRes = BnA % BnB. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI CryptoServiceBigNumMod(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes) | {
return CALL_BASECRYPTLIB (Bn.Services.Mod, BigNumMod, (BnA, BnB, BnRes), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* called prior to booting kernel or by 'fdt boardsetup' command */ | int ft_board_setup(void *blob, bd_t *bd) | /* called prior to booting kernel or by 'fdt boardsetup' command */
int ft_board_setup(void *blob, bd_t *bd) | {
static const struct node_info nodes[] = {
{ "physmap-flash.0", MTD_DEV_TYPE_NOR, },
{ "mxc_nand", MTD_DEV_TYPE_NAND, },
};
if (env_get("fdt_noauto")) {
puts(" Skiping ft_board_setup (fdt_noauto defined)\n");
return 0;
}
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Reads and returns the current value of DR7. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */ | UINTN EFIAPI AsmReadDr7(VOID) | /* Reads and returns the current value of DR7. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmReadDr7(VOID) | {
UINTN Data;
__asm__ __volatile__ (
"movl %%dr7, %0"
: "=r" (Data)
);
return Data;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If Address > 0x0FFFFFFF, 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(). If AndData is larger than the bitmask value range specified by StartBit an... | UINT16 EFIAPI PciBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData) | /* If Address > 0x0FFFFFFF, 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(). If AndData is larger than the bitmask value range specified by StartBit an... | {
return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* There are three reserved values for the TIF: 0, 99998 and 99999. These are trapped and displayed as an appropriate string. All other values are printed as a duration in hours, minutes and seconds. */ | static void format_tif(gchar *buf, guint32 value) | /* There are three reserved values for the TIF: 0, 99998 and 99999. These are trapped and displayed as an appropriate string. All other values are printed as a duration in hours, minutes and seconds. */
static void format_tif(gchar *buf, guint32 value) | {
guint32 hours;
guint32 mins;
guint32 secs;
switch (value) {
case 0:
g_snprintf(buf, ITEM_LABEL_LENGTH, "Immediate Or Cancel (%u)", value);
break;
case 99998:
g_snprintf(buf, ITEM_LABEL_LENGTH, "Market Hours (%u)", value);
break;
case 99999:
g_snprint... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Set pixel in LCD display memory.
This function sets a pixel in LCD display memory. If a parameter is out of range, then the function doesn't set any bit. */ | static void c42364a_slcdc_set_pixel(Slcdc *p_slcdc, uint8_t pix_com, uint8_t pix_seg) | /* Set pixel in LCD display memory.
This function sets a pixel in LCD display memory. If a parameter is out of range, then the function doesn't set any bit. */
static void c42364a_slcdc_set_pixel(Slcdc *p_slcdc, uint8_t pix_com, uint8_t pix_seg) | {
if (pix_seg < 32)
slcdc_set_lsb_memory(p_slcdc, pix_com, mask[pix_seg]);
else
slcdc_set_msb_memory(p_slcdc, pix_com, mask[pix_seg & 0x1F]);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* "implement" : set bits in a little endian bit stream. Same concepts as "extract" (see comments above). The data mangled in the bit stream remains in little endian order the whole time. It make more sense to talk about endianness of register values by considering a register a "cached" copy of the little endiad bit st... | static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) | /* "implement" : set bits in a little endian bit stream. Same concepts as "extract" (see comments above). The data mangled in the bit stream remains in little endian order the whole time. It make more sense to talk about endianness of register values by considering a register a "cached" copy of the little endiad bit st... | {
u64 x;
u64 m = (1ULL << n) - 1;
if (n > 32)
printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n",
n, current->comm);
if (value > m)
printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n",
value, current->comm);
WARN_ON(value > m);
value &= m;
report += offse... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return the buffer and buffer size occupied by the RAM Disk. */ | VOID* BmGetRamDiskMemoryInfo(IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath, OUT UINTN *RamDiskSizeInPages) | /* Return the buffer and buffer size occupied by the RAM Disk. */
VOID* BmGetRamDiskMemoryInfo(IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath, OUT UINTN *RamDiskSizeInPages) | {
EFI_STATUS Status;
EFI_HANDLE Handle;
UINT64 StartingAddr;
UINT64 EndingAddr;
ASSERT (RamDiskDevicePath != NULL);
*RamDiskSizeInPages = 0;
Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &RamDiskDevicePath, &Handle);
ASSERT_EFI_ERROR (Status);
ASSERT (
(DevicePathType (Ram... | tianocore/edk2 | C++ | Other | 4,240 |
/* This service enables the sending of commands to the TPM2. */ | EFI_STATUS EFIAPI DTpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock) | /* This service enables the sending of commands to the TPM2. */
EFI_STATUS EFIAPI DTpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock) | {
TPM2_PTP_INTERFACE_TYPE PtpInterface;
PtpInterface = GetCachedPtpInterface ();
switch (PtpInterface) {
case Tpm2PtpInterfaceCrb:
return PtpCrbTpmCommand (
(PTP_CRB_REGISTERS_PTR)(UINTN)PcdGet64 (PcdTpmBaseAddress),
InputParameterBlock,
InputParameterBlockS... | tianocore/edk2 | C++ | Other | 4,240 |
/* Select the SCK pin as the source of baudrate for the USART SPI slave mode. */ | static void usart_set_spi_slave_baudrate(Usart *p_usart) | /* Select the SCK pin as the source of baudrate for the USART SPI slave mode. */
static void usart_set_spi_slave_baudrate(Usart *p_usart) | {
p_usart->US_MR &= ~US_MR_USCLKS_Msk;
p_usart->US_MR |= US_MR_USCLKS_SCK;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Enable the discontinuous mode for the selected ADC channels. */ | void ADC_DiscModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState) | /* Enable the discontinuous mode for the selected ADC channels. */
void ADC_DiscModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState) | {
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADCx->CFGR1 |= (uint32_t)ADC_CFGR1_DISCEN;
}
else
{
ADCx->CFGR1 &= (uint32_t)(~ADC_CFGR1_DISCEN);
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* If 8-bit I/O port operations are not supported, then ASSERT(). */ | UINT8 EFIAPI S3IoWrite8(IN UINTN Port, IN UINT8 Value) | /* If 8-bit I/O port operations are not supported, then ASSERT(). */
UINT8 EFIAPI S3IoWrite8(IN UINTN Port, IN UINT8 Value) | {
return InternalSaveIoWrite8ValueToBootScript (Port, IoWrite8 (Port, Value));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Context switch function used by the tick. This must be identical to vPortYield() from the call to vTaskSwitchContext() onwards. The only difference from vPortYield() is the tick count is incremented as the call comes from the tick ISR. */ | void vPortYieldFromTick(void) | /* Context switch function used by the tick. This must be identical to vPortYield() from the call to vTaskSwitchContext() onwards. The only difference from vPortYield() is the tick count is incremented as the call comes from the tick ISR. */
void vPortYieldFromTick(void) | {
portSAVE_CONTEXT();
if( xTaskIncrementTick() != pdFALSE )
{
vTaskSwitchContext();
}
portRESTORE_CONTEXT();
asm volatile ( "ret" );
} | labapart/polymcu | C++ | null | 201 |
/* free all CallInfo structures not in use by a thread */ | void luaE_freeCI(lua_State *L) | /* free all CallInfo structures not in use by a thread */
void luaE_freeCI(lua_State *L) | {
next = ci->next;
luaM_free(L, ci);
L->nci--;
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Dissector for ZigBee Green Power commands attrib reporting. */ | static guint dissect_zbee_nwk_gp_cmd_attr_reporting(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, zbee_nwk_green_power_packet *packet _U_, guint offset) | /* Dissector for ZigBee Green Power commands attrib reporting. */
static guint dissect_zbee_nwk_gp_cmd_attr_reporting(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, zbee_nwk_green_power_packet *packet _U_, guint offset) | {
guint16 cluster_id;
proto_tree *field_tree;
cluster_id = tvb_get_letohs(tvb, offset);
proto_tree_add_item(tree, hf_zbee_nwk_gp_cmd_attr_report_cluster_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
field_tree = proto_tree_add_subtree_format(tree, tvb, offset, 2, ett_zbee_nwk_cmd_options,... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Prevent further output on the passed console device so that (for example) serial drivers can disable console output before suspending a port, and can re-enable output afterwards. */ | void console_stop(struct console *console) | /* Prevent further output on the passed console device so that (for example) serial drivers can disable console output before suspending a port, and can re-enable output afterwards. */
void console_stop(struct console *console) | {
acquire_console_sem();
console->flags &= ~CON_ENABLED;
release_console_sem();
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Write the data to the XHCI door bell register. */ | VOID XhcPeiWriteDoorBellReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Data) | /* Write the data to the XHCI door bell register. */
VOID XhcPeiWriteDoorBellReg(IN PEI_XHC_DEV *Xhc, IN UINT32 Offset, IN UINT32 Data) | {
ASSERT (Xhc->DBOff != 0);
MmioWrite32 (Xhc->UsbHostControllerBaseAddress + Xhc->DBOff + Offset, Data);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Open LIN mode on the specified UART.
The */ | void xUARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig) | /* Open LIN mode on the specified UART.
The */
void xUARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig) | {
xASSERT(UARTBaseValid(ulBase));
xASSERT((ulConfig&UART_CONFIG_BKFL_MASK)<16);
xUARTConfigSet(ulBase, ulBaud, UART_CONFIG_WLEN_8 |
UART_CONFIG_STOP_1 |
UART_CONFIG_PAR_NONE);
xUARTLINEnable(ulBase);
xHWREG(ulBase + UART_ALT_CSR) ... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Allow NOMMU mmap() to directly map the device (if not NULL) */ | static unsigned long ram_get_unmapped_area(struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags) | /* Allow NOMMU mmap() to directly map the device (if not NULL) */
static unsigned long ram_get_unmapped_area(struct mtd_info *mtd, unsigned long len, unsigned long offset, unsigned long flags) | {
return (unsigned long) mtd->priv + offset;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks if the power on a specified port is ready. */ | USBPD_StatusTypeDef USBPD_PWR_IF_SupplyReady(uint8_t PortNum, USBPD_VSAFE_StatusTypeDef Vsafe) | /* Checks if the power on a specified port is ready. */
USBPD_StatusTypeDef USBPD_PWR_IF_SupplyReady(uint8_t PortNum, USBPD_VSAFE_StatusTypeDef Vsafe) | {
USBPD_StatusTypeDef status = USBPD_ERROR;
if (!USBPD_PORT_IsValid(PortNum))
{
return USBPD_ERROR;
}
if (USBPD_VSAFE_0V == Vsafe)
{
status = (HW_IF_PWR_GetVoltage(PortNum) < CAD_threshold_VBus? USBPD_OK: USBPD_ERROR);
}
else
{
status = (HW_IF_PWR_GetVoltage(PortNum) > CAD_threshold_VBus? ... | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* The IRQ_NESTED_THREAD flag indicates that on request_threaded_irq() no separate interrupt thread should be created for the irq as the handler are called nested in the context of a demultiplexing interrupt handler thread. */ | void set_irq_nested_thread(unsigned int irq, int nest) | /* The IRQ_NESTED_THREAD flag indicates that on request_threaded_irq() no separate interrupt thread should be created for the irq as the handler are called nested in the context of a demultiplexing interrupt handler thread. */
void set_irq_nested_thread(unsigned int irq, int nest) | {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
if (!desc)
return;
raw_spin_lock_irqsave(&desc->lock, flags);
if (nest)
desc->status |= IRQ_NESTED_THREAD;
else
desc->status &= ~IRQ_NESTED_THREAD;
raw_spin_unlock_irqrestore(&desc->lock, flags);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* 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 Vector14_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 Vector14_handler(void) | {
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (14 * 2))
JMP 0,X
}
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Disable the PWM interrupt of the PWM module.
The */ | void PWMIntDisable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType) | /* Disable the PWM interrupt of the PWM module.
The */
void PWMIntDisable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType) | {
unsigned long ulChannelTemp;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
xASSERT((ulIntType == PWM_INT_CAP_BOTH) || (ulIntType == PWM_INT_CAP_FALL) ||
... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Write contents of register REGNO in task TASK. */ | int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data) | /* Write contents of register REGNO in task TASK. */
int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data) | {
if (task->thread.regs == NULL)
return -EIO;
if (regno == PT_MSR)
return set_user_msr(task, data);
if (regno == PT_TRAP)
return set_user_trap(task, data);
if (regno <= PT_MAX_PUT_REG) {
((unsigned long *)task->thread.regs)[regno] = data;
return 0;
}
return -EIO;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Callback used when screen needs redrawing.
This function is used as a calback during redrawing all screen elements. */ | static void _cbInvalidateWindow(WM_HWIN hWin, void *p) | /* Callback used when screen needs redrawing.
This function is used as a calback during redrawing all screen elements. */
static void _cbInvalidateWindow(WM_HWIN hWin, void *p) | {
(void)p;
WM_InvalidateWindow(hWin);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* sets the port maximum Rx frame size
This function is fully documented in the main header file, IxEthDB.h. */ | IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortMaximumRxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumRxFrameSize) | /* sets the port maximum Rx frame size
This function is fully documented in the main header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortMaximumRxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumRxFrameSize) | {
IX_ETH_DB_CHECK_PORT_EXISTS(portID);
IX_ETH_DB_CHECK_SINGLE_NPE(portID);
if (!ixEthDBPortInfo[portID].initialized)
{
return IX_ETH_DB_PORT_UNINITIALIZED;
}
if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE)
{
if ((maximumRxFrameSize < IX_ETHDB_MIN_NPE_FRAME_SIZE) ||
(maximumRxFrameSize ... | EmcraftSystems/u-boot | C++ | Other | 181 |
/* calc_timing - calculate timing divisor value and check in range. @hwtm: The hardware timing in 10ths of nanoseconds. @clk_tns: The clock period in 10ths of nanoseconds. @err: Pointer to err variable to update in event of failure. */ | static unsigned int calc_timing(unsigned int hwtm, unsigned int clk_tns, unsigned int *err) | /* calc_timing - calculate timing divisor value and check in range. @hwtm: The hardware timing in 10ths of nanoseconds. @clk_tns: The clock period in 10ths of nanoseconds. @err: Pointer to err variable to update in event of failure. */
static unsigned int calc_timing(unsigned int hwtm, unsigned int clk_tns, unsigned i... | {
unsigned int ret = to_div(hwtm, clk_tns);
if (ret > 0xf)
*err = -EINVAL;
return ret;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Reload counter one with the watchdog heartbeat. We don't bother reloading the cascade counter. */ | static int wdtpci_ping(void) | /* Reload counter one with the watchdog heartbeat. We don't bother reloading the cascade counter. */
static int wdtpci_ping(void) | {
unsigned long flags;
spin_lock_irqsave(&wdtpci_lock, flags);
inb(WDT_DC);
udelay(8);
wdtpci_ctr_mode(1, 2);
wdtpci_ctr_load(1, wd_heartbeat);
outb(0, WDT_DC);
udelay(8);
spin_unlock_irqrestore(&wdtpci_lock, flags);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Construction function for DMALD instruction. This function fills the program buffer with the constructed instruction. */ | static INLINE int XDmaPs_Instr_DMALD(char *DmaProg) | /* Construction function for DMALD instruction. This function fills the program buffer with the constructed instruction. */
static INLINE int XDmaPs_Instr_DMALD(char *DmaProg) | {
*DmaProg = 0x04;
return 1;
} | ua1arn/hftrx | C++ | null | 69 |
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */ | int main(void) | /* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */
int main(void) | {
SetupHardware();
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
for (;;)
{
HID_Device_USBTask(&Generic_HID_Interface);
USB_USBTask();
}
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Clears the interrupts.
Valid values for ui32IntFlags are: */ | void am_hal_clkgen_int_clear(uint32_t ui32Interrupt) | /* Clears the interrupts.
Valid values for ui32IntFlags are: */
void am_hal_clkgen_int_clear(uint32_t ui32Interrupt) | {
AM_REG(CLKGEN, INTCLR) = ui32Interrupt;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* BSG support fc_destroy_bsgjob - routine to teardown/delete a fc bsg job @job: fc_bsg_job that is to be torn down */ | static void fc_destroy_bsgjob(struct fc_bsg_job *job) | /* BSG support fc_destroy_bsgjob - routine to teardown/delete a fc bsg job @job: fc_bsg_job that is to be torn down */
static void fc_destroy_bsgjob(struct fc_bsg_job *job) | {
unsigned long flags;
spin_lock_irqsave(&job->job_lock, flags);
if (job->ref_cnt) {
spin_unlock_irqrestore(&job->job_lock, flags);
return;
}
spin_unlock_irqrestore(&job->job_lock, flags);
put_device(job->dev);
kfree(job->request_payload.sg_list);
kfree(job->reply_payload.sg_list);
kfree(job);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reads data from the specified Data Backup Register. */ | uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR) | /* Reads data from the specified Data Backup Register. */
uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR) | {
assert_param(IS_BKP_DR(BKP_DR));
return (*(__IO uint16_t *) (BKP_BASE + BKP_DR));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* @handle: handle of the loaded image @systable: system table */ | static int setup(const efi_handle_t img_handle, const struct efi_system_table *systable) | /* @handle: handle of the loaded image @systable: system table */
static int setup(const efi_handle_t img_handle, const struct efi_system_table *systable) | {
int ret;
boottime = systable->boottime;
ret = boottime->locate_protocol(&guid_device_path_utilities_protocol,
NULL, (void **)&dpu);
if (ret != EFI_SUCCESS) {
dpu = NULL;
efi_st_error(
"Device path to text protocol is not available.\n");
return EFI_ST_FAILURE;
}
return EFI_ST_SUCCESS;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Caution: This function may receive untrusted input. So this function will do basic check for PKCS#7 data structure. */ | BOOLEAN EFIAPI CryptoServicePkcs7GetAttachedContent(IN CONST UINT8 *P7Data, IN UINTN P7Length, OUT VOID **Content, OUT UINTN *ContentSize) | /* Caution: This function may receive untrusted input. So this function will do basic check for PKCS#7 data structure. */
BOOLEAN EFIAPI CryptoServicePkcs7GetAttachedContent(IN CONST UINT8 *P7Data, IN UINTN P7Length, OUT VOID **Content, OUT UINTN *ContentSize) | {
return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetAttachedContent, Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If RsaContext is NULL, then return FALSE. If Message is NULL, then return FALSE. If MsgSize is zero or > INT_MAX, then return FALSE. If DigestLen is NOT 32, 48 or 64, return FALSE. If SaltLen is not equal to DigestLen, then return FALSE. If SigSize is large enough but Signature is NULL, then return FALSE. If this in... | BOOLEAN EFIAPI CryptoServiceRsaPssSign(IN VOID *RsaContext, IN CONST UINT8 *Message, IN UINTN MsgSize, IN UINT16 DigestLen, IN UINT16 SaltLen, OUT UINT8 *Signature, IN OUT UINTN *SigSize) | /* If RsaContext is NULL, then return FALSE. If Message is NULL, then return FALSE. If MsgSize is zero or > INT_MAX, then return FALSE. If DigestLen is NOT 32, 48 or 64, return FALSE. If SaltLen is not equal to DigestLen, then return FALSE. If SigSize is large enough but Signature is NULL, then return FALSE. If this in... | {
return CALL_BASECRYPTLIB (RsaPss.Services.Sign, RsaPssSign, (RsaContext, Message, MsgSize, DigestLen, SaltLen, Signature, SigSize), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Search DM9000 board, allocate space and register it */ | int dm9000_probe(void) | /* Search DM9000 board, allocate space and register it */
int dm9000_probe(void) | {
u32 id_val;
id_val = DM9000_ior(DM9000_VIDL);
id_val |= DM9000_ior(DM9000_VIDH) << 8;
id_val |= DM9000_ior(DM9000_PIDL) << 16;
id_val |= DM9000_ior(DM9000_PIDH) << 24;
if (id_val == DM9000_ID) {
printf("dm9000 i/o: 0x%x, id: 0x%x \n", CONFIG_DM9000_BASE,
id_val);
return 0;
} else {
printf("dm900... | EmcraftSystems/u-boot | C++ | Other | 181 |
/* ac97_set_ctrl() set values for ac97 mute and volume */ | static int ac97_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl) | /* ac97_set_ctrl() set values for ac97 mute and volume */
static int ac97_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl) | {
int i;
for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++)
if (ctrl->id == ac97_qctrl[i].id)
goto handle;
return 1;
handle:
if (ctrl->value < ac97_qctrl[i].minimum ||
ctrl->value > ac97_qctrl[i].maximum)
return -ERANGE;
switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
dev->mute = ctrl->value;
break;
case... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the pixel at (x, y) to the given value NOTE: The surface must be locked before calling this! */ | void DT_PutPixel(SDL_Surface *surface, int x, int y, Uint32 pixel) | /* Set the pixel at (x, y) to the given value NOTE: The surface must be locked before calling this! */
void DT_PutPixel(SDL_Surface *surface, int x, int y, Uint32 pixel) | {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *) p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
} else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
bre... | DC-SWAT/DreamShell | C++ | null | 404 |
/* The memory space must be word-aligned. An assert will occur if asserts are turned on and the memory is not word-aligned. */ | XStatus XEmac_SetSgSendSpace(XEmac *InstancePtr, u32 *MemoryPtr, u32 ByteCount) | /* The memory space must be word-aligned. An assert will occur if asserts are turned on and the memory is not word-aligned. */
XStatus XEmac_SetSgSendSpace(XEmac *InstancePtr, u32 *MemoryPtr, u32 ByteCount) | {
XASSERT_NONVOID(InstancePtr != NULL);
XASSERT_NONVOID(MemoryPtr != NULL);
XASSERT_NONVOID(ByteCount != 0);
XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
if (!XEmac_mIsSgDma(InstancePtr)) {
return XST_NOT_SGDMA;
}
return XDmaChannel_CreateSgList(&InstancePtr->SendChannel, MemoryPtr,
ByteC... | EmcraftSystems/u-boot | C++ | Other | 181 |
/* fc_lun_reset_send() - Send LUN reset command @data: The FCP packet that identifies the LUN to be reset */ | static void fc_lun_reset_send(unsigned long data) | /* fc_lun_reset_send() - Send LUN reset command @data: The FCP packet that identifies the LUN to be reset */
static void fc_lun_reset_send(unsigned long data) | {
struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data;
struct fc_lport *lport = fsp->lp;
if (lport->tt.fcp_cmd_send(lport, fsp, fc_tm_done)) {
if (fsp->recov_retry++ >= FC_MAX_RECOV_RETRY)
return;
if (fc_fcp_lock_pkt(fsp))
return;
setup_timer(&fsp->timer, fc_lun_reset_send, (unsigned long)fsp);
fc_fcp_t... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* snd_vx_inb - read a byte from the register @offset: register enum */ | static unsigned char vx2_inb(struct vx_core *chip, int offset) | /* snd_vx_inb - read a byte from the register @offset: register enum */
static unsigned char vx2_inb(struct vx_core *chip, int offset) | {
return inb(vx2_reg_addr(chip, offset));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Determines if there are any characters in receiver register. */ | xtBoolean UARTCharsAvail(unsigned long ulBase) | /* Determines if there are any characters in receiver register. */
xtBoolean UARTCharsAvail(unsigned long ulBase) | {
xtBoolean ulStatus = xfalse;
xASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) ||
(ulBase == UART2_BASE) );
ulStatus = (xtBoolean)(xHWREGB(ulBase + UART_012_S1) &
((unsigned char) UART_012_S1_RDRF_MASK));
return (ulStatus);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Each option to be added is described in one entry of the input <args> This input must be terminated with an entry containing ARG_TABLE_ENDMARKER. */ | void nsi_add_command_line_opts(struct args_struct_t *args) | /* Each option to be added is described in one entry of the input <args> This input must be terminated with an entry containing ARG_TABLE_ENDMARKER. */
void nsi_add_command_line_opts(struct args_struct_t *args) | {
int count = 0;
while (args[count].option != NULL) {
count++;
}
count++;
if (used_args + count >= args_aval) {
int growby = count;
if (growby < ARGS_ALLOC_CHUNK_SIZE) {
growby = ARGS_ALLOC_CHUNK_SIZE;
}
struct args_struct_t *new_args_struct = realloc(args_struct,
(args_aval + growby)*
... | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* initialize TIMER break parameter struct with a default value */ | void timer_break_struct_para_init(timer_break_parameter_struct *breakpara) | /* initialize TIMER break parameter struct with a default value */
void timer_break_struct_para_init(timer_break_parameter_struct *breakpara) | {
breakpara->runoffstate = TIMER_ROS_STATE_DISABLE;
breakpara->ideloffstate = TIMER_IOS_STATE_DISABLE;
breakpara->deadtime = 0U;
breakpara->breakpolarity = TIMER_BREAK_POLARITY_LOW;
breakpara->outputautostate = TIMER_OUTAUTO_DISABLE;
breakpara->protectmode = TIMER_CCHP_PROT_O... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This file is part of the Simba project. */ | int mock_write_thrd_module_init(int res) | /* This file is part of the Simba project. */
int mock_write_thrd_module_init(int res) | {
harness_mock_write("thrd_module_init()",
NULL,
0);
harness_mock_write("thrd_module_init(): return (res)",
&res,
sizeof(res));
return (0);
} | eerimoq/simba | C++ | Other | 337 |
/* This function puts the system into Hibernate. The device enters HIB immediately and on exit from HIB device core starts its execution from reset thus the function never returns. */ | void PRCMHibernateEnter(void) | /* This function puts the system into Hibernate. The device enters HIB immediately and on exit from HIB device core starts its execution from reset thus the function never returns. */
void PRCMHibernateEnter(void) | {
MAP_PRCMHIBRegWrite((HIB3P3_BASE+HIB3P3_O_MEM_HIB_REQ),0x1);
__asm(" nop\n"
" nop\n"
" nop\n"
" nop\n");
} | micropython/micropython | C++ | Other | 18,334 |
/* Puts the processor into deep-sleep mode.
This function places the processor into deep-sleep mode; it will not return until the processor returns to run mode. */ | void SysCtlDeepSleep(void) | /* Puts the processor into deep-sleep mode.
This function places the processor into deep-sleep mode; it will not return until the processor returns to run mode. */
void SysCtlDeepSleep(void) | {
xHWREG(SCB_SCR) |= SCB_SCR_SLEEPDEEP;
xCPUwfi();
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Get Name Buffer.
This funtions is used to get the name information buffer. */ | void adi_ble_GetNameBuffer(ADI_BLER_BUFFER *pNameBuffer) | /* Get Name Buffer.
This funtions is used to get the name information buffer. */
void adi_ble_GetNameBuffer(ADI_BLER_BUFFER *pNameBuffer) | {
ASSERT(pNameBuffer != NULL);
memcpy(pNameBuffer, &pBLERadio->sNameBuffer, sizeof(ADI_BLER_BUFFER));
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Ensures final expression result (including results from its jump lists) is in some (any) register and return that register. */ | int luaK_exp2anyreg(FuncState *fs, expdesc *e) | /* Ensures final expression result (including results from its jump lists) is in some (any) register and return that register. */
int luaK_exp2anyreg(FuncState *fs, expdesc *e) | {
if (!hasjumps(e))
return e->u.info;
if (e->u.info >= fs->nactvar) {
exp2reg(fs, e, e->u.info);
return e->u.info;
}
}
luaK_exp2nextreg(fs, e);
return e->u.info;
} | nodemcu/nodemcu-firmware | C++ | MIT License | 7,566 |
/* smk_netlabel_audit_set - fill a netlbl_audit struct @nap: structure to fill */ | static void smk_netlabel_audit_set(struct netlbl_audit *nap) | /* smk_netlabel_audit_set - fill a netlbl_audit struct @nap: structure to fill */
static void smk_netlabel_audit_set(struct netlbl_audit *nap) | {
nap->loginuid = audit_get_loginuid(current);
nap->sessionid = audit_get_sessionid(current);
nap->secid = smack_to_secid(current_security());
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This service executes a caller provided function on all enabled CPUs. */ | EFI_STATUS EFIAPI MpInitLibStartupAllCPUs(IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL) | /* This service executes a caller provided function on all enabled CPUs. */
EFI_STATUS EFIAPI MpInitLibStartupAllCPUs(IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL) | {
if (Procedure == NULL) {
return EFI_INVALID_PARAMETER;
}
Procedure (ProcedureArgument);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enable the Capture of the PWM module.
The */ | void PWMCAPEnable(unsigned long ulBase, unsigned long ulChannel) | /* Enable the Capture of the PWM module.
The */
void PWMCAPEnable(unsigned long ulBase, unsigned long ulChannel) | {
unsigned long ulChannelTemp;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT(ulBase == PWMA_BASE);
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
xHWREG(ulBase + PWM_CCR0 + (ulChannelTemp >> 1)*4) |=
(PWM_CCR0_CAPCH0EN << ((ulChannel % 2) ? 16 : 0)... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* USART not able to wake up the MCU from deep-sleep mode. */ | void usart_wakeup_disable(uint32_t usart_periph) | /* USART not able to wake up the MCU from deep-sleep mode. */
void usart_wakeup_disable(uint32_t usart_periph) | {
USART_CTL0(usart_periph) &=~(USART_CTL0_UESM);
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* Finds the TLVs in the specified image slot, if any. */ | static int img_mgmt_find_tlvs(int slot, size_t *start_off, size_t *end_off, uint16_t magic) | /* Finds the TLVs in the specified image slot, if any. */
static int img_mgmt_find_tlvs(int slot, size_t *start_off, size_t *end_off, uint16_t magic) | {
struct image_tlv_info tlv_info;
int rc;
rc = img_mgmt_read(slot, *start_off, &tlv_info, sizeof(tlv_info));
if (rc != 0) {
return rc;
}
if (tlv_info.it_magic != magic) {
return IMG_MGMT_ERR_NO_TLVS;
}
*start_off += sizeof(tlv_info);
*end_off = *start_off + tlv_info.it_tlv_tot;
return IMG_MGMT_ERR_OK;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Created on: 16 feb. 2019 Author: Daniel Mårtensson Do repeate matrix. If you have a matrix A with size row x column and you want to repeat matrix A horz=3 times to left and vert=2 times down, Then you need a matrix B with size row*2 x column*3 */ | void repmat(double *A, int row, int column, int horz, int vert, double *B) | /* Created on: 16 feb. 2019 Author: Daniel Mårtensson Do repeate matrix. If you have a matrix A with size row x column and you want to repeat matrix A horz=3 times to left and vert=2 times down, Then you need a matrix B with size row*2 x column*3 */
void repmat(double *A, int row, int column, int horz, int vert, doubl... | {
for (int j = 0; j < horz; j++) {
memcpy(B, A + jump, sizeof(double) * column);
B += column;
}
jump += column;
if(jump >= column*row)
jump = 0;
}
} | DanielMartensson/EmbeddedLapack | C++ | MIT License | 129 |
/* General Purpose Input/Outputs Write to a Port.
Write a value to the given GPIO port. */ | void gpio_port_write(uint32_t gpioport, uint8_t data) | /* General Purpose Input/Outputs Write to a Port.
Write a value to the given GPIO port. */
void gpio_port_write(uint32_t gpioport, uint8_t data) | {
GPIO_DATA(gpioport)[GPIO_ALL] = data;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* calculate: 4.096x2^ack_timeout = 4.096x2^ack_delay + 2x4.096x2^life_time Because of how ack_timeout is stored, adding one doubles the timeout. To avoid large timeouts, select the max(ack_delay, life_time + 1), and increment it (round up) only if the other is within 50%. */ | static u8 cm_ack_timeout(u8 ca_ack_delay, u8 packet_life_time) | /* calculate: 4.096x2^ack_timeout = 4.096x2^ack_delay + 2x4.096x2^life_time Because of how ack_timeout is stored, adding one doubles the timeout. To avoid large timeouts, select the max(ack_delay, life_time + 1), and increment it (round up) only if the other is within 50%. */
static u8 cm_ack_timeout(u8 ca_ack_delay, ... | {
int ack_timeout = packet_life_time + 1;
if (ack_timeout >= ca_ack_delay)
ack_timeout += (ca_ack_delay >= (ack_timeout - 1));
else
ack_timeout = ca_ack_delay +
(ack_timeout >= (ca_ack_delay - 1));
return min(31, ack_timeout);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* show function for portno called by cat or similar things */ | static ssize_t lcs_portno_show(struct device *dev, struct device_attribute *attr, char *buf) | /* show function for portno called by cat or similar things */
static ssize_t lcs_portno_show(struct device *dev, struct device_attribute *attr, char *buf) | {
struct lcs_card *card;
card = dev_get_drvdata(dev);
if (!card)
return 0;
return sprintf(buf, "%d\n", card->portno);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This internal function checks if a Unicode character is a decimal character. The valid decimal character is from '0' to '9'. */ | BOOLEAN EFIAPI InternalAsciiIsDecimalDigitCharacter(IN CHAR8 Char) | /* This internal function checks if a Unicode character is a decimal character. The valid decimal character is from '0' to '9'. */
BOOLEAN EFIAPI InternalAsciiIsDecimalDigitCharacter(IN CHAR8 Char) | {
return (BOOLEAN)(Char >= '0' && Char <= '9');
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Read RX register using non-blocking method.
This function reads data from the TX register directly, upper layer must make sure the RX register is full or TX FIFO has data before calling this function. */ | static void UART_ReadNonBlocking(UART_Type *base, uint8_t *data, size_t length) | /* Read RX register using non-blocking method.
This function reads data from the TX register directly, upper layer must make sure the RX register is full or TX FIFO has data before calling this function. */
static void UART_ReadNonBlocking(UART_Type *base, uint8_t *data, size_t length) | {
assert(data);
size_t i;
for (i = 0; i < length; i++)
{
data[i] = base->D;
}
} | labapart/polymcu | C++ | null | 201 |
/* This routine is invoked to prepare for access to a given drive. */ | static void qd65xx_dev_select(ide_drive_t *drive) | /* This routine is invoked to prepare for access to a given drive. */
static void qd65xx_dev_select(ide_drive_t *drive) | {
u8 index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) |
(QD_TIMREG(drive) & 0x02);
if (timings[index] != QD_TIMING(drive))
outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive));
outb(drive->select | ATA_DEVICE_OBS, drive->hwif->io_ports.device_addr);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get service by {fwmark} in the service table. */ | static struct ip_vs_service* __ip_vs_svc_fwm_get(int af, __u32 fwmark) | /* Get service by {fwmark} in the service table. */
static struct ip_vs_service* __ip_vs_svc_fwm_get(int af, __u32 fwmark) | {
unsigned hash;
struct ip_vs_service *svc;
hash = ip_vs_svc_fwm_hashkey(fwmark);
list_for_each_entry(svc, &ip_vs_svc_fwm_table[hash], f_list) {
if (svc->fwmark == fwmark && svc->af == af) {
atomic_inc(&svc->usecnt);
return svc;
}
}
return NULL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Initializes the K6 PowerNow! support. Returns -ENODEV on unsupported devices, -EINVAL or -ENOMEM on problems during initiatization, and zero on success. */ | static int __init powernow_k6_init(void) | /* Initializes the K6 PowerNow! support. Returns -ENODEV on unsupported devices, -EINVAL or -ENOMEM on problems during initiatization, and zero on success. */
static int __init powernow_k6_init(void) | {
struct cpuinfo_x86 *c = &cpu_data(0);
if ((c->x86_vendor != X86_VENDOR_AMD) || (c->x86 != 5) ||
((c->x86_model != 12) && (c->x86_model != 13)))
return -ENODEV;
if (!request_region(POWERNOW_IOPORT, 16, "PowerNow!")) {
printk(KERN_INFO PFX "PowerNow IOPORT region already used.\n");
return -EIO;
}
if (cpufr... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Return the untagged transaction id for a given target/channel lun. Optionally, clear the entry. */ | static u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl) | /* Return the untagged transaction id for a given target/channel lun. Optionally, clear the entry. */
static u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl) | {
u_int scbid;
u_int target_offset;
if ((ahc->flags & AHC_SCB_BTT) != 0) {
u_int saved_scbptr;
saved_scbptr = ahc_inb(ahc, SCBPTR);
ahc_outb(ahc, SCBPTR, TCL_LUN(tcl));
scbid = ahc_inb(ahc, SCB_64_BTT + TCL_TARGET_OFFSET(tcl));
ahc_outb(ahc, SCBPTR, saved_scbptr);
} else {
target_offset = TCL_TARGET_OFF... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function returns a positive number if the physical eraseblock is bad, zero if not, and a negative error code if an error occurred. */ | int ubi_io_is_bad(const struct ubi_device *ubi, int pnum) | /* This function returns a positive number if the physical eraseblock is bad, zero if not, and a negative error code if an error occurred. */
int ubi_io_is_bad(const struct ubi_device *ubi, int pnum) | {
struct mtd_info *mtd = ubi->mtd;
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
if (ubi->bad_allowed) {
int ret;
ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
if (ret < 0)
ubi_err(ubi, "error %d while checking if PEB %d is bad",
ret, pnum);
else if (ret)
dbg_io("PEB %d is bad", pnum)... | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* It is also safe to call this with a task pointer of current, which the static wrapper mpol_set_task_struct_flag() does, for use within this file. */ | void mpol_fix_fork_child_flag(struct task_struct *p) | /* It is also safe to call this with a task pointer of current, which the static wrapper mpol_set_task_struct_flag() does, for use within this file. */
void mpol_fix_fork_child_flag(struct task_struct *p) | {
if (p->mempolicy)
p->flags |= PF_MEMPOLICY;
else
p->flags &= ~PF_MEMPOLICY;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Initialize a list of TCM825X registers. The list of registers is terminated by the pair of values { TCM825X_REG_TERM, TCM825X_VAL_TERM }. Returns zero if successful, or non-zero otherwise. */ | static int tcm825x_write_default_regs(struct i2c_client *client, const struct tcm825x_reg *reglist) | /* Initialize a list of TCM825X registers. The list of registers is terminated by the pair of values { TCM825X_REG_TERM, TCM825X_VAL_TERM }. Returns zero if successful, or non-zero otherwise. */
static int tcm825x_write_default_regs(struct i2c_client *client, const struct tcm825x_reg *reglist) | {
int err;
const struct tcm825x_reg *next = reglist;
while (!((next->reg == TCM825X_REG_TERM)
&& (next->val == TCM825X_VAL_TERM))) {
err = tcm825x_write_reg(client, next->reg, next->val);
if (err) {
dev_err(&client->dev, "register writing failed\n");
return err;
}
next++;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* System calibration osc get results.
Use this function to get system calibration osc results. */ | void system_osc_calibration_result(struct system_calibration_config *config) | /* System calibration osc get results.
Use this function to get system calibration osc results. */
void system_osc_calibration_result(struct system_calibration_config *config) | {
config->osc_fractional_part = LP_CLK_CAL_REGS0->CALIB_OSC_COUNT_REG.bit.CAL_FRAC_COUNT;
config->osc_integer_part = LP_CLK_CAL_REGS0->CALIB_OSC_COUNT_REG.bit.CAL_INT_COUNT;
} | memfault/zero-to-main | C++ | null | 200 |
/* Updates the SystemCoreClock with current core Clock retrieved from cpu registers.
Update SystemCoreClock variable */ | void SystemCoreClockUpdate(void) | /* Updates the SystemCoreClock with current core Clock retrieved from cpu registers.
Update SystemCoreClock variable */
void SystemCoreClockUpdate(void) | {
SystemCoreClock = __SYSTEM_CLOCK;
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* reset the window watchdog timer configuration
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */ | void wwdgt_deinit(void) | /* reset the window watchdog timer configuration
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
void wwdgt_deinit(void) | {
rcu_periph_reset_enable(RCU_WWDGTRST);
rcu_periph_reset_disable(RCU_WWDGTRST);
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* This function clears a pending uDMA error interrupt. It should be called from within the uDMA error interrupt handler to clear the interrupt. */ | void uDMAErrorStatusClear(void) | /* This function clears a pending uDMA error interrupt. It should be called from within the uDMA error interrupt handler to clear the interrupt. */
void uDMAErrorStatusClear(void) | {
HWREG(UDMA_ERRCLR) = 1;
} | watterott/WebRadio | C++ | null | 71 |
/* Registers that vary with the chip implementation constants (port) use this routine. */ | void ipath_write_kreg_port(const struct ipath_devdata *dd, ipath_kreg regno, unsigned port, u64 value) | /* Registers that vary with the chip implementation constants (port) use this routine. */
void ipath_write_kreg_port(const struct ipath_devdata *dd, ipath_kreg regno, unsigned port, u64 value) | {
u16 where;
if (port < dd->ipath_portcnt &&
(regno == dd->ipath_kregs->kr_rcvhdraddr ||
regno == dd->ipath_kregs->kr_rcvhdrtailaddr))
where = regno + port;
else
where = -1;
ipath_write_kreg(dd, where, value);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Request the PE to perform a VDM mode enter. */ | USBPD_StatusTypeDef USBPD_DPM_RequestVDM_EnterMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, uint16_t SVID, uint8_t ModeIndex) | /* Request the PE to perform a VDM mode enter. */
USBPD_StatusTypeDef USBPD_DPM_RequestVDM_EnterMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, uint16_t SVID, uint8_t ModeIndex) | {
return USBPD_PE_SVDM_RequestModeEnter(PortNum, SOPType, SVID, ModeIndex);
} | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* Waits to send a character from the specified port. */ | void UARTBufferWrite(unsigned long ulBase, unsigned char *ucBuffer, unsigned long ulLength) | /* Waits to send a character from the specified port. */
void UARTBufferWrite(unsigned long ulBase, unsigned char *ucBuffer, unsigned long ulLength) | {
unsigned long ulCount;
xASSERT(UARTBaseValid(ulBase));
for (ulCount=0; ulCount<ulLength; ulCount++)
{
while((xHWREG(ulBase + UART_FSR) & UART_FSR_TX_FF))
{
}
xHWREG(ulBase + UART_THR) = ucBuffer[ulCount];
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Wait for a specific thread in the Cadence controller to complete. */ | static int cdns_wait_for_thread(uintptr_t base_address, uint8_t thread) | /* Wait for a specific thread in the Cadence controller to complete. */
static int cdns_wait_for_thread(uintptr_t base_address, uint8_t thread) | {
if (!WAIT_FOR((sys_read32((base_address) + THR_STATUS) & BIT(thread)) == 0U,
THREAD_IDLE_TIME_OUT, k_msleep(1))) {
LOG_ERR("Timed out waiting for thread response");
return -ETIMEDOUT;
}
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Fast approximation to the trigonometric cosine function for Q15 data. */ | q15_t arm_cos_q15(q15_t x) | /* Fast approximation to the trigonometric cosine function for Q15 data. */
q15_t arm_cos_q15(q15_t x) | {
q15_t cosVal;
int32_t index;
q15_t a, b;
q15_t fract;
x = (uint16_t)x + 0x2000;
if (x < 0)
{
x = (uint16_t)x + 0x8000;
}
index = (uint32_t)x >> FAST_MATH_Q15_SHIFT;
fract = (x - (index << FAST_MATH_Q15_SHIFT)) << 9;
a = sinTable_q15[index];
b = sinTable_q15[index+1];
cosVal = (q31_t)(0... | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Decrements the reference count of a closure after it was previously incremented by the same caller. If no other callers are using the closure, then the closure will be destroyed and freed. */ | void g_closure_unref(GClosure *closure) | /* Decrements the reference count of a closure after it was previously incremented by the same caller. If no other callers are using the closure, then the closure will be destroyed and freed. */
void g_closure_unref(GClosure *closure) | {
guint new_ref_count;
g_return_if_fail (closure != NULL);
g_return_if_fail (closure->ref_count > 0);
if (closure->ref_count == 1)
g_closure_invalidate (closure);
DEC_ASSIGN (closure, ref_count, &new_ref_count);
if (new_ref_count == 0)
{
closure_invoke_notifiers (closure, FNOTIFY);
g_fre... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* If there is no additional space for HOB creation, then ASSERT(). If the FvImage buffer is not at its required alignment, then ASSERT(). */ | VOID EFIAPI BuildFv3Hob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT32 AuthenticationStatus, IN BOOLEAN ExtractedFv, IN CONST EFI_GUID *FvName OPTIONAL, IN CONST EFI_GUID *FileName OPTIONAL) | /* If there is no additional space for HOB creation, then ASSERT(). If the FvImage buffer is not at its required alignment, then ASSERT(). */
VOID EFIAPI BuildFv3Hob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT32 AuthenticationStatus, IN BOOLEAN ExtractedFv, IN CONST EFI_GUID *FvName OPTIONAL, IN CONS... | {
EFI_HOB_FIRMWARE_VOLUME3 *Hob;
if (!InternalCheckFvAlignment (BaseAddress, Length)) {
ASSERT (FALSE);
return;
}
Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV3, (UINT16)sizeof (EFI_HOB_FIRMWARE_VOLUME3));
if (Hob == NULL) {
return;
}
Hob->BaseAddress = BaseAddress;
Hob->Length ... | tianocore/edk2 | C++ | Other | 4,240 |
/* Initialize Event Port config structure. Fill each pstcEventPortInit with default value. */ | int32_t EP_StructInit(stc_ep_init_t *pstcEventPortInit) | /* Initialize Event Port config structure. Fill each pstcEventPortInit with default value. */
int32_t EP_StructInit(stc_ep_init_t *pstcEventPortInit) | {
int32_t i32Ret = LL_OK;
if (NULL == pstcEventPortInit) {
i32Ret = LL_ERR_INVD_PARAM;
} else {
pstcEventPortInit->u32PinDir = EP_DIR_IN;
pstcEventPortInit->enPinState = EVT_PIN_RESET;
pstcEventPortInit->u32PinTriggerOps = EP_OPS_NONE;
pstcEventPortInit->... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function will set an alternate setting for an interface. */ | rt_err_t rt_usbd_set_altsetting(uintf_t intf, rt_uint8_t value) | /* This function will set an alternate setting for an interface. */
rt_err_t rt_usbd_set_altsetting(uintf_t intf, rt_uint8_t value) | {
ualtsetting_t setting;
LOG_D("rt_usbd_set_altsetting");
RT_ASSERT(intf != RT_NULL);
setting = rt_usbd_find_altsetting(intf, value);
intf->curr_setting = setting;
return RT_EOK;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return true if: -The passed LSM is the one chosen by user at boot time, -or the passed LSM is configured as the default and the user did not choose an alternate LSM at boot time, -or there is no default LSM set and the user didn't specify a specific LSM and we're the first to ask for registration permission, -or the... | int __init security_module_enable(struct security_operations *ops) | /* Return true if: -The passed LSM is the one chosen by user at boot time, -or the passed LSM is configured as the default and the user did not choose an alternate LSM at boot time, -or there is no default LSM set and the user didn't specify a specific LSM and we're the first to ask for registration permission, -or the... | {
if (!*chosen_lsm)
strncpy(chosen_lsm, ops->name, SECURITY_NAME_MAX);
else if (strncmp(ops->name, chosen_lsm, SECURITY_NAME_MAX))
return 0;
return 1;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Read the specified SMC interrupt has occurred or not. */ | uint8_t SMC_ReadIntFlag(SMC_BANK_NAND_T bank, SMC_INT_T flag) | /* Read the specified SMC interrupt has occurred or not. */
uint8_t SMC_ReadIntFlag(SMC_BANK_NAND_T bank, SMC_INT_T flag) | {
uint32_t tmpsr = 0x0, itstatus = 0x0, itenable = 0x0;
if (bank == SMC_BANK2_NAND)
{
tmpsr = SMC_Bank2->STSINT2;
}
else if (bank == SMC_BANK3_NAND)
{
tmpsr = SMC_Bank3->STSINT3;
}
else
{
tmpsr = SMC_Bank4->STSINT4;
}
itstatus = tmpsr & flag;
itena... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check whether a conversion specification is valid. When called, first character in 'form' must be '' and last character must be a valid conversion specifier. 'flags' are the accepted flags; 'precision' signals whether to accept a precision. */ | static void checkformat(lua_State *L, const char *form, const char *flags, int precision) | /* Check whether a conversion specification is valid. When called, first character in 'form' must be '' and last character must be a valid conversion specifier. 'flags' are the accepted flags; 'precision' signals whether to accept a precision. */
static void checkformat(lua_State *L, const char *form, const char *flag... | {
const char *spec = form + 1;
spec += strspn(spec, flags);
if (*spec != '0') {
spec = get2digits(spec);
if (*spec == '.' && precision) {
spec++;
spec = get2digits(spec);
}
}
if (!isalpha(uchar(*spec)))
luaL_error(L, "invalid conversion specification: '%s'", form);
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Unregisters the device and notifier handler. Actual device deinitialization is handled by bfin_otp_close(). */ | static void __exit bfin_otp_exit(void) | /* Unregisters the device and notifier handler. Actual device deinitialization is handled by bfin_otp_close(). */
static void __exit bfin_otp_exit(void) | {
stampit();
misc_deregister(&bfin_otp_misc_device);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function cleans up the file list and any related data structures. It has no impact on the files themselves. */ | EFI_STATUS EFIAPI EfiShellFreeFileList(IN EFI_SHELL_FILE_INFO **FileList) | /* This function cleans up the file list and any related data structures. It has no impact on the files themselves. */
EFI_STATUS EFIAPI EfiShellFreeFileList(IN EFI_SHELL_FILE_INFO **FileList) | {
EFI_SHELL_FILE_INFO *ShellFileListItem;
if ((FileList == NULL) || (*FileList == NULL)) {
return (EFI_INVALID_PARAMETER);
}
for ( ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetFirstNode (&(*FileList)->Link)
; !IsListEmpty (&(*FileList)->Link)
; ShellFileListItem = (EFI_SHELL_FILE_INFO *)Ge... | tianocore/edk2 | C++ | Other | 4,240 |
/* see if an RxRPC socket is currently writable */ | static int rxrpc_writable(struct sock *sk) | /* see if an RxRPC socket is currently writable */
static int rxrpc_writable(struct sock *sk) | {
return atomic_read(&sk->sk_wmem_alloc) < (size_t) sk->sk_sndbuf;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Perform a "final reduction" in field F256 (field for curve P-256). The source value must be less than twice the modulus. If the value is not lower than the modulus, then the modulus is subtracted and this function returns 1; otherwise, it leaves it untouched and it returns 0. */ | static uint32_t reduce_final_f256(uint32_t *d) | /* Perform a "final reduction" in field F256 (field for curve P-256). The source value must be less than twice the modulus. If the value is not lower than the modulus, then the modulus is subtracted and this function returns 1; otherwise, it leaves it untouched and it returns 0. */
static uint32_t reduce_final_f256(ui... | {
uint32_t t[20];
uint32_t cc;
int i;
memcpy(t, d, sizeof t);
cc = 0;
for (i = 0; i < 20; i ++) {
uint32_t w;
w = t[i] - F256[i] - cc;
cc = w >> 31;
t[i] = w & 0x1FFF;
}
cc ^= 1;
CCOPY(cc, d, t, sizeof t);
return cc;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Check the status of the Tx buffer of the specified SPI port. */ | xtBoolean SPIIsTxEmpty(unsigned long ulBase) | /* Check the status of the Tx buffer of the specified SPI port. */
xtBoolean SPIIsTxEmpty(unsigned long ulBase) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_TX_EMPTY)? xtrue : xfalse);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Register the Service C.1 and all its Characteristics... */ | void service_c_1_2_init(void) | /* Register the Service C.1 and all its Characteristics... */
void service_c_1_2_init(void) | {
bt_gatt_service_register(&service_c_1_2_svc);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Returns 1 if fixup matches phydev in bus_id and phy_uid. Fixups can be set to match any in one or more fields. */ | static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) | /* Returns 1 if fixup matches phydev in bus_id and phy_uid. Fixups can be set to match any in one or more fields. */
static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) | {
if (strcmp(fixup->bus_id, dev_name(&phydev->dev)) != 0)
if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0)
return 0;
if ((fixup->phy_uid & fixup->phy_uid_mask) !=
(phydev->phy_id & fixup->phy_uid_mask))
if (fixup->phy_uid != PHY_ANY_UID)
return 0;
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.