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
|
|---|---|---|---|---|---|---|---|
/* Check to see if the ISA is supported. ISA = Instruction Set Architecture */
|
BOOLEAN CheckIsa(IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
|
/* Check to see if the ISA is supported. ISA = Instruction Set Architecture */
BOOLEAN CheckIsa(IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
|
{
return (BOOLEAN)(Isa == IsaIa32);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Retuns the USB status depending on the HAL status: */
|
USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status)
|
/* Retuns the USB status depending on the HAL status: */
USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status)
|
{
USBD_StatusTypeDef usb_status = USBD_OK;
switch (hal_status)
{
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* General errors are reported with an console message in TFShark. */
|
static void failure_message(const char *msg_format, va_list ap)
|
/* General errors are reported with an console message in TFShark. */
static void failure_message(const char *msg_format, va_list ap)
|
{
fprintf(stderr, "tfshark: ");
vfprintf(stderr, msg_format, ap);
fprintf(stderr, "\n");
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* m o v e A c t i v e T o I n a c t i v e */
|
returnValue Constraints_moveActiveToInactive(Constraints *_THIS, int number)
|
/* m o v e A c t i v e T o I n a c t i v e */
returnValue Constraints_moveActiveToInactive(Constraints *_THIS, int number)
|
{
if ( ( number < 0 ) || ( number >= _THIS->n ) )
return THROWERROR( RET_INDEX_OUT_OF_BOUNDS );
if ( Constraints_removeIndex( _THIS,Constraints_getActive( _THIS ),number ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_MOVING_BOUND_FAILED );
if ( Constraints_addIndex( _THIS,Constraints_getInactive( _THIS ),number,ST_INACTIVE ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_MOVING_BOUND_FAILED );
return SUCCESSFUL_RETURN;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Resets a network adapter and allocates the transmit and receive buffers required by the network interface; optionally, also requests allocation of additional transmit and receive buffers. */
|
EFI_STATUS EFIAPI EmuSnpInitialize(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINTN ExtraRxBufferSize OPTIONAL, IN UINTN ExtraTxBufferSize OPTIONAL)
|
/* Resets a network adapter and allocates the transmit and receive buffers required by the network interface; optionally, also requests allocation of additional transmit and receive buffers. */
EFI_STATUS EFIAPI EmuSnpInitialize(IN EFI_SIMPLE_NETWORK_PROTOCOL *This, IN UINTN ExtraRxBufferSize OPTIONAL, IN UINTN ExtraTxBufferSize OPTIONAL)
|
{
EFI_STATUS Status;
EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
Status = Private->Io->Initialize (Private->Io, ExtraRxBufferSize, ExtraTxBufferSize);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get a string descriptor Add string to USB device Get string index corresponding to a given string Writes an 8-bit value to the descriptor buffer */
|
sl_status_t sl_usbd_core_write_08b_to_descriptor_buf(uint8_t val)
|
/* Get a string descriptor Add string to USB device Get string index corresponding to a given string Writes an 8-bit value to the descriptor buffer */
sl_status_t sl_usbd_core_write_08b_to_descriptor_buf(uint8_t val)
|
{
sli_usbd_device_t *p_dev;
sl_status_t status;
p_dev = &usbd_ptr->device;
status = *(p_dev->desc_buf_status_ptr);
if (status == SL_STATUS_OK) {
usbd_core_write_to_descriptor_buf(p_dev, &val, 1u);
}
return status;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT64 EFIAPI AsmMsrBitFieldOr64(IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 OrData)
|
/* If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT64 EFIAPI AsmMsrBitFieldOr64(IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 OrData)
|
{
return AsmWriteMsr64 (
Index,
BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function completes cSHAKE-256 hash computation and retrieves the digest value into the specified memory. After this function has been called, the cSHAKE-256 context cannot be used again. cSHAKE-256 context should be already correctly initialized by */
|
BOOLEAN EFIAPI CShake256Final(IN OUT VOID *CShake256Context, OUT UINT8 *HashValue)
|
/* This function completes cSHAKE-256 hash computation and retrieves the digest value into the specified memory. After this function has been called, the cSHAKE-256 context cannot be used again. cSHAKE-256 context should be already correctly initialized by */
BOOLEAN EFIAPI CShake256Final(IN OUT VOID *CShake256Context, OUT UINT8 *HashValue)
|
{
if ((CShake256Context == NULL) || (HashValue == NULL)) {
return FALSE;
}
return (BOOLEAN)(Sha3Final ((Keccak1600_Ctx *)CShake256Context, HashValue));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This will configures the specified I2C own address2. */
|
void I2COwnAddress2Config(unsigned long ulBase, unsigned long ulDual, unsigned char ucAddress)
|
/* This will configures the specified I2C own address2. */
void I2COwnAddress2Config(unsigned long ulBase, unsigned long ulDual, unsigned char ucAddress)
|
{
xASSERT((ulBase == I2C1_BASE) || (ulBase == I2C2_BASE));
xHWREG(ulBase + I2C_OAR2) = ulDual | (ucAddress << 1);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* See "mss_ace.h" for details of how to use this function. */
|
uint32_t ACE_get_channel_count(void)
|
/* See "mss_ace.h" for details of how to use this function. */
uint32_t ACE_get_channel_count(void)
|
{
return (uint32_t)ACE_NB_OF_INPUT_CHANNELS;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Cancel aio. Since we don't reference acb in a non qemu threads, it is safe to access it here. */
|
static void qemu_rbd_aio_cancel(BlockDriverAIOCB *blockacb)
|
/* Cancel aio. Since we don't reference acb in a non qemu threads, it is safe to access it here. */
static void qemu_rbd_aio_cancel(BlockDriverAIOCB *blockacb)
|
{
RBDAIOCB *acb = (RBDAIOCB *) blockacb;
acb->cancelled = 1;
while (acb->status == -EINPROGRESS) {
qemu_aio_wait();
}
qemu_aio_release(acb);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Locks a Generic Clock channel from further configuration writes.
Locks a generic clock channel from further configuration writes. It is only possible to unlock the channel configuration through a power on reset. */
|
void system_gclk_chan_lock(const uint8_t channel)
|
/* Locks a Generic Clock channel from further configuration writes.
Locks a generic clock channel from further configuration writes. It is only possible to unlock the channel configuration through a power on reset. */
void system_gclk_chan_lock(const uint8_t channel)
|
{
system_interrupt_enter_critical_section();
GCLK->PCHCTRL[channel].reg |= GCLK_PCHCTRL_WRTLOCK | GCLK_PCHCTRL_CHEN;
system_interrupt_leave_critical_section();
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Gets the pulse width of a PWM output. */
|
uint32_t PWMPulseWidthGet(uint32_t ui32Base, uint32_t ui32PWMOut)
|
/* Gets the pulse width of a PWM output. */
uint32_t PWMPulseWidthGet(uint32_t ui32Base, uint32_t ui32PWMOut)
|
{
uint32_t ui32GenBase, ui32Reg, ui32Load;
ASSERT(ui32Base == PWM0_BASE);
ASSERT(_PWMOutValid(ui32PWMOut));
ui32GenBase = PWM_OUT_BADDR(ui32Base, ui32PWMOut);
ui32Load = HWREG(ui32GenBase + PWM_O_X_LOAD);
if (PWM_IS_OUTPUT_ODD(ui32PWMOut))
{
ui32Reg = HWREG(ui32GenBase + PWM_O_X_CMPB);
}
else
{
ui32Reg = HWREG(ui32GenBase + PWM_O_X_CMPA);
}
ui32Reg = ui32Load - ui32Reg;
if (HWREG(ui32GenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
{
ui32Reg = ui32Reg * 2;
}
return (ui32Reg);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Perform basic hardware initialization at boot.
This needs to be run at the very beginning. So the init priority has to be 0 (zero). */
|
static int atmel_samv71_init(void)
|
/* Perform basic hardware initialization at boot.
This needs to be run at the very beginning. So the init priority has to be 0 (zero). */
static int atmel_samv71_init(void)
|
{
if (CHIPID->CHIPID_CIDR != CHIP_CIDR) {
LOG_WRN("CIDR mismatch: chip = 0x%08x vs HAL = 0x%08x",
(uint32_t)CHIPID->CHIPID_CIDR, (uint32_t)CHIP_CIDR);
}
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185, published December 2016. */
|
BOOLEAN EFIAPI CryptoServiceParallelHash256HashAll(IN CONST VOID *Input, IN UINTN InputByteLen, IN UINTN BlockSize, OUT VOID *Output, IN UINTN OutputByteLen, IN CONST VOID *Customization, IN UINTN CustomByteLen)
|
/* Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185, published December 2016. */
BOOLEAN EFIAPI CryptoServiceParallelHash256HashAll(IN CONST VOID *Input, IN UINTN InputByteLen, IN UINTN BlockSize, OUT VOID *Output, IN UINTN OutputByteLen, IN CONST VOID *Customization, IN UINTN CustomByteLen)
|
{
return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Called during device stop to stop RX channel operation */
|
static void emac_stop_rxch(struct emac_priv *priv, u32 ch)
|
/* Called during device stop to stop RX channel operation */
static void emac_stop_rxch(struct emac_priv *priv, u32 ch)
|
{
struct emac_rxch *rxch = priv->rxch[ch];
if (rxch) {
rxch->teardown_pending = 1;
emac_write(EMAC_RXTEARDOWN, ch);
emac_rxch_teardown(priv, ch);
rxch->teardown_pending = 0;
emac_write(EMAC_RXINTMASKCLEAR, BIT(ch));
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat consistent between cpus (never more than 2 jiffies difference). Scheduler clock - returns current time in nanosec units. This is default implementation. Architectures and sub-architectures can override this. */
|
unsigned long long __attribute__((weak))
|
/* The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat consistent between cpus (never more than 2 jiffies difference). Scheduler clock - returns current time in nanosec units. This is default implementation. Architectures and sub-architectures can override this. */
unsigned long long __attribute__((weak))
|
{
return (unsigned long long)(jiffies - INITIAL_JIFFIES)
* (NSEC_PER_SEC / HZ);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Initializes the specified state variable. Must be called before invoking skb_seq_read() for the first time. */
|
void skb_prepare_seq_read(struct sk_buff *skb, unsigned int from, unsigned int to, struct skb_seq_state *st)
|
/* Initializes the specified state variable. Must be called before invoking skb_seq_read() for the first time. */
void skb_prepare_seq_read(struct sk_buff *skb, unsigned int from, unsigned int to, struct skb_seq_state *st)
|
{
st->lower_offset = from;
st->upper_offset = to;
st->root_skb = st->cur_skb = skb;
st->frag_idx = st->stepped_offset = 0;
st->frag_data = NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get CNTFRQ This function returns the value of the PL1 Physical Timer Counter Frequency Register (CNTFRQ). return CNTFRQ Register value */
|
static rt_uint32_t __get_cntfrq(void)
|
/* Get CNTFRQ This function returns the value of the PL1 Physical Timer Counter Frequency Register (CNTFRQ). return CNTFRQ Register value */
static rt_uint32_t __get_cntfrq(void)
|
{
rt_uint32_t result;
__get_cp(15, 0, result, 14, 0 , 0);
return result;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* param base DMA base address. param channel DMA channel. param descriptor configured DMA descriptor. */
|
void DMA_LoadChannelDescriptor(DMA_Type *base, uint32_t channel, dma_descriptor_t *descriptor)
|
/* param base DMA base address. param channel DMA channel. param descriptor configured DMA descriptor. */
void DMA_LoadChannelDescriptor(DMA_Type *base, uint32_t channel, dma_descriptor_t *descriptor)
|
{
assert(NULL != descriptor);
assert(channel < (uint32_t)FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base));
uint32_t instance = DMA_GetInstance(base);
dma_descriptor_t *channelDescriptor = (dma_descriptor_t *)(&s_dma_descriptor_table[instance][channel]);
channelDescriptor->xfercfg = descriptor->xfercfg;
channelDescriptor->srcEndAddr = descriptor->srcEndAddr;
channelDescriptor->dstEndAddr = descriptor->dstEndAddr;
channelDescriptor->linkToNextDesc = descriptor->linkToNextDesc;
base->CHANNEL[channel].XFERCFG = descriptor->xfercfg;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Configures the main PLL clock source, multiplication and division factors. */
|
void RCM_ConfigPLL1(uint32_t pllSelect, uint32_t inputDiv, uint32_t vcoMul, RCM_PLL_SYS_DIV_T sysDiv, uint32_t appDiv)
|
/* Configures the main PLL clock source, multiplication and division factors. */
void RCM_ConfigPLL1(uint32_t pllSelect, uint32_t inputDiv, uint32_t vcoMul, RCM_PLL_SYS_DIV_T sysDiv, uint32_t appDiv)
|
{
RCM->PLL1CFG_B.PLL1CLKS = pllSelect;
RCM->PLL1CFG_B.PLLB = inputDiv;
RCM->PLL1CFG_B.PLL1A = vcoMul;
RCM->PLL1CFG_B.PLL1C = sysDiv;
RCM->PLL1CFG_B.PLLD = appDiv;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but can be done using any given RLT. */
|
static void prvSetupRLT0Interrupt(void)
|
/* Sets up the periodic ISR used for the RTOS tick. This uses RLT0, but can be done using any given RLT. */
static void prvSetupRLT0Interrupt(void)
|
{
const unsigned short usReloadValue = ( unsigned short ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );
TMRLR0 = usReloadValue;
TMCSR0 = 0x041B;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* search the supplied keyring tree for a key that matches the criterion */
|
key_ref_t keyring_search(key_ref_t keyring, struct key_type *type, const char *description)
|
/* search the supplied keyring tree for a key that matches the criterion */
key_ref_t keyring_search(key_ref_t keyring, struct key_type *type, const char *description)
|
{
if (!type->match)
return ERR_PTR(-ENOKEY);
return keyring_search_aux(keyring, current->cred,
type, description, type->match);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeUint16ToInt8(IN UINT16 Operand, OUT INT8 *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint16ToInt8(IN UINT16 Operand, OUT INT8 *Result)
|
{
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (Operand <= MAX_INT8) {
*Result = (INT8)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = INT8_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Creates the MD4 Hash of the users password in NT UNICODE. */
|
void E_md4hash(const unsigned char *passwd, unsigned char *p16)
|
/* Creates the MD4 Hash of the users password in NT UNICODE. */
void E_md4hash(const unsigned char *passwd, unsigned char *p16)
|
{
int len;
__u16 wpwd[129];
if (passwd) {
len = strlen((char *) passwd);
if (len > 128)
len = 128;
_my_mbstowcs(wpwd, passwd, len);
} else
len = 0;
wpwd[len] = 0;
len = _my_wcslen(wpwd) * sizeof(__u16);
mdfour(p16, (unsigned char *) wpwd, len);
memset(wpwd, 0, 129 * 2);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the TIMx Output Compare 2 Fast feature. */
|
void TIM_OC2FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
|
/* Configures the TIMx Output Compare 2 Fast feature. */
void TIM_OC2FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
|
{
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_LIST6_PERIPH(TIMx));
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2FE);
tmpccmr1 |= (uint16_t)(TIM_OCFast << 8);
TIMx->CCMR1 = tmpccmr1;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Receives a byte that has been sent to the I2C Master. */
|
unsigned long I2CDataGet(unsigned long ulBase)
|
/* Receives a byte that has been sent to the I2C Master. */
unsigned long I2CDataGet(unsigned long ulBase)
|
{
xASSERT((ulBase == I2C0_BASE));
return(xHWREG(ulBase + I2C_DR));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Gets the error status of the I2C Master module. */
|
unsigned long I2CMasterError(unsigned long ulBase)
|
/* Gets the error status of the I2C Master module. */
unsigned long I2CMasterError(unsigned long ulBase)
|
{
unsigned long ulStatus;
xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE)));
ulStatus = (xHWREGB(ulBase + I2C_STATUS));
if((ulStatus & I2C_STATUS_RXAK))
{
return xI2C_MASTER_ERR_ADDR_ACK;
}
if((ulStatus & I2C_STATUS_RXAK))
{
return xI2C_MASTER_ERR_DATA_ACK;
}
if((ulStatus & I2C_STATUS_ARBL))
{
return xI2C_MASTER_ERR_ARB_LOST;
}
return xI2C_MASTER_ERR_NONE;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* param base ENET peripheral base address. param mask ENET interrupt source to be cleared. This is the logical OR of members of the enumeration :: enet_qos_mac_interrupt_enable_t. */
|
void ENET_QOS_ClearMacInterruptStatus(ENET_QOS_Type *base, uint32_t mask)
|
/* param base ENET peripheral base address. param mask ENET interrupt source to be cleared. This is the logical OR of members of the enumeration :: enet_qos_mac_interrupt_enable_t. */
void ENET_QOS_ClearMacInterruptStatus(ENET_QOS_Type *base, uint32_t mask)
|
{
volatile uint32_t dummy;
if ((mask & (uint32_t)kENET_QOS_MacTimestamp) != 0U)
{
dummy = base->MAC_TIMESTAMP_STATUS;
}
else if ((mask & (uint32_t)kENET_QOS_MacPmt) != 0U)
{
dummy = base->MAC_PMT_CONTROL_STATUS;
}
else
{
}
(void)dummy;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This is called to attempt to lock the buffer associated with this buf log item. Don't sleep on the buffer lock. If we can't get the lock right away, return 0. If we can get the lock, pull the buffer from the free list, mark it busy, and return 1. */
|
STATIC uint xfs_buf_item_trylock(xfs_buf_log_item_t *bip)
|
/* This is called to attempt to lock the buffer associated with this buf log item. Don't sleep on the buffer lock. If we can't get the lock right away, return 0. If we can get the lock, pull the buffer from the free list, mark it busy, and return 1. */
STATIC uint xfs_buf_item_trylock(xfs_buf_log_item_t *bip)
|
{
xfs_buf_t *bp;
bp = bip->bli_buf;
if (XFS_BUF_ISPINNED(bp)) {
return XFS_ITEM_PINNED;
}
if (!XFS_BUF_CPSEMA(bp)) {
return XFS_ITEM_LOCKED;
}
XFS_BUF_HOLD(bp);
ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
trace_xfs_buf_item_trylock(bip);
return XFS_ITEM_SUCCESS;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Read, classify, and fill other details about the next option. 'psize' is filled with option's size, 'notoalign' with its alignment requirements. Local variable 'size' gets the size to be aligned. (Kpadal option always gets its full alignment, other options are limited by the maximum alignment ('maxalign'). Kchar option needs no alignment despite its size. */
|
static KOption getdetails(Header *h, size_t totalsize, const char **fmt, int *psize, int *ntoalign)
|
/* Read, classify, and fill other details about the next option. 'psize' is filled with option's size, 'notoalign' with its alignment requirements. Local variable 'size' gets the size to be aligned. (Kpadal option always gets its full alignment, other options are limited by the maximum alignment ('maxalign'). Kchar option needs no alignment despite its size. */
static KOption getdetails(Header *h, size_t totalsize, const char **fmt, int *psize, int *ntoalign)
|
{
KOption opt = getoption(h, fmt, psize);
int align = *psize;
if (opt == Kpaddalign) {
if (**fmt == '\0' || getoption(h, fmt, &align) == Kchar || align == 0)
luaL_argerror(h->L, 1, "invalid next option for option 'X'");
}
if (align <= 1 || opt == Kchar)
*ntoalign = 0;
else {
if (align > h->maxalign)
align = h->maxalign;
if ((align & (align - 1)) != 0)
luaL_argerror(h->L, 1, "format asks for alignment not power of 2");
*ntoalign = (align - (int)(totalsize & (align - 1))) & (align - 1);
}
return opt;
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* param base Pointer to the FLEXIO_UART_Type structure. param mask Interrupt source. */
|
void FLEXIO_UART_EnableInterrupts(FLEXIO_UART_Type *base, uint32_t mask)
|
/* param base Pointer to the FLEXIO_UART_Type structure. param mask Interrupt source. */
void FLEXIO_UART_EnableInterrupts(FLEXIO_UART_Type *base, uint32_t mask)
|
{
if (mask & kFLEXIO_UART_TxDataRegEmptyInterruptEnable)
{
FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, 1U << base->shifterIndex[0]);
}
if (mask & kFLEXIO_UART_RxDataRegFullInterruptEnable)
{
FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, 1U << base->shifterIndex[1]);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* ATTENTION: Although partially referenced initdram does NOT make real use use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE is something else than 0x00000000. */
|
int checkboard(void)
|
/* ATTENTION: Although partially referenced initdram does NOT make real use use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE is something else than 0x00000000. */
int checkboard(void)
|
{
puts ("Board: CANMB\n");
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Enable the PWM output of the PWM module.
The */
|
void PWMOutputEnable(unsigned long ulBase, unsigned long ulChannel)
|
/* Enable the PWM output of the PWM module.
The */
void PWMOutputEnable(unsigned long ulBase, unsigned long ulChannel)
|
{
unsigned long ulChannelTemp;
ulChannelTemp = ulChannel;
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 5)));
xHWREG(ulBase + PWM_POEN) |= (1 << (ulChannelTemp));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Disable the irq on the current core for chips that have the EN*_W1{S,C} registers. */
|
static void octeon_irq_ciu0_disable_v2(unsigned int irq)
|
/* Disable the irq on the current core for chips that have the EN*_W1{S,C} registers. */
static void octeon_irq_ciu0_disable_v2(unsigned int irq)
|
{
int index = cvmx_get_core_num() * 2;
u64 mask = 1ull << (irq - OCTEON_IRQ_WORKQ0);
cvmx_write_csr(CVMX_CIU_INTX_EN0_W1C(index), mask);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* check 3 arrays of commands for a match in match_buf: */
|
static const struct modem_cmd* find_cmd_match(struct modem_cmd_handler_data *data)
|
/* check 3 arrays of commands for a match in match_buf: */
static const struct modem_cmd* find_cmd_match(struct modem_cmd_handler_data *data)
|
{
int j;
size_t i;
for (j = 0; j < ARRAY_SIZE(data->cmds); j++) {
if (!data->cmds[j] || data->cmds_len[j] == 0U) {
continue;
}
for (i = 0; i < data->cmds_len[j]; i++) {
if (strlen(data->cmds[j][i].cmd) == 0 ||
strncmp(data->match_buf, data->cmds[j][i].cmd,
data->cmds[j][i].cmd_len) == 0) {
return &data->cmds[j][i];
}
}
}
return NULL;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Remove a route entry and all the route caches spawn from it. */
|
EFI_STATUS Ip4DelRoute(IN OUT IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR Gateway)
|
/* Remove a route entry and all the route caches spawn from it. */
EFI_STATUS Ip4DelRoute(IN OUT IP4_ROUTE_TABLE *RtTable, IN IP4_ADDR Dest, IN IP4_ADDR Netmask, IN IP4_ADDR Gateway)
|
{
LIST_ENTRY *Head;
LIST_ENTRY *Entry;
LIST_ENTRY *Next;
IP4_ROUTE_ENTRY *RtEntry;
Head = &(RtTable->RouteArea[NetGetMaskLength (Netmask)]);
NET_LIST_FOR_EACH_SAFE (Entry, Next, Head) {
RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);
if (IP4_NET_EQUAL (RtEntry->Dest, Dest, Netmask) && (RtEntry->NextHop == Gateway)) {
Ip4PurgeRouteCache (&RtTable->Cache, (UINTN)RtEntry);
RemoveEntryList (Entry);
Ip4FreeRouteEntry (RtEntry);
RtTable->TotalNum--;
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
|
int main(void)
|
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
|
{
SetupHardware();
puts_P(PSTR(ESC_FG_CYAN "Joystick HID Parser Host Demo running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
for (;;)
{
JoystickHost_Task();
USB_USBTask();
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Get the device path info saved in the menu structure. */
|
VOID LibGetDevicePath(IN UINT16 KeyValue)
|
/* Get the device path info saved in the menu structure. */
VOID LibGetDevicePath(IN UINT16 KeyValue)
|
{
UINT16 FileOptionMask;
MENU_ENTRY *NewMenuEntry;
FILE_CONTEXT *NewFileContext;
FileOptionMask = (UINT16)(FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate;
NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask);
NewFileContext = (FILE_CONTEXT *)NewMenuEntry->VariableContext;
if (gFileExplorerPrivate.RetDevicePath != NULL) {
FreePool (gFileExplorerPrivate.RetDevicePath);
}
gFileExplorerPrivate.RetDevicePath = DuplicateDevicePath (NewFileContext->DevicePath);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* mux the pin to the gpio controller (instead of "A" or "B" peripheral), and configure it for an input. */
|
int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)
|
/* mux the pin to the gpio controller (instead of "A" or "B" peripheral), and configure it for an input. */
int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)
|
{
void __iomem *pio = pin_to_controller(pin);
unsigned mask = pin_to_mask(pin);
if (!pio)
return -EINVAL;
__raw_writel(mask, pio + PIO_IDR);
__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
__raw_writel(mask, pio + PIO_ODR);
__raw_writel(mask, pio + PIO_PER);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Locking Note: The rport lock is expected to be held before calling this routine. */
|
static void fc_rport_enter_adisc(struct fc_rport_priv *)
|
/* Locking Note: The rport lock is expected to be held before calling this routine. */
static void fc_rport_enter_adisc(struct fc_rport_priv *)
|
{
struct fc_lport *lport = rdata->local_port;
struct fc_frame *fp;
FC_RPORT_DBG(rdata, "sending ADISC from %s state\n",
fc_rport_state(rdata));
fc_rport_state_enter(rdata, RPORT_ST_ADISC);
fp = fc_frame_alloc(lport, sizeof(struct fc_els_adisc));
if (!fp) {
fc_rport_error_retry(rdata, fp);
return;
}
if (!lport->tt.elsct_send(lport, rdata->ids.port_id, fp, ELS_ADISC,
fc_rport_adisc_resp, rdata,
2 * lport->r_a_tov))
fc_rport_error_retry(rdata, NULL);
else
kref_get(&rdata->kref);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Read the current count value from the current-count register. */
|
UINT32 EFIAPI GetApicTimerCurrentCount(VOID)
|
/* Read the current count value from the current-count register. */
UINT32 EFIAPI GetApicTimerCurrentCount(VOID)
|
{
return ReadLocalApicReg (XAPIC_TIMER_CURRENT_COUNT_OFFSET);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Setup I2CMode for only pins that provide special I2C functionality. */
|
void PINSEL_SetI2CMode(uint8_t portnum, uint8_t pinnum, PinSel_I2cMode I2CMode)
|
/* Setup I2CMode for only pins that provide special I2C functionality. */
void PINSEL_SetI2CMode(uint8_t portnum, uint8_t pinnum, PinSel_I2cMode I2CMode)
|
{
uint32_t *pPIN = NULL;
pPIN = PIN_GetPointer(portnum, pinnum);
*(uint32_t *)pPIN &= ~(PINSEL_I2C_MODE_BITMASK<< PINSEL_I2C_MODE_POS);
*(uint32_t *)pPIN |= (I2CMode << PINSEL_I2C_MODE_POS);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Deinitializes the WWDG peripheral registers to their default reset values. */
|
void WWDG_DeInit(void)
|
/* Deinitializes the WWDG peripheral registers to their default reset values. */
void WWDG_DeInit(void)
|
{
RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_WWDG, ENABLE);
RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_WWDG, DISABLE);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Return true if the demo tasks are executing without error - otherwise return false. */
|
static void prvMainCheckOtherTasksAreStillRunning(void)
|
/* Return true if the demo tasks are executing without error - otherwise return false. */
static void prvMainCheckOtherTasksAreStillRunning(void)
|
{
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
{
lErrorInTask = pdTRUE;
}
if( xArePollingQueuesStillRunning() != pdTRUE )
{
lErrorInTask = pdTRUE;
}
if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
lErrorInTask = pdTRUE;
}
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
{
lErrorInTask = pdTRUE;
}
if( xAreBlockingQueuesStillRunning() != pdTRUE )
{
lErrorInTask = pdTRUE;
}
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Check whether the application's newly delivered data can be sent out. */
|
INTN TcpOnAppSend(IN OUT TCP_CB *Tcb)
|
/* Check whether the application's newly delivered data can be sent out. */
INTN TcpOnAppSend(IN OUT TCP_CB *Tcb)
|
{
switch (Tcb->State) {
case TCP_CLOSED:
return -1;
case TCP_LISTEN:
return -1;
case TCP_SYN_SENT:
case TCP_SYN_RCVD:
return 0;
case TCP_ESTABLISHED:
case TCP_CLOSE_WAIT:
TcpToSendData (Tcb, 0);
return 0;
case TCP_FIN_WAIT_1:
case TCP_FIN_WAIT_2:
case TCP_CLOSING:
case TCP_LAST_ACK:
case TCP_TIME_WAIT:
return -1;
default:
break;
}
return 0;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Fills each ADC_InitStruct member with its default value. */
|
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
|
/* Fills each ADC_InitStruct member with its default value. */
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
|
{
ADC_InitStruct->ADC_ScanConvMode = DISABLE;
ADC_InitStruct->ADC_ContinuousConvMode = DISABLE;
ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T19_TRGO;
ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStruct->ADC_NbrOfChannel = 1;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* parport_ip32_write_econtrol - write new contents to the ECR register */
|
static void parport_ip32_write_econtrol(struct parport *p, unsigned int c)
|
/* parport_ip32_write_econtrol - write new contents to the ECR register */
static void parport_ip32_write_econtrol(struct parport *p, unsigned int c)
|
{
struct parport_ip32_private * const priv = p->physport->private_data;
writeb(c, priv->regs.ecr);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The function is used to return if the provided JSON value contains a JSON object. */
|
BOOLEAN EFIAPI JsonValueIsObject(IN EDKII_JSON_VALUE Json)
|
/* The function is used to return if the provided JSON value contains a JSON object. */
BOOLEAN EFIAPI JsonValueIsObject(IN EDKII_JSON_VALUE Json)
|
{
return json_is_object ((json_t *)Json);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* (Re)insert all elements from the hash part of 'ot' into table 't'. */
|
static void reinsert(lua_State *L, Table *ot, Table *t)
|
/* (Re)insert all elements from the hash part of 'ot' into table 't'. */
static void reinsert(lua_State *L, Table *ot, Table *t)
|
{
Node *old = gnode(ot, j);
if (!isempty(gval(old))) {
TValue k;
getnodekey(L, &k, old);
luaH_set(L, t, &k, gval(old));
}
}
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* XXX - for text printing, we probably want to wrap lines at 80 characters; (PostScript printing is doing this already), and perhaps put some kind of dingbat (to use the technical term) to indicate a wrapped line, along the lines of what's done when displaying this in a window, as per Warren Young's suggestion. */
|
static gboolean follow_print_text(char *buffer, size_t nchars, gboolean is_from_server _U_, void *arg)
|
/* XXX - for text printing, we probably want to wrap lines at 80 characters; (PostScript printing is doing this already), and perhaps put some kind of dingbat (to use the technical term) to indicate a wrapped line, along the lines of what's done when displaying this in a window, as per Warren Young's suggestion. */
static gboolean follow_print_text(char *buffer, size_t nchars, gboolean is_from_server _U_, void *arg)
|
{
print_stream_t *stream = (print_stream_t *)arg;
size_t i;
char *str;
for (i = 0; i < nchars; i++) {
if (buffer[i] == '\n' || buffer[i] == '\r')
continue;
if (! g_ascii_isprint(buffer[i])) {
buffer[i] = '.';
}
}
str = (char *)g_malloc(nchars + 1);
memcpy(str, buffer, nchars);
str[nchars] = 0;
print_line(stream, 0, str);
g_free(str);
return TRUE;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Reset USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
|
void USBD_ResetEP(uint32_t EPNum)
|
/* Reset USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_ResetEP(uint32_t EPNum)
|
{
if (EPNum & 0x80) {
EPNum &= 0x0F;
protected_or(&Data1, (1 << ((EPNum * 2) + 1)));
BD[IDX(EPNum, TX, ODD)].buf_addr = (uint32_t) & (EPBuf[IDX(EPNum, TX, ODD)][0]);
BD[IDX(EPNum, TX, EVEN)].buf_addr = 0;
} else {
protected_and(&Data1, ~(1 << (EPNum * 2)));
BD[IDX(EPNum, RX, ODD)].bc = OutEpSize[EPNum];
BD[IDX(EPNum, RX, ODD)].buf_addr = (uint32_t) & (EPBuf[IDX(EPNum, RX, ODD)][0]);
BD[IDX(EPNum, RX, ODD)].stat = BD_OWN_MASK | BD_DTS_MASK;
BD[IDX(EPNum, RX, EVEN)].stat = 0;
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* To make lock name printouts unique, we calculate a unique class->name_version generation counter: */
|
static int count_matching_names(struct lock_class *new_class)
|
/* To make lock name printouts unique, we calculate a unique class->name_version generation counter: */
static int count_matching_names(struct lock_class *new_class)
|
{
struct lock_class *class;
int count = 0;
if (!new_class->name)
return 0;
list_for_each_entry(class, &all_lock_classes, lock_entry) {
if (new_class->key - new_class->subclass == class->key)
return class->name_version;
if (class->name && !strcmp(class->name, new_class->name))
count = max(count, class->name_version);
}
return count + 1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* check whether the buffer is the last node in the queue */
|
unsigned char RtbNodeIsLast(IN RTB_QUEUE_HEAD *RtkQueueHead, IN RTK_BUFFER *pRtkBuffer)
|
/* check whether the buffer is the last node in the queue */
unsigned char RtbNodeIsLast(IN RTB_QUEUE_HEAD *RtkQueueHead, IN RTK_BUFFER *pRtkBuffer)
|
{
RTK_BUFFER* pBuf;
aos_mutex_lock(&RtkQueueHead->Lock, AOS_WAIT_FOREVER);
pBuf = (RTK_BUFFER*)RtkQueueHead->List.Prev;
if(pBuf == pRtkBuffer)
{
aos_mutex_unlock(&RtkQueueHead->Lock);
return true;
}
aos_mutex_unlock(&RtkQueueHead->Lock);
return false;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Blink the current screen content.
This function will make the current screen blink. */
|
void xpro_lcd_blink_screen(void)
|
/* Blink the current screen content.
This function will make the current screen blink. */
void xpro_lcd_blink_screen(void)
|
{
slcd_disable_blink();
slcd_disable();
struct slcd_blink_config blink_config;
slcd_blink_get_config_defaults(&blink_config);
blink_config.blink_all_seg = true;
blink_config.fc = CONF_XPRO_LCD_BLINK_TIMER;
slcd_blink_set_config(&blink_config);
slcd_enable_frame_counter(CONF_XPRO_LCD_BLINK_TIMER);
slcd_enable_blink();
slcd_enable();
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Unregisters the function to be called when an interrupt occurs. */
|
void IntUnregister(uint32_t ui32Interrupt)
|
/* Unregisters the function to be called when an interrupt occurs. */
void IntUnregister(uint32_t ui32Interrupt)
|
{
ASSERT(ui32Interrupt < NUM_INTERRUPTS);
g_pfnRAMVectors[ui32Interrupt] = _IntDefaultHandler;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* edac_device_remove_main_sysfs_attributes remove any attributes to this instance's main kobject */
|
static void edac_device_remove_main_sysfs_attributes(struct edac_device_ctl_info *edac_dev)
|
/* edac_device_remove_main_sysfs_attributes remove any attributes to this instance's main kobject */
static void edac_device_remove_main_sysfs_attributes(struct edac_device_ctl_info *edac_dev)
|
{
struct edac_dev_sysfs_attribute *sysfs_attrib;
sysfs_attrib = edac_dev->sysfs_attributes;
if (sysfs_attrib) {
while (sysfs_attrib->attr.name != NULL) {
sysfs_remove_file(&edac_dev->kobj,
(struct attribute *) sysfs_attrib);
sysfs_attrib++;
}
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* RTC MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
|
/* RTC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
|
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
__HAL_RCC_RTC_ENABLE();
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Register address automatically incremented during a multiple byte access with a serial interface.. */
|
int32_t lsm6dsl_auto_increment_set(stmdev_ctx_t *ctx, uint8_t val)
|
/* Register address automatically incremented during a multiple byte access with a serial interface.. */
int32_t lsm6dsl_auto_increment_set(stmdev_ctx_t *ctx, uint8_t val)
|
{
lsm6dsl_ctrl3_c_t ctrl3_c;
int32_t ret;
ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t*)&ctrl3_c, 1);
if(ret == 0){
ctrl3_c.if_inc = val;
ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL3_C, (uint8_t*)&ctrl3_c, 1);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Returns 0 in case of success, 1 in case of failure */
|
int xmlListInsert(xmlListPtr l, void *data)
|
/* Returns 0 in case of success, 1 in case of failure */
int xmlListInsert(xmlListPtr l, void *data)
|
{
xmlLinkPtr lkPlace, lkNew;
if (l == NULL)
return(1);
lkPlace = xmlListLowerSearch(l, data);
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
if (lkNew == NULL) {
xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for new link");
return (1);
}
lkNew->data = data;
lkPlace = lkPlace->prev;
lkNew->next = lkPlace->next;
(lkPlace->next)->prev = lkNew;
lkPlace->next = lkNew;
lkNew->prev = lkPlace;
return 0;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Count leaf blocks given a range of extent records originally in btree format. */
|
STATIC void xfs_bmap_disk_count_leaves(struct xfs_mount *mp, struct xfs_btree_block *block, int numrecs, int *count)
|
/* Count leaf blocks given a range of extent records originally in btree format. */
STATIC void xfs_bmap_disk_count_leaves(struct xfs_mount *mp, struct xfs_btree_block *block, int numrecs, int *count)
|
{
int b;
xfs_bmbt_rec_t *frp;
for (b = 1; b <= numrecs; b++) {
frp = XFS_BMBT_REC_ADDR(mp, block, b);
*count += xfs_bmbt_disk_get_blockcount(frp);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If ValueA is not equal ValueB, then TRUE is returned. If ValueA is equal to ValueB, then an assert is triggered and the location of the assert provided by FunctionName, LineNumber, FileName, DescriptionA and DescriptionB are recorded and FALSE is returned. */
|
BOOLEAN EFIAPI UnitTestAssertNotEqual(IN UINT64 ValueA, IN UINT64 ValueB, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *DescriptionA, IN CONST CHAR8 *DescriptionB)
|
/* If ValueA is not equal ValueB, then TRUE is returned. If ValueA is equal to ValueB, then an assert is triggered and the location of the assert provided by FunctionName, LineNumber, FileName, DescriptionA and DescriptionB are recorded and FALSE is returned. */
BOOLEAN EFIAPI UnitTestAssertNotEqual(IN UINT64 ValueA, IN UINT64 ValueB, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *DescriptionA, IN CONST CHAR8 *DescriptionB)
|
{
CHAR8 TempStr[MAX_STRING_SIZE];
snprintf (TempStr, sizeof (TempStr), "UT_ASSERT_NOT_EQUAL(%s:%llx, %s:%llx)", DescriptionA, ValueA, DescriptionB, ValueB);
_assert_true ((ValueA != ValueB), TempStr, FileName, (INT32)LineNumber);
return (ValueA != ValueB);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This routine checks whether a removable media has been changed, and invalidates all buffer-cache-entries in that case. This is a relatively slow routine, so we have to try to minimize using it. Thus it is called only upon a 'mount' or 'open'. This is the best way of combining speed and utility, I think. People changing diskettes in the middle of an operation deserve to lose :-) */
|
int check_disk_change(struct block_device *bdev)
|
/* This routine checks whether a removable media has been changed, and invalidates all buffer-cache-entries in that case. This is a relatively slow routine, so we have to try to minimize using it. Thus it is called only upon a 'mount' or 'open'. This is the best way of combining speed and utility, I think. People changing diskettes in the middle of an operation deserve to lose :-) */
int check_disk_change(struct block_device *bdev)
|
{
struct gendisk *disk = bdev->bd_disk;
const struct block_device_operations *bdops = disk->fops;
if (!bdops->media_changed)
return 0;
if (!bdops->media_changed(bdev->bd_disk))
return 0;
flush_disk(bdev);
if (bdops->revalidate_disk)
bdops->revalidate_disk(bdev->bd_disk);
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Handle an ARP failure for a CPL_ABORT_REQ. Change it into a no RST variant and send it along. */
|
static void abort_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
|
/* Handle an ARP failure for a CPL_ABORT_REQ. Change it into a no RST variant and send it along. */
static void abort_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
|
{
struct cpl_abort_req *req = cplhdr(skb);
PDBG("%s t3cdev %p\n", __func__, dev);
req->cmd = CPL_ABORT_NO_RST;
iwch_cxgb3_ofld_send(dev, skb);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Write string to the print buffer.
This is a helper function for copying a string into the print buffer, using circular buffer indexing. */
|
static void _dbg_write_str_to_buffer(const char *str, dbg_buffer_space_t length)
|
/* Write string to the print buffer.
This is a helper function for copying a string into the print buffer, using circular buffer indexing. */
static void _dbg_write_str_to_buffer(const char *str, dbg_buffer_space_t length)
|
{
Assert(str);
while (length--) {
dbg_buffer[buffer_head++] = (uint8_t)*(str++);
buffer_head &= DBG_BUFFER_MASK;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* The function is to Enter very low power run mode or not. */
|
void SysCtlVeryLowPowerRunModeEnable(xtBoolean bEnable)
|
/* The function is to Enter very low power run mode or not. */
void SysCtlVeryLowPowerRunModeEnable(xtBoolean bEnable)
|
{
if(bEnable)
{
xHWREGB(SMC_PMPROT) |= SMC_PMPROT_AVLP;
xHWREGB(SMC_PMCTRL) &= ~SMC_PMCTRL_RUNM_M;
xHWREGB(SMC_PMCTRL) |= SMC_PMCTRL_RUNM_VLPR;
}
else
{
xHWREGB(SMC_PMPROT) &= ~SMC_PMPROT_AVLP;
xHWREGB(SMC_PMCTRL) &= ~SMC_PMCTRL_RUNM_M;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Initialize the clock system and blink a LED at a constant 1 Hz frequency. */
|
int main(void)
|
/* Initialize the clock system and blink a LED at a constant 1 Hz frequency. */
int main(void)
|
{
sysclk_init();
board_init();
if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
while (1) {
}
}
while (1) {
ioport_toggle_pin_level(EXAMPLE_LED_GPIO);
mdelay(500);
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* This action sends an I-format PDU as acknowledge to received PDUs which have not been acknowledged, yet, if there is any. By using of this action number of acknowledgements decreases, this technic is called piggy backing. Returns 0 for success, 1 otherwise. */
|
int llc_conn_ac_send_i_as_ack(struct sock *sk, struct sk_buff *skb)
|
/* This action sends an I-format PDU as acknowledge to received PDUs which have not been acknowledged, yet, if there is any. By using of this action number of acknowledgements decreases, this technic is called piggy backing. Returns 0 for success, 1 otherwise. */
int llc_conn_ac_send_i_as_ack(struct sock *sk, struct sk_buff *skb)
|
{
struct llc_sock *llc = llc_sk(sk);
if (llc->ack_must_be_send) {
llc_conn_ac_send_i_rsp_f_set_ackpf(sk, skb);
llc->ack_must_be_send = 0 ;
llc->ack_pf = 0;
} else
llc_conn_ac_send_i_cmd_p_set_0(sk, skb);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* gfs2_glock_dq_uninit - dequeue a holder from a glock and initialize it @gh: the holder structure */
|
void gfs2_glock_dq_uninit(struct gfs2_holder *gh)
|
/* gfs2_glock_dq_uninit - dequeue a holder from a glock and initialize it @gh: the holder structure */
void gfs2_glock_dq_uninit(struct gfs2_holder *gh)
|
{
gfs2_glock_dq(gh);
gfs2_holder_uninit(gh);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* OPTI: high four bits are nibble pointer.. I wonder what the low bits do? */
|
static int pirq_opti_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
|
/* OPTI: high four bits are nibble pointer.. I wonder what the low bits do? */
static int pirq_opti_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
|
{
return read_config_nybble(router, 0xb8, pirq >> 4);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Read the bad block table for all chips starting at a given page We assume that the bbt bits are in consecutive order. */
|
static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip)
|
/* Read the bad block table for all chips starting at a given page We assume that the bbt bits are in consecutive order. */
static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip)
|
{
struct nand_chip *this = mtd->priv;
int res = 0, i;
if (td->options & NAND_BBT_PERCHIP) {
int offs = 0;
for (i = 0; i < this->numchips; i++) {
if (chip == -1 || chip == i)
res = read_bbt(mtd, buf, td->pages[i],
this->chipsize >> this->bbt_erase_shift,
td, offs);
if (res)
return res;
offs += this->chipsize >> (this->bbt_erase_shift + 2);
}
} else {
res = read_bbt(mtd, buf, td->pages[0],
mtd->size >> this->bbt_erase_shift, td, 0);
if (res)
return res;
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* This function place APs in Mwait or Run loop. */
|
VOID PlaceAPInMwaitLoopOrRunLoop(IN UINT8 ApLoopMode, IN volatile UINT32 *ApStartupSignalBuffer, IN UINT8 ApTargetCState)
|
/* This function place APs in Mwait or Run loop. */
VOID PlaceAPInMwaitLoopOrRunLoop(IN UINT8 ApLoopMode, IN volatile UINT32 *ApStartupSignalBuffer, IN UINT8 ApTargetCState)
|
{
while (TRUE) {
DisableInterrupts ();
if (ApLoopMode == ApInMwaitLoop) {
AsmMonitor ((UINTN)ApStartupSignalBuffer, 0, 0);
if ((*ApStartupSignalBuffer != WAKEUP_AP_SIGNAL) && (*ApStartupSignalBuffer != MP_HAND_OFF_SIGNAL)) {
AsmMwait (ApTargetCState << 4, 0);
}
} else if (ApLoopMode == ApInRunLoop) {
CpuPause ();
} else {
ASSERT (FALSE);
}
if ((*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) || (*ApStartupSignalBuffer == MP_HAND_OFF_SIGNAL)) {
break;
}
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Disables SIR (IrDA) mode on the specified UART. */
|
void UARTDisableSIR(unsigned long ulBase)
|
/* Disables SIR (IrDA) mode on the specified UART. */
void UARTDisableSIR(unsigned long ulBase)
|
{
ASSERT(UARTBaseValid(ulBase));
HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_SIREN | UART_CTL_SIRLP);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Return: Address that can be used to access the configation space of the requested device / offset */
|
static uintptr_t set_cfg_address(struct pcie_dw_mvebu *pcie, pci_dev_t d, uint where)
|
/* Return: Address that can be used to access the configation space of the requested device / offset */
static uintptr_t set_cfg_address(struct pcie_dw_mvebu *pcie, pci_dev_t d, uint where)
|
{
uintptr_t va_address;
u32 atu_type;
if (PCI_BUS(d) == (pcie->first_busno + 1))
atu_type = PCIE_ATU_TYPE_CFG0;
else
atu_type = PCIE_ATU_TYPE_CFG1;
if (PCI_BUS(d) == pcie->first_busno) {
va_address = (uintptr_t)pcie->ctrl_base;
} else {
d = PCI_MASK_BUS(d) | (PCI_BUS(d) - pcie->first_busno);
pcie_dw_prog_outbound_atu(pcie, PCIE_ATU_REGION_INDEX0,
atu_type, (u64)pcie->cfg_base,
d << 8, pcie->cfg_size);
va_address = (uintptr_t)pcie->cfg_base;
}
va_address += where & ~0x3;
return va_address;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Seek the address of the first byte of the Ia option header. */
|
UINT8* Dhcp6SeekIaOption(IN UINT8 *Buf, IN UINT32 SeekLen, IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc)
|
/* Seek the address of the first byte of the Ia option header. */
UINT8* Dhcp6SeekIaOption(IN UINT8 *Buf, IN UINT32 SeekLen, IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc)
|
{
UINT8 *Cursor;
UINT8 *Option;
UINT16 DataLen;
UINT16 OpCode;
UINT32 IaId;
Option = NULL;
Cursor = Buf;
while (Cursor < Buf + SeekLen) {
OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
IaId = ReadUnaligned32 ((UINT32 *)(Cursor + 4));
if ((OpCode == HTONS (IaDesc->Type)) && (IaId == HTONL (IaDesc->IaId))) {
Option = Cursor;
break;
}
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4);
}
return Option;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the specified I2C software reset. */
|
void I2C_SoftwareResetCmd(I2C_TypeDef *I2Cx)
|
/* Enables or disables the specified I2C software reset. */
void I2C_SoftwareResetCmd(I2C_TypeDef *I2Cx)
|
{
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_PE);
*(__IO uint32_t *)(uint32_t)I2Cx;
I2Cx->CR1 |= I2C_CR1_PE;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* Note: this function is executed on TCP thread and should return as soon as possible. */
|
void websocket_cb(struct tcp_pcb *pcb, uint8_t *data, u16_t data_len, uint8_t mode)
|
/* Note: this function is executed on TCP thread and should return as soon as possible. */
void websocket_cb(struct tcp_pcb *pcb, uint8_t *data, u16_t data_len, uint8_t mode)
|
{
printf("[websocket_callback]:\n%.*s\n", (int) data_len, (char*) data);
uint8_t response[2];
uint16_t val;
switch (data[0]) {
case 'A':
val = sdk_system_adc_read();
break;
case 'D':
gpio_write(LED_PIN, true);
val = 0xDEAD;
break;
case 'E':
gpio_write(LED_PIN, false);
val = 0xBEEF;
break;
default:
printf("Unknown command\n");
val = 0;
break;
}
response[1] = (uint8_t) val;
response[0] = val >> 8;
websocket_write(pcb, response, 2, WS_BIN_MODE);
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* The active part of our cycle counter is only 32-bits wide, and we're treating the difference between two marks as signed. On a 1GHz box, that's about 2 seconds. */
|
void __delay(int loops)
|
/* The active part of our cycle counter is only 32-bits wide, and we're treating the difference between two marks as signed. On a 1GHz box, that's about 2 seconds. */
void __delay(int loops)
|
{
int tmp;
__asm__ __volatile__(
" rpcc %0\n"
" addl %1,%0,%1\n"
"1: rpcc %0\n"
" subl %1,%0,%0\n"
" bgt %0,1b"
: "=&r" (tmp), "=r" (loops) : "1"(loops));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* ipath_eeprom_write - writes data to the eeprom via I2C @dd: the infinipath device @eeprom_offset: where to place data @buffer: data to write @len: number of bytes to write */
|
int ipath_eeprom_write(struct ipath_devdata *dd, u8 eeprom_offset, const void *buff, int len)
|
/* ipath_eeprom_write - writes data to the eeprom via I2C @dd: the infinipath device @eeprom_offset: where to place data @buffer: data to write @len: number of bytes to write */
int ipath_eeprom_write(struct ipath_devdata *dd, u8 eeprom_offset, const void *buff, int len)
|
{
int ret;
ret = mutex_lock_interruptible(&dd->ipath_eep_lock);
if (!ret) {
ret = ipath_eeprom_internal_write(dd, eeprom_offset, buff, len);
mutex_unlock(&dd->ipath_eep_lock);
}
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The libata core provides separate functions for handling PIO and DMA programming. The architecture of the Firestar makes it easier for us to have a common function so we provide wrappers */
|
static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
|
/* The libata core provides separate functions for handling PIO and DMA programming. The architecture of the Firestar makes it easier for us to have a common function so we provide wrappers */
static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
|
{
optidma_mode_setup(ap, adev, adev->pio_mode);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Simple lookup of best MSEL and NSEL values for wanted frequency.
Not optimized. */
|
static void cgu_findMN(uint32_t wantedFreq, uint32_t *pMsel, uint32_t *pNsel)
|
/* Simple lookup of best MSEL and NSEL values for wanted frequency.
Not optimized. */
static void cgu_findMN(uint32_t wantedFreq, uint32_t *pMsel, uint32_t *pNsel)
|
{
uint32_t besterr = wantedFreq;
uint32_t m, n, f, tmp, err;
#define ABSDIFF(__a, __b) ( ((__a) < (__b)) ? ((__b) - (__a)) : ((__a) - (__b)) )
for (n = 1; n <= 4; n++) {
f = 12000000 / n;
tmp = 0;
for (m = 1; m <= 256; m++) {
tmp += f;
err = ABSDIFF(tmp, wantedFreq);
if (err == 0) {
*pMsel = m - 1;
*pNsel = n - 1;
return;
} else if (err < besterr) {
*pMsel = m - 1;
*pNsel = n - 1;
besterr = err;
}
if (tmp > wantedFreq) {
break;
}
}
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Get current temperature code from register, then calculate and calibrate it's value in degree celsius. */
|
static int get_cur_temp(struct tmu_info *info)
|
/* Get current temperature code from register, then calculate and calibrate it's value in degree celsius. */
static int get_cur_temp(struct tmu_info *info)
|
{
struct exynos5_tmu_reg *reg = info->tmu_base;
ulong start;
int cur_temp = 0;
if (info->tmu_state == TMU_STATUS_NORMAL) {
start = get_timer(0);
do {
cur_temp = readl(®->current_temp) & 0xff;
} while ((cur_temp == 0) || (get_timer(start) > 100));
}
if (cur_temp == 0)
return cur_temp;
cur_temp = cur_temp - info->te1 + info->dc_value;
return cur_temp;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* If DhContext is NULL, then return FALSE. If Prime is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI DhGenerateParameter(IN OUT VOID *DhContext, IN UINTN Generator, IN UINTN PrimeLength, OUT UINT8 *Prime)
|
/* If DhContext is NULL, then return FALSE. If Prime is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI DhGenerateParameter(IN OUT VOID *DhContext, IN UINTN Generator, IN UINTN PrimeLength, OUT UINT8 *Prime)
|
{
CALL_CRYPTO_SERVICE (DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get Redfish attribute value with the given Schema and Configure Language. */
|
EFI_STATUS RedfishPlatformConfigGetAttribute(IN CHAR8 *Schema, IN CHAR8 *Version, IN EFI_STRING ConfigureLang, OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue)
|
/* Get Redfish attribute value with the given Schema and Configure Language. */
EFI_STATUS RedfishPlatformConfigGetAttribute(IN CHAR8 *Schema, IN CHAR8 *Version, IN EFI_STRING ConfigureLang, OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue)
|
{
if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
return EFI_NOT_READY;
}
return mRedfishPlatformConfigLibPrivate.Protocol->GetAttribute (
mRedfishPlatformConfigLibPrivate.Protocol,
Schema,
Version,
ConfigureLang,
AttributeValue
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Note, we use (erase counter, physical eraseblock number) pairs as keys in the @ubi->used and @ubi->free RB-trees. */
|
static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
|
/* Note, we use (erase counter, physical eraseblock number) pairs as keys in the @ubi->used and @ubi->free RB-trees. */
static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
|
{
struct rb_node **p, *parent = NULL;
p = &root->rb_node;
while (*p) {
struct ubi_wl_entry *e1;
parent = *p;
e1 = rb_entry(parent, struct ubi_wl_entry, u.rb);
if (e->ec < e1->ec)
p = &(*p)->rb_left;
else if (e->ec > e1->ec)
p = &(*p)->rb_right;
else {
ubi_assert(e->pnum != e1->pnum);
if (e->pnum < e1->pnum)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
}
rb_link_node(&e->u.rb, parent, p);
rb_insert_color(&e->u.rb, root);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This will set vpif input to capture data from tvp514x or tvp7002. */
|
static int setup_vpif_input_path(int channel, const char *sub_dev_name)
|
/* This will set vpif input to capture data from tvp514x or tvp7002. */
static int setup_vpif_input_path(int channel, const char *sub_dev_name)
|
{
int err = 0;
int val;
if (channel != 0)
return 0;
if (!cpld_client)
return -ENXIO;
val = i2c_smbus_read_byte(cpld_client);
if (val < 0)
return val;
if (!strcmp(sub_dev_name, TVP5147_CH0) ||
!strcmp(sub_dev_name, TVP5147_CH1))
val &= TVP5147_INPUT;
else
val |= TVP7002_INPUT;
err = i2c_smbus_write_byte(cpld_client, val);
if (err)
return err;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Disable the irq on the current core for chips that have the EN*_W1{S,C} registers. */
|
static void octeon_irq_ciu1_disable_v2(unsigned int irq)
|
/* Disable the irq on the current core for chips that have the EN*_W1{S,C} registers. */
static void octeon_irq_ciu1_disable_v2(unsigned int irq)
|
{
int index = cvmx_get_core_num() * 2 + 1;
u64 mask = 1ull << (irq - OCTEON_IRQ_WDOG0);
cvmx_write_csr(CVMX_CIU_INTX_EN1_W1C(index), mask);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* APIs to access CFPA pages This routine will erase CFPA and program the CFPA page with passed data. */
|
status_t FFR_InfieldPageWrite(flash_config_t *config, uint8_t *page_data, uint32_t valid_len)
|
/* APIs to access CFPA pages This routine will erase CFPA and program the CFPA page with passed data. */
status_t FFR_InfieldPageWrite(flash_config_t *config, uint8_t *page_data, uint32_t valid_len)
|
{
assert(BOOTLOADER_API_TREE_POINTER);
return BOOTLOADER_API_TREE_POINTER->flashDriver->ffr_infield_page_write(config, page_data, valid_len);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns non-zero if the value is changed, zero if not changed. */
|
void snd_range_muldivk(const snd_interval_t *a, const snd_interval_t *b, unsigned int k, snd_interval_t *c)
|
/* Returns non-zero if the value is changed, zero if not changed. */
void snd_range_muldivk(const snd_interval_t *a, const snd_interval_t *b, unsigned int k, snd_interval_t *c)
|
{
unsigned int r;
if (a->range.empty || b->range.empty) {
snd_range_none(c);
return;
}
c->range.empty = 0;
c->range.min = muldiv32(a->range.min, b->range.min, k, &r);
c->range.openmin = (r || a->range.openmin || b->range.openmin);
c->range.max = muldiv32(a->range.max, b->range.max, k, &r);
if (r) {
c->range.max++;
c->range.openmax = 1;
} else {
c->range.openmax = (a->range.openmax || b->range.openmax);
}
c->range.integer = 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* send a string to the modem, processing for \336 (sleep 1 sec) and \335 (break signal) */
|
void zsend_break(char *cmd)
|
/* send a string to the modem, processing for \336 (sleep 1 sec) and \335 (break signal) */
void zsend_break(char *cmd)
|
{
while (*cmd++)
{
switch (*cmd)
{
case '\336':
continue;
case '\335':
rt_thread_delay(RT_TICK_PER_SECOND);
continue;
default:
zsend_line(*cmd);
break;
}
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Return the number of bytes of space available in the circular buffer. */
|
static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb)
|
/* Return the number of bytes of space available in the circular buffer. */
static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb)
|
{
if (pb == NULL)
return 0;
return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function handles RX_TIM global interrupt for Port 1. */
|
void USBPD_RX_PORT1_Interrupt_IRQHandler(void)
|
/* This function handles RX_TIM global interrupt for Port 1. */
void USBPD_RX_PORT1_Interrupt_IRQHandler(void)
|
{
RX_TIM_Interrupt_IRQHandler(1);
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Show keyboard status lights according to indicators in ConsoleIn. */
|
EFI_STATUS UpdateStatusLights(IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
|
/* Show keyboard status lights according to indicators in ConsoleIn. */
EFI_STATUS UpdateStatusLights(IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
|
{
EFI_STATUS Status;
UINT8 Command;
Status = KeyboardWrite (ConsoleIn, 0xed);
if (EFI_ERROR (Status)) {
return Status;
}
KeyboardWaitForValue (ConsoleIn, 0xfa);
Command = 0;
if (ConsoleIn->CapsLock) {
Command |= 4;
}
if (ConsoleIn->NumLock) {
Command |= 2;
}
if (ConsoleIn->ScrollLock) {
Command |= 1;
}
Status = KeyboardWrite (ConsoleIn, Command);
if (EFI_ERROR (Status)) {
return Status;
}
KeyboardWaitForValue (ConsoleIn, 0xfa);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* 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 IsLockFmpDeviceAtLockEventGuidRequired(VOID)
|
/* 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 IsLockFmpDeviceAtLockEventGuidRequired(VOID)
|
{
if (LookupCapsuleUpdatePolicyProtocol ()) {
return mCapsuleUpdatePolicy->IsLockFmpDeviceAtLockEventGuidRequired (mCapsuleUpdatePolicy);
}
return TRUE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* e1000_check_64k_bound - check that memory doesn't cross 64kB boundary @adapter: address of board private structure @start: address of beginning of memory @len: length of memory */
|
static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start, unsigned long len)
|
/* e1000_check_64k_bound - check that memory doesn't cross 64kB boundary @adapter: address of board private structure @start: address of beginning of memory @len: length of memory */
static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start, unsigned long len)
|
{
struct e1000_hw *hw = &adapter->hw;
unsigned long begin = (unsigned long)start;
unsigned long end = begin + len;
if (hw->mac_type == e1000_82545 ||
hw->mac_type == e1000_82546) {
return ((begin ^ (end - 1)) >> 16) != 0 ? false : true;
}
return true;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Add a DRM device to the DRM's device model class. We use @dev's PCI device as the parent for the Linux device, and make sure it has a file containing the driver we're using (for userspace compatibility). */
|
int drm_sysfs_device_add(struct drm_minor *minor)
|
/* Add a DRM device to the DRM's device model class. We use @dev's PCI device as the parent for the Linux device, and make sure it has a file containing the driver we're using (for userspace compatibility). */
int drm_sysfs_device_add(struct drm_minor *minor)
|
{
int err;
char *minor_str;
minor->kdev.parent = &minor->dev->pdev->dev;
minor->kdev.class = drm_class;
minor->kdev.release = drm_sysfs_device_release;
minor->kdev.devt = minor->device;
minor->kdev.type = &drm_sysfs_device_minor;
if (minor->type == DRM_MINOR_CONTROL)
minor_str = "controlD%d";
else if (minor->type == DRM_MINOR_RENDER)
minor_str = "renderD%d";
else
minor_str = "card%d";
dev_set_name(&minor->kdev, minor_str, minor->index);
err = device_register(&minor->kdev);
if (err) {
DRM_ERROR("device add failed: %d\n", err);
goto err_out;
}
return 0;
err_out:
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* @key: RSA key @num_bits: Storage for the number of public exponent bits */
|
static int num_public_exponent_bits(const struct rsa_public_key *key, int *num_bits)
|
/* @key: RSA key @num_bits: Storage for the number of public exponent bits */
static int num_public_exponent_bits(const struct rsa_public_key *key, int *num_bits)
|
{
uint64_t exponent;
int exponent_bits;
const uint max_bits = (sizeof(exponent) * 8);
exponent = key->exponent;
exponent_bits = 0;
if (!exponent) {
*num_bits = exponent_bits;
return 0;
}
for (exponent_bits = 1; exponent_bits < max_bits + 1; ++exponent_bits)
if (!(exponent >>= 1)) {
*num_bits = exponent_bits;
return 0;
}
return -EINVAL;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Read one information element - i.e. one string of byte values with one length byte in front */
|
static int diva_strace_read_ie(diva_man_var_header_t *pVar, diva_trace_ie_t *var)
|
/* Read one information element - i.e. one string of byte values with one length byte in front */
static int diva_strace_read_ie(diva_man_var_header_t *pVar, diva_trace_ie_t *var)
|
{
char* ptr = (char*)&pVar->path_length;
ptr += (pVar->path_length + 1);
var->length = *ptr;
memcpy (&var->data[0], ptr+1, *ptr);
return (0);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Reset AT24MACXX.
Send 9 clock cycles to reset memory state. */
|
void at24macxx_reset(void)
|
/* Reset AT24MACXX.
Send 9 clock cycles to reset memory state. */
void at24macxx_reset(void)
|
{
uint32_t i;
ioport_set_pin_dir(BOARD_CLK_TWIHS_EEPROM, IOPORT_DIR_OUTPUT);
ioport_set_pin_level(BOARD_CLK_TWIHS_EEPROM, 1);
ioport_enable_pin(BOARD_CLK_TWIHS_EEPROM);
for (i = 0; i < 10; i ++) {
delay_us(5);
ioport_set_pin_level(BOARD_CLK_TWIHS_EEPROM, 0);
delay_us(5);
ioport_set_pin_level(BOARD_CLK_TWIHS_EEPROM, 1);
}
ioport_set_pin_mode(BOARD_CLK_TWIHS_EEPROM, BOARD_CLK_TWIHS_MUX_EEPROM);
ioport_disable_pin(BOARD_CLK_TWIHS_EEPROM);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Release all locks held by clients accessing this host via the passed in IP address. */
|
int nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr)
|
/* Release all locks held by clients accessing this host via the passed in IP address. */
int nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr)
|
{
int ret;
ret = nlm_traverse_files(server_addr, nlmsvc_match_ip, NULL);
return ret ? -EIO : 0;
}
|
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.