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 |
|---|---|---|---|---|---|---|---|
/* If we don't find a terminating NUL, return -1 and set *err and *err_info appropriately. */ | static int name_resolution_block_find_name_end(const char *p, guint record_len, int *err, gchar **err_info) | /* If we don't find a terminating NUL, return -1 and set *err and *err_info appropriately. */
static int name_resolution_block_find_name_end(const char *p, guint record_len, int *err, gchar **err_info) | {
int namelen;
namelen = 0;
for (;;) {
if (record_len == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("pcapng_read_name_resolution_block: NRB record has non-null-terminated host name");
return -1;
}
if (*p == '\0')
break;
p++;
record_len--;
namelen++;
}
return namelen + 1;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Airpcap wrapper, used to close an airpcap adapter */ | void airpcap_if_close(PAirpcapHandle handle) | /* Airpcap wrapper, used to close an airpcap adapter */
void airpcap_if_close(PAirpcapHandle handle) | {
if (!AirpcapLoaded) return;
g_PAirpcapClose(handle);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Delete a Semaphore that was created by osSemaphoreCreate. */ | osStatus svcSemaphoreDelete(osSemaphoreId semaphore_id) | /* Delete a Semaphore that was created by osSemaphoreCreate. */
osStatus svcSemaphoreDelete(osSemaphoreId semaphore_id) | {
return osErrorParameter;
}
if (((P_SCB)sem)->cb_type != SCB) {
return osErrorParameter;
}
rt_sem_delete(sem);
return osOK;
} | labapart/polymcu | C++ | null | 201 |
/* We were unable to perform jbd_trylock_bh_state() inside j_list_lock. The caller must restart a list walk. Wait for someone else to run jbd_unlock_bh_state(). */ | static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh) __releases(journal -> j_list_lock) | /* We were unable to perform jbd_trylock_bh_state() inside j_list_lock. The caller must restart a list walk. Wait for someone else to run jbd_unlock_bh_state(). */
static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh) __releases(journal -> j_list_lock) | {
get_bh(bh);
spin_unlock(&journal->j_list_lock);
jbd_lock_bh_state(bh);
jbd_unlock_bh_state(bh);
put_bh(bh);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* UserCableDetection reporting events on a specified port from CAD layer. */ | void USBPD_DPM_UserCableDetection(uint8_t PortNum, USBPD_CAD_EVENT State) | /* UserCableDetection reporting events on a specified port from CAD layer. */
void USBPD_DPM_UserCableDetection(uint8_t PortNum, USBPD_CAD_EVENT State) | {
switch(State)
{
case USBPD_CAD_EVENT_ATTEMC:
if(USBPD_PORTPOWERROLE_SRC == DPM_Params[PortNum].PE_PowerRole)
{
}
DPM_Ports[PortNum].DPM_IsConnected = 1;
break;
case USBPD_CAD_EVENT_ATTACHED:
if(USBPD_PORTPOWERROLE_SRC == DPM_Params[PortNum].PE_PowerRole)
{
}
DPM_Ports[PortNum].DPM_IsConnected = 1;
break;
case USBPD_CAD_EVENT_LEGACY:
break;
case USBPD_CAD_EVENT_DETACHED :
case USBPD_CAD_EVENT_EMC :
default :
memset(&DPM_Ports[PortNum], 0, sizeof(DPM_Ports[PortNum]));
break;
}
} | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* Deselect, release chip lock and wake up anyone waiting on the device */ | static void nand_release_device(struct mtd_info *mtd) | /* Deselect, release chip lock and wake up anyone waiting on the device */
static void nand_release_device(struct mtd_info *mtd) | {
struct nand_chip *chip = mtd->priv;
chip->select_chip(mtd, -1);
spin_lock(&chip->controller->lock);
chip->controller->active = NULL;
chip->state = FL_READY;
wake_up(&chip->controller->wq);
spin_unlock(&chip->controller->lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* scsi_dh_handler_attach - Attach a device handler to a device @sdev - SCSI device the device handler should attach to @scsi_dh - The device handler to attach */ | static int scsi_dh_handler_attach(struct scsi_device *sdev, struct scsi_device_handler *scsi_dh) | /* scsi_dh_handler_attach - Attach a device handler to a device @sdev - SCSI device the device handler should attach to @scsi_dh - The device handler to attach */
static int scsi_dh_handler_attach(struct scsi_device *sdev, struct scsi_device_handler *scsi_dh) | {
int err = 0;
if (sdev->scsi_dh_data) {
if (sdev->scsi_dh_data->scsi_dh != scsi_dh)
err = -EBUSY;
else
kref_get(&sdev->scsi_dh_data->kref);
} else if (scsi_dh->attach) {
err = scsi_dh->attach(sdev);
if (!err) {
kref_init(&sdev->scsi_dh_data->kref);
sdev->scsi_dh_data->sdev = sdev;
}
}
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* bank_reg - convert bank number to pointer to the control register. @bank: The IO bank number. */ | static void __iomem* bank_reg(unsigned int bank) | /* bank_reg - convert bank number to pointer to the control register. @bank: The IO bank number. */
static void __iomem* bank_reg(unsigned int bank) | {
return S3C2410_BANKCON0 + (bank << 2);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Program Command Function: MX25_WREN Arguments: None. Description: The WREN instruction is for setting Write Enable Latch (WEL) bit. Return Message: FlashOperationSuccess */ | ReturnMsg MX25_WREN(void) | /* Program Command Function: MX25_WREN Arguments: None. Description: The WREN instruction is for setting Write Enable Latch (WEL) bit. Return Message: FlashOperationSuccess */
ReturnMsg MX25_WREN(void) | {
CS_Low();
SendByte( FLASH_CMD_WREN, SIO );
CS_High();
return FlashOperationSuccess;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Enables or disables the TIMER Capture Compare Channel xN. */ | static void timer_ccxn_channel_cmd(TIMER_TypeDef *TIMERx, ald_timer_channel_t ch, type_func_t state) | /* Enables or disables the TIMER Capture Compare Channel xN. */
static void timer_ccxn_channel_cmd(TIMER_TypeDef *TIMERx, ald_timer_channel_t ch, type_func_t state) | {
switch (ch) {
case ALD_TIMER_CHANNEL_1:
MODIFY_REG(TIMERx->CCEP, TIMER_CCEP_CC1NE_MSK, state << TIMER_CCEP_CC1NE_POS);
break;
case ALD_TIMER_CHANNEL_2:
MODIFY_REG(TIMERx->CCEP, TIMER_CCEP_CC2NE_MSK, state << TIMER_CCEP_CC2NE_POS);
break;
case ALD_TIMER_CHANNEL_3:
MODIFY_REG(TIMERx->CCEP, TIMER_CCEP_CC3NE_MSK, state << TIMER_CCEP_CC3NE_POS);
break;
default:
break;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Determines if the hardware module(s) are currently synchronizing to the bus.
Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application. */ | static bool rtc_calendar_is_syncing(struct rtc_module *const module) | /* Determines if the hardware module(s) are currently synchronizing to the bus.
Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application. */
static bool rtc_calendar_is_syncing(struct rtc_module *const module) | {
Assert(module);
Assert(module->hw);
Rtc *const rtc_module = module->hw;
if (rtc_module->MODE2.SYNCBUSY.reg) {
return true;
}
return false;
} | memfault/zero-to-main | C++ | null | 200 |
/* Invalidate the flash cache.
This function is used to invalidate the flash cache. */ | void am_hal_cachectrl_invalidate_flash_cache(void) | /* Invalidate the flash cache.
This function is used to invalidate the flash cache. */
void am_hal_cachectrl_invalidate_flash_cache(void) | {
AM_REG(CACHECTRL, CACHECTRL) |= AM_REG_CACHECTRL_CACHECTRL_INVALIDATE_GO;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* ADC MSP Initialization This function configures the hardware resources used in this example. */ | void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) | /* ADC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) | {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hadc->Instance==ADC1)
{
__HAL_RCC_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Walk one heuristic dissector table's list calling a user supplied function on each entry. */ | void heur_dissector_table_foreach(const char *table_name, DATFunc_heur func, gpointer user_data) | /* Walk one heuristic dissector table's list calling a user supplied function on each entry. */
void heur_dissector_table_foreach(const char *table_name, DATFunc_heur func, gpointer user_data) | {
heur_dissector_foreach_info_t info;
heur_dissector_list_t sub_dissectors = find_heur_dissector_list(table_name);
info.table_name = table_name;
info.caller_func = func;
info.caller_data = user_data;
g_slist_foreach(sub_dissectors->dissectors,
heur_dissector_table_foreach_func, &info);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Forces the tim output 2 waveform to active or inactive level. */ | void TIM_ForcedOC2Config(TIM_TypeDef *tim, TIMOCMODE_Typedef forced_action) | /* Forces the tim output 2 waveform to active or inactive level. */
void TIM_ForcedOC2Config(TIM_TypeDef *tim, TIMOCMODE_Typedef forced_action) | {
MODIFY_REG(tim->CCMR1, TIM_CCMR1_OC2M, forced_action << 8);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Change Logs: Date Author Notes Wayne First version */ | static void nu_pin_uart_init(void) | /* Change Logs: Date Author Notes Wayne First version */
static void nu_pin_uart_init(void) | {
outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & 0xFFF00FFF) | 0x00011000);
outpw(REG_SYS_GPC_MFPH, (inpw(REG_SYS_GPC_MFPH) & 0xFFFFF00F) | 0x00000770);
outpw(REG_SYS_GPC_MFPH, (inpw(REG_SYS_GPC_MFPH) & 0xF000FFFF) | 0x07770000);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Checks whether the specified SDIO flag is set or not. */ | FlagStatus SDIO_GetFlagStatus(u32 SDIO_FLAG) | /* Checks whether the specified SDIO flag is set or not. */
FlagStatus SDIO_GetFlagStatus(u32 SDIO_FLAG) | {
return ((SDIO->CLR_MMC_INT & SDIO_FLAG) ? SET : RESET);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ | BOOLEAN EFIAPI CryptoServiceAesCbcDecrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output) | /* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceAesCbcDecrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output) | {
return CALL_BASECRYPTLIB (Aes.Services.CbcDecrypt, AesCbcDecrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Discard data from a connection. Mostly used to discard wrong-sized messages. Returns 0 on success, logs a message and returns -1 on a network error. */ | static int rpcapd_discard(SOCKET sock, uint32 len) | /* Discard data from a connection. Mostly used to discard wrong-sized messages. Returns 0 on success, logs a message and returns -1 on a network error. */
static int rpcapd_discard(SOCKET sock, uint32 len) | {
char errbuf[PCAP_ERRBUF_SIZE + 1];
if (len != 0)
{
if (sock_discard(sock, len, errbuf, PCAP_ERRBUF_SIZE) == -1)
{
rpcapd_log(LOGPRIO_ERROR, "Read from client failed: %s", errbuf);
return -1;
}
}
return 0;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* 6.5.2.7. SM Device Annunciation (Unconfirmed Service Id = 16) 6.5.2.7.1. Request Message Parameters */ | static void dissect_ff_msg_sm_dev_annunc_req_h1_node_addr(tvbuff_t *tvb, gint offset, proto_tree *tree) | /* 6.5.2.7. SM Device Annunciation (Unconfirmed Service Id = 16) 6.5.2.7.1. Request Message Parameters */
static void dissect_ff_msg_sm_dev_annunc_req_h1_node_addr(tvbuff_t *tvb, gint offset, proto_tree *tree) | {
proto_tree *sub_tree;
if (!tree) {
return;
}
sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 2,
ett_ff_sm_dev_annunc_req_h1_node_addr, NULL, "H1 Node Address Version Number (%u bytes)", 2);
proto_tree_add_item(sub_tree,
hf_ff_sm_dev_annunc_req_h1_node_addr_ver_num_h1_node_addr,
tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(sub_tree,
hf_ff_sm_dev_annunc_req_h1_node_addr_ver_num_ver_num,
tvb, offset, 1, ENC_BIG_ENDIAN);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Converts a text device path node to VLAN device path structure. */ | EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextVlan(CHAR16 *TextDeviceNode) | /* Converts a text device path node to VLAN device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextVlan(CHAR16 *TextDeviceNode) | {
CHAR16 *VlanStr;
VLAN_DEVICE_PATH *Vlan;
VlanStr = GetNextParamStr (&TextDeviceNode);
Vlan = (VLAN_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_VLAN_DP,
(UINT16) sizeof (VLAN_DEVICE_PATH)
);
Vlan->VlanId = (UINT16) Strtoi (VlanStr);
return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* stmmac_cleanup_module - Cleanup routine for the driver Description: This function is the cleanup routine for the driver. */ | static void __exit stmmac_cleanup_module(void) | /* stmmac_cleanup_module - Cleanup routine for the driver Description: This function is the cleanup routine for the driver. */
static void __exit stmmac_cleanup_module(void) | {
platform_driver_unregister(&stmmacphy_driver);
platform_driver_unregister(&stmmac_driver);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Determine frame start: first field for field picture or frame picture */ | static int mpeg2_get_is_frame_start(MpegEncContext *s) | /* Determine frame start: first field for field picture or frame picture */
static int mpeg2_get_is_frame_start(MpegEncContext *s) | {
return s->first_field || s->picture_structure == PICT_FRAME;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Checks whether the specified TIM flag is set or not. */ | FlagStatus TIM_GetFlagStatus(TIM_TypeDef *TIMx, uint16_t TIM_FLAG) | /* Checks whether the specified TIM flag is set or not. */
FlagStatus TIM_GetFlagStatus(TIM_TypeDef *TIMx, uint16_t TIM_FLAG) | {
ITStatus bitstatus = RESET;
assert_param(IS_TIM_ALL_PERIPH(TIMx));
assert_param(IS_TIM_GET_FLAG(TIM_FLAG));
if ((TIMx->SR & TIM_FLAG) != (uint16_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | gcallipo/RadioDSP-Stm32f103 | C++ | Common Creative - Attribution 3.0 | 51 |
/* Give up the control of the DHCP service to let other child resume. Don't change the service's DHCP state and the Client address and option list configure as required by RFC2131. */ | VOID DhcpYieldControl(IN DHCP_SERVICE *DhcpSb) | /* Give up the control of the DHCP service to let other child resume. Don't change the service's DHCP state and the Client address and option list configure as required by RFC2131. */
VOID DhcpYieldControl(IN DHCP_SERVICE *DhcpSb) | {
EFI_DHCP4_CONFIG_DATA *Config;
Config = &DhcpSb->ActiveConfig;
DhcpSb->ServiceState = DHCP_UNCONFIGED;
DhcpSb->ActiveChild = NULL;
if (Config->DiscoverTimeout != NULL) {
FreePool (Config->DiscoverTimeout);
Config->DiscoverTryCount = 0;
Config->DiscoverTimeout = NULL;
}
if (Config->RequestTimeout != NULL) {
FreePool (Config->RequestTimeout);
Config->RequestTryCount = 0;
Config->RequestTimeout = NULL;
}
Config->Dhcp4Callback = NULL;
Config->CallbackContext = NULL;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Wait until the LCD FCTRL register is synchronized in the LCDCLK domain. This function must be called after any write operation to LCD_FCTRL register. */ | LCD_ErrorTypeDef LCD_WaitForSynchro(void) | /* Wait until the LCD FCTRL register is synchronized in the LCDCLK domain. This function must be called after any write operation to LCD_FCTRL register. */
LCD_ErrorTypeDef LCD_WaitForSynchro(void) | {
uint32_t timeout;
timeout = 0;
while (RESET == (__LCD_GET_FLAG(LCD_FLAG_FCRSF)))
{
if (++timeout >= LCD_TIME_OUT)
{
return LCD_ERROR_FCRSF;
}
}
return LCD_ERROR_OK;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function parses the responses to the AT~LA and ATS311 commands, which list the radio's neighbours. */ | static void get_radio_neighbours(MetricomNodeTable *table, __u8 *ptr, __u8 *end) | /* This function parses the responses to the AT~LA and ATS311 commands, which list the radio's neighbours. */
static void get_radio_neighbours(MetricomNodeTable *table, __u8 *ptr, __u8 *end) | {
table->num_nodes = 0;
while (ptr < end && table->num_nodes < NODE_TABLE_SIZE) {
MetricomNode *node = &table->node[table->num_nodes++];
char *dst = node->c, *limit = dst + sizeof(*node) - 1;
while (ptr < end && *ptr <= 32)
ptr++;
while (ptr < end && dst < limit && *ptr != 10)
*dst++ = *ptr++;
*dst++ = 0;
while (ptr < end && ptr[-1] != 10)
ptr++;
}
do_gettimeofday(&table->timestamp);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base) | /* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base) | {
if(htim_base->Instance==TIM1)
{
__HAL_RCC_TIM1_CLK_DISABLE();
}
else if(htim_base->Instance==TIM16)
{
__HAL_RCC_TIM16_CLK_DISABLE();
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns 0 for success or NULL context or < 0 on error. */ | int audit_sockaddr(int len, void *a) | /* Returns 0 for success or NULL context or < 0 on error. */
int audit_sockaddr(int len, void *a) | {
struct audit_context *context = current->audit_context;
if (likely(!context || context->dummy))
return 0;
if (!context->sockaddr) {
void *p = kmalloc(sizeof(struct sockaddr_storage), GFP_KERNEL);
if (!p)
return -ENOMEM;
context->sockaddr = p;
}
context->sockaddr_len = len;
memcpy(context->sockaddr, a, len);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Find a section in a file by type and instance. An instance of 1 is the first instance. The function will return NULL if a matching section cannot be found. GUID-defined sections, if special processing is not needed, are handled in a depth-first manner. */ | EFI_STATUS GetSectionByType(IN EFI_FFS_FILE_HEADER *File, IN EFI_SECTION_TYPE SectionType, IN UINTN Instance, OUT EFI_FILE_SECTION_POINTER *Section) | /* Find a section in a file by type and instance. An instance of 1 is the first instance. The function will return NULL if a matching section cannot be found. GUID-defined sections, if special processing is not needed, are handled in a depth-first manner. */
EFI_STATUS GetSectionByType(IN EFI_FFS_FILE_HEADER *File, IN EFI_SECTION_TYPE SectionType, IN UINTN Instance, OUT EFI_FILE_SECTION_POINTER *Section) | {
EFI_FILE_SECTION_POINTER CurrentSection;
EFI_STATUS Status;
UINTN SectionCount;
if (File == NULL || Instance == 0) {
return EFI_INVALID_PARAMETER;
}
Status = VerifyFfsFile (File);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0006, "invalid FFS file", NULL);
return EFI_ABORTED;
}
SectionCount = 0;
CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + GetFfsHeaderLength(File));
Status = SearchSectionByType (
CurrentSection,
(UINT8 *) ((UINTN) File + GetFfsFileLength (File)),
SectionType,
&SectionCount,
Instance,
Section
);
if (!EFI_ERROR (Status)) {
return EFI_SUCCESS;
} else {
(*Section).Code16Section = NULL;
return EFI_NOT_FOUND;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function is called for every new tapedevice */ | int tapechar_setup_device(struct tape_device *device) | /* This function is called for every new tapedevice */
int tapechar_setup_device(struct tape_device *device) | {
char device_name[20];
sprintf(device_name, "ntibm%i", device->first_minor / 2);
device->nt = register_tape_dev(
&device->cdev->dev,
MKDEV(tapechar_major, device->first_minor),
&tape_fops,
device_name,
"non-rewinding"
);
device_name[0] = 'r';
device->rt = register_tape_dev(
&device->cdev->dev,
MKDEV(tapechar_major, device->first_minor + 1),
&tape_fops,
device_name,
"rewinding"
);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Relocation based on dirid, hashing them into a given bitmap block files. Formatted nodes are unaffected, a separate policy covers them */ | static void dirid_groups(reiserfs_blocknr_hint_t *hint) | /* Relocation based on dirid, hashing them into a given bitmap block files. Formatted nodes are unaffected, a separate policy covers them */
static void dirid_groups(reiserfs_blocknr_hint_t *hint) | {
unsigned long hash;
__u32 dirid = 0;
int bm = 0;
struct super_block *sb = hint->th->t_super;
if (hint->inode)
dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
else if (hint->formatted_node)
dirid = hint->key.k_dir_id;
if (dirid) {
bm = bmap_hash_id(sb, dirid);
hash = bm * (sb->s_blocksize << 3);
if (hint->inode)
hash += sb->s_blocksize / 2;
hint->search_start = hash;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ | RETURN_STATUS EFIAPI SafeInt64ToInt8(IN INT64 Operand, OUT INT8 *Result) | /* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64ToInt8(IN INT64 Operand, OUT INT8 *Result) | {
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if ((Operand >= MIN_INT8) && (Operand <= MAX_INT8)) {
*Result = (INT8)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = INT8_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enable or disable the specified UART interrupt.
@method UART_ITConfig */ | void UART_ITConfig(UART_TypeDef *UARTx, uint32_t UART_IT, FunctionalState NewState) | /* Enable or disable the specified UART interrupt.
@method UART_ITConfig */
void UART_ITConfig(UART_TypeDef *UARTx, uint32_t UART_IT, FunctionalState NewState) | {
_ASSERT(IS_UART(UARTx));
_ASSERT(IS_UART_IT(UART_IT));
if (UART_IT == UART_IT_TX)
{
UARTx->BAUD.bit.TX_INT_EN = NewState;
}
else if (UART_IT == UART_IT_RX)
{
UARTx->RX_INT_LEN.bit.VAL = NewState;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Converts from 2 digit BCD to Binary format. */ | static uint8_t Bcd2ToByte(uint8_t Value) | /* Converts from 2 digit BCD to Binary format. */
static uint8_t Bcd2ToByte(uint8_t Value) | {
uint8_t tmp = 0;
tmp = (uint8_t)((uint8_t)((uint8_t)(Value & (uint8_t)0xF0) >> 4) * (uint8_t)10);
return (uint8_t)(tmp + (Value & (uint8_t)0x0F));
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Check if the supplied point is at infinity. */ | BOOLEAN EFIAPI CryptoServiceEcPointIsAtInfinity(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint) | /* Check if the supplied point is at infinity. */
BOOLEAN EFIAPI CryptoServiceEcPointIsAtInfinity(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint) | {
return CALL_BASECRYPTLIB (Ec.Services.PointIsAtInfinity, EcPointIsAtInfinity, (EcGroup, EcPoint), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Deliver a message's payload to its intended recipient. */ | void xpc_deliver_payload(struct xpc_channel *ch) | /* Deliver a message's payload to its intended recipient. */
void xpc_deliver_payload(struct xpc_channel *ch) | {
void *payload;
payload = xpc_arch_ops.get_deliverable_payload(ch);
if (payload != NULL) {
xpc_msgqueue_ref(ch);
atomic_inc(&ch->kthreads_active);
if (ch->func != NULL) {
dev_dbg(xpc_chan, "ch->func() called, payload=0x%p "
"partid=%d channel=%d\n", payload, ch->partid,
ch->number);
ch->func(xpMsgReceived, ch->partid, ch->number, payload,
ch->key);
dev_dbg(xpc_chan, "ch->func() returned, payload=0x%p "
"partid=%d channel=%d\n", payload, ch->partid,
ch->number);
}
atomic_dec(&ch->kthreads_active);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* changes the status to the specified value. Doesn't change other bits in the status */ | static void gelic_descr_set_status(struct gelic_descr *descr, enum gelic_descr_dma_status status) | /* changes the status to the specified value. Doesn't change other bits in the status */
static void gelic_descr_set_status(struct gelic_descr *descr, enum gelic_descr_dma_status status) | {
descr->dmac_cmd_status = cpu_to_be32(status |
(be32_to_cpu(descr->dmac_cmd_status) &
~GELIC_DESCR_DMA_STAT_MASK));
wmb();
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* USB_OTG_WritePacket : Writes a packet into the Tx FIFO associated with the EP. */ | USB_OTG_STS USB_OTG_WritePacket(USB_OTG_CORE_HANDLE *pdev, uint8_t *src, uint8_t ch_ep_num, uint16_t len) | /* USB_OTG_WritePacket : Writes a packet into the Tx FIFO associated with the EP. */
USB_OTG_STS USB_OTG_WritePacket(USB_OTG_CORE_HANDLE *pdev, uint8_t *src, uint8_t ch_ep_num, uint16_t len) | {
USB_OTG_STS status = USB_OTG_OK;
if (pdev->cfg.dma_enable == 0)
{
uint32_t count32b= 0 , i= 0;
__IO uint32_t *fifo;
count32b = (len + 3) / 4;
fifo = pdev->regs.DFIFO[ch_ep_num];
for (i = 0; i < count32b; i++)
{
USB_OTG_WRITE_REG32( fifo, __UNALIGNED_UINT32_READ(src) );
src+=4;
}
}
return status;
} | opentx/opentx | C++ | GNU General Public License v2.0 | 2,025 |
/* db9_saturn_read_analog() sends clock and reads 8 bit data. */ | static unsigned char db9_saturn_read_analog(struct parport *port, int type, int powered) | /* db9_saturn_read_analog() sends clock and reads 8 bit data. */
static unsigned char db9_saturn_read_analog(struct parport *port, int type, int powered) | {
unsigned char data;
db9_saturn_write_sub(port, type, 0, powered, 0);
udelay(DB9_SATURN_DELAY);
data = db9_saturn_read_sub(port, type) << 4;
db9_saturn_write_sub(port, type, 2, powered, 0);
udelay(DB9_SATURN_DELAY);
data |= db9_saturn_read_sub(port, type);
return data;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The Si7210 device do not have a reset function, but most of the registers are reloaded when exiting from sleep mode. */ | static int si7210_reset(const struct device *dev) | /* The Si7210 device do not have a reset function, but most of the registers are reloaded when exiting from sleep mode. */
static int si7210_reset(const struct device *dev) | {
int rc;
rc = si7210_sleep(dev);
if (rc < 0) {
return rc;
}
rc = si7210_wakeup(dev);
return rc;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* read/write the ring buffer pointers. These routines' arguments and results are byte offsets from the beginning of the ring buffer. */ | static __inline__ int li_read_swptr(dma_chan_t *chan) | /* read/write the ring buffer pointers. These routines' arguments and results are byte offsets from the beginning of the ring buffer. */
static __inline__ int li_read_swptr(dma_chan_t *chan) | {
const unsigned long mask = chan->desc->swptrmask;
return CHUNKS_TO_BYTES(UNSHIFT_FIELD(chan->ctlval, mask));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return: 0 if all goes good, else appropriate error message. */ | static int k3_dsp_of_to_priv(struct udevice *dev, struct k3_dsp_privdata *dsp) | /* Return: 0 if all goes good, else appropriate error message. */
static int k3_dsp_of_to_priv(struct udevice *dev, struct k3_dsp_privdata *dsp) | {
int ret;
dev_dbg(dev, "%s\n", __func__);
ret = reset_get_by_index(dev, 0, &dsp->dsp_rst);
if (ret) {
dev_err(dev, "reset_get() failed: %d\n", ret);
return ret;
}
ret = ti_sci_proc_of_to_priv(dev, &dsp->tsp);
if (ret)
return ret;
ret = k3_dsp_of_get_memories(dev);
if (ret)
return ret;
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This routine is called when the OS wants the adapter's stats returned. It returns the address of the net_device_stats stucture for the device. If the statistics are currently being updated, then they might be incorrect for a short while. However, since this cannot actually cause damage, no locking is used. */ | struct net_device_stats * usbdrv_get_stats(struct net_device *) | /* This routine is called when the OS wants the adapter's stats returned. It returns the address of the net_device_stats stucture for the device. If the statistics are currently being updated, then they might be incorrect for a short while. However, since this cannot actually cause damage, no locking is used. */
struct net_device_stats * usbdrv_get_stats(struct net_device *) | {
struct usbdrv_private *macp = dev->ml_priv;
macp->drv_stats.net_stats.tx_errors =
macp->drv_stats.net_stats.tx_carrier_errors +
macp->drv_stats.net_stats.tx_aborted_errors;
macp->drv_stats.net_stats.rx_errors =
macp->drv_stats.net_stats.rx_crc_errors +
macp->drv_stats.net_stats.rx_frame_errors +
macp->drv_stats.net_stats.rx_length_errors;
return &(macp->drv_stats.net_stats);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Power role swap: Rp resitor on the CC line.
It requests Rp assertion on CC line as step of power role swap USB PD transaction */ | USBPD_StatusTypeDef USBPD_HW_IF_PRS_Assert_Rp(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole) | /* Power role swap: Rp resitor on the CC line.
It requests Rp assertion on CC line as step of power role swap USB PD transaction */
USBPD_StatusTypeDef USBPD_HW_IF_PRS_Assert_Rp(uint8_t PortNum, USBPD_PortPowerRole_TypeDef CurrentRole) | {
CAD_HW_HandleTypeDef *_handle = &CAD_HW_Handles[PortNum];
if ((USBPD_FALSE == _handle->settings->CAD_RoleToggle) && (CurrentRole != USBPD_PORTPOWERROLE_SNK))
{
return USBPD_ERROR;
}
return (USBPD_StatusTypeDef)STUSB1602_Type_C_Command(STUSB1602_I2C_Add(PortNum), PD_PR_SWAP_RP_ASSERT_REQ);
} | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* Returns the value of the register at @offset. */ | u32 hmatrix_read_reg(unsigned long offset) | /* Returns the value of the register at @offset. */
u32 hmatrix_read_reg(unsigned long offset) | {
u32 value;
clk_enable(&at32_hmatrix_clk);
value = __hmatrix_read_reg(offset);
clk_disable(&at32_hmatrix_clk);
return value;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Lock the Configuration of a Group of Pins.
The configuration of one or more pins of the given GPIO port is locked. There is no mechanism to unlock these via software. Unlocking occurs at the next reset. */ | void gpio_port_config_lock(uint32_t gpio_port, uint16_t gpios) | /* Lock the Configuration of a Group of Pins.
The configuration of one or more pins of the given GPIO port is locked. There is no mechanism to unlock these via software. Unlocking occurs at the next reset. */
void gpio_port_config_lock(uint32_t gpio_port, uint16_t gpios) | {
GPIO_P_PINLOCKN(gpio_port) = ~gpios;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* p_{j} = x_{j} / (period/2 + t % period/2) */ | void prop_fraction_single(struct prop_descriptor *pd, struct prop_local_single *pl, long *numerator, long *denominator) | /* p_{j} = x_{j} / (period/2 + t % period/2) */
void prop_fraction_single(struct prop_descriptor *pd, struct prop_local_single *pl, long *numerator, long *denominator) | {
struct prop_global *pg = prop_get_global(pd);
unsigned long period_2 = 1UL << (pg->shift - 1);
unsigned long counter_mask = period_2 - 1;
unsigned long global_count;
prop_norm_single(pg, pl);
*numerator = pl->events;
global_count = percpu_counter_read(&pg->events);
*denominator = period_2 + (global_count & counter_mask);
prop_put_global(pd, pg);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Check if any of the bits that affect a dumb device have changed between the two termios structures, or a speed change is needed. */ | int tty_termios_hw_change(struct ktermios *a, struct ktermios *b) | /* Check if any of the bits that affect a dumb device have changed between the two termios structures, or a speed change is needed. */
int tty_termios_hw_change(struct ktermios *a, struct ktermios *b) | {
if (a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed)
return 1;
if ((a->c_cflag ^ b->c_cflag) & ~(HUPCL | CREAD | CLOCAL))
return 1;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reads relative humidity and temperature from a Si/21 sensor. */ | sl_status_t sl_si70xx_read_rh_and_temp(sl_i2cspm_t *i2cspm, uint8_t addr, uint32_t *rhData, int32_t *tData) | /* Reads relative humidity and temperature from a Si/21 sensor. */
sl_status_t sl_si70xx_read_rh_and_temp(sl_i2cspm_t *i2cspm, uint8_t addr, uint32_t *rhData, int32_t *tData) | {
sl_status_t status;
status = sl_si70xx_read_data(i2cspm, addr, rhData);
if (status != SL_STATUS_OK) {
return status;
}
*rhData = sl_si70xx_get_percent_relative_humidity(*rhData);
status = sl_si70xx_send_command(i2cspm, addr, (uint32_t *) tData, SI70XX_READ_TEMP);
if (status != SL_STATUS_OK) {
return status;
}
*tData = sl_si70xx_get_celcius_temperature(*tData);
return status;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Opens a new file relative to the source file's location. */ | EFI_STATUS EFIAPI FileInterfaceFileOpen(IN EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes) | /* Opens a new file relative to the source file's location. */
EFI_STATUS EFIAPI FileInterfaceFileOpen(IN EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes) | {
return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Open (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, NewHandle, FileName, OpenMode, Attributes);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Output: void, but we will add to proto tree if !NULL. */ | static void dissect_area_address_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length) | /* Output: void, but we will add to proto tree if !NULL. */
static void dissect_area_address_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length) | {
while (length > 0) {
if (length < 4) {
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
"Short area address entry");
return;
}
proto_tree_add_item(tree, hf_nlsp_area_address_network_number, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
length -= 4;
if (length < 4) {
proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
"Short area address entry");
return;
}
proto_tree_add_item(tree, hf_nlsp_area_address_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
length -= 4;
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* release this cell, free extended data if available */ | static void free_cell(struct snd_seq_pool *pool, struct snd_seq_event_cell *cell) | /* release this cell, free extended data if available */
static void free_cell(struct snd_seq_pool *pool, struct snd_seq_event_cell *cell) | {
cell->next = pool->free;
pool->free = cell;
atomic_dec(&pool->counter);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Initializes the parameters in the CMP_InitStruct with default value. */ | void CMP_StructInit(CMP_InitTypeDef *CMP_InitStruct) | /* Initializes the parameters in the CMP_InitStruct with default value. */
void CMP_StructInit(CMP_InitTypeDef *CMP_InitStruct) | {
u8 i;
for(i = 0; i < COMP_CH_NUM; i++) {
CMP_InitStruct->CMP_ChanCtrl[i].CMP_ChIndex = i;
CMP_InitStruct->CMP_ChanCtrl[i].CMP_Ref0 = 0;
CMP_InitStruct->CMP_ChanCtrl[i].CMP_Ref1 = 0x1F;
CMP_InitStruct->CMP_ChanCtrl[i].CMP_WakeType = COMP_WK_NONE;
CMP_InitStruct->CMP_ChanCtrl[i].CMP_WakeSysCtrl = COMP_WITHIN_REF0_AND_REF1;
CMP_InitStruct->CMP_ChanCtrl[i].CMP_WakeADCCtrl = COMP_WITHIN_REF0_AND_REF1;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* param handle The RTOS LPI2C handle. param transfer Structure specifying the transfer parameters. return status of the operation. */ | status_t LPI2C_RTOS_Transfer(lpi2c_rtos_handle_t *handle, lpi2c_master_transfer_t *transfer) | /* param handle The RTOS LPI2C handle. param transfer Structure specifying the transfer parameters. return status of the operation. */
status_t LPI2C_RTOS_Transfer(lpi2c_rtos_handle_t *handle, lpi2c_master_transfer_t *transfer) | {
status_t status;
if (xSemaphoreTake(handle->mutex, portMAX_DELAY) != pdTRUE)
{
return kStatus_LPI2C_Busy;
}
status = LPI2C_MasterTransferNonBlocking(handle->base, &handle->drv_handle, transfer);
if (status != kStatus_Success)
{
(void)xSemaphoreGive(handle->mutex);
return status;
}
(void)xSemaphoreTake(handle->semaphore, portMAX_DELAY);
(void)xSemaphoreGive(handle->mutex);
return handle->async_status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Dump the initial data from the packet to dev_dbg(). */ | static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) | /* Dump the initial data from the packet to dev_dbg(). */
static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) | {
ks_dbg(ks, "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n",
rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7],
rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11],
rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* pressure_ref: The Reference pressure value is a 24-bit data expressed as 2’s complement. The value is used when AUTOZERO or AUTORIFP function is enabled. */ | int32_t lps22hb_pressure_ref_get(stmdev_ctx_t *ctx, uint8_t *buff) | /* pressure_ref: The Reference pressure value is a 24-bit data expressed as 2’s complement. The value is used when AUTOZERO or AUTORIFP function is enabled. */
int32_t lps22hb_pressure_ref_get(stmdev_ctx_t *ctx, uint8_t *buff) | {
int32_t ret;
ret = lps22hb_read_reg(ctx, LPS22HB_REF_P_XL, buff, 3);
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Configures EXTI lines 15 to 10 (connected to PC.13 pin) in interrupt mode. */ | static void EXTI15_10_IRQHandler_Config(void) | /* Configures EXTI lines 15 to 10 (connected to PC.13 pin) in interrupt mode. */
static void EXTI15_10_IRQHandler_Config(void) | {
GPIO_InitTypeDef GPIO_InitStructure;
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Pin = GPIO_PIN_13;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Initialize the boards on-board LEDs (LD3 to LD10)
The LEDs are connected to the following pins: */ | static void leds_init(void) | /* Initialize the boards on-board LEDs (LD3 to LD10)
The LEDs are connected to the following pins: */
static void leds_init(void) | {
RCC->AHBENR |= RCC_AHBENR_GPIOEEN;
LED_PORT->OSPEEDR |= 0xffff0000;
LED_PORT->OTYPER &= ~(0x0000ff00);
LED_PORT->MODER &= ~(0xffff0000);
LED_PORT->MODER |= 0x55550000;
LED_PORT->PUPDR &= ~(0xffff0000);
LED_PORT->BRR = 0xff00;
} | labapart/polymcu | C++ | null | 201 |
/* fsl_ddr_sdram_size(first_ctrl, last_intlv) - This function only returns the size of the total memory without setting ddr control registers. */ | phys_size_t fsl_ddr_sdram_size(void) | /* fsl_ddr_sdram_size(first_ctrl, last_intlv) - This function only returns the size of the total memory without setting ddr control registers. */
phys_size_t fsl_ddr_sdram_size(void) | {
fsl_ddr_info_t info;
unsigned long long total_memory = 0;
memset(&info, 0 , sizeof(fsl_ddr_info_t));
info.mem_base = CONFIG_SYS_FSL_DDR_SDRAM_BASE_PHY;
info.first_ctrl = 0;
info.num_ctrls = CONFIG_SYS_FSL_DDR_MAIN_NUM_CTRLS;
info.dimm_slots_per_ctrl = CONFIG_DIMM_SLOTS_PER_CTLR;
info.board_need_mem_reset = NULL;
remove_unused_controllers(&info);
total_memory = fsl_ddr_compute(&info, STEP_GET_SPD, 1);
return total_memory;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name. If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward compatibility support. */ | CHAR16* DriverHealthManagerGetDriverName(IN EFI_HANDLE DriverBindingHandle) | /* This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name. If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward compatibility support. */
CHAR16* DriverHealthManagerGetDriverName(IN EFI_HANDLE DriverBindingHandle) | {
EFI_STATUS Status;
CHAR16 *DriverName;
Status = DriverHealthManagerGetDriverNameWorker (&gEfiComponentName2ProtocolGuid, DriverBindingHandle, &DriverName);
if (EFI_ERROR (Status)) {
Status = DriverHealthManagerGetDriverNameWorker (&gEfiComponentNameProtocolGuid, DriverBindingHandle, &DriverName);
}
if (!EFI_ERROR (Status)) {
return AllocateCopyPool (StrSize (DriverName), DriverName);
} else {
return ConvertDevicePathToText (DevicePathFromHandle (DriverBindingHandle), FALSE, TRUE);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Function for transferring a byte when it collides with SLIP commands and follows the SLIP escape byte, that is 0xC0 => 0xDC and 0xDB => 0xDD. */ | static uint32_t send_tx_byte_encoded(void) | /* Function for transferring a byte when it collides with SLIP commands and follows the SLIP escape byte, that is 0xC0 => 0xDC and 0xDB => 0xDD. */
static uint32_t send_tx_byte_encoded(void) | {
uint32_t err_code;
switch(mp_tx_buffer[m_tx_buffer_index])
{
case APP_SLIP_END:
err_code = app_uart_put(APP_SLIP_ESC_END);
break;
case APP_SLIP_ESC:
err_code = app_uart_put(APP_SLIP_ESC_ESC);
break;
default:
err_code = NRF_ERROR_NO_MEM;
break;
}
if (err_code == NRF_SUCCESS)
{
m_tx_buffer_index++;
send_tx_byte = send_tx_byte_default;
}
return err_code;
} | labapart/polymcu | C++ | null | 201 |
/* 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 lsm6dsl_tap_dur_get(stmdev_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 lsm6dsl_tap_dur_get(stmdev_ctx_t *ctx, uint8_t *val) | {
lsm6dsl_int_dur2_t int_dur2;
int32_t ret;
ret = lsm6dsl_read_reg(ctx, LSM6DSL_INT_DUR2, (uint8_t*)&int_dur2, 1);
*val = int_dur2.dur;
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Clear the Write Protect Error Status Flag, upper Bank. */ | void flash_clear_wrprterr_flag_upper(void) | /* Clear the Write Protect Error Status Flag, upper Bank. */
void flash_clear_wrprterr_flag_upper(void) | {
if (DESIG_FLASH_SIZE > 512) {
FLASH_SR2 |= FLASH_SR_WRPRTERR;
}
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Function to compare 2 SMM_BASE_HOB_DATA pointer based on ProcessorIndex. */ | INTN EFIAPI SmBaseHobCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2) | /* Function to compare 2 SMM_BASE_HOB_DATA pointer based on ProcessorIndex. */
INTN EFIAPI SmBaseHobCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2) | {
if ((*(SMM_BASE_HOB_DATA **)Buffer1)->ProcessorIndex > (*(SMM_BASE_HOB_DATA **)Buffer2)->ProcessorIndex) {
return 1;
} else if ((*(SMM_BASE_HOB_DATA **)Buffer1)->ProcessorIndex < (*(SMM_BASE_HOB_DATA **)Buffer2)->ProcessorIndex) {
return -1;
}
return 0;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Configures the TIMx Output Compare 4 Fast feature. */ | void TIM_OC4FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast) | /* Configures the TIMx Output Compare 4 Fast feature. */
void TIM_OC4FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast) | {
uint16_t tmpccmr2 = 0;
assert_param(IS_TIM_LIST3_PERIPH(TIMx));
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr2 = TIMx->CCMR2;
tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4FE);
tmpccmr2 |= (uint16_t)(TIM_OCFast << 8);
TIMx->CCMR2 = tmpccmr2;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns the next event in "free" state, and NULL if none are free. Note that no synchronization is done here, we assume the host_lock will syncrhonze things. */ | static struct srp_event_struct* get_event_struct(struct event_pool *pool) | /* Returns the next event in "free" state, and NULL if none are free. Note that no synchronization is done here, we assume the host_lock will syncrhonze things. */
static struct srp_event_struct* get_event_struct(struct event_pool *pool) | {
int i;
int poolsize = pool->size;
int offset = pool->next;
for (i = 0; i < poolsize; i++) {
offset = (offset + 1) % poolsize;
if (!atomic_dec_if_positive(&pool->events[offset].free)) {
pool->next = offset;
return &pool->events[offset];
}
}
printk(KERN_ERR "ibmvscsi: found no event struct in pool!\n");
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Function for outputting usage info to the serial port. */ | static void help(void) | /* Function for outputting usage info to the serial port. */
static void help(void) | {
printf("Usage:\r\n");
printf("a: Enter start channel for sweep/channel for constant carrier\r\n");
printf("b: Enter end channel for sweep\r\n");
printf("c: Start TX carrier\r\n");
printf("d: Enter time on each channel (1ms-99ms)\r\n");
printf("e: Cancel sweep/carrier\r\n");
printf("m: Enter data rate\r\n");
printf("o: Start modulated TX carrier\r\n");
printf("p: Enter output power\r\n");
printf("s: Print current delay, channels and so on\r\n");
printf("r: Start RX sweep\r\n");
printf("t: Start TX sweep\r\n");
printf("x: Start RX carrier\r\n");
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Internal function. Frees pool pages allocated via AllocatePoolPages () */ | VOID CoreFreePoolPages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages) | /* Internal function. Frees pool pages allocated via AllocatePoolPages () */
VOID CoreFreePoolPages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages) | {
CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If 16-bit MMIO register operations are not supported, then ASSERT(). */ | UINT16 EFIAPI S3MmioRead16(IN UINTN Address) | /* If 16-bit MMIO register operations are not supported, then ASSERT(). */
UINT16 EFIAPI S3MmioRead16(IN UINTN Address) | {
return InternalSaveMmioWrite16ValueToBootScript (Address, MmioRead16 (Address));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* g e t O b j V a l */ | real_t QProblem_getObjVal(QProblem *_THIS) | /* g e t O b j V a l */
real_t QProblem_getObjVal(QProblem *_THIS) | {
real_t objVal;
if ( ( QProblem_getStatus( _THIS ) == QPS_AUXILIARYQPSOLVED ) ||
( QProblem_getStatus( _THIS ) == QPS_HOMOTOPYQPSOLVED ) ||
( QProblem_getStatus( _THIS ) == QPS_SOLVED ) )
{
objVal = QProblem_getObjValX( _THIS,_THIS->x );
}
else
{
objVal = QPOASES_INFTY;
}
return objVal;
} | DanielMartensson/EmbeddedLapack | C++ | MIT License | 129 |
/* 3. VGCS/VBS QUEUING INDICATION No data 3. UPLINK REQUEST */ | static void bssmap_uplink_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) | /* 3. VGCS/VBS QUEUING INDICATION No data 3. UPLINK REQUEST */
static void bssmap_uplink_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) | {
guint32 curr_offset;
guint32 consumed;
guint curr_len;
curr_offset = offset;
curr_len = len;
ELEM_OPT_TV(BE_TALKER_PRI, GSM_A_PDU_TYPE_BSSMAP, BE_TALKER_PRI, NULL);
ELEM_MAND_TLV(BE_CELL_ID, GSM_A_PDU_TYPE_BSSMAP, BE_CELL_ID, NULL, ei_gsm_a_bssmap_missing_mandatory_element);
ELEM_OPT_TLV(BE_L3_INFO, GSM_A_PDU_TYPE_BSSMAP, BE_L3_INFO, NULL);
ELEM_OPT_TLV(BE_MID, GSM_A_PDU_TYPE_COMMON, DE_MID, NULL);
EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_bssmap_extraneous_data);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Send the IO_SEND_OP_COND command for inquiring about the voltage range needed by the I/O card. */ | int32_t SDMMC_CMD5_IOSendOperateCond(CM_SDIOC_TypeDef *SDIOCx, uint32_t u32Argument, uint32_t *pu32ErrStatus) | /* Send the IO_SEND_OP_COND command for inquiring about the voltage range needed by the I/O card. */
int32_t SDMMC_CMD5_IOSendOperateCond(CM_SDIOC_TypeDef *SDIOCx, uint32_t u32Argument, uint32_t *pu32ErrStatus) | {
int32_t i32Ret;
stc_sdioc_cmd_config_t stcCmdConfig;
if (NULL == pu32ErrStatus) {
i32Ret = LL_ERR_INVD_PARAM;
} else {
stcCmdConfig.u32Argument = u32Argument;
stcCmdConfig.u16CmdIndex = SDIOC_CMD5_IO_SEND_OP_COND;
stcCmdConfig.u16CmdType = SDIOC_CMD_TYPE_NORMAL;
stcCmdConfig.u16DataLine = SDIOC_DATA_LINE_DISABLE;
stcCmdConfig.u16ResponseType = SDIOC_RESP_TYPE_R3_R4;
i32Ret = SDIOC_SendCommand(SDIOCx, &stcCmdConfig);
if (LL_OK == i32Ret) {
i32Ret = SDMMC_GetCmdResp4(SDIOCx, pu32ErrStatus);
}
}
return i32Ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check whether the specified I2S flag is set or not. */ | flag_status_t ald_i2s_get_status(ald_i2s_handle_t *hperh, ald_i2s_status_t status) | /* Check whether the specified I2S flag is set or not. */
flag_status_t ald_i2s_get_status(ald_i2s_handle_t *hperh, ald_i2s_status_t status) | {
assert_param(IS_I2S(hperh->perh));
assert_param(IS_I2S_STATUS(status));
if (hperh->perh->STAT & status)
return SET;
return RESET;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Delete or update Neighbor cache entries. It is a work function for EfiIp6Neighbors(). */ | EFI_STATUS Ip6DelNeighbor(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *TargetIp6Address, IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, IN UINT32 Timeout, IN BOOLEAN Override) | /* Delete or update Neighbor cache entries. It is a work function for EfiIp6Neighbors(). */
EFI_STATUS Ip6DelNeighbor(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *TargetIp6Address, IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, IN UINT32 Timeout, IN BOOLEAN Override) | {
IP6_NEIGHBOR_ENTRY *Neighbor;
Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address);
if (Neighbor == NULL) {
return EFI_NOT_FOUND;
}
RemoveEntryList (&Neighbor->Link);
FreePool (Neighbor);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: the signal name, or NULL if the signal number was invalid. */ | const gchar* g_signal_name(guint signal_id) | /* Returns: the signal name, or NULL if the signal number was invalid. */
const gchar* g_signal_name(guint signal_id) | {
SignalNode *node;
const gchar *name;
SIGNAL_LOCK ();
node = LOOKUP_SIGNAL_NODE (signal_id);
name = node ? node->name : NULL;
SIGNAL_UNLOCK ();
return (char*) name;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Selects the tim peripheral Capture Compare DMA source. */ | void TIM_SelectCCDMA(TIM_TypeDef *tim, FunctionalState state) | /* Selects the tim peripheral Capture Compare DMA source. */
void TIM_SelectCCDMA(TIM_TypeDef *tim, FunctionalState state) | {
(state) ? SET_BIT(tim->CR2, TIM_CR2_CCDS) : CLEAR_BIT(tim->CR2, TIM_CR2_CCDS);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* clk_enable - inform the system when the clock source should be running. */ | int clk_enable(struct clk *clk) | /* clk_enable - inform the system when the clock source should be running. */
int clk_enable(struct clk *clk) | {
unsigned long flags;
spin_lock_irqsave(&clocks_lock, flags);
if (clk->enabled++ == 0 && clk->clk_enable)
clk->clk_enable(clk);
spin_unlock_irqrestore(&clocks_lock, flags);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This functions converts in place a buffer of RGBA interleaved data into RGB interleaved data, adding 255-A to each component sample. */ | tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32) | /* This functions converts in place a buffer of RGBA interleaved data into RGB interleaved data, adding 255-A to each component sample. */
tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32) | {
uint32 i = 0;
uint32 sample = 0;
uint8 alpha = 0;
for (i = 0; i < samplecount; i++) {
sample=((uint32*)data)[i];
alpha=(uint8)((255 - ((sample >> 24) & 0xff)));
((uint8 *)data)[i * 3] = (uint8) ((sample >> 16) & 0xff) + alpha;
((uint8 *)data)[i * 3 + 1] = (uint8) ((sample >> 8) & 0xff) + alpha;
((uint8 *)data)[i * 3 + 2] = (uint8) (sample & 0xff) + alpha;
}
return (i * 3);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Set Shadow(Update) Register.
This function is used to reload frame buffer address after setting shoaw(update) register. */ | void CAP_SetShadowRegister(void) | /* Set Shadow(Update) Register.
This function is used to reload frame buffer address after setting shoaw(update) register. */
void CAP_SetShadowRegister(void) | {
outp32(REG_CAP_CTL, inp32(REG_CAP_CTL) | UPDATE);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns 1 if the status property is absent or set to "okay" or "ok", 0 otherwise */ | int of_device_is_available(const struct device_node *device) | /* Returns 1 if the status property is absent or set to "okay" or "ok", 0 otherwise */
int of_device_is_available(const struct device_node *device) | {
const char *status;
int statlen;
status = of_get_property(device, "status", &statlen);
if (status == NULL)
return 1;
if (statlen > 0) {
if (!strcmp(status, "okay") || !strcmp(status, "ok"))
return 1;
}
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This request allows the host to specify typical asynchronous line-character formatting properties This request applies to asynchronous byte stream data class interfaces and endpoints. */ | static USBH_StatusTypeDef SetLineCoding(USBH_HandleTypeDef *phost, CDC_LineCodingTypeDef *linecoding) | /* This request allows the host to specify typical asynchronous line-character formatting properties This request applies to asynchronous byte stream data class interfaces and endpoints. */
static USBH_StatusTypeDef SetLineCoding(USBH_HandleTypeDef *phost, CDC_LineCodingTypeDef *linecoding) | {
phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_TYPE_CLASS |
USB_REQ_RECIPIENT_INTERFACE;
phost->Control.setup.b.bRequest = CDC_SET_LINE_CODING;
phost->Control.setup.b.wValue.w = 0U;
phost->Control.setup.b.wIndex.w = 0U;
phost->Control.setup.b.wLength.w = LINE_CODING_STRUCTURE_SIZE;
return USBH_CtlReq(phost, linecoding->Array, LINE_CODING_STRUCTURE_SIZE);
} | ua1arn/hftrx | C++ | null | 69 |
/* This function must not block. So, the alloc can't block. In the worst case, it is ok to fail. It would simply mean we can't clear the region. Does nothing to current sync context, but does mean the region will be re-sync'ed on a reload of the mirror even though it is in-sync. */ | static void userspace_clear_region(struct dm_dirty_log *log, region_t region) | /* This function must not block. So, the alloc can't block. In the worst case, it is ok to fail. It would simply mean we can't clear the region. Does nothing to current sync context, but does mean the region will be re-sync'ed on a reload of the mirror even though it is in-sync. */
static void userspace_clear_region(struct dm_dirty_log *log, region_t region) | {
unsigned long flags;
struct log_c *lc = log->context;
struct flush_entry *fe;
fe = mempool_alloc(flush_entry_pool, GFP_ATOMIC);
if (!fe) {
DMERR("Failed to allocate memory to clear region.");
return;
}
spin_lock_irqsave(&lc->flush_lock, flags);
fe->type = DM_ULOG_CLEAR_REGION;
fe->region = region;
list_add(&fe->list, &lc->flush_list);
spin_unlock_irqrestore(&lc->flush_lock, flags);
return;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* I picked the pattern-matching-functions from an old GNU-tar version (1.10) It was originally written and put to PD by */ | static int isdn_star(char *s, char *p) | /* I picked the pattern-matching-functions from an old GNU-tar version (1.10) It was originally written and put to PD by */
static int isdn_star(char *s, char *p) | {
while (isdn_wildmat(s, p)) {
if (*++s == '\0')
return (2);
}
return (0);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The precision internal oscillator can be powered down in deep-sleep mode by specifying */ | void SysCtlDeepSleepClockSet(unsigned long ulConfig) | /* The precision internal oscillator can be powered down in deep-sleep mode by specifying */
void SysCtlDeepSleepClockSet(unsigned long ulConfig) | {
HWREG(SYSCTL_DSLPCLKCFG) = ulConfig;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Returns 1 if the buffer is empty, 0 otherwise. */ | static int relay_buf_empty(struct rchan_buf *buf) | /* Returns 1 if the buffer is empty, 0 otherwise. */
static int relay_buf_empty(struct rchan_buf *buf) | {
return (buf->subbufs_produced - buf->subbufs_consumed) ? 0 : 1;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Checks whether the packet received is a wakeup frame?. */ | bool synopGMAC_is_wakeup_frame_received(synopGMACdevice *gmacdev) | /* Checks whether the packet received is a wakeup frame?. */
bool synopGMAC_is_wakeup_frame_received(synopGMACdevice *gmacdev) | {
u32 data;
data = synopGMACReadReg(gmacdev->MacBase, GmacPmtCtrlStatus);
return ((data & GmacPmtWakeupFrameReceived) == GmacPmtWakeupFrameReceived);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Configures the PLL clock source and multiplication factor. */ | void RCC_ConfigPll(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul) | /* Configures the PLL clock source and multiplication factor. */
void RCC_ConfigPll(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul) | {
uint32_t tmpregister = 0;
assert_param(IS_RCC_PLL_SRC(RCC_PLLSource));
assert_param(IS_RCC_PLL_MUL(RCC_PLLMul));
tmpregister = RCC->CFG;
tmpregister &= CFG_PLL_MASK;
tmpregister |= RCC_PLLSource | RCC_PLLMul;
RCC->CFG = tmpregister;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* USBH_SetCfg The command sets the configuration value to the connected device. */ | USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, uint16_t cfg_idx) | /* USBH_SetCfg The command sets the configuration value to the connected device. */
USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, uint16_t cfg_idx) | {
if (phost->RequestState == CMD_SEND)
{
phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_DEVICE
| USB_REQ_TYPE_STANDARD;
phost->Control.setup.b.bRequest = USB_REQ_SET_CONFIGURATION;
phost->Control.setup.b.wValue.w = cfg_idx;
phost->Control.setup.b.wIndex.w = 0U;
phost->Control.setup.b.wLength.w = 0U;
}
return USBH_CtlReq(phost, NULL, 0U);
} | ua1arn/hftrx | C++ | null | 69 |
/* Same as above, but for a sub-range of the mapping. */ | static void swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr, unsigned long offset, size_t size, int dir, int target) | /* Same as above, but for a sub-range of the mapping. */
static void swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr, unsigned long offset, size_t size, int dir, int target) | {
swiotlb_sync_single(hwdev, dev_addr + offset, size, dir, target);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate space for the new device path, then NULL is returned. The memory is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */ | EFI_DEVICE_PATH_PROTOCOL* EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength) | /* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate space for the new device path, then NULL is returned. The memory is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */
EFI_DEVICE_PATH_PROTOCOL* EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength) | {
return mDevicePathLibDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* must be called with the lock held and interrupts disabled. */ | static int enable_promisc(struct xircom_private *card) | /* must be called with the lock held and interrupts disabled. */
static int enable_promisc(struct xircom_private *card) | {
unsigned int val;
enter("enable_promisc");
val = inl(card->io_port + CSR6);
val = val | (1 << 6);
outl(val, card->io_port + CSR6);
leave("enable_promisc");
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns -EEXISTS if an ematch of the same kind has already registered. */ | int tcf_em_register(struct tcf_ematch_ops *ops) | /* Returns -EEXISTS if an ematch of the same kind has already registered. */
int tcf_em_register(struct tcf_ematch_ops *ops) | {
int err = -EEXIST;
struct tcf_ematch_ops *e;
if (ops->match == NULL)
return -EINVAL;
write_lock(&ematch_mod_lock);
list_for_each_entry(e, &ematch_ops, link)
if (ops->kind == e->kind)
goto errout;
list_add_tail(&ops->link, &ematch_ops);
err = 0;
errout:
write_unlock(&ematch_mod_lock);
return err;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function provides accurate delay (in microseconds) based on variable incremented. */ | __weak void ald_delay_1us(__IO uint32_t delay) | /* This function provides accurate delay (in microseconds) based on variable incremented. */
__weak void ald_delay_1us(__IO uint32_t delay) | {
uint32_t start, now, delta, us_tick;
start = CORET->MTIME;
us_tick = ald_cmu_get_sys_clock() / 1000000UL;
do
{
now = CORET->MTIME;
delta = now - start;
}
while (delta < (us_tick * delay));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* create a chip instance and set its names. */ | int usX2Y_audio_create(struct snd_card *card) | /* create a chip instance and set its names. */
int usX2Y_audio_create(struct snd_card *card) | {
snd_usX2Y_pcm_private_free(pcm);
return err;
}
usX2Y(card)->pcm_devs++;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Gets the device path information of the underlying ATA host controller. */ | EFI_STATUS EFIAPI AhciAtaPassThruGetDevicePath(IN EDKII_PEI_ATA_PASS_THRU_PPI *This, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath) | /* Gets the device path information of the underlying ATA host controller. */
EFI_STATUS EFIAPI AhciAtaPassThruGetDevicePath(IN EDKII_PEI_ATA_PASS_THRU_PPI *This, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath) | {
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_PASS_THRU (This);
*DevicePathLength = Private->DevicePathLength;
*DevicePath = AllocateCopyPool (Private->DevicePathLength, Private->DevicePath);
if (*DevicePath == NULL) {
*DevicePathLength = 0;
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Output: void, will modify proto_tree if not null. */ | static void dissect_snp_instance_identifier_clv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int id_length _U_, int length) | /* Output: void, will modify proto_tree if not null. */
static void dissect_snp_instance_identifier_clv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int id_length _U_, int length) | {
isis_dissect_instance_identifier_clv(tree, pinfo, tvb, &ei_isis_csnp_short_packet, hf_isis_csnp_instance_identifier, hf_isis_csnp_supported_itid, offset, length);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* asymmetric_key_id_same - Return true if two asymmetric keys IDs are the same. @kid_1, @kid_2: The key IDs to compare */ | bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2) | /* asymmetric_key_id_same - Return true if two asymmetric keys IDs are the same. @kid_1, @kid_2: The key IDs to compare */
bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1, const struct asymmetric_key_id *kid2) | {
if (!kid1 || !kid2)
return false;
if (kid1->len != kid2->len)
return false;
return memcmp(kid1->data, kid2->data, kid1->len) == 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details. */ | EFI_STATUS SdMmcHcStopClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot) | /* Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details. */
EFI_STATUS SdMmcHcStopClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot) | {
EFI_STATUS Status;
UINT32 PresentState;
UINT16 ClockCtrl;
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
SD_MMC_HC_PRESENT_STATE,
sizeof (PresentState),
BIT0 | BIT1,
0,
SD_MMC_HC_GENERIC_TIMEOUT
);
if (EFI_ERROR (Status)) {
return Status;
}
ClockCtrl = (UINT16) ~BIT2;
Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Copy current Menu list to the new menu list. */ | VOID UiCopyMenuList(OUT LIST_ENTRY *NewMenuListHead, IN LIST_ENTRY *CurrentMenuListHead) | /* Copy current Menu list to the new menu list. */
VOID UiCopyMenuList(OUT LIST_ENTRY *NewMenuListHead, IN LIST_ENTRY *CurrentMenuListHead) | {
LIST_ENTRY *Link;
FORM_ENTRY_INFO *MenuList;
FORM_ENTRY_INFO *NewMenuEntry;
UiFreeMenuList (NewMenuListHead);
Link = GetFirstNode (CurrentMenuListHead);
while (!IsNull (CurrentMenuListHead, Link)) {
MenuList = FORM_ENTRY_INFO_FROM_LINK (Link);
Link = GetNextNode (CurrentMenuListHead, Link);
NewMenuEntry = AllocateZeroPool (sizeof (FORM_ENTRY_INFO));
ASSERT (NewMenuEntry != NULL);
NewMenuEntry->Signature = FORM_ENTRY_INFO_SIGNATURE;
NewMenuEntry->HiiHandle = MenuList->HiiHandle;
CopyMem (&NewMenuEntry->FormSetGuid, &MenuList->FormSetGuid, sizeof (EFI_GUID));
NewMenuEntry->FormId = MenuList->FormId;
NewMenuEntry->QuestionId = MenuList->QuestionId;
InsertTailList (NewMenuListHead, &NewMenuEntry->Link);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.