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 |
|---|---|---|---|---|---|---|---|
/* Convert the NT UTC (based , in hundred nanosecond units) into Unix UTC (based , in seconds). */ | struct timespec cifs_NTtimeToUnix(__le64 ntutc) | /* Convert the NT UTC (based , in hundred nanosecond units) into Unix UTC (based , in seconds). */
struct timespec cifs_NTtimeToUnix(__le64 ntutc) | {
struct timespec ts;
u64 t;
t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
ts.tv_nsec = do_div(t, 10000000) * 100;
ts.tv_sec = t;
return ts;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns 0 if the device function was successfully reset or negative if the device doesn't support resetting a single function. */ | int pci_reset_function(struct pci_dev *dev) | /* Returns 0 if the device function was successfully reset or negative if the device doesn't support resetting a single function. */
int pci_reset_function(struct pci_dev *dev) | {
int rc;
rc = pci_dev_reset(dev, 1);
if (rc)
return rc;
pci_save_state(dev);
pci_write_config_word(dev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE);
rc = pci_dev_reset(dev, 0);
pci_restore_state(dev);
return rc;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Usb interrupt enable/disable Parameters: ena: enable/disable 0: disable interrupt 1: enable interrupt USB Device Initialize Function Called by the User to initialize USB Device Return Value: None */ | void USBD_Init(void) | /* Usb interrupt enable/disable Parameters: ena: enable/disable 0: disable interrupt 1: enable interrupt USB Device Initialize Function Called by the User to initialize USB Device Return Value: None */
void USBD_Init(void) | {
LPC_SYSCON->SYSAHBCLKCTRL |= (1UL << 6);
LPC_SYSCON->SYSAHBCLKCTRL |= (1UL << 14) |
(1UL << 27);
LPC_USB->DEVCMDSTAT |= (1UL << 9);
LPC_IOCON->PIO0_3 &= ~(0x1F);
LPC_IOCON->PIO0_3 |= (1UL << 0);
LPC_IOCON->PIO0_6 &= ~7;
LPC_IOCON->PIO0_6 |= (1UL << 0);
LPC_SYSCON->PDRUNCFG &= ~((1UL << 8) |
(1UL << 10));
LPC_USB->DATABUFSTART = EP_BUF_BASE & 0xFFC00000;
LPC_USB->EPLISTSTART = EP_LIST_BASE;
NVIC_EnableIRQ(USB_IRQn);
USBD_Reset();
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* This function renders an image to a bitmap or the screen using the specified color and options. It draws the image on an existing bitmap, allocates a new bitmap or uses the screen. The images can be clipped. */ | EFI_STATUS EFIAPI HiiDrawImageId(IN CONST EFI_HII_IMAGE_PROTOCOL *This, IN EFI_HII_DRAW_FLAGS Flags, IN EFI_HII_HANDLE PackageList, IN EFI_IMAGE_ID ImageId, IN OUT EFI_IMAGE_OUTPUT **Blt, IN UINTN BltX, IN UINTN BltY) | /* This function renders an image to a bitmap or the screen using the specified color and options. It draws the image on an existing bitmap, allocates a new bitmap or uses the screen. The images can be clipped. */
EFI_STATUS EFIAPI HiiDrawImageId(IN CONST EFI_HII_IMAGE_PROTOCOL *This, IN EFI_HII_DRAW_FLAGS Flags, IN EFI_HII_HANDLE PackageList, IN EFI_IMAGE_ID ImageId, IN OUT EFI_IMAGE_OUTPUT **Blt, IN UINTN BltX, IN UINTN BltY) | {
EFI_STATUS Status;
EFI_IMAGE_INPUT Image;
if ((This == NULL) || (Blt == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = HiiGetImage (This, PackageList, ImageId, &Image);
if (EFI_ERROR (Status)) {
return Status;
}
Status = HiiDrawImage (This, Flags, &Image, Blt, BltX, BltY);
if (Image.Bitmap != NULL) {
FreePool (Image.Bitmap);
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: TRUE if a mount point is read only. */ | gboolean g_unix_mount_point_is_readonly(GUnixMountPoint *mount_point) | /* Returns: TRUE if a mount point is read only. */
gboolean g_unix_mount_point_is_readonly(GUnixMountPoint *mount_point) | {
g_return_val_if_fail (mount_point != NULL, FALSE);
return mount_point->is_read_only;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* returns the byte length of received frame including CRC. This returns the no of bytes received in the received ethernet frame including CRC(FCS). */ | u32 synopGMAC_get_rx_desc_frame_length(u32 status) | /* returns the byte length of received frame including CRC. This returns the no of bytes received in the received ethernet frame including CRC(FCS). */
u32 synopGMAC_get_rx_desc_frame_length(u32 status) | {
return ((status & DescFrameLengthMask) >> DescFrameLengthShift);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Update names of Name/Value storage to current language. */ | EFI_STATUS LoadNameValueNames(IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData) | /* Update names of Name/Value storage to current language. */
EFI_STATUS LoadNameValueNames(IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData) | {
UINTN Index;
for (Index = 0; Index < NAME_VALUE_NAME_NUMBER; Index++) {
PrivateData->NameValueName[Index] = HiiGetString (
PrivateData->HiiHandle[0],
PrivateData->NameStringId[Index],
NULL
);
if (PrivateData->NameValueName[Index] == NULL) {
return EFI_NOT_FOUND;
}
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* HASH Set Algorithm.
Sets up the specified algorithm - either MD5 or SHA1. */ | void hash_set_algorithm(uint8_t algorithm) | /* HASH Set Algorithm.
Sets up the specified algorithm - either MD5 or SHA1. */
void hash_set_algorithm(uint8_t algorithm) | {
HASH_CR &= ~HASH_CR_ALGO;
HASH_CR |= algorithm;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Construction function for DMAWMB instruction. This function fills the program buffer with the constructed instruction. */ | int XDmaPs_Instr_DMAWMB(char *DmaProg) | /* Construction function for DMAWMB instruction. This function fills the program buffer with the constructed instruction. */
int XDmaPs_Instr_DMAWMB(char *DmaProg) | {
*DmaProg = 0x13;
return 1;
} | ua1arn/hftrx | C++ | null | 69 |
/* Changes the state of a network interface from "started" to "stopped". */ | EFI_STATUS EmuSnpStop(IN EMU_SNP_PROTOCOL *This) | /* Changes the state of a network interface from "started" to "stopped". */
EFI_STATUS EmuSnpStop(IN EMU_SNP_PROTOCOL *This) | {
EMU_SNP_PRIVATE *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Given the contents of the status register, return the index of the CPLB that caused the fault. */ | static int faulting_cplb_index(int status) | /* Given the contents of the status register, return the index of the CPLB that caused the fault. */
static int faulting_cplb_index(int status) | {
int signbits = __builtin_bfin_norm_fr1x32(status & 0xFFFF);
return 30 - signbits;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* the gpio_init_mux function is not defined as it is not needed for this CPU */ | void gpio_irq_enable(gpio_t pin) | /* the gpio_init_mux function is not defined as it is not needed for this CPU */
void gpio_irq_enable(gpio_t pin) | {
NRF_GPIOTE->INTENSET |= GPIOTE_INTENSET_IN0_Msk;
} | labapart/polymcu | C++ | null | 201 |
/* Check whether the value of a TPM chip register satisfies the input BIT setting. */ | EFI_STATUS Tpm12TisPcWaitRegisterBits(IN UINT8 *Register, IN UINT8 BitSet, IN UINT8 BitClear, IN UINT32 TimeOut) | /* Check whether the value of a TPM chip register satisfies the input BIT setting. */
EFI_STATUS Tpm12TisPcWaitRegisterBits(IN UINT8 *Register, IN UINT8 BitSet, IN UINT8 BitClear, IN UINT32 TimeOut) | {
UINT8 RegRead;
UINT32 WaitTime;
for (WaitTime = 0; WaitTime < TimeOut; WaitTime += 30) {
RegRead = MmioRead8 ((UINTN)Register);
if (((RegRead & BitSet) == BitSet) && ((RegRead & BitClear) == 0)) {
return EFI_SUCCESS;
}
MicroSecondDelay (30);
}
return EFI_TIMEOUT;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* this function is a POSIX compliant version, which will get file status. */ | int fstat(int fildes, struct stat *buf) | /* this function is a POSIX compliant version, which will get file status. */
int fstat(int fildes, struct stat *buf) | {
int ret = -1;
struct dfs_file *file;
if (buf == NULL)
{
rt_set_errno(-EBADF);
return -1;
}
file = fd_get(fildes);
if (file == NULL)
{
rt_set_errno(-EBADF);
return -1;
}
if (dfs_is_mounted(file->dentry->mnt) == 0)
{
ret = file->dentry->mnt->fs_ops->stat(file->dentry, buf);
}
return ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Measures relative humidity and temperature from a Si/21 sensor. */ | sl_status_t sl_si70xx_measure_rh_and_temp(sl_i2cspm_t *i2cspm, uint8_t addr, uint32_t *rhData, int32_t *tData) | /* Measures relative humidity and temperature from a Si/21 sensor. */
sl_status_t sl_si70xx_measure_rh_and_temp(sl_i2cspm_t *i2cspm, uint8_t addr, uint32_t *rhData, int32_t *tData) | {
sl_status_t retval;
retval = sl_si70xx_send_command(i2cspm, addr, rhData, SI70XX_MEASURE_RH);
if (retval != SL_STATUS_OK) {
return retval;
}
*rhData = sl_si70xx_get_percent_relative_humidity(*rhData);
retval = sl_si70xx_send_command(i2cspm, addr, (uint32_t *) tData, SI70XX_READ_TEMP);
if (retval != SL_STATUS_OK) {
return retval;
}
*tData = sl_si70xx_get_celcius_temperature(*tData);
return retval;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Whenever you want to write a blob of data to the internal buffer you have to start by using this function first. It will write the number of bytes that will be written to the buffer. If necessary it will remove old records to make room for the new one. Needs to be called with bufferlock held. */ | static int dasd_eer_start_record(struct eerbuffer *eerb, int count) | /* Whenever you want to write a blob of data to the internal buffer you have to start by using this function first. It will write the number of bytes that will be written to the buffer. If necessary it will remove old records to make room for the new one. Needs to be called with bufferlock held. */
static int dasd_eer_start_record(struct eerbuffer *eerb, int count) | {
int tailcount;
if (count + sizeof(count) > eerb->buffersize)
return -ENOMEM;
while (dasd_eer_get_free_bytes(eerb) < count + sizeof(count)) {
if (eerb->residual > 0) {
eerb->tail += eerb->residual;
if (eerb->tail >= eerb->buffersize)
eerb->tail -= eerb->buffersize;
eerb->residual = -1;
}
dasd_eer_read_buffer(eerb, (char *) &tailcount,
sizeof(tailcount));
eerb->tail += tailcount;
if (eerb->tail >= eerb->buffersize)
eerb->tail -= eerb->buffersize;
}
dasd_eer_write_buffer(eerb, (char*) &count, sizeof(count));
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sleep-to-wake, return-to-sleep activation threshold in low-power mode. 1 LSb = 16mg@2g / 32mg@4g / 62mg@8g / 186mg@16g. */ | int32_t lis2dh12_act_threshold_get(stmdev_ctx_t *ctx, uint8_t *val) | /* Sleep-to-wake, return-to-sleep activation threshold in low-power mode. 1 LSb = 16mg@2g / 32mg@4g / 62mg@8g / 186mg@16g. */
int32_t lis2dh12_act_threshold_get(stmdev_ctx_t *ctx, uint8_t *val) | {
lis2dh12_act_ths_t act_ths;
int32_t ret;
ret = lis2dh12_read_reg(ctx, LIS2DH12_ACT_THS, (uint8_t *)&act_ths, 1);
*val = (uint8_t)act_ths.acth;
return ret;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* USBH_MTP_SelectStorage Select the storage Unit to be used. */ | USBH_StatusTypeDef USBH_MTP_SelectStorage(USBH_HandleTypeDef *phost, uint8_t storage_idx) | /* USBH_MTP_SelectStorage Select the storage Unit to be used. */
USBH_StatusTypeDef USBH_MTP_SelectStorage(USBH_HandleTypeDef *phost, uint8_t storage_idx) | {
USBH_StatusTypeDef status = USBH_FAIL;
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready == 1U))
{
MTP_Handle->params.CurrentStorageId = MTP_Handle->info.storids.Storage[storage_idx];
status = USBH_OK;
}
return status;
} | ua1arn/hftrx | C++ | null | 69 |
/* Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). */ | void I2C_ExtendedClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | /* Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). */
void I2C_ExtendedClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | {
assert_param(IS_I2C_1_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TEXTEN;
}
else
{
I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TEXTEN);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Convert a BT GAP event type to a string representation. */ | static const char * bt_event_type_to_string(uint32_t eventType) | /* Convert a BT GAP event type to a string representation. */
static const char * bt_event_type_to_string(uint32_t eventType) | {
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
return "ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT";
case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT:
return "ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT";
case ESP_GAP_BLE_SCAN_RESULT_EVT:
return "ESP_GAP_BLE_SCAN_RESULT_EVT";
case ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT:
return "ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT";
default:
return "Unknown event type";
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Return the output level (high or low) of the selected comparator. */ | uint32_t OPA_GetOutputLevel(OPA_TypeDef *OPAx, uint32_t OPA_OutLevel) | /* Return the output level (high or low) of the selected comparator. */
uint32_t OPA_GetOutputLevel(OPA_TypeDef *OPAx, uint32_t OPA_OutLevel) | {
uint32_t compout = 0x0;
assert_param(IS_OPA_ALL_PERIPH(OPAx));
assert_param(IS_OPA_OUTPUT_LEVEL(OPA_OutLevel));
if ((OPAx->CR & OPA_OutLevel) != 0)
{
compout = OPA_OutLevel;
}
else
{
compout = OPA_OutputLevel_Low;
}
return (uint32_t)(compout);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Message: CallSelectStatMessage Opcode: 0x0130 Type: CallControl Direction: pbx2dev VarLength: no */ | static void handle_CallSelectStatMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | /* Message: CallSelectStatMessage Opcode: 0x0130 Type: CallControl Direction: pbx2dev VarLength: no */
static void handle_CallSelectStatMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | {
ptvcursor_add(cursor, hf_skinny_callSelectStat, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* fill the target region with a given 16bit colour */ | arm_fsm_rt_t arm_2dp_rgb16_fill_colour(arm_2d_op_fill_cl_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast16_t hwColour) | /* fill the target region with a given 16bit colour */
arm_fsm_rt_t arm_2dp_rgb16_fill_colour(arm_2d_op_fill_cl_t *ptOP, const arm_2d_tile_t *ptTarget, const arm_2d_region_t *ptRegion, uint_fast16_t hwColour) | {
assert(NULL != ptTarget);
ARM_2D_IMPL(arm_2d_op_fill_cl_t, ptOP);
if (!__arm_2d_op_acquire((arm_2d_op_core_t *)ptThis)) {
return arm_fsm_rt_on_going;
}
OP_CORE.ptOp = &ARM_2D_OP_FILL_COLOUR_RGB16;
this.Target.ptTile = ptTarget;
this.Target.ptRegion = ptRegion;
this.hwColour = hwColour;
return __arm_2d_op_invoke((arm_2d_op_core_t *)ptThis);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Simple udelay variant. To be used on startup and reboot when the interrupt handler isn't working. */ | void udelay_simple(unsigned long long usecs) | /* Simple udelay variant. To be used on startup and reboot when the interrupt handler isn't working. */
void udelay_simple(unsigned long long usecs) | {
u64 end;
end = get_clock() + (usecs << 12);
while (get_clock() < end)
cpu_relax();
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Reads the byte value from the linear address. */ | static blt_int8u FlashGetLinearAddrByte(blt_addr addr) | /* Reads the byte value from the linear address. */
static blt_int8u FlashGetLinearAddrByte(blt_addr addr) | {
blt_int8u oldPage;
blt_int8u result;
oldPage = FLASH_PPAGE_REG;
FLASH_PPAGE_REG = FlashGetPhysPage(addr);
result = *((blt_int8u *)FlashGetPhysAddr(addr));
FLASH_PPAGE_REG = oldPage;
return result;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* System shutdown should not return, if it returns, it means the system does not support shut down reset. */ | VOID EFIAPI ResetShutdown(VOID) | /* System shutdown should not return, if it returns, it means the system does not support shut down reset. */
VOID EFIAPI ResetShutdown(VOID) | {
IoBitFieldWrite16 (BHYVE_PM_REG, 10, 13, 5);
IoOr16 (BHYVE_PM_REG, BIT13);
CpuDeadLoop ();
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Configures User push-button in GPIO or EXTI Line Mode. */ | void UserButton_Init(void) | /* Configures User push-button in GPIO or EXTI Line Mode. */
void UserButton_Init(void) | {
USER_BUTTON_GPIO_CLK_ENABLE();
LL_GPIO_SetPinMode(USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinPull(USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, LL_GPIO_PULL_NO);
USER_BUTTON_SYSCFG_SET_EXTI();
USER_BUTTON_EXTI_LINE_ENABLE();
USER_BUTTON_EXTI_FALLING_TRIG_ENABLE();
NVIC_EnableIRQ(USER_BUTTON_EXTI_IRQn);
NVIC_SetPriority(USER_BUTTON_EXTI_IRQn,0x03);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Returns the read byte or 0 if something bad happened. */ | guchar cr_input_peek_byte2(CRInput *a_this, gulong a_offset, gboolean *a_eof) | /* Returns the read byte or 0 if something bad happened. */
guchar cr_input_peek_byte2(CRInput *a_this, gulong a_offset, gboolean *a_eof) | {
guchar result = 0;
enum CRStatus status = CR_ERROR;
g_return_val_if_fail (a_this && PRIVATE (a_this), 0);
if (a_eof)
*a_eof = FALSE;
status = cr_input_peek_byte (a_this, CR_SEEK_CUR, a_offset, &result);
if ((status == CR_END_OF_INPUT_ERROR)
&& a_eof)
*a_eof = TRUE;
return result;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base Pointer to FLEXIO_I2C_Type structure. param handle Pointer to flexio_i2c_master_handle_t structure to store the transfer state. param callback Pointer to user callback function. param userData User param passed to the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/isr table out of range. */ | status_t FLEXIO_I2C_MasterTransferCreateHandle(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle, flexio_i2c_master_transfer_callback_t callback, void *userData) | /* param base Pointer to FLEXIO_I2C_Type structure. param handle Pointer to flexio_i2c_master_handle_t structure to store the transfer state. param callback Pointer to user callback function. param userData User param passed to the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/isr table out of range. */
status_t FLEXIO_I2C_MasterTransferCreateHandle(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle, flexio_i2c_master_transfer_callback_t callback, void *userData) | {
assert(handle);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
memset(handle, 0, sizeof(*handle));
handle->completionCallback = callback;
handle->userData = userData;
EnableIRQ(flexio_irqs[FLEXIO_I2C_GetInstance(base)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_I2C_MasterTransferHandleIRQ);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* XEmacPs_GetOperatingSpeed gets the current operating link speed. This may be the value set by */ | u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr) | /* XEmacPs_GetOperatingSpeed gets the current operating link speed. This may be the value set by */
u16 XEmacPs_GetOperatingSpeed(XEmacPs *InstancePtr) | {
u32 Reg;
u16 Status;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == (u32)XIL_COMPONENT_IS_READY);
Reg = XEmacPs_ReadReg(InstancePtr->Config.BaseAddress,
XEMACPS_NWCFG_OFFSET);
if ((Reg & XEMACPS_NWCFG_1000_MASK) != 0x00000000U) {
Status = (u16)(1000);
} else {
if ((Reg & XEMACPS_NWCFG_100_MASK) != 0x00000000U) {
Status = (u16)(100);
} else {
Status = (u16)(10);
}
}
return Status;
} | ua1arn/hftrx | C++ | null | 69 |
/* FKS: This is a one-on-one copy of sb1_audio_set_bits */ | static unsigned int ess_audio_set_bits(int dev, unsigned int bits) | /* FKS: This is a one-on-one copy of sb1_audio_set_bits */
static unsigned int ess_audio_set_bits(int dev, unsigned int bits) | {
sb_devc *devc = audio_devs[dev]->devc;
if (bits != 0) {
if (bits == AFMT_U8 || bits == AFMT_S16_LE) {
devc->bits = bits;
} else {
devc->bits = AFMT_U8;
}
}
return devc->bits;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base ENET_QOS peripheral base address. param statistics The statistics structure pointer. */ | void ENET_QOS_GetStatistics(ENET_QOS_Type *base, enet_qos_transfer_stats_t *statistics) | /* param base ENET_QOS peripheral base address. param statistics The statistics structure pointer. */
void ENET_QOS_GetStatistics(ENET_QOS_Type *base, enet_qos_transfer_stats_t *statistics) | {
statistics->statsRxFrameCount = base->MAC_RX_PACKETS_COUNT_GOOD_BAD;
statistics->statsRxCrcErr = base->MAC_RX_CRC_ERROR_PACKETS;
statistics->statsRxAlignErr = base->MAC_RX_ALIGNMENT_ERROR_PACKETS;
statistics->statsRxLengthErr = base->MAC_RX_LENGTH_ERROR_PACKETS;
statistics->statsRxFifoOverflowErr = base->MAC_RX_FIFO_OVERFLOW_PACKETS;
statistics->statsTxFrameCount = base->MAC_TX_PACKET_COUNT_GOOD_BAD;
statistics->statsTxFifoUnderRunErr = base->MAC_TX_UNDERFLOW_ERROR_PACKETS;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* e1000_configure - configure the hardware for Rx and Tx @adapter: private board structure */ | static void e1000_configure(struct e1000_adapter *adapter) | /* e1000_configure - configure the hardware for Rx and Tx @adapter: private board structure */
static void e1000_configure(struct e1000_adapter *adapter) | {
e1000_set_multi(adapter->netdev);
e1000_restore_vlan(adapter);
e1000_init_manageability(adapter);
e1000_configure_tx(adapter);
e1000_setup_rctl(adapter);
e1000_configure_rx(adapter);
adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns the offset of the first Marker in a FPDU where the beginning of a FPDU has an offset of 0. It also addresses possible sequence number overflows. The endpoint is either the Initiator or the Responder. */ | static guint32 get_first_marker_offset(mpa_state_t *state, struct tcpinfo *tcpinfo, guint8 endpoint) | /* Returns the offset of the first Marker in a FPDU where the beginning of a FPDU has an offset of 0. It also addresses possible sequence number overflows. The endpoint is either the Initiator or the Responder. */
static guint32 get_first_marker_offset(mpa_state_t *state, struct tcpinfo *tcpinfo, guint8 endpoint) | {
guint32 offset = 0;
if (tcpinfo->seq > state->minfo[endpoint].seq) {
offset = (tcpinfo->seq - state->minfo[endpoint].seq)
% MPA_MARKER_INTERVAL;
}
if (tcpinfo->seq < state->minfo[endpoint].seq) {
offset = state->minfo[endpoint].seq
+ (TCP_MAX_SEQ - tcpinfo->seq) % MPA_MARKER_INTERVAL;
}
return (MPA_MARKER_INTERVAL - offset) % MPA_MARKER_INTERVAL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Enables or disables the Ultra Low Power mode. */ | void PWR_UltraLowPowerCmd(FunctionalState NewState) | /* Enables or disables the Ultra Low Power mode. */
void PWR_UltraLowPowerCmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
*(__IO uint32_t *) CR_ULP_BB = (uint32_t)NewState;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* If JumpBuffer is NULL, then ASSERT(). For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). If Value is 0, then ASSERT(). */ | VOID EFIAPI LongJump(IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, IN UINTN Value) | /* If JumpBuffer is NULL, then ASSERT(). For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT(). If Value is 0, then ASSERT(). */
VOID EFIAPI LongJump(IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, IN UINTN Value) | {
InternalAssertJumpBuffer (JumpBuffer);
ASSERT (Value != 0);
InternalLongJump (JumpBuffer, Value);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Read the ft5336 device ID, pre initialize I2C in case of need to be able to read the FT5336 device ID, and verify this is a FT5336. */ | uint16_t ft5336_ReadID(uint16_t DeviceAddr) | /* Read the ft5336 device ID, pre initialize I2C in case of need to be able to read the FT5336 device ID, and verify this is a FT5336. */
uint16_t ft5336_ReadID(uint16_t DeviceAddr) | {
volatile uint8_t ucReadId = 0;
uint8_t nbReadAttempts = 0;
uint8_t bFoundDevice = 0;
ft5336_I2C_InitializeIfRequired();
for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++)
{
ucReadId = TS_IO_Read(DeviceAddr, FT5336_CHIP_ID_REG);
if(ucReadId == FT5336_ID_VALUE)
{
bFoundDevice = 1;
}
}
return (ucReadId);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Again, this (and the write routine) are generic versions that can be overridden by the platform. This is necessary on platforms that don't support legacy I/O routing or that hard fail on legacy I/O timeouts. */ | int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size) | /* Again, this (and the write routine) are generic versions that can be overridden by the platform. This is necessary on platforms that don't support legacy I/O routing or that hard fail on legacy I/O timeouts. */
int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size) | {
int ret = size;
switch (size) {
case 1:
*val = inb(port);
break;
case 2:
*val = inw(port);
break;
case 4:
*val = inl(port);
break;
default:
ret = -EINVAL;
break;
}
return ret;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function is used for getting the count of block I/O devices that one specific block driver detects. If no device is detected, then the function will return zero. */ | EFI_STATUS EFIAPI AhciBlockIoGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices) | /* This function is used for getting the count of block I/O devices that one specific block driver detects. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI AhciBlockIoGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices) | {
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
if ((This == NULL) || (NumberBlockDevices == NULL)) {
return EFI_INVALID_PARAMETER;
}
Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2 (This);
*NumberBlockDevices = Private->ActiveDevices;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Arch-specific wrapper function for memory unmapping at run-time Unmaps memory according to the parameters provided by the caller at run-time. This function wraps the ARMv7 MMU specific implementation #__arch_mem_unmap() for the upper layers of the memory management. */ | void arch_mem_unmap(void *addr, size_t size) | /* Arch-specific wrapper function for memory unmapping at run-time Unmaps memory according to the parameters provided by the caller at run-time. This function wraps the ARMv7 MMU specific implementation #__arch_mem_unmap() for the upper layers of the memory management. */
void arch_mem_unmap(void *addr, size_t size) | {
int ret = __arch_mem_unmap(addr, size);
if (ret) {
LOG_ERR("__arch_mem_unmap() returned %d", ret);
} else {
invalidate_tlb_all();
}
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Reads up to 4 bytes of data from the serial flash. The location of the read needs to be specified prior to calling this by issuing the appropriate commands to the serial flash. */ | static int sf1_read(struct adapter *adapter, unsigned int byte_cnt, int cont, u32 *valp) | /* Reads up to 4 bytes of data from the serial flash. The location of the read needs to be specified prior to calling this by issuing the appropriate commands to the serial flash. */
static int sf1_read(struct adapter *adapter, unsigned int byte_cnt, int cont, u32 *valp) | {
int ret;
if (!byte_cnt || byte_cnt > 4)
return -EINVAL;
if (t3_read_reg(adapter, A_SF_OP) & F_BUSY)
return -EBUSY;
t3_write_reg(adapter, A_SF_OP, V_CONT(cont) | V_BYTECNT(byte_cnt - 1));
ret = t3_wait_op_done(adapter, A_SF_OP, F_BUSY, 0, SF_ATTEMPTS, 10);
if (!ret)
*valp = t3_read_reg(adapter, A_SF_DATA);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets or clears the selected data port bit. */ | void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal) | /* Sets or clears the selected data port bit. */
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal) | {
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
GPIOx->BSRR = GPIO_Pin;
}
else
{
GPIOx->BRR = GPIO_Pin ;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This API is used to get the pressure oversampling setting in the register 0xF4 bits from 2 to 4. */ | BMP280_RETURN_FUNCTION_TYPE bmp280_get_oversamp_pressure(u8 *v_value_u8) | /* This API is used to get the pressure oversampling setting in the register 0xF4 bits from 2 to 4. */
BMP280_RETURN_FUNCTION_TYPE bmp280_get_oversamp_pressure(u8 *v_value_u8) | {
BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR;
u8 v_data_u8 = BMP280_INIT_VALUE;
if (p_bmp280 == BMP280_NULL) {
com_rslt = E_BMP280_NULL_PTR;
} else {
com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->dev_addr,
BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE__REG,
&v_data_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH);
*v_value_u8 = BMP280_GET_BITSLICE(v_data_u8,
BMP280_CTRL_MEAS_REG_OVERSAMP_PRESSURE);
p_bmp280->oversamp_pressure = *v_value_u8;
}
return com_rslt;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Open LIN mode on the specified UART.
The */ | void UARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig) | /* Open LIN mode on the specified UART.
The */
void UARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig) | {
xASSERT(UARTBaseValid(ulBase));
xASSERT((ulConfig&UART_CONFIG_BKFL_MASK)<16);
UARTConfigSetExpClk(ulBase, ulBaud,
UART_CONFIG_WLEN_8 |
UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE);
UARTEnableLIN(ulBase);
xHWREG(ulBase + UART_LIN_BCNT) = (ulConfig);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Given a desired number of PAGE_CACHE_SIZE readahead pages, return a sensible upper limit. */ | unsigned long max_sane_readahead(unsigned long nr) | /* Given a desired number of PAGE_CACHE_SIZE readahead pages, return a sensible upper limit. */
unsigned long max_sane_readahead(unsigned long nr) | {
return min(nr, (node_page_state(numa_node_id(), NR_INACTIVE_FILE)
+ node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Apply the replay tree. Returns zero in case of success and a negative error code in case of failure. */ | static int apply_replay_tree(struct ubifs_info *c) | /* Apply the replay tree. Returns zero in case of success and a negative error code in case of failure. */
static int apply_replay_tree(struct ubifs_info *c) | {
struct rb_node *this = rb_first(&c->replay_tree);
while (this) {
struct replay_entry *r;
int err;
cond_resched();
r = rb_entry(this, struct replay_entry, rb);
err = apply_replay_entry(c, r);
if (err)
return err;
this = rb_next(this);
}
return 0;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Called to determine if the pdu is a TERMINATE_IND */ | int ble_ll_ctrl_is_terminate_ind(uint8_t hdr, uint8_t opcode) | /* Called to determine if the pdu is a TERMINATE_IND */
int ble_ll_ctrl_is_terminate_ind(uint8_t hdr, uint8_t opcode) | {
int rc;
rc = 0;
if ((hdr & BLE_LL_DATA_HDR_LLID_MASK) == BLE_LL_LLID_CTRL) {
if (opcode == BLE_LL_CTRL_TERMINATE_IND) {
rc = 1;
}
}
return rc;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Schedules the AP tasklet using a high resolution timer. */ | static enum hrtimer_restart ap_poll_timeout(struct hrtimer *) | /* Schedules the AP tasklet using a high resolution timer. */
static enum hrtimer_restart ap_poll_timeout(struct hrtimer *) | {
tasklet_schedule(&ap_tasklet);
return HRTIMER_NORESTART;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Deinitializes the EXTI registers to their default reset value. */ | void EXTI_DeInit(void) | /* Deinitializes the EXTI registers to their default reset value. */
void EXTI_DeInit(void) | {
EXTI->CR1 = EXTI_CR1_RESET_VALUE;
EXTI->CR2 = EXTI_CR2_RESET_VALUE;
EXTI->CR3 = EXTI_CR3_RESET_VALUE;
EXTI->CR4 = EXTI_CR4_RESET_VALUE;
EXTI->SR1 = 0xFF;
EXTI->SR2 = 0xFF;
EXTI->CONF1 = EXTI_CONF1_RESET_VALUE;
EXTI->CONF2 = EXTI_CONF2_RESET_VALUE;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Gets a data element from the SPI interface. */ | void SPIDataRead(unsigned long ulBase, void *pulRData, unsigned long ulLen) | /* Gets a data element from the SPI interface. */
void SPIDataRead(unsigned long ulBase, void *pulRData, unsigned long ulLen) | {
unsigned long i;
unsigned char ucBitLength = SPIBitLengthGet(ulBase);
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
for (i=0; i<ulLen; i++)
{
if (ucBitLength <= 8)
{
((unsigned char*)pulRData)[i] =
SPISingleDataReadWrite(ulBase, 0xFF);
}
else if (ucBitLength >= 8 && ucBitLength <= 16)
{
((unsigned short*)pulRData)[i] =
SPISingleDataReadWrite(ulBase, 0xFFFF);
}
else
{
((unsigned long*)pulRData)[i] =
SPISingleDataReadWrite(ulBase, 0xFFFFFF);
}
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Before you start, select your target, on the right of the "Load" button */ | int main(void) | /* Before you start, select your target, on the right of the "Load" button */
int main(void) | {
TM_DISCO_LedOn(LED_RED);
} else {
TM_DISCO_LedOn(LED_GREEN);
}
while (1) {
while (TM_DISCO_ButtonPressed());
TM_WATCHDOG_Reset();
}
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Selects the data transfer direction in bi-directional mode for the specified SPI. */ | void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction) | /* Selects the data transfer direction in bi-directional mode for the specified SPI. */
void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction) | {
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_SPI_DIRECTION(SPI_Direction));
if(SPI_Direction==SPI_Direction_Tx)
{
SPIx->GCTL |= SPI_Direction_Tx;
}
if(SPI_Direction==SPI_Direction_Rx)
{
SPIx->GCTL |= SPI_Direction_Rx;
}
if(SPI_Direction==SPI_Disable_Tx)
{
SPIx->GCTL &= SPI_Disable_Tx;
}
if(SPI_Direction==SPI_Disable_Rx)
{
SPIx->GCTL &= SPI_Disable_Rx;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Determines if the FMP device should be locked when the event specified by PcdFmpDeviceLockEventGuid is signaled. The expected result from this function is TRUE so the FMP device is always locked. A platform can choose to return FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked. */ | BOOLEAN EFIAPI CapsuleUpdatePolicyIsLockFmpDeviceAtLockEventGuidRequired(IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This) | /* Determines if the FMP device should be locked when the event specified by PcdFmpDeviceLockEventGuid is signaled. The expected result from this function is TRUE so the FMP device is always locked. A platform can choose to return FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked. */
BOOLEAN EFIAPI CapsuleUpdatePolicyIsLockFmpDeviceAtLockEventGuidRequired(IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This) | {
return IsLockFmpDeviceAtLockEventGuidRequired ();
} | tianocore/edk2 | C++ | Other | 4,240 |
/* hw - Struct containing variables accessed by shared code Assumes that the controller has previously been reset and is in a post-reset uninitialized state. Initializes multicast table, and Calls routines to setup link Leaves the transmit and receive units disabled and uninitialized. */ | int atl1e_init_hw(struct atl1e_hw *hw) | /* hw - Struct containing variables accessed by shared code Assumes that the controller has previously been reset and is in a post-reset uninitialized state. Initializes multicast table, and Calls routines to setup link Leaves the transmit and receive units disabled and uninitialized. */
int atl1e_init_hw(struct atl1e_hw *hw) | {
s32 ret_val = 0;
atl1e_init_pcie(hw);
AT_WRITE_REG(hw, REG_RX_HASH_TABLE, 0);
AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);
ret_val = atl1e_phy_init(hw);
return ret_val;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the FMC NAND ECC feature. */ | void FMC_NANDECCCmd(uint32_t FMC_Bank, FunctionalState NewState) | /* Enables or disables the FMC NAND ECC feature. */
void FMC_NANDECCCmd(uint32_t FMC_Bank, FunctionalState NewState) | {
assert_param(IS_FMC_NAND_BANK(FMC_Bank));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
if(FMC_Bank == FMC_Bank2_NAND)
{
FMC_Bank2->PCR2 |= PCR_ECCEN_SET;
}
else
{
FMC_Bank3->PCR3 |= PCR_ECCEN_SET;
}
}
else
{
if(FMC_Bank == FMC_Bank2_NAND)
{
FMC_Bank2->PCR2 &= PCR_ECCEN_RESET;
}
else
{
FMC_Bank3->PCR3 &= PCR_ECCEN_RESET;
}
}
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Caller gets one enabled AP to execute a caller-provided function. */ | EFI_STATUS MpServicesUnitTestStartupThisAP(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument) | /* Caller gets one enabled AP to execute a caller-provided function. */
EFI_STATUS MpServicesUnitTestStartupThisAP(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument) | {
return MpServices.Protocol->StartupThisAP (MpServices.Protocol, Procedure, ProcessorNumber, NULL, TimeoutInMicroSeconds, ProcedureArgument, NULL);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Initializes the timer device, include timer registers and interrupt. */ | void gtimer_init(gtimer_t *obj, uint32_t tid) | /* Initializes the timer device, include timer registers and interrupt. */
void gtimer_init(gtimer_t *obj, uint32_t tid) | {
RTIM_TimeBaseInitTypeDef TIM_InitStruct;
assert_param(tid < GTIMER_MAX);
obj->timer_id = tid;
RTIM_TimeBaseStructInit(&TIM_InitStruct);
TIM_InitStruct.TIM_Idx = (u8)tid;
TIM_InitStruct.TIM_UpdateEvent = ENABLE;
TIM_InitStruct.TIM_UpdateSource = TIM_UpdateSource_Overflow;
TIM_InitStruct.TIM_ARRProtection = ENABLE;
RTIM_TimeBaseInit(TIMx[tid], &TIM_InitStruct, TIMx_irq[tid], (IRQ_FUN) gtimer_timeout_handler, (u32)obj);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* inotify_init_watch - initialize an inotify watch @watch: watch to initialize */ | void inotify_init_watch(struct inotify_watch *watch) | /* inotify_init_watch - initialize an inotify watch @watch: watch to initialize */
void inotify_init_watch(struct inotify_watch *watch) | {
INIT_LIST_HEAD(&watch->h_list);
INIT_LIST_HEAD(&watch->i_list);
atomic_set(&watch->count, 0);
get_inotify_watch(watch);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks for changes in the position of the board joystick, sending strings to the host upon each change. */ | void CheckJoystickMovement(void) | /* Checks for changes in the position of the board joystick, sending strings to the host upon each change. */
void CheckJoystickMovement(void) | {
uint8_t JoyStatus_LCL = Joystick_GetStatus();
char* ReportString = NULL;
static bool ActionSent = false;
if (JoyStatus_LCL & JOY_UP)
ReportString = "Joystick Up\r\n";
else if (JoyStatus_LCL & JOY_DOWN)
ReportString = "Joystick Down\r\n";
else if (JoyStatus_LCL & JOY_LEFT)
ReportString = "Joystick Left\r\n";
else if (JoyStatus_LCL & JOY_RIGHT)
ReportString = "Joystick Right\r\n";
else if (JoyStatus_LCL & JOY_PRESS)
ReportString = "Joystick Pressed\r\n";
else
ActionSent = false;
if ((ReportString != NULL) && (ActionSent == false))
{
ActionSent = true;
fputs(ReportString, &USBSerialStream);
}
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* write() implementation for reset file. Reset all profiling data to zero and remove ghost nodes. */ | static ssize_t reset_write(struct file *file, const char __user *addr, size_t len, loff_t *pos) | /* write() implementation for reset file. Reset all profiling data to zero and remove ghost nodes. */
static ssize_t reset_write(struct file *file, const char __user *addr, size_t len, loff_t *pos) | {
struct gcov_node *node;
mutex_lock(&node_lock);
restart:
list_for_each_entry(node, &all_head, all) {
if (node->info)
gcov_info_reset(node->info);
else if (list_empty(&node->children)) {
remove_node(node);
goto restart;
}
}
mutex_unlock(&node_lock);
return len;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Extract the blockcount field from an on disk bmap extent record. */ | xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r) | /* Extract the blockcount field from an on disk bmap extent record. */
xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r) | {
return (xfs_filblks_t)(be64_to_cpu(r->l1) & xfs_mask64lo(21));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If HmacSha256Context is NULL, then return FALSE. If NewHmacSha256Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ | BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context) | /* If HmacSha256Context is NULL, then return FALSE. If NewHmacSha256Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context) | {
CALL_CRYPTO_SERVICE (HmacSha256Duplicate, (HmacSha256Context, NewHmacSha256Context), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Wakeup mode lets this IRQ wake the system from sleep states like "suspend to RAM". */ | int set_irq_wake(unsigned int irq, unsigned int on) | /* Wakeup mode lets this IRQ wake the system from sleep states like "suspend to RAM". */
int set_irq_wake(unsigned int irq, unsigned int on) | {
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
int ret = 0;
raw_spin_lock_irqsave(&desc->lock, flags);
if (on) {
if (desc->wake_depth++ == 0) {
ret = set_irq_wake_real(irq, on);
if (ret)
desc->wake_depth = 0;
else
desc->status |= IRQ_WAKEUP;
}
} else {
if (desc->wake_depth == 0) {
WARN(1, "Unbalanced IRQ %d wake disable\n", irq);
} else if (--desc->wake_depth == 0) {
ret = set_irq_wake_real(irq, on);
if (ret)
desc->wake_depth = 1;
else
desc->status &= ~IRQ_WAKEUP;
}
}
raw_spin_unlock_irqrestore(&desc->lock, flags);
return ret;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Return with the pointer of the previous node after act. */ | void* ramfs_ll_get_prev(ramfs_ll_t *ll, void *act) | /* Return with the pointer of the previous node after act. */
void* ramfs_ll_get_prev(ramfs_ll_t *ll, void *act) | {
void *prev = NULL;
ramfs_ll_node_t *node = act;
if (ll != NULL) {
memcpy(&prev, node + RAMFS_LL_PREV_OFFSET(ll), sizeof(void *));
}
return prev;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* clean up after reading from the cells list */ | static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) | /* clean up after reading from the cells list */
static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) | {
struct afs_cell *cell = p->private;
read_unlock(&cell->servers_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Locking Note: The rport lock is expected to be held before calling this routine */ | static void fc_rport_error_retry(struct fc_rport_priv *, struct fc_frame *) | /* Locking Note: The rport lock is expected to be held before calling this routine */
static void fc_rport_error_retry(struct fc_rport_priv *, struct fc_frame *) | {
unsigned long delay = FC_DEF_E_D_TOV;
if (PTR_ERR(fp) == -FC_EX_CLOSED)
return fc_rport_error(rdata, fp);
if (rdata->retries < rdata->local_port->max_rport_retry_count) {
FC_RPORT_DBG(rdata, "Error %ld in state %s, retrying\n",
PTR_ERR(fp), fc_rport_state(rdata));
rdata->retries++;
if (PTR_ERR(fp) == -FC_EX_TIMEOUT)
delay = 0;
schedule_delayed_work(&rdata->retry_work, delay);
return;
}
return fc_rport_error(rdata, fp);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This is only called once at the beginning of all the conversions, all channels as a group. */ | static void adc_context_start_sampling(struct adc_context *ctx) | /* This is only called once at the beginning of all the conversions, all channels as a group. */
static void adc_context_start_sampling(struct adc_context *ctx) | {
struct adc_sam_data *data = CONTAINER_OF(ctx, struct adc_sam_data, ctx);
data->channels = ctx->sequence.channels;
adc_sam_start_conversion(data->dev);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* An active TM is being cleaned up since ITN is offline. Awaiting cleanup completion event from firmware. */ | static void bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) | /* An active TM is being cleaned up since ITN is offline. Awaiting cleanup completion event from firmware. */
static void bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event) | {
bfa_trc(tskim->bfa, event);
switch (event) {
case BFA_TSKIM_SM_DONE:
break;
case BFA_TSKIM_SM_CLEANUP_DONE:
bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
bfa_tskim_cleanup_ios(tskim);
break;
case BFA_TSKIM_SM_HWFAIL:
bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
bfa_tskim_iocdisable_ios(tskim);
bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
break;
default:
bfa_assert(0);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* options dissector. return offset pointing the next of options. (i.e. the top of the paylaod or the end of the data. */ | static int dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, gint coap_length) | /* options dissector. return offset pointing the next of options. (i.e. the top of the paylaod or the end of the data. */
static int dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, gint coap_length) | {
guint opt_num = 0;
int i;
guint8 endmarker;
for (i = 1; offset < coap_length; i++) {
offset = dissect_coap_options_main(tvb, pinfo, coap_tree,
offset, i, &opt_num, coap_length);
if (offset == -1)
return -1;
if (offset >= coap_length)
break;
endmarker = tvb_get_guint8(tvb, offset);
if (endmarker == 0xff) {
proto_tree_add_item(coap_tree, hf_coap_opt_end_marker, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
break;
}
}
return offset;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Returns 0 on success, and error code otherwise */ | static int smack_socket_connect(struct socket *sock, struct sockaddr *sap, int addrlen) | /* Returns 0 on success, and error code otherwise */
static int smack_socket_connect(struct socket *sock, struct sockaddr *sap, int addrlen) | {
if (sock->sk == NULL || sock->sk->sk_family != PF_INET)
return 0;
if (addrlen < sizeof(struct sockaddr_in))
return -EINVAL;
return smack_netlabel_send(sock->sk, (struct sockaddr_in *)sap);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Splits the given string into segments. You should call one of the macros coap_split_path() or coap_split_query() instead. */ | static size_t coap_split_path_impl(const unsigned char *s, size_t length, segment_handler_t h, void *data) | /* Splits the given string into segments. You should call one of the macros coap_split_path() or coap_split_query() instead. */
static size_t coap_split_path_impl(const unsigned char *s, size_t length, segment_handler_t h, void *data) | {
const unsigned char *p, *q;
p = q = s;
while (length > 0 && !strnchr((unsigned char *)"?#", 2, *q)) {
if (*q == '/') {
if (!dots((unsigned char *)p, q - p)) {
h((unsigned char *)p, q - p, data);
}
p = q + 1;
}
q++;
length--;
}
if (!dots((unsigned char *)p, q - p)) {
h((unsigned char *)p, q - p, data);
}
return q - s;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* This is called from fuse_handle_notify() on FUSE_NOTIFY_POLL and wakes up the poll waiters. */ | int fuse_notify_poll_wakeup(struct fuse_conn *fc, struct fuse_notify_poll_wakeup_out *outarg) | /* This is called from fuse_handle_notify() on FUSE_NOTIFY_POLL and wakes up the poll waiters. */
int fuse_notify_poll_wakeup(struct fuse_conn *fc, struct fuse_notify_poll_wakeup_out *outarg) | {
u64 kh = outarg->kh;
struct rb_node **link;
spin_lock(&fc->lock);
link = fuse_find_polled_node(fc, kh, NULL);
if (*link) {
struct fuse_file *ff;
ff = rb_entry(*link, struct fuse_file, polled_node);
wake_up_interruptible_sync(&ff->poll_wait);
}
spin_unlock(&fc->lock);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* mcs7830_phy_emit_wait() - emit PHY read/write access, wait for its execution @udev: network device to talk to @rwflag: PHY_CMD1_READ or PHY_CMD1_WRITE opcode @index: number of the PHY register to read or write Return: zero upon success, negative upon error */ | static int mcs7830_phy_emit_wait(struct usb_device *udev, uint8_t rwflag, uint8_t index) | /* mcs7830_phy_emit_wait() - emit PHY read/write access, wait for its execution @udev: network device to talk to @rwflag: PHY_CMD1_READ or PHY_CMD1_WRITE opcode @index: number of the PHY register to read or write Return: zero upon success, negative upon error */
static int mcs7830_phy_emit_wait(struct usb_device *udev, uint8_t rwflag, uint8_t index) | {
int rc;
int retry;
uint8_t cmd[2];
cmd[0] = rwflag | PHY_CMD1_PHYADDR;
cmd[1] = PHY_CMD2_PEND | (index & 0x1f);
rc = mcs7830_write_reg(udev, REG_PHY_CMD, sizeof(cmd), cmd);
if (rc < 0)
return rc;
retry = 10;
do {
rc = mcs7830_read_reg(udev, REG_PHY_CMD, sizeof(cmd), cmd);
if (rc < 0)
return rc;
if (cmd[1] & PHY_CMD2_READY)
return 0;
if (!retry--)
return -ETIMEDOUT;
mdelay(1);
} while (1);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Callback function that's called from chardevs when backend becomes writable. */ | static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond, void *opaque) | /* Callback function that's called from chardevs when backend becomes writable. */
static gboolean chr_write_unblocked(GIOChannel *chan, GIOCondition cond, void *opaque) | {
VirtConsole *vcon = opaque;
vcon->watch = 0;
virtio_serial_throttle_port(VIRTIO_SERIAL_PORT(vcon), false);
return FALSE;
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Sets the current coordinates of the cursor position */ | EFI_STATUS EFIAPI ConsoleLoggerSetCursorPosition(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Column, IN UINTN Row) | /* Sets the current coordinates of the cursor position */
EFI_STATUS EFIAPI ConsoleLoggerSetCursorPosition(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Column, IN UINTN Row) | {
EFI_STATUS Status;
CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
return (EFI_UNSUPPORTED);
}
ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
Status = ConsoleInfo->OldConOut->SetCursorPosition (
ConsoleInfo->OldConOut,
Column,
Row
);
if (!EFI_ERROR (Status)) {
ConsoleInfo->HistoryMode.CursorColumn = (INT32)Column;
ConsoleInfo->HistoryMode.CursorRow = (INT32)(ConsoleInfo->OriginalStartRow + Row);
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function allows a caller to extract the current configuration for one or more named elements from the target driver. */ | EFI_STATUS EFIAPI BootManagerExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results) | /* This function allows a caller to extract the current configuration for one or more named elements from the target driver. */
EFI_STATUS EFIAPI BootManagerExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results) | {
if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Request;
return EFI_NOT_FOUND;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Add a new head to the linked list. */ | static void* ramfs_ll_ins_head(ramfs_ll_t *ll) | /* Add a new head to the linked list. */
static void* ramfs_ll_ins_head(ramfs_ll_t *ll) | {
ramfs_ll_node_t *new = NULL;
new = ramfs_mm_alloc(ll->size + RAMFS_LL_NODE_META_SIZE);
if (new != NULL) {
ramfs_node_set_prev(ll, new, NULL);
ramfs_node_set_next(ll, new, ll->head);
if (ll->head != NULL) {
ramfs_node_set_prev(ll, ll->head, new);
}
ll->head = new;
if (ll->tail == NULL) {
ll->tail = new;
}
}
return new;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* The only special thing we need to do here is to make sure that all journal_end calls result in the superblock being marked dirty, so that sync() will call the filesystem's write_super callback if appropriate. */ | handle_t* ext3_journal_start_sb(struct super_block *sb, int nblocks) | /* The only special thing we need to do here is to make sure that all journal_end calls result in the superblock being marked dirty, so that sync() will call the filesystem's write_super callback if appropriate. */
handle_t* ext3_journal_start_sb(struct super_block *sb, int nblocks) | {
journal_t *journal;
if (sb->s_flags & MS_RDONLY)
return ERR_PTR(-EROFS);
journal = EXT3_SB(sb)->s_journal;
if (is_journal_aborted(journal)) {
ext3_abort(sb, __func__,
"Detected aborted journal");
return ERR_PTR(-EROFS);
}
return journal_start(journal, nblocks);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* sched_setscheduler - change the scheduling policy and/or RT priority of a thread. */ | int sched_setscheduler(struct task_struct *p, int policy, struct sched_param *param) | /* sched_setscheduler - change the scheduling policy and/or RT priority of a thread. */
int sched_setscheduler(struct task_struct *p, int policy, struct sched_param *param) | {
return __sched_setscheduler(p, policy, param, true);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Will be called only by the device core when all users of this of device are done. */ | void of_release_dev(struct device *dev) | /* Will be called only by the device core when all users of this of device are done. */
void of_release_dev(struct device *dev) | {
struct of_device *ofdev;
ofdev = to_of_device(dev);
of_node_put(ofdev->node);
kfree(ofdev);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns: 1 if the EA should be stuffed */ | static int ea_calc_size(struct gfs2_sbd *sdp, unsigned int nsize, size_t dsize, unsigned int *size) | /* Returns: 1 if the EA should be stuffed */
static int ea_calc_size(struct gfs2_sbd *sdp, unsigned int nsize, size_t dsize, unsigned int *size) | {
unsigned int jbsize = sdp->sd_jbsize;
*size = ALIGN(sizeof(struct gfs2_ea_header) + nsize + dsize, 8);
if (*size <= jbsize)
return 1;
*size = ALIGN(sizeof(struct gfs2_ea_header) + nsize +
(sizeof(__be64) * DIV_ROUND_UP(dsize, jbsize)), 8);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return nonzero if there is a SIGKILL that should be waking us up. Called with the siglock held. */ | static int sigkill_pending(struct task_struct *tsk) | /* Return nonzero if there is a SIGKILL that should be waking us up. Called with the siglock held. */
static int sigkill_pending(struct task_struct *tsk) | {
return sigismember(&tsk->pending.signal, SIGKILL) ||
sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* brief DMA instance 0, channel 5 IRQ handler. */ | void EDMA_0_CH5_DriverIRQHandler(void) | /* brief DMA instance 0, channel 5 IRQ handler. */
void EDMA_0_CH5_DriverIRQHandler(void) | {
EDMA_DriverIRQHandler(0U, 5U);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* alua_bus_detach - Detach device handler @sdev: device to be detached from */ | static void alua_bus_detach(struct scsi_device *sdev) | /* alua_bus_detach - Detach device handler @sdev: device to be detached from */
static void alua_bus_detach(struct scsi_device *sdev) | {
struct scsi_dh_data *scsi_dh_data;
struct alua_dh_data *h;
unsigned long flags;
spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
scsi_dh_data = sdev->scsi_dh_data;
sdev->scsi_dh_data = NULL;
spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
h = (struct alua_dh_data *) scsi_dh_data->buf;
if (h->buff && h->inq != h->buff)
kfree(h->buff);
kfree(scsi_dh_data);
module_put(THIS_MODULE);
sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", ALUA_DH_NAME);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Search our internal record of configured devices (not the XenStore) to determine if the XenBus device indicated by Node is known to the system. */ | STATIC XENBUS_PRIVATE_DATA* XenBusDeviceInitialized(IN XENBUS_DEVICE *Dev, IN CONST CHAR8 *Node) | /* Search our internal record of configured devices (not the XenStore) to determine if the XenBus device indicated by Node is known to the system. */
STATIC XENBUS_PRIVATE_DATA* XenBusDeviceInitialized(IN XENBUS_DEVICE *Dev, IN CONST CHAR8 *Node) | {
LIST_ENTRY *Entry;
XENBUS_PRIVATE_DATA *Child;
XENBUS_PRIVATE_DATA *Result;
if (IsListEmpty (&Dev->ChildList)) {
return NULL;
}
Result = NULL;
for (Entry = GetFirstNode (&Dev->ChildList);
!IsNodeAtEnd (&Dev->ChildList, Entry);
Entry = GetNextNode (&Dev->ChildList, Entry))
{
Child = XENBUS_PRIVATE_DATA_FROM_LINK (Entry);
if (!AsciiStrCmp (Child->XenBusIo.Node, Node)) {
Result = Child;
break;
}
}
return (Result);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Fills in the struct omap_sdrc_params * for each chip select. Returns 0 upon success or -1 upon failure. */ | int omap2_sdrc_get_params(unsigned long r, struct omap_sdrc_params **sdrc_cs0, struct omap_sdrc_params **sdrc_cs1) | /* Fills in the struct omap_sdrc_params * for each chip select. Returns 0 upon success or -1 upon failure. */
int omap2_sdrc_get_params(unsigned long r, struct omap_sdrc_params **sdrc_cs0, struct omap_sdrc_params **sdrc_cs1) | {
struct omap_sdrc_params *sp0, *sp1;
if (!sdrc_init_params_cs0)
return -1;
sp0 = sdrc_init_params_cs0;
sp1 = sdrc_init_params_cs1;
while (sp0->rate && sp0->rate != r) {
sp0++;
if (sdrc_init_params_cs1)
sp1++;
}
if (!sp0->rate)
return -1;
*sdrc_cs0 = sp0;
*sdrc_cs1 = sp1;
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function adds a protection domain to the global protection domain list */ | static void add_domain_to_list(struct protection_domain *domain) | /* This function adds a protection domain to the global protection domain list */
static void add_domain_to_list(struct protection_domain *domain) | {
unsigned long flags;
spin_lock_irqsave(&amd_iommu_pd_lock, flags);
list_add(&domain->list, &amd_iommu_pd_list);
spin_unlock_irqrestore(&amd_iommu_pd_lock, flags);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* USB Device Bulk In/Out Endpoint Event Callback Parameters: event: USB Device Event USBD_EVT_OUT: Output Event USBD_EVT_IN: Input Event Return Value: None */ | void USBD_BULK_EP_BULK_Event(U32 event) | /* USB Device Bulk In/Out Endpoint Event Callback Parameters: event: USB Device Event USBD_EVT_OUT: Output Event USBD_EVT_IN: Input Event Return Value: None */
void USBD_BULK_EP_BULK_Event(U32 event) | {
if (event & USBD_EVT_OUT) {
USBD_BULK_EP_BULKOUT_Event(0);
}
if (event & USBD_EVT_IN) {
USBD_BULK_EP_BULKIN_Event(0);
}
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Driver done interrupt service routine for channel 1. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */ | void XDmaPs_DoneISR_1(XDmaPs *InstPtr) | /* Driver done interrupt service routine for channel 1. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */
void XDmaPs_DoneISR_1(XDmaPs *InstPtr) | {
XDmaPs_DoneISR_n(InstPtr, 1);
} | ua1arn/hftrx | C++ | null | 69 |
/* Returns: sync count on success, 0 on failure */ | static region_t userspace_get_sync_count(struct dm_dirty_log *log) | /* Returns: sync count on success, 0 on failure */
static region_t userspace_get_sync_count(struct dm_dirty_log *log) | {
int r;
size_t rdata_size;
uint64_t sync_count;
struct log_c *lc = log->context;
rdata_size = sizeof(sync_count);
r = userspace_do_request(lc, lc->uuid, DM_ULOG_GET_SYNC_COUNT,
NULL, 0,
(char *)&sync_count, &rdata_size);
if (r)
return 0;
if (sync_count >= lc->region_count)
lc->in_sync_hint = lc->region_count;
return (region_t)sync_count;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This routine generates to the provided buffer the driver-unique EDAC report message from the specified ECC status. */ | static void ppc4xx_edac_generate_message(const struct mem_ctl_info *mci, const struct ppc4xx_ecc_status *status, char *buffer, size_t size) | /* This routine generates to the provided buffer the driver-unique EDAC report message from the specified ECC status. */
static void ppc4xx_edac_generate_message(const struct mem_ctl_info *mci, const struct ppc4xx_ecc_status *status, char *buffer, size_t size) | {
int n;
if (buffer == NULL || size == 0)
return;
n = ppc4xx_edac_generate_ecc_message(mci, status, buffer, size);
if (n < 0 || n >= size)
return;
buffer += n;
size -= n;
ppc4xx_edac_generate_plb_message(mci, status, buffer, size);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read from UART Receive Holding Register. Before reading user should check if rx is ready. */ | uint32_t uart_read(Uart *p_uart, uint8_t *puc_data) | /* Read from UART Receive Holding Register. Before reading user should check if rx is ready. */
uint32_t uart_read(Uart *p_uart, uint8_t *puc_data) | {
if ((p_uart->UART_SR & UART_SR_RXRDY) == 0)
return 1;
*puc_data = (uint8_t) p_uart->UART_RHR;
return 0;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* This function checks if a handle corresponds to the Virtio Device ID given at the VIRTIO_DEVICE_PROTOCOL level. */ | STATIC BOOLEAN EFIAPI IsVirtio(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText, IN UINT16 VirtIoDeviceId) | /* This function checks if a handle corresponds to the Virtio Device ID given at the VIRTIO_DEVICE_PROTOCOL level. */
STATIC BOOLEAN EFIAPI IsVirtio(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText, IN UINT16 VirtIoDeviceId) | {
EFI_STATUS Status;
VIRTIO_DEVICE_PROTOCOL *VirtIo;
Status = gBS->HandleProtocol (
Handle,
&gVirtioDeviceProtocolGuid,
(VOID **)&VirtIo
);
if (EFI_ERROR (Status)) {
return FALSE;
}
return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
VirtIoDeviceId);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Called to read the RSSI for a given connection handle */ | int ble_ll_conn_hci_rd_rssi(const uint8_t *cmdbuf, uint8_t len, uint8_t *rspbuf, uint8_t *rsplen) | /* Called to read the RSSI for a given connection handle */
int ble_ll_conn_hci_rd_rssi(const uint8_t *cmdbuf, uint8_t len, uint8_t *rspbuf, uint8_t *rsplen) | {
const struct ble_hci_rd_rssi_cp *cmd = (const void *) cmdbuf;
struct ble_hci_rd_rssi_rp *rsp = (void *) rspbuf;
struct ble_ll_conn_sm *connsm;
int rc;
if (len != sizeof(*cmd)) {
return BLE_ERR_INV_HCI_CMD_PARMS;
}
rsp->handle = cmd->handle;
connsm = ble_ll_conn_find_active_conn(le16toh(cmd->handle));
if (!connsm) {
rsp->rssi = 127;
rc = BLE_ERR_UNK_CONN_ID;
} else {
rsp->rssi = connsm->conn_rssi;
rc = BLE_ERR_SUCCESS;
}
*rsplen = sizeof(*rsp);
return rc;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* If there is an existing add event in the queue, it needs to be modified to have the right value for which, because the number of controllers in the system is now one less. */ | static void UpdateEventsForDeviceRemoval() | /* If there is an existing add event in the queue, it needs to be modified to have the right value for which, because the number of controllers in the system is now one less. */
static void UpdateEventsForDeviceRemoval() | {
int i, num_events;
SDL_Event *events;
SDL_bool isstack;
num_events = SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED);
if (num_events <= 0) {
return;
}
events = SDL_small_alloc(SDL_Event, num_events, &isstack);
if (!events) {
return;
}
num_events = SDL_PeepEvents(events, num_events, SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED);
for (i = 0; i < num_events; ++i) {
--events[i].jdevice.which;
}
SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0);
SDL_small_free(events, isstack);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) | /* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) | {
if(hspi->Instance==SPI1)
{
__HAL_RCC_SPI1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
HAL_NVIC_DisableIRQ(SPI1_IRQn);
}
else if(hspi->Instance==SPI2)
{
__HAL_RCC_SPI2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_2|GPIO_PIN_3);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* If no active link can be found, uses default maximum packet size. */ | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | /* If no active link can be found, uses default maximum packet size. */
u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | {
struct tipc_node *n_ptr;
struct link *l_ptr;
u32 res = MAX_PKT_DEFAULT;
if (dest == tipc_own_addr)
return MAX_MSG_SIZE;
read_lock_bh(&tipc_net_lock);
n_ptr = tipc_node_select(dest, selector);
if (n_ptr) {
tipc_node_lock(n_ptr);
l_ptr = n_ptr->active_links[selector & 1];
if (l_ptr)
res = link_max_pkt(l_ptr);
tipc_node_unlock(n_ptr);
}
read_unlock_bh(&tipc_net_lock);
return res;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Use the index to get an exchange from within an exchange pool. exches will point to an array of exchange pointers. */ | static struct fc_exch* fc_exch_ptr_get(struct fc_exch_pool *pool, u16 index) | /* Use the index to get an exchange from within an exchange pool. exches will point to an array of exchange pointers. */
static struct fc_exch* fc_exch_ptr_get(struct fc_exch_pool *pool, u16 index) | {
struct fc_exch **exches = (struct fc_exch **)(pool + 1);
return exches[index];
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns 0 if successful, anything else for an error. */ | int pci_hp_deregister(struct hotplug_slot *hotplug) | /* Returns 0 if successful, anything else for an error. */
int pci_hp_deregister(struct hotplug_slot *hotplug) | {
struct hotplug_slot *temp;
struct pci_slot *slot;
if (!hotplug)
return -ENODEV;
mutex_lock(&pci_hp_mutex);
temp = get_slot_from_name(hotplug_slot_name(hotplug));
if (temp != hotplug) {
mutex_unlock(&pci_hp_mutex);
return -ENODEV;
}
list_del(&hotplug->slot_list);
slot = hotplug->pci_slot;
fs_remove_slot(slot);
dbg("Removed slot %s from the list\n", hotplug_slot_name(hotplug));
hotplug->release(hotplug);
slot->hotplug = NULL;
pci_destroy_slot(slot);
mutex_unlock(&pci_hp_mutex);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Clear checksum and lifetime prior to signature verification. */ | static void isis_clear_checksum_lifetime(void *header) | /* Clear checksum and lifetime prior to signature verification. */
static void isis_clear_checksum_lifetime(void *header) | {
struct isis_lsp_header *header_lsp = (struct isis_lsp_header *) header;
header_lsp->checksum[0] = 0;
header_lsp->checksum[1] = 0;
header_lsp->remaining_lifetime[0] = 0;
header_lsp->remaining_lifetime[1] = 0;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.