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 |
|---|---|---|---|---|---|---|---|
/* Enables or disables the receiver Time Out feature. */ | void USART_ReceiverTimeOutCmd(USART_TypeDef *USARTx, FunctionalState NewState) | /* Enables or disables the receiver Time Out feature. */
void USART_ReceiverTimeOutCmd(USART_TypeDef *USARTx, FunctionalState NewState) | {
assert_param(IS_USART_123_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
USARTx->CR2 |= USART_CR2_RTOEN;
}
else
{
USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_RTOEN);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* (As all part of the Linux kernel, this file is GPL) */ | static struct iw_spy_data* get_spydata(struct net_device *dev) | /* (As all part of the Linux kernel, this file is GPL) */
static struct iw_spy_data* get_spydata(struct net_device *dev) | {
if (dev->wireless_data)
return dev->wireless_data->spy_data;
return NULL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Description: Removes the CIPSO option from a socket, if present. */ | void cipso_v4_sock_delattr(struct sock *sk) | /* Description: Removes the CIPSO option from a socket, if present. */
void cipso_v4_sock_delattr(struct sock *sk) | {
int hdr_delta;
struct ip_options *opt;
struct inet_sock *sk_inet;
sk_inet = inet_sk(sk);
opt = sk_inet->opt;
if (opt == NULL || opt->cipso == 0)
return;
hdr_delta = cipso_v4_delopt(&sk_inet->opt);
if (sk_inet->is_icsk && hdr_delta > 0) {
struct inet_connection_sock *sk_conn = inet_csk(sk);
sk_conn->icsk_ext_hdr_len -= hdr_delta;
sk_conn->icsk_sync_mss(sk, sk_conn->icsk_pmtu_cookie);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* For a dissector table, print on the stream described by output, its short name (which is what's used in the "-d" option) and its descriptive name. */ | static void display_dissector_table_names(const char *table_name, const char *ui_name, gpointer output) | /* For a dissector table, print on the stream described by output, its short name (which is what's used in the "-d" option) and its descriptive name. */
static void display_dissector_table_names(const char *table_name, const char *ui_name, gpointer output) | {
if ((prev_display_dissector_name == NULL) ||
(strcmp(prev_display_dissector_name, table_name) != 0)) {
fprintf((FILE *)output, "\t%s (%s)\n", table_name, ui_name);
prev_display_dissector_name = table_name;
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function returns the local private key data which was currently set in the specified TLS object. */ | EFI_STATUS EFIAPI TlsGetHostPrivateKey(IN VOID *Tls, OUT VOID *Data, IN OUT UINTN *DataSize) | /* This function returns the local private key data which was currently set in the specified TLS object. */
EFI_STATUS EFIAPI TlsGetHostPrivateKey(IN VOID *Tls, OUT VOID *Data, IN OUT UINTN *DataSize) | {
CALL_CRYPTO_SERVICE (TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Gets the cuurent sd card data transfer status. */ | SDTransferState SD_GetStatus(void) | /* Gets the cuurent sd card data transfer status. */
SDTransferState SD_GetStatus(void) | {
SDCardState cardstate = SD_GetState();
if (cardstate == SD_CARD_TRANSFER) {
return SD_TRANSFER_OK;
}
else if (cardstate == SD_CARD_ERROR) {
return SD_TRANSFER_ERROR;
}
else {
return SD_TRANSFER_BUSY;
}
} | opentx/opentx | C++ | GNU General Public License v2.0 | 2,025 |
/* This function reads from the SPI interface using the configuration parameter within the sc structure. The opcode parameter is used to specify which control register to access. This controller has the following seven control register commands */ | void enc28j60_lwip_read_spi(uint32_t spiHandle, uint8_t opcode, uint8_t address, uint8_t *byteData, uint32_t numBytes, uint8_t offset) | /* This function reads from the SPI interface using the configuration parameter within the sc structure. The opcode parameter is used to specify which control register to access. This controller has the following seven control register commands */
void enc28j60_lwip_read_spi(uint32_t spiHandle, uint8_t opcode, uint8_t address, uint8_t *byteData, uint32_t numBytes, uint8_t offset) | {
uint8_t opcodeArg;
opcodeArg = ENC28J60_SPI_OPCODE_ARGUMENT(opcode, address);
SPI_WRITE_READ_SETTINGS wrc{false, offset, false, 0, ENC28J60_CS, ENC28J60_CS_ACTIVE};
nanoSPI_Write_Read(spiHandle, wrc, &opcodeArg, 1, byteData, numBytes);
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* Get a GUID identifying the RNG algorithm implementation. */ | EFI_STATUS EFIAPI GetRngGuid(GUID *RngGuid) | /* Get a GUID identifying the RNG algorithm implementation. */
EFI_STATUS EFIAPI GetRngGuid(GUID *RngGuid) | {
GUID *RngLibGuid;
if (RngGuid == NULL) {
return EFI_INVALID_PARAMETER;
}
if (!mRndrSupported) {
return EFI_UNSUPPORTED;
}
RngLibGuid = PcdGetPtr (PcdCpuRngSupportedAlgorithm);
if (!IsZeroGuid (RngLibGuid)) {
CopyMem (RngGuid, RngLibGuid, sizeof (*RngGuid));
} else {
CopyMem (RngGuid, &gEfiRngAlgorithmArmRndr, sizeof (*RngGuid));
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable.
Initialize the system */ | void SystemInit(void) | /* Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable.
Initialize the system */
void SystemInit(void) | {
SystemCoreClock = __SYSTEM_CLOCK;
return;
} | memfault/zero-to-main | C++ | null | 200 |
/* FSM long counter status register. Long counter value is an unsigned integer value (16-bit format).. */ | int32_t lsm6dso_long_cnt_get(stmdev_ctx_t *ctx, uint16_t *val) | /* FSM long counter status register. Long counter value is an unsigned integer value (16-bit format).. */
int32_t lsm6dso_long_cnt_get(stmdev_ctx_t *ctx, uint16_t *val) | {
uint8_t buff[2];
int32_t ret;
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_FSM_LONG_COUNTER_L, buff, 2);
}
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
*val = buff[1];
*val = (*val * 256U) + buff[0];
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* A Buffer is allocated to store the raw AML absolute path. */ | STATIC EFI_STATUS EFIAPI AmlCreateMethodRefNode(IN CONST AML_OBJECT_NODE *ObjectNode, IN CONST CHAR8 *RawAbsolutePath, IN UINT32 RawAbsolutePathSize, OUT AML_NAMESPACE_REF_NODE **NameSpaceRefNodePtr) | /* A Buffer is allocated to store the raw AML absolute path. */
STATIC EFI_STATUS EFIAPI AmlCreateMethodRefNode(IN CONST AML_OBJECT_NODE *ObjectNode, IN CONST CHAR8 *RawAbsolutePath, IN UINT32 RawAbsolutePathSize, OUT AML_NAMESPACE_REF_NODE **NameSpaceRefNodePtr) | {
AML_NAMESPACE_REF_NODE *NameSpaceRefNode;
if (!AmlNodeHasAttribute (ObjectNode, AML_IN_NAMESPACE) ||
(RawAbsolutePath == NULL) ||
(RawAbsolutePathSize == 0) ||
(NameSpaceRefNodePtr == NULL))
{
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
NameSpaceRefNode = AllocateZeroPool (sizeof (AML_NAMESPACE_REF_NODE));
if (NameSpaceRefNode == NULL) {
ASSERT (0);
return EFI_OUT_OF_RESOURCES;
}
NameSpaceRefNode->RawAbsolutePathSize = RawAbsolutePathSize;
NameSpaceRefNode->RawAbsolutePath = AllocateCopyPool (
RawAbsolutePathSize,
RawAbsolutePath
);
if (NameSpaceRefNode->RawAbsolutePath == NULL) {
FreePool (NameSpaceRefNode);
ASSERT (0);
return EFI_OUT_OF_RESOURCES;
}
InitializeListHead (&NameSpaceRefNode->Link);
NameSpaceRefNode->NodeRef = ObjectNode;
*NameSpaceRefNodePtr = NameSpaceRefNode;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Create expression 't'. 't' must have its final result already in a register or upvalue. Upvalues can only be indexed by literal strings. Keys can be literal strings in the constant table or arbitrary values in registers. */ | void luaK_indexed(FuncState *fs, expdesc *t, expdesc *k) | /* Create expression 't'. 't' must have its final result already in a register or upvalue. Upvalues can only be indexed by literal strings. Keys can be literal strings in the constant table or arbitrary values in registers. */
void luaK_indexed(FuncState *fs, expdesc *t, expdesc *k) | {
t->u.ind.t = t->u.info;
t->u.ind.idx = k->u.info;
t->k = VINDEXUP;
}
else {
t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
if (isKstr(fs, k)) {
t->u.ind.idx = k->u.info;
t->k = VINDEXSTR;
}
else if (isCint(k)) {
t->u.ind.idx = cast_int(k->u.ival);
t->k = VINDEXI;
}
else {
t->u.ind.idx = luaK_exp2anyreg(fs, k);
t->k = VINDEXED;
}
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Fills each CRYP_KeyInitStruct member with its default value. */ | void CRYP_KeyStructInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct) | /* Fills each CRYP_KeyInitStruct member with its default value. */
void CRYP_KeyStructInit(CRYP_KeyInitTypeDef *CRYP_KeyInitStruct) | {
CRYP_KeyInitStruct->CRYP_Key0Left = 0;
CRYP_KeyInitStruct->CRYP_Key0Right = 0;
CRYP_KeyInitStruct->CRYP_Key1Left = 0;
CRYP_KeyInitStruct->CRYP_Key1Right = 0;
CRYP_KeyInitStruct->CRYP_Key2Left = 0;
CRYP_KeyInitStruct->CRYP_Key2Right = 0;
CRYP_KeyInitStruct->CRYP_Key3Left = 0;
CRYP_KeyInitStruct->CRYP_Key3Right = 0;
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Setup various clocks and wakeup sources in the SoC.
Configures the clocks and wakeup sources in the SoC. */ | void soc_power_init(void) | /* Setup various clocks and wakeup sources in the SoC.
Configures the clocks and wakeup sources in the SoC. */
void soc_power_init(void) | {
clock_active_init();
clock_sleep_init();
clock_deepsleep_init();
wakeup_src_init();
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* We are about to scan this zone at a certain priority level. If that priority level is smaller (ie: more urgent) than the previous priority, then note that priority level within the zone. This is done so that when the next process comes in to scan this zone, it will immediately start out at this priority level rather than having to build up its own scanning priority. Here, this priority affects only the reclaim-mapped threshold. */ | static void note_zone_scanning_priority(struct zone *zone, int priority) | /* We are about to scan this zone at a certain priority level. If that priority level is smaller (ie: more urgent) than the previous priority, then note that priority level within the zone. This is done so that when the next process comes in to scan this zone, it will immediately start out at this priority level rather than having to build up its own scanning priority. Here, this priority affects only the reclaim-mapped threshold. */
static void note_zone_scanning_priority(struct zone *zone, int priority) | {
if (priority < zone->prev_priority)
zone->prev_priority = priority;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Forces the TIMx output 1 waveform to active or inactive level. */ | void TIM_ForcedOC1Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction) | /* Forces the TIMx output 1 waveform to active or inactive level. */
void TIM_ForcedOC1Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction) | {
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_LIST4_PERIPH(TIMx));
assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1M);
tmpccmr1 |= TIM_ForcedAction;
TIMx->CCMR1 = tmpccmr1;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* if it cannot handle the case of removing a directory that is still in use by something else.. */ | void dentry_unhash(struct dentry *dentry) | /* if it cannot handle the case of removing a directory that is still in use by something else.. */
void dentry_unhash(struct dentry *dentry) | {
dget(dentry);
shrink_dcache_parent(dentry);
spin_lock(&dcache_lock);
spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) == 2)
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&dcache_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Add a value to the end of the plot.
Scales the input value to fit the plot dimensions and adds it to the end of the ring buffer. */ | bool wtk_plot_add_value(struct wtk_plot *plot, uint8_t value) | /* Add a value to the end of the plot.
Scales the input value to fit the plot dimensions and adds it to the end of the ring buffer. */
bool wtk_plot_add_value(struct wtk_plot *plot, uint8_t value) | {
uint8_t height;
uint8_t maximum;
struct win_area const *area;
Assert(plot);
Assert(value <= plot->maximum);
Assert(plot->buffer_start < plot->num_datapoints);
maximum = plot->maximum;
area = win_get_area(plot->container);
height = area->size.y - 2;
*(plot->plot_buffer + plot->buffer_start)
= height - wtk_rescale_value((value), maximum, height - 1);
plot->buffer_start++;
if (plot->buffer_start >= plot->num_datapoints) {
plot->buffer_start = 0;
}
return true;
} | memfault/zero-to-main | C++ | null | 200 |
/* Removes the specified SAS PORT. If the SAS PORT has an associated phys, unlink them from the port as well. */ | void sas_port_delete(struct sas_port *port) | /* Removes the specified SAS PORT. If the SAS PORT has an associated phys, unlink them from the port as well. */
void sas_port_delete(struct sas_port *port) | {
struct device *dev = &port->dev;
struct sas_phy *phy, *tmp_phy;
if (port->rphy) {
sas_rphy_delete(port->rphy);
port->rphy = NULL;
}
mutex_lock(&port->phy_list_mutex);
list_for_each_entry_safe(phy, tmp_phy, &port->phy_list,
port_siblings) {
sas_port_delete_link(port, phy);
list_del_init(&phy->port_siblings);
}
mutex_unlock(&port->phy_list_mutex);
if (port->is_backlink) {
struct device *parent = port->dev.parent;
sysfs_remove_link(&port->dev.kobj, dev_name(parent));
port->is_backlink = 0;
}
transport_remove_device(dev);
device_del(dev);
transport_destroy_device(dev);
put_device(dev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is to locate PCD_PPI PPI via PeiService. If fail to locate PCD_PPI, then ASSERT_EFI_ERROR(). */ | PCD_PPI* GetPcdPpiPointer(VOID) | /* This function is to locate PCD_PPI PPI via PeiService. If fail to locate PCD_PPI, then ASSERT_EFI_ERROR(). */
PCD_PPI* GetPcdPpiPointer(VOID) | {
EFI_STATUS Status;
PCD_PPI *PcdPpi;
Status = PeiServicesLocatePpi (&gPcdPpiGuid, 0, NULL, (VOID **)&PcdPpi);
ASSERT_EFI_ERROR (Status);
return PcdPpi;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Flush all requests from the request/pending queue of an AP device. */ | static void __ap_flush_queue(struct ap_device *ap_dev) | /* Flush all requests from the request/pending queue of an AP device. */
static void __ap_flush_queue(struct ap_device *ap_dev) | {
struct ap_message *ap_msg, *next;
list_for_each_entry_safe(ap_msg, next, &ap_dev->pendingq, list) {
list_del_init(&ap_msg->list);
ap_dev->pendingq_count--;
ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
}
list_for_each_entry_safe(ap_msg, next, &ap_dev->requestq, list) {
list_del_init(&ap_msg->list);
ap_dev->requestq_count--;
ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* sunxi_lcd_dsi_gen_short_read0p - generic read without param @screen_id: The index of screen. @paran: Para to be transfer. */ | s32 sunxi_lcd_dsi_gen_short_read0p(u32 screen_id, u8 *result) | /* sunxi_lcd_dsi_gen_short_read0p - generic read without param @screen_id: The index of screen. @paran: Para to be transfer. */
s32 sunxi_lcd_dsi_gen_short_read0p(u32 screen_id, u8 *result) | {
u8 tmp[2];
return sunxi_lcd_dsi_gen_short_read(screen_id, tmp, 0, result);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Writes a Generic Clock configuration to the hardware module.
Writes out a given configuration of a Generic Clock configuration to the hardware module. If the clock is currently running, it will be stopped. */ | void system_gclk_chan_set_config(const uint8_t channel, struct system_gclk_chan_config *const config) | /* Writes a Generic Clock configuration to the hardware module.
Writes out a given configuration of a Generic Clock configuration to the hardware module. If the clock is currently running, it will be stopped. */
void system_gclk_chan_set_config(const uint8_t channel, struct system_gclk_chan_config *const config) | {
Assert(config);
system_gclk_chan_disable(channel);
GCLK->PCHCTRL[channel].reg = GCLK_PCHCTRL_GEN(config->source_generator);
} | memfault/zero-to-main | C++ | null | 200 |
/* This is a temperary function that will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime. */ | VOID AcquireLockOnlyAtBootTime(IN EFI_LOCK *Lock) | /* This is a temperary function that will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime. */
VOID AcquireLockOnlyAtBootTime(IN EFI_LOCK *Lock) | {
if (!EfiAtRuntime ()) {
EfiAcquireLock (Lock);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */ | static void format_price_correction_reason(char *buf, guint32 value) | /* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
static void format_price_correction_reason(char *buf, guint32 value) | {
g_snprintf(buf, ITEM_LABEL_LENGTH,
"%s (%c)",
val_to_str_const(value,
ouch_price_correction_reason_val,
"Unknown"),
value);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This helper moves the initial part of @head, up to and including @entry, from @head to @list. You should pass on @entry an element you know is on @head. @list should be an empty list or a list you do not care about losing its data. */ | static void list_cut_position(struct list_head *list, struct list_head *head, struct list_head *entry) | /* This helper moves the initial part of @head, up to and including @entry, from @head to @list. You should pass on @entry an element you know is on @head. @list should be an empty list or a list you do not care about losing its data. */
static void list_cut_position(struct list_head *list, struct list_head *head, struct list_head *entry) | {
if (list_empty(head))
return;
if (list_is_singular(head) && (head->next != entry && head != entry))
return;
if (entry == head)
INIT_LIST_HEAD(list);
else
__list_cut_position(list, head, entry);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Free the resource used by this USB device. */ | VOID UsbFreeDevice(IN USB_DEVICE *Device) | /* Free the resource used by this USB device. */
VOID UsbFreeDevice(IN USB_DEVICE *Device) | {
if (Device->DevDesc != NULL) {
UsbFreeDevDesc (Device->DevDesc);
}
gBS->FreePool (Device);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function will control network interface device DHCP capability enable or disable. */ | int netdev_dhcpd_enabled(struct netdev *netdev, bool is_enabled) | /* This function will control network interface device DHCP capability enable or disable. */
int netdev_dhcpd_enabled(struct netdev *netdev, bool is_enabled) | {
ASSERT(netdev);
if (!netdev->ops || !netdev->ops->set_dhcpd)
{
LOGE(TAG, "The network interface device(%s) not support to set DHCPD status.", netdev->name);
return -1;
}
if (netdev_is_dhcpd_enabled(netdev) == is_enabled)
{
return 0;
}
if (is_enabled)
{
netdev->flags |= NETDEV_FLAG_DHCPD;
}
else
{
netdev->flags &= ~NETDEV_FLAG_DHCPD;
}
return netdev->ops->set_dhcpd(netdev, is_enabled);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* This routine can be used from both task and interrupt context. */ | atomic_val_t rhino_atomic_dec(atomic_t *target) | /* This routine can be used from both task and interrupt context. */
atomic_val_t rhino_atomic_dec(atomic_t *target) | {
CPSR_ALLOC();
atomic_val_t old_value;
RHINO_CPU_INTRPT_DISABLE();
old_value = *target;
(*target)--;
RHINO_CPU_INTRPT_ENABLE();
return old_value;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Writes the current value of MM2. This function is only available on IA32 and x64. */ | VOID EFIAPI AsmWriteMm2(IN UINT64 Value) | /* Writes the current value of MM2. This function is only available on IA32 and x64. */
VOID EFIAPI AsmWriteMm2(IN UINT64 Value) | {
_asm {
movq mm2, qword ptr [Value]
emms
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set Endpoint Status Parameters: EPNum: Endpoint Number EPNum.0..3: Address EPNum.7: Dir stat: New Status Return Value: None */ | void EP_Status(U32 EPNum, U32 stat) | /* Set Endpoint Status Parameters: EPNum: Endpoint Number EPNum.0..3: Address EPNum.7: Dir stat: New Status Return Value: None */
void EP_Status(U32 EPNum, U32 stat) | {
U32 num, val;
num = EPNum & 0x0F;
val = EPxREG(num);
if (EPNum & 0x80) {
EPxREG(num) = EP_VAL_UNCHANGED(val) | ((val ^ stat) & EP_STAT_TX);
} else {
EPxREG(num) = EP_VAL_UNCHANGED(val) | ((val ^ stat) & EP_STAT_RX);
}
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Programs a double word (64-bit) at a specified address. */ | FMC_STATUS_T FMC_ProgramDoubleWord(uint32_t address, uint64_t data) | /* Programs a double word (64-bit) at a specified address. */
FMC_STATUS_T FMC_ProgramDoubleWord(uint32_t address, uint64_t data) | {
FMC_STATUS_T status = FMC_COMPLETE;
status = FMC_WaitForLastOperation();
if (status == FMC_COMPLETE)
{
FMC->CTRL &= 0xFFFFFCFF;
FMC->CTRL |= FMC_PSIZE_DOUBLE_WORD;
FMC->CTRL |= FMC_CTRL_PG;
*(__IO uint64_t *)address = data;
status = FMC_WaitForLastOperation();
FMC->CTRL &= (~FMC_CTRL_PG);
}
return status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* returns the index of a 'key' for table traversals. First goes all elements in the array part, then elements in the hash part. The beginning of a traversal is signaled by 0. */ | static unsigned int findindex(lua_State *L, Table *t, StkId key) | /* returns the index of a 'key' for table traversals. First goes all elements in the array part, then elements in the hash part. The beginning of a traversal is signaled by 0. */
static unsigned int findindex(lua_State *L, Table *t, StkId key) | {
int nx;
Node *n = mainposition(t, key);
for (;;) {
if (luaV_rawequalobj(gkey(n), key) ||
(ttisdeadkey(gkey(n)) && iscollectable(key) &&
deadvalue(gkey(n)) == gcvalue(key))) {
i = cast_int(n - gnode(t, 0));
return (i + 1) + t->sizearray;
}
nx = gnext(n);
if (nx == 0)
luaG_runerror(L, "invalid key to 'next'");
else n += nx;
}
}
} | nodemcu/nodemcu-firmware | C++ | MIT License | 7,566 |
/* configure RCU
, 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 rcu_config(void) | /* configure RCU
, 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 rcu_config(void) | {
rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_DAC);
rcu_periph_clock_enable(RCU_CFGCMP);
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* 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 Vector18_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 Vector18_handler(void) | {
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (18 * 2))
JMP 0,X
}
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Map legacy memory space for this device back to userspace using a machine vector to get the base address. */ | int pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma, enum pci_mmap_state mmap_state) | /* Map legacy memory space for this device back to userspace using a machine vector to get the base address. */
int pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma, enum pci_mmap_state mmap_state) | {
unsigned long size = vma->vm_end - vma->vm_start;
pgprot_t prot;
char *addr;
if (mmap_state != pci_mmap_mem)
return -ENOSYS;
if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
return -EINVAL;
prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size,
vma->vm_page_prot);
addr = pci_get_legacy_mem(bus);
if (IS_ERR(addr))
return PTR_ERR(addr);
vma->vm_pgoff += (unsigned long)addr >> PAGE_SHIFT;
vma->vm_page_prot = prot;
if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
size, vma->vm_page_prot))
return -EAGAIN;
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Ok. This isn't fun, but this is the EASY case. */ | static unsigned long csum_partial_cfu_aligned(const unsigned long __user *src, unsigned long *dst, long len, unsigned long checksum, int *errp) | /* Ok. This isn't fun, but this is the EASY case. */
static unsigned long csum_partial_cfu_aligned(const unsigned long __user *src, unsigned long *dst, long len, unsigned long checksum, int *errp) | {
unsigned long carry = 0;
int err = 0;
while (len >= 0) {
unsigned long word;
err |= __get_user(word, src);
checksum += carry;
src++;
checksum += word;
len -= 8;
carry = checksum < word;
*dst = word;
dst++;
}
len += 8;
checksum += carry;
if (len) {
unsigned long word, tmp;
err |= __get_user(word, src);
tmp = *dst;
mskql(word, len, word);
checksum += word;
mskqh(tmp, len, tmp);
carry = checksum < word;
*dst = word | tmp;
checksum += carry;
}
if (err) *errp = err;
return checksum;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* De-Initialize the SX8651 communication bus from MCU to SX8651 : ie I2C channel initialization (if required). */ | int32_t SX8651_DeInit(SX8651_Object_t *pObj) | /* De-Initialize the SX8651 communication bus from MCU to SX8651 : ie I2C channel initialization (if required). */
int32_t SX8651_DeInit(SX8651_Object_t *pObj) | {
int32_t ret = SX8651_OK;
if (pObj->IsInitialized == 1U)
{
pObj->IsInitialized = 0;
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Triggers a pending transmit for the specified find-included-services proc. */ | static int ble_gattc_find_inc_svcs_tx(struct ble_gattc_proc *proc) | /* Triggers a pending transmit for the specified find-included-services proc. */
static int ble_gattc_find_inc_svcs_tx(struct ble_gattc_proc *proc) | {
ble_uuid16_t uuid = BLE_UUID16_INIT(BLE_ATT_UUID_INCLUDE);
int rc;
ble_gattc_dbg_assert_proc_not_inserted(proc);
if (proc->find_inc_svcs.cur_start == 0) {
rc = ble_att_clt_tx_read_type(proc->conn_handle,
proc->find_inc_svcs.prev_handle + 1,
proc->find_inc_svcs.end_handle, &uuid.u);
if (rc != 0) {
return rc;
}
} else {
rc = ble_att_clt_tx_read(proc->conn_handle,
proc->find_inc_svcs.cur_start);
if (rc != 0) {
return rc;
}
}
return 0;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* This function is wrapper function to validate the buffer. */ | BOOLEAN EFIAPI VarCheckPolicyIsBufferOutsideValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length) | /* This function is wrapper function to validate the buffer. */
BOOLEAN EFIAPI VarCheckPolicyIsBufferOutsideValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length) | {
return SmmIsBufferOutsideSmmValid (Buffer, Length);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Note: if the focus is on the border of one of the two circles (in which case the circles are tangent in the focus point), it is not considered as contained in the circle, hence this function returns FALSE. */ | cairo_bool_t _cairo_radial_pattern_focus_is_inside(const cairo_radial_pattern_t *radial) | /* Note: if the focus is on the border of one of the two circles (in which case the circles are tangent in the focus point), it is not considered as contained in the circle, hence this function returns FALSE. */
cairo_bool_t _cairo_radial_pattern_focus_is_inside(const cairo_radial_pattern_t *radial) | {
double cx, cy, cr, dx, dy, dr;
cx = radial->cd1.center.x;
cy = radial->cd1.center.y;
cr = radial->cd1.radius;
dx = radial->cd2.center.x - cx;
dy = radial->cd2.center.y - cy;
dr = radial->cd2.radius - cr;
return dx*dx + dy*dy < dr*dr;
} | xboot/xboot | C++ | MIT License | 779 |
/* Get the file info from the open file of the IFile into Buffer. */ | EFI_STATUS FatIFileReadDir(IN FAT_IFILE *IFile, IN OUT UINTN *BufferSize, OUT VOID *Buffer) | /* Get the file info from the open file of the IFile into Buffer. */
EFI_STATUS FatIFileReadDir(IN FAT_IFILE *IFile, IN OUT UINTN *BufferSize, OUT VOID *Buffer) | {
EFI_STATUS Status;
FAT_OFILE *OFile;
FAT_ODIR *ODir;
FAT_DIRENT *DirEnt;
UINT32 CurrentPos;
OFile = IFile->OFile;
ODir = OFile->ODir;
CurrentPos = ((UINT32)IFile->Position) / sizeof (FAT_DIRECTORY_ENTRY);
if (CurrentPos < ODir->CurrentPos) {
FatResetODirCursor (OFile);
}
do {
Status = FatGetNextDirEnt (OFile, &DirEnt);
if (EFI_ERROR (Status) || (DirEnt == NULL)) {
*BufferSize = 0;
goto Done;
}
} while (ODir->CurrentPos <= CurrentPos);
Status = FatGetDirEntInfo (OFile->Volume, DirEnt, BufferSize, Buffer);
Done:
if (!EFI_ERROR (Status)) {
CurrentPos = ODir->CurrentPos;
IFile->Position = CurrentPos * sizeof (FAT_DIRECTORY_ENTRY);
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Service incoming interrupts from the WLAN device. We can't sleep here, so don't try to talk on the SPI bus, just wake up the SPI thread. */ | static irqreturn_t if_spi_host_interrupt(int irq, void *dev_id) | /* Service incoming interrupts from the WLAN device. We can't sleep here, so don't try to talk on the SPI bus, just wake up the SPI thread. */
static irqreturn_t if_spi_host_interrupt(int irq, void *dev_id) | {
struct if_spi_card *card = dev_id;
up(&card->spi_ready);
return IRQ_HANDLED;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a UINTN boundary, then ASSERT(). If Length is not aligned on a UINTN boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ | VOID* EFIAPI ScanMemN(IN CONST VOID *Buffer, IN UINTN Length, IN UINTN Value) | /* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a UINTN boundary, then ASSERT(). If Length is not aligned on a UINTN boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI ScanMemN(IN CONST VOID *Buffer, IN UINTN Length, IN UINTN Value) | {
if (sizeof (UINTN) == sizeof (UINT64)) {
return ScanMem64 (Buffer, Length, (UINT64)Value);
} else {
return ScanMem32 (Buffer, Length, (UINT32)Value);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* We do this by first locating the chunk in which the descriptor resides, and then scanning forward in the chunk and the list for the next used descriptor. */ | xfs_log_item_desc_t* xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp) | /* We do this by first locating the chunk in which the descriptor resides, and then scanning forward in the chunk and the list for the next used descriptor. */
xfs_log_item_desc_t* xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp) | {
xfs_log_item_chunk_t *licp;
int i;
licp = xfs_lic_desc_to_chunk(lidp);
for (i = (int)xfs_lic_desc_to_slot(lidp) + 1; i < licp->lic_unused; i++) {
if (xfs_lic_isfree(licp, i)) {
continue;
}
return xfs_lic_slot(licp, i);
}
if (licp->lic_next == NULL) {
return NULL;
}
licp = licp->lic_next;
ASSERT(!xfs_lic_are_all_free(licp));
for (i = 0; i < licp->lic_unused; i++) {
if (xfs_lic_isfree(licp, i)) {
continue;
}
return xfs_lic_slot(licp, i);
}
ASSERT(0);
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* we do not have to muck with descriptors here, that is done in switch_mm() as needed. */ | int init_new_context(struct task_struct *tsk, struct mm_struct *mm) | /* we do not have to muck with descriptors here, that is done in switch_mm() as needed. */
int init_new_context(struct task_struct *tsk, struct mm_struct *mm) | {
struct mm_struct *old_mm;
int retval = 0;
mutex_init(&mm->context.lock);
mm->context.size = 0;
old_mm = current->mm;
if (old_mm && old_mm->context.size > 0) {
mutex_lock(&old_mm->context.lock);
retval = copy_ldt(&mm->context, &old_mm->context);
mutex_unlock(&old_mm->context.lock);
}
return retval;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Check if an address is valid for the flash device. */ | bool NORFLASH_AddressValid(uint32_t addr) | /* Check if an address is valid for the flash device. */
bool NORFLASH_AddressValid(uint32_t addr) | {
if (!flashInitialized)
{
if (flashInterrogate() != NORFLASH_STATUS_OK)
return false;
}
if ((addr >= flashInfo.baseAddress) &&
(addr < (flashInfo.baseAddress + flashInfo.deviceSize)))
return true;
return false;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* sd_ref_mutex must be held entering this routine. Because it is called on last put, you should always use the scsi_disk_get() scsi_disk_put() helpers which manipulate the semaphore directly and never do a direct put_device. */ | static void scsi_disk_release(struct device *cdev) | /* sd_ref_mutex must be held entering this routine. Because it is called on last put, you should always use the scsi_disk_get() scsi_disk_put() helpers which manipulate the semaphore directly and never do a direct put_device. */
static void scsi_disk_release(struct device *cdev) | {
struct scsi_disk *sdkp = to_scsi_disk(dev);
struct gendisk *disk = sdkp->disk;
spin_lock(&sd_index_lock);
ida_remove(&sd_index_ida, sdkp->index);
spin_unlock(&sd_index_lock);
disk->private_data = NULL;
put_disk(disk);
put_device(&sdkp->device->sdev_gendev);
kfree(sdkp);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Selects gyroscope OIS chain digital high-pass filter cutoff.. */ | int32_t lsm6dso_aux_gy_hp_bandwidth_set(lsm6dso_ctx_t *ctx, lsm6dso_hpm_ois_t val) | /* Selects gyroscope OIS chain digital high-pass filter cutoff.. */
int32_t lsm6dso_aux_gy_hp_bandwidth_set(lsm6dso_ctx_t *ctx, lsm6dso_hpm_ois_t val) | {
lsm6dso_ctrl2_ois_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1);
if (ret == 0) {
reg.hpm_ois = (uint8_t)val & 0x03U;
reg.hp_en_ois = ((uint8_t)val & 0x10U) >> 4;
ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL2_OIS, (uint8_t*)®, 1);
}
return ret;
} | alexander-g-dean/ESF | C++ | null | 41 |
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */ | UINTN EFIAPI PciWriteBuffer(IN UINTN StartAddress, IN UINTN Size, IN VOID *Buffer) | /* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */
UINTN EFIAPI PciWriteBuffer(IN UINTN StartAddress, IN UINTN Size, IN VOID *Buffer) | {
return mRunningOnQ35 ?
PciExpressWriteBuffer (StartAddress, Size, Buffer) :
PciCf8WriteBuffer (StartAddress, Size, Buffer);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enables or disables the TIMx peripheral Preload register on CCR3. */ | void TIM_OC3PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload) | /* Enables or disables the TIMx peripheral Preload register on CCR3. */
void TIM_OC3PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload) | {
uint16_t tmpccmr2 = 0;
assert_param(IS_TIM_123458_PERIPH(TIMx));
assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
tmpccmr2 = TIMx->CCMR2;
tmpccmr2 &= CCMR_OC13PE_Reset;
tmpccmr2 |= TIM_OCPreload;
TIMx->CCMR2 = tmpccmr2;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */ | status_t HAL_CODEC_WM8960_SetMute(void *handle, uint32_t playChannel, bool isMute) | /* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_WM8960_SetMute(void *handle, uint32_t playChannel, bool isMute) | {
assert(handle != NULL);
status_t retVal = kStatus_Success;
if ((playChannel & kWM8960_HeadphoneLeft) || (playChannel & kWM8960_HeadphoneRight))
{
retVal = WM8960_SetMute((wm8960_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)),
kWM8960_ModuleHP, isMute);
}
if ((playChannel & kWM8960_SpeakerLeft) || (playChannel & kWM8960_SpeakerRight))
{
retVal = WM8960_SetMute((wm8960_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)),
kWM8960_ModuleSpeaker, isMute);
}
return retVal;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Returns: TRUE if @drive supports removable media, FALSE otherwise. */ | gboolean g_drive_is_media_removable(GDrive *drive) | /* Returns: TRUE if @drive supports removable media, FALSE otherwise. */
gboolean g_drive_is_media_removable(GDrive *drive) | {
GDriveIface *iface;
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
iface = G_DRIVE_GET_IFACE (drive);
return (* iface->is_media_removable) (drive);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Gets the states of the DTR and RTS modem control signals. */ | uint32_t UARTModemControlGet(uint32_t ui32Base) | /* Gets the states of the DTR and RTS modem control signals. */
uint32_t UARTModemControlGet(uint32_t ui32Base) | {
ASSERT(ui32Base == UART1_BASE);
return (HWREG(ui32Base + UART_O_CTL) & (UART_OUTPUT_RTS | UART_OUTPUT_DTR));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Reads the 128-bit unique chip ID via an IAP call. */ | err_t iapReadUID(uint32_t uid[]) | /* Reads the 128-bit unique chip ID via an IAP call. */
err_t iapReadUID(uint32_t uid[]) | {
unsigned int command[5] = {58};
unsigned int response[5] = { 0 };
__disable_irq();
iap_entry(command, response);
__enable_irq();
memcpy(uid, &response[1], 16);
return ERROR_NONE;
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* Initializes the OPAMP peripheral according to the specified parameters in OPAMP_InitStruct. */ | void OPAMP_Init(uint32_t OPAMP_Selection, OPAMP_InitTypeDef *OPAMP_InitStruct) | /* Initializes the OPAMP peripheral according to the specified parameters in OPAMP_InitStruct. */
void OPAMP_Init(uint32_t OPAMP_Selection, OPAMP_InitTypeDef *OPAMP_InitStruct) | {
uint32_t tmpreg = 0;
assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
assert_param(IS_OPAMP_INVERTING_INPUT(OPAMP_InitStruct->OPAMP_InvertingInput));
assert_param(IS_OPAMP_NONINVERTING_INPUT(OPAMP_InitStruct->OPAMP_NonInvertingInput));
tmpreg = *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection);
tmpreg &= (uint32_t) (OPAMP_CSR_DEFAULT_MASK);
tmpreg |= (uint32_t)(OPAMP_InitStruct->OPAMP_InvertingInput | OPAMP_InitStruct->OPAMP_NonInvertingInput);
*(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = tmpreg;
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Reads and returns the current value of the EFLAGS register. 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 AsmReadEflags(VOID) | /* Reads and returns the current value of the EFLAGS register. 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 AsmReadEflags(VOID) | {
UINTN Eflags;
__asm__ __volatile__ (
"pushfq \n\t"
"pop %0 "
: "=r" (Eflags)
);
return Eflags;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Function gets the file information from an open file descriptor, and stores it in a buffer allocated from pool. */ | VOID* LibFileInfo(IN EFI_FILE_HANDLE FHand, IN EFI_GUID *InfoType) | /* Function gets the file information from an open file descriptor, and stores it in a buffer allocated from pool. */
VOID* LibFileInfo(IN EFI_FILE_HANDLE FHand, IN EFI_GUID *InfoType) | {
EFI_STATUS Status;
EFI_FILE_INFO *Buffer;
UINTN BufferSize;
Buffer = NULL;
BufferSize = 0;
Status = FHand->GetInfo (
FHand,
InfoType,
&BufferSize,
Buffer
);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocatePool (BufferSize);
ASSERT (Buffer != NULL);
}
Status = FHand->GetInfo (
FHand,
InfoType,
&BufferSize,
Buffer
);
return Buffer;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Disconnect the driver specified by ImageHandle from all the devices in the handle database. Uninstall all the protocols installed in the driver entry point. */ | EFI_STATUS EFIAPI I2cUnload(IN EFI_HANDLE ImageHandle) | /* Disconnect the driver specified by ImageHandle from all the devices in the handle database. Uninstall all the protocols installed in the driver entry point. */
EFI_STATUS EFIAPI I2cUnload(IN EFI_HANDLE ImageHandle) | {
EFI_STATUS Status;
Status = I2cBusUnload (ImageHandle);
if ( !EFI_ERROR (Status)) {
Status = I2cHostUnload (ImageHandle);
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Return true iff value at stack index 'a' is less than the value at index 'b' (according to the order of the sort). */ | static int sort_comp(lua_State *L, int a, int b) | /* Return true iff value at stack index 'a' is less than the value at index 'b' (according to the order of the sort). */
static int sort_comp(lua_State *L, int a, int b) | {
int res;
lua_pushvalue(L, 2);
lua_pushvalue(L, a-1);
lua_pushvalue(L, b-2);
lua_call(L, 2, 1);
res = lua_toboolean(L, -1);
lua_pop(L, 1);
return res;
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Given a source file, open the file and parse it */ | STATIC STATUS ProcessIncludeFile(SOURCE_FILE *SourceFile, SOURCE_FILE *ParentSourceFile) | /* Given a source file, open the file and parse it */
STATIC STATUS ProcessIncludeFile(SOURCE_FILE *SourceFile, SOURCE_FILE *ParentSourceFile) | {
STATIC UINTN NestDepth = 0;
CHAR8 FoundFileName[MAX_PATH];
STATUS Status;
Status = STATUS_SUCCESS;
NestDepth++;
if (mGlobals.VerboseFile) {
fprintf (stdout, "%*cProcessing file '%s'\n", (int)NestDepth * 2, ' ', SourceFile->FileName);
fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile->FileName);
}
if (NestDepth > MAX_NEST_DEPTH) {
Error (NULL, 0, 3001, "Not Supported", "%s exceeds max nesting depth (%u)", SourceFile->FileName, (unsigned) NestDepth);
Status = STATUS_ERROR;
goto Finish;
}
strcpy (FoundFileName, SourceFile->FileName);
if ((SourceFile->Fptr = fopen (LongFilePath (FoundFileName), "rb")) == NULL) {
return STATUS_ERROR;
}
ProcessFile (SourceFile);
Finish:
if (SourceFile->Fptr != NULL) {
fclose (SourceFile->Fptr);
SourceFile->Fptr = NULL;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* sunxi_lcd_power_disable - disable the power of panel. @screen_id: The index of screen. @pwr_id: The index of power */ | void sunxi_lcd_power_disable(u32 screen_id, u32 pwr_id) | /* sunxi_lcd_power_disable - disable the power of panel. @screen_id: The index of screen. @pwr_id: The index of power */
void sunxi_lcd_power_disable(u32 screen_id, u32 pwr_id) | {
if (g_lcd_drv.src_ops.sunxi_lcd_power_disable)
g_lcd_drv.src_ops.sunxi_lcd_power_disable(screen_id, pwr_id);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns: The fileset header structure on success, else Zero. */ | static struct vxfs_fsh* vxfs_getfsh(struct inode *ip, int which) | /* Returns: The fileset header structure on success, else Zero. */
static struct vxfs_fsh* vxfs_getfsh(struct inode *ip, int which) | {
struct buffer_head *bp;
bp = vxfs_bread(ip, which);
if (bp) {
struct vxfs_fsh *fhp;
if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL)))
goto out;
memcpy(fhp, bp->b_data, sizeof(*fhp));
put_bh(bp);
return (fhp);
}
out:
brelse(bp);
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Called upon reg changes or a new wiphy is added */ | static void wiphy_update_beacon_reg(struct wiphy *wiphy) | /* Called upon reg changes or a new wiphy is added */
static void wiphy_update_beacon_reg(struct wiphy *wiphy) | {
unsigned int i;
struct ieee80211_supported_band *sband;
struct reg_beacon *reg_beacon;
assert_cfg80211_lock();
if (list_empty(®_beacon_list))
return;
list_for_each_entry(reg_beacon, ®_beacon_list, list) {
if (!wiphy->bands[reg_beacon->chan.band])
continue;
sband = wiphy->bands[reg_beacon->chan.band];
for (i = 0; i < sband->n_channels; i++)
handle_reg_beacon(wiphy, i, reg_beacon);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* 3. QUEUEING INDICATION No data 3. SAPI "n" REJECT */ | static void bssmap_sapi_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) | /* 3. QUEUEING INDICATION No data 3. SAPI "n" REJECT */
static void bssmap_sapi_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) | {
guint32 consumed;
guint32 curr_offset;
guint curr_len;
curr_offset = offset;
curr_len = len;
ELEM_MAND_TV(BE_DLCI, GSM_A_PDU_TYPE_BSSMAP, BE_DLCI, NULL, ei_gsm_a_bssmap_missing_mandatory_element);
ELEM_MAND_TLV(BE_CAUSE, GSM_A_PDU_TYPE_BSSMAP, BE_CAUSE, NULL, ei_gsm_a_bssmap_missing_mandatory_element);
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 |
/* Stop timer and free the resources allocated by */ | int32_t adc_update_remove(struct adc_update_desc *dev) | /* Stop timer and free the resources allocated by */
int32_t adc_update_remove(struct adc_update_desc *dev) | {
int32_t ret;
if(!dev)
return -1;
ret = adc_update_activate(dev, false);
if(ret < 0)
return ret;
free(dev);
return ret;
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Assumption: No other processor is mucking around with the hub control register. So, upper layer has to single thread this. */ | void hubiio_crb_free(struct hubdev_info *hubdev_info, int crbnum) | /* Assumption: No other processor is mucking around with the hub control register. So, upper layer has to single thread this. */
void hubiio_crb_free(struct hubdev_info *hubdev_info, int crbnum) | {
ii_icrb0_b_u_t icrbb;
icrbb.ii_icrb0_b_regval = REMOTE_HUB_L(hubdev_info->hdi_nasid,
IIO_ICRB_B(crbnum));
icrbb.b_mark = 0;
REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICRB_B(crbnum),
icrbb.ii_icrb0_b_regval);
REMOTE_HUB_S(hubdev_info->hdi_nasid, IIO_ICDR, (IIO_ICDR_PND | crbnum));
while (REMOTE_HUB_L(hubdev_info->hdi_nasid, IIO_ICDR) & IIO_ICDR_PND)
cpu_relax();
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* return kStatus_Success: success in setting the SNVS RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed */ | status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime) | /* return kStatus_Success: success in setting the SNVS RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed */
status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime) | {
assert(alarmTime);
uint32_t alarmSeconds = 0U;
uint32_t currSeconds = 0U;
uint32_t tmp = base->HPCR;
if (!(SNVS_HP_CheckDatetimeFormat(alarmTime)))
{
return kStatus_InvalidArgument;
}
alarmSeconds = SNVS_HP_ConvertDatetimeToSeconds(alarmTime);
currSeconds = SNVS_HP_RTC_GetSeconds(base);
if (alarmSeconds < currSeconds)
{
return kStatus_Fail;
}
base->HPCR &= ~SNVS_HPCR_HPTA_EN_MASK;
while (base->HPCR & SNVS_HPCR_HPTA_EN_MASK)
{
}
base->HPTAMR = (uint32_t)(alarmSeconds >> 17U);
base->HPTALR = (uint32_t)(alarmSeconds << 15U);
base->HPCR = tmp;
return kStatus_Success;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is called while unloading the kernel-module */ | static void __exit usb_gigaset_exit(void) | /* This function is called while unloading the kernel-module */
static void __exit usb_gigaset_exit(void) | {
int i;
gigaset_blockdriver(driver);
for (i = 0; i < driver->minors; i++)
gigaset_shutdown(driver->cs + i);
usb_deregister(&gigaset_usb_driver);
gigaset_freedriver(driver);
driver = NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ps3_repository_read_spu_resource_id - spu resource reservation id value. @res_index: Resource reservation index. @resource_type: Resource reservation type. @resource_id: Resource reservation id. */ | int ps3_repository_read_spu_resource_id(unsigned int res_index, enum ps3_spu_resource_type *resource_type, unsigned int *resource_id) | /* ps3_repository_read_spu_resource_id - spu resource reservation id value. @res_index: Resource reservation index. @resource_type: Resource reservation type. @resource_id: Resource reservation id. */
int ps3_repository_read_spu_resource_id(unsigned int res_index, enum ps3_spu_resource_type *resource_type, unsigned int *resource_id) | {
int result;
u64 v1;
u64 v2;
result = read_node(PS3_LPAR_ID_CURRENT,
make_first_field("bi", 0),
make_field("spursv", 0),
res_index,
0,
&v1, &v2);
*resource_type = v1;
*resource_id = v2;
return result;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* 16-bit packed samples => RGBA w/ associated alpha (known to have Map == NULL) */ | DECLAREContigPutFunc(putRGBAAcontig16bittile) | /* 16-bit packed samples => RGBA w/ associated alpha (known to have Map == NULL) */
DECLAREContigPutFunc(putRGBAAcontig16bittile) | {
int samplesperpixel = img->samplesperpixel;
uint16 *wp = (uint16 *)pp;
(void) y;
fromskew *= samplesperpixel;
for( ; h > 0; --h) {
for (x = w; x > 0; --x) {
*cp++ = PACK4(img->Bitdepth16To8[wp[0]],
img->Bitdepth16To8[wp[1]],
img->Bitdepth16To8[wp[2]],
img->Bitdepth16To8[wp[3]]);
wp += samplesperpixel;
}
cp += toskew;
wp += fromskew;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* param base XRDC2 peripheral base address. param periph The peripheral to operate. */ | void XRDC2_ForcePeriphExclAccessLockRelease(XRDC2_Type *base, xrdc2_periph_t periph) | /* param base XRDC2 peripheral base address. param periph The peripheral to operate. */
void XRDC2_ForcePeriphExclAccessLockRelease(XRDC2_Type *base, xrdc2_periph_t periph) | {
uint32_t pac = XRDC2_GET_PAC((uint32_t)periph);
uint32_t pdac = XRDC2_GET_PDAC((uint32_t)periph);
base->PACI_PDACJ[pac][pdac].PAC_PDAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_0;
base->PACI_PDACJ[pac][pdac].PAC_PDAC_W1 = XRDC2_EAL_FORCE_RELEASE_MAGIC_1;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Scan a list of BSSIDs to process for finalize join. Allows for extension to process multiple BSSIDs. */ | static int mwl8k_capture_bssid(struct mwl8k_priv *priv, struct ieee80211_hdr *wh) | /* Scan a list of BSSIDs to process for finalize join. Allows for extension to process multiple BSSIDs. */
static int mwl8k_capture_bssid(struct mwl8k_priv *priv, struct ieee80211_hdr *wh) | {
return priv->capture_beacon &&
ieee80211_is_beacon(wh->frame_control) &&
!compare_ether_addr(wh->addr3, priv->capture_bssid);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the specified ADC DMA request. */ | void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState) | /* Enables or disables the specified ADC DMA request. */
void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState) | {
assert_param(IS_ADC_DMA_PERIPH(ADCx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADCx->CR2 |= (uint32_t)ADC_CR2_DMA;
}
else
{
ADCx->CR2 &= (uint32_t)(~ADC_CR2_DMA);
}
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* The function is used to Get HCLK clock and the UNIT is in Hz. */ | unsigned long xSysCtlClockGet(void) | /* The function is used to Get HCLK clock and the UNIT is in Hz. */
unsigned long xSysCtlClockGet(void) | {
unsigned long ulHCLKSrc;
ulHCLKSrc = xHWREG(SYSCLK_CLKSEL0) & SYSCLK_CLKSEL0_HCLK_S_M;
if(ulHCLKSrc == 0)
{
return 48000000;
}
else if (ulHCLKSrc == 1)
{
return 32000;
}
else
{
return 16000;
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Enter a CRITICAL section.
When a CRITICAL section is entered, all interrupts (except fault handlers) are disabled. */ | SL_WEAK CORE_irqState_t CORE_EnterCritical(void) | /* Enter a CRITICAL section.
When a CRITICAL section is entered, all interrupts (except fault handlers) are disabled. */
SL_WEAK CORE_irqState_t CORE_EnterCritical(void) | {
CORE_irqState_t irqState = __get_PRIMASK();
__disable_irq();
return irqState;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* For short delays only. It will overflow after a few seconds. */ | void __udelay(unsigned long usec) | /* For short delays only. It will overflow after a few seconds. */
void __udelay(unsigned long usec) | {
unsigned long cycles;
unsigned long base;
unsigned long now;
base = sysreg_read(COUNT);
cycles = ((usec * (get_tbclk() / 10000)) + 50) / 100;
do {
now = sysreg_read(COUNT);
} while ((now - base) < cycles);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Module 'remove' entry point. o unregister all adapters from the WAN router o release all remaining system resources */ | static void __exit cycx_exit(void) | /* Module 'remove' entry point. o unregister all adapters from the WAN router o release all remaining system resources */
static void __exit cycx_exit(void) | {
int i = 0;
for (; i < cycx_ncards; ++i) {
struct cycx_device *card = &cycx_card_array[i];
unregister_wan_device(card->devname);
}
kfree(cycx_card_array);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks whether the specified SPIx/I2Sx interrupt has occurred or not. */ | ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT) | /* Checks whether the specified SPIx/I2Sx interrupt has occurred or not. */
ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT) | {
ITStatus bitstatus = RESET;
uint16_t itpos = 0, itmask = 0, enablestatus = 0;
assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT));
itpos = 0x01 << (SPI_I2S_IT & 0x0F);
itmask = SPI_I2S_IT >> 4;
itmask = 0x01 << itmask;
enablestatus = (SPIx->CR2 & itmask) ;
if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Unpacks unsigned 16 bit value from the buffer from the offset requested. */ | static int unpack_uint16(struct buf_ctx *buf, uint16_t *val) | /* Unpacks unsigned 16 bit value from the buffer from the offset requested. */
static int unpack_uint16(struct buf_ctx *buf, uint16_t *val) | {
NET_DBG(">> cur:%p, end:%p", (void *)buf->cur, (void *)buf->end);
if ((buf->end - buf->cur) < sizeof(uint16_t)) {
return -EINVAL;
}
*val = *(buf->cur++) << 8;
*val |= *(buf->cur++);
NET_DBG("<< val:%04x", *val);
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Send CMD8 to get EXT_CSD value of MMC;. */ | static int mmc_read_esd(uint32_t instance) | /* Send CMD8 to get EXT_CSD value of MMC;. */
static int mmc_read_esd(uint32_t instance) | {
command_t cmd;
card_cmd_config(&cmd, CMD16, BLK_LEN, READ, RESPONSE_48, DATA_PRESENT_NONE, TRUE, TRUE);
usdhc_printf("Send CMD16.\n");
if (SUCCESS == host_send_cmd(instance, &cmd)) {
host_cfg_block(instance, BLK_LEN, ONE, ESDHC_BLKATTR_WML_BLOCK);
card_cmd_config(&cmd, CMD8, NO_ARG, READ, RESPONSE_48, DATA_PRESENT, TRUE, TRUE);
usdhc_printf("Send CMD8.\n");
if (SUCCESS == host_send_cmd(instance, &cmd)) {
return host_data_read(instance, (int *)ext_csd_data, BLK_LEN,
ESDHC_BLKATTR_WML_BLOCK);
}
}
return FAIL;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns: Pointer to a page, NULL on error. */ | PAGE* __bt_new(BTREE *t, pgno_t *npg) | /* Returns: Pointer to a page, NULL on error. */
PAGE* __bt_new(BTREE *t, pgno_t *npg) | {
PAGE *h;
if (t->bt_free != P_INVALID &&
(h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
*npg = t->bt_free;
t->bt_free = h->nextpg;
F_SET(t, B_METADIRTY);
return (h);
}
return (mpool_new(t->bt_mp, npg));
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Function: MX25_2READ Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The 2READ instruction enable double throughput of Serial Flash in read mode Return Message: FlashAddressInvalid, FlashOperationSuccess */ | ReturnMsg MX25_2READ(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length) | /* Function: MX25_2READ Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The 2READ instruction enable double throughput of Serial Flash in read mode Return Message: FlashAddressInvalid, FlashOperationSuccess */
ReturnMsg MX25_2READ(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length) | {
uint32_t index;
uint8_t addr_4byte_mode;
uint8_t dc;
if( flash_address > FlashSize ) return FlashAddressInvalid;
if( IsFlash4Byte() )
addr_4byte_mode = TRUE;
else
addr_4byte_mode = FALSE;
dc = GetDummyCycle( DUMMY_CONF_2READ );
CS_Low();
SendByte( FLASH_CMD_2READ, SIO );
SendFlashAddr( flash_address, DIO, addr_4byte_mode );
InsertDummyCycle( dc );
for( index=0; index < byte_length; index++ )
{
*(target_address + index) = GetByte( DIO );
}
CS_High();
return FlashOperationSuccess;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* If this function is not defined here, board.c alters dram bank zero configuration defined above. */ | int dram_init_banksize(void) | /* If this function is not defined here, board.c alters dram bank zero configuration defined above. */
int dram_init_banksize(void) | {
dram_init();
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* param masterConfig User provided configuration structure for default values. Refer to #i2c_master_config_t. */ | void I2C_MasterGetDefaultConfig(i2c_master_config_t *masterConfig) | /* param masterConfig User provided configuration structure for default values. Refer to #i2c_master_config_t. */
void I2C_MasterGetDefaultConfig(i2c_master_config_t *masterConfig) | {
(void)memset(masterConfig, 0, sizeof(*masterConfig));
masterConfig->enableMaster = true;
masterConfig->baudRate_Bps = 100000U;
masterConfig->enableTimeout = false;
masterConfig->timeout_Ms = 35;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Write out pagecache data for the whole filesystem. */ | int xfs_sync_data(struct xfs_mount *mp, int flags) | /* Write out pagecache data for the whole filesystem. */
int xfs_sync_data(struct xfs_mount *mp, int flags) | {
int error;
ASSERT((flags & ~(SYNC_TRYLOCK|SYNC_WAIT)) == 0);
error = xfs_inode_ag_iterator(mp, xfs_sync_inode_data, flags,
XFS_ICI_NO_TAG, 0);
if (error)
return XFS_ERROR(error);
xfs_log_force(mp, 0,
(flags & SYNC_WAIT) ?
XFS_LOG_FORCE | XFS_LOG_SYNC :
XFS_LOG_FORCE);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is called by ZCL foundation dissector in order to decode */ | void dissect_zcl_thermostat_ui_config_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type) | /* This function is called by ZCL foundation dissector in order to decode */
void dissect_zcl_thermostat_ui_config_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type) | {
switch (attr_id) {
case ZBEE_ZCL_ATTR_ID_THERMOSTAT_UI_CONFIG_TEMP_DISP_MODE:
proto_tree_add_item(tree, hf_zbee_zcl_thermostat_ui_config_attr_temp_disp_mode, tvb, *offset, 1, ENC_NA);
*offset += 1;
break;
case ZBEE_ZCL_ATTR_ID_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT:
proto_tree_add_item(tree, hf_zbee_zcl_thermostat_ui_config_attr_keypad_lockout, tvb, *offset, 1, ENC_NA);
*offset += 1;
break;
default:
dissect_zcl_attr_data(tvb, tree, offset, data_type);
break;
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Most of these aren't static because they may be used by the parport_xxx_yyy macros. extern */ | void parport_gsc_init_state(struct pardevice *dev, struct parport_state *s) | /* Most of these aren't static because they may be used by the parport_xxx_yyy macros. extern */
void parport_gsc_init_state(struct pardevice *dev, struct parport_state *s) | {
s->u.pc.ctr = 0xc | (dev->irq_func ? 0x10 : 0x0);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* pci_add_save_buffer - allocate buffer for saving given capability registers @dev: the PCI device @cap: the capability to allocate the buffer for @size: requested size of the buffer */ | static int pci_add_cap_save_buffer(struct pci_dev *dev, char cap, unsigned int size) | /* pci_add_save_buffer - allocate buffer for saving given capability registers @dev: the PCI device @cap: the capability to allocate the buffer for @size: requested size of the buffer */
static int pci_add_cap_save_buffer(struct pci_dev *dev, char cap, unsigned int size) | {
int pos;
struct pci_cap_saved_state *save_state;
pos = pci_find_capability(dev, cap);
if (pos <= 0)
return 0;
save_state = kzalloc(sizeof(*save_state) + size, GFP_KERNEL);
if (!save_state)
return -ENOMEM;
save_state->cap_nr = cap;
pci_add_saved_cap(dev, save_state);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns -1, 0 or 1 depending on whether data1 is greater equal or smaller than data0 */ | static int xmlLinkCompare(const void *data0, const void *data1) | /* Returns -1, 0 or 1 depending on whether data1 is greater equal or smaller than data0 */
static int xmlLinkCompare(const void *data0, const void *data1) | {
if (data0 < data1)
return (-1);
else if (data0 == data1)
return (0);
return (1);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function is the entry point of this Status Code PEIM. It initializes supported status code devices according to PCD settings, and installs Status Code PPI. */ | EFI_STATUS EFIAPI StatusCodeHandlerPeiEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices) | /* This function is the entry point of this Status Code PEIM. It initializes supported status code devices according to PCD settings, and installs Status Code PPI. */
EFI_STATUS EFIAPI StatusCodeHandlerPeiEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices) | {
EFI_STATUS Status;
EFI_PEI_RSC_HANDLER_PPI *RscHandlerPpi;
Status = PeiServicesLocatePpi (
&gEfiPeiRscHandlerPpiGuid,
0,
NULL,
(VOID **)&RscHandlerPpi
);
ASSERT_EFI_ERROR (Status);
if (PcdGetBool (PcdStatusCodeUseSerial)) {
Status = SerialPortInitialize ();
ASSERT_EFI_ERROR (Status);
Status = RscHandlerPpi->Register (SerialStatusCodeReportWorker);
ASSERT_EFI_ERROR (Status);
}
if (PcdGetBool (PcdStatusCodeUseMemory)) {
Status = MemoryStatusCodeInitializeWorker ();
ASSERT_EFI_ERROR (Status);
Status = RscHandlerPpi->Register (MemoryStatusCodeReportWorker);
ASSERT_EFI_ERROR (Status);
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* div_s64 - signed 64bit divide with 32bit divisor */ | LIBC_ROM_TEXT_SECTION static _LONG_CALL_ const char* _parse_integer_fixup_radix(const char *s, unsigned int *base) | /* div_s64 - signed 64bit divide with 32bit divisor */
LIBC_ROM_TEXT_SECTION static _LONG_CALL_ const char* _parse_integer_fixup_radix(const char *s, unsigned int *base) | {
if (*base == 0) {
if (s[0] == '0') {
if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
*base = 16;
else
*base = 8;
} else
*base = 10;
}
if (*base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
s += 2;
return s;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Remove any -d options from an argument vector. */ | static int filter_daemonize_argv(char **argv) | /* Remove any -d options from an argument vector. */
static int filter_daemonize_argv(char **argv) | {
int ret = 0;
for (char **narg = argv; *narg != NULL; narg++) {
if (strcmp("-d", narg[0]) == 0) {
ret = 1;
char **xarg = narg;
do {
xarg[0] = xarg[1];
} while (*xarg++ != NULL);
narg--;
}
}
return ret;
} | labapart/polymcu | C++ | null | 201 |
/* The proc filesystem read/write function, a simple proc implement to get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, DVP1Driving, DFPHigh, DFPLow CR96, SR2A, SR1B, SR2A, SR1E, CR9B, SR65, CR97, CR99 */ | static int viafb_dvp0_proc_show(struct seq_file *m, void *v) | /* The proc filesystem read/write function, a simple proc implement to get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, DVP1Driving, DFPHigh, DFPLow CR96, SR2A, SR1B, SR2A, SR1E, CR9B, SR65, CR97, CR99 */
static int viafb_dvp0_proc_show(struct seq_file *m, void *v) | {
u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
dvp0_data_dri =
(viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
(viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
dvp0_clk_dri =
(viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
(viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function handles multiple format printing by sending to the appropriate dispatch function */ | int reporter_print(ReporterData *stats, int type, int end) | /* This function handles multiple format printing by sending to the appropriate dispatch function */
int reporter_print(ReporterData *stats, int type, int end) | {
case TRANSFER_REPORT:
statistics_reports[stats->mode]( &stats->info );
if ( end != 0 && isPrintMSS( stats ) && !isUDP( stats ) ) {
PrintMSS( stats );
}
break;
case SERVER_RELAY_REPORT:
serverstatistics_reports[stats->mode]( &stats->connection, &stats->info );
break;
case SETTINGS_REPORT:
settings_reports[stats->mode]( stats );
break;
case CONNECTION_REPORT:
stats->info.reserved_delay = connection_reports[stats->mode](
&stats->connection,
stats->info.transferID );
break;
case MULTIPLE_REPORT:
multiple_reports[stats->mode]( &stats->info );
break;
default:
fprintf( stderr, "Printing type not implemented! No Output\n" );
}
fflush( stdout );
return end;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Callback function which provided by user to remove one node in NetDestroyLinkList process. */ | EFI_STATUS EFIAPI Mtftp6DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context) | /* Callback function which provided by user to remove one node in NetDestroyLinkList process. */
EFI_STATUS EFIAPI Mtftp6DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context) | {
MTFTP6_INSTANCE *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
UINTN NumberOfChildren;
EFI_HANDLE *ChildHandleBuffer;
if ((Entry == NULL) || (Context == NULL)) {
return EFI_INVALID_PARAMETER;
}
Instance = NET_LIST_USER_STRUCT_S (Entry, MTFTP6_INSTANCE, Link, MTFTP6_INSTANCE_SIGNATURE);
ServiceBinding = ((MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
NumberOfChildren = ((MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
ChildHandleBuffer = ((MTFTP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (Instance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
}
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr */ | CHAR8* BasicWriteRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr) | /* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr */
CHAR8* BasicWriteRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr) | {
UINTN RegSize;
UINTN TempValue;
UINT32 NewValue;
if (gRegisterOffsets[RegNumber] > 0xF00) {
return InBufPtr + 8;
}
NewValue = 0;
RegSize = 0;
while (RegSize < 32) {
TempValue = HexCharToInt (*InBufPtr++);
if ((INTN)TempValue < 0) {
SendError (GDB_EBADMEMDATA);
return NULL;
}
NewValue += (TempValue << (RegSize+4));
TempValue = HexCharToInt (*InBufPtr++);
if ((INTN)TempValue < 0) {
SendError (GDB_EBADMEMDATA);
return NULL;
}
NewValue += (TempValue << RegSize);
RegSize = RegSize + 8;
}
*(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
return InBufPtr;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Deal with module insertion/removal Mostly tell USB about our existence Module insertion */ | static int __init usb_irda_init(void) | /* Deal with module insertion/removal Mostly tell USB about our existence Module insertion */
static int __init usb_irda_init(void) | {
int ret;
ret = usb_register(&irda_driver);
if (ret < 0)
return ret;
IRDA_MESSAGE("USB IrDA support registered\n");
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* GPIO EXTI Callback function Handle remote-wakeup through key button. */ | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) | /* GPIO EXTI Callback function Handle remote-wakeup through key button. */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) | {
if (GPIO_Pin == KEY_BUTTON_PIN)
{
if ((((USBD_HandleTypeDef *)hpcd.pData)->dev_remote_wakeup == 1)&&
(((USBD_HandleTypeDef *)hpcd.pData)->dev_state == USBD_STATE_SUSPENDED))
{
if ((&hpcd)->Init.low_power_enable)
{
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
SystemClockConfig_STOP();
}
__HAL_PCD_UNGATE_PHYCLOCK((&hpcd));
HAL_PCD_ActivateRemoteWakeup((&hpcd));
HAL_Delay(10);
HAL_PCD_DeActivateRemoteWakeup((&hpcd));
((USBD_HandleTypeDef *)hpcd.pData)->dev_state = USBD_STATE_CONFIGURED;
((USBD_HandleTypeDef *)hpcd.pData)->dev_remote_wakeup=0;
remotewakeupon = 1;
}
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* stmmac_verify_args - verify the driver parameters. Description: it verifies if some wrong parameter is passed to the driver. Note that wrong parameters are replaced with the default values. */ | static void stmmac_verify_args(void) | /* stmmac_verify_args - verify the driver parameters. Description: it verifies if some wrong parameter is passed to the driver. Note that wrong parameters are replaced with the default values. */
static void stmmac_verify_args(void) | {
if (unlikely(watchdog < 0))
watchdog = TX_TIMEO;
if (unlikely(dma_rxsize < 0))
dma_rxsize = DMA_RX_SIZE;
if (unlikely(dma_txsize < 0))
dma_txsize = DMA_TX_SIZE;
if (unlikely((buf_sz < DMA_BUFFER_SIZE) || (buf_sz > BUF_SIZE_16KiB)))
buf_sz = DMA_BUFFER_SIZE;
if (unlikely(flow_ctrl > 1))
flow_ctrl = FLOW_AUTO;
else if (likely(flow_ctrl < 0))
flow_ctrl = FLOW_OFF;
if (unlikely((pause < 0) || (pause > 0xffff)))
pause = PAUSE_TIME;
return;
} | 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.