repo_name
stringlengths 2
55
| dataset
stringclasses 1
value | owner
stringlengths 3
31
| lang
stringclasses 10
values | func_name
stringlengths 1
104
| code
stringlengths 20
96.7k
| docstring
stringlengths 1
4.92k
| url
stringlengths 94
241
| sha
stringlengths 40
40
|
|---|---|---|---|---|---|---|---|---|
FPGA_Library
|
github_2023
|
suisuisi
|
c
|
XIic_SetOptions
|
void XIic_SetOptions(XIic *InstancePtr, u32 NewOptions)
{
u32 CntlReg;
Xil_AssertVoid(InstancePtr != NULL);
XIic_IntrGlobalDisable(InstancePtr->BaseAddress);
/*
* Update the options in the instance and get the contents of the
* control register such that the general call option can be modified.
*/
InstancePtr->Options = NewOptions;
CntlReg = XIic_ReadReg(InstancePtr->BaseAddress, XIIC_CR_REG_OFFSET);
/*
* The general call option is the only option that maps directly to
* a hardware register feature.
*/
if (NewOptions & XII_GENERAL_CALL_OPTION) {
CntlReg |= XIIC_CR_GENERAL_CALL_MASK;
} else {
CntlReg &= ~XIIC_CR_GENERAL_CALL_MASK;
}
/*
* Write the new control register value to the register.
*/
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_CR_REG_OFFSET, CntlReg);
XIic_IntrGlobalEnable(InstancePtr->BaseAddress);
}
|
/************************** Constant Definitions ***************************/
/**************************** Type Definitions *****************************/
/***************** Macros (Inline Functions) Definitions *******************/
/************************** Function Prototypes ****************************/
/************************** Variable Definitions **************************/
/*****************************************************************************/
/**
*
* This function sets the options for the IIC device driver. The options control
* how the device behaves relative to the IIC bus. If an option applies to
* how messages are sent or received on the IIC bus, it must be set prior to
* calling functions which send or receive data.
*
* To set multiple options, the values must be ORed together. To not change
* existing options, read/modify/write with the current options using
* XIic_GetOptions().
*
* <b>USAGE EXAMPLE:</b>
*
* Read/modify/write to enable repeated start:
* <pre>
* u8 Options;
* Options = XIic_GetOptions(&Iic);
* XIic_SetOptions(&Iic, Options | XII_REPEATED_START_OPTION);
* </pre>
*
* Disabling General Call:
* <pre>
* Options = XIic_GetOptions(&Iic);
* XIic_SetOptions(&Iic, Options &= ~XII_GENERAL_CALL_OPTION);
* </pre>
*
* @param InstancePtr is a pointer to the XIic instance to be worked on.
* @param NewOptions are the options to be set. See xiic.h for a list of
* the available options.
*
* @return None.
*
* @note
*
* Sending or receiving messages with repeated start enabled, and then
* disabling repeated start, will not take effect until another master
* transaction is completed. i.e. After using repeated start, the bus will
* continue to be throttled after repeated start is disabled until a master
* transaction occurs allowing the IIC to release the bus.
* <br><br>
* Options enabled will have a 1 in its appropriate bit position.
*
****************************************************************************/
|
https://github.com/suisuisi/FPGA_Library/blob/1e33525198872d63ced48e8f0cebaa2419b9eb22/ThreePart/digilent_ip/ip/Pmods/PmodHYGRO_v1_0/drivers/PmodHYGRO_v1_0/src/xiic_options.c#L116-L147
|
1e33525198872d63ced48e8f0cebaa2419b9eb22
|
FPGA_Library
|
github_2023
|
suisuisi
|
c
|
NAV_ReadRegister
|
void NAV_ReadRegister(PmodNAV *InstancePtr, uint8_t bInst, uint8_t bAddr,
uint8_t bCntBytes, uint8_t *pData) {
u8 recv[bCntBytes + 1];
int i = 0;
for (i = 0; i < bCntBytes; i++) {
recv[i + 1] = 0;
}
// Add write bit
if (bInst == NAV_INST_AG)
recv[0] = bAddr | 0x80;
else
recv[0] = bAddr | 0xC0;
// Select a slave
XSpi_SetSlaveSelect(&InstancePtr->NAVSpi, bInst);
XSpi_Transfer(&InstancePtr->NAVSpi, recv, recv, bCntBytes + 1);
// Set chip select high
XSpi_SetSlaveSelect(&InstancePtr->NAVSpi, 0b000);
for (i = 0; i < bCntBytes; i++) {
pData[i] = recv[i + 1];
}
}
|
/* ------------------------------------------------------------ */
/*** void NAV_ReadRegister(PmodNAV *InstancePtr, uint8_t bInst, uint8_t bAddr, uint8_t bCntBytes, uint8_t *pData)
**
** Parameters:
** InstancePtr - instance of PmodNAV
** bInst - instrument Chip Select to be used: Accelerometer/Gyro,
** Magnetometer or Altimeter
** bAddr - register address to start reading bytes from
** bCntBytes - number of bytes to be read
** pData - pointer to the 16 bit data array to be read
**
** Return Value:
** None
**
** Errors:
** None
**
** Description:
** Reads bCntBytes bytes from device via SPI, from register having
** consecutive addresses, starting with bAddr.
*/
|
https://github.com/suisuisi/FPGA_Library/blob/1e33525198872d63ced48e8f0cebaa2419b9eb22/ThreePart/digilent_ip/ip/Pmods/PmodNAV_v1_0/drivers/PmodNAV_v1_0/src/PmodNAV.c#L565-L591
|
1e33525198872d63ced48e8f0cebaa2419b9eb22
|
FPGA_Library
|
github_2023
|
suisuisi
|
c
|
NAV_SetIntThresholdALT
|
void NAV_SetIntThresholdALT(PmodNAV *InstancePtr, float thVal) {
u8 buffer[2];
u16 bthVal;
// Converts the float value in gauss to raw magnetic field data to be written
// in NAV_MAG_INT_THS_L/NAV_MAG_INT_THS_H registers
bthVal = (u16) (thVal * 4096);
// Split bytes
// Make sure the first bit of the High byte is 0, for correct functionality
// of the device
buffer[0] = (bthVal & 0xFF00) >> 8;
buffer[1] = (bthVal & 0x00FF);
NAV_WriteSPI(InstancePtr, NAV_INST_ALT, NAV_ALT_THS_P_H, buffer[0]);
NAV_WriteSPI(InstancePtr, NAV_INST_ALT, NAV_ALT_THS_P_L, buffer[1]);
}
|
/* ------------------------------------------------------------ */
/*** void NAV_SetIntThresholdALT(PmodNAV *InstancePtr, float thVal)
**
** Parameters:
** InstancePtr - instance of PmodNAV
** thVal - the interrupt threshold parameter for alt instrument
**
** Return Value:
** None
**
** Errors:
** None
**
** Description:
** The function sets the interrupt threshold for the altimeter instrument
*/
|
https://github.com/suisuisi/FPGA_Library/blob/1e33525198872d63ced48e8f0cebaa2419b9eb22/ThreePart/digilent_ip/ip/Pmods/PmodNAV_v1_0/drivers/PmodNAV_v1_0/src/PmodNAV.c#L2100-L2113
|
1e33525198872d63ced48e8f0cebaa2419b9eb22
|
FPGA_Library
|
github_2023
|
suisuisi
|
c
|
DynRecvMasterData
|
static void DynRecvMasterData(XIic *InstancePtr)
{
u8 LoopCnt;
u8 BytesInFifo;
u8 BytesToRead;
u32 CntlReg;
/*
* Device is a master receiving, get the contents of the control
* register and determine the number of bytes in fifo to be read out.
*/
CntlReg = XIic_ReadReg(InstancePtr->BaseAddress, XIIC_CR_REG_OFFSET);
BytesInFifo = (u8) XIic_ReadReg(InstancePtr->BaseAddress,
XIIC_RFO_REG_OFFSET) + 1;
/*
* If data in FIFO holds all data to be retrieved - 1, set NOACK and
* disable the Tx error.
*/
if ((InstancePtr->RecvByteCount - BytesInFifo) == 1) {
/*
* Disable Tx error interrupt to prevent interrupt as this
* device will cause it when it set NO ACK next.
*/
XIic_DisableIntr(InstancePtr->BaseAddress,
XIIC_INTR_TX_ERROR_MASK);
XIic_ClearIntr(InstancePtr->BaseAddress,
XIIC_INTR_TX_ERROR_MASK);
/*
* Read one byte to clear a place for the last byte to be read
* which will set the NO ACK.
*/
XIic_ReadRecvByte(InstancePtr);
}
/*
* If data in FIFO is all the data to be received then get the data and
* also leave the device in a good state for the next transaction.
*/
else if ((InstancePtr->RecvByteCount - BytesInFifo) == 0) {
if (InstancePtr->Options & XII_REPEATED_START_OPTION) {
CntlReg |= XIIC_CR_REPEATED_START_MASK;
XIic_WriteReg(InstancePtr->BaseAddress,
XIIC_CR_REG_OFFSET,
CntlReg);
}
/*
* Read data from the FIFO then set zero based FIFO read depth
* for a byte.
*/
for (LoopCnt = 0; LoopCnt < BytesInFifo; LoopCnt++) {
XIic_ReadRecvByte(InstancePtr);
}
XIic_WriteReg(InstancePtr->BaseAddress,
XIIC_RFD_REG_OFFSET, 0);
/*
* Disable Rx full interrupt and write the control reg with ACK
* allowing next byte sent to be acknowledged automatically.
*/
XIic_DisableIntr(InstancePtr->BaseAddress,
XIIC_INTR_RX_FULL_MASK);
/*
* Send notification of msg Rx complete in RecvHandler callback.
*/
InstancePtr->RecvHandler(InstancePtr->RecvCallBackRef, 0);
}
else {
/*
* Fifo data not at n-1, read all but the last byte of data
* from the slave, if more than a FIFO full yet to receive
* read a FIFO full.
*/
BytesToRead = InstancePtr->RecvByteCount - BytesInFifo - 1;
if (BytesToRead > IIC_RX_FIFO_DEPTH) {
BytesToRead = IIC_RX_FIFO_DEPTH;
}
/*
* Read in data from the FIFO.
*/
for (LoopCnt = 0; LoopCnt < BytesToRead; LoopCnt++) {
XIic_ReadRecvByte(InstancePtr);
}
}
}
|
/*****************************************************************************/
/**
*
* This function is called when the receive register is full. The number
* of bytes received to cause the interrupt is adjustable using the Receive FIFO
* Depth register. The number of bytes in the register is read in the Receive
* FIFO occupancy register. Both these registers are zero based values (0-15)
* such that a value of zero indicates 1 byte.
*
* For a Master Receiver to properly signal the end of a message, the data must
* be read in up to the message length - 1, where control register bits will be
* set for bus controls to occur on reading of the last byte.
*
* @param InstancePtr is a pointer to the XIic instance to be worked on.
*
* @return None.
*
* @note None.
*
******************************************************************************/
|
https://github.com/suisuisi/FPGA_Library/blob/1e33525198872d63ced48e8f0cebaa2419b9eb22/ThreePart/digilent_ip/ip/Pmods/PmodRTCC_v1_0/drivers/PmodRTCC_v1_0/src/xiic_dyn_master.c#L466-L555
|
1e33525198872d63ced48e8f0cebaa2419b9eb22
|
FPGA_Library
|
github_2023
|
suisuisi
|
c
|
DynSendMasterData
|
static void DynSendMasterData(XIic *InstancePtr)
{
u32 CntlReg;
/*
* In between 1st and last byte of message, fill the FIFO with more data
* to send, disable the 1/2 empty interrupt based upon data left to
* send.
*/
if (InstancePtr->SendByteCount > 1) {
XIic_TransmitFifoFill(InstancePtr, XIIC_MASTER_ROLE);
if (InstancePtr->SendByteCount < 2) {
XIic_DisableIntr(InstancePtr->BaseAddress,
XIIC_INTR_TX_HALF_MASK);
}
}
/*
* If there is only one byte left to send, processing differs between
* repeated start and normal messages.
*/
else if (InstancePtr->SendByteCount == 1) {
/*
* When using repeated start, another interrupt is expected
* after the last byte has been sent, so the message is not
* done yet.
*/
if (InstancePtr->Options & XII_REPEATED_START_OPTION) {
XIic_WriteSendByte(InstancePtr);
} else {
XIic_DynSendStop(InstancePtr->BaseAddress,
*InstancePtr->SendBufferPtr);
/*
* Wait for bus to not be busy before declaring message
* has been sent for the no repeated start operation.
* The callback will be called from the BusNotBusy part
* of the Interrupt handler to ensure that the message
* is completely sent. Disable the Tx interrupts and
* enable the BNB interrupt.
*/
InstancePtr->BNBOnly = FALSE;
XIic_DisableIntr(InstancePtr->BaseAddress,
XIIC_TX_INTERRUPTS);
XIic_EnableIntr(InstancePtr->BaseAddress,
XIIC_INTR_BNB_MASK);
}
} else {
if (InstancePtr->Options & XII_REPEATED_START_OPTION) {
/*
* The message being sent has completed. When using
* repeated start with no more bytes to send repeated
* start needs to be set in the control register so
* that the bus will still be held by this master.
*/
CntlReg = XIic_ReadReg(InstancePtr->BaseAddress,
XIIC_CR_REG_OFFSET);
CntlReg |= XIIC_CR_REPEATED_START_MASK;
XIic_WriteReg(InstancePtr->BaseAddress,
XIIC_CR_REG_OFFSET, CntlReg);
/*
* If the message that was being sent has finished,
* disable all transmit interrupts and call the callback
* that was setup to indicate the message was sent,
* with 0 bytes remaining.
*/
XIic_DisableIntr(InstancePtr->BaseAddress,
XIIC_TX_INTERRUPTS);
InstancePtr->SendHandler(InstancePtr->SendCallBackRef,
0);
}
}
return;
}
|
/******************************************************************************
*
* When the IIC Tx FIFO/register goes empty, this routine is called by the
* interrupt service routine to fill the transmit FIFO with data to be sent.
*
* This function also is called by the Tx � empty interrupt as the data handling
* is identical when you don't assume the FIFO is empty but use the Tx_FIFO_OCY
* register to indicate the available free FIFO bytes.
*
* @param InstancePtr is a pointer to the XIic instance to be worked on.
*
* @return None.
*
* @note None.
*
******************************************************************************/
|
https://github.com/suisuisi/FPGA_Library/blob/1e33525198872d63ced48e8f0cebaa2419b9eb22/ThreePart/digilent_ip/ip/Pmods/PmodTMP3_v1_0/drivers/PmodTMP3_v1_0/src/xiic_dyn_master.c#L218-L294
|
1e33525198872d63ced48e8f0cebaa2419b9eb22
|
FPGA_Library
|
github_2023
|
suisuisi
|
c
|
WF_SecurityWpaSet
|
void WF_SecurityWpaSet(t_wpaContext* p_context)
{
#if defined(WF_ERROR_CHECKING)
uint32_t errorCode;
errorCode = UdSetSecurityWpa(p_context);
if (errorCode != UD_SUCCESS)
{
EventEnqueue(WF_EVENT_ERROR, errorCode);
return;
}
#endif /* WF_ERROR_CHECKING */
WF_SetSecurity(p_context->wpaSecurityType,
0, // not used
p_context->keyInfo.key,
p_context->keyInfo.keyLength);
}
|
//============================================================================
|
https://github.com/suisuisi/FPGA_Library/blob/1e33525198872d63ced48e8f0cebaa2419b9eb22/ThreePart/digilent_ip/ip/Pmods/PmodWIFI_v1_0/drivers/PmodWIFI_v1_0/src/MRF24G/utility/wf_connection_profile.c#L367-L384
|
1e33525198872d63ced48e8f0cebaa2419b9eb22
|
MCUViewer
|
github_2023
|
klonyyy
|
c
|
HAL_DMAEx_ConfigMuxRequestGenerator
|
HAL_StatusTypeDef HAL_DMAEx_ConfigMuxRequestGenerator(DMA_HandleTypeDef *hdma,
HAL_DMA_MuxRequestGeneratorConfigTypeDef *pRequestGeneratorConfig)
{
/* Check the parameters */
assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
assert_param(IS_DMAMUX_REQUEST_GEN_SIGNAL_ID(pRequestGeneratorConfig->SignalID));
assert_param(IS_DMAMUX_REQUEST_GEN_POLARITY(pRequestGeneratorConfig->Polarity));
assert_param(IS_DMAMUX_REQUEST_GEN_REQUEST_NUMBER(pRequestGeneratorConfig->RequestNumber));
/* check if the DMA state is ready
and DMA is using a DMAMUX request generator block
*/
if ((hdma->State == HAL_DMA_STATE_READY) && (hdma->DMAmuxRequestGen != 0U))
{
/* Process Locked */
__HAL_LOCK(hdma);
/* Set the request generator new parameters */
hdma->DMAmuxRequestGen->RGCR = pRequestGeneratorConfig->SignalID | \
((pRequestGeneratorConfig->RequestNumber - 1U) << (POSITION_VAL(DMAMUX_RGxCR_GNBREQ) & 0x1FU)) | \
pRequestGeneratorConfig->Polarity;
/* Process UnLocked */
__HAL_UNLOCK(hdma);
return HAL_OK;
}
else
{
return HAL_ERROR;
}
}
|
/**
* @brief Configure the DMAMUX request generator block used by the given DMA channel (instance).
* @param hdma: pointer to a DMA_HandleTypeDef structure that contains
* the configuration information for the specified DMA channel.
* @param pRequestGeneratorConfig : pointer to HAL_DMA_MuxRequestGeneratorConfigTypeDef :
* contains the request generator parameters.
*
* @retval HAL status
*/
|
https://github.com/klonyyy/MCUViewer/blob/3650ed7feaff963ca76abcb72423ee220cdbfa69/example/MCUViewer_test/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c#L141-L173
|
3650ed7feaff963ca76abcb72423ee220cdbfa69
|
MCUViewer
|
github_2023
|
klonyyy
|
c
|
HAL_EXTI_GetConfigLine
|
HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig)
{
__IO uint32_t *regaddr;
uint32_t regval;
uint32_t linepos;
uint32_t maskline;
uint32_t offset;
/* Check null pointer */
if ((hexti == NULL) || (pExtiConfig == NULL))
{
return HAL_ERROR;
}
/* Check the parameter */
assert_param(IS_EXTI_LINE(hexti->Line));
/* Store handle line number to configuration structure */
pExtiConfig->Line = hexti->Line;
/* Compute line register offset and line mask */
offset = ((pExtiConfig->Line & EXTI_REG_MASK) >> EXTI_REG_SHIFT);
/* Compute line position */
linepos = (pExtiConfig->Line & EXTI_PIN_MASK);
/* Compute mask */
maskline = (1uL << linepos);
/* 1] Get core mode : interrupt */
regaddr = (&EXTI->IMR1 + (EXTI_MODE_OFFSET * offset));
regval = *regaddr;
/* Check if selected line is enable */
if ((regval & maskline) != 0x00u)
{
pExtiConfig->Mode = EXTI_MODE_INTERRUPT;
}
else
{
pExtiConfig->Mode = EXTI_MODE_NONE;
}
/* Get event mode */
regaddr = (&EXTI->EMR1 + (EXTI_MODE_OFFSET * offset));
regval = *regaddr;
/* Check if selected line is enable */
if ((regval & maskline) != 0x00u)
{
pExtiConfig->Mode |= EXTI_MODE_EVENT;
}
/* Get default Trigger and GPIOSel configuration */
pExtiConfig->Trigger = EXTI_TRIGGER_NONE;
pExtiConfig->GPIOSel = 0x00u;
/* 2] Get trigger for configurable lines : rising */
if ((pExtiConfig->Line & EXTI_CONFIG) != 0x00u)
{
regaddr = (&EXTI->RTSR1 + (EXTI_CONFIG_OFFSET * offset));
regval = *regaddr;
/* Check if configuration of selected line is enable */
if ((regval & maskline) != 0x00u)
{
pExtiConfig->Trigger = EXTI_TRIGGER_RISING;
}
/* Get falling configuration */
regaddr = (&EXTI->FTSR1 + (EXTI_CONFIG_OFFSET * offset));
regval = *regaddr;
/* Check if configuration of selected line is enable */
if ((regval & maskline) != 0x00u)
{
pExtiConfig->Trigger |= EXTI_TRIGGER_FALLING;
}
/* Get Gpio port selection for gpio lines */
if ((pExtiConfig->Line & EXTI_GPIO) == EXTI_GPIO)
{
assert_param(IS_EXTI_GPIO_PIN(linepos));
regval = SYSCFG->EXTICR[linepos >> 2u];
pExtiConfig->GPIOSel = (regval >> (SYSCFG_EXTICR1_EXTI1_Pos * (linepos & 0x03u))) & SYSCFG_EXTICR1_EXTI0;
}
}
return HAL_OK;
}
|
/**
* @brief Get configuration of a dedicated Exti line.
* @param hexti Exti handle.
* @param pExtiConfig Pointer on structure to store Exti configuration.
* @retval HAL Status.
*/
|
https://github.com/klonyyy/MCUViewer/blob/3650ed7feaff963ca76abcb72423ee220cdbfa69/example/MCUViewer_test/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c#L268-L356
|
3650ed7feaff963ca76abcb72423ee220cdbfa69
|
MCUViewer
|
github_2023
|
klonyyy
|
c
|
FLASH_OB_BootLockConfig
|
static HAL_StatusTypeDef FLASH_OB_BootLockConfig(uint32_t BootLockConfig)
{
HAL_StatusTypeDef status;
/* Check the parameters */
assert_param(IS_OB_BOOT_LOCK(BootLockConfig));
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
if (status == HAL_OK)
{
MODIFY_REG(FLASH->SEC1R, FLASH_SEC1R_BOOT_LOCK, BootLockConfig);
/* Set OPTSTRT Bit */
SET_BIT(FLASH->CR, FLASH_CR_OPTSTRT);
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
}
return status;
}
|
/**
* @brief Configure the Boot Lock into Option Bytes.
* @note To configure any option bytes, the option lock bit OPTLOCK must be
* cleared with the call of HAL_FLASH_OB_Unlock() function.
* @note New option bytes configuration will be taken into account in two cases:
* - after an option bytes launch through the call of HAL_FLASH_OB_Launch()
* - after a power reset (BOR reset or exit from Standby/Shutdown modes)
* @param BootLockConfig specifies the boot lock configuration.
* This parameter can be one of the following values:
* @arg OB_BOOT_LOCK_ENABLE: Enable Boot Lock
* @arg OB_BOOT_LOCK_DISABLE: Disable Boot Lock
*
* @retval HAL_Status
*/
|
https://github.com/klonyyy/MCUViewer/blob/3650ed7feaff963ca76abcb72423ee220cdbfa69/example/MCUViewer_test/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c#L1175-L1197
|
3650ed7feaff963ca76abcb72423ee220cdbfa69
|
MCUViewer
|
github_2023
|
klonyyy
|
c
|
HAL_TIM_PWM_Start_IT
|
HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
{
HAL_StatusTypeDef status = HAL_OK;
uint32_t tmpsmcr;
/* Check the parameters */
assert_param(IS_TIM_CCX_CHANNEL(htim->Instance, Channel));
/* Check the TIM channel state */
if (TIM_CHANNEL_STATE_GET(htim, Channel) != HAL_TIM_CHANNEL_STATE_READY)
{
return HAL_ERROR;
}
/* Set the TIM channel state */
TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
switch (Channel)
{
case TIM_CHANNEL_1:
{
/* Enable the TIM Capture/Compare 1 interrupt */
__HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
break;
}
case TIM_CHANNEL_2:
{
/* Enable the TIM Capture/Compare 2 interrupt */
__HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
break;
}
case TIM_CHANNEL_3:
{
/* Enable the TIM Capture/Compare 3 interrupt */
__HAL_TIM_ENABLE_IT(htim, TIM_IT_CC3);
break;
}
case TIM_CHANNEL_4:
{
/* Enable the TIM Capture/Compare 4 interrupt */
__HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
break;
}
default:
status = HAL_ERROR;
break;
}
if (status == HAL_OK)
{
/* Enable the Capture compare channel */
TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
{
/* Enable the main output */
__HAL_TIM_MOE_ENABLE(htim);
}
/* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
{
tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
{
__HAL_TIM_ENABLE(htim);
}
}
else
{
__HAL_TIM_ENABLE(htim);
}
}
/* Return function status */
return status;
}
|
/**
* @brief Starts the PWM signal generation in interrupt mode.
* @param htim TIM PWM handle
* @param Channel TIM Channel to be enabled
* This parameter can be one of the following values:
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
* @retval HAL status
*/
|
https://github.com/klonyyy/MCUViewer/blob/3650ed7feaff963ca76abcb72423ee220cdbfa69/example/MCUViewer_test/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c#L1566-L1646
|
3650ed7feaff963ca76abcb72423ee220cdbfa69
|
MCUViewer
|
github_2023
|
klonyyy
|
c
|
HAL_TIM_IC_Stop_DMA
|
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
{
HAL_StatusTypeDef status = HAL_OK;
/* Check the parameters */
assert_param(IS_TIM_CCX_CHANNEL(htim->Instance, Channel));
assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
/* Disable the Input Capture channel */
TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
switch (Channel)
{
case TIM_CHANNEL_1:
{
/* Disable the TIM Capture/Compare 1 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
break;
}
case TIM_CHANNEL_2:
{
/* Disable the TIM Capture/Compare 2 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
break;
}
case TIM_CHANNEL_3:
{
/* Disable the TIM Capture/Compare 3 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
break;
}
case TIM_CHANNEL_4:
{
/* Disable the TIM Capture/Compare 4 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
break;
}
default:
status = HAL_ERROR;
break;
}
if (status == HAL_OK)
{
/* Disable the Peripheral */
__HAL_TIM_DISABLE(htim);
/* Set the TIM channel state */
TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
}
/* Return function status */
return status;
}
|
/**
* @brief Stops the TIM Input Capture measurement in DMA mode.
* @param htim TIM Input Capture handle
* @param Channel TIM Channels to be disabled
* This parameter can be one of the following values:
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
* @retval HAL status
*/
|
https://github.com/klonyyy/MCUViewer/blob/3650ed7feaff963ca76abcb72423ee220cdbfa69/example/MCUViewer_test/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c#L2546-L2608
|
3650ed7feaff963ca76abcb72423ee220cdbfa69
|
kui.nvim
|
github_2023
|
romgrk
|
c
|
cairo_xlib_surface_set_size
|
void
cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface,
int width,
int height)
{
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
cairo_status_t status;
if (unlikely (abstract_surface->status))
return;
if (unlikely (abstract_surface->finished)) {
_cairo_surface_set_error (abstract_surface,
_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
return;
}
if (! _cairo_surface_is_xlib (abstract_surface)) {
_cairo_surface_set_error (abstract_surface,
_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
return;
}
if (surface->width == width && surface->height == height)
return;
if (! valid_size (width, height)) {
_cairo_surface_set_error (abstract_surface,
_cairo_error (CAIRO_STATUS_INVALID_SIZE));
return;
}
status = _cairo_surface_flush (abstract_surface, 0);
if (unlikely (status)) {
_cairo_surface_set_error (abstract_surface, status);
return;
}
_cairo_xlib_surface_discard_shm (surface);
surface->width = width;
surface->height = height;
}
|
/**
* cairo_xlib_surface_set_size:
* @surface: a #cairo_surface_t for the XLib backend
* @width: the new width of the surface
* @height: the new height of the surface
*
* Informs cairo of the new size of the X Drawable underlying the
* surface. For a surface created for a Window (rather than a Pixmap),
* this function must be called each time the size of the window
* changes. (For a subwindow, you are normally resizing the window
* yourself, but for a toplevel window, it is necessary to listen for
* ConfigureNotify events.)
*
* A Pixmap can never change size, so it is never necessary to call
* this function on a surface created for a Pixmap.
*
* Since: 1.0
**/
|
https://github.com/romgrk/kui.nvim/blob/b3b2f53d6678dce86acc91043b32eab6059ce0cf/lua/kui/cairo/csrc/cairo/src/cairo-xlib-surface.c#L2090-L2131
|
b3b2f53d6678dce86acc91043b32eab6059ce0cf
|
QCVM
|
github_2023
|
erysdren
|
c
|
qcvm_set_parm_int
|
void qcvm_set_parm_int(qcvm_t *qcvm, int parm, int val)
{
GET_INT(OFS_PARM0 + (parm * 3)) = val;
}
|
/* set integer parameter */
|
https://github.com/erysdren/QCVM/blob/acd27d22c040f0636df61b4c8fb92a81e455262a/qcvm/qcvm_parameters.c#L68-L71
|
acd27d22c040f0636df61b4c8fb92a81e455262a
|
ps4-ezremote-client
|
github_2023
|
cy33hc
|
c
|
terminate_jbc
|
void terminate_jbc()
{
if (!is_jailbroken())
return;
// Restores original creds
jbc_set_cred(&g_Cred);
}
|
// Unload libjbc libraries
|
https://github.com/cy33hc/ps4-ezremote-client/blob/b7fe46cb94310f8591275d3c34107b5944137a4a/source/orbis_jbc.c#L115-L122
|
b7fe46cb94310f8591275d3c34107b5944137a4a
|
GlobalSfMpy
|
github_2023
|
zhangganlin
|
c
|
LZ4HC_Insert
|
FORCE_INLINE void LZ4HC_Insert (LZ4HC_Data_Structure* hc4, const BYTE* ip)
{
U16* chainTable = hc4->chainTable;
U32* HashTable = hc4->hashTable;
const BYTE* const base = hc4->base;
const U32 target = (U32)(ip - base);
U32 idx = hc4->nextToUpdate;
while(idx < target)
{
U32 h = LZ4HC_hashPtr(base+idx);
size_t delta = idx - HashTable[h];
if (delta>MAX_DISTANCE) delta = MAX_DISTANCE;
DELTANEXTU16(idx) = (U16)delta;
HashTable[h] = idx;
idx++;
}
hc4->nextToUpdate = target;
}
|
/* Update chains up to ip (excluded) */
|
https://github.com/zhangganlin/GlobalSfMpy/blob/ac6a0564d84e1d6e9a4077195e384d379aa20492/thirdparty/TheiaSfM/libraries/flann/src/cpp/flann/ext/lz4hc.c#L130-L149
|
ac6a0564d84e1d6e9a4077195e384d379aa20492
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
calcrate
|
static speed_t
calcrate(int baudrate)
{
#ifdef B50
if (baudrate == 50)
return B50;
#endif
#ifdef B75
if (baudrate == 75)
return B75;
#endif
#ifdef B110
if (baudrate == 110)
return B110;
#endif
#ifdef B134
if (baudrate == 134)
return B134;
#endif
#ifdef B150
if (baudrate == 150)
return B150;
#endif
#ifdef B200
if (baudrate == 200)
return B200;
#endif
#ifdef B300
if (baudrate == 300)
return B300;
#endif
#ifdef B600
if (baudrate == 600)
return B600;
#endif
#ifdef B1200
if (baudrate == 1200)
return B1200;
#endif
#ifdef B1800
if (baudrate == 1800)
return B1800;
#endif
#ifdef B2400
if (baudrate == 2400)
return B2400;
#endif
#ifdef B4800
if (baudrate == 4800)
return B4800;
#endif
#ifdef B9600
if (baudrate == 9600)
return B9600;
#endif
#ifdef B19200
else if (baudrate == 19200)
return B19200;
#endif
#ifdef B38400
else if (baudrate == 38400)
return B38400;
#endif
#ifdef B57600
else if (baudrate == 57600)
return B57600;
#endif
#ifdef B76800
else if (baudrate == 76800)
return B76800;
#endif
#ifdef B115200
else if (baudrate == 115200)
return B115200;
#endif
#ifdef B230400
else if (baudrate == 230400)
return B230400;
#endif
#ifdef B460800
else if (baudrate == 460800)
return B460800;
#endif
LOG((PI_DBG_DEV, PI_DBG_LVL_ERR,
"DEV Serial CHANGEBAUD Unable to set baud rate %d\n",
baudrate));
abort(); /* invalid baud rate */
return 0;
}
|
/***********************************************************************
*
* Function: calcrate
*
* Summary: validates the selected baudrate
*
* Paramters: buadrate
*
* Returns: POSIX defined baudrate constant or terminates the process
* if the requested baudrate is not supported.
*
***********************************************************************/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/Hotsync/unixserial.c#L649-L738
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
ListViewLoadTable
|
static void ListViewLoadTable (FormPtr frm)
{
UInt16 row;
UInt16 recordNum;
UInt16 lineHeight;
UInt16 dataHeight;
UInt16 tableHeight;
UInt16 numRows;
UInt32 uniqueID;
FontID currFont;
TablePtr table;
MemHandle recordH;
RectangleType r;
table = GetObjectPtr (ListTable);
TblGetBounds (table, &r);
tableHeight = r.extent.y;
currFont = FntSetFont (ListFont);
lineHeight = FntLineHeight ();
FntSetFont (currFont);
dataHeight = 0;
recordNum = TopVisibleRecord;
// For each row in the table, store the record number in the table item
// that will dispaly the record.
numRows = TblGetNumberOfRows (table);
for (row = 0; row < numRows; row++)
{
// Get the next record in the currunt category.
recordH = DmQueryNextInCategory (MemoDB, &recordNum, CurrentCategory);
if(row == 0)
{
// store the position of the first row so we can use TopRowPositionInCategory+row
// when drawing
TopRowPositionInCategory = recordH ? DmPositionInCategory(MemoDB, recordNum, CurrentCategory) : 0;
}
// If the record was found, store the record number in the table item,
// otherwise set the table row unusable.
if (recordH && (tableHeight >= dataHeight + lineHeight))
{
TblSetRowID (table, row, recordNum);
TblSetItemStyle (table, row, 0, customTableItem);
TblSetItemFont (table, row, 0, ListFont);
TblSetRowHeight (table, row, lineHeight);
DmRecordInfo (MemoDB, recordNum, NULL, &uniqueID, NULL);
if ((TblGetRowData (table, row) != uniqueID) ||
( ! TblRowUsable (table, row)))
{
TblSetRowUsable (table, row, true);
// Store the unique id of the record in the row.
TblSetRowData (table, row, uniqueID);
// Mark the row invalid so that it will draw when we call the
// draw routine.
TblMarkRowInvalid (table, row);
}
if (row+1 < numRows) recordNum++;
dataHeight += lineHeight;
}
else
{
// Set the row height - when scrolling winDown, the heights of the last rows of
// the table are used to determine how far to scroll. As rows are deleted
// from the top of the table, formerly unused rows scroll into view, and the
// height is used before the next call to ListViewLoadTable (which would set
// the height correctly).
TblSetRowHeight (table, row, lineHeight);
TblSetRowUsable (table, row, false);
}
}
// Update the scroll arrows.
ListViewUpdateScrollers (frm);
}
|
/***********************************************************************
*
* FUNCTION: ListViewLoadTable
*
* DESCRIPTION: This routine loads memo database records into
* the list view form.
*
* PARAMETERS: recordNum index of the first record to display.
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* art 2/16/95 Initial Revision
* grant 1/29/99 Set the heights of unused rows
* ryw 1/11/01 update global TopRowPositionInCategory on table load
*
***********************************************************************/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/MemoPad/MemoMain.c#L3046-L3132
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
duk_get_top_require_min
|
DUK_INTERNAL duk_idx_t duk_get_top_require_min(duk_hthread *thr, duk_idx_t min_top) {
duk_idx_t ret;
DUK_ASSERT_API_ENTRY(thr);
ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
if (DUK_UNLIKELY(ret < min_top)) {
DUK_ERROR_TYPE_INVALID_ARGS(thr);
DUK_WO_NORETURN(return 0;);
}
return ret;
}
|
/* Internal helper to get current top but to require a minimum top value
* (TypeError if not met).
*/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/duktape/duk_api_stack.c#L412-L423
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
duk_join
|
DUK_EXTERNAL void duk_join(duk_hthread *thr, duk_idx_t count) {
DUK_ASSERT_API_ENTRY(thr);
duk__concat_and_join_helper(thr, count, 1 /*is_join*/);
}
|
/* DUK_USE_PREFER_SIZE */
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/duktape/duk_api_string.c#L161-L165
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
duk_debug_write_uint
|
DUK_INTERNAL void duk_debug_write_uint(duk_hthread *thr, duk_uint32_t x) {
/* The debugger protocol doesn't support a plain integer encoding for
* the full 32-bit unsigned range (only 32-bit signed). For now,
* unsigned 32-bit values simply written as signed ones. This is not
* a concrete issue except for 32-bit heaphdr fields. Proper solutions
* would be to (a) write such integers as IEEE doubles or (b) add an
* unsigned 32-bit dvalue.
*/
if (x >= 0x80000000UL) {
DUK_D(DUK_DPRINT("writing unsigned integer 0x%08lx as signed integer",
(long) x));
}
duk_debug_write_int(thr, (duk_int32_t) x);
}
|
/* Write unsigned 32-bit integer. */
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/duktape/duk_debugger.c#L758-L771
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
duk__bi_mul
|
DUK_LOCAL void duk__bi_mul(duk__bigint *x, duk__bigint *y, duk__bigint *z) {
duk_small_int_t i, j, nx, nz;
DUK_ASSERT(duk__bi_is_valid(y));
DUK_ASSERT(duk__bi_is_valid(z));
nx = y->n + z->n; /* max possible */
DUK_ASSERT(nx <= DUK__BI_MAX_PARTS);
if (nx == 0) {
/* Both inputs are zero; cases where only one is zero can go
* through main algorithm.
*/
x->n = 0;
return;
}
duk_memzero((void *) x->v, (size_t) (sizeof(duk_uint32_t) * (size_t) nx));
x->n = nx;
nz = z->n;
for (i = 0; i < y->n; i++) {
#if defined(DUK_USE_64BIT_OPS)
duk_uint64_t tmp = 0U;
for (j = 0; j < nz; j++) {
tmp += (duk_uint64_t) y->v[i] * (duk_uint64_t) z->v[j] + x->v[i+j];
x->v[i+j] = (duk_uint32_t) (tmp & 0xffffffffUL);
tmp = tmp >> 32;
}
if (tmp > 0) {
DUK_ASSERT(i + j < nx);
DUK_ASSERT(i + j < DUK__BI_MAX_PARTS);
DUK_ASSERT(x->v[i+j] == 0U);
x->v[i+j] = (duk_uint32_t) tmp;
}
#else
/*
* Multiply + add + carry for 32-bit components using only 16x16->32
* multiplies and carry detection based on unsigned overflow.
*
* 1st mult, 32-bit: (A*2^16 + B)
* 2nd mult, 32-bit: (C*2^16 + D)
* 3rd add, 32-bit: E
* 4th add, 32-bit: F
*
* (AC*2^16 + B) * (C*2^16 + D) + E + F
* = AC*2^32 + AD*2^16 + BC*2^16 + BD + E + F
* = AC*2^32 + (AD + BC)*2^16 + (BD + E + F)
* = AC*2^32 + AD*2^16 + BC*2^16 + (BD + E + F)
*/
duk_uint32_t a, b, c, d, e, f;
duk_uint32_t r, s, t;
a = y->v[i]; b = a & 0xffffUL; a = a >> 16;
f = 0;
for (j = 0; j < nz; j++) {
c = z->v[j]; d = c & 0xffffUL; c = c >> 16;
e = x->v[i+j];
/* build result as: (r << 32) + s: start with (BD + E + F) */
r = 0;
s = b * d;
/* add E */
t = s + e;
if (t < s) { r++; } /* carry */
s = t;
/* add F */
t = s + f;
if (t < s) { r++; } /* carry */
s = t;
/* add BC*2^16 */
t = b * c;
r += (t >> 16);
t = s + ((t & 0xffffUL) << 16);
if (t < s) { r++; } /* carry */
s = t;
/* add AD*2^16 */
t = a * d;
r += (t >> 16);
t = s + ((t & 0xffffUL) << 16);
if (t < s) { r++; } /* carry */
s = t;
/* add AC*2^32 */
t = a * c;
r += t;
DUK_DDD(DUK_DDDPRINT("ab=%08lx cd=%08lx ef=%08lx -> rs=%08lx %08lx",
(unsigned long) y->v[i], (unsigned long) z->v[j],
(unsigned long) x->v[i+j], (unsigned long) r,
(unsigned long) s));
x->v[i+j] = s;
f = r;
}
if (f > 0U) {
DUK_ASSERT(i + j < nx);
DUK_ASSERT(i + j < DUK__BI_MAX_PARTS);
DUK_ASSERT(x->v[i+j] == 0U);
x->v[i+j] = (duk_uint32_t) f;
}
#endif /* DUK_USE_64BIT_OPS */
}
duk__bi_normalize(x);
DUK_ASSERT(duk__bi_is_valid(x));
}
|
/* x <- y * z */
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/duktape/duk_numconv.c#L396-L507
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
read_restart_marker
|
METHODDEF(boolean)
read_restart_marker (j_decompress_ptr cinfo)
{
/* Obtain a marker unless we already did. */
/* Note that next_marker will complain if it skips any data. */
if (cinfo->unread_marker == 0) {
if (! next_marker(cinfo))
return FALSE;
}
if (cinfo->unread_marker ==
((int) M_RST0 + cinfo->marker->next_restart_num)) {
/* Normal case --- swallow the marker and let entropy decoder continue */
TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
cinfo->unread_marker = 0;
} else {
/* Uh-oh, the restart markers have been messed up. */
/* Let the data source manager determine how to resync. */
if (! (*cinfo->src->resync_to_restart) (cinfo,
cinfo->marker->next_restart_num))
return FALSE;
}
/* Update next-restart state */
cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
return TRUE;
}
|
/*
* Read a restart marker, which is expected to appear next in the datastream;
* if the marker is not there, take appropriate recovery action.
* Returns FALSE if suspension is required.
*
* This is called by the entropy decoder after it has read an appropriate
* number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder
* has already read a marker from the data source. Under normal conditions
* cinfo->unread_marker will be reset to 0 before returning; if not reset,
* it holds a marker which the decoder will be unable to read past.
*/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/jpeg-8d/jdmarker.c#L1158-L1185
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
absx6502
|
void absx6502(m6502_t *m6502) {
SAVEPC = RM16(PC);
PC++;
PC++;
if (m6502_cycles[m6502->opcode] == 4)
if ((SAVEPC >> 8) != ((SAVEPC + X) >> 8))
m6502->clockticks6502++;
SAVEPC += X;
}
|
// ABS,X
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/libemulation/m6502.c#L224-L232
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
andcc
|
static void andcc(m6809_t *m6809)
{
uint8_t t;
IMMBYTE(t);
CC &= t;
CHECK_IRQ_LINES;
}
|
// case 0x1B: //ILLEGAL
// case 0x1C: //ANDCC immediate #####
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/libemulation/m6809ops.c#L223-L229
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
sys_country
|
int sys_country(char *country, int len) {
int r = -1;
#ifdef WINDOWS
char buf[32];
GEOID myGEO = GetUserGeoID(GEOCLASS_NATION);
if (GetGeoInfoA(myGEO, GEO_ISO2, buf, sizeof(buf), 0)) {
sys_strncpy(country, buf, len-1);
r = 0;
}
#else
char *s, *p, buf[32];
if ((s = getenv("LANG")) != NULL) {
sys_strncpy(buf, s, sizeof(buf)-1);
if ((p = sys_strchr(buf, '.')) != NULL) {
// "pt_BR.UTF-8" -> "pt_BR"
*p = 0;
}
if (!sys_strcmp(buf, "C")) {
sys_strncpy(buf, EN_US, sizeof(buf)-1);
}
if ((p = sys_strchr(buf, '_')) != NULL) {
// "pt_BR" -> "BR"
sys_strncpy(country, p+1, len-1);
r = 0;
}
}
#endif
return r;
}
|
/*
The name of a locale consists of language codes, character encoding, and the description of a selected variant.
A name starts with an ISO 639-1 lowercase two-letter language code, or an ISO 639-2 three-letter language code if the language has no two-letter code. For example, it is de for German, fr for French, and cel for Celtic. The code is followed for many but not all languages by an underscore _ and by an ISO 3166 uppercase two-letter country code. For example, this leads to de_CH for Swiss German, and fr_CA for a French-speaking system for a Canadian user likely to be located in Quebec.
Optionally, a dot . follows the name of the character encoding such as UTF-8, or ISO-8859-1, and the @ sign followed by the name of a variant. For example, the name en_IE.UTF-8@euro describes the setup for an English system for Ireland with UTF-8 character encoding, and the Euro as the currency symbol.
*/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/libpit/sys.c#L344-L374
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
SW_FT_Vector_Length
|
SW_FT_Fixed SW_FT_Vector_Length(SW_FT_Vector* vec)
{
SW_FT_Int shift;
SW_FT_Vector v;
v = *vec;
/* handle trivial cases */
if (v.x == 0) {
return SW_FT_ABS(v.y);
} else if (v.y == 0) {
return SW_FT_ABS(v.x);
}
/* general case */
shift = ft_trig_prenorm(&v);
ft_trig_pseudo_polarize(&v);
v.x = ft_trig_downscale(v.x);
if (shift > 0) return (v.x + (1 << (shift - 1))) >> shift;
return (SW_FT_Fixed)((SW_FT_UInt32)v.x << -shift);
}
|
/* documentation is in fttrigon.h */
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/libpluto/sw_ft_math.c#L388-L411
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
loadline
|
static int loadline (lua_State *L) {
int status;
lua_settop(L, 0);
if (!pushline(L, 1))
return -1; /* no input */
if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */
status = multiline(L); /* try as command, maybe with continuation lines */
lua_remove(L, 1); /* remove line from the stack */
lua_assert(lua_gettop(L) == 1);
return status;
}
|
/*
** Read a line and try to load (compile) it first as an expression (by
** adding "return " in front of it) and second as a statement. Return
** the final status of load/call with the resulting function (if any)
** in the top of the stack.
*/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/lua/lua.c#L372-L382
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
PumpkinOS
|
github_2023
|
migueletto
|
c
|
SetOutFileDir
|
VOID
SetOutFileDir(const char *sz)
{
if (sz && strcmp(sz, ".") == 0)
szOutFileDir = "";
else
szOutFileDir = sz;
}
|
/*-----------------------------------------------------------------------------
| SetOutFileDir
|
| Set output file path -- no trailing / or \
-------------------------------------------------------------WESC------------*/
|
https://github.com/migueletto/PumpkinOS/blob/d31ba3aca31b73c8f1ce40dbf812ddffe44c22de/src/pilrc/util.c#L475-L482
|
d31ba3aca31b73c8f1ce40dbf812ddffe44c22de
|
T-Display-S3-AMOLED
|
github_2023
|
Xinyuan-LilyGO
|
c
|
begin_SDA_Read
|
void TFT_eSPI::begin_SDA_Read(void)
{
#ifdef TFT_SPI_OVERLAP
// Reads in overlap mode not supported
#else
spi.end();
#endif
}
|
/***************************************************************************************
** Function name: beginSDA
** Description: Detach SPI from pin to permit software SPI
***************************************************************************************/
|
https://github.com/Xinyuan-LilyGO/T-Display-S3-AMOLED/blob/edd133335c9f7c38d1e9be2d0eb67371f1f6428e/lib/TFT_eSPI/Processors/TFT_eSPI_ESP8266.c#L40-L47
|
edd133335c9f7c38d1e9be2d0eb67371f1f6428e
|
T-Display-S3-AMOLED
|
github_2023
|
Xinyuan-LilyGO
|
c
|
lv_example_flex_5
|
void lv_example_flex_5(void)
{
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_center(cont);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
uint32_t i;
for(i = 0; i < 9; i++) {
lv_obj_t * obj = lv_obj_create(cont);
lv_obj_set_size(obj, 70, LV_SIZE_CONTENT);
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text_fmt(label, "%"LV_PRIu32, i);
lv_obj_center(label);
}
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, cont);
lv_anim_set_values(&a, 0, 10);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_exec_cb(&a, row_gap_anim);
lv_anim_set_time(&a, 500);
lv_anim_set_playback_time(&a, 500);
lv_anim_start(&a);
lv_anim_set_exec_cb(&a, column_gap_anim);
lv_anim_set_time(&a, 3000);
lv_anim_set_playback_time(&a, 3000);
lv_anim_start(&a);
}
|
/**
* Demonstrate the effect of column and row gap style properties
*/
|
https://github.com/Xinyuan-LilyGO/T-Display-S3-AMOLED/blob/edd133335c9f7c38d1e9be2d0eb67371f1f6428e/lib/lvgl/examples/layouts/flex/lv_example_flex_5.c#L17-L49
|
edd133335c9f7c38d1e9be2d0eb67371f1f6428e
|
T-Display-S3-AMOLED
|
github_2023
|
Xinyuan-LilyGO
|
c
|
lv_example_style_9
|
void lv_example_style_9(void)
{
static lv_style_t style;
lv_style_init(&style);
lv_style_set_line_color(&style, lv_palette_main(LV_PALETTE_GREY));
lv_style_set_line_width(&style, 6);
lv_style_set_line_rounded(&style, true);
/*Create an object with the new style*/
lv_obj_t * obj = lv_line_create(lv_scr_act());
lv_obj_add_style(obj, &style, 0);
static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}};
lv_line_set_points(obj, p, 3);
lv_obj_center(obj);
}
|
/**
* Using the line style properties
*/
|
https://github.com/Xinyuan-LilyGO/T-Display-S3-AMOLED/blob/edd133335c9f7c38d1e9be2d0eb67371f1f6428e/lib/lvgl/examples/styles/lv_example_style_9.c#L7-L24
|
edd133335c9f7c38d1e9be2d0eb67371f1f6428e
|
T-Display-S3-AMOLED
|
github_2023
|
Xinyuan-LilyGO
|
c
|
lv_fs_fatfs_init
|
void lv_fs_fatfs_init(void)
{
/*----------------------------------------------------
* Initialize your storage device and File System
* -------------------------------------------------*/
fs_init();
/*---------------------------------------------------
* Register the file system interface in LVGL
*--------------------------------------------------*/
/*Add a simple drive to open images*/
static lv_fs_drv_t fs_drv; /*A driver descriptor*/
lv_fs_drv_init(&fs_drv);
/*Set up fields...*/
fs_drv.letter = LV_FS_FATFS_LETTER;
fs_drv.cache_size = LV_FS_FATFS_CACHE_SIZE;
fs_drv.open_cb = fs_open;
fs_drv.close_cb = fs_close;
fs_drv.read_cb = fs_read;
fs_drv.write_cb = fs_write;
fs_drv.seek_cb = fs_seek;
fs_drv.tell_cb = fs_tell;
fs_drv.dir_close_cb = fs_dir_close;
fs_drv.dir_open_cb = fs_dir_open;
fs_drv.dir_read_cb = fs_dir_read;
lv_fs_drv_register(&fs_drv);
}
|
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
|
https://github.com/Xinyuan-LilyGO/T-Display-S3-AMOLED/blob/edd133335c9f7c38d1e9be2d0eb67371f1f6428e/lib/lvgl/src/extra/libs/fsdrv/lv_fs_fatfs.c#L53-L84
|
edd133335c9f7c38d1e9be2d0eb67371f1f6428e
|
T-Display-S3-AMOLED
|
github_2023
|
Xinyuan-LilyGO
|
c
|
fillRectangle
|
static void fillRectangle(int left, int top, int width, int height, uint8_t qrcode[]) {
for (int dy = 0; dy < height; dy++) {
for (int dx = 0; dx < width; dx++)
setModule(qrcode, left + dx, top + dy, true);
}
}
|
// Sets every pixel in the range [left : left + width] * [top : top + height] to black.
|
https://github.com/Xinyuan-LilyGO/T-Display-S3-AMOLED/blob/edd133335c9f7c38d1e9be2d0eb67371f1f6428e/lib/lvgl/src/extra/libs/qrcode/qrcodegen.c#L559-L564
|
edd133335c9f7c38d1e9be2d0eb67371f1f6428e
|
T-Display-S3-AMOLED
|
github_2023
|
Xinyuan-LilyGO
|
c
|
lv_switch_trigger_anim
|
static void lv_switch_trigger_anim(lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_switch_t * sw = (lv_switch_t *)obj;
uint32_t anim_dur_full = lv_obj_get_style_anim_time(obj, LV_PART_MAIN);
if(anim_dur_full > 0) {
bool chk = lv_obj_get_state(obj) & LV_STATE_CHECKED;
int32_t anim_start;
int32_t anim_end;
/*No animation in progress -> simply set the values*/
if(sw->anim_state == LV_SWITCH_ANIM_STATE_INV) {
anim_start = chk ? LV_SWITCH_ANIM_STATE_START : LV_SWITCH_ANIM_STATE_END;
anim_end = chk ? LV_SWITCH_ANIM_STATE_END : LV_SWITCH_ANIM_STATE_START;
}
/*Animation in progress. Start from the animation end value*/
else {
anim_start = sw->anim_state;
anim_end = chk ? LV_SWITCH_ANIM_STATE_END : LV_SWITCH_ANIM_STATE_START;
}
/*Calculate actual animation duration*/
uint32_t anim_dur = (anim_dur_full * LV_ABS(anim_start - anim_end)) / LV_SWITCH_ANIM_STATE_END;
/*Stop the previous animation if it exists*/
lv_anim_del(sw, NULL);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, sw);
lv_anim_set_exec_cb(&a, lv_switch_anim_exec_cb);
lv_anim_set_values(&a, anim_start, anim_end);
lv_anim_set_ready_cb(&a, lv_switch_anim_ready);
lv_anim_set_time(&a, anim_dur);
lv_anim_start(&a);
}
}
|
/**
* Starts an animation for the switch knob. if the anim_time style property is greater than 0
* @param obj the switch to animate
*/
|
https://github.com/Xinyuan-LilyGO/T-Display-S3-AMOLED/blob/edd133335c9f7c38d1e9be2d0eb67371f1f6428e/lib/lvgl/src/widgets/lv_switch.c#L238-L274
|
edd133335c9f7c38d1e9be2d0eb67371f1f6428e
|
ch32v003fun
|
github_2023
|
cnlohr
|
c
|
adc_init
|
void adc_init( void )
{
// ADCCLK = 24 MHz => RCC_ADCPRE = 0: divide by 2
RCC->CFGR0 &= ~(0x1F<<11);
// Enable GPIOD and ADC
RCC->APB2PCENR |= RCC_APB2Periph_GPIOD | RCC_APB2Periph_ADC1;
// PD4 is analog input chl 7
GPIOD->CFGLR &= ~(0xf<<(4*4)); // CNF = 00: Analog, MODE = 00: Input
// Reset the ADC to init all regs
RCC->APB2PRSTR |= RCC_APB2Periph_ADC1;
RCC->APB2PRSTR &= ~RCC_APB2Periph_ADC1;
// Set up single conversion on chl 7
ADC1->RSQR1 = 0;
ADC1->RSQR2 = 0;
ADC1->RSQR3 = 7; // 0-9 for 8 ext inputs and two internals
// set sampling time for chl 7
ADC1->SAMPTR2 &= ~(ADC_SMP0<<(3*7));
ADC1->SAMPTR2 |= 7<<(3*7); // 0:7 => 3/9/15/30/43/57/73/241 cycles
// turn on ADC and set rule group to sw trig
ADC1->CTLR2 |= ADC_ADON | ADC_EXTSEL;
// Reset calibration
ADC1->CTLR2 |= ADC_RSTCAL;
while(ADC1->CTLR2 & ADC_RSTCAL);
// Calibrate
ADC1->CTLR2 |= ADC_CAL;
while(ADC1->CTLR2 & ADC_CAL);
// should be ready for SW conversion now
}
|
/*
* initialize adc for polling
*/
|
https://github.com/cnlohr/ch32v003fun/blob/92b39c8984cab685ab59d6cc6c108de21e21d98a/examples/adc_polled/adc_polled.c#L12-L48
|
92b39c8984cab685ab59d6cc6c108de21e21d98a
|
platform-ch32v
|
github_2023
|
Community-PIO-CH32V
|
c
|
EXTI_Line_Init
|
void EXTI_Line_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
EXTI_InitTypeDef EXTI_InitStructure = {0};
NVIC_InitTypeDef NVIC_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* GPIOC 7 ----> EXTI_Line7 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource7);
EXTI_InitStructure.EXTI_Line = EXTI_Line7;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
|
/*********************************************************************
* @fn EXTI_Line_Init
*
* @brief Configure EXTI Line7.
*
* @param none.
*
* @return none.
*/
|
https://github.com/Community-PIO-CH32V/platform-ch32v/blob/8af792530c1b16b24526f6e64e2ea1b383890047/examples/webserver-ch32v307-none-os/lib/NetLib/eth_driver_RMII.c#L172-L197
|
8af792530c1b16b24526f6e64e2ea1b383890047
|
AtomLdr
|
github_2023
|
NUL0x4C
|
c
|
FetchAesKetAndIv
|
VOID FetchAesKetAndIv(IN OUT PBYTE ctAesKey, IN OUT PBYTE ctAesIv) {
for (int i = 0; i < IV_SIZE; i++) {
ctAesIv[i] -= 0x03;
}
for (int i = 0; i < KEY_SIZE; i++) {
ctAesKey[i] -= 0x03;
}
for (int i = 0; i < IV_SIZE; i++) {
ctAesIv[i] ^= (BYTE)ctAesKey[0];
}
for (int i = 1; i < KEY_SIZE; i++) {
for (int j = 0; j < IV_SIZE; j++) {
ctAesKey[i] ^= (BYTE)ctAesIv[j];
}
}
}
|
/*
function to decrypt the aes key and iv
*/
|
https://github.com/NUL0x4C/AtomLdr/blob/f18cb75c28f312fb8edaa86ea7c65f148ff26d0d/AtomLdr/dllmain.c#L83-L99
|
f18cb75c28f312fb8edaa86ea7c65f148ff26d0d
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
recoverTransferSettings
|
static void recoverTransferSettings(sqlite3_recover *p){
const char *aPragma[] = {
"encoding",
"page_size",
"auto_vacuum",
"user_version",
"application_id"
};
int ii;
/* Truncate the output database to 0 pages in size. This is done by
** opening a new, empty, temp db, then using the backup API to clobber
** any existing output db with a copy of it. */
if( p->errCode==SQLITE_OK ){
sqlite3 *db2 = 0;
int rc = sqlite3_open("", &db2);
if( rc!=SQLITE_OK ){
recoverDbError(p, db2);
return;
}
for(ii=0; ii<sizeof(aPragma)/sizeof(aPragma[0]); ii++){
const char *zPrag = aPragma[ii];
sqlite3_stmt *p1 = 0;
p1 = recoverPreparePrintf(p, p->dbIn, "PRAGMA %Q.%s", p->zDb, zPrag);
if( p->errCode==SQLITE_OK && sqlite3_step(p1)==SQLITE_ROW ){
const char *zArg = (const char*)sqlite3_column_text(p1, 0);
char *z2 = recoverMPrintf(p, "PRAGMA %s = %Q", zPrag, zArg);
recoverSqlCallback(p, z2);
recoverExec(p, db2, z2);
sqlite3_free(z2);
if( zArg==0 ){
recoverError(p, SQLITE_NOMEM, 0);
}
}
recoverFinalize(p, p1);
}
recoverExec(p, db2, "CREATE TABLE t1(a); DROP TABLE t1;");
if( p->errCode==SQLITE_OK ){
sqlite3 *db = p->dbOut;
sqlite3_backup *pBackup = sqlite3_backup_init(db, "main", db2, "main");
if( pBackup ){
sqlite3_backup_step(pBackup, -1);
p->errCode = sqlite3_backup_finish(pBackup);
}else{
recoverDbError(p, db);
}
}
sqlite3_close(db2);
}
}
|
/*
** Transfer the following settings from the input database to the output
** database:
**
** + page-size,
** + auto-vacuum settings,
** + database encoding,
** + user-version (PRAGMA user_version), and
** + application-id (PRAGMA application_id), and
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/shell.c#L13507-L13559
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
memsys5Size
|
static int memsys5Size(void *p){
int iSize, i;
assert( p!=0 );
i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);
assert( i>=0 && i<mem5.nBlock );
iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));
return iSize;
}
|
/*
** Return the size of an outstanding allocation, in bytes.
** This only works for chunks that are currently checked out.
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/sqlite3.c#L27076-L27083
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
pagerOpenWalIfPresent
|
static int pagerOpenWalIfPresent(Pager *pPager){
int rc = SQLITE_OK;
assert( pPager->eState==PAGER_OPEN );
assert( pPager->eLock>=SHARED_LOCK );
if( !pPager->tempFile ){
int isWal; /* True if WAL file exists */
rc = sqlite3OsAccess(
pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
);
if( rc==SQLITE_OK ){
if( isWal ){
Pgno nPage; /* Size of the database file */
rc = pagerPagecount(pPager, &nPage);
if( rc ) return rc;
if( nPage==0 ){
rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
}else{
testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
rc = sqlite3PagerOpenWal(pPager, 0);
}
}else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
pPager->journalMode = PAGER_JOURNALMODE_DELETE;
}
}
}
return rc;
}
|
/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists if the database is not empy, or verify that the *-wal file does
** not exist (by deleting it) if the database file is empty.
**
** If the database is not empty and the *-wal file exists, open the pager
** in WAL mode. If the database is empty or if no *-wal file exists and
** if no error occurs, make sure Pager.journalMode is not set to
** PAGER_JOURNALMODE_WAL.
**
** Return SQLITE_OK or an error code.
**
** The caller must hold a SHARED lock on the database file to call this
** function. Because an EXCLUSIVE lock on the db file is required to delete
** a WAL on a none-empty database, this ensures there is no race condition
** between the xAccess() below and an xDelete() being executed by some
** other connection.
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/sqlite3.c#L58481-L58509
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
sqlite3WalLimit
|
SQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){
if( pWal ) pWal->mxWalSize = iLimit;
}
|
/*
** Change the size to which the WAL file is trucated on each reset.
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/sqlite3.c#L64512-L64514
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
sqlite3WalBeginReadTransaction
|
SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
int rc; /* Return code */
int cnt = 0; /* Number of TryBeginRead attempts */
#ifdef SQLITE_ENABLE_SNAPSHOT
int bChanged = 0;
WalIndexHdr *pSnapshot = pWal->pSnapshot;
#endif
assert( pWal->ckptLock==0 );
#ifdef SQLITE_ENABLE_SNAPSHOT
if( pSnapshot ){
if( memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
bChanged = 1;
}
/* It is possible that there is a checkpointer thread running
** concurrent with this code. If this is the case, it may be that the
** checkpointer has already determined that it will checkpoint
** snapshot X, where X is later in the wal file than pSnapshot, but
** has not yet set the pInfo->nBackfillAttempted variable to indicate
** its intent. To avoid the race condition this leads to, ensure that
** there is no checkpointer process by taking a shared CKPT lock
** before checking pInfo->nBackfillAttempted. */
(void)walEnableBlocking(pWal);
rc = walLockShared(pWal, WAL_CKPT_LOCK);
walDisableBlocking(pWal);
if( rc!=SQLITE_OK ){
return rc;
}
pWal->ckptLock = 1;
}
#endif
do{
rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
}while( rc==WAL_RETRY );
testcase( (rc&0xff)==SQLITE_BUSY );
testcase( (rc&0xff)==SQLITE_IOERR );
testcase( rc==SQLITE_PROTOCOL );
testcase( rc==SQLITE_OK );
#ifdef SQLITE_ENABLE_SNAPSHOT
if( rc==SQLITE_OK ){
if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
/* At this point the client has a lock on an aReadMark[] slot holding
** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr
** is populated with the wal-index header corresponding to the head
** of the wal file. Verify that pSnapshot is still valid before
** continuing. Reasons why pSnapshot might no longer be valid:
**
** (1) The WAL file has been reset since the snapshot was taken.
** In this case, the salt will have changed.
**
** (2) A checkpoint as been attempted that wrote frames past
** pSnapshot->mxFrame into the database file. Note that the
** checkpoint need not have completed for this to cause problems.
*/
volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
assert( pWal->readLock>0 || pWal->hdr.mxFrame==0 );
assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame );
/* Check that the wal file has not been wrapped. Assuming that it has
** not, also check that no checkpointer has attempted to checkpoint any
** frames beyond pSnapshot->mxFrame. If either of these conditions are
** true, return SQLITE_ERROR_SNAPSHOT. Otherwise, overwrite pWal->hdr
** with *pSnapshot and set *pChanged as appropriate for opening the
** snapshot. */
if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
&& pSnapshot->mxFrame>=pInfo->nBackfillAttempted
){
assert( pWal->readLock>0 );
memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
*pChanged = bChanged;
}else{
rc = SQLITE_ERROR_SNAPSHOT;
}
/* A client using a non-current snapshot may not ignore any frames
** from the start of the wal file. This is because, for a system
** where (minFrame < iSnapshot < maxFrame), a checkpointer may
** have omitted to checkpoint a frame earlier than minFrame in
** the file because there exists a frame after iSnapshot that
** is the same database page. */
pWal->minFrame = 1;
if( rc!=SQLITE_OK ){
sqlite3WalEndReadTransaction(pWal);
}
}
}
/* Release the shared CKPT lock obtained above. */
if( pWal->ckptLock ){
assert( pSnapshot );
walUnlockShared(pWal, WAL_CKPT_LOCK);
pWal->ckptLock = 0;
}
#endif
return rc;
}
|
/* SQLITE_ENABLE_SNAPSHOT */
/*
** Begin a read transaction on the database.
**
** This routine used to be called sqlite3OpenSnapshot() and with good reason:
** it takes a snapshot of the state of the WAL and wal-index for the current
** instant in time. The current thread will continue to use this snapshot.
** Other threads might append new content to the WAL and wal-index but
** that extra content is ignored by the current thread.
**
** If the database contents have changes since the previous read
** transaction, then *pChanged is set to 1 before returning. The
** Pager layer will use this to know that its cache is stale and
** needs to be flushed.
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/sqlite3.c#L65947-L66049
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
vdbeAssertFieldCountWithinLimits
|
static void vdbeAssertFieldCountWithinLimits(
int nKey, const void *pKey, /* The record to verify */
const KeyInfo *pKeyInfo /* Compare size with this KeyInfo */
){
int nField = 0;
u32 szHdr;
u32 idx;
u32 notUsed;
const unsigned char *aKey = (const unsigned char*)pKey;
if( CORRUPT_DB ) return;
idx = getVarint32(aKey, szHdr);
assert( nKey>=0 );
assert( szHdr<=(u32)nKey );
while( idx<szHdr ){
idx += getVarint32(aKey+idx, notUsed);
nField++;
}
assert( nField <= pKeyInfo->nAllField );
}
|
/*
** Count the number of fields (a.k.a. columns) in the record given by
** pKey,nKey. The verify that this count is less than or equal to the
** limit given by pKeyInfo->nAllField.
**
** If this constraint is not satisfied, it means that the high-speed
** vdbeRecordCompareInt() and vdbeRecordCompareString() routines will
** not work correctly. If this assert() ever fires, it probably means
** that the KeyInfo.nKeyField or KeyInfo.nAllField values were computed
** incorrectly.
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/sqlite3.c#L86235-L86254
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
duckdb-spatial
|
github_2023
|
duckdb
|
c
|
countOfViewOptimization
|
static int countOfViewOptimization(Parse *pParse, Select *p){
Select *pSub, *pPrior;
Expr *pExpr;
Expr *pCount;
sqlite3 *db;
if( (p->selFlags & SF_Aggregate)==0 ) return 0; /* This is an aggregate */
if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
if( p->pWhere ) return 0;
if( p->pGroupBy ) return 0;
pExpr = p->pEList->a[0].pExpr;
if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */
assert( ExprUseUToken(pExpr) );
if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */
assert( ExprUseXList(pExpr) );
if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */
if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */
pSub = p->pSrc->a[0].pSelect;
if( pSub==0 ) return 0; /* The FROM is a subquery */
if( pSub->pPrior==0 ) return 0; /* Must be a compound ry */
do{
if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
if( pSub->pWhere ) return 0; /* No WHERE clause */
if( pSub->pLimit ) return 0; /* No LIMIT clause */
if( pSub->selFlags & SF_Aggregate ) return 0; /* Not an aggregate */
pSub = pSub->pPrior; /* Repeat over compound */
}while( pSub );
/* If we reach this point then it is OK to perform the transformation */
db = pParse->db;
pCount = pExpr;
pExpr = 0;
pSub = p->pSrc->a[0].pSelect;
p->pSrc->a[0].pSelect = 0;
sqlite3SrcListDelete(db, p->pSrc);
p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc));
while( pSub ){
Expr *pTerm;
pPrior = pSub->pPrior;
pSub->pPrior = 0;
pSub->pNext = 0;
pSub->selFlags |= SF_Aggregate;
pSub->selFlags &= ~SF_Compound;
pSub->nSelectRow = 0;
sqlite3ExprListDelete(db, pSub->pEList);
pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount;
pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm);
pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
sqlite3PExprAddSelect(pParse, pTerm, pSub);
if( pExpr==0 ){
pExpr = pTerm;
}else{
pExpr = sqlite3PExpr(pParse, TK_PLUS, pTerm, pExpr);
}
pSub = pPrior;
}
p->pEList->a[0].pExpr = pExpr;
p->selFlags &= ~SF_Aggregate;
#if TREETRACE_ENABLED
if( sqlite3TreeTrace & 0x400 ){
SELECTTRACE(0x400,pParse,p,("After count-of-view optimization:\n"));
sqlite3TreeViewSelect(0, p, 0);
}
#endif
return 1;
}
|
/*
** Attempt to transform a query of the form
**
** SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2)
**
** Into this:
**
** SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)
**
** The transformation only works if all of the following are true:
**
** * The subquery is a UNION ALL of two or more terms
** * The subquery does not have a LIMIT clause
** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
** * The outer query is a simple count(*) with no WHERE clause or other
** extraneous syntax.
**
** Return TRUE if the optimization is undertaken.
*/
|
https://github.com/duckdb/duckdb-spatial/blob/aa95ed8049da630da45e763f3bb6e9aeb1891e34/deps/vendor/sqlite3/src/sqlite3.c#L143883-L143949
|
aa95ed8049da630da45e763f3bb6e9aeb1891e34
|
clr
|
github_2023
|
ROCm
|
c
|
khrIcdOsLibraryUnload
|
void khrIcdOsLibraryUnload(void *library)
{
dlclose(library);
}
|
// unload a library
|
https://github.com/ROCm/clr/blob/a8edb8d467ebb5678d2f4506bd01efd3aaeddcab/opencl/khronos/icd/loader/linux/icd_linux.c#L191-L194
|
a8edb8d467ebb5678d2f4506bd01efd3aaeddcab
|
view.py
|
github_2023
|
ZeroIntensity
|
c
|
handle_result
|
int
handle_result(
PyObject *raw_result,
char **res_target,
int *status_target,
PyObject **headers_target,
PyObject *raw_path,
const char *method
)
{
/*
* This calls handle_result_impl() internally, but
* this function is the actual interface for handling a return value.
*
* The only extra thing that this does is write to the route log.
*/
int res = handle_result_impl(
raw_result,
res_target,
status_target,
headers_target
);
return res;
// Calling route_log is extremely slow
if (res < 0)
return -1;
if (!route_log) return res;
PyObject *args = Py_BuildValue(
"(iOs)",
*status_target,
raw_path,
method
);
if (!args)
return -1;
/*
* A lot of errors related to memory corruption are traced
* to here by debuggers.
*
* This is, more or less, a false positive! It's quite
* unlikely that the actual cause of the issue is here.
*/
PyObject *result = PyObject_Call(
route_log,
args,
NULL
);
if (!result)
{
Py_DECREF(args);
return -1;
}
Py_DECREF(result);
Py_DECREF(args);
return res;
}
|
/*
* Generate HTTP response components (i.e. the body, status, and headers) from
* a route return value.
*
* The result passed should be a tuple, or body string. This function
* does not call __view_result__(), as that is up to the caller.
*
* The body output parameter will be a string on the heap,
* and is responsible for deallocating it with PyMem_Free()
*
* The status output parameter can be *any* integer (including non-HTTP
* status codes). Validation is up to the caller.
*
* The headers will always be an ASGI headers iterable [(bytes_key, bytes_value), ...]
*
* If this function fails, the caller is not responsible for
* deallocating or managing references of any of the parameters.
*/
|
https://github.com/ZeroIntensity/view.py/blob/7fe291b0feb5f5ae2da3fbf552010a4ee4e470ef/src/_view/results.c#L304-L367
|
7fe291b0feb5f5ae2da3fbf552010a4ee4e470ef
|
doom-teletext
|
github_2023
|
lukneu
|
c
|
AM_rotate
|
void
AM_rotate
( fixed_t* x,
fixed_t* y,
angle_t a )
{
fixed_t tmpx;
tmpx =
FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT])
- FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]);
*y =
FixedMul(*x,finesine[a>>ANGLETOFINESHIFT])
+ FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]);
*x = tmpx;
}
|
//
// Rotation in 2D.
// Used to rotate player arrow line character.
//
|
https://github.com/lukneu/doom-teletext/blob/b9f5fd1cd89a15150c4efcc02f63f6e0e7ce21f4/doom-teletext/am_map.c#L1178-L1195
|
b9f5fd1cd89a15150c4efcc02f63f6e0e7ce21f4
|
CMSIS_6
|
github_2023
|
ARM-software
|
c
|
Default_Handler
|
void Default_Handler(void) {
while(1);
}
|
/*----------------------------------------------------------------------------
Default Handler for Exceptions / Interrupts
*----------------------------------------------------------------------------*/
|
https://github.com/ARM-software/CMSIS_6/blob/1a1799c6c58c47e737bb19523483344a25d29895/CMSIS/CoreValidation/Layer/Target/CA9/RTE/Device/ARMCA9/startup_ARMCA9.c#L146-L148
|
1a1799c6c58c47e737bb19523483344a25d29895
|
CMSIS_6
|
github_2023
|
ARM-software
|
c
|
ARM_USBH_PipeTransferGetResult
|
uint32_t ARM_USBH_PipeTransferGetResult (ARM_USBH_PIPE_HANDLE pipe_hndl) {
return 0;
}
|
/**
\fn int32_t ARM_USBH_PipeTransfer (ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t packet, uint8_t *data, uint32_t num)
\details
The function \b ARM_USBH_PipeTransfer generates packets for sending or receiving data from an USB Endpoint.
The function specifies the buffer with data to send or for data to receive and the number of bytes to transfer (must be multiple of device endpoint maximum packet size for receive).
It also specifies \ref USBH_packets with parameter \em packet.
The function is non-blocking and returns as soon as the driver starts the operation on the specified pipe. During the operation it is not allowed to call this function again on the same pipe. Also the data buffer must stay allocated and the contents of data must not be modified.
Operation is completed when the the requested number of data bytes have been transferred and is indicated with \ref ARM_USBH_EVENT_TRANSFER_COMPLETE event.
It can also finish earlier on reception of different handshake tokens which are also indicated through \ref USBH_pipe_events.
Transfer operation can be aborted by calling \ref ARM_USBH_PipeTransferAbort.
*****************************************************************************************************************/
|
https://github.com/ARM-software/CMSIS_6/blob/1a1799c6c58c47e737bb19523483344a25d29895/CMSIS/Documentation/Doxygen/Driver/src/Driver_USBH.c#L399-L401
|
1a1799c6c58c47e737bb19523483344a25d29895
|
fdskey
|
github_2023
|
ClusterM
|
c
|
HAL_TIM_IC_Stop_DMA
|
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
{
HAL_StatusTypeDef status = HAL_OK;
/* Check the parameters */
assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
/* Disable the Input Capture channel */
TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
switch (Channel)
{
case TIM_CHANNEL_1:
{
/* Disable the TIM Capture/Compare 1 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC1);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
break;
}
case TIM_CHANNEL_2:
{
/* Disable the TIM Capture/Compare 2 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC2);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
break;
}
case TIM_CHANNEL_3:
{
/* Disable the TIM Capture/Compare 3 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC3);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
break;
}
case TIM_CHANNEL_4:
{
/* Disable the TIM Capture/Compare 4 DMA request */
__HAL_TIM_DISABLE_DMA(htim, TIM_DMA_CC4);
(void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
break;
}
default:
status = HAL_ERROR;
break;
}
if (status == HAL_OK)
{
/* Disable the Peripheral */
__HAL_TIM_DISABLE(htim);
/* Set the TIM channel state */
TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
}
/* Return function status */
return status;
}
|
/**
* @brief Stops the TIM Input Capture measurement in DMA mode.
* @param htim TIM Input Capture handle
* @param Channel TIM Channels to be disabled
* This parameter can be one of the following values:
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
* @retval HAL status
*/
|
https://github.com/ClusterM/fdskey/blob/f07ab82864a9f4a2e7b14b37f1837715edb0d0fe/FdsKey/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c#L2542-L2604
|
f07ab82864a9f4a2e7b14b37f1837715edb0d0fe
|
fdskey
|
github_2023
|
ClusterM
|
c
|
HAL_TIMEx_CommutCallback
|
__weak void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(htim);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_TIMEx_CommutCallback could be implemented in the user file
*/
}
|
/**
* @}
*/
/** @defgroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
* @brief Extended Callbacks functions
*
@verbatim
==============================================================================
##### Extended Callbacks functions #####
==============================================================================
[..]
This section provides Extended TIM callback functions:
(+) Timer Commutation callback
(+) Timer Break callback
@endverbatim
* @{
*/
/**
* @brief Hall commutation changed callback in non-blocking mode
* @param htim TIM handle
* @retval None
*/
|
https://github.com/ClusterM/fdskey/blob/f07ab82864a9f4a2e7b14b37f1837715edb0d0fe/FdsKey/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c#L2606-L2614
|
f07ab82864a9f4a2e7b14b37f1837715edb0d0fe
|
nostr-signing-device
|
github_2023
|
lnbits
|
c
|
bn_read_le
|
void bn_read_le(const uint8_t *in_number, bignum256 *out_number)
{
int i;
uint32_t temp = 0;
for (i = 0; i < 8; i++) {
// invariant: temp = (in_number % 2^(32i)) >> 30i
// get next limb = (in_number % 2^(32(i+1))) >> 32i
uint32_t limb = read_le(in_number + i * 4);
// temp = (in_number % 2^(32(i+1))) << 30i
temp |= limb << (2*i);
// store 30 bits into val[i]
out_number->val[i]= temp & 0x3FFFFFFF;
// prepare temp for next round
temp = limb >> (30 - 2*i);
}
out_number->val[8] = temp;
}
|
// convert a raw little endian 256 bit value into a normalized bignum.
// out_number is partly reduced (since it fits in 256 bit).
|
https://github.com/lnbits/nostr-signing-device/blob/1956e5933b3da5e49d30db9b8597497b157a5cbc/libraries/uBitcoin/src/utility/trezor/bignum.c#L126-L142
|
1956e5933b3da5e49d30db9b8597497b157a5cbc
|
llama.cpp
|
github_2023
|
ggerganov
|
c
|
ggml_compute_forward_sgn_f32
|
static void ggml_compute_forward_sgn_f32(
const struct ggml_compute_params * params,
struct ggml_tensor * dst) {
const struct ggml_tensor * src0 = dst->src[0];
if (params->ith != 0) {
return;
}
assert(ggml_is_contiguous_1(src0));
assert(ggml_is_contiguous_1(dst));
assert(ggml_are_same_shape(src0, dst));
const int n = ggml_nrows(src0);
const int nc = src0->ne[0];
for (int i = 0; i < n; i++) {
ggml_vec_sgn_f32(nc,
(float *) ((char *) dst->data + i*( dst->nb[1])),
(float *) ((char *) src0->data + i*(src0->nb[1])));
}
}
|
// ggml_compute_forward_sgn
|
https://github.com/ggerganov/llama.cpp/blob/4078c77f9891831f29ffc7c315c8ec6695ba5ce7/ggml/src/ggml-cpu/ggml-cpu.c#L6205-L6227
|
4078c77f9891831f29ffc7c315c8ec6695ba5ce7
|
llama.cpp
|
github_2023
|
ggerganov
|
c
|
ggml_compute_forward_soft_max_ext_back_f32
|
static void ggml_compute_forward_soft_max_ext_back_f32(
const struct ggml_compute_params * params,
struct ggml_tensor * dst) {
const struct ggml_tensor * src0 = dst->src[0];
const struct ggml_tensor * src1 = dst->src[1];
GGML_ASSERT(ggml_is_contiguous(src0));
GGML_ASSERT(ggml_is_contiguous(src1));
GGML_ASSERT(ggml_is_contiguous(dst));
GGML_ASSERT(ggml_are_same_shape(src0, dst));
GGML_ASSERT(ggml_are_same_shape(src1, dst));
float scale = 1.0f;
float max_bias = 0.0f;
memcpy(&scale, (const float *) dst->op_params + 0, sizeof(float));
memcpy(&max_bias, (const float *) dst->op_params + 1, sizeof(float));
GGML_ASSERT(max_bias == 0.0f);
// TODO: handle transposed/permuted matrices
const int ith = params->ith;
const int nth = params->nth;
const int nc = src0->ne[0];
const int nr = ggml_nrows(src0);
// rows per thread
const int dr = (nr + nth - 1)/nth;
// row range for this thread
const int ir0 = dr*ith;
const int ir1 = MIN(ir0 + dr, nr);
for (int i1 = ir0; i1 < ir1; i1++) {
float *dy = (float *)((char *) src0->data + i1*src0->nb[1]);
float *y = (float *)((char *) src1->data + i1*src1->nb[1]);
float *dx = (float *)((char *) dst->data + i1*dst->nb[1]);
#ifndef NDEBUG
for (int i = 0; i < nc; ++i) {
//printf("p[%d] = %f\n", i, p[i]);
assert(!isnan(dy[i]));
assert(!isnan(y[i]));
}
#endif
// Jii = yi - yi*yi
// Jij = -yi*yj
// J = diag(y)-y.T*y
// dx = J * dy
// dxk = sum_i(Jki * dyi)
// dxk = sum_i(-yk*yi * dyi) - (-yk*yk)*dyk + (yk - yk*yk)*dyk
// dxk = sum_i(-yk*yi * dyi) + yk*yk*dyk + yk*dyk - yk*yk*dyk
// dxk = sum_i(-yk*yi * dyi) + yk*dyk
// dxk = -yk * sum_i(yi * dyi) + yk*dyk
// dxk = -yk * dot(y, dy) + yk*dyk
// dxk = yk * (- dot(y, dy) + dyk)
// dxk = yk * (dyk - dot(y, dy))
//
// post-order:
// dot_y_dy := dot(y, dy)
// dx := dy
// dx := dx - dot_y_dy
// dx := dx * y
// linear runtime, no additional memory
float dot_y_dy = 0;
ggml_vec_dot_f32 (nc, &dot_y_dy, 0, y, 0, dy, 0, 1);
ggml_vec_cpy_f32 (nc, dx, dy);
ggml_vec_acc1_f32 (nc, dx, -dot_y_dy);
ggml_vec_mul_f32 (nc, dx, dx, y);
ggml_vec_scale_f32(nc, dx, scale);
#ifndef NDEBUG
for (int i = 0; i < nc; ++i) {
assert(!isnan(dx[i]));
assert(!isinf(dx[i]));
}
#endif
}
}
|
// ggml_compute_forward_soft_max_ext_back
|
https://github.com/ggerganov/llama.cpp/blob/4078c77f9891831f29ffc7c315c8ec6695ba5ce7/ggml/src/ggml-cpu/ggml-cpu.c#L8967-L9049
|
4078c77f9891831f29ffc7c315c8ec6695ba5ce7
|
bloomz.cpp
|
github_2023
|
NouamaneTazi
|
c
|
ggml_vec_set_i8
|
inline static void ggml_vec_set_i8(const int n, int8_t * x, const int8_t v) { for (int i = 0; i < n; ++i) x[i] = v; }
|
//
// fundamental operations
//
|
https://github.com/NouamaneTazi/bloomz.cpp/blob/9614897a272e69a64ca9e57102cd1f86b2d2e34b/Bloomer/bloomz/ggml.c#L1205-L1205
|
9614897a272e69a64ca9e57102cd1f86b2d2e34b
|
RuntimeSpeechRecognizer
|
github_2023
|
gtreshchev
|
c
|
ggml_v_silu
|
inline static __m512 ggml_v_silu(__m512 x) {
const __m512 one = _mm512_set1_ps(1);
const __m512 zero = _mm512_setzero_ps();
const __m512 neg_x = _mm512_sub_ps(zero, x);
const __m512 exp_neg_x = ggml_v_expf(neg_x);
const __m512 one_plus_exp_neg_x = _mm512_add_ps(one, exp_neg_x);
return _mm512_div_ps(x, one_plus_exp_neg_x);
}
|
// computes silu x/(1+exp(-x)) in single precision vector
|
https://github.com/gtreshchev/RuntimeSpeechRecognizer/blob/4faa894a1ed82e8cf4013c4adebdc8fa130471d3/Source/ThirdParty/ggml/src/ggml.c#L2705-L2712
|
4faa894a1ed82e8cf4013c4adebdc8fa130471d3
|
dillo-plus
|
github_2023
|
crossbowerbt
|
c
|
File_serve_client
|
static void File_serve_client(void *data, int f_write)
{
char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *path;
ClientInfo *client = data;
int st;
while (1) {
_MSG("File_serve_client %p, flags=%d state=%d\n",
client, client->flags, client->state);
if (client->flags & (FILE_DONE | FILE_ERR))
break;
if (client->flags & FILE_READ) {
dpip_tag = a_Dpip_dsh_read_token(client->sh, 0);
_MSG("dpip_tag={%s}\n", dpip_tag);
if (!dpip_tag)
break;
}
if (client->flags & FILE_READ) {
if (!(client->flags & FILE_AUTH_OK)) {
/* Authenticate our client... */
st = a_Dpip_check_auth(dpip_tag);
_MSG("a_Dpip_check_auth returned %d\n", st);
client->flags |= (st == 1) ? FILE_AUTH_OK : FILE_ERR;
} else {
/* Get file request */
cmd = a_Dpip_get_attr(dpip_tag, "cmd");
url = a_Dpip_get_attr(dpip_tag, "url");
path = FileUtil_normalize_path("file", url);
if (cmd) {
if (strcmp(cmd, "DpiBye") == 0) {
DPIBYE = 1;
MSG("(pid %d): Got DpiBye.\n", (int)getpid());
client->flags |= FILE_DONE;
} else if (url && dStrnAsciiCasecmp(url, "dpi:", 4) == 0 &&
strcmp(url+4, "/file/toggle") == 0) {
File_toggle_html_style(client);
} else if (path) {
File_get(client, path, url);
} else {
client->flags |= FILE_ERR;
MSG("ERROR: URL was %s\n", url);
}
}
dFree(path);
dFree(url);
dFree(cmd);
dFree(dpip_tag);
break;
}
dFree(dpip_tag);
} else if (f_write) {
/* send our answer */
if (client->state == st_err)
File_send_error_page(client);
else if (client->d_dir)
File_send_dir(client);
else
File_send_file(client);
break;
}
} /*while*/
client->flags |= (client->sh->status & DPIP_ERROR) ? FILE_ERR : 0;
client->flags |= (client->sh->status & DPIP_EOF) ? FILE_DONE : 0;
}
|
/*
* Serve this client.
*/
|
https://github.com/crossbowerbt/dillo-plus/blob/7d093e6bddcb3338938ea5959844e62ff1f9b76f/dpi/file.c#L524-L590
|
7d093e6bddcb3338938ea5959844e62ff1f9b76f
|
whisper.rn
|
github_2023
|
mybigday
|
c
|
wsp_ggml_compute_forward_clamp_f32
|
static void wsp_ggml_compute_forward_clamp_f32(
const struct wsp_ggml_compute_params * params,
struct wsp_ggml_tensor * dst) {
const struct wsp_ggml_tensor * src0 = dst->src[0];
if (params->ith != 0) {
return;
}
float min;
float max;
memcpy(&min, (float *) dst->op_params + 0, sizeof(float));
memcpy(&max, (float *) dst->op_params + 1, sizeof(float));
const int ith = params->ith;
const int nth = params->nth;
const int n = wsp_ggml_nrows(src0);
const int nc = src0->ne[0];
const size_t nb00 = src0->nb[0];
const size_t nb01 = src0->nb[1];
const size_t nb0 = dst->nb[0];
const size_t nb1 = dst->nb[1];
WSP_GGML_ASSERT( nb0 == sizeof(float));
WSP_GGML_ASSERT(nb00 == sizeof(float));
for (int j = ith; j < n; j += nth) {
float * dst_ptr = (float *) ((char *) dst->data + j*nb1);
float * src0_ptr = (float *) ((char *) src0->data + j*nb01);
for (int i = 0; i < nc; i++) {
dst_ptr[i] = MAX(MIN(src0_ptr[i], max), min);
}
}
}
|
// wsp_ggml_compute_forward_clamp
|
https://github.com/mybigday/whisper.rn/blob/844cbde318fe8962d0d378e0c093f3cb8000f9a0/cpp/ggml-cpu.c#L9057-L9095
|
844cbde318fe8962d0d378e0c093f3cb8000f9a0
|
nsproxy
|
github_2023
|
nlzy
|
c
|
pbuf_memcmp
|
u16_t
pbuf_memcmp(const struct pbuf *p, u16_t offset, const void *s2, u16_t n)
{
u16_t start = offset;
const struct pbuf *q = p;
u16_t i;
/* pbuf long enough to perform check? */
if (p->tot_len < (offset + n)) {
return 0xffff;
}
/* get the correct pbuf from chain. We know it succeeds because of p->tot_len check above. */
while ((q != NULL) && (q->len <= start)) {
start = (u16_t)(start - q->len);
q = q->next;
}
/* return requested data if pbuf is OK */
for (i = 0; i < n; i++) {
/* We know pbuf_get_at() succeeds because of p->tot_len check above. */
u8_t a = pbuf_get_at(q, (u16_t)(start + i));
u8_t b = ((const u8_t *)s2)[i];
if (a != b) {
return (u16_t)LWIP_MIN(i + 1, 0xFFFF);
}
}
return 0;
}
|
/**
* @ingroup pbuf
* Compare pbuf contents at specified offset with memory s2, both of length n
*
* @param p pbuf to compare
* @param offset offset into p at which to start comparing
* @param s2 buffer to compare
* @param n length of buffer to compare
* @return zero if equal, nonzero otherwise
* (0xffff if p is too short, diffoffset+1 otherwise)
*/
|
https://github.com/nlzy/nsproxy/blob/9dd996380a4d1e8edaca359cbf32969f74d0286c/lwip/pbuf.c#L1433-L1461
|
9dd996380a4d1e8edaca359cbf32969f74d0286c
|
VkDoom
|
github_2023
|
dpjudas
|
c
|
ChunkCount
|
static int ChunkCount(const WebPDemuxer* const dmux, const char fourcc[4]) {
const uint8_t* const mem_buf = dmux->mem_.buf_;
const Chunk* c;
int count = 0;
for (c = dmux->chunks_; c != NULL; c = c->next_) {
const uint8_t* const header = mem_buf + c->data_.offset_;
if (!memcmp(header, fourcc, TAG_SIZE)) ++count;
}
return count;
}
|
// -----------------------------------------------------------------------------
// Chunk iteration
|
https://github.com/dpjudas/VkDoom/blob/bbaaa9a49db3e22e5c31787faaf790b46b8c87c4/libraries/webp/src/demux/demux.c#L898-L907
|
bbaaa9a49db3e22e5c31787faaf790b46b8c87c4
|
VkDoom
|
github_2023
|
dpjudas
|
c
|
DoVerticalFilter_SSE2
|
static WEBP_INLINE void DoVerticalFilter_SSE2(const uint8_t* in,
int width, int height, int stride,
int row, int num_rows,
uint8_t* out) {
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out);
in += start_offset;
out += start_offset;
if (row == 0) {
// Very first top-left pixel is copied.
out[0] = in[0];
// Rest of top scan-line is left-predicted.
PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
row = 1;
in += stride;
out += stride;
}
// Filter line-by-line.
while (row < last_row) {
PredictLineTop_SSE2(in, in - stride, out, width);
++row;
in += stride;
out += stride;
}
}
|
//------------------------------------------------------------------------------
// Vertical filter.
|
https://github.com/dpjudas/VkDoom/blob/bbaaa9a49db3e22e5c31787faaf790b46b8c87c4/libraries/webp/src/dsp/filters_sse2.c#L110-L137
|
bbaaa9a49db3e22e5c31787faaf790b46b8c87c4
|
VkDoom
|
github_2023
|
dpjudas
|
c
|
pthread_cond_destroy
|
static int pthread_cond_destroy(pthread_cond_t* const condition) {
int ok = 1;
#ifdef USE_WINDOWS_CONDITION_VARIABLE
(void)condition;
#else
ok &= (CloseHandle(condition->waiting_sem_) != 0);
ok &= (CloseHandle(condition->received_sem_) != 0);
ok &= (CloseHandle(condition->signal_event_) != 0);
#endif
return !ok;
}
|
// Condition
|
https://github.com/dpjudas/VkDoom/blob/bbaaa9a49db3e22e5c31787faaf790b46b8c87c4/libraries/webp/src/utils/thread_utils.c#L131-L141
|
bbaaa9a49db3e22e5c31787faaf790b46b8c87c4
|
SphereSfM
|
github_2023
|
json87
|
c
|
vl_aib_merge_nodes
|
void
vl_aib_merge_nodes (VlAIB * aib, vl_uint i, vl_uint j, vl_uint new)
{
vl_uint last_entry = aib->nentries - 1 ;
vl_uint c, n ;
/* clear the list of nodes to update */
aib->nwhich = 0;
/* make sure that i is smaller than j */
if(i > j) { vl_uint tmp = j; j = i; i = tmp; }
/* -----------------------------------------------------------------
* Merge entries i and j, storing the result in i
* -------------------------------------------------------------- */
aib-> Px [i] += aib->Px[j] ;
aib-> beta [i] = BETA_MAX ;
aib-> nodes[i] = new ;
for (c = 0; c < aib->nlabels; c++)
aib-> Pcx [i*aib->nlabels + c] += aib-> Pcx [j*aib->nlabels + c] ;
/* -----------------------------------------------------------------
* Move last entry to j
* -------------------------------------------------------------- */
aib-> Px [j] = aib-> Px [last_entry];
aib-> beta [j] = aib-> beta [last_entry];
aib-> bidx [j] = aib-> bidx [last_entry];
aib-> nodes [j] = aib-> nodes [last_entry];
for (c = 0 ; c < aib->nlabels ; c++)
aib-> Pcx[j*aib->nlabels + c] = aib-> Pcx [last_entry*aib->nlabels + c] ;
/* delete last entry */
aib-> nentries -- ;
/* -----------------------------------------------------------------
* Scan for entries to update
* -------------------------------------------------------------- */
/*
* After mergin entries i and j, we need to update all other entries
* that had one of these two as closest match. We also need to
* update the renewend entry i. This is added by the loop below
* since bidx [i] = j exactly because i was merged.
*
* Additionaly, since we moved the last entry back to the entry j,
* we need to adjust the valeus of bidx to reflect this.
*/
for (n = 0 ; n < aib->nentries; n++) {
if(aib->bidx[n] == i || aib->bidx[n] == j) {
aib->bidx [n] = 0;
aib->beta [n] = BETA_MAX;
aib->which [aib->nwhich++] = n ;
}
else if(aib->bidx[n] == last_entry) {
aib->bidx[n] = j ;
}
}
}
|
/** ------------------------------------------------------------------
** @internal
** @brief Merges two nodes i,j in the internal datastructure
**
** @param aib A pointer to the internal data structure
** @param i The index of one member of the pair to merge
** @param j The index of the other member of the pair to merge
** @param new The index of the new node which corresponds to the union of
** (@a i, @a j).
**
** Nodes are merged by replacing the entry @a i with the union of @c
** ij, moving the node stored in last position (called @c lastnode)
** back to jth position and the entry at the end.
**
** After the nodes have been merged, it updates which nodes should be
** considered on the next iteration based on which beta values could
** potentially change. The merged node will always be part of this
** list.
**/
|
https://github.com/json87/SphereSfM/blob/1a01a12be58af8f4f3a8245ea2a0018828336ee8/lib/VLFeat/aib.c#L271-L333
|
1a01a12be58af8f4f3a8245ea2a0018828336ee8
|
SphereSfM
|
github_2023
|
json87
|
c
|
vl_dsift_delete
|
VL_EXPORT void
vl_dsift_delete (VlDsiftFilter * self)
{
_vl_dsift_free_buffers (self) ;
if (self->convTmp2) vl_free (self->convTmp2) ;
if (self->convTmp1) vl_free (self->convTmp1) ;
vl_free (self) ;
}
|
/** ------------------------------------------------------------------
** @brief Delete DSIFT filter
** @param self DSIFT filter.
**/
|
https://github.com/json87/SphereSfM/blob/1a01a12be58af8f4f3a8245ea2a0018828336ee8/lib/VLFeat/dsift.c#L483-L490
|
1a01a12be58af8f4f3a8245ea2a0018828336ee8
|
SphereSfM
|
github_2023
|
json87
|
c
|
vl_svm_logistic_loss
|
double
vl_svm_logistic_loss (double inner,double label)
{
double z = label * inner ;
if (z >= 0) {
return log(1.0 + exp(-z)) ;
} else {
return -z + log(exp(z) + 1.0) ;
}
}
|
/** @brief SVM l2 loss
** @copydetails VlSvmLossFunction */
|
https://github.com/json87/SphereSfM/blob/1a01a12be58af8f4f3a8245ea2a0018828336ee8/lib/VLFeat/svm.c#L1759-L1768
|
1a01a12be58af8f4f3a8245ea2a0018828336ee8
|
FreshCryptoLib
|
github_2023
|
rdubois-crypto
|
c
|
CheckDel
|
static void CheckDel(void* ptr, const char* k, size_t klen) {
int* state = (int*) ptr;
CheckCondition(*state == 2);
CheckEqual("bar", k, klen);
(*state)++;
}
|
// Callback from leveldb_writebatch_iterate()
|
https://github.com/rdubois-crypto/FreshCryptoLib/blob/8179e08cac72072bd260796633fec41fdfd5b441/solidity/tests/hardhat/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/c_test.c#L108-L113
|
8179e08cac72072bd260796633fec41fdfd5b441
|
AlpacaChat
|
github_2023
|
niw
|
c
|
ggml_vec_set_i8
|
inline static void ggml_vec_set_i8(const int n, int8_t * x, const int8_t v) { for (int i = 0; i < n; ++i) x[i] = v; }
|
//
// fundamental operations
//
|
https://github.com/niw/AlpacaChat/blob/9b5600eb4624cb7739b6df03d3acde76cb7bd2ef/Sources/alpaca.cpp/ggml.c#L1205-L1205
|
9b5600eb4624cb7739b6df03d3acde76cb7bd2ef
|
af
|
github_2023
|
zeldaret
|
c
|
Fado_ConstructStringVectors
|
void Fado_ConstructStringVectors(vc_vector** stringVectors, FairyFileInfo* fileInfo, int numFiles) {
int currentFile;
size_t currentSym;
for (currentFile = 0; currentFile < numFiles; currentFile++) {
FairySym* symtab = fileInfo[currentFile].symtabInfo.sectionData;
stringVectors[currentFile] = vc_vector_create(0x40, sizeof(char**), NULL);
/* Build a vector of pointers to defined symbols' names */
for (currentSym = 0; currentSym < fileInfo[currentFile].symtabInfo.sectionEntryCount; currentSym++) {
if ((symtab[currentSym].st_shndx != STN_UNDEF) &&
Fado_CheckInProgBitsSections(symtab[currentSym].st_shndx, fileInfo[currentFile].progBitsSections)) {
/* Have to pass a double pointer so it copies the pointer instead of the start of the string */
char* stringPtr = &fileInfo[currentFile].strtab[symtab[currentSym].st_name];
assert(vc_vector_push_back(stringVectors[currentFile], &stringPtr));
}
}
}
}
|
/**
* For each input file, construct a vector of pointers to the starts of the strings defined in that file.
*/
|
https://github.com/zeldaret/af/blob/f013a028f42a1b11134bc5f22f28e9f48236b6f0/tools/fado/src/fado.c#L33-L52
|
f013a028f42a1b11134bc5f22f28e9f48236b6f0
|
tuyaZigbee
|
github_2023
|
doctor64
|
c
|
contactSensor_zclReportCmd
|
static void contactSensor_zclReportCmd(u16 clusterId, zclReportCmd_t *pReportCmd)
{
printf("contactSensor_zclReportCmd\n");
}
|
/*********************************************************************
* @fn contactSensor_zclReportCmd
*
* @brief Handler for ZCL Report command.
*
* @param pInHdlrMsg - incoming message to process
*
* @return None
*/
|
https://github.com/doctor64/tuyaZigbee/blob/3a85776223ac4e689871b3b21852b9fc46325835/IASsensor/zcl_contactSensorCb.c#L248-L252
|
3a85776223ac4e689871b3b21852b9fc46325835
|
tuyaZigbee
|
github_2023
|
doctor64
|
c
|
tuyaLight_colorTimerStop
|
static void tuyaLight_colorTimerStop(void)
{
if(colorTimerEvt){
TL_ZB_TIMER_CANCEL(&colorTimerEvt);
}
}
|
/*********************************************************************
* @fn tuyaLight_colorTimerStop
*
* @brief
*
* @param None
*
* @return None
*/
|
https://github.com/doctor64/tuyaZigbee/blob/3a85776223ac4e689871b3b21852b9fc46325835/light/zcl_colorCtrlCb.c#L247-L252
|
3a85776223ac4e689871b3b21852b9fc46325835
|
tuyaZigbee
|
github_2023
|
doctor64
|
c
|
tuyaSwitch_zclStoreSceneRspCmdHandler
|
static void tuyaSwitch_zclStoreSceneRspCmdHandler(storeSceneRsp_t *pStoreSceneRsp)
{
}
|
/*********************************************************************
* @fn tuyaSwitch_zclStoreSceneRspCmdHandler
*
* @brief Handler for ZCL store scene response command.
*
* @param pStoreSceneRsp
*
* @return None
*/
|
https://github.com/doctor64/tuyaZigbee/blob/3a85776223ac4e689871b3b21852b9fc46325835/switch/zcl_tuyaSwitchCb.c#L611-L614
|
3a85776223ac4e689871b3b21852b9fc46325835
|
Flipper-Zero-Game-Boy-Pokemon-Trading
|
github_2023
|
kbembedded
|
c
|
pokemon_stat_calc
|
void pokemon_stat_calc(PokemonData* pdata, DataStat stat) {
furi_assert(pdata);
uint8_t iv;
uint16_t ev;
uint8_t base;
uint8_t level;
uint16_t calc;
level = pokemon_stat_get(pdata, STAT_LEVEL, NONE);
base = table_stat_base_get(
pdata->pokemon_table, pokemon_stat_get(pdata, STAT_NUM, NONE), stat, NONE);
ev = pokemon_stat_get(pdata, stat + STAT_EV_OFFS, NONE);
iv = pokemon_stat_get(pdata, stat + STAT_IV_OFFS, NONE);
/* Gen I and II calculation */
// https://bulbapedia.bulbagarden.net/wiki/Stat#Generations_I_and_II
calc = floor((((2 * (base + iv)) + floor(sqrt(ev) / 4)) * level) / 100);
if(stat == STAT_HP)
calc += (level + 10);
else
calc += 5;
pokemon_stat_set(pdata, stat, NONE, calc);
}
|
/* Calculates stat from current level */
|
https://github.com/kbembedded/Flipper-Zero-Game-Boy-Pokemon-Trading/blob/8769074c727ef3fa2da83e30daaf1aa964349c7e/src/pokemon_data.c#L855-L879
|
8769074c727ef3fa2da83e30daaf1aa964349c7e
|
Linux0.11
|
github_2023
|
TonyWriting
|
c
|
rw_interrupt
|
static void rw_interrupt(void)
{
if (result() != 7 || (ST0 & 0xf8) || (ST1 & 0xbf) || (ST2 & 0x73)) {
if (ST1 & 0x02) {
printk("Drive %d is write protected\n\r",current_drive);
floppy_deselect(current_drive);
end_request(0);
} else
bad_flp_intr();
do_fd_request();
return;
}
if (command == FD_READ && (unsigned long)(CURRENT->buffer) >= 0x100000)
copy_buffer(tmp_floppy_area,CURRENT->buffer);
floppy_deselect(current_drive);
end_request(1);
do_fd_request();
}
|
/*
* Ok, this interrupt is called after a DMA read/write has succeeded,
* so we check the results, and copy any buffers.
*/
|
https://github.com/TonyWriting/Linux0.11/blob/7fecb719e8261e274d827dc43dc1424bd26cc483/kernel/blk_drv/floppy.c#L250-L267
|
7fecb719e8261e274d827dc43dc1424bd26cc483
|
lidar-slam-detection
|
github_2023
|
w111liang222
|
c
|
socket_wait
|
static int socket_wait(int fd, int is_read)
{
fd_set fds, *fdr = 0, *fdw = 0;
struct timeval tv;
int ret;
tv.tv_sec = 5; tv.tv_usec = 0; // 5 seconds time out
FD_ZERO(&fds);
FD_SET(fd, &fds);
if (is_read) fdr = &fds;
else fdw = &fds;
ret = select(fd+1, fdr, fdw, 0, &tv);
#ifndef _WIN32
if (ret == -1) perror("select");
#else
if (ret == 0)
fprintf(stderr, "select time-out\n");
else if (ret == SOCKET_ERROR)
fprintf(stderr, "select: %d\n", WSAGetLastError());
#endif
return ret;
}
|
/* In winsock.h, the type of a socket is SOCKET, which is: "typedef
* u_int SOCKET". An invalid SOCKET is: "(SOCKET)(~0)", or signed
* integer -1. In knetfile.c, I use "int" for socket type
* throughout. This should be improved to avoid confusion.
*
* In Linux/Mac, recv() and read() do almost the same thing. You can see
* in the header file that netread() is simply an alias of read(). In
* Windows, however, they are different and using recv() is mandatory.
*/
/* This function tests if the file handler is ready for reading (or
* writing if is_read==0). */
|
https://github.com/w111liang222/lidar-slam-detection/blob/d57a923b3972d0a0bfdfc0016c32de53c26b9f9f/slam/thirdparty/fast_gicp/thirdparty/nvbio/contrib/htslib/knetfile.c#L60-L80
|
d57a923b3972d0a0bfdfc0016c32de53c26b9f9f
|
lidar-slam-detection
|
github_2023
|
w111liang222
|
c
|
ss_insertionsort
|
static
void
ss_insertionsort(const unsigned char *T, const int *PA,
int *first, int *last, int depth) {
int *i, *j;
int t;
int r;
for(i = last - 2; first <= i; --i) {
for(t = *i, j = i + 1; 0 < (r = ss_compare(T, PA + t, PA + *j, depth));) {
do { *(j - 1) = *j; } while((++j < last) && (*j < 0));
if(last <= j) { break; }
}
if(r == 0) { *j = ~*j; }
*(j - 1) = t;
}
}
|
/* Insertionsort for small size groups */
|
https://github.com/w111liang222/lidar-slam-detection/blob/d57a923b3972d0a0bfdfc0016c32de53c26b9f9f/slam/thirdparty/fast_gicp/thirdparty/nvbio/contrib/libdivsufsort-lite/divsufsort.c#L241-L257
|
d57a923b3972d0a0bfdfc0016c32de53c26b9f9f
|
cs2-sdk
|
github_2023
|
bruhmoment21
|
c
|
operands_set_tsi
|
_INLINE_ void operands_set_tsi(_DInst* di, _Operand* op, _OperandType type, uint16_t size, unsigned int index)
{
op->type = type;
op->index = (uint8_t)index;
op->size = size;
di->usedRegistersMask |= _REGISTERTORCLASS[index];
}
|
/* A helper function to set operand's type, size and index. */
|
https://github.com/bruhmoment21/cs2-sdk/blob/3fdb26b0eba5a7335f011c68bb5c7ef5a3171144/cs2-sdk/libs/distorm/src/operands.c#L51-L57
|
3fdb26b0eba5a7335f011c68bb5c7ef5a3171144
|
microkernel-book
|
github_2023
|
nuta
|
c
|
sys_task_exit
|
__noreturn static void sys_task_exit(void) {
task_exit(EXP_GRACE_EXIT);
}
|
// 実行中タスクを正常終了する。
|
https://github.com/nuta/microkernel-book/blob/8665ccb23eef1136f2bfcd4770e43a3388fba78a/kernel/syscall.c#L120-L122
|
8665ccb23eef1136f2bfcd4770e43a3388fba78a
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
sqlite3TreeViewWindow
|
SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView* pView, const Window* pWin, u8 more) {
int nElement = 0;
if (pWin == 0)
return;
if (pWin->pFilter) {
sqlite3TreeViewItem(pView, "FILTER", 1);
sqlite3TreeViewExpr(pView, pWin->pFilter, 0);
sqlite3TreeViewPop(&pView);
}
sqlite3TreeViewPush(&pView, more);
if (pWin->zName) {
sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin);
} else {
sqlite3TreeViewLine(pView, "OVER (%p)", pWin);
}
if (pWin->zBase)
nElement++;
if (pWin->pOrderBy)
nElement++;
if (pWin->eFrmType)
nElement++;
if (pWin->eExclude)
nElement++;
if (pWin->zBase) {
sqlite3TreeViewPush(&pView, (--nElement) > 0);
sqlite3TreeViewLine(pView, "window: %s", pWin->zBase);
sqlite3TreeViewPop(&pView);
}
if (pWin->pPartition) {
sqlite3TreeViewExprList(pView, pWin->pPartition, nElement > 0, "PARTITION-BY");
}
if (pWin->pOrderBy) {
sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement) > 0, "ORDER-BY");
}
if (pWin->eFrmType) {
char zBuf[30];
const char* zFrmType = "ROWS";
if (pWin->eFrmType == TK_RANGE)
zFrmType = "RANGE";
if (pWin->eFrmType == TK_GROUPS)
zFrmType = "GROUPS";
sqlite3_snprintf(sizeof(zBuf), zBuf, "%s%s", zFrmType, pWin->bImplicitFrame ? " (implied)" : "");
sqlite3TreeViewItem(pView, zBuf, (--nElement) > 0);
sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);
sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);
sqlite3TreeViewPop(&pView);
}
if (pWin->eExclude) {
char zBuf[30];
const char* zExclude;
switch (pWin->eExclude) {
case TK_NO:
zExclude = "NO OTHERS";
break;
case TK_CURRENT:
zExclude = "CURRENT ROW";
break;
case TK_GROUP:
zExclude = "GROUP";
break;
case TK_TIES:
zExclude = "TIES";
break;
default:
sqlite3_snprintf(sizeof(zBuf), zBuf, "invalid(%d)", pWin->eExclude);
zExclude = zBuf;
break;
}
sqlite3TreeViewPush(&pView, 0);
sqlite3TreeViewLine(pView, "EXCLUDE %s", zExclude);
sqlite3TreeViewPop(&pView);
}
sqlite3TreeViewPop(&pView);
}
|
/*
** Generate a human-readable explanation for a Window object
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L31036-L31109
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
winShmUnmap
|
static int winShmUnmap(sqlite3_file* fd, /* Database holding shared memory */
int deleteFlag /* Delete after closing if true */
) {
winFile* pDbFd; /* Database holding shared-memory */
winShm* p; /* The connection to be closed */
winShmNode* pShmNode; /* The underlying shared-memory file */
winShm** pp; /* For looping over sibling connections */
pDbFd = (winFile*)fd;
p = pDbFd->pShm;
if (p == 0)
return SQLITE_OK;
pShmNode = p->pShmNode;
/* Remove connection p from the set of connections associated
** with pShmNode */
sqlite3_mutex_enter(pShmNode->mutex);
for (pp = &pShmNode->pFirst; (*pp) != p; pp = &(*pp)->pNext) {
}
*pp = p->pNext;
/* Free the connection p */
sqlite3_free(p);
pDbFd->pShm = 0;
sqlite3_mutex_leave(pShmNode->mutex);
/* If pShmNode->nRef has reached 0, then close the underlying
** shared-memory file, too */
winShmEnterMutex();
assert(pShmNode->nRef > 0);
pShmNode->nRef--;
if (pShmNode->nRef == 0) {
winShmPurge(pDbFd->pVfs, deleteFlag);
}
winShmLeaveMutex();
return SQLITE_OK;
}
|
/*
** Close a connection to shared-memory. Delete the underlying
** storage if deleteFlag is true.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L47001-L47038
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
memdbDeviceCharacteristics
|
static int memdbDeviceCharacteristics(sqlite3_file* pFile) {
UNUSED_PARAMETER(pFile);
return SQLITE_IOCAP_ATOMIC | SQLITE_IOCAP_POWERSAFE_OVERWRITE | SQLITE_IOCAP_SAFE_APPEND | SQLITE_IOCAP_SEQUENTIAL;
}
|
/*
** Return the device characteristic flags supported by an memdb-file.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L49514-L49517
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
sqlite3PagerSharedLock
|
SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager* pPager) {
int rc = SQLITE_OK; /* Return code */
/* This routine is only called from b-tree and only when there are no
** outstanding pages. This implies that the pager state should either
** be OPEN or READER. READER is only possible if the pager is or was in
** exclusive access mode. */
assert(sqlite3PcacheRefCount(pPager->pPCache) == 0);
assert(assert_pager_state(pPager));
assert(pPager->eState == PAGER_OPEN || pPager->eState == PAGER_READER);
assert(pPager->errCode == SQLITE_OK);
if (!pagerUseWal(pPager) && pPager->eState == PAGER_OPEN) {
int bHotJournal = 1; /* True if there exists a hot journal-file */
assert(!MEMDB);
assert(pPager->tempFile == 0 || pPager->eLock == EXCLUSIVE_LOCK);
rc = pager_wait_on_lock(pPager, SHARED_LOCK);
if (rc != SQLITE_OK) {
assert(pPager->eLock == NO_LOCK || pPager->eLock == UNKNOWN_LOCK);
goto failed;
}
/* If a journal file exists, and there is no RESERVED lock on the
** database file, then it either needs to be played back or deleted.
*/
if (pPager->eLock <= SHARED_LOCK) {
rc = hasHotJournal(pPager, &bHotJournal);
}
if (rc != SQLITE_OK) {
goto failed;
}
if (bHotJournal) {
if (pPager->readOnly) {
rc = SQLITE_READONLY_ROLLBACK;
goto failed;
}
/* Get an EXCLUSIVE lock on the database file. At this point it is
** important that a RESERVED lock is not obtained on the way to the
** EXCLUSIVE lock. If it were, another process might open the
** database file, detect the RESERVED lock, and conclude that the
** database is safe to read while this process is still rolling the
** hot-journal back.
**
** Because the intermediate RESERVED lock is not requested, any
** other process attempting to access the database file will get to
** this point in the code and fail to obtain its own EXCLUSIVE lock
** on the database file.
**
** Unless the pager is in locking_mode=exclusive mode, the lock is
** downgraded to SHARED_LOCK before this function returns.
*/
rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
if (rc != SQLITE_OK) {
goto failed;
}
/* If it is not already open and the file exists on disk, open the
** journal for read/write access. Write access is required because
** in exclusive-access mode the file descriptor will be kept open
** and possibly used for a transaction later on. Also, write-access
** is usually required to finalize the journal in journal_mode=persist
** mode (and also for journal_mode=truncate on some systems).
**
** If the journal does not exist, it usually means that some
** other connection managed to get in and roll it back before
** this connection obtained the exclusive lock above. Or, it
** may mean that the pager was in the error-state when this
** function was called and the journal file does not exist.
*/
if (!isOpen(pPager->jfd) && pPager->journalMode != PAGER_JOURNALMODE_OFF) {
sqlite3_vfs* const pVfs = pPager->pVfs;
int bExists; /* True if journal file exists */
rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);
if (rc == SQLITE_OK && bExists) {
int fout = 0;
int f = SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL;
assert(!pPager->tempFile);
rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);
assert(rc != SQLITE_OK || isOpen(pPager->jfd));
if (rc == SQLITE_OK && fout & SQLITE_OPEN_READONLY) {
rc = SQLITE_CANTOPEN_BKPT;
sqlite3OsClose(pPager->jfd);
}
}
}
/* Playback and delete the journal. Drop the database write
** lock and reacquire the read lock. Purge the cache before
** playing back the hot-journal so that we don't end up with
** an inconsistent cache. Sync the hot journal before playing
** it back since the process that crashed and left the hot journal
** probably did not sync it and we are required to always sync
** the journal before playing it back.
*/
if (isOpen(pPager->jfd)) {
assert(rc == SQLITE_OK);
rc = pagerSyncHotJournal(pPager);
if (rc == SQLITE_OK) {
rc = pager_playback(pPager, !pPager->tempFile);
pPager->eState = PAGER_OPEN;
}
} else if (!pPager->exclusiveMode) {
pagerUnlockDb(pPager, SHARED_LOCK);
}
if (rc != SQLITE_OK) {
/* This branch is taken if an error occurs while trying to open
** or roll back a hot-journal while holding an EXCLUSIVE lock. The
** pager_unlock() routine will be called before returning to unlock
** the file. If the unlock attempt fails, then Pager.eLock must be
** set to UNKNOWN_LOCK (see the comment above the #define for
** UNKNOWN_LOCK above for an explanation).
**
** In order to get pager_unlock() to do this, set Pager.eState to
** PAGER_ERROR now. This is not actually counted as a transition
** to ERROR state in the state diagram at the top of this file,
** since we know that the same call to pager_unlock() will very
** shortly transition the pager object to the OPEN state. Calling
** assert_pager_state() would fail now, as it should not be possible
** to be in ERROR state when there are zero outstanding page
** references.
*/
pager_error(pPager, rc);
goto failed;
}
assert(pPager->eState == PAGER_OPEN);
assert((pPager->eLock == SHARED_LOCK) || (pPager->exclusiveMode && pPager->eLock > SHARED_LOCK));
}
if (!pPager->tempFile && pPager->hasHeldSharedLock) {
/* The shared-lock has just been acquired then check to
** see if the database has been modified. If the database has changed,
** flush the cache. The hasHeldSharedLock flag prevents this from
** occurring on the very first access to a file, in order to save a
** single unnecessary sqlite3OsRead() call at the start-up.
**
** Database changes are detected by looking at 15 bytes beginning
** at offset 24 into the file. The first 4 of these 16 bytes are
** a 32-bit counter that is incremented with each change. The
** other bytes change randomly with each file change when
** a codec is in use.
**
** There is a vanishingly small chance that a change will not be
** detected. The chance of an undetected change is so small that
** it can be neglected.
*/
char dbFileVers[sizeof(pPager->dbFileVers)];
IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
if (rc != SQLITE_OK) {
if (rc != SQLITE_IOERR_SHORT_READ) {
goto failed;
}
memset(dbFileVers, 0, sizeof(dbFileVers));
}
if (memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers)) != 0) {
pager_reset(pPager);
/* Unmap the database file. It is possible that external processes
** may have truncated the database file and then extended it back
** to its original size while this process was not holding a lock.
** In this case there may exist a Pager.pMap mapping that appears
** to be the right size but is not actually valid. Avoid this
** possibility by unmapping the db here. */
if (USEFETCH(pPager)) {
sqlite3OsUnfetch(pPager->fd, 0, 0);
}
}
}
/* If there is a WAL file in the file-system, open this database in WAL
** mode. Otherwise, the following function call is a no-op.
*/
rc = pagerOpenWalIfPresent(pPager);
#ifndef SQLITE_OMIT_WAL
assert(pPager->pWal == 0 || rc == SQLITE_OK);
#endif
}
if (pagerUseWal(pPager)) {
assert(rc == SQLITE_OK);
rc = pagerBeginReadTransaction(pPager);
}
if (pPager->tempFile == 0 && pPager->eState == PAGER_OPEN && rc == SQLITE_OK) {
rc = pagerPagecount(pPager, &pPager->dbSize);
}
failed:
if (rc != SQLITE_OK) {
assert(!MEMDB);
pager_unlock(pPager);
assert(pPager->eState == PAGER_OPEN);
} else {
pPager->eState = PAGER_READER;
pPager->hasHeldSharedLock = 1;
}
return rc;
}
|
/*
** This function is called to obtain a shared lock on the database file.
** It is illegal to call sqlite3PagerGet() until after this function
** has been successfully called. If a shared-lock is already held when
** this function is called, it is a no-op.
**
** The following operations are also performed by this function.
**
** 1) If the pager is currently in PAGER_OPEN state (no lock held
** on the database file), then an attempt is made to obtain a
** SHARED lock on the database file. Immediately after obtaining
** the SHARED lock, the file-system is checked for a hot-journal,
** which is played back if present. Following any hot-journal
** rollback, the contents of the cache are validated by checking
** the 'change-counter' field of the database file header and
** discarded if they are found to be invalid.
**
** 2) If the pager is running in exclusive-mode, and there are currently
** no outstanding references to any pages, and is in the error state,
** then an attempt is made to clear the error state by discarding
** the contents of the page cache and rolling back any open journal
** file.
**
** If everything is successful, SQLITE_OK is returned. If an IO error
** occurs while locking the database, checking for a hot-journal file or
** rolling back a journal file, the IO error code is returned.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L58291-L58495
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
sqlite3BtreeSeekCount
|
SQLITE_PRIVATE sqlite3_uint64 sqlite3BtreeSeekCount(Btree* pBt) {
u64 n = pBt->nSeek;
pBt->nSeek = 0;
return n;
}
|
/*
** Return and reset the seek counter for a Btree object.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L66055-L66059
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
sqlite3VdbeIOTraceSql
|
SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe* p) {
int nOp = p->nOp;
VdbeOp* pOp;
if (sqlite3IoTrace == 0)
return;
if (nOp < 1)
return;
pOp = &p->aOp[0];
if (pOp->opcode == OP_Init && pOp->p4.z != 0) {
int i, j;
char z[1000];
sqlite3_snprintf(sizeof(z), z, "%s", pOp->p4.z);
for (i = 0; sqlite3Isspace(z[i]); i++) {
}
for (j = 0; z[i]; i++) {
if (sqlite3Isspace(z[i])) {
if (z[i - 1] != ' ') {
z[j++] = ' ';
}
} else {
z[j++] = z[i];
}
}
z[j] = 0;
sqlite3IoTrace("SQL %s\n", z);
}
}
|
/*
** Print an IOTRACE message showing SQL content.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L82084-L82110
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
sqlite3_blob_bytes
|
SQLITE_API int sqlite3_blob_bytes(sqlite3_blob* pBlob) {
Incrblob* p = (Incrblob*)pBlob;
return (p && p->pStmt) ? p->nByte : 0;
}
|
/*
** Query a blob handle for the size of the data.
**
** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
** so no mutex is required for access.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L96615-L96618
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
jsonIs4Hex
|
static int jsonIs4Hex(const char* z) {
int i;
for (i = 0; i < 4; i++)
if (!sqlite3Isxdigit(z[i]))
return 0;
return 1;
}
|
/*
** Return true if z[] begins with 4 (or more) hexadecimal digits
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L194002-L194008
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
jsonEachColumn
|
static int jsonEachColumn(sqlite3_vtab_cursor* cur, /* The cursor */
sqlite3_context* ctx, /* First argument to sqlite3_result_...() */
int i /* Which column to return */
) {
JsonEachCursor* p = (JsonEachCursor*)cur;
JsonNode* pThis = &p->sParse.aNode[p->i];
switch (i) {
case JEACH_KEY: {
if (p->i == 0)
break;
if (p->eType == JSON_OBJECT) {
jsonReturn(pThis, ctx, 0);
} else if (p->eType == JSON_ARRAY) {
u32 iKey;
if (p->bRecursive) {
if (p->iRowid == 0)
break;
assert(p->sParse.aNode[p->sParse.aUp[p->i]].eU == 3);
iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey;
} else {
iKey = p->iRowid;
}
sqlite3_result_int64(ctx, (sqlite3_int64)iKey);
}
break;
}
case JEACH_VALUE: {
if (pThis->jnFlags & JNODE_LABEL)
pThis++;
jsonReturn(pThis, ctx, 0);
break;
}
case JEACH_TYPE: {
if (pThis->jnFlags & JNODE_LABEL)
pThis++;
sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC);
break;
}
case JEACH_ATOM: {
if (pThis->jnFlags & JNODE_LABEL)
pThis++;
if (pThis->eType >= JSON_ARRAY)
break;
jsonReturn(pThis, ctx, 0);
break;
}
case JEACH_ID: {
sqlite3_result_int64(ctx, (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL) != 0));
break;
}
case JEACH_PARENT: {
if (p->i > p->iBegin && p->bRecursive) {
sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]);
}
break;
}
case JEACH_FULLKEY: {
JsonString x;
jsonInit(&x, ctx);
if (p->bRecursive) {
jsonEachComputePath(p, &x, p->i);
} else {
if (p->zRoot) {
jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));
} else {
jsonAppendChar(&x, '$');
}
if (p->eType == JSON_ARRAY) {
jsonPrintf(30, &x, "[%d]", p->iRowid);
} else if (p->eType == JSON_OBJECT) {
jsonAppendObjectPathElement(&x, pThis);
}
}
jsonResult(&x);
break;
}
case JEACH_PATH: {
if (p->bRecursive) {
JsonString x;
jsonInit(&x, ctx);
jsonEachComputePath(p, &x, p->sParse.aUp[p->i]);
jsonResult(&x);
break;
}
/* For json_each() path and root are the same so fall through
** into the root case */
/* no break */ deliberate_fall_through
}
default: {
const char* zRoot = p->zRoot;
if (zRoot == 0)
zRoot = "$";
sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);
break;
}
case JEACH_JSON: {
assert(i == JEACH_JSON);
sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
break;
}
}
return SQLITE_OK;
}
|
/* Return the value of a column */
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L195566-L195668
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
react-native-nitro-sqlite
|
github_2023
|
margelo
|
c
|
sessionDiffHooks
|
static void sessionDiffHooks(sqlite3_session* pSession, SessionDiffCtx* pDiffCtx) {
pSession->hook.pCtx = (void*)pDiffCtx;
pSession->hook.xOld = sessionDiffOld;
pSession->hook.xNew = sessionDiffNew;
pSession->hook.xCount = sessionDiffCount;
pSession->hook.xDepth = sessionDiffDepth;
}
|
/*
** Install the diff hooks on the session object passed as the only
** argument.
*/
|
https://github.com/margelo/react-native-nitro-sqlite/blob/09d9159c7d3aca803c69fda2b626868338acbb50/package/cpp/sqlite/sqlite3.c#L211450-L211456
|
09d9159c7d3aca803c69fda2b626868338acbb50
|
Nissan-LEAF-Battery-Upgrade
|
github_2023
|
dalathegreat
|
c
|
HAL_CAN_RxFifo1FullCallback
|
__weak void HAL_CAN_RxFifo1FullCallback(CAN_HandleTypeDef *hcan)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hcan);
/* NOTE : This function Should not be modified, when the callback is needed,
the HAL_CAN_RxFifo1FullCallback could be implemented in the user
file
*/
}
|
/**
* @brief Rx FIFO 1 full callback.
* @param hcan pointer to a CAN_HandleTypeDef structure that contains
* the configuration information for the specified CAN.
* @retval None
*/
|
https://github.com/dalathegreat/Nissan-LEAF-Battery-Upgrade/blob/96cee856d7fb38b2e72736ddfccb8e07eb7bb594/Software/CANBRIDGE-2port/source/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c#L2259-L2268
|
96cee856d7fb38b2e72736ddfccb8e07eb7bb594
|
Nissan-LEAF-Battery-Upgrade
|
github_2023
|
dalathegreat
|
c
|
HAL_RCC_GetClockConfig
|
void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency)
{
/* Check the parameters */
assert_param(RCC_ClkInitStruct != NULL);
assert_param(pFLatency != NULL);
/* Set all possible values for the Clock type parameter --------------------*/
RCC_ClkInitStruct->ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
/* Get the SYSCLK configuration --------------------------------------------*/
RCC_ClkInitStruct->SYSCLKSource = (uint32_t)(RCC->CFGR & RCC_CFGR_SW);
/* Get the HCLK configuration ----------------------------------------------*/
RCC_ClkInitStruct->AHBCLKDivider = (uint32_t)(RCC->CFGR & RCC_CFGR_HPRE);
/* Get the APB1 configuration ----------------------------------------------*/
RCC_ClkInitStruct->APB1CLKDivider = (uint32_t)(RCC->CFGR & RCC_CFGR_PPRE1);
/* Get the APB2 configuration ----------------------------------------------*/
RCC_ClkInitStruct->APB2CLKDivider = (uint32_t)((RCC->CFGR & RCC_CFGR_PPRE2) >> 3);
#if defined(FLASH_ACR_LATENCY)
/* Get the Flash Wait State (Latency) configuration ------------------------*/
*pFLatency = (uint32_t)(FLASH->ACR & FLASH_ACR_LATENCY);
#else
/* For VALUE lines devices, only LATENCY_0 can be set*/
*pFLatency = (uint32_t)FLASH_LATENCY_0;
#endif
}
|
/**
* @brief Get the RCC_ClkInitStruct according to the internal
* RCC configuration registers.
* @param RCC_ClkInitStruct pointer to an RCC_ClkInitTypeDef structure that
* contains the current clock configuration.
* @param pFLatency Pointer on the Flash Latency.
* @retval None
*/
|
https://github.com/dalathegreat/Nissan-LEAF-Battery-Upgrade/blob/96cee856d7fb38b2e72736ddfccb8e07eb7bb594/Software/CANBRIDGE-2port/source/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c#L1312-L1340
|
96cee856d7fb38b2e72736ddfccb8e07eb7bb594
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
zipfileColumn
|
static int zipfileColumn(
sqlite3_vtab_cursor *cur, /* The cursor */
sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
int i /* Which column to return */
){
ZipfileCsr *pCsr = (ZipfileCsr*)cur;
ZipfileCDS *pCDS = &pCsr->pCurrent->cds;
int rc = SQLITE_OK;
switch( i ){
case 0: /* name */
sqlite3_result_text(ctx, pCDS->zFile, -1, SQLITE_TRANSIENT);
break;
case 1: /* mode */
/* TODO: Whether or not the following is correct surely depends on
** the platform on which the archive was created. */
sqlite3_result_int(ctx, pCDS->iExternalAttr >> 16);
break;
case 2: { /* mtime */
sqlite3_result_int64(ctx, pCsr->pCurrent->mUnixTime);
break;
}
case 3: { /* sz */
if( sqlite3_vtab_nochange(ctx)==0 ){
sqlite3_result_int64(ctx, pCDS->szUncompressed);
}
break;
}
case 4: /* rawdata */
if( sqlite3_vtab_nochange(ctx) ) break;
case 5: { /* data */
if( i==4 || pCDS->iCompression==0 || pCDS->iCompression==8 ){
int sz = pCDS->szCompressed;
int szFinal = pCDS->szUncompressed;
if( szFinal>0 ){
u8 *aBuf;
u8 *aFree = 0;
if( pCsr->pCurrent->aData ){
aBuf = pCsr->pCurrent->aData;
}else{
aBuf = aFree = sqlite3_malloc64(sz);
if( aBuf==0 ){
rc = SQLITE_NOMEM;
}else{
FILE *pFile = pCsr->pFile;
if( pFile==0 ){
pFile = ((ZipfileTab*)(pCsr->base.pVtab))->pWriteFd;
}
rc = zipfileReadData(pFile, aBuf, sz, pCsr->pCurrent->iDataOff,
&pCsr->base.pVtab->zErrMsg
);
}
}
if( rc==SQLITE_OK ){
if( i==5 && pCDS->iCompression ){
zipfileInflate(ctx, aBuf, sz, szFinal);
}else{
sqlite3_result_blob(ctx, aBuf, sz, SQLITE_TRANSIENT);
}
}
sqlite3_free(aFree);
}else{
/* Figure out if this is a directory or a zero-sized file. Consider
** it to be a directory either if the mode suggests so, or if
** the final character in the name is '/'. */
u32 mode = pCDS->iExternalAttr >> 16;
if( !(mode & S_IFDIR) && pCDS->zFile[pCDS->nFile-1]!='/' ){
sqlite3_result_blob(ctx, "", 0, SQLITE_STATIC);
}
}
}
break;
}
case 6: /* method */
sqlite3_result_int(ctx, pCDS->iCompression);
break;
default: /* z */
assert( i==7 );
sqlite3_result_int64(ctx, pCsr->iId);
break;
}
return rc;
}
|
/*
** Return values of columns for the row at which the series_cursor
** is currently pointing.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/shell.c#L8711-L8793
|
099aec4292676b58c179e4d6e11635e624fcd289
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
read32bits
|
static int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){
unsigned char ac[4];
int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);
if( rc==SQLITE_OK ){
*pRes = sqlite3Get4byte(ac);
}
return rc;
}
|
/*
** Read a 32-bit integer from the given file descriptor. Store the integer
** that is read in *pRes. Return SQLITE_OK if everything worked, or an
** error code is something goes wrong.
**
** All values are stored on disk as big-endian.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/sqlite3.c#L56589-L56596
|
099aec4292676b58c179e4d6e11635e624fcd289
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
sqlite3PagerCommitPhaseOne
|
SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(
Pager *pPager, /* Pager object */
const char *zSuper, /* If not NULL, the super-journal name */
int noSync /* True to omit the xSync on the db file */
){
int rc = SQLITE_OK; /* Return code */
assert( pPager->eState==PAGER_WRITER_LOCKED
|| pPager->eState==PAGER_WRITER_CACHEMOD
|| pPager->eState==PAGER_WRITER_DBMOD
|| pPager->eState==PAGER_ERROR
);
assert( assert_pager_state(pPager) );
/* If a prior error occurred, report that error again. */
if( NEVER(pPager->errCode) ) return pPager->errCode;
/* Provide the ability to easily simulate an I/O error during testing */
if( sqlite3FaultSim(400) ) return SQLITE_IOERR;
PAGERTRACE(("DATABASE SYNC: File=%s zSuper=%s nSize=%d\n",
pPager->zFilename, zSuper, pPager->dbSize));
/* If no database changes have been made, return early. */
if( pPager->eState<PAGER_WRITER_CACHEMOD ) return SQLITE_OK;
assert( MEMDB==0 || pPager->tempFile );
assert( isOpen(pPager->fd) || pPager->tempFile );
if( 0==pagerFlushOnCommit(pPager, 1) ){
/* If this is an in-memory db, or no pages have been written to, or this
** function has already been called, it is mostly a no-op. However, any
** backup in progress needs to be restarted. */
sqlite3BackupRestart(pPager->pBackup);
}else{
PgHdr *pList;
if( pagerUseWal(pPager) ){
PgHdr *pPageOne = 0;
pList = sqlite3PcacheDirtyList(pPager->pPCache);
if( pList==0 ){
/* Must have at least one page for the WAL commit flag.
** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */
rc = sqlite3PagerGet(pPager, 1, &pPageOne, 0);
pList = pPageOne;
pList->pDirty = 0;
}
assert( rc==SQLITE_OK );
if( ALWAYS(pList) ){
rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1);
}
sqlite3PagerUnref(pPageOne);
if( rc==SQLITE_OK ){
sqlite3PcacheCleanAll(pPager->pPCache);
}
}else{
/* The bBatch boolean is true if the batch-atomic-write commit method
** should be used. No rollback journal is created if batch-atomic-write
** is enabled.
*/
#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
sqlite3_file *fd = pPager->fd;
int bBatch = zSuper==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */
&& (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC)
&& !pPager->noSync
&& sqlite3JournalIsInMemory(pPager->jfd);
#else
# define bBatch 0
#endif
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
/* The following block updates the change-counter. Exactly how it
** does this depends on whether or not the atomic-update optimization
** was enabled at compile time, and if this transaction meets the
** runtime criteria to use the operation:
**
** * The file-system supports the atomic-write property for
** blocks of size page-size, and
** * This commit is not part of a multi-file transaction, and
** * Exactly one page has been modified and store in the journal file.
**
** If the optimization was not enabled at compile time, then the
** pager_incr_changecounter() function is called to update the change
** counter in 'indirect-mode'. If the optimization is compiled in but
** is not applicable to this transaction, call sqlite3JournalCreate()
** to make sure the journal file has actually been created, then call
** pager_incr_changecounter() to update the change-counter in indirect
** mode.
**
** Otherwise, if the optimization is both enabled and applicable,
** then call pager_incr_changecounter() to update the change-counter
** in 'direct' mode. In this case the journal file will never be
** created for this transaction.
*/
if( bBatch==0 ){
PgHdr *pPg;
assert( isOpen(pPager->jfd)
|| pPager->journalMode==PAGER_JOURNALMODE_OFF
|| pPager->journalMode==PAGER_JOURNALMODE_WAL
);
if( !zSuper && isOpen(pPager->jfd)
&& pPager->journalOff==jrnlBufferSize(pPager)
&& pPager->dbSize>=pPager->dbOrigSize
&& (!(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)
){
/* Update the db file change counter via the direct-write method. The
** following call will modify the in-memory representation of page 1
** to include the updated change counter and then write page 1
** directly to the database file. Because of the atomic-write
** property of the host file-system, this is safe.
*/
rc = pager_incr_changecounter(pPager, 1);
}else{
rc = sqlite3JournalCreate(pPager->jfd);
if( rc==SQLITE_OK ){
rc = pager_incr_changecounter(pPager, 0);
}
}
}
#else /* SQLITE_ENABLE_ATOMIC_WRITE */
#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
if( zSuper ){
rc = sqlite3JournalCreate(pPager->jfd);
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
assert( bBatch==0 );
}
#endif
rc = pager_incr_changecounter(pPager, 0);
#endif /* !SQLITE_ENABLE_ATOMIC_WRITE */
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
/* Write the super-journal name into the journal file. If a
** super-journal file name has already been written to the journal file,
** or if zSuper is NULL (no super-journal), then this call is a no-op.
*/
rc = writeSuperJournal(pPager, zSuper);
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
/* Sync the journal file and write all dirty pages to the database.
** If the atomic-update optimization is being used, this sync will not
** create the journal file or perform any real IO.
**
** Because the change-counter page was just modified, unless the
** atomic-update optimization is used it is almost certain that the
** journal requires a sync here. However, in locking_mode=exclusive
** on a system under memory pressure it is just possible that this is
** not the case. In this case it is likely enough that the redundant
** xSync() call will be changed to a no-op by the OS anyhow.
*/
rc = syncJournal(pPager, 0);
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
pList = sqlite3PcacheDirtyList(pPager->pPCache);
#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
if( bBatch ){
rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);
if( rc==SQLITE_OK ){
rc = pager_write_pagelist(pPager, pList);
if( rc==SQLITE_OK ){
rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);
}
if( rc!=SQLITE_OK ){
sqlite3OsFileControlHint(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0);
}
}
if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){
rc = sqlite3JournalCreate(pPager->jfd);
if( rc!=SQLITE_OK ){
sqlite3OsClose(pPager->jfd);
goto commit_phase_one_exit;
}
bBatch = 0;
}else{
sqlite3OsClose(pPager->jfd);
}
}
#endif /* SQLITE_ENABLE_BATCH_ATOMIC_WRITE */
if( bBatch==0 ){
rc = pager_write_pagelist(pPager, pList);
}
if( rc!=SQLITE_OK ){
assert( rc!=SQLITE_IOERR_BLOCKED );
goto commit_phase_one_exit;
}
sqlite3PcacheCleanAll(pPager->pPCache);
/* If the file on disk is smaller than the database image, use
** pager_truncate to grow the file here. This can happen if the database
** image was extended as part of the current transaction and then the
** last page in the db image moved to the free-list. In this case the
** last page is never written out to disk, leaving the database file
** undersized. Fix this now if it is the case. */
if( pPager->dbSize>pPager->dbFileSize ){
Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_SJ_PGNO(pPager));
assert( pPager->eState==PAGER_WRITER_DBMOD );
rc = pager_truncate(pPager, nNew);
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
}
/* Finally, sync the database file. */
if( !noSync ){
rc = sqlite3PagerSync(pPager, zSuper);
}
IOTRACE(("DBSYNC %p\n", pPager))
}
}
commit_phase_one_exit:
if( rc==SQLITE_OK && !pagerUseWal(pPager) ){
pPager->eState = PAGER_WRITER_FINISHED;
}
return rc;
}
|
/*
** Sync the database file for the pager pPager. zSuper points to the name
** of a super-journal file that should be written into the individual
** journal file. zSuper may be NULL, which is interpreted as no
** super-journal (a single database transaction).
**
** This routine ensures that:
**
** * The database file change-counter is updated,
** * the journal is synced (unless the atomic-write optimization is used),
** * all dirty pages are written to the database file,
** * the database file is truncated (if required), and
** * the database file synced.
**
** The only thing that remains to commit the transaction is to finalize
** (delete, truncate or zero the first part of) the journal file (or
** delete the super-journal file if specified).
**
** Note that if zSuper==NULL, this does not overwrite a previous value
** passed to an sqlite3PagerCommitPhaseOne() call.
**
** If the final parameter - noSync - is true, then the database file itself
** is not synced. The caller must call sqlite3PagerSync() directly to
** sync the database file before calling CommitPhaseTwo() to delete the
** journal file in this case.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/sqlite3.c#L61867-L62079
|
099aec4292676b58c179e4d6e11635e624fcd289
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
sqlite3PagerWalFramesize
|
SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
assert( pPager->eState>=PAGER_READER );
return sqlite3WalFramesize(pPager->pWal);
}
|
/*
** A read-lock must be held on the pager when this function is called. If
** the pager is in WAL mode and the WAL file currently contains one or more
** frames, return the size in bytes of the page images stored within the
** WAL frames. Otherwise, if this is not a WAL database or the WAL file
** is empty, return 0.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/sqlite3.c#L63209-L63212
|
099aec4292676b58c179e4d6e11635e624fcd289
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
geopolyCcwFunc
|
static void geopolyCcwFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
(void)argc;
if( p ){
if( geopolyArea(p)<0.0 ){
int ii, jj;
for(ii=1, jj=p->nVertex-1; ii<jj; ii++, jj--){
GeoCoord t = GeoX(p,ii);
GeoX(p,ii) = GeoX(p,jj);
GeoX(p,jj) = t;
t = GeoY(p,ii);
GeoY(p,ii) = GeoY(p,jj);
GeoY(p,jj) = t;
}
}
sqlite3_result_blob(context, p->hdr,
4+8*p->nVertex, SQLITE_TRANSIENT);
sqlite3_free(p);
}
}
|
/*
** Implementation of the geopoly_ccw(X) function.
**
** If the rotation of polygon X is clockwise (incorrect) instead of
** counter-clockwise (the correct winding order according to RFC7946)
** then reverse the order of the vertexes in polygon X.
**
** In other words, this routine returns a CCW polygon regardless of the
** winding order of its input.
**
** Use this routine to sanitize historical inputs that that sometimes
** contain polygons that wind in the wrong direction.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/sqlite3.c#L206454-L206477
|
099aec4292676b58c179e4d6e11635e624fcd289
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
geopolyBBoxFunc
|
static void geopolyBBoxFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
GeoPoly *p = geopolyBBox(context, argv[0], 0, 0);
(void)argc;
if( p ){
sqlite3_result_blob(context, p->hdr,
4+8*p->nVertex, SQLITE_TRANSIENT);
sqlite3_free(p);
}
}
|
/*
** Implementation of the geopoly_bbox(X) SQL function.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/sqlite3.c#L206619-L206631
|
099aec4292676b58c179e4d6e11635e624fcd289
|
sqlwrite
|
github_2023
|
plasma-umass
|
c
|
fts5DecodeStructure
|
static void fts5DecodeStructure(
int *pRc, /* IN/OUT: error code */
Fts5Buffer *pBuf,
const u8 *pBlob, int nBlob
){
int rc; /* Return code */
Fts5Structure *p = 0; /* Decoded structure object */
rc = fts5StructureDecode(pBlob, nBlob, 0, &p);
if( rc!=SQLITE_OK ){
*pRc = rc;
return;
}
fts5DebugStructure(pRc, pBuf, p);
fts5StructureRelease(p);
}
|
/*
** This is part of the fts5_decode() debugging aid.
**
** Arguments pBlob/nBlob contain a serialized Fts5Structure object. This
** function appends a human-readable representation of the same object
** to the buffer passed as the second argument.
*/
|
https://github.com/plasma-umass/sqlwrite/blob/099aec4292676b58c179e4d6e11635e624fcd289/sqlite3.c#L237040-L237056
|
099aec4292676b58c179e4d6e11635e624fcd289
|
Understanding-VITS
|
github_2023
|
JunityZhan
|
c
|
__Pyx_pretend_to_initialize
|
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
|
/* __GNUC__ */
|
https://github.com/JunityZhan/Understanding-VITS/blob/908a46a2af87606c3039a402cc7af3984ef8aafd/monotonic_align/core.c#L817-L817
|
908a46a2af87606c3039a402cc7af3984ef8aafd
|
ragnar
|
github_2023
|
cococry
|
c
|
switchclientdesktop
|
void
switchclientdesktop(state_t* s, client_t* cl, int32_t desktop) {
char** names = (char**)malloc(s->monfocus->desktopcount * sizeof(char*));
for (size_t i = 0; i < s->monfocus->desktopcount ; i++) {
names[i] = strdup(s->monfocus->activedesktops[i].name);
}
// Create the desktop if it was not created yet
if(!strinarr(names, s->monfocus->desktopcount, s->config.desktopnames[desktop])) {
createdesktop(s, desktop, s->monfocus);
}
free(names);
cl->desktop = desktop;
if(cl == s->focus) {
unfocusclient(s, cl);
}
hideclient(s, cl);
makelayout(s, s->monfocus);
}
|
/**
* @brief Switches the desktop of a given client and hides that client.
*
* @param s The window manager's state
* @param cl The client to switch the desktop of
* @param desktop The desktop to set the client of
*/
|
https://github.com/cococry/ragnar/blob/8b95f82411d8956a29fb556cc6a9ab721492e985/src/ragnar.c#L1283-L1301
|
8b95f82411d8956a29fb556cc6a9ab721492e985
|
Server
|
github_2023
|
2004Scape
|
c
|
makeMaps_e
|
static
void makeMaps_e ( EState* s )
{
Int32 i;
s->nInUse = 0;
for (i = 0; i < 256; i++)
if (s->inUse[i]) {
s->unseqToSeq[i] = s->nInUse;
s->nInUse++;
}
}
|
/*---------------------------------------------------*/
/*--- The back end proper ---*/
/*---------------------------------------------------*/
/*---------------------------------------------------*/
|
https://github.com/2004Scape/Server/blob/408c538428f8fb0cd7fd387ebece0a8c9cbcac57/src/3rdparty/bzip2-wasm/bzip2-1.0.8/compress.c#L105-L115
|
408c538428f8fb0cd7fd387ebece0a8c9cbcac57
|
Whisper-Finetune
|
github_2023
|
yeyupiaoling
|
c
|
ggml_compute_forward_conv_transpose_1d_f16_f32
|
static void ggml_compute_forward_conv_transpose_1d_f16_f32(
const struct ggml_compute_params * params,
const struct ggml_tensor * src0,
const struct ggml_tensor * src1,
struct ggml_tensor * dst) {
GGML_ASSERT(src0->type == GGML_TYPE_F16);
GGML_ASSERT(src1->type == GGML_TYPE_F32);
GGML_ASSERT( dst->type == GGML_TYPE_F32);
int64_t t0 = ggml_perf_time_us();
UNUSED(t0);
GGML_TENSOR_BINARY_OP_LOCALS
const int ith = params->ith;
const int nth = params->nth;
const int nk = ne00*ne01*ne02;
GGML_ASSERT(nb00 == sizeof(ggml_fp16_t));
GGML_ASSERT(nb10 == sizeof(float));
if (params->type == GGML_TASK_INIT) {
memset(params->wdata, 0, params->wsize);
// permute kernel data (src0) from (K x Cout x Cin) to (Cin x K x Cout)
{
ggml_fp16_t * const wdata = (ggml_fp16_t *) params->wdata + 0;
for (int64_t i02 = 0; i02 < ne02; i02++) {
for (int64_t i01 = 0; i01 < ne01; i01++) {
const ggml_fp16_t * const src = (ggml_fp16_t *)((char *) src0->data + i02*nb02 + i01*nb01);
ggml_fp16_t * dst_data = wdata + i01*ne00*ne02;
for (int64_t i00 = 0; i00 < ne00; i00++) {
dst_data[i00*ne02 + i02] = src[i00];
}
}
}
}
// permute source data (src1) from (L x Cin) to (Cin x L)
{
ggml_fp16_t * const wdata = (ggml_fp16_t *) params->wdata + nk;
ggml_fp16_t * dst_data = wdata;
for (int64_t i11 = 0; i11 < ne11; i11++) {
const float * const src = (float *)((char *) src1->data + i11*nb11);
for (int64_t i10 = 0; i10 < ne10; i10++) {
dst_data[i10*ne11 + i11] = GGML_FP32_TO_FP16(src[i10]);
}
}
}
// need to zero dst since we are accumulating into it
memset(dst->data, 0, ggml_nbytes(dst));
return;
}
if (params->type == GGML_TASK_FINALIZE) {
return;
}
const int32_t s0 = ((const int32_t*)(dst->op_params))[0];
// total rows in dst
const int nr = ne1;
// rows per thread
const int dr = (nr + nth - 1)/nth;
// row range for this thread
const int ir0 = dr*ith;
const int ir1 = MIN(ir0 + dr, nr);
ggml_fp16_t * const wdata = (ggml_fp16_t *) params->wdata + 0;
ggml_fp16_t * const wdata_src = wdata + nk;
for (int i1 = ir0; i1 < ir1; i1++) {
float * dst_data = (float *)((char *) dst->data + i1*nb1);
ggml_fp16_t * wdata_kernel = wdata + i1*ne02*ne00;
for (int i10 = 0; i10 < ne10; i10++) {
const int i1n = i10*ne11;
for (int i00 = 0; i00 < ne00; i00++) {
float v = 0;
ggml_vec_dot_f16(ne02, &v,
(ggml_fp16_t *) wdata_src + i1n,
(ggml_fp16_t *) wdata_kernel + i00*ne02);
dst_data[i10*s0 + i00] += v;
}
}
}
}
|
// ggml_compute_forward_conv_transpose_1d
|
https://github.com/yeyupiaoling/Whisper-Finetune/blob/e763980251b3307e6518ba2a352f56192bc1c43b/AndroidDemo/app/src/main/jni/whisper/libwhisper/ggml.c#L11502-L11594
|
e763980251b3307e6518ba2a352f56192bc1c43b
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.